ZX81: Plot, Unplot and test-point for LOWRES (64x44) screen

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

z88dk/lib/config/trs80.cfg is missing a minus in the disk subtype line:

Code: Select all

..
SUBTYPE                default -lgfxtrs80 
SUBTYPE                disk lgfxtrs80 -Cz--cmd
SUBTYPE                wav -lgfxtrs80 -Cz--audio -Cz--fast
..
I'll commit that now. I don't see how zcc is turning "lgfxtrs80" into "lgfxtrs80.asm.m4".
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I just closed the issue on GitHub after the successful test on the Colour Genie:

https://github.com/z88dk/z88dk/issues/6 ... -378634493
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Thanks for the updates! A few issues with two systems still remain, and in the meantime I have tested two more systems. I'm posting these issues here just in case that they can be easily fixed:

Jupiter Ace: clearing the screen does not clear the bottom line. Strangely, this only happens in this plot test program, while in my game H-Tron (which does basically the same) the entire screen gets cleared correctly. I really don't know what makes the difference.

EG2000: screen is shifted towards the bottom so that the bottom line of the border cannot be seen. Clearing the screen does not work.

Philips P2000 (tested with the M2000 emulator for DOS running in DOSBox): plotted points cannot be seen (some characters appear instead), everything else is ok.

Robotron Z9001: Compiler errors "symbol ?plot? not defined" when trying to compile with
zcc +z9001 -lm -o plottest_z9001 -create-app plottest.c

Maybe someone with more interest in the ABC80 and Nascom systems can try to test these.

Here is the updated test program:

Code: Select all

/* Plot(), Unplot() and Point() Test by RobertK, 2018-04-07

   Compile command for the following targets:
  
   === ZX81 (64?48) === (ok)
   zcc +zx81 -startup=2 -Cz--disable-autorun -o plottest_ZX81 -create-app plottest.c
   
   === ZX80 (64?48) === (ok)
   zcc +zx80 -o plottest_ZX80 -create-app plottest.c
   Note: point() function was not working yet for this system 
   with 1.99B (calling it made the program crash), since nightly 
   build 2018-03-22 it works correctly.
 
   === Jupiter Ace (64x48) ===
   zcc +ace -lgfxace -vn -create-app plottest.c -o pt.bin
   Note: with 1.99B plotted points could not be seen, and the 
   point() function returned inverse values -> fixed since nightly
   build 2018-03-28 (-lgfxace option added by Stefano for 64x48)
   Last remaining issue: clearing the screen does not clear the 
   bottom line (only in this test program, while in H-Tron the entire 
   screen gets cleared correctly).
   Load the program on the Jupiter Ace by typing:
   0 0 bload pt.bin
   
   === Galaksija (64?48) === (ok)
   zcc +gal -vn -create-app plottest.c -o plottest_galaksija.bin   
   Note: on the Galaksija computer type OLD to load a program from cassette.

   === VZ200 / Laser 210 / Laser 110 (128?64) === (ok)
   zcc +vz -lm -pragma-redirect=fputc_cons=putc4x6 -o plottest_vz200.vz plottest.c 
   Note from the z88dk wiki: "The graphics mode is automatically switched on 
   by calling ?clg? or printing CHR$ 12 or calling the vz_mode() function."
   We use clg() in this example.
   Works correctly since nightly build 2018-03-31. Stefano: 
   "The VZ200. Its "operating system" (aka BASIC interpreter) is designed to switch 
   back to text mode as soon as a character is being printed.
   After this nightly build you should have a new function in all the mid and low-rez 
   graphics drivers permitting to output some text in graphics mode.
   You just need to add the following parameter in your zcc command line:"
   -pragma-redirect=fputc_cons=putc4x6

   === TRS-80 (128?48) === (ok)
   zcc  +trs80 -lndos -lm -create-app -o plottest_trs80.bin -subtype=disk plottest.c
   Clearing the screen does not work with 1.99B, since nightly build 2018-03-24 
   this works as well. Use the HT1080Z emulator for testing (select "Autostart file" 
   and open the .cmd file)
   
   === Robotron Z1013 (64?64) === (ok)
   zcc +z1013 -lm -create-app plottest.c -o plottest_z1013
   Note: top line (plotted pixel at 1,1) was not visible with 1.99B, 
   since nightly build 2018-03-22 it works correctly.
   
   === Philips VG5000 (80?72) === (ok)
   zcc +vg5k -create-app -clib=graphics -lm plottest.c -o plottest_vg5000
   Note: In 1.99B Plot() function displayed " characters instead of pixels.
   New compile option -clib=graphics added since nightly build 2018-03-31.
   Use the DCVG5K emulator (dcvg5k.free.fr) for testing
   Attach the .k7 cassette file and type CLOAD to load the program
   (note that the VG5000 has a French AZERTY keyboard so on most 
   other keyboard layouts you have to type CLOQD)
   
   === Mattel Aquarius (80?48) === (ok)
   zcc +aquarius -lm -create-app plottest.c -o plottest_aquarius
   Note: Everything works, except for that plotted pixels are not 
   all the same size. In the plot test the second pixel looks ok 
   while the first and third are too flat.
   
   Stefano: "I saw a comment about odd pixels on the Mattel Aquarius. 
   Sadly there is very little we can do for it, the character set is 
   so fancy and unbalanced.  The bottom right pixel in a 2x3 matrix is 
   totally missing while the bottom-right pixel in a 2x2 matrix is 
   repeated twice, this is something I really can't understand because 
   the font was accurately overloaded of any kind of different symbol 
   and a duplicate like this is very odd (chr 26 = chr 224).
   By the way I added a graphics variant [in nightly build 2018-03-29]:
   just use  '-lgfxaq48' to bend your graphics resolution from 64x72 
   to 64x48 [should be 80x48],  they are both compatible with the text mode."
   -> looks good now, the plotted pixels are all the same size now
   
   Use the "Virtual Aquarius" emulator for testing. Loading 
   instructions from the z88dk wiki:
    from within the emulator, load the loader: cload
    press ENTER twice, then play the ?_plottest_aquarius.caq? cassette file (loader)
    at the ?OK? prompt, type RUN <ENTER>
    press ENTER twice, then play the ?plottest_aquarius.caq? cassette file
    wait? then have fun !

   === EG2000 (160?100) ===
   zcc  +trs80 -lndos -lm -create-app -subtype=eg2000disk -pragma-redirect=fputc_cons=putc4x6 -o plottest_eg2000.bin plottest.c   
   Note: plotted points could not be seen with 1.99B. New compile option
   -pragma-redirect=fputc_cons=putc4x6 added in nightly build 2018-04-05.
   Last remaining issues: screen is shifted towards the bottom 
   so that the bottom line of the border cannot be seen. Clearing the screen 
   does not work.
   Use the Genieous emulator (gaia.atilia.eu) for testing. See the TRS-80 
   loading instructions above (use "Autostart file" after entering SYSTEM)
   
   === Sharp MZ-700 (80?50) === (ok)
   zcc +mz -lm -create-app plottest.c -o plottest_sharpmz
   Note: clearing the screen does not work in 1.99B, fixed since 
   nightly build 2018-03-29
   In M.A.M.E. attach The .mzt cassette file, then press L and Enter 
   to initiate loading, then use M.A.M.E.'s tape control to start the tape.
   
   === Philips P2000 (78?72) ===
   zcc +p2000 -o plottest_p2000 -create-app -lm plottest.c
   M.A.M.E. (tested with 0.170 and 0.196) does not allow to load software on that system. 
   Tested with the M2000 emulator for DOS (in DOSBox), use the -tape <filename> option to 
   attach the .cas file, load it with "cload" and then type "run".
   Plotted points cannot be seen (some characters appear instead), everything else is ok.
   
   === ABC80 (78?72) === (still to be tested)
   zcc +abc80 -lm -o plottest_abc80 -create-app plottest.c
   Note from z88dk Wiki: "The pseudo graphics mode is supported. You first 
   need to issue a clg () command to set up the graphics page."
   .BAC or .BAS file can be quickloaded and listed in M.A.M.E., but cannot be run
   
   === Nascom (96?48) === (still to be tested)
   zcc +nascom -lm -o plottest_nascom -create-app plottest.c
   (.nas file can be successfully loaded in M.A.M.E. in 
   both Nascom 1 and Nascom 2, but what to do next?)
   
   === Robotron Z9001 (80x48) === (still to be tested)
   zcc +z9001 -lm -o plottest_z9001 -create-app plottest.c
   Compiler errors "symbol ?plot? not defined"
   
   
*/

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

