1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-17 15:06:29 +00:00
C02/include/apple1.a02
Curtis F Kaylor 35377b5807 Squashed commit of the following:
commit ed00e1d1b5a9783a72dade3f3676b161a9cfe287
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 22:20:49 2018 -0400

    Documented joystk, paddle, and lgtpen modules

commit ec0a5ede8d1b043fcf0094ea653255a808dbf8d3
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 20:31:11 2018 -0400

    Added joystick, paddle, and lightpen test programs

commit 7b787f432e2f4f7ae5d7f0053ade1d3586a4fad1
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 20:30:03 2018 -0400

    Updated Apple II and VIC-20 Batch Files

commit 50568294349d7e3c6b7d0d364aeaece73c9e4ab6
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 20:28:09 2018 -0400

    Separated light pen code into separate files

commit d45e59f73d55eef1d30c591d19a043ad79cfd81a
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 19:28:56 2018 -0400

    Moved code for paddles into separate include files

commit fc5c5472d758c960332ea14105d5ec4a7c8cbbfb
Author: Curtis F Kaylor <revcurtis@gmail.com>
Date:   Sun Sep 9 16:15:32 2018 -0400

    Added system specific module 'joystk'
2018-09-12 09:54:54 -04:00

110 lines
3.3 KiB
Plaintext

;Apple 1 program initialization code for c02 programs
;System Specific ASCII Key Mappings
DELKEY EQU $5F ;Delete/Backspace Key (Left Arrow/Underscore)
ESCKEY EQU $1B ;Escape/Stop Key (Escape)
RTNKEY EQU $0D ;Return/Enter Key (Carriage Return)
;Locations used by Monitor
XAML EQU $24 ;Examine Index
XAMH EQU $25 ;
STL EQU $26 ;Store Index
STH EQU $27 ;
HEXL EQU $28 ;Hex Data
HEXH EQU $29 ;
YSAVE EQU $2A ;Y Register Storage
MODE EQU $2B ;Mode: Store, Examine, Block Examine
BUFFER EQU $200 ;Input Buffer
;Standard Library Variables
SRCLO EQU $30 ;Source String Pointer (stdio.a02)
SRCHI EQU $31
DSTLO EQU $32 ;Destination String Pointer (string.a02)
DSTHI EQU $33
BLKLO EQU $34 ;Block Segment Pointer (block.a02)
BLKHI EQU $35
STKLO EQU $35 ;System Pointer (pointer.a02)
STKHI EQU $36
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
BLKLEN EQU $47 ;Block Segment Length
BLKSLO EQU $48 ;Block Start Address
BLKSHI EQU $49
BLKELO EQU $4A ;Block End Address
BLKEHI EQU $4B
STKSLO EQU $4C ;Stack Start Address
STKSHI EQU $4D
STKELO EQU $4E ;Stack End Address
STKEHI EQU $4F
;PIA 6820 Registers
KBD EQU $D010 ;Keyboard Data
KBDCR EQU $D011 ;Keyboard Control Register
DSP EQU $D012 ;Display Data
DSPCR EQU $D013 ;Display Control Register
EXIT EQU $FF00 ;Monitor Entry Point
ECHO EQU $FFEF ;Subroutine - Print Character in Accumulator
PRBYTE EQU $FFDC ;Subroutine - Print Accumulator as Hexadadecimal number
PRHEX EQU $FFE5 ;Subroutine - Print Low Nybble of Accumulator as Hex Digit
ORG $0300 ;Start one page above Monitor input buffer
START: LDX #$FF ;Reset stack - the monitor doesn't do this
TXS ; (probably because of lack of space)
JSR NEWLIN ;Move cursor to next line before executing program
JMP MAIN ;Execute Program
;Subroutine Poll Keyboard
PLKEY: INC RDSEED ;Cycle Keypress Counter
BIT KBDCR ;Check the Keyboard Control Register
BMI RDKEYA ;If Key Pressed, Read Key
LDA #0 ;Otherwise Return ASCII NUL
RTS
GETCHR: INC RDSEED ;Cycle Keypress Counter
RDKEYC: BIT KBDCR ;Check the Keyboard Control Register
BPL RDKEYC ; and loop if key not pressed
RDKEYA: LDA KBD ; Read key into Accumulator
RTS
GETKEY: JSR GETCHR ;Subroutine - Read ASCII from Keyboard
GETKEA: AND #$7F ;Strip High Bit
BIT GETKEM ;If Character is in
BEQ GETKEX ; Alpha Block ($40-$74)
AND #$5F ; Strip Bit 5
GETKEX: RTS
GETKEM: DC $40 ;Character Block Bit Mask
PUTCHR EQU ECHO ;Alias to Monitor Routine
;Delete Previous Character
DELCHR: LDA #DELKEY ;Load Underscore Character
JMP PUTCHR ; and Print it
;Advance Character to Next line
NEWLIN: LDA #$0D ;Load C/R into Accumulator
JMP PUTCHR ; and Print it
;Clear the Screen
CLRSCR: ;Do Nothing (Drop to RTS)
;Move Cursor to Specified Coordinates
SETPOS: RTS ;No Action
;Get Cursor Position
GETPOS EQU LGTPEN ;Return Error
;Get Screen Size
GETSIZ: LDA #40 ;40 Columns
LDY #24 ;24 Lines
RTS