mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-22 01:31:33 +00:00
Added VIC-20 specific header files vic/include/*
This commit is contained in:
parent
c36f788275
commit
7b5386806f
289
vic20/include/file.a02
Normal file
289
vic20/include/file.a02
Normal file
@ -0,0 +1,289 @@
|
||||
; Requires external routines SETSRC and SETDST
|
||||
; Requires the following RAM locations be defined
|
||||
; external zero page byte pairs SRCLO,SRCHI and DSTLO,DSTHI
|
||||
; and external bytes TEMP0, TEMP1, TEMP2, and TEMP3
|
||||
; as well as constant FOMAX and a table of FOMAX+1
|
||||
; consecutive bytes named FTBL
|
||||
|
||||
;finit() - Initialize File System
|
||||
FSINIT: LDA #$40 ;Control Messages Only
|
||||
JSR SETMSG ;Kernal - Set System Messages
|
||||
JMP FSHUT ;Close All Files
|
||||
|
||||
LDA #15 ;OPEN 15,8,15,"I"
|
||||
LDX #8
|
||||
TAY
|
||||
JMP SETLFS
|
||||
LDA 1
|
||||
LDY #>FSINII
|
||||
LDX #<FSINII
|
||||
JMP OPEN
|
||||
FSINII: DC "I"
|
||||
|
||||
;fshut() - Shut Down File System
|
||||
FSHUT: LDA #0 ;Clear File Table
|
||||
LDX #FOMAX
|
||||
FSHUTL: STA FTBL,X
|
||||
DEX
|
||||
BPL FSHUTL
|
||||
JMP CLALL ;Kernal - Close All Files
|
||||
|
||||
;fsptr(fn) - Generate File Pointer
|
||||
;Returns: A,X = An Unused File Pointer (Logical File Number)
|
||||
; 0 if None Available
|
||||
FSPTR: LDX #FOMAX ;Start at Top of Table
|
||||
FSPTRL: LDA FTBL,X ;Check File Table Entry
|
||||
BEQ FSPTRX ;If Not 0
|
||||
DEX ; Decrement Index and
|
||||
BNE FSPTRL ; Loop if Greater Than 0
|
||||
FSPTRX: TXA ;Move Channel# to Accumulator
|
||||
RTS ;and Return
|
||||
|
||||
;fschk(fn) - Check File Pointer
|
||||
;Args: A = File Pointer (Logical File Number)
|
||||
;Sets: TEMP0 = Logical File Number
|
||||
;Returns: A = 0 if File Pointer is Valid
|
||||
; 255 if File Pointer is Invalid
|
||||
; X = Logical file number
|
||||
FSCHK: STA TEMP0 ;Save Logical File Number
|
||||
TAX ;Transfer LFN to X register
|
||||
BEQ FERR ;If LFN is 0, Return ERROR
|
||||
JSR FSTCK ;Get File Table Entry
|
||||
BNE FZERO ;If Populated, Return 0
|
||||
BEQ FERR ;Else Return ERROR
|
||||
|
||||
;fstat(fn) - Get Status of Channel
|
||||
;Args: A = File Pointer (Logical File Number)
|
||||
;Returns: A = Result of Last READST if Argument is 0
|
||||
; Contents of File Table Entry
|
||||
; 255 if File Pointer is Greater Than FOMAX
|
||||
; X = Logical file number
|
||||
FSTAT: TAX ;Transfer Logical File Number to X Register
|
||||
FSTCK: CLC ;If LFN
|
||||
SBC #FOMAX ; is Greater Than FOMAX
|
||||
BCS FERR ; Return ERROR
|
||||
LDA FTBL,X ;Load File Table Entry
|
||||
RTS ;And Return It
|
||||
|
||||
;fopen(dn, &s) - Open File with Specified Name
|
||||
;Args: A = Device Number
|
||||
; Y,X = Pointer to File Name
|
||||
;Sets: TEMP0 = Logical File Number
|
||||
; TEMP1 = Device Number
|
||||
; TEMP4 = Length of File Name
|
||||
;Returns: A = Logical file number
|
||||
FOPEN: STA TEMP1 ;Save Device Number
|
||||
JSR STRLEN ;Get File Name Length
|
||||
STA TEMP3 ;and Save It
|
||||
JSR FSPTR ;Find Unused Channel
|
||||
BEQ FRTS ;If None Found - Return 0
|
||||
STA TEMP0 ;Save Logical File Number
|
||||
LDX TEMP1 ;Load Device Number
|
||||
LDY TEMP0 ;Set Secondary Address tp
|
||||
INY ; Logical File Number+1
|
||||
JSR SETLFS ;Set Up Logical File
|
||||
LDA TEMP3 ;Load File Name Length
|
||||
JSR GETSRC ;Kernal - Load File Name Pointer
|
||||
JSR SETNAM ;Kernal - Set File Name
|
||||
JSR OPEN ;Open File
|
||||
JSR READST ;Kernal - Read Status Word
|
||||
STA FTBL ;Save in File Table Entry 0
|
||||
BNE FZERO ;If No Errors
|
||||
LDX TEMP0 ; Load Logical File Number
|
||||
LDA TEMP1 ; Load Device Number
|
||||
STA FTBL,X ; Store in Table Entry
|
||||
TXA ; Return Logical File Number
|
||||
RTS
|
||||
FZERO: LDA #0 ;Return 0
|
||||
RTS
|
||||
|
||||
;fclose(fn) - Close File
|
||||
;Args: A = File Pointer (Logical File Number)
|
||||
;Returns: A = 0,240 (see FSTAT)
|
||||
FCLOSE: JSR FSCHK ;Save and Check Logical File Number
|
||||
BNE FRTS ;If Invalid, then Return
|
||||
JSR CLOSE ;Execute Kernal Close and Return
|
||||
BCC FCLOSX ;If Error On Close
|
||||
JSR FSERR ; If File System Error
|
||||
BNE FERR ; Return 255
|
||||
FCLOSX: LDX TEMP0 ;Retrieve Logical File Number
|
||||
LDA #0 ;Ensure that Z Flag is Set
|
||||
STA FTBL,X ;Clear File Table Entry
|
||||
RTS ;and Return 0
|
||||
|
||||
;feof(fn) - Check for End of File
|
||||
;Args: A = Logical file number
|
||||
;Affects: A,X
|
||||
FEOF: TAX ;Move Channel# to X
|
||||
LDA FTBL,X ;Test File Table Entry
|
||||
BPL FZERO ;If High Bit Clear, Return 0
|
||||
FERR: LDA #$FF ;Set Generic Error Condition
|
||||
FRTS: RTS ;Return from Subroutine
|
||||
|
||||
;ferror(fn) - Check for Error
|
||||
;Args: A = Logical file number
|
||||
;Affects: A,X
|
||||
;Returns: A = Error Bit Mask
|
||||
; Bit Cassette Read Serial Bus I/O Tape Load/Verify
|
||||
; $01 Write Timeout
|
||||
; $02 Read Timeout
|
||||
; $04 Short Block Short Block
|
||||
; $08 Long Block Long Block
|
||||
; $10 Read Error Any Mismatch
|
||||
; $20 Checksum Err Checksum Err
|
||||
; $40 End of File EOI Line
|
||||
; $80 End of Tape Device Not Present End of Tape
|
||||
FERROR LDA FTBL ;File Table Entry 0 Contains Last Error
|
||||
RTS
|
||||
|
||||
;fgetc(fn) - Read character from file
|
||||
;Args: A = Logical file number
|
||||
;Stack: 9
|
||||
;Affects: A,X
|
||||
;Returns: A = 0,240 (see FERROR)
|
||||
FGETC: JSR FSCHK ;Save and Validate Logical File Number
|
||||
BNE FRTS ;If Error, Return 255
|
||||
JSR CHKIN ;Open channel for input
|
||||
JSR CHRIN ;Get character from input channel
|
||||
PHA ;Save read character
|
||||
JSR FSERR ;Check for Error
|
||||
JSR CLRCHN ;Clear I/O channels
|
||||
PLA ;Retrieve read Character
|
||||
RTS
|
||||
|
||||
;fputc(fn) - Write character to file
|
||||
;Args: A = Logical file number
|
||||
; Y = Character to Write
|
||||
;Stack: 9
|
||||
;Affects: A,X
|
||||
;Returns: A = 0,240 (see FERROR)
|
||||
FPUTC: JSR FSCHK ;Save and Validate Logical File Number
|
||||
BNE FRTS ;If Error, Return 255
|
||||
JSR CHKOUT ;Open channel for input
|
||||
TYA ;Move character to accumulator
|
||||
FPUTCH: JSR CHROUT ;Output a character
|
||||
JSR FSERR ;Check for Error
|
||||
JMP CLRCHN ;Clear I/O channels and return
|
||||
|
||||
;fgets(fn, &s) - Read string from file
|
||||
;Requires: DSTLO, DSTHI - Pointer to destination string
|
||||
;Args: A = Logical file number
|
||||
; Y,X = Pointer to String
|
||||
;Stack: 9
|
||||
;Affects: X,Y
|
||||
;Returns: A = Number of bytes read
|
||||
FGETS: JSR SETSRC ;Save string address and initialize pointer
|
||||
JSR FSCHK ;Save and Validate Logical File Number
|
||||
BNE FRTS ;If Error, Return 255
|
||||
JSR CHKIN ;Open Channel for Input (X set in FSCHK)
|
||||
FGETSL: JSR CHRIN ;Get character from input channel
|
||||
STA TEMP3
|
||||
JSR FSERR ;Check for Error
|
||||
BNE FGETSX ;If Not 0, Exit
|
||||
LDA TEMP3 ;Retrieve read character
|
||||
STA (SRCLO),Y ;Store character in string
|
||||
CMP #$0D ;If Carriage Return
|
||||
BEQ FGETSX ; Then Exit
|
||||
INY ;Increment pointer
|
||||
BPL FGETSL ;and loop if less than 128
|
||||
FGETSX: LDA #$00 ;Terminate String
|
||||
STA (SRCLO),Y ;
|
||||
FGETSY: JSR CLRCHN ;Clear I/O channels
|
||||
TYA ;Return string length
|
||||
RTS
|
||||
|
||||
;fputs(fn, &s) - Write String to File
|
||||
;Requires: DSTLO, DSTHI - Pointer to source string
|
||||
;Args: A = Logical file number
|
||||
; Y,X = Pointer to String
|
||||
;Affects: X,Y
|
||||
;Returns: A = Number of bytes written
|
||||
FPUTS: JSR SETSRC ;Save string address & initialize pointer
|
||||
BNE FRTS ;If Error, Return 255
|
||||
JSR FSCHK ;Save and Validate Logical File Number
|
||||
JSR CHKOUT ;Open channel for Output
|
||||
FPUTSL: LDA (SRCLO),Y ;Load next character
|
||||
CMP #$00 ;If Null Terminator
|
||||
BEQ FGETSY ; Then Exit
|
||||
JSR CHROUT ;Write character to output channel
|
||||
JSR FSERR ;Check for Error
|
||||
BNE FGETSY ;If Not 0, Exit
|
||||
INY ;Increment pointer
|
||||
BPL FPUTSL ;If less than 128 then loop
|
||||
BMI FGETSY ;Else exit
|
||||
|
||||
;fserr() - Check for File Read/Write Error
|
||||
;Requires: TEMP0 - Logical File Number of Last Read/Write
|
||||
;Sets: High Bit of File Table Entry to 1 if Error
|
||||
;Returns: A = 0 if No Error, Otherwise LFN | $80
|
||||
; N = 1 if Error, 0 if None
|
||||
; X = Logical File Number
|
||||
;Check for End of File and Set Flag
|
||||
FSERR: JSR READST ;Read status word
|
||||
STA FTBL ;and Save It
|
||||
BEQ FSERRX ;If Not 0
|
||||
LDX TEMP0 ; Get Channel#
|
||||
LDA FTBL,X ; Load Table Entry
|
||||
ORA #$80 ; Set High Bit
|
||||
STA FTBL,X ; and Save
|
||||
FSERRX: RTS
|
||||
|
||||
;fsdst(&s) - Set Destination String
|
||||
; Called before fread()
|
||||
;Args: X,Y = Pointer to destination string
|
||||
;Sets: DSTLO,DSTHI = Pointer to destination string
|
||||
;Affects: N,Z
|
||||
FSDST EQU SETDST ;Aliased to System Header function
|
||||
|
||||
;fread(fn, n) - Read bytes from file
|
||||
;Requires: DSTLO, DSTHI - Pointer to destination string
|
||||
;Args: A = Logical file number
|
||||
; Y = Maximum number of bytes to read
|
||||
;Affects: X,Y
|
||||
;Returns: A = Number of bytes read
|
||||
FREAD: STY TEMP1 ;Save Number of Bytes to Read
|
||||
LDY #0 ;Initialize pointer
|
||||
JSR FSCHK ;Save and Validate Logical File Number
|
||||
BNE FREADR ;If Error, Return 255
|
||||
JSR CHKIN ;Open Channel for Input (X set in FSCHK)
|
||||
FREADL: JSR CHRIN ;Get character from input channel
|
||||
STA TEMP3
|
||||
JSR FSERR ;Check for Error
|
||||
BNE FREADX ;If Not 0, Exit
|
||||
LDA TEMP3 ;Retrieve read character
|
||||
STA (DSTLO),Y ;Store character in string
|
||||
INY ;Increment pointer
|
||||
CPY TEMP1 ;If Less Than Maximum
|
||||
BNE FREADL ; Then Loop
|
||||
FREADX: JSR CLRCHN ;Clear I/O channels
|
||||
TYA ;Return string length
|
||||
FREADR: RTS
|
||||
|
||||
;fssrc(&s) - Set Destination String
|
||||
; Called before fwrite()
|
||||
;Args: X,Y = Pointer to destination string
|
||||
;Sets: SRCLO,SRCHI = Pointer to destination string
|
||||
;Affects: N,Z
|
||||
FSSRC EQU SETSRC ;Aliased to System Header function
|
||||
|
||||
;fwrite(fn, n) - Write bytes from file
|
||||
;Requires: SRCLO, SRCHI - Pointer to destination string
|
||||
;Args: A = Logical file number
|
||||
; Y = Maximum number of bytes to read
|
||||
;Affects: X,Y
|
||||
;Returns: A = Number of bytes written
|
||||
FWRITE: STY TEMP1 ;Save Number of Bytes to Writre
|
||||
LDY #0 ;Initialize pointer
|
||||
JSR FSCHK ;Save and Validate Logical File Number
|
||||
BNE FWRITR ;If Error, Return 255
|
||||
JSR CHKOUT ;Open Channel for Input (X set in FSCHK)
|
||||
FWRITL: LDA (SRCLO),Y ;Get Byte to Write
|
||||
JSR CHROUT ;Get character from input channel
|
||||
JSR FSERR ;Check for Error
|
||||
BNE FWRITX ;If Not 0, Exit
|
||||
INY ;Increment pointer
|
||||
CPY TEMP1 ;If Less Than Maximum
|
||||
BNE FWRITL ; Then Loop
|
||||
FWRITX: JSR CLRCHN ;Clear I/O channels
|
||||
TYA ;Return string length
|
||||
FWRITR: RTS
|
108
vic20/include/file.h02
Normal file
108
vic20/include/file.h02
Normal file
@ -0,0 +1,108 @@
|
||||
/******************************************
|
||||
* file - Standard File Functions for C02 *
|
||||
******************************************/
|
||||
|
||||
/* Initialize File System *
|
||||
char fsinit();
|
||||
|
||||
/* Get Next Available File Pointer *
|
||||
* Returns: file pointer *
|
||||
0 if none available */
|
||||
char fsptr();
|
||||
|
||||
/* Check File Pointer *
|
||||
* Args: fp - file pointer *
|
||||
* Returns: 0 if valid *
|
||||
255 if invalid */
|
||||
char fschk();
|
||||
|
||||
/* Get File Pointer Status *
|
||||
* Args: fp - file pointer *
|
||||
* Returns: last READST result if fp = 0 *
|
||||
* 255 if fp > FOMAX *
|
||||
* file table entry, otherwise */
|
||||
char fstat();
|
||||
|
||||
/* Open File *
|
||||
* Args: fd - device number *
|
||||
* &f - string containing filename *
|
||||
* Returns: file pointer if successful *
|
||||
0 if an error occurs */
|
||||
char fopen();
|
||||
|
||||
/* Close File *
|
||||
* Args: fp - file pointer *
|
||||
* Returns: 0 if successful *
|
||||
255 if an error occurred */
|
||||
char fclose();
|
||||
|
||||
/* Close All Files *
|
||||
* Returns: system dependent error number *
|
||||
0 if no error */
|
||||
char fclall();
|
||||
|
||||
/* End of File *
|
||||
* Args: fp - file pointer *
|
||||
* Returns: 0 if not at end of file *
|
||||
255 if end of file reached */
|
||||
char feof();
|
||||
|
||||
/* File Error *
|
||||
* Returns: system dependent error number *
|
||||
0 if no error */
|
||||
char ferror();
|
||||
|
||||
/* Read Character from File *
|
||||
* Args: fp - file pointer *
|
||||
* Returns: ASCII value of character *
|
||||
* system dependent garbage *
|
||||
character if past end of file */
|
||||
char fgetc();
|
||||
|
||||
/* Write Character to File *
|
||||
* Args: fp - file pointer *
|
||||
* c - ASCII character to write *
|
||||
* Returns: ASCII value of character */
|
||||
char fputc();
|
||||
|
||||
/* Read String from File *
|
||||
* Args: fp - file pointer *
|
||||
* &s - string read from file *
|
||||
* Returns: length of string *
|
||||
* 255 if error during write */
|
||||
char fgets();
|
||||
|
||||
/* Write String to File *
|
||||
* Args: fp - file pointer *
|
||||
* &s - string to print from *
|
||||
* Returns: ending position in string *
|
||||
* 255 if error during write */
|
||||
char fputs();
|
||||
|
||||
/* Write Line to File *
|
||||
* Args: fp - file pointer *
|
||||
* &s - string to print from *
|
||||
* Returns: ending position in string *
|
||||
* 255 if error during write */
|
||||
char fputln();
|
||||
|
||||
/* Set Array for fread() *
|
||||
* Args: &s - Destination string */
|
||||
void fsdst();
|
||||
|
||||
/* Read Bytes from File *
|
||||
* Args: fp - file pointer *
|
||||
* n - number of bytes to read *
|
||||
* Returns: number of bytes read */
|
||||
char fread();
|
||||
|
||||
/* Set Array for fwrite() *
|
||||
* Args: &s - Destination string */
|
||||
void fssrc();
|
||||
|
||||
/* Write Bytes to File *
|
||||
* Args: fp - file pointer *
|
||||
* n - number of bytes to write *
|
||||
* Returns: number of bytes written */
|
||||
char fwrite();
|
||||
|
50
vic20/include/hires.a02
Normal file
50
vic20/include/hires.a02
Normal file
@ -0,0 +1,50 @@
|
||||
; C02 library hires.h02 assembly language subroutines
|
||||
; Requires Thomas Magnusson's HIRES Package loaded at $1C00
|
||||
|
||||
;void hrinit() - Initialize High Resolution Graphics
|
||||
HRINIT EQU $1C00 ;Aliased to Initialize Routine
|
||||
|
||||
;void hrfclr() - Set Foreground Color
|
||||
HRFCLR EQU $1C2E ;Set Dot Color Routine Alternate Entry Point
|
||||
|
||||
;void hrclrs() - Clear High Resolution Screen
|
||||
HRCLRS EQU $1C37 ;Aliased to Clear Screen Routine
|
||||
|
||||
;void hrsetp(x, y) - Set Pixel to Foreground Color
|
||||
HRSETP JSR HRSTRT ;Store X and Y Coordinates
|
||||
JMP $1CB2 ;Execute Draw Dot Routine
|
||||
|
||||
;void hrrstp(x, y) - Reset Pixel to Background Color
|
||||
HRRSTP JSR HRSTRT ;Store X and Y Coordinates
|
||||
JMP $1CC0 ;Execute Clear Dot Routine
|
||||
|
||||
;char hrgetp(x, y) - Get Pixel Status
|
||||
HRGETP JSR HRSTRT ;Store X and Y Coordinates
|
||||
JMP $1CCD ;Execute Get Dot Routine
|
||||
|
||||
HRSTRX STX 2 ;Store A, Y, and X Registers
|
||||
;void hrstrt(x, y) - Set Start Point
|
||||
HRSTRT STA 0 ;Store X Coordinate
|
||||
STY 1 ;Store Y Coordianate
|
||||
RTS
|
||||
|
||||
;void hrdrto(x, y) - Draw To Point
|
||||
HRDRTO STA 2 ;Store Ending X Coordinate
|
||||
STY 3 ;Store Ending Y Coordinate
|
||||
JMP $1D98 ;Execute Draw Line Routine
|
||||
|
||||
;void hrclto(x, y) - Clear to Point
|
||||
HRCLTO STA 2 ;Store Ending X Coordinate
|
||||
STY 3 ;Store Ending Y Coordinate
|
||||
JMP $1D98 ;Execute Draw Line Routine
|
||||
|
||||
;void hrsave() - Save Image from Tape
|
||||
HRSAVE EQU $1DA8 ;Aliased to Save ROutine
|
||||
|
||||
;void hrload(f, r, b) - Load Image from Tape
|
||||
HRLOAD JSR HRSTRX ;Store A, Y and X Registers
|
||||
JMP $1DBA ;Execute Load Routine
|
||||
|
||||
;void hrsetc(f, r, b) - Set Screen Colors
|
||||
HRSETC JSR HRSTRX ;Store A, Y and X Registers
|
||||
JMP $1DCC ;Execute Set Screen Colors Routine
|
157
vic20/include/vic20.a02
Normal file
157
vic20/include/vic20.a02
Normal file
@ -0,0 +1,157 @@
|
||||
; c02 Program Initialization Code for Unexpanded VIC-20
|
||||
|
||||
;ASCII Control Codes Equivalents
|
||||
CR EQU $0D ;Carriage Return
|
||||
LF EQU $11 ;Line Feed (Cursor Down)
|
||||
DEL EQU $14 ;Delete
|
||||
HT EQU $1D ;Horizontal Tab (Cursor Right)
|
||||
VT EQU $91 ;Vertical Tab (Cursor Up)
|
||||
FF EQU $93 ;Form Feed (Clear Screen)
|
||||
BS EQU $9D ;Backspace (Cursor Left)
|
||||
|
||||
;PETSCII Key Mappings
|
||||
DELKEY EQU $14 ;Delete/Backspace Key (Delete)
|
||||
ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
|
||||
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
|
||||
|
||||
;Standard Library Constants
|
||||
FOMAX EQU 7 ;Maximum Number of Open Files
|
||||
FNMAX EQU 16 ;Maximum Filename Length
|
||||
|
||||
;Zero Page Variables
|
||||
PTRLO EQU $35 ;System Pointer (pointer.a02)
|
||||
PTRHI EQU $36 ;NOTE: Overwritten by BASIC String Routines
|
||||
|
||||
BLKLO EQU $50 ;Block Pointer (block.a02)
|
||||
BLKHI EQU $51 ;NOTE: Overwritten by BASIC String Routines
|
||||
|
||||
TIMEH EQU $A0 ;Jiffy Clock High Byte
|
||||
TIMEM EQU $A1 ;Jiffy Clock Middle Byte
|
||||
TIMEL EQU $A2 ;Jiffy Clock Low Byte
|
||||
|
||||
SRCLO EQU $FB ;Source Pointer Low Byte (stdlib.a02, etc.)
|
||||
SRCHI EQU $FC ;Source Pointer High Byte
|
||||
DSTLO EQU $FD ;Destination Pointer Low Byte (stdlib.a02, etc.)
|
||||
DSTHI EQU $FE ;Destination Pointer High Byte
|
||||
|
||||
;Page 1 RAM Locations (Unused Area at Bottom of Stack)
|
||||
FTBL EQU $0140 ;File Table (files.a02) Same on PET
|
||||
|
||||
;Other RAM Locations
|
||||
TEMP0 EQU $0310 ;Temporary Variables
|
||||
TEMP1 EQU $0311 ;Used by Library Functions
|
||||
TEMP2 EQU $0312
|
||||
TEMP3 EQU $0334 ;($0313 is Free on VIC-20 but not C64)
|
||||
BLKLEN EQU $0335 ;Block Segment Length
|
||||
BLKSLO EQU $0336 ;Block Start Address
|
||||
BLKSHI EQU $0337
|
||||
BLKELO EQU $0338 ;Block End Address
|
||||
BLKEHI EQU $0339
|
||||
; EQU $033A ;Free Byte for User Programs
|
||||
; EQU $033B ;Free Byte for User Programs
|
||||
TBFFR EQU $033C ;Cassette I/O Buffer
|
||||
; EQU $03FC ;Free Byte for User Programs
|
||||
RANDOM EQU $03FD ;Seed for rand() Function
|
||||
RDSEED EQU $03FE ;Seed for random() Function
|
||||
STKPTR EQU $03FF ;Stack Pointer Storage
|
||||
|
||||
;Video RAM and ROM
|
||||
VICSCN EQU $1E00 ;Video Screen Memory Area (Unexpanded)
|
||||
CHRROM EQU $8000 ;Character Generator ROM
|
||||
VICCLR EQU $9600 ;COLOR RAM (UNEXPANDED)
|
||||
|
||||
;Kernal Routines
|
||||
SETMSG EQU $FF90 ;Control System Message Output
|
||||
SETLFS EQU $FFBA ;Set up Logical File
|
||||
READST EQU $FFB7 ;Read Status Word
|
||||
SETNAM EQU $FFBD ;Set File Name
|
||||
OPEN EQU $FFC0 ;Open a Logical File
|
||||
CLOSE EQU $FFC3 ;Close Logical File
|
||||
CHKIN EQU $FFC6 ;Open Channel for Input
|
||||
CHKOUT EQU $FFC9 ;Open Channel for Output
|
||||
CLRCHN EQU $FFCC ;Clear I/O Channels
|
||||
CHRIN EQU $FFCF ;Input Character to Channel
|
||||
CHROUT EQU $FFD2 ;Output Character to Channel
|
||||
GETIN EQU $FFE4 ;Read Character from Keyboard Buffer
|
||||
CLALL EQU $FFE7 ;Close All Files
|
||||
|
||||
;Machine Language Basic Stub
|
||||
ORG $1001 ;Start
|
||||
BASIC: DC $0C, $10 ; Pointer to Next Line (4108)
|
||||
DC $00, $00 ; Line Number (0)
|
||||
DC $9E ; SYS
|
||||
DC $20 ; ' '
|
||||
DC $34, $31, $31 ,$30 ; "4110"
|
||||
DC $00 ;End of Line Marker
|
||||
DC $00, $00 ;End of Basic Program
|
||||
|
||||
START: TSX ;Get Stack Pointer
|
||||
STX STKPTR ;and Save for Exit
|
||||
LDA TIMEL ;Load Jiffy Clock Low Byte
|
||||
STA RDSEED ;and Store in Random Seed
|
||||
JMP MAIN ;Execute Program
|
||||
|
||||
EXIT: LDX STKPTR ;Retrieve Saved Stack Pointer
|
||||
TXS ;and Restore It
|
||||
RTS ;Return to BASIC
|
||||
|
||||
;Poll Keyboard for Character
|
||||
PLKEY EQU GETIN ;Read Character from Keyboard Buffer
|
||||
|
||||
;Get Character from Keyboard
|
||||
GETKEY:
|
||||
;Wait for Character from Keyboard
|
||||
RDKEY: JSR PLKEY ;Poll Keyboard
|
||||
BEQ GETKEY ;If No Key, Loop
|
||||
RTS
|
||||
|
||||
;Print Character to Console
|
||||
PRCHR EQU CHROUT ;
|
||||
|
||||
;Delete Previous Character
|
||||
DELCHR: LDA #$9D ;Load Cursor Left into Accumulator
|
||||
JSR PRCHR ; and Print it
|
||||
LDA #$14 ;Load Delete into Accumulater
|
||||
JMP PRCHR ; and Print it
|
||||
|
||||
;Advance Character to Next line
|
||||
NEWLIN: LDA #$0D ;Load C/R into Accumulator
|
||||
JMP PRCHR ; and Print it
|
||||
|
||||
;Print Byte as Two-Digit Hex Number to Console
|
||||
PRBYTE: PHA ;Save Accumulater
|
||||
LSR ;Shift Hi Nybble to Low Nybble
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
JSR PRHEX ; and Print it
|
||||
PLA ;Restore Accumulator
|
||||
; and fall into prhex
|
||||
|
||||
;Print Low Nybble as Hex Digit to Console
|
||||
PRHEX: AND #$0F ;Strip High Nybble
|
||||
CMP #$0A ;If Low Nybble >= 10
|
||||
BCC PRHEXC ;
|
||||
ADC #$06 ; Convert ':' to 'A'...
|
||||
PRHEXC: ADC #$30 ;Convert to ASCII Character
|
||||
JMP PRCHR ;Print Hex Digit and Return
|
||||
|
||||
;Functions to set String Pointers
|
||||
;Used by memory, stdio, stdlin, string, and stringx libraries
|
||||
|
||||
;Initialize Destination String Pointer and Index
|
||||
SETDST: STX DSTLO ;Save Destination String Pointer
|
||||
STY DSTHI
|
||||
RTS
|
||||
|
||||
;Initialize Source String Pointer and Index
|
||||
SETSRC: STX SRCLO ;Save Source String Pointer
|
||||
STY SRCHI
|
||||
LDY #$00 ;Initialize Index Into String
|
||||
RTS
|
||||
|
||||
;Retrieve Source String Pointer
|
||||
GETSRC: LDX SRCLO
|
||||
LDY SRCHI
|
||||
RTS
|
||||
**
|
37
vic20/include/vic20.h02
Normal file
37
vic20/include/vic20.h02
Normal file
@ -0,0 +1,37 @@
|
||||
/* C02 Header File for Unexpanded VIC-20 */
|
||||
|
||||
//Zero Page Variables
|
||||
char ptrhi, ptrlo; //Pointer Library
|
||||
char blkhi, blklo; //Block Pointer
|
||||
char srchi, srclo; //Source Pointer
|
||||
char dsthi, dstlo; //Destination Pointer
|
||||
|
||||
//File Library Constants
|
||||
//define #fomax //Maximum Number of Open Files
|
||||
//define #fnmax //Maximum Filename Length
|
||||
|
||||
//Static Library Variables
|
||||
char blklen; //Block Segment Length
|
||||
char blkshi, blkslo; //Block Start Address
|
||||
char blkehi, blkelo; //Block End Address
|
||||
|
||||
//Temporary Variables - Used by Libraries
|
||||
char temp0, temp1, temp2, temp3;
|
||||
|
||||
//Useful Areas in RAM
|
||||
char tbffr; //Tape Buffer (192 bytes)
|
||||
|
||||
//Kernal Routines Memory Mapped I/O
|
||||
char chrin(); //Input Character to Channel
|
||||
void chrout(); //Output Character to Channel
|
||||
char getin(); //Read Character from Keyboard Buffer
|
||||
|
||||
//System Subroutines
|
||||
char plkey(); //Poll Console for character
|
||||
char rdkey(); //Wait for character from Console
|
||||
char getkey(); //Read ASCII character from Console
|
||||
void newlin(); //Advance cursor to beginning of next line
|
||||
void prchr(); //Print ASCII character to Console
|
||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
|
128
vic20/include/vic20a0.a02
Normal file
128
vic20/include/vic20a0.a02
Normal file
@ -0,0 +1,128 @@
|
||||
; c02 Program Initialization Code for Unexpanded VIC-20
|
||||
|
||||
;ASCII Control Codes Equivalents
|
||||
CR EQU $0D ;Carriage Return
|
||||
LF EQU $11 ;Line Feed (Cursor Down)
|
||||
DEL EQU $14 ;Delete
|
||||
HT EQU $1D ;Horizontal Tab (Cursor Right)
|
||||
VT EQU $91 ;Vertical Tab (Cursor Up)
|
||||
FF EQU $93 ;Form Feed (Clear Screen)
|
||||
BS EQU $9D ;Backspace (Cursor Left)
|
||||
|
||||
;PETSCII Key Mappings
|
||||
DELKEY EQU $14 ;Delete/Backspace Key (Delete)
|
||||
ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
|
||||
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
|
||||
|
||||
;Standard Library Constants
|
||||
FOMAX EQU 7 ;Maximum Number of Open Files
|
||||
FNMAX EQU 16 ;Maximum Filename Length
|
||||
|
||||
;Zero Page Locations
|
||||
SRCLO EQU $FB ;String Pointer (stdio.asm)
|
||||
SRCHI EQU $FC ;Free Byte for User Programs
|
||||
DSTLO EQU $FD ;Free Byte for User Programs
|
||||
DSTHI EQU $FE ;Free Byte for User Programs
|
||||
|
||||
;Other RAM Locations
|
||||
TEMP0 EQU $0310 ;Free Byte for User Programs
|
||||
TEMP1 EQU $0311 ;Free Byte for User Programs
|
||||
TEMP2 EQU $0312 ;Free Byte for User Programs
|
||||
TEMP3 EQU $0313 ;Free Byte for User Programs
|
||||
FTBL EQU $0334 ;File Table (files.a02)
|
||||
TBFFR EQU $033C ;Cassette I/O Buffer
|
||||
user12 EQU $03FC ;Free Byte for User Programs
|
||||
user13 EQU $03FD ;Free Byte for User Programs
|
||||
user14 EQU $03FE ;Free Byte for User Programs
|
||||
STKPTR EQU $03FF ;Stack Pointer Storage
|
||||
|
||||
;Video RAM and ROM
|
||||
VICSCN EQU $1E00 ;Video Screen Memory Area (Unexpanded)
|
||||
CHRROM EQU $8000 ;Character Generator ROM
|
||||
VICCLR EQU $9600 ;COLOR RAM (UNEXPANDED)
|
||||
|
||||
;Kernal Routines
|
||||
SETMSG EQU $FF90 ;Control System Message Output
|
||||
SETLFS EQU $FFBA ;Set up Logical File
|
||||
READST EQU $FFB7 ;Read Status Word
|
||||
SETNAM EQU $FFBD ;Set File Name
|
||||
OPEN EQU $FFC0 ;Open a Logical File
|
||||
CLOSE EQU $FFC3 ;Close Logical File
|
||||
CHKIN EQU $FFC6 ;Open Channel for Input
|
||||
CHKOUT EQU $FFC9 ;Open Channel for Output
|
||||
CLRCHN EQU $FFCC ;Clear I/O Channels
|
||||
CHRIN EQU $FFCF ;Input Character to Channel
|
||||
CHROUT EQU $FFD2 ;Output Character to Channel
|
||||
GETIN EQU $FFE4 ;Read Character from Keyboard Buffer
|
||||
CLALL EQU $FFE7 ;Close All Files
|
||||
|
||||
;Machine Language Basic Stub
|
||||
ORG $A000 ;Start
|
||||
START: TSX ;Get Stack Pointer
|
||||
STX STKPTR ;and Save for Exit
|
||||
JMP MAIN ;Execute Program
|
||||
|
||||
EXIT: LDX STKPTR ;Retrieve Saved Stack Pointer
|
||||
TXS ;and Restore It
|
||||
RTS ;Return to BASIC
|
||||
|
||||
;Poll Keyboard for Character
|
||||
PLKEY EQU GETIN ;Read Character from Keyboard Buffer
|
||||
|
||||
;Get Character from Keyboard
|
||||
GETKEY:
|
||||
;Wait for Character from Keyboard
|
||||
RDKEY: JSR PLKEY ;Poll Keyboard
|
||||
BEQ GETKEY ;If No Key, Loop
|
||||
RTS
|
||||
|
||||
;Print Character to Console
|
||||
PRCHR EQU CHROUT ;
|
||||
|
||||
;Delete Previous Character
|
||||
DELCHR: LDA #$9D ;Load Cursor Left into Accumulator
|
||||
JSR PRCHR ; and Print it
|
||||
LDA #$14 ;Load Delete into Accumulater
|
||||
JMP PRCHR ; and Print it
|
||||
|
||||
;Advance Character to Next line
|
||||
NEWLIN: LDA #$0D ;Load C/R into Accumulator
|
||||
JMP PRCHR ; and Print it
|
||||
|
||||
;Print Byte as Two-Digit Hex Number to Console
|
||||
PRBYTE: PHA ;Save Accumulater
|
||||
LSR ;Shift Hi Nybble to Low Nybble
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
JSR PRHEX ; and Print it
|
||||
PLA ;Restore Accumulator
|
||||
; and fall into prhex
|
||||
|
||||
;Print Low Nybble as Hex Digit to Console
|
||||
PRHEX: AND #$0F ;Strip High Nybble
|
||||
CMP #$0A ;If Low Nybble >= 10
|
||||
BCC PRHEXC ;
|
||||
ADC #$06 ; Convert ':' to 'A'...
|
||||
PRHEXC: ADC #$30 ;Convert to ASCII Character
|
||||
JMP PRCHR ;Print Hex Digit and Return
|
||||
|
||||
;Functions to set String Pointers
|
||||
;Used by memory, stdio, stdlin, string, and stringx libraries
|
||||
|
||||
;Initialize Destination String Pointer and Index
|
||||
SETDST: STX DSTLO ;Save Destination String Pointer
|
||||
STY DSTHI
|
||||
RTS
|
||||
|
||||
;Initialize Source String Pointer and Index
|
||||
SETSRC: STX SRCLO ;Save Source String Pointer
|
||||
STY SRCHI
|
||||
LDY #$00 ;Initialize Index Into String
|
||||
RTS
|
||||
|
||||
;Retrieve Source String Pointer
|
||||
GETSRC: LDX SRCLO
|
||||
LDY SRCHI
|
||||
RTS
|
||||
**
|
24
vic20/include/vic20a0.h02
Normal file
24
vic20/include/vic20a0.h02
Normal file
@ -0,0 +1,24 @@
|
||||
/* VIC0-20 $A000 Header File *
|
||||
* Compiles into Block 5 RAM at $A000 *
|
||||
* Load using LOAD "progfile",8,1 *
|
||||
* Execute using SYS 40960 */
|
||||
|
||||
//Zero Page Variables
|
||||
char srchi, srclo; //Source Pointer
|
||||
char dsthi, dstlo; //Destination Pointer
|
||||
|
||||
|
||||
//Kernal Routines Memory Mapped I/O
|
||||
char chrin(); //Input Character to Channel
|
||||
void chrout(); //Output Character to Channel
|
||||
char getin(); //Read Character from Keyboard Buffer
|
||||
|
||||
//System Subroutines
|
||||
char plkey(); //Poll Console for character
|
||||
char rdkey(); //Wait for character from Console
|
||||
char getkey(); //Read ASCII character from Console
|
||||
void newlin(); //Advance cursor to beginning of next line
|
||||
void prchr(); //Print ASCII character to Console
|
||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
|
133
vic20/include/vic20a0cart.a02
Normal file
133
vic20/include/vic20a0cart.a02
Normal file
@ -0,0 +1,133 @@
|
||||
; c02 Program Initialization Code for Unexpanded VIC-20
|
||||
|
||||
;ASCII Control Codes Equivalents
|
||||
CR EQU $0D ;Carriage Return
|
||||
LF EQU $11 ;Line Feed (Cursor Down)
|
||||
DEL EQU $14 ;Delete
|
||||
HT EQU $1D ;Horizontal Tab (Cursor Right)
|
||||
VT EQU $91 ;Vertical Tab (Cursor Up)
|
||||
FF EQU $93 ;Form Feed (Clear Screen)
|
||||
BS EQU $9D ;Backspace (Cursor Left)
|
||||
|
||||
;PETSCII Key Mappings
|
||||
DELKEY EQU $14 ;Delete/Backspace Key (Delete)
|
||||
ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
|
||||
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
|
||||
|
||||
;Standard Library Constants
|
||||
FOMAX EQU 7 ;Maximum Number of Open Files
|
||||
FNMAX EQU 16 ;Maximum Filename Length
|
||||
|
||||
;Zero Page Locations
|
||||
SRCLO EQU $FB ;String Pointer (stdio.asm)
|
||||
SRCHI EQU $FC ;Free Byte for User Programs
|
||||
DSTLO EQU $FD ;Free Byte for User Programs
|
||||
DSTHI EQU $FE ;Free Byte for User Programs
|
||||
|
||||
;Other RAM Locations
|
||||
TEMP0 EQU $0310 ;Free Byte for User Programs
|
||||
TEMP1 EQU $0311 ;Free Byte for User Programs
|
||||
TEMP2 EQU $0312 ;Free Byte for User Programs
|
||||
TEMP3 EQU $0313 ;Free Byte for User Programs
|
||||
FTBL EQU $0334 ;File Table (files.a02)
|
||||
TBFFR EQU $033C ;Cassette I/O Buffer
|
||||
user12 EQU $03FC ;Free Byte for User Programs
|
||||
user13 EQU $03FD ;Free Byte for User Programs
|
||||
user14 EQU $03FE ;Free Byte for User Programs
|
||||
STKPTR EQU $03FF ;Stack Pointer Storage
|
||||
|
||||
;Video RAM and ROM
|
||||
VICSCN EQU $1E00 ;Video Screen Memory Area (Unexpanded)
|
||||
CHRROM EQU $8000 ;Character Generator ROM
|
||||
VICCLR EQU $9600 ;COLOR RAM (UNEXPANDED)
|
||||
|
||||
;Kernal Routines
|
||||
SETMSG EQU $FF90 ;Control System Message Output
|
||||
SETLFS EQU $FFBA ;Set up Logical File
|
||||
READST EQU $FFB7 ;Read Status Word
|
||||
SETNAM EQU $FFBD ;Set File Name
|
||||
OPEN EQU $FFC0 ;Open a Logical File
|
||||
CLOSE EQU $FFC3 ;Close Logical File
|
||||
CHKIN EQU $FFC6 ;Open Channel for Input
|
||||
CHKOUT EQU $FFC9 ;Open Channel for Output
|
||||
CLRCHN EQU $FFCC ;Clear I/O Channels
|
||||
CHRIN EQU $FFCF ;Input Character to Channel
|
||||
CHROUT EQU $FFD2 ;Output Character to Channel
|
||||
GETIN EQU $FFE4 ;Read Character from Keyboard Buffer
|
||||
CLALL EQU $FFE7 ;Close All Files
|
||||
|
||||
;Machine Language Basic Stub
|
||||
ORG $A000 ;Start
|
||||
DC.W START ;Cartridge Start Address
|
||||
DC.W RESTR ;Restore Key Routine
|
||||
DC $41,$30,$C3,$C2,$CD ;Cartridge Start Sequence
|
||||
START: JMP MAIN ;Execute Program
|
||||
|
||||
;Exit - Return to BASIC
|
||||
;Execute a Warm Start, bypassing the Cartridge Check Code
|
||||
EXIT: LDX #$FF ; Set X for stack
|
||||
SEI ; Disable interrupts
|
||||
TXS ; Clear stack
|
||||
CLD ; Clear decimal mode
|
||||
JMP $FD2F ; Jump into Initialization Code
|
||||
|
||||
;Poll Keyboard for Character
|
||||
PLKEY EQU GETIN ;Read Character from Keyboard Buffer
|
||||
|
||||
;Get Character from Keyboard
|
||||
GETKEY:
|
||||
;Wait for Character from Keyboard
|
||||
RDKEY: JSR PLKEY ;Poll Keyboard
|
||||
BEQ GETKEY ;If No Key, Loop
|
||||
RTS
|
||||
|
||||
;Print Character to Console
|
||||
PRCHR EQU CHROUT ;
|
||||
|
||||
;Delete Previous Character
|
||||
DELCHR: LDA #$9D ;Load Cursor Left into Accumulator
|
||||
JSR PRCHR ; and Print it
|
||||
LDA #$14 ;Load Delete into Accumulater
|
||||
JMP PRCHR ; and Print it
|
||||
|
||||
;Advance Character to Next line
|
||||
NEWLIN: LDA #$0D ;Load C/R into Accumulator
|
||||
JMP PRCHR ; and Print it
|
||||
|
||||
;Print Byte as Two-Digit Hex Number to Console
|
||||
PRBYTE: PHA ;Save Accumulater
|
||||
LSR ;Shift Hi Nybble to Low Nybble
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
JSR PRHEX ; and Print it
|
||||
PLA ;Restore Accumulator
|
||||
; and fall into prhex
|
||||
|
||||
;Print Low Nybble as Hex Digit to Console
|
||||
PRHEX: AND #$0F ;Strip High Nybble
|
||||
CMP #$0A ;If Low Nybble >= 10
|
||||
BCC PRHEXC ;
|
||||
ADC #$06 ; Convert ':' to 'A'...
|
||||
PRHEXC: ADC #$30 ;Convert to ASCII Character
|
||||
JMP PRCHR ;Print Hex Digit and Return
|
||||
|
||||
;Functions to set String Pointers
|
||||
;Used by memory, stdio, stdlin, string, and stringx libraries
|
||||
|
||||
;Initialize Destination String Pointer and Index
|
||||
SETDST: STX DSTLO ;Save Destination String Pointer
|
||||
STY DSTHI
|
||||
RTS
|
||||
|
||||
;Initialize Source String Pointer and Index
|
||||
SETSRC: STX SRCLO ;Save Source String Pointer
|
||||
STY SRCHI
|
||||
LDY #$00 ;Initialize Index Into String
|
||||
RTS
|
||||
|
||||
;Retrieve Source String Pointer
|
||||
GETSRC: LDX SRCLO
|
||||
LDY SRCHI
|
||||
RTS
|
||||
**
|
Loading…
Reference in New Issue
Block a user