// define the screen dimensions for the current system
#if defined(__ZX81__) || defined(__ZX80__) || defined(__ACE__) || defined(__GAL__) // ZX81, ZX80, Jupiter Ace, Galaksija
        #define X_RES 64
        #define Y_RES 48
#elif defined(__VG5000__)        // Philips VG5000
        #define X_RES 80
        #define Y_RES 72
#elif defined(__AQUARIUS__)        // Mattel Aquarius
        #define X_RES 80
        #define Y_RES 48        
#elif defined(__VZ200__)        // VZ200 / Laser 210 / Laser 110
        #define X_RES 128
        #define Y_RES 64
#elif defined(__TRS80__) && !defined(__EG2000__)        // TRS-80
        #define X_RES 128
        #define Y_RES 48
#elif defined(__TRS80__) && defined(__EG2000__)                // EG2000  (constant for this sub-type available since nightly 2018-03-31)
        #define X_RES 160
        #define Y_RES 100
#elif defined(__Z1013__)        // Robotron Z1013
        #define X_RES 64
        #define Y_RES 64
#elif defined(__SHARPMZ__)        // Sharp MZ-700
        #define X_RES 80
        #define Y_RES 50
#elif defined(__ABC80__)        // Luxor ABC 80
        #define X_RES 78
        #define Y_RES 72        
#elif defined(__NASCOM__)        // Nascom
        #define X_RES 96
        #define Y_RES 48
#elif defined(__P2000__)        // Philips P2000
        #define X_RES 78
        #define Y_RES 72
#elif defined(__Z9001__)        // Robotron Z9001
        #define X_RES 80
        #define Y_RES 48
#else
        #define X_RES 0
        #define Y_RES 0        
#endif 

void main()
{ 
  int x,y;
    
  printf("%c",12); // clear the screen  
  printf("\n\n\n\n\n*** plot test (%d x %d) ***\n\n",X_RES,Y_RES);
  printf("press any key to plot and unplot\n\n");

  fgetc_cons();        // wait for keypress

  #if defined(__VZ200__) || defined(__VG5000__) || defined(__ABC80__)
        clg();  // activate graphics mode
        printf("%c",12);   // we clear the screen...
        printf("\n\n",12); // ...and move a little down because otherwise the huge letters of the VZ200 and VG5000 graphics mode wouldn't fit on the screen
  #endif

  plot(1,1);
  plot(3,3);
  plot(5,5);
  unplot(5,5);
  plot(7,7);
    
  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)); // should be 1
  printf("point(5,5)   (unplotted) is %d\n",point(5,5)); // should be 0
  printf("point(10,10) (blank)     is %d\n",point(10,10)); // should be 0

  // check if the screen dimensions for this platform have been defined above
  if (X_RES>0 && Y_RES>0)
  { 
          printf("\npress any key to draw border\n");
          fgetc_cons();        // wait for keypress
          for (x = 0; x < X_RES; ++x)
          {
                plot(x,Y_RES-1);
                plot(x,0);
          }
          for (y = 1; y < Y_RES; ++y)
          {
                plot(0,y);
                plot(X_RES-1,y);
          }
  }
  
  printf("\npress any key to clear screen\n");
  fgetc_cons();        // wait for keypress
  printf("%c",12); // clear the screen 
  
  printf("done.\n");
  fgetc_cons();        // wait for keypress        
}
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

