diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2020-04-08 12:51:31 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2020-04-08 12:51:31 -0400 |
commit | 2073a56531c82875e014985f4b87dd9e6b4cf0dc (patch) | |
tree | fa9a31158f527f74ee465020623da21d299be213 /src | |
parent | d7c165d8fecc3e605436135c526e5fe647b04677 (diff) |
Finish naming objs in slot_machine
Diffstat (limited to 'src')
-rw-r--r-- | src/mystery_gift_menu.c | 2 | ||||
-rw-r--r-- | src/option_menu.c | 2 | ||||
-rw-r--r-- | src/pokemon_jump_4.c | 2 | ||||
-rw-r--r-- | src/slot_machine.c | 1391 | ||||
-rw-r--r-- | src/text_window.c | 2 |
5 files changed, 750 insertions, 649 deletions
diff --git a/src/mystery_gift_menu.c b/src/mystery_gift_menu.c index cdfd62624..a80ffe1b3 100644 --- a/src/mystery_gift_menu.c +++ b/src/mystery_gift_menu.c @@ -398,7 +398,7 @@ bool32 HandleMysteryGiftOrEReaderSetup(s32 mg_or_ereader) SetBgTilemapBuffer(0, Alloc(0x800)); LoadUserWindowBorderGfx(0, 10, 0xE0); - sub_814FDA0(0, 1, 0xF0); + DrawWindowBorderWithStdpal3(0, 1, 0xF0); DecompressAndLoadBgGfxUsingHeap(3, gUnkTextboxBorderGfx, 0x100, 0, 0); InitWindows(sMainWindows); DeactivateAllTextPrinters(); diff --git a/src/option_menu.c b/src/option_menu.c index 54cca0501..f224db1bc 100644 --- a/src/option_menu.c +++ b/src/option_menu.c @@ -352,7 +352,7 @@ static bool8 LoadOptionMenuPalette(void) LoadPalette(stdpal_get(2), 0xF0, 0x20); break; case 3: - sub_814FDA0(1, 0x1B3, 0x30); + DrawWindowBorderWithStdpal3(1, 0x1B3, 0x30); break; default: return TRUE; diff --git a/src/pokemon_jump_4.c b/src/pokemon_jump_4.c index c125734a3..123aafdc1 100644 --- a/src/pokemon_jump_4.c +++ b/src/pokemon_jump_4.c @@ -220,7 +220,7 @@ static void sub_8149DC8(void) FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); sub_814A84C(); sub_814AA24(0); - sub_814FDA0(0, 1, 0xE0); + DrawWindowBorderWithStdpal3(0, 1, 0xE0); LoadUserWindowBorderGfx(0, 0x00A, 0xD0); CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(2); diff --git a/src/slot_machine.c b/src/slot_machine.c index 761a78019..bb0829268 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -19,23 +19,61 @@ #include "strings.h" #include "constants/songs.h" +#define SLOT_IMAGE_7 0 +#define SLOT_IMAGE_ROCKET 1 +#define SLOT_IMAGE_PIKACHU 2 +#define SLOT_IMAGE_PSYDUCK 3 +#define SLOT_IMAGE_CHERRIES 4 +#define SLOT_IMAGE_MAGNEMITE 5 +#define SLOT_IMAGE_SHELLDER 6 + +#define SLOT_PAYOUT_NONE 0 +#define SLOT_PAYOUT_CHERRIES2 1 +#define SLOT_PAYOUT_CHERRIES3 2 +#define SLOT_PAYOUT_MAGSHELL 3 +#define SLOT_PAYOUT_PIKAPSY 4 +#define SLOT_PAYOUT_ROCKET 5 +#define SLOT_PAYOUT_7 6 + +#define ROWATTR_COL1POS 0 +#define ROWATTR_COL2POS 1 +#define ROWATTR_COL3POS 2 +#define ROWATTR_MINBET 3 + +#define SLOTTASK_GFX_INIT 0 +#define SLOTTASK_FADEOUT_EXIT 1 +#define SLOTTASK_UPDATE_LINE_LIGHTS 2 +#define SLOTTASK_CLEFAIRY_BOUNCE 3 +#define SLOTTASK_ANIM_WIN 4 +#define SLOTTASK_END_ANIM_WIN 5 +#define SLOTTASK_ANIM_LOSE 6 +#define SLOTTASK_ANIM_BETTING 7 +#define SLOTTASK_SHOW_AMOUNTS 8 +#define SLOTTASK_MSG_NO_COINS 9 +#define SLOTTASK_ASK_QUIT 10 +#define SLOTTASK_DESTROY_YESNO 11 +#define SLOTTASK_PRESS_BUTTON 12 +#define SLOTTASK_RELEASE_BUTTONS 13 +#define SLOTTASK_SHOWHELP 14 +#define SLOTTASK_HIDEHELP 15 + struct SlotMachineState { MainCallback savedCallback; u16 machineidx; - u16 field_06; - u16 field_08; + u16 currentReel; + u16 machineBias; u16 slotRewardClass; - u16 field_0C; + u16 biasCooldown; u16 bet; - u8 field_10; - u8 field_11; - bool32 field_14[3]; + u8 taskId; + u8 spinReelsTaskId; + bool32 reelIsSpinning[3]; s16 reelPositions[3]; - s16 field_26[3]; - s16 field_2C[3]; - s16 field_32[3]; - u32 field_38; + s16 reelSubpixel[3]; + s16 destReelPos[3]; + s16 reelStopOrder[3]; + u32 reel2BiasInPlay; bool32 winFlags[5]; u16 payout; }; @@ -43,11 +81,11 @@ struct SlotMachineState struct SlotMachineGfxManager { u32 field_00[3]; - struct Sprite * field_0C[3][5]; - struct Sprite * field_48[4]; - struct Sprite * field_58[4]; - struct Sprite * field_68[2]; - vu16 * field_70; + struct Sprite * reelIconSprites[3][5]; + struct Sprite * creditDigitSprites[4]; + struct Sprite * payoutDigitSprites[4]; + struct Sprite * clefairySprites[2]; + vu16 * reelIconAffineParamPtr; }; struct SlotMachineSetupTaskDataSub_0000 @@ -60,20 +98,20 @@ struct SlotMachineSetupTaskDataSub_0000 struct SlotMachineSetupTaskData { struct SlotMachineSetupTaskDataSub_0000 tasks[8]; - u8 field_0020; + u8 reelButtonToPress; // align 2 - s32 field_0024; - u32 field_0028; - u16 field_002C[3][4]; - u16 field_0044[3][4]; + s32 bg1X; + bool32 yesNoMenuActive; + u16 buttonPressedTiles[3][4]; + u16 buttonReleasedTiles[3][4]; u8 field_005C[0x800]; - u8 field_085C[0x800]; - u8 field_105C[0x800]; - u8 field_185C[0x800]; - u8 reelPositions5C[0x800]; + u8 bg0TilemapBuffer[0x800]; + u8 bg1TilemapBuffer[0x800]; + u8 bg2TilemapBuffer[0x800]; + u8 bg3TilemapBuffer[0x800]; }; // size: 285C -struct UnkStruct_8466C0C +struct LineStateTileIdxList { const u16 * tiles; u32 count; @@ -82,10 +120,10 @@ struct UnkStruct_8466C0C static EWRAM_DATA struct SlotMachineState * sSlotMachineState = NULL; static EWRAM_DATA struct SlotMachineGfxManager * sSlotMachineGfxManager = NULL; -static void sub_813F84C(struct SlotMachineState * ptr); -static void sub_813F898(void); -static void sub_813F92C(void); -static void sub_813F94C(void); +static void InitSlotMachineState(struct SlotMachineState * ptr); +static void CB2_InitSlotMachine(void); +static void CleanSupSlotMachineState(void); +static void CB2_RunSlotMachine(void); static void MainTask_SlotsGameLoop(u8 taskId); static void MainTask_NoCoinsGameOver(u8 taskId); static void MainTask_ShowHelp(u8 taskId); @@ -94,57 +132,57 @@ static void MainTask_DarnNoPayout(u8 taskId); static void MainTask_WinHandlePayout(u8 taskId); static void MainTask_ExitSlots(u8 taskId); static void SetMainTask(TaskFunc taskFunc); -static void sub_8140060(u8 taskId); -static void sub_8140148(void); -static void sub_814016C(u16 whichReel, u16 whichReel2); -static bool32 sub_81401A0(u16); -static void sub_81401F0(u16 whichReel); -static void sub_81403BC(u16 whichReel); -static void sub_81404B8(u16 whichReel); -static bool32 sub_814054C(s32, s32, s32, s32, s32); -static bool32 sub_81406E8(s32, s32, s32); -static bool32 sub_81408F4(s32, s32); -static void sub_81409B4(void); -static void sub_8140A70(void); +static void Task_SpinReels(u8 taskId); +static void StartReels(void); +static void StopCurrentReel(u16 whichReel, u16 whichReel2); +static bool32 IsReelSpinning(u16); +static void StopReel1(u16 whichReel); +static void StopReel2(u16 whichReel); +static void StopReel3(u16 whichReel); +static bool32 TwoReelBiasCheck(s32 reel0id, s32 reel0pos, s32 reel1id, s32 reel1pos, s32 icon); +static bool32 OneReelBiasCheck(s32, s32, s32); +static bool32 TestReelIconAttribute(s32 attr, s32 icon); +static void CalcSlotBias(void); +static void ResetMachineBias(void); static u16 CalcPayout(void); -static void sub_8140C6C(struct SlotMachineGfxManager * manager); -static void sub_8140D7C(const s16 *, const s16 *); -static bool32 sub_814104C(void); -static void sub_8141094(void); +static void InitGfxManager(struct SlotMachineGfxManager * manager); +static void UpdateReelIconSprites(const s16 *, const s16 *); +static bool32 CreateSlotMachine(void); +static void DestroySlotMachine(void); static struct SlotMachineSetupTaskData * GetSlotMachineSetupTaskDataPtr(void); -static void sub_81410CC(u8 taskId); -static void SetSlotMachineSetupTask(u16 a0, u8 a1); -static bool32 IsSlotMachineSetupTaskActive(u8 a0); -static bool8 sub_8141198(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_8141460(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_81414AC(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_81414EC(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_81414FC(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_8141518(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_8141558(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_8141568(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_8141578(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_8141584(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_81415C8(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_8141610(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_8141650(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_8141690(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_81416C8(u8 *, struct SlotMachineSetupTaskData *); -static bool8 sub_8141764(u8 *, struct SlotMachineSetupTaskData *); -static void sub_81417E4(const u8 * str); -static void sub_8141828(void); -static void sub_8141834(u16 * bgTilemapBuffer); -static void sub_81418C4(u16 * bgTilemapBuffer, u16 a0, u16 a1); -static void sub_814191C(u8 taskId); -static void sub_8141AB0(void); -static void sub_8141AD8(u8 a0); -static void sub_8141B18(void); -static void sub_8141B34(void); -static void sub_8141BA0(u8 a0); -static void sub_8141BE4(void); -static void sub_8141C30(u8, u8); - -static const u8 gUnknown_8464890[][2] = { +static void Task_SlotMachine(u8 taskId); +static void SetSlotMachineSetupTask(u16 funcno, u8 taskId); +static bool32 IsSlotMachineSetupTaskActive(u8 taskId); +static bool8 SlotsTask_GraphicsInit(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_FadeOut(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_UpdateLineStates(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_ClefairyUpdateOnReelsStart(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_StartClefairyDanceAndWinningLineFlash(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_StopWinningLineFlashTask(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_ClefairyFainted(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_ClefairyNeutral(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_UpdateCoinsDisplay(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_MessageOutOfCoins(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_AskQuitPlaying(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_DestroyYesNoMenu(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_PressReelButton(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_ReleaseReelButtons(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_ShowHelp(u8 *state, struct SlotMachineSetupTaskData * ptr); +static bool8 SlotsTask_HideHelp(u8 *state, struct SlotMachineSetupTaskData * ptr); +static void Slot_PrintOnWindow0(const u8 * str); +static void Slot_ClearWindow0(void); +static void SetLineStatesByBet(u16 * bgTilemapBuffer); +static void SetLineState(u16 * bgTilemapBuffer, u16 lineId, u16 paletteNo); +static void Task_FlashWinningLine(u8 taskId); +static void SignalStopWinningLineFlashTask(void); +static void Slot_CreateYesNoMenu(u8 cursorPos); +static void Slot_DestroyYesNoMenu(void); +static void InitReelButtonTileMem(void); +static void SetReelButtonPressed(u8 reel); +static void ReleaseReelButtons(void); +static void PressReelButton(u8 reel, u8 taskId); + +static const u8 sSecondReelBiasCheckIndices[][2] = { {0x00, 0x03}, {0x00, 0x06}, {0x03, 0x06}, @@ -166,7 +204,7 @@ static const u8 gUnknown_8464890[][2] = { {0x04, 0x06} }; -static const u8 gUnknown_84648AE[][3] = { +static const u8 sThirdReelBiasCheckIndices[][3] = { {0x00, 0x03, 0x06}, // top row {0x01, 0x04, 0x07}, // middle row {0x02, 0x05, 0x08}, // bottom row @@ -174,7 +212,7 @@ static const u8 gUnknown_84648AE[][3] = { {0x02, 0x04, 0x06} // bl-tr }; -static const u8 gUnknown_84648BD[][4] = { +static const u8 sRowAttributes[][4] = { {0x00, 0x04, 0x08, 0x03}, // tl-br {0x00, 0x03, 0x06, 0x02}, // top row {0x01, 0x04, 0x07, 0x01}, // middle row @@ -182,7 +220,7 @@ static const u8 gUnknown_84648BD[][4] = { {0x02, 0x04, 0x06, 0x03} // bl-tr }; -static const u16 gUnknown_84648D2[][7] = { +static const u16 sReelBiasChances[][7] = { {0x1fa1, 0x2eab, 0x3630, 0x39f3, 0x3bd4, 0x3bfc, 0x0049}, {0x1f97, 0x2ea2, 0x3627, 0x39e9, 0x3bca, 0x3bf8, 0x0049}, {0x1f91, 0x2e9b, 0x3620, 0x39e3, 0x3bc4, 0x3bf4, 0x0049}, @@ -191,27 +229,91 @@ static const u16 gUnknown_84648D2[][7] = { {0x1fc9, 0x2efc, 0x3696, 0x3a63, 0x3c49, 0x3c8b, 0x0073}, }; -static const u8 gUnknown_8464926[][21] = { - {0x00, 0x03, 0x04, 0x01, 0x02, 0x06, 0x02, 0x05, 0x00, 0x06, 0x03, 0x01, 0x04, 0x02, 0x06, 0x00, 0x05, 0x02, 0x01, 0x06, 0x02}, - {0x00, 0x05, 0x04, 0x03, 0x01, 0x05, 0x04, 0x03, 0x02, 0x05, 0x04, 0x03, 0x00, 0x05, 0x04, 0x01, 0x03, 0x06, 0x05, 0x03, 0x04}, - {0x00, 0x03, 0x06, 0x05, 0x02, 0x03, 0x06, 0x05, 0x02, 0x03, 0x05, 0x06, 0x02, 0x03, 0x05, 0x06, 0x02, 0x03, 0x05, 0x06, 0x01}, +static const u8 sReelIconAnimByReelAndPos[][21] = { + { + SLOT_IMAGE_7, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_CHERRIES, + SLOT_IMAGE_ROCKET, + SLOT_IMAGE_PIKACHU, + SLOT_IMAGE_SHELLDER, + SLOT_IMAGE_PIKACHU, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_7, + SLOT_IMAGE_SHELLDER, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_ROCKET, + SLOT_IMAGE_CHERRIES, + SLOT_IMAGE_PIKACHU, + SLOT_IMAGE_SHELLDER, + SLOT_IMAGE_7, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_PIKACHU, + SLOT_IMAGE_ROCKET, + SLOT_IMAGE_SHELLDER, + SLOT_IMAGE_PIKACHU + }, { + SLOT_IMAGE_7, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_CHERRIES, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_ROCKET, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_CHERRIES, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_PIKACHU, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_CHERRIES, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_7, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_CHERRIES, + SLOT_IMAGE_ROCKET, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_SHELLDER, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_CHERRIES + }, { + SLOT_IMAGE_7, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_SHELLDER, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_PIKACHU, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_SHELLDER, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_PIKACHU, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_SHELLDER, + SLOT_IMAGE_PIKACHU, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_SHELLDER, + SLOT_IMAGE_PIKACHU, + SLOT_IMAGE_PSYDUCK, + SLOT_IMAGE_MAGNEMITE, + SLOT_IMAGE_SHELLDER, + SLOT_IMAGE_ROCKET + }, }; static const u16 sPayoutTable[] = { - 0, - 2, - 6, - 8, - 15, - 100, - 300 -}; - -static const u16 sSpritePal_ReelIcons[] = INCBIN_U16("graphics/slot_machine/unk_8464974.gbapal"); -static const u16 gUnknown_8464994[] = INCBIN_U16("graphics/slot_machine/unk_8464994.gbapal"); -static const u16 gUnknown_84649B4[] = INCBIN_U16("graphics/slot_machine/unk_84649b4.gbapal"); -static const u16 gUnknown_84649D4[] = INCBIN_U16("graphics/slot_machine/unk_84649d4.gbapal"); -static const u16 gUnknown_84649F4[] = INCBIN_U16("graphics/slot_machine/unk_84649f4.gbapal"); + [SLOT_PAYOUT_NONE] = 0, + [SLOT_PAYOUT_CHERRIES2] = 2, + [SLOT_PAYOUT_CHERRIES3] = 6, + [SLOT_PAYOUT_MAGSHELL] = 8, + [SLOT_PAYOUT_PIKAPSY] = 15, + [SLOT_PAYOUT_ROCKET] = 100, + [SLOT_PAYOUT_7] = 300 +}; + +static const u16 sSpritePal_ReelIcons_0[] = INCBIN_U16("graphics/slot_machine/unk_8464974.gbapal"); +static const u16 sSpritePal_ReelIcons_1[] = INCBIN_U16("graphics/slot_machine/unk_8464994.gbapal"); +static const u16 sSpritePal_ReelIcons_2[] = INCBIN_U16("graphics/slot_machine/unk_84649b4.gbapal"); +static const u16 sSpritePal_ReelIcons_3[] = INCBIN_U16("graphics/slot_machine/unk_84649d4.gbapal"); +static const u16 sSpritePal_ReelIcons_4[] = INCBIN_U16("graphics/slot_machine/unk_84649f4.gbapal"); #if defined(FIRERED) static const u32 sSpriteTiles_ReelIcons[] = INCBIN_U32("graphics/slot_machine/unk_8464a14.4bpp.lz"); static const u16 sSpritePal_Clefairy[] = INCBIN_U16("graphics/slot_machine/unk_846506c.gbapal"); @@ -226,44 +328,44 @@ static const u32 sSpriteTiles_Digits[] = INCBIN_U32("graphics/slot_machine/unk_8 static const struct CompressedSpriteSheet sSpriteSheets[] = { {(const void *)sSpriteTiles_ReelIcons, 0xe00, 0}, - {(const void *)sSpriteTiles_Clefairy, 0xc00, 1}, - {(const void *)sSpriteTiles_Digits, 0x280, 2}, + {(const void *)sSpriteTiles_Clefairy, 0xc00, 1}, + {(const void *)sSpriteTiles_Digits, 0x280, 2}, }; static const struct SpritePalette sSpritePalettes[] = { - {sSpritePal_ReelIcons, 0}, - {gUnknown_8464994, 1}, - {gUnknown_84649B4, 2}, - {gUnknown_84649D4, 3}, - {gUnknown_84649F4, 4}, - {sSpritePal_Clefairy, 5}, - {sSpritePal_Digits, 6}, + {sSpritePal_ReelIcons_0, 0}, + {sSpritePal_ReelIcons_1, 1}, + {sSpritePal_ReelIcons_2, 2}, + {sSpritePal_ReelIcons_3, 3}, + {sSpritePal_ReelIcons_4, 4}, + {sSpritePal_Clefairy, 5}, + {sSpritePal_Digits, 6}, {NULL} }; #if defined(FIRERED) -static const u16 gUnknown_8465608[] = { - 2, - 2, - 0, - 0, - 2, - 4, - 3 +static const u16 sReelIconPaletteTags[] = { + [SLOT_IMAGE_7] = 2, + [SLOT_IMAGE_ROCKET] = 2, + [SLOT_IMAGE_PIKACHU] = 0, + [SLOT_IMAGE_PSYDUCK] = 0, + [SLOT_IMAGE_CHERRIES] = 2, + [SLOT_IMAGE_MAGNEMITE] = 4, + [SLOT_IMAGE_SHELLDER] = 3 }; #elif defined(LEAFGREEN) -static const u16 gUnknown_8465608[] = { - 2, - 2, - 0, - 3, - 2, - 1, - 1 +static const u16 sReelIconPaletteTags[] = { + [SLOT_IMAGE_7] = 2, + [SLOT_IMAGE_ROCKET] = 2, + [SLOT_IMAGE_PIKACHU] = 0, + [SLOT_IMAGE_PSYDUCK] = 3, + [SLOT_IMAGE_CHERRIES] = 2, + [SLOT_IMAGE_MAGNEMITE] = 1, + [SLOT_IMAGE_SHELLDER] = 1 }; #endif -static const u16 gUnknown_8465616[] = { +static const u16 sReelIconAffineParams[] = { 0x0120, 0x011f, 0x011e, 0x011d, 0x011c, 0x011b, 0x011a, 0x0119, 0x0118, 0x0117, 0x0116, 0x0115, 0x0114, 0x0113, 0x0112, 0x0111, 0x0110, 0x010f, 0x010e, 0x010d, 0x010c, 0x010b, 0x010a, 0x0109, 0x0108, 0x0107, 0x0106, 0x0105, 0x0104, 0x0103, 0x0102, 0x0101, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, @@ -272,7 +374,7 @@ static const u16 gUnknown_8465616[] = { 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117, 0x0118, 0x0119, 0x011a, 0x011b, 0x011c, 0x011d, 0x011e, 0x011f, 0x0120 }; -static const u8 gUnknown_84656D6[] = { +static const u8 sReelIconBldY[] = { 0x10, 0x10, 0x10, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0c, 0x0b, 0x0a, 0x0a, 0x09, 0x08, 0x07, 0x07, 0x06, 0x05, 0x04, 0x04, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x09, 0x09, 0x0a, 0x0b, 0x0c, 0x0c, 0x0d, 0x0e, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f @@ -369,13 +471,13 @@ static const union AnimCmd *const sAnimTable_ReelIcons[] = { sAnimCmd_ReelIcon_Shellder_2 }; -static const union AffineAnimCmd gUnknown_84657D0[] = { +static const union AffineAnimCmd sAffineAnimCmd_ReelIcons_Unused[] = { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 1), AFFINEANIMCMD_END }; -static const union AffineAnimCmd *const gUnknown_84657E0[] = { - gUnknown_84657D0 +static const union AffineAnimCmd *const sAffineAnimTable_ReelIcons_Unused[] = { + sAffineAnimCmd_ReelIcons_Unused }; static const struct SpriteTemplate sSpriteTemplate_ReelIcons = { @@ -477,7 +579,7 @@ static const struct SpriteTemplate sSpriteTemplate_Digits = { .callback = SpriteCallbackDummy }; -static const struct OamData gUnknown_8465894 = { +static const struct OamData sOamData_Clefairy = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -493,99 +595,99 @@ static const struct OamData gUnknown_8465894 = { .affineParam = 0 }; -static const union AnimCmd gUnknown_846589C[] = { +static const union AnimCmd sAnimCmd_Clefairy_Neutral[] = { ANIMCMD_FRAME(0, 4), ANIMCMD_END }; -static const union AnimCmd gUnknown_84658A4[] = { +static const union AnimCmd sAnimCmd_Clefairy_Spinning[] = { ANIMCMD_FRAME( 0, 24), ANIMCMD_FRAME(16, 24), ANIMCMD_JUMP(0) }; -static const union AnimCmd gUnknown_84658B0[] = { +static const union AnimCmd sAnimCmd_Clefairy_Payout[] = { ANIMCMD_FRAME(32, 28), ANIMCMD_FRAME(48, 28), ANIMCMD_JUMP(0) }; -static const union AnimCmd gUnknown_84658BC[] = { +static const union AnimCmd sAnimCmd_Clefairy_Lose[] = { ANIMCMD_FRAME(64, 12), ANIMCMD_FRAME(80, 12), ANIMCMD_JUMP(0) }; -static const union AnimCmd *const gUnknown_84658C8[] = { - gUnknown_846589C, - gUnknown_84658A4, - gUnknown_84658B0, - gUnknown_84658BC +static const union AnimCmd *const sAnimTable_Clefairy[] = { + sAnimCmd_Clefairy_Neutral, + sAnimCmd_Clefairy_Spinning, + sAnimCmd_Clefairy_Payout, + sAnimCmd_Clefairy_Lose }; -static const struct SpriteTemplate gUnknown_84658D8 = { +static const struct SpriteTemplate sSpriteTemplate_Clefairy = { .tileTag = 1, .paletteTag = 5, - .oam = &gUnknown_8465894, - .anims = gUnknown_84658C8, + .oam = &sOamData_Clefairy, + .anims = sAnimTable_Clefairy, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -bool8 (*const gUnknown_84658F0[])(u8 *, struct SlotMachineSetupTaskData *) = { - sub_8141198, - sub_8141460, - sub_81414AC, - sub_81414EC, - sub_81414FC, - sub_8141518, - sub_8141558, - sub_8141568, - sub_8141578, - sub_8141584, - sub_81415C8, - sub_8141610, - sub_8141650, - sub_8141690, - sub_81416C8, - sub_8141764 +bool8 (*const sSlotMachineSetupTasks[])(u8 *, struct SlotMachineSetupTaskData *) = { + [SLOTTASK_GFX_INIT] = SlotsTask_GraphicsInit, + [SLOTTASK_FADEOUT_EXIT] = SlotsTask_FadeOut, + [SLOTTASK_UPDATE_LINE_LIGHTS] = SlotsTask_UpdateLineStates, + [SLOTTASK_CLEFAIRY_BOUNCE] = SlotsTask_ClefairyUpdateOnReelsStart, + [SLOTTASK_ANIM_WIN] = SlotsTask_StartClefairyDanceAndWinningLineFlash, + [SLOTTASK_END_ANIM_WIN] = SlotsTask_StopWinningLineFlashTask, + [SLOTTASK_ANIM_LOSE] = SlotsTask_ClefairyFainted, + [SLOTTASK_ANIM_BETTING] = SlotsTask_ClefairyNeutral, + [SLOTTASK_SHOW_AMOUNTS] = SlotsTask_UpdateCoinsDisplay, + [SLOTTASK_MSG_NO_COINS] = SlotsTask_MessageOutOfCoins, + [SLOTTASK_ASK_QUIT] = SlotsTask_AskQuitPlaying, + [SLOTTASK_DESTROY_YESNO] = SlotsTask_DestroyYesNoMenu, + [SLOTTASK_PRESS_BUTTON] = SlotsTask_PressReelButton, + [SLOTTASK_RELEASE_BUTTONS] = SlotsTask_ReleaseReelButtons, + [SLOTTASK_SHOWHELP] = SlotsTask_ShowHelp, + [SLOTTASK_HIDEHELP] = SlotsTask_HideHelp }; #if defined(FIRERED) -static const u16 gUnknown_8465930[] = INCBIN_U16("graphics/slot_machine/unk_8465930.gbapal"); -static const u16 gUnknown_8465950[] = INCBIN_U16("graphics/slot_machine/unk_8465950.gbapal"); -static const u16 gUnknown_8465970[] = INCBIN_U16("graphics/slot_machine/unk_8465970.gbapal"); -static const u16 gUnknown_8465990[] = INCBIN_U16("graphics/slot_machine/unk_8465990.gbapal"); -static const u16 gUnknown_84659B0[] = INCBIN_U16("graphics/slot_machine/unk_84659b0.gbapal"); -static const u32 gUnknown_84659D0[] = INCBIN_U32("graphics/slot_machine/unk_84659d0.4bpp.lz"); -static const u32 gUnknown_84661D4[] = INCBIN_U32("graphics/slot_machine/unk_84661d4.bin.lz"); -static const u16 gUnknown_84664BC[] = INCBIN_U16("graphics/slot_machine/unk_84664bc.gbapal"); -static const u16 gUnknown_84664DC[] = INCBIN_U16("graphics/slot_machine/unk_84664dc.gbapal","graphics/slot_machine/unk_84664fc.gbapal", "graphics/slot_machine/unk_846651c.gbapal"); +static const u16 sBgPal_00[] = INCBIN_U16("graphics/slot_machine/unk_8465930.gbapal"); +static const u16 sBgPal_10[] = INCBIN_U16("graphics/slot_machine/unk_8465950.gbapal"); +static const u16 sBgPal_20[] = INCBIN_U16("graphics/slot_machine/unk_8465970.gbapal"); +static const u16 sBgPal_30[] = INCBIN_U16("graphics/slot_machine/unk_8465990.gbapal"); +static const u16 sBgPal_40[] = INCBIN_U16("graphics/slot_machine/unk_84659b0.gbapal"); +static const u32 sBg2Tiles_00[] = INCBIN_U32("graphics/slot_machine/unk_84659d0.4bpp.lz"); +static const u32 sBg2Map[] = INCBIN_U32("graphics/slot_machine/unk_84661d4.bin.lz"); +static const u16 sBgPal_50[] = INCBIN_U16("graphics/slot_machine/unk_84664bc.gbapal"); +static const u16 sBgPal_VictoryFlash[] = INCBIN_U16("graphics/slot_machine/unk_84664dc.gbapal","graphics/slot_machine/unk_84664fc.gbapal", "graphics/slot_machine/unk_846651c.gbapal"); #elif defined(LEAFGREEN) -static const u16 gUnknown_8465930[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652bc.gbapal"); -static const u16 gUnknown_8465950[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652dc.gbapal"); -static const u16 gUnknown_8465970[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652fc.gbapal"); -static const u16 gUnknown_8465990[] = INCBIN_U16("graphics/slot_machine/unk_lg_846531c.gbapal"); -static const u16 gUnknown_84659B0[] = INCBIN_U16("graphics/slot_machine/unk_lg_846533c.gbapal"); -static const u32 gUnknown_84659D0[] = INCBIN_U32("graphics/slot_machine/unk_lg_846535c.4bpp.lz"); -static const u32 gUnknown_84661D4[] = INCBIN_U32("graphics/slot_machine/unk_lg_8465ab8.bin.lz"); -static const u16 gUnknown_84664BC[] = INCBIN_U16("graphics/slot_machine/unk_lg_8465d9c.gbapal"); -static const u16 gUnknown_84664DC[] = INCBIN_U16("graphics/slot_machine/unk_lg_8465dbc.gbapal","graphics/slot_machine/unk_lg_8465ddc.gbapal", "graphics/slot_machine/unk_lg_8465dfc.gbapal"); +static const u16 sBgPal_00[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652bc.gbapal"); +static const u16 sBgPal_10[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652dc.gbapal"); +static const u16 sBgPal_20[] = INCBIN_U16("graphics/slot_machine/unk_lg_84652fc.gbapal"); +static const u16 sBgPal_30[] = INCBIN_U16("graphics/slot_machine/unk_lg_846531c.gbapal"); +static const u16 sBgPal_40[] = INCBIN_U16("graphics/slot_machine/unk_lg_846533c.gbapal"); +static const u32 sBg2Tiles_00[] = INCBIN_U32("graphics/slot_machine/unk_lg_846535c.4bpp.lz"); +static const u32 sBg2Map[] = INCBIN_U32("graphics/slot_machine/unk_lg_8465ab8.bin.lz"); +static const u16 sBgPal_50[] = INCBIN_U16("graphics/slot_machine/unk_lg_8465d9c.gbapal"); +static const u16 sBgPal_VictoryFlash[] = INCBIN_U16("graphics/slot_machine/unk_lg_8465dbc.gbapal","graphics/slot_machine/unk_lg_8465ddc.gbapal", "graphics/slot_machine/unk_lg_8465dfc.gbapal"); #endif -static const u32 gUnknown_846653C[] = INCBIN_U32("graphics/slot_machine/unk_846653c.4bpp.lz"); -static const u16 gUnknown_84665C0[] = INCBIN_U16("graphics/slot_machine/unk_84665c0.gbapal"); -static const u16 gUnknown_84665E0[] = INCBIN_U16("graphics/slot_machine/unk_84665e0.gbapal"); -static const u16 gUnknown_8466600[] = INCBIN_U16("graphics/slot_machine/unk_8466600.gbapal"); +static const u32 sBg2Tiles_C0[] = INCBIN_U32("graphics/slot_machine/unk_846653c.4bpp.lz"); +static const u16 sBgPal_70[] = INCBIN_U16("graphics/slot_machine/unk_84665c0.gbapal"); +static const u16 sBgPal_80[] = INCBIN_U16("graphics/slot_machine/unk_84665e0.gbapal"); +static const u16 sBgPal_90[] = INCBIN_U16("graphics/slot_machine/unk_8466600.gbapal"); #if defined(FIRERED) -static const u32 gUnknown_8466620[] = INCBIN_U32("graphics/slot_machine/unk_8466620.4bpp.lz"); -static const u32 gUnknown_8466998[] = INCBIN_U32("graphics/slot_machine/unk_8466998.bin.lz"); +static const u32 sBg1Tiles[] = INCBIN_U32("graphics/slot_machine/unk_8466620.4bpp.lz"); +static const u32 sBg1Map[] = INCBIN_U32("graphics/slot_machine/unk_8466998.bin.lz"); #elif defined(LEAFGREEN) -static const u32 gUnknown_8466620[] = INCBIN_U32("graphics/slot_machine/unk_lg_8465f00.4bpp.lz"); -static const u32 gUnknown_8466998[] = INCBIN_U32("graphics/slot_machine/unk_lg_8466278.bin.lz"); +static const u32 sBg1Tiles[] = INCBIN_U32("graphics/slot_machine/unk_lg_8465f00.4bpp.lz"); +static const u32 sBg1Map[] = INCBIN_U32("graphics/slot_machine/unk_lg_8466278.bin.lz"); #endif -static const struct BgTemplate gUnknown_8466B10[] = { +static const struct BgTemplate sBgTemplates[] = { { .bg = 0, .charBaseIndex = 0, @@ -621,7 +723,7 @@ static const struct BgTemplate gUnknown_8466B10[] = { } }; -static const struct WindowTemplate gUnknown_8466B20[] = { +static const struct WindowTemplate sWindowTemplates[] = { { .bg = 0, .tilemapLeft = 5, @@ -642,37 +744,37 @@ static const struct WindowTemplate gUnknown_8466B20[] = { DUMMY_WIN_TEMPLATE }; -static const u16 gUnknown_8466B38[] = { +static const u16 sLineTiles_TLBR[] = { 0x00a4, 0x00a5, 0x00a6, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00e7, 0x012c, 0x014c, 0x0191, 0x01b1, 0x01f6, 0x0216, 0x0217, 0x0218, 0x0219, 0x0237, 0x0238, 0x0239 }; -static const u16 gUnknown_8466B60[] = { +static const u16 sLineTiles_TopRow[] = { 0x00e4, 0x00e5, 0x00e6, 0x00f7, 0x00f8, 0x00f9, 0x0104, 0x0105, 0x0106, 0x0107, 0x010c, 0x0111, 0x0116, 0x0117, 0x0118, 0x0119, 0x0124, 0x0125, 0x0126, 0x0137, 0x0138, 0x0139 }; -static const u16 gUnknown_8466B8C[] = { +static const u16 sLineTiles_MiddleRow[] = { 0x0144, 0x0145, 0x0146, 0x0157, 0x0158, 0x0159, 0x0164, 0x0165, 0x0166, 0x0167, 0x016c, 0x0171, 0x0176, 0x0177, 0x0178, 0x0179, 0x0184, 0x0185, 0x0186, 0x0197, 0x0198, 0x0199 }; -static const u16 gUnknown_8466BB8[] = { +static const u16 sLineTiles_BottomRow[] = { 0x01a4, 0x01a5, 0x01a6, 0x01b7, 0x01b8, 0x01b9, 0x01c4, 0x01c5, 0x01c6, 0x01c7, 0x01cc, 0x01d1, 0x01d6, 0x01d7, 0x01d8, 0x01d9, 0x01e4, 0x01e5, 0x01e6, 0x01f7, 0x01f8, 0x01f9 }; -static const u16 gUnknown_8466BE4[] = { +static const u16 sLineTiles_BLTR[] = { 0x0204, 0x0205, 0x0206, 0x0224, 0x0225, 0x0226, 0x01e7, 0x0207, 0x018c, 0x01ac, 0x0131, 0x0151, 0x00d6, 0x00f6, 0x00b7, 0x00b8, 0x00b9, 0x00d7, 0x00d8, 0x00d9 }; -static const struct UnkStruct_8466C0C gUnknown_8466C0C[] = { - { gUnknown_8466B38, NELEMS(gUnknown_8466B38) }, - { gUnknown_8466B60, NELEMS(gUnknown_8466B60) }, - { gUnknown_8466B8C, NELEMS(gUnknown_8466B8C) }, - { gUnknown_8466BB8, NELEMS(gUnknown_8466BB8) }, - { gUnknown_8466BE4, NELEMS(gUnknown_8466BE4) } +static const struct LineStateTileIdxList sLineStateTileIdxs[] = { + { sLineTiles_TLBR, NELEMS(sLineTiles_TLBR) }, + { sLineTiles_TopRow, NELEMS(sLineTiles_TopRow) }, + { sLineTiles_MiddleRow, NELEMS(sLineTiles_MiddleRow) }, + { sLineTiles_BottomRow, NELEMS(sLineTiles_BottomRow) }, + { sLineTiles_BLTR, NELEMS(sLineTiles_BLTR) } }; -static const u8 gUnknown_8466C34[2] = {2, 4}; +static const u8 sWInningLineFlashPalIdxs[2] = {2, 4}; -static const struct WindowTemplate gUnknown_8466C38 = { +static const struct WindowTemplate sYesNoWindowTemplate = { .bg = 0, .tilemapLeft = 19, .tilemapTop = 9, @@ -682,7 +784,7 @@ static const struct WindowTemplate gUnknown_8466C38 = { .baseBlock = 0x9F }; -static const u16 gUnknown_8466C40[][4] = { +static const u16 sReelButtonMapTileIdxs[][4] = { {0x0229, 0x022a, 0x0249, 0x024a}, {0x022e, 0x022f, 0x024e, 0x024f}, {0x0233, 0x0234, 0x0253, 0x0254} @@ -700,29 +802,29 @@ void PlaySlotMachine(u16 machineIdx, MainCallback savedCallback) machineIdx = 0; sSlotMachineState->machineidx = machineIdx; sSlotMachineState->savedCallback = savedCallback; - sub_813F84C(sSlotMachineState); - SetMainCallback2(sub_813F898); + InitSlotMachineState(sSlotMachineState); + SetMainCallback2(CB2_InitSlotMachine); } } -static void sub_813F84C(struct SlotMachineState * ptr) +static void InitSlotMachineState(struct SlotMachineState * ptr) { s32 i; - ptr->field_06 = 0; + ptr->currentReel = 0; ptr->bet = 0; ptr->payout = 0; // for whatever reason, the loop does not use the ptr param for (i = 0; i < 3; i++) { - sSlotMachineState->field_14[i] = FALSE; - sSlotMachineState->reelPositions[i] = 0; - sSlotMachineState->field_26[i] = 0; - sSlotMachineState->field_2C[i] = 21; + sSlotMachineState->reelIsSpinning[i] = FALSE; + sSlotMachineState->reelPositions[i] = 0; + sSlotMachineState->reelSubpixel[i] = 0; + sSlotMachineState->destReelPos[i] = 21; } } -static void sub_813F898(void) +static void CB2_InitSlotMachine(void) { RunTasks(); AnimateSprites(); @@ -731,31 +833,31 @@ static void sub_813F898(void) switch (gMain.state) { case 0: - if (sub_814104C()) + if (CreateSlotMachine()) { SetMainCallback2(sSlotMachineState->savedCallback); - sub_813F92C(); + CleanSupSlotMachineState(); } else { - SetSlotMachineSetupTask(0, 0); + SetSlotMachineSetupTask(SLOTTASK_GFX_INIT, 0); gMain.state++; } break; case 1: if (!IsSlotMachineSetupTaskActive(0)) { - sSlotMachineState->field_10 = CreateTask(MainTask_SlotsGameLoop, 0); - sSlotMachineState->field_11 = CreateTask(sub_8140060, 1); - SetMainCallback2(sub_813F94C); + sSlotMachineState->taskId = CreateTask(MainTask_SlotsGameLoop, 0); + sSlotMachineState->spinReelsTaskId = CreateTask(Task_SpinReels, 1); + SetMainCallback2(CB2_RunSlotMachine); } break; } } -static void sub_813F92C(void) +static void CleanSupSlotMachineState(void) { - sub_8141094(); + DestroySlotMachine(); if (sSlotMachineState != NULL) { Free(sSlotMachineState); @@ -763,7 +865,7 @@ static void sub_813F92C(void) } } -static void sub_813F94C(void) +static void CB2_RunSlotMachine(void) { RunTasks(); AnimateSprites(); @@ -788,8 +890,8 @@ static void MainTask_SlotsGameLoop(u8 taskId) sSlotMachineState->bet++; RemoveCoins(1); PlaySE(SE_REGI); - SetSlotMachineSetupTask(8, 0); - SetSlotMachineSetupTask(2, 1); + SetSlotMachineSetupTask(SLOTTASK_SHOW_AMOUNTS, 0); + SetSlotMachineSetupTask(SLOTTASK_UPDATE_LINE_LIGHTS, 1); data[0] = 1; } else if (JOY_NEW(R_BUTTON)) @@ -806,8 +908,8 @@ static void MainTask_SlotsGameLoop(u8 taskId) SetCoins(0); } PlaySE(SE_REGI); - SetSlotMachineSetupTask(8, 0); - SetSlotMachineSetupTask(2, 1); + SetSlotMachineSetupTask(SLOTTASK_SHOW_AMOUNTS, 0); + SetSlotMachineSetupTask(SLOTTASK_UPDATE_LINE_LIGHTS, 1); data[0] = 1; } else if (JOY_NEW(A_BUTTON) && sSlotMachineState->bet != 0) @@ -834,10 +936,10 @@ static void MainTask_SlotsGameLoop(u8 taskId) break; case 2: SetQLPlayedTheSlots(); - sub_81409B4(); - sub_8140148(); - sSlotMachineState->field_06 = 0; - SetSlotMachineSetupTask(3, 0); + CalcSlotBias(); + StartReels(); + sSlotMachineState->currentReel = 0; + SetSlotMachineSetupTask(SLOTTASK_CLEFAIRY_BOUNCE, 0); data[0] = 3; break; case 3: @@ -846,28 +948,28 @@ static void MainTask_SlotsGameLoop(u8 taskId) if (JOY_NEW(A_BUTTON)) { PlaySE(SE_JYUNI); - sub_814016C(sSlotMachineState->field_06, sSlotMachineState->field_06); - sub_8141C30(sSlotMachineState->field_06, 0); + StopCurrentReel(sSlotMachineState->currentReel, sSlotMachineState->currentReel); + PressReelButton(sSlotMachineState->currentReel, 0); data[0] = 4; } } break; case 4: - if (sub_81401A0(sSlotMachineState->field_06) == 0 && !IsSlotMachineSetupTaskActive(0)) + if (IsReelSpinning(sSlotMachineState->currentReel) == 0 && !IsSlotMachineSetupTaskActive(0)) { - sSlotMachineState->field_06++; - if (sSlotMachineState->field_06 >= 3) + sSlotMachineState->currentReel++; + if (sSlotMachineState->currentReel >= 3) { sSlotMachineState->slotRewardClass = CalcPayout(); sSlotMachineState->bet = 0; - sSlotMachineState->field_06 = 0; - if (sSlotMachineState->slotRewardClass == 0) + sSlotMachineState->currentReel = 0; + if (sSlotMachineState->slotRewardClass == SLOT_PAYOUT_NONE) SetMainTask(MainTask_DarnNoPayout); else { - if (sSlotMachineState->slotRewardClass == 6) + if (sSlotMachineState->slotRewardClass == SLOT_PAYOUT_7) IncrementGameStat(GAME_STAT_SLOT_JACKPOTS); - sub_8140A70(); + ResetMachineBias(); SetMainTask(MainTask_WinHandlePayout); } } @@ -885,7 +987,7 @@ static void MainTask_NoCoinsGameOver(u8 taskId) switch (data[0]) { case 0: - SetSlotMachineSetupTask(9, 0); + SetSlotMachineSetupTask(SLOTTASK_MSG_NO_COINS, 0); data[0]++; break; case 1: @@ -906,7 +1008,7 @@ static void MainTask_ShowHelp(u8 taskId) switch (data[0]) { case 0: - SetSlotMachineSetupTask(14, 0); + SetSlotMachineSetupTask(SLOTTASK_SHOWHELP, 0); data[0]++; break; case 1: @@ -916,7 +1018,7 @@ static void MainTask_ShowHelp(u8 taskId) case 2: if (JOY_NEW(DPAD_LEFT)) { - SetSlotMachineSetupTask(15, 0); + SetSlotMachineSetupTask(SLOTTASK_HIDEHELP, 0); data[0]++; } break; @@ -934,7 +1036,7 @@ static void MainTask_ConfirmExitGame(u8 taskId) switch (data[0]) { case 0: - SetSlotMachineSetupTask(10, 0); + SetSlotMachineSetupTask(SLOTTASK_ASK_QUIT, 0); data[0]++; break; case 1: @@ -946,12 +1048,12 @@ static void MainTask_ConfirmExitGame(u8 taskId) { case 0: AddCoins(sSlotMachineState->bet); - SetSlotMachineSetupTask(8, 0); + SetSlotMachineSetupTask(SLOTTASK_SHOW_AMOUNTS, 0); data[0] = 3; break; case 1: case -1: - SetSlotMachineSetupTask(11, 0); + SetSlotMachineSetupTask(SLOTTASK_DESTROY_YESNO, 0); data[0] = 4; break; } @@ -974,7 +1076,7 @@ static void MainTask_DarnNoPayout(u8 taskId) switch (data[0]) { case 0: - SetSlotMachineSetupTask(6, 0); + SetSlotMachineSetupTask(SLOTTASK_ANIM_LOSE, 0); data[1] = 0; data[0]++; break; @@ -982,9 +1084,9 @@ static void MainTask_DarnNoPayout(u8 taskId) data[1]++; if (data[1] > 60) { - SetSlotMachineSetupTask(7, 0); - SetSlotMachineSetupTask(2, 1); - SetSlotMachineSetupTask(13, 2); + SetSlotMachineSetupTask(SLOTTASK_ANIM_BETTING, 0); + SetSlotMachineSetupTask(SLOTTASK_UPDATE_LINE_LIGHTS, 1); + SetSlotMachineSetupTask(SLOTTASK_RELEASE_BUTTONS, 2); data[0]++; } break; @@ -1002,12 +1104,12 @@ static void MainTask_WinHandlePayout(u8 taskId) switch (data[0]) { case 0: - if (sSlotMachineState->slotRewardClass == 5 || sSlotMachineState->slotRewardClass == 6) + if (sSlotMachineState->slotRewardClass == SLOT_PAYOUT_ROCKET || sSlotMachineState->slotRewardClass == SLOT_PAYOUT_7) PlayFanfare(MUS_ME_B_BIG); else PlayFanfare(MUS_ME_B_SMALL); - SetSlotMachineSetupTask(8, 0); - SetSlotMachineSetupTask(4, 1); + SetSlotMachineSetupTask(SLOTTASK_SHOW_AMOUNTS, 0); + SetSlotMachineSetupTask(SLOTTASK_ANIM_WIN, 1); data[1] = 8; data[0]++; break; @@ -1046,7 +1148,7 @@ static void MainTask_WinHandlePayout(u8 taskId) data[1] = 2; } } - SetSlotMachineSetupTask(8, 0); + SetSlotMachineSetupTask(SLOTTASK_SHOW_AMOUNTS, 0); if (sSlotMachineState->payout == 0) data[0]++; } @@ -1054,15 +1156,15 @@ static void MainTask_WinHandlePayout(u8 taskId) case 3: if (IsFanfareTaskInactive() && !IsSlotMachineSetupTaskActive(0)) { - SetSlotMachineSetupTask(5, 0); + SetSlotMachineSetupTask(SLOTTASK_END_ANIM_WIN, 0); data[0]++; } break; case 4: if (!IsSlotMachineSetupTaskActive(0)) { - SetSlotMachineSetupTask(2, 0); - SetSlotMachineSetupTask(13, 1); + SetSlotMachineSetupTask(SLOTTASK_UPDATE_LINE_LIGHTS, 0); + SetSlotMachineSetupTask(SLOTTASK_RELEASE_BUTTONS, 1); data[0]++; } break; @@ -1080,14 +1182,14 @@ static void MainTask_ExitSlots(u8 taskId) switch (data[0]) { case 0: - SetSlotMachineSetupTask(1, 0); + SetSlotMachineSetupTask(SLOTTASK_FADEOUT_EXIT, 0); data[0]++; break; case 1: if (!IsSlotMachineSetupTaskActive(0)) { SetMainCallback2(sSlotMachineState->savedCallback); - sub_813F92C(); + CleanSupSlotMachineState(); } break; } @@ -1095,11 +1197,11 @@ static void MainTask_ExitSlots(u8 taskId) static void SetMainTask(TaskFunc taskFunc) { - gTasks[sSlotMachineState->field_10].func = taskFunc; - gTasks[sSlotMachineState->field_10].data[0] = 0; + gTasks[sSlotMachineState->taskId].func = taskFunc; + gTasks[sSlotMachineState->taskId].data[0] = 0; } -static void sub_8140060(u8 taskId) +static void Task_SpinReels(u8 taskId) { // taskId is never used @@ -1107,63 +1209,63 @@ static void sub_8140060(u8 taskId) for (i = 0; i < 3; i++) { - if (sSlotMachineState->field_14[i] || sSlotMachineState->field_26[i] != 0) + if (sSlotMachineState->reelIsSpinning[i] || sSlotMachineState->reelSubpixel[i] != 0) { - if (sSlotMachineState->field_26[i] != 0 || sSlotMachineState->reelPositions[i] != sSlotMachineState->field_2C[i]) + if (sSlotMachineState->reelSubpixel[i] != 0 || sSlotMachineState->reelPositions[i] != sSlotMachineState->destReelPos[i]) { - sSlotMachineState->field_26[i]++; - if (sSlotMachineState->field_26[i] > 2) + sSlotMachineState->reelSubpixel[i]++; + if (sSlotMachineState->reelSubpixel[i] > 2) { - sSlotMachineState->field_26[i] = 0; + sSlotMachineState->reelSubpixel[i] = 0; sSlotMachineState->reelPositions[i]--; if (sSlotMachineState->reelPositions[i] < 0) sSlotMachineState->reelPositions[i] = 20; } - if (sSlotMachineState->reelPositions[i] != sSlotMachineState->field_2C[i]) + if (sSlotMachineState->reelPositions[i] != sSlotMachineState->destReelPos[i]) continue; } - sSlotMachineState->field_2C[i] = 21; - sSlotMachineState->field_14[i] = FALSE; + sSlotMachineState->destReelPos[i] = 21; + sSlotMachineState->reelIsSpinning[i] = FALSE; } } - sub_8140D7C(sSlotMachineState->reelPositions, sSlotMachineState->field_26); + UpdateReelIconSprites(sSlotMachineState->reelPositions, sSlotMachineState->reelSubpixel); } -static void sub_8140148(void) +static void StartReels(void) { s32 i; for (i = 0; i < 3; i++) { - sSlotMachineState->field_14[i] = TRUE; + sSlotMachineState->reelIsSpinning[i] = TRUE; } } -static void sub_814016C(u16 whichReel, u16 whichReel2) +static void StopCurrentReel(u16 whichReel, u16 whichReel2) { switch (whichReel2) { case 0: - sub_81401F0(whichReel); + StopReel1(whichReel); break; case 1: - sub_81403BC(whichReel); + StopReel2(whichReel); break; case 2: - sub_81404B8(whichReel); + StopReel3(whichReel); break; } } -static bool32 sub_81401A0(u16 whichReel) +static bool32 IsReelSpinning(u16 whichReel) { - return sSlotMachineState->field_14[whichReel]; + return sSlotMachineState->reelIsSpinning[whichReel]; } -static s16 sub_81401B4(u16 whichReel) +static s16 GetNextReelPosition(u16 whichReel) { s16 position = sSlotMachineState->reelPositions[whichReel]; - if (sSlotMachineState->field_26[whichReel] != 0) + if (sSlotMachineState->reelSubpixel[whichReel] != 0) { position--; if (position < 0) @@ -1172,205 +1274,204 @@ static s16 sub_81401B4(u16 whichReel) return position; } -static void sub_81401F0(u16 whichReel) +static void StopReel1(u16 whichReel) { s32 i, j; - s16 r2; - u8 sp0[5]; - s16 sp0C = sub_81401B4(whichReel); - s32 r8 = 0; + s16 destPos; + u8 posToSample[5]; + s16 nextPos = GetNextReelPosition(whichReel); + s32 numPosToSample = 0; - if (sSlotMachineState->field_08 == 0 && whichReel == 0) + if (sSlotMachineState->machineBias == 0 && whichReel == 0) { for (i = 0; i < 5; i++) { - for (j = 0, r2 = sp0C - i + 1; j < 3; j++, r2++) + for (j = 0, destPos = nextPos - i + 1; j < 3; j++, destPos++) { - if (r2 >= 21) - r2 = 0; - if (sub_81408F4(1, gUnknown_8464926[whichReel][r2])) + if (destPos >= 21) + destPos = 0; + if (TestReelIconAttribute(1, sReelIconAnimByReelAndPos[whichReel][destPos])) break; } if (j == 3) { - sp0[r8] = i; - r8++; + posToSample[numPosToSample] = i; + numPosToSample++; } } } - else if (sSlotMachineState->field_08 != 1 || whichReel == 0) + else if (sSlotMachineState->machineBias != 1 || whichReel == 0) { - for (i = 0, r2 = sp0C + 1; i < 3; i++, r2++) + for (i = 0, destPos = nextPos + 1; i < 3; i++, destPos++) { - if (r2 >= 21) - r2 = 0; - if (sub_81408F4(sSlotMachineState->field_08, gUnknown_8464926[whichReel][r2])) + if (destPos >= 21) + destPos = 0; + if (TestReelIconAttribute(sSlotMachineState->machineBias, sReelIconAnimByReelAndPos[whichReel][destPos])) { - sp0[0] = 0; - r8 = 1; + posToSample[0] = 0; + numPosToSample = 1; break; } } - for (i = 0, r2 = sp0C; i < 4; i++, r2--) + for (i = 0, destPos = nextPos; i < 4; i++, destPos--) { - if (r2 < 0) - r2 = 20; - if (sub_81408F4(sSlotMachineState->field_08, gUnknown_8464926[whichReel][r2])) + if (destPos < 0) + destPos = 20; + if (TestReelIconAttribute(sSlotMachineState->machineBias, sReelIconAnimByReelAndPos[whichReel][destPos])) { - sp0[r8] = i + 1; - r8++; + posToSample[numPosToSample] = i + 1; + numPosToSample++; } } } - if (r8 == 0) + if (numPosToSample == 0) { - r2 = Random() % 5; + destPos = Random() % 5; } else { - r2 = sp0[Random() % r8]; + destPos = posToSample[Random() % numPosToSample]; } - r2 = sp0C - r2; - if (r2 < 0) - r2 += 21; - sSlotMachineState->field_32[0] = whichReel; - sSlotMachineState->field_2C[whichReel] = r2; + destPos = nextPos - destPos; + if (destPos < 0) + destPos += 21; + sSlotMachineState->reelStopOrder[0] = whichReel; + sSlotMachineState->destReelPos[whichReel] = destPos; } -static void sub_81403BC(u16 whichReel) +static void StopReel2(u16 whichReel) { - s16 r2, r4, r7, sp10; + s16 pos, firstStoppedReelPos, firstStoppedReelId, nextPos; s32 i; - s32 r6; - u8 sp4[5]; - - r7 = sSlotMachineState->field_32[0]; - r4 = sSlotMachineState->reelPositions[r7] + 1; - if (r4 >= 21) - r4 = 0; - sp10 = sub_81401B4(whichReel); - r2 = sp10 + 1; - if (r2 >= 21) - r2 = 0; - r6 = 0; + s32 numPossiblePositions; + u8 possiblePositions[5]; + + firstStoppedReelId = sSlotMachineState->reelStopOrder[0]; + firstStoppedReelPos = sSlotMachineState->reelPositions[firstStoppedReelId] + 1; + if (firstStoppedReelPos >= 21) + firstStoppedReelPos = 0; + nextPos = GetNextReelPosition(whichReel); + pos = nextPos + 1; + if (pos >= 21) + pos = 0; + numPossiblePositions = 0; for (i = 0; i < 5; i++) { - if (sub_814054C(r7, r4, whichReel, r2, sSlotMachineState->field_08)) + if (TwoReelBiasCheck(firstStoppedReelId, firstStoppedReelPos, whichReel, pos, sSlotMachineState->machineBias)) { - sp4[r6] = i; - r6++; + possiblePositions[numPossiblePositions] = i; + numPossiblePositions++; } - r2--; - if (r2 < 0) - r2 = 20; + pos--; + if (pos < 0) + pos = 20; } - if (r6 == 0) + if (numPossiblePositions == 0) { - sSlotMachineState->field_38 = 0; - if (sSlotMachineState->field_08 == 5 || sSlotMachineState->field_08 == 6) - r2 = 4; + sSlotMachineState->reel2BiasInPlay = 0; + if (sSlotMachineState->machineBias == SLOT_PAYOUT_ROCKET || sSlotMachineState->machineBias == SLOT_PAYOUT_7) + pos = 4; else - r2 = 0; + pos = 0; } else { - sSlotMachineState->field_38 = 1; - r2 = sp4[0]; + sSlotMachineState->reel2BiasInPlay = 1; + pos = possiblePositions[0]; } - r2 = sp10 - r2; - if (r2 < 0) - r2 += 21; - sSlotMachineState->field_32[1] = whichReel; - sSlotMachineState->field_2C[whichReel] = r2; + pos = nextPos - pos; + if (pos < 0) + pos += 21; + sSlotMachineState->reelStopOrder[1] = whichReel; + sSlotMachineState->destReelPos[whichReel] = pos; } -static void sub_81404B8(u16 whichReel) +static void StopReel3(u16 whichReel) { s32 i; - s32 r6; - s32 r9; - s32 r4; - s32 r2; - u8 sp0[5]; - - r9 = sub_81401B4(whichReel); - r4 = r9; - r6 = 0; + s32 numPossiblePositions; + s32 nextPos; + s32 testPos; + s32 pos; + u8 possiblePositions[5]; + + nextPos = GetNextReelPosition(whichReel); + testPos = nextPos; + numPossiblePositions = 0; for (i = 0; i < 5; i++) { - if (sub_81406E8(whichReel, r4, sSlotMachineState->field_08)) + if (OneReelBiasCheck(whichReel, testPos, sSlotMachineState->machineBias)) { - sp0[r6] = i; - r6++; + possiblePositions[numPossiblePositions] = i; + numPossiblePositions++; } - r4--; - if (r4 < 0) - r4 = 20; + testPos--; + if (testPos < 0) + testPos = 20; } - if (r6 == 0) + if (numPossiblePositions == 0) { - if (sSlotMachineState->field_08 == 5 || sSlotMachineState->field_08 == 6) - r2 = 4; + if (sSlotMachineState->machineBias == SLOT_PAYOUT_ROCKET || sSlotMachineState->machineBias == SLOT_PAYOUT_7) + pos = 4; else - r2 = 0; + pos = 0; } else - r2 = sp0[0]; - r2 = r9 - r2; - if (r2 < 0) - r2 += 21; - sSlotMachineState->field_2C[whichReel] = r2; + pos = possiblePositions[0]; + pos = nextPos - pos; + if (pos < 0) + pos += 21; + sSlotMachineState->destReelPos[whichReel] = pos; } -static bool32 sub_814054C(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4) +static bool32 TwoReelBiasCheck(s32 reel0id, s32 reel0pos, s32 reel1id, s32 reel1pos, s32 icon) { s32 i; - s32 r5; - u8 sp0[9] = {}; + u8 icons[9] = {}; for (i = 0; i < 9; i++) - sp0[i] = 7; + icons[i] = 7; for (i = 0; i < 3; i++) { - sp0[3 * a0 + i] = gUnknown_8464926[a0][a1]; - sp0[3 * a2 + i] = gUnknown_8464926[a2][a3]; - a1++; - if (a1 >= 21) - a1 = 0; - a3++; - if (a3 >= 21) - a3 = 0; + icons[3 * reel0id + i] = sReelIconAnimByReelAndPos[reel0id][reel0pos]; + icons[3 * reel1id + i] = sReelIconAnimByReelAndPos[reel1id][reel1pos]; + reel0pos++; + if (reel0pos >= 21) + reel0pos = 0; + reel1pos++; + if (reel1pos >= 21) + reel1pos = 0; } - switch (a4) + switch (icon) { case 0: for (i = 0; i < 3; i++) { - if (sub_81408F4(1, sp0[i])) + if (TestReelIconAttribute(1, icons[i])) return FALSE; } for (i = 0; i < 15; i++) { - if (sp0[gUnknown_8464890[i][0]] == sp0[gUnknown_8464890[i][1]]) + if (icons[sSecondReelBiasCheckIndices[i][0]] == icons[sSecondReelBiasCheckIndices[i][1]]) return TRUE; } return FALSE; case 1: - if (a0 == 0 || a2 == 0) + if (reel0id == 0 || reel1id == 0) { - if (a0 == 1 || a2 == 1) + if (reel0id == 1 || reel1id == 1) { for (i = 0; i < 15; i += 3) { - if (sp0[gUnknown_8464890[i][0]] == sp0[gUnknown_8464890[i][1]]) + if (icons[sSecondReelBiasCheckIndices[i][0]] == icons[sSecondReelBiasCheckIndices[i][1]]) return FALSE; } } for (i = 0; i < 3; i++) { - if (sub_81408F4(a4, sp0[i])) + if (TestReelIconAttribute(icon, icons[i])) return TRUE; } return FALSE; @@ -1378,11 +1479,11 @@ static bool32 sub_814054C(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4) else return TRUE; case 2: - if (a0 == 2 || a2 == 2) + if (reel0id == 2 || reel1id == 2) { for (i = 0; i < 9; i++) { - if (sub_81408F4(a4, sp0[i])) + if (TestReelIconAttribute(icon, icons[i])) return TRUE; } return FALSE; // wrong level @@ -1390,159 +1491,159 @@ static bool32 sub_814054C(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4) } for (i = 0; i < 15; i++) { - if (sp0[gUnknown_8464890[i][0]] == sp0[gUnknown_8464890[i][1]] && sub_81408F4(a4, sp0[gUnknown_8464890[i][0]])) + if (icons[sSecondReelBiasCheckIndices[i][0]] == icons[sSecondReelBiasCheckIndices[i][1]] && TestReelIconAttribute(icon, icons[sSecondReelBiasCheckIndices[i][0]])) return TRUE; } return FALSE; } -static bool32 sub_81406E8(s32 a0, s32 a1, s32 a2) +static bool32 OneReelBiasCheck(s32 reelId, s32 reelPos, s32 biasIcon) { - u8 sp0[9]; - s32 r3, r6; + u8 icons[9]; + s32 secondStoppedPos, firstStoppedPos; s32 i; - r6++; r6--; - r6 = sSlotMachineState->reelPositions[sSlotMachineState->field_32[0]] + 1; - r3 = sSlotMachineState->reelPositions[sSlotMachineState->field_32[1]] + 1; - a1++; - if (r6 >= 21) - r6 = 0; - if (r3 >= 21) - r3 = 0; - if (a1 >= 21) - a1 = 0; + firstStoppedPos++; firstStoppedPos--; + firstStoppedPos = sSlotMachineState->reelPositions[sSlotMachineState->reelStopOrder[0]] + 1; + secondStoppedPos = sSlotMachineState->reelPositions[sSlotMachineState->reelStopOrder[1]] + 1; + reelPos++; + if (firstStoppedPos >= 21) + firstStoppedPos = 0; + if (secondStoppedPos >= 21) + secondStoppedPos = 0; + if (reelPos >= 21) + reelPos = 0; for (i = 0; i < 3; i++) { - sp0[sSlotMachineState->field_32[0] * 3 + i] = gUnknown_8464926[sSlotMachineState->field_32[0]][r6]; - sp0[sSlotMachineState->field_32[1] * 3 + i] = gUnknown_8464926[sSlotMachineState->field_32[1]][r3]; - sp0[a0 * 3 + i] = gUnknown_8464926[a0][a1]; - if (++r6 >= 21) - r6 = 0; - if (++r3 >= 21) - r3 = 0; - if (++a1 >= 21) - a1 = 0; + icons[sSlotMachineState->reelStopOrder[0] * 3 + i] = sReelIconAnimByReelAndPos[sSlotMachineState->reelStopOrder[0]][firstStoppedPos]; + icons[sSlotMachineState->reelStopOrder[1] * 3 + i] = sReelIconAnimByReelAndPos[sSlotMachineState->reelStopOrder[1]][secondStoppedPos]; + icons[reelId * 3 + i] = sReelIconAnimByReelAndPos[reelId][reelPos]; + if (++firstStoppedPos >= 21) + firstStoppedPos = 0; + if (++secondStoppedPos >= 21) + secondStoppedPos = 0; + if (++reelPos >= 21) + reelPos = 0; } - switch (a2) + switch (biasIcon) { - case 0: + case SLOT_PAYOUT_NONE: for (i = 0; i < 3; i++) { - if (sub_81408F4(1, sp0[i])) + if (TestReelIconAttribute(1, icons[i])) return FALSE; } for (i = 0; i < 5; i++) { - if (sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][1]] && sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][2]]) + if (icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][1]] && icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][2]]) return FALSE; } return TRUE; - case 1: + case SLOT_PAYOUT_CHERRIES2: for (i = 0; i < 5; i++) { - if (sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][1]] && sub_81408F4(a2, sp0[gUnknown_84648AE[i][0]])) + if (icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][1]] && TestReelIconAttribute(biasIcon, icons[sThirdReelBiasCheckIndices[i][0]])) return FALSE; } for (i = 0; i < 3; i++) { - if (sub_81408F4(a2, sp0[i])) + if (TestReelIconAttribute(biasIcon, icons[i])) return TRUE; } return FALSE; - case 2: + case SLOT_PAYOUT_CHERRIES3: for (i = 0; i < 5; i++) { - if (sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][1]] && sub_81408F4(a2, sp0[gUnknown_84648AE[i][0]])) + if (icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][1]] && TestReelIconAttribute(biasIcon, icons[sThirdReelBiasCheckIndices[i][0]])) return TRUE; } return FALSE; } for (i = 0; i < 5; i++) { - if (sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][1]] && sp0[gUnknown_84648AE[i][0]] == sp0[gUnknown_84648AE[i][2]] && sub_81408F4(a2, sp0[gUnknown_84648AE[i][0]])) + if (icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][1]] && icons[sThirdReelBiasCheckIndices[i][0]] == icons[sThirdReelBiasCheckIndices[i][2]] && TestReelIconAttribute(biasIcon, icons[sThirdReelBiasCheckIndices[i][0]])) return TRUE; } return FALSE; } -static bool32 sub_81408F4(s32 a0, s32 a1) +static bool32 TestReelIconAttribute(s32 attr, s32 icon) { - switch (a0) + switch (attr) { - case 0: - return a1 ^ 4 ? TRUE : FALSE; - case 1: - case 2: - return a1 == 4 ? TRUE : FALSE; - case 3: - return a1 == 5 || a1 == 6 ? TRUE : FALSE; - case 4: - return a1 == 2 || a1 == 3 ? TRUE : FALSE; - case 5: - return a1 == 1 ? TRUE : FALSE; - case 6: - return a1 == 0 ? TRUE : FALSE; + case SLOT_PAYOUT_NONE: + return icon ^ 4 ? TRUE : FALSE; + case SLOT_PAYOUT_CHERRIES2: + case SLOT_PAYOUT_CHERRIES3: + return icon == SLOT_IMAGE_CHERRIES ? TRUE : FALSE; + case SLOT_PAYOUT_MAGSHELL: + return icon == SLOT_IMAGE_MAGNEMITE || icon == SLOT_IMAGE_SHELLDER ? TRUE : FALSE; + case SLOT_PAYOUT_PIKAPSY: + return icon == SLOT_IMAGE_PIKACHU || icon == SLOT_IMAGE_PSYDUCK ? TRUE : FALSE; + case SLOT_PAYOUT_ROCKET: + return icon == SLOT_IMAGE_ROCKET ? TRUE : FALSE; + case SLOT_PAYOUT_7: + return icon == SLOT_IMAGE_7 ? TRUE : FALSE; default: return FALSE; } } -static u8 sub_814096C(s32 a0) +static u8 ReelIconToPayoutRank(s32 iconId) { - switch (a0) + switch (iconId) { default: - case 4: - return 1; - case 5: - case 6: - return 3; - case 2: - case 3: - return 4; - case 1: - return 5; - case 0: - return 6; + case SLOT_IMAGE_CHERRIES: + return SLOT_PAYOUT_CHERRIES2; + case SLOT_IMAGE_MAGNEMITE: + case SLOT_IMAGE_SHELLDER: + return SLOT_PAYOUT_MAGSHELL; + case SLOT_IMAGE_PIKACHU: + case SLOT_IMAGE_PSYDUCK: + return SLOT_PAYOUT_PIKAPSY; + case SLOT_IMAGE_ROCKET: + return SLOT_PAYOUT_ROCKET; + case SLOT_IMAGE_7: + return SLOT_PAYOUT_7; } } -static void sub_81409B4(void) +static void CalcSlotBias(void) { - u16 r2 = Random() / 4; + u16 rval = Random() / 4; s32 i; - const u16 * r4 = gUnknown_84648D2[sSlotMachineState->machineidx]; + const u16 * biasChances = sReelBiasChances[sSlotMachineState->machineidx]; for (i = 0; i < 6; i++) { - if (r2 < r4[i]) + if (rval < biasChances[i]) break; } - if (sSlotMachineState->field_08 < 5) + if (sSlotMachineState->machineBias < SLOT_PAYOUT_ROCKET) { - if (sSlotMachineState->field_0C == 0) + if (sSlotMachineState->biasCooldown == 0) { - if ((Random() & 0x3FFF) < r4[6]) - sSlotMachineState->field_0C = (Random() & 1) ? 5 : 60; + if ((Random() & 0x3FFF) < biasChances[SLOT_PAYOUT_7]) + sSlotMachineState->biasCooldown = (Random() & 1) ? 5 : 60; } - if (sSlotMachineState->field_0C != 0) + if (sSlotMachineState->biasCooldown != 0) { - if (i == 0 && (Random() & 0x3FFF) < 0x2CCC) - sSlotMachineState->field_0C = (Random() & 1) ? 5 : 60; - sSlotMachineState->field_0C--; + if (i == 0 && (Random() & 0x3FFF) < 0x2CCC) // 70% + sSlotMachineState->biasCooldown = (Random() & 1) ? 5 : 60; + sSlotMachineState->biasCooldown--; } - sSlotMachineState->field_08 = i; + sSlotMachineState->machineBias = i; } } -static void sub_8140A70(void) +static void ResetMachineBias(void) { - sSlotMachineState->field_08 = 0; + sSlotMachineState->machineBias = 0; } static u16 CalcPayout(void) { - u8 sp0[9] = {}; + u8 visibleIcons[9] = {}; s32 i; s32 reel1pos, reel2pos, reel3pos; s32 bestMatch; @@ -1566,20 +1667,20 @@ static u16 CalcPayout(void) reel3pos++; if (reel3pos >= 21) reel3pos = 0; - sp0[0 * 3 + i] = gUnknown_8464926[0][reel1pos]; - sp0[1 * 3 + i] = gUnknown_8464926[1][reel2pos]; - sp0[2 * 3 + i] = gUnknown_8464926[2][reel3pos]; + visibleIcons[0 * 3 + i] = sReelIconAnimByReelAndPos[0][reel1pos]; + visibleIcons[1 * 3 + i] = sReelIconAnimByReelAndPos[1][reel2pos]; + visibleIcons[2 * 3 + i] = sReelIconAnimByReelAndPos[2][reel3pos]; } sSlotMachineState->payout = 0; for (i = 0; i < 5; i++) { - if (sSlotMachineState->bet >= gUnknown_84648BD[i][3]) + if (sSlotMachineState->bet >= sRowAttributes[i][ROWATTR_MINBET]) { int curMatch; - if (sub_81408F4(1, sp0[gUnknown_84648BD[i][0]])) - curMatch = sub_81408F4(2, sp0[gUnknown_84648BD[i][1]]) ? 2 : 1; - else if (sp0[gUnknown_84648BD[i][0]] == sp0[gUnknown_84648BD[i][1]] && sp0[gUnknown_84648BD[i][0]] == sp0[gUnknown_84648BD[i][2]]) - curMatch = sub_814096C(sp0[gUnknown_84648BD[i][0]]); + if (TestReelIconAttribute(1, visibleIcons[sRowAttributes[i][ROWATTR_COL1POS]])) + curMatch = TestReelIconAttribute(2, visibleIcons[sRowAttributes[i][ROWATTR_COL2POS]]) ? 2 : 1; + else if (visibleIcons[sRowAttributes[i][ROWATTR_COL1POS]] == visibleIcons[sRowAttributes[i][ROWATTR_COL2POS]] && visibleIcons[sRowAttributes[i][ROWATTR_COL1POS]] == visibleIcons[sRowAttributes[i][ROWATTR_COL3POS]]) + curMatch = ReelIconToPayoutRank(visibleIcons[sRowAttributes[i][ROWATTR_COL1POS]]); else curMatch = 0; if (curMatch != 0) @@ -1609,7 +1710,7 @@ static bool32 GetWinFlagByLine(int a0) return sSlotMachineState->winFlags[a0]; } -static bool32 sub_8140C0C(void) +static bool32 LoadSpriteGraphicsAndAllocateManager(void) { s32 i; @@ -1619,11 +1720,11 @@ static bool32 sub_8140C0C(void) sSlotMachineGfxManager = Alloc(sizeof(*sSlotMachineGfxManager)); if (sSlotMachineGfxManager == NULL) return FALSE; - sub_8140C6C(sSlotMachineGfxManager); + InitGfxManager(sSlotMachineGfxManager); return TRUE; } -static void sub_8140C50(void) +static void DestroyGfxManager(void) { if (sSlotMachineGfxManager != NULL) { @@ -1632,7 +1733,7 @@ static void sub_8140C50(void) } } -static void sub_8140C6C(struct SlotMachineGfxManager * manager) +static void InitGfxManager(struct SlotMachineGfxManager * manager) { s32 i, j; @@ -1641,12 +1742,12 @@ static void sub_8140C6C(struct SlotMachineGfxManager * manager) manager->field_00[i] = 0; for (j = 0; j < 5; j++) { - manager->field_0C[i][j] = NULL; + manager->reelIconSprites[i][j] = NULL; } } } -static void sub_8140CA0(void) +static void CreateReelIconSprites(void) { struct Sprite * sprite; s32 i, j; @@ -1657,69 +1758,69 @@ static void sub_8140CA0(void) for (j = 0; j < 5; j++) { spriteId = CreateSprite(&sSpriteTemplate_ReelIcons, 80 + 40 * i, 44 + 24 * j, 2); - animId = gUnknown_8464926[i][j]; + animId = sReelIconAnimByReelAndPos[i][j]; sprite = &gSprites[spriteId]; StartSpriteAnim(sprite, animId); - sprite->oam.paletteNum = IndexOfSpritePaletteTag(gUnknown_8465608[animId]); + sprite->oam.paletteNum = IndexOfSpritePaletteTag(sReelIconPaletteTags[animId]); sprite->data[0] = i; sprite->data[1] = j; sprite->data[2] = j; sprite->data[3] = 0; sprite->oam.matrixNum = 0; - sSlotMachineGfxManager->field_0C[i][j] = sprite; - sSlotMachineGfxManager->field_70 = (vu16 *)(OAM + 0 * sizeof(struct OamData) + offsetof(struct OamData, affineParam)); + sSlotMachineGfxManager->reelIconSprites[i][j] = sprite; + sSlotMachineGfxManager->reelIconAffineParamPtr = (vu16 *)(OAM + 0 * sizeof(struct OamData) + offsetof(struct OamData, affineParam)); } } } -static void sub_8140D7C(const s16 * a0, const s16 * a1) +static void UpdateReelIconSprites(const s16 * reelPosPtr, const s16 * yposPtr) { s32 i, j; - s32 r6, r10; + s32 reelPos, ypos; for (i = 0; i < 3; i++) { - r6 = *a0; - r10 = *a1 * 8; + reelPos = *reelPosPtr; + ypos = *yposPtr * 8; for (j = 0; j < 5; j++) { - sSlotMachineGfxManager->field_0C[i][j]->pos2.y = r10; + sSlotMachineGfxManager->reelIconSprites[i][j]->pos2.y = ypos; { - s32 r4 = gUnknown_8464926[i][r6]; - struct Sprite * sprite = sSlotMachineGfxManager->field_0C[i][j]; - StartSpriteAnim(sprite, r4); + s32 animId = sReelIconAnimByReelAndPos[i][reelPos]; + struct Sprite * sprite = sSlotMachineGfxManager->reelIconSprites[i][j]; + StartSpriteAnim(sprite, animId); } { - s32 r4 = gUnknown_8464926[i][r6]; - struct Sprite * sprite = sSlotMachineGfxManager->field_0C[i][j]; - StartSpriteAnim(sprite, r4); + s32 animId = sReelIconAnimByReelAndPos[i][reelPos]; + struct Sprite * sprite = sSlotMachineGfxManager->reelIconSprites[i][j]; + StartSpriteAnim(sprite, animId); } - sSlotMachineGfxManager->field_0C[i][j]->oam.paletteNum = IndexOfSpritePaletteTag(gUnknown_8465608[gUnknown_8464926[i][r6]]); - r6++; - if (r6 >= 21) - r6 = 0; + sSlotMachineGfxManager->reelIconSprites[i][j]->oam.paletteNum = IndexOfSpritePaletteTag(sReelIconPaletteTags[sReelIconAnimByReelAndPos[i][reelPos]]); + reelPos++; + if (reelPos >= 21) + reelPos = 0; } - a0++; - a1++; + reelPosPtr++; + yposPtr++; } } static void HBlankCB_SlotMachine(void) { s32 vcount = REG_VCOUNT - 0x2B; - if (vcount >= 0 && vcount < 0x54) + if (vcount < 0x54u) { - *sSlotMachineGfxManager->field_70 = gUnknown_8465616[vcount]; - REG_BLDY = gUnknown_84656D6[vcount]; + *sSlotMachineGfxManager->reelIconAffineParamPtr = sReelIconAffineParams[vcount]; + REG_BLDY = sReelIconBldY[vcount]; } else { - *sSlotMachineGfxManager->field_70 = 0x100; + *sSlotMachineGfxManager->reelIconAffineParamPtr = 0x100; REG_BLDY = 0; } } -static void sub_8140E9C(void) +static void CreateScoreDigitSprites(void) { s32 i; s32 spriteId; @@ -1727,13 +1828,13 @@ static void sub_8140E9C(void) for (i = 0; i < 4; i++) { spriteId = CreateSprite(&sSpriteTemplate_Digits, 0x55 + 7 * i, 30, 0); - sSlotMachineGfxManager->field_48[i] = &gSprites[spriteId]; + sSlotMachineGfxManager->creditDigitSprites[i] = &gSprites[spriteId]; spriteId = CreateSprite(&sSpriteTemplate_Digits, 0x85 + 7 * i, 30, 0); - sSlotMachineGfxManager->field_58[i] = &gSprites[spriteId]; + sSlotMachineGfxManager->payoutDigitSprites[i] = &gSprites[spriteId]; } } -static void sub_8140F2C(void) +static void UpdateCoinsDisplay(void) { s32 coins = GetCoins(); s32 payout = GetPayout(); @@ -1744,36 +1845,36 @@ static void sub_8140F2C(void) for (i = 0; i < 4; i++) { quotient = coins / divisor; - StartSpriteAnim(sSlotMachineGfxManager->field_48[i], quotient); + StartSpriteAnim(sSlotMachineGfxManager->creditDigitSprites[i], quotient); coins -= quotient * divisor; quotient = payout / divisor; - StartSpriteAnim(sSlotMachineGfxManager->field_58[i], quotient); + StartSpriteAnim(sSlotMachineGfxManager->payoutDigitSprites[i], quotient); payout -= quotient * divisor; divisor /= 10; } } -static void sub_8140FC4(void) +static void CreateClefairySprites(void) { s32 spriteId; - spriteId = CreateSprite(&gUnknown_84658D8, 0x10, 0x88, 1); - sSlotMachineGfxManager->field_68[0] = &gSprites[spriteId]; - spriteId = CreateSprite(&gUnknown_84658D8, 0xE0, 0x88, 1); - sSlotMachineGfxManager->field_68[1] = &gSprites[spriteId]; - sSlotMachineGfxManager->field_68[1]->hFlip = TRUE; + spriteId = CreateSprite(&sSpriteTemplate_Clefairy, 0x10, 0x88, 1); + sSlotMachineGfxManager->clefairySprites[0] = &gSprites[spriteId]; + spriteId = CreateSprite(&sSpriteTemplate_Clefairy, 0xE0, 0x88, 1); + sSlotMachineGfxManager->clefairySprites[1] = &gSprites[spriteId]; + sSlotMachineGfxManager->clefairySprites[1]->hFlip = TRUE; } -static void sub_8141020(u8 a0) +static void SetClefairySpriteAnim(u8 animId) { s32 i; for (i = 0; i < 2; i++) { - StartSpriteAnim(sSlotMachineGfxManager->field_68[i], a0); + StartSpriteAnim(sSlotMachineGfxManager->clefairySprites[i], animId); } } -static bool32 sub_814104C(void) +static bool32 CreateSlotMachine(void) { s32 i; @@ -1782,23 +1883,23 @@ static bool32 sub_814104C(void) return FALSE; for (i = 0; i < 8; i++) ptr->tasks[i].active = 0; - ptr->field_0028 = 0; - SetWordTaskArg(CreateTask(sub_81410CC, 2), 0, (uintptr_t)ptr); + ptr->yesNoMenuActive = FALSE; + SetWordTaskArg(CreateTask(Task_SlotMachine, 2), 0, (uintptr_t)ptr); return FALSE; } -static void sub_8141094(void) +static void DestroySlotMachine(void) { - if (FuncIsActiveTask(sub_81410CC)) + if (FuncIsActiveTask(Task_SlotMachine)) { Free(GetSlotMachineSetupTaskDataPtr()); - DestroyTask(FindTaskIdByFunc(sub_81410CC)); + DestroyTask(FindTaskIdByFunc(Task_SlotMachine)); } - sub_8140C50(); + DestroyGfxManager(); FreeAllWindowBuffers(); } -static void sub_81410CC(u8 taskId) +static void Task_SlotMachine(u8 taskId) { struct SlotMachineSetupTaskData * ptr = (void *)GetWordTaskArg(taskId, 0); s32 i; @@ -1806,7 +1907,7 @@ static void sub_81410CC(u8 taskId) for (i = 0; i < 8; i++) { if (ptr->tasks[i].active) - ptr->tasks[i].active = gUnknown_84658F0[ptr->tasks[i].funcno](&ptr->tasks[i].state, ptr); + ptr->tasks[i].active = sSlotMachineSetupTasks[ptr->tasks[i].funcno](&ptr->tasks[i].state, ptr); } } @@ -1819,7 +1920,7 @@ static void VBlankCB_SlotMachine(void) static struct SlotMachineSetupTaskData * GetSlotMachineSetupTaskDataPtr(void) { - return (void *)GetWordTaskArg(FindTaskIdByFunc(sub_81410CC), 0); + return (void *)GetWordTaskArg(FindTaskIdByFunc(Task_SlotMachine), 0); } static void SetSlotMachineSetupTask(u16 funcno, u8 taskId) @@ -1827,7 +1928,7 @@ static void SetSlotMachineSetupTask(u16 funcno, u8 taskId) struct SlotMachineSetupTaskData * ptr = GetSlotMachineSetupTaskDataPtr(); ptr->tasks[taskId].funcno = funcno; ptr->tasks[taskId].state = 0; - ptr->tasks[taskId].active = gUnknown_84658F0[funcno](&ptr->tasks[taskId].state, ptr); + ptr->tasks[taskId].active = sSlotMachineSetupTasks[funcno](&ptr->tasks[taskId].state, ptr); } static bool32 IsSlotMachineSetupTaskActive(u8 taskId) @@ -1841,7 +1942,7 @@ static inline void LoadColor(u16 color, u16 *pal) LoadPalette(pal, 0x00, 0x02); } -static bool8 sub_8141198(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_GraphicsInit(u8 * state, struct SlotMachineSetupTaskData * ptr) { u16 pal[2]; u8 textColor[3]; @@ -1863,50 +1964,50 @@ static bool8 sub_8141198(u8 * state, struct SlotMachineSetupTaskData * ptr) SetGpuReg(REG_OFFSET_DISPCNT, 0); ResetBgPositions(); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_8466B10, NELEMS(gUnknown_8466B10)); - InitWindows(gUnknown_8466B20); + InitBgsFromTemplates(0, sBgTemplates, NELEMS(sBgTemplates)); + InitWindows(sWindowTemplates); - SetBgTilemapBuffer(3, ptr->reelPositions5C); + SetBgTilemapBuffer(3, ptr->bg3TilemapBuffer); FillBgTilemapBufferRect_Palette0(3, 0, 0, 0, 32, 32); CopyBgTilemapBufferToVram(3); ResetTempTileDataBuffers(); - DecompressAndCopyTileDataToVram(2, gUnknown_84659D0, 0, 0x00, 0); - DecompressAndCopyTileDataToVram(2, gUnknown_846653C, 0, 0xC0, 0); - SetBgTilemapBuffer(2, ptr->field_185C); - CopyToBgTilemapBuffer(2, gUnknown_84661D4, 0, 0x00); + DecompressAndCopyTileDataToVram(2, sBg2Tiles_00, 0, 0x00, 0); + DecompressAndCopyTileDataToVram(2, sBg2Tiles_C0, 0, 0xC0, 0); + SetBgTilemapBuffer(2, ptr->bg2TilemapBuffer); + CopyToBgTilemapBuffer(2, sBg2Map, 0, 0x00); CopyBgTilemapBufferToVram(2); - LoadPalette(gUnknown_8465930, 0x00, 0xA0); - LoadPalette(gUnknown_84664BC, 0x50, 0x20); - LoadPalette(gUnknown_84665C0, 0x70, 0x60); + LoadPalette(sBgPal_00, 0x00, 0xA0); + LoadPalette(sBgPal_50, 0x50, 0x20); + LoadPalette(sBgPal_70, 0x70, 0x60); LoadColor(RGB(30, 30, 31), pal); LoadUserWindowBorderGfx(0, 0x00A, 0xD0); - sub_814FDA0(0, 0x001, 0xF0); + DrawWindowBorderWithStdpal3(0, 0x001, 0xF0); - SetBgTilemapBuffer(0, ptr->field_085C); + SetBgTilemapBuffer(0, ptr->bg0TilemapBuffer); FillBgTilemapBufferRect_Palette0(0, 0, 0, 2, 32, 30); - DecompressAndCopyTileDataToVram(1, gUnknown_8466620, 0, 0, 0); - DecompressAndCopyTileDataToVram(1, gUnknown_8466998, 0, 0, 1); + DecompressAndCopyTileDataToVram(1, sBg1Tiles, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, sBg1Map, 0, 0, 1); CopyBgTilemapBufferToVram(1); LoadPalette(stdpal_get(2), 0xE0, 0x20); FillWindowPixelBuffer(1, 0xFF); PutWindowTilemap(1); - x = 0xEC - GetStringWidth(0, gString_SlotMachineControls, 0); - textColor[0] = 15; - textColor[1] = 1; - textColor[2] = 2; + x = 236 - GetStringWidth(0, gString_SlotMachineControls, 0); + textColor[0] = TEXT_DYNAMIC_COLOR_6; + textColor[1] = TEXT_COLOR_WHITE; + textColor[2] = TEXT_COLOR_DARK_GREY; AddTextPrinterParameterized3(1, 0, x, 0, textColor, 0, gString_SlotMachineControls); CopyBgTilemapBufferToVram(0); SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | 0x20 | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_TGT1_OBJ | BLDCNT_TGT1_BD | BLDCNT_EFFECT_DARKEN); - sub_8140C0C(); - sub_8140CA0(); - sub_8140E9C(); - sub_8140FC4(); - sub_8140F2C(); + LoadSpriteGraphicsAndAllocateManager(); + CreateReelIconSprites(); + CreateScoreDigitSprites(); + CreateClefairySprites(); + UpdateCoinsDisplay(); BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK); SetVBlankCallback(VBlankCB_SlotMachine); SetHBlankCallback(HBlankCB_SlotMachine); @@ -1919,7 +2020,7 @@ static bool8 sub_8141198(u8 * state, struct SlotMachineSetupTaskData * ptr) ShowBg(3); ShowBg(2); HideBg(1); - sub_8141B34(); + InitReelButtonTileMem(); BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK); BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK); @@ -1935,7 +2036,7 @@ static bool8 sub_8141198(u8 * state, struct SlotMachineSetupTaskData * ptr) return TRUE; } -static bool8 sub_8141460(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_FadeOut(u8 * state, struct SlotMachineSetupTaskData * ptr) { switch (*state) { @@ -1951,12 +2052,12 @@ static bool8 sub_8141460(u8 * state, struct SlotMachineSetupTaskData * ptr) return TRUE; } -static bool8 sub_81414AC(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_UpdateLineStates(u8 * state, struct SlotMachineSetupTaskData * ptr) { switch (*state) { case 0: - sub_8141834(GetBgTilemapBuffer(2)); + SetLineStatesByBet(GetBgTilemapBuffer(2)); CopyBgTilemapBufferToVram(2); (*state)++; break; @@ -1968,31 +2069,31 @@ static bool8 sub_81414AC(u8 * state, struct SlotMachineSetupTaskData * ptr) return TRUE; } -static bool8 sub_81414EC(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_ClefairyUpdateOnReelsStart(u8 * state, struct SlotMachineSetupTaskData * ptr) { - sub_8141020(1); + SetClefairySpriteAnim(1); return FALSE; } -static bool8 sub_81414FC(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_StartClefairyDanceAndWinningLineFlash(u8 * state, struct SlotMachineSetupTaskData * ptr) { - sub_8141020(2); - CreateTask(sub_814191C, 3); + SetClefairySpriteAnim(2); + CreateTask(Task_FlashWinningLine, 3); return FALSE; } -static bool8 sub_8141518(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_StopWinningLineFlashTask(u8 * state, struct SlotMachineSetupTaskData * ptr) { switch (*state) { case 0: - sub_8141AB0(); + SignalStopWinningLineFlashTask(); (*state)++; break; case 1: - if (!FuncIsActiveTask(sub_814191C)) + if (!FuncIsActiveTask(Task_FlashWinningLine)) { - sub_8141020(0); + SetClefairySpriteAnim(0); return FALSE; } break; @@ -2000,30 +2101,30 @@ static bool8 sub_8141518(u8 * state, struct SlotMachineSetupTaskData * ptr) return TRUE; } -static bool8 sub_8141558(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_ClefairyFainted(u8 * state, struct SlotMachineSetupTaskData * ptr) { - sub_8141020(3); + SetClefairySpriteAnim(3); return FALSE; } -static bool8 sub_8141568(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_ClefairyNeutral(u8 * state, struct SlotMachineSetupTaskData * ptr) { - sub_8141020(FALSE); + SetClefairySpriteAnim(0); return FALSE; } -static bool8 sub_8141578(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_UpdateCoinsDisplay(u8 * state, struct SlotMachineSetupTaskData * ptr) { - sub_8140F2C(); + UpdateCoinsDisplay(); return FALSE; } -static bool8 sub_8141584(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_MessageOutOfCoins(u8 * state, struct SlotMachineSetupTaskData * ptr) { switch (*state) { case 0: - sub_81417E4(gString_OutOfCoins); + Slot_PrintOnWindow0(gString_OutOfCoins); CopyWindowToVram(0, 3); (*state)++; break; @@ -2035,13 +2136,13 @@ static bool8 sub_8141584(u8 * state, struct SlotMachineSetupTaskData * ptr) return TRUE; } -static bool8 sub_81415C8(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_AskQuitPlaying(u8 * state, struct SlotMachineSetupTaskData * ptr) { switch (*state) { case 0: - sub_81417E4(gString_QuitPlaying); - sub_8141AD8(0); + Slot_PrintOnWindow0(gString_QuitPlaying); + Slot_CreateYesNoMenu(0); CopyWindowToVram(0, 3); (*state)++; break; @@ -2053,13 +2154,13 @@ static bool8 sub_81415C8(u8 * state, struct SlotMachineSetupTaskData * ptr) return TRUE; } -static bool8 sub_8141610(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_DestroyYesNoMenu(u8 * state, struct SlotMachineSetupTaskData * ptr) { switch (*state) { case 0: - sub_8141828(); - sub_8141B18(); + Slot_ClearWindow0(); + Slot_DestroyYesNoMenu(); CopyWindowToVram(0, 3); (*state)++; break; @@ -2071,12 +2172,12 @@ static bool8 sub_8141610(u8 * state, struct SlotMachineSetupTaskData * ptr) return TRUE; } -static bool8 sub_8141650(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_PressReelButton(u8 * state, struct SlotMachineSetupTaskData * ptr) { switch (*state) { case 0: - sub_8141BA0(ptr->field_0020); + SetReelButtonPressed(ptr->reelButtonToPress); CopyBgTilemapBufferToVram(2); (*state)++; break; @@ -2088,12 +2189,12 @@ static bool8 sub_8141650(u8 * state, struct SlotMachineSetupTaskData * ptr) return TRUE; } -static bool8 sub_8141690(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_ReleaseReelButtons(u8 * state, struct SlotMachineSetupTaskData * ptr) { switch (*state) { case 0: - sub_8141BE4(); + ReleaseReelButtons(); CopyBgTilemapBufferToVram(2); (*state)++; break; @@ -2105,7 +2206,7 @@ static bool8 sub_8141690(u8 * state, struct SlotMachineSetupTaskData * ptr) return TRUE; } -static bool8 sub_81416C8(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_ShowHelp(u8 * state, struct SlotMachineSetupTaskData * ptr) { switch (*state) { @@ -2117,18 +2218,18 @@ static bool8 sub_81416C8(u8 * state, struct SlotMachineSetupTaskData * ptr) SetGpuReg(REG_OFFSET_WIN1H, 0xA0); ShowBg(1); PlaySE(SE_WIN_OPEN); - ptr->field_0024 = 0; + ptr->bg1X = 0; (*state)++; break; case 1: - ptr->field_0024 += 16; - if (ptr->field_0024 >= 256) + ptr->bg1X += 16; + if (ptr->bg1X >= 256) { - ptr->field_0024 = 256; + ptr->bg1X = 256; (*state)++; } - ChangeBgX(1, 256 * (256 - ptr->field_0024), 0); - SetGpuReg(REG_OFFSET_WIN0H, ptr->field_0024); + ChangeBgX(1, 256 * (256 - ptr->bg1X), 0); + SetGpuReg(REG_OFFSET_WIN0H, ptr->bg1X); break; case 2: return FALSE; @@ -2136,7 +2237,7 @@ static bool8 sub_81416C8(u8 * state, struct SlotMachineSetupTaskData * ptr) return TRUE; } -static bool8 sub_8141764(u8 * state, struct SlotMachineSetupTaskData * ptr) +static bool8 SlotsTask_HideHelp(u8 * state, struct SlotMachineSetupTaskData * ptr) { switch (*state) { @@ -2145,14 +2246,14 @@ static bool8 sub_8141764(u8 * state, struct SlotMachineSetupTaskData * ptr) (*state)++; // fallthrough case 1: - ptr->field_0024 -= 16; - if (ptr->field_0024 <= 0) + ptr->bg1X -= 16; + if (ptr->bg1X <= 0) { - ptr->field_0024 = 0; + ptr->bg1X = 0; (*state)++; } - ChangeBgX(1, 256 * (256 - ptr->field_0024), 0); - SetGpuReg(REG_OFFSET_WIN0H, ptr->field_0024); + ChangeBgX(1, 256 * (256 - ptr->bg1X), 0); + SetGpuReg(REG_OFFSET_WIN0H, ptr->bg1X); break; case 2: HideBg(1); @@ -2165,49 +2266,49 @@ static bool8 sub_8141764(u8 * state, struct SlotMachineSetupTaskData * ptr) return TRUE; } -static void sub_81417E4(const u8 * str) +static void Slot_PrintOnWindow0(const u8 * str) { - FillWindowPixelBuffer(0, 0x11); + FillWindowPixelBuffer(0, PIXEL_FILL(1)); PutWindowTilemap(0); DrawTextBorderOuter(0, 0x001, 15); - AddTextPrinterParameterized5(0, 2, str, 1, 2, -1, NULL, 1, 2); + AddTextPrinterParameterized5(0, 2, str, 1, 2, TEXT_SPEED_FF, NULL, 1, 2); } -static void sub_8141828(void) +static void Slot_ClearWindow0(void) { rbox_fill_rectangle(0); } -static void sub_8141834(u16 * bgTilemapBuffer) +static void SetLineStatesByBet(u16 * bgTilemapBuffer) { switch (GetPlayerBet()) { case 0: - sub_81418C4(bgTilemapBuffer, 0, 4); - sub_81418C4(bgTilemapBuffer, 1, 4); - sub_81418C4(bgTilemapBuffer, 2, 4); - sub_81418C4(bgTilemapBuffer, 3, 4); - sub_81418C4(bgTilemapBuffer, 4, 4); + SetLineState(bgTilemapBuffer, 0, 4); + SetLineState(bgTilemapBuffer, 1, 4); + SetLineState(bgTilemapBuffer, 2, 4); + SetLineState(bgTilemapBuffer, 3, 4); + SetLineState(bgTilemapBuffer, 4, 4); break; case 3: - sub_81418C4(bgTilemapBuffer, 0, 5); - sub_81418C4(bgTilemapBuffer, 4, 5); + SetLineState(bgTilemapBuffer, 0, 5); + SetLineState(bgTilemapBuffer, 4, 5); case 2: - sub_81418C4(bgTilemapBuffer, 1, 5); - sub_81418C4(bgTilemapBuffer, 3, 5); + SetLineState(bgTilemapBuffer, 1, 5); + SetLineState(bgTilemapBuffer, 3, 5); case 1: - sub_81418C4(bgTilemapBuffer, 2, 5); + SetLineState(bgTilemapBuffer, 2, 5); break; } } -static void sub_81418C4(u16 * bgTilemapBuffer, u16 whichLine, u16 paletteNum) +static void SetLineState(u16 * bgTilemapBuffer, u16 whichLine, u16 paletteNum) { s32 i; - const u16 * tileIdxs = gUnknown_8466C0C[whichLine].tiles; + const u16 * tileIdxs = sLineStateTileIdxs[whichLine].tiles; u16 palMask = (paletteNum & 0xF) << 12; - for (i = 0; i < gUnknown_8466C0C[whichLine].count; i++) + for (i = 0; i < sLineStateTileIdxs[whichLine].count; i++) { bgTilemapBuffer[*tileIdxs] &= 0x0FFF; bgTilemapBuffer[*tileIdxs] |= palMask; @@ -2215,7 +2316,7 @@ static void sub_81418C4(u16 * bgTilemapBuffer, u16 whichLine, u16 paletteNum) } } -static void sub_814191C(u8 taskId) +static void Task_FlashWinningLine(u8 taskId) { s16 * data = gTasks[taskId].data; s32 i; @@ -2223,11 +2324,11 @@ static void sub_814191C(u8 taskId) switch (data[0]) { case 0: - LoadPalette(gUnknown_84664BC, 0x60, 0x20); + LoadPalette(sBgPal_50, 0x60, 0x20); for (i = 0; i < 5; i++) { if (GetWinFlagByLine(i)) - sub_81418C4(GetBgTilemapBuffer(2), i, 6); + SetLineState(GetBgTilemapBuffer(2), i, 6); } CopyBgTilemapBufferToVram(2); data[0]++; @@ -2236,7 +2337,7 @@ static void sub_814191C(u8 taskId) if (data[1] == 0) { u16 y = gSineTable[data[2]] >> 7; - LoadPalette(&gUnknown_84664DC[16 * y], 0x10, 0x20); + LoadPalette(&sBgPal_VictoryFlash[16 * y], 0x10, 0x20); data[2] += 32; data[2] &= 0x7F; data[1] = 8; @@ -2263,18 +2364,18 @@ static void sub_814191C(u8 taskId) } } - for (i = 0; i < NELEMS(gUnknown_8466C34); i++) + for (i = 0; i < NELEMS(sWInningLineFlashPalIdxs); i++) { - gPlttBufferFaded[gUnknown_8466C34[i] + 0x60] = gPlttBufferUnfaded[gUnknown_8466C34[i] + 0x60]; + gPlttBufferFaded[sWInningLineFlashPalIdxs[i] + 0x60] = gPlttBufferUnfaded[sWInningLineFlashPalIdxs[i] + 0x60]; } break; case 2: for (i = 0; i < 5; i++) { if (GetWinFlagByLine(i)) - sub_81418C4(GetBgTilemapBuffer(2), i, 4); + SetLineState(GetBgTilemapBuffer(2), i, 4); } - LoadPalette(gUnknown_8465950, 0x10, 0x20); + LoadPalette(sBgPal_10, 0x10, 0x20); CopyBgTilemapBufferToVram(2); data[0]++; break; @@ -2285,29 +2386,29 @@ static void sub_814191C(u8 taskId) } } -static void sub_8141AB0(void) +static void SignalStopWinningLineFlashTask(void) { - gTasks[FindTaskIdByFunc(sub_814191C)].data[0] = 2; + gTasks[FindTaskIdByFunc(Task_FlashWinningLine)].data[0] = 2; } -static void sub_8141AD8(u8 cursorPos) +static void Slot_CreateYesNoMenu(u8 cursorPos) { - CreateYesNoMenu(&gUnknown_8466C38, 2, 0, 2, 10, 13, cursorPos); + CreateYesNoMenu(&sYesNoWindowTemplate, 2, 0, 2, 10, 13, cursorPos); Menu_MoveCursorNoWrapAround(cursorPos); - GetSlotMachineSetupTaskDataPtr()->field_0028 = TRUE; + GetSlotMachineSetupTaskDataPtr()->yesNoMenuActive = TRUE; } -static void sub_8141B18(void) +static void Slot_DestroyYesNoMenu(void) { struct SlotMachineSetupTaskData * data = GetSlotMachineSetupTaskDataPtr(); - if (data->field_0028) + if (data->yesNoMenuActive) { DestroyYesNoMenu(); - data->field_0028 = FALSE; + data->yesNoMenuActive = FALSE; } } -static void sub_8141B34(void) +static void InitReelButtonTileMem(void) { s32 i, j; struct SlotMachineSetupTaskData * data = GetSlotMachineSetupTaskDataPtr(); @@ -2317,14 +2418,14 @@ static void sub_8141B34(void) { for (j = 0; j < 4; j++) { - u16 idx = gUnknown_8466C40[i][j]; - data->field_0044[i][j] = buffer[idx]; - data->field_002C[i][j] = j + 0xC0; + u16 idx = sReelButtonMapTileIdxs[i][j]; + data->buttonReleasedTiles[i][j] = buffer[idx]; + data->buttonPressedTiles[i][j] = j + 0xC0; } } } -static void sub_8141BA0(u8 reel) +static void SetReelButtonPressed(u8 reel) { if (reel < 3) { @@ -2333,13 +2434,13 @@ static void sub_8141BA0(u8 reel) u16 * buffer = GetBgTilemapBuffer(2); for (i = 0; i < 4; i++) { - u16 idx = gUnknown_8466C40[reel][i]; - buffer[idx] = data->field_002C[reel][i]; + u16 idx = sReelButtonMapTileIdxs[reel][i]; + buffer[idx] = data->buttonPressedTiles[reel][i]; } } } -static void sub_8141BE4(void) +static void ReleaseReelButtons(void) { s32 i, j; struct SlotMachineSetupTaskData * data = GetSlotMachineSetupTaskDataPtr(); @@ -2349,14 +2450,14 @@ static void sub_8141BE4(void) { for (j = 0; j < 4; j++) { - u16 idx = gUnknown_8466C40[i][j]; - buffer[idx] = data->field_0044[i][j]; + u16 idx = sReelButtonMapTileIdxs[i][j]; + buffer[idx] = data->buttonReleasedTiles[i][j]; } } } -static void sub_8141C30(u8 a0, u8 a1) +static void PressReelButton(u8 reel, u8 taskId) { - GetSlotMachineSetupTaskDataPtr()->field_0020 = a0; - SetSlotMachineSetupTask(12, a1); + GetSlotMachineSetupTaskDataPtr()->reelButtonToPress = reel; + SetSlotMachineSetupTask(SLOTTASK_PRESS_BUTTON, taskId); } diff --git a/src/text_window.c b/src/text_window.c index 6fde39078..8b2572fd1 100644 --- a/src/text_window.c +++ b/src/text_window.c @@ -28,7 +28,7 @@ void sub_814FD6C(u8 bgId, u16 destOffset, u8 palIdx) LoadPalette(stdpal_get(1), palIdx, 32); } -void sub_814FDA0(u8 bgId, u16 destOffset, u8 palIdx) +void DrawWindowBorderWithStdpal3(u8 bgId, u16 destOffset, u8 palIdx) { LoadBgTiles(bgId, gStdFrame0, 0x120, destOffset); LoadPalette(stdpal_get(3), palIdx, 32); |