Jump to content



0

Losing lives without trying


8 replies to this topic

#1 jbs30000 OFFLINE  

jbs30000

    Moonsweeper

  • 459 posts

Posted Fri Mar 21, 2008 4:57 PM

In a game I've pretty much completed, there's a part where the number of lives decreases even though I do not put lives=lives-32.

Has anybody else had this problem before or have any idea of what could be happening?

Any help is appreciated. Thank you.

#2 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,543 posts
  • Location:Georgia, USA

Posted Fri Mar 21, 2008 5:31 PM

View Postjbs30000, on Fri Mar 21, 2008 6:57 PM, said:

In a game I've pretty much completed, there's a part where the number of lives decreases even though I do not put lives=lives-32.

Has anybody else had this problem before or have any idea of what could be happening?

Any help is appreciated. Thank you.
In the standard kernel, I think "lives" is at $F3. So one possibility is that you may have too many nested subroutines, and the stack is interfering with the "lives" counter. You might want to run the program with the Stella debugger, and have the debugger halt whenever location $F3 changes, so you can see at what points in the program this is occurring.

Michael

#3 jbs30000 OFFLINE  

jbs30000

    Moonsweeper

  • 459 posts

Posted Fri Mar 21, 2008 6:11 PM

I'm not familiar with the Stella Debugger but I'll look it up. Thank you.
And yes, I do have a few. Maybe I'll see about adding more labels and changing the gosub's to goto's. Thank you again.

#4 Fort Apocalypse OFFLINE  

Fort Apocalypse

    Stargunner

  • 1,593 posts

Posted Fri Mar 21, 2008 8:38 PM

View Postjbs30000, on Fri Mar 21, 2008 8:11 PM, said:

I'm not familiar with the Stella Debugger but I'll look it up. Thank you.
And yes, I do have a few. Maybe I'll see about adding more labels and changing the gosub's to goto's. Thank you again.

Be careful if you do any gotos from within a subroutine (that you gosub'd to) that you call "pop" as many times as the subroutine is deep before calling goto from within a subroutine. Otherwise each time you do that puts the game within a less and less stable state - first shown by degradation of the pflives and then finally by just locking up (after a few times).

#5 Fort Apocalypse OFFLINE  

Fort Apocalypse

    Stargunner

  • 1,593 posts

Posted Fri Mar 21, 2008 8:41 PM

View PostFort Apocalypse, on Fri Mar 21, 2008 10:38 PM, said:

View Postjbs30000, on Fri Mar 21, 2008 8:11 PM, said:

I'm not familiar with the Stella Debugger but I'll look it up. Thank you.
And yes, I do have a few. Maybe I'll see about adding more labels and changing the gosub's to goto's. Thank you again.

Be careful if you do any gotos from within a subroutine (that you gosub'd to) that you call "pop" as many times as the subroutine is deep before calling goto from within a subroutine. Otherwise each time you do that puts the game within a less and less stable state - first shown by degradation of the pflives and then finally by just locking up (after a few times).

Also, I've noticed (see the ufo traffic game I wrote) that when using the lives icons, even without the goto from within subroutine without pop stuff, it doesn't act correctly. this may be because of the bB kernel I'm using (the latest development kernel posted to the bB bugs thread by Fred Quimby (batari) having some issue with lives that isn't in the "normal" last formally released version of bB. However, in other ways (like bgnd and pf row colors) the newer kernel is better. I haven't tested the lives thing with the older kernel tho.

#6 jbs30000 OFFLINE  

jbs30000

    Moonsweeper

  • 459 posts

Posted Fri Mar 21, 2008 8:45 PM

View PostFort Apocalypse, on Fri Mar 21, 2008 8:38 PM, said:

View Postjbs30000, on Fri Mar 21, 2008 8:11 PM, said:

I'm not familiar with the Stella Debugger but I'll look it up. Thank you.
And yes, I do have a few. Maybe I'll see about adding more labels and changing the gosub's to goto's. Thank you again.

Be careful if you do any gotos from within a subroutine (that you gosub'd to) that you call "pop" as many times as the subroutine is deep before calling goto from within a subroutine. Otherwise each time you do that puts the game within a less and less stable state - first shown by degradation of the pflives and then finally by just locking up (after a few times).
It seems weird that I'd need a pop before goto, but I'll remember that. Thank you.

#7 Fort Apocalypse OFFLINE  

Fort Apocalypse

    Stargunner

  • 1,593 posts

Posted Fri Mar 21, 2008 9:17 PM

It would help us to help you if you could post source, even if just the relevant part

#8 jbs30000 OFFLINE  

jbs30000

    Moonsweeper

  • 459 posts

Posted Fri Mar 21, 2008 10:52 PM

View PostFort Apocalypse, on Fri Mar 21, 2008 9:17 PM, said:

It would help us to help you if you could post source, even if just the relevant part
SeaGtGruff was right, I did have a few nested subroutines and changing a few to GOTOs did the trick. When I finish the program I will post the source along with the program.

#9 jbs30000 OFFLINE  

jbs30000

    Moonsweeper

  • 459 posts

Posted Tue Mar 25, 2008 2:19 AM

This post edited twice.
Using the Stella debugger, it turns out my lives getting messed up have to do with bank switching. Three asm commands that show when the breakpoint of $F3<32 is trigged is
LDA $D4
PHA
TXA

Now $D4 is Temp7 which is used in bank switching. Although I don't know why $D4 would interfere with $F3. And it doesn't do it all the time either, but when $F3 is less than 32 it seems that it has to do with $D4.

Edited by jbs30000, Tue Mar 25, 2008 2:53 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users