Extending BASIC
Posted: Mon Dec 23, 2013 2:41 pm
This is about extending BASIC 83B to include new functions with relative ease.
The first problem to me was that the existing BASIC83B CART was located at $7000-$7FFF and $A000-$BFFF. This left a gap of 8K of nothing.
My solution to this was to 'rebase' the lower 4K to $9000. So now the CART is 16k in size, located at $8000-$BFFF. This gives 4K for extensions!
BASIC83B uses a table based look up to find the next reserved word. To make life easy, I also relocated this to $8000. This means there's still 100 or so bytes free at $9EFF, should we fill the extension 4k!
To assemble your own, you will need DASM, or a DASM compatible assembler.
Hopefully, the included sample function "CALL" will be enough to get you started.
CALL extension
You must include a RTS ($60) at the end of your function.
Simplest example
PRAT Example
Edit: v1.3 - Changed table layout and pointers, no longer need to update offsets at $Bxxx.
Edit: Fixed PEEK indexed record to $9C in offset table. Also added ? print short cut to save space, and some new equates in the .s
Edit: Speed up line load.
Edit: Added PRintAT
Edit: Added VPOKE and sprite stuff
Edit: Added VREG, VSAVE and VLOAD
Edit: Added VPK and function support
The first problem to me was that the existing BASIC83B CART was located at $7000-$7FFF and $A000-$BFFF. This left a gap of 8K of nothing.
My solution to this was to 'rebase' the lower 4K to $9000. So now the CART is 16k in size, located at $8000-$BFFF. This gives 4K for extensions!
BASIC83B uses a table based look up to find the next reserved word. To make life easy, I also relocated this to $8000. This means there's still 100 or so bytes free at $9EFF, should we fill the extension 4k!
To assemble your own, you will need DASM, or a DASM compatible assembler.
Hopefully, the included sample function "CALL" will be enough to get you started.
CALL extension
You must include a RTS ($60) at the end of your function.
Simplest example
Code: Select all
10 POKE 640,96
20 CALL 640
Code: Select all
PRAT 10,4,"HELLO WORLD!"
Syntax: PRAT column, row, output
Uses original PRINT function, so if you can print it, you can PRAT it.
Edit: Fixed PEEK indexed record to $9C in offset table. Also added ? print short cut to save space, and some new equates in the .s
Edit: Speed up line load.
Edit: Added PRintAT
Edit: Added VPOKE and sprite stuff
Edit: Added VREG, VSAVE and VLOAD
Edit: Added VPK and function support