mirror of https://github.com/LIJI32/SameBoy.git
Various optimizations
This commit is contained in:
parent
7e071e463d
commit
a0c5b6f97a
|
@ -310,8 +310,8 @@ static void render(GB_gameboy_t *gb)
|
|||
if (gb->sgb && gb->sgb->intro_animation < GB_SGB_INTRO_ANIMATION_LENGTH) return;
|
||||
|
||||
GB_sample_t filtered_output = gb->apu_output.highpass_mode?
|
||||
(GB_sample_t) {output.left - gb->apu_output.highpass_diff.left,
|
||||
output.right - gb->apu_output.highpass_diff.right} :
|
||||
(GB_sample_t) {output.left - (int16_t)gb->apu_output.highpass_diff.left,
|
||||
output.right - (int16_t)gb->apu_output.highpass_diff.right} :
|
||||
output;
|
||||
|
||||
switch (gb->apu_output.highpass_mode) {
|
||||
|
|
|
@ -588,7 +588,7 @@ static void add_object_from_index(GB_gameboy_t *gb, unsigned index)
|
|||
gb->mode2_x_bus = oam_read(gb, index * 4 + 1);
|
||||
}
|
||||
|
||||
if (gb->n_visible_objs == 10) return;
|
||||
if (unlikely(gb->n_visible_objs == 10)) return;
|
||||
|
||||
/* TODO: It appears that DMA blocks PPU access to OAM, but it needs verification. */
|
||||
if (unlikely(GB_is_dma_active(gb) && (gb->halted || gb->stopped))) {
|
||||
|
@ -1903,8 +1903,11 @@ void GB_display_run(GB_gameboy_t *gb, unsigned cycles, bool force)
|
|||
}
|
||||
}
|
||||
|
||||
if ((!GB_is_cgb(gb) || gb->io_registers[GB_IO_WX] == 0) && gb->wx_triggered && !gb->window_is_being_fetched &&
|
||||
gb->fetcher_state == GB_FETCHER_GET_TILE_T1 && gb->io_registers[GB_IO_WX] == (uint8_t) (gb->position_in_line + 7) && gb->bg_fifo.size == 8) {
|
||||
if (unlikely(gb->io_registers[GB_IO_WX] == (uint8_t) (gb->position_in_line + 7) &&
|
||||
(!GB_is_cgb(gb) || gb->io_registers[GB_IO_WX] == 0) &&
|
||||
gb->wx_triggered && !gb->window_is_being_fetched &&
|
||||
gb->fetcher_state == GB_FETCHER_GET_TILE_T1 &&
|
||||
gb->bg_fifo.size == 8)) {
|
||||
// Insert a pixel right at the FIFO's end
|
||||
gb->insert_bg_pixel = true;
|
||||
}
|
||||
|
|
|
@ -430,6 +430,10 @@ static void sanitize_state(GB_gameboy_t *gb)
|
|||
gb->apu.apu_cycles >>= 2;
|
||||
gb->apu.apu_cycles_in_2mhz = true;
|
||||
}
|
||||
|
||||
if (gb->n_visible_objs > 10) {
|
||||
gb->n_visible_objs = 10;
|
||||
}
|
||||
}
|
||||
|
||||
static bool dump_section(virtual_file_t *file, const void *src, uint32_t size)
|
||||
|
|
|
@ -226,22 +226,22 @@ void GB_set_internal_div_counter(GB_gameboy_t *gb, uint16_t value)
|
|||
{
|
||||
/* TIMA increases when a specific high-bit becomes a low-bit. */
|
||||
uint16_t triggers = gb->div_counter & ~value;
|
||||
if ((gb->io_registers[GB_IO_TAC] & 4) && (triggers & TAC_TRIGGER_BITS[gb->io_registers[GB_IO_TAC] & 3])) {
|
||||
if ((gb->io_registers[GB_IO_TAC] & 4) && unlikely(triggers & TAC_TRIGGER_BITS[gb->io_registers[GB_IO_TAC] & 3])) {
|
||||
increase_tima(gb);
|
||||
}
|
||||
|
||||
if (triggers & gb->serial_mask) {
|
||||
if (unlikely(triggers & gb->serial_mask)) {
|
||||
GB_serial_master_edge(gb);
|
||||
}
|
||||
|
||||
/* TODO: Can switching to double speed mode trigger an event? */
|
||||
uint16_t apu_bit = gb->cgb_double_speed? 0x2000 : 0x1000;
|
||||
if (triggers & apu_bit) {
|
||||
if (unlikely(triggers & apu_bit)) {
|
||||
GB_apu_div_event(gb);
|
||||
}
|
||||
else {
|
||||
uint16_t secondary_triggers = ~gb->div_counter & value;
|
||||
if (secondary_triggers & apu_bit) {
|
||||
if (unlikely(secondary_triggers & apu_bit)) {
|
||||
GB_apu_div_secondary_event(gb);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue