In https://wiki.nesdev.com/w/index.php/Programming_UNROM there is the following code:
In line 4, wouldn't TYA do the same (since the values in banktable equal their offset value), but be shorter?
Code:
bankswitch_y:
sty current_bank ; save the current bank in RAM so the NMI handler can restore it
bankswitch_nosave:
lda banktable, y ; read a byte from the banktable
sta banktable, y ; and write it back, switching banks
rts
sty current_bank ; save the current bank in RAM so the NMI handler can restore it
bankswitch_nosave:
lda banktable, y ; read a byte from the banktable
sta banktable, y ; and write it back, switching banks
rts
In line 4, wouldn't TYA do the same (since the values in banktable equal their offset value), but be shorter?