Skip to content
Open
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
40 changes: 31 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,33 @@ else
CPP := $(PREFIX)cpp
endif

ROM_NAME := pokeemerald.gba
ROM_NAME := inclementemerald.gba
ELF_NAME := $(ROM_NAME:.gba=.elf)
MAP_NAME := $(ROM_NAME:.gba=.map)
OBJ_DIR_NAME := build/emerald
OBJ_DIR_NAME := build/inclementemerald

MODERN_ROM_NAME := pokeemerald_modern.gba
MODERN_ROM_NAME := inclementemerald_modern.gba
MODERN_ELF_NAME := $(MODERN_ROM_NAME:.gba=.elf)
MODERN_MAP_NAME := $(MODERN_ROM_NAME:.gba=.map)
MODERN_OBJ_DIR_NAME := build/modern

# Change output based on whether we're building debug.
#
# If DEBUG=1 then..
# ..Else, it isn't, and we're making normal build.
ifeq ($(DDEBUG),1)
ROM_NAME := inclementemerald-debug.gba
ELF_NAME := $(ROM_NAME:.gba=.elf)
MAP_NAME := $(ROM_NAME:.gba=.map)
OBJ_DIR_NAME := build/inclementemerald-debug
else
ROM_NAME := inclementemerald.gba
ELF_NAME := $(ROM_NAME:.gba=.elf)
MAP_NAME := $(ROM_NAME:.gba=.map)
OBJ_DIR_NAME := build/inclementemerald
endif


SHELL := /bin/bash -o pipefail

ELF = $(ROM:.gba=.elf)
Expand Down Expand Up @@ -229,10 +246,11 @@ endif
# For contributors to make sure a change didn't affect the contents of the ROM.
compare: all

clean: mostlyclean clean-tools
# clean: mostlyclean clean-tools
clean: mostlyclean

clean-tools:
@$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);)
#clean-tools:
# @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);)

