new approach for dos port

This commit is contained in:
veclavtlica
2026-10-08 13:46:16 +03:00
parent dc594e5e82
commit b92458862e
6 changed files with 190 additions and 119 deletions
+14 -5
View File
@@ -3,8 +3,9 @@ RELEASE ?= 0 # Optimize.
DEBUG ?= 1 # Emit debug info.
SQUEEZE ?= 0 # Nuclear option to save space.
BITS ?= 64
CFLAGS = -Wall -std=gnu99 -flto=thin -ffast-math -fno-ident -fvisibility=hidden
CFLAGS = -Wall -std=gnu99 -flto=thin -ffast-math -fno-ident -fvisibility=hidden -fuse-ld=lld
ifeq ($(MAKECMDGOALS),linux)
CFLAGS += -fno-pic -fno-pie
ifeq ($(RELEASE), 1)
CFLAGS += -Wl,--ignore-data-address-equality -Wl,--ignore-function-address-equality \
-Wl,--optimize-bb-jumps
@@ -30,7 +31,7 @@ else
CFLAGS += -DNDEBUG -Wl,--strip-all
endif
ifeq ($(RELEASE), 1)
CFLAGS += -O1 -fuse-ld=lld -fmerge-all-constants -Wl,-O3 \
CFLAGS += -O3 -fmerge-all-constants -Wl,-O3 \
-ffunction-sections -fdata-sections -Wl,--gc-sections \
-Wl,-mllvm,--vectorize-slp=true \
-Wl,-mllvm,--enable-gvn-hoist=true
@@ -49,6 +50,9 @@ DOS = maindos.c Display/dos.c
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
%.o: %.s $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
# TODO: Make it work with no stdlib.
linux: CFLAGS += -static -mbmi2 -nostdlib
linux: $(LINUX) | $(SRC)
@@ -59,9 +63,14 @@ wasm: CFLAGS += --target=wasm32 -nostdlib -Wl,--no-entry -msimd128 -mbulk-memory
wasm:
$(CC) -o player.wasm $(WASM) $(CFLAGS)
# TODO: Use https://github.com/amindlost/pmodew
dos: $(DOS) $(DEPS)
wcl386 -bt=dos4g -ox -l=dos4g $(DOS)
# https://tippach.hier-im-netz.de/wdosx
dos: CFLAGS += -ffreestanding -m32 -fno-PIC -fno-PIE -no-pie -nostdlib -nodefaultlibs
dos:
$(CC) -c ./Main/dos.s -o ./Main/dos.o $(CFLAGS)
$(CC) -c ./Display/dos.c -o ./Display/dos.o $(CFLAGS)
ld.lld -m elf_i386 --oformat binary -Ttext 0x0 --image-base=0x0 ./Main/dos.o ./Display/dos.o -o dos.bin
dosbox -noconsole -c "mount c $(PWD)" -c "c:" -c "WDOSX\STUBIT.EXE DOS.BIN" -exit
mv ./DOS.BIN ./DOS.EXE
clean:
rm -r *.o ../*.o