issue with super mario bros sprite 0 xy, when reading $2007

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
infidelity
Posts: 339
Joined: Fri Mar 01, 2013 4:46 am

issue with super mario bros sprite 0 xy, when reading $2007

Post by infidelity » Fri Jul 03, 2020 5:48 am

Yup i'm at it again with needing assistance with timing, ugh. So here is what i'm doing. I need to read an attribute byte so i can ORA it, and stick it within the games vram buffer. My code works, the bits i need modified are done so correctly, but i keep forgetting how to handle $2005 when my routine is over. Here is the code.

Code: Select all

;at this point when my code starts, the scanline is between 93-95
BIT $2002
BPL #$FB ;back to $2002

;at this point now, the scanline has reached 241
LDA $05		;hi address for attribute
STA $2006
LDA $04		;lo address for attribute
STA $2006
LDA $2007		;dummy read 
LDA $2007		;read current byte within loaded attribute address
ORA $1A3		;take current value of A, and ORA it to the current byte in $1A3
STA $1A3		;now store the new A value back into $1A3, this is my new attribute value for later

;at this point i load the games xy registers to restore $2005
LDA $73F
STA $2005
LDA $740
STA $2005
RTS
So with that, the main screen looks ok, but the sprite 0 split (the hud/info bar at the top of the screen), it's xy fluctuates. I'm at a loss trying to figure out what i am missing? I appreciate any help please. Thanks everyone. :-)

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

Re: issue with super mario bros sprite 0 xy, when reading $2007

Post by Quietust » Fri Jul 03, 2020 6:14 am

At the very least, you need to write to $2000 again and set the bottom 2 bits to point at the expected "base" nametable.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

infidelity
Posts: 339
Joined: Fri Mar 01, 2013 4:46 am

Re: issue with super mario bros sprite 0 xy, when reading $2007

Post by infidelity » Fri Jul 03, 2020 6:33 am

i tried that, but it looks like sprite 0 dissapears, meaning the entire screen for a split second looks like the entire said NT, whether you are on $2000 or $2400. Not sure if my order of things happening is the issue?

infidelity
Posts: 339
Joined: Fri Mar 01, 2013 4:46 am

Re: issue with super mario bros sprite 0 xy, when reading $2007

Post by infidelity » Fri Jul 03, 2020 9:57 am

Here is an updated version of my code. I'm still getting an xy error within the info bar where sprite0 is. Is the order placements of my routines correct? What else am I missing?

Code: Select all

BIT $2002
BPL #$FB		;back to BIT $2002

;scanline at this point is 241
;this code is to allow more time to pass 
;so that the scanline can reach 247 lines.
;i picked this value because SMB does it's 
;writes to $2007 during that many scanlines
LDY #$90
DEY
BNE #$FD		;back to DEY

;scanline at this point is 247
LDA $2002
LDA $05		;hi byte for attribute address
STA $2006
LDA $04		;lo byte for attribute address
STA $2006
LDA $2007		;dummy read 
LDA $2007		;read current byte within loaded attribute address
ORA $1A3		;take current value of A, and ORA it to the current byte in $1A3
STA $1A3		;now store the new A value back into $1A3, this is my new attribute value for later

;at this point I reset $2006, 
;load the last known x,y values into $2005, 
;load the nametable and store to $2000
LDA #$00
STA $2006
STA $2006
LDA $73F
STA $2005
LDA $740
STA $2005
LDA $778
STA $2000
RTS
Im not getting the correct nametable and xy values within the sprite0 region, the main game screen is fine when on both nametables, it's just the info bar that's out of whack...

infidelity
Posts: 339
Joined: Fri Mar 01, 2013 4:46 am

Re: issue with super mario bros sprite 0 xy, when reading $2007

Post by infidelity » Sat Jul 04, 2020 3:22 am

Any help would be greatly appreciated! I'm at a dead end here. :-/

Post Reply