I'm here straight from NerdyNights, Easy6502 by Skilled Rick, useage.txt included with NESASM, Patater, and every other resource I could find (nesdev wiki included) and I'm not sure I've got my terms correct.
That being said:
I'm learning NESASM and attempting to create a general-purpose megasprite drawing routine (function?). My idea for making this work is as follows:
Declare a 2 byte variable in the zero page RAM using .rs 2 (spriteframe)
Declare two 1 byte variables in the zero page RAM using .rs 2 (spriteX, spriteY)
In bank 2, I set a label and use .db to write many bytes describing a single metasprite (numberoftiles, vert1, tile1, attr1, horz1, vert2, tile2, etc...)
The label is, for instance, MetaSprite0. Of course after that I would place a label for MetaSprite1 and use .db again.
And then each frame I jsr to my general purpose metasprite routine. It loops through 'numberoftiles'/4 amount of times, the four bytes of each tile and storing them in place for the automatic sprite dma. (the reason spritex and spritey are involved is so that I can draw all of the tiles of the metasprite positioned relatively to a central drawing point)
Ideally, I would like to set the variable spriteframe to represent the location in my ROM that begins the metasprite. To accomplish this, I'm currently loading LOW(MetaSprite0) and HIGH(MetaSprite0). By my understanding of things, this should place the address value of my label MetaSprite0 into my variable spriteframe, for instance if label MetaSprite0 points to $e020 then spriteframe would be $20, $e0 (reversed because of some weird 'little endian' term I hear thrown around?). BUT when looking through with the hex editor, I've found that LOW(MetaSprite0) evaluates to the value at location MetaSprite0 instead of the low byte of the location itself. What should I do instead?
Let's just pretend that works:
From there I think I should be able to use indirect indexed addressing to load the value at the address stored at the address of my variable spriteframe (spriteframe contains an address pointing to my label that begins the metasprite data, and from there we use the Y offset to pick an individual byte for each tile). That seems to work just fine when I test it in isolation... but of course I am having a hard time reading from the correct location as I have not found a way to store locations.
~~~~
Any and all thoughts are welcome. I'm fresh on the NES scene and new to assembly, so any comments you have about what I'm doing is welcome insight.
~~~~
If I should describe anything differently, say the word and I'll try again. I can post my source code too, but it's not commented and its even more disorganized than this post, plus the general nature of my question probably doesn't need much source...?
tl;dr: Is there a way to store the address of a label as opposed to the value at a label's address?
That being said:
I'm learning NESASM and attempting to create a general-purpose megasprite drawing routine (function?). My idea for making this work is as follows:
Declare a 2 byte variable in the zero page RAM using .rs 2 (spriteframe)
Declare two 1 byte variables in the zero page RAM using .rs 2 (spriteX, spriteY)
In bank 2, I set a label and use .db to write many bytes describing a single metasprite (numberoftiles, vert1, tile1, attr1, horz1, vert2, tile2, etc...)
The label is, for instance, MetaSprite0. Of course after that I would place a label for MetaSprite1 and use .db again.
And then each frame I jsr to my general purpose metasprite routine. It loops through 'numberoftiles'/4 amount of times, the four bytes of each tile and storing them in place for the automatic sprite dma. (the reason spritex and spritey are involved is so that I can draw all of the tiles of the metasprite positioned relatively to a central drawing point)
Ideally, I would like to set the variable spriteframe to represent the location in my ROM that begins the metasprite. To accomplish this, I'm currently loading LOW(MetaSprite0) and HIGH(MetaSprite0). By my understanding of things, this should place the address value of my label MetaSprite0 into my variable spriteframe, for instance if label MetaSprite0 points to $e020 then spriteframe would be $20, $e0 (reversed because of some weird 'little endian' term I hear thrown around?). BUT when looking through with the hex editor, I've found that LOW(MetaSprite0) evaluates to the value at location MetaSprite0 instead of the low byte of the location itself. What should I do instead?
Let's just pretend that works:
From there I think I should be able to use indirect indexed addressing to load the value at the address stored at the address of my variable spriteframe (spriteframe contains an address pointing to my label that begins the metasprite data, and from there we use the Y offset to pick an individual byte for each tile). That seems to work just fine when I test it in isolation... but of course I am having a hard time reading from the correct location as I have not found a way to store locations.
~~~~
Any and all thoughts are welcome. I'm fresh on the NES scene and new to assembly, so any comments you have about what I'm doing is welcome insight.
~~~~
If I should describe anything differently, say the word and I'll try again. I can post my source code too, but it's not commented and its even more disorganized than this post, plus the general nature of my question probably doesn't need much source...?
tl;dr: Is there a way to store the address of a label as opposed to the value at a label's address?