diff --git a/snes/alt/cpu/memory.cpp b/snes/alt/cpu/memory.cpp index fc39962..fed9870 100644 --- a/snes/alt/cpu/memory.cpp +++ b/snes/alt/cpu/memory.cpp @@ -5,7 +5,7 @@ uint8 CPU::pio() { } bool CPU::joylatch() { - return 0; + return status.joypad_strobe_latch; } bool CPU::interrupt_pending() { diff --git a/snes/alt/ppu-compatibility/render/mode7.cpp b/snes/alt/ppu-compatibility/render/mode7.cpp index b233efc..dc4d747 100644 --- a/snes/alt/ppu-compatibility/render/mode7.cpp +++ b/snes/alt/ppu-compatibility/render/mode7.cpp @@ -75,7 +75,7 @@ void PPU::render_line_mode7(uint8 pri0_pos, uint8 pri1_pos) { palette = memory::vram[(((tile << 6) + ((py & 7) << 3) + (px & 7)) << 1) + 1]; } break; case 2: { //palette color 0 outside of screen area - if(px < 0 || px > 1023 || py < 0 || py > 1023) { + if((px | py) & ~1023) { palette = 0; } else { px &= 1023; @@ -87,7 +87,7 @@ void PPU::render_line_mode7(uint8 pri0_pos, uint8 pri1_pos) { } } break; case 3: { //character 0 repetition outside of screen area - if(px < 0 || px > 1023 || py < 0 || py > 1023) { + if((px | py) & ~1023) { tile = 0; } else { px &= 1023; diff --git a/snes/alt/ppu-performance/background/background.cpp b/snes/alt/ppu-performance/background/background.cpp index 41603aa..9eb1f54 100644 --- a/snes/alt/ppu-performance/background/background.cpp +++ b/snes/alt/ppu-performance/background/background.cpp @@ -43,10 +43,10 @@ void PPU::Background::offset_per_tile(unsigned x, unsigned y, unsigned &hoffset, void PPU::Background::scanline() { if(self.vcounter() == 1) { mosaic_vcounter = regs.mosaic + 1; - y = 1; + mosaic_voffset = 1; } else if(--mosaic_vcounter == 0) { mosaic_vcounter = regs.mosaic + 1; - y += regs.mosaic + 1; + mosaic_voffset += regs.mosaic + 1; } if(self.regs.display_disable) return; @@ -93,7 +93,7 @@ void PPU::Background::render() { hscroll = regs.hoffset; vscroll = regs.voffset; - unsigned y = Background::y; + unsigned y = (regs.mosaic == 0 ? self.vcounter() : mosaic_voffset); if(hires) { hscroll <<= 1; if(self.regs.interlace) y = (y << 1) + self.field(); diff --git a/snes/alt/ppu-performance/background/background.hpp b/snes/alt/ppu-performance/background/background.hpp index b136738..38121a4 100644 --- a/snes/alt/ppu-performance/background/background.hpp +++ b/snes/alt/ppu-performance/background/background.hpp @@ -31,7 +31,6 @@ struct Background { const unsigned id; unsigned opt_valid_bit; - unsigned y; bool hires; signed width; @@ -48,6 +47,7 @@ struct Background { unsigned vscroll; unsigned mosaic_vcounter; + unsigned mosaic_voffset; LayerWindow window; diff --git a/snes/alt/ppu-performance/background/mode7.cpp b/snes/alt/ppu-performance/background/mode7.cpp index 026c4da..0f3c09c 100644 --- a/snes/alt/ppu-performance/background/mode7.cpp +++ b/snes/alt/ppu-performance/background/mode7.cpp @@ -49,7 +49,7 @@ void PPU::Background::render_mode7() { } case 2: { - if(px < 0 || px > 1023 || py < 0 || py > 1023) { + if((px | py) & ~1023) { palette = 0; } else { px &= 1023; @@ -63,7 +63,7 @@ void PPU::Background::render_mode7() { } case 3: { - if(px < 0 || px > 1023 || py < 0 || py > 1023) { + if((px | py) & ~1023) { tile = 0; } else { px &= 1023; diff --git a/snes/alt/ppu-performance/mmio/mmio.cpp b/snes/alt/ppu-performance/mmio/mmio.cpp index 4a796c5..ec0b689 100644 --- a/snes/alt/ppu-performance/mmio/mmio.cpp +++ b/snes/alt/ppu-performance/mmio/mmio.cpp @@ -283,7 +283,7 @@ void PPU::mmio_write(unsigned addr, uint8 data) { switch(addr & 0xffff) { case 0x2100: { //INIDISP - if(regs.display_disable && vcounter() == display.height) oam.address_reset(); + if(regs.display_disable && cpu.vcounter() == display.height) oam.address_reset(); regs.display_disable = data & 0x80; regs.display_brightness = data & 0x0f; return; diff --git a/snes/alt/ppu-performance/serialization.cpp b/snes/alt/ppu-performance/serialization.cpp index 90b182c..063f27e 100644 --- a/snes/alt/ppu-performance/serialization.cpp +++ b/snes/alt/ppu-performance/serialization.cpp @@ -115,7 +115,6 @@ void PPU::Background::serialize(serializer &s) { s.integer(regs.main_enable); s.integer(regs.sub_enable); - s.integer(y); s.integer(hires); s.integer(width); @@ -132,6 +131,7 @@ void PPU::Background::serialize(serializer &s) { s.integer(vscroll); s.integer(mosaic_vcounter); + s.integer(mosaic_voffset); window.serialize(s); } diff --git a/snes/chip/dsp1/dsp1emu.cpp b/snes/chip/dsp1/dsp1emu.cpp index f46f929..d161c5e 100644 --- a/snes/chip/dsp1/dsp1emu.cpp +++ b/snes/chip/dsp1/dsp1emu.cpp @@ -17,9 +17,11 @@ Dsp1::Dsp1() uint8 Dsp1::getSr() { mSrLowByteAccess = ~mSrLowByteAccess; - if (mSrLowByteAccess) - return 0; - else +//Overload: only high 8-bits are accessible externally +//this is required for "Ace wo Nerae!" +// if (mSrLowByteAccess) +// return 0; +// else return mSr; } diff --git a/snes/cpu/cpu.hpp b/snes/cpu/cpu.hpp index 4389d38..e41b50b 100644 --- a/snes/cpu/cpu.hpp +++ b/snes/cpu/cpu.hpp @@ -100,8 +100,8 @@ private: uint8 wrdivb; //$4207-$420a - uint10 hirq_pos; - uint10 virq_pos; + uint9 hirq_pos; + uint9 virq_pos; //$420d unsigned rom_speed; diff --git a/snes/libsnes/libsnes.cpp b/snes/libsnes/libsnes.cpp index 359c8d4..5160600 100644 --- a/snes/libsnes/libsnes.cpp +++ b/snes/libsnes/libsnes.cpp @@ -38,7 +38,7 @@ unsigned snes_library_revision_major(void) { } unsigned snes_library_revision_minor(void) { - return 0; + return 1; } void snes_set_video_refresh(snes_video_refresh_t video_refresh) { @@ -61,6 +61,10 @@ void snes_set_controller_port_device(bool port, unsigned device) { SNES::input.port_set_device(port, (SNES::Input::Device::e)device); } +void snes_set_cartridge_basename(const char *basename) { + SNES::cartridge.basename = basename; +} + void snes_init(void) { SNES::system.init(&interface); SNES::input.port_set_device(0, SNES::Input::Device::Joypad); diff --git a/snes/libsnes/libsnes.hpp b/snes/libsnes/libsnes.hpp index 2eaee5d..a7f25a5 100644 --- a/snes/libsnes/libsnes.hpp +++ b/snes/libsnes/libsnes.hpp @@ -205,6 +205,7 @@ void snes_set_input_state(snes_input_state_t); it safe to call this method from inside the input state callback? */ void snes_set_controller_port_device(bool port, unsigned device); +void snes_set_cartridge_basename(const char *basename); // Initializes library void snes_init(void); diff --git a/snes/snes.hpp b/snes/snes.hpp index 0b893c4..4f43728 100644 --- a/snes/snes.hpp +++ b/snes/snes.hpp @@ -1,8 +1,8 @@ namespace SNES { namespace Info { static const char Name[] = "bsnes"; - static const char Version[] = "070"; - static const unsigned SerializerVersion = 13; + static const char Version[] = "072"; + static const unsigned SerializerVersion = 14; } } diff --git a/snes/system/system.cpp b/snes/system/system.cpp index 3e264aa..62be0ca 100644 --- a/snes/system/system.cpp +++ b/snes/system/system.cpp @@ -92,6 +92,9 @@ void System::init(Interface *interface_) { video.init(); audio.init(); input.init(); + + input.port_set_device(0, config.controller_port1.i); + input.port_set_device(1, config.controller_port2.i); } void System::term() { @@ -173,8 +176,6 @@ void System::power() { scheduler.init(); - input.port_set_device(0, config.controller_port1.i); - input.port_set_device(1, config.controller_port2.i); input.update(); //video.update(); }