I am working on a little project to enter text into variables and then use that variable to generate custom text later in the game. Rather than make different topics for every issue, I thought I would make one topic if that is OK?
I am using a cursor to select letters kind of like a name entry screen at the start of an RPG or something. I map the cursor to where I want it using this code which works fine. See spriteselect.nes
However I want to change the vertical / horizontal values to variable so I can track my cursor sprites location and make sure it doesnt go out of bounds.
So I declare 2 variable, store the values I want in the variable and use the variable to write to the screen like this
Which I would assume would map the cursor sprite to the exact same location but it is mapping the sprite to the top left of the screen. I tried changing the values I am storing in cursorx and y but it always maps the sprite to the same location. See spriteselecttopleftt.nes
Any idea what I might be doing wrong?
Here is the full code.
http://pastebin.com/PynpV5sF
I am using a cursor to select letters kind of like a name entry screen at the start of an RPG or something. I map the cursor to where I want it using this code which works fine. See spriteselect.nes
Code:
loadtitlesprites:
LDA #$7f
STA $0200 ; put spritein center ($7f) of screen vert
LDA #tempval
STA $0201 ; tile
LDA #$00
STA $0202 ; color = 0, no flipping
LDA #$10
STA $0203 ; put sprite on left of screen ($10) of screen horiz
LDA #$7f
STA $0200 ; put spritein center ($7f) of screen vert
LDA #tempval
STA $0201 ; tile
LDA #$00
STA $0202 ; color = 0, no flipping
LDA #$10
STA $0203 ; put sprite on left of screen ($10) of screen horiz
However I want to change the vertical / horizontal values to variable so I can track my cursor sprites location and make sure it doesnt go out of bounds.
So I declare 2 variable, store the values I want in the variable and use the variable to write to the screen like this
Code:
cursorx .dsb 1
cursory .dsb 1
LDA #$10
STA cursorx
LDA #$7f
STA #cursory
loadtitlesprites:
LDA #cursory
STA $0200 ; put spritein center ($7f) of screen vert
LDA #tempval
STA $0201
LDA #$00
STA $0202 ; color = 0, no flipping
LDA #cursorx
STA $0203 ; put sprite on left of screen ($10) of screen horiz
cursory .dsb 1
LDA #$10
STA cursorx
LDA #$7f
STA #cursory
loadtitlesprites:
LDA #cursory
STA $0200 ; put spritein center ($7f) of screen vert
LDA #tempval
STA $0201
LDA #$00
STA $0202 ; color = 0, no flipping
LDA #cursorx
STA $0203 ; put sprite on left of screen ($10) of screen horiz
Which I would assume would map the cursor sprite to the exact same location but it is mapping the sprite to the top left of the screen. I tried changing the values I am storing in cursorx and y but it always maps the sprite to the same location. See spriteselecttopleftt.nes
Any idea what I might be doing wrong?
Here is the full code.
http://pastebin.com/PynpV5sF