RobertK wrote:Robotron Z9001: Compiler errors "symbol ?plot? not defined" when trying to compile with
zcc +z9001 -lm -o plottest_z9001 -create-app plottest.c
Ok, I have solved that now, I should have better read the documentation before asking: I need to add the -lgfx9001 parameter for lo-res graphics.

Here are my test notes:

Code: Select all

   === Robotron Z9001 (80x48) === (almost ok)
   zcc +z9001 -lm -lgfx9001 -o plottest_z9001 -create-app plottest.c
   or
   zcc +z9001 -lm -lgfx9001 -subtype=kcc -o plottest_z9001 -create-app plottest.c
   Use JKCEMU for testing, there you can run either a .TAP or a .KCC file.
   Note: combining -lgfx9001 and -clib=ansi...
   zcc +z9001 -lm -lgfx9001 -clib=ansi -o plottest_z9001_ansi -create-app plottest.c
   ...works only on monochrome systems (on colour machines, characters cannot be 
   seen and plotted points are partly invisible)
Is it supposed to be possible combining -lgfx9001 and -clib=ansi on colour machines?
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

or the j ace you can try with the ansi clib variant (clib=ansi), the native console support may suffer for some dirt in the input buffer area. I never understood this effect fully, but it may be connected to the autorun option.
this same trick is a valid fix on several targets, eg somewhere (msx, svi,..) it permits to mix text and graphics.
please confirm you are running the p2000 emulator in color mode (p2000c). the p2000m variant was 80 column text and is not supported. be sure to issue a clg() command, etc.. if problems persist, just answer here :)
you may also be interested in my p2000 emulator port to allegro, it is pre.built for but is surely easy to port on mac or linux.
my old webtite is gone, does anyone have a hint on where this stuff could be placed?
I noticed the eg2000 display centering problem, I thought it was normal but now I'll check.
I thought the z9001 was doing well also on colour models, but probably I checked only the krt high resolution ..something more to check I suppose. :)
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

stefano wrote:or the j ace you can try with the ansi clib variant (clib=ansi)
Exactly, that was the difference! My game is compiled for ANSI mode, while the plot test program was not.
Ok, then we have a workaround here.
stefano wrote:please confirm you are running the p2000 emulator in color mode (p2000c). the p2000m variant was 80 column text and is not supported. be sure to issue a clg() command, etc.
The clg() command was missing, thanks!

Two issues remain:
- last visible y coordinate is 69. Plotted points in lines 70, 71 and 72 cannot be seen.
- when plotting over a character, another character appears instead of the plotted pixel.

stefano wrote:you may also be interested in my p2000 emulator port to allegro, it is pre.built for but is surely easy to port on mac or linux.
my old webtite is gone, does anyone have a hint on where this stuff could be placed?
Maybe Marcel de Kogel would be interested to host it on his website? I hope he is still fine after so many years, his page was last updated in 2001...

Here is the updated test program with the clg() call added for P2000:

Code: Select all

