These questions might have been answered before on this forum, but I could not find anything.
Ok, so lets say you want to make a regular upper bank switch (or whatever you want to accomplish)
I'm all fine with that you need to write 5 times, the 5th time is what matters and all that stuff.
Looking into commercial games - all have the same procedure as above, so I am not questioning the wiki nor the setup itself.
But.. to me it seems like
would do the same thing, but wastefewer cycles and memory? Is there a timing issue with doing this? I have tested this loop method and it worked just fine (at least in an emulator, not tested with hardware).
Seeing all the compression, cycle critical code and what not that went into making some of the commercial games, it makes you wonder why this is so "inefficient".
ps: for anyone stumbling upon this thread; in a nutshell, yes you can loop writes like this, but it will only save memory, not execution time. In fact it will increase cycles (a lot..)
Ok, so lets say you want to make a regular upper bank switch (or whatever you want to accomplish)
Code:
switch:
sta $ffff
lsr
sta $ffff
lsr
sta $ffff
lsr
sta $ffff
lsr
sta $ffff
rts
sta $ffff
lsr
sta $ffff
lsr
sta $ffff
lsr
sta $ffff
lsr
sta $ffff
rts
I'm all fine with that you need to write 5 times, the 5th time is what matters and all that stuff.
Looking into commercial games - all have the same procedure as above, so I am not questioning the wiki nor the setup itself.
But.. to me it seems like
Code:
switch:
ldx #$05
write:
sta $ffff
lsr
dex
bne write
rts
ldx #$05
write:
sta $ffff
lsr
dex
bne write
rts
would do the same thing, but waste
Seeing all the compression, cycle critical code and what not that went into making some of the commercial games, it makes you wonder why this is so "inefficient".
ps: for anyone stumbling upon this thread; in a nutshell, yes you can loop writes like this, but it will only save memory, not execution time. In fact it will increase cycles (a lot..)