Page 1 of 1
Extending the Sinclair BASIC with C
Posted: Wed Jun 15, 2022 9:01 am
by stefano
I'm sure some of you will find this trick intriguing:
Code: Select all
#include <stdio.h>
#include <arch/zx/spectrum.h>
main(int arg2, char *arg1)
{
ARG_STR;
ARG_INT;
ARG_END;
printf("Arg1: %s, arg2: %d \n", arg1 ,arg2);
STMT_RET;
}
zx-basic-c.png
Re: Extending the Sinclair BASIC with C
Posted: Wed Jun 15, 2022 3:15 pm
by stefano
Attempting to gather a similar result on the ZX81 is more tricky.
The string termination patch works but the text requires to be converted to ASCII, or a bit of trickery with zx_asciimode(0)/zx_asciimode(1).
("-*114" = "HELLO")
Moreover I still haven't found a robust way to get back to the BASIC interpreter, due to the same reasons preventing zx_goto() to work on the ZX81.
Probably a bit of hacking around exit() will work
zx81-basic-c.png
Re: Extending the Sinclair BASIC with C
Posted: Wed Jun 15, 2022 3:29 pm
by stefano
2-zx-basic-c.png
Solved !
...to show "HELLO" correctly:
Code: Select all
#include <stdio.h>
#include <zx81.h>
main(unsigned int arg2, char *arg1)
{
ARG_STR;
ARG_UINT;
ARG_END;
printf("Arg1: ");
zx_asciimode(0);
printf("%s", arg1);
zx_asciimode(1);
printf(", arg2: %u \n" ,arg2);
STMT_RET;
}
Re: Extending the Sinclair BASIC with C
Posted: Thu Jun 16, 2022 8:23 pm
by stefano
Just extended support to Lambda 8300 and TS2068
Re: Extending the Sinclair BASIC with C
Posted: Wed Jun 22, 2022 9:06 pm
by stefano
Just to show myself that this could be useful, I tried to export few of the zx81 graphics functions to its BASIC interpreter.
https://www.sinclairzxworld.com/viewtop ... 192#p47192
It permitted me to identify a number of bugs I totally forgot to fix. .