From 840f75020a3c03b23d1d261359b3e1e83b574c60 Mon Sep 17 00:00:00 2001 From: Harry Culpan Date: Sun, 5 Jul 2026 20:22:44 -0400 Subject: [PATCH] Initial commit, basically just a 'hello world' with a Makefile --- .gitignore | 1 + Makefile | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/util.h | 6 +++++ ow_setup.sh | 3 +++ src/main.c | 15 ++++++++++++ src/util.c | 5 ++++ 6 files changed, 94 insertions(+) create mode 100644 Makefile create mode 100644 include/util.h create mode 100755 ow_setup.sh create mode 100644 src/main.c create mode 100644 src/util.c diff --git a/.gitignore b/.gitignore index c8bb3af..3a5445f 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ *.i*86 *.x86_64 *.hex +*.img # Debug files *.dSYM/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8afdb2c --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +# Directory layout +SRCDIR = src +OBJDIR = obj +INCDIR = include + +# Compiler and flags +CC = wcc386 +LD = wlink +CFLAGS = -zq -i=$(INCDIR) + +# Project name (root) — everything else derives from this +NAME = dspace +TARGET = $(NAME).exe +IMG = $(NAME).img + +# Deploy location for testing in DOSBox-X +DOSBOX_DRIVE = ~/DosBox-x/C_Drive + +# OpenWatcom DOS extender stub, needed on the disk image alongside TARGET +DOS4GW = ~/openwatcom_c/binw/dos4gw.exe + +# Disk image geometry (1.44MB floppy, FAT12) +IMG_BLOCKS = 1440 +IMG_FAT = 12 + +# Source and object files +SRCS = $(wildcard $(SRCDIR)/*.c) +OBJS = $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SRCS)) +DEPS = $(OBJS:.o=.d) + +# Default target +all: $(TARGET) + +# Link object files into executable +$(TARGET): $(OBJS) + $(LD) system dos4g name $@ file { $(OBJS) } + +# Compile .c files to .o files, with auto-dependency generation +$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR) + $(CC) -fo=$@ $(CFLAGS) -ad=$(@:.o=.d) -adfs $< + +# Ensure obj/ exists before any compile runs +$(OBJDIR): + mkdir -p $(OBJDIR) + +# Pull in auto-generated header dependencies (silently ignored if missing) +-include $(DEPS) + +# Clean up build artifacts +clean: + rm -f $(OBJS) $(DEPS) $(TARGET) $(IMG) + +test: $(TARGET) + cp $(TARGET) $(DOSBOX_DRIVE)/ + echo 'Ready to test' + +image: $(TARGET) + rm -f $(IMG) + dd if=/dev/zero of=$(IMG) bs=1024 count=$(IMG_BLOCKS) + mkfs.vfat -F $(IMG_FAT) $(IMG) + mcopy -i $(IMG) $(TARGET) :: + mcopy -i $(IMG) $(DOS4GW) :: + +.PHONY: all clean test image diff --git a/include/util.h b/include/util.h new file mode 100644 index 0000000..81c2263 --- /dev/null +++ b/include/util.h @@ -0,0 +1,6 @@ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +void displayMessage(int n); + +#endif diff --git a/ow_setup.sh b/ow_setup.sh new file mode 100755 index 0000000..0eaa6d2 --- /dev/null +++ b/ow_setup.sh @@ -0,0 +1,3 @@ +export WATCOM=~/openwatcom_c +export PATH=$WATCOM/bin:$WATCOM/binl:$WATCOM/binw:$PATH +export INCLUDE=$WATCOM/lh diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..eb9662b --- /dev/null +++ b/src/main.c @@ -0,0 +1,15 @@ +#include + +#include "util.h" + +void main() { + int i = 0; + + printf("DSPACE starting...\n"); + + for (i = 0; i < 10; i++) { + displayMessage(i + 1); + } + + return; +} diff --git a/src/util.c b/src/util.c new file mode 100644 index 0000000..7e20c47 --- /dev/null +++ b/src/util.c @@ -0,0 +1,5 @@ +#include + +void displayMessage(int n) { + printf("%02d: Hello MS-DOS!\n", n); + }