Rename UNROLL to unrolled (`unrolled for`)

This commit is contained in:
Lior Halphon 2021-02-22 14:45:30 +02:00
parent 9da0449797
commit 71c88323b7
3 changed files with 13 additions and 20 deletions

View File

@ -180,8 +180,7 @@ static void render(GB_gameboy_t *gb)
{
GB_sample_t output = {0, 0};
UNROLL
for (unsigned i = 0; i < GB_N_CHANNELS; i++) {
unrolled for (unsigned i = 0; i < GB_N_CHANNELS; i++) {
double multiplier = CH_STEP;
if (gb->model < GB_MODEL_AGB) {
@ -240,8 +239,7 @@ static void render(GB_gameboy_t *gb)
unsigned mask = gb->io_registers[GB_IO_NR51];
unsigned left_volume = 0;
unsigned right_volume = 0;
UNROLL
for (unsigned i = GB_N_CHANNELS; i--;) {
unrolled for (unsigned i = GB_N_CHANNELS; i--;) {
if (gb->apu.is_active[i]) {
if (mask & 1) {
left_volume += (gb->io_registers[GB_IO_NR50] & 7) * CH_STEP * 0xF;
@ -441,7 +439,7 @@ void GB_apu_div_event(GB_gameboy_t *gb)
}
if ((gb->apu.div_divider & 1) == 0) {
UNROLL for (unsigned i = GB_SQUARE_2 + 1; i--;) {
unrolled for (unsigned i = GB_SQUARE_2 + 1; i--;) {
uint8_t nrx2 = gb->io_registers[i == GB_SQUARE_1? GB_IO_NR12 : GB_IO_NR22];
if (gb->apu.is_active[i] && gb->apu.square_channels[i].volume_countdown == 0) {
tick_square_envelope(gb, i);
@ -456,7 +454,7 @@ void GB_apu_div_event(GB_gameboy_t *gb)
}
if ((gb->apu.div_divider & 7) == 7) {
UNROLL for (unsigned i = GB_SQUARE_2 + 1; i--;) {
unrolled for (unsigned i = GB_SQUARE_2 + 1; i--;) {
gb->apu.square_channels[i].volume_countdown--;
gb->apu.square_channels[i].volume_countdown &= 7;
}
@ -465,7 +463,7 @@ void GB_apu_div_event(GB_gameboy_t *gb)
}
if ((gb->apu.div_divider & 1) == 1) {
UNROLL for (unsigned i = GB_SQUARE_2 + 1; i--;) {
unrolled for (unsigned i = GB_SQUARE_2 + 1; i--;) {
if (gb->apu.square_channels[i].length_enabled) {
if (gb->apu.square_channels[i].pulse_length) {
if (!--gb->apu.square_channels[i].pulse_length) {
@ -586,8 +584,7 @@ void GB_apu_run(GB_gameboy_t *gb)
}
}
UNROLL
for (unsigned i = GB_SQUARE_1; i <= GB_SQUARE_2; i++) {
unrolled for (unsigned i = GB_SQUARE_1; i <= GB_SQUARE_2; i++) {
if (gb->apu.is_active[i]) {
uint8_t cycles_left = cycles;
while (unlikely(cycles_left > gb->apu.square_channels[i].sample_countdown)) {

View File

@ -28,8 +28,7 @@ static GB_fifo_item_t *fifo_pop(GB_fifo_t *fifo)
static void fifo_push_bg_row(GB_fifo_t *fifo, uint8_t lower, uint8_t upper, uint8_t palette, bool bg_priority, bool flip_x)
{
if (!flip_x) {
UNROLL
for (unsigned i = 8; i--;) {
unrolled for (unsigned i = 8; i--;) {
fifo->fifo[fifo->write_end] = (GB_fifo_item_t) {
(lower >> 7) | ((upper >> 7) << 1),
palette,
@ -44,8 +43,7 @@ static void fifo_push_bg_row(GB_fifo_t *fifo, uint8_t lower, uint8_t upper, uint
}
}
else {
UNROLL
for (unsigned i = 8; i--;) {
unrolled for (unsigned i = 8; i--;) {
fifo->fifo[fifo->write_end] = (GB_fifo_item_t) {
(lower & 1) | ((upper & 1) << 1),
palette,
@ -71,8 +69,7 @@ static void fifo_overlay_object_row(GB_fifo_t *fifo, uint8_t lower, uint8_t uppe
uint8_t flip_xor = flip_x? 0: 0x7;
UNROLL
for (unsigned i = 8; i--;) {
unrolled for (unsigned i = 8; i--;) {
uint8_t pixel = (lower >> 7) | ((upper >> 7) << 1);
GB_fifo_item_t *target = &fifo->fifo[(fifo->read_end + (i ^ flip_xor)) & (GB_FIFO_LENGTH - 1)];
if (pixel != 0 && (target->pixel == 0 || target->priority > priority)) {
@ -1551,8 +1548,7 @@ uint8_t GB_get_oam_info(GB_gameboy_t *gb, GB_oam_info_t *dest, uint8_t *sprite_h
}
for (unsigned y = 0; y < *sprite_height; y++) {
UNROLL
for (unsigned x = 0; x < 8; x++) {
unrolled for (unsigned x = 0; x < 8; x++) {
uint8_t color = (((gb->vram[vram_address ] >> ((~x)&7)) & 1 ) |
((gb->vram[vram_address + 1] >> ((~x)&7)) & 1) << 1 );

View File

@ -41,11 +41,11 @@
#ifdef GB_INTERNAL
#if __clang__
#define UNROLL _Pragma("unroll")
#define unrolled _Pragma("unroll")
#elif __GNUC__ >= 8
#define UNROLL _Pragma("GCC unroll 8")
#define unrolled _Pragma("GCC unroll 8")
#else
#define UNROLL
#define unrolled
#endif
#endif