.KERNALSETUP JSR SWAPPZERO ; Swap the contents of zero page with the page at $CE00, ; which we filled with the contents of zero page when we ; started the game ; ; This ensures that the Kernal functions get a zero page ; that works for them, and we can repeat the swap once ; we are done with the Kernal functions to ensure any ; changes they make do not corrupt the game's zero page ; variables LDA #%110 ; Set A to pass to the call to SETL1 so we page the ; Kernal ROM and I/O into the memory map SEI ; Disable interrupts so we can scan the keyboard ; without being hijacked JSR SETL1 ; Call SETL1 to set the 6510 input/output port to the ; following: ; ; * LORAM = 0 ; * HIRAM = 1 ; * CHAREN = 1 ; ; This sets the entire 64K memory map to RAM except for ; the I/O memory map at $D000-$DFFF, which gets mapped ; to registers in the VIC-II video controller chip, the ; SID sound chip, the two CIA I/O chips, and so on, and ; $E000-$FFFF, which gets mapped to the Kernal ROM ; ; See the memory map at the bottom of page 264 in the ; Programmer's Reference Guide LDA #0 ; Clear bits 0-3 in VIC register $1A to disable the STA VIC+$1A ; following interrupts: ; ; * Bit 0 = raster interrupt ; ; * Bit 1 = sprite-background collision interrupt ; ; * Bit 2 = sprite-sprite collision interrupt ; ; * Bit 3 = light pen interrupt CLI ; Allow interrupts again (or, as a comment in the ; original source says, "tell Ian to go away") LDA #%10000001 ; Set CIA1 register $0D to enable and disable interrupts STA CIA+$D ; as follows: ; ; * Bit 0 set = configure interrupts generated by ; timer A underflow ; ; * Bits 1-4 clear = do not change configuration of ; other interrupts ; ; * Bit 7 set = enable interrupts whose corresponding ; bits are set ; ; So this enables interrupts that are generated by timer ; A underflow, while leaving other interrupts as they ; are LDA #%11000000 ; Call the Kernal's SETMSG function to set the system JSR KERNALSETMSG ; error display switch as follows: ; ; * Bit 6 set = display I/O error messages ; ; * Bit 7 set = display system messages ; ; This ensures that any file system errors are shown LDX DISK ; Set X = DISK + 1 INX ; ; DISK is $FF (i.e. -1) for disk and 0 for tape, so this ; sets X to 0 for disk and 1 for tape LDA filesys,X ; Set X to the device number for the current media from TAX ; the lookup tape at filesys, so X is now 1 for tape or ; 8 for disk LDA #1 ; Call the Kernal's SETLFS function to set the file LDY #0 ; parameters as follows: JSR KERNALSETLFS ; ; * A = logical number 1 ; ; * X = device number 1 (tape) or 8 (disk) ; ; * Y = secondary address 0 ; ; The last setting enables us to specify a load address ; in (Y X) when using the Kernal's LOAD function to load ; a commander file in the LOD routine ; Before calling KERNALSETUP, the filename we want to ; work with has already been put into INWK+5 by the MT26 ; routine, with the length of the filename in thislong ; ; The address of the filename is INWK+5 because the ; first five characters of INWK contain a BBC Micro ; pathname like ":0.E.", which we can ignore in the ; Commodore 64 version LDA thislong ; Call SETNAM to set the filename parameters as LDX #(INWK+5) ; follows: LDY #0 ; JMP KERNALSETNAM ; * A = filename length ; ; * (Y X) = address of filename (Y is set to zero as ; INWK is in zero page) ; ; The call to SETNAM returns from the subroutine using ; a tail callName: KERNALSETUP [Show more] Type: Subroutine Category: Save and load Summary: Set up memory and interrupts so we can use the Kernal functions and configure the file system device number and filenameContext: See this subroutine in context in the source code References: This subroutine is called as follows: * LOD calls KERNALSETUP * SVE calls KERNALSETUP
[X]
Configuration variable CIA = $DC00
Registers for the CIA1 I/O interface chip, which are memory-mapped to the 16 bytes from $DC00 to $DC0F (see page 428 of the Programmer's Reference Guide)
[X]
Variable DISK in workspace Option variables
Current media configuration setting
[X]
Configuration variable KERNALSETLFS = $FFBA
The Kernal function to set the logical, first, and second addresses for file access
[X]
Configuration variable KERNALSETMSG = $FF90
The Kernal function to control Kernal messages
[X]
Configuration variable KERNALSETNAM = $FFBD
The Kernal function to set a filename
[X]
Subroutine SETL1 (category: Utility routines)
Set the 6510 input/output port register to control the memory map
[X]
Subroutine SWAPPZERO (category: Utility routines)
A routine that swaps zero page with the page at $CE00, so that zero page changes made by Kernal functions can be reversed
[X]
Configuration variable VIC = $D000
Registers for the VIC-II video controller chip, which are memory-mapped to the 46 bytes from $D000 to $D02E (see page 454 of the Programmer's Reference Guide)
[X]
Variable filesys (category: Save and load)
A lookup table containing the device numbers for tape and disk
[X]
Variable thislong (category: Save and load)
Contains the length of the most recently entered commander name