Jump to content
BNE Jeff

Indirect Addressing Question

Recommended Posts

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  by BNE Jeff
	
	

			
		

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...