more sane directory name, updated binaries

This commit is contained in:
FeralChild64 committed 2020-06-26 19:44:01 +02:00
1 parent d4d32095d1
commit 76aaf298b8
697 files changed
+56 -56

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Common part of CHKIN and CKOUT
//
chkinout_device_not_present:
ply_trash_a
pla
jsr kernalstatus_DEVICE_NOT_FOUND
jmp kernalerror_DEVICE_NOT_FOUND
chkinout_file_not_open:
ply_trash_a
pla
jmp kernalerror_FILE_NOT_OPEN
+38
View File
@@ -0,0 +1,38 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 281
// - [CM64] Computes Mapping the Commodore 64 - page 230
//
// CPU registers that has to be preserved (see [RG64]): .Y
//
clall_real:
// Store .Y register
phy_trash_a
// Original routine probably just sets LDTND to 0, but this is not really safe,
// so we actually close all the channels; at least IDE64 does the same for
// its channels, see CLALL description in the IDE64 Users Guide
!:
ldy LDTND
beq !+
dey
lda LAT, y
jsr JCLOSE
jmp !-
!:
// Restore .Y register
ply_trash_a
// 'C64 Programmers Reference Guide', page 281, claims it calls CLRCHN too
jsr CLRCHN
// Not sure whether original Kernal does so, but it seems sane to also clear possible errors
jmp kernalstatus_reset
+5
View File
@@ -0,0 +1,5 @@
The original reason to move PLOT routine into its original position was to provide support for unofficial $E50C address:
- it is well known: https://www.lemon64.com/forum/viewtopic.php?t=3296&amp%3Bstart=15
https://sys64738.org/2019/05/c64-bedtime-coding-eng-printing-08/
- 'Duotris' game calls $E50C during startup screen initialization
+37
View File
@@ -0,0 +1,37 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 290
// - [CM64] Computes Mapping the Commodore 64 - page 215
//
// CPU registers that has to be preserved (see [RG64]): none
//
PLOT:
bcs plot_get
// Note: the 'set' part has to start from $E50C, as this is a known address
// - https://www.lemon64.com/forum/viewtopic.php?t=3296&amp%3Bstart=15
// - https://sys64738.org/2019/05/c64-bedtime-coding-eng-printing-08/
// - 'Duotris' game calls $E50C during startup screen initialization
plot_set:
sty PNTR
stx TBLX
jsr screen_calculate_pointers
// FALLTROUGH to save one byte on RTS
plot_get:
ldy PNTR
ldx TBLX
rts
+16
View File
@@ -0,0 +1,16 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 283
// - [CM64] Computes Mapping the Commodore 64 - page 227/228
//
// CPU registers that has to be preserved (see [RG64]): for RS-232: .X, .Y
//
GETIN:
jmp getin_real
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+51
View File
@@ -0,0 +1,51 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 277/278
// - [CM64] Computes Mapping the Commodore 64 - page 228
//
// CPU registers that has to be preserved (see [RG64]): .Y
//
// Reads a byte of input, unless from keyboard.
// If from keyboard, then it gets a whole line of input, and returns the first char.
// Repeated calls after that read out the successive bytes of the line of input.
CHRIN:
// Determine the device number
lda DFLTN
// Try $00 - keyboard
beq_16 chrin_keyboard
// XXX Try $03 - screen
// cmp #$03
// beq_16 chrin_screen
#if HAS_RS232
// Try $02 - RS-232
cmp #$02
beq_16 chrin_rs232
#endif // HAS_RS232
chrin_getin: // jump entry for GETIN
#if CONFIG_IEC
// Try IEC devices
jsr iec_check_devnum_oc
bcc_16 chrin_iec
#endif // CONFIG_IEC
// Not a supported device
jmp lvs_device_not_found_error
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+80
View File
@@ -0,0 +1,80 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 278/279
// - [CM64] Computes Mapping the Commodore 64 - page 228
//
// CPU registers that has to be preserved (see [RG64]): .Y
// Additionally we have to preserve .X for out CHRIN and implementation
//
CHROUT:
sta SCHAR
// Save X and Y values
// (Confirmed by writing a test program that X and Y
// do not get modified, in agreement with C64 PRG
// description of CHROUT)
phx_trash_a
phy_trash_a
php
// Determine the device number
lda DFLTO
cmp #$03 // screen
beq_16 chrout_screen
#if HAS_RS232
cmp #$02
beq_16 chrout_rs232
#endif
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_16 chrout_iec
#endif
// FALLTROUGH
chrout_done_fail:
plp
// Restore X and Y
ply_trash_a
plx_trash_a
sec // indicate failure
rts
chrout_done_unknown_device:
plp
// Restore X and Y
ply_trash_a
plx_trash_a
// End wioth error
jmp lvs_device_not_found_error
chrout_done_success:
plp
cli // needed for screen (checked calling the routine on original ROMs), XXX what about other devices?
// Restore X and Y
ply_trash_a
plx_trash_a
lda SCHAR
clc // indicate success
rts
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+72
View File
@@ -0,0 +1,72 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routines, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 275
// - [CM64] Computes Mapping the Commodore 64 - page 229
//
// CPU registers that has to be preserved (see [RG64]): .Y, .A (see [CM64], page 213)
//
CHKIN:
// Store registers for preservation
pha
phy_trash_a
// Reset status
jsr kernalstatus_reset
// First retrieve the FAT/LAT/SAT table index (and check if file is open)
txa
jsr find_fls
bcs_16 chkinout_file_not_open
// Now we have table index in Y
lda FAT,Y
// Handle all the devices
beq chkin_set_device // 0 - keyboard
// Tape not supported here
#if HAS_RS232
cmp #$02
beq_16 chkin_rs232
#endif // HAS_RS232
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_16 chkin_iec
#endif // CONFIG_IEC
cmp #$03 // screen - only legal one left
bne_16 chkinout_device_not_present
chkin_set_device:
lda FAT,Y
sta DFLTN
// FALLTROUGH
chkinout_end:
ply_trash_a
pla
clc // indicate success
rts
chkin_file_not_input:
ply_trash_a
pla
jmp kernalerror_FILE_NOT_INPUT
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+65
View File
@@ -0,0 +1,65 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routines, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 276
// - [CM64] Computes Mapping the Commodore 64 - page 229
//
// CPU registers that has to be preserved (see [RG64]): .Y, .A (see [CM64], page 213)
//
CKOUT:
// Store registers for preservation
pha
phy_trash_a
// Reset status
jsr kernalstatus_reset
// First retrieve the FAT/LAT/SAT table index (and check if file is open)
txa
jsr find_fls
bcs_16 chkinout_file_not_open
// Now we have table index in Y
lda FAT,Y
// Handle all the devices
beq ckout_file_not_output // 0 - keyboard
// Tape not supported here
#if HAS_RS232
cmp #$02
beq_16 ckout_rs232
#endif // HAS_RS232
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_16 ckout_iec
#endif // CONFIG_IEC
cmp #$03 // screen - only legal one left
bne_16 chkinout_device_not_present
ckout_set_device:
lda FAT,Y
sta DFLTO
jmp chkinout_end
ckout_file_not_output:
ply_trash_a
pla
jmp kernalerror_FILE_NOT_OUTPUT
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+60
View File
@@ -0,0 +1,60 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 281/282
// - [CM64] Computes Mapping the Commodore 64 - page 229/230
// - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc (IEC command)
//
// CPU registers that has to be preserved (see [RG64]): none
//
CLOSE:
// Find the LAT / SAT / FAT entry which LAT corresponds to A
jsr find_fls
bcs close_end // XXX can we report error in IOSTATUS here?
// We have the entry index in .Y
lda FAT, y
// Perform device-specific actions
#if HAS_RS232
cmp #$02
beq_16 close_rs232
#endif
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_16 close_iec
#endif
// FALLTROUGH
close_remove_from_table:
// Remove channel from the table
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 close_remove_from_table
!:
// Decrement the list size variable
dec LDTND
clc // report success - not sure if original CLOSE does this, but it is nevertheless a good practice
close_end:
rts
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+11
View File
@@ -0,0 +1,11 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
// Our implementation is longer than the original one,
// placing it here would cause a collision with CLRCHN
CLALL:
jmp clall_real
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+35
View File
@@ -0,0 +1,35 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 282
// - [CM64] Computes Mapping the Commodore 64 - page 230
//
// CPU registers that has to be preserved (see [RG64]): .Y
//
CLRCHN:
#if CONFIG_IEC
jsr clrchn_iec
#else
nop // just to prevent double label
#endif
// FALLTROUGH
clrchn_reset: // entry needed by setup_vicii
// Set input device number to keyboard
lda #$00
sta DFLTN
// Set output device number to screen
lda #$03
sta DFLTO
rts
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+81
View File
@@ -0,0 +1,81 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 289
// - [CM64] Computes Mapping the Commodore 64 - page 230/231
//
// CPU registers that has to be preserved (see [RG64]): none
//
OPEN:
// Reset status
jsr kernalstatus_reset
// Check if the logical file number is unique
ldy LDTND
!:
beq !+
dey
lda LAT, y
cmp LA
bne open_not_yet_open
jmp kernalerror_FILE_ALREADY_OPEN
open_not_yet_open:
cpy #$00
jmp !-
!:
// Check if we have space in tables
ldy LDTND
cpy #$0A
bcc open_has_space
!:
// Table is full
jmp kernalerror_TOO_MANY_OPEN_FILES
open_has_space:
// Update the tables
// LAT / FAT / SAT support implemented according to
// 'Computes Mapping the Commodore 64', page 52
lda LA
sta LAT, y
lda FA
sta FAT, y
lda SA
sta SAT, y
iny
sty LDTND
lda FA
#if HAS_RS232
cmp #$02
beq_16 open_rs232
#endif
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_16 open_iec
#endif
// FALLTROUGH
open_done_success:
clc
rts
+2
View File
@@ -0,0 +1,2 @@
This is a well-known address of a heavily used Kernal routine, it has to be the same so our ROM is compatible.
+26
View File
@@ -0,0 +1,26 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// LOAD preparation routine
//
//
// Input (according to http://sta.c64.org/cbm64krnfunc.html)
// .A - 0 for load, non-0 for verify
// .X and .Y - load address (if secondary address is 0)
//
//
// Note: Although the vector at $330 points to $F4A5, the Kernal jump table points to $F49E
// (see also Mapping the C64, page 76). By experimenting I have discovered that $F49E performs
// indirect jump via ($0330) vector, after setting MEMUSS.
//
LOAD_PREP:
sty MEMUSS+1
stx MEMUSS+0
jmp (ILOAD)
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+74
View File
@@ -0,0 +1,74 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 286
// - [CM64] Computes Mapping the Commodore 64 - page 231
// - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
//
// CPU registers that has to be preserved (see [RG64]): none
//
// Expects that SETLFS and SETNAM are called before hand.
// $YYXX = load address.
// (ignored if SETLFS channel = 1, i.e., like ,8,1)
// If A=1 then VERIFY instead of LOAD.
// On exit, $YYXX is the highest address into which data
// will have been placed.
LOAD:
// Are we loading or verifying?
sta VERCKK
// Store start address of LOAD
lda MEMUSS+0
sta STAL+0
lda MEMUSS+1
sty STAL+1
// Reset status
jsr kernalstatus_reset
#if CONFIG_MEMORY_MODEL_60K
// We need our helpers to get to filenames under ROMs or IO area
jsr install_ram_routines
#endif
// Check whether we support the requested device
lda FA
#if !CONFIG_TAPE_AUTODETECT
#if CONFIG_TAPE_NORMAL
cmp #$01
beq_16 load_tape_normal
#endif
#if CONFIG_TAPE_TURBO
cmp #$07
beq_16 load_tape_turbo
#endif
#else // CONFIG_TAPE_AUTODETECT
cmp #$01
beq_16 load_tape_auto
cmp #$07
beq_16 load_tape_auto
#endif
#if CONFIG_IEC
jsr iec_check_devnum_lvs
bcc_16 load_iec
#endif
jmp lvs_illegal_device_number
+2
View File
@@ -0,0 +1,2 @@
This is a well-known address of a heavily used Kernal routine, it has to be the same so our ROM is compatible.
+32
View File
@@ -0,0 +1,32 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// SAVE preparation routine
//
//
// Input (according to http://sta.c64.org/cbm64krnfunc.html)
// .A - address of zero page register holding start address of memory area to save
// .X and .Y - end address of memory area plus 1
//
//
// Note: Experimenting can easily confirm that SAVE preparation routine does similar
// actions as LOAD preparation routine.
//
SAVE_PREP:
sty EAL+1
stx EAL+0
tax
lda $01, x
sta STAL+1
lda $00, x
sta STAL+0
jmp (ISAVE)
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+33
View File
@@ -0,0 +1,33 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 293/294
// - [CM64] Computes Mapping the Commodore 64 - page 231/232
// - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
//
// CPU registers that has to be preserved (see [RG64]): none
//
SAVE:
// Reset status
jsr kernalstatus_reset
#if CONFIG_MEMORY_MODEL_60K
// We need our helpers to get to filenames under ROMs or IO area
jsr install_ram_routines
#endif
// Check whether we support the requested device
lda FA
#if CONFIG_IEC
jsr iec_check_devnum_lvs
bcc_16 save_iec
#endif
jmp lvs_illegal_device_number
+8
View File
@@ -0,0 +1,8 @@
All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses.
Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point
to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify
different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original
C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory).
For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal.
+25
View File
@@ -0,0 +1,25 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
// Just a helper routine
// Find the LAT / SAT / FAT entry index where LAT corresponds to A, returns index in Y
// Carry flag set means not found
find_fls:
ldy LDTND
!:
dey
bmi find_fls_not_found // no more entries
cmp LAT, y
bne !- // does not match, try the next one
clc
rts
find_fls_not_found:
sec
rts
+31
View File
@@ -0,0 +1,31 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 283
// - [CM64] Computes Mapping the Commodore 64 - page 227/228
//
// CPU registers that has to be preserved (see [RG64]): for RS-232: .X, .Y
//
getin_real:
// Determine the device number
lda DFLTN
// Try $00 - keyboard
beq_16 getin_keyboard
#if HAS_RS232
// Try $02 - RS-232
cmp #$02
beq_16 getin_rs232
#endif // HAS_RS232
jmp chrin_getin
+288
View File
@@ -0,0 +1,288 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Helper functions for various LOAD/VERIFY/SAVE routine variants (IEC / U64 / etc.)
//
lvs_handle_byte_load_verify:
ldy VERCKK
bne lvs_handle_byte_verify
// As with our BASIC, we want to enable LOADing
// anywhere in memory, including over the IO space.
// Thus we have to use a helper routine in low memory
// to do the memory access
#if CONFIG_MEMORY_MODEL_60K
// Save byte under ROMs and IO if required
php
sei
ldx #$33
stx $01
ldy #0
sta (EAL),y
ldx #$37
stx $01
plp
#else
ldy #0
sta (EAL),y
#endif
// FALLTROUGH
lvs_handle_byte_load_verify_end:
clc
rts
lvs_handle_byte_verify:
#if CONFIG_MEMORY_MODEL_60K
// Store byte for comparing
sta TBTCNT
// Retrieve byte from under ROMs and IO if required
php
sei
ldx #$33
stx $01
ldy #0
lda (EAL),y
ldx #$37
stx $01
plp
// Compare with stored byte
cmp TBTCNT
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
// Store byte for comparing
sta TBTCNT
ldy #0
jsr peek_under_roms_via_EAL
// Compare with stored byte
cmp TBTCNT
#else // CONFIG_MEMORY_MODEL_38K
ldy #0
cmp (EAL),y
#endif
beq lvs_handle_byte_load_verify_end
sec
rts
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO || CONFIG_IEC
lvs_STAL_to_MEMUSS:
lda STAL+0
sta MEMUSS+0
lda STAL+1
sta MEMUSS+1
rts
#endif
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO || CONFIG_IEC
#if !HAS_OPCODES_65CE02
lvs_advance_MEMUSS:
// Advance pointer
inc MEMUSS+0
bne !+
inc MEMUSS+1
!:
rts
#endif
lvs_check_EAL:
lda MEMUSS+1
cmp EAL+1
bne !+
lda MEMUSS+0
cmp EAL+0
!:
rts
lvs_display_searching_for:
lda MSGFLG
bpl lvs_display_end
ldx #__MSG_KERNAL_SEARCHING_FOR
jsr print_kernal_message
ldy #$00
!:
cpy FNLEN
beq lvs_display_end
#if CONFIG_MEMORY_MODEL_60K
ldx #<FNADDR+0
jsr peek_under_roms
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
jsr peek_under_roms_via_FNADDR
#else // CONFIG_MEMORY_MODEL_38K
lda (FNADDR),y
#endif
jsr JCHROUT
iny
jmp !-
lvs_display_end:
rts
lvs_display_loading_verifying:
// Display LOADING / VERIFYING and start address
lda MSGFLG
bpl lvs_display_end
ldx #__MSG_KERNAL_LOADING
lda VERCKK
beq !+
ldx #__MSG_KERNAL_VERIFYING
!:
jsr print_kernal_message
// FALLTHROUGH
lvs_display_start_addr:
ldx #__MSG_KERNAL_FROM_HEX
jsr print_kernal_message
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO
lda FA
#if CONFIG_TAPE_NORMAL
cmp #$01
beq lvs_display_addr_STAL
#endif
#if CONFIG_TAPE_TURBO
cmp #$07
beq lvs_display_addr_STAL
#endif
#endif
// FALLTROUGH
lvs_display_addr_EAL:
lda EAL+1
jsr print_hex_byte
lda EAL+0
jmp print_hex_byte
lvs_display_addr_STAL:
lda STAL+1
jsr print_hex_byte
lda STAL+0
jmp print_hex_byte
lvs_display_done:
// Display end address
lda MSGFLG
bpl lvs_display_end
ldx #__MSG_KERNAL_TO_HEX
jsr print_kernal_message
jmp lvs_display_addr_EAL
lvs_display_saving:
// Display SAVING and file name
lda MSGFLG
bpl lvs_display_end
ldx #__MSG_KERNAL_SAVING
jsr print_kernal_message
ldy #$00
!:
cpy FNLEN
beq !+
lda (FNADDR), y
jsr JCHROUT
iny
bne !- // jump always
!:
rts
lvs_error_end:
sec
rts
lvs_return_last_address:
// Return last address - Computes Mapping the 64 says without the '+1',
// checked (short test program) on original ROMs that this is really the case
ldx EAL+0
ldy EAL+1
// FALLTHROUGH
lvs_success_end:
clc
rts
#endif
lvs_device_not_found_error:
jsr kernalstatus_DEVICE_NOT_FOUND
jmp kernalerror_DEVICE_NOT_FOUND
lvs_illegal_device_number:
jsr kernalstatus_DEVICE_NOT_FOUND
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO || CONFIG_IEC
lvs_load_verify_error:
// XXX should we really return BASIC error code here?
lda VERCKK
bne lvs_verify_error
lda #B_ERR_LOAD
bne lvs_error_end
// FALLTHROUGH
lvs_verify_error:
lda #B_ERR_VERIFY
sec
rts
#endif
+25
View File
@@ -0,0 +1,25 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
// Pop key out of keyboard buffer
// Disable interrupts while reading from keyboard buffer
// so that no race conditions can occur
//
// CPU registers that has to be preserved: .X
//
pop_keyboard_buffer:
ldy #$01
sei
!: lda KEYD,y
sta KEYD-1,y
iny
cpy XMAX
bne !-
dec NDX
cli
rts
+34
View File
@@ -0,0 +1,34 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 292
// - [CM64] Computes Mapping the Commodore 64 - page 239
//
// CPU registers that has to be preserved (see [RG64]): .X, .Y
//
READST:
// Check the current device number
lda FA
cmp #$02
bne !+
// This is RS-232 device - according to 'Computes Mapping the Commodore 64' page 239
// it reads status from RSSTAT
// XXX 'lda RSSTAT' not possible due to extended scnkey, fix it!
lda #$FF
rts
!:
// According to 'Computes Mapping the Commodore 64' page 239, it usually retrieves
// status from IOSTATUS
// XXX is it always the case if device is not RS-232 ?
lda IOSTATUS
rts
+23
View File
@@ -0,0 +1,23 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 297
// - [CM64] Computes Mapping the Commodore 64 - page 238
//
// CPU registers that has to be preserved (see [RG64]): .A, .X, .Y
//
SETFLS:
// There are 6 sane ways to implement this routine,
// I hope this one will not cause similarity to CBM code
sta LA
sty SA
stx FA
rts
+17
View File
@@ -0,0 +1,17 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 298
// - [CM64] Computes Mapping the Commodore 64 - page 239
//
// CPU registers that has to be preserved (see [RG64]): .A, .X, .Y
//
SETMSG:
sta MSGFLG
rts
+23
View File
@@ -0,0 +1,23 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 298/299
// - [CM64] Computes Mapping the Commodore 64 - page 238
//
// CPU registers that has to be preserved (see [RG64]): .A, .X, .Y
//
SETNAM:
// There are 6 sane ways to implement this routine,
// I hope this one will not cause similarity to CBM code
sta FNLEN
sty FNADDR + 1
stx FNADDR + 0
rts
+18
View File
@@ -0,0 +1,18 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmers Reference Guide - page 300
// - [CM64] Computes Mapping the Commodore 64 - page 239
//
// CPU registers that has to be preserved (see [RG64]): .A, .X, .Y
//
SETTMO:
sta TIMOUT
rts