finished OPEN routine, some IEC cleanups

This commit is contained in:
FeralChild64 committed 2019-07-25 21:40:24 +02:00
1 parent 893371733b
commit 32fbed93f7
17 files changed
+168 -96

No files matched your search

+1 -1
View File
@@ -88,7 +88,7 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on
| $FFB7 | READST | DONE | | | $FFB7 | READST | DONE | |
| $FFBA | SETFLS | DONE | | | $FFBA | SETFLS | DONE | |
| $FFBD | SETNAM | DONE | | | $FFBD | SETNAM | DONE | |
| $FFC0 | OPEN | PARTIAL | * work in progress | | $FFC0 | OPEN | DONE | |
| $FFC3 | CLOSE | DONE | | | $FFC3 | CLOSE | DONE | |
| $FFC6 | CHKIN | DONE | | | $FFC6 | CHKIN | DONE | |
| $FFC9 | CHKOUT | PARTIAL | | | $FFC9 | CHKOUT | PARTIAL | |
+2 -2
View File
@@ -42,7 +42,7 @@ chkin:
;; For IEC devices, send TALK + TKSA first ;; For IEC devices, send TALK + TKSA first
lda FAT,Y lda FAT,Y
jsr iec_devnum_check jsr iec_check_devnum
bcs chkin_set_device bcs chkin_set_device
jsr talk jsr talk
@@ -125,7 +125,7 @@ ckout:
;; For IEC devices, send LISTEN + SECOND first ;; For IEC devices, send LISTEN + SECOND first
lda FAT,Y lda FAT,Y
jsr iec_devnum_check jsr iec_check_devnum
bcs chkin_set_device bcs chkin_set_device
jsr listen jsr listen
+1 -1
View File
@@ -21,7 +21,7 @@ chrin:
beq chrin_keyboard ; #$00 - keyboard beq chrin_keyboard ; #$00 - keyboard
;; XXX add screen support ;; XXX add screen support
jsr iec_devnum_check jsr iec_check_devnum
bcs chrin_done_fail ; not a supported device bcs chrin_done_fail ; not a supported device
chrin_iec: chrin_iec:
+32 -30
View File
@@ -28,15 +28,43 @@ chrout:
cmp #$03 ; screen cmp #$03 ; screen
beq chrout_screen beq chrout_screen
jsr iec_devnum_check jsr iec_check_devnum
bcs chrout_done_fail ; not a supported device bcs chrout_done_fail ; not a supported device
chrout_iec: chrout_iec:
lda last_printed_character_ascii lda last_printed_character_ascii
jsr JCIOUT jsr JCIOUT
bcs chrout_done_fail bcc chrout_done
jmp chrout_done
;; FALLTROUGH
chrout_done_fail:
jsr show_cursor_if_enabled
plp
;; Restore X and Y, set carry to mark success on exit
pla
tay
pla
tax
sec ; indicate failure
rts
chrout_done:
jsr show_cursor_if_enabled
plp
;; Restore X and Y, set carry to mark success on exit
pla
tay
pla
tax
lda last_printed_character_ascii
clc ; indicate success
rts
chrout_screen: chrout_screen:
@@ -399,33 +427,7 @@ not_quote:
sta current_screen_x sta current_screen_x
jmp screen_advance_to_next_line jmp screen_advance_to_next_line
no_screen_advance_to_next_line: no_screen_advance_to_next_line:
jmp chrout_done
chrout_done:
jsr show_cursor_if_enabled
plp
;; Restore X and Y, set carry to mark success on exit
pla
tay
pla
tax
lda last_printed_character_ascii
clc ; indicate success
rts
chrout_done_fail:
jsr show_cursor_if_enabled
plp
;; Restore X and Y, set carry to mark success on exit
pla
tay
pla
tax
sec ; indicate failure
rts
screen_grow_logical_line: screen_grow_logical_line:
ldy current_screen_y ldy current_screen_y
+1 -1
View File
@@ -20,7 +20,7 @@ close:
;; We have the entry index in Y - check whether this is IEC device ;; We have the entry index in Y - check whether this is IEC device
lda FAT, y lda FAT, y
jsr iec_devnum_check jsr iec_check_devnum
bcs close_remove_from_table bcs close_remove_from_table
;; IEC device ;; IEC device
+2 -2
View File
@@ -13,14 +13,14 @@ clrchn:
;; Handle IEC input device ;; Handle IEC input device
lda DFLTN lda DFLTN
jsr iec_devnum_check jsr iec_check_devnum
bcs + bcs +
;; Previous device was IEC one - send UNTALK first ;; Previous device was IEC one - send UNTALK first
jsr untlk jsr untlk
* *
;; Restore output device to default ;; Restore output device to default
lda DFLTO lda DFLTO
jsr iec_devnum_check jsr iec_check_devnum
bcs + bcs +
;; Handle IEC output device ;; Handle IEC output device
jsr unlsn jsr unlsn
@@ -1,22 +1,22 @@
;; ;;
;; Checks whether device numbe (in .A) is a correct IEC device number ;; Checks whether device number (in .A) is a correct IEC device number
;; ;;
;; Preserves .A, .X and .Y ;; Preserves .A, .X and .Y
;; ;;
iec_devnum_check: iec_check_devnum:
;; 0, 1, 2, or 3 are illegal - reserved for non-IEC devices on Commodore ;; 0, 1, 2, or 3 are illegal - reserved for non-IEC devices on Commodore
cmp #$04 cmp #$04
bcs + bcs +
;; FALLTROUGH ;; FALLTROUGH
iec_devnum_check_failed: iec_check_devnum_failed:
sec ; indicate non-IEC device sec ; indicate non-IEC device
rts rts
* *
;; 31 and above are illegal too, due to IEC command encoding scheme, ;; 31 and above are illegal too, due to IEC command encoding scheme,
;; see https://www.pagetable.com/?p=1031 ;; see https://www.pagetable.com/?p=1031
cmp #$1F cmp #$1F
bcs iec_devnum_check_failed bcs iec_check_devnum_failed
;; Carry is clear here - indicates IEC device ;; Carry is clear here - indicates IEC device
rts rts
+20
View File
@@ -0,0 +1,20 @@
;;
;; Kernal internal IEC routine
;;
;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
;;
iec_cmd_close:
jsr iec_tx_flush
;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031),
;; allowed channels are 0-15; report error if out of range
cmp #$10
bcc +
jmp kernalerror_FILE_NOT_INPUT
*
ora #$E0
jmp common_open_close_unlsn_second
+29
View File
@@ -0,0 +1,29 @@
;;
;; Kernal internal IEC routine
;;
;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
;;
iec_cmd_open: ; similar to TKSA, but without turnaround
;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031),
;; allowed channels are 0-15; report error if out of range
cmp #$10
bcc +
jmp kernalerror_FILE_NOT_INPUT
*
ora #$F0
;; FALLTROUGH
common_open_close_unlsn_second: ; common part of several commands
sta IEC_TMP2
jsr iec_tx_command
bcs + ; branch if error
jmp iec_tx_command_finalize
*
rts
+4 -3
View File
@@ -17,9 +17,10 @@ listen:
jsr iec_tx_flush jsr iec_tx_flush
;; Check whether device number is correct ;; Check whether device number is correct
jsr iec_devnum_check jsr iec_check_devnum
bcs kernalerror_DEVICE_NOT_FOUND bcc +
jmp kernalerror_DEVICE_NOT_FOUND
*
;; Encode and execute the command ;; Encode and execute the command
ora #$20 ora #$20
+5 -34
View File
@@ -62,42 +62,13 @@ load:
jsr listen jsr listen
bcs lvs_device_not_found_error bcs lvs_device_not_found_error
;; Open channel #0 (p16) ;; Open channel 0 (reserved for file reading)
lda #$F0 ; $F0 for TKSA + 0 for channel number lda #$00
sta IEC_TMP2 jsr iec_cmd_open
jsr iec_tx_command
bcs lvs_load_verify_error
jsr iec_tx_command_finalize
bcs lvs_load_verify_error bcs lvs_load_verify_error
;; Send filename (p16) ;; Send file name
ldy #0 jsr lvs_send_file_name
load_send_filename:
cpy FNLEN
beq load_filename_sent
ldx #<current_filename_ptr
jsr peek_under_roms
iny
;; Set Carry flag on the last file name character, to mark EOI
cpy FNLEN
clc
bne +
sec
*
;; Transmit one character
sta IEC_TMP2
jsr iec_tx_byte
jmp load_send_filename
load_filename_sent:
;; Command device to unlisten to indicate end of file name. (p16)
jsr unlsn
bcs lvs_load_verify_error bcs lvs_load_verify_error
;; Now command device to talk (p16) ;; Now command device to talk (p16)
+22
View File
@@ -3,6 +3,28 @@
;; Helper functions for various LOAD/VERIVY/SAVE routine variants (IEC / U64 / etc.) ;; Helper functions for various LOAD/VERIVY/SAVE routine variants (IEC / U64 / etc.)
;; ;;
lvs_send_file_name:
ldy #0
lvs_send_file_name_loop:
cpy FNLEN
beq lvs_send_file_name_done
ldx #<current_filename_ptr
jsr peek_under_roms
iny
;; Set Carry flag on the last file name character, to mark EOI
cpy FNLEN
clc
bne +
sec
*
;; Transmit one character
sta IEC_TMP2
jsr iec_tx_byte
jmp lvs_send_file_name_loop
lvs_send_file_name_done:
jsr unlsn
rts
lvs_handle_byte_load_verify: lvs_handle_byte_load_verify:
;; XXX add VERIFY support ;; XXX add VERIFY support
+30 -1
View File
@@ -8,7 +8,6 @@
;; CPU registers that has to be preserved (see [RG64]): none ;; CPU registers that has to be preserved (see [RG64]): none
;; ;;
;; XXX send the name to the drive (if it's length is non-zero)
open: open:
@@ -52,6 +51,36 @@ open_has_space:
iny iny
sty LDTND sty LDTND
;; Check for command to send
lda FNLEN
beq open_done_success
;; Check for IEC device
lda current_device_number
jsr iec_check_devnum
bcc open_iec
;; FALLTROUGH
open_done_success:
clc clc
rts rts
open_iec:
;; We have a command to send to IEC device
jsr listen
bcc +
jmp kernalerror_DEVICE_NOT_FOUND
*
lda current_secondary_address
jsr iec_cmd_open
bcc +
jmp kernalerror_DEVICE_NOT_FOUND ; XXX find a better error message for wrong channel (create new one?)
*
;; Send command ('file name')
jsr lvs_send_file_name
jmp open_done_success
+6 -4
View File
@@ -12,12 +12,14 @@
second: second:
;; Due to TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031),
;; allowed channels are 0-15; report error if out of range ;; allowed channels are 0-15; report error if out of range
cmp #$10 cmp #$10
bcs kernalerror_FILE_NOT_INPUT bcc +
jmp kernalerror_DEVICE_NOT_FOUND ; XXX find a better error message for wrong channel (create new one?)
*
ora #$60 ora #$60
jmp common_unlsn_second jmp common_open_close_unlsn_second
+4 -3
View File
@@ -17,9 +17,10 @@ talk:
jsr iec_tx_flush jsr iec_tx_flush
;; Check whether device number is correct ;; Check whether device number is correct
jsr iec_devnum_check jsr iec_check_devnum
bcs kernalerror_DEVICE_NOT_FOUND bcc +
jmp kernalerror_DEVICE_NOT_FOUND
*
;; Encode and execute the command ;; Encode and execute the command
ora #$40 ora #$40
+4 -3
View File
@@ -12,11 +12,12 @@
tksa: tksa:
;; Due to TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031),
;; allowed channels are 0-15; report error if out of range ;; allowed channels are 0-15; report error if out of range
cmp #$10 cmp #$10
bcs kernalerror_FILE_NOT_INPUT bcc +
jmp kernalerror_DEVICE_NOT_FOUND ; XXX find a better error message for wrong channel (create new one?)
*
ora #$F0 ora #$F0
jmp common_untlk_tksa jmp common_untlk_tksa
+1 -7
View File
@@ -19,13 +19,7 @@ unlsn:
;; Buffer empty, send the command ;; Buffer empty, send the command
lda #$3F lda #$3F
common_unlsn_second: ; common part of UNSLS and SECOND jmp common_open_close_unlsn_second
sta IEC_TMP2
jsr iec_tx_command
bcs + ; branch if error
jmp iec_tx_command_finalize
*
rts