Page 1 of 2

ZX80: ersatz PAUSE and PRINT AT?

Posted: Mon Dec 06, 2021 2:29 pm
by TMD2003
I am being somewhat thwarted by the ZX80's extreme simplicity again.

My overall question is: "is there any way to keep a picture on screen for a specific length of time on the ZX80?"

I had some thoughts, knowing that FOR N=1 TO 1000: NEXT N would just blank the screen. I looked for the ZX80's equivalent of FRAMES in the system variables, POKE both bytes to 0, then wait for the value to increase to a certain point - but not only does that blank the screen, it also never gets raised above 0 so this is a loop that will only end with BREAK.

I also tried repeated PRINT CHR$(116), i.e. HOME, which I thought would reset the equivalent of the PRINT AT position to 0,0 - but it affects the program cursor instead. Even so, would it work? No. It printed a question mark. The same happened with CHR$(112), the cursor-up character. So we can't control the PRINT AT position that way, Commodore-style.

While fiddling around with the potential for a PRINT AT on the ZX80, I thought I'd POKE the system variables 16420 and 16421, even though the manual says not to (they're marked with an X for "DO NOT POKE"). POKE 16420,33 and POKE 16421,23 should, as I understood it, return the PRINT AT position to 0,0 - but the POKEs have no effect on the PRINT position - all it did is made the error report invisible.

This thread from 2014 implies "PAUSE is impossible, and also, it is possible". It will take the ZX80 *some time* to keep doing loops, and all I have to do is work out how many times it needs to loop. But there's still that problem of the screen shutting off while it happens. The thread also mentions making input requests to the keyboard...

So my thoughts turned to machine code. Is there a way of printing non-printable characters to the screen - is there even a non-printable character that would not appear as a question mark - that could be deposited on screen with RST 16 (or POKE directly to the screen), and controlled by a BC loop, which in turn might be inside another BC loop? Is there a way of shifting the PRINT AT position from a ROM call that I'm unaware of? And is any of this going to be possible without the screen blanking, without digging very deep into the "flicker-free graphics" that are way, way beyond my understanding?

The only way I can find to PRINT AT is to POKE directly to the display file, but it seems to change depending on what else I've done. So, for instance:

10 PRINT "BOB"
20 LET X=PEEK(16396)+256*PEEK(16397)
30 POKE X+6,41

...this changes BOB to BOD, requiring an adjustment of 6 to the PEEKed D_FILE to PRINT AT 0,2;"D". However, if we try to POKE directly without a variable...

10 PRINT "BOB"
20 POKE 3+PEEK(16396)+256*PEEK(16397),41

...this has the same effect; only an adjustment of 3 is needed.

It's the same result with 1K, 4K or 16K - unlike the ZX81.

Any bright ideas, ZX80 experts? I'm out of options.

Re: ZX80: ersatz PAUSE and PRINT AT?

Posted: Mon Dec 06, 2021 7:06 pm
by 1024MAK
As far as I am aware, the only time the ZX80 BASIC will produce a screen display is if either it is waiting for input (waiting at the line editor for a command or new line, waiting for the user to type something at an INPUT command) or displaying a status/error message.

The FRAMES counter only increases when a video picture is being generated, and as that only happens when the ZX80 BASIC is waiting for user input as described above…

The ZX80 always operates with a the equivalent of a collapsed display file, regardless of available RAM. So this makes directly manipulating it from BASIC rather tricky.

Plus look at where it is in the memory map:

Code: Select all

ZX80 Memory Map
  4000..4027                System Area
  4028..(4008)-1            Basic Program
  (4008)..(4004 or 400A)-1  VARS
  (4004 or 400A)..(400C)-1  Input Buffer, and probably something else ???
  (400C)...                 VRAM
  ...
Yes, after everything else apart from the Z80 machine stack. Hence every time the length of the variables section or the input buffer changes, so will the position of the display file/VRAM area…

