True,
tya can be faster. But reading the bank table before writing lets you use a non-identity mapping. For example, you can
watermark your ROM by shuffling banks within the ROM, not unlike
source code shuffling.
In my most ambitious UNROM production (240p Test Suite), I've tended to switch banks by overwriting the operand of an immediate load instruction (LDA, LDX, or LDY), like this:
Or when the bank number is in a table (the BNROM version of Action 53 does this a lot):
Code: Select all
lda sb53_files,y
sta ciSrc
lda sb53_files+1,y
sta ciSrc+1
lda sb53_files+2,y
sta sb53_files+2,y ; switch bank