Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
c2829e0
Fixes required for MacOS and QT6
bdpedersen Apr 24, 2025
20895c2
int32 clarification
bdpedersen Apr 26, 2025
d6343b5
Merge branch 'doomhack:master' into master
bdpedersen Nov 22, 2025
c13ceed
Added makefile for Linux/MacOS
bdpedersen Nov 22, 2025
8e5b023
[WiP] fixing compiler warnings
bdpedersen Nov 22, 2025
070adea
[WiP] More compiler warning
bdpedersen Nov 22, 2025
deb94de
[WiP] more warning cleaning
bdpedersen Nov 22, 2025
f0ec505
[WiP] even more compiler warnings fixed - strong types around thinkin…
bdpedersen Nov 22, 2025
1c40e5e
Building using Makefile.posix with -Werror enabled
bdpedersen Nov 22, 2025
59df749
Warning clean
bdpedersen Nov 27, 2025
cfee979
Bugfix in P_ThinkerFunctionForType() to fix moving fireballs - and ot…
bdpedersen Dec 8, 2025
f247a36
Removed C source
bdpedersen Dec 13, 2025
f0f59bf
Makefile cleanup
bdpedersen Dec 13, 2025
99053b9
C++ baseline
bdpedersen Dec 13, 2025
fd5bace
Baseline for newcache introduction
bdpedersen Dec 14, 2025
19919e9
[WiP] first few files migrated to newcache - POC running
bdpedersen Dec 14, 2025
c20c6f1
Colormaps moved to newcache
bdpedersen Dec 14, 2025
3d0c120
r_hotpath moved to newcache wrt. numbered lumps
bdpedersen Dec 14, 2025
15ed30a
r_hotpath moved to newcache wrt. numbered lumps (actually)
bdpedersen Dec 14, 2025
8452b28
Demo moved to newcache
bdpedersen Dec 14, 2025
5815aa8
wi_stuff moved to newcache
bdpedersen Dec 14, 2025
ed972fc
Pallete handling moved to newcache
bdpedersen Dec 14, 2025
b8e1de5
Moved m_menu to newcache
bdpedersen Dec 14, 2025
663b5b4
moved font handling to newcache
bdpedersen Dec 14, 2025
94233f5
texture patches moved to newcache
bdpedersen Dec 14, 2025
38ff739
vertex objects moved to newcache
bdpedersen Dec 14, 2025
bb3c252
segment objects moved to newcache
bdpedersen Dec 14, 2025
723f43b
loadsectors moved to newcache
bdpedersen Dec 14, 2025
f155394
Modified .gitignore
bdpedersen Dec 14, 2025
e09c58d
LoadSubsectors moved to newcache
bdpedersen Dec 15, 2025
50db4ae
nodes moved to newcache
bdpedersen Dec 15, 2025
743d03c
LoadThings moved to newcache
bdpedersen Dec 15, 2025
a3be927
lines moved to newcache
bdpedersen Dec 15, 2025
6fb4046
Reject matrix moved to newcache
bdpedersen Dec 15, 2025
51667b5
loadsidedefs2 moved to newcache
bdpedersen Dec 15, 2025
1a42ed2
blockmap and thereby entire p_setup moved to newcache
bdpedersen Dec 15, 2025
e98e974
Minor fix due to misunderstanding tag
bdpedersen Dec 15, 2025
d848a8e
moved pnames to newcache
bdpedersen Dec 15, 2025
a9a5bdc
Fixed array access in offset cachedbuffer
bdpedersen Dec 15, 2025
b9b4e2d
LoadTexture moved to newcache
bdpedersen Dec 17, 2025
a3ec3bf
GetTextureNumForName moved to newcache
bdpedersen Dec 17, 2025
5a57a1b
InitTextures moved to newcache
bdpedersen Dec 17, 2025
f391303
All objects moved to newcache
bdpedersen Dec 17, 2025
fbba51c
preparing for un-hacking stbar
bdpedersen Dec 17, 2025
234468c
Slight improvement in ergonomy of Cached<>
bdpedersen Dec 18, 2025
1c92707
guardmalloc added
bdpedersen Dec 18, 2025
4b8d86b
Refactored guardmalloc tests
bdpedersen Dec 20, 2025
ee4803e
Refactored directory structure to prepare for caching refactoring
bdpedersen Dec 22, 2025
d80db4f
Removed w_wad dependency to make space for clean newcache implementat…
bdpedersen Dec 22, 2025
eff7765
Introduced pinning infrastructure in NewCache
bdpedersen Dec 22, 2025
c3b28e1
[WiP] cleaning out pointer stealing
bdpedersen Dec 22, 2025
8b8c85c
Moved line logic to newcache
bdpedersen Dec 22, 2025
7f1bb9c
Minor fixes around pinning
bdpedersen Dec 22, 2025
203ba78
Major rework of moving lines to newcache
bdpedersen Dec 22, 2025
6f593ce
Game working on guard malloc
bdpedersen Dec 22, 2025
828eabd
Cleaned up junk and aligned with stbar
bdpedersen Dec 23, 2025
33ec119
Refactored GetNameForNum to not rely on pointer stealing
bdpedersen Dec 23, 2025
ddb6b4d
minimem cache introduced
bdpedersen Dec 23, 2025
3cc5919
Moved minimem to full file access
bdpedersen Dec 23, 2025
d39f2a7
Moved thinkers to per-level allocation
bdpedersen Dec 23, 2025
cf303a8
[WiP] tagheap added
bdpedersen Dec 24, 2025
7e5773a
[WiP] first version of the tagheap
bdpedersen Dec 25, 2025
1dfd2dd
tagheap tested and debugged.
bdpedersen Dec 25, 2025
c7bfc9c
Infrastructure now in place for creating the cache
bdpedersen Dec 25, 2025
f1fe6e8
extra tests of realloc
bdpedersen Dec 25, 2025
75cf28a
[WiP] non-working but complete cache
bdpedersen Dec 26, 2025
04bfd4f
First working version with new cache - all elements are in play (defr…
bdpedersen Dec 26, 2025
9f1a929
Played a little with memory size
bdpedersen Dec 26, 2025
d6c2923
Silenced memory chatter from newcache
bdpedersen Dec 27, 2025
5006ccc
Moved z_bmalloc to newcache
bdpedersen Dec 27, 2025
ee1ed02
[WiP] moving rest of memory allocation to newcache
bdpedersen Dec 27, 2025
6d91364
[WiP] still hunting stolen pointers
bdpedersen Dec 27, 2025
1cb6f68
[WiP] Fixing up null pointer handling
bdpedersen Dec 29, 2025
48fea6d
[WiP] Most memory errors now gone - demo runs
bdpedersen Dec 29, 2025
5a8311a
Demo and two levels work now
bdpedersen Dec 29, 2025
5ee1a92
Optimized allocation strategy to save more memory
bdpedersen Dec 29, 2025
0f5b719
Added screenshot and GIF generation
bdpedersen Dec 30, 2025
c2114b3
[WiP] porting guide
bdpedersen Dec 30, 2025
e23a7ca
Ports directory implemented
bdpedersen Dec 30, 2025
ec61498
Standalone rendering of 10 seconds added
bdpedersen Dec 30, 2025
0e0cd37
Constant memory support added
bdpedersen Dec 30, 2025
b1672d4
Parameterized title screen duration
bdpedersen Dec 30, 2025
b1777d1
Porting description added
bdpedersen Dec 30, 2025
d295dcd
Fixed a few issues with disabling memory reporting
bdpedersen Dec 30, 2025
15c218a
moved byte to uint8_t and removed dependency on stdlib
Jan 2, 2026
57eada4
Building on very limited platform
Jan 2, 2026
7af1c31
Fixed point updates
bdpedersen Jan 2, 2026
28003dd
Merge branch 'master' of github.com:bdpedersen/GBADoomPlusPlus
bdpedersen Jan 2, 2026
f22e4c2
Fixed build issues on host
bdpedersen Jan 2, 2026
60529b0
File output in simulator
Jan 2, 2026
8628fae
Various debugging
Jan 2, 2026
05d181c
More memory optimization
bdpedersen Jan 2, 2026
942a334
Lump header cache
bdpedersen Jan 2, 2026
018a88e
Main directory makefile restored
bdpedersen Jan 2, 2026
f9e2736
Removed debug text
bdpedersen Jan 2, 2026
8ff97c5
Fixed CPU load issue in screen wipe
bdpedersen Jan 2, 2026
70a7c0c
Minor fixes on target
Jan 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,12 @@ source/iwad/doom64.c
source/iwad/

.qtc_clangd/
GBADoom
GBADoomCpp
cppbuild/am_map.o cppbuild/d_client.o cppbuild/d_items.o cppbuild/d_main.o cppbuild/doom_iwad.o cppbuild/f_finale.o cppbuild/f_wipe.o cppbuild/g_game.o cppbuild/global_data.o cppbuild/hu_lib.o cppbuild/hu_stuff.o cppbuild/i_audio.o cppbuild/i_main.o cppbuild/i_system_e32.o cppbuild/i_system.o cppbuild/i_video.o cppbuild/info.o cppbuild/lprintf.o cppbuild/m_bbox.o cppbuild/m_cheat.o cppbuild/m_menu.o cppbuild/m_random.o cppbuild/m_recip.o cppbuild/p_ceilng.o cppbuild/p_doors.o cppbuild/p_enemy.o cppbuild/p_floor.o cppbuild/p_genlin.o cppbuild/p_inter.o cppbuild/p_lights.o cppbuild/p_map.o cppbuild/p_maputl.o cppbuild/p_mobj.o cppbuild/p_plats.o cppbuild/p_pspr.o cppbuild/p_setup.o cppbuild/p_sight.o cppbuild/p_spec.o cppbuild/p_switch.o cppbuild/p_telept.o cppbuild/p_tick.o cppbuild/p_user.o cppbuild/r_data.o cppbuild/r_draw.o cppbuild/r_hotpath.iwram.o cppbuild/r_main.o cppbuild/r_patch.o cppbuild/r_plane.o cppbuild/r_things.o cppbuild/s_sound.o cppbuild/sounds.o cppbuild/st_gfx.o cppbuild/st_lib.o cppbuild/st_stuff.o cppbuild/tables.o cppbuild/v_video.o cppbuild/version.o cppbuild/w_wad.o cppbuild/wi_stuff.o cppbuild/z_bmalloc.o cppbuild/z_zone_rpt.o cppbuild/z_zone.o
cppbuild

*.gif

**/screenbuffers/*.raw
**/screenbuffers
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/GBADoomCpp",
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
35 changes: 35 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"makefile.makefilePath": "",
"makefile.launchConfigurations": [
{
"cwd": "/Users/brian/src/GBADoom",
"binaryPath": "/Users/brian/src/GBADoom/GBADoom",
"binaryArgs": []
},
{
"cwd": "/Users/brian/src/GBADoom",
"binaryPath": "/Users/brian/src/GBADoom/GBADoomCpp",
"binaryArgs": []
}
],
"files.associations": {
"bitset": "cpp",
"map": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"__hash_table": "cpp",
"__split_buffer": "cpp",
"__tree": "cpp",
"array": "cpp",
"deque": "cpp",
"initializer_list": "cpp",
"list": "cpp",
"queue": "cpp",
"span": "cpp",
"stack": "cpp",
"string": "cpp",
"string_view": "cpp",
"vector": "cpp"
}
}
2 changes: 1 addition & 1 deletion GBADoom.pro
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ HEADERS += \
include/tables.h \
include/v_video.h \
include/version.h \
include/w_wad.h \

