I'm currently trying to develop a small game for my +2 using z88dk, but the code I'm using to sync up the display and avoid flickering isn't working on the real hardware where it does on an emulator. I mostly copied Sidewize's vsync code by making one attribute tile 0x40, and waiting for it to be returned so I can write to the display memory safely. But on real hardware using this function instead of HALT just ends up with the program freezing?
void WaitForVSync ()
{
unsigned char result;
while (result != 0x40)
result = M_INP(0x40FF); //Fetch data from ULA to check if the current attribute byte is 0x40.
}
...
//How I set up the last attribute byte.
attribute = zx_cyx2aaddr (0,0);
attribute [31*24] = 0x40;
I'm using an Interface 1bis if it helps, and the latest nightly build of z88dk. I'm afraid I don't know much assembler so I didn't know how to implement it exactly with the inline assembler.
void (*WaitforVSync) (void);
void FloatingBusWait ()
{
unsigned char result;
while (result != 0x40)
result = M_INP(0x40FF); //Fetch data from ULA bus to check if the current attribute byte is 0x40.
}
void HackyWait ()
{
#asm
halt
#endasm
}
//...
if (zx_floatingbus() == 1) //am I doing that right?
{
WaitforVSync = FloatingBusWait;
printf ("float");
}
else
{
WaitforVSync = HackyWait;
printf ("hack");
}
//...
WaitforVSync ();
But the compiler gives me this warning:
sccz80:"test.c" L:210 Warning:Assigning from a void expression [-Wvoid]
Line 210 is result = M_INP(0x40FF);.
How do I write this so that it doesn't give a warning?