mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-06-26 05:29:32 +00:00
Moved common Vic 20 code to vic.a02
This commit is contained in:
parent
9f705b5fe3
commit
fcd68dcfaa
106
include/vic.a02
Normal file
106
include/vic.a02
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
;c02 Program Initialization Code for Vic-20 - Common Code
|
||||||
|
|
||||||
|
;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)
|
||||||
|
|
||||||
|
;Zero Page Locations
|
||||||
|
SRCLO EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
||||||
|
SRCHI EQU $23 ;Source Pointer MSB [Temporary Pointers]
|
||||||
|
DSTLO EQU $24 ;Destination Pointer LSB [Temporary Pointers]
|
||||||
|
DSTHI EQU $25 ;Destination Pointer MSB [Temporary Pointers]
|
||||||
|
BLKLO EQU $26 ;Block Pointer LSB [Floating Point Work Area]
|
||||||
|
BLKHI EQU $27 ;Block Pointer MSB [Floating Point Work Area]
|
||||||
|
STKLO EQU $28 ;Stack Pointer LSB [Floating Point Work Area]
|
||||||
|
STKHI EQU $29 ;Stack Pointer MSB [Floating Point Work Area]
|
||||||
|
RDSEED EQU $2A ;Random Seed [Software Jiffy Clock (Low Byte)]
|
||||||
|
TEMP0 EQU $FB ;Temporary Variable [Unused Byte]
|
||||||
|
TEMP1 EQU $FC ;Temporary Variable [Unused Byte]
|
||||||
|
TEMP2 EQU $FD ;Temporary Variable [Unused Byte]
|
||||||
|
TEMP3 EQU $FE ;Temporary Variable [Unused Byte]
|
||||||
|
|
||||||
|
USER0 EQU $0310 ;Free Byte for User Programs
|
||||||
|
RANDOM EQU $0311 ;Random Number Storage [Unused Byte]
|
||||||
|
STKSAV EQU $0312 ;Machine Stack Storage [Unused Byte]
|
||||||
|
STKSLO EQU $0313 ;Stack Start LSB [Unused Byte]
|
||||||
|
STKSHI EQU $0334 ;Stack Start MSB [Unused Byte]
|
||||||
|
STKELO EQU $0335 ;Stack End LSB [Unused Byte]
|
||||||
|
STKEHI EQU $0336 ;Stack End MSB [Unused Byte]
|
||||||
|
BLKSLO EQU $0337 ;Block Start LSB [Unused Byte]
|
||||||
|
BLKSHI EQU $0338 ;Block Start MSB [Unused Byte]
|
||||||
|
BLKELO EQU $0339 ;Block Start MSB [Unused Byte]
|
||||||
|
BLKEHI EQU $033A ;Block End MSB [Unused Byte]
|
||||||
|
BLKLEN EQU $033B ;Block Length [Unused Byte]
|
||||||
|
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
|
||||||
|
USER15 EQU $03FF ;Free Byte for User Programs
|
||||||
|
|
||||||
|
;Cakculated Addresses
|
||||||
|
BASICX EQU BASIC+$0B ;End of Basic Program
|
||||||
|
|
||||||
|
;Machine Language Basic Stub
|
||||||
|
ORG BASIC ;Start
|
||||||
|
DC <BASICX, >BASICX ; Pointer to Next Line
|
||||||
|
DC $00, $00 ; Line Number (0)
|
||||||
|
DC $9E ; SYS
|
||||||
|
DC $20 ; ' '
|
||||||
|
DC SYSADR ; "addr"
|
||||||
|
DC $00 ;End of Line Marker
|
||||||
|
DC $00, $00 ;End of Basic Program
|
||||||
|
|
||||||
|
START: TSX ;Get Stack Pointer
|
||||||
|
STX STKSAV ;and Save for Exit
|
||||||
|
; LDA #$0E ;Switch to Upper/Lower Case
|
||||||
|
; JSR PRCHR
|
||||||
|
; LDA #$08 ;Disable Commodore+Shift
|
||||||
|
; JSR PRCHR
|
||||||
|
; LDA #$93 ;Clear Screen
|
||||||
|
; JSR PRCHR
|
||||||
|
JMP MAIN ;Execute Program
|
||||||
|
|
||||||
|
EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
|
||||||
|
TXS ;and Restore It
|
||||||
|
RTS ;Return to BASIC
|
||||||
|
|
||||||
|
;Poll Keyboard for Character
|
||||||
|
PLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
|
||||||
|
|
||||||
|
;Get Character from Keyboard
|
||||||
|
GETKEY: EQU PLKEY
|
||||||
|
|
||||||
|
;Wait for Character from Keyboard
|
||||||
|
RDKEY: JSR GETKEY ;Poll Keyboard
|
||||||
|
BEQ RDKEY ;If No Key, Loop
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;Delete Previous Character
|
||||||
|
DELCHR: LDA #DELKEY ;Load Delete Character
|
||||||
|
JMP PRCHR ;Print and Return
|
||||||
|
|
||||||
|
;Advance Character to Next line
|
||||||
|
NEWLIN: LDA #RTNKEY ;Load C/R into Accumulator
|
||||||
|
JMP PRCHR ;Print and Return
|
||||||
|
|
||||||
|
;Print Character to Console
|
||||||
|
PRCHR EQU $FFD2 ;Aliased to Kernal CHROUT Routine
|
||||||
|
|
||||||
|
;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
|
|
@ -1,119 +1,12 @@
|
||||||
; c02 Program Initialization Code for Unexpanded VIC-20
|
; 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)
|
|
||||||
|
|
||||||
;Zero Page Locations
|
|
||||||
strlo EQU $FB ;String Pointer (stdio.asm)
|
|
||||||
strhi EQU $FC ;Free Byte for User Programs
|
|
||||||
usrzp3 EQU $FD ;Free Byte for User Programs
|
|
||||||
usrzp4 EQU $FE ;Free Byte for User Programs
|
|
||||||
|
|
||||||
;Other RAM Locations
|
|
||||||
user0 EQU $0310 ;Free Byte for User Programs
|
|
||||||
user1 EQU $0311 ;Free Byte for User Programs
|
|
||||||
user2 EQU $0312 ;Free Byte for User Programs
|
|
||||||
user3 EQU $0313 ;Free Byte for User Programs
|
|
||||||
user4 EQU $0334 ;Free Byte for User Programs
|
|
||||||
user5 EQU $0335 ;Free Byte for User Programs
|
|
||||||
user6 EQU $0336 ;Free Byte for User Programs
|
|
||||||
user7 EQU $0337 ;Free Byte for User Programs
|
|
||||||
user8 EQU $0338 ;Free Byte for User Programs
|
|
||||||
user9 EQU $0339 ;Free Byte for User Programs
|
|
||||||
user10 EQU $033A ;Free Byte for User Programs
|
|
||||||
user11 EQU $033B ;Free Byte for User Programs
|
|
||||||
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
|
|
||||||
user15 EQU $03FF ;Free Byte for User Programs
|
|
||||||
|
|
||||||
;Video RAM and ROM
|
;Video RAM and ROM
|
||||||
vicscn EQU $1E00 ;Video Screen Memory Area (Unexpanded)
|
VICSCN EQU $1E00 ;Video Screen Memory Area (Unexpanded)
|
||||||
chrrom EQU $8000 ;Character Generator ROM
|
CHRROM EQU $8000 ;Character Generator ROM
|
||||||
vicclr EQU $9600 ;Color RAM (Unexpanded)
|
VICCLR EQU $9600 ;COLOR RAM (UNEXPANDED)
|
||||||
|
|
||||||
;Kernal Routines
|
;BASIC Stub Constants
|
||||||
chrin EQU $FFCF ;Input Character to Channel
|
BASIC EQU $1001 ;Start of BASIC Program
|
||||||
chrout EQU $FFD2 ;Output Character to Channel
|
SYSADR EQM "4110" ;M/L SYS Address
|
||||||
getin EQU $FFE4 ;Read Character from Keyboard Buffer
|
|
||||||
|
|
||||||
;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 user15 ;and Save for Exit
|
|
||||||
JMP main ;Execute Program
|
|
||||||
|
|
||||||
exit: LDX user15 ;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
|
|
||||||
|
|
||||||
;Delete Previous Character
|
|
||||||
delchr: RTS
|
|
||||||
|
|
||||||
;Advance Character to Next line
|
|
||||||
newlin: LDA #$0D ;Load C/R into Accumulator
|
|
||||||
|
|
||||||
;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
|
|
||||||
|
|
||||||
exit: RTS ;Return to Monitor
|
|
||||||
|
|
||||||
|
INCLUDE "../include/vic.a02" ;Include VIC 20 Common Code
|
||||||
|
|
|
@ -1,18 +1,34 @@
|
||||||
/* py65mon Header File */
|
/* Unexpanded VIC 20 Header File */
|
||||||
|
|
||||||
//Zero Page Variables
|
//#pragma ascii invert //switch case for PETSCII
|
||||||
|
|
||||||
//Kernal Routines Memory Mapped I/O
|
//Platform Specific Constants
|
||||||
char chrin(); //Input Character to Channel
|
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
||||||
void chrout(); //Output Character to Channel
|
#define ESCKEY $03 //Escape/Stop Key (STOP)
|
||||||
char getin(); //Read Character from Keyboard Buffer
|
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
||||||
|
|
||||||
|
//Library Pointer Variables
|
||||||
|
char srclo,srchi; //Source String Pointer for Library Functions
|
||||||
|
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||||
|
char blklo,blkhi; //Block Segment Pointer
|
||||||
|
char stklo,stkhi; //Stack Pointer
|
||||||
|
|
||||||
|
//Library Variables
|
||||||
|
char blkslo, blkshi; //Block Start Address
|
||||||
|
char blkelo, blkehi; //Block End Address
|
||||||
|
char blklen; //Block Segment Length
|
||||||
|
char stkslo, stkshi; //Stack Start Address
|
||||||
|
char stkelo, stkehi; //Stsck End Address
|
||||||
|
char random, rdseed; //Pseudo-Random Number Generation
|
||||||
|
char temp0, temp1, temp2, temp3; //Temporary Storage
|
||||||
|
|
||||||
//System Subroutines
|
//System Subroutines
|
||||||
char plkey(); //Poll Console for character
|
char plkey(); //Poll Console for character
|
||||||
char rdkey(); //Wait for character from Console
|
char rdkey(); //Wait for character from Console
|
||||||
char getkey(); //Read ASCII character from Console
|
char getkey(); //Read ASCII character from Console
|
||||||
void newlin(); //Advance cursor to beginning of next line
|
void newlin(); //Advance cursor to beginning of next line
|
||||||
void prchr(); //Print ASCII character to Console
|
void delchr(); //Delete previous character
|
||||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
void prchr(); //Print ASCII character to Console
|
||||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||||
|
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||||
|
|
||||||
|
|
|
@ -1,98 +1,12 @@
|
||||||
;c02 Program Initialization Code for VIC-20 with 3K Expansion
|
;c02 Program Initialization Code for VIC-20 with 3K Expansion
|
||||||
|
|
||||||
;System Specific ASCII Key Mappings
|
|
||||||
DELKEY EQU $7F ;Delete/Backspace Key (Delete)
|
|
||||||
ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
|
|
||||||
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
|
|
||||||
|
|
||||||
;Zero Page Locations
|
|
||||||
SRCLO EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
|
||||||
SRCHI EQU $23 ;Source Pointer MSB [Temporary Pointers]
|
|
||||||
DSTLO EQU $25 ;Destination Pointer LSB [Temporary Pointers]
|
|
||||||
DSTHI EQU $24 ;Destination Pointer MSB [Temporary Pointers]
|
|
||||||
RDSEED EQU $A2 ;Random Seed [Software Jiffy Clock (Low Byte)]
|
|
||||||
BLKLO EQU $FD ;Block Pointer LSB [Unused Byte]
|
|
||||||
BLKHI EQU $FE ;Block Pointer MSB [Unused Byte]
|
|
||||||
STKLO EQU $FD ;Stack Pointer LSB [Unused Byte]
|
|
||||||
STKHI EQU $FE ;Stack Pointer MSB [Unused Byte]
|
|
||||||
|
|
||||||
USER0 EQU $0310 ;Free Byte for User Programs
|
|
||||||
USER1 EQU $0311 ;Free Byte for User Programs
|
|
||||||
STKSAV EQU $0312 ;Machine Stack Storage [Unused Byte]
|
|
||||||
STKSLO EQU $0313 ;Stack Start LSB [Unused Byte]
|
|
||||||
STKSHI EQU $0334 ;Stack Start MSB [Unused Byte]
|
|
||||||
STKELO EQU $0335 ;Stack End LSB [Unused Byte]
|
|
||||||
STKEHI EQU $0336 ;Stack End MSB [Unused Byte]
|
|
||||||
BLKSLO EQU $0337 ;Block Start LSB [Unused Byte]
|
|
||||||
BLKSHI EQU $0338 ;Block Start MSB [Unused Byte]
|
|
||||||
BLKELO EQU $0339 ;Block Start MSB [Unused Byte]
|
|
||||||
BLKEHI EQU $033A ;Block End MSB [Unused Byte]
|
|
||||||
BLKLEN EQU $033B ;Block Length [Unused Byte]
|
|
||||||
TBFFR EQU $033C ;Cassette I/O Buffer
|
|
||||||
TEMP0 EQU $03FC ;Temporary Variable [Unused Byte]
|
|
||||||
TEMP1 EQU $03FD ;Temporary Variable [Unused Byte]
|
|
||||||
TEMP2 EQU $03FE ;Temporary Variable [Unused Byte]
|
|
||||||
TEMP3 EQU $03FF ;Temporary Variable [Unused Byte]
|
|
||||||
|
|
||||||
;Video RAM and ROM
|
;Video RAM and ROM
|
||||||
VICSCN EQU $1E00 ;Video Screen Memory Area (Unexpanded)
|
VICSCN EQU $1E00 ;Video Screen Memory Area (Unexpanded)
|
||||||
CHRROM EQU $8000 ;Character Generator ROM
|
CHRROM EQU $8000 ;Character Generator ROM
|
||||||
VICCLR EQU $9600 ;Color RAM (Unexpanded)
|
VICCLR EQU $9600 ;Color RAM (Unexpanded)
|
||||||
|
|
||||||
;Machine Language Basic Stub
|
;BASIC Stub Constants
|
||||||
ORG $0401 ;Start
|
BASIC EQU $0401 ;Start of BASIC Program
|
||||||
BASIC: DC $0C, $04 ; Pointer to Next Line (1036)
|
SYSADR EQM "1038" ;M/L SYS Address
|
||||||
DC $00, $00 ; Line Number (0)
|
|
||||||
DC $9E ; SYS
|
|
||||||
DC $20 ; ' '
|
|
||||||
DC $31, $30, $33 ,$38 ; "1038"
|
|
||||||
DC $00 ;End of Line Marker
|
|
||||||
DC $00, $00 ;End of Basic Program
|
|
||||||
|
|
||||||
START: TSX ;Get Stack Pointer
|
INCLUDE "../include/vic.a02" ;Include VIC 20 Common Code
|
||||||
STX STKSAV ;and Save for Exit
|
|
||||||
JMP main ;Execute Program
|
|
||||||
|
|
||||||
EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
|
|
||||||
TXS ;and Restore It
|
|
||||||
RTS ;Return to BASIC
|
|
||||||
|
|
||||||
;Poll Keyboard for Character
|
|
||||||
PLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
|
|
||||||
|
|
||||||
;Get Character from Keyboard
|
|
||||||
GETKEY EQU PLKEY
|
|
||||||
|
|
||||||
;Wait for Character from Keyboard
|
|
||||||
RDKEY: JSR GETKEY ;Poll Keyboard
|
|
||||||
BEQ RDKEY ;If No Key, Loop
|
|
||||||
RTS
|
|
||||||
|
|
||||||
;Delete Previous Character
|
|
||||||
DELCHR: LDA #DELKEY ;Load Delete Character
|
|
||||||
JMP PRCHR ;Print and Return
|
|
||||||
|
|
||||||
;Advance Character to Next line
|
|
||||||
NEWLIN: LDA #RTNKEY ;Load C/R into Accumulator
|
|
||||||
JMP PRCHR ;Print and Return
|
|
||||||
|
|
||||||
;Print Character to Console
|
|
||||||
PRCHR EQU $FFD2 ;Aliased to Kernal CHROUT Routine
|
|
||||||
|
|
||||||
;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
|
|
||||||
|
|
34
include/vic3k.h02
Normal file
34
include/vic3k.h02
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* VIC 20 with 3k Expansion Header File */
|
||||||
|
|
||||||
|
//#pragma ascii invert //switch case for PETSCII
|
||||||
|
|
||||||
|
//Platform Specific Constants
|
||||||
|
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
||||||
|
#define ESCKEY $03 //Escape/Stop Key (STOP)
|
||||||
|
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
||||||
|
|
||||||
|
//Library Pointer Variables
|
||||||
|
char srclo,srchi; //Source String Pointer for Library Functions
|
||||||
|
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||||
|
char blklo,blkhi; //Block Segment Pointer
|
||||||
|
char stklo,stkhi; //Stack Pointer
|
||||||
|
|
||||||
|
//Library Variables
|
||||||
|
char blkslo, blkshi; //Block Start Address
|
||||||
|
char blkelo, blkehi; //Block End Address
|
||||||
|
char blklen; //Block Segment Length
|
||||||
|
char stkslo, stkshi; //Stack Start Address
|
||||||
|
char stkelo, stkehi; //Stsck End Address
|
||||||
|
char random, rdseed; //Pseudo-Random Number Generation
|
||||||
|
char temp0, temp1, temp2, temp3; //Temporary Storage
|
||||||
|
|
||||||
|
//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 delchr(); //Delete previous character
|
||||||
|
void prchr(); //Print ASCII character to Console
|
||||||
|
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||||
|
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||||
|
|
|
@ -1,108 +1,12 @@
|
||||||
;c02 Program Initialization Code for Vic-20 with at 8K Expansion
|
;c02 Program Initialization Code for Vic-20 with at 8K Expansion
|
||||||
|
|
||||||
;System Specific ASCII Key Mappings
|
|
||||||
DELKEY EQU $14 ;Delete/Backspace Key (Delete)
|
|
||||||
ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
|
|
||||||
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
|
|
||||||
|
|
||||||
;Zero Page Locations
|
|
||||||
SRCLO EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
|
||||||
SRCHI EQU $23 ;Source Pointer MSB [Temporary Pointers]
|
|
||||||
DSTLO EQU $24 ;Destination Pointer LSB [Temporary Pointers]
|
|
||||||
DSTHI EQU $25 ;Destination Pointer MSB [Temporary Pointers]
|
|
||||||
BLKLO EQU $26 ;Block Pointer LSB [Floating Point Work Area]
|
|
||||||
BLKHI EQU $27 ;Block Pointer MSB [Floating Point Work Area]
|
|
||||||
STKLO EQU $28 ;Stack Pointer LSB [Floating Point Work Area]
|
|
||||||
STKHI EQU $29 ;Stack Pointer MSB [Floating Point Work Area]
|
|
||||||
RDSEED EQU $2A ;Random Seed [Software Jiffy Clock (Low Byte)]
|
|
||||||
TEMP0 EQU $FB ;Temporary Variable [Unused Byte]
|
|
||||||
TEMP1 EQU $FC ;Temporary Variable [Unused Byte]
|
|
||||||
TEMP2 EQU $FD ;Temporary Variable [Unused Byte]
|
|
||||||
TEMP3 EQU $FE ;Temporary Variable [Unused Byte]
|
|
||||||
|
|
||||||
USER0 EQU $0310 ;Free Byte for User Programs
|
|
||||||
RANDOM EQU $0311 ;Random Number Storage [Unused Byte]
|
|
||||||
STKSAV EQU $0312 ;Machine Stack Storage [Unused Byte]
|
|
||||||
STKSLO EQU $0313 ;Stack Start LSB [Unused Byte]
|
|
||||||
STKSHI EQU $0334 ;Stack Start MSB [Unused Byte]
|
|
||||||
STKELO EQU $0335 ;Stack End LSB [Unused Byte]
|
|
||||||
STKEHI EQU $0336 ;Stack End MSB [Unused Byte]
|
|
||||||
BLKSLO EQU $0337 ;Block Start LSB [Unused Byte]
|
|
||||||
BLKSHI EQU $0338 ;Block Start MSB [Unused Byte]
|
|
||||||
BLKELO EQU $0339 ;Block Start MSB [Unused Byte]
|
|
||||||
BLKEHI EQU $033A ;Block End MSB [Unused Byte]
|
|
||||||
BLKLEN EQU $033B ;Block Length [Unused Byte]
|
|
||||||
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
|
|
||||||
USER15 EQU $03FF ;Free Byte for User Programs
|
|
||||||
|
|
||||||
;Video RAM and ROM
|
;Video RAM and ROM
|
||||||
VICSCN EQU $1000 ;Video Screen Memory Area (Unexpanded)
|
VICSCN EQU $1000 ;Video Screen Memory Area (Unexpanded)
|
||||||
CHRROM EQU $8000 ;Character Generator ROM
|
CHRROM EQU $8000 ;Character Generator ROM
|
||||||
VICCLR EQU $9400 ;Color RAM (Unexpanded)
|
VICCLR EQU $9400 ;Color RAM (Unexpanded)
|
||||||
|
|
||||||
;Machine Language Basic Stub
|
;BASIC Stub Constants
|
||||||
ORG $1201 ;Start
|
BASIC EQU $1201 ;Start of BASIC Program
|
||||||
BASIC: DC $0C, $12 ; Pointer to Next Line (4108)
|
SYSADR EQM "4622" ;M/L SYS Address
|
||||||
DC $00, $00 ; Line Number (0)
|
|
||||||
DC $9E ; SYS
|
|
||||||
DC $20 ; ' '
|
|
||||||
DC $34, $36, $32 ,$32 ; "4622"
|
|
||||||
DC $00 ;End of Line Marker
|
|
||||||
DC $00, $00 ;End of Basic Program
|
|
||||||
|
|
||||||
START: TSX ;Get Stack Pointer
|
INCLUDE "../include/vic.a02" ;Include VIC 20 Common Code
|
||||||
STX STKSAV ;and Save for Exit
|
|
||||||
; LDA #$0E ;Switch to Upper/Lower Case
|
|
||||||
; JSR PRCHR
|
|
||||||
; LDA #$08 ;Disable Commodore+Shift
|
|
||||||
; JSR PRCHR
|
|
||||||
; LDA #$93 ;Clear Screen
|
|
||||||
; JSR PRCHR
|
|
||||||
JMP MAIN ;Execute Program
|
|
||||||
|
|
||||||
EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
|
|
||||||
TXS ;and Restore It
|
|
||||||
RTS ;Return to BASIC
|
|
||||||
|
|
||||||
;Poll Keyboard for Character
|
|
||||||
PLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
|
|
||||||
|
|
||||||
;Get Character from Keyboard
|
|
||||||
GETKEY: EQU PLKEY
|
|
||||||
|
|
||||||
;Wait for Character from Keyboard
|
|
||||||
RDKEY: JSR GETKEY ;Poll Keyboard
|
|
||||||
BEQ RDKEY ;If No Key, Loop
|
|
||||||
RTS
|
|
||||||
|
|
||||||
;Delete Previous Character
|
|
||||||
DELCHR: LDA #DELKEY ;Load Delete Character
|
|
||||||
JMP PRCHR ;Print and Return
|
|
||||||
|
|
||||||
;Advance Character to Next line
|
|
||||||
NEWLIN: LDA #RTNKEY ;Load C/R into Accumulator
|
|
||||||
JMP PRCHR ;Print and Return
|
|
||||||
|
|
||||||
;Print Character to Console
|
|
||||||
PRCHR EQU $FFD2 ;Aliased to Kernal CHROUT Routine
|
|
||||||
|
|
||||||
;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
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user