openswe1r icon indicating copy to clipboard operation
openswe1r copied to clipboard

Video settings are not saved

Open JayFoxRox opened this issue 6 years ago • 2 comments

When quitting after changing video settings; then restarting the game, the previous video settings are not restored. Instead, they are returned to the initial state they were before making any changes.

This probably happens because of crashes while exiting the game:

Unknown function!

Stack at 0xC07FFE78; returning EAX: 0x0DDE1000
 463142 Emulation at 484A17 ('IA3dListener__2') from 484A17

openswe1r: /home/fox/Data/Projects/OpenSWE1R/main.c:3682: UnknownImport: Assertion `false' failed.

The video config might not have been written at this point.

JayFoxRox avatar May 25 '18 23:05 JayFoxRox

IA3dListener__2 is IA3dListener::Release, and IA3d4__2 is IA3d4::Release. I think it may use the stub to avoid the assert(false).

diff --git a/com/a3d.c b/com/a3d.c
index 5cdf154..375581e 100644
--- a/com/a3d.c
+++ b/com/a3d.c
@@ -232,6 +232,13 @@ HACKY_COM_BEGIN(IA3d4, 0)
   esp += 3 * 4;
 HACKY_COM_END()
 
+// IA3d4 -> STDMETHOD_(ULONG,Release)       (THIS) PURE; //2
+HACKY_COM_BEGIN(IA3d4, 2)
+  hacky_printf("p 0x%" PRIX32 "\n", stack[1]);
+  eax = 0; // FIXME: No idea what this expects to return..
+  esp += 1 * 4;
+HACKY_COM_END()
+
 // IA3d4 -> STDMETHOD(GetHardwareCaps)                         (THIS_ LPA3DCAPS_HARDWARE) PURE; // 11
 HACKY_COM_BEGIN(IA3d4, 11)
   hacky_printf("GetHardwareCaps\n");
@@ -666,6 +673,13 @@ HACKY_COM_END()
 
 
 
+// IA3dListener -> STDMETHOD_(ULONG,Release)       (THIS) PURE; //2
+HACKY_COM_BEGIN(IA3dListener, 2)
+  hacky_printf("p 0x%" PRIX32 "\n", stack[1]);
+  eax = 0; // FIXME: No idea what this expects to return..
+  esp += 1 * 4;
+HACKY_COM_END()
+
 // IA3dListener -> STDMETHOD(SetPosition3f)            (THIS_ A3DVAL, A3DVAL, A3DVAL) PURE; // 3
 HACKY_COM_BEGIN(IA3dListener, 3)
   hacky_printf("SetPosition3f\n");

firodj avatar Aug 26 '18 03:08 firodj

If you want to submit changes, please send a PR. For something minor like this I'll probably just hit merge. Review of existing PRs by other people is also welcome.

Note that there's also a WIP branch which includes this fix: https://github.com/JayFoxRox/openswe1r/pull/16 However, I don't have time or motivation for coding, reviewing or testing larger changes for OpenSWE1R right now.

JayFoxRox avatar Aug 26 '18 11:08 JayFoxRox