mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-19 12:32:08 +00:00
93 lines
2.8 KiB
Plaintext
93 lines
2.8 KiB
Plaintext
|
;Apple 1 program initialization code for c02 programs
|
||
|
|
||
|
;System Specific ASCII Key Mappings
|
||
|
DELKEY EQU $08 ;Delete/Backspace Key (Left Arrow)
|
||
|
ESCKEY EQU $1B ;Escape/Stop Key (Escape)
|
||
|
RTNKEY EQU $0D ;Return/Enter Key (Return)
|
||
|
|
||
|
;Standard Library Variables
|
||
|
DSTLO EQU $06 ;Destination String Pointer (string.a02)
|
||
|
DSTHI EQU $07
|
||
|
BLKLO EQU $08 ;Block Segment Pointer (block.a02)
|
||
|
BLKHI EQU $09
|
||
|
PTRLO EQU $1D ;System Pointer (pointer.a02)
|
||
|
PTRHI EQU $1E
|
||
|
RANDOM EQU $1F ;Random Number
|
||
|
RDSEED EQU $4E ;O/S Random Number Low Byte
|
||
|
; EQU $4F ;O/S Random Number High Byte
|
||
|
SRCLO EQU $71 ;Source String Pointer (stdio.a02)
|
||
|
SRCHI EQU $72
|
||
|
; $E3 ;Unused
|
||
|
BLKSLO EQU $EB ;Block Start Address
|
||
|
BLKSHI EQU $ED
|
||
|
BLKELO EQU $ED ;Block End Address
|
||
|
BLKEHI EQU $EE
|
||
|
BLKLEN EQU $EF ;Block Segment Length
|
||
|
TEMP0 EQU $FC ;Temporary Storage
|
||
|
TEMP1 EQU $FD
|
||
|
TEMP2 EQU $FE
|
||
|
TEMP3 EQU $FF
|
||
|
|
||
|
;I/O Locations
|
||
|
KBD EQU $C000 ;Keyboard Data
|
||
|
AKD EQU $C010 ;Keyboard Strobe Register
|
||
|
|
||
|
;Monitor Routines
|
||
|
RDKEY EQU $FD0C ;Waits for keypress and return in A
|
||
|
KEYIN EQU $FD1B ;Waits for keypress and cycle random-number generator
|
||
|
RDCHAR EQU $FD35 ;Read keyboard (processing escapes)
|
||
|
GETLIN EQU $FD6A ;Get Line from Keyboard into Input Buffer
|
||
|
CROUT EQU $FD8E ;Performs a carriage return
|
||
|
PRBYTE EQU $FDDA ;Print Accumulator as Hexadecimal Number
|
||
|
PRHEX EQU $FDE3 ;Print Low Nybble of Accumulator as Hex Digit
|
||
|
COUT EQU $FDED ;Print Character in Accumulator
|
||
|
BELL EQU $FF3A ;Ring Bell through COUT
|
||
|
MONZ EQU $FF69 ;Enter monitor (<Control-C>, <Return> leaves the monitor)
|
||
|
|
||
|
ECHO EQU COUT ;Print Character
|
||
|
EXIT EQU MONZ ;Return to Monitor
|
||
|
|
||
|
ORG $0C00 ;Safe Area for Machine Language
|
||
|
|
||
|
START: JMP MAIN ;Execute Program
|
||
|
|
||
|
|
||
|
;Subroutine Poll Keyboard
|
||
|
PLKEY: LDA #0 ;Clear Accumulator
|
||
|
BIT KBD ;Check Keyboard Strobe Bit
|
||
|
BPL PLKEYR ;If Key Pressed
|
||
|
LDA KBD ; Load Key Value
|
||
|
STA AKD ; Clear Strobe
|
||
|
PLKEYR: RTS
|
||
|
|
||
|
;Read Keyboard
|
||
|
GETKEY EQU KEYIN ;Alias to Monitor Routine
|
||
|
|
||
|
PRCHR EQU ECHO ;Alias to Monitor Routine
|
||
|
|
||
|
;Delete Previous Character
|
||
|
DELCHR: LDX #2 ;Two Characters Total
|
||
|
LDA #$88 ;Load Backspace Character
|
||
|
JSR PRBLNX ;Print Accumulator and X-1 Blanks
|
||
|
LDA #$88 ;Load Backspace Character
|
||
|
JMP PRCHR ;and Print it
|
||
|
|
||
|
;Advance Character to Next line
|
||
|
NEWLIN EQU CROUT ;Alias to Monitor Routine
|
||
|
|
||
|
;Initialize Destination String Pointer and Index
|
||
|
SETDST: STX DSTLO ;Save Destination String Pointer
|
||
|
STY DSTHI
|
||
|
RTS
|
||
|
|
||
|
;Initialize Source String Pointer and Index
|
||
|
SETSRC: STX SRCLO ;Save Source String Pointer
|
||
|
STY SRCHI
|
||
|
LDY #$00 ;Initialize Index Into String
|
||
|
RTS
|
||
|
|
||
|
;Retrieve Source String Pointer
|
||
|
GETSRC: LDX SRCLO
|
||
|
LDY SRCHI
|
||
|
RTS
|