Thanks for your explanation, now I finally understand why DStar has smooth flicker-free animation and why I couldn't make it: in my game there are just too many other things going on inside the main game loop.
To prove that, I now made a very simple demo (it just fills the screen from right to left by plotting every pixel), and there you have it: a flicker-free animation on the ZX80.
May I encourage all z88dk developers to experiment with this technique? The ZX80 definitively needs more action games!

Code: Select all
/* Plotting "Animation" Test by RobertK, 2018-08-24
Demonstrates how flicker-free animation can be achieved on the ZX80,
provided that there is not too much other logic done inside the loop.
In this sample, only plotting of one pixel and an in_KeyPressed()
check are done inside the loop.
Compile command for the following targets (use latest nightly build, not 1.99B):
=== ZX81 (64×48) ===
zcc +zx81 -startup=2 -o plotani_ZX81 -create-app plotani.c
=== ZX80 (64×48) ===
zcc +zx80 -o plotani_ZX80 -create-app plotani.c
*/
#include <stdio.h> // required for printf()
#include <graphics.h> // contains plot() and point() functions
#define KEYPRESS_CODE_X 1278 // x key on both the ZX81 and ZX80
void main()
{
int x,y;
int xMax, yMax;
int exit=0;
// determine the screen dimensions for this system
// coordinates go from 0 to this max value
xMax=getmaxx();
yMax=getmaxy();
#if defined(__ZX80__)
gen_tv_field_init(0); // has to be called once for screen-refreshing on the ZX80
#endif
// check if the screen dimensions for this platform have been defined above
if (xMax>0 && yMax>0)
{
while(exit<1)
{
printf("%c",12); // clear the screen
printf("*** plotting (%d x %d) ***\n\n\n",xMax+1,yMax+1);
printf("press x to exit...");
for (x = xMax; x >=0 && exit<1; x--)
for (y = 0; y <=yMax && exit<1; y++)
{
plot(x,y);
// ZX80: make the screen visible (as the ZX80 only runs in FAST mode,
// the screen is normally only visible during fgetc_cons() calls)
#if defined(__ZX80__)
gen_tv_field();
#endif
if (in_KeyPressed(KEYPRESS_CODE_X)>0) exit=1;
}
}
}
printf("%c",12); // clear the screen
printf("done.\n");
fgetc_cons(); // wait for keypress
}