diff options
Diffstat (limited to 'src/devices/video/gb_lcd.cpp')
-rw-r--r-- | src/devices/video/gb_lcd.cpp | 90 |
1 files changed, 39 insertions, 51 deletions
diff --git a/src/devices/video/gb_lcd.cpp b/src/devices/video/gb_lcd.cpp index 019ba778144..76066883ade 100644 --- a/src/devices/video/gb_lcd.cpp +++ b/src/devices/video/gb_lcd.cpp @@ -156,7 +156,7 @@ TODO: ***************************************************************************/ #include "emu.h" -#include "video/gb_lcd.h" +#include "gb_lcd.h" #include "screen.h" @@ -365,7 +365,7 @@ void dmg_ppu_device::common_start() m_vram = make_unique_clear<uint8_t[]>(m_vram_size); machine().save().register_postload(save_prepost_delegate(FUNC(dmg_ppu_device::videoptr_restore), this)); - m_lcd_timer = timer_alloc(); + m_lcd_timer = timer_alloc(FUNC(dmg_ppu_device::update_tick), this); m_program_space = &m_lr35902->space(AS_PROGRAM); @@ -429,15 +429,12 @@ void dmg_ppu_device::common_start() save_item(NAME(m_next_state)); save_item(NAME(m_old_curline)); - for (int i = 0; i < ARRAY_LENGTH(m_layer); i++) - { - save_item(NAME(m_layer[i].enabled), i); - save_item(NAME(m_layer[i].xindex), i); - save_item(NAME(m_layer[i].xshift), i); - save_item(NAME(m_layer[i].xstart), i); - save_item(NAME(m_layer[i].xend), i); - save_item(NAME(m_layer[i].bgline), i); - } + save_item(STRUCT_MEMBER(m_layer, enabled)); + save_item(STRUCT_MEMBER(m_layer, xindex)); + save_item(STRUCT_MEMBER(m_layer, xshift)); + save_item(STRUCT_MEMBER(m_layer, xstart)); + save_item(STRUCT_MEMBER(m_layer, xend)); + save_item(STRUCT_MEMBER(m_layer, bgline)); save_item(NAME(m_line.tile_cycle)); save_item(NAME(m_line.tile_count)); @@ -465,16 +462,13 @@ void dmg_ppu_device::common_start() save_item(NAME(m_line.window_enable)); save_item(NAME(m_line.window_enable_index)); save_item(NAME(m_line.window_should_trigger)); - for (int i = 0; i < ARRAY_LENGTH(m_line.sprite); i++) - { - save_item(NAME(m_line.sprite[i].enabled), i); - save_item(NAME(m_line.sprite[i].x), i); - save_item(NAME(m_line.sprite[i].y), i); - save_item(NAME(m_line.sprite[i].pattern), i); - save_item(NAME(m_line.sprite[i].flags), i); - save_item(NAME(m_line.sprite[i].tile_plane_0), i); - save_item(NAME(m_line.sprite[i].tile_plane_1), i); - } + save_item(STRUCT_MEMBER(m_line.sprite, enabled)); + save_item(STRUCT_MEMBER(m_line.sprite, x)); + save_item(STRUCT_MEMBER(m_line.sprite, y)); + save_item(STRUCT_MEMBER(m_line.sprite, pattern)); + save_item(STRUCT_MEMBER(m_line.sprite, flags)); + save_item(STRUCT_MEMBER(m_line.sprite, tile_plane_0)); + save_item(STRUCT_MEMBER(m_line.sprite, tile_plane_1)); save_item(NAME(m_frame_window_active)); } @@ -671,7 +665,7 @@ void cgb_ppu_device::device_reset() inline void dmg_ppu_device::plot_pixel(int x, int y, uint16_t color) { - m_bitmap.pix16(y, x) = color; + m_bitmap.pix(y, x) = color; } @@ -1034,14 +1028,14 @@ void dmg_ppu_device::check_start_of_window() } // 4 makes most tests pass - m_line.window_start_y[(m_line.window_start_y_index + 4) % ARRAY_LENGTH(m_line.window_start_y)] = WNDPOSY; + m_line.window_start_y[(m_line.window_start_y_index + 4) % std::size(m_line.window_start_y)] = WNDPOSY; // 2-4 makes most tests pass - m_line.window_start_x[(m_line.window_start_y_index + 4) % ARRAY_LENGTH(m_line.window_start_x)] = WNDPOSX; - m_line.window_start_y_index = (m_line.window_start_y_index + 1) % ARRAY_LENGTH(m_line.window_start_y); + m_line.window_start_x[(m_line.window_start_y_index + 4) % std::size(m_line.window_start_x)] = WNDPOSX; + m_line.window_start_y_index = (m_line.window_start_y_index + 1) % std::size(m_line.window_start_y); // 3 makes most tests pass - m_line.window_enable[(m_line.window_enable_index + 3) % ARRAY_LENGTH(m_line.window_enable)] = LCDCONT; - m_line.window_enable_index = (m_line.window_enable_index + 1) % ARRAY_LENGTH(m_line.window_enable); + m_line.window_enable[(m_line.window_enable_index + 3) % std::size(m_line.window_enable)] = LCDCONT; + m_line.window_enable_index = (m_line.window_enable_index + 1) % std::size(m_line.window_enable); if (!m_line.starting && m_line.tile_cycle < 8) { @@ -1142,7 +1136,7 @@ void dmg_ppu_device::update_scanline(uint32_t cycles_to_go) return; } - g_profiler.start(PROFILER_VIDEO); + auto profile = g_profiler.start(PROFILER_VIDEO); /* Make sure we're in mode 3 */ if ((LCDSTAT & 0x03) == 0x03) @@ -1276,8 +1270,6 @@ void dmg_ppu_device::update_scanline(uint32_t cycles_to_go) } } } - - g_profiler.stop(); } /* --- Super Game Boy Specific --- */ @@ -1431,7 +1423,7 @@ void sgb_ppu_device::refresh_border() void sgb_ppu_device::update_scanline(uint32_t cycles_to_go) { - g_profiler.start(PROFILER_VIDEO); + auto profile = g_profiler.start(PROFILER_VIDEO); if ((LCDSTAT & 0x03) == 0x03) { @@ -1545,7 +1537,7 @@ void sgb_ppu_device::update_scanline(uint32_t cycles_to_go) while (i > 0) { /* Figure out which palette we're using */ - assert(((m_end_x - i) >> 3) >= 0 && ((m_end_x - i) >> 3) < ARRAY_LENGTH(m_sgb_pal_map)); + assert(((m_end_x - i) >> 3) >= 0 && ((m_end_x - i) >> 3) < std::size(m_sgb_pal_map)); sgb_palette = m_sgb_pal_map[(m_end_x - i) >> 3][m_current_line >> 3] << 2; while ((m_layer[l].xshift < 8) && i) @@ -1600,8 +1592,6 @@ void sgb_ppu_device::update_scanline(uint32_t cycles_to_go) } } } - - g_profiler.stop(); } /* --- Game Boy Color Specific --- */ @@ -1721,7 +1711,7 @@ void cgb_ppu_device::update_sprites() void cgb_ppu_device::update_scanline(uint32_t cycles_to_go) { - g_profiler.start(PROFILER_VIDEO); + auto profile = g_profiler.start(PROFILER_VIDEO); if ((LCDSTAT & 0x03) == 0x03) { @@ -1897,8 +1887,6 @@ void cgb_ppu_device::update_scanline(uint32_t cycles_to_go) } } } - - g_profiler.stop(); } @@ -1923,7 +1911,7 @@ void dmg_ppu_device::increment_scanline() } -void dmg_ppu_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(dmg_ppu_device::update_tick) { update_state(); } @@ -2209,13 +2197,13 @@ void dmg_ppu_device::update_state() break; case GB_LCD_STATE_LYXX_M3: /* Switch to mode 3 */ - for (int i = 0; i < ARRAY_LENGTH(m_line.window_start_y); i++) + for (int i = 0; i < std::size(m_line.window_start_y); i++) { m_line.window_start_y[i] = WNDPOSY; m_line.window_start_x[i] = WNDPOSX; } m_line.window_start_y_index = 0; - for (int i = 0; i < ARRAY_LENGTH(m_line.window_enable); i++) + for (int i = 0; i < std::size(m_line.window_enable); i++) { m_line.window_enable[i] = LCDCONT; } @@ -2640,13 +2628,13 @@ void cgb_ppu_device::update_state() break; case GB_LCD_STATE_LYXX_M3: /* Switch to mode 3 */ - for (int i = 0; i < ARRAY_LENGTH(m_line.window_start_y); i++) + for (int i = 0; i < std::size(m_line.window_start_y); i++) { m_line.window_start_y[i] = WNDPOSY; m_line.window_start_x[i] = WNDPOSX; } m_line.window_start_y_index = 0; - for (int i = 0; i < ARRAY_LENGTH(m_line.window_enable); i++) + for (int i = 0; i < std::size(m_line.window_enable); i++) { m_line.window_enable[i] = LCDCONT; } @@ -2866,7 +2854,7 @@ void dmg_ppu_device::lcd_switch_on(uint8_t new_data) } -READ8_MEMBER(dmg_ppu_device::vram_r) +uint8_t dmg_ppu_device::vram_r(offs_t offset) { if (!machine().side_effects_disabled()) { @@ -2878,7 +2866,7 @@ READ8_MEMBER(dmg_ppu_device::vram_r) } -WRITE8_MEMBER(dmg_ppu_device::vram_w) +void dmg_ppu_device::vram_w(offs_t offset, uint8_t data) { update_state(); if (m_vram_locked == LOCKED) @@ -2888,7 +2876,7 @@ WRITE8_MEMBER(dmg_ppu_device::vram_w) } -READ8_MEMBER(dmg_ppu_device::oam_r) +uint8_t dmg_ppu_device::oam_r(offs_t offset) { if (!machine().side_effects_disabled()) { @@ -2900,7 +2888,7 @@ READ8_MEMBER(dmg_ppu_device::oam_r) } -WRITE8_MEMBER(dmg_ppu_device::oam_w) +void dmg_ppu_device::oam_w(offs_t offset, uint8_t data) { update_state(); if (m_oam_locked == LOCKED || offset >= 0xa0 || m_oam_dma_processing) @@ -2911,7 +2899,7 @@ WRITE8_MEMBER(dmg_ppu_device::oam_w) -READ8_MEMBER(dmg_ppu_device::video_r) +uint8_t dmg_ppu_device::video_r(offs_t offset) { if (!machine().side_effects_disabled()) { @@ -3048,7 +3036,7 @@ void dmg_ppu_device::check_stat_irq() } -WRITE8_MEMBER(dmg_ppu_device::video_w) +void dmg_ppu_device::video_w(offs_t offset, uint8_t data) { update_state(); LOG("video_w: offset = %02x, data = %02x\n", offset, data); @@ -3183,7 +3171,7 @@ WRITE8_MEMBER(dmg_ppu_device::video_w) m_vid_regs[offset] = data; } -READ8_MEMBER(cgb_ppu_device::video_r) +uint8_t cgb_ppu_device::video_r(offs_t offset) { if (!machine().side_effects_disabled()) { @@ -3271,7 +3259,7 @@ bool cgb_ppu_device::stat_write(uint8_t new_data) } -WRITE8_MEMBER(cgb_ppu_device::video_w) +void cgb_ppu_device::video_w(offs_t offset, uint8_t data) { update_state(); LOG("video_w\n"); @@ -3487,7 +3475,7 @@ WRITE8_MEMBER(cgb_ppu_device::video_w) return; default: /* we didn't handle the write, so pass it to the GB handler */ - dmg_ppu_device::video_w(space, offset, data); + dmg_ppu_device::video_w(offset, data); return; } |