unreachable fun

This commit is contained in:
Lior Halphon 2022-01-03 17:17:35 +02:00
parent cd16431699
commit 5c17c0ec3b
7 changed files with 20 additions and 9 deletions

View File

@ -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;
}
}

View File

@ -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)

View File

@ -834,6 +834,8 @@ static void advance_fetcher_state_machine(GB_gameboy_t *gb)
gb->fetcher_state++;
}
break;
nodefault;
}
}

View File

@ -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 */

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;
}