[Coco] Color BASIC and "CURLIN" (direct versus in a program)

William Astle lost at l-w.ca
Fri Oct 24 14:56:17 EDT 2025


On 2025-10-24 12:20, Allen Huffman wrote:
> 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?

On an ASCII save, it should. It should also handle LLIST.

> Which vector are you referring to for LINE INPUT?

RVEC12 would be right. You can clobber X in this case. You would check 
4,s to see if it's $AC7F. If it is, you just set CURLIN to $FFFF. This 
works around the unfortunate ordering of the instructions in the 
immediate mode loop. I think there's actually a reason for it but I 
can't remember now what it is. This little hack would solve the problem 
for the first line after the program exits. This works because INPUT and 
LINE INPUT which both call the same $A390 routine, but from different 
places (and they cannot be run from immediate mode).

> 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.

For PUTCHR, *all* registers need to be preserved (except CC). Your test 
for immediate mode should be reasonable.

> 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.

The check won't slow things down much and a global flag won't be all 
that much faster.

> 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.

You can theoretically intercept PRINT but it's truly miserable to do if 
you need to do anything on actual character output. But you might be 
able to intercept PRINT, set a flag, and then intercept the command 
interpretation loop to reset the flag before command dispatch. That's a 
bit weird to accomplish, but it's doable.

You can check how Extended Basic intercepts CLOADM or how Disk Basic 
intercepts PMODE to figure out how you might set a flag based on whether 
PRINT is running.


More information about the Coco mailing list