mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-28 10:51:14 +00:00
Added function strtok to module stringx
This commit is contained in:
parent
acd1cbe3c3
commit
2767158d30
@ -16,11 +16,13 @@ RTNKEY EQU $0D ;Return/Enter Key (Carriage Return)
|
|||||||
.HEXH EQU $29 ;
|
.HEXH EQU $29 ;
|
||||||
.YSAVE EQU $2A ;Y Register Storage
|
.YSAVE EQU $2A ;Y Register Storage
|
||||||
.MODE EQU $2B ;Mode: Store, Examine, Block Examine
|
.MODE EQU $2B ;Mode: Store, Examine, Block Examine
|
||||||
.BUFFER EQU $200 ;Input Buffer
|
.IN EQU $200 ;Input Buffer
|
||||||
|
|
||||||
;Standard Library Variables
|
;Standard Library Variables
|
||||||
|
SRCPTR EQU $30 ;Source String Pointer (stdio.a02)
|
||||||
SRCLO EQU $30 ;Source String Pointer (stdio.a02)
|
SRCLO EQU $30 ;Source String Pointer (stdio.a02)
|
||||||
SRCHI EQU $31
|
SRCHI EQU $31
|
||||||
|
DSTPTR EQU $32 ;Destination String Pointer (string.a02)
|
||||||
DSTLO EQU $32 ;Destination String Pointer (string.a02)
|
DSTLO EQU $32 ;Destination String Pointer (string.a02)
|
||||||
DSTHI EQU $33
|
DSTHI EQU $33
|
||||||
BFRLO EQU $34 ;Work Buffer Pointer
|
BFRLO EQU $34 ;Work Buffer Pointer
|
||||||
@ -48,6 +50,11 @@ STKSHI EQU $4D
|
|||||||
STKELO EQU $4E ;Stack End Address
|
STKELO EQU $4E ;Stack End Address
|
||||||
STKEHI EQU $4F
|
STKEHI EQU $4F
|
||||||
|
|
||||||
|
SYSBFP EQU $50 ;Position in System Buffer
|
||||||
|
|
||||||
|
SYSBFL EQU 128 ;System Buffer Size (128 Bytes)
|
||||||
|
SYSBFR EQU .IN ;System Buffer (Input Buffer
|
||||||
|
|
||||||
;PIA 6820 Registers
|
;PIA 6820 Registers
|
||||||
.KBD EQU $D010 ;Keyboard Data
|
.KBD EQU $D010 ;Keyboard Data
|
||||||
.KBDCR EQU $D011 ;Keyboard Control Register
|
.KBDCR EQU $D011 ;Keyboard Control Register
|
||||||
@ -100,3 +107,5 @@ NEWLIN: LDA #$0D ;Load C/R into Accumulator
|
|||||||
JMP PUTCHR ; and Print it
|
JMP PUTCHR ; and Print it
|
||||||
|
|
||||||
INCLUDE "../include/putstr.a02" ;PUTSTR routine
|
INCLUDE "../include/putstr.a02" ;PUTSTR routine
|
||||||
|
|
||||||
|
ENDSUBROUTINE
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define DELKEY $5F //Delete/Backspace Key
|
#define DELKEY $5F //Delete/Backspace Key
|
||||||
#define ESCKEY $1B //Escape/Stop Key
|
#define ESCKEY $1B //Escape/Stop Key
|
||||||
#define RTNKEY $0D //Return/Enter Key
|
#define RTNKEY $0D //Return/Enter Key
|
||||||
|
#define SYSBFL 128 //System Buffer Length
|
||||||
|
|
||||||
/* Standard Library Variables */
|
/* Standard Library Variables */
|
||||||
char srclo,srchi; //Source String Pointer for Library Functions
|
char srclo,srchi; //Source String Pointer for Library Functions
|
||||||
@ -17,8 +18,9 @@ char blklen; //Block Segment Length
|
|||||||
|
|
||||||
char stkslo, stkshi; //Stack Start Address
|
char stkslo, stkshi; //Stack Start Address
|
||||||
char stkelo, stkehi; //Stack End Address
|
char stkelo, stkehi; //Stack End Address
|
||||||
|
char random, rdseed; //Pseudo-Random Number Generator
|
||||||
char temp0, temp1, temp2, temp3; //Temporary Variables
|
char temp0, temp1, temp2, temp3; //Temporary Variables
|
||||||
|
char sysbfr[], sysbfp; //System String Buffer and Position
|
||||||
|
|
||||||
//Monitor Subroutines
|
//Monitor Subroutines
|
||||||
void echo(); //Print Character in Accumulator
|
void echo(); //Print Character in Accumulator
|
||||||
|
@ -8,29 +8,38 @@ ESCKEY EQU $1B ;Escape/Stop Key (Escape)
|
|||||||
RTNKEY EQU $0D ;Return/Enter Key (Return)
|
RTNKEY EQU $0D ;Return/Enter Key (Return)
|
||||||
|
|
||||||
;Zero Page Variables (*=System Variable)
|
;Zero Page Variables (*=System Variable)
|
||||||
DSTLO EQU $06 ;Destination Pointer
|
DSTPTR EQU $06 ;Destination Pointer [Unused]
|
||||||
|
DSTLO EQU $06
|
||||||
DSTHI EQU $07
|
DSTHI EQU $07
|
||||||
BLKLO EQU $08 ;Block Segment Pointer (block.a02)
|
BLKLO EQU $08 ;Block Segment Pointer [Unused]
|
||||||
BLKHI EQU $09
|
BLKHI EQU $09
|
||||||
STKLO EQU $1D ;Stack Pointer (stack.a02)
|
SYSBFP EQU $1D ;Stack Pointer [Unused]
|
||||||
STKHI EQU $1E
|
; $1E ;Unused
|
||||||
|
STKLO EQU $2E ;Stack Pointer [Tape Read Work Area]
|
||||||
|
STKHI EQU $2F
|
||||||
RANDOM EQU $1F ;Random Number
|
RANDOM EQU $1F ;Random Number
|
||||||
INVFLG EQU $32 ;*Inverse Flag: $3F=Blinking, $7F=Inverse, $FF=Normal
|
.INVFLG EQU $32 ;*Inverse Flag: $3F=Blinking, $7F=Inverse, $FF=Normal
|
||||||
SRCLO EQU $71 ;Source Pointer
|
SRCPTR EQU $71 ;Source Pointer [Temporary Register]
|
||||||
|
SRCLO EQU $71
|
||||||
SRCHI EQU $72
|
SRCHI EQU $72
|
||||||
RDSEED EQU $E3 ;Random Seed
|
RDSEED EQU $E3 ;Random Seed
|
||||||
BLKSLO EQU $EB ;Block Start Address
|
BLKSLO EQU $EB ;Block Start Address [Unused]
|
||||||
BLKSHI EQU $ED
|
BLKSHI EQU $EC
|
||||||
BLKELO EQU $ED ;Block End Address
|
BLKELO EQU $ED ;Block End Address [Unused]
|
||||||
BLKEHI EQU $EE
|
BLKEHI EQU $EE
|
||||||
BLKLEN EQU $EF ;Block Segment Length
|
BLKLEN EQU $EF ;Block Segment Length [Unused]
|
||||||
BFRLO EQU $FA ;Work Buffer Pointer
|
BFRLO EQU $FA ;Work Buffer Pointer [Unused]
|
||||||
BFRHI EQU $FB
|
BFRHI EQU $FB
|
||||||
TEMP0 EQU $FC ;Temporary Storage
|
TEMP0 EQU $FC ;Temporary Variables [Unused]
|
||||||
TEMP1 EQU $FD
|
TEMP1 EQU $FD
|
||||||
TEMP2 EQU $FE
|
TEMP2 EQU $FE
|
||||||
TEMP3 EQU $FF
|
TEMP3 EQU $FF
|
||||||
|
|
||||||
|
;System Variables
|
||||||
|
SYSBFL EQU 255 ;System Buffer Size [88 Bytes]
|
||||||
|
SYSBFR EQU $0300 ;System Buffer [Keyboard Buffer]
|
||||||
|
|
||||||
|
|
||||||
;I/O Locations
|
;I/O Locations
|
||||||
.KBD EQU $C000 ;Keyboard Data
|
.KBD EQU $C000 ;Keyboard Data
|
||||||
.AKD EQU $C010 ;Keyboard Strobe Register
|
.AKD EQU $C010 ;Keyboard Strobe Register
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define DELKEY $08 //Delete/Backspace Key
|
#define DELKEY $08 //Delete/Backspace Key
|
||||||
#define ESCKEY $1B //Escape/Stop Key
|
#define ESCKEY $1B //Escape/Stop Key
|
||||||
#define RTNKEY $0D //Return/Enter Key
|
#define RTNKEY $0D //Return/Enter Key
|
||||||
|
#define SYSBFL 255 //System Buffer Length
|
||||||
|
|
||||||
/* Standard Library Pointers */
|
/* Standard Library Pointers */
|
||||||
char srclo,srchi; //Source String Pointer for Library Functions
|
char srclo,srchi; //Source String Pointer for Library Functions
|
||||||
@ -20,6 +21,7 @@ char stkslo, stkshi; //Stack Start Address
|
|||||||
char stkelo, stkehi; //Stsck End Address
|
char stkelo, stkehi; //Stsck End Address
|
||||||
char random, rdseed; //Pseudo-Random Number Generation
|
char random, rdseed; //Pseudo-Random Number Generation
|
||||||
char temp0, temp1, temp2, temp3; //Temporary Variables
|
char temp0, temp1, temp2, temp3; //Temporary Variables
|
||||||
|
char sysbfr[], sysbfp; //System String Buffer and Position
|
||||||
|
|
||||||
/* Platform Specific Variables */
|
/* Platform Specific Variables */
|
||||||
char invflg; //Video Invert Mask
|
char invflg; //Video Invert Mask
|
||||||
|
@ -9,8 +9,10 @@ RTNKEY EQU $0D ;Return/Enter Key (RETURN)
|
|||||||
XMBANK EQU $0A ;Extended Memory Bank (Load/Verify Flag)
|
XMBANK EQU $0A ;Extended Memory Bank (Load/Verify Flag)
|
||||||
XADRLO EQU $0B ;Ext Memory Address LSB (Text Index/Array Size)
|
XADRLO EQU $0B ;Ext Memory Address LSB (Text Index/Array Size)
|
||||||
XADRHI EQU $0C ;Ext Memory Address MSB (Array Dimension Fkags)
|
XADRHI EQU $0C ;Ext Memory Address MSB (Array Dimension Fkags)
|
||||||
|
SRCPTR EQU $22 ;Source Pointer [Temporary Pointers]
|
||||||
SRCLO EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
SRCLO EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
||||||
SRCHI EQU $23 ;Source Pointer MSB [Temporary Pointers]
|
SRCHI EQU $23 ;Source Pointer MSB [Temporary Pointers]
|
||||||
|
DSTPTR EQU $24 ;Destination Pointer [Temporary Pointers]
|
||||||
DSTLO EQU $24 ;Destination Pointer LSB [Temporary Pointers]
|
DSTLO EQU $24 ;Destination Pointer LSB [Temporary Pointers]
|
||||||
DSTHI EQU $25 ;Destination Pointer MSB [Temporary Pointers]
|
DSTHI EQU $25 ;Destination Pointer MSB [Temporary Pointers]
|
||||||
BLKLO EQU $26 ;Block Pointer LSB [Floating Point Work Area]
|
BLKLO EQU $26 ;Block Pointer LSB [Floating Point Work Area]
|
||||||
@ -26,7 +28,9 @@ TEMP2 EQU $FD ;Temporary Variable [Unused Byte]
|
|||||||
TEMP3 EQU $FE ;Temporary Variable [Unused Byte]
|
TEMP3 EQU $FE ;Temporary Variable [Unused Byte]
|
||||||
|
|
||||||
;System Variables
|
;System Variables
|
||||||
USER3 EQU $0313 ;Free Byte for User Programs
|
SYSBFL EQU 88 ;System Buffer Size [88 Bytes]
|
||||||
|
SYSBFR EQU $0200 ;System Buffer [Keyboard Buffer]
|
||||||
|
SYSBFP EQU $0313 ;Position in System Buffer [Free Byte]
|
||||||
|
|
||||||
BLKSLO EQU $0334 ;Block Start LSB [Unused Byte]
|
BLKSLO EQU $0334 ;Block Start LSB [Unused Byte]
|
||||||
BLKSHI EQU $0335 ;Block Start MSB [Unused Byte]
|
BLKSHI EQU $0335 ;Block Start MSB [Unused Byte]
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
||||||
#define ESCKEY $03 //Escape/Break Key (STOP)
|
#define ESCKEY $03 //Escape/Break Key (STOP)
|
||||||
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
||||||
|
#define SYSBFL 88 //System Buffer Length
|
||||||
|
|
||||||
/* Standard Library Pointers */
|
/* Standard Library Pointers */
|
||||||
char srclo,srchi; //Source String Pointer for Library Functions
|
char srclo,srchi; //Source String Pointer for Library Functions
|
||||||
@ -17,9 +18,10 @@ char blkslo, blkshi; //Block Start Address
|
|||||||
char blkelo, blkehi; //Block End Address
|
char blkelo, blkehi; //Block End Address
|
||||||
char blklen; //Block Segment Length
|
char blklen; //Block Segment Length
|
||||||
char stkslo, stkshi; //Stack Start Address
|
char stkslo, stkshi; //Stack Start Address
|
||||||
char stkelo, stkehi; //Stsck End Address
|
char stkelo, stkehi; //Stack End Address
|
||||||
char random, rdseed; //Pseudo-Random Number Generation
|
char random, rdseed; //Pseudo-Random Number Generator
|
||||||
char temp0, temp1, temp2, temp3; //Temporary Storage
|
char temp0, temp1, temp2, temp3; //Temporary Storage
|
||||||
|
char sysbfr[], sysbfp; //System String Buffer and Position
|
||||||
|
|
||||||
/* System Subroutines */
|
/* System Subroutines */
|
||||||
void delchr(); //Delete previous character
|
void delchr(); //Delete previous character
|
||||||
|
@ -40,11 +40,17 @@ STKSHI EQU $4D
|
|||||||
STKELO EQU $4E ;Stack End Address
|
STKELO EQU $4E ;Stack End Address
|
||||||
STKEHI EQU $4F
|
STKEHI EQU $4F
|
||||||
|
|
||||||
|
SYSBFP EQU $50 ;Position in System Buffer
|
||||||
|
|
||||||
|
SYSBFL EQU 128 ;System Buffer Size (Max String Size)
|
||||||
|
SYSBFR EQU $0200 ;System Buffer
|
||||||
|
|
||||||
|
|
||||||
;Memory Mapped I/O
|
;Memory Mapped I/O
|
||||||
_KBHIT EQU $FFF0 ;Is a Key Pressed
|
_KBHIT EQU $FFF0 ;Is a Key Pressed
|
||||||
_GETCH EQU $FFF1 ;Read Keyboard (Blocking)
|
_GETCH EQU $FFF1 ;Read Keyboard (Blocking)
|
||||||
|
|
||||||
ORG $0200 ;START at RAM midpoint
|
ORG $0400 ;START at RAM midpoint
|
||||||
|
|
||||||
START: JMP MAIN ;Execute Program
|
START: JMP MAIN ;Execute Program
|
||||||
|
|
||||||
@ -80,5 +86,7 @@ PUTCHR EQU $FFE3 ;Emulator CHROUT Routine
|
|||||||
|
|
||||||
EXIT EQU $FFEC ;Emulator SHUTDN Routine
|
EXIT EQU $FFEC ;Emulator SHUTDN Routine
|
||||||
|
|
||||||
|
FSCMD EQU $FFE6 ;run6502 File System Command Routine
|
||||||
|
|
||||||
INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routines
|
INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routines
|
||||||
INCLUDE "../include/putstr.a02" ;PUTSTR routine
|
INCLUDE "../include/putstr.a02" ;PUTSTR routine
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define DELKEY $08 //Delete/Backspace Key
|
#define DELKEY $08 //Delete/Backspace Key
|
||||||
#define ESCKEY $18 //Escape/Stop Key
|
#define ESCKEY $18 //Escape/Stop Key
|
||||||
#define RTNKEY $0D //Return/Enter Key
|
#define RTNKEY $0D //Return/Enter Key
|
||||||
|
#define SYSBFL 128 //System Buffer Length
|
||||||
|
|
||||||
//Library Pointer Variables
|
//Library Pointer Variables
|
||||||
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
zeropage int srcptr, dstptr, bfrptr, blkptr;
|
||||||
@ -12,7 +13,6 @@ char dstlo,dsthi; //Destination String Pointer for Library Functions
|
|||||||
char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
char bfrlo,bfrhi; //Buffer Pointer for Library Functions
|
||||||
char blklo,blkhi; //Block Segment Pointer
|
char blklo,blkhi; //Block Segment Pointer
|
||||||
char stklo,stkhi; //Stack Pointer
|
char stklo,stkhi; //Stack Pointer
|
||||||
|
|
||||||
//Library Variables
|
//Library Variables
|
||||||
char blkslo, blkshi; //Block Start Address
|
char blkslo, blkshi; //Block Start Address
|
||||||
char blkelo, blkehi; //Block End Address
|
char blkelo, blkehi; //Block End Address
|
||||||
@ -21,6 +21,7 @@ char stkslo, stkshi; //Stack Start Address
|
|||||||
char stkelo, stkehi; //Stsck End Address
|
char stkelo, stkehi; //Stsck End Address
|
||||||
char random, rdseed; //Pseudo-Random Number Generation
|
char random, rdseed; //Pseudo-Random Number Generation
|
||||||
char temp0, temp1, temp2, temp3; //Temporary Storage
|
char temp0, temp1, temp2, temp3; //Temporary Storage
|
||||||
|
char sysbfr[], sysbfp; //System String Buffer and Position
|
||||||
|
|
||||||
//Memory Mapped I/O
|
//Memory Mapped I/O
|
||||||
char putcon; //Write Character to Console
|
char putcon; //Write Character to Console
|
||||||
|
@ -1,20 +1,21 @@
|
|||||||
;c02 library stddef.h02 assembly language subroutines
|
;c02 library stddef.h02 assembly language subroutines
|
||||||
;Requires External Zero Page Variables
|
;Requires External Zero Page Variables DSTPTR, SRCPTR
|
||||||
;DSTLO, DSTHI, SRCLO, SRCHI
|
;and External Variables TEMP0, TEMP1, TEMP2 (system header)
|
||||||
;External Variables
|
|
||||||
;TEMP0, TEMP1, TEMP2
|
SUBROUTINE STDDEF
|
||||||
|
|
||||||
;Constant Definitions
|
;Constant Definitions
|
||||||
|
STRSIZ EQU 128 ;Maximum String Size
|
||||||
TRUE EQU $FF ;Returned for Success or Failure
|
TRUE EQU $FF ;Returned for Success or Failure
|
||||||
FALSE EQU $00 ;by some Library Routines
|
FALSE EQU $00 ;by some Library Routines
|
||||||
|
|
||||||
;savdst() - Save Destination Pointer
|
;savdst() - Save Destination Pointer
|
||||||
SAVDST: JSR GETDST ;Load Destination Pointer
|
SAVDST: JSR GETDST ;Load Destination Pointer
|
||||||
JMP SAVRXY ;Save X & Y Registers
|
BVC SAVRXY ;Save X & Y Registers
|
||||||
|
|
||||||
;savsrc() - Save Source Pointer
|
;savsrc() - Save Source Pointer
|
||||||
SAVSRC: JSR GETSRC ;Load Destination Pointer
|
SAVSRC: JSR GETSRC ;Load Destination Pointer
|
||||||
JMP SAVRXY ;Save X & Y Registers
|
BVC SAVRXY ;Save X & Y Registers
|
||||||
|
|
||||||
;Save Registers
|
;Save Registers
|
||||||
SAVREG: STA TEMP0 ;Save Accumulater
|
SAVREG: STA TEMP0 ;Save Accumulater
|
||||||
@ -23,44 +24,60 @@ SAVRXY: STX TEMP1 ;Save X Index
|
|||||||
RTS
|
RTS
|
||||||
|
|
||||||
;Restore Registers
|
;Restore Registers
|
||||||
RESREG: LDA TEMP0 ;Load Accumlator
|
RESREG: LDA TEMP0 ;Load Accumulator
|
||||||
RESRXY: LDX TEMP1 ;Load X Index
|
RESRXY: LDX TEMP1 ;Load X Index
|
||||||
LDY TEMP2 ;Load Y Index
|
LDY TEMP2 ;Load Y Index
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
;Set Destination Pointer to System Buffer
|
||||||
|
SETDSB: JSR GETBFR ;Get Buffer Address
|
||||||
|
BVC SETDST
|
||||||
|
|
||||||
;Set Destination Pointer to Source Pointer
|
;Set Destination Pointer to Source Pointer
|
||||||
SETDSS: JSR GETSRC ;Get Destination Pointer
|
SETDSS: JSR GETSRC ;Get Destination Pointer
|
||||||
JMP SETDST ;Store in Source Pointer
|
BVC SETDST ;Store in Source Pointer
|
||||||
|
|
||||||
;Restore Destination Pointer
|
;Restore Destination Pointer
|
||||||
RESDST: JSR RESRXY ;Load Address and Drop into SETDST
|
RESDST: JSR RESRXY ;Load Address and Drop into SETDST
|
||||||
|
|
||||||
;Initialize Destination Pointer
|
;Initialize Destination Pointer
|
||||||
SETDST: STX DSTLO ;Store Destination Pointer
|
SETDST: STX DSTPTR ;Store Destination Pointer
|
||||||
STY DSTHI
|
STY DSTPTR+1
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
;Restore Source Pointer
|
;Restore Source Pointer
|
||||||
RESSRC: JSR RESRXY ;Load Saved Address
|
RESSRC: JSR RESRXY ;Load Saved Address
|
||||||
JMP SETSRC ;Set Source Pointer
|
BVC SETSRC ;Set Source Pointer
|
||||||
|
|
||||||
|
;Set Source Pointer to System Buffer
|
||||||
|
SETSRB: JSR GETBFR ;Get Buffer Address
|
||||||
|
BVC SETSRC
|
||||||
|
|
||||||
;Set Source Pointer to Destination Pointer
|
;Set Source Pointer to Destination Pointer
|
||||||
SETSRD: JSR GETDST ;Get Destination Point and fall into SETSRC
|
SETSRD: JSR GETDST ;Get Destination Point and fall into SETSRC
|
||||||
|
|
||||||
;Initialize Source Pointer and Index
|
;Initialize Source Pointer and Index
|
||||||
SETSRC: STX SRCLO ;Store Source Pointer
|
SETSRC: STX SRCPTR ;Store Source Pointer
|
||||||
STY SRCHI
|
STY SRCPTR+1
|
||||||
LDY #$00 ;Initialize Index Into String
|
LDY #$00 ;Initialize Index Into String
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
;Retrieve Source String Pointer
|
;Retrieve System Buffer Address
|
||||||
GETDST: LDX DSTLO
|
GETBFR: LDX #<SYSBFR
|
||||||
LDY DSTHI
|
LDY #>SYSBFR
|
||||||
|
CLV ;Clear Overflow Flag for BVC
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
;Retrieve Source String Pointer
|
;Retrieve Source String Pointer
|
||||||
GETSRC: LDX SRCLO
|
GETDST: LDX DSTPTR
|
||||||
LDY SRCHI
|
LDY DSTPTR+1
|
||||||
|
CLV ;Clear Overflow Flag for BVC
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;Retrieve Source String Pointer
|
||||||
|
GETSRC: LDX SRCPTR
|
||||||
|
LDY SRCPTR+1
|
||||||
|
CLV ;Clear Overflow Flag for BVC
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
;Add TEMP1,TEMP2 to X,Y
|
;Add TEMP1,TEMP2 to X,Y
|
||||||
@ -85,16 +102,20 @@ SUBTXY: TXA
|
|||||||
|
|
||||||
;Decrement X,Y Register Pair
|
;Decrement X,Y Register Pair
|
||||||
DECRXY: CPY #0
|
DECRXY: CPY #0
|
||||||
BNE DECRXZ
|
BNE .SKIP
|
||||||
DEY
|
DEY
|
||||||
DECRXZ: DEX
|
.SKIP DEX
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
;Increment X,Y Register Pair
|
;Increment X,Y Register Pair
|
||||||
INCRXY: INX
|
INCRXY: INX
|
||||||
BNE INCRXZ
|
BNE .RETURN
|
||||||
INY
|
INY
|
||||||
INCRXZ: RTS
|
.RETURN RTS
|
||||||
|
|
||||||
|
;Set Source Pointer to Buffer Location and Add Accumulator
|
||||||
|
SETDBA: LDA SYSBFP ;Get Buffer Position
|
||||||
|
JSR SETDSB ;Set Destination to Buffer Address
|
||||||
|
|
||||||
;Add Accumulator to Destination Address
|
;Add Accumulator to Destination Address
|
||||||
ADDDSA: TAX ;Move Accumulator to Argument LSB
|
ADDDSA: TAX ;Move Accumulator to Argument LSB
|
||||||
@ -103,9 +124,14 @@ ADDDSA: TAX ;Move Accumulator to Argument LSB
|
|||||||
;Add to Destination Address
|
;Add to Destination Address
|
||||||
;Args: Y,X = MSB,LSB of Integer to Add
|
;Args: Y,X = MSB,LSB of Integer to Add
|
||||||
;Affects: A,Y,X
|
;Affects: A,Y,X
|
||||||
ADDDST: LDA #DSTLO ;Set Index to Destination Pointer
|
ADDDST: LDA #DSTPTR ;Set Index to Destination Pointer
|
||||||
BNE ADDZPW ;and Execute ADDZPW
|
BNE ADDZPW ;and Execute ADDZPW
|
||||||
|
|
||||||
|
;Set Source Pointer to System Buffer Position
|
||||||
|
SETSBP: LDA SYSBFP ;Load Position in Buffer
|
||||||
|
BMI .RETURN ;If Greater than 127, Return
|
||||||
|
JSR SETSRB ;Set Source Pointer to Buffer Address
|
||||||
|
|
||||||
;Add Accumulator to Source Address
|
;Add Accumulator to Source Address
|
||||||
ADDSRA: TAX ;Move Accumulator to Argument LSB
|
ADDSRA: TAX ;Move Accumulator to Argument LSB
|
||||||
LDY #0 ;Clear Argument MSB
|
LDY #0 ;Clear Argument MSB
|
||||||
@ -113,7 +139,7 @@ ADDSRA: TAX ;Move Accumulator to Argument LSB
|
|||||||
;Add to Source Address
|
;Add to Source Address
|
||||||
;Args: Y,X = MSB,LSB of Integer to Add
|
;Args: Y,X = MSB,LSB of Integer to Add
|
||||||
;Affects: A,Y,X
|
;Affects: A,Y,X
|
||||||
ADDSRC: LDA #SRCLO ;Set Index and Drop into ADDZPW
|
ADDSRC: LDA #SRCPTR ;Set Index and Drop into ADDZPW
|
||||||
|
|
||||||
;Add to Zero Page Word
|
;Add to Zero Page Word
|
||||||
;Args: A = Address of Zero Page Word
|
;Args: A = Address of Zero Page Word
|
||||||
@ -130,3 +156,4 @@ ADDZPW: STA TEMP3 ;Save Zero Page Address
|
|||||||
STA 1,X ;and Save Result
|
STA 1,X ;and Save Result
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
ENDSUBROUTINE
|
||||||
|
@ -47,7 +47,7 @@ STRCMR: RTS ;
|
|||||||
; A = $FF, C=0 if not found
|
; A = $FF, C=0 if not found
|
||||||
; Y = Position of last character scanned
|
; Y = Position of last character scanned
|
||||||
STRCHR: JSR SETSRC ;Initialize Source String
|
STRCHR: JSR SETSRC ;Initialize Source String
|
||||||
STRCHA: STA TEMP3; ;Save Search Character (alternate entry point)
|
STRCHA: STA TEMP3 ;Save Search Character (alternate entry point)
|
||||||
STRCHL: LDA (SRCLO),Y ;Get Next Character
|
STRCHL: LDA (SRCLO),Y ;Get Next Character
|
||||||
BEQ STRCLC ;If NUL, Return $FF and Carry Clear
|
BEQ STRCLC ;If NUL, Return $FF and Carry Clear
|
||||||
CMP TEMP3 ;Compare Character
|
CMP TEMP3 ;Compare Character
|
||||||
@ -83,6 +83,11 @@ STRLEX: TYA ;Transfer Index to Accumulator
|
|||||||
;Affects: N,Z
|
;Affects: N,Z
|
||||||
STRDST EQU SETDST ;Aliased to System Header function
|
STRDST EQU SETDST ;Aliased to System Header function
|
||||||
|
|
||||||
|
;strcpb(&s) - Copy String to System Buffer
|
||||||
|
STRCPB: JSR SETSRC ;Set Source Pointer to String Address
|
||||||
|
JSR SETDSB ;Set Destination Pointer to System Buffer
|
||||||
|
BVC STRCPA ;Execute String Copy
|
||||||
|
|
||||||
;strcat(&s) Concatenate String (to Destination String)
|
;strcat(&s) Concatenate String (to Destination String)
|
||||||
;Requires: DSTLO, DSTHI - Pointer to destination string
|
;Requires: DSTLO, DSTHI - Pointer to destination string
|
||||||
;Args: X,Y = Pointer to source string
|
;Args: X,Y = Pointer to source string
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* string - String Handling Routines for C02 *
|
* string - String Handling Routines for C02 *
|
||||||
*********************************************/
|
*********************************************/
|
||||||
|
|
||||||
/* Find Charaacter in String *
|
/* Find Character in String *
|
||||||
* Args: c - Character to find *
|
* Args: c - Character to find *
|
||||||
* &s - String to search *
|
* &s - String to search *
|
||||||
* Returns: c in s *
|
* Returns: c in s *
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
; C02 library stringx.h02 assembly language subroutines
|
; C02 library stringx.h02 assembly language subroutines
|
||||||
; Requires the subroutines and definitions from string.asm
|
; Requires the subroutines and definitions from string.asm
|
||||||
|
|
||||||
|
SUBROUTINE STRINGX
|
||||||
|
|
||||||
;Common Code - Initialize Variables
|
;Common Code - Initialize Variables
|
||||||
STRXSI: JSR SETSRC ;Initialize Source String
|
STRXSI: JSR SETSRC ;Initialize Source String
|
||||||
STY TEMP1 ;Save Destination Pointer
|
STY TEMP1 ;Save Destination Pointer
|
||||||
@ -73,3 +75,56 @@ STRSPL: JSR STRXSL ;and Search for Character in Source String
|
|||||||
BPL STRSPL ; and Loop if < 128
|
BPL STRSPL ; and Loop if < 128
|
||||||
BMI STRXSP ;Else Return Position
|
BMI STRXSP ;Else Return Position
|
||||||
|
|
||||||
|
;strtok(c, &s) - Split String by Specified Character
|
||||||
|
;Args: A = Delimiter, 0 = Set String to Tokenize
|
||||||
|
; X,Y = Address of Argument String
|
||||||
|
;Sets: DSTPTR = Address of Argument String
|
||||||
|
; or Address of System Buffer (A=0)
|
||||||
|
; SRCPTR = Address of System Buffer Location
|
||||||
|
; or Address of Argument String (A=0)
|
||||||
|
; TEMP0 = Delimiter Character
|
||||||
|
;Populates: SYSBFR - String to Tokenize
|
||||||
|
;Returns: A = Length of Token
|
||||||
|
; Y = New Buffer Position, $FF = End of String
|
||||||
|
; X = End of String Flag, $00 or $FF
|
||||||
|
STRTOK: ORA #0
|
||||||
|
BNE .STRTOK ;If Delimiter is NUL
|
||||||
|
STA SYSBFP ; Initialize System Buffer Position
|
||||||
|
JMP STRCPB ; Copy String to System Buffer and Return
|
||||||
|
.STRTOK STA TEMP0 ;Save Delimiter Character
|
||||||
|
JSR SETDST ;Set Destination to String Address
|
||||||
|
JSR SETSBP ;Set Source to Current Buffer Position
|
||||||
|
BPL .STCOPY ;If at End of Buffer
|
||||||
|
LDA #0
|
||||||
|
TAY ;Set Destination String to ""
|
||||||
|
STA (DSTPTR),Y ;and Return String Length 0
|
||||||
|
RTS
|
||||||
|
.STCOPY LDY #0 ;Initialize Index
|
||||||
|
LDX #0 ;Clear End of String Flag
|
||||||
|
.STLOOP LDA (SRCPTR),Y ;Get Character from Source String
|
||||||
|
BNE .STSKIP ;If End of String
|
||||||
|
DEX ; Set End of Buffer Flag
|
||||||
|
BMI .STDONE ; and Finish Up
|
||||||
|
.STSKIP CMP TEMP0 ;
|
||||||
|
BEQ .STDONE ;If Not Delimiter Character
|
||||||
|
STA (DSTPTR),Y ; Copy to Destination String
|
||||||
|
INY ; Increment Index
|
||||||
|
CPY #SYSBFL ; If Less Than Buffer Size
|
||||||
|
BCC .STLOOP ; Loop
|
||||||
|
DEX ;Else Set End of Buffer Flag
|
||||||
|
.STDONE LDA #0 ;Terminate String
|
||||||
|
STA (DSTLO),Y ;
|
||||||
|
.STRTN STY TEMP0 ;Save String Length
|
||||||
|
INY ;Increment Past Delimiter
|
||||||
|
TYA ; and Add to Buffer Position
|
||||||
|
CLC
|
||||||
|
ADC SYSBFP
|
||||||
|
STA SYSBFP ;Save New Buffer Position
|
||||||
|
CPX #0 ;If End of Buffer Flag is Set
|
||||||
|
BPL .STRTRN
|
||||||
|
STX SYSBFP ; Set Buffer Position to 255
|
||||||
|
.STRTRN LDA TEMP0 ;Return String Length
|
||||||
|
RTS
|
||||||
|
|
||||||
|
|
||||||
|
ENDSUBROUTINE
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
/* Find Span of Characters not matching String *
|
/* Find Span of Characters not matching String *
|
||||||
* Args: &s - String of characters to match *
|
* Args: &s - String of characters to match *
|
||||||
* Uses: String to parse specified by strdst() *
|
* Uses: String to parse specified by setdst() *
|
||||||
* Sets: temp1 - Result *
|
* Sets: temp1 - Result *
|
||||||
* Returns: Number of consecutive characters in *
|
* Returns: Number of consecutive characters in *
|
||||||
* Destination that are not in Source */
|
* Destination that are not in Source */
|
||||||
@ -12,16 +12,15 @@ char strbrk();
|
|||||||
char strcsp(); //Alias
|
char strcsp(); //Alias
|
||||||
|
|
||||||
/* Find Span of Characters matching String *
|
/* Find Span of Characters matching String *
|
||||||
* Args: &s - String of characters to match *
|
* Setup: setdst(s) - String to Search *
|
||||||
* Uses: String to parse specified by strdst() *
|
* Args: int &m - String to match *
|
||||||
* Sets: temp1 - Result *
|
* Returns: Number of consecutive characters *
|
||||||
* Returns: Number of consecutive characters in *
|
* in m that are also in s */
|
||||||
* Destination that are also in Source */
|
|
||||||
char strspn();
|
char strspn();
|
||||||
|
|
||||||
/* Find First Character matching String *
|
/* Find First Character matching String *
|
||||||
* Args: &s - String of characters to match *
|
* Args: &s - String of characters to match *
|
||||||
* Uses: String to parse specified by strdst() *
|
* Uses: String to parse specified by setdst() *
|
||||||
* Sets: temp1 - Result *
|
* Sets: temp1 - Result *
|
||||||
* Returns: Position of first character in *
|
* Returns: Position of first character in *
|
||||||
* Destination that is also in Source *
|
* Destination that is also in Source *
|
||||||
|
@ -6,8 +6,10 @@ ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
|
|||||||
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
|
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
|
||||||
|
|
||||||
;Zero Page Locations
|
;Zero Page Locations
|
||||||
|
SRCPTR EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
||||||
SRCLO EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
SRCLO EQU $22 ;Source Pointer LSB [Temporary Pointers]
|
||||||
SRCHI EQU $23 ;Source Pointer MSB [Temporary Pointers]
|
SRCHI EQU $23 ;Source Pointer MSB [Temporary Pointers]
|
||||||
|
DSTPTR EQU $24 ;Destination Pointer LSB [Temporary Pointers]
|
||||||
DSTLO EQU $24 ;Destination Pointer LSB [Temporary Pointers]
|
DSTLO EQU $24 ;Destination Pointer LSB [Temporary Pointers]
|
||||||
DSTHI EQU $25 ;Destination Pointer MSB [Temporary Pointers]
|
DSTHI EQU $25 ;Destination Pointer MSB [Temporary Pointers]
|
||||||
BLKLO EQU $26 ;Block Pointer LSB [Floating Point Work Area]
|
BLKLO EQU $26 ;Block Pointer LSB [Floating Point Work Area]
|
||||||
@ -23,10 +25,12 @@ TEMP2 EQU $FD ;Temporary Variable [Unused Byte]
|
|||||||
TEMP3 EQU $FE ;Temporary Variable [Unused Byte]
|
TEMP3 EQU $FE ;Temporary Variable [Unused Byte]
|
||||||
|
|
||||||
;System Variables
|
;System Variables
|
||||||
|
SYSBFL EQU 88 ;System Buffer Size [88 Bytes]
|
||||||
|
SYSBFR EQU $0200 ;System Buffer [Keyboard Buffer]
|
||||||
USER0 EQU $0310 ;Free Byte for User Programs
|
USER0 EQU $0310 ;Free Byte for User Programs
|
||||||
USER1 EQU $0311 ;Free Byte for User Programs
|
USER1 EQU $0311 ;Free Byte for User Programs
|
||||||
USER2 EQU $0312 ;Free Byte for User Programs
|
USER2 EQU $0312 ;Free Byte for User Programs
|
||||||
USER3 EQU $0313 ;Free Byte for User Programs
|
SYSBFP EQU $0313 ;Position in System Buffer [Free Byte]
|
||||||
|
|
||||||
BLKSLO EQU $0334 ;Block Start LSB [Unused Byte]
|
BLKSLO EQU $0334 ;Block Start LSB [Unused Byte]
|
||||||
BLKSHI EQU $0335 ;Block Start MSB [Unused Byte]
|
BLKSHI EQU $0335 ;Block Start MSB [Unused Byte]
|
||||||
|
60
include/vic/float.a02
Normal file
60
include/vic/float.a02
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
;VIC20 BASIC Floating Point Functions
|
||||||
|
|
||||||
|
;pival - PI Expressed as a Five-Byte Floating Point Number
|
||||||
|
PIVAL EQU $CEA8
|
||||||
|
|
||||||
|
maxint EQU $D1A5 ;The Constant -32768 in Five-Byte Floating Point Format
|
||||||
|
ayint EQU $D1AA ;Convert Floating Point to Signed Integer in A and Y
|
||||||
|
intidx EQU $D1B2 ;Convert Floating Point Subscript to a Positive Integer
|
||||||
|
fpint EQU $D1BF ;Convert Floating Point Number to Signed Integer
|
||||||
|
|
||||||
|
makfp EQU $D391 ;Convert 16-Bit Signed Integer to Floating Pointers
|
||||||
|
fpadr EQU $D7F7 ;Convert Floating Point to Unsigned Two-Byte Integer
|
||||||
|
|
||||||
|
fpsubm EQU $D850 ;Subtract FAC1 from a Number in Memory
|
||||||
|
fpsub EQU $D853 ;Subtract FAC2 from FAC1
|
||||||
|
fpaddm EQU $D867 ;Add FAC1 to a Number in Memory
|
||||||
|
fpaddh EQU $D86A ;Add FAC1 to FAC2
|
||||||
|
|
||||||
|
normlz EQU $D8FE ;Normalize Floating Point Accumulator #1
|
||||||
|
comfac EQU $D947 ;Replace FAC1 with Its 2's Complement
|
||||||
|
|
||||||
|
denorm EQU $D983 ;Denormalize Exponents of FAC1 and FAC2
|
||||||
|
fpcone EQU $D9BC ;Floating Point Constant with a Value of 1
|
||||||
|
|
||||||
|
dolog EQU $D9EA ;Perform LOG
|
||||||
|
fpmult EQU $DA28 ;Multiply FAC1 with FAC2
|
||||||
|
fpmltb EQU $DA59 ;Multiply Byte Subroutine
|
||||||
|
lodarg EQU $DA8C ;Move Floating Point Number from Memory into FAC2
|
||||||
|
|
||||||
|
multen EQU $DAE2 ;Multiply FAC1 by 10
|
||||||
|
fpcten EQU $BAF9 ;The Constant 10 in Five-Byte Floating Format
|
||||||
|
divten EQU $DAFE ;Divide FAC1 by 10
|
||||||
|
fpdivm EQU $DB0F ;Divide a Number in Memory by FAC1
|
||||||
|
fpdivm EQU $DB12 ;Divide FAC2 by FAC1
|
||||||
|
lodfac EQU $DBA2 ;Move Floating Point Number from Memory to FAC1
|
||||||
|
|
||||||
|
strfac EQU $DBD4 ;Move Floating Point Number from FAC1 to Memory
|
||||||
|
argfac EQU $DBFC ;Move Floating Point Number from FAC2 to FAC1
|
||||||
|
rndmov EQU $DC0C ;Round and Move Floating Point Number from FAC1 to FAC2
|
||||||
|
facarg EQU $DC0F ;Move Floating Point Number from FAC1 to FAC2
|
||||||
|
round EQU $DC1B ;Round FAC1 by Adjusting Rounding Byte
|
||||||
|
sgnfac EQU $DC2B ;Put Sign of FAC1 into A Register
|
||||||
|
dosgn EQU $DC39 ;Perform SGN
|
||||||
|
bytfp EQU $DC3C ;Convert Signed Byte in A Register to Floating Point
|
||||||
|
doabs EQU $DC58 ;Perform ABS
|
||||||
|
cmpfac EQU $DC5B ;Compare FAC1 to Memory
|
||||||
|
fpint EQU $DC9B ;Convert FAC1 to 32-bit Signed Integer in $62-$65
|
||||||
|
doint EQU $DCCC ;Perform INT
|
||||||
|
|
||||||
|
ascfp EQU $DCF3 ;Convert ASCII String to Floating Point Number
|
||||||
|
addbyt EQU $DD7E ;Add Signed Byte in A Register to FAC1
|
||||||
|
fpasc EQU $DDDD ;Convert Contents of FAC1 to ASCII String
|
||||||
|
dosqr EQU $DF71 ;Perform SQR
|
||||||
|
expont EQU $DF7B ;Perform ^
|
||||||
|
negfac EQU $DFB4 ;Perform - (Unary Minus)
|
||||||
|
doexp EQU $DFED ;Perform EXP
|
||||||
|
dorrnd EQU $E094 ;Perform RND
|
||||||
|
docos EQU $E261 ;Perform COS
|
||||||
|
dosin EQU $E268 ;Perform SIN
|
||||||
|
dotan EQU $E2B1 ;Perform TAN
|
41
include/vic/sounds.a02
Normal file
41
include/vic/sounds.a02
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
; C02 sounds library assembly routines for VIC-20
|
||||||
|
|
||||||
|
;beep() - Produce System Beep Sound
|
||||||
|
;Affects: A,Y
|
||||||
|
BEEP NOP ;Sound Bell
|
||||||
|
|
||||||
|
;Uses VIA Timer 2...
|
||||||
|
BEEPD: JSR $EF96 ;Delay YX Milliseconds
|
||||||
|
DEX
|
||||||
|
BPL BEEPD
|
||||||
|
DEY
|
||||||
|
BPL BEEPD
|
||||||
|
RTS
|
||||||
|
|
||||||
|
BEEPX: LDX #3 ;Turn off all Sound
|
||||||
|
BEEPXL: LDA #0 ;Store 0 in all four
|
||||||
|
STA $900A,X ; VIC Sound Registers
|
||||||
|
DEX
|
||||||
|
BPL BEEPXL
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;bomb() - Produce System Explosion Sound
|
||||||
|
;Affects: None
|
||||||
|
BOMB: RTS ;Function Not Available
|
||||||
|
|
||||||
|
;shoot() - Produce Shooting Sound
|
||||||
|
;Affects: None
|
||||||
|
SHOT: RTS ;Function Not Available
|
||||||
|
|
||||||
|
;tick() - Produce System Tick Sound
|
||||||
|
;Affects: None
|
||||||
|
TICK: LDA $C030 ;Click Speaker Once
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;tock() - Produce System Tock Sound
|
||||||
|
;Affects: None
|
||||||
|
TOCK: RTS ;Function Not Available
|
||||||
|
|
||||||
|
;zap() - Produce System Zap Sound
|
||||||
|
;Affects: None
|
||||||
|
ZAP: RTS ;Function Not Available
|
42
include/vic/template.h02
Normal file
42
include/vic/template.h02
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*********************************************************
|
||||||
|
* vector - 6502 Interrupt Vector Manipulation Functions *
|
||||||
|
*********************************************************/
|
||||||
|
|
||||||
|
/* Get Maskable Interrupt Address *
|
||||||
|
* Returns: $00 If Address can be *
|
||||||
|
* modified, otherwise $FF *
|
||||||
|
* Address MSB *
|
||||||
|
* Address LSB */
|
||||||
|
char getirq();
|
||||||
|
|
||||||
|
/* Get Non-Maskable Interrupt Address *
|
||||||
|
* Returns: $00 If Address can be *
|
||||||
|
* modified, otherwise $FF *
|
||||||
|
* Address MSB *
|
||||||
|
* Address LSB */
|
||||||
|
char getnmi();
|
||||||
|
|
||||||
|
/* Get "Reset" Interrupt Address *
|
||||||
|
* Returns: $00 If Address can be *
|
||||||
|
* modified, otherwise $FF *
|
||||||
|
* Address MSB *
|
||||||
|
* Address LSB */
|
||||||
|
char getrst();
|
||||||
|
|
||||||
|
/* Set Maskable Interrupt Address */
|
||||||
|
* Args: &d - New Interrupt Address *
|
||||||
|
* Returns: $00 If Successful, *
|
||||||
|
* otherwise $FF */
|
||||||
|
char setirq();
|
||||||
|
|
||||||
|
/* Set Non-Maskable Interrupt Address */
|
||||||
|
* Args: &d - New Interrupt Address *
|
||||||
|
* Returns: $00 If Successful, *
|
||||||
|
* otherwise $FF */
|
||||||
|
char setnmi();
|
||||||
|
|
||||||
|
/* Set "Reset" Interrupt Address */
|
||||||
|
* Args: &d - New Interrupt Address *
|
||||||
|
* Returns: $00 If Successful, *
|
||||||
|
* otherwise $FF */
|
||||||
|
char setrst();
|
82
include/vic/vectors.a02
Normal file
82
include/vic/vectors.a02
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
; C02 Interrupt Vector Assembly Language Routines for VIC-20
|
||||||
|
|
||||||
|
;getirq() - Return IRQ Interrupt Handler Address
|
||||||
|
;Returns: A = $00 - Software Definable Address
|
||||||
|
; Y = Address MSB
|
||||||
|
; X = Address LSB
|
||||||
|
GETIRQ: LDA #$00 ;Return software definable
|
||||||
|
LDX $0314 ;and Address in CINV
|
||||||
|
LDY $0315
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;getbrk() - Return BRK Interrupt Handler Address
|
||||||
|
;Returns: A = $00 - Software Definable Address
|
||||||
|
; Y = Address MSB
|
||||||
|
; X = Address LSB
|
||||||
|
GETBRK: LDA #$00 ;Return software definable
|
||||||
|
LDX $0316 ;and Address in CBINV
|
||||||
|
LDY $0317
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;getnmi() - Return NMI Interrupt Handler Address
|
||||||
|
;Returns: A = $00 - Software Definable Address
|
||||||
|
; Y = Address MSB
|
||||||
|
; X = Address LSB
|
||||||
|
GETNMI: LDA #$00 ;Return software definable
|
||||||
|
LDX $0318 ;and Address in CBINV
|
||||||
|
LDY $0319
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;getrst() - Return RESET Interrupt Handler Address
|
||||||
|
;Returns: A = $7F - Firmware Defined Address
|
||||||
|
; Y = Address MSB
|
||||||
|
; X = Address LSB
|
||||||
|
GETRST: LDX $FFFC ;Load 6502 Interrupt Vector
|
||||||
|
LDY $FFFD ;and Fall into SETRST
|
||||||
|
|
||||||
|
;setrst() - Set RESET Interrupt Handler Address
|
||||||
|
;Args: Y = Address MSB
|
||||||
|
; X = Address LSB
|
||||||
|
;Returns: A = $7F - Failure - Can't be Changed
|
||||||
|
SETRST: LDA #$7F ;Return "Hard Coded"
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;setirq() - Set IRQ Interrupt Handler Address
|
||||||
|
;Args: Y = Address MSB
|
||||||
|
; X = Address LSB
|
||||||
|
;Returns: A = $00 - Successfully Set
|
||||||
|
SETIRQ: SEI ;Disable Interrupts
|
||||||
|
STX $0314 ;Store Address in CINV
|
||||||
|
STY $0315
|
||||||
|
CLI ;Enable Interrupts
|
||||||
|
LDA #$00 ;Return "Modified"
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;setrst() - Set BRK Interrupt Handler Address
|
||||||
|
;Args: Y = Address MSB
|
||||||
|
; X = Address LSB
|
||||||
|
;Returns: A = $00 - Successfully Set
|
||||||
|
SETBRK: SEI ;Disable Interrupts
|
||||||
|
STX $0316 ;Store Address in CBINV
|
||||||
|
STY $0317
|
||||||
|
CLI ;Enable Interrupts
|
||||||
|
LDA #$00 Return "Modified"
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;setnmi() - Set NMI Interrupt Handler Address
|
||||||
|
;Args: Y = Address MSB
|
||||||
|
; X = Address LSB
|
||||||
|
;Returns: A = $00 - Successfully Set
|
||||||
|
SETNMI: STX $0318 ;Store Address in NMINV
|
||||||
|
STY $0319
|
||||||
|
LDA #$00 ;Return "Modified"
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;xitirq - Exit from IRQ Interrupt
|
||||||
|
;Exit IRQ if not Executing System IRQ Routine
|
||||||
|
XITIRQ: PLA ;Restore Y Register
|
||||||
|
TAY
|
||||||
|
PLA ;Restore Y Register
|
||||||
|
TAX
|
||||||
|
PLA ;Restore Accumulator
|
||||||
|
RTI ;Return from Interrupt
|
75
include/vic/vectors.h02
Normal file
75
include/vic/vectors.h02
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*********************************************************
|
||||||
|
* vector - 6502 Interrupt Vector Manipulation Functions *
|
||||||
|
*********************************************************/
|
||||||
|
|
||||||
|
/* Get BRK Handler Address *
|
||||||
|
* Returns: Status *
|
||||||
|
* $00 = modifiable *
|
||||||
|
* $7F = hard coded *
|
||||||
|
* $FF = unavailable *
|
||||||
|
* Address MSB *
|
||||||
|
* Address LSB */
|
||||||
|
char getbrk();
|
||||||
|
|
||||||
|
/* Get IRQ Handler Address *
|
||||||
|
* Returns: Status *
|
||||||
|
* $00 = modifiable *
|
||||||
|
* $7F = hard coded *
|
||||||
|
* $FF = unavailable *
|
||||||
|
* Address MSB *
|
||||||
|
* Address LSB */
|
||||||
|
char getirq();
|
||||||
|
|
||||||
|
/* Get NMI Handler Address *
|
||||||
|
* Returns: Status *
|
||||||
|
* $00 = modifiable *
|
||||||
|
* $7F = hard coded *
|
||||||
|
* $FF = unavailable *
|
||||||
|
* Address MSB *
|
||||||
|
* Address LSB */
|
||||||
|
char getnmi();
|
||||||
|
|
||||||
|
/* Get RESET Handler Address *
|
||||||
|
* Returns: Status *
|
||||||
|
* $00 = modifiable *
|
||||||
|
* $7F = hard coded *
|
||||||
|
* $FF = unavailable *
|
||||||
|
* Address MSB *
|
||||||
|
* Address LSB */
|
||||||
|
char getrst();
|
||||||
|
|
||||||
|
/* Set BRK Handler Address */
|
||||||
|
* Args: &d - New Address *
|
||||||
|
* Returns: Result *
|
||||||
|
* $00 = modifiable *
|
||||||
|
* $7F = hard coded *
|
||||||
|
* $FF = unavailable *
|
||||||
|
char setbrk();
|
||||||
|
|
||||||
|
/* Set IRQ Handler Address */
|
||||||
|
* Args: &d - New Address *
|
||||||
|
* Returns: Result *
|
||||||
|
* $00 = modifiable *
|
||||||
|
* $7F = hard coded *
|
||||||
|
* $FF = unavailable *
|
||||||
|
char setirq();
|
||||||
|
|
||||||
|
/* Set NMI Handler Address */
|
||||||
|
* Args: &d - New Address *
|
||||||
|
* Returns: Result *
|
||||||
|
* $00 = modifiable *
|
||||||
|
* $7F = hard coded *
|
||||||
|
* $FF = unavailable *
|
||||||
|
char setnmi();
|
||||||
|
|
||||||
|
/* Set RESET Handler Address */
|
||||||
|
* Args: &d - New Address *
|
||||||
|
* Returns: Result *
|
||||||
|
* $00 = modifiable *
|
||||||
|
* $7F = hard coded *
|
||||||
|
* $FF = unavailable *
|
||||||
|
char setrst();
|
||||||
|
|
||||||
|
/* Exit from IRQ Interrupt */
|
||||||
|
xitirq:
|
||||||
|
|
@ -4,6 +4,7 @@
|
|||||||
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
||||||
#define ESCKEY $03 //Escape/Break Key (STOP)
|
#define ESCKEY $03 //Escape/Break Key (STOP)
|
||||||
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
||||||
|
#define SYSBFL 88 //System Buffer Length
|
||||||
|
|
||||||
/* Standard Library Pointers */
|
/* Standard Library Pointers */
|
||||||
char srclo,srchi; //Source String Pointer for Library Functions
|
char srclo,srchi; //Source String Pointer for Library Functions
|
||||||
@ -20,6 +21,7 @@ char stkslo, stkshi; //Stack Start Address
|
|||||||
char stkelo, stkehi; //Stsck End Address
|
char stkelo, stkehi; //Stsck End Address
|
||||||
char random, rdseed; //Pseudo-Random Number Generation
|
char random, rdseed; //Pseudo-Random Number Generation
|
||||||
char temp0, temp1, temp2, temp3; //Temporary Storage
|
char temp0, temp1, temp2, temp3; //Temporary Storage
|
||||||
|
char sysbfr[], sysbfp; //System String Buffer and Position
|
||||||
|
|
||||||
/* System Subroutines */
|
/* System Subroutines */
|
||||||
void delchr(); //Delete previous character
|
void delchr(); //Delete previous character
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
||||||
#define ESCKEY $03 //Escape/Stop Key (STOP)
|
#define ESCKEY $03 //Escape/Stop Key (STOP)
|
||||||
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
||||||
|
#define SYSBFL 88 //System Buffer Length
|
||||||
|
|
||||||
//Library Pointer Variables
|
//Library Pointer Variables
|
||||||
char srclo,srchi; //Source String Pointer for Library Functions
|
char srclo,srchi; //Source String Pointer for Library Functions
|
||||||
@ -21,6 +22,7 @@ char stkslo, stkshi; //Stack Start Address
|
|||||||
char stkelo, stkehi; //Stsck End Address
|
char stkelo, stkehi; //Stsck End Address
|
||||||
char random, rdseed; //Pseudo-Random Number Generation
|
char random, rdseed; //Pseudo-Random Number Generation
|
||||||
char temp0, temp1, temp2, temp3; //Temporary Storage
|
char temp0, temp1, temp2, temp3; //Temporary Storage
|
||||||
|
char sysbfr[], sysbfp; //System String Buffer and Position
|
||||||
|
|
||||||
//System Subroutines
|
//System Subroutines
|
||||||
char polkey(); //Poll Console for character
|
char polkey(); //Poll Console for character
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
||||||
#define ESCKEY $03 //Escape/Stop Key (STOP)
|
#define ESCKEY $03 //Escape/Stop Key (STOP)
|
||||||
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
||||||
|
#define SYSBFL 88 //System Buffer Length
|
||||||
|
|
||||||
//Library Pointer Variables
|
//Library Pointer Variables
|
||||||
char srclo,srchi; //Source String Pointer for Library Functions
|
char srclo,srchi; //Source String Pointer for Library Functions
|
||||||
@ -21,6 +22,7 @@ char stkslo, stkshi; //Stack Start Address
|
|||||||
char stkelo, stkehi; //Stsck End Address
|
char stkelo, stkehi; //Stsck End Address
|
||||||
char random, rdseed; //Pseudo-Random Number Generation
|
char random, rdseed; //Pseudo-Random Number Generation
|
||||||
char temp0, temp1, temp2, temp3; //Temporary Storage
|
char temp0, temp1, temp2, temp3; //Temporary Storage
|
||||||
|
char sysbfr[], sysbfp; //System String Buffer and Position
|
||||||
|
|
||||||
//System Subroutines
|
//System Subroutines
|
||||||
char polkey(); //Poll Console for character
|
char polkey(); //Poll Console for character
|
||||||
|
@ -6,9 +6,9 @@ DELKEY EQU $14 ;Delete/Backspace Key (Delete)
|
|||||||
ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
|
ESCKEY EQU $03 ;Escape/Stop Key (RUN/STOP)
|
||||||
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
|
RTNKEY EQU $0D ;Return/Enter Key (RETURN)
|
||||||
|
|
||||||
;Zero Page System Variables - x16emu Release 34 Memory Map
|
; $00-$01 ;Miscellaneous Pointer
|
||||||
;UNUSED $00-$01 ;Available to User
|
; $02-$21 ;ABI Registers
|
||||||
; $02-$52 ;Used by Basic graphics commands
|
; $22-$52 ;Used by Basic graphics commands
|
||||||
XMBANK EQU $53 ;Extended Memory Bank
|
XMBANK EQU $53 ;Extended Memory Bank
|
||||||
XADRLO EQU $54 ;Ext Memory Address LSB
|
XADRLO EQU $54 ;Ext Memory Address LSB
|
||||||
XADRHI EQU $55 ;Ext Memory Address MSB
|
XADRHI EQU $55 ;Ext Memory Address MSB
|
||||||
@ -30,12 +30,16 @@ TEMP0 EQU $64 ;Temporary Variable
|
|||||||
TEMP1 EQU $65 ;Temporary Variable
|
TEMP1 EQU $65 ;Temporary Variable
|
||||||
TEMP2 EQU $66 ;Temporary Variable
|
TEMP2 EQU $66 ;Temporary Variable
|
||||||
TEMP3 EQU $67 ;Temporary Variable
|
TEMP3 EQU $67 ;Temporary Variable
|
||||||
; $68-7F ;Available to User
|
SYSBFP EQU $68 ;Position in System Buffer [Free Byte]
|
||||||
|
; $69-7F ;Available to User
|
||||||
; $80-$83 ;Used by Kernal and DOS
|
; $80-$83 ;Used by Kernal and DOS
|
||||||
; $A4-$A8 ;Reserved for KERNAL/DOS/BASIC
|
; $A4-$A8 ;Reserved for KERNAL/DOS/BASIC
|
||||||
; $A9-$FF ;Used by BASIC
|
; $A9-$FF ;Used by BASIC
|
||||||
|
|
||||||
;Other Variables - Top of Extended System RAM Area
|
;Other Constants
|
||||||
|
SYSBFL EQU 128 ;System Buffer Length
|
||||||
|
;Other Variables - User Storage Area
|
||||||
|
SYSBFR EQU $0700 ;System Buffer
|
||||||
BLKSLO EQU $07F4 ;Block Start LSB
|
BLKSLO EQU $07F4 ;Block Start LSB
|
||||||
BLKSHI EQU $07F5 ;Block Start MSB
|
BLKSHI EQU $07F5 ;Block Start MSB
|
||||||
BLKELO EQU $07F6 ;Block End LSB
|
BLKELO EQU $07F6 ;Block End LSB
|
||||||
@ -92,5 +96,5 @@ DELCHR: LDA #DELKEY ;Load Delete Character
|
|||||||
NEWLIN: LDA #RTNKEY ;Load Return Character
|
NEWLIN: LDA #RTNKEY ;Load Return Character
|
||||||
JMP PUTCHR ;Print and Return
|
JMP PUTCHR ;Print and Return
|
||||||
|
|
||||||
INCLUDE "../include/prbyte.a02" ;PRBYTE and PRHEX routine
|
INCLUDE "prbyte.a02" ;PRBYTE and PRHEX routine
|
||||||
INCLUDE "../include/putstr.a02" ;PUTSTR routine
|
INCLUDE "putstr.a02" ;PUTSTR routine
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
/* C02 System Header file for Commander X16 */
|
/* C02 System Header file for Commander X16 */
|
||||||
|
|
||||||
/* Platform Specific Settings */
|
/* Platform Specific Settings */
|
||||||
#pragma zeropage $68 //Unused Zero Page - $68-$7F
|
#pragma zeropage $69 //Unused Zero Page - $69-$7F
|
||||||
|
|
||||||
/* Platform Specific Constants */
|
/* Platform Specific Constants */
|
||||||
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
#define DELKEY $14 //Delete/Backspace Key (DEL)
|
||||||
#define ESCKEY $03 //Escape/Break Key (STOP)
|
#define ESCKEY $03 //Escape/Break Key (STOP)
|
||||||
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
#define RTNKEY $0D //Return/Enter Key (RETURN)
|
||||||
|
#define SYSBFL 128 //System Buffer Length
|
||||||
|
|
||||||
/* Standard Library Pointers */
|
/* Standard Library Pointers */
|
||||||
zeropage char srclo,srchi; //Source Pointer for Library Functions
|
zeropage char srclo,srchi; //Source Pointer for Library Functions
|
||||||
@ -24,22 +25,22 @@ char blklen; //Block Segment Length
|
|||||||
char stkslo,stkshi; //Stack Start Address
|
char stkslo,stkshi; //Stack Start Address
|
||||||
char stkelo,stkehi; //Stsck End Address
|
char stkelo,stkehi; //Stsck End Address
|
||||||
char random,rdseed; //Pseudo-Random Number Generation
|
char random,rdseed; //Pseudo-Random Number Generation
|
||||||
char temp0,temp1,temp2,temp3; //Temporary Storage
|
|
||||||
char xmbank; //Physical Bank
|
char xmbank; //Physical Bank
|
||||||
|
char temp0,temp1,temp2,temp3; //Temporary Storage
|
||||||
|
char sysbfr[], sysbfp; //System String Buffer and Position
|
||||||
|
|
||||||
/* System Subroutines */
|
/* System Subroutines */
|
||||||
void delchr(); //Delete previous character
|
void delchr(); //Delete previous character
|
||||||
char getkey(); //Read ASCII character from Keyboard
|
char getkey(); //Read ASCII character from Keyboard
|
||||||
char getpos(); //Get Cursor Position
|
|
||||||
char getsiz(); //Get Screen Size
|
|
||||||
void newlin(); //Advance cursor to beginning of next line
|
void newlin(); //Advance cursor to beginning of next line
|
||||||
char polkey(); //Poll Keyboard for character
|
char polkey(); //Poll Keyboard for character
|
||||||
char putchr(); //Print ASCII character to Keyboard
|
char putchr(); //Print ASCII character to Screen
|
||||||
void prbyte(); //Print Accumulator as Hexadadecimal number
|
void prbyte(); //Print Accumulator as Hexadadecimal number
|
||||||
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
void prhex(); //Print Low Nybble of Accumulator as Hex Digit
|
||||||
char getchr(); //Wait for character from Keyboard
|
char getchr(); //Wait for character from Keyboard
|
||||||
void setpos(); //Set Cursor Position
|
void putstr(); //Print String to Screen
|
||||||
|
|
||||||
//System Labels
|
//System Labels
|
||||||
start: //Start of Code
|
start: //Start of Code
|
||||||
exit: //Return to Operating System
|
exit: //Return to Operating System
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user