hzaccheo Posted November 1, 2023 Share Posted November 1, 2023 Hello! I giving my first steps with the ultimate goal of creating a game. While I was debugging my code, I found this unexplainable (for me) behaviour: with the accumulator containing 80, SBC #1 sets it to 73, please see attached before-and-after screenshots for details. It doesn't happen in every execution of the game, sometimes it runs correctly, and sometimes I consistently get this. I am sure I am missing something but I have no idea what, could someone please explain it? Thanks for reading! Quote Link to comment Share on other sites More sharing options...
RevEng Posted November 1, 2023 Share Posted November 1, 2023 You've left decimal mode switched on somewhere. A starts off as $50, and after subtracting one, A becomes $49. That's normal decimal mode behaviour. 2 Quote Link to comment Share on other sites More sharing options...
hzaccheo Posted November 1, 2023 Author Share Posted November 1, 2023 (edited) Thank you very much for your help! It was indeed the decimal mode, I somehow didn't notice the flag when I took the screenshots. I am not explicitly enabling it but adding a CLD at the beginning of the program fixed the problem. I read here https://www.atariarchives.org/2bml/chapter_10.php that the D flag is not necessary cleared at start so I presume it is good practice to do it. Edited November 1, 2023 by hzaccheo Quote Link to comment Share on other sites More sharing options...
RevEng Posted November 1, 2023 Share Posted November 1, 2023 You're totally welcome! Various aspects of the 6502 aren't supposed to be reliable on power-up, so Stella is probably emulating that. Best practise is to initialise the cpu, console ram, cart-based ram (if present), and allow for power-up with any bank active. (if using bankswitching) Sometimes people will skip one or more of those, observing that it works fine on their hardware, but if you do that and your game endures, it will eventually become a headache for someone. 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.