1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-25 21:33:44 +00:00
C02/include/vic3k.a02
2018-08-02 05:10:14 -04:00

100 lines
3.5 KiB
Plaintext

;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
VICSCN EQU $1E00 ;Video Screen Memory Area (Unexpanded)
CHRROM EQU $8000 ;Character Generator ROM
VICCLR EQU $9600 ;Color RAM (Unexpanded)
;Machine Language Basic Stub
ORG $0401 ;Start
BASIC: DC $0C, $04 ; Pointer to Next Line (1036)
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
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