diff --git a/BizHawk.Client.Common/movie/MnemonicsGenerator.cs b/BizHawk.Client.Common/movie/MnemonicsGenerator.cs index 835e2ce1d5..2ae68342b5 100644 --- a/BizHawk.Client.Common/movie/MnemonicsGenerator.cs +++ b/BizHawk.Client.Common/movie/MnemonicsGenerator.cs @@ -76,7 +76,7 @@ namespace BizHawk.Client.Common case "SAT": return "|.|.............|.............|"; case "WSWAN": - return "|....|....|...|"; + return "|....|....|.....|"; } } } diff --git a/BizHawk.Client.Common/movie/MovieMnemonics.cs b/BizHawk.Client.Common/movie/MovieMnemonics.cs index bcb24ea9ac..d0d44c77f5 100644 --- a/BizHawk.Client.Common/movie/MovieMnemonics.cs +++ b/BizHawk.Client.Common/movie/MovieMnemonics.cs @@ -211,6 +211,7 @@ namespace BizHawk.Client.Common new Tuple("B", 'B'), new Tuple("A", 'A'), new Tuple("Power", 'P'), + new Tuple("Rotate", 'R'), new Tuple(null, '|'), }; } diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs index c20643ac99..e9fee26375 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs @@ -42,9 +42,10 @@ namespace BizHawk.Emulation.Cores.WonderSwan /// uint32 video output buffer /// int16 sound output buffer /// [In] max hold size of soundbuff [Out] number of samples actually deposited + /// (out) true if the screen is rotated left 90 /// true if lagged [DllImport(dd, CallingConvention = cc)] - public static extern bool bizswan_advance(IntPtr core, Buttons buttons, bool novideo, int[] surface, short[] soundbuff, ref int soundbuffsize); + public static extern bool bizswan_advance(IntPtr core, Buttons buttons, bool novideo, int[] surface, short[] soundbuff, ref int soundbuffsize, ref bool IsRotated); /// /// load rom @@ -170,6 +171,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan Start = 0x0100, A = 0x0200, B = 0x0400, + Rotate = 0x8000, } public enum Language : uint diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index bee8490f59..00267f278f 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan public static readonly ControllerDefinition WonderSwanController = new ControllerDefinition { Name = "WonderSwan Controller", - BoolButtons = { "Up X", "Down X", "Left X", "Right X", "Up Y", "Down Y", "Left Y", "Right Y", "Start", "B", "A", "Power" } + BoolButtons = { "Up X", "Down X", "Left X", "Right X", "Up Y", "Down Y", "Left Y", "Right Y", "Start", "B", "A", "Power", "Rotate" } }; public ControllerDefinition ControllerDefinition { get { return WonderSwanController; } } public IController Controller { get; set; } @@ -38,6 +38,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan if (Controller["Start"]) ret |= BizSwan.Buttons.Start; if (Controller["B"]) ret |= BizSwan.Buttons.B; if (Controller["A"]) ret |= BizSwan.Buttons.A; + if (Controller["Rotate"]) ret |= BizSwan.Buttons.Rotate; return ret; } @@ -103,11 +104,13 @@ namespace BizHawk.Emulation.Cores.WonderSwan if (Controller["Power"]) BizSwan.bizswan_reset(Core); + bool rotate = false; int soundbuffsize = sbuff.Length; - IsLagFrame = BizSwan.bizswan_advance(Core, GetButtons(), !render, vbuff, sbuff, ref soundbuffsize); + IsLagFrame = BizSwan.bizswan_advance(Core, GetButtons(), !render, vbuff, sbuff, ref soundbuffsize, ref rotate); if (soundbuffsize == sbuff.Length) throw new Exception(); sbuffcontains = soundbuffsize; + InitVideo(rotate); if (IsLagFrame) LagCount++; diff --git a/output/dll/bizswan.dll b/output/dll/bizswan.dll index a45545bccc..dcbd9d7842 100644 Binary files a/output/dll/bizswan.dll and b/output/dll/bizswan.dll differ diff --git a/wonderswan/system.cpp b/wonderswan/system.cpp index e87d24b854..c88e99c51c 100644 --- a/wonderswan/system.cpp +++ b/wonderswan/system.cpp @@ -80,6 +80,10 @@ namespace MDFN_IEN_WSWAN bool System::Advance(uint16 buttons, bool novideo, uint32 *surface, int16 *soundbuff, int &soundbuffsize) { + // we hijack the top bit of the buttons input and use it as a positive edge sensitive toggle to the rotate input + rotate ^= (buttons & 0x8000) > (oldbuttons & 0x8000); + oldbuttons = buttons; + memory.WSButtonStatus = rotate ? RotateButtons(buttons) : buttons; memory.Lagged = true; while (!gfx.ExecuteLine(surface, novideo)) @@ -306,6 +310,7 @@ namespace MDFN_IEN_WSWAN SSS(interrupt); NSS(rotate); + NSS(oldbuttons); } void System::SaveRamClearHacky(const SyncSettings &s) @@ -330,9 +335,11 @@ namespace MDFN_IEN_WSWAN s->Reset(); } - EXPORT int bizswan_advance(System *s, uint16 buttons, bool novideo, uint32 *surface, int16 *soundbuff, int *soundbuffsize) + EXPORT int bizswan_advance(System *s, uint16 buttons, bool novideo, uint32 *surface, int16 *soundbuff, int *soundbuffsize, int *IsRotated) { - return s->Advance(buttons, novideo, surface, soundbuff, *soundbuffsize); + int ret = s->Advance(buttons, novideo, surface, soundbuff, *soundbuffsize); + *IsRotated = s->rotate; + return ret; } EXPORT int bizswan_load(System *s, const uint8 *data, int length, const SyncSettings *settings, int *IsRotated) diff --git a/wonderswan/system.h b/wonderswan/system.h index 875d926f53..fb92d91bfe 100644 --- a/wonderswan/system.h +++ b/wonderswan/system.h @@ -57,6 +57,7 @@ public: Interrupt interrupt; bool rotate; // rotate screen and controls left 90 + uint16 oldbuttons; templatevoid SyncState(NewState *ns); };