Hi,
I"m a little new to 6502 stuff...I was trying to access data with pointers and I saw how some source was doing it, so I tried testing stuff in a simulator, but I can't seem to get it to work.
the pointer is always at $0000, and the STA tileset_ptr results in nothing
being stored from the accumulator to the pointer.
I'm probably doing something very stupid... the code is below.
I'm trying to get a tile from the tbank0x sections by referring to them with
tilesetbanks...
tileset_ptr is not holding the address of what I want, though...
I may be doing this all wrong as well...
Could someone tell me how to do this sorta thing properly in NESASM?
I"m a little new to 6502 stuff...I was trying to access data with pointers and I saw how some source was doing it, so I tried testing stuff in a simulator, but I can't seem to get it to work.
the pointer is always at $0000, and the STA tileset_ptr results in nothing
being stored from the accumulator to the pointer.
I'm probably doing something very stupid... the code is below.
I'm trying to get a tile from the tbank0x sections by referring to them with
tilesetbanks...
tileset_ptr is not holding the address of what I want, though...
I may be doing this all wrong as well...
Could someone tell me how to do this sorta thing properly in NESASM?
Code:
; set tileset bank to $01 (tbank01)
LDA #$01
TAY
LDA tilesetbanks,y
STA tileset_ptr
LDA tilesetbanks+1,y
STA tileset_ptr+1
;load tile $02 from bank $01 to $6000
LDA #$02 ; this number is recieved from map data
ASL
ASL
TAY
LDA (tileset_ptr),y
STA $6000
INY
LDA (tileset_ptr),y
STA $6001
INY
LDA (tileset_ptr),y
INY
STA $6002
LDA (tileset_ptr),y
INY
STA $6003
tbank00:
.DB $00,$01,$02,$03 ;tile $00
.DB $04,$05,$06,$07 ;tile $01
.DB $08,$09,$0A,$0B ;tile $02
.DB $0C,$0D,$0E,$0F ;tile $03
tbank01:
.DB $10,$11,$12,$13 ;tile $00
.DB $14,$15,$16,$17 ;tile $01
.DB $18,$19,$1A,$1B ;tile $02
.DB $1C,$1D,$1E,$1F ;tile $03
tilesetbanks:
.DW tbank00,tbank01
LDA #$01
TAY
LDA tilesetbanks,y
STA tileset_ptr
LDA tilesetbanks+1,y
STA tileset_ptr+1
;load tile $02 from bank $01 to $6000
LDA #$02 ; this number is recieved from map data
ASL
ASL
TAY
LDA (tileset_ptr),y
STA $6000
INY
LDA (tileset_ptr),y
STA $6001
INY
LDA (tileset_ptr),y
INY
STA $6002
LDA (tileset_ptr),y
INY
STA $6003
tbank00:
.DB $00,$01,$02,$03 ;tile $00
.DB $04,$05,$06,$07 ;tile $01
.DB $08,$09,$0A,$0B ;tile $02
.DB $0C,$0D,$0E,$0F ;tile $03
tbank01:
.DB $10,$11,$12,$13 ;tile $00
.DB $14,$15,$16,$17 ;tile $01
.DB $18,$19,$1A,$1B ;tile $02
.DB $1C,$1D,$1E,$1F ;tile $03
tilesetbanks:
.DW tbank00,tbank01