From 5ce8cf5016ec16c97521d49dc1ad98232ef21288 Mon Sep 17 00:00:00 2001 From: orbea Date: Thu, 9 May 2019 09:01:15 -0700 Subject: [PATCH 1/2] Makefile: Allow setting CC. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 5870d42..542fee0 100755 --- a/Makefile +++ b/Makefile @@ -44,9 +44,11 @@ endif # Set tools # Use clang if it's available. +ifeq ($(origin CC),default) ifneq (, $(shell which clang)) CC := clang endif +endif ifeq ($(PLATFORM),windows32) # To force use of the Unix version instead of the Windows version From 2bded45397f39772b57b7a8943ebbd15ea4a927d Mon Sep 17 00:00:00 2001 From: orbea Date: Thu, 9 May 2019 09:08:25 -0700 Subject: [PATCH 2/2] Disable pragmas for gcc. --- Core/apu.c | 6 ++++++ Core/display.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/Core/apu.c b/Core/apu.c index 1b3dd2b..9a55f26 100644 --- a/Core/apu.c +++ b/Core/apu.c @@ -69,7 +69,9 @@ static void update_sample(GB_gameboy_t *gb, unsigned index, int8_t value, unsign static void render(GB_gameboy_t *gb, bool no_downsampling, GB_sample_t *dest) { GB_sample_t output = {0,0}; +#ifdef __clang__ #pragma unroll +#endif for (unsigned i = GB_N_CHANNELS; i--;) { double multiplier = CH_STEP; if (!is_DAC_enabled(gb, i)) { @@ -126,7 +128,9 @@ static void render(GB_gameboy_t *gb, bool no_downsampling, GB_sample_t *dest) unsigned mask = gb->io_registers[GB_IO_NR51]; unsigned left_volume = 0; unsigned right_volume = 0; +#ifdef __clang__ #pragma unroll +#endif for (unsigned i = GB_N_CHANNELS; i--;) { if (gb->apu.is_active[i]) { if (mask & 1) { @@ -374,7 +378,9 @@ void GB_apu_run(GB_gameboy_t *gb) } } +#ifdef __clang__ #pragma unroll +#endif for (unsigned i = GB_SQUARE_2 + 1; i--;) { if (gb->apu.is_active[i]) { uint8_t cycles_left = cycles; diff --git a/Core/display.c b/Core/display.c index 4989cca..fdd4a2f 100644 --- a/Core/display.c +++ b/Core/display.c @@ -27,7 +27,9 @@ 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) { +#ifdef __clang__ #pragma unroll +#endif for (unsigned i = 8; i--;) { fifo->fifo[fifo->write_end] = (GB_fifo_item_t) { (lower >> 7) | ((upper >> 7) << 1), @@ -43,7 +45,9 @@ static void fifo_push_bg_row(GB_fifo_t *fifo, uint8_t lower, uint8_t upper, uint } } else { +#ifdef __clang__ #pragma unroll +#endif for (unsigned i = 8; i--;) { fifo->fifo[fifo->write_end] = (GB_fifo_item_t) { (lower & 1) | ((upper & 1) << 1), @@ -70,7 +74,9 @@ static void fifo_overlay_object_row(GB_fifo_t *fifo, uint8_t lower, uint8_t uppe uint8_t flip_xor = flip_x? 0: 0x7; +#ifdef __clang__ #pragma unroll +#endif 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)]; @@ -1117,7 +1123,9 @@ 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++) { +#ifdef __clang__ #pragma unroll +#endif 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 );