To get a ZX80 to execute code and display a stable image requires cycle perfect timing of machine code. However, it should be possible to produce some simpler code that does the equivalent of a combined pause and inkey$.

Mark

Re: ZX80: ersatz PAUSE and PRINT AT?

Posted: Sun Dec 19, 2021 8:41 pm
by TMD2003
1024MAK wrote: Mon Dec 06, 2021 7:06 pm To get a ZX80 to execute code and display a stable image requires cycle perfect timing of machine code. However, it should be possible to produce some simpler code that does the equivalent of a combined pause and inkey$.
I think I've had it on this front. It's not even a PAUSE and INKEY$ I need, just a PAUSE for a specific time without the need to interrupt it. The code to make it happen, at this stage, is beyond me.

Re: ZX80: ersatz PAUSE and PRINT AT?

Posted: Mon Dec 20, 2021 12:08 am
by Fruitcake
TMD2003 wrote: Sun Dec 19, 2021 8:41 pm It's not even a PAUSE and INKEY$ I need, just a PAUSE for a specific time without the need to interrupt it.
If it is just a pause routine you need that is callable from BASIC then check out the ZX80 Active Display routine by Macronics that appeared in the book Making The Most Of Your ZX80 (program 50).

Re: ZX80: ersatz PAUSE and PRINT AT?

Posted: Mon Dec 20, 2021 10:29 am
by TMD2003
That's certainly got my attention.

*cracks knuckles*

Come here, ZX80, I've got a job for you...

Re: ZX80: ersatz PAUSE and PRINT AT?

Posted: Mon Dec 20, 2021 12:39 pm
by Fruitcake
There was also a pause routine published in Personal Computer World magazine February 1981.


Re: ZX80: ersatz PAUSE and PRINT AT?

Posted: Mon Dec 20, 2021 1:29 pm
by TMD2003
I've tried Tim Hartnell's program, and it seems to be working. I've just loaded into my own program... let's see if it will work now! I've disassembled the code - it's full of ROM calls, and an INC IY at the end that seems very out of place (there are no other index register instructions in this listing, so it must be something to do with one of those ROM calls) and I've found no absolute jumps or calls to within the listing. There's no reason it shouldn't work now...

Re: ZX80: ersatz PAUSE and PRINT AT?

Posted: Mon Dec 20, 2021 1:55 pm
by Moggy
Fruitcake wrote: Mon Dec 20, 2021 12:08 am
TMD2003 wrote: Sun Dec 19, 2021 8:41 pm It's not even a PAUSE and INKEY$ I need, just a PAUSE for a specific time without the need to interrupt it.
If it is just a pause routine you need that is callable from BASIC then check out the ZX80 Active Display routine by Macronics that appeared in the book Making The Most Of Your ZX80 (program 50).
Is the file for this modified by your self Paul in someway? I have the original book and cannot get the listing to work without crashing and did read somewhere that the listing as printed is in error. I have another of Hartnell's book that has this listing or something similar and that definitely is borked.

Not important in the scheme of things just curious.

Re: ZX80: ersatz PAUSE and PRINT AT?

Posted: Mon Dec 20, 2021 2:01 pm
by TMD2003
One thing's for sure, what I just took from Paul's site is working, and the 20-second pause it produces is pretty much spot on.

Watch out, 2022 CSSCGC, there's a ZX80 game coming your way! Unoriginal! Generic! Dull! Won't have a hope of fitting into 1K! But it keeps something on the screen and I can't take credit for it!

Re: ZX80: ersatz PAUSE and PRINT AT?

Posted: Mon Dec 20, 2021 6:37 pm
by Fruitcake
Moggy wrote: Mon Dec 20, 2021 1:55 pm Is the file for this modified by your self Paul in someway? I have the original book and cannot get the listing to work without crashing and did read somewhere that the listing as printed is in error. I have another of Hartnell's book that has this listing or something similar and that definitely is borked.
No, the program just worked ok for me. There was a minor typo in the listing on line 200 that is printed as LT but should be LET, but that was the only correction I made.