Plot function in z88dk

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
Andy Rea
Posts: 1553
Joined: Fri May 09, 2008 2:48 pm

Re: Plot function in z88dk

Post by Andy Rea »

Ahah great find Siggi, when I'm back I'll search out this library ( its bound to be more complete ) and do some. Speed comparisons

Regards Andy
AFK

User avatar
RobertK
Posts: 52
Joined: Tue Dec 19, 2017 4:29 pm
Location: Vienna

Re: Plot function in z88dk

Post by RobertK »

Ok, now I have found out that the graphics.h functions plot(), unplot() and point() work with the ZX81 target and do exactly the same. Sorry that I didn't notice that earlier, :oops: but that's why I asked here. We definitely need more ZX81 z88dk developers! :)

However, a quick test shows that Andy's functions are a little faster.
I have compiled a test version of the game using the graphics.h functions. Try the demo mode (which is most demanding for the CPU because it requires AI logic for two computer players), you will notice that it runs a little slower. But the game is still playable.
Also the drawing of the screen border at the beginning has some noticable speed difference.

Maybe I will use the graphics.h functions for a potential ZX80 version of the game. As expected, Andy's functions would require some modifications to be ZX80ised - they do plot, but not 100% correctly. The graphics.h functions work identically on both the ZX81 and ZX80.
Attachments
HTron_16K_2018-03-08_GraphicsHTest.P
(7.95 KiB) Downloaded 158 times

User avatar
Andy Rea
Posts: 1553
Joined: Fri May 09, 2008 2:48 pm

Re: Plot function in z88dk

Post by Andy Rea »

well the graphics library is very much more complete as i expected, of the little bit of code i looked at there is bounds checking, but the other differences i do bot know at this time.

zx80 character set is a little different to the ZX81 so a different method of plotting is required

Andy
AFK

User avatar
RobertK
Posts: 52
Joined: Tue Dec 19, 2017 4:29 pm
Location: Vienna

Re: Plot function in z88dk

Post by RobertK »

My ambitious attempt to port the H-Tron game to the ZX80 has come to a halt...

While the graphics.h plot() function works great on the ZX80 (I can already see the correctly displayed game screen), its point() function does not - it makes the program crash. The z88dk wiki says "this function might not work correctly on all the platforms".

Here is a little test program that can be compiled for either the ZX81 and ZX80, if anyone wants to experiment with it in z88dk.

Code: Select all

/* Plot Test by RobertK, 2018-03-14
   Compile for ZX81:
   zcc +zx81 -startup=2 -o plottest -create-app plottest.c
   Compile for ZX80:
   zcc +zx80 -o plottestZX80 -create-app plottest.c   
*/

#include <stdio.h>		// required for printf()
#include <graphics.h>	// contains plot() and point() functions

void main()
{
  printf("\n\n\n\n\n*** plot test ***\n\n");

  plot(1,1);
  plot(3,3);
  plot(5,5);
  
  printf("press any key to point-check\n\n");
  fgetc_cons();	// wait for keypress
  
  printf("point(3,3) (plotted) is %d\n",point(3,3));
  printf("point(10,10) (blank) is %d\n",point(10,10));
    
  fgetc_cons();	// wait for keypress	
}
If you add the -lgfx81 option when compiling the ZX80 version, the point() function works, but the plot() function no longer works correctly, as it obviously uses the wrong character (from the ZX81 character set). Unfortunately there is no -lgfx80 option yet in z88dk, since there is no gfx80.lib file (only gfx81.lib).

@Andy: if you could *easily* adapt your functions to make them work on the ZX80, then I could try to continue adapting my game for the ZX80.

However, I am experiencing more problems with the compiled ZX80 file. A function containing some for/next/do loop works only when I add fgetc_cons() statements to wait for a keypress - looks like some timing problem. So I cannot guarantee that in the end it would work at all. Maybe I will have to try porting the game to other targets...

User avatar
stefano
Posts: 418
Joined: Tue Dec 11, 2012 9:24 am
Contact:

Re: Plot function in z88dk

Post by stefano »

hmm, that dammn graphics reorganization left lots of bugs behind,
if I haven't fixed this point issue already I hope I'll remember to do it :oops:

User avatar
RobertK
Posts: 52
Joined: Tue Dec 19, 2017 4:29 pm
Location: Vienna

Re: Plot function in z88dk

Post by RobertK »

Thanks, but I think that you (or someone else) fixed the crash problem soon after my last post from March 2018.

Here are two WIP ZX80 versions of my game: a fresh compile using the current htron.c source, and a version that I compiled in July 2018, both flickering heavily. The older version looks a little better, but I have no idea what the difference was, maybe I will dig in my old sources to find out.

You are all invited to experiment with my source to create a better ZX80 version, grab the latest source from here and compile it like this:

zcc +zx80 -o htron_ZX80 -create-app htron.c

BTW, I doubt that EightyOne or any other emulator can exactly reproduce the display of a real ZX80. Here I showed you a simple Animation which looked quite good on the emulator. Later I tried it on my MiST FPGA computer, and there it didn't look good at all. I don't have a ZX80 for comparison, and I don't know how close the FPGA reproduction is to the real thing, but I think that we will have to try all flicker-reducing tricks on the real hardware.
Attachments
htron_ZX80_2018-07-10.O
(7.04 KiB) Downloaded 52 times
htron_ZX80.O
(7.01 KiB) Downloaded 56 times

Post Reply