include/wi_stuff.h \
include/z_bmalloc.h \
include/z_zone.h
Expand Down
251 changes: 90 additions & 161 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,177 +1,106 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------

ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif

include $(DEVKITARM)/gba_rules

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
# DATA is a list of directories containing binary data
# GRAPHICS is a list of directories containing files to be processed by grit
#
# All directories are specified relative to the project directory where
# the makefile is found
#
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
INCLUDES := include
DATA := data
MUSIC := music

#---------------------------------------------------------------------------------
# Disable LTO for IWRAM
#---------------------------------------------------------------------------------
%.iwram.o: %.iwram.cpp
$(SILENTMSG) $(notdir $<)
$(SILENTCMD)$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.iwram.d $(CXXFLAGS) -fno-lto -marm -c $< -o $@ $(ERROR_FILTER)

#---------------------------------------------------------------------------------
%.iwram.o: %.iwram.c
$(SILENTMSG) $(notdir $<)
$(SILENTCMD)$(CC) -MMD -MP -MF $(DEPSDIR)/$*.iwram.d $(CFLAGS) -fno-lto -marm -c $< -o $@ $(ERROR_FILTER)

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -mthumb -mthumb-interwork

CFLAGS := -g -Wall -O3 -fgcse-after-reload -gdwarf-4\
-mcpu=arm7tdmi -mtune=arm7tdmi -flto=8\
-fallow-store-data-races -fpermissive\
-DGBA\
$(ARCH)

