Jump to content
IGNORED

score corruption (playerscores minikernel)


Karl G

Recommended Posts

Oh great and wise Atari developers, I humbly seek your help with a strange mystery I am seeing with a game I am creating. This is my first project, and it is only partially done, and some of the code needs to be reworked. Right now, I just need help with a strange issue where part of the score gets corrupted when I am in my SubServeBall subroutine, and only after the first point is scored. When this sub is called before the main loop for the first time, it works fine. Further, after the ball has been served (exiting the SubServeBall sub), the score is back to normal. I am only using two levels of nested gosubs, so I don't think it's related to stack corruption for that reason at least.



I don't suppose anyone has any thoughts or advice? The game is a paddle air hockey game, and two-player only for now (although the second paddle isn't needed to see the problem occur - just one point needs to be scored by either player).



I am attaching my code plus the playerscores.asm mini kernel that I am using.



Thanks in advance for any advice!



post-48311-0-62550100-1478190889_thumb.png



airhockey.bas



playerscores.asm


Link to comment
Share on other sites

How do you handle a block of code that is called from more than one place, in that case? Or do you have to duplicate code to avoid that case?

 

I've managed to avoid doing so as a side effect of not using gosubs. The only gosubs I use are blocks of code outside the main loop.

 

Sometimes there is code duplication. But, yeah.

Link to comment
Share on other sites

SubMainLoop is a goto loop instead of gosub. However, I tried calling SubServeBall from the main loop instead, and it fixed the problem. Color me surprised, though.

 

oops you're right I misread it

 

 

however you use on-gosub in SubPlayerScore and on-gosub uses two

 

it's not hard to rig an equivalent to on-gosub that doesn't use two but it needs a dab of asm and it's a little uglier code wise

 

 

for your problem you could probably go into the minikernel and give it a different variable than the stack location it uses

 

 

edit:

it looks like the minikernel uses four bytes of stack and you've only got ten

drawscreen uses four at least (with the call to the minikernel)

sounds like when your code works it's using six

so the way I'm figuring it doesn't add up

hmm

Edited by bogax
Link to comment
Share on other sites

 

oops you're right I misread it

 

 

however you use on-gosub in SubPlayerScore and on-gosub uses two

 

it's not hard to rig an equivalent to on-gosub that doesn't use two but it needs a dab of asm and it's a little uglier code wise

 

 

for your problem you could probably go into the minikernel and give it a different variable than the stack location it uses

 

 

edit:

it looks like the minikernel uses four bytes of stack and you've only got ten

drawscreen uses four at least (with the call to the minikernel)

sounds like when your code works it's using six

so the way I'm figuring it doesn't add up

hmm

 

Using a different variable for that digit sounds like a good solution. Any suggestions on what to use instead of stack1? I use "a" as a temp variable in my program, so I could use that one, but I don't know the names of those variables in assembly. I tried "a", but it didn't work.

 

Edit: Probably learning assembly is a good idea for me in the longer term, anyway, since I really only need one digit, not two, anyway, which would free up two variables if I could figure out how to hack this minikernel appropriately.

Edited by kdgarris
Link to comment
Share on other sites

your temp variable has to be persistent across drawscreens so I don't think that will work

 

if you go into the minkernel and change temp1digit2 = stack1 to, say, temp1digit2 = z

it seems to work

 

the minikernel its self uses one stack slot so drawscreen + minikernel must be three

that is, one for the call to drawscreen one for drawscreens call to the minikernel and one internal to the minikernel

 

 

edit

it looks to me like the jsr in the minikernel is unneccesary so it could probably be removed (with some other modifications to the minikernel)

 

 

more edit

 

here I commented some stuff out and moved things around a bit

I commented out the four scores stuff and removed the jsr

I changed the scores so they use the score variables instead of stack space

I used z for temp1digit2 but you could probably use something else

you can see if it works for you I didn't test it much

 

 

even more edit

updated to use scorepointers for the temp1digit2 score pointer (instead of z, see below)

playerscores_mod.asm

Edited by bogax
Link to comment
Share on other sites

I got corruption of the second digit right away with this version. However, I see the same thing with the unmodified version when I change temp1digit2 to z, so it's not your changes that caused that to happen. Oddly, changing temp1digit2 to y instead fixes it. So, for my purposes my issue is solved, but it's maddening not knowing why that would make a difference.

 

Anyway, thanks for all of your help!

Link to comment
Share on other sites

oh hell

 

it is my changes

 

temp1digit2 is a 16 bit pointer so it needs two (consecutive) bytes

if you specify y it will use y and z

 

specify z and in the version of bB that I'm using it'll use z and aux1

 

if you're using RevEng's latest and greatest I think he changed that

 

edit

since its an alternative to the normal score the logical thing is probably to use the scorepointers

so it would be temp1digit2 = scorepointers

but I haven't tested that

Edited by bogax
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...