The Hires Galaksija Plus version of H-Tron is already available on available on my Sourceforge site.
Yes, using -lmath48 instead of -lm had indeed solved the floating point problem, my WIP program works fine now.
However, I have found another issue that I could reproduce on both MAME and the ZX-Uno. After switching back from graphics mode to text mode for the first time, the text screen is no longer centered.
Here is a test program to reproduce this:
Code: Select all
// smt.c
// Test program for screen mode switching on the Galaksija Plus and the NEC PC-6001 Mk2
// (also for MC-1000, Tiki-100 or Samsung SPC-1000, but not tested yet on these systems)
// Author: RobertK, 2019-01-07
// Compile with:
// zcc +gal -subtype=galaxyp -create-app -pragma-redirect:fputc_cons=fputc_cons_generic -pragma-redirect:CRT_FONT=_font_8x8_bbc_system -o smtgalplus smt.c -D__GALPLUSHIRES__
// zcc +pc6001 -subtype=rom -pragma-redirect:fputc_cons=fputc_cons_generic -pragma-redirect:CRT_FONT=_font_8x8_bbc_system -create-app -o smt_pc6001Mk2 smt.c
#include <stdio.h>
#include <graphics.h>
#include <sys/ioctl.h> // required for switching the screen mode
void myCls() // Clear the screen (generic or VT100 console)
{
printf("%c",12);
printf("\x0c"); // the "\x0c" (0x0c character) resets the cursor position to the top left corner
}
void main()
{
int XScreenSize,YScreenSize; // dimensions of the text screen
int xMax,yMax; // dimensions of the graphics screen
int mode; // for screen mode switching
int x,y;
char c; // for keyboard input
int exitProgram=0;
// determine screen size
screensize(&XScreenSize, &YScreenSize);
/* main loop */
while(exitProgram<1)
{
// Text screen
myCls(); // Clear the screen
// Draw a screen border using the character "x"
for (x = 0; x <XScreenSize; ++x)
{
gotoxy(x,YScreenSize-1);
printf("x");
gotoxy(x,0);
printf("x");
}
for (y = 1; y <YScreenSize; ++y)
{
gotoxy(0,y);
printf("x");
gotoxy(XScreenSize-1,y);
printf("x");
}
gotoxy(2,2);
printf("text screen test");
gotoxy(2,4);
printf("screen size: x=%d, y=%d\n",XScreenSize,YScreenSize);
gotoxy(2,6);
printf("press x to exit, any");
gotoxy(2,7);
printf("other key to switch");
gotoxy(2,8);
printf("to graphics mode...");
c = fgetc_cons(); // wait for keypress
if (c=='x' || c=='X')
exitProgram=1;
else
{
// Graphics Screen
// switch to hires mode
mode = 1;
console_ioctl(IOCTL_GENCON_SET_MODE, &mode);
// clg();
// determine the screen dimensions for this system
// coordinates go from 0 to this max value
xMax=getmaxx();
yMax=getmaxy();
// Draw a screen border
for (x = 0; x <=xMax; ++x)
{
plot(x,yMax);
plot(x,0);
}
for (y = 1; y <=yMax; ++y)
{
plot(0,y);
plot(xMax,y);
}
gotoxy(2,2);
printf("graphics screen test");
gotoxy(2,4);
printf("screen size: x=%d, y=%d\n",xMax+1,yMax+1);
gotoxy(2,6);
printf("press x to exit, any");
gotoxy(2,7);
printf("other key to switch");
gotoxy(2,8);
printf("to text mode...");
c = fgetc_cons(); // wait for keypress
if (c=='x' || c=='X') exitProgram=1;
// switch back to text mode
mode = 0;
console_ioctl(IOCTL_GENCON_SET_MODE, &mode);
}
}
myCls(); // Clear the screen
return;
}
And here is the result, first in MAME...
...and here in FPGA on the ZX-Uno:
(On the second screen it should of course be "switch to text mode" instead of graphics mode, I didn't notice that error before I made the screenshots.)
For some reason, on the FPGA in graphics mode only the top line of the screen border is visible. This could be a bug in the ZX-Uno Galaksija core, there can of course be errors in such an FPGA implementation just as in an any emulator.
On the FPGA Galaksija Plus, when you type GRAPHICS and then TEXT, you briefly see the vertical full block line appearing, but then it goes away and the screen goes into position to the left again, so the characters are always at the same locations (you see their font changing) - probably the real hardware also behaves like that.