/* Plot(), Unplot() and Point() Test by RobertK, 2018-04-13

   Compile command for the following targets:
  
   === ZX81 (64?48) === (ok)
   zcc +zx81 -startup=2 -Cz--disable-autorun -o plottest_ZX81 -create-app plottest.c
   
   === ZX80 (64?48) === (ok)
   zcc +zx80 -o plottest_ZX80 -create-app plottest.c
   Note: point() function was not working yet for this system 
   with 1.99B (calling it made the program crash), since nightly 
   build 2018-03-22 it works correctly.
 
   === Jupiter Ace (64x48) === (ok)
   zcc +ace -lgfxace -clib=ansi -vn -create-app plottest.c -o pt.bin
   Note: with 1.99B plotted points could not be seen, and the 
   point() function returned inverse values -> fixed since nightly
   build 2018-03-28 (-lgfxace option added by Stefano for 64x48)
   Last remaining issue: clearing the screen does not clear the 
   bottom line. Workaround: compiling with the paramter -clib=ansi for 
   VT100 ANSI mode solves the problem.
   Load the program on the Jupiter Ace by typing:
   0 0 bload pt.bin
   
   === Galaksija (64?48) === (ok)
   zcc +gal -vn -create-app plottest.c -o plottest_galaksija.bin   
   Note: on the Galaksija computer type OLD to load a program from cassette.

   === VZ200 / Laser 210 / Laser 110 (128?64) === (ok)
   zcc +vz -lm -pragma-redirect=fputc_cons=putc4x6 -o plottest_vz200.vz plottest.c 
   Note from the z88dk wiki: "The graphics mode is automatically switched on 
   by calling ?clg? or printing CHR$ 12 or calling the vz_mode() function."
   We use clg() in this example.
   Works correctly since nightly build 2018-03-31. Stefano: 
   "The VZ200. Its "operating system" (aka BASIC interpreter) is designed to switch 
   back to text mode as soon as a character is being printed.
   After this nightly build you should have a new function in all the mid and low-rez 
   graphics drivers permitting to output some text in graphics mode.
   You just need to add the following parameter in your zcc command line:"
   -pragma-redirect=fputc_cons=putc4x6

   === TRS-80 (128?48) === (ok)
   zcc  +trs80 -lndos -lm -create-app -o plottest_trs80.bin -subtype=disk plottest.c
   Clearing the screen does not work with 1.99B, since nightly build 2018-03-24 
   this works as well. Use the HT1080Z emulator for testing (select "Autostart file" 
   and open the .cmd file)
   
   === Robotron Z1013 (64?64) === (ok)
   zcc +z1013 -lm -create-app plottest.c -o plottest_z1013
   Note: top line (plotted pixel at 1,1) was not visible with 1.99B, 
   since nightly build 2018-03-22 it works correctly.
 
   === Robotron Z9001 (80x48) === (almost ok)
   zcc +z9001 -lm -lgfx9001 -o plottest_z9001 -create-app plottest.c
   or
   zcc +z9001 -lm -lgfx9001 -subtype=kcc -o plottest_z9001 -create-app plottest.c
   Use JKCEMU for testing, there you can run either a .TAP or a .KCC file.
   Note: combining -lgfx9001 and -clib=ansi...
   zcc +z9001 -lm -lgfx9001 -clib=ansi -o plottest_z9001_ansi -create-app plottest.c
   ...works only on monochrome systems (on colour machines, characters cannot be 
   seen and plotted points are partly invisible)
   
   === Philips VG5000 (80?72) === (ok)
   zcc +vg5k -create-app -clib=graphics -lm plottest.c -o plottest_vg5000
   Note: In 1.99B Plot() function displayed " characters instead of pixels.
   New compile option -clib=graphics added since nightly build 2018-03-31.
   Use the DCVG5K emulator (dcvg5k.free.fr) for testing
   Attach the .k7 cassette file and type CLOAD to load the program
   (note that the VG5000 has a French AZERTY keyboard so on most 
   other keyboard layouts you have to type CLOQD)
   
   === Mattel Aquarius (80?48) === (ok)
   zcc +aquarius -lm -create-app plottest.c -o plottest_aquarius
   Note: Everything works, except for that plotted pixels are not 
   all the same size. In the plot test the second pixel looks ok 
   while the first and third are too flat.
   
   Stefano: "I saw a comment about odd pixels on the Mattel Aquarius. 
   Sadly there is very little we can do for it, the character set is 
   so fancy and unbalanced.  The bottom right pixel in a 2x3 matrix is 
   totally missing while the bottom-right pixel in a 2x2 matrix is 
   repeated twice, this is something I really can't understand because 
   the font was accurately overloaded of any kind of different symbol 
   and a duplicate like this is very odd (chr 26 = chr 224).
   By the way I added a graphics variant [in nightly build 2018-03-29]:
   just use  '-lgfxaq48' to bend your graphics resolution from 64x72 
   to 64x48 [should be 80x48],  they are both compatible with the text mode."
   -> looks good now, the plotted pixels are all the same size now
   
   Use the "Virtual Aquarius" emulator for testing. Loading 
   instructions from the z88dk wiki:
    from within the emulator, load the loader: cload
    press ENTER twice, then play the ?_plottest_aquarius.caq? cassette file (loader)
    at the ?OK? prompt, type RUN <ENTER>
    press ENTER twice, then play the ?plottest_aquarius.caq? cassette file
    wait? then have fun !

   === EG2000 (160?100) ===
   zcc  +trs80 -lndos -lm -create-app -subtype=eg2000disk -pragma-redirect=fputc_cons=putc4x6 -o plottest_eg2000.bin plottest.c   
   Note: plotted points could not be seen with 1.99B. New compile option
   -pragma-redirect=fputc_cons=putc4x6 added in nightly build 2018-04-05.
   Last remaining issues: screen is shifted towards the bottom 
   so that the bottom line of the border cannot be seen. Clearing the screen 
   does not work.
   Use the Genieous emulator (gaia.atilia.eu) for testing. See the TRS-80 
   loading instructions above (use "Autostart file" after entering SYSTEM)
   
   === Sharp MZ-700 (80?50) === (ok)
   zcc +mz -lm -create-app plottest.c -o plottest_sharpmz
   Note: clearing the screen does not work in 1.99B, fixed since 
   nightly build 2018-03-29
   In M.A.M.E. attach The .mzt cassette file, then press L and Enter 
   to initiate loading, then use M.A.M.E.'s tape control to start the tape.
   
   === Philips P2000 (78?72) ===
   zcc +p2000 -o plottest_p2000 -create-app -lm plottest.c
   M.A.M.E. (tested with 0.170 and 0.196) does not allow to load software on that system. 
   Tested with the M2000 emulator for DOS (in DOSBox), use the -tape <filename> option to 
   attach the .cas file, load it with "cload" and then type "run".
   Issues:
   - last visible y coordinate is 69. Plotted points in lines 70, 71 and 72 cannot be seen.
   - when plotting over a character, another character appears instead of the plotted pixel.
   
   === ABC80 (78?72) === (still to be tested)
   zcc +abc80 -lm -o plottest_abc80 -create-app plottest.c
   Note from z88dk Wiki: "The pseudo graphics mode is supported. You first 
   need to issue a clg () command to set up the graphics page."
   .BAC or .BAS file can be quickloaded and listed in M.A.M.E., but cannot be run
   
   === Nascom (96?48) === (still to be tested)
   zcc +nascom -lm -o plottest_nascom -create-app plottest.c
   (.nas file can be successfully loaded in M.A.M.E. in 
   both Nascom 1 and Nascom 2, but what to do next?)
      
*/

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

