diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index 101d1c79dd..11effbd27f 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -11,7 +11,7 @@ using System.Runtime.InteropServices; namespace BizHawk.Emulation.Cores.WonderSwan { - [CoreAttributes("Cygne/Mednafen", "Dox", true, true, "0.9.34.1", "http://mednafen.sourceforge.net/")] + [CoreAttributes("Cygne/Mednafen", "Dox", true, true, "0.9.36.5", "http://mednafen.sourceforge.net/")] public class WonderSwan : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, IDebuggable, ISettable { diff --git a/output/dll/bizswan.dll b/output/dll/bizswan.dll index 45bbcb3671..a696b5bbd2 100644 Binary files a/output/dll/bizswan.dll and b/output/dll/bizswan.dll differ diff --git a/wonderswan/interrupt.cpp b/wonderswan/interrupt.cpp index d88dd53871..92cd8e05b0 100644 --- a/wonderswan/interrupt.cpp +++ b/wonderswan/interrupt.cpp @@ -5,13 +5,15 @@ namespace MDFN_IEN_WSWAN { void Interrupt::Recalc() { - IOn_Cache = FALSE; + IStatus |= (IAsserted & LevelTriggeredMask) & IEnable; + + IOn_Cache = false; IOn_Which = 0; IVector_Cache = 0; for(int i = 0; i < 8; i++) { - if(IStatus & IEnable & (1 << i)) + if(IStatus & IEnable & (1U << i)) { IOn_Cache = TRUE; IOn_Which = i; @@ -21,17 +23,21 @@ namespace MDFN_IEN_WSWAN } } - void Interrupt::DebugForce(unsigned int level) + void Interrupt::AssertInterrupt(unsigned which, bool asserted) + { + const uint8 prev_IAsserted = IAsserted; + + IAsserted &= ~(1U << which); + IAsserted |= (unsigned)asserted << which; + + IStatus |= ((prev_IAsserted ^ IAsserted) & IAsserted) & IEnable; + + Recalc(); + } + + void Interrupt::DoInterrupt(unsigned which) { - sys->cpu.interrupt((IVectorBase + level) * 4, TRUE); - } - - void Interrupt::DoInterrupt(int which) - { - if(IEnable & (1 << which)) - IStatus |= 1 << which; - - //printf("Interrupt: %d\n", which); + IStatus |= (1U << which) & IEnable; Recalc(); } @@ -42,7 +48,7 @@ namespace MDFN_IEN_WSWAN { case 0xB0: IVectorBase = V; Recalc(); break; case 0xB2: IEnable = V; IStatus &= IEnable; Recalc(); break; - case 0xB6: /*printf("IStatus: %02x\n", V);*/ IStatus &= ~V; Recalc(); break; + case 0xB6: IStatus &= ~V; Recalc(); break; } } @@ -68,6 +74,7 @@ namespace MDFN_IEN_WSWAN void Interrupt::Reset() { + IAsserted = 0x00; IEnable = 0x00; IStatus = 0x00; IVectorBase = 0x00; @@ -76,6 +83,7 @@ namespace MDFN_IEN_WSWAN SYNCFUNC(Interrupt) { + NSS(IAsserted); NSS(IStatus); NSS(IEnable); NSS(IVectorBase); diff --git a/wonderswan/interrupt.h b/wonderswan/interrupt.h index 429fa93df2..2a76cc1636 100644 --- a/wonderswan/interrupt.h +++ b/wonderswan/interrupt.h @@ -5,30 +5,30 @@ namespace MDFN_IEN_WSWAN { - enum { - WSINT_SERIAL_SEND = 0, - WSINT_KEY_PRESS, - WSINT_RTC_ALARM, - WSINT_SERIAL_RECV, - WSINT_LINE_HIT, - WSINT_VBLANK_TIMER, - WSINT_VBLANK, - WSINT_HBLANK_TIMER + WSINT_SERIAL_SEND = 0, + WSINT_KEY_PRESS, + WSINT_RTC_ALARM, + WSINT_SERIAL_RECV, + WSINT_LINE_HIT, + WSINT_VBLANK_TIMER, + WSINT_VBLANK, + WSINT_HBLANK_TIMER }; class Interrupt { public: - void DoInterrupt(int); + void DoInterrupt(unsigned); + void AssertInterrupt(unsigned which, bool asserted); void Write(uint32 A, uint8 V); uint8 Read(uint32 A); void Check(); void Reset(); - void DebugForce(unsigned int level); private: + uint8 IAsserted; uint8 IStatus; uint8 IEnable; uint8 IVectorBase; @@ -37,6 +37,8 @@ private: uint32 IOn_Which; uint32 IVector_Cache; + static const uint8 LevelTriggeredMask = (1U << WSINT_SERIAL_RECV); + private: void Recalc(); public: diff --git a/wonderswan/rtc.cpp b/wonderswan/rtc.cpp index aa56a23bb2..2da6d9c5e8 100644 --- a/wonderswan/rtc.cpp +++ b/wonderswan/rtc.cpp @@ -23,6 +23,9 @@ namespace MDFN_IEN_WSWAN { + // TODO: replace all use of libc time functions with internal stuff for movie recording + // (when userealtime == true, OK to use libc stuff) + static void GMTime(uint64 ticks, tm &time) { time_t t = ticks; diff --git a/wonderswan/sound.cpp b/wonderswan/sound.cpp index db43ea5126..db65ec006d 100644 --- a/wonderswan/sound.cpp +++ b/wonderswan/sound.cpp @@ -15,12 +15,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* -Noise emulation is almost certainly wrong wrong wrong. Testing on a real system is needed to determine LFSR(assuming it uses an LFSR) taps. -*/ - #include "system.h" - #include @@ -134,12 +129,9 @@ namespace MDFN_IEN_WSWAN period_counter[ch] -= run_time; while(period_counter[ch] <= 0) { - // Yay, random numbers, so let's use totally wrong numbers to make them! - const int bstab1[8] = { 14, 13, 12, 14, 12, 13, 14, 14 }; - const int bstab2[8] = { 13, 12, 9, 12, 1, 1, 5, 11 }; - //const int bstab1[8] = { 14, 13, 12, 14, 10, 9, 8, 13 }; - //const int bstab2[8] = { 13, 12, 9, 12, 1, 6, 4, 11 }; - nreg = (~((nreg << 1) | ( ((nreg >> bstab1[noise_control & 0x7]) & 1) ^ ((nreg >> bstab2[noise_control & 0x7]) & 1)))) & 0x7FFF; + static const uint8 stab[8] = { 14, 10, 13, 4, 8, 6, 9, 11 }; + nreg = ((nreg << 1) | ((1 ^ (nreg >> 7) ^ (nreg >> stab[noise_control & 0x7])) & 1)) & 0x7FFF; + if(control & 0x80) { MK_SAMPLE_CACHE_NOISE; @@ -213,20 +205,23 @@ namespace MDFN_IEN_WSWAN } else if(A == 0x8E) { - noise_control = V; - if(V & 0x8) nreg = 1; + if(V & 0x8) + nreg = 0; + noise_control = V & 0x17; //printf("NOISECONTROL: %02x\n", V); } else if(A == 0x90) { for(int n = 0; n < 4; n++) + { if(!(control & (1 << n)) && (V & (1 << n))) { period_counter[n] = 0; sample_pos[n] = 0x1F; } - control = V; - //printf("Sound Control: %02x\n", V); + } + control = V; + //printf("Sound Control: %02x\n", V); } else if(A == 0x91) { @@ -366,7 +361,7 @@ namespace MDFN_IEN_WSWAN SampleRAMPos = 0; std::memset(period_counter, 0, sizeof(period_counter)); std::memset(sample_pos, 0, sizeof(sample_pos)); - nreg = 1; + nreg = 0; std::memset(sample_cache, 0, sizeof(sample_cache)); std::memset(last_val, 0, sizeof(last_val)); diff --git a/wonderswan/start.inc b/wonderswan/start.inc index c2d6d3daea..8a6da32f9f 100644 --- a/wonderswan/start.inc +++ b/wonderswan/start.inc @@ -304,13 +304,19 @@ static const DLEntry Developers[] = { 0x1F, "Emotion" }, // Bandai Visual?? { 0x20, "Athena" }, { 0x21, "KID" }, + { 0x22, "HAL" }, + { 0x23, "Yuki-Enterprise" }, { 0x24, "Omega Micott" }, { 0x25, "Upstar" }, { 0x26, "Kadokawa/Megas" }, { 0x27, "Cocktail Soft" }, { 0x28, "Squaresoft" }, + { 0x2A, "NTT DoCoMo" }, { 0x2B, "TomCreate" }, { 0x2D, "Namco" }, { 0x2F, "Gust" }, + { 0x31, "Vanguard" }, // or Elorg? + { 0x32, "Megatron" }, + { 0x33, "WiZ" }, { 0x36, "Capcom" }, }; diff --git a/wonderswan/system.cpp b/wonderswan/system.cpp index 01ad02322c..2af8b6c70c 100644 --- a/wonderswan/system.cpp +++ b/wonderswan/system.cpp @@ -153,10 +153,11 @@ namespace MDFN_IEN_WSWAN switch(header[5]) { - case 0x01: memory.sram_size = 8*1024; break; - case 0x02: memory.sram_size = 32*1024; break; - case 0x03: memory.sram_size = 16 * 65536; break; - case 0x04: memory.sram_size = 32 * 65536; break; // Dicing Knight! + case 0x01: memory.sram_size = 8 * 1024; break; + case 0x02: memory.sram_size = 32 * 1024; break; + case 0x03: memory.sram_size = 128 * 1024; break; // Taikyoku Igo. Maybe it should only be 65536 bytes? + case 0x04: memory.sram_size = 256 * 1024; break; // Dicing Knight, Judgement Silversword + case 0x05: memory.sram_size = 512 * 1024; break; // Wonder Gate case 0x10: eeprom.eeprom_size = 128; break; case 0x20: eeprom.eeprom_size = 2*1024; break;