IEC code cleanup, saved few bytes

This commit is contained in:
FeralChild64 committed 2019-12-27 18:05:43 +01:00
1 parent b5f9b6593b
commit 55f5041aa6
13 files changed
+64 -173

No files matched your search

+4 -4
View File
@@ -32,13 +32,13 @@ ciout_store_in_buffer:
ciout_send_byte:
clc // don't send with EOI
#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS
clc // send without EOI
#if CONFIG_IEC_JIFFYDOS
jsr iec_tx_dispatch
#else // no turbo supported
#else
jsr iec_tx_byte
#endif
inc C3PO // iec_tx_byte sets it to 0, but we still have something to send
inc C3PO // tx byte routine sets to 0, but we still have something to send
jmp ciout_store_in_buffer
#else
+13
View File
@@ -8,6 +8,19 @@
#if CONFIG_IEC
#if CONFIG_IEC_JIFFYDOS
iec_rx_dispatch:
lda IECPROTO
cmp #$01
beq_far jiffydos_rx_byte
// FALLTROUGH
#endif // CONFIG_IEC_JIFFYDOS
iec_rx_byte:
// Store .X and .Y on the stack - preserve them
+2 -2
View File
@@ -30,9 +30,9 @@ iec_send_file_name_loop:
!:
// Transmit one character
sta TBTCNT
#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS
#if CONFIG_IEC_JIFFYDOS
jsr iec_tx_dispatch
#else // no turbo supported
#else
jsr iec_tx_byte
#endif
jmp iec_send_file_name_loop
+20
View File
@@ -9,6 +9,26 @@
#if CONFIG_IEC
#if CONFIG_IEC_JIFFYDOS
iec_tx_dispatch:
php // preserve C flag for EOI indication
lda IECPROTO
cmp #$01
bne !+
plp
jmp jiffydos_tx_byte
!:
plp
// FALLTROUGH
#endif // CONFIG_IEC_JIFFYDOS
iec_tx_byte:
// Store .X and .Y on the stack - preserve them
+2 -2
View File
@@ -103,12 +103,12 @@ load_iec:
#if CONFIG_IEC_JIFFYDOS
cmp #$01
beq_far load_jiffydos // branch if JiffyDOS
beq_far jiffydos_load // branch if JiffyDOS
#endif
#if CONFIG_IEC_DOLPHINDOS
cmp #$02
beq_far load_dolphindos // branch if DolphinDOS
beq_far dolphindos_load // branch if DolphinDOS
#endif
#endif
@@ -7,7 +7,7 @@
#if CONFIG_IEC_DOLPHINDOS && !CONFIG_MEMORY_MODEL_60K
load_dolphindos:
dolphindos_load:
// Timing is critical for some parts, do not allow interrupts
sei
@@ -26,12 +26,12 @@ load_dolphindos:
// FALLTROUGH
load_dolphindos_loop:
dolphindos_load_loop:
#if !CONFIG_IEC_DOLPHINDOS_FAST
// Check if this was EOI
bit IOSTATUS
bvs load_dolphindos_end
bvs dolphindos_load_end
#endif
// Wait for the talker to release the CLK line
@@ -59,7 +59,7 @@ load_dolphindos_loop:
ldx #$13
!:
bit CIA2_PRA
bvc load_dolphindos_no_eoi
bvc dolphindos_load_no_eoi
dex
bne !-
@@ -79,7 +79,7 @@ load_dolphindos_loop:
// End of load loop
jmp load_iec_loop_end
load_dolphindos_no_eoi:
dolphindos_load_no_eoi:
#endif
@@ -98,13 +98,13 @@ load_dolphindos_no_eoi:
// Handle EAL
iny
bne load_dolphindos_loop
bne dolphindos_load_loop
inc EAL+1
jmp load_dolphindos_loop
jmp dolphindos_load_loop
#if !CONFIG_IEC_DOLPHINDOS_FAST
load_dolphindos_end:
dolphindos_load_end:
// Update EAL
clc
@@ -1,61 +0,0 @@
//
// DolphinDOS protocol support for IEC - byte reception
//
#if CONFIG_IEC_DOLPHINDOS
// XXX experimental, partially copied from standard protocol, not fully tested yet!
// XXX maybe this can be integrated into iec_rx_byte???
iec_rx_byte_dolphindos:
// Store .X and .Y on the stack - preserve them
phx_trash_a
phy_trash_a
// First, we wait for the talker to release the CLK line
jsr iec_wait_for_clk_release
// We then release the DATA to signal we are ready
// We can use this routine, since we were not pulling CLK anyway
jsr iec_release_clk_data
// Wait for talker to pull CLK.
// If over 200 usec (205 cycles on NTSC machine) , then it is EOI.
// Loop iteraction takes 13 cycles, 17 full iterations are enough
ldx #$11 // 2 cycles
iec_rx_dd_clk_wait1:
lda CIA2_PRA // 4 cycles
rol // 2 cycles, to put CLK in as the last bit
bpl iec_rx_dd_not_eoi // 2 cycles if not jumped
dex // 2 cycles
bne iec_rx_dd_clk_wait1 // 3 cycles if jumped
// Timeout - either this is the last byte of stream, or the stream is empty at all.
// Mark end of stream in IOSTATUS
jsr kernalstatus_EOI
iec_rx_dd_not_empty:
// Pull data for 60 usec to confirm it
jsr iec_release_clk_pull_data
jsr iec_wait60us
jsr iec_release_clk_data
iec_rx_dd_not_eoi:
// Retrieve byte via parallel, store it
lda CIA2_PRB
sta TBTCNT // $A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html
// Inform the drive about byte reception
jsr iec_release_clk_pull_data
jmp iec_rx_end
#endif
-22
View File
@@ -1,22 +0,0 @@
//
// Arbitration code for normal/JiffyDOS transfer
//
#if CONFIG_IEC_JIFFYDOS
iec_rx_dispatch:
lda IECPROTO
#if CONFIG_IEC_JIFFYDOS
cmp #$01
beq_far iec_rx_byte_jiffydos
#endif // CONFIG_IEC_JIFFYDOS
jmp iec_rx_byte
#endif
@@ -1,15 +0,0 @@
//
// DolphinDOS protocol support for IEC - byte transfer
//
#if CONFIG_IEC_DOLPHINDOS
iec_tx_byte_dolphindos:
panic #$00 // XXX implement this
#endif
-45
View File
@@ -1,45 +0,0 @@
//
// Arbitration code for normal/turbo transfer
//
#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS
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
#if CONFIG_IEC_DOLPHINDOS
cmp #$02
beq iec_tx_dispatch_dolphindos
#endif // CONFIG_IEC_DOLPHINDOS
// 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
#if CONFIG_IEC_DOLPHINDOS
iec_tx_dispatch_dolphindos:
plp
jmp iec_tx_byte_dolphindos
#endif // CONFIG_IEC_DOLPHINDOS
#endif // any turbo supported
@@ -15,7 +15,7 @@
// will want to terminate the loading.
load_jiffydos:
jiffydos_load:
// Timing is critical, do not allow interrupts
sei
@@ -48,7 +48,7 @@ load_jiffydos:
// FALLTROUGH
load_jiffydos_loop:
jiffydos_load_loop:
// Wait until device is ready to send (releases CLK)
jsr iec_wait_for_clk_release
@@ -118,15 +118,15 @@ load_jiffydos_loop:
stx CIA2_PRA
// If CLK line not active - this was the last byte
bvs load_jiffydos_end
bvs jiffydos_load_end
// Handle EAL
cpy #$FF
bne load_jiffydos_loop
bne jiffydos_load_loop
inc EAL+1
jmp load_jiffydos_loop
jmp jiffydos_load_loop
load_jiffydos_end:
jiffydos_load_end:
// Save last byte
tax
@@ -7,7 +7,7 @@
#if CONFIG_IEC_JIFFYDOS
iec_rx_byte_jiffydos:
jiffydos_rx_byte:
// Timing is critical, do not allow interrupts
sei
@@ -81,14 +81,15 @@ iec_rx_byte_jiffydos:
stx CIA2_PRA
// If CLK line active - success
bvc iec_rx_byte_jiffydos_end
bvc jiffydos_rx_byte_end
// XXX the DATA line can probably be used to distinguish between file not found error and normal stream EOI
jsr kernalstatus_EOI
// FALLTROUGH
iec_rx_byte_jiffydos_end:
jiffydos_rx_byte_end:
// Indicate that no byte waits in output buffer
lda #$00
@@ -7,7 +7,7 @@
#if CONFIG_IEC_JIFFYDOS
iec_tx_byte_jiffydos:
jiffydos_tx_byte:
// Timing is critical, do not allow interrupts
sei
@@ -70,11 +70,11 @@ iec_tx_byte_jiffydos:
// Signal EOI if needed; cycles till no EOI: 3 + 3 + 2 + 2 + 4 = 14
lda C3PO
ldx IECPROTO
beq iec_tx_byte_jiffydos_wait_eoi
beq jiffydos_tx_byte_wait_eoi
// FALLTROUGH
iec_tx_byte_jiffydos_finalize:
jiffydos_tx_byte_finalize:
ora #BIT_CIA2_PRA_CLK_OUT // pull CLK
sta CIA2_PRA
@@ -92,12 +92,12 @@ iec_tx_byte_jiffydos_finalize:
jmp iec_return_success
iec_tx_byte_jiffydos_wait_eoi:
jiffydos_tx_byte_wait_eoi:
sta CIA2_PRA
jsr iec_wait20us
lda C3PO
jmp iec_tx_byte_jiffydos_finalize
jmp jiffydos_tx_byte_finalize
#endif // CONFIG_IEC_JIFFYDOS