// define the screen dimensions for the current system
#if defined(__ZX81__) || defined(__ZX80__) || defined(__ACE__) || defined(__GAL__) // ZX81, ZX80, Jupiter Ace, Galaksija
        #define X_RES 64
        #define Y_RES 48
#elif defined(__VG5000__)        // Philips VG5000
        #define X_RES 80
        #define Y_RES 72
#elif defined(__AQUARIUS__)        // Mattel Aquarius
        #define X_RES 80
        #define Y_RES 48        
#elif defined(__VZ200__)        // VZ200 / Laser 210 / Laser 110
        #define X_RES 128
        #define Y_RES 64
#elif defined(__TRS80__) && !defined(__EG2000__)        // TRS-80
        #define X_RES 128
        #define Y_RES 48
#elif defined(__TRS80__) && defined(__EG2000__)                // EG2000  (constant for this sub-type available since nightly 2018-03-31)
        #define X_RES 160
        #define Y_RES 100
#elif defined(__Z1013__)        // Robotron Z1013
        #define X_RES 64
        #define Y_RES 64
#elif defined(__SHARPMZ__)        // Sharp MZ-700
        #define X_RES 80
        #define Y_RES 50
#elif defined(__ABC80__)        // Luxor ABC 80
        #define X_RES 78
        #define Y_RES 72        
#elif defined(__NASCOM__)        // Nascom
        #define X_RES 96
        #define Y_RES 48
#elif defined(__P2000__)        // Philips P2000
        #define X_RES 78
        #define Y_RES 72        // 69 is the last visible y coordinate
#elif defined(__Z9001__)        // Robotron Z9001
        #define X_RES 80
        #define Y_RES 48
#else
        #define X_RES 0
        #define Y_RES 0        
#endif 

void main()
{ 
  int x,y;
    
  printf("%c",12); // clear the screen  
  printf("\n\n\n\n\n*** plot test (%d x %d) ***\n\n",X_RES,Y_RES);
  printf("press any key to plot and unplot\n\n");

  fgetc_cons();        // wait for keypress

  #if defined(__P2000__) || defined(__ABC80__)
        clg();  // activate graphics mode
  #elif defined(__VZ200__) || defined(__VG5000__)
        clg();  // activate graphics mode
        printf("%c",12);   // we clear the screen...
        printf("\n\n",12); // ...and move a little down because otherwise the huge letters of the VZ200 and VG5000 graphics mode wouldn't fit on the screen
  #endif

  plot(1,1);
  plot(3,3);
  plot(5,5);
  unplot(5,5);
  plot(7,7);
    
  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)); // should be 1
  printf("point(5,5)   (unplotted) is %d\n",point(5,5)); // should be 0
  printf("point(10,10) (blank)     is %d\n",point(10,10)); // should be 0

  // check if the screen dimensions for this platform have been defined above
  if (X_RES>0 && Y_RES>0)
  { 
          printf("\npress any key to draw border\n");
          fgetc_cons();        // wait for keypress
          for (x = 0; x < X_RES; ++x)
          {
                plot(x,Y_RES-1);
                plot(x,0);
          }
          for (y = 1; y < Y_RES; ++y)
          {
                plot(0,y);
                plot(X_RES-1,y);
          }
  }
  
  printf("\npress any key to clear screen\n");
  fgetc_cons();        // wait for keypress
  printf("%c",12); // clear the screen 
  
  printf("done.\n");
  fgetc_cons();        // wait for keypress        
}
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

do you know getmaxx() and getmaxy() ? it can help portability.
Also, clg() shouldn't be harmful where not strictly necessary
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

stefano wrote:do you know getmaxx() and getmaxy() ?
Thanks, that makes my test program much more compact.

One more issue with the P2000 lo-res graphics:

- plotting does not work in combination with ansi mode:
zcc +p2000 -clib=ansi -o plottest_p2000ansi -create-app -lm plottest.c
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Reason for this last evidenced P2000 behavior is that text and graphics cannot be mixed on the P2000.
As on the vg5000 it uses the same videochip designed for the "TELETEXT" TV service (known in Italy as TELEVIDEO), later adopted also by the French "MINITEL" (known in Italy as "VIDEOTEL", or "PRESTEL" in the UK).
It works on a text row base, where a first control character determines the output mode for the whole text row (e.g. TEXT versus GRAPHICS). The Graphics mode is just a different font configured for the well known blocky low resolution.

So.. you can still try to apply some target specific trick to force text or graphics content on selected rows (I could provide a clg variant acting on a single row specified), or you try to fit the new 4x6 font mode.
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

stefano wrote:Reason for this last evidenced P2000 behavior is that text and graphics cannot be mixed on the P2000.
Ok, so I have to compile it like this...

zcc +p2000 -pragma-redirect=fputc_cons=putc4x6 -o plottest_p2000g -create-app -lm plottest.c

...and then text (with big characters) and graphics can be mixed, as on the VG5000 and VZ200. And as you noted here, I can position text in 4x6 character mode by specifiying pixel coordinates like this...

Code: Select all

        #if defined(__VZ200__) || defined(__VG5000__) || defined(__P2000__)
          x_4x6 = 19;
          y_4x6 = 9;
          printf("testing 4x6...\n\n");
        #endif
That's fine, thanks. Last remaining issue with the P2000 target is this one:
- last visible y coordinate is 69. Plotted points in lines 70, 71 and 72 cannot be seen.

