1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-29 01:49:19 +00:00
C02/include/vic8k.a02
2018-08-02 05:10:14 -04:00

99 lines
3.5 KiB
Plaintext

; c02 Program Initialization Code for Vic-20 with at 8K 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
USER2 EQU $0312 ;Free Byte for User Programs
STKSLO EQU $0313 ;Free Byte for User Programs
STKSHI EQU $0334 ;Free Byte for User Programs
STKELO EQU $0335 ;Free Byte for User Programs
STKEHI EQU $0336 ;Free Byte for User Programs
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]
STKSAV EQU $033B ;Machine Stack Storage [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
VICSCN EQU $1000 ;Video Screen Memory Area (Unexpanded)
CHRROM EQU $8000 ;Character Generator ROM
VICCLR EQU $9400 ;Color RAM (Unexpanded)
;Machine Language Basic Stub
ORG $1201 ;Start
BASIC: DC $0C, $12 ; Pointer to Next Line (4108)
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
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