size optimization of the IEC support
This commit is contained in:
1 parent
ef183a6cb1
commit
ee499b6b21
2 files changed
+13
-21
No files matched your search
@@ -19,17 +19,10 @@ iec_tx_command:
|
|||||||
;; and it is going to be a command (pulled ATN)
|
;; and it is going to be a command (pulled ATN)
|
||||||
jsr iec_pull_atn_clk_release_data
|
jsr iec_pull_atn_clk_release_data
|
||||||
|
|
||||||
;; Give devices time to respond (response is mandatory!)
|
;; Give devices time to respond (response is mandatory!) by pulling DATA
|
||||||
jsr iec_wait1ms
|
jsr iec_wait1ms_for_data
|
||||||
|
bmi iec_tx_command_dev_not_found
|
||||||
|
|
||||||
;; Did at least one device respond by pulling DATA?
|
|
||||||
lda CIA2_PRA
|
|
||||||
and #BIT_CIA2_PRA_DAT_IN ; XXX try to optimize this, move to separate routine
|
|
||||||
beq +
|
|
||||||
|
|
||||||
;; No devices present on the bus, so we can immediately return with device not found
|
|
||||||
jmp iec_return_DEVICE_NOT_FOUND
|
|
||||||
*
|
|
||||||
;; At least one device responded, but they are still allowed to stall
|
;; At least one device responded, but they are still allowed to stall
|
||||||
;; (can be busy processing something), we have to wait till they are all
|
;; (can be busy processing something), we have to wait till they are all
|
||||||
;; ready (or bored with DOS attack...)
|
;; ready (or bored with DOS attack...)
|
||||||
@@ -46,17 +39,14 @@ iec_tx_command:
|
|||||||
;; According to https://www.pagetable.com/?p=1135 there is some complicated and dangerous
|
;; According to https://www.pagetable.com/?p=1135 there is some complicated and dangerous
|
||||||
;; flow here, but http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf (page 6)
|
;; flow here, but http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf (page 6)
|
||||||
;; advices to just wait 1ms and check the DATA status
|
;; advices to just wait 1ms and check the DATA status
|
||||||
jsr iec_wait1ms
|
|
||||||
lda CIA2_PRA
|
|
||||||
and #BIT_CIA2_PRA_DAT_IN ; XXX try to optimize this, move to separate routine
|
|
||||||
beq +
|
|
||||||
|
|
||||||
;; XXX possible optimization of the flow above: for many commands it is enough
|
jsr iec_wait1ms_for_data
|
||||||
;; to wait for the DATA being pulled, as confirmation is expected from
|
bmi iec_tx_command_dev_not_found
|
||||||
;; a single device only - but not sure if it's worth the trouble
|
|
||||||
|
|
||||||
jmp iec_return_DEVICE_NOT_FOUND
|
|
||||||
*
|
|
||||||
;; Done
|
;; Done
|
||||||
|
|
||||||
jmp iec_return_success
|
jmp iec_return_success
|
||||||
|
|
||||||
|
iec_tx_command_dev_not_found:
|
||||||
|
|
||||||
|
jmp iec_return_DEVICE_NOT_FOUND
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
;;
|
;;
|
||||||
;; Wait 1 ms (1000 usec)
|
;; Wait 1 ms (1000 usec) - afterwards can use 'bpl' to check that DATA is pulled
|
||||||
;;
|
;;
|
||||||
;; On NTSC this means 1023 cycles (slightly less on PAL, but we have to be sure).
|
;; On NTSC this means 1023 cycles (slightly less on PAL, but we have to be sure).
|
||||||
;; We can't count on badlines, as the screen might be disabled.
|
;; We can't count on badlines, as the screen might be disabled.
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
;; 63 cycles, we need at least 17 full rasters to be 100% sure we wait enough
|
;; 63 cycles, we need at least 17 full rasters to be 100% sure we wait enough
|
||||||
|
|
||||||
|
|
||||||
iec_wait1ms:
|
iec_wait1ms_for_data:
|
||||||
ldx #18 ; we probably won't start with the beginning of raster
|
ldx #18 ; we probably won't start with the beginning of raster
|
||||||
lda VIC_RASTER
|
lda VIC_RASTER
|
||||||
*
|
*
|
||||||
@@ -17,4 +17,6 @@ iec_wait1ms:
|
|||||||
lda VIC_RASTER
|
lda VIC_RASTER
|
||||||
dex
|
dex
|
||||||
bne -
|
bne -
|
||||||
|
|
||||||
|
lda CIA2_PRA ; pulled DATA = highest bit 0 = 'plus'
|
||||||
rts
|
rts
|
||||||
Reference in new issue
Block a user