Jump to content
IGNORED

Really strange bug in my program.


Recommended Posts

So what it's supposed to do is move the player0 sprite when the player 0 fire button is pressed. However, it only works if I make it stop the player0 sprite when the button is pressed.

 

Go to line 84 which says lda #%01111111 and turn it into lda #%10000000. It messes up the program completely somehow.

 

 

I'm sorry for the horrible description of the bug. I'll post a much better explanation of the bug in the morning.

panto_gametest.asm

Link to comment
Share on other sites

Alright, good morning. So basically in the last two scanlines of the overscan, my program runs this:

checkfire:
	sta WSYNC
	lda #%01000010
	sta VBLANK
	lda #%01111111
	eor INPT4
	bmi fireisnotchecked
	sta WSYNC
	rts
fireisnotchecked:
	sta WSYNC
	ldy $80
	iny
	sty $80
	rts

What I was trying to do is make it so that the p0 sprite moves down when the fire button is pressed by player 0. This part of the code is what loads and stores the new Y position of the p0 sprite whenever the fire button is pressed.

 

 

However, it only works if I check if INPT4 is not held down. If I reverse

	lda #%01111111

to

	lda #%10000000

The program goes haywire and Stella tells me that the framerate is ranging from 300-400 FPS. When I debug with Stella the VBLANK area seems to start somewhere in the middle of where the program would be drawing the visible picture. How is it that this is causing such a massive problem?

 

 

 

 

Also, obviously I could have used

bit INPT4

instead of

lda #%01111111
eor INPT4

but I was trying to find if that one would work.

Link to comment
Share on other sites

I'd say that what is happening is that your $80 value is rapidly incremented' (there is no top limit) over multiple frames, and it gets to a large value (say 200+). Then, your loop to draw the sprite within the 192 line area is failing because the loop is based on the Y value, not the X value. In other words, it draws (say) 200+ scanlines and by that time x has decremented past zero too and it's now (say) 200 as well for the latter part of the screen draw after the sprite, and so that loop (unused lines) will ALSO draw another 200+ scanlines. So I'd say that's what's probably going wrong. :)

Link to comment
Share on other sites

I'd say that what is happening is that your $80 value is rapidly incremented' (there is no top limit) over multiple frames, and it gets to a large value (say 200+). Then, your loop to draw the sprite within the 192 line area is failing because the loop is based on the Y value, not the X value. In other words, it draws (say) 200+ scanlines and by that time x has decremented past zero too and it's now (say) 200 as well for the latter part of the screen draw after the sprite, and so that loop (unused lines) will ALSO draw another 200+ scanlines. So I'd say that's what's probably going wrong. :)

 

I found out the problem after reading this. Apparently the loop to draw the sprite cannot handle if the y position is 0 which caused the program to go haywire. So now it doesn't go under 1.

Link to comment
Share on other sites

Your analasis is, I am pretty sure, wrong. Yes, when it's 0 it will do what you say. It will ALSO fail when Y is (say) 255. Because it will loop 255 times (instead of 256 when it's 0). When Y is 200, it will loop 200 times. The error is in the code at 'fireisnotchecked' where $80 is incremented without a check on the upper bound. It can go right up to 200... 250... and then to 0. You asked for an analysis; I gave it. Pay close attention to what I've pointed out is the problem, because unless I'm badly misunderstanding what your code is doing, then the same problem is going to come back and bite you. You appear to have fixed the symptom, not the problem.

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