Jump to content

80 - 1 = 73, why?


Recommended Posts


  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! 



Link to comment
Share on other sites

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 by hzaccheo
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...