Quantcast
Channel: stardot.org.uk
Viewing all articles
Browse latest Browse all 3292

8-bit acorn hardware • Re: Time & Config.

$
0
0
The obvious thing is to implement a new event. It's a great pity that BASIC doesn't have an ON EVENT GOSUB command similar to ON ERROR GOTO, but even without this, I think events are the most useful way to do it.
Kicking off an event is simple enough (JSR OSEVNT). I'm having vauge fuzzy memories of a magazine article that let you register a BASIC subroutine for the interpreter to call on an event. I'm vaugely remembering something like:

IF FNcatch(blah):....

and the subroutine would set something up, and return FALSE so the program continued, and when the event occured it would fake returning from the subroutine with TRUE so the .... would be executed. The hardest part, of course, is finding a clean place to branch out of the interpreter. You can't just leap off arbitarilty, the interpreter could be in the middle of, for example, incrementing VAREND or something.

The only regular clean "polling" the interpreter does is check the Escape flag between instructions. I suppose a way to "fake" a BASIC event is to trap OSBYTE 126, set the Escape flag, catch BASIC calling OSBYTE 126, clear the Escape flag, untrap OSBYTE 126, do your "ON EVENT" call, fiddle the return address from the OSBYTE call to prevent BASIC continuing into the "Escape" error, then return back.

Statistics: Posted by jgharston — Fri Jan 24, 2025 6:11 pm



Viewing all articles
Browse latest Browse all 3292

Trending Articles