mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-28 10:51:14 +00:00
83 lines
2.4 KiB
Plaintext
83 lines
2.4 KiB
Plaintext
;py65mon program initialization code for c02 programs
|
|
|
|
;System Specific ASCII Key Mappings
|
|
DELKEY EQU $08 ;Delete/Backspace Key (Backspace)
|
|
ESCKEY EQU $1B ;Escape/Stop Key (Escape)
|
|
RTNKEY EQU $0D ;Return/Enter Key (Carriage Return)
|
|
|
|
;Zero Page Locations
|
|
SRCPTR EQU $30 ;Source Pointer
|
|
DSTPTR EQU $32 ;Destination Pointer
|
|
BFRLO EQU $34 ;Work Buffer Pointer
|
|
BFRHI EQU $35
|
|
BLKPTR EQU $36 ;Block Segment Pointer (block.a02)
|
|
STKLO EQU $38 ;Stack Pointer (stack.a02)
|
|
STKHI EQU $39
|
|
|
|
RDSEED EQU $3E ;Pseudo-RANDOM Seed
|
|
RANDOM EQU $3F ;Pseudo-RANDOM Number Storage
|
|
|
|
TEMP0 EQU $40 ;Temporary Storage
|
|
TEMP1 EQU $41
|
|
TEMP2 EQU $42
|
|
TEMP3 EQU $43
|
|
|
|
BLKBGN EQU $46 ;Block Start Address
|
|
BLKEND EQU $48 ;Block End Address
|
|
BLKLEN EQU $4A ;Block Segment Length
|
|
|
|
STKSLO EQU $4C ;Stack Start Address
|
|
STKSHI EQU $4D
|
|
STKELO EQU $4E ;Stack End Address
|
|
STKEHI EQU $4F
|
|
|
|
;Memory Mapped I/O
|
|
PUTCON EQU $F001 ;Write Character to Console
|
|
GETCON EQU $F004 ;Read Character from Console
|
|
|
|
ORG $0200 ;START Directly Above Stack
|
|
|
|
START: JMP MAIN ;Execute Program
|
|
|
|
;Poll Character from Keyboard
|
|
POLKEY: INC RDSEED ;Cycle the RANDOM Seed (if not provided by system)
|
|
LDA GETCON ;Read Character from Console
|
|
RTS
|
|
|
|
;Read Character from Console
|
|
GETKEY JSR POLKEY ;Get Raw Key Character
|
|
CMP #$E0
|
|
BEQ GETKEX ;If Not E0 Extended Key
|
|
ORA #$00 ; Set Status Flags
|
|
RTS ; and Return
|
|
GETKEX: JSR POLKEY ;Else Get Second Byte
|
|
ORA #$80 ; Set High Bit
|
|
RTS ; and Return
|
|
|
|
;Wait for Character from Console
|
|
GETCHR: JSR GETKEY ;Read Character from Console
|
|
BEQ GETCHR ; Loop if None Received
|
|
RTS
|
|
|
|
;Delete Previous Character
|
|
DELCHR: LDA #$08 ;Load Backspace into Accumulator
|
|
JSR PUTCHR ; and Print it
|
|
LDA #$20 ;Load Space into Accumulater
|
|
JSR PUTCHR ; and Print it
|
|
LDA #$08 ;Load Backspace into Accumulator
|
|
JMP PUTCHR ; and Print it
|
|
|
|
;Advance Character to Next line
|
|
NEWLIN: LDA #$0D ;Load C/R into Accumulator
|
|
JSR PUTCHR ; and Print it
|
|
LDA #$0A ;Load L/F into Accumulater
|
|
; and fall into PRCHR
|
|
|
|
;Print Character to Console
|
|
PUTCHR STA PUTCON ;Write Character to Console
|
|
RTS
|
|
|
|
EXIT: BRK ;Return to Monitor
|
|
|
|
INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routines
|