;Wait until drive init is finished bit $dd00 bmi *-3 bit $dd00 bpl *-3 ;Drive seems to be ready here... (?)
lda $dd00 and $df sta $dd00 cmp #$3f bne !+ lda $dd00 and #$ef sta $dd00 +: lda $dd00 ora #$08 sta $dd00 sei lda $dd00 ora #$10 sta $dd00 lda $dd00 and $df sta $dd00 (1ms time loop) lda $dd00 and $df sta $dd00 !: lda $dd00 cmp $dd00 bne !- asl bcs DEVICE_NOT_PRESENT etcetera...
ldy #0 ldx #0 @wait1: nop ;To make the delay loop behavior take a little more time nop iny beq @yfallthrough ;Needed to make sure 1581 drives (and no-drive-connected) won't end up in eternal loop bit $dd00 bmi @wait1 bpl @wait2 ;Skip to second loop @yfallthrough: inx bne @wait1 @wait2: bit $dd00 bpl @wait2