diff --git a/Makefile b/Makefile index 7ea5bdb926..ca282d07e6 100644 --- a/Makefile +++ b/Makefile @@ -63,13 +63,13 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN) ifeq ($(MODERN),0) CC1 := tools/agbcc/bin/agbcc$(EXE) -override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -g +override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm ROM := pokeemerald.gba OBJ_DIR := build/emerald LIBPATH := -L ../../tools/agbcc/lib else CC1 = $(shell $(CC) --print-prog-name=cc1) -quiet -override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast -g +override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mcpu=arm7tdmi -fno-toplevel-reorder -Wno-pointer-to-int-cast ROM := pokeemerald_modern.gba OBJ_DIR := build/modern LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))" @@ -111,13 +111,13 @@ MAKEFLAGS += --no-print-directory # Secondary expansion is required for dependency variables in object rules. .SECONDEXPANSION: -.PHONY: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern debugging debugging_modern +.PHONY: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line)))) # Build tools when building the rom # Disable dependency scanning for clean/tidy/tools -ifeq (,$(filter-out all rom compare modern debugging debugging_modern berry_fix libagbsyscall,$(MAKECMDGOALS))) +ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall,$(MAKECMDGOALS))) $(call infoshell, $(MAKE) tools) else NODEP := 1 @@ -136,9 +136,6 @@ C_ASM_OBJS := $(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o,$(C_ASM_SRCS)) ASM_SRCS := $(wildcard $(ASM_SUBDIR)/*.s) ASM_OBJS := $(patsubst $(ASM_SUBDIR)/%.s,$(ASM_BUILDDIR)/%.o,$(ASM_SRCS)) -# get all the data/*.s files EXCEPT the ones with specific rules -REGULAR_DATA_ASM_SRCS := $(filter-out $(DATA_ASM_SUBDIR)/maps.s $(DATA_ASM_SUBDIR)/map_events.s, $(wildcard $(DATA_ASM_SUBDIR)/*.s)) - DATA_ASM_SRCS := $(wildcard $(DATA_ASM_SUBDIR)/*.s) DATA_ASM_OBJS := $(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o,$(DATA_ASM_SRCS)) @@ -181,7 +178,7 @@ mostlyclean: tidy rm -f $(SAMPLE_SUBDIR)/*.bin rm -f $(CRY_SUBDIR)/*.bin rm -f $(MID_SUBDIR)/*.s - find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.rl' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} + + find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} + rm -f $(DATA_ASM_SUBDIR)/layouts/layouts.inc $(DATA_ASM_SUBDIR)/layouts/layouts_table.inc rm -f $(DATA_ASM_SUBDIR)/maps/connections.inc $(DATA_ASM_SUBDIR)/maps/events.inc $(DATA_ASM_SUBDIR)/maps/groups.inc $(DATA_ASM_SUBDIR)/maps/headers.inc find $(DATA_ASM_SUBDIR)/maps \( -iname 'connections.inc' -o -iname 'events.inc' -o -iname 'header.inc' \) -exec rm {} + @@ -251,12 +248,6 @@ ifeq ($(DINFO),1) override CFLAGS += -g endif -# Debug menu -ifeq ($(DDEBUGGING),1) -override ASFLAGS += --defsym DEBUGGING=1 -override CPPFLAGS += -D DEBUGGING=1 -endif - $(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep) @$(CPP) $(CPPFLAGS) $< -o $(C_BUILDDIR)/$*.i @$(PREPROC) $(C_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(C_BUILDDIR)/$*.s @@ -284,33 +275,24 @@ endif $(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s $$(c_asm_dep) $(AS) $(ASFLAGS) -o $@ $< -# The dep rules have to be explicit or else missing files won't be reported. -# As a side effect, they're evaluated immediately instead of when the rule is invoked. -# It doesn't look like $(shell) can be deferred so there might not be a better way. - - ifeq ($(NODEP),1) -$(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s +$(ASM_BUILDDIR)/%.o: asm_dep := +else +$(ASM_BUILDDIR)/%.o: asm_dep = $(shell $(SCANINC) -I "" $(ASM_SUBDIR)/$*.s) +endif + +$(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s $$(asm_dep) $(AS) $(ASFLAGS) -o $@ $< -else -define ASM_DEP -$1: $2 $$(shell $(SCANINC) -I include -I "" $2) - $$(AS) $$(ASFLAGS) -o $$@ $$< -endef -$(foreach src, $(ASM_SRCS), $(eval $(call ASM_DEP,$(patsubst $(ASM_SUBDIR)/%.s,$(ASM_BUILDDIR)/%.o, $(src)),$(src)))) -endif ifeq ($(NODEP),1) -$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s - $(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@ +$(DATA_ASM_BUILDDIR)/%.o: data_dep := else -define DATA_ASM_DEP -$1: $2 $$(shell $(SCANINC) -I include -I "" $2) - $$(PREPROC) $$< charmap.txt | $$(CPP) -I include | $$(AS) $$(ASFLAGS) -o $$@ -endef -$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) +$(DATA_ASM_BUILDDIR)/%.o: data_dep = $(shell $(SCANINC) -I include -I "" $(DATA_ASM_SUBDIR)/$*.s) endif +$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s $$(data_dep) + $(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@ + $(SONG_BUILDDIR)/%.o: $(SONG_SUBDIR)/%.s $(AS) $(ASFLAGS) -I sound -o $@ $< @@ -351,7 +333,3 @@ berry_fix: libagbsyscall: @$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) - -# Debug menu -debugging: ; @$(MAKE) DDEBUGGING=1 DINFO=1 -debugging_modern: ; @$(MAKE) MODERN=1 DDEBUGGING=1 DINFO=1 diff --git a/include/debug.h b/include/debug.h index 864176e4f3..1014690a5a 100644 --- a/include/debug.h +++ b/include/debug.h @@ -1,10 +1,11 @@ #ifndef GUARD_DEBUG_H #define GUARD_DEBUG_H -#if DEBUGGING -void Debug_ShowMainMenu(void); -#endif +#define TX_DEBUGGING +#define TX_DEBUG_MENU_OPTION FALSE + + +void Debug_ShowMainMenu(void); -#define DEBUG_MENU FALSE #endif // GUARD_DEBUG_H \ No newline at end of file diff --git a/src/debug.c b/src/debug.c index 8cb5ddbaca..ae3ff02e0b 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1,4 +1,3 @@ -#if DEBUGGING //CREDITS //TheXaman: https://github.com/TheXaman/pokeemerald/tree/tx_debug_system //CODE USED FROM: @@ -3626,5 +3625,3 @@ static void DebugTask_HandleMenuInput(u8 taskId, void (*HandleInput)(u8)) } */ - -#endif diff --git a/src/event_object_movement.c b/src/event_object_movement.c index de17be1254..44686fefe7 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -4724,10 +4724,10 @@ u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir) { u8 direction = dir; -#if DEBUGGING //DEBUG - if (FlagGet(FLAG_SYS_NO_COLLISION)) - return COLLISION_NONE; -#endif // + #ifdef TX_DEBUGGING //DEBUG + if (FlagGet(FLAG_SYS_NO_COLLISION)) + return COLLISION_NONE; + #endif // if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y)) return COLLISION_OUTSIDE_RANGE; diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 916287b0b7..3089c13671 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -132,34 +132,36 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys) else if (heldKeys & DPAD_RIGHT) input->dpadDirection = DIR_EAST; -#if DEBUGGING && !DEBUG_MENU //DEBUG - if (heldKeys & R_BUTTON) - { - if(input->pressedSelectButton) + #ifdef TX_DEBUGGING + if (!TX_DEBUG_MENU_OPTION) { - input->input_field_1_0 = TRUE; - input->pressedSelectButton = FALSE; - }else if(input->pressedStartButton) - { - input->input_field_1_2 = TRUE; - input->pressedStartButton = FALSE; + if (heldKeys & R_BUTTON) + { + if(input->pressedSelectButton) + { + input->input_field_1_0 = TRUE; + input->pressedSelectButton = FALSE; + }else if(input->pressedStartButton) + { + input->input_field_1_2 = TRUE; + input->pressedStartButton = FALSE; + } + } + if (heldKeys & L_BUTTON) + { + if(input->pressedSelectButton) + { + input->input_field_1_1 = TRUE; + input->pressedSelectButton = FALSE; + }else if(input->pressedStartButton) + { + input->input_field_1_3 = TRUE; + input->pressedStartButton = FALSE; + } + } } - } - if (heldKeys & L_BUTTON) - { - if(input->pressedSelectButton) - { - input->input_field_1_1 = TRUE; - input->pressedSelectButton = FALSE; - }else if(input->pressedStartButton) - { - input->input_field_1_3 = TRUE; - input->pressedStartButton = FALSE; - } - } -#endif - + #endif } int ProcessPlayerFieldInput(struct FieldInput *input) @@ -219,14 +221,17 @@ int ProcessPlayerFieldInput(struct FieldInput *input) if (input->pressedSelectButton && UseRegisteredKeyItemOnField() == TRUE) return TRUE; -#if DEBUGGING && !DEBUG_MENU - if (input->input_field_1_2) - { - PlaySE(SE_WIN_OPEN); - Debug_ShowMainMenu(); - return TRUE; - } -#endif + #ifdef TX_DEBUGGING + if (!TX_DEBUG_MENU_OPTION) + { + if (input->input_field_1_2) + { + PlaySE(SE_WIN_OPEN); + Debug_ShowMainMenu(); + return TRUE; + } + } + #endif return FALSE; } diff --git a/src/start_menu.c b/src/start_menu.c index b765761513..75bdc618a0 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -267,16 +267,20 @@ static void BuildStartMenuActions(void) { BuildMultiPartnerRoomStartMenu(); } - #if DEBUGGING && DEBUG_MENU - else + #ifdef TX_DEBUGGING + if (TX_DEBUG_MENU_OPTION) { BuildDebugStartMenu(); } - #else - else + else { BuildNormalStartMenu(); } + #else + else + { + BuildNormalStartMenu(); + } #endif } @@ -755,7 +759,7 @@ static bool8 StartMenuDebugCallback(void) RemoveExtraStartMenuWindows(); HideStartMenuDebug(); // Hide start menu without enabling movement - #if DEBUGGING + #ifdef TX_DEBUGGING Debug_ShowMainMenu(); #endif diff --git a/src/trainer_see.c b/src/trainer_see.c index 83783469c1..4ca19cd7f0 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -177,10 +177,10 @@ bool8 CheckForTrainersWantingBattle(void) { u8 i; -#if DEBUGGING //DEBUG - if (FlagGet(FLAG_SYS_NO_TRAINER_SEE)) - return FALSE; -#endif // + #ifdef TX_DEBUGGING //DEBUG + if (FlagGet(FLAG_SYS_NO_TRAINER_SEE)) + return FALSE; + #endif // gNoOfApproachingTrainers = 0; gApproachingTrainerId = 0;