2018-08-14 18:49:55 +00:00
|
|
|
;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]
|
2019-03-23 00:28:43 +00:00
|
|
|
BFRLO EQU $35 ;Buffer Pointer LSB [Temporary String Pointer]
|
|
|
|
BFRHI EQU $36 ;Buffer Pointer MSB [Temporary String Pointer]
|
|
|
|
RDSEED EQU $A2 ;Random Seed [Software Jiffy Clock (Low Byte)
|
2018-08-14 18:49:55 +00:00
|
|
|
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]
|
|
|
|
|
2018-09-17 00:30:25 +00:00
|
|
|
;System Variables
|
2018-08-14 18:49:55 +00:00
|
|
|
USER0 EQU $0310 ;Free Byte for User Programs
|
2018-09-17 00:30:25 +00:00
|
|
|
USER1 EQU $0311 ;Free Byte for User Programs
|
|
|
|
USER2 EQU $0312 ;Free Byte for User Programs
|
|
|
|
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
|
2018-08-14 18:49:55 +00:00
|
|
|
TBFFR EQU $033C ;Cassette I/O Buffer
|
2018-09-17 00:30:25 +00:00
|
|
|
|
|
|
|
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]
|
2018-08-14 18:49:55 +00:00
|
|
|
|
2019-03-29 23:06:12 +00:00
|
|
|
;ROM Routines
|
|
|
|
FSFLFA EQU $F3D4 ;Find Logical File A
|
|
|
|
|
2018-08-14 18:49:55 +00:00
|
|
|
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
|
2018-09-12 13:54:54 +00:00
|
|
|
POLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
|
2018-08-14 18:49:55 +00:00
|
|
|
|
|
|
|
;Get Character from Keyboard
|
2018-09-17 00:30:25 +00:00
|
|
|
GETKEY EQU POLKEY ;Get Key From Keybord
|
|
|
|
|
|
|
|
;Get Character from Keyboard
|
|
|
|
;GETKEY: JSR POLKEY ;Get Key From Keybord
|
|
|
|
; ;The below is not working...
|
|
|
|
; LDY $9005 ;Get Character Memory Offset
|
|
|
|
; CPY #242 ;If Upper/Lower
|
|
|
|
; BNE GETKEX
|
|
|
|
; BIT $FF ; Bit 7 -> C, Bit 6 -> V
|
|
|
|
; BVC GETKEX ; If Bit 6 Set (Alpha)
|
|
|
|
; BCC GETKEL ; If Bit 7 Set (PETSCII Upper)
|
|
|
|
; AND #$7F ; Clear Bit 7 (ASCII Upper)
|
|
|
|
; BNE GETKEX ; Else
|
|
|
|
;GETKEL: ORA #$20 ; Set Bit 5 (ASCII Lower)
|
|
|
|
;GETKEX: ORA #$00 ;Set Flags
|
|
|
|
; RTS
|
2018-09-12 13:54:54 +00:00
|
|
|
|
|
|
|
;A = $41 %0100 0001
|
|
|
|
;a = $C1 %1100 0001 PETSCII
|
|
|
|
;a = $61 %0110 0001 PETSCII
|
|
|
|
;$9005 = 240 UPR/GFX
|
|
|
|
; 242 UPR/LWR
|
2018-08-14 18:49:55 +00:00
|
|
|
|
|
|
|
;Wait for Character from Keyboard
|
2018-09-12 13:54:54 +00:00
|
|
|
GETCHR: JSR GETKEY ;Poll Keyboard
|
|
|
|
BEQ GETCHR ;If No Key, Loop
|
2018-08-14 18:49:55 +00:00
|
|
|
RTS
|
|
|
|
|
2018-09-12 13:54:54 +00:00
|
|
|
;Print Character to Console
|
|
|
|
;uses direct call to SCRNOUT instead of CHROUT
|
2019-03-23 00:28:43 +00:00
|
|
|
PUTCHR EQU $E742 ;Aliased to SRCOUT Routine
|
2018-09-12 13:54:54 +00:00
|
|
|
|
2018-08-14 18:49:55 +00:00
|
|
|
;Delete Previous Character
|
|
|
|
DELCHR: LDA #DELKEY ;Load Delete Character
|
2018-09-12 13:54:54 +00:00
|
|
|
JMP PUTCHR ;Print and Return
|
2018-08-14 18:49:55 +00:00
|
|
|
|
|
|
|
;Advance Character to Next line
|
2018-09-17 00:30:25 +00:00
|
|
|
NEWLIN: LDX #0 ;Store 0
|
|
|
|
STX $D3 ;in Cursor Column and
|
|
|
|
JMP $E8C3 ;Execute NXTLINE Routine
|
2018-08-14 18:49:55 +00:00
|
|
|
|