From 92ab697f8c9a8398ba705f5517647a63bc41466b Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Thu, 9 Sep 2010 16:34:54 +1000 Subject: [PATCH] Update to v068r17 release. byuu says: This hopefully fixes vertical and horizontal mosaic with the accurate S-PPU core. It also adds frame-skipping support to the compatibility and performance S-PPU cores. This is not visible to the user interface, because I feel that virtually nobody is going to play with frame-skipping on when they could use a faster emulation with it off. However, I did use it to enhance the 'Fast Forward' key. When you press it, it will now turn off video and audio sync, and set a frameskip of 9. This allows you to speed things up an additional ~60% over your max theoretical speed without frameskipping. ~35% with the compatible core, because the PPU is less of a bottleneck for it. Slowdown was improved, it will turn on audio sync if it is off until you release the key to ensure you actually get 30fps. Eventually it'd probably be wise to set a cap on the fast forward speed, but I hardly think it's an issue on today's computers. --- bsnes/Makefile | 2 +- bsnes/qt/base/main.cpp | 3 ++ .../qt/input/userinterface-emulationspeed.cpp | 27 ++++++++++++ bsnes/snes/Makefile | 4 +- .../debugger/debugger.cpp | 0 .../debugger/debugger.hpp | 0 .../memory/memory.cpp | 0 .../memory/memory.hpp | 0 .../{ppu => ppu-compatibility}/mmio/mmio.cpp | 0 .../{ppu => ppu-compatibility}/mmio/mmio.hpp | 0 .../alt/{ppu => ppu-compatibility}/ppu.cpp | 10 +++++ .../alt/{ppu => ppu-compatibility}/ppu.hpp | 3 ++ .../render/addsub.cpp | 0 .../{ppu => ppu-compatibility}/render/bg.cpp | 0 .../render/cache.cpp | 0 .../render/line.cpp | 0 .../render/mode7.cpp | 0 .../{ppu => ppu-compatibility}/render/oam.cpp | 0 .../render/render.cpp | 0 .../render/render.hpp | 0 .../render/windows.cpp | 0 .../serialization.cpp | 0 .../background/background.cpp | 0 .../background/background.hpp | 0 .../background/mode7.cpp | 0 .../cache/cache.cpp | 0 .../cache/cache.hpp | 0 .../debugger/debugger.cpp | 0 .../debugger/debugger.hpp | 0 .../mmio/mmio.cpp | 0 .../mmio/mmio.hpp | 0 .../alt/{ppu-new => ppu-performance}/ppu.cpp | 11 +++++ .../alt/{ppu-new => ppu-performance}/ppu.hpp | 3 ++ .../screen/screen.cpp | 0 .../screen/screen.hpp | 0 .../serialization.cpp | 0 .../sprite/sprite.cpp | 0 .../sprite/sprite.hpp | 0 .../window/window.cpp | 0 .../window/window.hpp | 0 bsnes/snes/ppu/background/background.cpp | 42 +++++++++++-------- bsnes/snes/ppu/background/background.hpp | 5 ++- bsnes/snes/ppu/background/mode7.cpp | 4 +- bsnes/snes/ppu/ppu.cpp | 11 +++-- bsnes/snes/ppu/serialization.cpp | 3 ++ bsnes/snes/profile-compatibility.hpp | 2 +- bsnes/snes/profile-performance.hpp | 2 +- bsnes/snes/snes.hpp | 2 +- 48 files changed, 101 insertions(+), 33 deletions(-) rename bsnes/snes/alt/{ppu => ppu-compatibility}/debugger/debugger.cpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/debugger/debugger.hpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/memory/memory.cpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/memory/memory.hpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/mmio/mmio.cpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/mmio/mmio.hpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/ppu.cpp (97%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/ppu.hpp (95%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/render/addsub.cpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/render/bg.cpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/render/cache.cpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/render/line.cpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/render/mode7.cpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/render/oam.cpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/render/render.cpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/render/render.hpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/render/windows.cpp (100%) rename bsnes/snes/alt/{ppu => ppu-compatibility}/serialization.cpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/background/background.cpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/background/background.hpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/background/mode7.cpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/cache/cache.cpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/cache/cache.hpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/debugger/debugger.cpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/debugger/debugger.hpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/mmio/mmio.cpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/mmio/mmio.hpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/ppu.cpp (89%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/ppu.hpp (93%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/screen/screen.cpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/screen/screen.hpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/serialization.cpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/sprite/sprite.cpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/sprite/sprite.hpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/window/window.cpp (100%) rename bsnes/snes/alt/{ppu-new => ppu-performance}/window/window.hpp (100%) diff --git a/bsnes/Makefile b/bsnes/Makefile index 9051d500..b82a6065 100755 --- a/bsnes/Makefile +++ b/bsnes/Makefile @@ -1,6 +1,6 @@ include nall/Makefile snes := snes -profile := compatibility +profile := performance ui := qt # compiler diff --git a/bsnes/qt/base/main.cpp b/bsnes/qt/base/main.cpp index 02125f4b..db693c40 100755 --- a/bsnes/qt/base/main.cpp +++ b/bsnes/qt/base/main.cpp @@ -178,6 +178,9 @@ MainWindow::MainWindow() { tools_stateManager = tools->addAction("&State Manager ..."); tools_effectToggle = tools->addAction("Effect &Toggle ..."); + #if !defined(PROFILE_COMPATIBILITY) && !defined(PROFILE_PERFORMANCE) + tools_effectToggle->setVisible(false); + #endif tools_debugger = tools->addAction("&Debugger ..."); #if !defined(DEBUGGER) diff --git a/bsnes/qt/input/userinterface-emulationspeed.cpp b/bsnes/qt/input/userinterface-emulationspeed.cpp index 0f9a1d51..2ac19c67 100755 --- a/bsnes/qt/input/userinterface-emulationspeed.cpp +++ b/bsnes/qt/input/userinterface-emulationspeed.cpp @@ -8,15 +8,21 @@ namespace UserInterfaceEmulationSpeed { struct Slowdown : HotkeyInput { bool syncVideo; + bool syncAudio; void pressed() { config().system.speed = 0; utility.updateEmulationSpeed(); syncVideo = config().video.synchronize; + syncAudio = config().audio.synchronize; if(syncVideo) { config().video.synchronize = false; utility.updateAvSync(); } + if(!syncAudio) { + config().audio.synchronize = true; + utility.updateAvSync(); + } mainWindow->syncUi(); } @@ -27,35 +33,56 @@ struct Slowdown : HotkeyInput { config().video.synchronize = true; utility.updateAvSync(); } + if(!syncAudio) { + config().audio.synchronize = false; + utility.updateAvSync(); + } mainWindow->syncUi(); } Slowdown() : HotkeyInput("Slowdown", "input.userInterface.emulationSpeed.slowdown") { + name = "Shift+KB0::Tilde"; userInterfaceEmulationSpeed.attach(this); } } slowdown; struct Speedup : HotkeyInput { bool syncVideo; + bool syncAudio; void pressed() { + #if defined(PROFILE_COMPATIBILITY) || defined(PROFILE_PERFORMANCE) + SNES::ppu.set_frameskip(9); + #endif config().system.speed = 4; utility.updateEmulationSpeed(); syncVideo = config().video.synchronize; + syncAudio = config().audio.synchronize; if(syncVideo) { config().video.synchronize = false; utility.updateAvSync(); } + if(syncAudio) { + config().audio.synchronize = false; + utility.updateAvSync(); + } mainWindow->syncUi(); } void released() { + #if defined(PROFILE_COMPATIBILITY) || defined(PROFILE_PERFORMANCE) + SNES::ppu.set_frameskip(0); + #endif config().system.speed = 2; utility.updateEmulationSpeed(); if(syncVideo) { config().video.synchronize = true; utility.updateAvSync(); } + if(syncAudio) { + config().audio.synchronize = true; + utility.updateAvSync(); + } mainWindow->syncUi(); } diff --git a/bsnes/snes/Makefile b/bsnes/snes/Makefile index 06d1ca7c..e47c23ae 100755 --- a/bsnes/snes/Makefile +++ b/bsnes/snes/Makefile @@ -21,13 +21,13 @@ else ifeq ($(profile),compatibility) snescpu := $(snes)/cpu snessmp := $(snes)/smp snesdsp := $(snes)/alt/dsp - snesppu := $(snes)/alt/ppu + snesppu := $(snes)/alt/ppu-compatibility else ifeq ($(profile),performance) flags += -DPROFILE_PERFORMANCE snescpu := $(snes)/alt/cpu snessmp := $(snes)/smp snesdsp := $(snes)/alt/dsp - snesppu := $(snes)/alt/ppu-new + snesppu := $(snes)/alt/ppu-performance endif obj/libco.o : libco/libco.c libco/* diff --git a/bsnes/snes/alt/ppu/debugger/debugger.cpp b/bsnes/snes/alt/ppu-compatibility/debugger/debugger.cpp similarity index 100% rename from bsnes/snes/alt/ppu/debugger/debugger.cpp rename to bsnes/snes/alt/ppu-compatibility/debugger/debugger.cpp diff --git a/bsnes/snes/alt/ppu/debugger/debugger.hpp b/bsnes/snes/alt/ppu-compatibility/debugger/debugger.hpp similarity index 100% rename from bsnes/snes/alt/ppu/debugger/debugger.hpp rename to bsnes/snes/alt/ppu-compatibility/debugger/debugger.hpp diff --git a/bsnes/snes/alt/ppu/memory/memory.cpp b/bsnes/snes/alt/ppu-compatibility/memory/memory.cpp similarity index 100% rename from bsnes/snes/alt/ppu/memory/memory.cpp rename to bsnes/snes/alt/ppu-compatibility/memory/memory.cpp diff --git a/bsnes/snes/alt/ppu/memory/memory.hpp b/bsnes/snes/alt/ppu-compatibility/memory/memory.hpp similarity index 100% rename from bsnes/snes/alt/ppu/memory/memory.hpp rename to bsnes/snes/alt/ppu-compatibility/memory/memory.hpp diff --git a/bsnes/snes/alt/ppu/mmio/mmio.cpp b/bsnes/snes/alt/ppu-compatibility/mmio/mmio.cpp similarity index 100% rename from bsnes/snes/alt/ppu/mmio/mmio.cpp rename to bsnes/snes/alt/ppu-compatibility/mmio/mmio.cpp diff --git a/bsnes/snes/alt/ppu/mmio/mmio.hpp b/bsnes/snes/alt/ppu-compatibility/mmio/mmio.hpp similarity index 100% rename from bsnes/snes/alt/ppu/mmio/mmio.hpp rename to bsnes/snes/alt/ppu-compatibility/mmio/mmio.hpp diff --git a/bsnes/snes/alt/ppu/ppu.cpp b/bsnes/snes/alt/ppu-compatibility/ppu.cpp similarity index 97% rename from bsnes/snes/alt/ppu/ppu.cpp rename to bsnes/snes/alt/ppu-compatibility/ppu.cpp index 5bc92246..768ca4c7 100755 --- a/bsnes/snes/alt/ppu/ppu.cpp +++ b/bsnes/snes/alt/ppu-compatibility/ppu.cpp @@ -105,6 +105,7 @@ void PPU::scanline() { void PPU::render_scanline() { if(line >= 1 && line < (!overscan() ? 225 : 240)) { + if(framecounter) return; render_line_oam_rto(); render_line(); } @@ -117,6 +118,8 @@ void PPU::frame() { display.interlace = regs.interlace; regs.scanlines = (regs.overscan == false) ? 224 : 239; } + + framecounter = (frameskip == 0 ? 0 : (framecounter + 1) % frameskip); } void PPU::power() { @@ -382,6 +385,11 @@ void PPU::layer_enable(unsigned layer, unsigned priority, bool enable) { } } +void PPU::set_frameskip(unsigned frameskip_) { + frameskip = frameskip_; + framecounter = 0; +} + PPU::PPU() { surface = new uint16[512 * 512]; output = surface + 16 * 512; @@ -420,6 +428,8 @@ PPU::PPU() { layer_enabled[OAM][1] = true; layer_enabled[OAM][2] = true; layer_enabled[OAM][3] = true; + frameskip = 0; + framecounter = 0; } PPU::~PPU() { diff --git a/bsnes/snes/alt/ppu/ppu.hpp b/bsnes/snes/alt/ppu-compatibility/ppu.hpp similarity index 95% rename from bsnes/snes/alt/ppu/ppu.hpp rename to bsnes/snes/alt/ppu-compatibility/ppu.hpp index 0a01b045..4587d489 100755 --- a/bsnes/snes/alt/ppu/ppu.hpp +++ b/bsnes/snes/alt/ppu-compatibility/ppu.hpp @@ -61,6 +61,9 @@ public: bool layer_enabled[5][4]; void layer_enable(unsigned layer, unsigned priority, bool enable); + unsigned frameskip; + unsigned framecounter; + void set_frameskip(unsigned frameskip); void serialize(serializer&); PPU(); diff --git a/bsnes/snes/alt/ppu/render/addsub.cpp b/bsnes/snes/alt/ppu-compatibility/render/addsub.cpp similarity index 100% rename from bsnes/snes/alt/ppu/render/addsub.cpp rename to bsnes/snes/alt/ppu-compatibility/render/addsub.cpp diff --git a/bsnes/snes/alt/ppu/render/bg.cpp b/bsnes/snes/alt/ppu-compatibility/render/bg.cpp similarity index 100% rename from bsnes/snes/alt/ppu/render/bg.cpp rename to bsnes/snes/alt/ppu-compatibility/render/bg.cpp diff --git a/bsnes/snes/alt/ppu/render/cache.cpp b/bsnes/snes/alt/ppu-compatibility/render/cache.cpp similarity index 100% rename from bsnes/snes/alt/ppu/render/cache.cpp rename to bsnes/snes/alt/ppu-compatibility/render/cache.cpp diff --git a/bsnes/snes/alt/ppu/render/line.cpp b/bsnes/snes/alt/ppu-compatibility/render/line.cpp similarity index 100% rename from bsnes/snes/alt/ppu/render/line.cpp rename to bsnes/snes/alt/ppu-compatibility/render/line.cpp diff --git a/bsnes/snes/alt/ppu/render/mode7.cpp b/bsnes/snes/alt/ppu-compatibility/render/mode7.cpp similarity index 100% rename from bsnes/snes/alt/ppu/render/mode7.cpp rename to bsnes/snes/alt/ppu-compatibility/render/mode7.cpp diff --git a/bsnes/snes/alt/ppu/render/oam.cpp b/bsnes/snes/alt/ppu-compatibility/render/oam.cpp similarity index 100% rename from bsnes/snes/alt/ppu/render/oam.cpp rename to bsnes/snes/alt/ppu-compatibility/render/oam.cpp diff --git a/bsnes/snes/alt/ppu/render/render.cpp b/bsnes/snes/alt/ppu-compatibility/render/render.cpp similarity index 100% rename from bsnes/snes/alt/ppu/render/render.cpp rename to bsnes/snes/alt/ppu-compatibility/render/render.cpp diff --git a/bsnes/snes/alt/ppu/render/render.hpp b/bsnes/snes/alt/ppu-compatibility/render/render.hpp similarity index 100% rename from bsnes/snes/alt/ppu/render/render.hpp rename to bsnes/snes/alt/ppu-compatibility/render/render.hpp diff --git a/bsnes/snes/alt/ppu/render/windows.cpp b/bsnes/snes/alt/ppu-compatibility/render/windows.cpp similarity index 100% rename from bsnes/snes/alt/ppu/render/windows.cpp rename to bsnes/snes/alt/ppu-compatibility/render/windows.cpp diff --git a/bsnes/snes/alt/ppu/serialization.cpp b/bsnes/snes/alt/ppu-compatibility/serialization.cpp similarity index 100% rename from bsnes/snes/alt/ppu/serialization.cpp rename to bsnes/snes/alt/ppu-compatibility/serialization.cpp diff --git a/bsnes/snes/alt/ppu-new/background/background.cpp b/bsnes/snes/alt/ppu-performance/background/background.cpp similarity index 100% rename from bsnes/snes/alt/ppu-new/background/background.cpp rename to bsnes/snes/alt/ppu-performance/background/background.cpp diff --git a/bsnes/snes/alt/ppu-new/background/background.hpp b/bsnes/snes/alt/ppu-performance/background/background.hpp similarity index 100% rename from bsnes/snes/alt/ppu-new/background/background.hpp rename to bsnes/snes/alt/ppu-performance/background/background.hpp diff --git a/bsnes/snes/alt/ppu-new/background/mode7.cpp b/bsnes/snes/alt/ppu-performance/background/mode7.cpp similarity index 100% rename from bsnes/snes/alt/ppu-new/background/mode7.cpp rename to bsnes/snes/alt/ppu-performance/background/mode7.cpp diff --git a/bsnes/snes/alt/ppu-new/cache/cache.cpp b/bsnes/snes/alt/ppu-performance/cache/cache.cpp similarity index 100% rename from bsnes/snes/alt/ppu-new/cache/cache.cpp rename to bsnes/snes/alt/ppu-performance/cache/cache.cpp diff --git a/bsnes/snes/alt/ppu-new/cache/cache.hpp b/bsnes/snes/alt/ppu-performance/cache/cache.hpp similarity index 100% rename from bsnes/snes/alt/ppu-new/cache/cache.hpp rename to bsnes/snes/alt/ppu-performance/cache/cache.hpp diff --git a/bsnes/snes/alt/ppu-new/debugger/debugger.cpp b/bsnes/snes/alt/ppu-performance/debugger/debugger.cpp similarity index 100% rename from bsnes/snes/alt/ppu-new/debugger/debugger.cpp rename to bsnes/snes/alt/ppu-performance/debugger/debugger.cpp diff --git a/bsnes/snes/alt/ppu-new/debugger/debugger.hpp b/bsnes/snes/alt/ppu-performance/debugger/debugger.hpp similarity index 100% rename from bsnes/snes/alt/ppu-new/debugger/debugger.hpp rename to bsnes/snes/alt/ppu-performance/debugger/debugger.hpp diff --git a/bsnes/snes/alt/ppu-new/mmio/mmio.cpp b/bsnes/snes/alt/ppu-performance/mmio/mmio.cpp similarity index 100% rename from bsnes/snes/alt/ppu-new/mmio/mmio.cpp rename to bsnes/snes/alt/ppu-performance/mmio/mmio.cpp diff --git a/bsnes/snes/alt/ppu-new/mmio/mmio.hpp b/bsnes/snes/alt/ppu-performance/mmio/mmio.hpp similarity index 100% rename from bsnes/snes/alt/ppu-new/mmio/mmio.hpp rename to bsnes/snes/alt/ppu-performance/mmio/mmio.hpp diff --git a/bsnes/snes/alt/ppu-new/ppu.cpp b/bsnes/snes/alt/ppu-performance/ppu.cpp similarity index 89% rename from bsnes/snes/alt/ppu-new/ppu.cpp rename to bsnes/snes/alt/ppu-performance/ppu.cpp index da1b539d..82e37544 100755 --- a/bsnes/snes/alt/ppu-new/ppu.cpp +++ b/bsnes/snes/alt/ppu-performance/ppu.cpp @@ -56,6 +56,7 @@ void PPU::add_clocks(unsigned clocks) { } void PPU::render_scanline() { + if(display.framecounter) return; //skip this frame? bg1.scanline(); bg2.scanline(); bg3.scanline(); @@ -80,6 +81,7 @@ void PPU::scanline() { void PPU::frame() { oam.frame(); system.frame(); + display.framecounter = display.frameskip == 0 ? 0 : (display.framecounter + 1) % display.frameskip; } void PPU::power() { @@ -113,6 +115,11 @@ void PPU::layer_enable(unsigned layer, unsigned priority, bool enable) { } } +void PPU::set_frameskip(unsigned frameskip) { + display.frameskip = frameskip; + display.framecounter = 0; +} + PPU::PPU() : cache(*this), bg1(*this, Background::ID::BG1), @@ -123,6 +130,10 @@ oam(*this), screen(*this) { surface = new uint16[512 * 512]; output = surface + 16 * 512; + display.width = 256; + display.height = 224; + display.frameskip = 0; + display.framecounter = 0; } PPU::~PPU() { diff --git a/bsnes/snes/alt/ppu-new/ppu.hpp b/bsnes/snes/alt/ppu-performance/ppu.hpp similarity index 93% rename from bsnes/snes/alt/ppu-new/ppu.hpp rename to bsnes/snes/alt/ppu-performance/ppu.hpp index 79eb37f2..d88e4e84 100755 --- a/bsnes/snes/alt/ppu-new/ppu.hpp +++ b/bsnes/snes/alt/ppu-performance/ppu.hpp @@ -16,6 +16,7 @@ public: void frame(); void layer_enable(unsigned layer, unsigned priority, bool enable); + void set_frameskip(unsigned frameskip); void serialize(serializer&); PPU(); @@ -43,6 +44,8 @@ private: struct Display { unsigned width; unsigned height; + unsigned frameskip; + unsigned framecounter; } display; static void Enter(); diff --git a/bsnes/snes/alt/ppu-new/screen/screen.cpp b/bsnes/snes/alt/ppu-performance/screen/screen.cpp similarity index 100% rename from bsnes/snes/alt/ppu-new/screen/screen.cpp rename to bsnes/snes/alt/ppu-performance/screen/screen.cpp diff --git a/bsnes/snes/alt/ppu-new/screen/screen.hpp b/bsnes/snes/alt/ppu-performance/screen/screen.hpp similarity index 100% rename from bsnes/snes/alt/ppu-new/screen/screen.hpp rename to bsnes/snes/alt/ppu-performance/screen/screen.hpp diff --git a/bsnes/snes/alt/ppu-new/serialization.cpp b/bsnes/snes/alt/ppu-performance/serialization.cpp similarity index 100% rename from bsnes/snes/alt/ppu-new/serialization.cpp rename to bsnes/snes/alt/ppu-performance/serialization.cpp diff --git a/bsnes/snes/alt/ppu-new/sprite/sprite.cpp b/bsnes/snes/alt/ppu-performance/sprite/sprite.cpp similarity index 100% rename from bsnes/snes/alt/ppu-new/sprite/sprite.cpp rename to bsnes/snes/alt/ppu-performance/sprite/sprite.cpp diff --git a/bsnes/snes/alt/ppu-new/sprite/sprite.hpp b/bsnes/snes/alt/ppu-performance/sprite/sprite.hpp similarity index 100% rename from bsnes/snes/alt/ppu-new/sprite/sprite.hpp rename to bsnes/snes/alt/ppu-performance/sprite/sprite.hpp diff --git a/bsnes/snes/alt/ppu-new/window/window.cpp b/bsnes/snes/alt/ppu-performance/window/window.cpp similarity index 100% rename from bsnes/snes/alt/ppu-new/window/window.cpp rename to bsnes/snes/alt/ppu-performance/window/window.cpp diff --git a/bsnes/snes/alt/ppu-new/window/window.hpp b/bsnes/snes/alt/ppu-performance/window/window.hpp similarity index 100% rename from bsnes/snes/alt/ppu-new/window/window.hpp rename to bsnes/snes/alt/ppu-performance/window/window.hpp diff --git a/bsnes/snes/ppu/background/background.cpp b/bsnes/snes/ppu/background/background.cpp index 2c77aab6..fa324a4b 100755 --- a/bsnes/snes/ppu/background/background.cpp +++ b/bsnes/snes/ppu/background/background.cpp @@ -20,7 +20,7 @@ void PPU::Background::scanline() { mosaic_voffset += regs.mosaic + 1; } - mosaic_hcounter = 0; + mosaic_hcounter = regs.mosaic + 1; mosaic_hoffset = 0; } @@ -46,7 +46,7 @@ void PPU::Background::get_tile() { mask_y--; unsigned px = x << hires; - unsigned py = mosaic_voffset; + unsigned py = (regs.mosaic == 0 ? y : mosaic_voffset); unsigned hscroll = regs.hoffset; unsigned vscroll = regs.voffset; @@ -152,38 +152,41 @@ void PPU::Background::run(bool screen) { tile_counter = 7; get_tile(); } - if(screen == Screen::Main) x++; uint8 palette = get_tile_color(); - if(x >= 0 && mosaic_hcounter++ >= regs.mosaic) { - mosaic_hcounter = 0; - mosaic_palette = palette; + if(x == 0) mosaic_hcounter = 1; + if(x >= 0 && --mosaic_hcounter == 0) { + mosaic_hcounter = regs.mosaic + 1; + mosaic_priority = priority; + mosaic_palette = palette ? palette_index + palette : 0; + mosaic_tile = tile; } + if(screen == Screen::Main) x++; if(mosaic_palette == 0) return; if(hires == false) { if(regs.main_enable) { - output.main.priority = priority; - output.main.palette = palette_index + mosaic_palette; - output.main.tile = tile; + output.main.priority = mosaic_priority; + output.main.palette = mosaic_palette; + output.main.tile = mosaic_tile; } if(regs.sub_enable) { - output.sub.priority = priority; - output.sub.palette = palette_index + mosaic_palette; - output.sub.tile = tile; + output.sub.priority = mosaic_priority; + output.sub.palette = mosaic_palette; + output.sub.tile = mosaic_tile; } } else if(screen == Screen::Main) { if(regs.main_enable) { - output.main.priority = priority; - output.main.palette = palette_index + mosaic_palette; - output.main.tile = tile; + output.main.priority = mosaic_priority; + output.main.palette = mosaic_palette; + output.main.tile = mosaic_tile; } } else if(screen == Screen::Sub) { if(regs.sub_enable) { - output.sub.priority = priority; - output.sub.palette = palette_index + mosaic_palette; - output.sub.tile = tile; + output.sub.priority = mosaic_priority; + output.sub.palette = mosaic_palette; + output.sub.tile = mosaic_tile; } } } @@ -233,7 +236,10 @@ void PPU::Background::reset() { mosaic_voffset = 0; mosaic_hcounter = 0; mosaic_hoffset = 0; + + mosaic_priority = 0; mosaic_palette = 0; + mosaic_tile = 0; tile_counter = 0; tile = 0; diff --git a/bsnes/snes/ppu/background/background.hpp b/bsnes/snes/ppu/background/background.hpp index b460539c..8e0c4a70 100755 --- a/bsnes/snes/ppu/background/background.hpp +++ b/bsnes/snes/ppu/background/background.hpp @@ -41,7 +41,10 @@ class Background { unsigned mosaic_voffset; unsigned mosaic_hcounter; unsigned mosaic_hoffset; - unsigned mosaic_palette; + + unsigned mosaic_priority; + uint8 mosaic_palette; + uint16 mosaic_tile; unsigned tile_counter; unsigned tile; diff --git a/bsnes/snes/ppu/background/mode7.cpp b/bsnes/snes/ppu/background/mode7.cpp index 7efa036c..2bcbda3e 100755 --- a/bsnes/snes/ppu/background/mode7.cpp +++ b/bsnes/snes/ppu/background/mode7.cpp @@ -20,8 +20,8 @@ void PPU::Background::run_mode7() { unsigned x = mosaic_hoffset; unsigned y = self.bg1.mosaic_voffset; //BG2 vertical mosaic uses BG1 mosaic size - if(mosaic_hcounter++ == regs.mosaic) { - mosaic_hcounter = 0; + if(--mosaic_hcounter == 0) { + mosaic_hcounter = regs.mosaic + 1; mosaic_hoffset += regs.mosaic + 1; } diff --git a/bsnes/snes/ppu/ppu.cpp b/bsnes/snes/ppu/ppu.cpp index 85c77f9f..7d8d977e 100755 --- a/bsnes/snes/ppu/ppu.cpp +++ b/bsnes/snes/ppu/ppu.cpp @@ -38,11 +38,10 @@ void PPU::enter() { } scanline(); - add_clocks(56); + add_clocks(60); if(vcounter() <= (!regs.overscan ? 224 : 239)) { - add_clocks(4); - for(unsigned pixel = 1; pixel < 8 + 256; pixel++) { + for(signed pixel = -7; pixel <= 255; pixel++) { bg1.run(1); bg2.run(1); bg3.run(1); @@ -53,7 +52,7 @@ void PPU::enter() { bg2.run(0); bg3.run(0); bg4.run(0); - if(pixel >= 8) { + if(pixel >= 0) { oam.run(); window.run(); screen.run(); @@ -64,10 +63,10 @@ void PPU::enter() { add_clocks(22); oam.tilefetch(); } else { - add_clocks(1056 + 22 + 136); + add_clocks(1052 + 22 + 136); } - add_clocks(lineclocks() - 56 - 1056 - 22 - 136); + add_clocks(lineclocks() - 60 - 1052 - 22 - 136); } } diff --git a/bsnes/snes/ppu/serialization.cpp b/bsnes/snes/ppu/serialization.cpp index af38171b..9f074bbc 100755 --- a/bsnes/snes/ppu/serialization.cpp +++ b/bsnes/snes/ppu/serialization.cpp @@ -120,7 +120,10 @@ void PPU::Background::serialize(serializer &s) { s.integer(mosaic_voffset); s.integer(mosaic_hcounter); s.integer(mosaic_hoffset); + + s.integer(mosaic_priority); s.integer(mosaic_palette); + s.integer(mosaic_tile); s.integer(tile_counter); s.integer(tile); diff --git a/bsnes/snes/profile-compatibility.hpp b/bsnes/snes/profile-compatibility.hpp index faf3ff9e..b3e3a0eb 100755 --- a/bsnes/snes/profile-compatibility.hpp +++ b/bsnes/snes/profile-compatibility.hpp @@ -5,4 +5,4 @@ namespace Info { #include #include #include -#include +#include diff --git a/bsnes/snes/profile-performance.hpp b/bsnes/snes/profile-performance.hpp index 074959e6..b21fbbb1 100755 --- a/bsnes/snes/profile-performance.hpp +++ b/bsnes/snes/profile-performance.hpp @@ -5,4 +5,4 @@ namespace Info { #include #include #include -#include +#include diff --git a/bsnes/snes/snes.hpp b/bsnes/snes/snes.hpp index ffbf7579..19a87bcd 100755 --- a/bsnes/snes/snes.hpp +++ b/bsnes/snes/snes.hpp @@ -1,7 +1,7 @@ namespace SNES { namespace Info { static const char Name[] = "bsnes"; - static const char Version[] = "068.16"; + static const char Version[] = "068.17"; static const unsigned SerializerVersion = 13; } }