Sensing STOP key

Page 1/2
| 2

By Eugeny_Brychkov

Paragon (1232)

Eugeny_Brychkov's picture

22-06-2017, 19:40

I am writing routine outputting a lot of text onto the screen. Initially I though to count number of lines, but it became too complicated. Next though was that user will press STOP key when needed.

And there's a bump. I know the call which tests for CTRL-STOP, but can not find standard way to check for STOP key so that I suspend output. STOP key does not have character code, thus I can not poll buffer for it.

Any ideas?

Login or register to post comments

By NYYRIKKI

Enlighted (6016)

NYYRIKKI's picture

22-06-2017, 19:49


snsmat	equ #141

pause_on_stop:

	ld a,7
	call snsmat
	and 16
	ret nz
.loop1
	ld a,7
	call snsmat
	and 16
	jr z,.loop1
.loop2
	ld a,7
	call snsmat
	and 16
	jr nz,.loop2
.loop3
	ld a,7
	call snsmat
	and 16
	jr z,.loop3
	ret

By Latok

msx guru (3925)

Latok's picture

22-06-2017, 19:49

In the keyboard matrix, the STOP key is bit 4 at address &HFBEC.

If STOP key isn't pressed, this bit is 1. If the STOP key is pressed, this bit will be 0.

By Eugeny_Brychkov

Paragon (1232)

Eugeny_Brychkov's picture

22-06-2017, 20:00

One issue with this program - it must also sense CTRL-STOP and exit immediately if it is pressed in suspended mode.

Any system call like this? I hardly believe it is not there! (Almost) Everything in BASIC is being represented with system calls Smile

By NYYRIKKI

Enlighted (6016)

NYYRIKKI's picture

22-06-2017, 20:07

Well... you can either check the CTRL first with same way (Row 6, Bit 1 / one earlier byte in RAM) or you can call BREAKX (#B7) first to check CTRL+STOP status.

By Latok

msx guru (3925)

Latok's picture

22-06-2017, 20:09

CTRL is bit 1 at &HFBEB. I would just check if both bit 1 at &HFBEB and bit 4 at &HFBEC are set to 0 and if yes, then exit. If only bit 4 at &HFBEC is 0 then I would suspend text output....

But probably I am missing something here? Please help me out, thx Smile

By NYYRIKKI

Enlighted (6016)

NYYRIKKI's picture

22-06-2017, 20:15

In BASIC you can use ISCNTC (#BA) but it does all kind of other stuff as well such as erase cursor, clear keyboard buffer, check if CTRL+STOP is disabled, execute ON STOP GOSUB etc.

By Eugeny_Brychkov

Paragon (1232)

Eugeny_Brychkov's picture

22-06-2017, 20:16

Ok, solution found by scanning MSX Red Book.

    Address ... 03FBH (from 00BAH)
    Name ...... ISCNTC (Is Control-stop)
    Input ..... None
    Exit ...... None
    Modifies .. AF, EI
Quote:

Standard routine to check whether the CTRL-STOP or STOP keys have been pressed. It is used by the BASIC Interpreter at the end of each statement to check for program termination. BASROM is first examined to see if it contains a non-zero value, if so the routine terminates immediately. This is to prevent users breaking into any extension ROM containing a BASIC program.

INTFLG is then checked to determine whether the interrupt handler has placed the CTRL-STOP or STOP key codes (03H or 04H) there. If STOP has been detected then the cursor is turned on (09DAH) and INTFLG continually checked until one of the two key codes reappears. The cursor is then turned off (0A27H) and, if the key is STOP, the routine terminates.

I tested, it works! I must say that "MSX system call" info pages do not list this functionality of ISCNTC call.

By MsxKun

Paragon (1115)

MsxKun's picture

22-06-2017, 20:52

What Latok said, that simple.
But only if you have interrupts and BIOS enabled.

By djh1697

Paragon (1695)

djh1697's picture

22-06-2017, 21:05

A long time ago, i wrote a BASIC program, the command 'poke BASROM,1' to disable the STOP and CTRL STOP functions, I forgot to save the program before running it. I kicked myself!

By Latok

msx guru (3925)

Latok's picture

22-06-2017, 22:04

Isn't that done with poke &hfbb1,1? It disables a running BASIC program to be stopped with ctrl+stop...

Page 1/2
| 2