The ZX80 with its annoying "fast mode only" feature refreshes the screen only when it is waiting for user input.
In my program I would like to show a message for three seconds and then remove it again, and during these three seconds I would like to keep the screen "as visible as possible".
During an msleep() pause, the ZX80 screen remains black, so this is not an option.
So I tried to busy loop with repeated gen_tv_field() calls, but the result was not satisfying.
Is there a better way to do this on the ZX80? The screen may bounce at the beginning and the end of the pause, but it should be stable in between.
A crazy idea came to my mind: can we make an fgetc_cons() call and after three seconds somehow trigger a fake keyboard input, so that execution would continue? Could this be already done with the current z88dk functionality, or could this be a potential new z88dk feature?
Such a feature could also be useful for displaying various simulations (Game of Life, solar system orbits, etc.) on the ZX80.
ZX80: "Visible" msleep()
Looking at the code for fgetc_cons() on the ZX80 it looks like there's an infinite loop, so in theory having it time out should be a case of adding a loop counter which has some rough calibration.
So, it's a new feature, however looking around the source code sleep() does something special for the ZX80 so it might work for you - though it might be unsatisfactory since it does the gen_tv_field() thing.
So, it's a new feature, however looking around the source code sleep() does something special for the ZX80 so it might work for you - though it might be unsatisfactory since it does the gen_tv_field() thing.
I did some testing with sleep() on the ZX80, but whatever value I use (the parameter seems to be in seconds), I don't notice any pause, it only makes the screen bounce and that's it.
Here is my test program:
Here is my test program:
Code: Select all
/* sleeptest2.c
Compile with
zcc +zx80 -o sleeptest2_ZX80 -create-app sleeptest2.c
zcc +zx81 -startup=2 -lm -o sleeptest2_ZX81 -create-app sleeptest2.c
*/
void main()
{
printf("press any key for test");
fgetc_cons(); // wait for keypress
printf("\nwaiting some time\n");
// msleep(3000); // keeps the ZX80 screen black during the pause
sleep(1); // makes the ZX80 screen bounce but without any pause
printf("\nfinished waiting\npress any key to exit");
fgetc_cons(); // wait for keypress
}
It took me a while to remember: that code portion never worked on a zx80.
Oddly it worked perfectly on the zx81, so I kept it with the intention of fixing it later (which never happened so far).
I can't see why it doesn't work on the zx80, though ! The hw differences shouldn't be relevant for this code portion, and a similar trick makes data run smoothly, so.. ?
Oddly it worked perfectly on the zx81, so I kept it with the intention of fixing it later (which never happened so far).
I can't see why it doesn't work on the zx80, though ! The hw differences shouldn't be relevant for this code portion, and a similar trick makes data run smoothly, so.. ?