diff options
Diffstat (limited to 'src/devices/video/gba_lcd.cpp')
-rw-r--r-- | src/devices/video/gba_lcd.cpp | 94 |
1 files changed, 32 insertions, 62 deletions
diff --git a/src/devices/video/gba_lcd.cpp b/src/devices/video/gba_lcd.cpp index 94ee1e49c0d..26f53ac5ad7 100644 --- a/src/devices/video/gba_lcd.cpp +++ b/src/devices/video/gba_lcd.cpp @@ -15,6 +15,9 @@ #include "screen.h" +#define VERBOSE (0) +#include "logmacro.h" + namespace { @@ -63,21 +66,6 @@ namespace { #define DISPSTAT_SET(val) HWLO_SET(0x004, val) #define DISPSTAT_RESET(val) HWLO_RESET(0x004, val) -#define VERBOSE_LEVEL (0) - -inline void ATTR_PRINTF(3,4) verboselog(device_t &device, int n_level, const char *s_fmt, ...) -{ - if (VERBOSE_LEVEL >= n_level) - { - va_list v; - char buf[32768]; - va_start(v, s_fmt); - vsprintf(buf, s_fmt, v); - va_end(v); - device.logerror("%08x: %s", device.machine().describe_context(), buf); - } -} - class object { public: @@ -130,7 +118,7 @@ public: height = size_table[shape][size][1]; if (shape == 4) - verboselog(m_device, 0, "WARNING: attempted to draw an object of invalid shape\n"); + m_device.logerror("WARNING: attempted to draw an object of invalid shape\n"); } private: @@ -148,6 +136,7 @@ DEFINE_DEVICE_TYPE(GBA_LCD, gba_lcd_device, "gba_lcd", "GBA LCD") gba_lcd_device::gba_lcd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, GBA_LCD, tag, owner, clock) , device_video_interface(mconfig, *this) + , device_palette_interface(mconfig, *this) , m_int_hblank_cb(*this) , m_int_vblank_cb(*this) , m_int_vcount_cb(*this) @@ -162,7 +151,7 @@ inline uint8_t gba_lcd_device::bg_video_mode() if (mode > 5) { - verboselog(*this, 0, "WARNING: attempted to set invalid BG video mode %d\n", mode); + logerror("WARNING: attempted to set invalid BG video mode %d\n", mode); return 0; } @@ -267,7 +256,7 @@ inline void gba_lcd_device::update_mask(uint8_t* mask, int y) void gba_lcd_device::draw_scanline(int y) { - uint16_t *scanline = &m_bitmap.pix16(y); + uint16_t *const scanline = &m_bitmap.pix(y); if (is_set(dispcnt::forced_blank)) { @@ -1556,7 +1545,7 @@ static char const *const reg_names[] = { "Unused", "Unused", "Unused", "Unused", }; -READ32_MEMBER(gba_lcd_device::video_r) +uint32_t gba_lcd_device::video_r(offs_t offset, uint32_t mem_mask) { uint32_t retval = 0; @@ -1577,30 +1566,30 @@ READ32_MEMBER(gba_lcd_device::video_r) break; } - if (offset >= ARRAY_LENGTH(reg_names) / 2) + if (offset >= std::size(reg_names) / 2) throw emu_fatalerror("gba_lcd_device::video_r: Not enough register names in gba_lcd_device"); if (ACCESSING_BITS_0_15) - verboselog(*this, 2, "GBA I/O Read: %s = %04x\n", reg_names[offset * 2], retval & 0x0000ffff); + LOG("%s: GBA I/O Read: %s = %04x\n", machine().describe_context(), reg_names[offset * 2], retval & 0x0000ffff); if (ACCESSING_BITS_16_31) - verboselog(*this, 2, "GBA I/O Read: %s = %04x\n", reg_names[offset * 2 + 1], (retval & 0xffff0000) >> 16); + LOG("%s: GBA I/O Read: %s = %04x\n", machine().describe_context(), reg_names[offset * 2 + 1], (retval & 0xffff0000) >> 16); return retval; } -WRITE32_MEMBER(gba_lcd_device::video_w) +void gba_lcd_device::video_w(offs_t offset, uint32_t data, uint32_t mem_mask) { COMBINE_DATA(&m_regs[offset]); - if (offset >= ARRAY_LENGTH(reg_names) / 2) + if (offset >= std::size(reg_names) / 2) throw emu_fatalerror("gba_lcd_device::video_w: Not enough register names in gba_lcd_device"); if (ACCESSING_BITS_0_15) - verboselog(*this, 2, "GBA I/O Write: %s = %04x\n", reg_names[offset * 2], data & 0x0000ffff); + LOG("%s: GBA I/O Write: %s = %04x\n", machine().describe_context(), reg_names[offset * 2], data & 0x0000ffff); if (ACCESSING_BITS_16_31) - verboselog(*this, 2, "GBA I/O Write: %s = %04x\n", reg_names[offset * 2 + 1], (data & 0xffff0000) >> 16); + LOG("%s: GBA I/O Write: %s = %04x\n", machine().describe_context(), reg_names[offset * 2 + 1], (data & 0xffff0000) >> 16); switch (offset) { @@ -1619,32 +1608,32 @@ WRITE32_MEMBER(gba_lcd_device::video_w) } } -READ32_MEMBER(gba_lcd_device::gba_pram_r) +uint32_t gba_lcd_device::gba_pram_r(offs_t offset) { return m_pram[offset]; } -WRITE32_MEMBER(gba_lcd_device::gba_pram_w) +void gba_lcd_device::gba_pram_w(offs_t offset, uint32_t data, uint32_t mem_mask) { COMBINE_DATA(&m_pram[offset]); } -READ32_MEMBER(gba_lcd_device::gba_vram_r) +uint32_t gba_lcd_device::gba_vram_r(offs_t offset) { return m_vram[offset]; } -WRITE32_MEMBER(gba_lcd_device::gba_vram_w) +void gba_lcd_device::gba_vram_w(offs_t offset, uint32_t data, uint32_t mem_mask) { COMBINE_DATA(&m_vram[offset]); } -READ32_MEMBER(gba_lcd_device::gba_oam_r) +uint32_t gba_lcd_device::gba_oam_r(offs_t offset) { return m_oam[offset]; } -WRITE32_MEMBER(gba_lcd_device::gba_oam_w) +void gba_lcd_device::gba_oam_w(offs_t offset, uint32_t data, uint32_t mem_mask) { COMBINE_DATA(&m_oam[offset]); } @@ -1666,16 +1655,11 @@ TIMER_CALLBACK_MEMBER(gba_lcd_device::perform_hbl) if (scanline < 160) { draw_scanline(scanline); - - if (!m_dma_hblank_cb.isnull()) - m_dma_hblank_cb(ASSERT_LINE); + m_dma_hblank_cb(ASSERT_LINE); } if (is_set(dispstat::hblank_irq_en)) - { - if (!m_int_hblank_cb.isnull()) - m_int_hblank_cb(ASSERT_LINE); - } + m_int_hblank_cb(ASSERT_LINE); set(dispstat::hblank); @@ -1698,13 +1682,9 @@ TIMER_CALLBACK_MEMBER(gba_lcd_device::perform_scan) if (scanline == 160) { if (is_set(dispstat::vblank_irq_en)) - { - if (!m_int_vblank_cb.isnull()) - m_int_vblank_cb(ASSERT_LINE); - } + m_int_vblank_cb(ASSERT_LINE); - if (!m_dma_vblank_cb.isnull()) - m_dma_vblank_cb(ASSERT_LINE); + m_dma_vblank_cb(ASSERT_LINE); } } else @@ -1718,17 +1698,14 @@ TIMER_CALLBACK_MEMBER(gba_lcd_device::perform_scan) set(dispstat::vcount); if (is_set(dispstat::vcount_irq_en)) - { - if (!m_int_vcount_cb.isnull()) - m_int_vcount_cb(ASSERT_LINE); - } + m_int_vcount_cb(ASSERT_LINE); } m_hbl_timer->adjust(screen().time_until_pos(scanline, 240)); m_scan_timer->adjust(screen().time_until_pos((scanline + 1) % 228, 0)); } -void gba_lcd_device::gba_palette(palette_device &palette) const +void gba_lcd_device::palette_init() { for (uint8_t b = 0; b < 32; b++) { @@ -1736,7 +1713,7 @@ void gba_lcd_device::gba_palette(palette_device &palette) const { for (uint8_t r = 0; r < 32; r++) { - palette.set_pen_color((b << 10) | (g << 5) | r, pal5bit(r), pal5bit(g), pal5bit(b)); + set_pen_color((b << 10) | (g << 5) | r, pal5bit(r), pal5bit(g), pal5bit(b)); } } } @@ -1751,12 +1728,7 @@ uint32_t gba_lcd_device::screen_update(screen_device &screen, bitmap_ind16 &bitm void gba_lcd_device::device_start() { - /* resolve callbacks */ - m_int_hblank_cb.resolve(); - m_int_vblank_cb.resolve(); - m_int_vcount_cb.resolve(); - m_dma_hblank_cb.resolve(); - m_dma_vblank_cb.resolve(); + palette_init(); m_pram = make_unique_clear<uint32_t[]>(0x400 / 4); m_vram = make_unique_clear<uint32_t[]>(0x18000 / 4); @@ -1765,8 +1737,8 @@ void gba_lcd_device::device_start() screen().register_screen_bitmap(m_bitmap); /* create a timer to fire scanline functions */ - m_scan_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_lcd_device::perform_scan),this)); - m_hbl_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gba_lcd_device::perform_hbl),this)); + m_scan_timer = timer_alloc(FUNC(gba_lcd_device::perform_scan), this); + m_hbl_timer = timer_alloc(FUNC(gba_lcd_device::perform_hbl), this); m_scan_timer->adjust(screen().time_until_pos(0, 0)); save_item(NAME(m_regs)); @@ -1808,7 +1780,5 @@ void gba_lcd_device::device_add_mconfig(machine_config &config) screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD)); screen.set_raw(XTAL(16'777'216) / 4, 308, 0, 240, 228, 0, 160); screen.set_screen_update(FUNC(gba_lcd_device::screen_update)); - screen.set_palette("palette"); - - PALETTE(config, "palette", FUNC(gba_lcd_device::gba_palette), 32768); + screen.set_palette(*this); } |