I stumbled upon a couple of FDS games that do something that seems weird while waiting for a disk to be inserted:
And then others do this instead (which makes a lot more sense to me):
My 6502 assembly skills are pretty terrible, so I could be understanding this wrong, but I can actually get this behavior several times in a row in the games (Aspic, Ao no Senritsu) that use the first version (e.g doing eject disk -> wait -> insert disk causes the execution to go back to the first loop and the game doesn't react at all)
The only way the first version would "reliably" be able to exit its loop was if the value of the "drive is empty" bit quickly toggled between 0 and 1 a number of times when physically ejecting or inserting a disk?
Code:
loop:
LDA $4032
AND #$01
BEQ loop ;if a disk is currently inserted, loop (e.g wait for eject)
LDA $4032
AND #$01
BNE loop ;if no disk is currently inserted, loop (e.g wait for insert, but the loop goes back to the first check!)
LDA $4032
AND #$01
BEQ loop ;if a disk is currently inserted, loop (e.g wait for eject)
LDA $4032
AND #$01
BNE loop ;if no disk is currently inserted, loop (e.g wait for insert, but the loop goes back to the first check!)
And then others do this instead (which makes a lot more sense to me):
Code:
wait_eject_loop:
LDA $4032
AND #$01
BEQ wait_eject_loop
LDY #$FF
JSR Delayms
wait_insert_loop:
LDA $4032
AND #$01
BNE wait_insert_loop
As far as I can tell, the first version can fail to recognize the newly inserted disk pretty often (which would force the user to eject the disk and then reinsert it). This can happen if you the "drive is empty" bit gets cleared while the code is in the first part of the loop (which loops until the disk is ejected).LDA $4032
AND #$01
BEQ wait_eject_loop
LDY #$FF
JSR Delayms
wait_insert_loop:
LDA $4032
AND #$01
BNE wait_insert_loop
My 6502 assembly skills are pretty terrible, so I could be understanding this wrong, but I can actually get this behavior several times in a row in the games (Aspic, Ao no Senritsu) that use the first version (e.g doing eject disk -> wait -> insert disk causes the execution to go back to the first loop and the game doesn't react at all)
The only way the first version would "reliably" be able to exit its loop was if the value of the "drive is empty" bit quickly toggled between 0 and 1 a number of times when physically ejecting or inserting a disk?