Just Jeff Posted May 17, 2019 Share Posted May 17, 2019 (edited) Good Afternoon, Got an indirect addressing question I'm wondering if someone could help me with. I'm used to doing indirect addressing by doing something like lda #<(Player0Gfx) sta Player0Ptr lda #>(Player0Gfx) sta Player0Ptr+1 then that's the address for my graphics pointer. Uses two bytes of RAM. But currently, I'm working on something that has 14 graphics pointers using 28 bytes of RAM, 14 of which are the same number because its all on the same page. Looking over lda in the 6502 guide I notice this syntax: Indirect,X LDA ($44,X) $A1 2 6 Indirect,Y LDA ($44),Y $B1 2 5+ It looks to me like y is an indexed lda. But the x example looks like x might be representing the page. Is that what its doing? Could I just skip the Player0Ptr+1. Then when loading graphics have something like: ldx #$FB ;The page all my graphics happen to be on. lda (Player0Ptr,x) ; which is #<(Player0Gfx) sta GRP0 Edited May 17, 2019 by BNE Jeff Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted May 18, 2019 Share Posted May 18, 2019 Radically different address modes. You know that the y register is added to the base address specified by the argument for (indirect),y. Notice where the brackets are? With (indirect,x) the value of x determines which base address to use from a group of base addresses. ;if $82 holds #0, $83 holds #$FF... ldx #2 lda ($80,x) ;A is loaded from address $FF00 Since zero page is usually in short supply on most platforms, this address mode is far less useful than (indirect),y Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted May 18, 2019 Share Posted May 18, 2019 Tho it is a handy way to burn 6 cycles in 2 bytes if you know the value of x and the contents of A are unimportant. Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted May 19, 2019 Author Share Posted May 19, 2019 OK Thanks.. Took me a while to digest that. So does this mode only allow a nonindexed pointer address, and only in page 0? So in any case am I stuck with using the two bytes? Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted May 24, 2019 Share Posted May 24, 2019 Correct. And yeah, you are stuck with using 2 bytes for either address mode. Tho you can usually repurpose those for temp Ram outside of the kernel...so long as you reset them before their display area(s) begin. Have you looked at Alien? That game uses a single byte for each sprite as a pointer to 2 page long data tables. Slower than (ind),y but more Ram efficient. Another drawback is that sprites car limited to that 512-byte range instead of being allowed anywhere in Rom. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.