CFLAGS += $(INCLUDE) -std=gnu11

CXXFLAGS:= $(CFLAGS) -fno-rtti -fno-exceptions

ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map)

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lmm -lgba


#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBGBA)

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------


ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT := $(CURDIR)/$(TARGET)

export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))

export DEPSDIR := $(CURDIR)/$(BUILD)

CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

ifneq ($(strip $(MUSIC)),)
export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir))
BINFILES += soundbank.bin
endif

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

export OFILES_BIN := $(addsuffix .o,$(BINFILES))

export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)

export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))
# Simple Makefile for GBADoom (Qt6, macOS, Apple Silicon)

export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
# ---- Project -----------------------------------------------------

export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
TARGET := GBADoomCpp

.PHONY: $(BUILD) clean
SRC_DIR := cppsrc
OBJ_DIR := cppbuild

#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
# Use all C sources in source/, plus the C++ ones we know about.
# (If you add more .cpp files, just drop them in $(SRC_DIR)/)
CPP_SOURCES := $(wildcard $(SRC_DIR)/*.cc)

#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba
SRCS := $(CPP_SOURCES)

# Port specific source files
SRCS += ports/qt/i_system_e32.cc
SRCS += ports/qt/wadfilereader.cc
SRCS += ports/qt/i_main.cc


# ---- Original Doom Sources --------------------------------------------
#SRCS += ../../gamedata/original/doom_iwad.cc
#SRCS += ../../gamedata/original/w_wad.cc
#SRCS += ../../gamedata/original/w_nc.cc
#SRCS += ../../gamedata/original/z_bmalloc.cc
#vpath %.cc $(SRC_DIR) ../../gamedata/original

# ---- Guardmalloc Sources ----------------------------------------
#SRCS += ../../gamedata/original/doom_iwad.cc
#SRCS += ../../gamedata/original/w_wad.cc
#SRCS += ../../gamedata/original/z_bmalloc.cc
#SRCS += ../../gamedata/guard/w_nc.cc
#SRCS += guardmalloc/guardmalloc.cc
#vpath %.cc guardmalloc ../../gamedata/guard ../../gamedata/original $(SRC_DIR)

# ---- Minimem Sources ----------------------------------------
SRCS += gamedata/minimem/w_nc.cc
SRCS += gamedata/minimem/tagheap.cc
SRCS += gamedata/minimem/z_mem_emu.cc
SRCS += gamedata/minimem/w_lumps.cc
SRCS += gamedata/minimem/gbadoom1_lumps.cc
vpath %.cc gamedata/minimem ports/qt $(SRC_DIR)


# ---- Objects -----------------------------------------------------
OBJS := $(patsubst %.cc,$(OBJ_DIR)/%.o,$(notdir $(SRCS)))

# ---- Toolchain ---------------------------------------------------

#---------------------------------------------------------------------------------
else
CXX := clang++
CC := clang
AR := ar
RM := rm -f
MKDIR_P := mkdir -p

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
# QT configuration
QT_MODULE := Qt6Widgets
QT_CFLAGS := $(shell pkg-config --cflags $(QT_MODULE))
QT_LIBS := $(shell pkg-config --libs $(QT_MODULE))

$(OUTPUT).gba : $(OUTPUT).elf
# ---- Flags / Defines ---------------------------------------------

$(OUTPUT).elf : $(OFILES)
DEFINES := \
-DQT_DEPRECATED_WARNINGS \
-DRANGECHECK \
-DRPT_MALLOC \
-D_CRT_SECURE_NO_WARNINGS \

$(OFILES_SOURCES) : $(HFILES)
INCLUDEPATH := \
-Iinclude \
-Igamedata/minimem \
-Iports/qt

#---------------------------------------------------------------------------------
# The bin2o rule should be copied and modified
# for each extension used in the data directories
#---------------------------------------------------------------------------------
CXXFLAGS := -std=c++17 -Wall -Wextra -Werror -Wno-unknown-pragmas -Os $(DEFINES) $(INCLUDEPATH)
CFLAGS += $(QT_CFLAGS)
CXXFLAGS += $(QT_CFLAGS)

#---------------------------------------------------------------------------------
# rule to build soundbank from music files
#---------------------------------------------------------------------------------
soundbank.bin soundbank.h : $(AUDIOFILES)
#---------------------------------------------------------------------------------
@mmutil $^ -osoundbank.bin -hsoundbank.h
LDFLAGS := $(QT_LIBS)

#---------------------------------------------------------------------------------
# This rule links in binary data with the .wad extension
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# ---- Targets -----------------------------------------------------

.PHONY: all clean distclean run

all: $(TARGET)

$(TARGET): $(OBJ_DIR) $(OBJS)
$(CXX) -o $@ $(OBJS) $(LDFLAGS)

$(OBJ_DIR):
$(MKDIR_P) $(OBJ_DIR)


# C++ compilation rule - works for .cc files from any directory in vpath
$(OBJ_DIR)/%.o: %.cc
$(MKDIR_P) $(OBJ_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@

clean:
$(RM) $(OBJ_DIR)/*.o

distclean: clean
$(RM) $(TARGET)

-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
run: all
./$(TARGET)
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
## GBADoom

This is a modified version of the original GBADoom. It is rewritten to C++11 to
allow use of a stronger type system around caching of lumps. This in turn allows
more aggressive caching strategies where objects are loaded from flash on
demand - possibly even external flash. The goal is to have a port that is very
light on RAM requirements for platforms such as microcontrollers that have
large program memory areas (typically flash) but small RAM areas. GBADoom is
the starting point as a number of memory reducing efforts had already been done.

The memory allocation in this build only allows for compatibilty with the Doom1
wad, so what is stated below around compatibility is no longer true.


Original README below:

A port of prBoom to the GBA.

**What's hot?**
Expand Down
Loading