[Coco] Intercepting commands like POKE?
Jim McClanahan
jim30109 at gmail.com
Thu Jan 4 10:48:19 EST 2024
I'm more familiar with MS's 6502 BASIC and it has been a while since I dug
into either, but there is a routine that gets called each time BASIC is
ready to fetch the next command down in Page Zero. (In Extended BASIC, it
looks like it is at $009F.) That is set up when BASIC initializes, but you
can change it to call another routine. I've done that to implement a
"trace" function (showing the line number currently being executed each
time it changes). Basically (no pun intended) you just have to fetch the
next tokenized (or non-tokenized) character that is going to be executed
and see if it is one you want to do something with. As long as you
increment the pointers and handle things like they need to be handled (for
example, if you intercept POKE, you need to be responsible for pulling the
next two arguments also) it is fairly seamless. If it isn't one you want to
do anything with, you just jump back into the regular execution routine.
The times I've messed with it, I've either been doing something like the
trace example or I've added my own "token" to intercept (like looking for a
"!" as the next character and then pulling a command from the characters
after that). In using something like a "!", you don't have to worry about
it showing up inside quotes after a print command because when the print
token gets parsed and processed, the routine runs through the command line
and prints what it needs to and you either get pointed to the next line
with the next call through the Page Zero routine or to the ":" on a line
with multiple commands.
Thanks,
Jim W4JBM
On Thu, Jan 4, 2024 at 10:21 AM Allen Huffman via Coco <coco at maltedmedia.com>
wrote:
> Hey there. I toyed with ROM/RAM hooks a bit, and learned how to intercept
> the CONSOUT character output routine:
>
> https://subethasoftware.com/2022/07/26/color-basic-ram-hooks/
>
> I have a project where I’d like to intercept things like PRINT@ and POKE.
> Does anyone here know anything about that? I don’t even know where to
> begin, outside of using a 64K machine and going in to ROM-to-RAM mode and
> just patching BASIC.
>
> --
> Allen Huffman - PO Box 7634 - Urbandale IA 50323 - 515-999-0227 (vmail/TXT
> only)
> http://www.subethasoftware.com - https://www.facebook.com/subethasoftware
> http://www.PayPal.me/AllenHuffman.
> http://swagbucks.com/refer/allenhuffman
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>
More information about the Coco
mailing list