Files
Philippe Symons 99d196825d Work on isolating mystery_gift_builder from PTGB (WIP, doesn't compile yet)
This is the start of reworking mystery_gift_builder to run outside of PTGB and generate (most) of the payload
at compile time.

The idea is to leave most of the code intact, but inject some things at runtime.

It looks currently like that would be:

- Looker sprite (avoid LZ77UnCompWram AND having to bin2o the sprite file)
- text (avoid LZ77UnCompWram AND having to bin2o the text into this tool project)
- Pokémon box data

To that end, the goal is to generate a metadata struct with offsets of where to insert those things
at runtime.

But this commit is incomplete. It already tackles a bunch of stuff, but it can't be compiled yet.

TODO:

- Replace injection of the aforementioned things at compile time with something to record the offsets into
struct.
- Make it compileable
- output the payload to a (set of?) file(s)
- replace mystery_gift_builder IN PTGB with the pregenerated payload
- Inject the aforementioned things into the pregenerated payload at runtime in PTGB.
- Validate the pregenerated payload by comparing with mg_array and section30 dumps
 from the previous implementation.
2026-07-28 21:42:26 +02:00

66 lines
1.7 KiB
Makefile

BUILD_LANGS := japanese english french german italian spanishEU spanishLA
BUILD_TYPES := release debug
# defaults
BUILD_LANG ?= english
BUILD_TYPE ?= release
GIT_VERSION ?= $(shell git describe --tags --abbrev=0)
GIT_FULL ?= $(shell git describe --tags --always --dirty 2>/dev/null)
CMD_GOALS := $(filter-out build,$(MAKECMDGOALS))
LANG_INDEX := $(shell echo $(BUILD_LANGS) | tr ' ' '\n' | nl -v0 | grep -w $(BUILD_LANG) | awk '{print $$1 + 1}')
TYPE_INDEX := $(shell echo $(BUILD_TYPES) | tr ' ' '\n' | nl -v0 | grep -w $(BUILD_TYPE) | awk '{print $$1}')
CPPFLAGS += -DPTGB_BUILD_LANGUAGE=$(LANG_INDEX)
CPPFLAGS += -DDEBUG_MODE=$(TYPE_INDEX)
CPPFLAGS += -DBUILD_INFO=\"$(GIT_FULL)\"
CFLAGS += $(CPPFLAGS)
CXXFLAGS += $(CPPFLAGS)
# # Compiler flags
CXXFLAGS += -std=c++20 -fno-rtti -fno-exceptions -fno-unwind-tables -Wall -Wextra -I $(CURDIR)/include -g
# Source files directory
SRC_DIR := ./src
# Build directory
BUILD_DIR := build
# Source files (add more as needed)
SRCS := $(shell find $(SRC_DIR) -type f -name '*.cpp')
# Object files
OBJS := $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCS))
# Ensure necessary directories exist
# This function ensures the directory for the target exists
define make_directory
@mkdir -p $(dir $@)
endef
# Target executable
TARGET := gba-payload-generator
# Phony targets
.PHONY: all clean
# Default target
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) $(CXXFLAGS) $^ -o $@
# Rule to compile source files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp | $(BUILD_DIR)
$(make_directory)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Create the build directory if it doesn't exist
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Clean rule
clean:
rm -rf $(BUILD_DIR) $(TARGET) *.bin