Code: Select all
PLAYER_Y = $0200
PLAYER_TILE = $0201
PLAYER_ATTR = $0202
PLAYER_X = $0203
player_x .rs 1
player_y .rs 1
Code: Select all
DrawPlayer:
LDA player_x
STA PLAYER_X
LDA player_y
STA PLAYER_Y
Now this all works just fine but it's not the way I would approach it if I were coding in something like C or C++. I'm having a hard time wrapping my head around doing any abstraction when I'm coding in assembly. I see some people talking about using arrays and tables and things like that but I'm not quite sure how those are implemented in 6502 assembly.
I've added my sprites and nametables to a section of memory starting at $E000, which I understand to be cartridge rom. Is this the space that is typically used to store things like arrays and tables? For example if I wanted to create some simple sprite animations, would a typical approach be to do something like this:
Code: Select all
walk_anim_ptr .rs 1
Code: Select all
walk_animation_array:
.db $03, walk1, walk2, walk3 ; length, 1, 2, 3
walk1:
.db $80, $32, $00, $80
.db $80, $33, $00, $88
.db $88, $34, $00, $80
.db $88, $35, $00, $88
walk2:
.db $80, $32, $00, $80
.db $80, $33, $00, $88
.db $88, $34, $00, $80
.db $88, $35, $00, $88
walk3:
.db $80, $32, $00, $80
.db $80, $33, $00, $88
.db $88, $34, $00, $80
.db $88, $35, $00, $88
Are further abstractions possible here in terms of data structures? Could I for example implement something like a C struct? What would that look like? Or is that specific to the assembler that I'm using?
What would be a very simple next step from this approach I've outlined above to something that uses a bit more abstraction and possibly a more generalized approach?