Jump to content
IGNORED

What does SBC $0F do in Haunted House?


Dan Piponi

Recommended Posts

In Haunted House I see this bit of code being executed (in both Stella and my own emulator):

 

F44E INY

F44F SBC $0F

F451 BCS F44E

 

That SBC is reading from address $0F. This is in TIA, but there is no readable register there. So what does this read? My own emulator returns zero and so the code hangs. But Stella seems to not hang. When I read the Stella source it looks like this returns (depending on settings) something randomised or what was left on the data bus from before (though I don't fully understand how something can linger on the data bus). As the last thing on the bus was (I think) the $0F of the SBC instruction, it ends up subtracting $0F. That seems pretty weird. Anyone know what's going on here?

 

Im the end I hard-coded a read from $0F to return $0F in my emulator and now I can play Haunted House in it.

--

Dan

Link to comment
Share on other sites

Interesting but yes the effect is substracting 15 from A register.

 

If you follow the code you'll see the result is used in a classic horizontal positioning routine for TIA display objects.

 

Most probable thing is that as TIA doesn't respond to reads in this direction, so the bus keeps the $0F floating in data bus (from last byte read of instruction) and it uses it to substract 15.

Link to comment
Share on other sites

Probably it's a bug. It's easy to miss the # it happened to my several times but with other code and the bugs are really hard to pinpoint :ponder:

 

We plan at some point to add checks for common problems like this to the Stella disassembler, so programmers can see common, but hard-to-find errors.

Link to comment
Share on other sites

 

We plan at some point to add checks for common problems like this to the Stella disassembler, so programmers can see common, but hard-to-find errors.

That's a pretty good idea :thumbsup: any chance it could handle bank switched labels? Or a tab to see each bank disassembly?

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.

Guest
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.

Loading...
  • Recently Browsing   0 members

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