1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-22 01:31:33 +00:00
C02/include/run6502.a02

96 lines
2.7 KiB
Plaintext
Raw Normal View History

2020-04-27 15:50:22 +00:00
;run6502 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)
2020-04-27 15:50:22 +00:00
;Zero Page Locations
SRCPTR EQU $30 ;Source String Pointer
DSTPTR EQU $32 ;Destination String Pointer
BLKPTR EQU $34 ;Block Segment Pointer
STKPTR EQU $36 ;Stack Pointer
USRPTR EQU $38 ;User Pointer
XMADDR EQU $3A ;Extended Memory Address
XMBANK EQU $3C ;Extended Memory Bank
; $3D ;Unused
2020-04-27 15:50:22 +00:00
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
TMPPTR EQU $44 ;Temporary Pointer
2020-04-27 15:50:22 +00:00
BLKBGN EQU $46
BLKEND EQU $48
2020-04-27 15:50:22 +00:00
BLKLEN EQU $4A ;Block Segment Length
SYSBFP EQU $4B ;Position in System Buffer
STKBGN EQU $4C ;Stack Start Address
STKEND EQU $4E ;Stack End Address
; $50-$FF ;Free Zero Page for Applications
SYSBFL EQU 128 ;System Buffer Size (Max String Size)
SYSBFR EQU $0200 ;System Buffer
; $0281-$03FF ;Unused
2020-04-27 15:50:22 +00:00
;Memory Mapped I/O
_KBHIT EQU $FFF0 ;Is a Key Pressed
_GETCH EQU $FFF1 ;Read Keyboard (Blocking)
ORG $0400 ;START at RAM midpoint
2020-04-27 15:50:22 +00:00
START: JMP MAIN ;Execute Program
;Read Character from Console
GETKEY EQU $FFE0 ;Emulator _GETCH Routine
2020-04-27 15:50:22 +00:00
;Poll Character from Keyboard
POLKEY: BRK ;Exit Emulator
;Wait for Character from Console
GETCHR: JSR GETKEY ;Get Key from Console
BEQ GETCHR ;If None Pressed, Loop
RTS
;Read Character from stdin
RDCHAR: LDA $FFEA ;Read Character from STDIN
2020-04-27 15:50:22 +00:00
CMP #$FF ;If EOF
BNE RDCHAX
LDA #0 ; Set to ASCII NUL
RDCHAX ORA #0 ;Set Flags
2020-04-27 15:50:22 +00:00
RTS
;Delete Previous Character
DELCHR: LDA #$08 ;Load Backspace into Accumulator
JSR PUTCHR ; and Print it
LDA #$20 ;Load Space into Accumulator
2020-04-27 15:50:22 +00:00
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 Carriage Return into Accumulator
JSR PUTCHR ; and Print it
LDA #$0A ;Load Line Feed into Accumulator
2020-04-27 15:50:22 +00:00
JMP PUTCHR ; and Print it
;Print Character to Console
2020-04-27 16:53:59 +00:00
PUTCHR EQU $FFE3 ;Emulator CHROUT Routine
2020-04-27 15:50:22 +00:00
;Write Character to stdout
PRCHAR: STA $FFEA ;Read Character from STDIN
RTS
2020-04-27 16:53:59 +00:00
EXIT EQU $FFEC ;Emulator SHUTDN Routine
2020-04-27 15:50:22 +00:00
FSCMD EQU $FFE6 ;run6502 File System Command Routine
INCLUDE "prbyte.a02" ;PRBYTE and PRHEX routines
INCLUDE "putstr.a02" ;PUTSTR routine