Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ build/*
*.pyc
*.ips
*.zar
source/patch_symbols*.hpp
source/patch_symbols*
.DS_Store
27 changes: 18 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules

# Detect Python command to use
PYTHON := $(shell command -v python3 > /dev/null 2>&1 && echo python3 || echo python)

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
Expand Down Expand Up @@ -51,7 +54,7 @@ ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft

CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(ARCH)
-fdiagnostics-color=always $(ARCH)

CFLAGS += $(INCLUDE) -D__3DS__

Expand All @@ -62,8 +65,10 @@ LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS := -lctru -lm

# Debug-specific flags
# Auto-generated CPP file
PATCH_SYMBOLS_FILE := patch_symbols.cpp

# Debug-specific flags
debug ?= 0
ifneq ($(debug), 0)
CFLAGS += -g -DENABLE_DEBUG
Expand Down Expand Up @@ -104,6 +109,10 @@ SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

ifeq ($(filter $(PATCH_SYMBOLS_FILE),$(CPPFILES)),)
CPPFILES += $(PATCH_SYMBOLS_FILE)
endif

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
Expand Down Expand Up @@ -172,14 +181,13 @@ ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
endif

.PHONY: all clean delete3DSX create_basecode
.PHONY: app create_basecode clean

#---------------------------------------------------------------------------------
all: delete3DSX create_basecode $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

delete3DSX:
app: create_basecode $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
@rm -fr $(TARGET).3dsx
@$(PYTHON) generate_patch_symbols.py
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

create_basecode:
ifeq ($(app_only), 0)
Expand All @@ -206,7 +214,8 @@ endif
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(GFXBUILD) \
$(ROMFS)/basecode.ips $(ROMFS)/basecode_USA.ips $(ROMFS)/basecode_EUR.ips
$(ROMFS)/basecode.ips $(ROMFS)/basecode_USA.ips $(ROMFS)/basecode_EUR.ips \
source/patch_symbols*
$(MAKE) clean -C code

#---------------------------------------------------------------------------------
Expand Down Expand Up @@ -279,4 +288,4 @@ endef

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------
75 changes: 35 additions & 40 deletions code/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules

# Detect Python command to use
PYTHON := $(shell command -v python3 > /dev/null 2>&1 && echo python3 || echo python)

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
Expand All @@ -27,7 +30,7 @@ include $(DEVKITARM)/3ds_rules
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
# TARGET Defined below
BUILD := build
SOURCES := $(sort $(dir $(wildcard src/*/ src/)))
DATA := data
Expand All @@ -38,51 +41,43 @@ INCLUDES += assets
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
USA := USA
EUR := EUR
JP := JP
REGION := USA

VERFLAGS := -D USA=$(USA) -D EUR=$(EUR) -D JP=$(JP) -D REGION=$(REGION)

ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=softfp -mtp=soft -mfpu=vfpv2

CFLAGS := -g -Wall -mword-relocations -D DEBUG \
-fomit-frame-pointer -ffunction-sections \
$(ARCH)
-fdiagnostics-color=always $(ARCH)

CFLAGS += $(INCLUDE) -DARM11 -D_3DS $(VERFLAGS)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11

LINK_SCRIPT := oot.ld

LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) -T $(TOPDIR)/$(LINK_SCRIPT) $(VERFLAGS) -lgcc
LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) -T $(TOPDIR)/$(LINK_SCRIPT) -lgcc

ifeq ($(USA), $(REGION))
ASFLAGS += -D _USA_=1 -D _EUR_=0 -D _JP_=0
CFLAGS += -g -DVersion_USA
BUILD := build_usa
TARGET := code_usa
else
ifeq ($(EUR), $(REGION))
LDFLAGS += -Wl,--defsym,_EUR_=1
ASFLAGS += -D _USA_=0 -D _EUR_=1 -D _JP_=0
CFLAGS += -g -DVersion_EUR
BUILD := build_eur
TARGET := code_eur
ifeq ($(JP), $(REGION))
ASFLAGS += -D _USA_=0 -D _EUR_=0 -D _JP_=1
CFLAGS += -g -DVersion_JP
BUILD := build_jp
TARGET := code_jp
endif
endif
ASFLAGS += -g $(ARCH)

