Users browsing this thread: 1 Guest(s)
How Do We Index Address

#1
Posts: 61
Threads: 18
Thanks Received: 1
Thanks Given: 47
Joined: May 2014
Status
None
So I ran up against a wall trying to edit esper level-up bonuses because index addressing seems so simple, but does not compute.  This thread is for the posterity of figuring it out.  From my readings, index addressing is simple.  Instead of going to a static location, you go to a pointed location that is instead increased (or decreased?) by one of the other registers (X, Y, etc.).  So (LDA, X) JSR ($CA24,X) means you jump to the address but if 2 is the current value in the X register, then you go to that address +2.

This is how index addressing works, isn't it?  When I try to modify things in FF6 based on this it doesn't work out.  Also, I often can't follow the C2 notes that are based on index addressing, as they look to be using it differently than I imagine.

Thanks All,
RS

Edit: I did mean JSR for that example.  (LDA, X) is loading to the accumulator like you all said
  Find
Quote  

#2
Posts: 676
Threads: 44
Thanks Received: 26
Thanks Given: 21
Joined: Jan 2015
Reputation: 11
Status
Zombie
The 8 bit and 16 bit modes always get me on the multiplication part while adjusting for how many bytes to skip to reach the desired entry. Course, saving that loaded value for use was always a hassle too.

In theory that seems like the correct method, but I'm certainly not good enough to check it without knowing whats going on around it and what its trying to load/read.


The only true wisdom is knowing you know nothing.
  Find
Quote  
[-] The following 1 user says Thank You to Catone for this post:
  • ReturnerScum (02-11-2016)

#3
Posts: 61
Threads: 18
Thanks Received: 1
Thanks Given: 47
Joined: May 2014
Status
None
You know what's cool? The Socrates quote in your sig
  Find
Quote  

#4
Posts: 676
Threads: 44
Thanks Received: 26
Thanks Given: 21
Joined: Jan 2015
Reputation: 11
Status
Zombie
Yeah, I used to always say "The closest you'll ever get to knowing everything is knowing, you don't know chit."

Then one day watching Bill & Ted's Excellent Adventure I realized just how smart ol' Socrates really was. Since his quote was alot prettier than mine, I figured I'd go with his. Although I still think he said it the same way I did, they just translated it wrong.

But yeah, if you "know" nothing, then you can learn anything. Least it always made since to me.


The only true wisdom is knowing you know nothing.
  Find
Quote  

#5
Posts: 127
Threads: 8
Thanks Received: 21
Thanks Given: 12
Joined: Jan 2012
Reputation: 13
Status
None
(02-07-2016, 12:33 PM)ReturnerScum Wrote: So (LDA, X) means you jump to the address but if 2 is the current value in the X register, then you go to that address +2.

You're on the right track.
Maybe I'm taking you to literally but LDA does not jump. LDA (load accumulator) loads the A register with a value.
So LDA $0000,X loads the binary value at address $0000+X (as you said) but puts the value into the A register and does not jump.
  Find
Quote  
[-] The following 1 user says Thank You to m06 for this post:
  • ReturnerScum (02-11-2016)

#6
Posts: 3,970
Threads: 279
Thanks Received: 236
Thanks Given: 58
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
You're right on the basic. There's a resume but with little explanation on the snesdevelopment site. There's also about 20 different addressing combination described here covering 20 pages: http://wiki.nesdev.com/w/images/7/76/Programmanual.pdf

Maybe it would worth you read them. Read! (I haven't Tongue)
  Find
Quote  
[-] The following 1 user says Thank You to madsiur for this post:
  • ReturnerScum (02-11-2016)

#7
Posts: 290
Threads: 3
Thanks Received: 40
Thanks Given: 1
Joined: Apr 2012
Reputation: 9
Status
None
What you're likely thinking of is indexed jumping - i.e., JSR $8C4A,X

In this case, $8C4A is generally the start of the jump table. The table itself is simply a list of addresses in little Endian (essentially meaning that you read them backwards) that redirect the jump. So, using the esper bonus jump table for example:

Code:
C2/614E: 70 61  (~10% HP bonus)
C2/6150: 74 61  (~30% HP bonus)
C2/6152: 78 61  (50% HP bonus)
C2/6154: 70 61  (~10% MP bonus)
C2/6156: 74 61  (~30% MP bonus)
C2/6158: 78 61  (50% MP bonus)
C2/615A: B0 61  (Double natural HP gain for level)
C2/615C: 97 61  (No bonus)
C2/615E: 97 61  (No bonus)
C2/6160: 9B 61  (Vigor bonus)
C2/6162: 9B 61  (Vigor bonus)
C2/6164: 9A 61  (Speed bonus)
C2/6166: 9A 61  (Speed bonus)
C2/6168: 99 61  (Stamina bonus)
C2/616A: 99 61  (Stamina bonus)
C2/616C: 98 61  (MagPwr bonus)
C2/616E: 98 61  (MagPwr bonus)

If you look at these backwards, you can see where each one will redirect the jump to. For instance, the HP +50% boost would redirect the jump to C2/6178.

It's important to remember that X needs to be an even number for a jump table to work properly. Since all addresses in a jump table are two bytes, you need to push the index forward by two bytes to get the next proper address in the table. That's why you will see things like ASL, TAX before the jump (like at C2/60EF).


GET A SILK BAG FROM THE GRAVEYARD DUCK TO LIVE LONGER.

Brave New World
  Find
Quote  
[-] The following 1 user says Thank You to Synchysi for this post:
  • ReturnerScum (02-08-2016)



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite