Files
open-roms/c64/kernal/close.s
T

44 lines
931 B
ArmAsm

;;
;; Official Kernal routine, described in:
;;
;; - [RG64] C64 Programmer's Reference Guide - page 281/282
;; - [CM64] Compute's Mapping the Commodore 64 - page 229/230
;;
;; CPU registers that has to be preserved (see [RG64]): none
;;
close:
;; XXX this needs more testing (opening 10 files at once, closing in various orders, etc) once the code is more mature
;; Find the LAT / SAT / FAT entry which LAT corresponds to A
jsr find_fls
bcs close_error_not_found ;; XXX can we report error in IOSTATUS here?
;; We have the entry index in Y
;; XXX some devices (like IEC) needs special support here, to free their internal resources!
;; Just make sure the Y register value is kept, or redo ldy DFTLN
*
iny
cpy #$0A
bpl +
lda LAT, y
sta LAT-1, y
lda FAT, y
sta FAT-1, y
lda SAT, y
sta SAT-1, y
jmp -
*
;; Decrement the list size variable
dec LDTND
;; FALLTHROUGH - success
close_error_not_found:
rts