feat: add warning in DOOM for missing wad

This commit is contained in:
2026-07-09 11:43:21 +02:00
parent 33d850b9ad
commit 08d3cbe218
4 changed files with 83 additions and 11 deletions
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once #pragma once
#define MONTAUK_BUILD_NUMBER 6 #define MONTAUK_BUILD_NUMBER 7
+38 -2
View File
@@ -9,9 +9,11 @@ MAKEFLAGS += -rR
TOOLCHAIN_PREFIX := $(shell cd ../../.. && pwd)/toolchain/local/bin/x86_64-elf- TOOLCHAIN_PREFIX := $(shell cd ../../.. && pwd)/toolchain/local/bin/x86_64-elf-
ifneq ($(wildcard $(TOOLCHAIN_PREFIX)gcc),) ifneq ($(wildcard $(TOOLCHAIN_PREFIX)gcc),)
CC := $(TOOLCHAIN_PREFIX)gcc CC := $(TOOLCHAIN_PREFIX)gcc
CXX := $(TOOLCHAIN_PREFIX)g++
LD := $(TOOLCHAIN_PREFIX)gcc LD := $(TOOLCHAIN_PREFIX)gcc
else else
CC := gcc CC := gcc
CXX := g++
LD := gcc LD := gcc
endif endif
@@ -21,6 +23,7 @@ DOOM_SRC := ../../../doomgeneric/doomgeneric
LIBC_INC := ../../include/libc LIBC_INC := ../../include/libc
PROG_INC := ../../include PROG_INC := ../../include
LIBDIR := ../../lib LIBDIR := ../../lib
LOADER_LIB := ../../lib/libloader
LINK_LD := ../../link.ld LINK_LD := ../../link.ld
BINDIR := ../../bin BINDIR := ../../bin
OBJDIR := obj OBJDIR := obj
@@ -58,6 +61,32 @@ CFLAGS := \
-I $(DOOM_SRC) \ -I $(DOOM_SRC) \
-isystem $(shell $(CC) -print-file-name=include) -isystem $(shell $(CC) -print-file-name=include)
CXXFLAGS := \
-std=gnu++20 \
-g -O2 -pipe \
-Wall \
-Wno-unused-parameter \
-nostdinc \
-ffreestanding \
-fno-stack-protector \
-fno-stack-check \
-fno-PIC \
-fno-rtti \
-fno-exceptions \
-ffunction-sections \
-fdata-sections \
-m64 \
-march=x86-64 \
-msse \
-msse2 \
-mno-red-zone \
-mcmodel=small \
-isystem $(LIBC_INC) \
-I . \
-I $(PROG_INC) \
-isystem ../../../kernel/freestnd-c-hdrs/x86_64/include \
-isystem ../../../kernel/freestnd-cxx-hdrs/x86_64/include
# ---- Linker flags ---- # ---- Linker flags ----
LDFLAGS := \ LDFLAGS := \
@@ -157,12 +186,14 @@ DOOM_SRCS := \
# Local source files # Local source files
LOCAL_SRCS := doomgeneric_montauk.c i_sound_montauk.c LOCAL_SRCS := doomgeneric_montauk.c i_sound_montauk.c
LOCAL_CXX_SRCS := doom_wad_check.cpp
# ---- Object files ---- # ---- Object files ----
DOOM_OBJS := $(addprefix $(OBJDIR)/,$(DOOM_SRCS:.c=.o)) DOOM_OBJS := $(addprefix $(OBJDIR)/,$(DOOM_SRCS:.c=.o))
LOCAL_OBJS := $(addprefix $(OBJDIR)/,$(LOCAL_SRCS:.c=.o)) LOCAL_OBJS := $(addprefix $(OBJDIR)/,$(LOCAL_SRCS:.c=.o))
ALL_OBJS := $(DOOM_OBJS) $(LOCAL_OBJS) LOCAL_CXX_OBJS := $(addprefix $(OBJDIR)/,$(LOCAL_CXX_SRCS:.cpp=.o))
ALL_OBJS := $(DOOM_OBJS) $(LOCAL_OBJS) $(LOCAL_CXX_OBJS)
# ---- Target ---- # ---- Target ----
@@ -174,7 +205,7 @@ all: $(TARGET)
$(TARGET): $(ALL_OBJS) $(LINK_LD) Makefile $(TARGET): $(ALL_OBJS) $(LINK_LD) Makefile
mkdir -p $(BINDIR)/apps/doom mkdir -p $(BINDIR)/apps/doom
$(LD) $(CFLAGS) $(LDFLAGS) $(ALL_OBJS) $(LIBDIR)/libc/liblibc.a -o $@ $(LD) $(CFLAGS) $(LDFLAGS) $(ALL_OBJS) $(LOADER_LIB)/liblibloader.a $(LIBDIR)/libc/liblibc.a -o $@
# DOOM source files (from doomgeneric directory) # DOOM source files (from doomgeneric directory)
$(OBJDIR)/%.o: $(DOOM_SRC)/%.c Makefile $(OBJDIR)/%.o: $(DOOM_SRC)/%.c Makefile
@@ -186,6 +217,11 @@ $(OBJDIR)/%.o: %.c Makefile
mkdir -p $(OBJDIR) mkdir -p $(OBJDIR)
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@ $(CC) $(CFLAGS) -MMD -MP -c $< -o $@
# Local C++ source files
$(OBJDIR)/%.o: %.cpp Makefile
mkdir -p $(OBJDIR)
$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@
clean: clean:
rm -rf $(OBJDIR) $(TARGET) rm -rf $(OBJDIR) $(TARGET)
+22
View File
@@ -0,0 +1,22 @@
/*
* doom_wad_check.cpp
* Warns the user and exits cleanly if no DOOM WAD is present
* Copyright (c) 2026 Daniel Hammer
*/
#include <gui/dialogs.hpp>
#include <montauk/syscall.h>
#include <stdio.h>
extern "C" [[noreturn]] void doom_warn_missing_wad(const char* path) {
char message[400];
snprintf(message, sizeof(message),
"No DOOM WAD file was found at %s.\n\n"
"MontaukOS cannot ship proprietary DOOM WADs (doom1.wad, doom.wad, "
"freedoom1.wad, etc.) on its ISO images due to copyright restrictions.\n\n"
"Copy a legally obtained WAD file to that path and relaunch DOOM.",
path);
gui::dialogs::message_box("DOOM", message, gui::dialogs::MESSAGE_BOX_OK);
montauk::exit(1);
}
+15 -1
View File
@@ -246,8 +246,22 @@ void DG_SetWindowTitle(const char* title) {
/* ---- Entry point ---- */ /* ---- Entry point ---- */
/* Shows a warning dialog explaining that MontaukOS cannot ship proprietary
* DOOM WADs and does not return (implemented in doom_wad_check.cpp, which
* links against the shared dialog library). */
extern void doom_warn_missing_wad(const char* path);
void _start(void) { void _start(void) {
char *argv[] = { "doom", "-iwad", "0:/apps/doom/doom1.wad", 0 }; static const char* wadPath = "0:/apps/doom/doom1.wad";
FILE* wad = fopen(wadPath, "rb");
if (!wad) {
doom_warn_missing_wad(wadPath);
/* unreachable: doom_warn_missing_wad() exits the process */
}
fclose(wad);
char *argv[] = { "doom", "-iwad", (char*)wadPath, 0 };
doomgeneric_Create(3, argv); doomgeneric_Create(3, argv);
for (;;) { for (;;) {
doomgeneric_Tick(); doomgeneric_Tick();