Files
open-roms/c64/kernal/iec_fast/jiffydos_detect.s
T

43 lines
1.2 KiB
ArmAsm

//
// Helper routine for JiffyDOS detection
//
// Detection is done by inserting a long delay (above 400us?) during sending command last bit, see:
// - https://sites.google.com/site/h2obsession/CBM/C128/JiffySoft128
// - https://github.com/rkrajnc/sd2iec/blob/master/src/iec.c
// The 'iec.s' suggests, that the drive should respond by pulling data
#if CONFIG_IEC_JIFFYDOS
jiffydos_detect:
ldy #$25 // 400us is nearly 410 cycles on NTSC
// loop iteration below is 11 cycles,
// and several cycles were already used
jiffydos_detect_loop:
lda CIA2_PRA // 4 cycles
bpl jiffydos_detected // 2 cycles
dey // 2 cycles
bne jiffydos_detect_loop // 3 cycles if branch
lda #$00 // normal protocol
beq jiffydos_store_proto // branch always
jiffydos_detected:
jsr iec_wait_for_data_release // guessed from VICE logs
lda #$01 // JiffyDOS protocol
// FALLTROUGH
jiffydos_store_proto:
sta IECPROTO
rts
#endif // CONFIG_IEC_JIFFYDOS