The idea is that you have a table of pointers and each of them point to a different routine. That means, you not only need an index (typically $C2,x but it can be anything) but also a code which handles the pointers. Reading helps as the codes were, in fact, mentioned in my tutorial:
Originally posted by my tutorial (removed unspoiler tags)Execute pointers (option 1):
Code LDA something
JSL $0086DF
dw Code1
dw Code2
dw Code3
;etc.
Scratch RAM pointers (option 2):
Code LDA something
ASL
TAY
LDA Pointers,y
STA $00
SEP #$20
JSR.w ($0000)
; other code
Pointers:
dw Code1
dw Code2
dw Code3
;etc.
Indexed address pointer (option 3):
Code LDA something
ASL
TAX
JSR.w (Pointers,x)
;other code
Pointers:
dw Code1
dw Code2
dw Code3
;etc.
Okay, we have the codes but which pointers should we take? Well, let's take a look at them:
- Option 1 is the value saving most space but is the slowest option because it requires on using the stack.
- Option 2 is quite large but is at least faster than the first option.
- Option 3 isn't much larger than the first option and also faster than the second option but requires X. "JSR (Pointers,y)" doesn't exist in the 65c816 processor.
Generally, you want to use the first option. Speed isn't an issue here and option 3 has got the problem that you need to use X for the index.