1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-29 16:51:10 +00:00
C02/include/header.a02

86 lines
3.1 KiB
Plaintext
Raw Normal View History

;Template Program Initialization code for C02 programs
2018-01-28 18:30:49 +00:00
;System Specific ASCII Key Mappings
DELKEY EQU $7F ;Delete/Backspace Key ($08=Backspace, $7F=Delete)
ESCKEY EQU $1B ;Escape/Stop Key ($03=Ctrl-C, $1B=Escape)
RTNKEY EQU $0D ;Return/Enter Key ($0D=Carriage Return)
;Zero Page Locations
SRCPTR EQU $00 ;Source Pointer
DSTPTR EQU $02 ;Destination Pointer
BLKPTR EQU $34 ;Block Segment Pointer
STKPTR EQU $06 ;Stack Pointer
USRPTR EQU $08 ;User Pointer
2018-01-28 18:30:49 +00:00
XMADDR EQU $0A ;Extended Memory Address
XMBANK EQU $0C ;Extended Memory Bank
2018-01-28 18:30:49 +00:00
STKSAV EQU $0D ;Stack Pointer Storage
2018-01-28 18:30:49 +00:00
RDSEED EQU $0E ;Pseudo-RANDOM Seed
RANDOM EQU $0F ;Pseudo-RANDOM Number Storage
2018-01-28 18:30:49 +00:00
TEMP0 EQU $10 ;Temporary Storage
TEMP1 EQU $11
TEMP2 EQU $12
TEMP3 EQU $13
TMPPTR EQU $14 ;Temporary Pointer
2018-01-28 18:30:49 +00:00
BLKBGN EQU $16 ;Block Start Address
BLKEND EQU $18 ;Block End Address
BLKLEN EQU $1A ;Block Segment Length
SYSBFP EQU $1B ;Position in System Buffer
STKBGN EQU $1C ;Stack Start Address
STKEND EQU $1E ;Stack End Address
; $20-$FF ;Free Zero Page for Applications
2018-07-25 23:00:46 +00:00
SYSBFL EQU 128 ;System Buffer Size (Max String Size)
SYSBFR EQU $0200 ;System Buffer
; $0281-$02FF ;Unused
2018-01-28 18:30:49 +00:00
;Placeholders Labels for the Example Code Below
POLKEY EQU $FFFE ;ROM Read Key Routine
WSTART EQU $FFFF ;BASIC Warm Start Routine
ORG $0300 ;Program Start Address
2018-01-28 18:30:49 +00:00
START: NOP ;System specific initialization code
TXS ;If an RTS is used to return to the Operating System,
STX STKSAV ; the Stack Pointer should be preserved
JMP MAIN ;Execute Program
2018-11-07 05:11:09 +00:00
;Exit Program and Return to Operating System or Monitor
EXIT: BRK ;Usually BRK if returning to Monitor
LDX STKSAV ;If an RTS is used to return to the Operating System,
TXS ; the Stack Pointer should be restored to original state
RTS ; in case program exits in the middle of a Function
JMP WSTART ;Or it may just execute the BASIC Warm Start Routine
2018-01-28 18:30:49 +00:00
;Poll Character from Keyboard
PLKEY: INC RDSEED ;Cycle the Random Seed (if not provided by system)
NOP ;Code Read from Keyboad
RTS
;Read Character from Console
GETKEY; ;Usually Drops into RDKEY, but may need to call RDKEY
; then clean/convert returned value (e.g. Apple-1)
;Wait for Character from Console
2018-11-07 05:11:09 +00:00
GETCHR: JSR POLKEY ;Usually calls POLKEY
BEQ GETCHR ; until a non-zero is returned
2018-01-28 18:30:49 +00:00
RTS
;Delete Previous Character
DELCHR: RTS ;Code to move Cursor to left and clear that position
;May work differently on systems that don't support this
;Advance Cursor to Next line
NEWLIN: RTS ;Code to move Cursor to beginning of next line
;May emit Carriage Return, Line Feed, or both
;Print Character to Screen
PUTCHR: RTS ;Code to write ASCII character to Screen
2018-01-28 18:30:49 +00:00
INCLUDE "prbyte.a02" ;PRBYTE and PRHEX routines
INCLUDE "putstr.a02" ;PUTSTR routine