From 25067c56541e8998ecacf7189cfcb8320d74bf63 Mon Sep 17 00:00:00 2001 From: 0kmg <9137159+0kmg@users.noreply.github.com> Date: Tue, 13 Dec 2022 10:46:37 -0800 Subject: video/ppu2c0x.cpp: Improved behavior of OAM writes during PPU rendering. (#10678) Noticeably improves high hopes demo. --- src/devices/video/ppu2c0x.cpp | 16 ++++++++-------- src/devices/video/ppu2c0x.h | 4 ---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/devices/video/ppu2c0x.cpp b/src/devices/video/ppu2c0x.cpp index d8f3ca4748b..0dc21dfa062 100644 --- a/src/devices/video/ppu2c0x.cpp +++ b/src/devices/video/ppu2c0x.cpp @@ -114,8 +114,7 @@ ppu2c0x_device::ppu2c0x_device(const machine_config& mconfig, device_type type, m_buffered_data(0), m_sprite_page(0), m_scan_scale(1), // set the scan scale (this is for dual monitor vertical setups) - m_draw_phase(0), - m_use_sprite_write_limitation(true) + m_draw_phase(0) { for (auto& elem : m_regs) elem = 0; @@ -1284,12 +1283,13 @@ void ppu2c0x_device::write(offs_t offset, uint8_t data) break; case PPU_SPRITE_DATA: /* 4 */ - // If the PPU is currently rendering the screen, 0xff is written instead of the desired data. - if (m_use_sprite_write_limitation) - if (m_scanline <= BOTTOM_VISIBLE_SCANLINE) - data = 0xff; - m_spriteram[m_regs[PPU_SPRITE_ADDRESS]] = data; - m_regs[PPU_SPRITE_ADDRESS] = (m_regs[PPU_SPRITE_ADDRESS] + 1) & 0xff; + // writes to sprite data during rendering do not modify memory + // TODO: however writes during rendering do perform a glitchy increment to the address + if (m_scanline > BOTTOM_VISIBLE_SCANLINE || !(m_regs[PPU_CONTROL1] & (PPU_CONTROL1_BACKGROUND | PPU_CONTROL1_SPRITES))) + { + m_spriteram[m_regs[PPU_SPRITE_ADDRESS]] = data; + m_regs[PPU_SPRITE_ADDRESS] = (m_regs[PPU_SPRITE_ADDRESS] + 1) & 0xff; + } break; case PPU_SCROLL: /* 5 */ diff --git a/src/devices/video/ppu2c0x.h b/src/devices/video/ppu2c0x.h index 0be6231b97d..0ade2597466 100644 --- a/src/devices/video/ppu2c0x.h +++ b/src/devices/video/ppu2c0x.h @@ -127,8 +127,6 @@ public: // void update_screen(bitmap_t &bitmap, const rectangle &cliprect); - // some bootleg / clone hardware appears to ignore this - void use_sprite_write_limitation_disable() { m_use_sprite_write_limitation = false; } uint16_t get_vram_dest(); void set_vram_dest(uint16_t dest); @@ -244,8 +242,6 @@ private: emu_timer *m_hblank_timer; /* hblank period at end of each scanline */ emu_timer *m_nmi_timer; /* NMI timer */ emu_timer *m_scanline_timer; /* scanline timer */ - - bool m_use_sprite_write_limitation; }; class ppu2c0x_rgb_device : public ppu2c0x_device { -- cgit v1.2.3