+Karl G Posted May 22, 2023 Share Posted May 22, 2023 I've noticed a strange issue with my unreleased game (Penult) where it will crash about 1/4 of the time when developer settings are enabled, specifically when SP is randomized. If SP is not randomized, then it never happens, and none of the other developer settings seem to affect this one way or another. What is strange about it is that I use the CLEAN_START macro almost immediately upon start, which should set this to $FF, so a random SP shouldn't make a difference. It still happens when I changed it to do CLEAN_START as the first operation, and also when I explicitly do a LDX #$FF followed by TXS even before the CLEAN_START macro. I've only noticed this happening since I've gotten my new laptop, and I can reproduce it with Stella 6.6 and 6.7 under Linux. I never noticed it when using my now-dead MacBook, and I don't recall what version of Stella I had installed there. Anyway, it seems to happen also with the public demo of the game found here. This is a 128K DFSC ROM. Any ideas as to what might be going on? Quote Link to comment Share on other sites More sharing options...
+ZeroPage Homebrew Posted May 22, 2023 Share Posted May 22, 2023 Just tried the latest public demo (20220819) of Penult with Stella 6.7 and can confirm that the immediate crashing happens to me as well at about the same 1 out of 4 frequency upon starting the game. - James 1 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted May 23, 2023 Share Posted May 23, 2023 The code uses the stack pointer before it is in initialized. And when the SP points below $80, the game will crash. Lffb8 pha tya pha lda Lffc0,x rts 1 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted May 23, 2023 Author Share Posted May 23, 2023 4 hours ago, Thomas Jentzsch said: The code uses the stack pointer before it is in initialized. And when the SP points below $80, the game will crash. Lffb8 pha tya pha lda Lffc0,x rts Thank you. That does make sense, but I'm not sure how I should avoid that? This is my bankswitching code that gets triggered if the game gets started in any bank other than the desired startup bank. I'm pretty sure I got this method from a template. Do you have any suggestions on how to better handle this? Do I just need to expand my startup code in every bank to set the SP first thing before doing my bank switch? It's strange that I didn't run into this issue previously. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted May 23, 2023 Share Posted May 23, 2023 13 minutes ago, Karl G said: Do you have any suggestions on how to better handle this? Do I just need to expand my startup code in every bank to set the SP first thing before doing my bank switch? Either use a different template which avoids the stack (e.g. using jmp.ind instead) or set the SP to a valid value before using the current one. 13 minutes ago, Karl G said: It's strange that I didn't run into this issue previously. Did you always use developer settings? 1 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted May 23, 2023 Author Share Posted May 23, 2023 29 minutes ago, Thomas Jentzsch said: Did you always use developer settings? Yes. And they have helped me ferret out many other issues in my code. That's what's strange about it. Maybe I accidentally had "randomize SP" unchecked, though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.