1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-22 16:34:15 +00:00
C02/include/appl2std.a02

116 lines
3.7 KiB
Plaintext
Raw Normal View History

2018-02-14 00:55:25 +00:00
;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)
;Zero Page Variables (*=System Variable)
DSTLO EQU $06 ;Destination String/Array Pointer
2018-02-14 00:55:25 +00:00
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
INVFLG EQU $32 ;*Inverse Flag: $3F=Blinking, $7F=Inverse, $FF=Normal
RDSEED EQU $4E ;O/S Random Number Low Byte
2018-02-14 00:55:25 +00:00
; EQU $4F ;O/S Random Number High Byte
SRCLO EQU $71 ;Source String/Array Pointer
2018-02-14 00:55:25 +00:00
SRCHI EQU $72
; $E3 ;Unused
BLKSLO EQU $EB ;Block Start Address
BLKSHI EQU $EC
2018-02-14 00:55:25 +00:00
BLKELO EQU $ED ;Block End Address
BLKEHI EQU $EE
BLKLEN EQU $EF ;Block Segment Length
BFRLO EQU $FA ;Work Buffer Pointer
BFRHI EQU $FB
2018-02-14 00:55:25 +00:00
TEMP0 EQU $FC ;Temporary Storage
TEMP1 EQU $FD
TEMP2 EQU $FE
TEMP3 EQU $FF
;Page 3 Vectors
WARMST EQU $3D0 ;Jump vector to DOS warm start
COLDST EQU $3D3 ;Jump vector to DOS cold start
2018-02-14 00:55:25 +00:00
;I/O Locations
KBD EQU $C000 ;Keyboard Data
AKD EQU $C010 ;Keyboard Strobe Register
2018-03-03 19:35:12 +00:00
;BASIC Routines
SHWCUR EQU $CC4C ;Display Cursor
UPDATE EQU $CC70 ;Flash Cursor
STORY EQU $C3B3 ;Store Accumulator at Current Screen Position
2018-02-14 00:55:25 +00:00
;Monitor Routines
PRBLNK EQU $F94C ;Print 3 blanks
PRBLNX EQU $F94C ;Print X blanks
PRBLAX EQU $F94C ;Print character in A followed by X-1 blanks
2018-11-07 05:11:09 +00:00
GETCHR EQU $FD0C ;Waits for keypress and return in A
2018-02-14 00:55:25 +00:00
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 to Current Output Device
COUT1 EQU $FDF0 ;Print Character to Screen
2018-02-14 00:55:25 +00:00
BELL EQU $FF3A ;Ring Bell through COUT
MONZ EQU $FF69 ;Enter monitor (<Control-C>, <Return> leaves the monitor)
ECHO EQU COUT1 ;Print Character
EXIT EQU WARMST ;Return to Monitor
2018-02-14 00:55:25 +00:00
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
2018-11-07 05:11:09 +00:00
GETKEY JSR POLKEY ;Poll Keyboard
2018-03-03 19:35:12 +00:00
BEQ GETKEY ;Loop if No Key
AND #$7F ;Strip High Bit
RTS
2018-02-17 18:52:13 +00:00
;Print Character to Screen
2018-11-07 05:11:09 +00:00
PUTCHR ORA #$80 ;Set High Bit
CMP #$E0 ;
BCC PRCHRX ;If Lower Case
2018-03-03 19:35:12 +00:00
AND #$1F ; Convert to Inverse
PRCHRX: JMP ECHO ;Alias to Monitor Routine
2018-02-14 00:55:25 +00:00
;Delete Previous Character
DELCHR: LDX #2 ;Two Characters Total
LDA #$88 ;Load Backspace Character
JSR PRBLAX ;Print Accumulator and X-1 Blanks
2018-02-14 00:55:25 +00:00
LDA #$88 ;Load Backspace Character
2018-11-07 05:11:09 +00:00
JMP PUTCHR ;and Print it
2018-02-14 00:55:25 +00:00
;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