why did I decide to do DOS development
writing shit in pure C fucking sucks
and i decided to do it for DOS with nothing more than fucking Watcom C (thankfully I cross-compile, it probably helps my sanity a little)
apparently Watcom has a wmake command that is not compatible with GNU make so I'm just using GNU make instead because I at least know how to write Makefiles and I don't want to learn again
and also I'm incredibly stupid so my code somehow calls an ILLEGAL INTERRUPT 6 which hangs dosbox-x
but at least I'm not writing assembly am I???
spoiler alert
(jk writing C that old is basically just fancy macroassembly)
if you wish to see my struggles (also because openwatcom license is STUPID AS HELL and I am thinking of printing it and taking my Nerf gun to it to unleash my inner Doomguy) here you go
#include <conio.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
void main(int argc, char* argv[]) {
int i;
int file;
struct stat* stats;
char* buf;
printf("Hello, world\nGot passed %i arguments\n", argc);
for (i = 0; i < argc; i++) {
printf("argv[%i]: %s\n", i, argv[i]);
}
file = open("hello.c", O_RDONLY | O_TEXT);
if (file == -1) {
goto file_fail;
}
if (fstat(file, stats) == -1) {
goto stat_fail;
}
printf("Opened file handle: %i, size: %i bytes\n", file, stats->st_size);
buf = malloc(stats->st_size);
if (buf == 0) {
goto alloc_fail;
}
printf("Buffer location: 0x%p\n", buf);
i = read(file, buf, stats->st_size);
// Force null byte
if (i == -1) {
goto read_fail;
}
buf[i] = '\0';
printf("Read %i bytes. Press any key to continue . . . ", i);
fflush(stdout);
getch();
printf("Here's ur data:\n%s", buf);
free(buf);
free(stats);
close(file);
exit(0);
read_fail:
free(buf);
alloc_fail:
free(stats);
stat_fail:
close(file);
file_fail:
if (errno == 0) {
printf("Error: memory allocation failure\n");
} else {
perror("Error: ");
}
exit(1);
}