diff --git a/src/devices/video/ppu2c0x_vt.cpp b/src/devices/video/ppu2c0x_vt.cpp index 1246fa347ae..25ff75be59e 100644 --- a/src/devices/video/ppu2c0x_vt.cpp +++ b/src/devices/video/ppu2c0x_vt.cpp @@ -40,10 +40,21 @@ READ8_MEMBER(ppu_vt03_device::palette_read) void ppu_vt03_device::set_new_pen(int i) { - uint16_t palval = (m_newpal[i&0x7f] & 0x3f) | ((m_newpal[(i&0x7f)+0x80] & 0x3f)<<6); - // &0x3f so we don't attempt to use any of the extended colours right now because - // I haven't managed to work out the format - m_palette->set_pen_indirect(i&0x7f,palval&0x3f); + if(m_pal_mode == PAL_MODE_NEW_RGB) { + + uint16_t rgbval = (m_newpal[i&0x7f] & 0xff) | ((m_newpal[(i&0x7f)+0x80] & 0xff)<<8); + logerror ("pal %d rgb %04x\n",i,rgbval); + uint8_t blue = (rgbval & 0x001f) << 3; + uint8_t green = (rgbval & 0x3e0) >> 2; + uint8_t red = (rgbval & 0x7C00) >> 7; + m_palette->set_pen_color(i & 0x7f, rgb_t(red, green, blue)); + } else { + uint16_t palval = (m_newpal[i&0x7f] & 0x3f) | ((m_newpal[(i&0x7f)+0x80] & 0x3f)<<6); + // &0x3f so we don't attempt to use any of the extended colours right now because + // I haven't managed to work out the format + m_palette->set_pen_indirect(i&0x7f,palval&0x3f); + } + } WRITE8_MEMBER(ppu_vt03_device::palette_write) diff --git a/src/devices/video/ppu2c0x_vt.h b/src/devices/video/ppu2c0x_vt.h index 0666ee5c8bd..757254ee966 100644 --- a/src/devices/video/ppu2c0x_vt.h +++ b/src/devices/video/ppu2c0x_vt.h @@ -25,13 +25,25 @@ #define MCFG_PPU_VT03_READ_SP_CB(_devcb) \ devcb = &ppu_vt03_device::set_read_sp_callback(*device, DEVCB_##_devcb); +#define MCFG_PPU_VT03_MODIFY MCFG_DEVICE_MODIFY + +#define MCFG_PPU_VT03_SET_PAL_MODE(pmode) \ + ppu_vt03_device::set_palette_mode(*device, pmode); + +enum vtxx_pal_mode { + PAL_MODE_VT0x, + PAL_MODE_NEW_RGB, +}; + class ppu_vt03_device : public ppu2c0x_device { public: ppu_vt03_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); template static devcb_base &set_read_bg_callback(device_t &device, Object &&cb) { return downcast(device).m_read_bg.set_callback(std::forward(cb)); } template static devcb_base &set_read_sp_callback(device_t &device, Object &&cb) { return downcast(device).m_read_sp.set_callback(std::forward(cb)); } - + + static void set_palette_mode(device_t &device, vtxx_pal_mode pmode) { downcast(device).m_pal_mode = pmode; } + virtual DECLARE_READ8_MEMBER(read) override; virtual DECLARE_WRITE8_MEMBER(write) override; virtual DECLARE_READ8_MEMBER(palette_read) override; @@ -73,7 +85,9 @@ private: palette_device *m_palette; uint8_t m_201x_regs[0x20]; - + + vtxx_pal_mode m_pal_mode = PAL_MODE_VT0x; + void set_2010_reg(uint8_t data); void set_new_pen(int i); diff --git a/src/mame/drivers/nes_vt.cpp b/src/mame/drivers/nes_vt.cpp index 5b3f0ab6f41..91e01c2865a 100644 --- a/src/mame/drivers/nes_vt.cpp +++ b/src/mame/drivers/nes_vt.cpp @@ -121,7 +121,7 @@ private: void scanline_irq(int scanline, int vblank, int blanked); uint8_t m_410x[0xc]; - uint8_t vdma_ctrl; + uint8_t m_vdma_ctrl; int m_timer_irq_enabled; int m_timer_running; @@ -749,9 +749,9 @@ WRITE8_MEMBER(nes_vt_state::nes_vh_sprite_dma_w) WRITE8_MEMBER(nes_vt_state::vt_hh_sprite_dma_w) { - uint8_t dma_mode = vdma_ctrl & 0x01; - uint8_t dma_len = (vdma_ctrl >> 1) & 0x07; - uint8_t src_nib_74 = (vdma_ctrl >> 4) & 0x0F; + uint8_t dma_mode = m_vdma_ctrl & 0x01; + uint8_t dma_len = (m_vdma_ctrl >> 1) & 0x07; + uint8_t src_nib_74 = (m_vdma_ctrl >> 4) & 0x0F; int length = 256; switch(dma_len) { case 0x0: length = 256; break; @@ -761,7 +761,7 @@ WRITE8_MEMBER(nes_vt_state::vt_hh_sprite_dma_w) case 0x7: length = 128; break; } uint16_t src_addr = (data << 8) | (src_nib_74 << 4); - logerror("vthh dma start ctrl=%02x addr=%04x\n", vdma_ctrl, src_addr); + logerror("vthh dma start ctrl=%02x addr=%04x\n", m_vdma_ctrl, src_addr); for (int i = 0; i < length; i++) { uint8_t spriteData = space.read_byte(src_addr + i); @@ -779,7 +779,7 @@ WRITE8_MEMBER(nes_vt_state::vt_hh_sprite_dma_w) WRITE8_MEMBER(nes_vt_state::vt03_4034_w) { - vdma_ctrl = data; + m_vdma_ctrl = data; } static ADDRESS_MAP_START( nes_vt_map, AS_PROGRAM, 8, nes_vt_state ) @@ -935,6 +935,8 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( nes_vt_hh, nes_vt_xx ) MCFG_CPU_MODIFY("maincpu") MCFG_CPU_PROGRAM_MAP(nes_vt_hh_map) + MCFG_PPU_VT03_MODIFY("ppu") + MCFG_PPU_VT03_SET_PAL_MODE(PAL_MODE_NEW_RGB); MACHINE_CONFIG_END static INPUT_PORTS_START( nes_vt )