diff --git a/bsnes/emulator/emulator.hpp b/bsnes/emulator/emulator.hpp index fe2d12a0..b9f022b4 100755 --- a/bsnes/emulator/emulator.hpp +++ b/bsnes/emulator/emulator.hpp @@ -3,7 +3,7 @@ namespace Emulator { static const char Name[] = "bsnes"; - static const char Version[] = "088.15"; + static const char Version[] = "088.16"; static const char Author[] = "byuu"; static const char License[] = "GPLv3"; } diff --git a/bsnes/gb/interface/interface.cpp b/bsnes/gb/interface/interface.cpp index 43dc6758..691a22a6 100755 --- a/bsnes/gb/interface/interface.cpp +++ b/bsnes/gb/interface/interface.cpp @@ -4,6 +4,14 @@ namespace GameBoy { Interface *interface = nullptr; +void Interface::lcdScanline() { + if(hook) hook->lcdScanline(); +} + +void Interface::joypWrite(bool p15, bool p14) { + if(hook) hook->joypWrite(p15, p14); +} + double Interface::videoFrequency() { return 4194304.0 / (154.0 * 456.0); } @@ -97,6 +105,7 @@ void Interface::updatePalette() { Interface::Interface() { interface = this; + hook = nullptr; information.name = "Game Boy"; information.width = 160; diff --git a/bsnes/gb/interface/interface.hpp b/bsnes/gb/interface/interface.hpp index 394b6d44..e7ceeaf0 100755 --- a/bsnes/gb/interface/interface.hpp +++ b/bsnes/gb/interface/interface.hpp @@ -19,8 +19,13 @@ struct ID { struct Interface : Emulator::Interface { //Super Game Boy bindings - virtual void lcdScanline() {} - virtual void joypWrite(bool p15, bool p14) {} + struct Hook { + virtual void lcdScanline() {} + virtual void joypWrite(bool p15, bool p14) {} + } *hook; + + void lcdScanline(); + void joypWrite(bool p15, bool p14); double videoFrequency(); double audioFrequency(); diff --git a/bsnes/sfc/chip/armdsp/armdsp.hpp b/bsnes/sfc/chip/armdsp/armdsp.hpp index 385cfc47..78b4191c 100755 --- a/bsnes/sfc/chip/armdsp/armdsp.hpp +++ b/bsnes/sfc/chip/armdsp/armdsp.hpp @@ -1,6 +1,6 @@ //ARMv3 (ARM6) -struct ArmDSP : Processor::ARM, public Coprocessor { +struct ArmDSP : Processor::ARM, Coprocessor { uint8 *firmware; uint8 *programROM; uint8 *dataROM; diff --git a/bsnes/sfc/chip/bsx/cartridge/cartridge.cpp b/bsnes/sfc/chip/bsx/cartridge/cartridge.cpp index d2441f80..9006af89 100755 --- a/bsnes/sfc/chip/bsx/cartridge/cartridge.cpp +++ b/bsnes/sfc/chip/bsx/cartridge/cartridge.cpp @@ -8,11 +8,11 @@ void BSXCartridge::init() { void BSXCartridge::load() { sram.map(allocate(32 * 1024, 0xff), 32 * 1024); sram.write_protect(false); - interface->memory.append({ID::BsxRAM, "bsx.ram"}); + interface->memory.append({ID::BsxRAM, "save.ram"}); psram.map(allocate(512 * 1024, 0xff), 512 * 1024); psram.write_protect(false); - interface->memory.append({ID::BsxPSRAM, "bsx.psram"}); + interface->memory.append({ID::BsxPSRAM, "bsx.ram"}); } void BSXCartridge::unload() { diff --git a/bsnes/sfc/chip/bsx/cartridge/cartridge.hpp b/bsnes/sfc/chip/bsx/cartridge/cartridge.hpp index eb5f9bf9..feda3f9a 100755 --- a/bsnes/sfc/chip/bsx/cartridge/cartridge.hpp +++ b/bsnes/sfc/chip/bsx/cartridge/cartridge.hpp @@ -1,5 +1,4 @@ -class BSXCartridge { -public: +struct BSXCartridge { MappedRAM sram; MappedRAM psram; diff --git a/bsnes/sfc/chip/bsx/flash/flash.hpp b/bsnes/sfc/chip/bsx/flash/flash.hpp index 353bef19..3232fb45 100755 --- a/bsnes/sfc/chip/bsx/flash/flash.hpp +++ b/bsnes/sfc/chip/bsx/flash/flash.hpp @@ -1,5 +1,4 @@ -class BSXFlash : public Memory { -public: +struct BSXFlash : Memory { MappedRAM memory; void init(); diff --git a/bsnes/sfc/chip/bsx/satellaview/satellaview.hpp b/bsnes/sfc/chip/bsx/satellaview/satellaview.hpp index 0f99acbd..56caf0b7 100755 --- a/bsnes/sfc/chip/bsx/satellaview/satellaview.hpp +++ b/bsnes/sfc/chip/bsx/satellaview/satellaview.hpp @@ -1,5 +1,4 @@ -class BSXSatellaview { -public: +struct BSXSatellaview { void init(); void load(); void unload(); diff --git a/bsnes/sfc/chip/icd2/icd2.cpp b/bsnes/sfc/chip/icd2/icd2.cpp index 722d7dec..29f3a121 100755 --- a/bsnes/sfc/chip/icd2/icd2.cpp +++ b/bsnes/sfc/chip/icd2/icd2.cpp @@ -33,12 +33,15 @@ void ICD2::init() { } void ICD2::load() { - interface = GameBoy::interface->bind; + bind = GameBoy::interface->bind; + hook = GameBoy::interface->hook; GameBoy::interface->bind = this; + GameBoy::interface->hook = this; } void ICD2::unload() { - GameBoy::interface->bind = interface; + GameBoy::interface->bind = bind; + GameBoy::interface->hook = hook; } void ICD2::power() { @@ -56,7 +59,7 @@ void ICD2::reset() { r6005 = 0xff; r6006 = 0xff; r6007 = 0xff; - for(unsigned n = 0; n < 16; n++) r7000[n] = 0x00; + for(auto &r : r7000) r = 0x00; r7800 = 0x0000; mlt_req = 0; diff --git a/bsnes/sfc/chip/icd2/icd2.hpp b/bsnes/sfc/chip/icd2/icd2.hpp index 061d8097..e95b7f8a 100755 --- a/bsnes/sfc/chip/icd2/icd2.hpp +++ b/bsnes/sfc/chip/icd2/icd2.hpp @@ -1,4 +1,4 @@ -struct ICD2 : Emulator::Interface::Bind, Coprocessor { +struct ICD2 : Emulator::Interface::Bind, GameBoy::Interface::Hook, Coprocessor { unsigned revision; static void Enter(); @@ -16,7 +16,8 @@ struct ICD2 : Emulator::Interface::Bind, Coprocessor { void serialize(serializer&); private: - Emulator::Interface::Bind *interface; + Emulator::Interface::Bind *bind; + GameBoy::Interface::Hook *hook; #include "interface/interface.hpp" #include "mmio/mmio.hpp" }; diff --git a/bsnes/sfc/chip/link/link.hpp b/bsnes/sfc/chip/link/link.hpp index 1898fa02..6736888b 100755 --- a/bsnes/sfc/chip/link/link.hpp +++ b/bsnes/sfc/chip/link/link.hpp @@ -1,5 +1,4 @@ -class Link : public Coprocessor, public library { -public: +struct Link : Coprocessor, library { string program; static void Enter(); diff --git a/bsnes/sfc/chip/msu1/msu1.hpp b/bsnes/sfc/chip/msu1/msu1.hpp index 25572eaf..e599d498 100755 --- a/bsnes/sfc/chip/msu1/msu1.hpp +++ b/bsnes/sfc/chip/msu1/msu1.hpp @@ -1,5 +1,4 @@ -class MSU1 : public Coprocessor { -public: +struct MSU1 : Coprocessor { static void Enter(); void enter(); void init(); diff --git a/bsnes/sfc/chip/obc1/obc1.hpp b/bsnes/sfc/chip/obc1/obc1.hpp index 686adbc9..11fdb36b 100755 --- a/bsnes/sfc/chip/obc1/obc1.hpp +++ b/bsnes/sfc/chip/obc1/obc1.hpp @@ -1,5 +1,4 @@ -class OBC1 { -public: +struct OBC1 { void init(); void load(); void unload(); diff --git a/bsnes/sfc/chip/sdd1/sdd1.hpp b/bsnes/sfc/chip/sdd1/sdd1.hpp index b0af2ac4..4cc68939 100755 --- a/bsnes/sfc/chip/sdd1/sdd1.hpp +++ b/bsnes/sfc/chip/sdd1/sdd1.hpp @@ -1,5 +1,4 @@ -class SDD1 { -public: +struct SDD1 { void init(); void load(); void unload(); diff --git a/bsnes/sfc/chip/spc7110/spc7110.hpp b/bsnes/sfc/chip/spc7110/spc7110.hpp index 003c4237..5164a326 100755 --- a/bsnes/sfc/chip/spc7110/spc7110.hpp +++ b/bsnes/sfc/chip/spc7110/spc7110.hpp @@ -1,8 +1,7 @@ //SPC7110 emulator - version 0.05 (2011-06-27) //Copyright (c) 2008-2011, byuu and neviksti -class SPC7110 { -public: +struct SPC7110 { uint8 rtc[20]; unsigned data_rom_offset; diff --git a/bsnes/sfc/chip/srtc/srtc.hpp b/bsnes/sfc/chip/srtc/srtc.hpp index 93dcbe51..280be4d8 100755 --- a/bsnes/sfc/chip/srtc/srtc.hpp +++ b/bsnes/sfc/chip/srtc/srtc.hpp @@ -1,5 +1,4 @@ -class SRTC { -public: +struct SRTC { uint8 rtc[20]; void init(); diff --git a/bsnes/sfc/chip/sufamiturbo/sufamiturbo.hpp b/bsnes/sfc/chip/sufamiturbo/sufamiturbo.hpp index b38d75b5..ccc83a67 100755 --- a/bsnes/sfc/chip/sufamiturbo/sufamiturbo.hpp +++ b/bsnes/sfc/chip/sufamiturbo/sufamiturbo.hpp @@ -1,5 +1,4 @@ -class SufamiTurbo { -public: +struct SufamiTurbo { struct Slot { MappedRAM rom; MappedRAM ram; diff --git a/bsnes/sfc/chip/superfx/superfx.cpp b/bsnes/sfc/chip/superfx/superfx.cpp index dca09904..69e607d8 100755 --- a/bsnes/sfc/chip/superfx/superfx.cpp +++ b/bsnes/sfc/chip/superfx/superfx.cpp @@ -39,8 +39,8 @@ void SuperFX::enter() { void SuperFX::init() { initialize_opcode_table(); - regs.r[14].modify = { &SuperFX::r14_modify, this }; - regs.r[15].modify = { &SuperFX::r15_modify, this }; + regs.r[14].modify = {&SuperFX::r14_modify, this}; + regs.r[15].modify = {&SuperFX::r15_modify, this}; } void SuperFX::load() { diff --git a/bsnes/sfc/interface/interface.cpp b/bsnes/sfc/interface/interface.cpp index 9659a15f..a9a0ecbd 100755 --- a/bsnes/sfc/interface/interface.cpp +++ b/bsnes/sfc/interface/interface.cpp @@ -228,6 +228,7 @@ void Interface::updatePalette() { Interface::Interface() { interface = this; + system.init(); information.name = "Super Famicom"; information.width = 256; diff --git a/bsnes/sfc/ppu/background/background.cpp b/bsnes/sfc/ppu/background/background.cpp index d989323b..dc99bf46 100755 --- a/bsnes/sfc/ppu/background/background.cpp +++ b/bsnes/sfc/ppu/background/background.cpp @@ -2,6 +2,16 @@ #include "mode7.cpp" +unsigned PPU::Background::voffset() const { + if(regs.mosaic) return cache.voffset; + return regs.voffset; +} + +unsigned PPU::Background::hoffset() const { + if(regs.mosaic) return cache.hoffset; + return regs.hoffset; +} + //V = 0, H = 0 void PPU::Background::frame() { } @@ -10,7 +20,7 @@ void PPU::Background::frame() { void PPU::Background::scanline() { } -//H = 60 +//H = 28 void PPU::Background::begin() { bool hires = (self.regs.bgmode == 5 || self.regs.bgmode == 6); x = -7; @@ -65,8 +75,8 @@ void PPU::Background::get_tile() { unsigned px = x << hires; unsigned py = (regs.mosaic == 0 ? y : mosaic.voffset); - unsigned hscroll = cache.hoffset; - unsigned vscroll = cache.voffset; + unsigned hscroll = hoffset(); + unsigned vscroll = voffset(); if(hires) { hscroll <<= 1; if(self.regs.interlace) py = (py << 1) + self.field(); @@ -79,8 +89,8 @@ void PPU::Background::get_tile() { uint16 offset_x = (x + (hscroll & 7)); if(offset_x >= 8) { - unsigned hval = self.bg3.get_tile((offset_x - 8) + (self.bg3.cache.hoffset & ~7), self.bg3.cache.voffset + 0); - unsigned vval = self.bg3.get_tile((offset_x - 8) + (self.bg3.cache.hoffset & ~7), self.bg3.cache.voffset + 8); + unsigned hval = self.bg3.get_tile((offset_x - 8) + (self.bg3.hoffset() & ~7), self.bg3.voffset() + 0); + unsigned vval = self.bg3.get_tile((offset_x - 8) + (self.bg3.hoffset() & ~7), self.bg3.voffset() + 8); unsigned valid_mask = (id == ID::BG1 ? 0x2000 : 0x4000); if(self.regs.bgmode == 4) { diff --git a/bsnes/sfc/ppu/background/background.hpp b/bsnes/sfc/ppu/background/background.hpp index c279a806..6811be29 100755 --- a/bsnes/sfc/ppu/background/background.hpp +++ b/bsnes/sfc/ppu/background/background.hpp @@ -30,6 +30,9 @@ struct Background { uint16 voffset; } cache; + unsigned voffset() const; + unsigned hoffset() const; + struct Output { struct Pixel { unsigned priority; //0 = none (transparent) diff --git a/bsnes/sfc/ppu/background/mode7.cpp b/bsnes/sfc/ppu/background/mode7.cpp index bb630647..afb735af 100755 --- a/bsnes/sfc/ppu/background/mode7.cpp +++ b/bsnes/sfc/ppu/background/mode7.cpp @@ -5,7 +5,7 @@ signed PPU::Background::clip(signed n) { return n & 0x2000 ? (n | ~1023) : (n & 1023); } -//H = 60 +//H = 28 void PPU::Background::begin_mode7() { cache.hoffset = self.regs.mode7_hoffset; cache.voffset = self.regs.mode7_voffset; diff --git a/bsnes/target-ethos/general/browser.cpp b/bsnes/target-ethos/general/browser.cpp index 7e9be8ab..f14385b4 100755 --- a/bsnes/target-ethos/general/browser.cpp +++ b/bsnes/target-ethos/general/browser.cpp @@ -124,7 +124,7 @@ string Browser::select(const string &title, const string &extension) { if(path.empty()) path = application->basepath; setPath(path, selection); - filterLabel.setText({"Files of type: *.", extension}); + filterLabel.setText({"Filter: *.", extension}); audio.clear(); setTitle(title); diff --git a/bsnes/target-ethos/tools/state-manager.cpp b/bsnes/target-ethos/tools/state-manager.cpp index 7c3a94da..23bd39b5 100755 --- a/bsnes/target-ethos/tools/state-manager.cpp +++ b/bsnes/target-ethos/tools/state-manager.cpp @@ -101,6 +101,8 @@ bool StateManager::save(const string &filename, unsigned revision) { return true; } + directory::create(dir(filename)); + file fp; if(fp.open(filename, file::mode::write) == false) return false; diff --git a/bsnes/target-ethos/utility/utility.cpp b/bsnes/target-ethos/utility/utility.cpp index 5b0f3ada..5ca4fb34 100755 --- a/bsnes/target-ethos/utility/utility.cpp +++ b/bsnes/target-ethos/utility/utility.cpp @@ -68,7 +68,6 @@ void Utility::saveMemory() { system().save(memory.id, fs); } - directory::create({pathname[0], "bsnes/"}); cheatEditor->save({pathname[0], "cheats.xml"}); stateManager->save({pathname[0], "bsnes/states.bsa"}, 1); } @@ -138,9 +137,9 @@ void Utility::saveState(unsigned slot) { void Utility::loadState(unsigned slot) { if(application->active == nullptr) return; auto memory = file::read({pathname[0], "bsnes/state-", slot, ".bsa"}); - if(memory.size() == 0) return; + if(memory.size() == 0) return showMessage({"Unable to locate slot ", slot, " state"}); serializer s(memory.data(), memory.size()); - if(system().unserialize(s) == false) return; + if(system().unserialize(s) == false) return showMessage({"Slot ", slot, " state incompatible"}); showMessage({"Loaded from slot ", slot}); }