diff --git a/Cocoa/Document.m b/Cocoa/Document.m index fafdefc..bb1fc6f 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -1043,6 +1043,13 @@ static unsigned *multiplication_table_for_frequency(unsigned frequency) else if ([anItem action] == @selector(toggleCheats:)) { [(NSMenuItem*)anItem setState:GB_cheats_enabled(&gb)]; } + else if ([anItem action] == @selector(toggleDisplayBackground:)) { + [(NSMenuItem*)anItem setState:!GB_is_background_rendering_disabled(&gb)]; + } + else if ([anItem action] == @selector(toggleDisplayObjects:)) { + [(NSMenuItem*)anItem setState:!GB_is_object_rendering_disabled(&gb)]; + } + return [super validateUserInterfaceItem:anItem]; } @@ -2307,4 +2314,14 @@ static unsigned *multiplication_table_for_frequency(unsigned frequency) [self.osdView displayText:@"Screenshot copied"]; } +- (IBAction)toggleDisplayBackground:(id)sender +{ + GB_set_background_rendering_disabled(&gb, !GB_is_background_rendering_disabled(&gb)); +} + +- (IBAction)toggleDisplayObjects:(id)sender +{ + GB_set_object_rendering_disabled(&gb, !GB_is_object_rendering_disabled(&gb)); +} + @end diff --git a/Cocoa/MainMenu.xib b/Cocoa/MainMenu.xib index ca15de4..aafa8aa 100644 --- a/Cocoa/MainMenu.xib +++ b/Cocoa/MainMenu.xib @@ -456,6 +456,19 @@ + + + + + + + + + + + + + diff --git a/Core/display.c b/Core/display.c index 1d4ee52..6d54ec6 100644 --- a/Core/display.c +++ b/Core/display.c @@ -522,8 +522,8 @@ static uint8_t data_for_tile_sel_glitch(GB_gameboy_t *gb, bool *should_use, bool static void render_pixel_if_possible(GB_gameboy_t *gb) { - GB_fifo_item_t *fifo_item = NULL; - GB_fifo_item_t *oam_fifo_item = NULL; + const GB_fifo_item_t *fifo_item = NULL; + const GB_fifo_item_t *oam_fifo_item = NULL; bool draw_oam = false; bool bg_enabled = true, bg_priority = false; @@ -533,7 +533,7 @@ static void render_pixel_if_possible(GB_gameboy_t *gb) if (fifo_size(&gb->oam_fifo)) { oam_fifo_item = fifo_pop(&gb->oam_fifo); - if (oam_fifo_item->pixel && (gb->io_registers[GB_IO_LCDC] & 2)) { + if (oam_fifo_item->pixel && (gb->io_registers[GB_IO_LCDC] & 2) && unlikely(!gb->objects_disabled)) { draw_oam = true; bg_priority |= oam_fifo_item->bg_priority; } @@ -559,6 +559,12 @@ static void render_pixel_if_possible(GB_gameboy_t *gb) bg_enabled = false; } } + + if (unlikely(gb->background_disabled)) { + bg_enabled = false; + static const GB_fifo_item_t empty_item = {0,}; + fifo_item = &empty_item; + } uint8_t icd_pixel = 0; uint32_t *dest = NULL; @@ -1624,3 +1630,24 @@ bool GB_is_odd_frame(GB_gameboy_t *gb) { return gb->is_odd_frame; } + +void GB_set_object_rendering_disabled(GB_gameboy_t *gb, bool disabled) +{ + gb->objects_disabled = disabled; +} + +void GB_set_background_rendering_disabled(GB_gameboy_t *gb, bool disabled) +{ + gb->background_disabled = disabled; +} + +bool GB_is_object_rendering_disabled(GB_gameboy_t *gb) +{ + return gb->objects_disabled; +} + +bool GB_is_background_rendering_disabled(GB_gameboy_t *gb) +{ + return gb->background_disabled; +} + diff --git a/Core/display.h b/Core/display.h index 1d35d96..fdc855f 100644 --- a/Core/display.h +++ b/Core/display.h @@ -61,4 +61,11 @@ uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color, bool for_border); void GB_set_color_correction_mode(GB_gameboy_t *gb, GB_color_correction_mode_t mode); void GB_set_light_temperature(GB_gameboy_t *gb, double temperature); bool GB_is_odd_frame(GB_gameboy_t *gb); + +void GB_set_object_rendering_disabled(GB_gameboy_t *gb, bool disabled); +void GB_set_background_rendering_disabled(GB_gameboy_t *gb, bool disabled); +bool GB_is_object_rendering_disabled(GB_gameboy_t *gb); +bool GB_is_background_rendering_disabled(GB_gameboy_t *gb); + + #endif /* display_h */ diff --git a/Core/gb.h b/Core/gb.h index 3c77aed..e6b5f41 100644 --- a/Core/gb.h +++ b/Core/gb.h @@ -630,6 +630,8 @@ struct GB_gameboy_internal_s { GB_sgb_border_t borrowed_border; bool tried_loading_sgb_border; bool has_sgb_border; + bool objects_disabled; + bool background_disabled; /* Timing */ uint64_t last_sync;