So I'm reworking a few things, and this thing I feel *should* be working just fine is returning the wrong values. Just wondering if anyone sees anything funny about it. There also may be an easier way.
I need a LUT table to point to a variable LUT table with an offset, so in trying to get the address of the second lut table, I've used four bytes...
I have a table that essentially looks like this:
And then I have high and lo LUT tables for all possible things....
...with the goal of getting the value at that eventual address. This is what I thought was working to get the end value:
LDY #$01 ;; would now make the rest of this code point to 'thing2'
LDA Item1Lo_lo,y
STA findTheAdd
LDA Item1Lo_hi,y
STA findTheAdd+1
LDA Item1Hi_lo,y
STA findTheAdd+2
LDA Item1Hi_hi,y
STA findTheAdd+3
LDX #$02 ;; now the below should point to address6 values
LDA (findTheAdd),x
STA thisIsTheAddressOfTheValue_Lo
LDA (findTheAdd+2),x
STA thisIsTheAddressOfTheValue_Hi
LDX offsetAmount
LDA (thisIsTheAddressOfTheValue_lo),x
;;;; A should now be loaded with the desired value...which should be X beyond address6...
I feel like this is sound, but it is not returning the value at the expected address (debugged the value to make sure, and the value at that particular address is correct, but this routine is not pointing to it).
Essentially, I'm looking for the best way to have a table of addresses, that points to a table of addresses, that finds the value at an offset of that address.
Any thoughts? Thanks!
I need a LUT table to point to a variable LUT table with an offset, so in trying to get the address of the second lut table, I've used four bytes...
I have a table that essentially looks like this:
Code:
Item1Lo_Lo:
.db <thing1Lo, <thing2Lo, <thing3Lo
Item1Lo_Hi:
.db >thing1Lo, >thing2Lo, >thing3Lo
Item1Hi_Lo:
.db <thing1Hi, <thing2Hi, <thing3Hi
Item1Hi_hi:
.db >thing1Hi, >thing2Hi, >thing3Hi
.db <thing1Lo, <thing2Lo, <thing3Lo
Item1Lo_Hi:
.db >thing1Lo, >thing2Lo, >thing3Lo
Item1Hi_Lo:
.db <thing1Hi, <thing2Hi, <thing3Hi
Item1Hi_hi:
.db >thing1Hi, >thing2Hi, >thing3Hi
And then I have high and lo LUT tables for all possible things....
Code:
thing1Lo:
.db <address, <address2, <address3
thing1Hi:
.db >address, >address2, >address3
thing2Lo:
.db <address4, <address5, <address6
thing2Hi:
.db >address4, >address5, >address6
.db <address, <address2, <address3
thing1Hi:
.db >address, >address2, >address3
thing2Lo:
.db <address4, <address5, <address6
thing2Hi:
.db >address4, >address5, >address6
...with the goal of getting the value at that eventual address. This is what I thought was working to get the end value:
Code:
LDY #$01 ;; would now make the rest of this code point to 'thing2'
LDA Item1Lo_lo,y
STA findTheAdd
LDA Item1Lo_hi,y
STA findTheAdd+1
LDA Item1Hi_lo,y
STA findTheAdd+2
LDA Item1Hi_hi,y
STA findTheAdd+3
LDX #$02 ;; now the below should point to address6 values
LDA (findTheAdd),x
STA thisIsTheAddressOfTheValue_Lo
LDA (findTheAdd+2),x
STA thisIsTheAddressOfTheValue_Hi
LDX offsetAmount
LDA (thisIsTheAddressOfTheValue_lo),x
;;;; A should now be loaded with the desired value...which should be X beyond address6...
I feel like this is sound, but it is not returning the value at the expected address (debugged the value to make sure, and the value at that particular address is correct, but this routine is not pointing to it).
Essentially, I'm looking for the best way to have a table of addresses, that points to a table of addresses, that finds the value at an offset of that address.
Any thoughts? Thanks!