mirror of
https://github.com/RevCurtisP/C02.git
synced 2026-04-19 19:16:37 +00:00
Added system specific header files
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
;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
|
||||
PTRLO EQU $35 ;System Pointer (pointer.a02)
|
||||
PTRHI 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
|
||||
|
||||
BLKSLO EQU $4A ;Block Start Address
|
||||
BLKSHI EQU $4B
|
||||
BLKELO EQU $4C ;Block End Address
|
||||
BLKEHI EQU $4D
|
||||
BLKLEN EQU $4E ;Block Segment Length
|
||||
|
||||
|
||||
;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)
|
||||
LDA #$0D ;Move cursor to next line before
|
||||
JSR ECHO ; 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
|
||||
|
||||
RDKEY: 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 RDKEY ;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
|
||||
|
||||
PRCHR EQU ECHO ;Alias to Monitor Routine
|
||||
|
||||
;Delete Previous Character
|
||||
DELCHR: LDA #DELKEY ;Load Underscore Character
|
||||
JMP PRCHR ; and Print it
|
||||
|
||||
;Advance Character to Next line
|
||||
NEWLIN: LDA #$0D ;Load C/R into Accumulator
|
||||
JMP PRCHR ; and Print it
|
||||
|
||||
;Initialize Destination String Pointer and Index
|
||||
SETDST: STX DSTLO ;Save Destination String Pointer
|
||||
STY DSTHI
|
||||
RTS
|
||||
|
||||
;Initialize Source String Pointer and Index
|
||||
SETSRC: STX SRCLO ;Save Source String Pointer
|
||||
STY SRCHI
|
||||
LDY #$00 ;Initialize Index Into String
|
||||
RTS
|
||||
|
||||
;Retrieve Source String Pointer
|
||||
GETSRC: LDX SRCLO
|
||||
LDY SRCHI
|
||||
RTS
|
||||
@@ -0,0 +1,41 @@
|
||||
/* 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
|
||||
|
||||
/* Standard Library Variables */
|
||||
char srclo,srchi; //Source String Pointer for Library Functions
|
||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
char ptrlo,ptrhi; //System Pointer
|
||||
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
|
||||
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
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
|
||||
//System Subroutines
|
||||
char plkey(); //Poll Console for character
|
||||
char rdkey(); //Wait for character from Console
|
||||
char getkey(); //Read ASCII character from Console
|
||||
void newlin(); //Advance cursor to beginning of next line
|
||||
void prchr(); //Print ASCII character to Console
|
||||
void setdst(); //Set Destination Pointer
|
||||
void setsrc(); //Set Source Pointer
|
||||
@@ -0,0 +1,92 @@
|
||||
;Apple 1 program initialization code for c02 programs
|
||||
|
||||
;System Specific ASCII Key Mappings
|
||||
DELKEY EQU $08 ;Delete/Backspace Key (Left Arrow)
|
||||
ESCKEY EQU $1B ;Escape/Stop Key (Escape)
|
||||
RTNKEY EQU $0D ;Return/Enter Key (Return)
|
||||
|
||||
;Standard Library Variables
|
||||
DSTLO EQU $06 ;Destination String Pointer (string.a02)
|
||||
DSTHI EQU $07
|
||||
BLKLO EQU $08 ;Block Segment Pointer (block.a02)
|
||||
BLKHI EQU $09
|
||||
PTRLO EQU $1D ;System Pointer (pointer.a02)
|
||||
PTRHI EQU $1E
|
||||
RANDOM EQU $1F ;Random Number
|
||||
RDSEED EQU $4E ;O/S Random Number Low Byte
|
||||
; EQU $4F ;O/S Random Number High Byte
|
||||
SRCLO EQU $71 ;Source String Pointer (stdio.a02)
|
||||
SRCHI EQU $72
|
||||
; $E3 ;Unused
|
||||
BLKSLO EQU $EB ;Block Start Address
|
||||
BLKSHI EQU $ED
|
||||
BLKELO EQU $ED ;Block End Address
|
||||
BLKEHI EQU $EE
|
||||
BLKLEN EQU $EF ;Block Segment Length
|
||||
TEMP0 EQU $FC ;Temporary Storage
|
||||
TEMP1 EQU $FD
|
||||
TEMP2 EQU $FE
|
||||
TEMP3 EQU $FF
|
||||
|
||||
;I/O Locations
|
||||
KBD EQU $C000 ;Keyboard Data
|
||||
AKD EQU $C010 ;Keyboard Strobe Register
|
||||
|
||||
;Monitor Routines
|
||||
RDKEY EQU $FD0C ;Waits for keypress and return in A
|
||||
KEYIN EQU $FD1B ;Waits for keypress and cycle random-number generator
|
||||
RDCHAR EQU $FD35 ;Read keyboard (processing escapes)
|
||||
GETLIN EQU $FD6A ;Get Line from Keyboard into Input Buffer
|
||||
CROUT EQU $FD8E ;Performs a carriage return
|
||||
PRBYTE EQU $FDDA ;Print Accumulator as Hexadecimal Number
|
||||
PRHEX EQU $FDE3 ;Print Low Nybble of Accumulator as Hex Digit
|
||||
COUT EQU $FDED ;Print Character in Accumulator
|
||||
BELL EQU $FF3A ;Ring Bell through COUT
|
||||
MONZ EQU $FF69 ;Enter monitor (<Control-C>, <Return> leaves the monitor)
|
||||
|
||||
ECHO EQU COUT ;Print Character
|
||||
EXIT EQU MONZ ;Return to Monitor
|
||||
|
||||
ORG $0C00 ;Safe Area for Machine Language
|
||||
|
||||
START: JMP MAIN ;Execute Program
|
||||
|
||||
|
||||
;Subroutine Poll Keyboard
|
||||
PLKEY: LDA #0 ;Clear Accumulator
|
||||
BIT KBD ;Check Keyboard Strobe Bit
|
||||
BPL PLKEYR ;If Key Pressed
|
||||
LDA KBD ; Load Key Value
|
||||
STA AKD ; Clear Strobe
|
||||
PLKEYR: RTS
|
||||
|
||||
;Read Keyboard
|
||||
GETKEY EQU KEYIN ;Alias to Monitor Routine
|
||||
|
||||
PRCHR EQU ECHO ;Alias to Monitor Routine
|
||||
|
||||
;Delete Previous Character
|
||||
DELCHR: LDX #2 ;Two Characters Total
|
||||
LDA #$88 ;Load Backspace Character
|
||||
JSR PRBLNX ;Print Accumulator and X-1 Blanks
|
||||
LDA #$88 ;Load Backspace Character
|
||||
JMP PRCHR ;and Print it
|
||||
|
||||
;Advance Character to Next line
|
||||
NEWLIN EQU CROUT ;Alias to Monitor Routine
|
||||
|
||||
;Initialize Destination String Pointer and Index
|
||||
SETDST: STX DSTLO ;Save Destination String Pointer
|
||||
STY DSTHI
|
||||
RTS
|
||||
|
||||
;Initialize Source String Pointer and Index
|
||||
SETSRC: STX SRCLO ;Save Source String Pointer
|
||||
STY SRCHI
|
||||
LDY #$00 ;Initialize Index Into String
|
||||
RTS
|
||||
|
||||
;Retrieve Source String Pointer
|
||||
GETSRC: LDX SRCLO
|
||||
LDY SRCHI
|
||||
RTS
|
||||
@@ -0,0 +1,33 @@
|
||||
/* Apple 1 Header File */
|
||||
|
||||
/* Monitor Variables */
|
||||
|
||||
/* Standard Library Variables */
|
||||
char srclo,srchi; //Source String Pointer for Library Functions
|
||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
char ptrlo,ptrhi; //System Pointer
|
||||
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
|
||||
char temp0, temp1, temp2, temp3; //Temporary Variables
|
||||
|
||||
//PIA 6820 Registers
|
||||
char kbd; //Keyboard Data
|
||||
char abd; //Keyboard Strobe
|
||||
|
||||
//Monitor Subroutines
|
||||
void echo(); //Print Character in Accumulator
|
||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
|
||||
//System Subroutines
|
||||
char plkey(); //Poll Console for character
|
||||
char rdkey(); //Wait for character from Console
|
||||
char getkey(); //Read ASCII character from Console
|
||||
void newlin(); //Advance cursor to beginning of next line
|
||||
void prchr(); //Print ASCII character to Console
|
||||
void setdst(); //Set Destination Pointer
|
||||
void setsrc(); //Set Source Pointer
|
||||
@@ -0,0 +1,26 @@
|
||||
; py65mon program initialization code for c02 programs
|
||||
|
||||
;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 (Carriage Return)
|
||||
|
||||
;Memory Mapped I/O
|
||||
PUTC EQU $F001 ;Write Character to Console
|
||||
GETC EQU $F004 ;Read Character from Console
|
||||
|
||||
ORG $0200 ;Start Directly Above Stack
|
||||
|
||||
START: JMP MAIN ;Execute Program
|
||||
|
||||
;Wait for Character from Console
|
||||
RDKEY: LDA GETC ;Read Character from Console
|
||||
BEQ RDKEY ; Loop if None Received
|
||||
RTS
|
||||
|
||||
;Print Character to Console
|
||||
PRCHR: STA PUTC ;Write Character to Console
|
||||
RTS
|
||||
|
||||
EXIT: BRK ;Return to Monitor
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/* py65mon Header File */
|
||||
|
||||
//Memory Mapped I/O
|
||||
char putc; //Write Character to Console
|
||||
char getc; //Read Character from Console
|
||||
|
||||
//System Subroutines
|
||||
char plkey(); //Poll Console for character
|
||||
char rdkey(); //Wait for character from Console
|
||||
char getkey(); //Read ASCII character from Console
|
||||
void prchr(); //Print ASCII character to Console
|
||||
|
||||
Reference in New Issue
Block a user