Getting Stuck in the 1970s with a Modern C Compiler

in #retro3 days ago

I've been getting back into retro programming, and the plan has always been to start with the earliest machines and work up to closer to present-day.

This has been fun, getting elbow-deep in the systems of the 1970s and early 1980s. The very start of personal computing.

My issues started when I wanted to write "real" programs, and playable games, rather than simple tech demos.

Simple CP/M examples can be created right on the machine - edited with ZDE and then compiled with Hi-tech C (CP/M-80) V3.09.

In those days you would have to output escape codes, special codes that the dumb terminal would interpret, to do anything other than output lines of text. Think about the difference between a printer outputting a page of writing versus a data entry form where the input boxes can be anywhere on the screen.

The codes are simple but your program and the output device need to match up.

For example, the following program clears the screen, turns off the cursor, and then locates the cursor position to 10,10 before printing the message.

void gotoxy(char x,char y) {
     printf("\033[%d;%dH", (y), (x));
}

void main() {
     printf("\033[2J");
     printf("\033[?25l");
     gotoxy(10,10);
     printf("Hello World!");
}

For large programs it is easier to use z88dk and cross-Compile to create Z80 Pack compatible disks:

zcc +cpm -lm -o cpm-keyb.com -subtype=z80pack -create-app cpm-keyb.c

The problem is that stops it being VT100 compatible.

image.png

Trying -pragma-need=ansiterminal with CP/M target doesn't seem to take.

So I went down a rabbit hole of parameters.

For CPM, this supposedly compiles compatible with a 'console' of 80x24:

zcc +cpm -o cpm-conio.com -subtype=z80pack -create-app cpm-conio.c --generic-console -pragma-define:CONSOLE_COLUMNS=80 -pragma-define:CONSOLE_ROWS=24

But in my IMSAI 8080 I have to also add VIO and use the CRT emulation:

zcc +cpm -o cpm-conio.com -subtype=z80pack -create-app cpm-conio.c --generic-console -pragma-define:CONSOLE_COLUMNS=80 -pragma-define:CONSOLE_ROWS=24 --vio

This requires for me to use the VIO BIOS like so:

image.png

It also requires the startup NVM to be set to allow this:

image.png

This works but I am not happy with constraining the program to people with this setup - a more compatible option would be plain VT100 escape codes as I started out with.

image.png

I have no idea why the modern C compiler is more device-specific than the 1980s one but it is getting frustrating!

In researching the issue I have come across a forum for the cross-compiler at https://www.z88dk.org/forum so wish me luck!

Sort:  

I admire your dedication. I'm quite happy that programming has moved on.