From f3d04843e3f7eac89bdd933da1b32cbcd7a7710e Mon Sep 17 00:00:00 2001 From: David Haywood Date: Wed, 24 May 2017 13:50:18 +0100 Subject: [PATCH] some tidying (nw) --- src/devices/sound/nes_apu.h | 4 +-- src/devices/video/ppu2c0x_vt.cpp | 60 ++++++++++++++++++++++++-------- src/devices/video/ppu2c0x_vt.h | 14 +++++--- src/mame/drivers/nes_vt.cpp | 2 +- src/mame/includes/nes.h | 10 +++--- 5 files changed, 64 insertions(+), 26 deletions(-) diff --git a/src/devices/sound/nes_apu.h b/src/devices/sound/nes_apu.h index 6fc470a878a..1410b02e189 100644 --- a/src/devices/sound/nes_apu.h +++ b/src/devices/sound/nes_apu.h @@ -52,8 +52,8 @@ public: nesapu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); // static configuration helpers - template static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast(device).m_irq_handler.set_callback(object); } - template static devcb_base &set_mem_read_callback(device_t &device, _Object object) { return downcast(device).m_mem_read_cb.set_callback(object); } + template static devcb_base &set_irq_handler(device_t &device, Object &&cb) { return downcast(device).m_irq_handler.set_callback(std::forward(cb)); } + template static devcb_base &set_mem_read_callback(device_t &device, Object &&cb) { return downcast(device).m_mem_read_cb.set_callback(std::forward(cb)); } virtual void device_clock_changed() override; diff --git a/src/devices/video/ppu2c0x_vt.cpp b/src/devices/video/ppu2c0x_vt.cpp index cfadea2a8c3..8ecc3e963dc 100644 --- a/src/devices/video/ppu2c0x_vt.cpp +++ b/src/devices/video/ppu2c0x_vt.cpp @@ -128,32 +128,64 @@ void ppu_vt03_device::read_sprite_plane_data(int address) m_va34 = 0; m_planebuf[0] = m_read_sp((address + 0) & 0x1fff); m_planebuf[1] = m_read_sp((address + 8) & 0x1fff); - m_va34 = 1; - m_extplanebuf[0] = m_read_sp((address + 0) & 0x1fff); - m_extplanebuf[1] = m_read_sp((address + 8) & 0x1fff); + + int is4bpp = get_201x_reg(0x0) & 0x04; + + if (is4bpp) + { + m_va34 = 1; + m_extplanebuf[0] = m_read_sp((address + 0) & 0x1fff); + m_extplanebuf[1] = m_read_sp((address + 8) & 0x1fff); + } } void ppu_vt03_device::make_sprite_pixel_data(uint8_t &pixel_data, int flipx) { ppu2c0x_device::make_sprite_pixel_data(pixel_data, flipx); - if (flipx) + int is4bpp = get_201x_reg(0x0) & 0x04; + + if (is4bpp) { - pixel_data |= (((m_extplanebuf[0] & 1) << 5) | ((m_extplanebuf[1] & 1) << 6)); // yes, shift by 5 and 6 because of the way the palette is arranged in RAM - m_extplanebuf[0] = m_extplanebuf[0] >> 1; - m_extplanebuf[1] = m_extplanebuf[1] >> 1; - } - else - { - pixel_data |= (((m_extplanebuf[0] >> 7) & 1) << 5) | (((m_extplanebuf[1] >> 7) & 1) << 6); // yes, shift by 5 and 6 because of the way the palette is arranged in RAM - m_extplanebuf[0] = m_extplanebuf[0] << 1; - m_extplanebuf[1] = m_extplanebuf[1] << 1; + if (flipx) + { + // yes, shift by 5 and 6 because of the way the palette is arranged in RAM + pixel_data |= (((m_extplanebuf[0] & 1) << 5) | ((m_extplanebuf[1] & 1) << 6)); + m_extplanebuf[0] = m_extplanebuf[0] >> 1; + m_extplanebuf[1] = m_extplanebuf[1] >> 1; + } + else + { + pixel_data |= (((m_extplanebuf[0] >> 7) & 1) << 5) | (((m_extplanebuf[1] >> 7) & 1) << 6); + m_extplanebuf[0] = m_extplanebuf[0] << 1; + m_extplanebuf[1] = m_extplanebuf[1] << 1; + } } } void ppu_vt03_device::draw_sprite_pixel(int sprite_xpos, int color, int pixel, uint8_t pixel_data, bitmap_ind16& bitmap) { - bitmap.pix16(m_scanline, sprite_xpos + pixel) = pixel_data + (4 * color); + int is4bpp = get_201x_reg(0x0) & 0x04; + int is16pix = get_201x_reg(0x0) & 0x01; + + if (is4bpp) + { + if (!is16pix) + { + bitmap.pix16(m_scanline, sprite_xpos + pixel) = pixel_data + (4 * color); + } + else + { + /* this mode makes use of the extra planes to increase sprite width instead + we probably need to split them out again and draw them at xpos+8 with a + cliprect - not seen used yet */ + bitmap.pix16(m_scanline, sprite_xpos + pixel) = pixel_data + (machine().rand()&3); + } + } + else + { + ppu2c0x_device::draw_sprite_pixel(sprite_xpos, color, pixel, pixel_data, bitmap); + } } void ppu_vt03_device::read_tile_plane_data(int address, int color) diff --git a/src/devices/video/ppu2c0x_vt.h b/src/devices/video/ppu2c0x_vt.h index b365aa8ed20..d9a62348584 100644 --- a/src/devices/video/ppu2c0x_vt.h +++ b/src/devices/video/ppu2c0x_vt.h @@ -9,7 +9,11 @@ ******************************************************************************/ -#include "emu.h" +#ifndef MAME_VIDEO_PPU_VT03_H +#define MAME_VIDEO_PPU_VT03_H + +#pragma once + #include "video/ppu2c0x.h" #define MCFG_PPU_VT03_ADD(_tag) \ @@ -25,8 +29,8 @@ 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 object) { return downcast(device).m_read_bg.set_callback(object); } - template static devcb_base &set_read_sp_callback(device_t &device, _Object object) { return downcast(device).m_read_sp.set_callback(object); } + 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)); } virtual DECLARE_READ8_MEMBER(read) override; virtual DECLARE_WRITE8_MEMBER(write) override; @@ -75,4 +79,6 @@ private: void set_new_pen(int i); }; -DECLARE_DEVICE_TYPE(PPU_VT03, ppu_vt03_device) \ No newline at end of file +DECLARE_DEVICE_TYPE(PPU_VT03, ppu_vt03_device) + +#endif // MAME_VIDEO_PPU_VT03_H diff --git a/src/mame/drivers/nes_vt.cpp b/src/mame/drivers/nes_vt.cpp index 747b81ccdfc..e608a54520d 100644 --- a/src/mame/drivers/nes_vt.cpp +++ b/src/mame/drivers/nes_vt.cpp @@ -366,7 +366,7 @@ void nes_vt_state::machine_reset() int nes_vt_state::calculate_real_video_address(int addr, int extended, int readtype) { - // might be a VT09 only feature (8bpp or 4bpp direct colour mode??) + // might be a VT09 only feature (8bpp?) but where are the other 4 bits? int alt_order = m_ppu->get_201x_reg(0x0) & 0x40; if (readtype == 0) diff --git a/src/mame/includes/nes.h b/src/mame/includes/nes.h index 44a57acd9b0..073f24c7395 100644 --- a/src/mame/includes/nes.h +++ b/src/mame/includes/nes.h @@ -72,11 +72,11 @@ class nes_state : public nes_base_state public: nes_state(const machine_config &mconfig, device_type type, const char *tag) : nes_base_state(mconfig, type, tag), - m_ppu(*this, "ppu"), - m_exp(*this, "exp"), - m_cartslot(*this, "nes_slot"), - m_disk(*this, "disk") - { } + m_ppu(*this, "ppu"), + m_exp(*this, "exp"), + m_cartslot(*this, "nes_slot"), + m_disk(*this, "disk") + { } int nes_ppu_vidaccess(int address, int data);