From 1a8fe435e7deabf06029c8e50201136518e3af73 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sat, 12 Aug 2017 01:26:29 -0400 Subject: split out src/ directory into categorized subdirectories. --- src/field/trader.c | 261 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 src/field/trader.c (limited to 'src/field/trader.c') diff --git a/src/field/trader.c b/src/field/trader.c new file mode 100644 index 000000000..ea06058e9 --- /dev/null +++ b/src/field/trader.c @@ -0,0 +1,261 @@ +#include "global.h" +#include "decoration.h" +#include "decoration_inventory.h" +#include "event_data.h" +#include "main.h" +#include "menu.h" +#include "menu_helpers.h" +#include "script.h" +#include "songs.h" +#include "sound.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" + +extern u16 gSpecialVar_0x8004; +extern u16 gSpecialVar_0x8005; +extern u16 gSpecialVar_0x8006; + +static const u8 * const gUnknown_083F62D8[] = +{ + SecretBaseText_Tristan, + SecretBaseText_Philip, + SecretBaseText_Dennis, + SecretBaseText_Roberto, +}; + +static const u8 gTraderDecorations[] = +{ + DECOR_DUSKULL_DOLL, + DECOR_BALL_CUSHION, + DECOR_TIRE, + DECOR_PRETTY_FLOWERS, +}; + +void sub_810993C(void) +{ + u8 i, j; + u8 buffer[12]; + struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + + for (i = 0; i < 3; i++) + { + for (j = i + 1; j < 4; j++) + { + if (trader->unk1[i] == 0) + { + u8 temp = trader->unk1[i]; + trader->unk1[i] = trader->unk1[j]; + trader->unk1[j] = temp; + StringCopy(buffer, trader->unk5[i]); + StringCopy(trader->unk5[i], trader->unk5[j]); + StringCopy(trader->unk5[j], buffer); + } + } + } +} + +void sub_81099CC(void) +{ + u8 i; + struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + + trader->unk0 = 2; + trader->unk31 = 0; + + for (i = 0; i < 4; i++) + { + StringCopy(trader->unk5[i], gUnknown_083F62D8[i]); + trader->unk1[i] = gTraderDecorations[i]; + } + + sub_810993C(); +} + +void sub_8109A20(void) +{ + struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + trader->unk31 = 0; +} + +void sub_8109A30(u8 value) +{ + VarSet(VAR_RECYCLE_GOODS, value); +} + +void sub_8109A48(u8 taskId) +{ + u8 i; + u8 numChoices = 1; + u8 numDecorations = 0; + struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + + for (i = 0; i < 4; i++) + { + if (trader->unk1[i]) + { + numChoices++; + } + } + + MenuDrawTextWindow(0, 1, 12, numChoices * 2 + 2); + + for (i = 0; i < 4; i++) + { + if (trader->unk1[i]) + { + if (trader->unk1[i] > DECOR_REGISTEEL_DOLL) + { + MenuPrint(gOtherText_FiveQuestionsAndSlash, 1, numDecorations * 2 + 2); + } + else + { + MenuPrint(gDecorations[trader->unk1[i]].name, 1, numDecorations * 2 + 2); + } + + numDecorations++; + } + } + + MenuPrint(gOtherText_CancelNoTerminator, 1, numDecorations * 2 + 2); + InitMenu(0, 1, 2, numChoices, 0, 11); + gTasks[taskId].data[1] = numDecorations; +} + +void sub_8109B34(u8 taskId, u8 decorationId) +{ + if (decorationId > DECOR_REGISTEEL_DOLL) + { + gSpecialVar_0x8004 = 0xFFFF; + } + else + { + gSpecialVar_0x8004 = decorationId; + } + + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 1, 12, 12); + DestroyTask(taskId); + EnableBothScriptContexts(); +} + +void sub_8109B7C(u8 taskId) +{ + struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + + if (gMain.newKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + } + else if (gMain.newKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + } + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + gSpecialVar_0x8005 = GetMenuCursorPos(); + if (gTasks[taskId].data[1] == gSpecialVar_0x8005) + { + sub_8109B34(taskId, 0); + } + else + { + StringCopy(gStringVar1, trader->unk5[gSpecialVar_0x8005]); + sub_8109B34(taskId, trader->unk1[gSpecialVar_0x8005]); + } + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + sub_8109B34(taskId, 0); + } +} + +void sub_8109C44(void) +{ + struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + gScriptResult = trader->unk31; +} + +void sub_8109C58(void) +{ + u8 i; + + for (i = 0; i < 8; i++) + { + if (sub_8134194(i)) + { + gScriptResult = FALSE; + return; + } + } + gScriptResult = TRUE; +} + +void sub_8109C90(void) +{ + gScriptResult = FALSE; + if (gDecorations[gSpecialVar_0x8004].category != gDecorations[gSpecialVar_0x8006].category + && sub_8133F9C(gDecorations[gSpecialVar_0x8004].category) == -1) + { + sub_80FE7D4(gStringVar2, gDecorations[gSpecialVar_0x8004].category); + gScriptResult = TRUE; + } +} + +void sub_8109CF0(void) +{ + CreateTask(sub_80FE7A8, 0); +} + +void sub_8109D04(u8 taskId) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 29, 19); + DestroyVerticalScrollIndicator(0); + DestroyVerticalScrollIndicator(1); + sub_80F9520(gUnknown_020388F7, 8); + BuyMenuFreeMemory(); + if (sub_80FEFA4() == TRUE) + { + gSpecialVar_0x8006 = gUnknown_020388D0[gUnknown_020388F5]; + StringCopy(gStringVar3, gDecorations[gSpecialVar_0x8004].name); + StringCopy(gStringVar2, gDecorations[gSpecialVar_0x8006].name); + } + else + { + gSpecialVar_0x8006 = 0xFFFF; + } + DestroyTask(taskId); + EnableBothScriptContexts(); +} + +void sub_8109DAC(u8 taskId) +{ + HandleDestroyMenuCursors(); + MenuZeroFillWindowRect(0, 0, 29, 19); + gSpecialVar_0x8006 = 0; + DestroyTask(taskId); + EnableBothScriptContexts(); +} + +void sub_8109DE0(void) +{ + struct MauvilleOldManTrader *trader = &gSaveBlock1.oldMan.trader; + + sub_81340A8(gSpecialVar_0x8006); + IsThereStorageSpaceForDecoration(gSpecialVar_0x8004); + StringCopy(trader->unk5[gSpecialVar_0x8005], gSaveBlock2.playerName); + trader->unk1[gSpecialVar_0x8005] = gSpecialVar_0x8006; + sub_810993C(); + trader->unk31 = 1; +} + +void sub_8109E34(void) +{ + u8 taskId = CreateTask(sub_8109B7C, 0); + sub_8109A48(taskId); +} -- cgit v1.2.3 From 5f242ae6cee377d219defa8290ef1c164b003f52 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sun, 26 Nov 2017 13:00:26 -0600 Subject: abilities, songs, species constants --- src/field/trader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/field/trader.c') diff --git a/src/field/trader.c b/src/field/trader.c index 61f48fad8..69eef1152 100644 --- a/src/field/trader.c +++ b/src/field/trader.c @@ -7,7 +7,7 @@ #include "menu.h" #include "menu_helpers.h" #include "script.h" -#include "songs.h" +#include "constants/songs.h" #include "sound.h" #include "string_util.h" #include "strings.h" -- cgit v1.2.3 From 611984671904aa19cf678c59ff2a8682cba09224 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sun, 26 Nov 2017 17:01:50 -0600 Subject: opponents, map_objects, hold_effects, game_stat, decorations, battle_move_effects constants --- src/field/trader.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/field/trader.c') diff --git a/src/field/trader.c b/src/field/trader.c index 69eef1152..c4fe73ba1 100644 --- a/src/field/trader.c +++ b/src/field/trader.c @@ -1,4 +1,5 @@ #include "global.h" +#include "constants/decorations.h" #include "decoration.h" #include "decoration_inventory.h" #include "event_data.h" -- cgit v1.2.3 From 754e911b4e95205bafa5dc93242da9cee3f2c5c6 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Thu, 21 Dec 2017 11:40:26 -0600 Subject: Rename gScript* vars to gSpecialVar_* --- src/field/trader.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/field/trader.c') diff --git a/src/field/trader.c b/src/field/trader.c index c4fe73ba1..61cb0b4a2 100644 --- a/src/field/trader.c +++ b/src/field/trader.c @@ -179,7 +179,7 @@ void Task_HandleGetDecorationMenuInput(u8 taskId) void ScrSpecial_GetTraderTradedFlag(void) { struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; - gScriptResult = trader->alreadyTraded; + gSpecialVar_Result = trader->alreadyTraded; } void ScrSpecial_DoesPlayerHaveNoDecorations(void) @@ -190,21 +190,21 @@ void ScrSpecial_DoesPlayerHaveNoDecorations(void) { if (sub_8134194(i)) { - gScriptResult = FALSE; + gSpecialVar_Result = FALSE; return; } } - gScriptResult = TRUE; + gSpecialVar_Result = TRUE; } void ScrSpecial_IsDecorationFull(void) { - gScriptResult = FALSE; + gSpecialVar_Result = FALSE; if (gDecorations[gSpecialVar_0x8004].category != gDecorations[gSpecialVar_0x8006].category && sub_8133F9C(gDecorations[gSpecialVar_0x8004].category) == -1) { sub_80FE7D4(gStringVar2, gDecorations[gSpecialVar_0x8004].category); - gScriptResult = TRUE; + gSpecialVar_Result = TRUE; } } -- cgit v1.2.3