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
+169 -97

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 | |
| $FFBA | SETFLS | DONE | |
| $FFBD | SETNAM | DONE | |
| $FFC0 | OPEN | PARTIAL | * work in progress |
| $FFC0 | OPEN | DONE | |
| $FFC3 | CLOSE | DONE | |
| $FFC6 | CHKIN | DONE | |
| $FFC9 | CHKOUT | PARTIAL | |
+2 -2
View File
@@ -42,7 +42,7 @@ chkin:
;; For IEC devices, send TALK + TKSA first
lda FAT,Y
jsr iec_devnum_check
jsr iec_check_devnum
bcs chkin_set_device
jsr talk
@@ -125,7 +125,7 @@ ckout:
;; For IEC devices, send LISTEN + SECOND first
lda FAT,Y
jsr iec_devnum_check
jsr iec_check_devnum
bcs chkin_set_device
jsr listen
+1 -1
View File
@@ -21,7 +21,7 @@ chrin:
beq chrin_keyboard ; #$00 - keyboard
;; XXX add screen support
jsr iec_devnum_check
jsr iec_check_devnum
bcs chrin_done_fail ; not a supported device
chrin_iec:
+33 -31
View File
@@ -27,16 +27,44 @@ chrout:
cmp #$03 ; screen
beq chrout_screen
jsr iec_devnum_check
jsr iec_check_devnum
bcs chrout_done_fail ; not a supported device
chrout_iec:
lda last_printed_character_ascii
jsr JCIOUT
bcs chrout_done_fail
jmp chrout_done
bcc 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:
@@ -399,33 +427,7 @@ not_quote:
sta current_screen_x
jmp screen_advance_to_next_line
no_screen_advance_to_next_line:
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
jmp chrout_done
screen_grow_logical_line:
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
lda FAT, y
jsr iec_devnum_check
jsr iec_check_devnum
bcs close_remove_from_table
;; IEC device
+2 -2
View File
@@ -13,14 +13,14 @@ clrchn:
;; Handle IEC input device
lda DFLTN
jsr iec_devnum_check
jsr iec_check_devnum
bcs +
;; Previous device was IEC one - send UNTALK first
jsr untlk
*
;; Restore output device to default
lda DFLTO
jsr iec_devnum_check
jsr iec_check_devnum
bcs +
;; Handle IEC output device
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
;;
iec_devnum_check:
iec_check_devnum:
;; 0, 1, 2, or 3 are illegal - reserved for non-IEC devices on Commodore
cmp #$04
bcs +
;; FALLTROUGH
iec_devnum_check_failed:
iec_check_devnum_failed:
sec ; indicate non-IEC device
rts
*
;; 31 and above are illegal too, due to IEC command encoding scheme,
;; see https://www.pagetable.com/?p=1031
cmp #$1F
bcs iec_devnum_check_failed
bcs iec_check_devnum_failed
;; Carry is clear here - indicates IEC device
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
;; Check whether device number is correct
jsr iec_devnum_check
bcs kernalerror_DEVICE_NOT_FOUND
jsr iec_check_devnum
bcc +
jmp kernalerror_DEVICE_NOT_FOUND
*
;; Encode and execute the command
ora #$20
+5 -34
View File
@@ -62,42 +62,13 @@ load:
jsr listen
bcs lvs_device_not_found_error
;; Open channel #0 (p16)
lda #$F0 ; $F0 for TKSA + 0 for channel number
sta IEC_TMP2
jsr iec_tx_command
bcs lvs_load_verify_error
jsr iec_tx_command_finalize
;; Open channel 0 (reserved for file reading)
lda #$00
jsr iec_cmd_open
bcs lvs_load_verify_error
;; Send filename (p16)
ldy #0
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
;; Send file name
jsr lvs_send_file_name
bcs lvs_load_verify_error
;; 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.)
;;
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:
;; XXX add VERIFY support
+30 -1
View File
@@ -8,7 +8,6 @@
;; 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:
@@ -51,7 +50,37 @@ open_has_space:
iny
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
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:
;; 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
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
jmp common_unlsn_second
jmp common_open_close_unlsn_second
+4 -3
View File
@@ -17,9 +17,10 @@ talk:
jsr iec_tx_flush
;; Check whether device number is correct
jsr iec_devnum_check
bcs kernalerror_DEVICE_NOT_FOUND
jsr iec_check_devnum
bcc +
jmp kernalerror_DEVICE_NOT_FOUND
*
;; Encode and execute the command
ora #$40
+4 -3
View File
@@ -12,11 +12,12 @@
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
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
jmp common_untlk_tksa
+1 -7
View File
@@ -19,13 +19,7 @@ unlsn:
;; Buffer empty, send the command
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