diff --git a/Core/apu.c b/Core/apu.c index b3a8e8e..5919427 100644 --- a/Core/apu.c +++ b/Core/apu.c @@ -40,6 +40,8 @@ bool GB_apu_is_DAC_enabled(GB_gameboy_t *gb, unsigned index) case GB_NOISE: return gb->io_registers[GB_IO_NR42] & 0xF8; + + nodefault; } return false; @@ -58,6 +60,8 @@ static uint8_t agb_bias_for_channel(GB_gameboy_t *gb, unsigned index) return 0; case GB_NOISE: return gb->apu.noise_channel.current_volume; + + nodefault; } return 0; } @@ -257,7 +261,8 @@ static void render(GB_gameboy_t *gb) {left_volume * (1 - gb->apu_output.highpass_rate) + gb->apu_output.highpass_diff.left * gb->apu_output.highpass_rate, right_volume * (1 - gb->apu_output.highpass_rate) + gb->apu_output.highpass_diff.right * gb->apu_output.highpass_rate}; - case GB_HIGHPASS_MAX:; + case GB_HIGHPASS_MAX: + nodefault; } } diff --git a/Core/defs.h b/Core/defs.h index 0517b22..b512986 100644 --- a/Core/defs.h +++ b/Core/defs.h @@ -17,6 +17,9 @@ #define unrolled #endif +#define unreachable() __builtin_unreachable(); +#define nodefault default: unreachable() + #ifdef GB_BIG_ENDIAN #define LE16(x) __builtin_bswap16(x) #define LE32(x) __builtin_bswap32(x) diff --git a/Core/display.c b/Core/display.c index 2e03039..1a36916 100644 --- a/Core/display.c +++ b/Core/display.c @@ -834,6 +834,8 @@ static void advance_fetcher_state_machine(GB_gameboy_t *gb) gb->fetcher_state++; } break; + + nodefault; } } diff --git a/Core/joypad.c b/Core/joypad.c index 3527742..db50f66 100644 --- a/Core/joypad.c +++ b/Core/joypad.c @@ -53,9 +53,7 @@ void GB_update_joyp(GB_gameboy_t *gb) } break; - default: - __builtin_unreachable(); - break; + nodefault; } /* Todo: This assumes the keys *always* bounce, which is incorrect when emulating an SGB */ diff --git a/Core/mbc.c b/Core/mbc.c index 82771eb..5ade9aa 100644 --- a/Core/mbc.c +++ b/Core/mbc.c @@ -77,6 +77,7 @@ void GB_update_mbc_mappings(GB_gameboy_t *gb) gb->mbc_rom_bank++; } break; + nodefault; } break; case GB_MBC2: @@ -121,6 +122,7 @@ void GB_update_mbc_mappings(GB_gameboy_t *gb) gb->mbc_ram_bank = gb->tpp1.ram_bank; gb->mbc_ram_enable = (gb->tpp1.mode == 2) || (gb->tpp1.mode == 3); break; + nodefault; } } diff --git a/Core/memory.c b/Core/memory.c index dd24f84..29d8534 100644 --- a/Core/memory.c +++ b/Core/memory.c @@ -360,6 +360,7 @@ static uint8_t read_mbc_ram(GB_gameboy_t *gb, uint16_t addr) case 1: return gb->tpp1.rom_bank >> 8; case 2: return gb->tpp1.ram_bank; case 3: return gb->rumble_strength | gb->tpp1_mr4; + nodefault; } case 2: case 3: @@ -533,8 +534,7 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr) oam[target >> 1] = bitwise_glitch_read(a, b, c); break; - default: - __builtin_unreachable(); + nodefault; } for (unsigned i = 0; i < 8; i++) { @@ -706,7 +706,7 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr) } return 0xFF; } - __builtin_unreachable(); + unreachable(); } if (addr == 0xFFFF) { @@ -899,6 +899,7 @@ static void write_mbc(GB_gameboy_t *gb, uint16_t addr, uint8_t value) } } break; + nodefault; } GB_update_mbc_mappings(gb); } @@ -1243,7 +1244,7 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) case GB_MODEL_SGB_PAL_NO_SFC: case GB_MODEL_SGB2: case GB_MODEL_SGB2_NO_SFC: - __builtin_unreachable(); + unreachable(); } return; } diff --git a/Core/sm83_cpu.c b/Core/sm83_cpu.c index 130bfb3..fdaf85d 100644 --- a/Core/sm83_cpu.c +++ b/Core/sm83_cpu.c @@ -658,8 +658,8 @@ static bool condition_code(GB_gameboy_t *gb, uint8_t opcode) return !(gb->af & GB_CARRY_FLAG); case 3: return (gb->af & GB_CARRY_FLAG); + nodefault; } - __builtin_unreachable(); return false; }