1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-20 03:33:14 +00:00
C02/include/c64.a02

110 lines
3.8 KiB
Plaintext
Raw Normal View History

2018-01-28 18:30:49 +00:00
; c02 Program Initialization Code for Unexpanded VIC-20
;PETSCII Key Mappings
DELKEY EQU $14 ;Delete/Backspace Key (Delete)
2018-01-28 18:30:49 +00:00
ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
;Zero Page Variables
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 $A2 ;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]
;System Variables
USER3 EQU $0313 ;Free Byte for User Programs
BLKSLO EQU $0334 ;Block Start LSB [Unused Byte]
BLKSHI EQU $0335 ;Block Start MSB [Unused Byte]
BLKELO EQU $0336 ;Block Start MSB [Unused Byte]
BLKEHI EQU $0337 ;Block End MSB [Unused Byte]
BLKLEN EQU $0338 ;Block Length [Unused Byte]
RANDOM EQU $0339 ;Random Number Storage [Unused Byte]
STKSAV EQU $033A ;Machine Stack Storage [Unused Byte]
USER11 EQU $033B ;Free Byte for User Programs
TBFFR EQU $033C ;Cassette I/O Buffer
STKSLO EQU $03FC ;Stack Start LSB [Unused Byte]
STKSHI EQU $03FD ;Stack Start MSB [Unused Byte]
STKELO EQU $03FE ;Stack End LSB [Unused Byte]
STKEHI EQU $03FF ;Stack End MSB [Unused Byte]
;Video RAM and ROM
VICSCN EQU $0400 ;Video Screen Memory Area (Unexpanded)
CHRROM EQU $D000 ;Character Generator ROM
VICCLR EQU $D800 ;Color RAM (Unexpanded)
2018-01-28 18:30:49 +00:00
;Kernal Routines
chrin EQU $FFCF ;Input Character to Channel
chrout EQU $FFD2 ;Output Character to Channel
;Machine Language Basic Stub
ORG $0801 ;Start of Basic Program
BASIC: DC $0C, $10 ;Pointer to Next Line (4109)
DC $00, $00 ;Line Number (0)
DC $9E ;SYS
DC $20 ;' '
DC $32, $30, $36 ,$32 ;"2062"
2018-01-28 18:30:49 +00:00
DC $00 ;End of Line Marker
DC $00, $00 ;End of Basic Program
START: TSX ;Get Stack Pointer
STX STKSAV ;and Save for Exit
JMP MAIN ;Execute Program
2018-01-28 18:30:49 +00:00
EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
TXS ;and Restore It
RTS ;Return to BASIC
2018-01-28 18:30:49 +00:00
;Poll Keyboard for Character
POLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
2018-01-28 18:30:49 +00:00
;Get Character from Keyboard
GETKEY EQU POLKEY ;Get Key From Keybord
2018-01-28 18:30:49 +00:00
;Wait for Character from Keyboard
GETCHR: JSR GETKEY ;Poll Keyboard
BEQ GETCHR ;If No Key, Loop
2018-01-28 18:30:49 +00:00
RTS
;Print Character to Console
;uses direct call to SCRNOUT instead of CHROUT
PUTCHR EQU $E716 ;Aliased to SRCNOUT Routine
2018-01-28 18:30:49 +00:00
;Delete Previous Character
DELCHR: LDA #DELKEY ;Load Delete Character
JMP PUTCHR ;Print and Return
2018-01-28 18:30:49 +00:00
;Advance Character to Next line
NEWLIN: LDX #0 ;Store 0
STX $D3 ;in Cursor Column and
JMP $E87C ;Execute NXTLINE Routine
2018-01-28 18:30:49 +00:00
;Print Byte as Two-Digit Hex Number to Console
PRBYTE: PHA ;Save Accumulater
2018-01-28 18:30:49 +00:00
LSR ;Shift Hi Nybble to Low Nybble
LSR
LSR
LSR
JSR PRHEX ; and Print it
2018-01-28 18:30:49 +00:00
PLA ;Restore Accumulator
; and fall into prhex
2018-01-28 18:30:49 +00:00
;Print Low Nybble as Hex Digit to Console
PRHEX: AND #$0F ;Strip High Nybble
2018-01-28 18:30:49 +00:00
CMP #$0A ;If Low Nybble >= 10
BCC PRHEXC ;
2018-01-28 18:30:49 +00:00
ADC #$06 ; Convert ':' to 'A'...
PRHEXC: ADC #$30 ;Convert to ASCII Character
JMP PUTCHR ;Print Hex Digit and Return