Initial commit, basically just a 'hello world' with a Makefile

This commit is contained in:
Harry Culpan 2026-07-05 20:22:44 -04:00
parent 0da73eddc6
commit 840f75020a
6 changed files with 94 additions and 0 deletions

1
.gitignore vendored
View file

@ -36,6 +36,7 @@
*.i*86 *.i*86
*.x86_64 *.x86_64
*.hex *.hex
*.img
# Debug files # Debug files
*.dSYM/ *.dSYM/

64
Makefile Normal file
View file

@ -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

6
include/util.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef _UTIL_H_
#define _UTIL_H_
void displayMessage(int n);
#endif

3
ow_setup.sh Executable file
View file

@ -0,0 +1,3 @@
export WATCOM=~/openwatcom_c
export PATH=$WATCOM/bin:$WATCOM/binl:$WATCOM/binw:$PATH
export INCLUDE=$WATCOM/lh

15
src/main.c Normal file
View file

@ -0,0 +1,15 @@
#include <stdio.h>
#include "util.h"
void main() {
int i = 0;
printf("DSPACE starting...\n");
for (i = 0; i < 10; i++) {
displayMessage(i + 1);
}
return;
}

5
src/util.c Normal file
View file

@ -0,0 +1,5 @@
#include <stdio.h>
void displayMessage(int n) {
printf("%02d: Hello MS-DOS!\n", n);
}