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

91 lines
2.7 KiB
Plaintext
Raw Normal View History

2018-01-28 18:30:49 +00:00
; c02 Program Initialization Code for Commodore Plus/4 & 16
;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)
;Zero Page Locations
2018-11-07 05:11:09 +00:00
STRLO EQU $FE ;String Pointer (stdio.asm)
STRHI EQU $FF ;
2018-01-28 18:30:49 +00:00
;Other RAM Locations
2018-11-07 05:11:09 +00:00
TBFFR EQU $0333 ;Cassette I/O Buffer
2018-01-28 18:30:49 +00:00
;Video RAM and ROM
2018-11-07 05:11:09 +00:00
VIDSCN EQU $0C00 ;Video Screen Memory Area
CHRROM EQU $D000 ;Character Generator ROM
VIDCLR EQU $0800 ;Color RAM
2018-01-28 18:30:49 +00:00
;Kernal Routines
2018-11-07 05:11:09 +00:00
CHROUT EQU $FFD2 ;Output Character to Channel
GETIN EQU $FFE4 ;Read Character from Keyboard Buffer
CHRIN EQU $FFCF ;Input Character to Channel
2018-01-28 18:30:49 +00:00
;Machine Language Basic Stub
ORG $1001 ;Start
2018-11-07 05:11:09 +00:00
BASIC: DC $0C, $10 ; Pointer to Next Line (4108)
2018-01-28 18:30:49 +00:00
DC $00, $00 ; Line Number (0)
DC $9E ; SYS
DC $20 ; ' '
DC $34, $31, $31 ,$30 ; "4110"
DC $00 ;End of Line Marker
DC $00, $00 ;End of Basic Program
2018-11-07 05:11:09 +00:00
START: TSX ;Get Stack Pointer
2018-01-28 18:30:49 +00:00
STX user15 ;and Save for Exit
JMP main ;Execute Program
2018-11-07 05:11:09 +00:00
EXIT: LDX user15 ;Retrieve Saved Stack Pointer
2018-01-28 18:30:49 +00:00
TXS ;and Restore It
RTS ;Return to BASIC
;Poll Keyboard for Character
2018-11-07 05:11:09 +00:00
POLKEY EQU $FFE4 ;Alias to Kernal Routine GETIN
2018-01-28 18:30:49 +00:00
;Get Character from Keyboard
2018-11-07 05:11:09 +00:00
GETKEY EQU POLKEY
2018-01-28 18:30:49 +00:00
;Wait for Character from Keyboard
2018-11-07 05:11:09 +00:00
GETCHR: JSR POLKEY ;Poll Keyboard
BEQ GETCHR ;If No Key, Loop
2018-01-28 18:30:49 +00:00
RTS
;Advance Character to Next line
2018-11-07 05:11:09 +00:00
NEWLIN: LDA #$0D ;Load C/R into Accumulator
JMP PUTCHR
2018-01-28 18:30:49 +00:00
;Print Character to Console
2018-11-07 05:11:09 +00:00
PUTCHR EQU $FFD2 ;Alias to Kernal Routine CHROUT
2018-01-28 18:30:49 +00:00
;Delete Previous Character
2018-11-07 05:11:09 +00:00
DELCJR: LDA #$9D ;Load Cursor Left into Accumulator
JSR PUTCHR ; and Print it
2018-01-28 18:30:49 +00:00
LDA #$14 ;Load Delete into Accumulater
2018-11-07 05:11:09 +00:00
JMP PUTCHR ; and Print it
2018-01-28 18:30:49 +00:00
;Advance Character to Next line
2018-11-07 05:11:09 +00:00
NEWLIN: LDA #$0D ;Load C/R into Accumulator
JMP PUTCHR ; and Print it
2018-01-28 18:30:49 +00:00
;Print Byte as Two-Digit Hex Number to Console
2018-11-07 05:11:09 +00:00
PRBYTE: PHA ;Save Accumulater
2018-01-28 18:30:49 +00:00
LSR ;Shift Hi Nybble to Low Nybble
LSR
LSR
LSR
JSR prhex ; and Print it
PLA ;Restore Accumulator
; and fall into prhex
;Print Low Nybble as Hex Digit to Console
2018-11-07 05:11:09 +00:00
PRHEX: AND #$0F ;Strip High Nybble
2018-01-28 18:30:49 +00:00
CMP #$0A ;If Low Nybble >= 10
2018-11-07 05:11:09 +00:00
BCC PRHEXC ;
2018-01-28 18:30:49 +00:00
ADC #$06 ; Convert ':' to 'A'...
2018-11-07 05:11:09 +00:00
PRHEXC: ADC #$30 ;Convert to ASCII Character
JMP PUTCHR ;Print Hex Digit and Return
2018-01-28 18:30:49 +00:00
2018-11-07 05:11:09 +00:00
EXIT: RTS ;Return to BASIC
2018-01-28 18:30:49 +00:00