diff --git a/data/event_scripts.s b/data/event_scripts.s index 7cc5960d4..058de953b 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -40,6 +40,7 @@ #include "constants/moves.h" #include "constants/party_menu.h" #include "constants/pokemon.h" +#include "constants/roulette.h" #include "constants/script_menu.h" #include "constants/secret_bases.h" #include "constants/songs.h" diff --git a/data/scripts/roulette.inc b/data/scripts/roulette.inc index 9aea65054..f590ca358 100644 --- a/data/scripts/roulette.inc +++ b/data/scripts/roulette.inc @@ -6,7 +6,7 @@ Roulette_EventScript_Table1:: @ 82A5AB1 getpricereduction POKENEWS_GAME_CORNER compare VAR_RESULT, FALSE goto_if_eq Roulette_EventScript_Play - addvar VAR_0x8004, 128 + addvar VAR_0x8004, ROULETTE_SPECIAL_RATE goto Roulette_EventScript_Play end @@ -18,7 +18,7 @@ Roulette_EventScript_Table2:: @ 82A5ADF getpricereduction POKENEWS_GAME_CORNER compare VAR_RESULT, FALSE goto_if_eq Roulette_EventScript_Play - addvar VAR_0x8004, 128 + addvar VAR_0x8004, ROULETTE_SPECIAL_RATE goto Roulette_EventScript_Play end diff --git a/graphics/roulette/poke_icons.png b/graphics/roulette/grid_icons.png similarity index 100% rename from graphics/roulette/poke_icons.png rename to graphics/roulette/grid_icons.png diff --git a/graphics/roulette/85B65D0.pal b/graphics/roulette/unused_1.pal similarity index 100% rename from graphics/roulette/85B65D0.pal rename to graphics/roulette/unused_1.pal diff --git a/graphics/roulette/85B65F0.pal b/graphics/roulette/unused_2.pal similarity index 100% rename from graphics/roulette/85B65F0.pal rename to graphics/roulette/unused_2.pal diff --git a/graphics/roulette/85B6610.pal b/graphics/roulette/unused_3.pal similarity index 100% rename from graphics/roulette/85B6610.pal rename to graphics/roulette/unused_3.pal diff --git a/graphics/roulette/85B6630.pal b/graphics/roulette/unused_4.pal similarity index 100% rename from graphics/roulette/85B6630.pal rename to graphics/roulette/unused_4.pal diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index 42fe82155..f2d14ef3c 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -483,7 +483,7 @@ $(ROULETTEGFXDIR)/roulette_tilt.4bpp: $(ROULETTEGFXDIR)/shroomish.4bpp \ $(ROULETTEGFXDIR)/tailow.4bpp @cat $^ >$@ -$(ROULETTEGFXDIR)/poke_icons2.4bpp: $(ROULETTEGFXDIR)/wynaut.4bpp \ +$(ROULETTEGFXDIR)/board_icons.4bpp: $(ROULETTEGFXDIR)/wynaut.4bpp \ $(ROULETTEGFXDIR)/azurill.4bpp \ $(ROULETTEGFXDIR)/skitty.4bpp \ $(ROULETTEGFXDIR)/makuhita.4bpp diff --git a/include/constants/coins.h b/include/constants/coins.h index 3ae3bb23f..e65e981d6 100644 --- a/include/constants/coins.h +++ b/include/constants/coins.h @@ -2,5 +2,6 @@ #define GUARD_CONSTANTS_COINS_H #define MAX_COINS 9999 +#define MAX_COIN_DIGITS 4 #endif // GUARD_CONSTANTS_COINS_H diff --git a/include/constants/roulette.h b/include/constants/roulette.h new file mode 100644 index 000000000..2ab17e476 --- /dev/null +++ b/include/constants/roulette.h @@ -0,0 +1,7 @@ +#ifndef GUARD_CONSTANTS_ROULETTE_H +#define GUARD_CONSTANTS_ROULETTE_H + +// Flag set in gSpecialVar_0x8004 when playing Roulette on a Game Corner service day +#define ROULETTE_SPECIAL_RATE (1 << 7) + +#endif // GUARD_CONSTANTS_ROULETTE_H diff --git a/include/graphics.h b/include/graphics.h index 8514d49bd..cf2abb825 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4919,13 +4919,13 @@ extern const u32 gPartyMenuPokeball_Pal[]; extern const u32 gStatusPal_Icons[]; // Roulette -extern const u32 gRouletteMenuTiles[]; -extern const u32 gRouletteWheelTiles[]; +extern const u32 gRouletteMenu_Gfx[]; +extern const u32 gRouletteWheel_Gfx[]; extern const u32 gRouletteCenter_Gfx[]; -extern const u32 gRouletteHeadersTiles[]; -extern const u32 gRouletteCreditTiles[]; -extern const u32 gRouletteNumbersTiles[]; -extern const u32 gRouletteMultiplierTiles[]; +extern const u32 gRouletteHeaders_Gfx[]; +extern const u32 gRouletteCredit_Gfx[]; +extern const u32 gRouletteNumbers_Gfx[]; +extern const u32 gRouletteMultiplier_Gfx[]; // Contest util extern const u32 gContestResults_Gfx[]; diff --git a/include/roulette_util.h b/include/roulette_util.h index 76752fe74..85b8de1f3 100644 --- a/include/roulette_util.h +++ b/include/roulette_util.h @@ -41,8 +41,8 @@ void MarkUsedPulseBlendPalettes(struct PulseBlend *, u16, u8); void UnloadUsedPulseBlendPalettes(struct PulseBlend *, u16, u8); void UnmarkUsedPulseBlendPalettes(struct PulseBlend *, u16, u8); void UpdatePulseBlend(struct PulseBlend *); -void sub_8152008(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height); -void sub_8152058(u16 *dest, u16 *src, u8 left, u8 top, u8 width, u8 height); +void ClearGridSelectionRect(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height); +void SetGridSelectionRect(u16 *dest, u16 *src, u8 left, u8 top, u8 width, u8 height); void task_tutorial_controls_fadein(struct UnkStruct0 *r0); void sub_8151678(struct UnkStruct0 *r0); u8 sub_815168C(struct UnkStruct0 *r0, u8 r1, const struct UnkStruct1 *r2); diff --git a/src/coins.c b/src/coins.c index 302817f8d..52c7dd3ec 100644 --- a/src/coins.c +++ b/src/coins.c @@ -14,7 +14,7 @@ void PrintCoinsString(u32 coinAmount) { u32 xAlign; - ConvertIntToDecimalStringN(gStringVar1, coinAmount, STR_CONV_MODE_RIGHT_ALIGN, 4); + ConvertIntToDecimalStringN(gStringVar1, coinAmount, STR_CONV_MODE_RIGHT_ALIGN, MAX_COIN_DIGITS); StringExpandPlaceholders(gStringVar4, gText_Coins); xAlign = GetStringRightAlignXOffset(1, gStringVar4, 0x40); diff --git a/src/graphics.c b/src/graphics.c index b774c5ad2..48323467d 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1227,13 +1227,14 @@ const u32 gCableCar_Gfx[] = INCBIN_U32("graphics/misc/cable_car.4bpp.lz"); const u32 gCableCarDoor_Gfx[] = INCBIN_U32("graphics/misc/cable_car_door.4bpp.lz"); const u32 gCableCarCord_Gfx[] = INCBIN_U32("graphics/misc/cable_car_cord.4bpp.lz"); -const u32 gRouletteMenuTiles[] = INCBIN_U32("graphics/roulette/window.4bpp.lz"); -const u32 gRouletteWheelTiles[] = INCBIN_U32("graphics/roulette/wheel.8bpp.lz"); +// Roulette +const u32 gRouletteMenu_Gfx[] = INCBIN_U32("graphics/roulette/window.4bpp.lz"); +const u32 gRouletteWheel_Gfx[] = INCBIN_U32("graphics/roulette/wheel.8bpp.lz"); const u32 gRouletteCenter_Gfx[] = INCBIN_U32("graphics/roulette/center.4bpp.lz"); -const u32 gRouletteHeadersTiles[] = INCBIN_U32("graphics/roulette/headers.4bpp.lz"); -const u32 gRouletteCreditTiles[] = INCBIN_U32("graphics/roulette/credit.4bpp.lz"); -const u32 gRouletteNumbersTiles[] = INCBIN_U32("graphics/roulette/numbers.4bpp.lz"); -const u32 gRouletteMultiplierTiles[] = INCBIN_U32("graphics/roulette/multiplier.4bpp.lz"); +const u32 gRouletteHeaders_Gfx[] = INCBIN_U32("graphics/roulette/headers.4bpp.lz"); +const u32 gRouletteCredit_Gfx[] = INCBIN_U32("graphics/roulette/credit.4bpp.lz"); +const u32 gRouletteNumbers_Gfx[] = INCBIN_U32("graphics/roulette/numbers.4bpp.lz"); +const u32 gRouletteMultiplier_Gfx[] = INCBIN_U32("graphics/roulette/multiplier.4bpp.lz"); #include "data/graphics/mail.h" diff --git a/src/roulette.c b/src/roulette.c index 1015687af..983a96e3f 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -26,10 +26,170 @@ #include "trig.h" #include "tv.h" #include "window.h" +#include "constants/coins.h" #include "constants/rgb.h" +#include "constants/roulette.h" #include "constants/species.h" #include "constants/songs.h" +#define BALLS_PER_ROUND 6 + +#define NUM_BOARD_COLORS 3 // Grid rows +#define NUM_BOARD_POKES 4 // Grid columns +#define NUM_ROULETTE_SLOTS (NUM_BOARD_COLORS * NUM_BOARD_POKES) + +// IDs for grid selections when betting +#define SELECTION_NONE 0 +#define COL_WYNAUT 1 +#define COL_AZURILL 2 +#define COL_SKITTY 3 +#define COL_MAKUHITA 4 +#define ROW_ORANGE (COL_MAKUHITA + 1) +#define SQU_ORANGE_WYNAUT (ROW_ORANGE + COL_WYNAUT) +#define SQU_ORANGE_AZURILL (ROW_ORANGE + COL_AZURILL) +#define SQU_ORANGE_SKITTY (ROW_ORANGE + COL_SKITTY) +#define SQU_ORANGE_MAKUHITA (ROW_ORANGE + COL_MAKUHITA) +#define ROW_GREEN (SQU_ORANGE_MAKUHITA + 1) +#define SQU_GREEN_WYNAUT (ROW_GREEN + COL_WYNAUT) +#define SQU_GREEN_AZURILL (ROW_GREEN + COL_AZURILL) +#define SQU_GREEN_SKITTY (ROW_GREEN + COL_SKITTY) +#define SQU_GREEN_MAKUHITA (ROW_GREEN + COL_MAKUHITA) +#define ROW_PURPLE (SQU_GREEN_MAKUHITA + 1) +#define SQU_PURPLE_WYNAUT (ROW_PURPLE + COL_WYNAUT) +#define SQU_PURPLE_AZURILL (ROW_PURPLE + COL_AZURILL) +#define SQU_PURPLE_SKITTY (ROW_PURPLE + COL_SKITTY) +#define SQU_PURPLE_MAKUHITA (ROW_PURPLE + COL_MAKUHITA) +#define NUM_GRID_SELECTIONS SQU_PURPLE_MAKUHITA + +#define GET_COL(selectionId)((selectionId) % (NUM_BOARD_POKES + 1)) +#define GET_ROW(selectionId)((selectionId) / (NUM_BOARD_POKES + 1) * (NUM_BOARD_POKES + 1)) + +// Flags for the above selections, used to set which spaces have been hit or bet on +#define F_WYNAUT_COL (1 << COL_WYNAUT) +#define F_AZURILL_COL (1 << COL_AZURILL) +#define F_SKITTY_COL (1 << COL_SKITTY) +#define F_MAKUHITA_COL (1 << COL_MAKUHITA) +#define F_ORANGE_ROW (1 << ROW_ORANGE) +#define F_ORANGE_WYNAUT (1 << SQU_ORANGE_WYNAUT) +#define F_ORANGE_AZURILL (1 << SQU_ORANGE_AZURILL) +#define F_ORANGE_SKITTY (1 << SQU_ORANGE_SKITTY) +#define F_ORANGE_MAKUHITA (1 << SQU_ORANGE_MAKUHITA) +#define F_GREEN_ROW (1 << ROW_GREEN) +#define F_GREEN_WYNAUT (1 << SQU_GREEN_WYNAUT) +#define F_GREEN_AZURILL (1 << SQU_GREEN_AZURILL) +#define F_GREEN_SKITTY (1 << SQU_GREEN_SKITTY) +#define F_GREEN_MAKUHITA (1 << SQU_GREEN_MAKUHITA) +#define F_PURPLE_ROW (1 << ROW_PURPLE) +#define F_PURPLE_WYNAUT (1 << SQU_PURPLE_WYNAUT) +#define F_PURPLE_AZURILL (1 << SQU_PURPLE_AZURILL) +#define F_PURPLE_SKITTY (1 << SQU_PURPLE_SKITTY) +#define F_PURPLE_MAKUHITA (1 << SQU_PURPLE_MAKUHITA) + +#define MAX_MULTIPLIER 12 + +#define PALTAG_SHADOW 1 +#define PALTAG_BALL 2 +#define PALTAG_BALL_COUNTER 3 +#define PALTAG_INTERFACE 5 +#define PALTAG_SHROOMISH 6 +#define PALTAG_TAILLOW 7 +#define PALTAG_GRID_ICONS 8 +#define PALTAG_WYNAUT 9 +#define PALTAG_AZURILL 10 +#define PALTAG_SKITTY 11 +#define PALTAG_MAKUHITA 12 + +#define GFXTAG_BOARD_ICONS 0 +#define GFXTAG_HEADERS 4 +#define GFXTAG_GRID_ICONS 5 +#define GFXTAG_BOARD_CENTER 6 +#define GFXTAG_CREDIT 7 +#define GFXTAG_CREDIT_DIGIT 8 +#define GFXTAG_MULTIPLIER 9 +#define GFXTAG_BALL_COUNTER 10 +#define GFXTAG_CURSOR 11 +#define GFXTAG_BALL 12 +#define GFXTAG_SHROOMISH_TAILLOW 13 +#define GFXTAG_SHADOW 14 + +// 2 different Roulette tables with 2 different rates (normal vs service day special) +// & 1 gets which table, >> 7 gets if ROULETTE_SPECIAL_RATE is set +#define GET_TABLE_ID(var)(((var) & 1) + (((var) >> 7) * 2)) + +#define HAS_SHROOMISH (1 << 0) +#define HAS_TAILLOW (1 << 1) + +enum { + SPR_BALL_1, + SPR_BALL_2, + SPR_BALL_3, + SPR_BALL_4, + SPR_BALL_5, + SPR_BALL_6, + SPR_6, + SPR_BOARD_ICON_ORANGE_WYNAUT, + SPR_BOARD_ICON_GREEN_AZURILL, + SPR_BOARD_ICON_PURPLE_SKITTY, + SPR_BOARD_ICON_ORANGE_MAKUHITA, + SPR_BOARD_ICON_GREEN_WYNAUT, + SPR_BOARD_ICON_PURPLE_AZURILL, + SPR_BOARD_ICON_ORANGE_SKITTY, + SPR_BOARD_ICON_GREEN_MAKUHITA, + SPR_BOARD_ICON_PURPLE_WYNAUT, + SPR_BOARD_ICON_ORANGE_AZURILL, + SPR_BOARD_ICON_GREEN_SKITTY, + SPR_BOARD_ICON_PURPLE_MAKUHITA, + SPR_19, + SPR_CREDIT, + SPR_CREDIT_DIG_1, + SPR_CREDIT_DIG_10, + SPR_CREDIT_DIG_100, + SPR_CREDIT_DIG_1000, + SPR_MULTIPLIER, + SPR_BALL_COUNTER_1, + SPR_BALL_COUNTER_2, + SPR_BALL_COUNTER_3, + SPR_GRID_ICON_ORANGE_WYNAUT, + SPR_GRID_ICON_2, + SPR_GRID_ICON_3, + SPR_GRID_ICON_4, + SPR_GRID_ICON_5, + SPR_GRID_ICON_6, + SPR_GRID_ICON_7, + SPR_GRID_ICON_8, + SPR_GRID_ICON_9, + SPR_GRID_ICON_10, + SPR_GRID_ICON_11, + SPR_GRID_ICON_12, + SPR_POKE_HEADER_1, + SPR_POKE_HEADER_2, + SPR_POKE_HEADER_3, + SPR_POKE_HEADER_4, + SPR_COLOR_HEADER_1, + SPR_COLOR_HEADER_2, + SPR_COLOR_HEADER_3, + SPR_WIN_SLOT_CURSOR, + SPR_GRID_BALL_1, + SPR_GRID_BALL_2, + SPR_GRID_BALL_3, + SPR_GRID_BALL_4, + SPR_GRID_BALL_5, + SPR_GRID_BALL_6, + SPR_CLEAR_MON, // Shroomish/Taillow + SPR_CLEAR_MON_SHADOW_1, + SPR_CLEAR_MON_SHADOW_2, + SPR_58, + SPR_59, + SPR_60, + SPR_61, + SPR_62, + SPR_63, +}; + +// Start points for sprite IDs that are looped over +#define SPR_BOARD_ICONS SPR_BOARD_ICON_ORANGE_WYNAUT +#define SPR_GRID_ICONS SPR_GRID_ICON_ORANGE_WYNAUT + struct StructgUnknown_083F8DF4 { u8 var00; @@ -51,49 +211,49 @@ struct StructgUnknown_083F8DF4 float var1C; }; -struct StructgUnknown_085B6154 +struct GridSelection { u8 var00; - u8 var01_0:4; - u8 var01_4:4; - u8 var02; - u8 var03; - u8 var04; - u8 var05; + u8 baseMultiplier:4; + u8 column:4; // Never read + u8 row; // Never read + u8 x; + u8 y; + u8 var05; // Never read u8 var06; - u32 var08; - u32 var0C; + u32 flag; + u32 inSelectionFlags; u16 var10; }; -struct StructgUnknown_083F8D90 +struct RouletteSlot { - u8 var00; - u8 var01; - u8 var02; - u32 var04; + u8 id1; // Never read + u8 id2; // Never read + u8 gridSquare; + u32 flag; }; -EWRAM_DATA struct Roulette +static EWRAM_DATA struct Roulette { u8 var00; u8 var01; - u8 var02; - u8 var03_0:5; - u8 var03_5:1; - u8 var03_6:1; - u8 var03_7:1; - u8 var04_0:2; + u8 partySpeciesFlags; + bool8 useTaillow:5; + bool8 var03_5:1; + bool8 var03_6:1; + bool8 var03_7:1; + u8 tableId:2; u8 var04_2:5; - u8 var04_7:1; - u32 var08; - u8 var0C[6]; - u8 var12[4]; - u8 var16[3]; - u8 var19; - u8 var1A_0:4; - u8 var1A_4:4; - u8 var1B[6]; + bool8 isSpecialRate:1; + u32 hitFlags; + u8 hitSquares[BALLS_PER_ROUND]; + u8 pokeHits[NUM_BOARD_POKES]; + u8 colorHits[NUM_BOARD_COLORS]; + u8 minBet; + u8 curBallNum:4; // Never actually gets incremented + u8 unk:4; // Never read + u8 betSelection[BALLS_PER_ROUND]; // Because curBallNum is used as the only index, only the first element is ever used (prev bet selections are never needed) u8 var21; u8 var22; u8 var23; @@ -104,7 +264,7 @@ EWRAM_DATA struct Roulette struct OamMatrix var2C; u16 var34; struct Sprite *var38; - u8 var3C[MAX_SPRITES]; // Sprite IDs + u8 spriteIds[MAX_SPRITES]; // Sprite IDs u8 var7C; u8 var7D; u8 var7E; @@ -123,70 +283,71 @@ EWRAM_DATA struct Roulette u8 varA4; u8 varA5; u8 v51[2]; - u16 varA8; - u16 varAA; - TaskFunc varAC; + u16 taskWaitDelay; + u16 taskWaitKey; + TaskFunc nextTask; u8 v46[4]; TaskFunc varB4; struct UnkStruct0 varB8; u16 tilemapBuffers[7][0x400]; u16 *unk_397C; -} *gUnknown_0203AB88 = NULL; -EWRAM_DATA u8 gUnknown_0203AB8C = 0; +} *sRoulette = NULL; -static void sub_8140814(u8); -static void sub_81408A8(u8); -static void sub_8140968(u8); -static void sub_8140994(u8); -static void sub_8140BD0(u8); -static void sub_8141040(u8); -static void sub_81410FC(u8); -static void sub_8141344(u8); -static void sub_814155C(u8); -static void sub_81415D4(u8); -static void sub_81416D4(u8); +static EWRAM_DATA u8 sTextWindowId = 0; + +static void Task_SpinBoard(u8); +static void Task_StartPlaying(u8); +static void Task_ContinuePlaying(u8); +static void Task_StopPlaying(u8); +static void Task_SelectFirstEmptySquare(u8); +static void Task_HandleBetGridInput(u8); +static void Task_SlideGridOffscreen(u8); +static void Task_RollBall(u8); +static void Task_EndBallRoll(u8); +static void Task_RecordBallHit(u8); +static void Task_SlideGridOnscreen(u8); static void sub_8141778(u8); -static void sub_814189C(u8); -static void sub_8141A18(u8); -static void sub_8141AC0(u8); -static void sub_8141B58(u8); -static void dp01t_12_3_battle_menu(u8); -static void sub_8141DE4(u8); -static void sub_8141E7C(u8); -static void sub_8141F7C(u8 taskId, TaskFunc r1, u16 r2, u16 r3); +static void Task_PrintSpinResult(u8); +static void Task_PrintPayout(u8); +static void Task_EndTurn(u8); +static void Task_TryPrintEndTurnMsg(u8); +static void Task_ClearBoard(u8); +static void ExitRoulette(u8); +static void Task_ExitRoulette(u8); +static void StartTaskAfterDelayOrInput(u8, TaskFunc, u16, u16); static void sub_8141FF4(u8); -static void sub_8142070(void); -static void sub_8142918(u8); -static void sub_814297C(u8); -static u8 sub_81420D0(u8, u8); -static bool8 sub_81421E8(u8, u8); -static void sub_8142284(u8); -static void sub_81424FC(u8); -static u8 sub_8142758(u8); +static void ResetHits(void); +static void Task_AcceptMinBet(u8); +static void Task_DeclineMinBet(u8); +static u8 RecordHit(u8, u8); +static bool8 IsHitInBetSelection(u8, u8); +static void FlashSelectionOnWheel(u8); +static void DrawGridBackground(u8); +static u8 GetMultiplier(u8); static void sub_8142814(void); -static void sub_8142C0C(u8); -static void sub_8142CD0(void); -static void sub_8142E70(u8, u8); -static void sub_8142F7C(void); -static void sub_8143038(u8, u8); -static void sub_8143150(u8); -static void sub_81431E4(void); -static void sub_8143280(struct Sprite *); -static void sub_8143314(void); -static void sub_8143514(u16); -static void sub_81436D0(u8); -static void sub_814372C(u8); -static void sub_814390C(struct Sprite *); -static void sub_814391C(void); -static void sub_814399C(struct Sprite *); -static void sub_81439C8(void); -static void sub_8143A40(void); +static void LoadOrFreeMiscSpritePalettesAndSheets(u8); +static void CreateGridSprites(void); +static void ShowHideGridIcons(bool8, u8); +static void CreateGridBallSprites(void); +static void ShowHideGridBalls(bool8, u8); +static void ShowHideWinSlotCursor(u8); +static void CreateBoardIconSprites(void); +static void SpriteCB_BoardIcon(struct Sprite *); +static void CreateInterfaceSprites(void); +static void SetCreditDigits(u16); +static void SetMultiplierSprite(u8); +static void SetBallCounterNumLeft(u8); +static void SpriteCB_GridSquare(struct Sprite *); +static void CreateBoardCenterSprite(void); +static void SpriteCB_BoardCenter(struct Sprite *); +static void CreateBoardBallSprites(void); +static void HideBoardBalls(void); static void sub_81446AC(struct Sprite *); -static void sub_81446DC(struct Sprite *); -static void sub_81448B8(struct Sprite *); +static void CreateShroomishSprite(struct Sprite *); +static void CreateTaillowSprite(struct Sprite *); static void sub_8144A24(struct Sprite *); static void sub_8144E60(struct Sprite *); -static void sub_8145294(struct Sprite *); +static void SpriteCB_Taillow(struct Sprite *); extern const u8 Roulette_Text_ControlsInstruction[]; extern const u8 Roulette_Text_KeepPlaying[]; @@ -203,8 +364,8 @@ extern const u8 Roulette_Text_NotEnoughCoins[]; static const u16 gUnknown_085B5BFC[] = INCBIN_U16("graphics/roulette/85B5BFC.gbapal"); static const u32 gUnknown_085B5DFC[] = INCBIN_U32("graphics/roulette/85B5DFC.bin.lz"); -static const u32 gUnknown_085B5FA0[] = INCBIN_U32("graphics/roulette/wheel_map.bin.lz"); -static const struct BgTemplate gUnknown_085B6140[] = +static const u32 sWheel_Tilemap[] = INCBIN_U32("graphics/roulette/wheel_map.bin.lz"); +static const struct BgTemplate sBgTemplates[] = { { .bg = 0, @@ -234,7 +395,7 @@ static const struct BgTemplate gUnknown_085B6140[] = .baseTile = 0 } }; -static const struct WindowTemplate gUnknown_085B614C[] = +static const struct WindowTemplate sWindowTemplates[] = { { .bg = 0, @@ -248,346 +409,349 @@ static const struct WindowTemplate gUnknown_085B614C[] = // BUG: Array not terminated properly //DUMMY_WIN_TEMPLATE }; -static const struct StructgUnknown_085B6154 gUnknown_085B6154[] = + +// var00, sprite id offset (from 7)? +static const struct GridSelection sGridSelections[NUM_GRID_SELECTIONS + 1] = { - { + [SELECTION_NONE] = { .var00 = 0xFF, - .var01_0 = 0, - .var01_4 = 0, - .var02 = 0, - .var03 = 7, - .var04 = 7, + .baseMultiplier = 0, + .column = 0, + .row = 0, + .x = 7, + .y = 7, .var05 = 0, .var06 = 0, - .var08 = 0x0, - .var0C = 0x0, + .flag = 0, + .inSelectionFlags = 0, .var10 = 0x0, }, - { + [COL_WYNAUT] = { .var00 = 12, - .var01_0 = 4, - .var01_4 = 1, - .var02 = 0, - .var03 = 17, - .var04 = 7, + .baseMultiplier = NUM_BOARD_POKES, + .column = 1, + .row = 0, + .x = 17, + .y = 7, .var05 = 0, .var06 = 0, - .var08 = 0x2, - .var0C = 0x10842, + .flag = F_WYNAUT_COL, + .inSelectionFlags = F_WYNAUT_COL | F_ORANGE_WYNAUT | F_GREEN_WYNAUT | F_PURPLE_WYNAUT, .var10 = 0xE000, }, - { + [COL_AZURILL] = { .var00 = 13, - .var01_0 = 4, - .var01_4 = 2, - .var02 = 0, - .var03 = 20, - .var04 = 7, + .baseMultiplier = NUM_BOARD_POKES, + .column = 2, + .row = 0, + .x = 20, + .y = 7, .var05 = 0, .var06 = 0, - .var08 = 0x4, - .var0C = 0x21084, + .flag = F_AZURILL_COL, + .inSelectionFlags = F_AZURILL_COL | F_ORANGE_AZURILL | F_GREEN_AZURILL | F_PURPLE_AZURILL, .var10 = 0xE000, }, - { + [COL_SKITTY] = { .var00 = 14, - .var01_0 = 4, - .var01_4 = 3, - .var02 = 0, - .var03 = 23, - .var04 = 7, + .baseMultiplier = NUM_BOARD_POKES, + .column = 3, + .row = 0, + .x = 23, + .y = 7, .var05 = 0, .var06 = 0, - .var08 = 0x8, - .var0C = 0x42108, + .flag = F_SKITTY_COL, + .inSelectionFlags = F_SKITTY_COL | F_ORANGE_SKITTY | F_GREEN_SKITTY | F_PURPLE_SKITTY, .var10 = 0xE000, }, - { + [COL_MAKUHITA] = { .var00 = 15, - .var01_0 = 4, - .var01_4 = 4, - .var02 = 0, - .var03 = 26, - .var04 = 7, + .baseMultiplier = NUM_BOARD_POKES, + .column = 4, + .row = 0, + .x = 26, + .y = 7, .var05 = 0, .var06 = 0, - .var08 = 0x10, - .var0C = 0x84210, + .flag = F_MAKUHITA_COL, + .inSelectionFlags = F_MAKUHITA_COL | F_ORANGE_MAKUHITA | F_GREEN_MAKUHITA | F_PURPLE_MAKUHITA, .var10 = 0xE000, }, - { + [ROW_ORANGE] = { .var00 = 16, - .var01_0 = 3, - .var01_4 = 0, - .var02 = 1, - .var03 = 14, - .var04 = 10, + .baseMultiplier = NUM_BOARD_COLORS, + .column = 0, + .row = 1, + .x = 14, + .y = 10, .var05 = 0, .var06 = 12, - .var08 = 0x20, - .var0C = 0x3E0, + .flag = F_ORANGE_ROW, + .inSelectionFlags = F_ORANGE_ROW | F_ORANGE_WYNAUT | F_ORANGE_AZURILL | F_ORANGE_SKITTY | F_ORANGE_MAKUHITA, .var10 = 0x249, }, - { + [SQU_ORANGE_WYNAUT] = { .var00 = 0, - .var01_0 = 12, - .var01_4 = 1, - .var02 = 1, - .var03 = 17, - .var04 = 10, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 1, + .row = 1, + .x = 17, + .y = 10, .var05 = 3, .var06 = 3, - .var08 = 0x40, - .var0C = 0x40, + .flag = F_ORANGE_WYNAUT, + .inSelectionFlags = F_ORANGE_WYNAUT, .var10 = 0x2001, }, - { + [SQU_ORANGE_AZURILL] = { .var00 = 9, - .var01_0 = 12, - .var01_4 = 2, - .var02 = 1, - .var03 = 20, - .var04 = 10, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 2, + .row = 1, + .x = 20, + .y = 10, .var05 = 3, .var06 = 3, - .var08 = 0x80, - .var0C = 0x80, + .flag = F_ORANGE_AZURILL, + .inSelectionFlags = F_ORANGE_AZURILL, .var10 = 0x2200, }, - { + [SQU_ORANGE_SKITTY] = { .var00 = 6, - .var01_0 = 12, - .var01_4 = 3, - .var02 = 1, - .var03 = 23, - .var04 = 10, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 3, + .row = 1, + .x = 23, + .y = 10, .var05 = 3, .var06 = 3, - .var08 = 0x100, - .var0C = 0x100, + .flag = F_ORANGE_SKITTY, + .inSelectionFlags = F_ORANGE_SKITTY, .var10 = 0x2040, }, - { + [SQU_ORANGE_MAKUHITA] = { .var00 = 3, - .var01_0 = 12, - .var01_4 = 4, - .var02 = 1, - .var03 = 26, - .var04 = 10, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 4, + .row = 1, + .x = 26, + .y = 10, .var05 = 3, .var06 = 3, - .var08 = 0x200, - .var0C = 0x200, + .flag = F_ORANGE_MAKUHITA, + .inSelectionFlags = F_ORANGE_MAKUHITA, .var10 = 0x2008, }, - { + [ROW_GREEN] = { .var00 = 17, - .var01_0 = 3, - .var01_4 = 0, - .var02 = 2, - .var03 = 14, - .var04 = 13, + .baseMultiplier = NUM_BOARD_COLORS, + .column = 0, + .row = 2, + .x = 14, + .y = 13, .var05 = 3, .var06 = 15, - .var08 = 0x400, - .var0C = 0x7C00, + .flag = F_GREEN_ROW, + .inSelectionFlags = F_GREEN_ROW | F_GREEN_WYNAUT | F_GREEN_AZURILL | F_GREEN_SKITTY | F_GREEN_MAKUHITA, .var10 = 0x492, }, - { + [SQU_GREEN_WYNAUT] = { .var00 = 4, - .var01_0 = 12, - .var01_4 = 1, - .var02 = 2, - .var03 = 17, - .var04 = 13, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 1, + .row = 2, + .x = 17, + .y = 13, .var05 = 6, .var06 = 6, - .var08 = 0x800, - .var0C = 0x800, + .flag = F_GREEN_WYNAUT, + .inSelectionFlags = F_GREEN_WYNAUT, .var10 = 0x2010, }, - { + [SQU_GREEN_AZURILL] = { .var00 = 1, - .var01_0 = 12, - .var01_4 = 2, - .var02 = 2, - .var03 = 20, - .var04 = 13, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 2, + .row = 2, + .x = 20, + .y = 13, .var05 = 6, .var06 = 6, - .var08 = 0x1000, - .var0C = 0x1000, + .flag = F_GREEN_AZURILL, + .inSelectionFlags = F_GREEN_AZURILL, .var10 = 0x2002, }, - { + [SQU_GREEN_SKITTY] = { .var00 = 10, - .var01_0 = 12, - .var01_4 = 3, - .var02 = 2, - .var03 = 23, - .var04 = 13, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 3, + .row = 2, + .x = 23, + .y = 13, .var05 = 6, .var06 = 6, - .var08 = 0x2000, - .var0C = 0x2000, + .flag = F_GREEN_SKITTY, + .inSelectionFlags = F_GREEN_SKITTY, .var10 = 0x2400, }, - { + [SQU_GREEN_MAKUHITA] = { .var00 = 7, - .var01_0 = 12, - .var01_4 = 4, - .var02 = 2, - .var03 = 26, - .var04 = 13, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 4, + .row = 2, + .x = 26, + .y = 13, .var05 = 6, .var06 = 6, - .var08 = 0x4000, - .var0C = 0x4000, + .flag = F_GREEN_MAKUHITA, + .inSelectionFlags = F_GREEN_MAKUHITA, .var10 = 0x2080, }, - { + [ROW_PURPLE] = { .var00 = 18, - .var01_0 = 3, - .var01_4 = 0, - .var02 = 3, - .var03 = 14, - .var04 = 16, + .baseMultiplier = NUM_BOARD_COLORS, + .column = 0, + .row = 3, + .x = 14, + .y = 16, .var05 = 6, .var06 = 18, - .var08 = 0x8000, - .var0C = 0xF8000, + .flag = F_PURPLE_ROW, + .inSelectionFlags = F_PURPLE_ROW | F_PURPLE_WYNAUT | F_PURPLE_AZURILL | F_PURPLE_SKITTY | F_PURPLE_MAKUHITA, .var10 = 0x924, }, - { + [SQU_PURPLE_WYNAUT] = { .var00 = 8, - .var01_0 = 12, - .var01_4 = 1, - .var02 = 3, - .var03 = 17, - .var04 = 16, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 1, + .row = 3, + .x = 17, + .y = 16, .var05 = 9, .var06 = 9, - .var08 = 0x10000, - .var0C = 0x10000, + .flag = F_PURPLE_WYNAUT, + .inSelectionFlags = F_PURPLE_WYNAUT, .var10 = 0x2100, }, - { + [SQU_PURPLE_AZURILL] = { .var00 = 5, - .var01_0 = 12, - .var01_4 = 2, - .var02 = 3, - .var03 = 20, - .var04 = 16, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 2, + .row = 3, + .x = 20, + .y = 16, .var05 = 9, .var06 = 9, - .var08 = 0x20000, - .var0C = 0x20000, + .flag = F_PURPLE_AZURILL, + .inSelectionFlags = F_PURPLE_AZURILL, .var10 = 0x2020, }, - { + [SQU_PURPLE_SKITTY] = { .var00 = 2, - .var01_0 = 12, - .var01_4 = 3, - .var02 = 3, - .var03 = 23, - .var04 = 16, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 3, + .row = 3, + .x = 23, + .y = 16, .var05 = 9, .var06 = 9, - .var08 = 0x40000, - .var0C = 0x40000, + .flag = F_PURPLE_SKITTY, + .inSelectionFlags = F_PURPLE_SKITTY, .var10 = 0x2004, }, - { + [SQU_PURPLE_MAKUHITA] = { .var00 = 11, - .var01_0 = 12, - .var01_4 = 4, - .var02 = 3, - .var03 = 26, - .var04 = 16, + .baseMultiplier = NUM_ROULETTE_SLOTS, + .column = 4, + .row = 3, + .x = 26, + .y = 16, .var05 = 9, .var06 = 9, - .var08 = 0x80000, - .var0C = 0x80000, + .flag = F_PURPLE_MAKUHITA, + .inSelectionFlags = F_PURPLE_MAKUHITA, .var10 = 0x2800, }, }; -static const struct StructgUnknown_083F8D90 gUnknown_085B62E4[] = +static const struct RouletteSlot sRouletteSlots[] = { { - .var00 = 0, - .var01 = 1, - .var02 = 6, - .var04 = 0x40, + .id1 = 0, + .id2 = 1, + .gridSquare = SQU_ORANGE_WYNAUT, + .flag = F_ORANGE_WYNAUT, }, { - .var00 = 1, - .var01 = 3, - .var02 = 12, - .var04 = 0x1000, + .id1 = 1, + .id2 = 3, + .gridSquare = SQU_GREEN_AZURILL, + .flag = F_GREEN_AZURILL, }, { - .var00 = 2, - .var01 = 5, - .var02 = 18, - .var04 = 0x40000, + .id1 = 2, + .id2 = 5, + .gridSquare = SQU_PURPLE_SKITTY, + .flag = F_PURPLE_SKITTY, }, { - .var00 = 3, - .var01 = 7, - .var02 = 9, - .var04 = 0x200, + .id1 = 3, + .id2 = 7, + .gridSquare = SQU_ORANGE_MAKUHITA, + .flag = F_ORANGE_MAKUHITA, }, { - .var00 = 4, - .var01 = 9, - .var02 = 11, - .var04 = 0x800, + .id1 = 4, + .id2 = 9, + .gridSquare = SQU_GREEN_WYNAUT, + .flag = F_GREEN_WYNAUT, }, { - .var00 = 5, - .var01 = 11, - .var02 = 17, - .var04 = 0x20000, + .id1 = 5, + .id2 = 11, + .gridSquare = SQU_PURPLE_AZURILL, + .flag = F_PURPLE_AZURILL, }, { - .var00 = 6, - .var01 = 13, - .var02 = 8, - .var04 = 0x100, + .id1 = 6, + .id2 = 13, + .gridSquare = SQU_ORANGE_SKITTY, + .flag = F_ORANGE_SKITTY, }, { - .var00 = 7, - .var01 = 15, - .var02 = 14, - .var04 = 0x4000, + .id1 = 7, + .id2 = 15, + .gridSquare = SQU_GREEN_MAKUHITA, + .flag = F_GREEN_MAKUHITA, }, { - .var00 = 8, - .var01 = 17, - .var02 = 16, - .var04 = 0x10000, + .id1 = 8, + .id2 = 17, + .gridSquare = SQU_PURPLE_WYNAUT, + .flag = F_PURPLE_WYNAUT, }, { - .var00 = 9, - .var01 = 19, - .var02 = 7, - .var04 = 0x80, + .id1 = 9, + .id2 = 19, + .gridSquare = SQU_ORANGE_AZURILL, + .flag = F_ORANGE_AZURILL, }, { - .var00 = 10, - .var01 = 21, - .var02 = 13, - .var04 = 0x2000, + .id1 = 10, + .id2 = 21, + .gridSquare = SQU_GREEN_SKITTY, + .flag = F_GREEN_SKITTY, }, { - .var00 = 11, - .var01 = 23, - .var02 = 19, - .var04 = 0x80000, + .id1 = 11, + .id2 = 23, + .gridSquare = SQU_PURPLE_MAKUHITA, + .flag = F_PURPLE_MAKUHITA, }, }; -static const u8 gUnknown_085B6344[] = {1, 3, 1, 6}; +static const u8 sTableMinBets[] = {1, 3, 1, 6}; + static const struct StructgUnknown_083F8DF4 gUnknown_085B6348[] = { { @@ -792,88 +956,88 @@ static const struct UnkStruct1 gUnknown_085B63F0[] = } }; -static const struct YesNoFuncTable gUnknown_085B6408 = +static const struct YesNoFuncTable sYesNoTable_AcceptMinBet = { - sub_8142918, - sub_814297C + Task_AcceptMinBet, + Task_DeclineMinBet }; -static const struct YesNoFuncTable gUnknown_085B6410 = +static const struct YesNoFuncTable sYesNoTable_KeepPlaying = { - sub_8140968, - sub_8140994 + Task_ContinuePlaying, + Task_StopPlaying }; -static void sub_8140238(void) +static void CB2_Roulette(void) { RunTasks(); AnimateSprites(); BuildOamBuffer(); - if (gUnknown_0203AB88->varB8.var00) - task_tutorial_controls_fadein(&gUnknown_0203AB88->varB8); + if (sRoulette->varB8.var00) + task_tutorial_controls_fadein(&sRoulette->varB8); } -static void sub_8140264(void) +static void VBlankCB_Roulette(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); sub_8142814(); - SetGpuReg(REG_OFFSET_BG1HOFS, 0x200 - gUnknown_0203AB88->var26); - if (gUnknown_0203AB88->var01) - SetGpuReg(REG_OFFSET_BLDALPHA, gUnknown_0203AB88->var34); - if (gUnknown_0203AB88->var2A != 0) + SetGpuReg(REG_OFFSET_BG1HOFS, 0x200 - sRoulette->var26); + if (sRoulette->var01) + SetGpuReg(REG_OFFSET_BLDALPHA, sRoulette->var34); + if (sRoulette->var2A != 0) { - DmaCopy16(3, &gUnknown_0203AB88->tilemapBuffers[2][0xE0], (void *)BG_SCREEN_ADDR(4) + 0x1C0, 0x340); - gUnknown_0203AB88->var2A = 0; + DmaCopy16(3, &sRoulette->tilemapBuffers[2][0xE0], (void *)BG_SCREEN_ADDR(4) + 0x1C0, 0x340); + sRoulette->var2A = 0; } - switch (gUnknown_0203AB88->var28) + switch (sRoulette->var28) { case 1: SetBgAttribute(0, BG_ATTR_CHARBASEINDEX, 0); ShowBg(0); - DmaCopy16(3, &gUnknown_0203AB88->tilemapBuffers[0][0xE0], (void *)BG_SCREEN_ADDR(31) + 0x1C0, 0x340); - gUnknown_0203AB88->var28 = 2; + DmaCopy16(3, &sRoulette->tilemapBuffers[0][0xE0], (void *)BG_SCREEN_ADDR(31) + 0x1C0, 0x340); + sRoulette->var28 = 2; break; case 2: - DmaCopy16(3, &gUnknown_0203AB88->tilemapBuffers[0][0xE0], (void *)BG_SCREEN_ADDR(31) + 0x1C0, 0x340); + DmaCopy16(3, &sRoulette->tilemapBuffers[0][0xE0], (void *)BG_SCREEN_ADDR(31) + 0x1C0, 0x340); break; case 0xFF: SetBgAttribute(0, BG_ATTR_CHARBASEINDEX, 2); ShowBg(0); DmaFill16(3, 0, (void *)BG_SCREEN_ADDR(31) + 0x1C0, 0x340); - gUnknown_0203AB88->var28 = 0; + sRoulette->var28 = 0; case 0: break; } } -static void sub_8140388(void) +static void InitRouletteBgAndWindows(void) { u32 size = 0; - gUnknown_0203AB88 = AllocZeroed(sizeof(*gUnknown_0203AB88)); + sRoulette = AllocZeroed(sizeof(*sRoulette)); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(1, gUnknown_085B6140, ARRAY_COUNT(gUnknown_085B6140)); - SetBgTilemapBuffer(0, gUnknown_0203AB88->tilemapBuffers[0]); - SetBgTilemapBuffer(1, gUnknown_0203AB88->tilemapBuffers[2]); - SetBgTilemapBuffer(2, gUnknown_0203AB88->tilemapBuffers[6]); - InitWindows(gUnknown_085B614C); + InitBgsFromTemplates(1, sBgTemplates, ARRAY_COUNT(sBgTemplates)); + SetBgTilemapBuffer(0, sRoulette->tilemapBuffers[0]); + SetBgTilemapBuffer(1, sRoulette->tilemapBuffers[2]); + SetBgTilemapBuffer(2, sRoulette->tilemapBuffers[6]); + InitWindows(sWindowTemplates); InitTextBoxGfxAndPrinters(); - gUnknown_0203AB8C = 0; - gUnknown_0203AB88->unk_397C = malloc_and_decompress(gUnknown_085B5DFC, &size); + sTextWindowId = 0; + sRoulette->unk_397C = malloc_and_decompress(gUnknown_085B5DFC, &size); } -static void sub_8140418(void) +static void FreeRoulette(void) { - FREE_AND_SET_NULL(gUnknown_0203AB88->unk_397C); + FREE_AND_SET_NULL(sRoulette->unk_397C); FreeAllWindowBuffers(); UnsetBgTilemapBuffer(0); UnsetBgTilemapBuffer(1); UnsetBgTilemapBuffer(2); ResetBgsAndClearDma3BusyFlags(0); - memset(gUnknown_0203AB88, 0, sizeof(*gUnknown_0203AB88)); - FREE_AND_SET_NULL(gUnknown_0203AB88); + memset(sRoulette, 0, sizeof(*sRoulette)); + FREE_AND_SET_NULL(sRoulette); } static void sub_8140470(void) @@ -881,26 +1045,26 @@ static void sub_8140470(void) u8 i; u16 arr[3] = {RGB(24, 4, 10), RGB(10, 19, 6), RGB(24, 4, 10)}; // the third is never used ? - gUnknown_0203AB88->var04_0 = (gSpecialVar_0x8004 & 1); + sRoulette->tableId = (gSpecialVar_0x8004 & 1); - if (gSpecialVar_0x8004 & 0x80) - gUnknown_0203AB88->var04_7 = 1; + if (gSpecialVar_0x8004 & ROULETTE_SPECIAL_RATE) + sRoulette->isSpecialRate = TRUE; - gUnknown_0203AB88->var22 = gUnknown_085B6348[gUnknown_0203AB88->var04_0].var03; - gUnknown_0203AB88->var23 = gUnknown_085B6348[gUnknown_0203AB88->var04_0].var04; - gUnknown_0203AB88->var19 = gUnknown_085B6344[gUnknown_0203AB88->var04_0 + gUnknown_0203AB88->var04_7 * 2]; - gUnknown_0203AB88->var1A_4 = 1; + sRoulette->var22 = gUnknown_085B6348[sRoulette->tableId].var03; + sRoulette->var23 = gUnknown_085B6348[sRoulette->tableId].var04; + sRoulette->minBet = sTableMinBets[sRoulette->tableId + sRoulette->isSpecialRate * 2]; + sRoulette->unk = 1; - if (gUnknown_0203AB88->var19 == 1) + if (sRoulette->minBet == 1) gPlttBufferUnfaded[0] = gPlttBufferUnfaded[0x51] = gPlttBufferFaded[0] = gPlttBufferFaded[0x51] = arr[0]; else gPlttBufferUnfaded[0] = gPlttBufferUnfaded[0x51] = gPlttBufferFaded[0] = gPlttBufferFaded[0x51] = arr[1]; - sub_8151678(&gUnknown_0203AB88->varB8); + sub_8151678(&sRoulette->varB8); for (i = 0; i < 13; i++) { - sub_815168C(&gUnknown_0203AB88->varB8, i, &gUnknown_085B6388[i]); + sub_815168C(&sRoulette->varB8, i, &gUnknown_085B6388[i]); } for (i = 0; i < PARTY_SIZE; i++) @@ -908,17 +1072,26 @@ static void sub_8140470(void) switch (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2)) { case SPECIES_SHROOMISH: - gUnknown_0203AB88->var02 |= 0x1; + sRoulette->partySpeciesFlags |= HAS_SHROOMISH; break; case SPECIES_TAILLOW: - gUnknown_0203AB88->var02 |= 0x2; + sRoulette->partySpeciesFlags |= HAS_TAILLOW; break; } } RtcCalcLocalTime(); } -static void sub_81405CC(void) +// Task data for the roulette game tasks, starting with Task_StartPlaying +#define tMultiplier data[2] +#define tSelectionId data[4] +#define tWonBet data[5] +#define tBallNum data[6] +#define tConsecutiveWins data[11] +#define tWinningSquare data[12] +#define tCoins data[13] + +static void CB2_LoadRoulette(void) { u8 taskId; @@ -932,7 +1105,7 @@ static void sub_81405CC(void) ResetAllBgsCoordinates(); break; case 1: - sub_8140388(); + InitRouletteBgAndWindows(); DeactivateAllTextPrinters(); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_NONE | BLDCNT_TGT2_BG2 | @@ -947,35 +1120,35 @@ static void sub_81405CC(void) break; case 3: LoadPalette(&gUnknown_085B5BFC, 0, 0x1C0); - DecompressAndCopyTileDataToVram(1, gRouletteMenuTiles, 0, 0, 0); - DecompressAndCopyTileDataToVram(2, gRouletteWheelTiles, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, gRouletteMenu_Gfx, 0, 0, 0); + DecompressAndCopyTileDataToVram(2, gRouletteWheel_Gfx, 0, 0, 0); break; case 4: if (FreeTempTileDataBuffersIfPossible()) return; sub_8140470(); - CopyToBgTilemapBuffer(2, gUnknown_085B5FA0, 0, 0); + CopyToBgTilemapBuffer(2, sWheel_Tilemap, 0, 0); break; case 5: - sub_8142C0C(0); - sub_81439C8(); - sub_814391C(); - sub_8143314(); - sub_8142CD0(); - sub_8142F7C(); - sub_81431E4(); + LoadOrFreeMiscSpritePalettesAndSheets(FALSE); + CreateBoardBallSprites(); + CreateBoardCenterSprite(); + CreateInterfaceSprites(); + CreateGridSprites(); + CreateGridBallSprites(); + CreateBoardIconSprites(); break; case 6: AnimateSprites(); BuildOamBuffer(); - sub_8143514(GetCoins()); - sub_814372C(6); - sub_81436D0(0); - sub_81424FC(0); - DrawStdWindowFrame(gUnknown_0203AB8C, FALSE); - AddTextPrinterParameterized(gUnknown_0203AB8C, 1, Roulette_Text_ControlsInstruction, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(gUnknown_0203AB8C, 3); + SetCreditDigits(GetCoins()); + SetBallCounterNumLeft(BALLS_PER_ROUND); + SetMultiplierSprite(SELECTION_NONE); + DrawGridBackground(SELECTION_NONE); + DrawStdWindowFrame(sTextWindowId, FALSE); + AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_ControlsInstruction, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(sTextWindowId, 3); gSpriteCoordOffsetX = -60; gSpriteCoordOffsetY = 0; break; @@ -991,39 +1164,39 @@ static void sub_81405CC(void) break; case 8: EnableInterrupts(INTR_FLAG_VBLANK); - SetVBlankCallback(sub_8140264); + SetVBlankCallback(VBlankCB_Roulette); BeginHardwarePaletteFade(0xFF, 0, 16, 0, 1); - taskId = gUnknown_0203AB88->varA4 = CreateTask(sub_81408A8, 0); - gTasks[taskId].data[6] = 6; - gTasks[taskId].data[13] = GetCoins(); + taskId = sRoulette->varA4 = CreateTask(Task_StartPlaying, 0); + gTasks[taskId].tBallNum = BALLS_PER_ROUND; + gTasks[taskId].tCoins = GetCoins(); AlertTVThatPlayerPlayedRoulette(GetCoins()); - gUnknown_0203AB88->varA5 = CreateTask(sub_8140814, 1); - SetMainCallback2(sub_8140238); + sRoulette->varA5 = CreateTask(Task_SpinBoard, 1); + SetMainCallback2(CB2_Roulette); return; } gMain.state++; } -static void sub_8140814(u8 unused) +static void Task_SpinBoard(u8 taskId) { s16 sin; s16 cos; - if (gUnknown_0203AB88->var21++ == gUnknown_0203AB88->var23) + if (sRoulette->var21++ == sRoulette->var23) { - gUnknown_0203AB88->var21 = 0; - if ((gUnknown_0203AB88->var24 -= gUnknown_0203AB88->var22) < 0) - gUnknown_0203AB88->var24 = 360 - gUnknown_0203AB88->var22; + sRoulette->var21 = 0; + if ((sRoulette->var24 -= sRoulette->var22) < 0) + sRoulette->var24 = 360 - sRoulette->var22; } - sin = Sin2(gUnknown_0203AB88->var24); - cos = Cos2(gUnknown_0203AB88->var24); + sin = Sin2(sRoulette->var24); + cos = Cos2(sRoulette->var24); sin = sin / 16; - gUnknown_0203AB88->var2C.a = gUnknown_0203AB88->var2C.d = cos / 16; - gUnknown_0203AB88->var2C.b = sin; - gUnknown_0203AB88->var2C.c = -sin; + sRoulette->var2C.a = sRoulette->var2C.d = cos / 16; + sRoulette->var2C.b = sin; + sRoulette->var2C.c = -sin; } -static void sub_81408A8(u8 taskId) +static void Task_StartPlaying(u8 taskId) { if (UpdatePaletteFade() == 0) { @@ -1031,222 +1204,227 @@ static void sub_81408A8(u8 taskId) BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BD); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 8)); - gTasks[taskId].data[6] = 0; + gTasks[taskId].tBallNum = 0; sub_8141FF4(taskId); - sub_8142070(); - sub_8143A40(); - sub_81424FC(0); - sub_814372C(6); - sub_8141F7C(taskId, sub_8140968, 0xFFFF, 0x3); + ResetHits(); + HideBoardBalls(); + DrawGridBackground(SELECTION_NONE); + SetBallCounterNumLeft(BALLS_PER_ROUND); + StartTaskAfterDelayOrInput(taskId, Task_ContinuePlaying, 0xFFFF, A_BUTTON | B_BUTTON); } } -static void sub_8140914(u8 taskId) +static void Task_AskKeepPlaying(u8 taskId) { DisplayYesNoMenuDefaultYes(); - DrawStdWindowFrame(gUnknown_0203AB8C, 0); - AddTextPrinterParameterized(gUnknown_0203AB8C, 1, Roulette_Text_KeepPlaying, 0, 1, TEXT_SPEED_FF, 0); - CopyWindowToVram(gUnknown_0203AB8C, 3); - DoYesNoFuncWithChoice(taskId, &gUnknown_085B6410); + DrawStdWindowFrame(sTextWindowId, 0); + AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_KeepPlaying, 0, 1, TEXT_SPEED_FF, 0); + CopyWindowToVram(sTextWindowId, 3); + DoYesNoFuncWithChoice(taskId, &sYesNoTable_KeepPlaying); } -static void sub_8140968(u8 taskId) +static void Task_ContinuePlaying(u8 taskId) { ClearStdWindowAndFrame(0, TRUE); - gTasks[taskId].func = sub_8140BD0; + gTasks[taskId].func = Task_SelectFirstEmptySquare; } -static void sub_8140994(u8 taskId) +static void Task_StopPlaying(u8 taskId) { - DestroyTask(gUnknown_0203AB88->varA5); - sub_8141DE4(taskId); + DestroyTask(sRoulette->varA5); + ExitRoulette(taskId); } -static void sub_81409B8(u8 r0) +static void UpdateGridSelectionRect(u8 selectionId) { u8 temp0, temp1; - switch (r0) + switch (selectionId) { - case 0: - sub_8152008(&gUnknown_0203AB88->tilemapBuffers[0][0], 0, 14, 7, 16, 13); + case SELECTION_NONE: + ClearGridSelectionRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); break; - case 1: - case 2: - case 3: - case 4: - temp0 = (r0 * 3 + 14); - sub_8152008(&gUnknown_0203AB88->tilemapBuffers[0][0], 0, 14, 7, 16, 13); - sub_8152058(&gUnknown_0203AB88->tilemapBuffers[0][0], &gUnknown_0203AB88->unk_397C[281], temp0, 7, 3, 13); + case COL_WYNAUT: + case COL_AZURILL: + case COL_SKITTY: + case COL_MAKUHITA: + temp0 = (selectionId * 3 + 14); + ClearGridSelectionRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); + SetGridSelectionRect(&sRoulette->tilemapBuffers[0][0], &sRoulette->unk_397C[281], temp0, 7, 3, 13); break; - case 0x5: - case 0xA: - case 0xF: - temp1 = ((r0 - 1) / 5 * 3 + 10); - sub_8152008(&gUnknown_0203AB88->tilemapBuffers[0][0], 0, 14, 7, 16, 13); - sub_8152058(&gUnknown_0203AB88->tilemapBuffers[0][0], &gUnknown_0203AB88->unk_397C[320], 14, temp1, 16, 3); + case ROW_ORANGE: + case ROW_GREEN: + case ROW_PURPLE: + temp1 = ((selectionId - 1) / 5 * 3 + 10); + ClearGridSelectionRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); + SetGridSelectionRect(&sRoulette->tilemapBuffers[0][0], &sRoulette->unk_397C[320], 14, temp1, 16, 3); break; + // Individual square default: - temp0 = ((r0 % 5) * 3 + 14); - temp1 = ((r0 - 1) / 5 * 3 + 7); - sub_8152008(&gUnknown_0203AB88->tilemapBuffers[0][0], 0, 14, 7, 16, 13); - sub_8152058(&gUnknown_0203AB88->tilemapBuffers[0][0], &gUnknown_0203AB88->unk_397C[272], temp0, temp1, 3, 3); + temp0 = GET_COL(selectionId) * 3 + 14; + temp1 = ((selectionId - 1) / 5 * 3 + 7); + ClearGridSelectionRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); + SetGridSelectionRect(&sRoulette->tilemapBuffers[0][0], &sRoulette->unk_397C[272], temp0, temp1, 3, 3); break; } } -static void sub_8140B64(u8 taskId) +static void UpdateGridSelection(u8 taskId) { - sub_81436D0(gTasks[taskId].data[4]); - sub_81409B8(gTasks[taskId].data[4]); + SetMultiplierSprite(gTasks[taskId].tSelectionId); + UpdateGridSelectionRect(gTasks[taskId].tSelectionId); } -static void sub_8140B8C(u8 taskId) +static void Task_StartHandleBetGridInput(u8 taskId) { - gUnknown_0203AB88->var28 = 1; - sub_81409B8(gTasks[taskId].data[4]); - gUnknown_0203AB88->var23 = 2; - gUnknown_0203AB88->var21 = 0; - gTasks[taskId].func = sub_8141040; + sRoulette->var28 = 1; + UpdateGridSelectionRect(gTasks[taskId].tSelectionId); + sRoulette->var23 = 2; + sRoulette->var21 = 0; + gTasks[taskId].func = Task_HandleBetGridInput; } -static void sub_8140BD0(u8 taskId) +static void Task_SelectFirstEmptySquare(u8 taskId) { s16 i; - if (gUnknown_0203AB88->var08 & 0x20) + if (sRoulette->hitFlags & F_ORANGE_ROW) { - for (i = 11; i < 14; i++) + // If the whole orange row is filled, get first in green row + for (i = SQU_GREEN_WYNAUT; i < SQU_GREEN_MAKUHITA; i++) { - if ((gUnknown_0203AB88->var08 & gUnknown_085B6154[i].var08) == 0) + if (!(sRoulette->hitFlags & sGridSelections[i].flag)) break; } } else { - for (i = 6; i < 10; i++) + // Otherwise get first in orange row + // With only 6 balls both rows can't be filled, no need to check purple row + for (i = SQU_ORANGE_WYNAUT; i <= SQU_ORANGE_MAKUHITA; i++) // <= is accidental, but it will never get that far { - if ((gUnknown_0203AB88->var08 & gUnknown_085B6154[i].var08) == 0) + if (!(sRoulette->hitFlags & sGridSelections[i].flag)) break; } } - gTasks[taskId].data[4] = i; + gTasks[taskId].tSelectionId = i; sub_8141FF4(taskId); - sub_81424FC(gTasks[taskId].data[4]); - sub_81436D0(gTasks[taskId].data[4]); - sub_8142284(gTasks[taskId].data[4]); + DrawGridBackground(gTasks[taskId].tSelectionId); + SetMultiplierSprite(gTasks[taskId].tSelectionId); + FlashSelectionOnWheel(gTasks[taskId].tSelectionId); gTasks[taskId].data[1] = 0; - gTasks[taskId].func = sub_8140B8C; + gTasks[taskId].func = Task_StartHandleBetGridInput; } -static u8 sub_8140CA8(s16 *r0, u8 r1) +static bool8 CanMoveSelectionInDir(s16 *selectionId, u8 dir) { s8 temp1 = 0; s8 temp = 0; - s8 arr[4] = {-5, 5, -1, 1}; - s8 t = *r0; + s8 moveOffsets[4] = {-5, 5, -1, 1}; + s8 originalSelection = *selectionId; - switch (r1) + switch (dir) { - case 0: - case 1: - temp1 = (*r0 % 5); - temp = temp1 + 15; - if (temp1 == 0) + case 0: // UP + case 1: // DOWN + temp1 = GET_COL(*selectionId); + temp = temp1 + ROW_PURPLE; + if (temp1 == SELECTION_NONE) temp1 = 5; break; - case 2: - case 3: - temp1 = (*r0 / 5) * 5; - temp = temp1 + 4; - if (temp1 == 0) + case 2: // LEFT + case 3: // RIGHT + temp1 = GET_ROW(*selectionId); + temp = temp1 + COL_MAKUHITA; + if (temp1 == SELECTION_NONE) temp1 = 1; break; } - *r0 += arr[r1]; + *selectionId += moveOffsets[dir]; - if (*r0 < temp1) - *r0 = temp; + if (*selectionId < temp1) + *selectionId = temp; - if (*r0 > temp) - *r0 = temp1; + if (*selectionId > temp) + *selectionId = temp1; - if (*r0 != t) + if (*selectionId != originalSelection) return TRUE; return FALSE; } -static void sub_8140D6C(u8 r0) +static void ProcessBetGridInput(u8 taskId) { u8 z = 0; - bool8 var0 = FALSE; - if (!(gMain.newKeys & DPAD_UP) || ((var0 = TRUE), sub_8140CA8(&gTasks[r0].data[4], 0))) - if (!(gMain.newKeys & DPAD_DOWN) || ((var0 = TRUE), sub_8140CA8(&gTasks[r0].data[4], 1))) - if (!(gMain.newKeys & DPAD_LEFT) || ((var0 = TRUE), sub_8140CA8(&gTasks[r0].data[4], 2))) - if (!(gMain.newKeys & DPAD_RIGHT) || ((var0 = TRUE), sub_8140CA8(&gTasks[r0].data[4], 3))) - if (var0) - { - u8 i; - sub_81424FC(gTasks[r0].data[4]); - sub_8140B64(r0); - gTasks[r0].data[1] = z; - PlaySE(SE_SELECT); - sub_8151A9C(&gUnknown_0203AB88->varB8, 0xFFFF); - gUnknown_0203AB88->varB8.var04[13].var00_7 = gUnknown_0203AB88->varB8.var04[14].var00_7 = gUnknown_0203AB88->varB8.var04[15].var00_7 = 0; - sub_8142284(gTasks[r0].data[4]); - for (i = 0; i < 4; i++) - { - gSprites[gUnknown_0203AB88->var3C[i + 41]].oam.tileNum = - gSprites[gUnknown_0203AB88->var3C[i + 41]].sheetTileStart - + (*gSprites[gUnknown_0203AB88->var3C[i + 41]].anims)->type; - } - if ((u16)(gTasks[r0].data[4] - 1) < 4 && !(gUnknown_0203AB88->var08 & gUnknown_085B6154[gTasks[r0].data[4]].var08) ) - { - z = gTasks[r0].data[4] - 1; - gSprites[gUnknown_0203AB88->var3C[z + 41]].oam.tileNum = - gSprites[gUnknown_0203AB88->var3C[z + 41]].sheetTileStart - + (*gSprites[gUnknown_0203AB88->var3C[z + 41]].anims + 1)->type; - } - } + bool8 dirPressed = FALSE; + if ((!(JOY_NEW(DPAD_UP)) || ((dirPressed = TRUE), CanMoveSelectionInDir(&gTasks[taskId].tSelectionId, 0))) + && (!(JOY_NEW(DPAD_DOWN)) || ((dirPressed = TRUE), CanMoveSelectionInDir(&gTasks[taskId].tSelectionId, 1))) + && (!(JOY_NEW(DPAD_LEFT)) || ((dirPressed = TRUE), CanMoveSelectionInDir(&gTasks[taskId].tSelectionId, 2))) + && (!(JOY_NEW(DPAD_RIGHT)) || ((dirPressed = TRUE), CanMoveSelectionInDir(&gTasks[taskId].tSelectionId, 3))) + && (dirPressed)) + { + u8 i; + DrawGridBackground(gTasks[taskId].tSelectionId); + UpdateGridSelection(taskId); + gTasks[taskId].data[1] = z; + PlaySE(SE_SELECT); + sub_8151A9C(&sRoulette->varB8, 0xFFFF); + sRoulette->varB8.var04[13].var00_7 = sRoulette->varB8.var04[14].var00_7 = sRoulette->varB8.var04[15].var00_7 = 0; + FlashSelectionOnWheel(gTasks[taskId].tSelectionId); + for (i = 0; i < NUM_BOARD_POKES; i++) + { + gSprites[sRoulette->spriteIds[i + SPR_POKE_HEADER_1]].oam.tileNum = + gSprites[sRoulette->spriteIds[i + SPR_POKE_HEADER_1]].sheetTileStart + + (*gSprites[sRoulette->spriteIds[i + SPR_POKE_HEADER_1]].anims)->type; + } + if ((u16)(gTasks[taskId].tSelectionId - 1) < 4 && !(sRoulette->hitFlags & sGridSelections[gTasks[taskId].tSelectionId].flag) ) + { + z = gTasks[taskId].tSelectionId - 1; + gSprites[sRoulette->spriteIds[z + SPR_POKE_HEADER_1]].oam.tileNum = + gSprites[sRoulette->spriteIds[z + SPR_POKE_HEADER_1]].sheetTileStart + + (*gSprites[sRoulette->spriteIds[z + SPR_POKE_HEADER_1]].anims + 1)->type; + } + } } static void sub_8140F6C(u8 r0) { IncrementDailyRouletteUses(); - gUnknown_0203AB88->var28 = 0xFF; - if (gUnknown_0203AB88->var19 == 1) - gUnknown_0203AB88->var23 = 1; + sRoulette->var28 = 0xFF; + if (sRoulette->minBet == 1) + sRoulette->var23 = 1; else - gUnknown_0203AB88->var23 = 0; - gUnknown_0203AB88->var21 = 0; + sRoulette->var23 = 0; + sRoulette->var21 = 0; gTasks[r0].data[1] = 32; - gTasks[r0].func = sub_81410FC; + gTasks[r0].func = Task_SlideGridOffscreen; } -static void sub_8140FC4(u8 taskId) +static void Task_PlaceBet(u8 taskId) { - gUnknown_0203AB88->var1B[gUnknown_0203AB88->var1A_0] = gTasks[taskId].data[4]; - gTasks[taskId].data[2] = sub_8142758(gUnknown_0203AB88->var1B[gUnknown_0203AB88->var1A_0]); - sub_81436D0(gUnknown_0203AB88->var1B[gUnknown_0203AB88->var1A_0]); - if ((gTasks[taskId].data[13] -= gUnknown_0203AB88->var19) < 0) - gTasks[taskId].data[13] = 0; - sub_8143514(gTasks[taskId].data[13]); + sRoulette->betSelection[sRoulette->curBallNum] = gTasks[taskId].tSelectionId; + gTasks[taskId].tMultiplier = GetMultiplier(sRoulette->betSelection[sRoulette->curBallNum]); + SetMultiplierSprite(sRoulette->betSelection[sRoulette->curBallNum]); + if ((gTasks[taskId].tCoins -= sRoulette->minBet) < 0) + gTasks[taskId].tCoins = 0; + SetCreditDigits(gTasks[taskId].tCoins); gTasks[taskId].func = sub_8140F6C; } -static void sub_8141040(u8 taskId) +static void Task_HandleBetGridInput(u8 taskId) { - sub_8140D6C(taskId); + ProcessBetGridInput(taskId); + // Flash selection rect switch (gTasks[taskId].data[1]) { case 0: - sub_81409B8(gTasks[taskId].data[4]); + UpdateGridSelectionRect(gTasks[taskId].tSelectionId); gTasks[taskId].data[1]++; break; case 30: - sub_81409B8(0); + UpdateGridSelectionRect(SELECTION_NONE); gTasks[taskId].data[1]++; break; case 59: @@ -1256,83 +1434,78 @@ static void sub_8141040(u8 taskId) gTasks[taskId].data[1]++; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { - if ((gUnknown_0203AB88->var08 & gUnknown_085B6154[gTasks[taskId].data[4]].var08)) + if ((sRoulette->hitFlags & sGridSelections[gTasks[taskId].tSelectionId].flag)) + { + // Ball has already landed on this space PlaySE(SE_BOO); + } else { m4aSongNumStart(SE_REGI); - gTasks[taskId].func = sub_8140FC4; + gTasks[taskId].func = Task_PlaceBet; } } } -static void sub_81410FC(u8 taskId) +static void Task_SlideGridOffscreen(u8 taskId) { if (gTasks[taskId].data[1]-- > 0) { if (gTasks[taskId].data[1] > 2) gSpriteCoordOffsetX += 2; - if ((gUnknown_0203AB88->var26 += 4) == 104) - gSprites[gUnknown_0203AB88->var3C[25]].callback = &SpriteCallbackDummy; + if ((sRoulette->var26 += 4) == 104) + gSprites[sRoulette->spriteIds[SPR_MULTIPLIER]].callback = &SpriteCallbackDummy; } else { - sub_8142E70(1, -1); - sub_8143038(1, -1); - gTasks[taskId].func = sub_8141344; + ShowHideGridIcons(TRUE, -1); + ShowHideGridBalls(TRUE, -1); + gTasks[taskId].func = Task_RollBall; gTasks[taskId].data[1] = 0; } } static u8 sub_814118C(u16 r0, u16 r1) { - switch (gUnknown_0203AB88->var02) + switch (sRoulette->partySpeciesFlags) { - case 1: // SHROOMISH - case 2: // TAILLOW + case HAS_SHROOMISH: + case HAS_TAILLOW: // one of the two is in party if (gLocalTime.hours > 3 && gLocalTime.hours < 10) { if (r0 < 12 || (r1 & 1)) - { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02 / 2; - } + return gUnknown_085B6348[sRoulette->tableId].var02 / 2; else - { return 1; - } } - else if (!(r1 & 0x3)) + else if (!(r1 & 0x3)) { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02 / 2; + return gUnknown_085B6348[sRoulette->tableId].var02 / 2; } - else + else { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02; + return gUnknown_085B6348[sRoulette->tableId].var02; } break; - case 3: + case HAS_SHROOMISH | HAS_TAILLOW: // both are in party if (gLocalTime.hours > 3 && gLocalTime.hours < 11) { if (r0 < 6 || (r1 & 1)) - { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02 / 2; - } + return gUnknown_085B6348[sRoulette->tableId].var02 / 2; else - { return 1; - } } - else if ((r1 & 1) && r0 > 6) + else if ((r1 & 1) && r0 > 6) { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02 / 4; + return gUnknown_085B6348[sRoulette->tableId].var02 / 4; } - else + else { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02 / 2; + return gUnknown_085B6348[sRoulette->tableId].var02 / 2; } break; case 0: @@ -1341,45 +1514,33 @@ static u8 sub_814118C(u16 r0, u16 r1) if (gLocalTime.hours > 3 && gLocalTime.hours < 10) { if (!(r1 & 3)) - { return 1; - } else - { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02 / 2; - } + return gUnknown_085B6348[sRoulette->tableId].var02 / 2; } else if (!(r1 & 3)) { if (r0 > 12) - { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02 / 2; - } + return gUnknown_085B6348[sRoulette->tableId].var02 / 2; else - { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02; - } + return gUnknown_085B6348[sRoulette->tableId].var02; } else if (r1 & 0x8000) { if (r0 > 12) - { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02; - } + return gUnknown_085B6348[sRoulette->tableId].var02; else - { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var01; - } + return gUnknown_085B6348[sRoulette->tableId].var01; } else { - return gUnknown_085B6348[gUnknown_0203AB88->var04_0].var01 * 2; + return gUnknown_085B6348[sRoulette->tableId].var01 * 2; } break; } } -static void sub_8141344(u8 taskId) +static void Task_RollBall(u8 taskId) { u8 randf; s8 randfinal; @@ -1391,8 +1552,8 @@ static void sub_8141344(u8 taskId) rand = Random(); randmod = rand % 100; - gUnknown_0203AB88->var7C = gTasks[taskId].data[6]; - gUnknown_0203AB88->var7D = gUnknown_0203AB88->var7E = gUnknown_0203AB88->var7F = g; + sRoulette->var7C = gTasks[taskId].tBallNum; + sRoulette->var7D = sRoulette->var7E = sRoulette->var7F = g; randf = sub_814118C(gTasks[taskId].data[8], rand); randfinal = (rand % randf) - (randf / 2); @@ -1406,88 +1567,88 @@ static void sub_8141344(u8 taskId) else r5 = (1 - r5) * 2; - gUnknown_0203AB88->var80 = g = gUnknown_085B6348[gUnknown_0203AB88->var04_0].var1A + randfinal; + sRoulette->var80 = g = gUnknown_085B6348[sRoulette->tableId].var1A + randfinal; g = S16TOPOSFLOAT(g) / 5.0f; - gUnknown_0203AB88->var82 = g * 3; - gUnknown_0203AB88->var86 = gUnknown_0203AB88->var84 = g; + sRoulette->var82 = g * 3; + sRoulette->var86 = sRoulette->var84 = g; - gUnknown_0203AB88->var88 = S16TOPOSFLOAT(angles[(rand & 1) + r5]); - gUnknown_0203AB88->var8C = S16TOPOSFLOAT(gUnknown_085B6348[gUnknown_0203AB88->var04_0].var18); - gUnknown_0203AB88->var90 = ((gUnknown_0203AB88->var8C * 0.5f) - gUnknown_0203AB88->var8C) / S16TOPOSFLOAT(gUnknown_0203AB88->var82); - gUnknown_0203AB88->var94 = 68.0f; - gUnknown_0203AB88->var9C = 0.0f; - gUnknown_0203AB88->var98 = -(8.0f / S16TOPOSFLOAT(gUnknown_0203AB88->var82)); - gUnknown_0203AB88->varA0 = 36.0f; - gTasks[taskId].func = sub_814155C; + sRoulette->var88 = S16TOPOSFLOAT(angles[(rand & 1) + r5]); + sRoulette->var8C = S16TOPOSFLOAT(gUnknown_085B6348[sRoulette->tableId].var18); + sRoulette->var90 = ((sRoulette->var8C * 0.5f) - sRoulette->var8C) / S16TOPOSFLOAT(sRoulette->var82); + sRoulette->var94 = 68.0f; + sRoulette->var9C = 0.0f; + sRoulette->var98 = -(8.0f / S16TOPOSFLOAT(sRoulette->var82)); + sRoulette->varA0 = 36.0f; + gTasks[taskId].func = Task_EndBallRoll; } -static void sub_814155C(u8 taskId) +static void Task_EndBallRoll(u8 taskId) { u8 index; - gUnknown_0203AB88->var03_7 = 1; - index = gUnknown_0203AB88->var3C[gUnknown_0203AB88->var7C]; - gUnknown_0203AB88->var38 = &gSprites[index]; - gUnknown_0203AB88->var38->callback = sub_81446AC; - gTasks[taskId].data[6]++; - gTasks[taskId].data[0x8]++; - sub_814372C(6 - gTasks[taskId].data[6]); + sRoulette->var03_7 = TRUE; + index = sRoulette->spriteIds[sRoulette->var7C]; + sRoulette->var38 = &gSprites[index]; + sRoulette->var38->callback = sub_81446AC; + gTasks[taskId].tBallNum++; + gTasks[taskId].data[8]++; + SetBallCounterNumLeft(BALLS_PER_ROUND - gTasks[taskId].tBallNum); m4aSongNumStart(SE_TAMAKORO); - gTasks[taskId].func = sub_81415D4; + gTasks[taskId].func = Task_RecordBallHit; } -static void sub_81415D4(u8 taskId) +static void Task_RecordBallHit(u8 taskId) { - if (gUnknown_0203AB88->var7D) + if (sRoulette->var7D) { - if (gUnknown_0203AB88->var03_5) + if (sRoulette->var03_5) { - if (gUnknown_0203AB88->var03_6) + if (sRoulette->var03_6) { - gUnknown_0203AB88->var03_6 = FALSE; - gUnknown_0203AB88->var03_5 = FALSE; + sRoulette->var03_6 = FALSE; + sRoulette->var03_5 = FALSE; } } else { if (!gTasks[taskId].data[1]) { - bool8 temp = sub_81421E8(sub_81420D0(taskId, gUnknown_0203AB88->var7E), gUnknown_0203AB88->var1B[gUnknown_0203AB88->var1A_0]); - gTasks[taskId].data[5] = temp; + bool8 temp = IsHitInBetSelection(RecordHit(taskId, sRoulette->var7E), sRoulette->betSelection[sRoulette->curBallNum]); + gTasks[taskId].tWonBet = temp; if (temp == TRUE) - sub_8151A48(&gUnknown_0203AB88->varB8, 0x1000); + sub_8151A48(&sRoulette->varB8, 0x1000); } if (gTasks[taskId].data[1] <= 60) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) gTasks[taskId].data[1] = 60; gTasks[taskId].data[1]++; } else { - sub_81424FC(gUnknown_0203AB88->var1B[gUnknown_0203AB88->var1A_0]); - sub_8142E70(0, gTasks[taskId].data[12]); - sub_8143038(0, gTasks[taskId].data[6] - 1); + DrawGridBackground(sRoulette->betSelection[sRoulette->curBallNum]); + ShowHideGridIcons(FALSE, gTasks[taskId].tWinningSquare); + ShowHideGridBalls(FALSE, gTasks[taskId].tBallNum - 1); gTasks[taskId].data[1] = 32; - gTasks[taskId].func = sub_81416D4; + gTasks[taskId].func = Task_SlideGridOnscreen; } } } } -static void sub_81416D4(u8 taskId) +static void Task_SlideGridOnscreen(u8 taskId) { if (gTasks[taskId].data[1]-- > 0) { if (gTasks[taskId].data[1] > 2) gSpriteCoordOffsetX -= 2; - if ((gUnknown_0203AB88->var26 -= 4) == 104) - gSprites[gUnknown_0203AB88->var3C[25]].callback = sub_814390C; + if ((sRoulette->var26 -= 4) == 104) + gSprites[sRoulette->spriteIds[SPR_MULTIPLIER]].callback = SpriteCB_GridSquare; } else { - sub_8143150(gTasks[taskId].data[12]); - if (gTasks[taskId].data[5] == 1) + ShowHideWinSlotCursor(gTasks[taskId].tWinningSquare); + if (gTasks[taskId].tWonBet == TRUE) gTasks[taskId].data[1] = 121; else gTasks[taskId].data[1] = 61; @@ -1502,95 +1663,96 @@ static void sub_8141778(u8 taskId) switch (gTasks[taskId].data[1] % 16) { case 8: - sub_8142E70(0, -1); - sub_8143038(0, -1); + ShowHideGridIcons(FALSE, -1); + ShowHideGridBalls(FALSE, -1); break; case 0: - sub_8142E70(0, gTasks[taskId].data[12]); - sub_8143038(0, gTasks[taskId].data[6] - 1); + ShowHideGridIcons(FALSE, gTasks[taskId].tWinningSquare); + ShowHideGridBalls(FALSE, gTasks[taskId].tBallNum - 1); break; } } else { - sub_8141F7C(taskId, sub_814189C, 30, 0); + StartTaskAfterDelayOrInput(taskId, Task_PrintSpinResult, 30, 0); } } -static void sub_8141800(u8 taskId) +static void Task_TryIncrementWins(u8 taskId) { - switch (gTasks[taskId].data[0x5]) + switch (gTasks[taskId].tWonBet) { - case 1: - case 2: + case TRUE: + case 2: // never happens if (IsFanfareTaskInactive()) { u32 wins = GetGameStat(GAME_STAT_CONSECUTIVE_ROULETTE_WINS); - if (wins < ++gTasks[taskId].data[11]) - SetGameStat(GAME_STAT_CONSECUTIVE_ROULETTE_WINS, gTasks[taskId].data[11]); - sub_8141F7C(taskId, sub_8141A18, 0xFFFF, 3); + if (wins < ++gTasks[taskId].tConsecutiveWins) + SetGameStat(GAME_STAT_CONSECUTIVE_ROULETTE_WINS, gTasks[taskId].tConsecutiveWins); + StartTaskAfterDelayOrInput(taskId, Task_PrintPayout, 0xFFFF, A_BUTTON | B_BUTTON); } break; - case 0: + case FALSE: default: if (!IsSEPlaying()) { - gTasks[taskId].data[11] = FALSE; - sub_8141F7C(taskId, sub_8141AC0, 0xFFFF, 3); + gTasks[taskId].tConsecutiveWins = 0; + StartTaskAfterDelayOrInput(taskId, Task_EndTurn, 0xFFFF, A_BUTTON | B_BUTTON); } break; } } -static void sub_814189C(u8 taskId) +static void Task_PrintSpinResult(u8 taskId) { - switch (gTasks[taskId].data[5]) + switch (gTasks[taskId].tWonBet) { - case 1: - case 2: - if (gTasks[taskId].data[2] == 12) + case TRUE: + case 2: // never happens + if (gTasks[taskId].tMultiplier == MAX_MULTIPLIER) { PlayFanfare(MUS_ME_B_BIG); - DrawStdWindowFrame(gUnknown_0203AB8C, FALSE); - AddTextPrinterParameterized(gUnknown_0203AB8C, 1, Roulette_Text_Jackpot, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(gUnknown_0203AB8C, 3); + DrawStdWindowFrame(sTextWindowId, FALSE); + AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_Jackpot, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(sTextWindowId, 3); } else { PlayFanfare(MUS_ME_B_SMALL); - DrawStdWindowFrame(gUnknown_0203AB8C, FALSE); - AddTextPrinterParameterized(gUnknown_0203AB8C, 1, Roulette_Text_ItsAHit, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(gUnknown_0203AB8C, 3); + DrawStdWindowFrame(sTextWindowId, FALSE); + AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_ItsAHit, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(sTextWindowId, 3); } break; - case 0: + case FALSE: default: m4aSongNumStart(SE_HAZURE); - DrawStdWindowFrame(gUnknown_0203AB8C, FALSE); - AddTextPrinterParameterized(gUnknown_0203AB8C, 1, Roulette_Text_NothingDoing, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(gUnknown_0203AB8C, 3); + DrawStdWindowFrame(sTextWindowId, FALSE); + AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_NothingDoing, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(sTextWindowId, 3); break; } gTasks[taskId].data[1] = 0; - gTasks[taskId].func = sub_8141800; + gTasks[taskId].func = Task_TryIncrementWins; } -static void sub_8141984(u8 taskId) +#define tPayout data[1] + +static void Task_GivePayout(u8 taskId) { - s32 r0 = gTasks[taskId].data[7]; - switch (r0) + switch (gTasks[taskId].data[7]) { case 0: - gTasks[taskId].data[13]++; + gTasks[taskId].tCoins++; m4aSongNumStart(SE_PIN); - sub_8143514(gTasks[taskId].data[13]); - if (gTasks[taskId].data[13] >= 9999) + SetCreditDigits(gTasks[taskId].tCoins); + if (gTasks[taskId].tCoins >= MAX_COINS) { - gTasks[taskId].data[1] = r0; + gTasks[taskId].tPayout = 0; } else { - gTasks[taskId].data[1]--; + gTasks[taskId].tPayout--; gTasks[taskId].data[7]++; } break; @@ -1602,117 +1764,123 @@ static void sub_8141984(u8 taskId) gTasks[taskId].data[7]++; break; } - if (gTasks[taskId].data[1] == 0) - sub_8141F7C(taskId, sub_8141AC0, 0xFFFF, 3); + if (gTasks[taskId].tPayout == 0) + StartTaskAfterDelayOrInput(taskId, Task_EndTurn, 0xFFFF, A_BUTTON | B_BUTTON); } -static void sub_8141A18(u8 taskId) +static void Task_PrintPayout(u8 taskId) { - ConvertIntToDecimalStringN(gStringVar1, (gUnknown_0203AB88->var19 * gTasks[taskId].data[2]), STR_CONV_MODE_LEFT_ALIGN, 2); + ConvertIntToDecimalStringN(gStringVar1, (sRoulette->minBet * gTasks[taskId].tMultiplier), STR_CONV_MODE_LEFT_ALIGN, 2); StringExpandPlaceholders(gStringVar4, Roulette_Text_YouveWonXCoins); - DrawStdWindowFrame(gUnknown_0203AB8C, FALSE); - AddTextPrinterParameterized(gUnknown_0203AB8C, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(gUnknown_0203AB8C, 3); - gTasks[taskId].data[1] = (gUnknown_0203AB88->var19 * gTasks[taskId].data[2]); + DrawStdWindowFrame(sTextWindowId, FALSE); + AddTextPrinterParameterized(sTextWindowId, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(sTextWindowId, 3); + gTasks[taskId].tPayout = (sRoulette->minBet * gTasks[taskId].tMultiplier); gTasks[taskId].data[7] = 0; - gTasks[taskId].func = sub_8141984; + gTasks[taskId].func = Task_GivePayout; } -static void sub_8141AC0(u8 taskId) +#undef tPayout + +static void Task_EndTurn(u8 taskId) { - sub_8151A9C(&gUnknown_0203AB88->varB8, 0xFFFF); - gUnknown_0203AB88->varB8.var04[13].var00_7 = gUnknown_0203AB88->varB8.var04[14].var00_7 = gUnknown_0203AB88->varB8.var04[15].var00_7 = 0; - gSprites[gUnknown_0203AB88->var3C[7 + gUnknown_085B6154[gTasks[taskId].data[12]].var00]].invisible = TRUE; - gTasks[taskId].func = sub_8141B58; + sub_8151A9C(&sRoulette->varB8, 0xFFFF); + sRoulette->varB8.var04[13].var00_7 = sRoulette->varB8.var04[14].var00_7 = sRoulette->varB8.var04[15].var00_7 = 0; + gSprites[sRoulette->spriteIds[SPR_BOARD_ICONS + sGridSelections[gTasks[taskId].tWinningSquare].var00]].invisible = TRUE; + gTasks[taskId].func = Task_TryPrintEndTurnMsg; } -static void sub_8141B58(u8 taskId) +static void Task_TryPrintEndTurnMsg(u8 taskId) { u8 i = 0; - gTasks[taskId].data[4] = i; - gUnknown_0203AB88->var1B[gUnknown_0203AB88->var1A_0] = 0; - sub_81424FC(0); - gSprites[gUnknown_0203AB88->var3C[48]].invisible = TRUE; - for (i = 0; i < 4; i++) + gTasks[taskId].tSelectionId = i; + sRoulette->betSelection[sRoulette->curBallNum] = SELECTION_NONE; + DrawGridBackground(SELECTION_NONE); + gSprites[sRoulette->spriteIds[SPR_WIN_SLOT_CURSOR]].invisible = TRUE; + for (i = 0; i < NUM_BOARD_POKES; i++) { - gSprites[gUnknown_0203AB88->var3C[i + 41]].oam.tileNum = - gSprites[gUnknown_0203AB88->var3C[i + 41]].sheetTileStart - + (*gSprites[gUnknown_0203AB88->var3C[i + 41]].anims)->type; + gSprites[sRoulette->spriteIds[i + SPR_POKE_HEADER_1]].oam.tileNum = + gSprites[sRoulette->spriteIds[i + SPR_POKE_HEADER_1]].sheetTileStart + + (*gSprites[sRoulette->spriteIds[i + SPR_POKE_HEADER_1]].anims)->type; } - if (gTasks[taskId].data[13] >= gUnknown_0203AB88->var19) + if (gTasks[taskId].tCoins >= sRoulette->minBet) { - if (gTasks[taskId].data[6] == 6) + if (gTasks[taskId].tBallNum == BALLS_PER_ROUND) { - DrawStdWindowFrame(gUnknown_0203AB8C, FALSE); - AddTextPrinterParameterized(gUnknown_0203AB8C, 1, Roulette_Text_BoardWillBeCleared, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(gUnknown_0203AB8C, 3); - sub_8141F7C(taskId, dp01t_12_3_battle_menu, 0xFFFF, 3); + // Reached Ball 6, clear board + DrawStdWindowFrame(sTextWindowId, FALSE); + AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_BoardWillBeCleared, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(sTextWindowId, 3); + StartTaskAfterDelayOrInput(taskId, Task_ClearBoard, 0xFFFF, A_BUTTON | B_BUTTON); } - else if (gTasks[taskId].data[13] == 9999) + else if (gTasks[taskId].tCoins == MAX_COINS) { - DrawStdWindowFrame(gUnknown_0203AB8C, FALSE); - AddTextPrinterParameterized(gUnknown_0203AB8C, 1, Roulette_Text_CoinCaseIsFull, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(gUnknown_0203AB8C, 3); - sub_8141F7C(taskId, sub_8140914, 0xFFFF, 0x3); + // Player maxed out coins + DrawStdWindowFrame(sTextWindowId, FALSE); + AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_CoinCaseIsFull, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(sTextWindowId, 3); + StartTaskAfterDelayOrInput(taskId, Task_AskKeepPlaying, 0xFFFF, A_BUTTON | B_BUTTON); } else { - gTasks[taskId].func = sub_8140914; + // No special msg, ask to continue + gTasks[taskId].func = Task_AskKeepPlaying; } } else { - DrawStdWindowFrame(gUnknown_0203AB8C, FALSE); - AddTextPrinterParameterized(gUnknown_0203AB8C, 1, Roulette_Text_NoCoinsLeft, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(gUnknown_0203AB8C, 3); - sub_8141F7C(taskId, sub_8140994, 0x3C, 0x3); + // Player out of coins + DrawStdWindowFrame(sTextWindowId, FALSE); + AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_NoCoinsLeft, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(sTextWindowId, 3); + StartTaskAfterDelayOrInput(taskId, Task_StopPlaying, 60, A_BUTTON | B_BUTTON); } } -static void dp01t_12_3_battle_menu(u8 taskId) +static void Task_ClearBoard(u8 taskId) { u8 i = 0; - gTasks[taskId].data[6] = 0; + gTasks[taskId].tBallNum = 0; sub_8141FF4(taskId); - sub_8142070(); - sub_8143A40(); - sub_81424FC(0); - sub_814372C(6); + ResetHits(); + HideBoardBalls(); + DrawGridBackground(SELECTION_NONE); + SetBallCounterNumLeft(BALLS_PER_ROUND); - for (i = 0; i < 12; i++) + for (i = 0; i < NUM_ROULETTE_SLOTS; i++) { - gSprites[gUnknown_0203AB88->var3C[i + 7]].invisible = FALSE; + gSprites[sRoulette->spriteIds[i + SPR_BOARD_ICONS]].invisible = FALSE; } - if (gTasks[taskId].data[13] == 9999) + if (gTasks[taskId].tCoins == MAX_COINS) { - DrawStdWindowFrame(gUnknown_0203AB8C, FALSE); - AddTextPrinterParameterized(gUnknown_0203AB8C, 1, Roulette_Text_CoinCaseIsFull, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(gUnknown_0203AB8C, 3); - sub_8141F7C(taskId, sub_8140914, 0xFFFF, 3); + DrawStdWindowFrame(sTextWindowId, FALSE); + AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_CoinCaseIsFull, 0, 1, TEXT_SPEED_FF, NULL); + CopyWindowToVram(sTextWindowId, 3); + StartTaskAfterDelayOrInput(taskId, Task_AskKeepPlaying, 0xFFFF, A_BUTTON | B_BUTTON); } else { - gTasks[taskId].func = sub_8140914; + gTasks[taskId].func = Task_AskKeepPlaying; } } -static void sub_8141DE4(u8 taskId) +static void ExitRoulette(u8 taskId) { - sub_8151A9C(&gUnknown_0203AB88->varB8, 0xFFFF); - sub_8151678(&gUnknown_0203AB88->varB8); - SetCoins(gTasks[taskId].data[13]); - if (GetCoins() < gUnknown_0203AB88->var19) + sub_8151A9C(&sRoulette->varB8, 0xFFFF); + sub_8151678(&sRoulette->varB8); + SetCoins(gTasks[taskId].tCoins); + if (GetCoins() < sRoulette->minBet) gSpecialVar_0x8004 = TRUE; else gSpecialVar_0x8004 = FALSE; AlertTVOfNewCoinTotal(GetCoins()); BeginHardwarePaletteFade(0xFF, 0, 0, 16, 0); - gTasks[taskId].func = sub_8141E7C; + gTasks[taskId].func = Task_ExitRoulette; } -static void sub_8141E7C(u8 taskId) // end roulette ? +static void Task_ExitRoulette(u8 taskId) { if (UpdatePaletteFade() == 0) { @@ -1726,184 +1894,201 @@ static void sub_8141E7C(u8 taskId) // end roulette ? FreeAllSpritePalettes(); ResetPaletteFade(); ResetSpriteData(); - sub_8140418(); + FreeRoulette(); gFieldCallback = FieldCB_ContinueScriptHandleMusic; SetMainCallback2(CB2_ReturnToField); DestroyTask(taskId); } } -static void sub_8141EF8(u8 taskId) +static void Task_WaitForNextTask(u8 taskId) { - if (gUnknown_0203AB88->varA8 == 0 || gMain.newKeys & gUnknown_0203AB88->varAA) + if (sRoulette->taskWaitDelay == 0 || JOY_NEW(sRoulette->taskWaitKey)) { - gTasks[taskId].func = gUnknown_0203AB88->varAC; - if (gUnknown_0203AB88->varAA > 0) + gTasks[taskId].func = sRoulette->nextTask; + if (sRoulette->taskWaitKey > 0) PlaySE(SE_SELECT); - gUnknown_0203AB88->varAC = NULL; - gUnknown_0203AB88->varAA = 0; - gUnknown_0203AB88->varA8 = 0; + sRoulette->nextTask = NULL; + sRoulette->taskWaitKey = 0; + sRoulette->taskWaitDelay = 0; } - if (gUnknown_0203AB88->varA8 != 0xFFFF) - gUnknown_0203AB88->varA8--; + if (sRoulette->taskWaitDelay != 0xFFFF) + sRoulette->taskWaitDelay--; } -static void sub_8141F7C(u8 taskId, TaskFunc r1, u16 r2, u16 r3) +static void StartTaskAfterDelayOrInput(u8 taskId, TaskFunc task, u16 delay, u16 key) { - gUnknown_0203AB88->varB4 = gTasks[taskId].func; - if (r1 == NULL) - r1 = gUnknown_0203AB88->varB4; - gUnknown_0203AB88->varAC = r1; - gUnknown_0203AB88->varA8 = r2; - if (r2 == 0xFFFF && r3 == 0) - gUnknown_0203AB88->varAA = 0xFFFF; + sRoulette->varB4 = gTasks[taskId].func; + if (task == NULL) + task = sRoulette->varB4; + sRoulette->nextTask = task; + sRoulette->taskWaitDelay = delay; + if (delay == 0xFFFF && key == 0) + sRoulette->taskWaitKey = 0xFFFF; else - gUnknown_0203AB88->varAA = r3; - gTasks[taskId].func = sub_8141EF8; + sRoulette->taskWaitKey = key; + gTasks[taskId].func = Task_WaitForNextTask; } static void sub_8141FF4(u8 taskId) { u8 i = 0; - gUnknown_0203AB88->var00 = i; - gUnknown_0203AB88->var03_7 = 0; - gUnknown_0203AB88->var03_5 = 0; - gUnknown_0203AB88->var03_6 = 0; - gUnknown_0203AB88->var03_0 = 0; - for (i = 0; i < 6; i++) - { - gUnknown_0203AB88->var1B[i] = 0; - } - gUnknown_0203AB88->var1A_0 = 0; + sRoulette->var00 = i; + sRoulette->var03_7 = FALSE; + sRoulette->var03_5 = FALSE; + sRoulette->var03_6 = FALSE; + sRoulette->useTaillow = FALSE; + + for (i = 0; i < BALLS_PER_ROUND; i++) + sRoulette->betSelection[i] = SELECTION_NONE; + + sRoulette->curBallNum = 0; gTasks[taskId].data[1] = 0; } -static void sub_8142070(void) +static void ResetHits(void) { u8 i; - gUnknown_0203AB88->var08 = 0; - for (i = 0; i < 6; i++) - { - gUnknown_0203AB88->var0C[i] = 0; - } - for (i = 0; i < 4; i++) - { - gUnknown_0203AB88->var12[i] = 0; - } - for (i = 0; i < 3; i++) - { - gUnknown_0203AB88->var16[i] = 0; - } - sub_8143038(1, -1); + sRoulette->hitFlags = 0; + + for (i = 0; i < BALLS_PER_ROUND; i++) + sRoulette->hitSquares[i] = 0; + + for (i = 0; i < NUM_BOARD_POKES; i++) + sRoulette->pokeHits[i] = 0; + + for (i = 0; i < NUM_BOARD_COLORS; i++) + sRoulette->colorHits[i] = 0; + + ShowHideGridBalls(TRUE, -1); } -static u8 sub_81420D0(u8 taskId, u8 r1) +static u8 RecordHit(u8 taskId, u8 slotId) { - u8 i; - u8 z; - u32 t0[4] = {0x10842, 0x21084, 0x42108, 0x84210}; - u32 t1[3] = {0x3E0, 0x7C00, 0xF8000}; + u8 i, j; + u32 columnFlags[NUM_BOARD_POKES] = { + F_WYNAUT_COL | F_ORANGE_WYNAUT | F_GREEN_WYNAUT | F_PURPLE_WYNAUT, + F_AZURILL_COL | F_ORANGE_AZURILL | F_GREEN_AZURILL | F_PURPLE_AZURILL, + F_SKITTY_COL | F_ORANGE_SKITTY | F_GREEN_SKITTY | F_PURPLE_SKITTY, + F_MAKUHITA_COL | F_ORANGE_MAKUHITA | F_GREEN_MAKUHITA | F_PURPLE_MAKUHITA + }; + u32 rowFlags[NUM_BOARD_COLORS] = { + F_ORANGE_ROW | F_ORANGE_WYNAUT | F_ORANGE_AZURILL | F_ORANGE_SKITTY | F_ORANGE_MAKUHITA, + F_GREEN_ROW | F_GREEN_WYNAUT | F_GREEN_AZURILL | F_GREEN_SKITTY | F_GREEN_MAKUHITA, + F_PURPLE_ROW | F_PURPLE_WYNAUT | F_PURPLE_AZURILL | F_PURPLE_SKITTY | F_PURPLE_MAKUHITA + }; - if (r1 > 11) + if (slotId >= NUM_ROULETTE_SLOTS) return 0; - gUnknown_0203AB88->var0C[gTasks[taskId].data[6] - 1] = gUnknown_085B62E4[r1].var02; - gTasks[taskId].data[12] = gUnknown_085B62E4[r1].var02; - gUnknown_0203AB88->var08 |= gUnknown_085B62E4[r1].var04; - for (i = 0; i < 4; i++) + sRoulette->hitSquares[gTasks[taskId].tBallNum - 1] = sRouletteSlots[slotId].gridSquare; + gTasks[taskId].tWinningSquare = sRouletteSlots[slotId].gridSquare; + sRoulette->hitFlags |= sRouletteSlots[slotId].flag; + for (i = 0; i < NUM_BOARD_POKES; i++) { - if (gUnknown_085B62E4[r1].var04 & t0[i]) - gUnknown_0203AB88->var12[i]++; - if (gUnknown_0203AB88->var12[i] > 2) - gUnknown_0203AB88->var08 |= t0[i]; + if (sRouletteSlots[slotId].flag & columnFlags[i]) + sRoulette->pokeHits[i]++; + // If hit every color of a poke, set column completed + if (sRoulette->pokeHits[i] >= NUM_BOARD_COLORS) + sRoulette->hitFlags |= columnFlags[i]; } - for (z = 0; z < 3; z++) + for (j = 0; j < NUM_BOARD_COLORS; j++) { - if (gUnknown_085B62E4[r1].var04 & t1[z]) - gUnknown_0203AB88->var16[z]++; - if (gUnknown_0203AB88->var16[z] > 3) - gUnknown_0203AB88->var08 |= t1[z]; + if (sRouletteSlots[slotId].flag & rowFlags[j]) + sRoulette->colorHits[j]++; + // If hit every poke of a color, set row completed + if (sRoulette->colorHits[j] >= NUM_BOARD_POKES) + sRoulette->hitFlags |= rowFlags[j]; } - return gUnknown_085B62E4[r1].var02; + return sRouletteSlots[slotId].gridSquare; } -static bool8 sub_81421E8(u8 r0, u8 r1) +static bool8 IsHitInBetSelection(u8 gridSquare, u8 betSelection) { - u8 t = r0; - if (--r0 < 19) + u8 hit = gridSquare; + if (--gridSquare < NUM_GRID_SELECTIONS) { - switch (r1) + switch (betSelection) { - case 0: - return 3; - case 1 ... 4: - if (t == r1 + 5 || t == r1 + 10 || t == r1 + 15) + case SELECTION_NONE: + return 3; // should never happen, player must place bet + case COL_WYNAUT: + case COL_AZURILL: + case COL_SKITTY: + case COL_MAKUHITA: + if (hit == betSelection + ROW_ORANGE + || hit == betSelection + ROW_GREEN + || hit == betSelection + ROW_PURPLE) return TRUE; break; - case 5: - case 10: - case 15: - if (t >= (r1 + 1) && t <= (r1 + 4)) + case ROW_ORANGE: + case ROW_GREEN: + case ROW_PURPLE: + if (hit >= (betSelection + COL_WYNAUT) + && hit <= (betSelection + COL_MAKUHITA)) return TRUE; break; + // Individual square default: - if (t == r1) + if (hit == betSelection) return TRUE; } } return FALSE; } -static void sub_8142284(u8 r0) +static void FlashSelectionOnWheel(u8 selectionId) { - u16 var0 = 0; u8 var2; u16 var3; u8 i; - switch (r0) + switch (selectionId) { - case 5: - case 10: - case 15: - for (i = (r0 + 1); i < (r0 + 5); i++) + case ROW_ORANGE: + case ROW_GREEN: + case ROW_PURPLE: + for (i = (selectionId + 1); i < (selectionId + 5); i++) { - if (!(gUnknown_0203AB88->var08 & gUnknown_085B6154[i].var08)) - var0 |= gUnknown_085B6154[i].var10; + if (!(sRoulette->hitFlags & sGridSelections[i].flag)) + var0 |= sGridSelections[i].var10; } - sub_8151A48(&gUnknown_0203AB88->varB8, var0 &= 0xDFFF); + sub_8151A48(&sRoulette->varB8, var0 &= 0xDFFF); break; default: { struct UnkStruct1 var1[3]; memcpy(var1, gUnknown_085B63F0, sizeof(var1)); - if (r0 > 0 && r0 < 5) + if (selectionId >= COL_WYNAUT && selectionId <= COL_MAKUHITA) var2 = 3; else var2 = 1; - var3 = r0 / 5 - 1; - switch (r0 % 5) + + var3 = selectionId / 5 - 1; + switch (GET_COL(selectionId)) { - case 1: - var3 = gSprites[gUnknown_0203AB88->var3C[7]].oam.paletteNum * 16; - break; - case 2: - var3 = gSprites[gUnknown_0203AB88->var3C[8]].oam.paletteNum * 16; - break; - case 3: - var3 = gSprites[gUnknown_0203AB88->var3C[9]].oam.paletteNum * 16; - break; - case 4: - var3 = gSprites[gUnknown_0203AB88->var3C[10]].oam.paletteNum * 16; - break; + // The specific color of the poke it references doesn't matter, because the icons themelves all share a palette + // So it just uses the first sprite ID of each + case COL_WYNAUT: + var3 = gSprites[sRoulette->spriteIds[SPR_BOARD_ICON_ORANGE_WYNAUT]].oam.paletteNum * 16; + break; + case COL_AZURILL: + var3 = gSprites[sRoulette->spriteIds[SPR_BOARD_ICON_GREEN_AZURILL]].oam.paletteNum * 16; + break; + case COL_SKITTY: + var3 = gSprites[sRoulette->spriteIds[SPR_BOARD_ICON_PURPLE_SKITTY]].oam.paletteNum * 16; + break; + case COL_MAKUHITA: + var3 = gSprites[sRoulette->spriteIds[SPR_BOARD_ICON_ORANGE_MAKUHITA]].oam.paletteNum * 16; + break; } if (var2 == 1) { - if (!(gUnknown_0203AB88->var08 & gUnknown_085B6154[r0].var08)) + if (!(sRoulette->hitFlags & sGridSelections[selectionId].flag)) { - var1[r0 / 5 - 1].var02 += var3; - sub_815168C(&gUnknown_0203AB88->varB8, 13, &var1[r0 / 5 - 1]); + var1[selectionId / 5 - 1].var02 += var3; + sub_815168C(&sRoulette->varB8, 13, &var1[selectionId / 5 - 1]); } else { @@ -1914,26 +2099,26 @@ static void sub_8142284(u8 r0) { for (i = 0; i < 3; i++) { - u8 var4 = i * 5 + r0 + 5; - if (!(gUnknown_0203AB88->var08 & gUnknown_085B6154[var4].var08)) + u8 var4 = i * 5 + selectionId + 5; + if (!(sRoulette->hitFlags & sGridSelections[var4].flag)) { var1[var4 / 5 - 1].var02 += var3; - sub_815168C(&gUnknown_0203AB88->varB8, i + 13, &var1[var4 / 5 - 1]); + sub_815168C(&sRoulette->varB8, i + 13, &var1[var4 / 5 - 1]); if (var2 == 3) - var0 = gUnknown_085B6154[var4].var10; + var0 = sGridSelections[var4].var10; var2--; } } if (var2 != 2) var0 = 0; } - sub_8151A48(&gUnknown_0203AB88->varB8, var0 |= gUnknown_085B6154[r0].var10); + sub_8151A48(&sRoulette->varB8, var0 |= sGridSelections[selectionId].var10); break; } } } -static void sub_81424FC(u8 r0) +static void DrawGridBackground(u8 selectionId) { vu8 i; vu8 z; @@ -1942,69 +2127,77 @@ static void sub_81424FC(u8 r0) vu8 var0; u8 v[5]; u8 l; - gUnknown_0203AB88->var2A = 1; - sub_8142E70(0, 0); - sub_8152058(gUnknown_0203AB88->tilemapBuffers[2], gUnknown_0203AB88->unk_397C, 14, 7, 16, 13); - switch (r0) + sRoulette->var2A = 1; + ShowHideGridIcons(FALSE, 0); + SetGridSelectionRect(sRoulette->tilemapBuffers[2], sRoulette->unk_397C, 14, 7, 16, 13); + switch (selectionId) { - case 0: + case SELECTION_NONE: return; - case 1 ... 4: + case COL_WYNAUT: + case COL_AZURILL: + case COL_SKITTY: + case COL_MAKUHITA: l = 4; for (i = 0; i < l; i++) { - v[i] = i * 5 + r0; + v[i] = i * 5 + selectionId; } break; - case 5: - case 10: - case 15: + case ROW_ORANGE: + case ROW_GREEN: + case ROW_PURPLE: l = 5; for (i = 0; i < l; i++) { - v[i] = i + r0; + v[i] = i + selectionId; } break; + // Individual square default: l = 1; - v[0] = r0; + v[0] = selectionId; } for (i = 0; i < l; i++) { - var0 = gUnknown_085B6154[v[i]].var06; - var1 = gUnknown_085B6154[v[i]].var03; + var0 = sGridSelections[v[i]].var06; + var1 = sGridSelections[v[i]].x; for (z = 0; z < 3; z++) { - var2 = (gUnknown_085B6154[v[i]].var04 + z) * 32; - gUnknown_0203AB88->tilemapBuffers[2][var1 + var2 + 0] = gUnknown_0203AB88->unk_397C[(var0 + z) * 3 + 208]; - gUnknown_0203AB88->tilemapBuffers[2][var1 + var2 + 1] = gUnknown_0203AB88->unk_397C[(var0 + z) * 3 + 209]; - gUnknown_0203AB88->tilemapBuffers[2][var1 + var2 + 2] = gUnknown_0203AB88->unk_397C[(var0 + z) * 3 + 210]; + var2 = (sGridSelections[v[i]].y + z) * 32; + sRoulette->tilemapBuffers[2][var1 + var2 + 0] = sRoulette->unk_397C[(var0 + z) * 3 + 208]; + sRoulette->tilemapBuffers[2][var1 + var2 + 1] = sRoulette->unk_397C[(var0 + z) * 3 + 209]; + sRoulette->tilemapBuffers[2][var1 + var2 + 2] = sRoulette->unk_397C[(var0 + z) * 3 + 210]; } } } -static u8 sub_8142758(u8 r0) +static u8 GetMultiplier(u8 selectionId) { - u8 var0[5] = {0, 3, 4, 6, 12}; + u8 multipliers[5] = {0, 3, 4, 6, 12}; - if (r0 > 19) - r0 = 0; - switch (gUnknown_085B6154[r0].var01_0) + if (selectionId > NUM_GRID_SELECTIONS) + selectionId = 0; + + switch (sGridSelections[selectionId].baseMultiplier) { - case 3: - r0 = r0 / 5 - 1; - if (gUnknown_0203AB88->var16[r0] > 3) + case NUM_BOARD_COLORS: + selectionId = selectionId / 5 - 1; + // If already hit all pokes of this color, multiplier is 0 + if (sRoulette->colorHits[selectionId] >= NUM_BOARD_POKES) return 0; - return var0[gUnknown_0203AB88->var16[r0] + 1]; - case 4: - r0--; - if (gUnknown_0203AB88->var12[r0] > 2) + return multipliers[sRoulette->colorHits[selectionId] + 1]; + case NUM_BOARD_POKES: + selectionId--; + // If already hit all colors of this poke, multiplier is 0 + if (sRoulette->pokeHits[selectionId] >= NUM_BOARD_COLORS) return 0; - return var0[gUnknown_0203AB88->var12[r0] + 2]; - case 12: - if (gUnknown_0203AB88->var08 & gUnknown_085B6154[r0].var08) + return multipliers[sRoulette->pokeHits[selectionId] + 2]; + case NUM_ROULETTE_SLOTS: + // If square has been hit already, multiplier is 0 + if (sRoulette->hitFlags & sGridSelections[selectionId].flag) return 0; - return var0[4]; + return multipliers[4]; } return 0; } @@ -2013,59 +2206,59 @@ static void sub_8142814(void) { s32 x1; s32 x2; - SetGpuReg(REG_OFFSET_BG2PA, gUnknown_0203AB88->var2C.a); - SetGpuReg(REG_OFFSET_BG2PB, gUnknown_0203AB88->var2C.b); - SetGpuReg(REG_OFFSET_BG2PC, gUnknown_0203AB88->var2C.c); - SetGpuReg(REG_OFFSET_BG2PD, gUnknown_0203AB88->var2C.d); - x1 = 0x7400 - gUnknown_0203AB88->var2C.a * (gSpriteCoordOffsetX + 116) - - gUnknown_0203AB88->var2C.b * (gSpriteCoordOffsetY + 80); - x2 = 0x5400 - gUnknown_0203AB88->var2C.c * (gSpriteCoordOffsetX + 116) - - gUnknown_0203AB88->var2C.d * (gSpriteCoordOffsetY + 80); + SetGpuReg(REG_OFFSET_BG2PA, sRoulette->var2C.a); + SetGpuReg(REG_OFFSET_BG2PB, sRoulette->var2C.b); + SetGpuReg(REG_OFFSET_BG2PC, sRoulette->var2C.c); + SetGpuReg(REG_OFFSET_BG2PD, sRoulette->var2C.d); + x1 = 0x7400 - sRoulette->var2C.a * (gSpriteCoordOffsetX + 116) + - sRoulette->var2C.b * (gSpriteCoordOffsetY + 80); + x2 = 0x5400 - sRoulette->var2C.c * (gSpriteCoordOffsetX + 116) + - sRoulette->var2C.d * (gSpriteCoordOffsetY + 80); SetGpuReg(REG_OFFSET_BG2X_L, x1); SetGpuReg(REG_OFFSET_BG2X_H, (x1 & 0x0fff0000) >> 16); SetGpuReg(REG_OFFSET_BG2Y_L, x2); SetGpuReg(REG_OFFSET_BG2Y_H, (x2 & 0x0fff0000) >> 16); } -static const u8 sFiller_085B644D[3] = {}; -static const u16 RouletteSpritePalette_01[] = INCBIN_U16("graphics/roulette/shadow.gbapal"); -static const u16 RouletteSpritePalette_02[] = INCBIN_U16("graphics/roulette/ball.gbapal"); -static const u16 RouletteSpritePalette_03[] = INCBIN_U16("graphics/roulette/ball_counter.gbapal"); -static const u16 RouletteSpritePalette_04[] = INCBIN_U16("graphics/roulette/cursor.gbapal"); -static const u16 RouletteSpritePalette_05[] = INCBIN_U16("graphics/roulette/credit.gbapal"); -static const u16 RouletteSpritePalette_06[] = INCBIN_U16("graphics/roulette/shroomish.gbapal"); -static const u16 RouletteSpritePalette_07[] = INCBIN_U16("graphics/roulette/tailow.gbapal"); -static const u16 RouletteSpritePalette_08[] = INCBIN_U16("graphics/roulette/poke_icons.gbapal"); -static const u16 RouletteSpritePalette_09[] = INCBIN_U16("graphics/roulette/wynaut.gbapal"); -static const u16 RouletteSpritePalette_10[] = INCBIN_U16("graphics/roulette/azurill.gbapal"); -static const u16 RouletteSpritePalette_11[] = INCBIN_U16("graphics/roulette/skitty.gbapal"); -static const u16 RouletteSpritePalette_12[] = INCBIN_U16("graphics/roulette/makuhita.gbapal"); -static const u16 RouletteSpritePalette_13[] = INCBIN_U16("graphics/roulette/85B65D0.gbapal"); -static const u16 RouletteSpritePalette_14[] = INCBIN_U16("graphics/roulette/85B65F0.gbapal"); -static const u16 RouletteSpritePalette_15[] = INCBIN_U16("graphics/roulette/85B6610.gbapal"); -static const u16 RouletteSpritePalette_16[] = INCBIN_U16("graphics/roulette/85B6630.gbapal"); -static const u32 gUnknown_085B6650[] = INCBIN_U32("graphics/roulette/ball.4bpp.lz"); -static const u32 RouletteBallCounterTiles[] = INCBIN_U32("graphics/roulette/ball_counter.4bpp.lz"); -static const u32 gUnknown_085B67FC[] = INCBIN_U32("graphics/roulette/roulette_tilt.4bpp.lz"); -static const u32 RoulettePokeIconsTiles[] = INCBIN_U32("graphics/roulette/poke_icons.4bpp.lz"); -static const u32 RoulettePokeIcons2Tiles[] = INCBIN_U32("graphics/roulette/poke_icons2.4bpp.lz"); -static const u32 gUnknown_085B7290[] = INCBIN_U32("graphics/roulette/shadow.4bpp.lz"); -static const u32 RouletteCursorTiles[] = INCBIN_U32("graphics/roulette/cursor.4bpp.lz"); +static const u8 sFiller[3] = {}; +static const u16 sShadow_Pal[] = INCBIN_U16("graphics/roulette/shadow.gbapal"); +static const u16 sBall_Pal[] = INCBIN_U16("graphics/roulette/ball.gbapal"); +static const u16 sBallCounter_Pal[] = INCBIN_U16("graphics/roulette/ball_counter.gbapal"); +static const u16 sCursor_Pal[] = INCBIN_U16("graphics/roulette/cursor.gbapal"); +static const u16 sCredit_Pal[] = INCBIN_U16("graphics/roulette/credit.gbapal"); +static const u16 sShroomish_Pal[] = INCBIN_U16("graphics/roulette/shroomish.gbapal"); +static const u16 sTaillow_Pal[] = INCBIN_U16("graphics/roulette/tailow.gbapal"); +static const u16 sGridIcons_Pal[] = INCBIN_U16("graphics/roulette/grid_icons.gbapal"); +static const u16 sWynaut_Pal[] = INCBIN_U16("graphics/roulette/wynaut.gbapal"); +static const u16 sAzurill_Pal[] = INCBIN_U16("graphics/roulette/azurill.gbapal"); +static const u16 sSkitty_Pal[] = INCBIN_U16("graphics/roulette/skitty.gbapal"); +static const u16 sMakuhita_Pal[] = INCBIN_U16("graphics/roulette/makuhita.gbapal"); +static const u16 sUnused1_Pal[] = INCBIN_U16("graphics/roulette/unused_1.gbapal"); +static const u16 sUnused2_Pal[] = INCBIN_U16("graphics/roulette/unused_2.gbapal"); +static const u16 sUnused3_Pal[] = INCBIN_U16("graphics/roulette/unused_3.gbapal"); +static const u16 sUnused4_Pal[] = INCBIN_U16("graphics/roulette/unused_4.gbapal"); +static const u32 sBall_Gfx[] = INCBIN_U32("graphics/roulette/ball.4bpp.lz"); +static const u32 sBallCounter_Gfx[] = INCBIN_U32("graphics/roulette/ball_counter.4bpp.lz"); +static const u32 sShroomishTaillow_Gfx[] = INCBIN_U32("graphics/roulette/roulette_tilt.4bpp.lz"); +static const u32 sGridIcons_Gfx[] = INCBIN_U32("graphics/roulette/grid_icons.4bpp.lz"); +static const u32 sBoardIcons_Gfx[] = INCBIN_U32("graphics/roulette/board_icons.4bpp.lz"); +static const u32 sShadow_Gfx[] = INCBIN_U32("graphics/roulette/shadow.4bpp.lz"); +static const u32 sCursor_Gfx[] = INCBIN_U32("graphics/roulette/cursor.4bpp.lz"); -static const struct SpritePalette gUnknown_085B7384[] = +static const struct SpritePalette sSpritePalettes[] = { - { .data = RouletteSpritePalette_01, .tag = 1 }, - { .data = RouletteSpritePalette_02, .tag = 2 }, - { .data = RouletteSpritePalette_03, .tag = 3 }, - { .data = RouletteSpritePalette_04, .tag = 4 }, - { .data = RouletteSpritePalette_05, .tag = 5 }, - { .data = RouletteSpritePalette_06, .tag = 6 }, - { .data = RouletteSpritePalette_07, .tag = 7 }, - { .data = RouletteSpritePalette_08, .tag = 8 }, - { .data = RouletteSpritePalette_09, .tag = 9 }, - { .data = RouletteSpritePalette_10, .tag = 10 }, - { .data = RouletteSpritePalette_11, .tag = 11 }, - { .data = RouletteSpritePalette_12, .tag = 12 }, + { .data = sShadow_Pal, .tag = PALTAG_SHADOW }, + { .data = sBall_Pal, .tag = PALTAG_BALL }, + { .data = sBallCounter_Pal, .tag = PALTAG_BALL_COUNTER }, + { .data = sCursor_Pal, .tag = 4 }, + { .data = sCredit_Pal, .tag = PALTAG_INTERFACE }, + { .data = sShroomish_Pal, .tag = PALTAG_SHROOMISH }, + { .data = sTaillow_Pal, .tag = PALTAG_TAILLOW }, + { .data = sGridIcons_Pal, .tag = PALTAG_GRID_ICONS }, + { .data = sWynaut_Pal, .tag = PALTAG_WYNAUT }, + { .data = sAzurill_Pal, .tag = PALTAG_AZURILL }, + { .data = sSkitty_Pal, .tag = PALTAG_SKITTY }, + { .data = sMakuhita_Pal, .tag = PALTAG_MAKUHITA }, {} }; @@ -2078,7 +2271,7 @@ static const struct OamData gOamData_85B73EC = .priority = 1, }; -static const struct OamData gOamData_85B73F4 = +static const struct OamData sOam_GridIcon = { .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -2087,7 +2280,7 @@ static const struct OamData gOamData_85B73F4 = .priority = 1, }; -static const struct OamData gOamData_85B73FC = +static const struct OamData sOam_BoardIcon = { .y = 60, .affineMode = ST_OAM_AFFINE_DOUBLE, @@ -2097,35 +2290,35 @@ static const struct OamData gOamData_85B73FC = .priority = 2, }; -static const union AnimCmd gSpriteAnim_85B7404[] = +static const union AnimCmd sAffineAnim_Unused1[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_END }; -static const union AnimCmd *const gSpriteAnimTable_85B740C[] = +static const union AnimCmd *const sAffineAnims_Unused1[] = { - gSpriteAnim_85B7404 + sAffineAnim_Unused1 }; -static const union AffineAnimCmd gSpriteAffineAnim_85B7410[] = +static const union AffineAnimCmd sAffineAnim_Unused2[] = { AFFINEANIMCMD_END }; -static const union AffineAnimCmd *const gSpriteAffineAnimTable_85B7418[] = +static const union AffineAnimCmd *const sAffineAnims_Unused2[] = { - gSpriteAffineAnim_85B7410 + sAffineAnim_Unused2 }; -static const struct CompressedSpriteSheet gUnknown_085B741C = +static const struct CompressedSpriteSheet sSpriteSheet_BoardIcons = { - .data = RoulettePokeIcons2Tiles, + .data = sBoardIcons_Gfx, .size = 0xC00, - .tag = 0 + .tag = GFXTAG_BOARD_ICONS }; -static const union AnimCmd gSpriteAnim_85B7420[] = +static const union AnimCmd sAnim_BoardIcons[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_FRAME(32, 0), @@ -2142,81 +2335,81 @@ static const union AnimCmd gSpriteAnim_85B7420[] = ANIMCMD_END }; -static const union AnimCmd *const gSpriteAnimTable_85B7458[] = +static const union AnimCmd *const sAnim_BoardIcon_OrangeWynaut[] = { - &gSpriteAnim_85B7420[0] + &sAnim_BoardIcons[0] }; -static const union AnimCmd *const gSpriteAnimTable_85B745C[] = +static const union AnimCmd *const sAnim_BoardIcon_GreenAzurill[] = { - &gSpriteAnim_85B7420[1] + &sAnim_BoardIcons[1] }; -static const union AnimCmd *const gSpriteAnimTable_85B7460[] = +static const union AnimCmd *const sAnim_BoardIcon_PurpleSkitty[] = { - &gSpriteAnim_85B7420[2] + &sAnim_BoardIcons[2] }; -static const union AnimCmd *const gSpriteAnimTable_85B7464[] = +static const union AnimCmd *const sAnim_BoardIcon_OrangeMakuhita[] = { - &gSpriteAnim_85B7420[3] + &sAnim_BoardIcons[3] }; -static const union AnimCmd *const gSpriteAnimTable_85B7468[] = +static const union AnimCmd *const sAnim_BoardIcon_GreenWynaut[] = { - &gSpriteAnim_85B7420[4] + &sAnim_BoardIcons[4] }; -static const union AnimCmd *const gSpriteAnimTable_85B746C[] = +static const union AnimCmd *const sAnim_BoardIcon_PurpleAzurill[] = { - &gSpriteAnim_85B7420[5] + &sAnim_BoardIcons[5] }; -static const union AnimCmd *const gSpriteAnimTable_85B7470[] = +static const union AnimCmd *const sAnim_BoardIcon_OrangeSkitty[] = { - &gSpriteAnim_85B7420[6] + &sAnim_BoardIcons[6] }; -static const union AnimCmd *const gSpriteAnimTable_85B7474[] = +static const union AnimCmd *const sAnim_BoardIcon_GreenMakuhita[] = { - &gSpriteAnim_85B7420[7] + &sAnim_BoardIcons[7] }; -static const union AnimCmd *const gSpriteAnimTable_85B7478[] = +static const union AnimCmd *const sAnim_BoardIcon_PurpleWynaut[] = { - &gSpriteAnim_85B7420[8] + &sAnim_BoardIcons[8] }; -static const union AnimCmd *const gSpriteAnimTable_85B747C[] = +static const union AnimCmd *const sAnim_BoardIcon_OrangeAzurill[] = { - &gSpriteAnim_85B7420[9] + &sAnim_BoardIcons[9] }; -static const union AnimCmd *const gSpriteAnimTable_85B7480[] = +static const union AnimCmd *const sAnim_BoardIcon_GreenSkitty[] = { - &gSpriteAnim_85B7420[10] + &sAnim_BoardIcons[10] }; -static const union AnimCmd *const gSpriteAnimTable_85B7484[] = +static const union AnimCmd *const sAnim_BoardIcon_PurpleMakuhita[] = { - &gSpriteAnim_85B7420[11] + &sAnim_BoardIcons[11] }; -static const struct CompressedSpriteSheet gUnknown_085B7488 = +static const struct CompressedSpriteSheet sSpriteSheet_Headers = { - .data = gRouletteHeadersTiles, + .data = gRouletteHeaders_Gfx, .size = 0x1600, - .tag = 4 + .tag = GFXTAG_HEADERS }; -static const struct CompressedSpriteSheet gUnknown_085B7490 = +static const struct CompressedSpriteSheet sSpriteSheet_PokeIcons = { - .data = RoulettePokeIconsTiles, + .data = sGridIcons_Gfx, .size = 0x400, - .tag = 5 + .tag = GFXTAG_GRID_ICONS }; -static const union AnimCmd gSpriteAnim_85B7498[] = +static const union AnimCmd sAnim_Headers[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_FRAME(16, 0), @@ -2232,7 +2425,7 @@ static const union AnimCmd gSpriteAnim_85B7498[] = ANIMCMD_END }; -static const union AnimCmd gSpriteAnim_85B74C8[] = +static const union AnimCmd sAnim_GridIcons[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_FRAME(4, 0), @@ -2241,285 +2434,287 @@ static const union AnimCmd gSpriteAnim_85B74C8[] = ANIMCMD_END }; -static const union AnimCmd *const gSpriteAnimTable_85B74DC[] = +static const union AnimCmd *const sAnim_WynautHeader[] = { - &gSpriteAnim_85B7498[0] + &sAnim_Headers[0] }; -static const union AnimCmd *const gSpriteAnimTable_85B74E0[] = +static const union AnimCmd *const sAnim_AzurillHeader[] = { - &gSpriteAnim_85B7498[2] + &sAnim_Headers[2] }; -static const union AnimCmd *const gSpriteAnimTable_85B74E4[] = +static const union AnimCmd *const sAnim_SkittyHeader[] = { - &gSpriteAnim_85B7498[4] + &sAnim_Headers[4] }; -static const union AnimCmd *const gSpriteAnimTable_85B74E8[] = +static const union AnimCmd *const sAnim_MakuhitaHeader[] = { - &gSpriteAnim_85B7498[6] + &sAnim_Headers[6] }; -static const union AnimCmd *const gSpriteAnimTable_85B74EC[] = +static const union AnimCmd *const sAnim_OrangeHeader[] = { - &gSpriteAnim_85B7498[8] + &sAnim_Headers[8] }; -static const union AnimCmd *const gSpriteAnimTable_85B74F0[] = +static const union AnimCmd *const sAnim_GreenHeader[] = { - &gSpriteAnim_85B7498[9] + &sAnim_Headers[9] }; -static const union AnimCmd *const gSpriteAnimTable_85B74F4[] = +static const union AnimCmd *const sAnim_PurpleHeader[] = { - &gSpriteAnim_85B7498[10] + &sAnim_Headers[10] }; -static const union AnimCmd *const gSpriteAnimTable_85B74F8[] = +static const union AnimCmd *const sAnim_GridIcon_Wynaut[] = { - &gSpriteAnim_85B74C8[0] + &sAnim_GridIcons[0] }; -static const union AnimCmd *const gSpriteAnimTable_85B74FC[] = +static const union AnimCmd *const sAnim_GridIcon_Azurill[] = { - &gSpriteAnim_85B74C8[1] + &sAnim_GridIcons[1] }; -static const union AnimCmd *const gSpriteAnimTable_85B7500[] = +static const union AnimCmd *const sAnim_GridIcon_Skitty[] = { - &gSpriteAnim_85B74C8[2] + &sAnim_GridIcons[2] }; -static const union AnimCmd *const gSpriteAnimTable_85B7504[] = +static const union AnimCmd *const sAnim_GridIcon_Makuhita[] = { - &gSpriteAnim_85B74C8[3] + &sAnim_GridIcons[3] }; -static const struct SpriteTemplate gSpriteTemplate_85B7508[] = +static const struct SpriteTemplate sSpriteTemplates_PokeHeaders[NUM_BOARD_POKES] = { { - .tileTag = 4, - .paletteTag = 8, + .tileTag = GFXTAG_HEADERS, + .paletteTag = PALTAG_GRID_ICONS, .oam = &gOamData_85B73EC, - .anims = gSpriteAnimTable_85B74DC, + .anims = sAnim_WynautHeader, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare }, { - .tileTag = 4, - .paletteTag = 8, + .tileTag = GFXTAG_HEADERS, + .paletteTag = PALTAG_GRID_ICONS, .oam = &gOamData_85B73EC, - .anims = gSpriteAnimTable_85B74E0, + .anims = sAnim_AzurillHeader, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare }, { - .tileTag = 4, - .paletteTag = 8, + .tileTag = GFXTAG_HEADERS, + .paletteTag = PALTAG_GRID_ICONS, .oam = &gOamData_85B73EC, - .anims = gSpriteAnimTable_85B74E4, + .anims = sAnim_SkittyHeader, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare }, { - .tileTag = 4, - .paletteTag = 8, + .tileTag = GFXTAG_HEADERS, + .paletteTag = PALTAG_GRID_ICONS, .oam = &gOamData_85B73EC, - .anims = gSpriteAnimTable_85B74E8, + .anims = sAnim_MakuhitaHeader, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare } }; -static const struct SpriteTemplate gSpriteTemplate_85B7568[] = +static const struct SpriteTemplate sSpriteTemplates_ColorHeaders[NUM_BOARD_COLORS] = { { - .tileTag = 4, - .paletteTag = 8, + .tileTag = GFXTAG_HEADERS, + .paletteTag = PALTAG_GRID_ICONS, .oam = &gOamData_85B73EC, - .anims = gSpriteAnimTable_85B74EC, + .anims = sAnim_OrangeHeader, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare }, { - .tileTag = 4, - .paletteTag = 8, + .tileTag = GFXTAG_HEADERS, + .paletteTag = PALTAG_GRID_ICONS, .oam = &gOamData_85B73EC, - .anims = gSpriteAnimTable_85B74F0, + .anims = sAnim_GreenHeader, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare }, { - .tileTag = 4, - .paletteTag = 8, + .tileTag = GFXTAG_HEADERS, + .paletteTag = PALTAG_GRID_ICONS, .oam = &gOamData_85B73EC, - .anims = gSpriteAnimTable_85B74F4, + .anims = sAnim_PurpleHeader, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare } }; -static const struct SpriteTemplate gSpriteTemplate_85B75B0[] = +static const struct SpriteTemplate sSpriteTemplate_GridIcons[NUM_BOARD_POKES] = { { - .tileTag = 5, - .paletteTag = 8, - .oam = &gOamData_85B73F4, - .anims = gSpriteAnimTable_85B74F8, + .tileTag = GFXTAG_GRID_ICONS, + .paletteTag = PALTAG_GRID_ICONS, + .oam = &sOam_GridIcon, + .anims = sAnim_GridIcon_Wynaut, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare }, { - .tileTag = 5, - .paletteTag = 8, - .oam = &gOamData_85B73F4, - .anims = gSpriteAnimTable_85B74FC, + .tileTag = GFXTAG_GRID_ICONS, + .paletteTag = PALTAG_GRID_ICONS, + .oam = &sOam_GridIcon, + .anims = sAnim_GridIcon_Azurill, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare }, { - .tileTag = 5, - .paletteTag = 8, - .oam = &gOamData_85B73F4, - .anims = gSpriteAnimTable_85B7500, + .tileTag = GFXTAG_GRID_ICONS, + .paletteTag = PALTAG_GRID_ICONS, + .oam = &sOam_GridIcon, + .anims = sAnim_GridIcon_Skitty, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare }, { - .tileTag = 5, - .paletteTag = 8, - .oam = &gOamData_85B73F4, - .anims = gSpriteAnimTable_85B7504, + .tileTag = GFXTAG_GRID_ICONS, + .paletteTag = PALTAG_GRID_ICONS, + .oam = &sOam_GridIcon, + .anims = sAnim_GridIcon_Makuhita, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare } }; -static const struct SpriteTemplate gSpriteTemplate_85B7610[] = +// Board icons are listed clockwise starting from 1 oclock on the roulette board (with pokeball upside right) +// They go Wynaut -> Azurill -> Skitty -> Makuhita, and Orange -> Green -> Purple +static const struct SpriteTemplate sSpriteTemplates_BoardIcons[NUM_ROULETTE_SLOTS] = { { - .tileTag = 0, - .paletteTag = 9, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B7458, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_WYNAUT, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_OrangeWynaut, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon }, { - .tileTag = 0, - .paletteTag = 10, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B745C, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_AZURILL, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_GreenAzurill, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon }, { - .tileTag = 0, - .paletteTag = 11, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B7460, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_SKITTY, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_PurpleSkitty, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon }, { - .tileTag = 0, - .paletteTag = 12, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B7464, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_MAKUHITA, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_OrangeMakuhita, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon }, { - .tileTag = 0, - .paletteTag = 9, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B7468, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_WYNAUT, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_GreenWynaut, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon }, { - .tileTag = 0, - .paletteTag = 10, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B746C, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_AZURILL, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_PurpleAzurill, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon }, { - .tileTag = 0, - .paletteTag = 11, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B7470, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_SKITTY, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_OrangeSkitty, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon }, { - .tileTag = 0, - .paletteTag = 12, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B7474, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_MAKUHITA, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_GreenMakuhita, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon }, { - .tileTag = 0, - .paletteTag = 9, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B7478, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_WYNAUT, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_PurpleWynaut, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon }, { - .tileTag = 0, - .paletteTag = 10, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B747C, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_AZURILL, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_OrangeAzurill, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon }, { - .tileTag = 0, - .paletteTag = 11, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B7480, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_SKITTY, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_GreenSkitty, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon }, { - .tileTag = 0, - .paletteTag = 12, - .oam = &gOamData_85B73FC, - .anims = gSpriteAnimTable_85B7484, + .tileTag = GFXTAG_BOARD_ICONS, + .paletteTag = PALTAG_MAKUHITA, + .oam = &sOam_BoardIcon, + .anims = sAnim_BoardIcon_PurpleMakuhita, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8143280 + .callback = SpriteCB_BoardIcon } }; -static const struct OamData gOamData_85B7730 = +static const struct OamData sOam_Credit = { .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -2528,7 +2723,7 @@ static const struct OamData gOamData_85B7730 = .priority = 1, }; -static const struct OamData gOamData_85B7738 = +static const struct OamData sOam_CreditDigit = { .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -2537,7 +2732,7 @@ static const struct OamData gOamData_85B7738 = .priority = 1, }; -static const struct OamData gOamData_85B7740 = +static const struct OamData sOam_Multiplier = { .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -2546,7 +2741,7 @@ static const struct OamData gOamData_85B7740 = .priority = 1, }; -static const struct OamData gOamData_85B7748 = +static const struct OamData sOam_BallCounter = { .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -2555,32 +2750,32 @@ static const struct OamData gOamData_85B7748 = .priority = 1, }; -static const struct CompressedSpriteSheet gUnknown_085B7750[] = +static const struct CompressedSpriteSheet sSpriteSheets_Interface[] = { { - .data = gRouletteCreditTiles, + .data = gRouletteCredit_Gfx, .size = 0x400, - .tag = 7 + .tag = GFXTAG_CREDIT }, { - .data = gRouletteNumbersTiles, + .data = gRouletteNumbers_Gfx, .size = 0x280, - .tag = 8 + .tag = GFXTAG_CREDIT_DIGIT }, { - .data = gRouletteMultiplierTiles, + .data = gRouletteMultiplier_Gfx, .size = 0x500, - .tag = 9 + .tag = GFXTAG_MULTIPLIER }, { - .data = RouletteBallCounterTiles, + .data = sBallCounter_Gfx, .size = 0x140, - .tag = 10 + .tag = GFXTAG_BALL_COUNTER }, { - .data = RouletteCursorTiles, + .data = sCursor_Gfx, .size = 0x200, - .tag = 11 + .tag = GFXTAG_CURSOR }, {} }; @@ -2606,7 +2801,7 @@ static const union AnimCmd *const gSpriteAnimTable_85B77A8[] = gSpriteAnim_85B7780 }; -static const union AnimCmd gSpriteAnim_85B77AC[] = +static const union AnimCmd sAnim_Multiplier[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_FRAME(8, 0), @@ -2616,12 +2811,12 @@ static const union AnimCmd gSpriteAnim_85B77AC[] = ANIMCMD_END }; -static const union AnimCmd *const gSpriteAnimTable_85B77C4[] = +static const union AnimCmd *const sAnims_Multiplier[] = { - gSpriteAnim_85B77AC + sAnim_Multiplier }; -static const union AnimCmd gSpriteAnim_85B77C8[] = +static const union AnimCmd sAnim_BallCounter[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_FRAME(2, 0), @@ -2631,59 +2826,60 @@ static const union AnimCmd gSpriteAnim_85B77C8[] = ANIMCMD_END }; -static const union AnimCmd *const gSpriteAnimTable_85B77E0[] = +static const union AnimCmd *const sAnims_BallCounter[] = { - gSpriteAnim_85B77C8 + sAnim_BallCounter }; -static const struct SpriteTemplate gSpriteTemplate_85B77E4 = +static const struct SpriteTemplate sSpriteTemplate_Credit = { - .tileTag = 7, - .paletteTag = 5, - .oam = &gOamData_85B7730, + .tileTag = GFXTAG_CREDIT, + .paletteTag = PALTAG_INTERFACE, + .oam = &sOam_Credit, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate gUnknown_085B77FC = +static const struct SpriteTemplate sSpriteTemplate_CreditDigit = { - .tileTag = 8, - .paletteTag = 5, - .oam = &gOamData_85B7738, + .tileTag = GFXTAG_CREDIT_DIGIT, + .paletteTag = PALTAG_INTERFACE, + .oam = &sOam_CreditDigit, .anims = gSpriteAnimTable_85B77A8, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate gUnknown_085B7814 = +static const struct SpriteTemplate sSpriteTemplate_Multiplier = { - .tileTag = 9, - .paletteTag = 5, - .oam = &gOamData_85B7740, - .anims = gSpriteAnimTable_85B77C4, + .tileTag = GFXTAG_MULTIPLIER, + .paletteTag = PALTAG_INTERFACE, + .oam = &sOam_Multiplier, + .anims = sAnims_Multiplier, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814390C + .callback = SpriteCB_GridSquare }; -static const struct SpriteTemplate gUnknown_085B782C = +static const struct SpriteTemplate sSpriteTemplate_BallCounter = { - .tileTag = 10, - .paletteTag = 3, - .oam = &gOamData_85B7748, - .anims = gSpriteAnimTable_85B77E0, + .tileTag = GFXTAG_BALL_COUNTER, + .paletteTag = PALTAG_BALL_COUNTER, + .oam = &sOam_BallCounter, + .anims = sAnims_BallCounter, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate gUnknown_085B7844 = +// NOTE: This cursor is only used to identify the winning square on the grid +static const struct SpriteTemplate sSpriteTemplate_Cursor = { - .tileTag = 11, - .paletteTag = 5, + .tileTag = GFXTAG_CURSOR, + .paletteTag = PALTAG_INTERFACE, .oam = &gOamData_85B73EC, .anims = gDummySpriteAnimTable, .images = NULL, @@ -2691,7 +2887,7 @@ static const struct SpriteTemplate gUnknown_085B7844 = .callback = SpriteCallbackDummy }; -static const struct OamData gOamData_85B785C = +static const struct OamData sOam_Ball = { .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -2700,10 +2896,10 @@ static const struct OamData gOamData_85B785C = .priority = 2, }; -static const struct CompressedSpriteSheet gUnknown_085B7864 = { - .data = gUnknown_085B6650, +static const struct CompressedSpriteSheet sSpriteSheet_Ball = { + .data = sBall_Gfx, .size = 0x200, - .tag = 12 + .tag = GFXTAG_BALL }; static const union AnimCmd gSpriteAnim_85B786C[] = @@ -2776,7 +2972,7 @@ static const union AnimCmd gSpriteAnim_85B78F0[] = ANIMCMD_END }; -static const union AnimCmd *const gSpriteAnimTable_85B7904[] = +static const union AnimCmd *const sAnims_Ball[] = { gSpriteAnim_85B786C, gSpriteAnim_85B7880, @@ -2789,18 +2985,18 @@ static const union AnimCmd *const gSpriteAnimTable_85B7904[] = gSpriteAnim_85B78E8 }; -static const struct SpriteTemplate gSpriteTemplate_85B7928 = +static const struct SpriteTemplate sSpriteTemplate_Ball = { - .tileTag = 12, - .paletteTag = 2, - .oam = &gOamData_85B785C, - .anims = gSpriteAnimTable_85B7904, + .tileTag = GFXTAG_BALL, + .paletteTag = PALTAG_BALL, + .oam = &sOam_Ball, + .anims = sAnims_Ball, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct OamData gOamData_85B7940 = +static const struct OamData sOam_BoardCenter = { .y = 81, .affineMode = ST_OAM_AFFINE_DOUBLE, @@ -2810,25 +3006,25 @@ static const struct OamData gOamData_85B7940 = .priority = 2, }; -static const struct CompressedSpriteSheet gUnknown_085B7948 = +static const struct CompressedSpriteSheet sSpriteSheet_BoardCenter = { .data = gRouletteCenter_Gfx, .size = 0x800, - .tag = 6 + .tag = GFXTAG_BOARD_CENTER }; -static const struct SpriteTemplate gSpriteTemplate_85B7950 = +static const struct SpriteTemplate sSpriteTemplate_BoardCenter = { - .tileTag = 6, - .paletteTag = 2, - .oam = &gOamData_85B7940, + .tileTag = GFXTAG_BOARD_CENTER, + .paletteTag = PALTAG_BALL, + .oam = &sOam_BoardCenter, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_814399C + .callback = SpriteCB_BoardCenter }; -static const struct OamData gOamData_85B7968 = +static const struct OamData sOam_Shroomish = { .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -2837,7 +3033,7 @@ static const struct OamData gOamData_85B7968 = .priority = 2, }; -static const struct OamData gOamData_85B7970 = +static const struct OamData sOam_Taillow = { .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -2846,14 +3042,14 @@ static const struct OamData gOamData_85B7970 = .priority = 2, }; -static const struct CompressedSpriteSheet gUnknown_085B7978 = +static const struct CompressedSpriteSheet sSpriteSheet_ShroomishTaillow = { - .data = gUnknown_085B67FC, + .data = sShroomishTaillow_Gfx, .size = 0xE00, - .tag = 13 + .tag = GFXTAG_SHROOMISH_TAILLOW }; -static const union AnimCmd gSpriteAnim_85B7980[] = +static const union AnimCmd sAnim_Shroomish[] = { ANIMCMD_FRAME(0, 6), ANIMCMD_FRAME(16, 6), @@ -2904,12 +3100,12 @@ static const union AnimCmd gSpriteAnim_85B79D0[] = ANIMCMD_JUMP(0) }; -static const union AnimCmd *const gSpriteAnimTable_85B79DC[] = +static const union AnimCmd *const sAnims_Shroomish[] = { - gSpriteAnim_85B7980 + sAnim_Shroomish }; -static const union AnimCmd *const gSpriteAnimTable_85B79E0[] = +static const union AnimCmd *const sAnims_Taillow[] = { gSpriteAnim_85B799C, gSpriteAnim_85B79A4, @@ -2919,26 +3115,26 @@ static const union AnimCmd *const gSpriteAnimTable_85B79E0[] = gSpriteAnim_85B79D0 }; -static const struct SpriteTemplate gSpriteTemplate_85B79F8 = +static const struct SpriteTemplate sSpriteTemplate_Shroomish = { - .tileTag = 13, - .paletteTag = 6, - .oam = &gOamData_85B7968, - .anims = gSpriteAnimTable_85B79DC, + .tileTag = GFXTAG_SHROOMISH_TAILLOW, + .paletteTag = PALTAG_SHROOMISH, + .oam = &sOam_Shroomish, + .anims = sAnims_Shroomish, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteTemplate gSpriteTemplate_85B7A10 = +static const struct SpriteTemplate sSpriteTemplate_Taillow = { - .tileTag = 13, - .paletteTag = 7, - .oam = &gOamData_85B7970, - .anims = gSpriteAnimTable_85B79E0, + .tileTag = GFXTAG_SHROOMISH_TAILLOW, + .paletteTag = PALTAG_TAILLOW, + .oam = &sOam_Taillow, + .anims = sAnims_Taillow, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8145294 + .callback = SpriteCB_Taillow }; static const struct OamData gOamData_85B7A28 = @@ -2959,7 +3155,7 @@ static const struct OamData gOamData_85B7A30 = .priority = 2, }; -static const struct OamData gOamData_85B7A38 = +static const struct OamData sOam_TaillowShadow = { .affineMode = ST_OAM_AFFINE_NORMAL, .objMode = ST_OAM_OBJ_NORMAL, @@ -2968,11 +3164,11 @@ static const struct OamData gOamData_85B7A38 = .priority = 2, }; -static const struct CompressedSpriteSheet gUnknown_085B7A40 = +static const struct CompressedSpriteSheet sSpriteSheet_Shadow = { - .data = gUnknown_085B7290, + .data = sShadow_Gfx, .size = 0x180, - .tag = 14 + .tag = GFXTAG_SHADOW }; static const union AffineAnimCmd gSpriteAffineAnim_85B7A48[] = @@ -2982,7 +3178,7 @@ static const union AffineAnimCmd gSpriteAffineAnim_85B7A48[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd gSpriteAffineAnim_85B7A60[] = +static const union AffineAnimCmd sAffineAnim_TaillowShadow[] = { AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), AFFINEANIMCMD_FRAME(-2, 0x0, 0, 15), @@ -2996,9 +3192,9 @@ static const union AffineAnimCmd *const gSpriteAffineAnimTable_85B7A88[] = gSpriteAffineAnim_85B7A48 }; -static const union AffineAnimCmd *const gSpriteAffineAnimTable_85B7A8C[] = +static const union AffineAnimCmd *const sAffineAnims_TaillowShadow[] = { - gSpriteAffineAnim_85B7A60 + sAffineAnim_TaillowShadow }; static const union AffineAnimCmd gSpriteAffineAnim_85B7A90[] = @@ -3034,11 +3230,11 @@ static const union AnimCmd *const gSpriteAnimTable_85B7AB8[] = gSpriteAnim_85B7AAC }; -static const struct SpriteTemplate gSpriteTemplate_85B7ABC[] = +static const struct SpriteTemplate sSpriteTemplate_ShroomishShadow[] = { { - .tileTag = 14, - .paletteTag = 1, + .tileTag = GFXTAG_SHADOW, + .paletteTag = PALTAG_SHADOW, .oam = &gOamData_85B7A28, .anims = gSpriteAnimTable_85B7AB4, .images = NULL, @@ -3046,8 +3242,8 @@ static const struct SpriteTemplate gSpriteTemplate_85B7ABC[] = .callback = SpriteCallbackDummy }, { - .tileTag = 14, - .paletteTag = 1, + .tileTag = GFXTAG_SHADOW, + .paletteTag = PALTAG_SHADOW, .oam = &gOamData_85B7A30, .anims = gSpriteAnimTable_85B7AB8, .images = NULL, @@ -3056,34 +3252,34 @@ static const struct SpriteTemplate gSpriteTemplate_85B7ABC[] = } }; -static const struct SpriteTemplate gUnknown_085B7AEC = +static const struct SpriteTemplate sSpriteTemplate_TaillowShadow = { - .tileTag = 14, - .paletteTag = 1, - .oam = &gOamData_85B7A38, + .tileTag = GFXTAG_SHADOW, + .paletteTag = PALTAG_SHADOW, + .oam = &sOam_TaillowShadow, .anims = gSpriteAnimTable_85B7AB8, .images = NULL, - .affineAnims = gSpriteAffineAnimTable_85B7A8C, - .callback = sub_8145294 + .affineAnims = sAffineAnims_TaillowShadow, + .callback = SpriteCB_Taillow }; -static void sub_81428C4(u8 r0) +static void Task_ShowMinBetYesNo(u8 taskId) { DisplayYesNoMenuDefaultYes(); - DoYesNoFuncWithChoice(r0, &gUnknown_085B6408); + DoYesNoFuncWithChoice(taskId, &sYesNoTable_AcceptMinBet); } -static void sub_81428E4(u8 taskId) +static void Task_FadeToRouletteGame(u8 taskId) { if (!gPaletteFade.active) { SetVBlankCallback(NULL); - SetMainCallback2(sub_81405CC); + SetMainCallback2(CB2_LoadRoulette); DestroyTask(taskId); } } -static void sub_8142918(u8 taskId) +static void Task_AcceptMinBet(u8 taskId) { ClearStdWindowAndFrame(0, TRUE); HideCoinsWindow(); @@ -3091,10 +3287,10 @@ static void sub_8142918(u8 taskId) BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gPaletteFade.delayCounter = gPaletteFade.multipurpose2; UpdatePaletteFade(); - gTasks[taskId].func = sub_81428E4; + gTasks[taskId].func = Task_FadeToRouletteGame; } -static void sub_814297C(u8 taskId) +static void Task_DeclineMinBet(u8 taskId) { ClearStdWindowAndFrame(0, FALSE); HideCoinsWindow(); @@ -3102,10 +3298,10 @@ static void sub_814297C(u8 taskId) DestroyTask(taskId); } -static void sub_81429A0(u8 taskId) +static void Task_NotEnoughForMinBet(u8 taskId) { gTasks[taskId].data[0]++; - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { gSpecialVar_0x8004 = 1; HideCoinsWindow(); @@ -3115,52 +3311,56 @@ static void sub_81429A0(u8 taskId) } } -static void sub_81429F0(u8 taskId) +static void Task_PrintMinBet(u8 taskId) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { - u32 temp = gUnknown_085B6344[(gSpecialVar_0x8004 & 1) + (gSpecialVar_0x8004 >> 7 << 1)]; - ConvertIntToDecimalStringN(gStringVar1, temp, STR_CONV_MODE_LEADING_ZEROS, 1); + u32 minBet = sTableMinBets[GET_TABLE_ID(gSpecialVar_0x8004)]; + ConvertIntToDecimalStringN(gStringVar1, minBet, STR_CONV_MODE_LEADING_ZEROS, 1); StringExpandPlaceholders(gStringVar4, Roulette_Text_PlayMinimumWagerIsX); DrawStdWindowFrame(0, FALSE); AddTextPrinterParameterized(0, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); CopyWindowToVram(0, 3); - gTasks[taskId].func = sub_81428C4; + gTasks[taskId].func = Task_ShowMinBetYesNo; } } -static void Task_Roulette_0(u8 taskId) +static void Task_PrintRouletteEntryMsg(u8 taskId) { - s32 temp; - PrintCoinsString(gTasks[taskId].data[13]); - temp = gUnknown_085B6344[(gSpecialVar_0x8004 & 1) + (gSpecialVar_0x8004 >> 7 << 1)]; - ConvertIntToDecimalStringN(gStringVar1, temp, STR_CONV_MODE_LEADING_ZEROS, 1); - if (gTasks[taskId].data[13] >= temp) + s32 minBet; + PrintCoinsString(gTasks[taskId].tCoins); + minBet = sTableMinBets[GET_TABLE_ID(gSpecialVar_0x8004)]; + ConvertIntToDecimalStringN(gStringVar1, minBet, STR_CONV_MODE_LEADING_ZEROS, 1); + + if (gTasks[taskId].tCoins >= minBet) { - if ((gSpecialVar_0x8004 & 0x80) && (gSpecialVar_0x8004 & 1)) + if ((gSpecialVar_0x8004 & ROULETTE_SPECIAL_RATE) && (gSpecialVar_0x8004 & 1)) { + // Special rate for Game Corner service day (only at second table) DrawStdWindowFrame(0, FALSE); AddTextPrinterParameterized(0, 1, Roulette_Text_SpecialRateTable, 0, 1, TEXT_SPEED_FF, NULL); CopyWindowToVram(0, 3); - gTasks[taskId].func = sub_81429F0; + gTasks[taskId].func = Task_PrintMinBet; } else { + // Print minimum bet StringExpandPlaceholders(gStringVar4, Roulette_Text_PlayMinimumWagerIsX); DrawStdWindowFrame(0, FALSE); AddTextPrinterParameterized(0, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); CopyWindowToVram(0, 3); - gTasks[taskId].func = sub_81428C4; + gTasks[taskId].func = Task_ShowMinBetYesNo; } } else { + // Not enough for minimum bet StringExpandPlaceholders(gStringVar4, Roulette_Text_NotEnoughCoins); DrawStdWindowFrame(0, FALSE); AddTextPrinterParameterized(0, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); CopyWindowToVram(0, 3); - gTasks[taskId].func = sub_81429A0; - gTasks[taskId].data[13] = 0; + gTasks[taskId].func = Task_NotEnoughForMinBet; + gTasks[taskId].tCoins = 0; gTasks[taskId].data[0] = 0; } } @@ -3171,38 +3371,39 @@ void PlayRoulette(void) ScriptContext2_Enable(); ShowCoinsWindow(GetCoins(), 1, 1); - taskId = CreateTask(Task_Roulette_0, 0); - gTasks[taskId].data[13] = GetCoins(); + taskId = CreateTask(Task_PrintRouletteEntryMsg, 0); + gTasks[taskId].tCoins = GetCoins(); } -static void sub_8142C0C(u8 r0) +static void LoadOrFreeMiscSpritePalettesAndSheets(bool8 free) { - if (!r0) + if (!free) { FreeAllSpritePalettes(); - LoadSpritePalettes(gUnknown_085B7384); - LoadCompressedSpriteSheet(&gUnknown_085B7864); - LoadCompressedSpriteSheet(&gUnknown_085B7978); - LoadCompressedSpriteSheet(&gUnknown_085B7A40); + LoadSpritePalettes(sSpritePalettes); + LoadCompressedSpriteSheet(&sSpriteSheet_Ball); + LoadCompressedSpriteSheet(&sSpriteSheet_ShroomishTaillow); + LoadCompressedSpriteSheet(&sSpriteSheet_Shadow); } else { - FreeSpriteTilesByTag(14); - FreeSpriteTilesByTag(13); - FreeSpriteTilesByTag(12); + // Unused + FreeSpriteTilesByTag(GFXTAG_SHADOW); + FreeSpriteTilesByTag(GFXTAG_SHROOMISH_TAILLOW); + FreeSpriteTilesByTag(GFXTAG_BALL); FreeAllSpritePalettes(); } } -static u8 sub_8142C60(const struct SpriteTemplate *r0, u8 r1, u16 *r2) +static u8 CreateBoardIconSprite(const struct SpriteTemplate *r0, u8 r1, u16 *r2) { u16 temp; u8 spriteId = CreateSprite(r0, 116, 80, r0->oam->y); - gSprites[spriteId].data[0] = *r2; - gSprites[spriteId].data[1] = r1; + gSprites[spriteId].data[0] = *r2; + gSprites[spriteId].data[1] = r1; gSprites[spriteId].coordOffsetEnabled = TRUE; - gSprites[spriteId].animPaused = TRUE; - gSprites[spriteId].affineAnimPaused = TRUE; + gSprites[spriteId].animPaused = TRUE; + gSprites[spriteId].affineAnimPaused = TRUE; temp = *r2; *r2 += 30; if (*r2 >= 360) @@ -3210,170 +3411,173 @@ static u8 sub_8142C60(const struct SpriteTemplate *r0, u8 r1, u16 *r2) return spriteId; } -static void sub_8142CD0(void) +static void CreateGridSprites(void) { u8 i, j; u8 spriteId; struct SpriteSheet s; - LZ77UnCompWram(gUnknown_085B7488.data, gDecompressionBuffer); + LZ77UnCompWram(sSpriteSheet_Headers.data, gDecompressionBuffer); s.data = gDecompressionBuffer; - s.size = gUnknown_085B7488.size; - s.tag = gUnknown_085B7488.tag; + s.size = sSpriteSheet_Headers.size; + s.tag = sSpriteSheet_Headers.tag; LoadSpriteSheet(&s); - LZ77UnCompWram(gUnknown_085B7490.data, gDecompressionBuffer); + LZ77UnCompWram(sSpriteSheet_PokeIcons.data, gDecompressionBuffer); s.data = gDecompressionBuffer; - s.size = gUnknown_085B7490.size; - s.tag = gUnknown_085B7490.tag; + s.size = sSpriteSheet_PokeIcons.size; + s.tag = sSpriteSheet_PokeIcons.tag; LoadSpriteSheet(&s); - for (i = 0; i < 3; i++) + for (i = 0; i < NUM_BOARD_COLORS; i++) { u8 o = i * 24; - for (j = 0; j < 4; j++) + for (j = 0; j < NUM_BOARD_POKES; j++) { - spriteId = gUnknown_0203AB88->var3C[(i * 4) + 29 + j] = CreateSprite(&gSpriteTemplate_85B75B0[j], (j * 24) + 148, o + 92, 30); + spriteId = sRoulette->spriteIds[(i * NUM_BOARD_POKES) + SPR_GRID_ICONS + j] = CreateSprite(&sSpriteTemplate_GridIcons[j], (j * 24) + 148, o + 92, 30); gSprites[spriteId].animPaused = TRUE; o += 24; if (o >= 72) o = 0; } } - for (i = 0; i < 4; i++) + for (i = 0; i < ARRAY_COUNT(sSpriteTemplates_PokeHeaders); i++) { - spriteId = gUnknown_0203AB88->var3C[i + 41] = CreateSprite(&gSpriteTemplate_85B7508[i], (i * 24) + 148, 70, 30); + spriteId = sRoulette->spriteIds[i + SPR_POKE_HEADER_1] = CreateSprite(&sSpriteTemplates_PokeHeaders[i], (i * 24) + 148, 70, 30); gSprites[spriteId].animPaused = TRUE; } - for (i = 0; i < 3; i++) + for (i = 0; i < ARRAY_COUNT(sSpriteTemplates_ColorHeaders); i++) { - spriteId = gUnknown_0203AB88->var3C[i + 45] = CreateSprite(&gSpriteTemplate_85B7568[i], 126, (i * 24) + 92, 30); + spriteId = sRoulette->spriteIds[i + SPR_COLOR_HEADER_1] = CreateSprite(&sSpriteTemplates_ColorHeaders[i], 126, (i * 24) + 92, 30); gSprites[spriteId].animPaused = TRUE; } } -static void unref_sub_8142E3C(void) +// Unused +static void DestroyGridSprites(void) { u8 i; - for (i = 0; i < 12; i++) + for (i = 0; i < NUM_ROULETTE_SLOTS; i++) { - DestroySprite(&gSprites[gUnknown_0203AB88->var3C[i + 29]]); + DestroySprite(&gSprites[sRoulette->spriteIds[i + SPR_GRID_ICONS]]); } } -static void sub_8142E70(u8 r0, u8 r1) +static void ShowHideGridIcons(bool8 hideAll, u8 hideSquare) { u8 i; - switch (r0) + switch (hideAll) { - case 1: - for (i = 0; i < 19; i++) + case TRUE: + // Hide grid icons and headers + for (i = 0; i < NUM_GRID_SELECTIONS; i++) { - gSprites[gUnknown_0203AB88->var3C[i + 29]].invisible = TRUE; + gSprites[sRoulette->spriteIds[i + SPR_GRID_ICONS]].invisible = TRUE; } break; - case 0: - for (i = 0; i < 12; i++) + case FALSE: + for (i = 0; i < NUM_ROULETTE_SLOTS; i++) { - if (!(gUnknown_0203AB88->var08 & gUnknown_085B62E4[i].var04)) - gSprites[gUnknown_0203AB88->var3C[i + 29]].invisible = FALSE; - else if (gUnknown_085B62E4[i].var02 != r1) - gSprites[gUnknown_0203AB88->var3C[i + 29]].invisible = TRUE; + if (!(sRoulette->hitFlags & sRouletteSlots[i].flag)) + gSprites[sRoulette->spriteIds[i + SPR_GRID_ICONS]].invisible = FALSE; + else if (sRouletteSlots[i].gridSquare != hideSquare) + gSprites[sRoulette->spriteIds[i + SPR_GRID_ICONS]].invisible = TRUE; else - gSprites[gUnknown_0203AB88->var3C[i + 29]].invisible = FALSE; + gSprites[sRoulette->spriteIds[i + SPR_GRID_ICONS]].invisible = FALSE; } - for (; i < 19; i++) + // Always show grid headers + for (; i < NUM_GRID_SELECTIONS; i++) { - gSprites[gUnknown_0203AB88->var3C[i + 29]].invisible = FALSE; + gSprites[sRoulette->spriteIds[i + SPR_GRID_ICONS]].invisible = FALSE; } break; } } -static void sub_8142F7C(void) +static void CreateGridBallSprites(void) { u8 i; - for (i = 0; i < 6; i++) + for (i = 0; i < BALLS_PER_ROUND; i++) { - gUnknown_0203AB88->var3C[i + 49] = CreateSprite(&gSpriteTemplate_85B7928, 116, 20, 10); - gSprites[gUnknown_0203AB88->var3C[i + 49]].invisible = TRUE; - gSprites[gUnknown_0203AB88->var3C[i + 49]].data[0] = 1; - gSprites[gUnknown_0203AB88->var3C[i + 49]].callback = sub_814390C; - gSprites[gUnknown_0203AB88->var3C[i + 49]].oam.priority = 1; - StartSpriteAnim(&gSprites[gUnknown_0203AB88->var3C[i + 49]], 8); + sRoulette->spriteIds[i + SPR_GRID_BALL_1] = CreateSprite(&sSpriteTemplate_Ball, 116, 20, 10); + gSprites[sRoulette->spriteIds[i + SPR_GRID_BALL_1]].invisible = TRUE; + gSprites[sRoulette->spriteIds[i + SPR_GRID_BALL_1]].data[0] = 1; + gSprites[sRoulette->spriteIds[i + SPR_GRID_BALL_1]].callback = SpriteCB_GridSquare; + gSprites[sRoulette->spriteIds[i + SPR_GRID_BALL_1]].oam.priority = 1; + StartSpriteAnim(&gSprites[sRoulette->spriteIds[i + SPR_GRID_BALL_1]], 8); } } -static void sub_8143038(u8 r0, u8 r1) +static void ShowHideGridBalls(bool8 hideAll, u8 hideBallId) { u8 i = 0; - if (r0) + if (hideAll) { - for ( ; i < 6; i++) + for (; i < BALLS_PER_ROUND; i++) { - gSprites[gUnknown_0203AB88->var3C[i + 49]].invisible = TRUE; + gSprites[sRoulette->spriteIds[i + SPR_GRID_BALL_1]].invisible = TRUE; } } else { - for ( ; i < 6; i++) + for (; i < BALLS_PER_ROUND; i++) { - if (!gUnknown_0203AB88->var0C[i] || i == r1) + if (!sRoulette->hitSquares[i] || i == hideBallId) { - gSprites[gUnknown_0203AB88->var3C[i + 49]].invisible = TRUE; + gSprites[sRoulette->spriteIds[i + SPR_GRID_BALL_1]].invisible = TRUE; } else { - gSprites[gUnknown_0203AB88->var3C[i + 49]].invisible = FALSE; - gSprites[gUnknown_0203AB88->var3C[i + 49]].pos1.x = (gUnknown_085B6154[gUnknown_0203AB88->var0C[i]].var03 + 1) * 8 + 4; - gSprites[gUnknown_0203AB88->var3C[i + 49]].pos1.y = (gUnknown_085B6154[gUnknown_0203AB88->var0C[i]].var04 + 1) * 8 + 3; + gSprites[sRoulette->spriteIds[i + SPR_GRID_BALL_1]].invisible = FALSE; + gSprites[sRoulette->spriteIds[i + SPR_GRID_BALL_1]].pos1.x = (sGridSelections[sRoulette->hitSquares[i]].x + 1) * 8 + 4; + gSprites[sRoulette->spriteIds[i + SPR_GRID_BALL_1]].pos1.y = (sGridSelections[sRoulette->hitSquares[i]].y + 1) * 8 + 3; } } } } -static void sub_8143150(u8 r0) +static void ShowHideWinSlotCursor(u8 selectionId) { - if (!r0) + if (selectionId == 0) { - gSprites[gUnknown_0203AB88->var3C[48]].invisible = TRUE; + gSprites[sRoulette->spriteIds[SPR_WIN_SLOT_CURSOR]].invisible = TRUE; } else { - gSprites[gUnknown_0203AB88->var3C[48]].invisible = FALSE; - gSprites[gUnknown_0203AB88->var3C[48]].pos1.x = (gUnknown_085B6154[r0].var03 + 2) * 8; - gSprites[gUnknown_0203AB88->var3C[48]].pos1.y = (gUnknown_085B6154[r0].var04 + 2) * 8; + gSprites[sRoulette->spriteIds[SPR_WIN_SLOT_CURSOR]].invisible = FALSE; + gSprites[sRoulette->spriteIds[SPR_WIN_SLOT_CURSOR]].pos1.x = (sGridSelections[selectionId].x + 2) * 8; + gSprites[sRoulette->spriteIds[SPR_WIN_SLOT_CURSOR]].pos1.y = (sGridSelections[selectionId].y + 2) * 8; } } -static void sub_81431E4(void) +static void CreateBoardIconSprites(void) { u8 i, j; u16 k; struct SpriteSheet s; - LZ77UnCompWram(gUnknown_085B741C.data, gDecompressionBuffer); + LZ77UnCompWram(sSpriteSheet_BoardIcons.data, gDecompressionBuffer); s.data = gDecompressionBuffer; - s.size = gUnknown_085B741C.size; - s.tag = gUnknown_085B741C.tag; + s.size = sSpriteSheet_BoardIcons.size; + s.tag = sSpriteSheet_BoardIcons.tag; LoadSpriteSheet(&s); k = 15; - for (i = 0; i < 3; i++) + for (i = 0; i < NUM_BOARD_COLORS; i++) { - for (j = 0; j < 4; j++) + for (j = 0; j < NUM_BOARD_POKES; j++) { u8 spriteId; - spriteId = gUnknown_0203AB88->var3C[(i * 4) + 7 + j] = sub_8142C60(&gSpriteTemplate_85B7610[i * 4 + j], 40, &k); + spriteId = sRoulette->spriteIds[(i * NUM_BOARD_POKES) + SPR_BOARD_ICONS + j] = CreateBoardIconSprite(&sSpriteTemplates_BoardIcons[i * NUM_BOARD_POKES + j], 40, &k); gSprites[spriteId].animPaused = TRUE; gSprites[spriteId].affineAnimPaused = TRUE; } } } -static void sub_8143280(struct Sprite *sprite) +static void SpriteCB_BoardIcon(struct Sprite *sprite) { s16 cos; s16 sin; u32 matrixNum; - s16 angle = gUnknown_0203AB88->var24 + sprite->data[0]; + s16 angle = sRoulette->var24 + sprite->data[0]; if (angle >= 360) angle -= 360; sin = Sin2(angle); @@ -3388,55 +3592,56 @@ static void sub_8143280(struct Sprite *sprite) gOamMatrices[matrixNum].c = -sin; } -static void sub_8143314(void) +static void CreateInterfaceSprites(void) { u8 i; - for (i = 0; i < 5; i++) + for (i = 0; i < ARRAY_COUNT(sSpriteSheets_Interface) - 1; i++) { struct SpriteSheet s; - LZ77UnCompWram(gUnknown_085B7750[i].data, gDecompressionBuffer); + LZ77UnCompWram(sSpriteSheets_Interface[i].data, gDecompressionBuffer); s.data = gDecompressionBuffer; - s.size = gUnknown_085B7750[i].size; - s.tag = gUnknown_085B7750[i].tag; + s.size = sSpriteSheets_Interface[i].size; + s.tag = sSpriteSheets_Interface[i].tag; LoadSpriteSheet(&s); } - gUnknown_0203AB88->var3C[20] = CreateSprite(&gSpriteTemplate_85B77E4, 208, 16, 4); - gSprites[gUnknown_0203AB88->var3C[20]].animPaused = TRUE; - for (i = 0; i < 4; i++) + sRoulette->spriteIds[SPR_CREDIT] = CreateSprite(&sSpriteTemplate_Credit, 208, 16, 4); + gSprites[sRoulette->spriteIds[SPR_CREDIT]].animPaused = TRUE; + for (i = 0; i < MAX_COIN_DIGITS; i++) { - gUnknown_0203AB88->var3C[i + 21] = CreateSprite(&gUnknown_085B77FC, i * 8 + 196, 24, 0); - gSprites[gUnknown_0203AB88->var3C[i + 21]].invisible = TRUE; - gSprites[gUnknown_0203AB88->var3C[i + 21]].animPaused = TRUE; + sRoulette->spriteIds[i + SPR_CREDIT_DIG_1] = CreateSprite(&sSpriteTemplate_CreditDigit, i * 8 + 196, 24, 0); + gSprites[sRoulette->spriteIds[i + SPR_CREDIT_DIG_1]].invisible = TRUE; + gSprites[sRoulette->spriteIds[i + SPR_CREDIT_DIG_1]].animPaused = TRUE; } - gUnknown_0203AB88->var3C[25] = CreateSprite(&gUnknown_085B7814, 120, 68, 4); - gSprites[gUnknown_0203AB88->var3C[25]].animPaused = TRUE; - for (i = 0; i < 3; i++) + sRoulette->spriteIds[SPR_MULTIPLIER] = CreateSprite(&sSpriteTemplate_Multiplier, 120, 68, 4); + gSprites[sRoulette->spriteIds[SPR_MULTIPLIER]].animPaused = TRUE; + for (i = 0; i < BALLS_PER_ROUND / 2; i++) { - gUnknown_0203AB88->var3C[i + 26] = CreateSprite(&gUnknown_085B782C, i * 16 + 192, 36, 4); - gSprites[gUnknown_0203AB88->var3C[i + 26]].invisible = TRUE; - gSprites[gUnknown_0203AB88->var3C[i + 26]].animPaused = TRUE; + // Each ball counter sprite has 2 balls + sRoulette->spriteIds[i + SPR_BALL_COUNTER_1] = CreateSprite(&sSpriteTemplate_BallCounter, i * 16 + 192, 36, 4); + gSprites[sRoulette->spriteIds[i + SPR_BALL_COUNTER_1]].invisible = TRUE; + gSprites[sRoulette->spriteIds[i + SPR_BALL_COUNTER_1]].animPaused = TRUE; } - gUnknown_0203AB88->var3C[48] = CreateSprite(&gUnknown_085B7844, 152, 96, 9); - gSprites[gUnknown_0203AB88->var3C[48]].oam.priority = 1; - gSprites[gUnknown_0203AB88->var3C[48]].animPaused = TRUE; - gSprites[gUnknown_0203AB88->var3C[48]].invisible = TRUE; + sRoulette->spriteIds[SPR_WIN_SLOT_CURSOR] = CreateSprite(&sSpriteTemplate_Cursor, 152, 96, 9); + gSprites[sRoulette->spriteIds[SPR_WIN_SLOT_CURSOR]].oam.priority = 1; + gSprites[sRoulette->spriteIds[SPR_WIN_SLOT_CURSOR]].animPaused = TRUE; + gSprites[sRoulette->spriteIds[SPR_WIN_SLOT_CURSOR]].invisible = TRUE; } -static void sub_8143514(u16 r0) +static void SetCreditDigits(u16 r0) { u8 i; u16 d = 1000; bool8 v = FALSE; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_COIN_DIGITS; i++) { u8 t = r0 / d; - gSprites[gUnknown_0203AB88->var3C[i + 21]].invisible = TRUE; - if (t > 0 || v || i == 3) + gSprites[sRoulette->spriteIds[i + SPR_CREDIT_DIG_1]].invisible = TRUE; + if (t > 0 || v || i == MAX_COIN_DIGITS - 1) { - gSprites[gUnknown_0203AB88->var3C[i + 21]].invisible = FALSE; - gSprites[gUnknown_0203AB88->var3C[i + 21]].oam.tileNum = - gSprites[gUnknown_0203AB88->var3C[i + 21]].sheetTileStart - + (*gSprites[gUnknown_0203AB88->var3C[i + 21]].anims + t)->type; + gSprites[sRoulette->spriteIds[i + SPR_CREDIT_DIG_1]].invisible = FALSE; + gSprites[sRoulette->spriteIds[i + SPR_CREDIT_DIG_1]].oam.tileNum = + gSprites[sRoulette->spriteIds[i + SPR_CREDIT_DIG_1]].sheetTileStart + + (*gSprites[sRoulette->spriteIds[i + SPR_CREDIT_DIG_1]].anims + t)->type; v = TRUE; } r0 = r0 % d; @@ -3444,143 +3649,145 @@ static void sub_8143514(u16 r0) } } -static u8 sub_8143614(u8 r0) +// Identical to GetMultiplier but with different data array +static u8 GetMultiplierAnimId(u8 selectionId) { - u8 t[5] = {0, 1, 2, 3, 4}; + u8 animIds[5] = {0, 1, 2, 3, 4}; - if (r0 >= 20) - r0 = 0; - switch (gUnknown_085B6154[r0].var01_0) + if (selectionId > NUM_GRID_SELECTIONS) + selectionId = 0; + + switch (sGridSelections[selectionId].baseMultiplier) { - case 3: - r0 = r0 / 5 - 1; - if (gUnknown_0203AB88->var16[r0] > 3) + case NUM_BOARD_COLORS: + selectionId = selectionId / 5 - 1; + if (sRoulette->colorHits[selectionId] > 3) return 0; - return t[gUnknown_0203AB88->var16[r0] + 1]; - case 4: - r0--; - if (gUnknown_0203AB88->var12[r0] > 2) + return animIds[sRoulette->colorHits[selectionId] + 1]; + case NUM_BOARD_POKES: + selectionId--; + if (sRoulette->pokeHits[selectionId] > 2) return 0; - return t[gUnknown_0203AB88->var12[r0] + 2]; - case 12: - if (gUnknown_0203AB88->var08 & gUnknown_085B6154[r0].var08) + return animIds[sRoulette->pokeHits[selectionId] + 2]; + case NUM_ROULETTE_SLOTS: + if (sRoulette->hitFlags & sGridSelections[selectionId].flag) return 0; - return t[4]; + return animIds[4]; } return 0; } -static void sub_81436D0(u8 r0) +static void SetMultiplierSprite(u8 selectionId) { - struct Sprite *s = &gSprites[gUnknown_0203AB88->var3C[25]]; - s->animCmdIndex = sub_8143614(r0); + struct Sprite *s = &gSprites[sRoulette->spriteIds[SPR_MULTIPLIER]]; + s->animCmdIndex = GetMultiplierAnimId(selectionId); s->oam.tileNum = s->sheetTileStart + (*s->anims + s->animCmdIndex)->type; } -static void sub_814372C(u8 r0) +static void SetBallCounterNumLeft(u8 numBalls) { u8 i; u8 t = 0; - if (gUnknown_0203AB88->var19 == 1) + if (sRoulette->minBet == 1) t = 2; - switch (r0) + switch (numBalls) { case 6: - for (i = 0; i < 3; i++) + for (i = 0; i < BALLS_PER_ROUND / 2; i++) { - gSprites[gUnknown_0203AB88->var3C[i + 26]].invisible = FALSE; - gSprites[gUnknown_0203AB88->var3C[i + 26]].oam.tileNum = - gSprites[gUnknown_0203AB88->var3C[i + 26]].sheetTileStart - + (*gSprites[gUnknown_0203AB88->var3C[i + 26]].anims)->type; + gSprites[sRoulette->spriteIds[i + SPR_BALL_COUNTER_1]].invisible = FALSE; + gSprites[sRoulette->spriteIds[i + SPR_BALL_COUNTER_1]].oam.tileNum = + gSprites[sRoulette->spriteIds[i + SPR_BALL_COUNTER_1]].sheetTileStart + + (*gSprites[sRoulette->spriteIds[i + SPR_BALL_COUNTER_1]].anims)->type; } break; case 5: - gSprites[gUnknown_0203AB88->var3C[28]].oam.tileNum = - gSprites[gUnknown_0203AB88->var3C[28]].sheetTileStart - + (*gSprites[gUnknown_0203AB88->var3C[28]].anims + t + 1)->type; + gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_3]].oam.tileNum = + gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_3]].sheetTileStart + + (*gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_3]].anims + t + 1)->type; break; case 4: - gSprites[gUnknown_0203AB88->var3C[28]].oam.tileNum = - gSprites[gUnknown_0203AB88->var3C[28]].sheetTileStart - + (*gSprites[gUnknown_0203AB88->var3C[28]].anims + t + 2)->type; + gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_3]].oam.tileNum = + gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_3]].sheetTileStart + + (*gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_3]].anims + t + 2)->type; break; case 3: - gSprites[gUnknown_0203AB88->var3C[27]].oam.tileNum = - gSprites[gUnknown_0203AB88->var3C[27]].sheetTileStart - + (*gSprites[gUnknown_0203AB88->var3C[27]].anims + t + 1)->type; + gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_2]].oam.tileNum = + gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_2]].sheetTileStart + + (*gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_2]].anims + t + 1)->type; break; case 2: - gSprites[gUnknown_0203AB88->var3C[27]].oam.tileNum = - gSprites[gUnknown_0203AB88->var3C[27]].sheetTileStart - + (*gSprites[gUnknown_0203AB88->var3C[27]].anims + t + 2)->type; + gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_2]].oam.tileNum = + gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_2]].sheetTileStart + + (*gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_2]].anims + t + 2)->type; break; case 1: - gSprites[gUnknown_0203AB88->var3C[26]].oam.tileNum = - gSprites[gUnknown_0203AB88->var3C[26]].sheetTileStart - + (*gSprites[gUnknown_0203AB88->var3C[26]].anims + t + 1)->type; + gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_1]].oam.tileNum = + gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_1]].sheetTileStart + + (*gSprites[sRoulette->spriteIds[SPR_BALL_COUNTER_1]].anims + t + 1)->type; break; case 0: default: - for (i = 0; i < 3; i++) + for (i = 0; i < BALLS_PER_ROUND / 2; i++) { - gSprites[gUnknown_0203AB88->var3C[i + 26]].oam.tileNum = - gSprites[gUnknown_0203AB88->var3C[i + 26]].sheetTileStart - + (*gSprites[gUnknown_0203AB88->var3C[i + 26]].anims + t + 2)->type; + gSprites[sRoulette->spriteIds[i + SPR_BALL_COUNTER_1]].oam.tileNum = + gSprites[sRoulette->spriteIds[i + SPR_BALL_COUNTER_1]].sheetTileStart + + (*gSprites[sRoulette->spriteIds[i + SPR_BALL_COUNTER_1]].anims + t + 2)->type; } } } -static void sub_814390C(struct Sprite *sprite) +static void SpriteCB_GridSquare(struct Sprite *sprite) { - sprite->pos2.x = gUnknown_0203AB88->var26; + sprite->pos2.x = sRoulette->var26; } -static void sub_814391C(void) +static void CreateBoardCenterSprite(void) { u8 spriteId; struct SpriteSheet s; - LZ77UnCompWram(gUnknown_085B7948.data, gDecompressionBuffer); + LZ77UnCompWram(sSpriteSheet_BoardCenter.data, gDecompressionBuffer); s.data = gDecompressionBuffer; - s.size = gUnknown_085B7948.size; - s.tag = gUnknown_085B7948.tag; + s.size = sSpriteSheet_BoardCenter.size; + s.tag = sSpriteSheet_BoardCenter.tag; LoadSpriteSheet(&s); - spriteId = CreateSprite(&gSpriteTemplate_85B7950, 116, 80, 81); - gSprites[spriteId].data[0] = gUnknown_0203AB88->var24; + spriteId = CreateSprite(&sSpriteTemplate_BoardCenter, 116, 80, 81); + gSprites[spriteId].data[0] = sRoulette->var24; gSprites[spriteId].data[1] = 0; gSprites[spriteId].animPaused = TRUE; gSprites[spriteId].affineAnimPaused = TRUE; gSprites[spriteId].coordOffsetEnabled = TRUE; } -static void sub_814399C(struct Sprite *sprite) +static void SpriteCB_BoardCenter(struct Sprite *sprite) { u32 t = sprite->oam.matrixNum; struct OamMatrix *m = &gOamMatrices[0]; - m[t].d = gUnknown_0203AB88->var2C.a; - m[t].a = gUnknown_0203AB88->var2C.a; - m[t].b = gUnknown_0203AB88->var2C.b; - m[t].c = gUnknown_0203AB88->var2C.c; + m[t].d = sRoulette->var2C.a; + m[t].a = sRoulette->var2C.a; + m[t].b = sRoulette->var2C.b; + m[t].c = sRoulette->var2C.c; } -static void sub_81439C8(void) +static void CreateBoardBallSprites(void) { u8 i; - for (i = 0; i < 6; i++) + for (i = 0; i < BALLS_PER_ROUND; i++) { - gUnknown_0203AB88->var3C[i] = CreateSprite(&gSpriteTemplate_85B7928, 116, 80, 57 - i); - if (gUnknown_0203AB88->var3C[i] != MAX_SPRITES) + sRoulette->spriteIds[i] = CreateSprite(&sSpriteTemplate_Ball, 116, 80, 57 - i); + if (sRoulette->spriteIds[i] != MAX_SPRITES) { - gSprites[gUnknown_0203AB88->var3C[i]].invisible = TRUE; - gSprites[gUnknown_0203AB88->var3C[i]].coordOffsetEnabled = TRUE; + gSprites[sRoulette->spriteIds[i]].invisible = TRUE; + gSprites[sRoulette->spriteIds[i]].coordOffsetEnabled = TRUE; } } } -static void sub_8143A40(void) +static void HideBoardBalls(void) { - u8 t = gUnknown_0203AB88->var3C[0]; + u8 t = sRoulette->spriteIds[SPR_BALL_1]; u8 i; - for (i = 0; i < 6; i++) + for (i = 0; i < BALLS_PER_ROUND; i++) { u8 j; gSprites[t].invisible = TRUE; @@ -3596,15 +3803,15 @@ static void sub_8143A40(void) static s16 sub_8143AC8(struct Sprite *sprite) { - if (gUnknown_0203AB88->var24 > sprite->data[3]) + if (sRoulette->var24 > sprite->data[3]) { - sprite->data[6] = 360 - gUnknown_0203AB88->var24 + sprite->data[3]; + sprite->data[6] = 360 - sRoulette->var24 + sprite->data[3]; if (sprite->data[6] >= 360) sprite->data[6] -= 360; } else { - sprite->data[6] = sprite->data[3] - gUnknown_0203AB88->var24; + sprite->data[6] = sprite->data[3] - sRoulette->var24; } return sprite->data[6]; @@ -3612,8 +3819,8 @@ static s16 sub_8143AC8(struct Sprite *sprite) static u8 sub_8143B14(struct Sprite *sprite) { - gUnknown_0203AB88->var7E = sub_8143AC8(sprite) / 30.0f; - return gUnknown_0203AB88->var7E; + sRoulette->var7E = sub_8143AC8(sprite) / 30.0f; + return sRoulette->var7E; } static s16 sub_8143B48(struct Sprite *sprite) @@ -3641,18 +3848,18 @@ static void sub_8143B84(struct Sprite *sprite) { s16 sin, cos; - gUnknown_0203AB88->var8C += gUnknown_0203AB88->var90; - gUnknown_0203AB88->var88 += gUnknown_0203AB88->var8C; + sRoulette->var8C += sRoulette->var90; + sRoulette->var88 += sRoulette->var8C; - if (gUnknown_0203AB88->var88 >= 360) - gUnknown_0203AB88->var88 -= 360.0f; - else if (gUnknown_0203AB88->var88 < 0.0f) - gUnknown_0203AB88->var88 += 360.0f; + if (sRoulette->var88 >= 360) + sRoulette->var88 -= 360.0f; + else if (sRoulette->var88 < 0.0f) + sRoulette->var88 += 360.0f; - sprite->data[3] = gUnknown_0203AB88->var88; - gUnknown_0203AB88->var98 += gUnknown_0203AB88->var9C; - gUnknown_0203AB88->var94 += gUnknown_0203AB88->var98; - sprite->data[4] = gUnknown_0203AB88->var94; + sprite->data[3] = sRoulette->var88; + sRoulette->var98 += sRoulette->var9C; + sRoulette->var94 += sRoulette->var98; + sprite->data[4] = sRoulette->var94; sin = Sin2(sprite->data[3]); cos = Cos2(sprite->data[3]); sprite->pos2.x = sin * sprite->data[4] >> 12; @@ -3667,7 +3874,7 @@ static void sub_8143B84(struct Sprite *sprite) static void sub_8143C90(struct Sprite *sprite) { s16 sin, cos; - sprite->data[3] = gUnknown_0203AB88->var24 + sprite->data[6]; + sprite->data[3] = sRoulette->var24 + sprite->data[6]; if (sprite->data[3] >= 360) sprite->data[3] -= 360; sin = Sin2(sprite->data[3]); @@ -3690,10 +3897,10 @@ static void sub_8143CFC(struct Sprite *sprite) { if (!sprite->data[0]) { - if (gUnknown_0203AB88->var94 <= gUnknown_0203AB88->varA0 - 2.0f) + if (sRoulette->var94 <= sRoulette->varA0 - 2.0f) { - gUnknown_0203AB88->var7D = 0xFF; - gUnknown_0203AB88->var03_7 = 0; + sRoulette->var7D = 0xFF; + sRoulette->var03_7 = FALSE; StartSpriteAnim(sprite, sprite->animCmdIndex + 0x3); sub_8143B14(sprite); sprite->data[4] = 30; @@ -3701,16 +3908,16 @@ static void sub_8143CFC(struct Sprite *sprite) sprite->data[6] = (sprite->data[6] / 30) * 30 + 15; sprite->callback = sub_8143C90; m4aSongNumStartOrChange(SE_HASHI); - gUnknown_0203AB88->var9C = gUnknown_0203AB88->var98 = 0.0f; - gUnknown_0203AB88->var8C = -1.0f; + sRoulette->var9C = sRoulette->var98 = 0.0f; + sRoulette->var8C = -1.0f; } } else { - if (gUnknown_0203AB88->var94 >= gUnknown_0203AB88->varA0 - 2.0f) + if (sRoulette->var94 >= sRoulette->varA0 - 2.0f) { - gUnknown_0203AB88->var7D = 0xFF; - gUnknown_0203AB88->var03_7 = 0; + sRoulette->var7D = 0xFF; + sRoulette->var03_7 = FALSE; StartSpriteAnim(sprite, sprite->animCmdIndex + 3); sub_8143B14(sprite); sprite->data[4] = 30; @@ -3718,14 +3925,14 @@ static void sub_8143CFC(struct Sprite *sprite) sprite->data[6] = (sprite->data[6] / 30) * 30 + 15; sprite->callback = sub_8143C90; m4aSongNumStartOrChange(SE_HASHI); - gUnknown_0203AB88->var9C = gUnknown_0203AB88->var98 = 0.0f; - gUnknown_0203AB88->var8C = -1.0f; + sRoulette->var9C = sRoulette->var98 = 0.0f; + sRoulette->var8C = -1.0f; } } } } -static void sub_8143E14(struct Sprite *sprite) +static void SpriteCB_Shroomish(struct Sprite *sprite) { float f0, f1, f2; sub_8143B84(sprite); @@ -3736,8 +3943,8 @@ static void sub_8143E14(struct Sprite *sprite) if (sprite->data[0] != 1) { f0 = sprite->data[7]; - f1 = (f0 * gUnknown_085B6348[gUnknown_0203AB88->var04_0].var01 + (gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02 - 1)); - f2 = (f0 / gUnknown_085B6348[gUnknown_0203AB88->var04_0].var0C); + f1 = (f0 * gUnknown_085B6348[sRoulette->tableId].var01 + (gUnknown_085B6348[sRoulette->tableId].var02 - 1)); + f2 = (f0 / gUnknown_085B6348[sRoulette->tableId].var0C); } else { @@ -3748,8 +3955,8 @@ static void sub_8143E14(struct Sprite *sprite) if (sprite->data[0] != 0) { f0 = sprite->data[7]; - f1 = (f0 * gUnknown_085B6348[gUnknown_0203AB88->var04_0].var01 + (gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02 - 1)); - f2 = -(f0 / gUnknown_085B6348[gUnknown_0203AB88->var04_0].var0C); + f1 = (f0 * gUnknown_085B6348[sRoulette->tableId].var01 + (gUnknown_085B6348[sRoulette->tableId].var02 - 1)); + f2 = -(f0 / gUnknown_085B6348[sRoulette->tableId].var0C); } else { @@ -3759,10 +3966,10 @@ static void sub_8143E14(struct Sprite *sprite) default: return; } - gUnknown_0203AB88->varA0 = gUnknown_0203AB88->var94; - gUnknown_0203AB88->var98 = f2; - gUnknown_0203AB88->var9C = -((f2 * 2.0f) / f1 + (2.0f / (f1 * f1))); - gUnknown_0203AB88->var8C = 0.0f; + sRoulette->varA0 = sRoulette->var94; + sRoulette->var98 = f2; + sRoulette->var9C = -((f2 * 2.0f) / f1 + (2.0f / (f1 * f1))); + sRoulette->var8C = 0.0f; sprite->animPaused = FALSE; sprite->animNum = 0; sprite->animBeginning = TRUE; @@ -3777,8 +3984,8 @@ static void sub_8143FA4(struct Sprite *sprite) sprite->data[2]++; if (sprite->data[2] > 29 && sprite->pos2.y >= 0) { - gUnknown_0203AB88->var7D = 0xFF; - gUnknown_0203AB88->var03_7 = FALSE; + sRoulette->var7D = 0xFF; + sRoulette->var03_7 = FALSE; StartSpriteAnim(sprite, sprite->animCmdIndex + 3); sub_8143B14(sprite); sprite->data[4] = 30; @@ -3786,7 +3993,7 @@ static void sub_8143FA4(struct Sprite *sprite) sprite->data[6] = (sprite->data[6] / 30) * 30 + 15; sprite->callback = sub_8143C90; m4aSongNumStartOrChange(SE_HASHI); - gUnknown_0203AB88->var03_6 = TRUE; + sRoulette->var03_6 = TRUE; } } @@ -3797,7 +4004,7 @@ static void sub_8144050(struct Sprite *sprite) sprite->pos2.y--; if (sprite->data[2] == 45) { - if (gSprites[gUnknown_0203AB88->var3C[55]].animCmdIndex == 1) + if (gSprites[sRoulette->spriteIds[SPR_CLEAR_MON]].animCmdIndex == 1) sprite->pos2.y++; } } @@ -3805,9 +4012,9 @@ static void sub_8144050(struct Sprite *sprite) { if (sprite->data[2] < sprite->data[7]) { - if (gSprites[gUnknown_0203AB88->var3C[55]].animDelayCounter == 0) + if (gSprites[sRoulette->spriteIds[SPR_CLEAR_MON]].animDelayCounter == 0) { - if (gSprites[gUnknown_0203AB88->var3C[55]].animCmdIndex == 1) + if (gSprites[sRoulette->spriteIds[SPR_CLEAR_MON]].animCmdIndex == 1) sprite->pos2.y++; else sprite->pos2.y--; @@ -3848,18 +4055,18 @@ static void sub_8144128(struct Sprite *sprite) } } -static void sub_8144168(struct Sprite *sprite) +static void CreateClearSpeciesSprite(struct Sprite *sprite) { sub_8143B84(sprite); - switch (gUnknown_0203AB88->var03_0) + switch (sRoulette->useTaillow) { default: - case 0: - sub_81446DC(sprite); - sprite->callback = sub_8143E14; + case FALSE: + CreateShroomishSprite(sprite); + sprite->callback = SpriteCB_Shroomish; break; - case 1: - sub_81448B8(sprite); + case TRUE: + CreateTaillowSprite(sprite); sprite->callback = sub_8144128; break; } @@ -3869,13 +4076,13 @@ static void prev_quest_read_x24_hm_usage(struct Sprite *sprite) { sub_8143B84(sprite); if (sprite->data[2]-- == 16) - gUnknown_0203AB88->var98 *= -1.0f; + sRoulette->var98 *= -1.0f; if (sprite->data[2] == 0) { if (!sprite->data[0]) { - gUnknown_0203AB88->var7D = 0xFF; - gUnknown_0203AB88->var03_7 = 0; + sRoulette->var7D = 0xFF; + sRoulette->var03_7 = FALSE; StartSpriteAnim(sprite, sprite->animCmdIndex + 3); sub_8143B14(sprite); sprite->data[4] = 30; @@ -3898,10 +4105,10 @@ static void sub_8144264(struct Sprite *sprite) sub_8143B84(sprite); sprite->data[2] = 0; sub_8143B14(sprite); - if (!(gUnknown_085B62E4[gUnknown_0203AB88->var7E].var04 & gUnknown_0203AB88->var08)) + if (!(sRouletteSlots[sRoulette->var7E].flag & sRoulette->hitFlags)) { - gUnknown_0203AB88->var7D = 0xFF; - gUnknown_0203AB88->var03_7 = 0; + sRoulette->var7D = 0xFF; + sRoulette->var03_7 = FALSE; StartSpriteAnim(sprite, sprite->animCmdIndex + 3); sub_8143B14(sprite); sprite->data[4] = 30; @@ -3912,48 +4119,44 @@ static void sub_8144264(struct Sprite *sprite) } else { - u8 t; + u8 slotId; u32 z; m4aSongNumStart(SE_KON); z = Random() & 1; if (z) { - gUnknown_0203AB88->var8C = 0.0f; - gUnknown_0203AB88->var7F = t = (gUnknown_0203AB88->var7E + 1) % 12; + sRoulette->var8C = 0.0f; + sRoulette->var7F = slotId = (sRoulette->var7E + 1) % NUM_ROULETTE_SLOTS; } else { float temp; - gUnknown_0203AB88->var8C = (temp = gUnknown_085B6348[gUnknown_0203AB88->var04_0].var1C) * 2.0f; - t = (gUnknown_0203AB88->var7E + 11) % 12; - gUnknown_0203AB88->var7F = gUnknown_0203AB88->var7E; + sRoulette->var8C = (temp = gUnknown_085B6348[sRoulette->tableId].var1C) * 2.0f; + slotId = (sRoulette->var7E + NUM_ROULETTE_SLOTS - 1) % NUM_ROULETTE_SLOTS; + sRoulette->var7F = sRoulette->var7E; } - if (gUnknown_085B62E4[t].var04 & gUnknown_0203AB88->var08) + if (sRouletteSlots[slotId].flag & sRoulette->hitFlags) { sprite->data[0] = 1; - sprite->data[2] = gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02; + sprite->data[2] = gUnknown_085B6348[sRoulette->tableId].var02; } else { - sprite->data[0] = gUnknown_085B62E4[t].var04 & gUnknown_0203AB88->var08; - if (gUnknown_0203AB88->var04_0) + sprite->data[0] = sRouletteSlots[slotId].flag & sRoulette->hitFlags; + if (sRoulette->tableId) { - sprite->data[2] = gUnknown_085B6348[gUnknown_0203AB88->var04_0].var01; + sprite->data[2] = gUnknown_085B6348[sRoulette->tableId].var01; } else { - sprite->data[2] = gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02; + sprite->data[2] = gUnknown_085B6348[sRoulette->tableId].var02; if (z) - { - gUnknown_0203AB88->var8C = 0.5f; - } + sRoulette->var8C = 0.5f; else - { - gUnknown_0203AB88->var8C = -1.5f; - } + sRoulette->var8C = -1.5f; } } - gUnknown_0203AB88->var98 = 0.085f; + sRoulette->var98 = 0.085f; sprite->callback = prev_quest_read_x24_hm_usage; sprite->data[1] = 5; } @@ -3962,27 +4165,27 @@ static void sub_8144264(struct Sprite *sprite) static void sub_8144410(struct Sprite *sprite) { sub_8143B84(sprite); - if (gUnknown_0203AB88->var8C > 0.5f) + if (sRoulette->var8C > 0.5f) return; sub_8143B14(sprite); if (!sub_8143B48(sprite)) { - gUnknown_0203AB88->var90 = 0.0f; - gUnknown_0203AB88->var8C -= (float)(gUnknown_085B6348[gUnknown_0203AB88->var04_0].var03) - / (gUnknown_085B6348[gUnknown_0203AB88->var04_0].var04 + 1); + sRoulette->var90 = 0.0f; + sRoulette->var8C -= (float)(gUnknown_085B6348[sRoulette->tableId].var03) + / (gUnknown_085B6348[sRoulette->tableId].var04 + 1); sprite->data[1] = 4; sprite->callback = sub_8144264; } else { - if (gUnknown_0203AB88->var90 != 0.0f) + if (sRoulette->var90 != 0.0f) { - if (gUnknown_0203AB88->var8C < 0.0f) + if (sRoulette->var8C < 0.0f) { - gUnknown_0203AB88->var90 = 0.0f; - gUnknown_0203AB88->var8C = 0.0f; - gUnknown_0203AB88->var98 /= 1.2; + sRoulette->var90 = 0.0f; + sRoulette->var8C = 0.0f; + sRoulette->var98 /= 1.2; } } } @@ -3991,11 +4194,11 @@ static void sub_8144410(struct Sprite *sprite) static void sub_8144514(struct Sprite *sprite) { sub_8143B84(sprite); - if (gUnknown_0203AB88->var94 > 40.f) + if (sRoulette->var94 > 40.f) return; - gUnknown_0203AB88->var98 = -(4.0f / (float)(gUnknown_0203AB88->var86)); - gUnknown_0203AB88->var90 = -(gUnknown_0203AB88->var8C / (float)(gUnknown_0203AB88->var86)); + sRoulette->var98 = -(4.0f / (float)(sRoulette->var86)); + sRoulette->var90 = -(sRoulette->var8C / (float)(sRoulette->var86)); sprite->animNum = 2; sprite->animBeginning = TRUE; sprite->animEnded = FALSE; @@ -4006,12 +4209,12 @@ static void sub_8144514(struct Sprite *sprite) static void sub_81445D8(struct Sprite *sprite) { sub_8143B84(sprite); - if (gUnknown_0203AB88->var94 > 60.0f) + if (sRoulette->var94 > 60.0f) return; m4aSongNumStartOrChange(SE_TAMAKORO_E); - gUnknown_0203AB88->var98 = -(20.0f / (float)(gUnknown_0203AB88->var84)); - gUnknown_0203AB88->var90 = ((1.0f - gUnknown_0203AB88->var8C) / (float)(gUnknown_0203AB88->var84)); + sRoulette->var98 = -(20.0f / (float)(sRoulette->var84)); + sRoulette->var90 = ((1.0f - sRoulette->var8C) / (float)(sRoulette->var84)); sprite->animNum = 1; sprite->animBeginning = TRUE; sprite->animEnded = FALSE; @@ -4028,7 +4231,7 @@ static void sub_81446AC(struct Sprite *sprite) sprite->callback = sub_81445D8; } -static void sub_81446DC(struct Sprite *sprite) +static void CreateShroomishSprite(struct Sprite *sprite) { u16 t; u8 i; @@ -4039,29 +4242,29 @@ static void sub_81446DC(struct Sprite *sprite) struct Roulette *p; t = sprite->data[7] - 2; - p = gUnknown_0203AB88; // why??? - gUnknown_0203AB88->var3C[55] = CreateSprite(&gSpriteTemplate_85B79F8, 36, -12, 50); - gUnknown_0203AB88->var3C[56] = CreateSprite(&gSpriteTemplate_85B7ABC[0], s[sprite->data[0]][0], s[sprite->data[0]][1], 59); - gUnknown_0203AB88->var3C[57] = CreateSprite(&gSpriteTemplate_85B7ABC[1], 36, 140, 51); - gSprites[gUnknown_0203AB88->var3C[57]].oam.objMode = ST_OAM_OBJ_BLEND; + p = sRoulette; // why??? + sRoulette->spriteIds[SPR_CLEAR_MON] = CreateSprite(&sSpriteTemplate_Shroomish, 36, -12, 50); + sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_1] = CreateSprite(&sSpriteTemplate_ShroomishShadow[0], s[sprite->data[0]][0], s[sprite->data[0]][1], 59); + sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_2] = CreateSprite(&sSpriteTemplate_ShroomishShadow[1], 36, 140, 51); + gSprites[sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_2]].oam.objMode = ST_OAM_OBJ_BLEND; for (i = 0; i < 3; i++) { - gSprites[gUnknown_0203AB88->var3C[i + 55]].coordOffsetEnabled = FALSE; - gSprites[gUnknown_0203AB88->var3C[i + 55]].invisible = TRUE; - gSprites[gUnknown_0203AB88->var3C[i + 55]].animPaused = TRUE; - gSprites[gUnknown_0203AB88->var3C[i + 55]].affineAnimPaused = TRUE; - gSprites[gUnknown_0203AB88->var3C[i + 55]].data[4] = gUnknown_0203AB88->var3C[55]; - gSprites[gUnknown_0203AB88->var3C[i + 55]].data[5] = gUnknown_0203AB88->var3C[56]; - gSprites[gUnknown_0203AB88->var3C[i + 55]].data[6] = gUnknown_0203AB88->var3C[57]; - gSprites[gUnknown_0203AB88->var3C[i + 55]].data[2] = t; - gSprites[gUnknown_0203AB88->var3C[i + 55]].data[3] = (sprite->data[7] * gUnknown_085B6348[gUnknown_0203AB88->var04_0].var01) + - (gUnknown_085B6348[gUnknown_0203AB88->var04_0].var02 + 0xFFFF); + gSprites[sRoulette->spriteIds[i + SPR_CLEAR_MON]].coordOffsetEnabled = FALSE; + gSprites[sRoulette->spriteIds[i + SPR_CLEAR_MON]].invisible = TRUE; + gSprites[sRoulette->spriteIds[i + SPR_CLEAR_MON]].animPaused = TRUE; + gSprites[sRoulette->spriteIds[i + SPR_CLEAR_MON]].affineAnimPaused = TRUE; + gSprites[sRoulette->spriteIds[i + SPR_CLEAR_MON]].data[4] = sRoulette->spriteIds[SPR_CLEAR_MON]; + gSprites[sRoulette->spriteIds[i + SPR_CLEAR_MON]].data[5] = sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_1]; + gSprites[sRoulette->spriteIds[i + SPR_CLEAR_MON]].data[6] = sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_2]; + gSprites[sRoulette->spriteIds[i + SPR_CLEAR_MON]].data[2] = t; + gSprites[sRoulette->spriteIds[i + SPR_CLEAR_MON]].data[3] = (sprite->data[7] * gUnknown_085B6348[sRoulette->tableId].var01) + + (gUnknown_085B6348[sRoulette->tableId].var02 + 0xFFFF); } - gSprites[gUnknown_0203AB88->var3C[56]].coordOffsetEnabled = TRUE; - gUnknown_0203AB88->var38 = sprite; + gSprites[sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_1]].coordOffsetEnabled = TRUE; + sRoulette->var38 = sprite; } -static void sub_81448B8(struct Sprite *sprite) +static void CreateTaillowSprite(struct Sprite *sprite) { u8 i = 0; s16 t; @@ -4071,21 +4274,21 @@ static void sub_81448B8(struct Sprite *sprite) }; t = sprite->data[7] - 2; - gUnknown_0203AB88->var3C[55] = CreateSprite(&gSpriteTemplate_85B7A10, s[sprite->data[0]][0], s[sprite->data[0]][1], 50); - StartSpriteAnim(&gSprites[gUnknown_0203AB88->var3C[55]], sprite->data[0]); - gUnknown_0203AB88->var3C[56] = CreateSprite(&gUnknown_085B7AEC, s[sprite->data[0]][0], s[sprite->data[0]][1], 51); - gSprites[gUnknown_0203AB88->var3C[56]].affineAnimPaused = TRUE; - gSprites[gUnknown_0203AB88->var3C[56]].animPaused = TRUE; - sprite->data[7] = (t * gUnknown_085B6348[gUnknown_0203AB88->var04_0].var01) + (gUnknown_085B6348[gUnknown_0203AB88->var04_0].var10 + 45); + sRoulette->spriteIds[SPR_CLEAR_MON] = CreateSprite(&sSpriteTemplate_Taillow, s[sprite->data[0]][0], s[sprite->data[0]][1], 50); + StartSpriteAnim(&gSprites[sRoulette->spriteIds[SPR_CLEAR_MON]], sprite->data[0]); + sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_1] = CreateSprite(&sSpriteTemplate_TaillowShadow, s[sprite->data[0]][0], s[sprite->data[0]][1], 51); + gSprites[sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_1]].affineAnimPaused = TRUE; + gSprites[sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_1]].animPaused = TRUE; + sprite->data[7] = (t * gUnknown_085B6348[sRoulette->tableId].var01) + (gUnknown_085B6348[sRoulette->tableId].var10 + 45); for (; i < 2; i++) { - gSprites[gUnknown_0203AB88->var3C[55 + i]].data[4] = gUnknown_0203AB88->var3C[55]; - gSprites[gUnknown_0203AB88->var3C[55 + i]].data[5] = gUnknown_0203AB88->var3C[56]; - gSprites[gUnknown_0203AB88->var3C[55 + i]].data[6] = gUnknown_0203AB88->var3C[56]; - gSprites[gUnknown_0203AB88->var3C[55 + i]].data[2] = t; - gSprites[gUnknown_0203AB88->var3C[55 + i]].data[3] = sprite->data[7] - 45; + gSprites[sRoulette->spriteIds[SPR_CLEAR_MON + i]].data[4] = sRoulette->spriteIds[SPR_CLEAR_MON]; + gSprites[sRoulette->spriteIds[SPR_CLEAR_MON + i]].data[5] = sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_1]; + gSprites[sRoulette->spriteIds[SPR_CLEAR_MON + i]].data[6] = sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_1]; + gSprites[sRoulette->spriteIds[SPR_CLEAR_MON + i]].data[2] = t; + gSprites[sRoulette->spriteIds[SPR_CLEAR_MON + i]].data[3] = sprite->data[7] - 45; } - gUnknown_0203AB88->var38 = sprite; + sRoulette->var38 = sprite; } static void sub_8144A24(struct Sprite *sprite) @@ -4100,33 +4303,33 @@ static void sub_8144A24(struct Sprite *sprite) u8 s[10] = {}; u16 rand = Random(); - gUnknown_0203AB88->var7D = 1; - gUnknown_0203AB88->var03_5 = TRUE; - gUnknown_0203AB88->var03_6 = FALSE; - gUnknown_0203AB88->var7E = 0xFF; - gUnknown_0203AB88->var88 = sprite->data[3]; - gUnknown_0203AB88->var98 = 0.0f; - gUnknown_0203AB88->var8C = gUnknown_085B6348[gUnknown_0203AB88->var04_0].var1C; + sRoulette->var7D = 1; + sRoulette->var03_5 = TRUE; + sRoulette->var03_6 = FALSE; + sRoulette->var7E = 0xFF; + sRoulette->var88 = sprite->data[3]; + sRoulette->var98 = 0.0f; + sRoulette->var8C = gUnknown_085B6348[sRoulette->tableId].var1C; - o = (gUnknown_0203AB88->var04_0 * 30 + 33) + (0x1 - gUnknown_0203AB88->var03_0) * 15; + o = (sRoulette->tableId * 30 + 33) + (1 - sRoulette->useTaillow) * 15; for (i = 0; i < 4; i++) { if (o < sprite->data[3] && sprite->data[3] <= o + 90) { sprite->data[0] = i / 2; - gUnknown_0203AB88->var03_0 = i % 2; + sRoulette->useTaillow = i % 2; break; } if (i == 3) { sprite->data[0] = 1; - gUnknown_0203AB88->var03_0 = 1; + sRoulette->useTaillow = TRUE; break; } o += 90; } - if (gUnknown_0203AB88->var03_0) + if (sRoulette->useTaillow) { if (sprite->data[0]) PlayCry1(SPECIES_TAILLOW, -63); @@ -4139,25 +4342,25 @@ static void sub_8144A24(struct Sprite *sprite) } val = 2; - z = (gUnknown_0203AB88->var7F + 2) % 12; + z = (sRoulette->var7F + 2) % 12; - if (gUnknown_0203AB88->var03_0 == 1 && gUnknown_0203AB88->var04_0 == 1) + if (sRoulette->useTaillow == TRUE && sRoulette->tableId == 1) j += 6; else j += val; for (i = val; i < j; i++) { - if (!(gUnknown_0203AB88->var08 & gUnknown_085B62E4[z].var04)) + if (!(sRoulette->hitFlags & sRouletteSlots[z].flag)) { s[h++] = i; - if (p == 0 && (gUnknown_085B62E4[z].var04 & gUnknown_085B6154[gUnknown_0203AB88->var1B[gUnknown_0203AB88->var1A_0]].var0C)) + if (p == 0 && (sRouletteSlots[z].flag & sGridSelections[sRoulette->betSelection[sRoulette->curBallNum]].inSelectionFlags)) p = i; } - z = (z + 1) % 0xC; + z = (z + 1) % 12; } - if ((gUnknown_0203AB88->var03_0 + 1) & gUnknown_0203AB88->var02) + if ((sRoulette->useTaillow + 1) & sRoulette->partySpeciesFlags) { if (p && (rand & 0xFF) < 0xc0) sprite->data[7] = p; @@ -4169,7 +4372,7 @@ static void sub_8144A24(struct Sprite *sprite) sprite->data[7] = s[rand % h]; } - sprite->callback = sub_8144168; + sprite->callback = CreateClearSpeciesSprite; } static const u16 gUnknown_085B7B1A[] = { @@ -4192,11 +4395,11 @@ static void sub_8144C70(struct Sprite *sprite) sprite->pos1.x -= 2; if (sprite->pos1.x < -16) { - if (!gUnknown_0203AB88->var03_6) - gUnknown_0203AB88->var03_6 = TRUE; + if (!sRoulette->var03_6) + sRoulette->var03_6 = TRUE; DestroySprite(sprite); - gUnknown_0203AB88->var01 = 0; - gUnknown_0203AB88->var34 = gUnknown_085B7B1A[0]; + sRoulette->var01 = 0; + sRoulette->var34 = gUnknown_085B7B1A[0]; } } } @@ -4223,7 +4426,7 @@ static void sub_8144CD0(struct Sprite *sprite) else { gSpriteCoordOffsetY = 0; - gSprites[gUnknown_0203AB88->var3C[55]].animPaused = FALSE; + gSprites[sRoulette->spriteIds[SPR_CLEAR_MON]].animPaused = FALSE; DestroySprite(sprite); } } @@ -4234,9 +4437,9 @@ static void sub_8144D94(struct Sprite *sprite) sprite->data[1]++; t = sprite->data[1]; sprite->pos2.y = t * 0.039f * t; - gUnknown_0203AB88->var34 = gUnknown_085B7B1A[(gUnknown_0203AB88->var01 - 1) / 2]; - if (gUnknown_0203AB88->var01 < 19) - gUnknown_0203AB88->var01++; + sRoulette->var34 = gUnknown_085B7B1A[(sRoulette->var01 - 1) / 2]; + if (sRoulette->var01 < 19) + sRoulette->var01++; if (sprite->data[1] > 60) { sprite->data[1] = 0; @@ -4253,37 +4456,37 @@ static void sub_8144E60(struct Sprite *sprite) { if (sprite->data[7] == 0) { - if (gUnknown_0203AB88->var38->data[0] == 0) + if (sRoulette->var38->data[0] == 0) { - if (gUnknown_0203AB88->var38->data[3] != gUnknown_085B6348[gUnknown_0203AB88->var04_0].var08) + if (sRoulette->var38->data[3] != gUnknown_085B6348[sRoulette->tableId].var08) return; } else { - if (gUnknown_0203AB88->var38->data[3] != gUnknown_085B6348[gUnknown_0203AB88->var04_0].var08 + 180) + if (sRoulette->var38->data[3] != gUnknown_085B6348[sRoulette->tableId].var08 + 180) return; } sprite->invisible = FALSE; sprite->data[7]++; m4aSongNumStart(SE_RU_HYUU); - gUnknown_0203AB88->var01 = 1; - gUnknown_0203AB88->var34 = gUnknown_085B7B1A[0]; + sRoulette->var01 = 1; + sRoulette->var34 = gUnknown_085B7B1A[0]; } else { - gUnknown_0203AB88->var34 = gUnknown_085B7B1A[(gUnknown_0203AB88->var01 - 1) / 2]; - if (gUnknown_0203AB88->var01 < 19) - gUnknown_0203AB88->var01++; + sRoulette->var34 = gUnknown_085B7B1A[(sRoulette->var01 - 1) / 2]; + if (sRoulette->var01 < 19) + sRoulette->var01++; - if (gUnknown_0203AB88->var38->data[0] == 0) + if (sRoulette->var38->data[0] == 0) { - if (gUnknown_0203AB88->var38->data[3] != gUnknown_085B6348[gUnknown_0203AB88->var04_0].var0A) + if (sRoulette->var38->data[3] != gUnknown_085B6348[sRoulette->tableId].var0A) return; } else { - if (gUnknown_0203AB88->var38->data[3] != gUnknown_085B6348[gUnknown_0203AB88->var04_0].var0A + 180) + if (sRoulette->var38->data[3] != gUnknown_085B6348[sRoulette->tableId].var0A + 180) return; } @@ -4312,8 +4515,8 @@ static void sub_8144FB0(struct Sprite *sprite) sprite->animPaused = TRUE; m4aSongNumStop(SE_BASABASA); DestroySprite(sprite); - FreeOamMatrix(gSprites[gUnknown_0203AB88->var3C[56]].oam.matrixNum); - DestroySprite(&gSprites[gUnknown_0203AB88->var3C[56]]); + FreeOamMatrix(gSprites[sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_1]].oam.matrixNum); + DestroySprite(&gSprites[sRoulette->spriteIds[SPR_CLEAR_MON_SHADOW_1]]); } } @@ -4342,7 +4545,7 @@ static void sub_8145030(struct Sprite *sprite) else { m4aSongNumStart(SE_RU_HYUU); - StartSpriteAnim(sprite, gUnknown_0203AB88->var38->data[0] + 4); + StartSpriteAnim(sprite, sRoulette->var38->data[0] + 4); sprite->callback = sub_8144FB0; gSprites[sprite->data[6]].affineAnimPaused = FALSE; } @@ -4365,7 +4568,7 @@ static void sub_81450D8(struct Sprite *sprite) if (sprite->data[1]-- > 7) { - sprite->pos1.x += t[gUnknown_0203AB88->var38->data[0]] * 2; + sprite->pos1.x += t[sRoulette->var38->data[0]] * 2; if (IsSEPlaying()) { s8 pan = -((116 - sprite->pos1.x) / 2); @@ -4377,17 +4580,17 @@ static void sub_81450D8(struct Sprite *sprite) { if (sprite->data[1] >= 0) { - sprite->pos1.x += t[gUnknown_0203AB88->var38->data[0]] * z[7 - sprite->data[1]][0]; + sprite->pos1.x += t[sRoulette->var38->data[0]] * z[7 - sprite->data[1]][0]; sprite->pos1.y += z[7 - sprite->data[1]][1]; } else { m4aSongNumStartOrChange(SE_BASABASA); - if (gUnknown_0203AB88->var38->data[0] == 0) + if (sRoulette->var38->data[0] == 0) PlayCry1(SPECIES_TAILLOW, 63); else PlayCry1(SPECIES_TAILLOW, -63); - StartSpriteAnim(sprite, gUnknown_0203AB88->var38->data[0] + 2); + StartSpriteAnim(sprite, sRoulette->var38->data[0] + 2); sprite->data[1] = 45; sprite->callback = sub_8145030; } @@ -4400,7 +4603,7 @@ static void sub_8145218(struct Sprite *sprite) if (sprite->data[1]-- >= 0) { - sprite->pos1.x += t[gUnknown_0203AB88->var38->data[0]] * 2; + sprite->pos1.x += t[sRoulette->var38->data[0]] * 2; gSprites[sprite->data[6]].invisible ^= 1; } else @@ -4409,11 +4612,11 @@ static void sub_8145218(struct Sprite *sprite) } } -static void sub_8145294(struct Sprite *sprite) +static void SpriteCB_Taillow(struct Sprite *sprite) { - if (gUnknown_0203AB88->var38->data[0] == 0) + if (sRoulette->var38->data[0] == 0) { - if (gUnknown_0203AB88->var38->data[3] == gUnknown_085B6348[gUnknown_0203AB88->var04_0].var12 + 90) + if (sRoulette->var38->data[3] == gUnknown_085B6348[sRoulette->tableId].var12 + 90) { gSprites[sprite->data[6]].data[1] = 52; gSprites[sprite->data[4]].data[1] = 52; @@ -4425,7 +4628,7 @@ static void sub_8145294(struct Sprite *sprite) } else { - if (gUnknown_0203AB88->var38->data[3] == gUnknown_085B6348[gUnknown_0203AB88->var04_0].var14 + 270) + if (sRoulette->var38->data[3] == gUnknown_085B6348[sRoulette->tableId].var14 + 270) { gSprites[sprite->data[6]].data[1] = 46; gSprites[sprite->data[4]].data[1] = 46; diff --git a/src/roulette_util.c b/src/roulette_util.c index f1f04a73a..c51330f21 100755 --- a/src/roulette_util.c +++ b/src/roulette_util.c @@ -429,7 +429,7 @@ void UpdatePulseBlend(struct PulseBlend *pulseBlend) } } -void sub_8152008(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height) +void ClearGridSelectionRect(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height) { u16 *_dest; u8 i; @@ -446,7 +446,7 @@ void sub_8152008(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height) } } -void sub_8152058(u16 *dest, u16 *src, u8 left, u8 top, u8 width, u8 height) +void SetGridSelectionRect(u16 *dest, u16 *src, u8 left, u8 top, u8 width, u8 height) { u16 *_dest; u16 *_src = src;