more JiffyDOS code - low nibble TX, general turbo dispatcher
This commit is contained in:
1 parent
28bc07ea23
commit
d0fd34e79f
10 files changed
+156
-27
No files matched your search
@@ -14,7 +14,11 @@ ACPTR:
|
|||||||
jsr kernalstatus_reset
|
jsr kernalstatus_reset
|
||||||
|
|
||||||
#if CONFIG_IEC
|
#if CONFIG_IEC
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
jmp iec_rx_dispatch
|
||||||
|
#else // no turbo supported
|
||||||
jmp iec_rx_byte
|
jmp iec_rx_byte
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||||
#endif
|
#endif
|
||||||
@@ -33,7 +33,11 @@ ciout_store_in_buffer:
|
|||||||
ciout_send_byte:
|
ciout_send_byte:
|
||||||
|
|
||||||
clc // don't send with EOI
|
clc // don't send with EOI
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
jsr iec_tx_dispatch
|
||||||
|
#else // no turbo supported
|
||||||
jsr iec_tx_byte
|
jsr iec_tx_byte
|
||||||
|
#endif
|
||||||
inc C3PO // iec_tx_byte sets it to 0, but we still have something to send
|
inc C3PO // iec_tx_byte sets it to 0, but we still have something to send
|
||||||
jmp ciout_store_in_buffer
|
jmp ciout_store_in_buffer
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ iec_tx_byte_jiffydos:
|
|||||||
// Prepare nibbles to send
|
// Prepare nibbles to send
|
||||||
lda TBTCNT
|
lda TBTCNT
|
||||||
and #$0F
|
and #$0F
|
||||||
|
tax
|
||||||
|
lda iec_jiffydos_bittable, X // low nibble has to be encoded
|
||||||
pha
|
pha
|
||||||
lda TBTCNT
|
lda TBTCNT
|
||||||
and #$F0
|
and #$F0
|
||||||
@@ -57,29 +59,16 @@ __jd_check1:
|
|||||||
and #%00110000 // clear everything but CLK/DATA
|
and #%00110000 // clear everything but CLK/DATA
|
||||||
sta CIA2_PRA // bits 6 and 7 on CLK/DATA
|
sta CIA2_PRA // bits 6 and 7 on CLK/DATA
|
||||||
|
|
||||||
// Send low nibble; cycles: XXX
|
// Send low nibble; cycles: 4 + 3 + 4 + 2 + 2 + 2 + 4 = 21
|
||||||
|
pla // retrieve low nibble from stack
|
||||||
|
ora C3PO // restore VIC-II and RS-232 bits
|
||||||
|
sta CIA2_PRA
|
||||||
|
ror
|
||||||
|
ror
|
||||||
|
and #%00110000 // clear everything but CLK/DATA
|
||||||
|
sta CIA2_PRA
|
||||||
|
|
||||||
// XXX something strange seems to happen with low nibble:
|
|
||||||
|
|
||||||
// $0 -> $00
|
|
||||||
// $1 -> $80 = $10 + $70
|
|
||||||
// $2 -> $20
|
|
||||||
// $3 -> $A0 = $30 + $70
|
|
||||||
// $4 -> $40
|
|
||||||
// $5 -> $C0 = $50 + $70
|
|
||||||
// $6 -> $60
|
|
||||||
// $7 -> $E0 = $70 + $70
|
|
||||||
|
|
||||||
// $8 -> $10 = $80 - $70
|
|
||||||
// $9 -> $90
|
|
||||||
// $A -> $30 = $A0 - $70
|
|
||||||
// $B -> $B0
|
|
||||||
// $C -> $50 = $C0 - $70
|
|
||||||
// $D -> $D0
|
|
||||||
// $E -> $70 = $E0 - $70
|
|
||||||
// $F -> $F0
|
|
||||||
|
|
||||||
// XXX why??? how this is calculated???
|
|
||||||
|
|
||||||
// XXX EOI signalled by early CLK (20us delay for non-CLK?)
|
// XXX EOI signalled by early CLK (20us delay for non-CLK?)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// Helper table for encoding lower nibble for JiffyyDOS,
|
||||||
|
// values found by observing the actual transfer
|
||||||
|
//
|
||||||
|
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
|
||||||
|
|
||||||
|
// XXX consider calculating the values on-the-fly
|
||||||
|
|
||||||
|
iec_jiffydos_bittable:
|
||||||
|
|
||||||
|
.byte $00
|
||||||
|
.byte $80 // $10 + $70
|
||||||
|
.byte $20
|
||||||
|
.byte $A0 // $30 + $70
|
||||||
|
.byte $40
|
||||||
|
.byte $C0 // $50 + $70
|
||||||
|
.byte $60
|
||||||
|
.byte $E0 // $70 + $70
|
||||||
|
|
||||||
|
.byte $10 // $80 - $70
|
||||||
|
.byte $90
|
||||||
|
.byte $30 // $A0 - $70
|
||||||
|
.byte $B0
|
||||||
|
.byte $50 // $C0 - $70
|
||||||
|
.byte $D0
|
||||||
|
.byte $70 // $E0 - $70
|
||||||
|
.byte $F0
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC_JIFFYDOS
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// Arbitration code for normal/turbo transfer
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
|
||||||
|
|
||||||
|
iec_rx_dispatch:
|
||||||
|
|
||||||
|
lda IECPROTO
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
cmp #$01
|
||||||
|
beq iec_rx_dispatch_jiffydos
|
||||||
|
#endif // CONFIG_IEC_JIFFYDOS
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
iec_rx_dispatch_normal:
|
||||||
|
|
||||||
|
plp
|
||||||
|
jmp iec_rx_byte
|
||||||
|
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
iec_rx_dispatch_jiffydos:
|
||||||
|
plp
|
||||||
|
jmp iec_rx_byte_jiffydos
|
||||||
|
#endif // CONFIG_IEC_JIFFYDOS
|
||||||
|
|
||||||
|
|
||||||
|
#endif // any turbo supported
|
||||||
@@ -68,21 +68,21 @@ iec_tx_common_sendbit:
|
|||||||
cpx #$00
|
cpx #$00
|
||||||
bne !+ // branch if not sending the last bit
|
bne !+ // branch if not sending the last bit
|
||||||
|
|
||||||
ldy #$1B // 400us is nearly 410 cycles on NTSC
|
ldy #$25 // 400us is nearly 410 cycles on NTSC
|
||||||
// loop iteration below is 15 cycles,
|
// loop iteration below is 11 cycles,
|
||||||
// and several cycles were already used
|
// and several cycles were already used
|
||||||
iec_jiffydos_detect_loop:
|
iec_jiffydos_detect_loop:
|
||||||
lda CIA2_PRA // 4 cycles
|
lda CIA2_PRA // 4 cycles
|
||||||
bpl iec_jiffydos_detected // 2 cycles
|
bpl iec_jiffydos_detected // 2 cycles
|
||||||
dey // 2 cycles
|
dey // 2 cycles
|
||||||
bne iec_jiffydos_detect_loop // 2 cycles
|
bne iec_jiffydos_detect_loop // 3 cycles if branch
|
||||||
|
|
||||||
lda #$00 // 2 cycles
|
lda #$00 // normal protocol
|
||||||
beq iec_jiffydos_store_proto // 3 cycles, branch always
|
skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
iec_jiffydos_detected:
|
iec_jiffydos_detected:
|
||||||
|
|
||||||
panic #$FF // WHOAAAA! He wants to speak jiffy, but I do not know this language yet!
|
lda #$01 // JiffyDOS protocol
|
||||||
|
|
||||||
iec_jiffydos_store_proto:
|
iec_jiffydos_store_proto:
|
||||||
sta IECPROTO
|
sta IECPROTO
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// Arbitration code for normal/turbo transfer
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
|
||||||
|
|
||||||
|
iec_tx_dispatch:
|
||||||
|
|
||||||
|
php // preserve C flag for EOI indication
|
||||||
|
lda IECPROTO
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
cmp #$01
|
||||||
|
beq iec_tx_dispatch_jiffydos
|
||||||
|
#endif // CONFIG_IEC_JIFFYDOS
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
iec_tx_dispatch_normal:
|
||||||
|
|
||||||
|
plp
|
||||||
|
jmp iec_tx_byte
|
||||||
|
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
iec_tx_dispatch_jiffydos:
|
||||||
|
plp
|
||||||
|
jmp iec_tx_byte_jiffydos
|
||||||
|
#endif // CONFIG_IEC_JIFFYDOS
|
||||||
|
|
||||||
|
|
||||||
|
#endif // any turbo supported
|
||||||
@@ -71,10 +71,18 @@ load_iec:
|
|||||||
|
|
||||||
// Get load address
|
// Get load address
|
||||||
|
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
jsr iec_rx_dispatch
|
||||||
|
#else // no turbo supported
|
||||||
jsr iec_rx_byte
|
jsr iec_rx_byte
|
||||||
|
#endif
|
||||||
bcs load_iec_file_not_found
|
bcs load_iec_file_not_found
|
||||||
sta EAL+0
|
sta EAL+0
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
jsr iec_rx_dispatch
|
||||||
|
#else // no turbo supported
|
||||||
jsr iec_rx_byte
|
jsr iec_rx_byte
|
||||||
|
#endif
|
||||||
bcs load_iec_file_not_found
|
bcs load_iec_file_not_found
|
||||||
sta EAL+1
|
sta EAL+1
|
||||||
|
|
||||||
@@ -92,7 +100,11 @@ load_iec:
|
|||||||
|
|
||||||
iec_load_loop:
|
iec_load_loop:
|
||||||
// We are now ready to receive bytes
|
// We are now ready to receive bytes
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
jsr iec_rx_dispatch
|
||||||
|
#else // no turbo supported
|
||||||
jsr iec_rx_byte
|
jsr iec_rx_byte
|
||||||
|
#endif
|
||||||
bcs load_iec_error
|
bcs load_iec_error
|
||||||
|
|
||||||
// Handle the byte (store in memory / verify)
|
// Handle the byte (store in memory / verify)
|
||||||
|
|||||||
@@ -48,12 +48,20 @@ save_iec:
|
|||||||
lda STAL+0
|
lda STAL+0
|
||||||
sta TBTCNT
|
sta TBTCNT
|
||||||
clc
|
clc
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
jsr iec_tx_dispatch
|
||||||
|
#else // no turbo supported
|
||||||
jsr iec_tx_byte
|
jsr iec_tx_byte
|
||||||
|
#endif
|
||||||
|
|
||||||
lda STAL+1
|
lda STAL+1
|
||||||
sta TBTCNT
|
sta TBTCNT
|
||||||
clc
|
clc
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
jsr iec_tx_dispatch
|
||||||
|
#else // no turbo supported
|
||||||
jsr iec_tx_byte
|
jsr iec_tx_byte
|
||||||
|
#endif
|
||||||
|
|
||||||
jsr lvs_setup_MEMUSS
|
jsr lvs_setup_MEMUSS
|
||||||
ldy #$00
|
ldy #$00
|
||||||
@@ -70,7 +78,11 @@ iec_save_loop:
|
|||||||
// Send the byte
|
// Send the byte
|
||||||
sta TBTCNT
|
sta TBTCNT
|
||||||
clc
|
clc
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
jsr iec_tx_dispatch
|
||||||
|
#else // no turbo supported
|
||||||
jsr iec_tx_byte
|
jsr iec_tx_byte
|
||||||
|
#endif
|
||||||
|
|
||||||
// Next iteration
|
// Next iteration
|
||||||
jsr lvs_advance_MEMUSS_check_EAL
|
jsr lvs_advance_MEMUSS_check_EAL
|
||||||
|
|||||||
@@ -26,6 +26,16 @@ TALK:
|
|||||||
// Encode and execute the command
|
// Encode and execute the command
|
||||||
ora #$40
|
ora #$40
|
||||||
|
|
||||||
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
|
|
||||||
|
// XXX temporary, until receiving is implemented too
|
||||||
|
sta TBTCNT
|
||||||
|
lda #$00 // standard protocol
|
||||||
|
sta IECPROTO
|
||||||
|
jmp iec_tx_command
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC_JIFFYDOS
|
||||||
|
|
||||||
common_talk_listen: // common part of TALK and LISTEN
|
common_talk_listen: // common part of TALK and LISTEN
|
||||||
|
|
||||||
sta TBTCNT
|
sta TBTCNT
|
||||||
|
|||||||
Reference in new issue
Block a user