[Coco] Color BASIC and "CURLIN" (direct versus in a program)
Allen Huffman
alsplace at pobox.com
Fri Oct 24 14:20:34 EDT 2025
> On Oct 23, 2025, at 11:56 PM, William Astle via Coco <coco at maltedmedia.com> wrote:
>
> Have you considered hooking the line input RAM vector. Then check the return address to see if it's $AC7F? If so, you can force CURLIN to $FFFF. Then just continue to whatever else may have hooked that RAM vector. That will catch immediate mode and also ASCII basic program loads. (ASCII program loads just open the file, set DEVNUM to that file, then transfer control to immediate mode.)
I have a check at my PUTCHR routine to only work if DEVNUM is 0. Would that suffice in blocking this from happening to an ASCII save?
Which vector are you referring to for LINE INPUT?
RVEC12 - INPUTTING A BASIC LINE
I see AC7F right after this:
LAC7C JSR LA390
LDU #FFFF *AC7F is this
STU CURLIN
Then that LA390 calls the RAM hook
LA390 JSR RVEC12
My attempt to check for CURLIN FFFF will work but not for the FIRST line after the program stops, which is annoying but maybe good enough.
But my hack to check for “direct” mode is cumbersome and surely can be made smarter:
* Do this only if NOT in Direct mode. Problem: After a BREAK, CURLIN
* has not been updated yet, so the very first line you type will be
* processing the special characters. Lines after that will not. Trying
* to find a different way to detect this.
pshs a save A
lda CURLIN GET CURRENT LINE NUMBER (CURLIN)
inca TEST FOR DIRECT MODE
puls a restore A
beq continue if 0, in direct mode.
I don’t know what registers are safe to use. And this would be done for EVERY byte output to the console, but I guess there is not much I can do about that unless I can set my own global flag of “direct mode” versus “program is running mode” and just check that one flag. Maybe that’s a better way.
> As a caution: LIST can be executed within a program. It will fall back to immediate mode after running, but you may need a way to trap that, too. The same thing can happen with SAVE and CSAVE in ASCII mode which just open the file, set DEVNUM, and call LIST.
Ah, I hadn’t considered LIST from a program. I think the SAVE stuff is taken care of with a check against DEVNUM 0.
Basically, I only want to filter if it is being done by a PRINT command. Not sure if there is a way to hijack PRINT.
— Allen
More information about the Coco
mailing list