clean-audio: tidynonmodern tidymodern
rm -f $(SAMPLE_SUBDIR)/*.bin
Expand Down Expand Up @@ -260,7 +278,7 @@ tidynonmodern:
tidymodern:
rm -f $(MODERN_ROM_NAME) $(MODERN_ELF_NAME) $(MODERN_MAP_NAME)
rm -rf $(MODERN_OBJ_DIR_NAME)

ifneq ($(MODERN),0)
$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member
endif
Expand Down Expand Up @@ -312,10 +330,14 @@ ifeq ($(DINFO),1)
override CFLAGS += -g
endif

ifeq ($(DDEBUGGING),1)
override ASFLAGS += --defsym DEBUGGING=1
override CPPFLAGS += -D DEBUGGING=1
endif

# 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 ($(SCAN_DEPS),1)
ifeq ($(NODEP),1)
$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.c
Expand Down Expand Up @@ -418,7 +440,7 @@ LD_SCRIPT := ld_script.txt
LD_SCRIPT_DEPS := $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld
else
LD_SCRIPT := ld_script_modern.txt
LD_SCRIPT_DEPS :=
LD_SCRIPT_DEPS :=
endif

$(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(LD_SCRIPT_DEPS)
Expand Down
2 changes: 1 addition & 1 deletion data/layouts/Seaspray_Cave/map.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2���Z[��������222222222222222�{{XY{{{{{{{�22222222222222�2�2�{{{{{{{{{PQ���222�2�2 "�{{{{{{{{{XY{{�222�2�2W3W3W3W3y{{{{{{{{{�222222222222�2�22�2�2�22W3W3W3W3W3W3y{{p�2��Z[�������222�2�22222�2�2�22222222�{{xW32�pXYpppppp�222�2�22?22�2�2�22�����ppppppppp�22�2�2�2�2222�2�2����W3W3W3W3W3W3�pp�W32'2�2�2�2�0�2�2�2BB��������2  "�2�2�2�2�2�2�2�2�2�2BB��������2�2�2�2�2�2�2�2�2�2�2BB�tuuv����Z[����tuuv�2�2�2�2�2�2�2�2�22BB�ppppppppXYpppppppp�2�2�2�222BB�pppppppPQppppppppp�22�2�2�2222222BB B BkBkBlpppppXYppppppppp�2'�2�2�22222222�B�B�B�B�B�BlpppppPQpppppppp�2�2�2�2�22����2�B�B�B�B�B�ByppppXYppxW3W3W3W3W3W322�2�2�2�22�{{�22�B�B�B�B�B�B�ppppppPQ��2�2�2�2�2�22�����2�{{�2�B�B�B�B�B�B�pppPQpXY��2�2�2�2�2�22�{{{�2�{{�2�pppXYppjkBbkB"�2�2�2P�{{{�2�{{�2222�ppppppjBBB"�2�2�{{{�2�{{�22222D2D2D2D2D2D2D2BBB�2�2W3W3W3W3W3�{Pe'22'222222�2�2�2�2�2BBB�2�22�{Xm22�2�2�2�2�2222�2�2�2�2�2BBB�2�2222�{{�22�2�2�2�2�222 B B B B B B BBBB�2�222222�{{�22�2�2�2�2�22BBBBBBBBBB�2�2222222W3W3W3W322�����2BBB?BBBBBBB22222�2�2�222222�{{{�2BBBBBBBBBB222�2$1$1$1�22222�{{{�2BBBBBBBBBB222�2$1$1$1$1$1�22222�{{{�2BBBBBB22�2$1$1$1$1$1$1$1�2222�{{{�2BBB22�2$1$1$1v$1$1$1�2222�{{{�2B'B22222222    XYZ         kkkkkk                                                                                                                 
2���Z[��������222222222222222�{{XY{{{{{{{�22222222222222�2�2�{{{{{{{{{PQ���222�2�2 "�{{{{{{{{{XY{{�222�2�2W3W3W3W3y{{{{{{{{{�222222222222�2�22�2�2�22W3W3W3W3W3W3y{{p�2��Z[�������222�2�22222�2�2�22222222�{{xW32�pXYpppppp�222�2�22?22�2�2�22�����ppppppppp�22�2�2�2�2222�2�2����W3W3W3W3W3W3�pp�W32'2�2�2�2�0�2�2�2BB��������2  "�2�2�2�2�2�2�2�2�2�2BB��������2�2�2�2�2�2�2�2�2�2�2BB�tuuv����Z[����tuuv�2�2�2�2�2�2�2�2�22BB�ppppppppXYpppppppp�2�2�2�222BB�pppppppPQppppppppp�22�2�2�2222222BB B BkBkBlpppppXYppppppppp�2'�2�2�22222222�B�B�B�B�B�BlpppppPQpppppppp�2�2�2�2�22����2�B�B�B�B�B�ByppppXYppxW3W3W3W3W3W322�2�2�2�22�{{�22�B�B�B�B�B�B�ppppppPQ��2�2�2�2�2�22�����2�{{�2�B�B�B�B�B�B�pppPQpXY��2�2�2�2�2�22�{{{�2�{{�2�pppXYppjkBbkB"�2�2�2P�{{{�2�{{�2222�ppppppjBBB"�2�2�{{{�2�{{�22222D2D2D2D2D2D2D2BBB�2�2W3W3W3W3W3�{Pe'22'222222�2�2�2�2�2BBB�2�22�{Xm22�2�2�2�2�2222�2�2�2�2�2BBB�2�2222�{{�22�2�2�2�2�222 B B B B B B BBBB�2�222222�{{�22�2�2�2�2�22BBBBBBBBBB�2�2222222W3W3W3W322�����2BBB?BBBBBBB22222�2�2�222222�{{{�2BBBBBBBBBB222�2$1$1$1�22222�{{{�2BBBBBBBBBB222�2$1$1$1$1$1�22222�{{{�2BBBBBB22�2$1$1$1$1$1$1$1�2222�{{{�2BBB22�2$1$1$1v2$1$1$1�2222�{{{�2B'B22222222    XYZ         kkkkkk                                                                                                                 
4 changes: 3 additions & 1 deletion ld_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ SECTIONS {
src/random.o(.text);
src/util.o(.text);
src/daycare.o(.text);
src/debug.o(.text);
src/egg_hatch.o(.text);
src/battle_interface.o(.text);
src/battle_anim_smokescreen.o(.text);
Expand Down Expand Up @@ -212,7 +213,7 @@ SECTIONS {
src/slot_machine.o(.text);
src/contest_painting.o(.text);
src/battle_ai_main.o(.text);
src/battle_ai_util.o(.text);
src/battle_ai_util.o(.text);
src/trader.o(.text);
src/starter_choose.o(.text);
src/wallclock.o(.text);
Expand Down Expand Up @@ -484,6 +485,7 @@ SECTIONS {
src/trig.o(.rodata);
src/util.o(.rodata);
src/daycare.o(.rodata);
src/debug.o(.rodata);
src/egg_hatch.o(.rodata);
src/battle_gfx_sfx_util.o(.rodata);
src/battle_interface.o(.rodata);
Expand Down
4 changes: 2 additions & 2 deletions src/battle_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,7 @@ s32 MoveBattleBar(u8 battlerId, u8 healthboxSpriteId, u8 whichBar, u8 unused)
gBattleSpritesDataPtr->battleBars[battlerId].oldValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
&gBattleSpritesDataPtr->battleBars[battlerId].currValue,
B_HEALTHBAR_PIXELS / 8, 1);
B_HEALTHBAR_PIXELS / 8, gBattleSpritesDataPtr->battleBars[battlerId].maxValue / 48);
}
else // exp bar
{
Expand Down Expand Up @@ -2481,7 +2481,7 @@ static void MoveBattleBarGraphically(u8 battlerId, u8 whichBar)
gBattleSpritesDataPtr->battleBars[battlerId].oldValue,
gBattleSpritesDataPtr->battleBars[battlerId].receivedValue,
&gBattleSpritesDataPtr->battleBars[battlerId].currValue,
array, B_HEALTHBAR_PIXELS / 8);
array, B_HEALTHBAR_PIXELS / gBattleSpritesDataPtr->battleBars[battlerId].maxValue / 48);

if (filledPixelsCount > (B_HEALTHBAR_PIXELS * 50 / 100)) // more than 50 % hp
barElementId = HEALTHBOX_GFX_HP_BAR_GREEN;
Expand Down
128 changes: 128 additions & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#if DEBUGGING

#include "global.h"
#include "list_menu.h"
#include "main.h"
#include "map_name_popup.h"
#include "menu.h"
#include "script.h"
#include "sound.h"
#include "strings.h"
#include "task.h"
#include "constants/songs.h"

#define DEBUG_MAIN_MENU_HEIGHT 7
#define DEBUG_MAIN_MENU_WIDTH 11

void Debug_ShowMainMenu(void);
static void Debug_DestroyMainMenu(u8);
static void DebugAction_Cancel(u8);
static void DebugTask_HandleMainMenuInput(u8);

enum {
DEBUG_MENU_ITEM_CANCEL,
};

static const u8 gDebugText_Cancel[] = _("Cancel");

static const struct ListMenuItem sDebugMenuItems[] =
{
[DEBUG_MENU_ITEM_CANCEL] = {gDebugText_Cancel, DEBUG_MENU_ITEM_CANCEL}
};

static void (*const sDebugMenuActions[])(u8) =
{
[DEBUG_MENU_ITEM_CANCEL] = DebugAction_Cancel
};

static const struct WindowTemplate sDebugMenuWindowTemplate =
{
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
.width = DEBUG_MAIN_MENU_WIDTH,
.height = 2 * DEBUG_MAIN_MENU_HEIGHT,
.paletteNum = 15,
.baseBlock = 1,
};

static const struct ListMenuTemplate sDebugMenuListTemplate =
{
.items = sDebugMenuItems,
.moveCursorFunc = ListMenuDefaultCursorMoveFunc,
.totalItems = ARRAY_COUNT(sDebugMenuItems),
.maxShowed = DEBUG_MAIN_MENU_HEIGHT,
.windowId = 0,
.header_X = 0,
.item_X = 8,
.cursor_X = 0,
.upText_Y = 1,
.cursorPal = 2,
.fillValue = 1,
.cursorShadowPal = 3,
.lettersSpacing = 1,
.itemVerticalPadding = 0,
.scrollMultiple = LIST_NO_MULTIPLE_SCROLL,
.fontId = 1,
.cursorKind = 0
};

void Debug_ShowMainMenu(void) {
struct ListMenuTemplate menuTemplate;
u8 windowId;
u8 menuTaskId;
u8 inputTaskId;

// create window
HideMapNamePopUpWindow();
LoadMessageBoxAndBorderGfx();
windowId = AddWindow(&sDebugMenuWindowTemplate);
DrawStdWindowFrame(windowId, FALSE);

// create list menu
menuTemplate = sDebugMenuListTemplate;
menuTemplate.windowId = windowId;
menuTaskId = ListMenuInit(&menuTemplate, 0, 0);

// draw everything
CopyWindowToVram(windowId, 3);

// create input handler task
inputTaskId = CreateTask(DebugTask_HandleMainMenuInput, 3);
gTasks[inputTaskId].data[0] = menuTaskId;
gTasks[inputTaskId].data[1] = windowId;
}

static void Debug_DestroyMainMenu(u8 taskId)
{
DestroyListMenuTask(gTasks[taskId].data[0], NULL, NULL);
ClearStdWindowAndFrame(gTasks[taskId].data[1], TRUE);
RemoveWindow(gTasks[taskId].data[1]);
DestroyTask(taskId);
EnableBothScriptContexts();
}

static void DebugTask_HandleMainMenuInput(u8 taskId)
{
void (*func)(u8);
u32 input = ListMenu_ProcessInput(gTasks[taskId].data[0]);

if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
if ((func = sDebugMenuActions[input]) != NULL)
func(taskId);
}
else if (gMain.newKeys & B_BUTTON)
{
PlaySE(SE_SELECT);
Debug_DestroyMainMenu(taskId);
}
}

static void DebugAction_Cancel(u8 taskId)
{
Debug_DestroyMainMenu(taskId);
}

#endif
18 changes: 18 additions & 0 deletions src/field_control_avatar.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "bike.h"
#include "coord_event_weather.h"
#include "daycare.h"
#include "debug.h"
#include "faraway_island.h"
#include "event_data.h"
#include "event_object_movement.h"
Expand Down Expand Up @@ -133,6 +134,14 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
input->dpadDirection = DIR_WEST;
else if (heldKeys & DPAD_RIGHT)
input->dpadDirection = DIR_EAST;

#if DEBUGGING
if ((heldKeys & R_BUTTON) && input->pressedStartButton)
{
input->input_field_1_2 = TRUE;
input->pressedStartButton = FALSE;
}
#endif
}

int ProcessPlayerFieldInput(struct FieldInput *input)
Expand Down Expand Up @@ -195,6 +204,15 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
if (input->pressedRButton && EnableAutoRun())
return TRUE;

#if DEBUGGING
if (input->input_field_1_2)
{
PlaySE(SE_WIN_OPEN);
Debug_ShowMainMenu();
return TRUE;
}
#endif

return FALSE;
}

Expand Down
17 changes: 9 additions & 8 deletions src/field_player_avatar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,7 @@ static void CreateStopSurfingTask(u8 direction)
gPlayerAvatar.preventStep = TRUE;
taskId = CreateTask(Task_StopSurfingInit, 0xFF);
gTasks[taskId].data[0] = direction;
playerObjEvent->triggerGroundEffectsOnMove = TRUE;
Task_StopSurfingInit(taskId);
}

Expand Down Expand Up @@ -1701,7 +1702,7 @@ static bool8 (*const sFishingStateFuncs[])(struct Task *) =
{
Fishing_Init,
Fishing_GetRodOut,
Fishing_WaitBeforeDots,
Fishing_WaitBeforeDots,
Fishing_InitDots, // FISHING_START_ROUND
Fishing_ShowDots,
Fishing_CheckForBite,
Expand Down Expand Up @@ -1743,13 +1744,13 @@ static bool8 Fishing_GetRodOut(struct Task *task)
{
struct ObjectEvent *playerObjEvent;
const s16 minRounds1[] = {
[OLD_ROD] = 1,
[GOOD_ROD] = 1,
[OLD_ROD] = 1,
[GOOD_ROD] = 1,
[SUPER_ROD] = 1
};
const s16 minRounds2[] = {
[OLD_ROD] = 1,
[GOOD_ROD] = 3,
[OLD_ROD] = 1,
[GOOD_ROD] = 3,
[SUPER_ROD] = 6
};

Expand Down Expand Up @@ -1866,8 +1867,8 @@ static bool8 Fishing_GotBite(struct Task *task)
static bool8 Fishing_WaitForA(struct Task *task)
{
const s16 reelTimeouts[3] = {
[OLD_ROD] = 36,
[GOOD_ROD] = 33,
[OLD_ROD] = 36,
[GOOD_ROD] = 33,
[SUPER_ROD] = 30
};

Expand Down Expand Up @@ -2101,7 +2102,7 @@ static void Task_DoPlayerSpinExit(u8 taskId)
tState++;
case 1: // Spin while rising
TrySpinPlayerForWarp(object, &tSpinDelayTimer);

// Rise and accelerate
tCurY -= tSpeed;
tSpeed += 3;
Expand Down
6 changes: 6 additions & 0 deletions src/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ static void SetPCItemQuantity(u16 *quantity, u16 newValue)
*quantity = newValue;
}

void ItemId_GetHoldEffectParam_Script();
void ItemId_GetHoldEffectParam_Script()
{
VarSet(VAR_RESULT, ItemId_GetHoldEffectParam(VarGet(VAR_0x8004)));
}

void ApplyNewEncryptionKeyToBagItems(u32 newKey)
{
u32 pocket, item;
Expand Down
1 change: 1 addition & 0 deletions src/item_use.c
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ static void Task_UseRepel(u8 taskId)
if (!IsSEPlaying())
{
VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId));
VarSet(VAR_REPEL_LAST_USED, gSpecialVar_ItemId);
RemoveUsedItem();
if (!InBattlePyramid())
DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage);
Expand Down
Loading