From 0b95f9646fdd783d71fef3032746e5d5f05c9cd3 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 14 Jun 2019 20:59:07 +0200 Subject: [PATCH] implemented VECTOR routine --- c64/basic/,aliases.s | 7 ++++ c64/kernal/,aliases.s | 5 +++ c64/kernal/restor.s | 42 ----------------------- c64/kernal/vector.s | 78 +++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 88 insertions(+), 44 deletions(-) delete mode 100644 c64/kernal/restor.s diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index 6b8abe57..e91993c0 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -66,6 +66,13 @@ .alias load_or_scroll_temp_pointer $AC ;; We also use the following for temp colour pointer when scrolling .alias load_save_verify_end_address $AE + + ;; 2-byte location below seems to be a good place for temporary storage, + ;; it seems used for timing during tape reads only - see: + ;; - 'C64 Programmer's Reference Guide', page 314 + ;; - 'Compute's Mapping the Commodore 64', page 32 + .alias CMP0 $B0 ;; $B0-$B1 + .alias cassette_buffer_ptr $B2 .alias current_filename_length $B7 .alias current_logical_filenum $B8 diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 47ca4cc8..8acaed6e 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -51,6 +51,11 @@ .alias rs232_rx_buffer_ptr $F7 .alias rs232_tx_buffer_ptr $F9 + ;; 2-byte location below seems to be a good place for temporary storage, + ;; it seems used for timing during tape reads only - see: + ;; - 'C64 Programmer's Reference Guide', page 314 + ;; - 'Compute's Mapping the Commodore 64', page 32 + .alias CMP0 $B0 ;; $B0-$B1 ; "Compute's Mapping the 64" book .alias keyboard_buffer $0277 diff --git a/c64/kernal/restor.s b/c64/kernal/restor.s deleted file mode 100644 index 8b26484a..00000000 --- a/c64/kernal/restor.s +++ /dev/null @@ -1,42 +0,0 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide -restor: - - ;; According to 'Compute's Mapping the Commodore 64' p237 this resets 15 vectors - ;; placed starting from $0314 - - ;; XXX simplify this implementation when vector is implemented - - ;; Make sure the IRQ is disabled - better safe than sorry - php - cli - - ;; Copy vectors in a loop - ldx #$1F -* - lda restor_def_arr, x - sta CINV, x - dex - bpl - - - ;; Restore status register before return - plp - rts - -restor_def_arr: - .word $0000 ;; CINV XXX implement this - .word $0000 ;; CBINV XXX implement this - .word $0000 ;; NMINV XXX implement this - - .word open ;; IOPEN - .word close ;; ICLOSE - .word chkin ;; ICHKIN - .word chkout ;; ICKOUT - .word clrchn ;; ICLRCH - .word chrin ;; IBASIN - .word chrout ;; IBASOUT - .word stop ;; ISTOP - .word getin ;; IGETIN - .word clall ;; ICLALL - .word $0000 ;; USRCMD XXX implement this - .word load ;; ILOAD - .word save ;; ISAVE diff --git a/c64/kernal/vector.s b/c64/kernal/vector.s index cacc606f..2a8c6e5d 100644 --- a/c64/kernal/vector.s +++ b/c64/kernal/vector.s @@ -1,6 +1,80 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide +; Functions defined on pp272-273 of C64 Programmers Reference Guide + +restor: + + clc ;; clear carry - for writing to system table + ldx #vector_defaults + + ;; FALLTHROUGH + vector: - ;; XXX adapt restor when this is implemented +.scope + ;; Temporary storage location + .alias _caller_arr_ptr CMP0 + + ;; According to 'Compute's Mapping the Commodore 64' page 237, + ;; the CBM implementation does not disable IRQs - yet, the + ;; 'C64 Programmers Reference Guide' does not contain such + ;; warning and does not mention any preparations needed, so... + ;; better safe than sorry, disable the IRQ for the duration + ;; of vector manipulation + php + cli + + ;; Prepare the user data pointer + stx _caller_arr_ptr + 0 + sty _caller_arr_ptr + 1 + + ;; Select routine variant - store or restore vectors + ldy #$1F + bcc vector_restore + + ;; FALLTHROUGH + +vector_store: +* + lda CINV, y + sta (_caller_arr_ptr), y + dey + bpl - + + ;; Restore status register (IRQ) before return + plp rts + +vector_restore: +* + lda (_caller_arr_ptr), y + sta CINV, y + dey + bpl - + + ;; Restore status register (IRQ) before return + plp + rts + +.scend + + ;; XXX below we have quite a lot of data... should we decouple them? + +vector_defaults: + .word $0000 ;; CINV XXX implement this + .word $0000 ;; CBINV XXX implement this + .word $0000 ;; NMINV XXX implement this + + .word open ;; IOPEN + .word close ;; ICLOSE + .word chkin ;; ICHKIN + .word chkout ;; ICKOUT + .word clrchn ;; ICLRCH + .word chrin ;; IBASIN + .word chrout ;; IBASOUT + .word stop ;; ISTOP + .word getin ;; IGETIN + .word clall ;; ICLALL + .word $0000 ;; USRCMD XXX implement this + .word load ;; ILOAD + .word save ;; ISAVE