When you find the time, please check the Robotron Z9001 problem on colour machines when combining -lgfx9001 and -clib=ansi.

Thanks again for all your support.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

P2000 coordinates bug should be fixed.
Please check tomorrow, after the nightly build.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

EG2000 needed some cleanup (sprites, etc..). I adjusted also the clg() command but I still see an oddly shifted display which I'm quite sure being a feature of the genieous emulator.
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Unfortunately, last night's build brought new problems...
stefano wrote:P2000 coordinates bug should be fixed.
Please check tomorrow, after the nightly build.
No change unfortunately, and a problem with the point() function:

- last visible y coordinate is 68. Plotted points in lines 69 through 72 cannot be seen.
- Since nightly build 2018-04-19 the point() function returns 5-digit numbers instead of 0 and 1.
stefano wrote:EG2000 needed some cleanup (sprites, etc..). I adjusted also the clg() command but I still see an oddly shifted display which I'm quite sure being a feature of the genieous emulator.
When running the compiled .cmd file in the Genieous emulator it only shows some underscore character in the top left part of the screen. Calling clg() does not help.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I discovered what happened to the EG2000 configuration: my new clg() implementation doesn't work with the earlier models.
I'll correct the problem. I'm also working on the P2000.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

they bot are now fixed, pls try tomorrow morning
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Both fixes were successful, thanks!

On the P2000 target the test program now runs perfectly.

On the EG2000 clearing the screen works now, so that system should probably be ok now. I can't try it in M.A.M.E. (to see if the shifted screen is a feature of the Genieous emulator) because M.A.M.E. can load only cassette files for that system, while -subtype=eg2000disk creates a .cmd file and I don't know yet how to put that into a cassette file. Maybe I will contact some fan of that system, to my knowledge it was quite popular in Australia and New Zealand.

