CTRL+STOP disabling

By MicroTech

Champion (385)

MicroTech's picture

11-01-2007, 12:19

Maybe already answered somewhere else but I didn't find...

In my application I need to switch from DOS(2) to BASIC environment and back.
I wish to prevent the user from breaking the execution with CTRL+STOP.

BASIC -> DOS:
I could poke at 0xFBB1,1 but there is a moment during the execution of CALL SYSTEM(MYPROG.COM) where user is allowed to break.

DOS -> BASIC
To switch to basic I would use a BASIC MYPROG.BAS instruction as last statement of a .BAT or I would place the "BASIC MYPROG.BAS" string in the keyboard buffer but, still, there is a moment when CTRL+STOP is enabled.

How could I prevent this from happening?

Thanks
MicroTech

Login or register to post comments

By foske

Resident (36)

foske's picture

11-01-2007, 16:19

don't know whether this works, don't have the BIOS listing at hand:

catch hook H.KEYC or H.KYEA and disable keyboard input or catch ctrl-STOP there.
restore the hook after switching

By MicroTech

Champion (385)

MicroTech's picture

22-01-2007, 15:24

Sorry for the late answer but I was busy with other (related) problems.

catch hook H.KEYC or H.KYEA and disable keyboard input or catch ctrl-STOP there.
restore the hook after switching

How can I disable keyboard input?

I've found the following:

Basic->DOS: is "CTRL+STOP safe" with the sequence
POKE &HFBB1,1
CALL SYSTEM("myprog.bat")

DOS->Basic: CTRL+STOP can be catched within my application with DOS call 0x63 (_DEFAB) when A = 0x9F (.STOP) or 0x9E (.CTRLC).
Unfortunately the first call to console-related function (e.g. AUXIN) seems to "remember" that a CTRL+STOP has been pressed and execution stops until a key is pressed.
How can this be avoided Question
I could simply don't call console functions but I should rewrite a my own getc and putc (I'm using Ascii C)

By turbor

Champion (490)

turbor's picture

22-01-2007, 16:34

Only a wild guess but:
If I remember correctly the standard bios keeps a counter somewhere in the system variables, if this counter reaches zero the keyboard is scanned. So if you use the interrupt hook and always place this keyboard variable at a non-zero value then the keyboard will never be scanned and the CRTL+STOP will not be remembered neither....
The only save place to put this rouine will probably be page 3 below the system vars since basic <-> dos will start remapping the other pages while page 3 is always visible and never changes. If you're sure that no TSR's are running then the buffer used by the play command might be a safe place.

By foske

Resident (36)

foske's picture

23-01-2007, 10:43

When you hook H.KEYC you can mask the STOP key. All you have to do is mask the bit indicating the STOP key on the correct row. This way the BIOS will never detect you pressed the stop key. When switching from DOS to BASIC or vice versa you are in text mode, which means you can also use the graphical variables in page 3.

By foske

Resident (36)

foske's picture

23-01-2007, 10:50

You can disable the entire keyboard by catching the hook and changing the right registers (or make H.HEYC pop the return address before a RET, so it returns to the caller of the keyboard handler instead of the handler itself)

I will write some code tonight if I can find my assembler :-)

By MicroTech

Champion (385)

MicroTech's picture

23-01-2007, 14:54

Thanks for your suggestions.
I think I'll reroute H.TIMI (0xFD9F) to jump to VOICAQ (0xF975) where my isr sets bit 4,(OLDKEY + 7).
I don't use PLAY commands so this trick should prevent STOP key from appearing to be pressed (both in BASIC, DOS and environment change).
Now I try...

By MicroTech

Champion (385)

MicroTech's picture

25-01-2007, 12:40

Tried!
It works but when autorepeat starts OLDKEY is reset inside BIOS and STOP key, if pressed, is detected.
So I disabled keyboard autorepeat in my isr checking REPCNT (0xF3F7) and preventing it from reaching 0 (autorepeat will never start).
Still thanks for your help Hannibal