1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-30 23:50:04 +00:00
C02/include/x16.a02
2020-10-15 22:58:12 -04:00

94 lines
3.0 KiB
Plaintext

; c02 Program Initialization Code for Commander X16
; Compatible with x16emu Release 34
;PETSCII Key Mappings
DELKEY EQU $14 ;Delete/Backspace Key (Delete)
ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
; $00-$01 ;Miscellaneous Pointer
; $02-$21 ;ABI Registers
; $22-$52 ;Used by Basic graphics commands
XMBANK EQU $53 ;Extended Memory Bank
XADRLO EQU $54 ;Ext Memory Address LSB
XADRHI EQU $55 ;Ext Memory Address MSB
SRCPTR EQU $56 ;Source Pointer
DSTPTR EQU $59 ;Destination Pointer
BLKPTR EQU $5C ;Block Pointer
STKLO EQU $5E ;Stack Pointer LSB
STKHI EQU $5F ;Stack Pointer MSB
BFRLO EQU $60 ;Buffer Pointer LSB
BFRHI EQU $61 ;Buffer Pointer MSB
RANDOM EQU $62 ;Random Number Storage
RDSEED EQU $63 ;Random Seed
TEMP0 EQU $64 ;Temporary Variable
TEMP1 EQU $65 ;Temporary Variable
TEMP2 EQU $66 ;Temporary Variable
TEMP3 EQU $67 ;Temporary Variable
SYSBFP EQU $68 ;Position in System Buffer [Free Byte]
; $69-7F ;Available to User
; $80-$83 ;Used by Kernal and DOS
; $A4-$A8 ;Reserved for KERNAL/DOS/BASIC
; $A9-$FF ;Used by BASIC
;Other Constants
SYSBFL EQU 128 ;System Buffer Length
;Other Variables - User Storage Area
SYSBFR EQU $0700 ;System Buffer
BLKBGN EQU $07F4 ;Block Start Address
BLKEND EQU $07F6 ;Block End Address
BLKLEN EQU $07F8 ;Block Length
STKSAV EQU $07FA ;Machine Stack Storage
STKSLO EQU $07FC ;Stack Start LSB
STKSHI EQU $07FD ;Stack Start MSB
STKELO EQU $07FE ;Stack End LSB
STKEHI EQU $07FF ;Stack End MSB
;Machine Language Basic Stub - Same as Commodore 64
ORG $0801 ;Start of Basic Program
BASIC: DC $0C, $08 ;Pointer to Next Line
DC $00, $00 ;Line Number (0)
DC $9E ;SYS
DC $20 ;' '
DC $32, $30, $36 ,$32 ;"2062"
DC $00 ;End of Line Marker
DC $00, $00 ;End of Basic Program
START: TSX ;Get Stack Pointer
STX STKSAV ;and Save for Exit
SEC ;Set Screen Mode
LDA #0 ;to 40x30 Text
JSR $FF5F ;using SCRMOD
JMP MAIN ;Execute Program
EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
TXS ;and Restore It
RTS ;Return to BASIC
;Poll Keyboard for Character
POLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
;Get Character from Keyboard
GETKEY EQU POLKEY ;Aliased to POLKEY Routine
;Wait for Character from Keyboard
GETCHR: JSR GETKEY ;Poll Keyboard
BEQ GETCHR ;If No Key, Loop
RTS
;Print Character to Console
PUTCHR EQU $FFD2 ;Aliased to CHROUT Routine
;Delete Previous Character
DELCHR: LDA #DELKEY ;Load Delete Character
JMP PUTCHR ;Print and Return
;Advance Character to Next line
NEWLIN: LDA #RTNKEY ;Load Return Character
JMP PUTCHR ;Print and Return
INCLUDE "prbyte.a02" ;PRBYTE and PRHEX routine
INCLUDE "putstr.a02" ;PUTSTR routine