Added prtstr() to apple, oric header files

This commit is contained in:
Curtis F Kaylor 2020-04-27 12:20:37 -04:00
parent fd7e1a708b
commit 0e060485ff
6 changed files with 53 additions and 52 deletions

View File

@ -1,28 +1,30 @@
;Apple 1 program initialization code for c02 programs
SUBROUTINE _APPLE1
;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
.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
DSTLO EQU $34 ;Destination String Pointer (string.a02)
DSTHI EQU $35
BFRLO EQU $34 ;Work Buffer Pointer
BFRHI EQU $35
BLKLO EQU $36 ;Block Segment Pointer (block.a02)
BLKHI EQU $37
STKLO EQU $38 ;System Pointer (pointer.a02)
@ -47,13 +49,13 @@ 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
.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
.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
@ -67,26 +69,27 @@ START: LDX #$FF ;Reset stack - the monitor doesn't do this
;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
LDA #0 ;Set Return Value to 0
BIT .KBDCR ;Check the Keyboard Control Register
BPL .PLKEYX ;If No Key Pressed, Return 0
LDA .KBD ;Else Read Key and Return
.PLKEYX 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 PLKEY ;Read Keyboard
AND #$7F ;Strip High Bit
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)
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
.GETKEX RTS
.GETKEM DC $40 ;Character Block Bit Mask
PUTCHR EQU ECHO ;Alias to Monitor Routine
GETCHR: JSR GETKEY ;Get Keypress
BEQ GETCHR ;Loop if No Key Pressed
RTS
PUTCHR EQU .ECHO ;Alias to Monitor Routine
;Delete Previous Character
DELCHR: LDA #DELKEY ;Load Underscore Character
@ -95,3 +98,5 @@ DELCHR: LDA #DELKEY ;Load Underscore Character
;Advance Character to Next line
NEWLIN: LDA #$0D ;Load C/R into Accumulator
JMP PUTCHR ; and Print it
INCLUDE "../include/putstr.a02" ;PUTSTR routine

View File

@ -1,13 +1,5 @@
/* Apple 1 Header File */
/* Monitor Variables */
char xaml, xamh; //Examine Index
char stl, sth; //Store Index
char hexl,hexh; //Hex Data
char ysave; //Y Register Storage
char mode; //Mode: Store, Examine, Block Examine
char buffer[]; //Input Buffer
//Platform Specific Constants
#define DELKEY $5F //Delete/Backspace Key
#define ESCKEY $1B //Escape/Stop Key
@ -28,12 +20,6 @@ char stkelo, stkehi; //Stack End Address
char temp0, temp1, temp2, temp3; //Temporary Variables
//PIA 6820 Registers
char kbd; //Keyboard Data
char kbdcr; //Keyboard Control Register
char dsp; //Display Data
char dspcr; //Display Control Register
//Monitor Subroutines
void echo(); //Print Character in Accumulator
void prbyte(); //Print Accumulator as Hexadadecimal number

View File

@ -1,5 +1,7 @@
;Apple 1 program initialization code for c02 programs
SUBROUTINE _APPLE2
;System Specific ASCII Key Mappings
DELKEY EQU $08 ;Delete/Backspace Key (Left Arrow)
ESCKEY EQU $1B ;Escape/Stop Key (Escape)
@ -30,8 +32,8 @@ TEMP2 EQU $FE
TEMP3 EQU $FF
;I/O Locations
KBD EQU $C000 ;Keyboard Data
AKD EQU $C010 ;Keyboard Strobe Register
.KBD EQU $C000 ;Keyboard Data
.AKD EQU $C010 ;Keyboard Strobe Register
;Monitor Routines
PRBYTE EQU $FDDA ;Print Accumulator as Hexadecimal Number
@ -46,10 +48,10 @@ START: JSR NEWLIN ;Start On New Line
;Poll Keyboard for Raw Character
POLKEY: INC RDSEED ;Cycle Random Seed
LDA #0 ;Clear Accumulator
BIT KBD ;Check Keyboard Strobe Bit
BIT .KBD ;Check Keyboard Strobe Bit
BPL POLKER ;If Key Pressed
LDA KBD ; Load Key Value
STA AKD ; Clear Strobe
LDA .KBD ; Load Key Value
STA .AKD ; Clear Strobe
POLKER: RTS
;Get ASCII Character from Keyboard
@ -74,7 +76,9 @@ PUTCHR: ORA #$80 ;Set High Bit
CMP #$E0 ;
BCC PRCHRX ;If Lower Case
AND #$1F ; Convert to Inverse
PRCHRX: JMP $FDF0 ;Call Monitor Routine COUT1
PRCHRX: JMP $FDF0 ;Execute Monitor Routine COUT1
;Advance Character to Next line
NEWLIN EQU $FD8E ;Monitor Routine CROUT
INCLUDE "../include/putstr.a02" ;PUTSTR routine

View File

@ -42,6 +42,7 @@ char getsiz(); //Get Screen Size
void newlin(); //Advance cursor to beginning of next line
char polkey(); //Poll Console for character
char putchr(); //Print ASCII character to Console
char putstr(); //Print ASCII string to Console
void setpos(); //Set Cursor Position
//System Labels

View File

@ -96,6 +96,10 @@ NEWLIN EQU $CB9F ;Basic NEWLINE Routine ($CBF0 for ATMOS)
PUTCHR: TAX ;Transfer Character to X Register
JMP $F409 ;Execute VDU Routine
;Print String to Screen
PUTSTR: TXA ;Copy LSB to A6
JMP $CCB0 ;Execute BASIC String Print Routine
;Get End of Free Memory
RAMTOP: LDX $A6 ;Load HIMEM LSB
LDY $A7 ;Load HIMEM MSB

View File

@ -23,6 +23,7 @@ char getchr(); //Wait for character from Console
char getkey(); //Read ASCII character from Console
void newlin(); //Advance cursor to beginning of next line
char putchr(); //Print ASCII character to Console
char putstr(); //Print ASCII string to Console
void prbyte(); //Print Accumulator as Hexadadecimal number
void prhex(); //Print Low Nybble of Accumulator as Hex Digit