LIBS := -lgcc


# Region selection
REGION ?= USA

VALID_REGIONS := USA EUR

ifeq ($(filter $(REGION),$(VALID_REGIONS)),)
$(error "Invalid region: $(REGION)")
endif

ASFLAGS += -g $(ARCH) $(VERFLAGS)
UNSELECTED_REGIONS := $(subst $(REGION),,$(VALID_REGIONS))

# Define region for the Linker Script
LDFLAGS += -Wl,--defsym,_LD_$(REGION)=1 $(foreach region,$(UNSELECTED_REGIONS),-Wl,--defsym,_LD_$(region)=0)

# Define target filename with region name
TARGET := basecode_$(REGION)

LIBS := -lgcc

# Debug-specific flags
debug ?= 0
Expand Down Expand Up @@ -158,21 +153,21 @@ else
endif


.PHONY: $(BUILD) clean all
.PHONY: base_patch clean

#---------------------------------------------------------------------------------
all: $(BUILD)

$(BUILD):
@[ -d $@ ] || mkdir -p $@
base_patch:
@[ -d $(BUILD) ] || mkdir -p $(BUILD)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
@python3 --version &> /dev/null && _python_="python3" || _python_="python"; \
eval $$_python_ patch.py $(OUTPUT).elf $(REGION) $(debug);
@$(PYTHON) patch.py $(OUTPUT).elf $(debug);
@mv basecode.ips $(TARGET).ips
@printf "Created $(TARGET).ips\n\n"

#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr build build_eur build_usa *.elf ../source/patch_symbols*
@printf "Cleaning..."
@rm -fr build* *.elf
@printf " Done\n"


#---------------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion code/include/z3D/actors/z_en_dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

struct EnDns;

typedef void (*EnDnsActionFunc)(struct EnDns* this, GlobalContext* globalCtx);

typedef u32 (*EnDnsPurchaseableCheck)(struct EnDns*);
typedef void (*EnDnsSetRupeesAndFlags)(struct EnDns*);

Expand All @@ -18,7 +20,7 @@ typedef struct {

typedef struct EnDns {
/* 0x000 */ Actor actor;
/* 0x1A4 */ void* action_fn;
/* 0x1A4 */ EnDnsActionFunc action_fn;
/* 0x1A8 */ char collider[0x58];
/* 0x200 */ s16 dust_timer;
/* 0x202 */ char unk_202;
Expand Down
6 changes: 5 additions & 1 deletion code/include/z3D/actors/z_en_item00.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include "z3D/z3D.h"

struct EnItem00;

typedef void (*EnItem00ActionFunc)(struct EnItem00* this, GlobalContext* globalCtx);

typedef enum Item00Type {
/* 0x00 */ ITEM00_RUPEE_GREEN,
/* 0x01 */ ITEM00_RUPEE_BLUE,
Expand Down Expand Up @@ -41,7 +45,7 @@ typedef struct EnItem00Extension {

typedef struct EnItem00 {
/* 0x000 */ Actor actor;
/* 0x1A4 */ void* actionFunc;
/* 0x1A4 */ EnItem00ActionFunc actionFunc;
/* 0x1A8 */ u16 collectibleFlag;
/* 0x1AA */ char unk_1AA[0x4];
/* 0x1AE */ u16 unk_1AE;
Expand Down
20 changes: 20 additions & 0 deletions code/include/z3D/actors/z_en_test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef _EN_TEST_H_
#define _EN_TEST_H_

#include "z3D/z3D.h"

struct EnTest;

typedef void (*EnTestActionFunc)(struct EnTest*, GlobalContext*);

typedef struct EnTest {
Actor base;
char unk_1A4[60];
SkelAnime anime;
char unk_264[6636];
EnTestActionFunc action_fn;
} EnTest;

void EnTest_Wait(EnTest* this, GlobalContext* globalCtx);

#endif //_EN_TEST_H_
Loading
Loading