1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-12-01 14:51:52 +00:00
C02/include/vic8k.a02

99 lines
3.5 KiB
Plaintext
Raw Normal View History

2018-01-28 18:30:49 +00:00
; 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]
2018-01-28 18:30:49 +00:00
;Video RAM and ROM
VICSCN EQU $1000 ;Video Screen Memory Area (Unexpanded)
CHRROM EQU $8000 ;Character Generator ROM
VICCLR EQU $9400 ;Color RAM (Unexpanded)
2018-01-28 18:30:49 +00:00
;Machine Language Basic Stub
ORG $1201 ;Start
BASIC: DC $0C, $12 ; Pointer to Next Line (4108)
2018-01-28 18:30:49 +00:00
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
2018-01-28 18:30:49 +00:00
JMP main ;Execute Program
EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
2018-01-28 18:30:49 +00:00
TXS ;and Restore It
RTS ;Return to BASIC
;Poll Keyboard for Character
PLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
2018-01-28 18:30:49 +00:00
;Get Character from Keyboard
GETKEY: EQU PLKEY
2018-01-28 18:30:49 +00:00
;Wait for Character from Keyboard
RDKEY: JSR GETKEY ;Poll Keyboard
BEQ RDKEY ;If No Key, Loop
2018-01-28 18:30:49 +00:00
RTS
;Delete Previous Character
DELCHR: LDA #DELKEY ;Load Delete Character
JMP PRCHR ;Print and Return
2018-01-28 18:30:49 +00:00
;Advance Character to Next line
NEWLIN: LDA #RTNKEY ;Load C/R into Accumulator
JMP PRCHR ;Print and Return
2018-01-28 18:30:49 +00:00
;Print Character to Console
PRCHR EQU $FFD2 ;Aliased to Kernal CHROUT 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 PRCHR ;Print Hex Digit and Return