[Z88dk-users] Control codes, bit more info?

Bridge to the z88dk-users mailing list
Post Reply
thricenightly
Member
Posts: 28
Joined: Thu Jun 01, 2017 5:46 pm

[Z88dk-users] Control codes, bit more info?

Post by thricenightly »

I was playing with control codes using crt1 on the Spectrum. I get the gist, but was puzzled by the flash code. I tried:

Code: Select all

\x12\x01Hello\x12\x00, world!
thinking the \x12\x01 would turn flash on, and \x12\x00 would turn it off again. What actually happens is that the "Hello" flashes, but the ", world!" doesn't appear at all!

What's going on? What's the sequence for turning off flash? And is this documented somewhere?



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I was playing with control codes using crt1 on the Spectrum. I get the gist, but was puzzled by the flash code. I tried:

Code: Select all

\x12\x01Hello\x12\x00, world!
thinking the \x12\x01 would turn flash on, and \x12\x00 would turn it off again. What actually happens is that the "Hello" flashes, but the ", world!" doesn't appear at all!

What's going on? What's the sequence for turning off flash? And is this documented somewhere?
Details are in:

{z88dk}/doc/zxscrdrv.txt

Existing wiki:

https://www.z88dk.org/wiki/doku.php?id=platform:zx

Wiki under creation:

https://github.com/z88dk/z88dk/wiki/Pla ... X-Spectrum

In a nutshell, since \0 is the end of string marker, the values are offset by 0x30 so that digits ('0' - '7') can be used.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
thricenightly
Member
Posts: 28
Joined: Thu Jun 01, 2017 5:46 pm

Post by thricenightly »

I was playing with control codes using crt1 on the Spectrum. I get the gist, but was puzzled by the flash code. I tried:

Code: Select all

\x12\x01Hello\x12\x00, world!
thinking the \x12\x01 would turn flash on, and \x12\x00 would turn it off again. What actually happens is that the "Hello" flashes, but the ", world!" doesn't appear at all!

What's going on? What's the sequence for turning off flash? And is this documented somewhere?
Details are in:

{z88dk}/doc/zxscrdrv.txt

Existing wiki:

https://www.z88dk.org/wiki/doku.php?id=platform:zx

Wiki under creation:

https://github.com/z88dk/z88dk/wiki/Pla ... X-Spectrum

In a nutshell, since \0 is the end of string marker, the values are offset by 0x30 so that digits ('0' - '7') can be used.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Heh, \0, yes, OK. I've got that working now.

One more question: which wiki is the one to reference in other documentation? I'm (slowly) doing another getting started guide. Which of those two links is the one to put in it?



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Heh, \0, yes, OK. I've got that working now.

One more question: which wiki is the one to reference in other documentation? I'm (slowly) doing another getting started guide. Which of those two links is the one to put in it?
Dom's supplied the links for the classic library.

If you're doing the new library the print codes are documented in the tty directories in https://github.com/z88dk/z88dk/tree/mas ... r/terminal . You have to use a driver that does tty_z88dk which is startup=1 (32 col), startup=5 (64 col), startup=9 (fzx).

The offset to get around \0 terminator has not been implemented in the newlib ( https://github.com/z88dk/z88dk/issues/227 ) but it needs to be fixed and can be done quickly if you are writing about it. Because the offset is not implemented you can send control codes via write() or putc() atm. The newlib can also send commands to the driver via ioctl().

You have to be careful with strings like this:

\x12\x01Hello\x12\x00, world!

because hex constants are greedily consumed by the compiler. It's maybe safer to split into strings to avoid unintended bugs:

"\x12\x01" "Hello" "\x12\x00" ", world!"



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
thricenightly
Member
Posts: 28
Joined: Thu Jun 01, 2017 5:46 pm

Post by thricenightly »

Heh, \0, yes, OK. I've got that working now.

One more question: which wiki is the one to reference in other documentation? I'm (slowly) doing another getting started guide. Which of those two links is the one to put in it?
Dom's supplied the links for the classic library.

If you're doing the new library the print codes are documented in the tty directories in https://github.com/z88dk/z88dk/tree/mas ... r/terminal . You have to use a driver that does tty_z88dk which is startup=1 (32 col), startup=5 (64 col), startup=9 (fzx).

The offset to get around \0 terminator has not been implemented in the newlib ( https://github.com/z88dk/z88dk/issues/227 ) but it needs to be fixed and can be done quickly if you are writing about it.
Ah, right. Yes, I should have said, I'm working exclusively with the new library, and yes, I'll be submitting another getting-started document in due course. If the offset issue can be changed before I submit that would remove the correction requirement which would become part of that work. But it's not that big a deal in the scheme of things. I've subscribed to the issue.

When you say "the print codes are documented in the tty directories" do you mean "the print codes can be deduced from the filenames in the tty directories"? For example, in zx_01_output_char_32_tty_z88dk/ there's a file named zx_01_output_char_32_tty_z88dk_18_flash.asm which links the "flash" control to the number "18". Is that how it can be interpreted or am I missing something more obvious?



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Ah, right. Yes, I should have said, I'm working exclusively with the new library, and yes, I'll be submitting another getting-started document in due course. If the offset issue can be changed before I submit that would remove the correction requirement which would become part of that work. But it's not that big a deal in the scheme of things. I've subscribed to the issue.
I'll see if I can fix it up tonight. The classic lib is adding the 0x30 offset for coordinates but I'm leaning toward 1-based coordinates instead which is what ansi terminals use, as does the ansi driver in the classic lib. For true/false values I'm looking at using 1 for false. A sensible choice might have been 255 but given false/true is normally 0/1, adding 255 to that, as might happen if writing true/false into a string, would yield 255/0, so another 0 value that would foul up strings.

When you say "the print codes are documented in the tty directories" do you mean "the print codes can be deduced from the filenames in the tty directories"? For example, in zx_01_output_char_32_tty_z88dk/ there's a file named zx_01_output_char_32_tty_z88dk_18_flash.asm which links the "flash" control to the number "18". Is that how it can be interpreted or am I missing something more obvious?
That's right - you can read the control codes from the filenames. The 32 column tty will be a complete list but if you look at the 64 column tty driver there is only one code there and that's because it's reusing the 32 column code. The exact list is in the *_oterm_msg_tty file in the action table as a list of defw.

There's no proper documentation for this as the drivers are meant to see a rewrite when disk io is added.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

I forgot to mention a little about ioctl(). ioctl() sends out-of-band commands to a driver attached to file descriptors (ie 0=stdin, 1=stdout, 2=stderr, etc). The output terminals can understand a set of ioctls to manage many things. These ioctls use 0/1 as false/true, can accept a new value and often return the old one, and can treat a value as special meaning nothing is changed so that the user can inquire a current setting.

Unfortunately the set of ioctls are not formally documented either but they are listed in each driver.

The drivers are located in the .asm files of this directory: https://github.com/z88dk/z88dk/tree/mas ... r/terminal and the ioctls each understand are listed in comments.

Eg, for the plain 32-column output driver : https://github.com/z88dk/z88dk/blob/mas ... 32.asm#L82

There are a couple of example programs using ioctl, one of which is here: https://github.com/z88dk/z88dk/blob/mas ... inals_x2.c and another here: https://github.com/z88dk/z88dk/blob/mas ... password.c . This last one does edit buffer stuffing and password mode on the input terminal.

Maybe this is something best mentioned rather than spoken of in detail.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Post Reply