Sprite 0 Bug

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
St_grld
Posts: 3
Joined: Sun Sep 23, 2018 1:33 pm

Sprite 0 Bug

Post by St_grld » Sun Sep 23, 2018 1:48 pm

So, I just got done rewriting my code, so that it could fix a few problems with the code (mainly adding stuff to the NMI), until I got to a section where it uses a sprite 0 split, instead of splitting the screen like it did before so it could show a dialogue box and the background, it's now pushing down the background, so it can display the box. It's a little hard to explain, so here's a drawing of it:

Background:
\\\\\\\\\\\\\\\\\\\\\\\\\\\
\ _________________\
\ _________________\
\ _________________\
\ _________________\
\ _________________\
\ _________________\
\ _________________\
\\\\\\\\\\\\\\\\\\\\\\\\\\\

Before with the box:
---------------------------
|__________________|
|__________________|
---------------------------
\ _________________\
\ _________________\
\ _________________\
\ _________________\
\\\\\\\\\\\\\\\\\\\\\\\\\\\

Now with the box:

---------------------------
|__________________|
|__________________|
---------------------------
\\\\\\\\\\\\\\\\\\\\\\\\\\\
\ _________________\
\ _________________\
\ _________________\
\ _________________\

I hope you guys understand what I mean

User avatar
pubby
Posts: 548
Joined: Thu Mar 31, 2016 11:15 am

Re: Sprite 0 Bug

Post by pubby » Sun Sep 23, 2018 2:01 pm

It looks like you're setting the Y-scroll to 0 at the sprite 0 hit. That's not what you want. Set the scroll to the background position you want to see.

St_grld
Posts: 3
Joined: Sun Sep 23, 2018 1:33 pm

Re: Sprite 0 Bug

Post by St_grld » Sun Sep 23, 2018 3:43 pm

That only seems to move the box around, which is not what I meant (unless I'm doing it wrong).
Attachments
Here is how it looks.
Here is how it looks.
And here's how it should look, and how it looked before.
And here's how it should look, and how it looked before.

User avatar
Quietust
Posts: 1492
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Sprite 0 Bug

Post by Quietust » Sun Sep 23, 2018 4:50 pm

It would help to explain exactly what your code is doing - from your description, I can only assume that you're doing a pair of writes to $2006 to point the VRAM address at the beginning of a nametable and then trying to set X/Y scroll using $2005, something which will not work because vertical scroll only updates once per frame (unless you use special tricks, like those described on the PPU scrolling wiki page).
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
tokumaru
Posts: 11466
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Sprite 0 Bug

Post by tokumaru » Sun Sep 23, 2018 5:19 pm

It would really help if you could show us what the code around the sprite 0 hit detection looks like.

St_grld
Posts: 3
Joined: Sun Sep 23, 2018 1:33 pm

Re: Sprite 0 Bug

Post by St_grld » Sun Sep 23, 2018 5:24 pm

Thanks! It works now!
I've removed the $2006 writes and that was the problem! :D

Here's how it was

Code: Select all

NMI
	lda #$00
	sta $2006
	sta $2006	
	sta $2005
	sta $2005	

;other NMI stuff        

sprite0
	lda #$40
.waitnospr0
	bit $2002
	bvs .waitnospr0
.waitspr0
	bit $2002
	bvc .waitspr0	
	ldx #$00
.waitscan
	inx
	cpx #$78
	bne .waitscan
	ldx #$00
	lda #$00
	sta $2006
	sta $2006	
	lda scrollh
	sta $2005
	lda scrollv
	sta $2005	
	rts

Post Reply