mirror of
https://github.com/RevCurtisP/C02.git
synced 2025-02-15 23:31:46 +00:00
Update include files
This commit is contained in:
parent
3132130f48
commit
9f705b5fe3
81
include/apple2.a02
Normal file
81
include/apple2.a02
Normal file
@ -0,0 +1,81 @@
|
||||
;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)
|
||||
|
||||
;Zero Page Variables (*=System Variable)
|
||||
DSTLO EQU $06 ;Destination Pointer
|
||||
DSTHI EQU $07
|
||||
BLKLO EQU $08 ;Block Segment Pointer (block.a02)
|
||||
BLKHI EQU $09
|
||||
STKLO EQU $1D ;Stack Pointer (stack.a02)
|
||||
STKHI EQU $1E
|
||||
RANDOM EQU $1F ;Random Number
|
||||
INVFLG EQU $32 ;*Inverse Flag: $3F=Blinking, $7F=Inverse, $FF=Normal
|
||||
SRCLO EQU $71 ;Source Pointer
|
||||
SRCHI EQU $72
|
||||
RDSEED EQU $E3 ;Random Seed
|
||||
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
|
||||
PRBYTE EQU $FDDA ;Print Accumulator as Hexadecimal Number
|
||||
PRHEX EQU $FDE3 ;Print Low Nybble of Accumulator as Hex Digit
|
||||
|
||||
ECHO EQU $FDF0 ;Print Character - Routine Monitor COUT1
|
||||
EXIT EQU $03D0 ;Return to Monitor - Jump Vector to DOS warm start
|
||||
|
||||
ORG $0C00 ;Safe Area for Machine Language
|
||||
|
||||
START: JSR NEWLIN ;Start On New Line
|
||||
JMP MAIN ;Execute Program
|
||||
|
||||
;Subroutine Poll Keyboard
|
||||
PLKEY: INC RDSEED ;Cycle Random Seed
|
||||
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 JSR PLKEY ;Poll Keyboard
|
||||
AND #$7F ;Strip High Bit
|
||||
RTS
|
||||
|
||||
;Wait for Keypress
|
||||
RDKEY: JSR GETKEY ;Get Modified Key Code
|
||||
BEQ RDKEY ;Loop if No Key
|
||||
RTS
|
||||
|
||||
;Delete Previous Character
|
||||
DELCHR: LDX #2 ;Two Characters Total
|
||||
LDA #$88 ;Load Backspace Character
|
||||
JSR $F94C ;Monitor Routine PRBLAX
|
||||
LDA #DELKEY ;Load Backspace Character
|
||||
;and Fall into PRCHR
|
||||
|
||||
;Print Character to Screen
|
||||
PRCHR: ORA #$80 ;Set High Bit
|
||||
CMP #$E0 ;
|
||||
BCC PRCHRX ;If Lower Case
|
||||
AND #$1F ; Convert to Inverse
|
||||
PRCHRX: JMP ECHO ;Alias to Monitor Routine
|
||||
|
||||
;Advance Character to Next line
|
||||
NEWLIN EQU $FD8E ;Monitor Routine CROUT
|
||||
|
39
include/apple2.h02
Normal file
39
include/apple2.h02
Normal file
@ -0,0 +1,39 @@
|
||||
/* Apple ][ Header File */
|
||||
|
||||
//Platform Specific Constants
|
||||
#define DELKEY $08 //Delete/Backspace Key
|
||||
#define ESCKEY $1B //Escape/Stop Key
|
||||
#define RTNKEY $0D //Return/Enter Key
|
||||
|
||||
/* 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 stklo,stkhi; //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
|
||||
|
||||
//System Variables
|
||||
char invflg; //Video Invert Mask
|
||||
|
||||
//Keyboard I/O
|
||||
char kbd; //Keyboard Data Register
|
||||
char abd; //Keyboard Strobe 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
|
@ -13,6 +13,8 @@
|
||||
/* Zero Page Variables used as Pointers */
|
||||
char strlo,strhi; //String pointer for String and I/O functions
|
||||
char dstlo,dsthi; //Secondary string pointer for String functions
|
||||
char blklo,blkhi; //Block Segment Pointer
|
||||
char stklo,stkhi; //Stack Pointer
|
||||
|
||||
/* Ephemeral Library Variables *
|
||||
* Available for use in program code, but may *
|
||||
@ -23,14 +25,19 @@ char temp0,temp1,temp2,temp3; //Temporary variables
|
||||
/* Static Library Variables *
|
||||
* Must be preserved between function calls *
|
||||
* May be Zero Page, but not required */
|
||||
char random; //Last Result of Pseudo-Random Number Generator
|
||||
char rdseed; //System Seed for Pseudo-Random Number Generator
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random; //Last Result of Pseudo-Random Number Generator
|
||||
char rdseed; //System Seed for Pseudo-Random Number Generator
|
||||
|
||||
//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 prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
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 prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
|
@ -45,7 +45,13 @@ START: JMP MAIN ;Execute Program
|
||||
;Poll Character from Keyboard
|
||||
PLKEY: INC RDSEED ;Cycle the RANDOM Seed (if not provided by system)
|
||||
LDA GETCON ;Read Character from Console
|
||||
RTS
|
||||
CMP #$E0
|
||||
BEQ PLKEYX ;If Not E0 Extended Key
|
||||
ORA #$00 ; Set Status Flags
|
||||
RTS ; and Return
|
||||
PLKEYX: LDA GETCON ;Else Get Second Byte
|
||||
ORA #$80 ; Set High Byte
|
||||
RTS ; and Return
|
||||
|
||||
;Read Character from Console
|
||||
GETKEY ;Same As RDKEY
|
||||
|
@ -6,30 +6,31 @@
|
||||
#define RTNKEY $0D //Return/Enter Key
|
||||
#define NULKEY $00 //No Key was Pressed
|
||||
|
||||
//System Pointer 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 stklo,stkhi; //Stack Pointer
|
||||
//Library Pointer 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 stklo,stkhi; //Stack Pointer
|
||||
|
||||
//System Variables
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char temp0, temp1; //Temporary Variables
|
||||
char temp2, temp3;
|
||||
//Library Variables
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random, rdseed; //Pseudo-Random Number Generation
|
||||
char temp0, temp1, temp2, temp3; //Temporary Storage
|
||||
|
||||
//Memory Mapped I/O
|
||||
char putcon; //Write Character to Console
|
||||
char getcomn; //Read Character from Console
|
||||
char putcon; //Write Character to Console
|
||||
char getcomn; //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 newlin(); //Advance cursor to beginning of next line
|
||||
void prchr(); //Print ASCII character to Console
|
||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
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 delchr(); //Delete previous character
|
||||
void prchr(); //Print ASCII character to Console
|
||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
|
@ -1,25 +1,41 @@
|
||||
; py65mon program initialization code for c02 programs
|
||||
|
||||
;System Specific ASCII Key Mappings
|
||||
DELKEY EQU $7F ;Delete/Backspace Key (Delete)
|
||||
DELKEY EQU $08 ;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
|
||||
PUTCON EQU $F001 ;Write Character to Console
|
||||
GETCON 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
|
||||
;Delete Previous Character
|
||||
DELCHR: JSR DELCHB ;Print Backspace
|
||||
LDA #$20 ;Load Space into Accumulater
|
||||
JSR PRCHR ; and Print it
|
||||
DELCHB: LDA #$08 ;Load Backspace into Accumulator
|
||||
BNE PRCHR ; and Print it
|
||||
|
||||
;Advance Character to Next line
|
||||
NEWLIN: LDA #$0D ;Load C/R into Accumulator
|
||||
JSR PRCHR ; and Print it
|
||||
LDA #$0A ;Load L/F into Accumulater
|
||||
; and fall into PRCHR
|
||||
;Print Character to Console
|
||||
PRCHR: STA PUTCON ;Write Character to Console
|
||||
RTS
|
||||
|
||||
;Print Character to Console
|
||||
PRCHR: STA PUTC ;Write Character to Console
|
||||
;Poll Keyboard for Keypress
|
||||
PLKEY: LDA GETCON ;Read Character from Console
|
||||
RTS
|
||||
|
||||
;Wait for Character from Console
|
||||
RDKEY: JSR PLKEY ;Read Character from Console
|
||||
BEQ RDKEY ; Loop if None Received
|
||||
RTS
|
||||
|
||||
EXIT: BRK ;Return to Monitor
|
||||
|
@ -1,12 +1,18 @@
|
||||
/* py65mon Header File */
|
||||
|
||||
#define DELKEY $08 //Delete/Backspace Key
|
||||
#define ESCKEY $1B //Escape/Stop Key
|
||||
#define RTNKEY $0D //Return/Enter Key
|
||||
|
||||
//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
|
||||
void newlin(); //Advance cursor to beginning of next line
|
||||
void delchr(); //Delete previous character
|
||||
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
|
||||
|
||||
|
99
include/py65win.a02
Normal file
99
include/py65win.a02
Normal file
@ -0,0 +1,99 @@
|
||||
; py65mon program initialization code for c02 programs
|
||||
|
||||
;System Specific ASCII Key Mappings
|
||||
DELKEY EQU $08 ;Delete/Backspace Key (Backspace)
|
||||
ESCKEY EQU $1B ;Escape/Stop Key (Escape)
|
||||
RTNKEY EQU $0D ;Return/Enter Key (Carriage Return)
|
||||
|
||||
;Zero Page Locations
|
||||
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
|
||||
STKLO EQU $36 ;Stack Pointer (stack.a02)
|
||||
STKHI EQU $37
|
||||
|
||||
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 $46 ;Block Start Address
|
||||
BLKSHI EQU $47
|
||||
BLKELO EQU $48 ;Block End Address
|
||||
BLKEHI EQU $49
|
||||
BLKLEN EQU $4A ;Block Segment Length
|
||||
|
||||
STKSLO EQU $4C ;Stack Start Address
|
||||
STKSHI EQU $4D
|
||||
STKELO EQU $4E ;Stack End Address
|
||||
STKEHI EQU $4F
|
||||
|
||||
;Memory Mapped I/O
|
||||
PUTCON EQU $F001 ;Write Character to Console
|
||||
GETCON EQU $F004 ;Read Character from Console
|
||||
|
||||
ORG $0200 ;START Directly Above Stack
|
||||
|
||||
START: JMP MAIN ;Execute Program
|
||||
|
||||
;Poll Character from Keyboard
|
||||
PLKEY: INC RDSEED ;Cycle the RANDOM Seed (if not provided by system)
|
||||
LDA GETCON ;Read Character from Console
|
||||
CMP $E0
|
||||
BNE PLKEYX ;If E0 Extended Key
|
||||
LDA GETCON ; Get Second Byte
|
||||
ORA $80 ; and Set High Byte
|
||||
PLKEYX: RTS
|
||||
|
||||
;Read Character from Console
|
||||
GETKEY ;Same As RDKEY
|
||||
|
||||
;Wait for Character from Console
|
||||
RDKEY: JSR PLKEY ;Read Character from Console
|
||||
BEQ RDKEY ; Loop if None Received
|
||||
RTS
|
||||
|
||||
;Delete Previous Character
|
||||
DELCHR: LDA #$08 ;Load Backspace into Accumulator
|
||||
JSR PRCHR ; and Print it
|
||||
LDA #$20 ;Load Space into Accumulater
|
||||
JSR PRCHR ; and Print it
|
||||
LDA #$08 ;Load Backspace into Accumulator
|
||||
JMP PRCHR ; and Print it
|
||||
|
||||
;Advance Character to Next line
|
||||
NEWLIN: LDA #$0D ;Load C/R into Accumulator
|
||||
JSR PRCHR ; and Print it
|
||||
LDA #$0A ;Load L/F into Accumulater
|
||||
; and fall into PRCHR
|
||||
|
||||
;Print Character to Console
|
||||
PRCHR: STA PUTCON ;Write Character to Console
|
||||
RTS
|
||||
|
||||
EXIT: BRK ;Return to Monitor
|
||||
|
||||
;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 Nybb
|
||||
SED ;Set Decimal Flag for
|
||||
CLC ; Addition Wizardry
|
||||
ADC #$90 ;Convert to $90-$99,$00-$05
|
||||
ADC #$40 ;Convert to $30-$39,$41-$46
|
||||
CLD ;Clear Decimal Flag
|
||||
JMP PRCHR ;Print Hex Digit and Return
|
@ -3,8 +3,8 @@
|
||||
* functions used in libraries. */
|
||||
|
||||
/* Constant Definitions */
|
||||
#define #TRUE $FF
|
||||
#define #FALSE $00
|
||||
#define TRUE $FF
|
||||
#define FALSE $00
|
||||
|
||||
/* Get Destination Pointer *
|
||||
* Returns: Y,X=Destination address */
|
||||
|
@ -8,7 +8,7 @@
|
||||
;Uses: System Dependent
|
||||
;Affects: System Dependent
|
||||
;Returns: A = Character Code of Key
|
||||
GETC EQU GETKEY ;Alias to external GETKEY routine
|
||||
GETC EQU RDKEY ;Alias to external RDKEY routine
|
||||
|
||||
;void putc(c) - PUT Character to screen
|
||||
;Args: Character code to display
|
||||
|
@ -1,6 +1,6 @@
|
||||
; C02 library stdiox.h02 assembly language subroutines
|
||||
|
||||
ANYKEP: DC "Press any key to continue...",0
|
||||
ANYKEP: DC "PRESS ANY KEY...",0
|
||||
|
||||
;
|
||||
;char anykey() - wait for character with ANY KEY prompt
|
||||
@ -138,10 +138,14 @@ PRINTD: CMP #'D ;'Else If "d" or "D"
|
||||
JSR PUTDEC ; Print as Decimal
|
||||
JMP PRINTY ; and Continue Printing Screen
|
||||
PRINTH: CMP #'H ;'Else If "h" or "H"
|
||||
BNE PRINTS
|
||||
BNE PRINTN
|
||||
LDA TEMP3 ; Load Byte to Format
|
||||
JSR PUTHEX ; Print as Hexadecimal
|
||||
JMP PRINTY ; and Continue Printing Screen
|
||||
PRINTN: CMP #'N ;'Else If "n" or "N"
|
||||
BNE PRINTS
|
||||
JSR NEWLIN ; Execute Newline Function
|
||||
JMP PRINTY ; and Continue Printing Screen
|
||||
PRINTS: CMP #'S ;'Else If "s" or "S"
|
||||
BNE PRINTW
|
||||
STY TEMP0 ; Save Index
|
||||
@ -158,8 +162,7 @@ PRINTW: CMP #'W ;'Else If "w" or "W"
|
||||
PRINTB: LDA TEMP3 ;Else
|
||||
JMP PRINTC ; Print Raw Byte and Continue
|
||||
|
||||
;and fall into putsub
|
||||
;char putdst()
|
||||
;char putdst()
|
||||
PUTDST: LDY #0 ;Initialize character offset
|
||||
PUTDSL: LDA (DSTLO),Y ;Read next character in string
|
||||
BEQ PUTDSX ;If Not 0
|
||||
|
@ -1,4 +1,4 @@
|
||||
f; C02 library stdlib.h02 assembly language subroutines
|
||||
; C02 library stdlib.h02 assembly language subroutines
|
||||
; Requires
|
||||
; external zero page locations SRCLO and srchi
|
||||
; and external locations RANDOM, RDSEED, TEMP0, TEMP1, and TEMP2.
|
||||
@ -121,18 +121,6 @@ SHIFTR: LSR ;Shift Byte to Right
|
||||
BNE SHIFTR ; and Loop if Not 0
|
||||
RTS
|
||||
|
||||
;SWAP Nybbles in Byte
|
||||
;Args: A = Byte containing Nybbles to Swap
|
||||
;Affects: C,N,Z
|
||||
;Returns: A = Byte with Nybbles Swapped
|
||||
SWAP: ASL ;Code by
|
||||
ADC #$80 ;David Galloway
|
||||
ROL ;posted on
|
||||
ASL ;6502.org by
|
||||
ADC #$80 ;Garth Wilson
|
||||
ROL ;Oct 27, 2017
|
||||
RTS
|
||||
|
||||
;atoc(&s) - ASCII string TO Character
|
||||
;Args: Y,X = Address of String to Convert
|
||||
;Uses: TEMP0, TEMP1
|
||||
|
@ -65,11 +65,6 @@ char shiftl();
|
||||
* Returns: Shifted Byte */
|
||||
char shiftr();
|
||||
|
||||
/* Swap Nybbles in Byte *
|
||||
* Args: b - Byte to Swap *
|
||||
* Returns: Swapped Byte */
|
||||
char swap();
|
||||
|
||||
/* Seed Pseudo-Random Number Generator *
|
||||
* Args: n - Seed number */
|
||||
void srand();
|
||||
|
@ -94,7 +94,7 @@ STRCAX: STY TEMP0 ;Subtract Destination String Length
|
||||
;Args: X,Y = Pointer to source string
|
||||
;Sets: SRCLO,SRCHI = Pointer to source string
|
||||
;Affects: N,Z
|
||||
;Returns: A,Y = Number of characters copies
|
||||
;Returns: A,Y = Number of characters copied
|
||||
STRCPY: JSR SETSRC ;Initialize Source String
|
||||
STRCPL: LDA (SRCLO),Y ;Get Character from Source String
|
||||
STA (DSTLO),Y ;Copy to Destination String
|
||||
|
@ -5,8 +5,8 @@
|
||||
; and external constants #TRUE and #FALSE
|
||||
|
||||
;Predefined Strings
|
||||
PASS DC " Pass",0
|
||||
FAIL DC " Fail",0
|
||||
PASS DC " PASS",0
|
||||
FAIL DC " FAIL",0
|
||||
|
||||
;putadr(&addr) - PUT ADdRess to screen
|
||||
;Args: Y = Address MSB
|
||||
@ -20,7 +20,7 @@ PUTADR: JSR SAVRXY ;Save Address
|
||||
LDX #<PUTADS ;Load String LSB
|
||||
JSR PUTS ;Print String
|
||||
JMP PUTWRA ;Print MSB & LSB
|
||||
PUTADS DC "address=$",0
|
||||
PUTADS DC "ADDRESS=$",0
|
||||
|
||||
;trufls(val) - convert value to TRUe or FaLSe
|
||||
;Args: A = Value to Convert
|
||||
|
77
include/util.a02
Normal file
77
include/util.a02
Normal file
@ -0,0 +1,77 @@
|
||||
; C02 library util.h02 assembly language subroutines
|
||||
; Requires external function SETSRC, STRLEN, STRCML, and STRCPL
|
||||
; and external zero page locations DSTLO, DSTHI, SRCLO, and SRCHI
|
||||
|
||||
;tkndec(&list) - Decode Token into Destination String
|
||||
;Args: A = Tokenized Value
|
||||
; Y,X = Address of Token List
|
||||
;Requires: DSTLO,DSTHI = Address of Destination String
|
||||
;Sets: SRCLO,SRCHI = Pointer to Token in List
|
||||
; End of List if Not Found
|
||||
;Affects: X,C
|
||||
;Returns: A,Y = Length of Token, 0=Not Found
|
||||
; N,Z based on A
|
||||
TKNDEC: JSR SETSRC ;Set Source String to Token List
|
||||
TAX ;Save Argument
|
||||
BNE TKNDEL ;If 0
|
||||
STA (DSTLO),Y ; Set String to Null
|
||||
BEQ TKNENX ; And Return 0
|
||||
TKNDEL: JSR STRLEL ;Get Length of first Token in List
|
||||
BEQ TKNENX ;If Null String, Return 0
|
||||
TAY ;Set Index to Token Length
|
||||
INY ;plus 1
|
||||
TXA ;Compare Argument
|
||||
CMP (SRCLO),Y ;to Tokenized Value
|
||||
BEQ TKNDET ;If Not Egual
|
||||
TYA ; Get Token Length
|
||||
JSR TKNNXT ; Skip to Next Token
|
||||
BEQ TKNDEL ; and Loop
|
||||
TKNDET: LDY #0 ;Initialize Index and
|
||||
JMP STRCPL ;Copy Token to Destination String
|
||||
|
||||
;tknenc(&list) - Encode Token in Destination String
|
||||
;Args: Y,X = Address of Token List
|
||||
;Requires: DSTLO,DSTHI = Address of String to be Tokenized
|
||||
;Sets: SRCLO,SRCHI = Pointer to Token in List
|
||||
; End of List if Not Found
|
||||
;Affects: X,C,N,Z
|
||||
;Returns: A = Tokenized Value
|
||||
; N,Z based on A
|
||||
TKNENC: JSR SETSRC ;Set Source String to Token List
|
||||
TKNENL: JSR STRLEL ;Get Length of first Token in List
|
||||
BEQ TKNENX ;If Null String, Return 0
|
||||
TAX ;Save Length of Token
|
||||
INX ;and Add 1 for Terminator
|
||||
LDY #0 ;Initialize Index and
|
||||
JSR STRCML ;Compare Destination to Token
|
||||
BEQ TKNENT ;If Not Egual
|
||||
TXA ; Get Token Length
|
||||
JSR TKNNXT ; Skip to Next Token
|
||||
BEQ TKNENL ; and Loop
|
||||
TKNENT: TXA ;Get Index to Byte After String
|
||||
TAY
|
||||
LDA (SRCLO),Y ;and Load Byte
|
||||
TKNENX: RTS
|
||||
|
||||
;Move to Next Token
|
||||
;Args: A = Length of Token (including Terminator)
|
||||
;Returns: Y=0
|
||||
TKNNXT: SEC ;Add Token Length
|
||||
ADC SRCLO ;plus 1 for Value Byte
|
||||
STA SRCLO ;to Source Pointer LSB
|
||||
BCC TKNNXX ;If Carry
|
||||
INC SRCHI ; Increment Source Pointer MSB
|
||||
TKNNXX: LDY #0 ;Clear Index Register
|
||||
RTS
|
||||
|
||||
;SWAP Nybbles in Byte
|
||||
;Args: A = Byte containing Nybbles to Swap
|
||||
;Affects: C,N,Z
|
||||
;Returns: A = Byte with Nybbles Swapped
|
||||
SWAP: ASL ;Code by
|
||||
ADC #$80 ;David Galloway
|
||||
ROL ;posted on
|
||||
ASL ;6502.org by
|
||||
ADC #$80 ;Garth Wilson
|
||||
ROL ;Oct 27, 2017
|
||||
RTS
|
18
include/util.h02
Normal file
18
include/util.h02
Normal file
@ -0,0 +1,18 @@
|
||||
/********************************
|
||||
* util - C02 Utility Functions *
|
||||
********************************/
|
||||
|
||||
/* Decode Tokeniz into Destination String *
|
||||
* Args: &t - Address of Token List *
|
||||
* Returns: Tokenized Value of String */
|
||||
char tkndec();
|
||||
|
||||
/* Encode Tokenized from Destination String *
|
||||
* Args: &t - Address of Token List *
|
||||
* Returns: Tokenized Value of String */
|
||||
char tknenc();
|
||||
|
||||
/* Swap Nybbles in Byte *
|
||||
* Args: b - Byte to Swap *
|
||||
* Returns: Swapped Byte */
|
||||
char swap();
|
@ -7,7 +7,6 @@ char chrin(); //Input Character to Channel
|
||||
void chrout(); //Output Character to Channel
|
||||
char getin(); //Read Character from Keyboard Buffer
|
||||
|
||||
|
||||
//System Subroutines
|
||||
char plkey(); //Poll Console for character
|
||||
char rdkey(); //Wait for character from Console
|
||||
|
@ -64,8 +64,8 @@ PLKEY EQU $FFE4 ;Aliased to Kernal GETIN Routine
|
||||
GETKEY EQU PLKEY
|
||||
|
||||
;Wait for Character from Keyboard
|
||||
RDKEY: JSR GETKEY ;Poll Keyboard
|
||||
BEQ RDKEY ;If No Key, Loop
|
||||
RDKEY: JSR GETKEY ;Poll Keyboard
|
||||
BEQ RDKEY ;If No Key, Loop
|
||||
RTS
|
||||
|
||||
;Delete Previous Character
|
||||
@ -96,4 +96,3 @@ PRHEX: AND #$0F ;Strip High Nybble
|
||||
ADC #$06 ; Convert ':' to 'A'...
|
||||
PRHEXC: ADC #$30 ;Convert to ASCII Character
|
||||
JMP PRCHR ;Print Hex Digit and Return
|
||||
|
||||
|
@ -1,38 +1,42 @@
|
||||
; c02 Program Initialization Code for Vic-20 with at 8K Expansion
|
||||
;c02 Program Initialization Code for Vic-20 with at 8K Expansion
|
||||
|
||||
;System Specific ASCII Key Mappings
|
||||
DELKEY EQU $7F ;Delete/Backspace Key (Delete)
|
||||
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
|
||||
SRCLO EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
||||
SRCHI EQU $23 ;Source Pointer MSB [Temporary Pointers]
|
||||
DSTLO EQU $25 ;Destination Pointer LSB [Temporary Pointers]
|
||||
DSTHI EQU $24 ;Destination Pointer MSB [Temporary Pointers]
|
||||
RDSEED EQU $A2 ;Random Seed [Software Jiffy Clock (Low Byte)]
|
||||
BLKLO EQU $FD ;Block Pointer LSB [Unused Byte]
|
||||
BLKHI EQU $FE ;Block Pointer MSB [Unused Byte]
|
||||
STKLO EQU $FD ;Stack Pointer LSB [Unused Byte]
|
||||
STKHI EQU $FE ;Stack Pointer MSB [Unused Byte]
|
||||
DSTLO EQU $24 ;Destination Pointer LSB [Temporary Pointers]
|
||||
DSTHI EQU $25 ;Destination Pointer MSB [Temporary Pointers]
|
||||
BLKLO EQU $26 ;Block Pointer LSB [Floating Point Work Area]
|
||||
BLKHI EQU $27 ;Block Pointer MSB [Floating Point Work Area]
|
||||
STKLO EQU $28 ;Stack Pointer LSB [Floating Point Work Area]
|
||||
STKHI EQU $29 ;Stack Pointer MSB [Floating Point Work Area]
|
||||
RDSEED EQU $2A ;Random Seed [Software Jiffy Clock (Low Byte)]
|
||||
TEMP0 EQU $FB ;Temporary Variable [Unused Byte]
|
||||
TEMP1 EQU $FC ;Temporary Variable [Unused Byte]
|
||||
TEMP2 EQU $FD ;Temporary Variable [Unused Byte]
|
||||
TEMP3 EQU $FE ;Temporary Variable [Unused Byte]
|
||||
|
||||
USER0 EQU $0310 ;Free Byte for User Programs
|
||||
USER1 EQU $0311 ;Free Byte for User Programs
|
||||
USER2 EQU $0312 ;Free Byte for User Programs
|
||||
STKSLO EQU $0313 ;Free Byte for User Programs
|
||||
STKSHI EQU $0334 ;Free Byte for User Programs
|
||||
STKELO EQU $0335 ;Free Byte for User Programs
|
||||
STKEHI EQU $0336 ;Free Byte for User Programs
|
||||
RANDOM EQU $0311 ;Random Number Storage [Unused Byte]
|
||||
STKSAV EQU $0312 ;Machine Stack Storage [Unused Byte]
|
||||
STKSLO EQU $0313 ;Stack Start LSB [Unused Byte]
|
||||
STKSHI EQU $0334 ;Stack Start MSB [Unused Byte]
|
||||
STKELO EQU $0335 ;Stack End LSB [Unused Byte]
|
||||
STKEHI EQU $0336 ;Stack End MSB [Unused Byte]
|
||||
BLKSLO EQU $0337 ;Block Start LSB [Unused Byte]
|
||||
BLKSHI EQU $0338 ;Block Start MSB [Unused Byte]
|
||||
BLKELO EQU $0339 ;Block Start MSB [Unused Byte]
|
||||
BLKEHI EQU $033A ;Block End MSB [Unused Byte]
|
||||
STKSAV EQU $033B ;Machine Stack Storage [Unused Byte]
|
||||
BLKLEN EQU $033B ;Block Length [Unused Byte]
|
||||
TBFFR EQU $033C ;Cassette I/O Buffer
|
||||
TEMP0 EQU $03FC ;Temporary Variable [Unused Byte]
|
||||
TEMP1 EQU $03FD ;Temporary Variable [Unused Byte]
|
||||
TEMP2 EQU $03FE ;Temporary Variable [Unused Byte]
|
||||
TEMP3 EQU $03FF ;Temporary Variable [Unused Byte]
|
||||
USER12 EQU $03FC ;Free Byte for User Programs
|
||||
USER13 EQU $03FD ;Free Byte for User Programs
|
||||
USER14 EQU $03FE ;Free Byte for User Programs
|
||||
USER15 EQU $03FF ;Free Byte for User Programs
|
||||
|
||||
;Video RAM and ROM
|
||||
VICSCN EQU $1000 ;Video Screen Memory Area (Unexpanded)
|
||||
@ -51,7 +55,13 @@ BASIC: DC $0C, $12 ; Pointer to Next Line (4108)
|
||||
|
||||
START: TSX ;Get Stack Pointer
|
||||
STX STKSAV ;and Save for Exit
|
||||
JMP main ;Execute Program
|
||||
; LDA #$0E ;Switch to Upper/Lower Case
|
||||
; JSR PRCHR
|
||||
; LDA #$08 ;Disable Commodore+Shift
|
||||
; JSR PRCHR
|
||||
; LDA #$93 ;Clear Screen
|
||||
; JSR PRCHR
|
||||
JMP MAIN ;Execute Program
|
||||
|
||||
EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
|
||||
TXS ;and Restore It
|
||||
|
34
include/vic8k.h02
Normal file
34
include/vic8k.h02
Normal file
@ -0,0 +1,34 @@
|
||||
/* VIC 20 with 8k Expansion Header File */
|
||||
|
||||
//#pragma ascii invert //switch case for PETSCII
|
||||
|
||||
//Platform Specific Constants
|
||||
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
||||
#define ESCKEY $03 //Escape/Stop Key (STOP)
|
||||
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
||||
|
||||
//Library Pointer 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 stklo,stkhi; //Stack Pointer
|
||||
|
||||
//Library Variables
|
||||
char blkslo, blkshi; //Block Start Address
|
||||
char blkelo, blkehi; //Block End Address
|
||||
char blklen; //Block Segment Length
|
||||
char stkslo, stkshi; //Stack Start Address
|
||||
char stkelo, stkehi; //Stsck End Address
|
||||
char random, rdseed; //Pseudo-Random Number Generation
|
||||
char temp0, temp1, temp2, temp3; //Temporary Storage
|
||||
|
||||
//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 delchr(); //Delete previous character
|
||||
void prchr(); //Print ASCII character to Console
|
||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||
|
Loading…
x
Reference in New Issue
Block a user