From 0c82cc325e310d14257e55b5a980ace6a86b9c6e Mon Sep 17 00:00:00 2001 From: byuu <2107894+byuu@users.noreply.github.com> Date: Sun, 6 Oct 2019 18:11:53 +0900 Subject: [PATCH] v111.2 Two sprite fixes for the accurate PPU and Star Ocean. --- bsnes/emulator/emulator.hpp | 4 ++-- bsnes/sfc/ppu/main.cpp | 2 +- bsnes/sfc/ppu/object.cpp | 9 +++++++-- bsnes/sfc/ppu/object.hpp | 4 ++++ bsnes/sfc/ppu/ppu.hpp | 1 - bsnes/sfc/ppu/serialization.cpp | 2 ++ 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bsnes/emulator/emulator.hpp b/bsnes/emulator/emulator.hpp index 9137e90d..1a0a0a38 100644 --- a/bsnes/emulator/emulator.hpp +++ b/bsnes/emulator/emulator.hpp @@ -29,13 +29,13 @@ using namespace nall; namespace Emulator { static const string Name = "bsnes"; - static const string Version = "111.1"; + static const string Version = "111.2"; static const string Author = "byuu"; static const string License = "GPLv3"; static const string Website = "https://byuu.org"; //incremented only when serialization format changes - static const string SerializerVersion = "110"; + static const string SerializerVersion = "111.2"; namespace Constants { namespace Colorburst { diff --git a/bsnes/sfc/ppu/main.cpp b/bsnes/sfc/ppu/main.cpp index fff23bf7..8c9fe468 100644 --- a/bsnes/sfc/ppu/main.cpp +++ b/bsnes/sfc/ppu/main.cpp @@ -184,7 +184,7 @@ auto PPU::cycleRenderPixel() -> void { template auto PPU::cycle() -> void { - if constexpr(Cycle >= 0 && Cycle <= 1022 && (Cycle - 0) % 8 == 0) cycleObjectEvaluate(); + if constexpr(Cycle >= 0 && Cycle <= 1016 && (Cycle - 0) % 8 == 0) cycleObjectEvaluate(); if constexpr(Cycle >= 0 && Cycle <= 1054 && (Cycle - 0) % 4 == 0) cycleBackgroundFetch<(Cycle - 0) / 4 & 7>(); if constexpr(Cycle == 56 ) cycleBackgroundBegin(); if constexpr(Cycle >= 56 && Cycle <= 1078 && (Cycle - 56) % 4 == 0) cycleBackgroundBelow(); diff --git a/bsnes/sfc/ppu/object.cpp b/bsnes/sfc/ppu/object.cpp index 58758b48..157d3c5e 100644 --- a/bsnes/sfc/ppu/object.cpp +++ b/bsnes/sfc/ppu/object.cpp @@ -15,6 +15,8 @@ auto PPU::Object::frame() -> void { } auto PPU::Object::scanline() -> void { + latch.firstSprite = io.firstSprite; + t.x = 0; t.y = ppu.vcounter(); t.itemCount = 0; @@ -33,11 +35,12 @@ auto PPU::Object::scanline() -> void { auto PPU::Object::evaluate(uint7 index) -> void { if(ppu.io.displayDisable) return; + if(t.itemCount > 32) return; auto oamItem = t.item[t.active]; auto oamTile = t.tile[t.active]; - uint7 sprite = io.firstSprite + index; + uint7 sprite = latch.firstSprite + index; if(!onScanline(oam.object[sprite])) return; ppu.latch.oamAddress = sprite; @@ -95,7 +98,7 @@ auto PPU::Object::fetch() -> void { for(uint i : reverse(range(32))) { if(!oamItem[i].valid) continue; - if(ppu.io.displayDisable) { + if(ppu.io.displayDisable || ppu.vcounter() >= ppu.vdisp() - 1) { ppu.step(8); continue; } @@ -209,6 +212,8 @@ auto PPU::Object::power() -> void { io.timeOver = false; io.rangeOver = false; + latch = {}; + output.above.palette = 0; output.above.priority = 0; output.below.palette = 0; diff --git a/bsnes/sfc/ppu/object.hpp b/bsnes/sfc/ppu/object.hpp index d25b994d..a3687849 100644 --- a/bsnes/sfc/ppu/object.hpp +++ b/bsnes/sfc/ppu/object.hpp @@ -50,6 +50,10 @@ struct Object { uint1 rangeOver; } io; + struct Latch { + uint7 firstSprite; + } latch; + struct Item { uint1 valid; uint7 index; diff --git a/bsnes/sfc/ppu/ppu.hpp b/bsnes/sfc/ppu/ppu.hpp index 66fd99c7..f7eac0f7 100644 --- a/bsnes/sfc/ppu/ppu.hpp +++ b/bsnes/sfc/ppu/ppu.hpp @@ -61,7 +61,6 @@ private: uint vdisp; } display; -// auto scanline() -> void; auto refresh() -> void; struct { diff --git a/bsnes/sfc/ppu/serialization.cpp b/bsnes/sfc/ppu/serialization.cpp index 73b78696..777ca41d 100644 --- a/bsnes/sfc/ppu/serialization.cpp +++ b/bsnes/sfc/ppu/serialization.cpp @@ -163,6 +163,8 @@ auto PPU::Object::serialize(serializer& s) -> void { s.integer(io.timeOver); s.integer(io.rangeOver); + s.integer(latch.firstSprite); + s.integer(t.x); s.integer(t.y);