mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-26 13:49:21 +00:00
113 lines
3.6 KiB
Plaintext
113 lines
3.6 KiB
Plaintext
; Program initialization code for Oric-1
|
|
|
|
;System Specific ASCII Key Mappings
|
|
DELKEY EQU $7F ;Delete/Backspace Key (Delete)
|
|
ESCKEY EQU $1B ;Escape/Stop Key (Escape)
|
|
RTNKEY EQU $0D ;Return/Enter Key ($0D=Carriage Return)
|
|
|
|
;Zero Page Locations
|
|
SRCLO EQU $00 ;Source String Pointer (stdio.asm)
|
|
SRCHI EQU $01
|
|
DSTLO EQU $02 ;Destination String Pointer (string.asm)
|
|
DSTHI EQU $03
|
|
|
|
RDSEED EQU $04 ;Pseudo-RANDOM Seed
|
|
RANDOM EQU $05 ;Pseudo-RANDOM Number Storage
|
|
|
|
TEMP0 EQU $06 ;Temporary Storage
|
|
TEMP1 EQU $07
|
|
TEMP2 EQU $08
|
|
TEMP3 EQU $09
|
|
|
|
BLKSLO EQU $0A ;Block Start Address
|
|
BLKSHI EQU $0B
|
|
BLKELO EQU $0C ;Block End Address
|
|
BLKEHI EQU $0D
|
|
|
|
;Oric-1 Tape images have the file extension ".tap"
|
|
;and have the following header prepended to the code
|
|
; $16,$16,$16, $16 Tape Syncronization Pattern
|
|
; $24 Tape Syncronization Byte
|
|
; $00,$00 Filler Bytes
|
|
; $00 Basic Program
|
|
; $00 No Autostart ($80 for Autostart)
|
|
; $xx,$xx MSB, LSB of End Address
|
|
; $05,$01 MSB, LSB of Start Address
|
|
; $00 Filler Byte
|
|
; "filename" Up to 16 ASCII Characters
|
|
; $00 Strint Terminator
|
|
|
|
;The End Address is actually one higher than the last
|
|
;byte of the Basic program and the first byte of Basic
|
|
;variable space. so the compiled program need to have
|
|
;one dummy byte added to the end.
|
|
|
|
ORG $0501 ;Basic Program Start Address
|
|
|
|
BASIC: .DC $0C,$05 ;Address of Next Line
|
|
.DC $00,$00 ;Basic Line Number (0)
|
|
.DC $BF ;Token for Basic Call Command
|
|
.DC $20 ;Space
|
|
.DC "1294" ;Address of START Label
|
|
.DC $00 ;End of Line
|
|
.DC $00,$00 ;End of Program Marker
|
|
|
|
START: LDA #127 ;Set Caps Lock Off
|
|
STA $020C
|
|
LDA #$0B ;Turn Cursor On, Keyclick Off
|
|
STA $026A ;and Protect Columns 0 & 1
|
|
JMP MAIN ;Execute Program
|
|
|
|
;Poll Character from Keyboard
|
|
POLKEY: INC RDSEED ;Cycle the Random Seed
|
|
JMP $E905 ;Execute GETORKB
|
|
|
|
;Read Character from Console
|
|
GETKEY EQU POLKEY ;Aliased to POLKEY
|
|
|
|
;Wait for Character from Console
|
|
GETCHR JSR POLKEY ;Calls POLKEY
|
|
BEQ GETCHR ; until a non-zero is returned
|
|
RTS
|
|
|
|
;Delete Previous Character
|
|
DELCHR: LDA #DELKEY ;Load Delete Character
|
|
BNE PUTCHR ;and Print to Screem
|
|
|
|
;Advance Cursor to Next line
|
|
NEWLIN EQU $CB9F ;Basic NEWLINE Routine ($CBF0 for ATMOS)
|
|
; LDA #$0D ;Load Carriage Return
|
|
; JSR PUTCHR ;and Print It
|
|
; LDA #$0A ;Load Line Feed and fall through to PRCHR
|
|
|
|
;Print Character to Screen
|
|
PUTCHR TAX ;Transfer Character to X Register
|
|
JMP $F409 ;Execute VDU Routine
|
|
|
|
;Exit Program and Return to Operating System or Monitor
|
|
EXIT LDA #255 ;Set Caps Lock On
|
|
STA $020C
|
|
JMP $C003 ;BASIC Warm Start
|
|
;
|
|
;Note: The following two functions replicate calls available
|
|
;in the Apple-1 monitor and are included for test purposes
|
|
;They will likely be removed before the final release
|
|
|
|
;Print Byte as Two-Digit Hex Number to Console
|
|
PRBYTE: PHA ;Save Accumulater
|
|
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
|
|
PRHEX: AND #$0F ;Strip High Nybble
|
|
CMP #$0A ;If Low Nybble >= 10
|
|
BCC PRHEXC ;
|
|
ADC #$06 ; Convert ':' to 'A'...
|
|
PRHEXC: ADC #$30 ;Convert to ASCII Character
|
|
JMP PUTCHR ;Print Hex Digit and Return
|