Here is the updated test program (BTW, too bad that in this forum we can't edit posts later on).
From the systems tested so far only the Robotron Z9001 issue with colour machines remains (when combining -lgfx9001 and -clib=ansi).

Code: Select all

/* Plot(), Unplot() and Point() Test by RobertK, 2018-04-20

   Compile command for the following targets:
  
   === ZX81 (64?48) === (ok)
   zcc +zx81 -startup=2 -Cz--disable-autorun -o plottest_ZX81 -create-app plottest.c
   
   === ZX80 (64?48) === (ok)
   zcc +zx80 -o plottest_ZX80 -create-app plottest.c
   Note: point() function was not working yet for this system 
   with 1.99B (calling it made the program crash), since nightly 
   build 2018-03-22 it works correctly.
 
   === Jupiter Ace (64x48) === (ok)
   zcc +ace -lgfxace -clib=ansi -vn -create-app plottest.c -o pt.bin
   Note: with 1.99B plotted points could not be seen, and the 
   point() function returned inverse values -> fixed since nightly
   build 2018-03-28 (-lgfxace option added by Stefano for 64x48)
   Last remaining issue: clearing the screen does not clear the 
   bottom line. Workaround: compiling with the paramter -clib=ansi for 
   VT100 ANSI mode solves the problem.
   Load the program on the Jupiter Ace by typing:
   0 0 bload pt.bin
   
   === Galaksija (64?48) === (ok)
   zcc +gal -vn -create-app plottest.c -o plottest_galaksija.bin   
   Note: on the Galaksija computer type OLD to load a program from cassette.

   === VZ200 / Laser 210 / Laser 110 (128?64) === (ok)
   zcc +vz -lm -pragma-redirect=fputc_cons=putc4x6 -o plottest_vz200.vz plottest.c 
   Note from the z88dk wiki: "The graphics mode is automatically switched on 
   by calling ?clg? or printing CHR$ 12 or calling the vz_mode() function."
   We use clg() in this example.
   Works correctly since nightly build 2018-03-31. Stefano: 
   "The VZ200. Its "operating system" (aka BASIC interpreter) is designed to switch 
   back to text mode as soon as a character is being printed.
   After this nightly build you should have a new function in all the mid and low-rez 
   graphics drivers permitting to output some text in graphics mode.
   You just need to add the following parameter in your zcc command line:"
   -pragma-redirect=fputc_cons=putc4x6

   === TRS-80 (128?48) === (ok)
   zcc  +trs80 -lndos -lm -create-app -o plottest_trs80.bin -subtype=disk plottest.c
   Clearing the screen does not work with 1.99B, since nightly build 2018-03-24 
   this works as well. Use the HT1080Z emulator for testing (select "Autostart file" 
   and open the .cmd file)
   
   === Robotron Z1013 (64?64) === (ok)
   zcc +z1013 -lm -create-app plottest.c -o plottest_z1013
   Note: top line (plotted pixel at 1,1) was not visible with 1.99B, 
   since nightly build 2018-03-22 it works correctly.
 
   === Robotron Z9001 (80x48) === (almost ok)
   zcc +z9001 -lm -lgfx9001 -o plottest_z9001 -create-app plottest.c
   or
   zcc +z9001 -lm -lgfx9001 -subtype=kcc -o plottest_z9001 -create-app plottest.c
   Use JKCEMU for testing, there you can run either a .TAP or a .KCC file.
   Note: combining -lgfx9001 and -clib=ansi...
   zcc +z9001 -lm -lgfx9001 -clib=ansi -o plottest_z9001_ansi -create-app plottest.c
   ...works only on monochrome systems (on colour machines, characters cannot be 
   seen and plotted points are partly invisible)
   
   === Philips VG5000 (80?72) === (ok)
   zcc +vg5k -create-app -clib=graphics -lm plottest.c -o plottest_vg5000
   Note: In 1.99B Plot() function displayed " characters instead of pixels.
   New compile option -clib=graphics added since nightly build 2018-03-31.
   Use the DCVG5K emulator (dcvg5k.free.fr) for testing
   Attach the .k7 cassette file and type CLOAD to load the program
   (note that the VG5000 has a French AZERTY keyboard so on most 
   other keyboard layouts you have to type CLOQD)
   
   === Mattel Aquarius (80?48) === (ok)
   zcc +aquarius -lm -create-app plottest.c -o plottest_aquarius
   Note: Everything works, except for that plotted pixels are not 
   all the same size. In the plot test the second pixel looks ok 
   while the first and third are too flat.
   
   Stefano: "I saw a comment about odd pixels on the Mattel Aquarius. 
   Sadly there is very little we can do for it, the character set is 
   so fancy and unbalanced.  The bottom right pixel in a 2x3 matrix is 
   totally missing while the bottom-right pixel in a 2x2 matrix is 
   repeated twice, this is something I really can't understand because 
   the font was accurately overloaded of any kind of different symbol 
   and a duplicate like this is very odd (chr 26 = chr 224).
   By the way I added a graphics variant [in nightly build 2018-03-29]:
   just use  '-lgfxaq48' to bend your graphics resolution from 64x72 
   to 64x48 [should be 80x48],  they are both compatible with the text mode."
   -> looks good now, the plotted pixels are all the same size now
   
   Use the "Virtual Aquarius" emulator for testing. Loading 
   instructions from the z88dk wiki:
    from within the emulator, load the loader: cload
    press ENTER twice, then play the ?_plottest_aquarius.caq? cassette file (loader)
    at the ?OK? prompt, type RUN <ENTER>
    press ENTER twice, then play the ?plottest_aquarius.caq? cassette file
    wait? then have fun !
   
   === Sharp MZ-700 (80?50) === (ok)
   zcc +mz -lm -create-app plottest.c -o plottest_sharpmz
   Note: clearing the screen does not work in 1.99B, fixed since 
   nightly build 2018-03-29
   In M.A.M.E. attach The .mzt cassette file, then press L and Enter 
   to initiate loading, then use M.A.M.E.'s tape control to start the tape.

   === EG2000 (160?100) === (probably ok)
   zcc  +trs80 -lndos -lm -create-app -subtype=eg2000disk -pragma-redirect=fputc_cons=putc4x6 -o plottest_eg2000.bin plottest.c   
   Note: plotted points could not be seen with 1.99B. New compile option
   -pragma-redirect=fputc_cons=putc4x6 added in nightly build 2018-04-05.
   Use the Genieous emulator (gaia.atilia.eu) for testing. See the TRS-80 
   loading instructions above (use "Autostart file" after entering SYSTEM).
   Last remaining issues: screen is shifted towards the bottom so that the bottom line 
   of the border cannot be seen. Stefano: "I still see an oddly shifted display which I'm 
   quite sure being a feature of the genieous emulator.
   
   === Philips P2000 (78?72) === (ok)
   zcc +p2000 -pragma-redirect=fputc_cons=putc4x6 -o plottest_p2000g -create-app -lm plottest.c
   M.A.M.E. (tested with 0.170 and 0.196) does not allow to load software on that system. 
   Tested with the M2000 emulator for DOS (in DOSBox), use the -tape <filename> option to 
   attach the .cas file, load it with "cload" and then type "run".
   Stefano: "text and graphics cannot be mixed on the P2000. As on the vg5000 it uses the same 
   videochip designed for the "TELETEXT" TV service (known in Italy as TELEVIDEO), later adopted 
   also by the French "MINITEL"  (known in Italy as "VIDEOTEL", or "PRESTEL" in the UK).
   It works on a text row base, where a first control character determines the output mode for 
   the whole text row (e.g. TEXT versus GRAPHICS).   The Graphics mode is just a different font 
   configured for the well known blocky low resolution.
   So..  you can still try to apply some target specific trick to force text or graphics 
   content on selected rows (I could provide a clg variant acting on a single row specified), 
   or you try to fit the new 4x6 font mode."
   -> 4x6 parameter added to the compile command above.
   Everything works correctly since nightly build 2018-04-20.
   
   === ABC80 (78?72) === (still to be tested)
   zcc +abc80 -lm -o plottest_abc80 -create-app plottest.c
   Note from z88dk Wiki: "The pseudo graphics mode is supported. You first 
   need to issue a clg () command to set up the graphics page."
   .BAC or .BAS file can be quickloaded and listed in M.A.M.E., but cannot be run
   
   === Nascom (96?48) === (still to be tested)
   zcc +nascom -lm -o plottest_nascom -create-app plottest.c
   (.nas file can be successfully loaded in M.A.M.E. in 
   both Nascom 1 and Nascom 2, but what to do next?)
      
*/

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

void main()
{ 
  int x,y;
  int xMax, yMax;
  // determine the screen dimensions for this system
  // coordinates go from 0 to this max value
  xMax=getmaxx();
  yMax=getmaxy();
  
  printf("%c",12); // clear the screen  
  printf("\n\n\n\n\n*** plot test (%d x %d) ***\n\n",xMax+1,yMax+1);
  printf("press any key to plot and unplot\n\n");

  fgetc_cons();        // wait for keypress

  #if defined(__ABC80__) || defined(__EG2000__)
        clg();  // activate graphics mode
  #elif defined(__VZ200__) || defined(__VG5000__) || defined(__P2000__)
        clg();  // activate graphics mode
        printf("%c",12);   // we clear the screen...
        printf("\n\n",12); // ...and move a little down because otherwise the huge 4x6 letters wouldn't fit on the screen
  #endif

  plot(1,1);
  plot(3,3);
  plot(5,5);
  unplot(5,5);
  plot(7,7);
    
  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)); // should be 1
  printf("point(5,5)   (unplotted) is %d\n",point(5,5)); // should be 0
  printf("point(10,10) (blank)     is %d\n",point(10,10)); // should be 0

  // check if the screen dimensions for this platform have been defined above
  if (xMax>0 && yMax>0)
  { 
          printf("\npress any key to draw border\n");
          fgetc_cons();        // wait for keypress
          for (x = 0; x <=xMax; ++x)
          {
                plot(x,yMax);
                plot(x,0);
          }
          for (y = 1; y <=yMax; ++y)
          {
                plot(0,y);
                plot(xMax,y);
          }
  }
  
  printf("\npress any key to clear screen\n");
  fgetc_cons();        // wait for keypress
  printf("%c",12); // clear the screen 
  
  printf("done.\n");
  fgetc_cons();        // wait for keypress        
}
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

