for a while now I've been working to add the C1P as a target for the cc65 C compiler (https://github.com/cc65/cc65). I think it's functional enough to share the current state.
Demo program:
Code: Select all
/*
* Challenger 1P Hello World Program for cc65.
*/
#include <conio.h>
int main(void)
{
static const char hello_world[] =
"Hello world!\r\ncc65 for Challenger 1P";
unsigned int i;
clrscr();
gotoxy(0, 0);
cputs(hello_world);
gotoxy(0, 4);
for (i = 0; i < 256; i += 1) {
if (i != '\n' && i != '\r') {
cputc((unsigned char ) i);
}
}
cputsxy(0, 14, "cputsxy\r\n");
cprintf("cprintf '%s' %d %d\r\n", "string", (int) wherex(), (int) wherey());
cputs("now type something:\r\n");
while (1) {
char c = cgetc();
cputc(c);
}
return 0;
}
http://www.pcjs.org/docs/c1pjs/
My current approach for the C1P object file format is to convert the binary file produced by the cc65 linker into an ASCII file that can be loaded via the PROM monitor. So far I've tested the compiled programs only in the C1Pjs simulator, as the serial port on my C1P is not working yet.
The code is on GitHub in my fork of the cc65 project:
https://github.com/smuehlst/cc65
A separate repository contains the test programs:
https://github.com/smuehlst/c1pctest
The repositories should be cloned side-by-side, and after the build of the compiler it should be possible to build the test programs in the "c1ptest/src" directory. The object files to upload have the suffix ".c1p".
Documentation is rather rudimentary, and currently the build of the cc65 compiler and the runtime library is only tested on Windows.
Let me know what you think. I will step by step continue to complete the implementation of the "conio" portion of the runtime library. Currently I'm doing this for my own fun, but if there's enough interest, I will contact the cc65 guys and ask what is necessary to get that integrated into the main cc65 repository.
Best Regards
Stephan