FYI, a new behaviour is now present on the EG2000, the graphics try to work with a 160x102 resolution, but the earlier models would show only the first 100 lines.
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

RobertK wrote:BTW, it seems that compiling for the TRS-80 with the subtype "disk" is broken now. With yesterdays nightly when you compile like this...

zcc +trs80 -lndos -lm -create-app -o plottest_trs80.bin -subtype=disk plottest.c

...at this step...

PROCESSING lgfxtrs80.asm.m4
m4 -I "C:\Misc\z88dk\lib\config\\..\..\\lib\target\trs80\classic" -I "C:\Misc\z88dk\lib\config\\..\..\/src/m4" < "lgfxtrs80.asm.m4" > "C:\Users\ws09.PSC\AppData\Local\Temp\zccD5B53"

...you get a "file not found" error. Without the subtype parameter it works.
It's processing a file "lgfxtrs80" that doesn't exist. It looks like the command line has "lgfxtrs80" instead of "-lgfxtrs80" to link that as a library. But lib/config/trs80.cfg still has the minus there in subtype disk.
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

stefano wrote:FYI, a new behaviour is now present on the EG2000, the graphics try to work with a 160x102 resolution, but the earlier models would show only the first 100 lines.
Hmm, I tried if maybe a 160x100 screen would be shown entirely on the Genieous emulator screen, but it wasn't. The last visible line is 95, that means a 160x96 fits on the screen.

So a workaround after calling yMax=getmaxy(); would be:

Code: Select all

  #if defined(__EG2000__)
        if (yMax==101) yMax=95;
  #endif
But we still don't know if the down-shifted screen is maybe really a feature of the emulator, so better don't spend too much time with that.
alvin wrote:It's processing a file "lgfxtrs80" that doesn't exist. It looks like the command line has "lgfxtrs80" instead of "-lgfxtrs80" to link that as a library. But lib/config/trs80.cfg still has the minus there in subtype disk.
No, it was a problem in one of the nightly builds that you have already fixed, see your reply #26. For the TRS-80 target everything works fine again.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

>Hmm, I tried if maybe a 160x100 screen would be shown entirely on the Genieous emulator screen, but it wasn't. The last visible >line is 95, that means a 160x96 fits on the screen

I tested the libraries before releasing them and I was sure that 'genieous' was putting 100 <> 102 pixels depending on the model being emulated. I'll check it again.
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Ah, sorry, now I have found the machine configuration options in the Genieous emulator.
And with both 25 row machine types, the entire border is visible (albeit a little shifted downwards).
So the problem only affects the 24 row machine where line number 95 is the last visible line.
Maybe on the 24 row machine the getmaxy() function should simply return 95?
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

getmaxx() and getmaxy() are bound to the graphics constants for the target computer.
I chose to have 102 rows because it doesn't harm the earlier variants, but obviously it will force a programmer to deal with this margin, either hardcoding the max y coordinate or rebuilding the library with the wanted value for ymax.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

@Stefano you should be able to do it with a pragma, export maxx from the crt file - see how I did CONSOLE_ROWS/CONSOLE_COLUMNS
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Thankyou Dom, I thught at it but I wonder if it is worth the extra complexity + the few extra bytes or extra compilation slowness: getmaxx(), getmaxy() are simply answering to the parameters used in building the library, the same boundaries are (should be) used on every function to permit the program to go out of screen without crashing (a mess often still happens, but normally it is less painful).
A generic program would loose 2 (expected by me) to 7 (measured by RobertK) extra rows on the earlier EG2000 models, no crashes.

E.G. in my experiments the lower 4x6 text row fits perfectly on the later models and looks slightly chopped on the earlier ones: to accept it or to slightly shift something is to reduce/avoid this effect would always require a more accurate programmer's intervention than simply suggest a different answer for getmaxy(). That's why I'd go with a custom constant where needed.
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Could you please check this final remaining lo-res plotting problem when you find the time?

On any Robotron Z9001 colour system...

Image

...when you compile my test program (use the latest source posted above) like this...

zcc +z9001 -lm -lgfx9001 -o plottest_z9001 -create-app plottest.c

...the result is correct:

Image

But when you add the -clib=ansi parameter...

zcc +z9001 -lm -lgfx9001 -clib=ansi -o plottest_z9001_ansi -create-app plottest.c

...the screen looks like this:

Image

The text output cannot be seen, and - not shown in this screenshot - some of the plotted points do not appear.

As a workaround, I tried using the native console instead of conio.h and compiling without -clib=ansi, but then gotoxy() has no effect, and a blinking cursor is visible after the last printed text.
Post Reply