2018-12-31 23:09:45 +01:00
# include "global.h"
2019-09-09 03:07:54 +02:00
# include "malloc.h"
2018-12-31 23:09:45 +01:00
# include "bg.h"
# include "coins.h"
2019-01-01 01:07:29 +01:00
# include "decompress.h"
2018-12-31 23:09:45 +01:00
# include "event_data.h"
2019-01-01 01:07:29 +01:00
# include "field_screen_effect.h"
2018-12-31 23:09:45 +01:00
# include "gpu_regs.h"
2019-01-02 23:55:50 +01:00
# include "graphics.h"
2018-12-31 23:09:45 +01:00
# include "m4a.h"
# include "main.h"
# include "menu.h"
# include "menu_helpers.h"
2019-01-01 01:07:29 +01:00
# include "overworld.h"
2018-12-31 23:09:45 +01:00
# include "palette.h"
# include "random.h"
# include "roulette.h"
# include "roulette_util.h"
# include "rtc.h"
# include "scanline_effect.h"
2019-01-01 01:07:29 +01:00
# include "script.h"
2018-12-31 23:09:45 +01:00
# include "sound.h"
# include "sprite.h"
2019-01-01 01:07:29 +01:00
# include "string_util.h"
2018-12-31 23:09:45 +01:00
# include "task.h"
# include "trig.h"
# include "tv.h"
# include "window.h"
2020-07-29 10:46:58 +02:00
# include "constants/coins.h"
2019-01-01 01:07:29 +01:00
# include "constants/rgb.h"
2020-07-29 10:46:58 +02:00
# include "constants/roulette.h"
2018-12-31 23:09:45 +01:00
# include "constants/species.h"
# include "constants/songs.h"
2020-07-29 10:46:58 +02:00
# 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
2018-12-31 23:09:45 +01:00
struct StructgUnknown_083F8DF4
{
u8 var00 ;
u8 var01 ;
u8 var02 ;
u8 var03 ;
u8 var04 ;
2019-01-02 23:40:40 +01:00
u8 filler_05 [ 3 ] ;
2018-12-31 23:09:45 +01:00
u16 var08 ;
u16 var0A ;
u16 var0C ;
2019-01-02 23:40:40 +01:00
u8 filler_0E [ 2 ] ;
2018-12-31 23:09:45 +01:00
u16 var10 ;
u16 var12 ;
u16 var14 ;
2019-01-02 23:40:40 +01:00
u8 filler_16 [ 2 ] ;
2018-12-31 23:09:45 +01:00
u16 var18 ;
u16 var1A ;
float var1C ;
} ;
2020-07-29 10:46:58 +02:00
struct GridSelection
2018-12-31 23:09:45 +01:00
{
u8 var00 ;
2020-07-29 10:46:58 +02:00
u8 baseMultiplier : 4 ;
u8 column : 4 ; // Never read
u8 row ; // Never read
u8 x ;
u8 y ;
u8 var05 ; // Never read
2018-12-31 23:09:45 +01:00
u8 var06 ;
2020-07-29 10:46:58 +02:00
u32 flag ;
u32 inSelectionFlags ;
2018-12-31 23:09:45 +01:00
u16 var10 ;
} ;
2020-07-29 10:46:58 +02:00
struct RouletteSlot
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
u8 id1 ; // Never read
u8 id2 ; // Never read
u8 gridSquare ;
u32 flag ;
2019-01-01 01:07:29 +01:00
} ;
2020-07-29 10:46:58 +02:00
static EWRAM_DATA struct Roulette
2018-12-31 23:09:45 +01:00
{
u8 var00 ;
u8 var01 ;
2020-07-29 10:46:58 +02:00
u8 partySpeciesFlags ;
bool8 useTaillow : 5 ;
bool8 var03_5 : 1 ;
bool8 var03_6 : 1 ;
bool8 var03_7 : 1 ;
u8 tableId : 2 ;
2018-12-31 23:09:45 +01:00
u8 var04_2 : 5 ;
2020-07-29 10:46:58 +02:00
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)
2018-12-31 23:09:45 +01:00
u8 var21 ;
u8 var22 ;
u8 var23 ;
s16 var24 ;
s16 var26 ;
s16 var28 ;
s16 var2A ;
struct OamMatrix var2C ;
u16 var34 ;
struct Sprite * var38 ;
2020-07-29 10:46:58 +02:00
u8 spriteIds [ MAX_SPRITES ] ; // Sprite IDs
2018-12-31 23:09:45 +01:00
u8 var7C ;
u8 var7D ;
u8 var7E ;
u8 var7F ;
s16 var80 ;
s16 var82 ;
2019-01-01 02:39:41 +01:00
u16 var84 ;
u16 var86 ;
2018-12-31 23:09:45 +01:00
float var88 ;
float var8C ;
float var90 ;
float var94 ;
float var98 ;
float var9C ;
float varA0 ;
u8 varA4 ;
u8 varA5 ;
2019-01-02 23:55:50 +01:00
u8 v51 [ 2 ] ;
2020-07-29 10:46:58 +02:00
u16 taskWaitDelay ;
u16 taskWaitKey ;
TaskFunc nextTask ;
2019-01-02 23:55:50 +01:00
u8 v46 [ 4 ] ;
2018-12-31 23:09:45 +01:00
TaskFunc varB4 ;
struct UnkStruct0 varB8 ;
u16 tilemapBuffers [ 7 ] [ 0x400 ] ;
u16 * unk_397C ;
2020-07-29 10:46:58 +02:00
} * sRoulette = NULL ;
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 ) ;
2019-01-02 23:55:50 +01:00
static void sub_8141778 ( u8 ) ;
2020-07-29 10:46:58 +02:00
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 ) ;
2019-01-02 23:55:50 +01:00
static void sub_8141FF4 ( u8 ) ;
2020-07-29 10:46:58 +02:00
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 ) ;
2019-01-02 23:55:50 +01:00
static void sub_8142814 ( void ) ;
2020-07-29 10:46:58 +02:00
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 ) ;
2019-01-02 23:55:50 +01:00
static void sub_81446AC ( struct Sprite * ) ;
2020-07-29 10:46:58 +02:00
static void CreateShroomishSprite ( struct Sprite * ) ;
static void CreateTaillowSprite ( struct Sprite * ) ;
2019-01-02 23:55:50 +01:00
static void sub_8144A24 ( struct Sprite * ) ;
static void sub_8144E60 ( struct Sprite * ) ;
2020-07-29 10:46:58 +02:00
static void SpriteCB_Taillow ( struct Sprite * ) ;
2019-01-02 23:55:50 +01:00
2019-10-07 08:00:16 +02:00
extern const u8 Roulette_Text_ControlsInstruction [ ] ;
extern const u8 Roulette_Text_KeepPlaying [ ] ;
extern const u8 Roulette_Text_Jackpot [ ] ;
extern const u8 Roulette_Text_ItsAHit [ ] ;
extern const u8 Roulette_Text_NothingDoing [ ] ;
extern const u8 Roulette_Text_YouveWonXCoins [ ] ;
extern const u8 Roulette_Text_BoardWillBeCleared [ ] ;
extern const u8 Roulette_Text_CoinCaseIsFull [ ] ;
extern const u8 Roulette_Text_NoCoinsLeft [ ] ;
extern const u8 Roulette_Text_PlayMinimumWagerIsX [ ] ;
extern const u8 Roulette_Text_SpecialRateTable [ ] ;
extern const u8 Roulette_Text_NotEnoughCoins [ ] ;
2018-12-31 23:09:45 +01:00
2019-01-02 23:40:40 +01:00
static const u16 gUnknown_085B5BFC [ ] = INCBIN_U16 ( " graphics/roulette/85B5BFC.gbapal " ) ;
static const u32 gUnknown_085B5DFC [ ] = INCBIN_U32 ( " graphics/roulette/85B5DFC.bin.lz " ) ;
2020-07-29 10:46:58 +02:00
static const u32 sWheel_Tilemap [ ] = INCBIN_U32 ( " graphics/roulette/wheel_map.bin.lz " ) ;
static const struct BgTemplate sBgTemplates [ ] =
2019-01-02 23:40:40 +01:00
{
{
. bg = 0 ,
. charBaseIndex = 2 ,
. mapBaseIndex = 31 ,
. screenSize = 0 ,
. paletteMode = 0 ,
. priority = 0 ,
. baseTile = 0
} ,
{
. bg = 1 ,
. charBaseIndex = 0 ,
. mapBaseIndex = 4 ,
. screenSize = 1 ,
. paletteMode = 0 ,
. priority = 1 ,
. baseTile = 0
} ,
{
. bg = 2 ,
. charBaseIndex = 1 ,
. mapBaseIndex = 6 ,
. screenSize = 1 ,
. paletteMode = 1 ,
. priority = 2 ,
. baseTile = 0
}
} ;
2020-07-29 10:46:58 +02:00
static const struct WindowTemplate sWindowTemplates [ ] =
2019-01-02 23:40:40 +01:00
{
{
. bg = 0 ,
. tilemapLeft = 3 ,
. tilemapTop = 15 ,
. width = 24 ,
. height = 4 ,
. paletteNum = 15 ,
. baseBlock = 0xC5
} ,
// BUG: Array not terminated properly
//DUMMY_WIN_TEMPLATE
} ;
2020-07-29 10:46:58 +02:00
// var00, sprite id offset (from 7)?
static const struct GridSelection sGridSelections [ NUM_GRID_SELECTIONS + 1 ] =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
[ SELECTION_NONE ] = {
2019-01-02 23:40:40 +01:00
. var00 = 0xFF ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = 0 ,
. column = 0 ,
. row = 0 ,
. x = 7 ,
. y = 7 ,
2019-01-02 23:40:40 +01:00
. var05 = 0 ,
. var06 = 0 ,
2020-07-29 10:46:58 +02:00
. flag = 0 ,
. inSelectionFlags = 0 ,
2019-01-02 23:40:40 +01:00
. var10 = 0x0 ,
} ,
2020-07-29 10:46:58 +02:00
[ COL_WYNAUT ] = {
2019-01-02 23:40:40 +01:00
. var00 = 12 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_BOARD_POKES ,
. column = 1 ,
. row = 0 ,
. x = 17 ,
. y = 7 ,
2019-01-02 23:40:40 +01:00
. var05 = 0 ,
. var06 = 0 ,
2020-07-29 10:46:58 +02:00
. flag = F_WYNAUT_COL ,
. inSelectionFlags = F_WYNAUT_COL | F_ORANGE_WYNAUT | F_GREEN_WYNAUT | F_PURPLE_WYNAUT ,
2019-01-02 23:40:40 +01:00
. var10 = 0xE000 ,
} ,
2020-07-29 10:46:58 +02:00
[ COL_AZURILL ] = {
2019-01-02 23:40:40 +01:00
. var00 = 13 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_BOARD_POKES ,
. column = 2 ,
. row = 0 ,
. x = 20 ,
. y = 7 ,
2019-01-02 23:40:40 +01:00
. var05 = 0 ,
. var06 = 0 ,
2020-07-29 10:46:58 +02:00
. flag = F_AZURILL_COL ,
. inSelectionFlags = F_AZURILL_COL | F_ORANGE_AZURILL | F_GREEN_AZURILL | F_PURPLE_AZURILL ,
2019-01-02 23:40:40 +01:00
. var10 = 0xE000 ,
} ,
2020-07-29 10:46:58 +02:00
[ COL_SKITTY ] = {
2019-01-02 23:40:40 +01:00
. var00 = 14 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_BOARD_POKES ,
. column = 3 ,
. row = 0 ,
. x = 23 ,
. y = 7 ,
2019-01-02 23:40:40 +01:00
. var05 = 0 ,
. var06 = 0 ,
2020-07-29 10:46:58 +02:00
. flag = F_SKITTY_COL ,
. inSelectionFlags = F_SKITTY_COL | F_ORANGE_SKITTY | F_GREEN_SKITTY | F_PURPLE_SKITTY ,
2019-01-02 23:40:40 +01:00
. var10 = 0xE000 ,
} ,
2020-07-29 10:46:58 +02:00
[ COL_MAKUHITA ] = {
2019-01-02 23:40:40 +01:00
. var00 = 15 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_BOARD_POKES ,
. column = 4 ,
. row = 0 ,
. x = 26 ,
. y = 7 ,
2019-01-02 23:40:40 +01:00
. var05 = 0 ,
. var06 = 0 ,
2020-07-29 10:46:58 +02:00
. flag = F_MAKUHITA_COL ,
. inSelectionFlags = F_MAKUHITA_COL | F_ORANGE_MAKUHITA | F_GREEN_MAKUHITA | F_PURPLE_MAKUHITA ,
2019-01-02 23:40:40 +01:00
. var10 = 0xE000 ,
} ,
2020-07-29 10:46:58 +02:00
[ ROW_ORANGE ] = {
2019-01-02 23:40:40 +01:00
. var00 = 16 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_BOARD_COLORS ,
. column = 0 ,
. row = 1 ,
. x = 14 ,
. y = 10 ,
2019-01-02 23:40:40 +01:00
. var05 = 0 ,
. var06 = 12 ,
2020-07-29 10:46:58 +02:00
. flag = F_ORANGE_ROW ,
. inSelectionFlags = F_ORANGE_ROW | F_ORANGE_WYNAUT | F_ORANGE_AZURILL | F_ORANGE_SKITTY | F_ORANGE_MAKUHITA ,
2019-01-02 23:40:40 +01:00
. var10 = 0x249 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_ORANGE_WYNAUT ] = {
2019-01-02 23:40:40 +01:00
. var00 = 0 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 1 ,
. row = 1 ,
. x = 17 ,
. y = 10 ,
2019-01-02 23:40:40 +01:00
. var05 = 3 ,
. var06 = 3 ,
2020-07-29 10:46:58 +02:00
. flag = F_ORANGE_WYNAUT ,
. inSelectionFlags = F_ORANGE_WYNAUT ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2001 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_ORANGE_AZURILL ] = {
2019-01-02 23:40:40 +01:00
. var00 = 9 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 2 ,
. row = 1 ,
. x = 20 ,
. y = 10 ,
2019-01-02 23:40:40 +01:00
. var05 = 3 ,
. var06 = 3 ,
2020-07-29 10:46:58 +02:00
. flag = F_ORANGE_AZURILL ,
. inSelectionFlags = F_ORANGE_AZURILL ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2200 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_ORANGE_SKITTY ] = {
2019-01-02 23:40:40 +01:00
. var00 = 6 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 3 ,
. row = 1 ,
. x = 23 ,
. y = 10 ,
2019-01-02 23:40:40 +01:00
. var05 = 3 ,
. var06 = 3 ,
2020-07-29 10:46:58 +02:00
. flag = F_ORANGE_SKITTY ,
. inSelectionFlags = F_ORANGE_SKITTY ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2040 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_ORANGE_MAKUHITA ] = {
2019-01-02 23:40:40 +01:00
. var00 = 3 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 4 ,
. row = 1 ,
. x = 26 ,
. y = 10 ,
2019-01-02 23:40:40 +01:00
. var05 = 3 ,
. var06 = 3 ,
2020-07-29 10:46:58 +02:00
. flag = F_ORANGE_MAKUHITA ,
. inSelectionFlags = F_ORANGE_MAKUHITA ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2008 ,
} ,
2020-07-29 10:46:58 +02:00
[ ROW_GREEN ] = {
2019-01-02 23:40:40 +01:00
. var00 = 17 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_BOARD_COLORS ,
. column = 0 ,
. row = 2 ,
. x = 14 ,
. y = 13 ,
2019-01-02 23:40:40 +01:00
. var05 = 3 ,
. var06 = 15 ,
2020-07-29 10:46:58 +02:00
. flag = F_GREEN_ROW ,
. inSelectionFlags = F_GREEN_ROW | F_GREEN_WYNAUT | F_GREEN_AZURILL | F_GREEN_SKITTY | F_GREEN_MAKUHITA ,
2019-01-02 23:40:40 +01:00
. var10 = 0x492 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_GREEN_WYNAUT ] = {
2019-01-02 23:40:40 +01:00
. var00 = 4 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 1 ,
. row = 2 ,
. x = 17 ,
. y = 13 ,
2019-01-02 23:40:40 +01:00
. var05 = 6 ,
. var06 = 6 ,
2020-07-29 10:46:58 +02:00
. flag = F_GREEN_WYNAUT ,
. inSelectionFlags = F_GREEN_WYNAUT ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2010 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_GREEN_AZURILL ] = {
2019-01-02 23:40:40 +01:00
. var00 = 1 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 2 ,
. row = 2 ,
. x = 20 ,
. y = 13 ,
2019-01-02 23:40:40 +01:00
. var05 = 6 ,
. var06 = 6 ,
2020-07-29 10:46:58 +02:00
. flag = F_GREEN_AZURILL ,
. inSelectionFlags = F_GREEN_AZURILL ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2002 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_GREEN_SKITTY ] = {
2019-01-02 23:40:40 +01:00
. var00 = 10 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 3 ,
. row = 2 ,
. x = 23 ,
. y = 13 ,
2019-01-02 23:40:40 +01:00
. var05 = 6 ,
. var06 = 6 ,
2020-07-29 10:46:58 +02:00
. flag = F_GREEN_SKITTY ,
. inSelectionFlags = F_GREEN_SKITTY ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2400 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_GREEN_MAKUHITA ] = {
2019-01-02 23:40:40 +01:00
. var00 = 7 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 4 ,
. row = 2 ,
. x = 26 ,
. y = 13 ,
2019-01-02 23:40:40 +01:00
. var05 = 6 ,
. var06 = 6 ,
2020-07-29 10:46:58 +02:00
. flag = F_GREEN_MAKUHITA ,
. inSelectionFlags = F_GREEN_MAKUHITA ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2080 ,
} ,
2020-07-29 10:46:58 +02:00
[ ROW_PURPLE ] = {
2019-01-02 23:40:40 +01:00
. var00 = 18 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_BOARD_COLORS ,
. column = 0 ,
. row = 3 ,
. x = 14 ,
. y = 16 ,
2019-01-02 23:40:40 +01:00
. var05 = 6 ,
. var06 = 18 ,
2020-07-29 10:46:58 +02:00
. flag = F_PURPLE_ROW ,
. inSelectionFlags = F_PURPLE_ROW | F_PURPLE_WYNAUT | F_PURPLE_AZURILL | F_PURPLE_SKITTY | F_PURPLE_MAKUHITA ,
2019-01-02 23:40:40 +01:00
. var10 = 0x924 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_PURPLE_WYNAUT ] = {
2019-01-02 23:40:40 +01:00
. var00 = 8 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 1 ,
. row = 3 ,
. x = 17 ,
. y = 16 ,
2019-01-02 23:40:40 +01:00
. var05 = 9 ,
. var06 = 9 ,
2020-07-29 10:46:58 +02:00
. flag = F_PURPLE_WYNAUT ,
. inSelectionFlags = F_PURPLE_WYNAUT ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2100 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_PURPLE_AZURILL ] = {
2019-01-02 23:40:40 +01:00
. var00 = 5 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 2 ,
. row = 3 ,
. x = 20 ,
. y = 16 ,
2019-01-02 23:40:40 +01:00
. var05 = 9 ,
. var06 = 9 ,
2020-07-29 10:46:58 +02:00
. flag = F_PURPLE_AZURILL ,
. inSelectionFlags = F_PURPLE_AZURILL ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2020 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_PURPLE_SKITTY ] = {
2019-01-02 23:40:40 +01:00
. var00 = 2 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 3 ,
. row = 3 ,
. x = 23 ,
. y = 16 ,
2019-01-02 23:40:40 +01:00
. var05 = 9 ,
. var06 = 9 ,
2020-07-29 10:46:58 +02:00
. flag = F_PURPLE_SKITTY ,
. inSelectionFlags = F_PURPLE_SKITTY ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2004 ,
} ,
2020-07-29 10:46:58 +02:00
[ SQU_PURPLE_MAKUHITA ] = {
2019-01-02 23:40:40 +01:00
. var00 = 11 ,
2020-07-29 10:46:58 +02:00
. baseMultiplier = NUM_ROULETTE_SLOTS ,
. column = 4 ,
. row = 3 ,
. x = 26 ,
. y = 16 ,
2019-01-02 23:40:40 +01:00
. var05 = 9 ,
. var06 = 9 ,
2020-07-29 10:46:58 +02:00
. flag = F_PURPLE_MAKUHITA ,
. inSelectionFlags = F_PURPLE_MAKUHITA ,
2019-01-02 23:40:40 +01:00
. var10 = 0x2800 ,
} ,
} ;
2020-07-29 10:46:58 +02:00
static const struct RouletteSlot sRouletteSlots [ ] =
2019-01-02 23:40:40 +01:00
{
{
2020-07-29 10:46:58 +02:00
. id1 = 0 ,
. id2 = 1 ,
. gridSquare = SQU_ORANGE_WYNAUT ,
. flag = F_ORANGE_WYNAUT ,
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. id1 = 1 ,
. id2 = 3 ,
. gridSquare = SQU_GREEN_AZURILL ,
. flag = F_GREEN_AZURILL ,
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. id1 = 2 ,
. id2 = 5 ,
. gridSquare = SQU_PURPLE_SKITTY ,
. flag = F_PURPLE_SKITTY ,
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. id1 = 3 ,
. id2 = 7 ,
. gridSquare = SQU_ORANGE_MAKUHITA ,
. flag = F_ORANGE_MAKUHITA ,
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. id1 = 4 ,
. id2 = 9 ,
. gridSquare = SQU_GREEN_WYNAUT ,
. flag = F_GREEN_WYNAUT ,
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. id1 = 5 ,
. id2 = 11 ,
. gridSquare = SQU_PURPLE_AZURILL ,
. flag = F_PURPLE_AZURILL ,
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. id1 = 6 ,
. id2 = 13 ,
. gridSquare = SQU_ORANGE_SKITTY ,
. flag = F_ORANGE_SKITTY ,
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. id1 = 7 ,
. id2 = 15 ,
. gridSquare = SQU_GREEN_MAKUHITA ,
. flag = F_GREEN_MAKUHITA ,
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. id1 = 8 ,
. id2 = 17 ,
. gridSquare = SQU_PURPLE_WYNAUT ,
. flag = F_PURPLE_WYNAUT ,
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. id1 = 9 ,
. id2 = 19 ,
. gridSquare = SQU_ORANGE_AZURILL ,
. flag = F_ORANGE_AZURILL ,
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. id1 = 10 ,
. id2 = 21 ,
. gridSquare = SQU_GREEN_SKITTY ,
. flag = F_GREEN_SKITTY ,
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. id1 = 11 ,
. id2 = 23 ,
. gridSquare = SQU_PURPLE_MAKUHITA ,
. flag = F_PURPLE_MAKUHITA ,
2019-01-02 23:40:40 +01:00
} ,
} ;
2020-07-29 10:46:58 +02:00
static const u8 sTableMinBets [ ] = { 1 , 3 , 1 , 6 } ;
2019-01-02 23:40:40 +01:00
static const struct StructgUnknown_083F8DF4 gUnknown_085B6348 [ ] =
{
{
. var00 = 1 ,
. var01 = 60 ,
. var02 = 30 ,
. var03 = 1 ,
. var04 = 1 ,
. var08 = 45 ,
. var0A = 30 ,
. var0C = 1 ,
. var10 = 75 ,
. var12 = 27 ,
. var14 = 24 ,
. var18 = 10 ,
. var1A = 360 ,
. var1C = - 0.5f
} ,
{
. var00 = 3 ,
. var01 = 30 ,
. var02 = 15 ,
. var03 = 1 ,
. var04 = 0 ,
. var08 = 75 ,
. var0A = 60 ,
. var0C = 2 ,
. var10 = 0 ,
. var12 = 54 ,
. var14 = 48 ,
. var18 = 10 ,
. var1A = 270 ,
. var1C = - 1.0f
}
} ;
static const struct UnkStruct1 gUnknown_085B6388 [ ] =
{
{
. var00 = 0x8000 ,
. var02 = 0x0005 ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x8000 ,
. var02 = 0x000A ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x8000 ,
. var02 = 0x0015 ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x8000 ,
. var02 = 0x0055 ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x8000 ,
. var02 = 0x005A ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x8000 ,
. var02 = 0x0065 ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x8000 ,
. var02 = 0x0075 ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x8000 ,
. var02 = 0x007A ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x8000 ,
. var02 = 0x0085 ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x8000 ,
. var02 = 0x0095 ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x8000 ,
. var02 = 0x009A ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x8000 ,
. var02 = 0x00A5 ,
. var04 = 1 ,
. var05 = 1 ,
. var06 = 0xFF ,
. var07_0 = 8 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x77D6 ,
. var02 = 0x0028 ,
. var04 = 2 ,
. var05 = 10 ,
. var06 = 0xFF ,
. var07_0 = 14 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
} ;
static const struct UnkStruct1 gUnknown_085B63F0 [ ] =
{
{
. var00 = 0x53FF ,
. var02 = 0x0101 ,
. var04 = 5 ,
. var05 = 30 ,
. var06 = 0xFF ,
. var07_0 = 14 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x7FFB ,
. var02 = 0x0106 ,
. var04 = 5 ,
. var05 = 30 ,
. var06 = 0xFF ,
. var07_0 = 14 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
} ,
{
. var00 = 0x7F7F ,
. var02 = 0x010B ,
. var04 = 5 ,
. var05 = 30 ,
. var06 = 0xFF ,
. var07_0 = 14 ,
2020-07-19 21:57:20 +02:00
. var07_5 = - 2 ,
2019-01-02 23:40:40 +01:00
. var07_7 = 0
}
} ;
2020-07-29 10:46:58 +02:00
static const struct YesNoFuncTable sYesNoTable_AcceptMinBet =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
Task_AcceptMinBet ,
Task_DeclineMinBet
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const struct YesNoFuncTable sYesNoTable_KeepPlaying =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
Task_ContinuePlaying ,
Task_StopPlaying
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static void CB2_Roulette ( void )
2018-12-31 23:09:45 +01:00
{
RunTasks ( ) ;
AnimateSprites ( ) ;
BuildOamBuffer ( ) ;
2020-07-29 10:46:58 +02:00
if ( sRoulette - > varB8 . var00 )
task_tutorial_controls_fadein ( & sRoulette - > varB8 ) ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
static void VBlankCB_Roulette ( void )
2018-12-31 23:09:45 +01:00
{
LoadOam ( ) ;
ProcessSpriteCopyRequests ( ) ;
TransferPlttBuffer ( ) ;
sub_8142814 ( ) ;
2020-07-29 10:46:58 +02:00
SetGpuReg ( REG_OFFSET_BG1HOFS , 0x200 - sRoulette - > var26 ) ;
if ( sRoulette - > var01 )
SetGpuReg ( REG_OFFSET_BLDALPHA , sRoulette - > var34 ) ;
if ( sRoulette - > var2A ! = 0 )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
DmaCopy16 ( 3 , & sRoulette - > tilemapBuffers [ 2 ] [ 0xE0 ] , ( void * ) BG_SCREEN_ADDR ( 4 ) + 0x1C0 , 0x340 ) ;
sRoulette - > var2A = 0 ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
switch ( sRoulette - > var28 )
2018-12-31 23:09:45 +01:00
{
case 1 :
SetBgAttribute ( 0 , BG_ATTR_CHARBASEINDEX , 0 ) ;
ShowBg ( 0 ) ;
2020-07-29 10:46:58 +02:00
DmaCopy16 ( 3 , & sRoulette - > tilemapBuffers [ 0 ] [ 0xE0 ] , ( void * ) BG_SCREEN_ADDR ( 31 ) + 0x1C0 , 0x340 ) ;
sRoulette - > var28 = 2 ;
2018-12-31 23:09:45 +01:00
break ;
case 2 :
2020-07-29 10:46:58 +02:00
DmaCopy16 ( 3 , & sRoulette - > tilemapBuffers [ 0 ] [ 0xE0 ] , ( void * ) BG_SCREEN_ADDR ( 31 ) + 0x1C0 , 0x340 ) ;
2018-12-31 23:09:45 +01:00
break ;
case 0xFF :
SetBgAttribute ( 0 , BG_ATTR_CHARBASEINDEX , 2 ) ;
ShowBg ( 0 ) ;
DmaFill16 ( 3 , 0 , ( void * ) BG_SCREEN_ADDR ( 31 ) + 0x1C0 , 0x340 ) ;
2020-07-29 10:46:58 +02:00
sRoulette - > var28 = 0 ;
2018-12-31 23:09:45 +01:00
case 0 :
break ;
}
}
2020-07-29 10:46:58 +02:00
static void InitRouletteBgAndWindows ( void )
2018-12-31 23:09:45 +01:00
{
u32 size = 0 ;
2020-07-29 10:46:58 +02:00
sRoulette = AllocZeroed ( sizeof ( * sRoulette ) ) ;
2018-12-31 23:09:45 +01:00
ResetBgsAndClearDma3BusyFlags ( 0 ) ;
2020-07-29 10:46:58 +02:00
InitBgsFromTemplates ( 1 , sBgTemplates , ARRAY_COUNT ( sBgTemplates ) ) ;
SetBgTilemapBuffer ( 0 , sRoulette - > tilemapBuffers [ 0 ] ) ;
SetBgTilemapBuffer ( 1 , sRoulette - > tilemapBuffers [ 2 ] ) ;
SetBgTilemapBuffer ( 2 , sRoulette - > tilemapBuffers [ 6 ] ) ;
InitWindows ( sWindowTemplates ) ;
2020-06-20 01:58:56 +02:00
InitTextBoxGfxAndPrinters ( ) ;
2020-07-29 10:46:58 +02:00
sTextWindowId = 0 ;
sRoulette - > unk_397C = malloc_and_decompress ( gUnknown_085B5DFC , & size ) ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
static void FreeRoulette ( void )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
FREE_AND_SET_NULL ( sRoulette - > unk_397C ) ;
2018-12-31 23:09:45 +01:00
FreeAllWindowBuffers ( ) ;
UnsetBgTilemapBuffer ( 0 ) ;
UnsetBgTilemapBuffer ( 1 ) ;
UnsetBgTilemapBuffer ( 2 ) ;
ResetBgsAndClearDma3BusyFlags ( 0 ) ;
2020-07-29 10:46:58 +02:00
memset ( sRoulette , 0 , sizeof ( * sRoulette ) ) ;
FREE_AND_SET_NULL ( sRoulette ) ;
2018-12-31 23:09:45 +01:00
}
2019-01-02 23:55:50 +01:00
static void sub_8140470 ( void )
2018-12-31 23:09:45 +01:00
{
u8 i ;
2019-01-02 23:40:40 +01:00
u16 arr [ 3 ] = { RGB ( 24 , 4 , 10 ) , RGB ( 10 , 19 , 6 ) , RGB ( 24 , 4 , 10 ) } ; // the third is never used ?
2018-12-31 23:09:45 +01:00
2020-07-29 10:46:58 +02:00
sRoulette - > tableId = ( gSpecialVar_0x8004 & 1 ) ;
2018-12-31 23:09:45 +01:00
2020-07-29 10:46:58 +02:00
if ( gSpecialVar_0x8004 & ROULETTE_SPECIAL_RATE )
sRoulette - > isSpecialRate = TRUE ;
2018-12-31 23:09:45 +01:00
2020-07-29 10:46:58 +02:00
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 ;
2018-12-31 23:09:45 +01:00
2020-07-29 10:46:58 +02:00
if ( sRoulette - > minBet = = 1 )
2018-12-31 23:09:45 +01:00
gPlttBufferUnfaded [ 0 ] = gPlttBufferUnfaded [ 0x51 ] = gPlttBufferFaded [ 0 ] = gPlttBufferFaded [ 0x51 ] = arr [ 0 ] ;
else
gPlttBufferUnfaded [ 0 ] = gPlttBufferUnfaded [ 0x51 ] = gPlttBufferFaded [ 0 ] = gPlttBufferFaded [ 0x51 ] = arr [ 1 ] ;
2020-07-29 10:46:58 +02:00
sub_8151678 ( & sRoulette - > varB8 ) ;
2018-12-31 23:09:45 +01:00
for ( i = 0 ; i < 13 ; i + + )
{
2020-07-29 10:46:58 +02:00
sub_815168C ( & sRoulette - > varB8 , i , & gUnknown_085B6388 [ i ] ) ;
2018-12-31 23:09:45 +01:00
}
2019-04-11 12:05:56 +02:00
2018-12-31 23:09:45 +01:00
for ( i = 0 ; i < PARTY_SIZE ; i + + )
{
switch ( GetMonData ( & gPlayerParty [ i ] , MON_DATA_SPECIES2 ) )
{
case SPECIES_SHROOMISH :
2020-07-29 10:46:58 +02:00
sRoulette - > partySpeciesFlags | = HAS_SHROOMISH ;
2018-12-31 23:09:45 +01:00
break ;
case SPECIES_TAILLOW :
2020-07-29 10:46:58 +02:00
sRoulette - > partySpeciesFlags | = HAS_TAILLOW ;
2018-12-31 23:09:45 +01:00
break ;
}
}
RtcCalcLocalTime ( ) ;
}
2020-07-29 10:46:58 +02:00
// 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 )
2018-12-31 23:09:45 +01:00
{
u8 taskId ;
switch ( gMain . state )
{
case 0 :
SetVBlankCallback ( NULL ) ;
ScanlineEffect_Stop ( ) ;
SetVBlankHBlankCallbacksToNull ( ) ;
ResetVramOamAndBgCntRegs ( ) ;
ResetAllBgsCoordinates ( ) ;
break ;
case 1 :
2020-07-29 10:46:58 +02:00
InitRouletteBgAndWindows ( ) ;
2018-12-31 23:09:45 +01:00
DeactivateAllTextPrinters ( ) ;
SetGpuReg ( REG_OFFSET_BLDCNT , BLDCNT_EFFECT_NONE |
BLDCNT_TGT2_BG2 |
BLDCNT_TGT2_BD ) ;
SetGpuReg ( REG_OFFSET_BLDALPHA , BLDALPHA_BLEND ( 10 , 6 ) ) ;
break ;
case 2 :
ResetPaletteFade ( ) ;
ResetSpriteData ( ) ;
ResetTasks ( ) ;
2020-05-14 10:37:09 +02:00
ResetTempTileDataBuffers ( ) ;
2018-12-31 23:09:45 +01:00
break ;
case 3 :
LoadPalette ( & gUnknown_085B5BFC , 0 , 0x1C0 ) ;
2020-07-29 10:46:58 +02:00
DecompressAndCopyTileDataToVram ( 1 , gRouletteMenu_Gfx , 0 , 0 , 0 ) ;
DecompressAndCopyTileDataToVram ( 2 , gRouletteWheel_Gfx , 0 , 0 , 0 ) ;
2018-12-31 23:09:45 +01:00
break ;
case 4 :
2020-05-14 10:37:09 +02:00
if ( FreeTempTileDataBuffersIfPossible ( ) )
2018-12-31 23:09:45 +01:00
return ;
2019-04-11 12:05:56 +02:00
2018-12-31 23:09:45 +01:00
sub_8140470 ( ) ;
2020-07-29 10:46:58 +02:00
CopyToBgTilemapBuffer ( 2 , sWheel_Tilemap , 0 , 0 ) ;
2018-12-31 23:09:45 +01:00
break ;
case 5 :
2020-07-29 10:46:58 +02:00
LoadOrFreeMiscSpritePalettesAndSheets ( FALSE ) ;
CreateBoardBallSprites ( ) ;
CreateBoardCenterSprite ( ) ;
CreateInterfaceSprites ( ) ;
CreateGridSprites ( ) ;
CreateGridBallSprites ( ) ;
CreateBoardIconSprites ( ) ;
2018-12-31 23:09:45 +01:00
break ;
case 6 :
AnimateSprites ( ) ;
BuildOamBuffer ( ) ;
2020-07-29 10:46:58 +02:00
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 ) ;
2019-01-01 02:39:41 +01:00
gSpriteCoordOffsetX = - 60 ;
gSpriteCoordOffsetY = 0 ;
2018-12-31 23:09:45 +01:00
break ;
case 7 :
SetGpuReg ( REG_OFFSET_DISPCNT , DISPCNT_MODE_0 |
DISPCNT_OBJ_1D_MAP |
DISPCNT_OBJ_ON ) ;
CopyBgTilemapBufferToVram ( 1 ) ;
CopyBgTilemapBufferToVram ( 2 ) ;
ShowBg ( 0 ) ;
ShowBg ( 1 ) ;
ShowBg ( 2 ) ;
break ;
case 8 :
EnableInterrupts ( INTR_FLAG_VBLANK ) ;
2020-07-29 10:46:58 +02:00
SetVBlankCallback ( VBlankCB_Roulette ) ;
2018-12-31 23:09:45 +01:00
BeginHardwarePaletteFade ( 0xFF , 0 , 16 , 0 , 1 ) ;
2020-07-29 10:46:58 +02:00
taskId = sRoulette - > varA4 = CreateTask ( Task_StartPlaying , 0 ) ;
gTasks [ taskId ] . tBallNum = BALLS_PER_ROUND ;
gTasks [ taskId ] . tCoins = GetCoins ( ) ;
2019-02-22 22:03:35 +01:00
AlertTVThatPlayerPlayedRoulette ( GetCoins ( ) ) ;
2020-07-29 10:46:58 +02:00
sRoulette - > varA5 = CreateTask ( Task_SpinBoard , 1 ) ;
SetMainCallback2 ( CB2_Roulette ) ;
2018-12-31 23:09:45 +01:00
return ;
}
gMain . state + + ;
}
2020-07-29 10:46:58 +02:00
static void Task_SpinBoard ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
s16 sin ;
s16 cos ;
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var21 + + = = sRoulette - > var23 )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
sRoulette - > var21 = 0 ;
if ( ( sRoulette - > var24 - = sRoulette - > var22 ) < 0 )
sRoulette - > var24 = 360 - sRoulette - > var22 ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
sin = Sin2 ( sRoulette - > var24 ) ;
cos = Cos2 ( sRoulette - > var24 ) ;
2018-12-31 23:09:45 +01:00
sin = sin / 16 ;
2020-07-29 10:46:58 +02:00
sRoulette - > var2C . a = sRoulette - > var2C . d = cos / 16 ;
sRoulette - > var2C . b = sin ;
sRoulette - > var2C . c = - sin ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_StartPlaying ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
if ( UpdatePaletteFade ( ) = = 0 )
{
SetGpuReg ( REG_OFFSET_BLDCNT , BLDCNT_EFFECT_NONE |
BLDCNT_TGT2_BG2 |
BLDCNT_TGT2_BD ) ;
SetGpuReg ( REG_OFFSET_BLDALPHA , BLDALPHA_BLEND ( 8 , 8 ) ) ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . tBallNum = 0 ;
2018-12-31 23:09:45 +01:00
sub_8141FF4 ( taskId ) ;
2020-07-29 10:46:58 +02:00
ResetHits ( ) ;
HideBoardBalls ( ) ;
DrawGridBackground ( SELECTION_NONE ) ;
SetBallCounterNumLeft ( BALLS_PER_ROUND ) ;
StartTaskAfterDelayOrInput ( taskId , Task_ContinuePlaying , 0xFFFF , A_BUTTON | B_BUTTON ) ;
2018-12-31 23:09:45 +01:00
}
}
2020-07-29 10:46:58 +02:00
static void Task_AskKeepPlaying ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
2019-02-27 04:30:40 +01:00
DisplayYesNoMenuDefaultYes ( ) ;
2020-07-29 10:46:58 +02:00
DrawStdWindowFrame ( sTextWindowId , 0 ) ;
AddTextPrinterParameterized ( sTextWindowId , 1 , Roulette_Text_KeepPlaying , 0 , 1 , TEXT_SPEED_FF , 0 ) ;
CopyWindowToVram ( sTextWindowId , 3 ) ;
DoYesNoFuncWithChoice ( taskId , & sYesNoTable_KeepPlaying ) ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_ContinuePlaying ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
2019-02-22 07:40:11 +01:00
ClearStdWindowAndFrame ( 0 , TRUE ) ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_SelectFirstEmptySquare ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_StopPlaying ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
DestroyTask ( sRoulette - > varA5 ) ;
ExitRoulette ( taskId ) ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
static void UpdateGridSelectionRect ( u8 selectionId )
2018-12-31 23:09:45 +01:00
{
u8 temp0 , temp1 ;
2020-07-29 10:46:58 +02:00
switch ( selectionId )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
case SELECTION_NONE :
ClearGridSelectionRect ( & sRoulette - > tilemapBuffers [ 0 ] [ 0 ] , 0 , 14 , 7 , 16 , 13 ) ;
2018-12-31 23:09:45 +01:00
break ;
2020-07-29 10:46:58 +02:00
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 ) ;
2018-12-31 23:09:45 +01:00
break ;
2020-07-29 10:46:58 +02:00
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 ) ;
2018-12-31 23:09:45 +01:00
break ;
2020-07-29 10:46:58 +02:00
// Individual square
2018-12-31 23:09:45 +01:00
default :
2020-07-29 10:46:58 +02:00
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 ) ;
2018-12-31 23:09:45 +01:00
break ;
}
}
2020-07-29 10:46:58 +02:00
static void UpdateGridSelection ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
SetMultiplierSprite ( gTasks [ taskId ] . tSelectionId ) ;
UpdateGridSelectionRect ( gTasks [ taskId ] . tSelectionId ) ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_StartHandleBetGridInput ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
sRoulette - > var28 = 1 ;
UpdateGridSelectionRect ( gTasks [ taskId ] . tSelectionId ) ;
sRoulette - > var23 = 2 ;
sRoulette - > var21 = 0 ;
gTasks [ taskId ] . func = Task_HandleBetGridInput ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_SelectFirstEmptySquare ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
s16 i ;
2020-07-29 10:46:58 +02:00
if ( sRoulette - > hitFlags & F_ORANGE_ROW )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
// If the whole orange row is filled, get first in green row
for ( i = SQU_GREEN_WYNAUT ; i < SQU_GREEN_MAKUHITA ; i + + )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
if ( ! ( sRoulette - > hitFlags & sGridSelections [ i ] . flag ) )
2018-12-31 23:09:45 +01:00
break ;
}
}
else
{
2020-07-29 10:46:58 +02:00
// 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
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
if ( ! ( sRoulette - > hitFlags & sGridSelections [ i ] . flag ) )
2018-12-31 23:09:45 +01:00
break ;
}
}
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . tSelectionId = i ;
2018-12-31 23:09:45 +01:00
sub_8141FF4 ( taskId ) ;
2020-07-29 10:46:58 +02:00
DrawGridBackground ( gTasks [ taskId ] . tSelectionId ) ;
SetMultiplierSprite ( gTasks [ taskId ] . tSelectionId ) ;
FlashSelectionOnWheel ( gTasks [ taskId ] . tSelectionId ) ;
2018-12-31 23:09:45 +01:00
gTasks [ taskId ] . data [ 1 ] = 0 ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_StartHandleBetGridInput ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
static bool8 CanMoveSelectionInDir ( s16 * selectionId , u8 dir )
2018-12-31 23:09:45 +01:00
{
s8 temp1 = 0 ;
s8 temp = 0 ;
2020-07-29 10:46:58 +02:00
s8 moveOffsets [ 4 ] = { - 5 , 5 , - 1 , 1 } ;
s8 originalSelection = * selectionId ;
2018-12-31 23:09:45 +01:00
2020-07-29 10:46:58 +02:00
switch ( dir )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
case 0 : // UP
case 1 : // DOWN
temp1 = GET_COL ( * selectionId ) ;
temp = temp1 + ROW_PURPLE ;
if ( temp1 = = SELECTION_NONE )
2018-12-31 23:09:45 +01:00
temp1 = 5 ;
break ;
2020-07-29 10:46:58 +02:00
case 2 : // LEFT
case 3 : // RIGHT
temp1 = GET_ROW ( * selectionId ) ;
temp = temp1 + COL_MAKUHITA ;
if ( temp1 = = SELECTION_NONE )
2018-12-31 23:09:45 +01:00
temp1 = 1 ;
break ;
}
2020-07-29 10:46:58 +02:00
* selectionId + = moveOffsets [ dir ] ;
2018-12-31 23:09:45 +01:00
2020-07-29 10:46:58 +02:00
if ( * selectionId < temp1 )
* selectionId = temp ;
2018-12-31 23:09:45 +01:00
2020-07-29 10:46:58 +02:00
if ( * selectionId > temp )
* selectionId = temp1 ;
2018-12-31 23:09:45 +01:00
2020-07-29 10:46:58 +02:00
if ( * selectionId ! = originalSelection )
2018-12-31 23:09:45 +01:00
return TRUE ;
return FALSE ;
}
2020-07-29 10:46:58 +02:00
static void ProcessBetGridInput ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
u8 z = 0 ;
2020-07-29 10:46:58 +02:00
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 ;
}
}
2018-12-31 23:09:45 +01:00
}
2019-01-02 23:55:50 +01:00
static void sub_8140F6C ( u8 r0 )
2018-12-31 23:09:45 +01:00
{
2019-10-20 08:31:51 +02:00
IncrementDailyRouletteUses ( ) ;
2020-07-29 10:46:58 +02:00
sRoulette - > var28 = 0xFF ;
if ( sRoulette - > minBet = = 1 )
sRoulette - > var23 = 1 ;
2018-12-31 23:09:45 +01:00
else
2020-07-29 10:46:58 +02:00
sRoulette - > var23 = 0 ;
sRoulette - > var21 = 0 ;
2018-12-31 23:09:45 +01:00
gTasks [ r0 ] . data [ 1 ] = 32 ;
2020-07-29 10:46:58 +02:00
gTasks [ r0 ] . func = Task_SlideGridOffscreen ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_PlaceBet ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
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 ) ;
2019-01-01 01:07:29 +01:00
gTasks [ taskId ] . func = sub_8140F6C ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_HandleBetGridInput ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
ProcessBetGridInput ( taskId ) ;
2018-12-31 23:09:45 +01:00
2020-07-29 10:46:58 +02:00
// Flash selection rect
2019-01-01 01:07:29 +01:00
switch ( gTasks [ taskId ] . data [ 1 ] )
2018-12-31 23:09:45 +01:00
{
case 0 :
2020-07-29 10:46:58 +02:00
UpdateGridSelectionRect ( gTasks [ taskId ] . tSelectionId ) ;
2019-01-02 23:55:50 +01:00
gTasks [ taskId ] . data [ 1 ] + + ;
2018-12-31 23:09:45 +01:00
break ;
case 30 :
2020-07-29 10:46:58 +02:00
UpdateGridSelectionRect ( SELECTION_NONE ) ;
2019-01-02 23:55:50 +01:00
gTasks [ taskId ] . data [ 1 ] + + ;
2018-12-31 23:09:45 +01:00
break ;
case 59 :
2019-01-01 01:07:29 +01:00
gTasks [ taskId ] . data [ 1 ] = 0 ;
2018-12-31 23:09:45 +01:00
break ;
default :
2019-01-01 01:07:29 +01:00
gTasks [ taskId ] . data [ 1 ] + + ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
if ( JOY_NEW ( A_BUTTON ) )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
if ( ( sRoulette - > hitFlags & sGridSelections [ gTasks [ taskId ] . tSelectionId ] . flag ) )
{
// Ball has already landed on this space
2018-12-31 23:09:45 +01:00
PlaySE ( SE_BOO ) ;
2020-07-29 10:46:58 +02:00
}
2018-12-31 23:09:45 +01:00
else
{
m4aSongNumStart ( SE_REGI ) ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_PlaceBet ;
2018-12-31 23:09:45 +01:00
}
}
}
2020-07-29 10:46:58 +02:00
static void Task_SlideGridOffscreen ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
2019-01-01 01:07:29 +01:00
if ( gTasks [ taskId ] . data [ 1 ] - - > 0 )
2018-12-31 23:09:45 +01:00
{
2019-01-01 01:07:29 +01:00
if ( gTasks [ taskId ] . data [ 1 ] > 2 )
gSpriteCoordOffsetX + = 2 ;
2020-07-29 10:46:58 +02:00
if ( ( sRoulette - > var26 + = 4 ) = = 104 )
gSprites [ sRoulette - > spriteIds [ SPR_MULTIPLIER ] ] . callback = & SpriteCallbackDummy ;
2018-12-31 23:09:45 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
ShowHideGridIcons ( TRUE , - 1 ) ;
ShowHideGridBalls ( TRUE , - 1 ) ;
gTasks [ taskId ] . func = Task_RollBall ;
2019-01-01 01:07:29 +01:00
gTasks [ taskId ] . data [ 1 ] = 0 ;
2018-12-31 23:09:45 +01:00
}
}
2019-01-02 23:55:50 +01:00
static u8 sub_814118C ( u16 r0 , u16 r1 )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
switch ( sRoulette - > partySpeciesFlags )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
case HAS_SHROOMISH :
case HAS_TAILLOW :
2018-12-31 23:09:45 +01:00
// one of the two is in party
if ( gLocalTime . hours > 3 & & gLocalTime . hours < 10 )
{
2019-01-02 23:55:50 +01:00
if ( r0 < 12 | | ( r1 & 1 ) )
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var02 / 2 ;
2018-12-31 23:09:45 +01:00
else
2019-01-02 23:55:50 +01:00
return 1 ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
else if ( ! ( r1 & 0x3 ) )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var02 / 2 ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
else
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var02 ;
2018-12-31 23:09:45 +01:00
}
break ;
2020-07-29 10:46:58 +02:00
case HAS_SHROOMISH | HAS_TAILLOW :
2018-12-31 23:09:45 +01:00
// both are in party
if ( gLocalTime . hours > 3 & & gLocalTime . hours < 11 )
{
2019-01-02 23:55:50 +01:00
if ( r0 < 6 | | ( r1 & 1 ) )
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var02 / 2 ;
2018-12-31 23:09:45 +01:00
else
2019-01-02 23:55:50 +01:00
return 1 ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
else if ( ( r1 & 1 ) & & r0 > 6 )
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var02 / 4 ;
2018-12-31 23:09:45 +01:00
}
2020-07-29 10:46:58 +02:00
else
2018-12-31 23:09:45 +01:00
{
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var02 / 2 ;
2018-12-31 23:09:45 +01:00
}
break ;
case 0 :
default :
// neither is in party
if ( gLocalTime . hours > 3 & & gLocalTime . hours < 10 )
{
2019-01-02 23:55:50 +01:00
if ( ! ( r1 & 3 ) )
return 1 ;
2018-12-31 23:09:45 +01:00
else
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var02 / 2 ;
2018-12-31 23:09:45 +01:00
}
2019-01-02 23:55:50 +01:00
else if ( ! ( r1 & 3 ) )
2018-12-31 23:09:45 +01:00
{
if ( r0 > 12 )
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var02 / 2 ;
2018-12-31 23:09:45 +01:00
else
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var02 ;
2018-12-31 23:09:45 +01:00
}
else if ( r1 & 0x8000 )
{
if ( r0 > 12 )
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var02 ;
2018-12-31 23:09:45 +01:00
else
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var01 ;
2018-12-31 23:09:45 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
return gUnknown_085B6348 [ sRoulette - > tableId ] . var01 * 2 ;
2018-12-31 23:09:45 +01:00
}
break ;
}
}
2020-07-29 10:46:58 +02:00
static void Task_RollBall ( u8 taskId )
2018-12-31 23:09:45 +01:00
{
u8 randf ;
s8 randfinal ;
s8 r5 ;
u16 g = 0 ;
u16 rand ;
u16 randmod ;
2019-01-02 23:40:40 +01:00
u16 angles [ 4 ] = { 0 , 180 , 90 , 270 } ; // angles in 90 degree steps
2018-12-31 23:09:45 +01:00
rand = Random ( ) ;
randmod = rand % 100 ;
2020-07-29 10:46:58 +02:00
sRoulette - > var7C = gTasks [ taskId ] . tBallNum ;
sRoulette - > var7D = sRoulette - > var7E = sRoulette - > var7F = g ;
2018-12-31 23:09:45 +01:00
randf = sub_814118C ( gTasks [ taskId ] . data [ 8 ] , rand ) ;
randfinal = ( rand % randf ) - ( randf / 2 ) ;
if ( gLocalTime . hours < 13 )
r5 = 0 ;
else
r5 = 1 ;
if ( randmod < 80 )
r5 * = 2 ;
else
r5 = ( 1 - r5 ) * 2 ;
2020-07-29 10:46:58 +02:00
sRoulette - > var80 = g = gUnknown_085B6348 [ sRoulette - > tableId ] . var1A + randfinal ;
2018-12-31 23:09:45 +01:00
g = S16TOPOSFLOAT ( g ) / 5.0f ;
2020-07-29 10:46:58 +02:00
sRoulette - > var82 = g * 3 ;
sRoulette - > var86 = sRoulette - > var84 = g ;
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 ;
2018-12-31 23:09:45 +01:00
}
2019-01-01 01:07:29 +01:00
2020-07-29 10:46:58 +02:00
static void Task_EndBallRoll ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
u8 index ;
2020-07-29 10:46:58 +02:00
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 ) ;
2019-01-01 01:07:29 +01:00
m4aSongNumStart ( SE_TAMAKORO ) ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_RecordBallHit ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_RecordBallHit ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var7D )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var03_5 )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var03_6 )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
sRoulette - > var03_6 = FALSE ;
sRoulette - > var03_5 = FALSE ;
2019-01-01 01:07:29 +01:00
}
}
else
{
if ( ! gTasks [ taskId ] . data [ 1 ] )
{
2020-07-29 10:46:58 +02:00
bool8 temp = IsHitInBetSelection ( RecordHit ( taskId , sRoulette - > var7E ) , sRoulette - > betSelection [ sRoulette - > curBallNum ] ) ;
gTasks [ taskId ] . tWonBet = temp ;
2019-01-01 01:07:29 +01:00
if ( temp = = TRUE )
2020-07-29 10:46:58 +02:00
sub_8151A48 ( & sRoulette - > varB8 , 0x1000 ) ;
2019-01-01 01:07:29 +01:00
}
if ( gTasks [ taskId ] . data [ 1 ] < = 60 )
{
2020-07-29 10:46:58 +02:00
if ( JOY_NEW ( A_BUTTON ) )
2019-01-01 01:07:29 +01:00
gTasks [ taskId ] . data [ 1 ] = 60 ;
gTasks [ taskId ] . data [ 1 ] + + ;
}
else
{
2020-07-29 10:46:58 +02:00
DrawGridBackground ( sRoulette - > betSelection [ sRoulette - > curBallNum ] ) ;
ShowHideGridIcons ( FALSE , gTasks [ taskId ] . tWinningSquare ) ;
ShowHideGridBalls ( FALSE , gTasks [ taskId ] . tBallNum - 1 ) ;
2019-01-01 01:07:29 +01:00
gTasks [ taskId ] . data [ 1 ] = 32 ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_SlideGridOnscreen ;
2019-01-01 01:07:29 +01:00
}
}
}
}
2020-07-29 10:46:58 +02:00
static void Task_SlideGridOnscreen ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
if ( gTasks [ taskId ] . data [ 1 ] - - > 0 )
{
if ( gTasks [ taskId ] . data [ 1 ] > 2 )
gSpriteCoordOffsetX - = 2 ;
2020-07-29 10:46:58 +02:00
if ( ( sRoulette - > var26 - = 4 ) = = 104 )
gSprites [ sRoulette - > spriteIds [ SPR_MULTIPLIER ] ] . callback = SpriteCB_GridSquare ;
2019-01-01 01:07:29 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
ShowHideWinSlotCursor ( gTasks [ taskId ] . tWinningSquare ) ;
if ( gTasks [ taskId ] . tWonBet = = TRUE )
2019-01-01 01:07:29 +01:00
gTasks [ taskId ] . data [ 1 ] = 121 ;
else
gTasks [ taskId ] . data [ 1 ] = 61 ;
gTasks [ taskId ] . func = sub_8141778 ;
}
}
2019-01-02 23:55:50 +01:00
static void sub_8141778 ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
if ( gTasks [ taskId ] . data [ 1 ] - - > 1 )
{
switch ( gTasks [ taskId ] . data [ 1 ] % 16 )
{
case 8 :
2020-07-29 10:46:58 +02:00
ShowHideGridIcons ( FALSE , - 1 ) ;
ShowHideGridBalls ( FALSE , - 1 ) ;
2019-01-01 01:07:29 +01:00
break ;
case 0 :
2020-07-29 10:46:58 +02:00
ShowHideGridIcons ( FALSE , gTasks [ taskId ] . tWinningSquare ) ;
ShowHideGridBalls ( FALSE , gTasks [ taskId ] . tBallNum - 1 ) ;
2019-01-01 01:07:29 +01:00
break ;
}
}
else
{
2020-07-29 10:46:58 +02:00
StartTaskAfterDelayOrInput ( taskId , Task_PrintSpinResult , 30 , 0 ) ;
2019-01-01 01:07:29 +01:00
}
}
2020-07-29 10:46:58 +02:00
static void Task_TryIncrementWins ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
switch ( gTasks [ taskId ] . tWonBet )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
case TRUE :
case 2 : // never happens
2019-01-01 01:07:29 +01:00
if ( IsFanfareTaskInactive ( ) )
{
u32 wins = GetGameStat ( GAME_STAT_CONSECUTIVE_ROULETTE_WINS ) ;
2020-07-29 10:46:58 +02:00
if ( wins < + + gTasks [ taskId ] . tConsecutiveWins )
SetGameStat ( GAME_STAT_CONSECUTIVE_ROULETTE_WINS , gTasks [ taskId ] . tConsecutiveWins ) ;
StartTaskAfterDelayOrInput ( taskId , Task_PrintPayout , 0xFFFF , A_BUTTON | B_BUTTON ) ;
2019-01-01 01:07:29 +01:00
}
break ;
2020-07-29 10:46:58 +02:00
case FALSE :
2019-01-01 01:07:29 +01:00
default :
if ( ! IsSEPlaying ( ) )
{
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . tConsecutiveWins = 0 ;
StartTaskAfterDelayOrInput ( taskId , Task_EndTurn , 0xFFFF , A_BUTTON | B_BUTTON ) ;
2019-01-01 01:07:29 +01:00
}
break ;
}
}
2020-07-29 10:46:58 +02:00
static void Task_PrintSpinResult ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
switch ( gTasks [ taskId ] . tWonBet )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
case TRUE :
case 2 : // never happens
if ( gTasks [ taskId ] . tMultiplier = = MAX_MULTIPLIER )
2019-01-01 01:07:29 +01:00
{
PlayFanfare ( MUS_ME_B_BIG ) ;
2020-07-29 10:46:58 +02:00
DrawStdWindowFrame ( sTextWindowId , FALSE ) ;
AddTextPrinterParameterized ( sTextWindowId , 1 , Roulette_Text_Jackpot , 0 , 1 , TEXT_SPEED_FF , NULL ) ;
CopyWindowToVram ( sTextWindowId , 3 ) ;
2019-01-01 01:07:29 +01:00
}
else
{
PlayFanfare ( MUS_ME_B_SMALL ) ;
2020-07-29 10:46:58 +02:00
DrawStdWindowFrame ( sTextWindowId , FALSE ) ;
AddTextPrinterParameterized ( sTextWindowId , 1 , Roulette_Text_ItsAHit , 0 , 1 , TEXT_SPEED_FF , NULL ) ;
CopyWindowToVram ( sTextWindowId , 3 ) ;
2019-01-01 01:07:29 +01:00
}
break ;
2020-07-29 10:46:58 +02:00
case FALSE :
2019-01-01 01:07:29 +01:00
default :
m4aSongNumStart ( SE_HAZURE ) ;
2020-07-29 10:46:58 +02:00
DrawStdWindowFrame ( sTextWindowId , FALSE ) ;
AddTextPrinterParameterized ( sTextWindowId , 1 , Roulette_Text_NothingDoing , 0 , 1 , TEXT_SPEED_FF , NULL ) ;
CopyWindowToVram ( sTextWindowId , 3 ) ;
2019-01-01 01:07:29 +01:00
break ;
}
gTasks [ taskId ] . data [ 1 ] = 0 ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_TryIncrementWins ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
# define tPayout data[1]
static void Task_GivePayout ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
switch ( gTasks [ taskId ] . data [ 7 ] )
2019-01-01 01:07:29 +01:00
{
case 0 :
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . tCoins + + ;
2019-01-01 01:07:29 +01:00
m4aSongNumStart ( SE_PIN ) ;
2020-07-29 10:46:58 +02:00
SetCreditDigits ( gTasks [ taskId ] . tCoins ) ;
if ( gTasks [ taskId ] . tCoins > = MAX_COINS )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . tPayout = 0 ;
2019-01-01 01:07:29 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . tPayout - - ;
2019-01-01 01:07:29 +01:00
gTasks [ taskId ] . data [ 7 ] + + ;
}
break ;
case 3 :
m4aSongNumStop ( SE_PIN ) ;
gTasks [ taskId ] . data [ 7 ] = 0 ;
break ;
default :
gTasks [ taskId ] . data [ 7 ] + + ;
break ;
}
2020-07-29 10:46:58 +02:00
if ( gTasks [ taskId ] . tPayout = = 0 )
StartTaskAfterDelayOrInput ( taskId , Task_EndTurn , 0xFFFF , A_BUTTON | B_BUTTON ) ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_PrintPayout ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
ConvertIntToDecimalStringN ( gStringVar1 , ( sRoulette - > minBet * gTasks [ taskId ] . tMultiplier ) , STR_CONV_MODE_LEFT_ALIGN , 2 ) ;
2019-10-07 08:00:16 +02:00
StringExpandPlaceholders ( gStringVar4 , Roulette_Text_YouveWonXCoins ) ;
2020-07-29 10:46:58 +02:00
DrawStdWindowFrame ( sTextWindowId , FALSE ) ;
AddTextPrinterParameterized ( sTextWindowId , 1 , gStringVar4 , 0 , 1 , TEXT_SPEED_FF , NULL ) ;
CopyWindowToVram ( sTextWindowId , 3 ) ;
gTasks [ taskId ] . tPayout = ( sRoulette - > minBet * gTasks [ taskId ] . tMultiplier ) ;
2019-01-01 01:07:29 +01:00
gTasks [ taskId ] . data [ 7 ] = 0 ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_GivePayout ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
# undef tPayout
static void Task_EndTurn ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_TryPrintEndTurnMsg ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
u8 i = 0 ;
2020-07-29 10:46:58 +02:00
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 [ 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 ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
if ( gTasks [ taskId ] . tCoins > = sRoulette - > minBet )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
if ( gTasks [ taskId ] . tBallNum = = BALLS_PER_ROUND )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
// 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 ) ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
else if ( gTasks [ taskId ] . tCoins = = MAX_COINS )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
// 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 ) ;
2019-01-01 01:07:29 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
// No special msg, ask to continue
gTasks [ taskId ] . func = Task_AskKeepPlaying ;
2019-01-01 01:07:29 +01:00
}
}
else
{
2020-07-29 10:46:58 +02:00
// 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 ) ;
2019-01-01 01:07:29 +01:00
}
}
2020-07-29 10:46:58 +02:00
static void Task_ClearBoard ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
u8 i = 0 ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . tBallNum = 0 ;
2019-01-01 01:07:29 +01:00
sub_8141FF4 ( taskId ) ;
2020-07-29 10:46:58 +02:00
ResetHits ( ) ;
HideBoardBalls ( ) ;
DrawGridBackground ( SELECTION_NONE ) ;
SetBallCounterNumLeft ( BALLS_PER_ROUND ) ;
2019-01-01 01:07:29 +01:00
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < NUM_ROULETTE_SLOTS ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
gSprites [ sRoulette - > spriteIds [ i + SPR_BOARD_ICONS ] ] . invisible = FALSE ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
if ( gTasks [ taskId ] . tCoins = = MAX_COINS )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 ) ;
2019-01-01 01:07:29 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_AskKeepPlaying ;
2019-01-01 01:07:29 +01:00
}
}
2020-07-29 10:46:58 +02:00
static void ExitRoulette ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
sub_8151A9C ( & sRoulette - > varB8 , 0xFFFF ) ;
sub_8151678 ( & sRoulette - > varB8 ) ;
SetCoins ( gTasks [ taskId ] . tCoins ) ;
if ( GetCoins ( ) < sRoulette - > minBet )
2019-01-01 01:07:29 +01:00
gSpecialVar_0x8004 = TRUE ;
else
gSpecialVar_0x8004 = FALSE ;
2019-02-22 22:12:37 +01:00
AlertTVOfNewCoinTotal ( GetCoins ( ) ) ;
2019-01-01 01:07:29 +01:00
BeginHardwarePaletteFade ( 0xFF , 0 , 0 , 16 , 0 ) ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_ExitRoulette ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_ExitRoulette ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
if ( UpdatePaletteFade ( ) = = 0 )
{
SetVBlankCallback ( NULL ) ;
gSpriteCoordOffsetX = gSpriteCoordOffsetY = 0 ;
ResetVramOamAndBgCntRegs ( ) ;
ResetAllBgsCoordinates ( ) ;
SetGpuReg ( REG_OFFSET_BLDCNT , 0 ) ;
SetGpuReg ( REG_OFFSET_BLDALPHA , 0 ) ;
SetGpuReg ( REG_OFFSET_BLDY , 0 ) ;
FreeAllSpritePalettes ( ) ;
ResetPaletteFade ( ) ;
ResetSpriteData ( ) ;
2020-07-29 10:46:58 +02:00
FreeRoulette ( ) ;
2019-12-17 09:24:44 +01:00
gFieldCallback = FieldCB_ContinueScriptHandleMusic ;
2019-01-01 01:07:29 +01:00
SetMainCallback2 ( CB2_ReturnToField ) ;
DestroyTask ( taskId ) ;
}
}
2020-07-29 10:46:58 +02:00
static void Task_WaitForNextTask ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > taskWaitDelay = = 0 | | JOY_NEW ( sRoulette - > taskWaitKey ) )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = sRoulette - > nextTask ;
if ( sRoulette - > taskWaitKey > 0 )
2019-01-01 01:07:29 +01:00
PlaySE ( SE_SELECT ) ;
2020-07-29 10:46:58 +02:00
sRoulette - > nextTask = NULL ;
sRoulette - > taskWaitKey = 0 ;
sRoulette - > taskWaitDelay = 0 ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
if ( sRoulette - > taskWaitDelay ! = 0xFFFF )
sRoulette - > taskWaitDelay - - ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
static void StartTaskAfterDelayOrInput ( u8 taskId , TaskFunc task , u16 delay , u16 key )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
else
2020-07-29 10:46:58 +02:00
sRoulette - > taskWaitKey = key ;
gTasks [ taskId ] . func = Task_WaitForNextTask ;
2019-01-01 01:07:29 +01:00
}
2019-01-02 23:55:50 +01:00
static void sub_8141FF4 ( u8 taskId )
2019-01-01 01:07:29 +01:00
{
u8 i = 0 ;
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
gTasks [ taskId ] . data [ 1 ] = 0 ;
}
2020-07-29 10:46:58 +02:00
static void ResetHits ( void )
2019-01-01 01:07:29 +01:00
{
u8 i ;
2020-07-29 10:46:58 +02:00
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 ) ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
static u8 RecordHit ( u8 taskId , u8 slotId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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
} ;
2019-01-01 01:07:29 +01:00
2020-07-29 10:46:58 +02:00
if ( slotId > = NUM_ROULETTE_SLOTS )
2019-01-01 01:07:29 +01:00
return 0 ;
2020-07-29 10:46:58 +02:00
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 + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 ] ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
for ( j = 0 ; j < NUM_BOARD_COLORS ; j + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 ] ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
return sRouletteSlots [ slotId ] . gridSquare ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
static bool8 IsHitInBetSelection ( u8 gridSquare , u8 betSelection )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
u8 hit = gridSquare ;
if ( - - gridSquare < NUM_GRID_SELECTIONS )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
switch ( betSelection )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 )
2019-01-01 01:07:29 +01:00
return TRUE ;
break ;
2020-07-29 10:46:58 +02:00
case ROW_ORANGE :
case ROW_GREEN :
case ROW_PURPLE :
if ( hit > = ( betSelection + COL_WYNAUT )
& & hit < = ( betSelection + COL_MAKUHITA ) )
2019-01-01 01:07:29 +01:00
return TRUE ;
break ;
2020-07-29 10:46:58 +02:00
// Individual square
2019-01-01 01:07:29 +01:00
default :
2020-07-29 10:46:58 +02:00
if ( hit = = betSelection )
2019-01-01 01:07:29 +01:00
return TRUE ;
}
}
return FALSE ;
}
2020-07-29 10:46:58 +02:00
static void FlashSelectionOnWheel ( u8 selectionId )
2019-01-01 01:07:29 +01:00
{
2019-01-01 02:39:41 +01:00
u16 var0 = 0 ;
2019-01-01 01:07:29 +01:00
u8 var2 ;
u16 var3 ;
u8 i ;
2020-07-29 10:46:58 +02:00
switch ( selectionId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
case ROW_ORANGE :
case ROW_GREEN :
case ROW_PURPLE :
for ( i = ( selectionId + 1 ) ; i < ( selectionId + 5 ) ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
if ( ! ( sRoulette - > hitFlags & sGridSelections [ i ] . flag ) )
var0 | = sGridSelections [ i ] . var10 ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
sub_8151A48 ( & sRoulette - > varB8 , var0 & = 0xDFFF ) ;
2019-01-01 01:07:29 +01:00
break ;
default :
{
struct UnkStruct1 var1 [ 3 ] ;
memcpy ( var1 , gUnknown_085B63F0 , sizeof ( var1 ) ) ;
2020-07-29 10:46:58 +02:00
if ( selectionId > = COL_WYNAUT & & selectionId < = COL_MAKUHITA )
2019-01-01 01:07:29 +01:00
var2 = 3 ;
else
var2 = 1 ;
2020-07-29 10:46:58 +02:00
var3 = selectionId / 5 - 1 ;
switch ( GET_COL ( selectionId ) )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
// 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 ;
2019-01-01 01:07:29 +01:00
}
if ( var2 = = 1 )
{
2020-07-29 10:46:58 +02:00
if ( ! ( sRoulette - > hitFlags & sGridSelections [ selectionId ] . flag ) )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
var1 [ selectionId / 5 - 1 ] . var02 + = var3 ;
sub_815168C ( & sRoulette - > varB8 , 13 , & var1 [ selectionId / 5 - 1 ] ) ;
2019-01-01 01:07:29 +01:00
}
else
{
break ;
}
}
else
{
for ( i = 0 ; i < 3 ; i + + )
{
2020-07-29 10:46:58 +02:00
u8 var4 = i * 5 + selectionId + 5 ;
if ( ! ( sRoulette - > hitFlags & sGridSelections [ var4 ] . flag ) )
2019-01-01 01:07:29 +01:00
{
var1 [ var4 / 5 - 1 ] . var02 + = var3 ;
2020-07-29 10:46:58 +02:00
sub_815168C ( & sRoulette - > varB8 , i + 13 , & var1 [ var4 / 5 - 1 ] ) ;
2019-01-01 01:07:29 +01:00
if ( var2 = = 3 )
2020-07-29 10:46:58 +02:00
var0 = sGridSelections [ var4 ] . var10 ;
2019-01-01 01:07:29 +01:00
var2 - - ;
}
}
if ( var2 ! = 2 )
var0 = 0 ;
}
2020-07-29 10:46:58 +02:00
sub_8151A48 ( & sRoulette - > varB8 , var0 | = sGridSelections [ selectionId ] . var10 ) ;
2019-01-01 01:07:29 +01:00
break ;
}
}
}
2020-07-29 10:46:58 +02:00
static void DrawGridBackground ( u8 selectionId )
2019-01-01 01:07:29 +01:00
{
vu8 i ;
vu8 z ;
vu16 var1 ;
vu16 var2 ;
vu8 var0 ;
u8 v [ 5 ] ;
u8 l ;
2020-07-29 10:46:58 +02:00
sRoulette - > var2A = 1 ;
ShowHideGridIcons ( FALSE , 0 ) ;
SetGridSelectionRect ( sRoulette - > tilemapBuffers [ 2 ] , sRoulette - > unk_397C , 14 , 7 , 16 , 13 ) ;
switch ( selectionId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
case SELECTION_NONE :
2019-01-01 01:07:29 +01:00
return ;
2020-07-29 10:46:58 +02:00
case COL_WYNAUT :
case COL_AZURILL :
case COL_SKITTY :
case COL_MAKUHITA :
2019-01-01 01:07:29 +01:00
l = 4 ;
for ( i = 0 ; i < l ; i + + )
{
2020-07-29 10:46:58 +02:00
v [ i ] = i * 5 + selectionId ;
2019-01-01 01:07:29 +01:00
}
break ;
2020-07-29 10:46:58 +02:00
case ROW_ORANGE :
case ROW_GREEN :
case ROW_PURPLE :
2019-01-01 01:07:29 +01:00
l = 5 ;
for ( i = 0 ; i < l ; i + + )
{
2020-07-29 10:46:58 +02:00
v [ i ] = i + selectionId ;
2019-01-01 01:07:29 +01:00
}
break ;
2020-07-29 10:46:58 +02:00
// Individual square
2019-01-01 01:07:29 +01:00
default :
l = 1 ;
2020-07-29 10:46:58 +02:00
v [ 0 ] = selectionId ;
2019-01-01 01:07:29 +01:00
}
for ( i = 0 ; i < l ; i + + )
{
2020-07-29 10:46:58 +02:00
var0 = sGridSelections [ v [ i ] ] . var06 ;
var1 = sGridSelections [ v [ i ] ] . x ;
2019-01-01 01:07:29 +01:00
for ( z = 0 ; z < 3 ; z + + )
{
2020-07-29 10:46:58 +02:00
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 ] ;
2019-01-01 01:07:29 +01:00
}
}
}
2020-07-29 10:46:58 +02:00
static u8 GetMultiplier ( u8 selectionId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
u8 multipliers [ 5 ] = { 0 , 3 , 4 , 6 , 12 } ;
if ( selectionId > NUM_GRID_SELECTIONS )
selectionId = 0 ;
2019-01-01 01:07:29 +01:00
2020-07-29 10:46:58 +02:00
switch ( sGridSelections [ selectionId ] . baseMultiplier )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 )
2019-01-01 01:07:29 +01:00
return 0 ;
2020-07-29 10:46:58 +02:00
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 )
2019-01-01 01:07:29 +01:00
return 0 ;
2020-07-29 10:46:58 +02:00
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 )
2019-01-01 01:07:29 +01:00
return 0 ;
2020-07-29 10:46:58 +02:00
return multipliers [ 4 ] ;
2019-01-01 01:07:29 +01:00
}
return 0 ;
}
2019-01-02 23:55:50 +01:00
static void sub_8142814 ( void )
2019-01-01 01:07:29 +01:00
{
s32 x1 ;
s32 x2 ;
2020-07-29 10:46:58 +02:00
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 ) ;
2019-01-01 01:07:29 +01:00
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 ) ;
}
2020-07-29 10:46:58 +02:00
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 sSpritePalettes [ ] =
{
{ . 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 } ,
2019-01-02 23:40:40 +01:00
{ }
} ;
static const struct OamData gOamData_85B73EC =
{
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 32 x32 ) ,
. size = SPRITE_SIZE ( 32 x32 ) ,
2019-01-02 23:40:40 +01:00
. priority = 1 ,
} ;
2020-07-29 10:46:58 +02:00
static const struct OamData sOam_GridIcon =
2019-01-02 23:40:40 +01:00
{
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 16 x16 ) ,
. size = SPRITE_SIZE ( 16 x16 ) ,
2019-01-02 23:40:40 +01:00
. priority = 1 ,
} ;
2020-07-29 10:46:58 +02:00
static const struct OamData sOam_BoardIcon =
2019-01-02 23:40:40 +01:00
{
. y = 60 ,
. affineMode = ST_OAM_AFFINE_DOUBLE ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 16 x32 ) ,
. size = SPRITE_SIZE ( 16 x32 ) ,
2019-01-02 23:40:40 +01:00
. priority = 2 ,
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd sAffineAnim_Unused1 [ ] =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 0 ) ,
ANIMCMD_END
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAffineAnims_Unused1 [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
sAffineAnim_Unused1
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AffineAnimCmd sAffineAnim_Unused2 [ ] =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
AFFINEANIMCMD_END
} ;
2020-07-29 10:46:58 +02:00
static const union AffineAnimCmd * const sAffineAnims_Unused2 [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
sAffineAnim_Unused2
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const struct CompressedSpriteSheet sSpriteSheet_BoardIcons =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
. data = sBoardIcons_Gfx ,
2019-01-02 23:40:40 +01:00
. size = 0xC00 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_BOARD_ICONS
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd sAnim_BoardIcons [ ] =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 0 ) ,
ANIMCMD_FRAME ( 32 , 0 ) ,
ANIMCMD_FRAME ( 64 , 0 ) ,
ANIMCMD_FRAME ( 72 , 0 ) ,
ANIMCMD_FRAME ( 8 , 0 ) ,
ANIMCMD_FRAME ( 40 , 0 ) ,
ANIMCMD_FRAME ( 48 , 0 ) ,
ANIMCMD_FRAME ( 80 , 0 ) ,
ANIMCMD_FRAME ( 16 , 0 ) ,
ANIMCMD_FRAME ( 24 , 0 ) ,
ANIMCMD_FRAME ( 56 , 0 ) ,
ANIMCMD_FRAME ( 88 , 0 ) ,
ANIMCMD_END
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_OrangeWynaut [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 0 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_GreenAzurill [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 1 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_PurpleSkitty [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 2 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_OrangeMakuhita [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 3 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_GreenWynaut [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 4 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_PurpleAzurill [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 5 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_OrangeSkitty [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 6 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_GreenMakuhita [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 7 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_PurpleWynaut [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 8 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_OrangeAzurill [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 9 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_GreenSkitty [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 10 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_BoardIcon_PurpleMakuhita [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_BoardIcons [ 11 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const struct CompressedSpriteSheet sSpriteSheet_Headers =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
. data = gRouletteHeaders_Gfx ,
2019-01-02 23:40:40 +01:00
. size = 0x1600 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_HEADERS
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const struct CompressedSpriteSheet sSpriteSheet_PokeIcons =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
. data = sGridIcons_Gfx ,
2019-01-02 23:40:40 +01:00
. size = 0x400 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_GRID_ICONS
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd sAnim_Headers [ ] =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 0 ) ,
ANIMCMD_FRAME ( 16 , 0 ) ,
ANIMCMD_FRAME ( 32 , 0 ) ,
ANIMCMD_FRAME ( 48 , 0 ) ,
ANIMCMD_FRAME ( 64 , 0 ) ,
ANIMCMD_FRAME ( 80 , 0 ) ,
ANIMCMD_FRAME ( 96 , 0 ) ,
ANIMCMD_FRAME ( 112 , 0 ) ,
ANIMCMD_FRAME ( 128 , 0 ) ,
ANIMCMD_FRAME ( 144 , 0 ) ,
ANIMCMD_FRAME ( 160 , 0 ) ,
ANIMCMD_END
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd sAnim_GridIcons [ ] =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 0 ) ,
ANIMCMD_FRAME ( 4 , 0 ) ,
ANIMCMD_FRAME ( 8 , 0 ) ,
ANIMCMD_FRAME ( 12 , 0 ) ,
ANIMCMD_END
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_WynautHeader [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_Headers [ 0 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_AzurillHeader [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_Headers [ 2 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_SkittyHeader [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_Headers [ 4 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_MakuhitaHeader [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_Headers [ 6 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_OrangeHeader [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_Headers [ 8 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_GreenHeader [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_Headers [ 9 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_PurpleHeader [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_Headers [ 10 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_GridIcon_Wynaut [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_GridIcons [ 0 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_GridIcon_Azurill [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_GridIcons [ 1 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_GridIcon_Skitty [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_GridIcons [ 2 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnim_GridIcon_Makuhita [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
& sAnim_GridIcons [ 3 ]
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplates_PokeHeaders [ NUM_BOARD_POKES ] =
2019-01-02 23:40:40 +01:00
{
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_HEADERS ,
. paletteTag = PALTAG_GRID_ICONS ,
2019-01-02 23:40:40 +01:00
. oam = & gOamData_85B73EC ,
2020-07-29 10:46:58 +02:00
. anims = sAnim_WynautHeader ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_HEADERS ,
. paletteTag = PALTAG_GRID_ICONS ,
2019-01-02 23:40:40 +01:00
. oam = & gOamData_85B73EC ,
2020-07-29 10:46:58 +02:00
. anims = sAnim_AzurillHeader ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_HEADERS ,
. paletteTag = PALTAG_GRID_ICONS ,
2019-01-02 23:40:40 +01:00
. oam = & gOamData_85B73EC ,
2020-07-29 10:46:58 +02:00
. anims = sAnim_SkittyHeader ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_HEADERS ,
. paletteTag = PALTAG_GRID_ICONS ,
2019-01-02 23:40:40 +01:00
. oam = & gOamData_85B73EC ,
2020-07-29 10:46:58 +02:00
. anims = sAnim_MakuhitaHeader ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
}
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplates_ColorHeaders [ NUM_BOARD_COLORS ] =
2019-01-02 23:40:40 +01:00
{
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_HEADERS ,
. paletteTag = PALTAG_GRID_ICONS ,
2019-01-02 23:40:40 +01:00
. oam = & gOamData_85B73EC ,
2020-07-29 10:46:58 +02:00
. anims = sAnim_OrangeHeader ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_HEADERS ,
. paletteTag = PALTAG_GRID_ICONS ,
2019-01-02 23:40:40 +01:00
. oam = & gOamData_85B73EC ,
2020-07-29 10:46:58 +02:00
. anims = sAnim_GreenHeader ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_HEADERS ,
. paletteTag = PALTAG_GRID_ICONS ,
2019-01-02 23:40:40 +01:00
. oam = & gOamData_85B73EC ,
2020-07-29 10:46:58 +02:00
. anims = sAnim_PurpleHeader ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
}
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplate_GridIcons [ NUM_BOARD_POKES ] =
2019-01-02 23:40:40 +01:00
{
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_GRID_ICONS ,
. paletteTag = PALTAG_GRID_ICONS ,
. oam = & sOam_GridIcon ,
. anims = sAnim_GridIcon_Wynaut ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_GRID_ICONS ,
. paletteTag = PALTAG_GRID_ICONS ,
. oam = & sOam_GridIcon ,
. anims = sAnim_GridIcon_Azurill ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_GRID_ICONS ,
. paletteTag = PALTAG_GRID_ICONS ,
. oam = & sOam_GridIcon ,
. anims = sAnim_GridIcon_Skitty ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_GRID_ICONS ,
. paletteTag = PALTAG_GRID_ICONS ,
. oam = & sOam_GridIcon ,
. anims = sAnim_GridIcon_Makuhita ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
}
} ;
2020-07-29 10:46:58 +02:00
// 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 ] =
2019-01-02 23:40:40 +01:00
{
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_WYNAUT ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_OrangeWynaut ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_AZURILL ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_GreenAzurill ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_SKITTY ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_PurpleSkitty ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_MAKUHITA ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_OrangeMakuhita ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_WYNAUT ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_GreenWynaut ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_AZURILL ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_PurpleAzurill ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_SKITTY ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_OrangeSkitty ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_MAKUHITA ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_GreenMakuhita ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_WYNAUT ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_PurpleWynaut ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_AZURILL ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_OrangeAzurill ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_SKITTY ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_GreenSkitty ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_ICONS ,
. paletteTag = PALTAG_MAKUHITA ,
. oam = & sOam_BoardIcon ,
. anims = sAnim_BoardIcon_PurpleMakuhita ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardIcon
2019-01-02 23:40:40 +01:00
}
} ;
2020-07-29 10:46:58 +02:00
static const struct OamData sOam_Credit =
2019-01-02 23:40:40 +01:00
{
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 64 x32 ) ,
. size = SPRITE_SIZE ( 64 x32 ) ,
2019-01-02 23:40:40 +01:00
. priority = 1 ,
} ;
2020-07-29 10:46:58 +02:00
static const struct OamData sOam_CreditDigit =
2019-01-02 23:40:40 +01:00
{
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 8 x16 ) ,
. size = SPRITE_SIZE ( 8 x16 ) ,
2019-01-02 23:40:40 +01:00
. priority = 1 ,
} ;
2020-07-29 10:46:58 +02:00
static const struct OamData sOam_Multiplier =
2019-01-02 23:40:40 +01:00
{
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 32 x16 ) ,
. size = SPRITE_SIZE ( 32 x16 ) ,
2019-01-02 23:40:40 +01:00
. priority = 1 ,
} ;
2020-07-29 10:46:58 +02:00
static const struct OamData sOam_BallCounter =
2019-01-02 23:40:40 +01:00
{
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 16 x8 ) ,
. size = SPRITE_SIZE ( 16 x8 ) ,
2019-01-02 23:40:40 +01:00
. priority = 1 ,
} ;
2020-07-29 10:46:58 +02:00
static const struct CompressedSpriteSheet sSpriteSheets_Interface [ ] =
2019-01-02 23:40:40 +01:00
{
{
2020-07-29 10:46:58 +02:00
. data = gRouletteCredit_Gfx ,
2019-01-02 23:40:40 +01:00
. size = 0x400 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_CREDIT
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. data = gRouletteNumbers_Gfx ,
2019-01-02 23:40:40 +01:00
. size = 0x280 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_CREDIT_DIGIT
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. data = gRouletteMultiplier_Gfx ,
2019-01-02 23:40:40 +01:00
. size = 0x500 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_MULTIPLIER
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. data = sBallCounter_Gfx ,
2019-01-02 23:40:40 +01:00
. size = 0x140 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_BALL_COUNTER
2019-01-02 23:40:40 +01:00
} ,
{
2020-07-29 10:46:58 +02:00
. data = sCursor_Gfx ,
2019-01-02 23:40:40 +01:00
. size = 0x200 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_CURSOR
2019-01-02 23:40:40 +01:00
} ,
{ }
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B7780 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 0 ) ,
ANIMCMD_FRAME ( 2 , 0 ) ,
ANIMCMD_FRAME ( 4 , 0 ) ,
ANIMCMD_FRAME ( 6 , 0 ) ,
ANIMCMD_FRAME ( 8 , 0 ) ,
ANIMCMD_FRAME ( 10 , 0 ) ,
ANIMCMD_FRAME ( 12 , 0 ) ,
ANIMCMD_FRAME ( 14 , 0 ) ,
ANIMCMD_FRAME ( 16 , 0 ) ,
ANIMCMD_FRAME ( 18 , 0 ) ,
// BUG: Animation not terminated properly
//ANIMCMD_END
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd * const gSpriteAnimTable_85B77A8 [ ] =
{
2019-01-02 23:40:40 +01:00
gSpriteAnim_85B7780
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd sAnim_Multiplier [ ] =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 0 ) ,
ANIMCMD_FRAME ( 8 , 0 ) ,
ANIMCMD_FRAME ( 16 , 0 ) ,
ANIMCMD_FRAME ( 24 , 0 ) ,
ANIMCMD_FRAME ( 32 , 0 ) ,
ANIMCMD_END
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnims_Multiplier [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
sAnim_Multiplier
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd sAnim_BallCounter [ ] =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 0 ) ,
ANIMCMD_FRAME ( 2 , 0 ) ,
ANIMCMD_FRAME ( 4 , 0 ) ,
ANIMCMD_FRAME ( 6 , 0 ) ,
ANIMCMD_FRAME ( 8 , 0 ) ,
ANIMCMD_END
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnims_BallCounter [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
sAnim_BallCounter
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplate_Credit =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_CREDIT ,
. paletteTag = PALTAG_INTERFACE ,
. oam = & sOam_Credit ,
2019-01-02 23:40:40 +01:00
. anims = gDummySpriteAnimTable ,
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
. callback = SpriteCallbackDummy
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplate_CreditDigit =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_CREDIT_DIGIT ,
. paletteTag = PALTAG_INTERFACE ,
. oam = & sOam_CreditDigit ,
2019-01-02 23:40:40 +01:00
. anims = gSpriteAnimTable_85B77A8 ,
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
. callback = SpriteCallbackDummy
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplate_Multiplier =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_MULTIPLIER ,
. paletteTag = PALTAG_INTERFACE ,
. oam = & sOam_Multiplier ,
. anims = sAnims_Multiplier ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_GridSquare
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplate_BallCounter =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BALL_COUNTER ,
. paletteTag = PALTAG_BALL_COUNTER ,
. oam = & sOam_BallCounter ,
. anims = sAnims_BallCounter ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
. callback = SpriteCallbackDummy
} ;
2020-07-29 10:46:58 +02:00
// NOTE: This cursor is only used to identify the winning square on the grid
static const struct SpriteTemplate sSpriteTemplate_Cursor =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_CURSOR ,
. paletteTag = PALTAG_INTERFACE ,
2019-01-02 23:40:40 +01:00
. oam = & gOamData_85B73EC ,
. anims = gDummySpriteAnimTable ,
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
. callback = SpriteCallbackDummy
} ;
2020-07-29 10:46:58 +02:00
static const struct OamData sOam_Ball =
2019-01-02 23:40:40 +01:00
{
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 16 x16 ) ,
. size = SPRITE_SIZE ( 16 x16 ) ,
2019-01-02 23:40:40 +01:00
. priority = 2 ,
} ;
2020-07-29 10:46:58 +02:00
static const struct CompressedSpriteSheet sSpriteSheet_Ball = {
. data = sBall_Gfx ,
2019-01-02 23:40:40 +01:00
. size = 0x200 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_BALL
2019-01-02 23:40:40 +01:00
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B786C [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 5 ) ,
ANIMCMD_FRAME ( 4 , 5 ) ,
ANIMCMD_FRAME ( 8 , 5 ) ,
ANIMCMD_FRAME ( 4 , 5 ) ,
ANIMCMD_JUMP ( 0 )
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B7880 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 10 ) ,
ANIMCMD_FRAME ( 4 , 10 ) ,
ANIMCMD_FRAME ( 8 , 10 ) ,
ANIMCMD_FRAME ( 4 , 10 ) ,
ANIMCMD_JUMP ( 0 )
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B7894 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 15 ) ,
ANIMCMD_FRAME ( 4 , 15 ) ,
ANIMCMD_FRAME ( 8 , 15 ) ,
ANIMCMD_FRAME ( 4 , 15 ) ,
ANIMCMD_JUMP ( 0 )
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B78A8 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 4 , 2 ) ,
ANIMCMD_FRAME ( 8 , 5 ) ,
ANIMCMD_FRAME ( 4 , 5 ) ,
ANIMCMD_FRAME ( 12 , 5 ) ,
ANIMCMD_END
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B78BC [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 4 , 2 ) ,
ANIMCMD_FRAME ( 0 , 4 ) ,
ANIMCMD_FRAME ( 4 , 4 ) ,
ANIMCMD_FRAME ( 8 , 4 ) ,
ANIMCMD_FRAME ( 12 , 4 ) ,
ANIMCMD_END
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B78D4 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 2 ) ,
ANIMCMD_FRAME ( 4 , 5 ) ,
ANIMCMD_FRAME ( 8 , 5 ) ,
ANIMCMD_FRAME ( 12 , 5 ) ,
ANIMCMD_END
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B78E8 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 12 , 0 ) ,
ANIMCMD_END
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B78F0 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 8 , 2 ) ,
ANIMCMD_FRAME ( 4 , 5 ) ,
ANIMCMD_FRAME ( 0 , 5 ) ,
ANIMCMD_FRAME ( 12 , 5 ) ,
ANIMCMD_END
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnims_Ball [ ] =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
gSpriteAnim_85B786C ,
gSpriteAnim_85B7880 ,
gSpriteAnim_85B7894 ,
gSpriteAnim_85B78A8 ,
gSpriteAnim_85B78F0 ,
gSpriteAnim_85B78BC ,
gSpriteAnim_85B78D4 ,
gSpriteAnim_85B78D4 ,
gSpriteAnim_85B78E8
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplate_Ball =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BALL ,
. paletteTag = PALTAG_BALL ,
. oam = & sOam_Ball ,
. anims = sAnims_Ball ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
. callback = SpriteCallbackDummy
} ;
2020-07-29 10:46:58 +02:00
static const struct OamData sOam_BoardCenter =
2019-01-02 23:40:40 +01:00
{
. y = 81 ,
. affineMode = ST_OAM_AFFINE_DOUBLE ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 64 x64 ) ,
. size = SPRITE_SIZE ( 64 x64 ) ,
2019-01-02 23:40:40 +01:00
. priority = 2 ,
} ;
2020-07-29 10:46:58 +02:00
static const struct CompressedSpriteSheet sSpriteSheet_BoardCenter =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
. data = gRouletteCenter_Gfx ,
. size = 0x800 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_BOARD_CENTER
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplate_BoardCenter =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_BOARD_CENTER ,
. paletteTag = PALTAG_BALL ,
. oam = & sOam_BoardCenter ,
2019-01-02 23:40:40 +01:00
. anims = gDummySpriteAnimTable ,
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_BoardCenter
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const struct OamData sOam_Shroomish =
2019-01-02 23:40:40 +01:00
{
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 32 x32 ) ,
. size = SPRITE_SIZE ( 32 x32 ) ,
2019-01-02 23:40:40 +01:00
. priority = 2 ,
} ;
2020-07-29 10:46:58 +02:00
static const struct OamData sOam_Taillow =
2019-01-02 23:40:40 +01:00
{
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 32 x32 ) ,
. size = SPRITE_SIZE ( 32 x32 ) ,
2019-01-02 23:40:40 +01:00
. priority = 2 ,
} ;
2020-07-29 10:46:58 +02:00
static const struct CompressedSpriteSheet sSpriteSheet_ShroomishTaillow =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
. data = sShroomishTaillow_Gfx ,
2019-01-02 23:40:40 +01:00
. size = 0xE00 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_SHROOMISH_TAILLOW
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd sAnim_Shroomish [ ] =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 6 ) ,
ANIMCMD_FRAME ( 16 , 6 ) ,
ANIMCMD_FRAME ( 32 , 6 ) ,
ANIMCMD_FRAME ( 48 , 6 ) ,
ANIMCMD_FRAME ( 32 , 6 ) ,
ANIMCMD_FRAME ( 64 , 6 ) ,
ANIMCMD_JUMP ( 2 )
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B799C [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 80 , 10 ) ,
ANIMCMD_END
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B79A4 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 80 , 10 , . hFlip = TRUE ) ,
ANIMCMD_END
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B79AC [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 80 , 20 ) ,
ANIMCMD_FRAME ( 96 , 20 ) ,
ANIMCMD_JUMP ( 0 )
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B79B8 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 80 , 20 , . hFlip = TRUE ) ,
ANIMCMD_FRAME ( 96 , 20 , . hFlip = TRUE ) ,
ANIMCMD_JUMP ( 0 )
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B79C4 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 80 , 10 ) ,
ANIMCMD_FRAME ( 96 , 10 ) ,
ANIMCMD_JUMP ( 0 )
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B79D0 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 80 , 10 , . hFlip = TRUE ) ,
ANIMCMD_FRAME ( 96 , 10 , . hFlip = TRUE ) ,
ANIMCMD_JUMP ( 0 )
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnims_Shroomish [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
sAnim_Shroomish
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static const union AnimCmd * const sAnims_Taillow [ ] =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
gSpriteAnim_85B799C ,
gSpriteAnim_85B79A4 ,
gSpriteAnim_85B79AC ,
gSpriteAnim_85B79B8 ,
gSpriteAnim_85B79C4 ,
gSpriteAnim_85B79D0
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplate_Shroomish =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_SHROOMISH_TAILLOW ,
. paletteTag = PALTAG_SHROOMISH ,
. oam = & sOam_Shroomish ,
. anims = sAnims_Shroomish ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
. callback = SpriteCallbackDummy
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplate_Taillow =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_SHROOMISH_TAILLOW ,
. paletteTag = PALTAG_TAILLOW ,
. oam = & sOam_Taillow ,
. anims = sAnims_Taillow ,
2019-01-02 23:40:40 +01:00
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
2020-07-29 10:46:58 +02:00
. callback = SpriteCB_Taillow
2019-01-02 23:40:40 +01:00
} ;
static const struct OamData gOamData_85B7A28 =
{
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 16 x16 ) ,
. size = SPRITE_SIZE ( 16 x16 ) ,
2019-01-02 23:40:40 +01:00
. priority = 2 ,
} ;
static const struct OamData gOamData_85B7A30 =
{
. affineMode = ST_OAM_AFFINE_OFF ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 32 x16 ) ,
. size = SPRITE_SIZE ( 32 x16 ) ,
2019-01-02 23:40:40 +01:00
. priority = 2 ,
} ;
2020-07-29 10:46:58 +02:00
static const struct OamData sOam_TaillowShadow =
2019-01-02 23:40:40 +01:00
{
. affineMode = ST_OAM_AFFINE_NORMAL ,
. objMode = ST_OAM_OBJ_NORMAL ,
2019-03-11 08:12:15 +01:00
. shape = SPRITE_SHAPE ( 32 x16 ) ,
. size = SPRITE_SIZE ( 32 x16 ) ,
2019-01-02 23:40:40 +01:00
. priority = 2 ,
} ;
2019-01-02 23:55:50 +01:00
2020-07-29 10:46:58 +02:00
static const struct CompressedSpriteSheet sSpriteSheet_Shadow =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
. data = sShadow_Gfx ,
2019-01-02 23:40:40 +01:00
. size = 0x180 ,
2020-07-29 10:46:58 +02:00
. tag = GFXTAG_SHADOW
2019-01-02 23:40:40 +01:00
} ;
2019-03-11 08:12:15 +01:00
static const union AffineAnimCmd gSpriteAffineAnim_85B7A48 [ ] =
{
2019-01-02 23:40:40 +01:00
AFFINEANIMCMD_FRAME ( 0x80 , 0x80 , 0 , 0 ) ,
AFFINEANIMCMD_FRAME ( 2 , 2 , 0 , 60 ) ,
AFFINEANIMCMD_END
} ;
2020-07-29 10:46:58 +02:00
static const union AffineAnimCmd sAffineAnim_TaillowShadow [ ] =
2019-03-11 08:12:15 +01:00
{
2019-01-02 23:40:40 +01:00
AFFINEANIMCMD_FRAME ( 0x100 , 0x100 , 0 , 0 ) ,
AFFINEANIMCMD_FRAME ( - 2 , 0x0 , 0 , 15 ) ,
AFFINEANIMCMD_FRAME ( - 1 , - 2 , 0 , 15 ) ,
AFFINEANIMCMD_FRAME ( - 1 , - 5 , 0 , 24 ) ,
AFFINEANIMCMD_END
} ;
2019-03-11 08:12:15 +01:00
static const union AffineAnimCmd * const gSpriteAffineAnimTable_85B7A88 [ ] =
{
2019-01-02 23:40:40 +01:00
gSpriteAffineAnim_85B7A48
} ;
2020-07-29 10:46:58 +02:00
static const union AffineAnimCmd * const sAffineAnims_TaillowShadow [ ] =
2019-03-11 08:12:15 +01:00
{
2020-07-29 10:46:58 +02:00
sAffineAnim_TaillowShadow
2019-01-02 23:40:40 +01:00
} ;
2019-03-11 08:12:15 +01:00
static const union AffineAnimCmd gSpriteAffineAnim_85B7A90 [ ] =
{
2019-01-02 23:40:40 +01:00
AFFINEANIMCMD_FRAME ( 0x100 , 0x100 , 0 , 0 ) ,
AFFINEANIMCMD_END
} ;
2019-03-11 08:12:15 +01:00
static const union AffineAnimCmd * const gSpriteAffineAnimTable_85B7AA0 [ ] =
{
2019-01-02 23:40:40 +01:00
gSpriteAffineAnim_85B7A90
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B7AA4 [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 0 , 0 ) ,
ANIMCMD_END
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd gSpriteAnim_85B7AAC [ ] =
{
2019-01-02 23:40:40 +01:00
ANIMCMD_FRAME ( 4 , 0 ) ,
ANIMCMD_END
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd * const gSpriteAnimTable_85B7AB4 [ ] =
{
2019-01-02 23:40:40 +01:00
gSpriteAnim_85B7AA4
} ;
2019-03-11 08:12:15 +01:00
static const union AnimCmd * const gSpriteAnimTable_85B7AB8 [ ] =
{
2019-01-02 23:40:40 +01:00
gSpriteAnim_85B7AAC
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplate_ShroomishShadow [ ] =
2019-01-02 23:40:40 +01:00
{
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_SHADOW ,
. paletteTag = PALTAG_SHADOW ,
2019-01-02 23:40:40 +01:00
. oam = & gOamData_85B7A28 ,
. anims = gSpriteAnimTable_85B7AB4 ,
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
. callback = SpriteCallbackDummy
} ,
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_SHADOW ,
. paletteTag = PALTAG_SHADOW ,
2019-01-02 23:40:40 +01:00
. oam = & gOamData_85B7A30 ,
. anims = gSpriteAnimTable_85B7AB8 ,
. images = NULL ,
. affineAnims = gDummySpriteAffineAnimTable ,
. callback = sub_8144E60
}
} ;
2020-07-29 10:46:58 +02:00
static const struct SpriteTemplate sSpriteTemplate_TaillowShadow =
2019-01-02 23:40:40 +01:00
{
2020-07-29 10:46:58 +02:00
. tileTag = GFXTAG_SHADOW ,
. paletteTag = PALTAG_SHADOW ,
. oam = & sOam_TaillowShadow ,
2019-01-02 23:40:40 +01:00
. anims = gSpriteAnimTable_85B7AB8 ,
. images = NULL ,
2020-07-29 10:46:58 +02:00
. affineAnims = sAffineAnims_TaillowShadow ,
. callback = SpriteCB_Taillow
2019-01-02 23:40:40 +01:00
} ;
2020-07-29 10:46:58 +02:00
static void Task_ShowMinBetYesNo ( u8 taskId )
2019-01-02 23:55:50 +01:00
{
2019-02-27 04:30:40 +01:00
DisplayYesNoMenuDefaultYes ( ) ;
2020-07-29 10:46:58 +02:00
DoYesNoFuncWithChoice ( taskId , & sYesNoTable_AcceptMinBet ) ;
2019-01-02 23:55:50 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_FadeToRouletteGame ( u8 taskId )
2019-01-02 23:55:50 +01:00
{
if ( ! gPaletteFade . active )
{
SetVBlankCallback ( NULL ) ;
2020-07-29 10:46:58 +02:00
SetMainCallback2 ( CB2_LoadRoulette ) ;
2019-01-02 23:55:50 +01:00
DestroyTask ( taskId ) ;
}
}
2020-07-29 10:46:58 +02:00
static void Task_AcceptMinBet ( u8 taskId )
2019-01-02 23:55:50 +01:00
{
2019-02-22 07:40:11 +01:00
ClearStdWindowAndFrame ( 0 , TRUE ) ;
2019-01-02 23:55:50 +01:00
HideCoinsWindow ( ) ;
FreeAllWindowBuffers ( ) ;
BeginNormalPaletteFade ( 0xFFFFFFFF , 0 , 0 , 16 , RGB_BLACK ) ;
gPaletteFade . delayCounter = gPaletteFade . multipurpose2 ;
UpdatePaletteFade ( ) ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_FadeToRouletteGame ;
2019-01-02 23:55:50 +01:00
}
2020-07-29 10:46:58 +02:00
static void Task_DeclineMinBet ( u8 taskId )
2019-01-02 23:55:50 +01:00
{
2019-02-22 07:40:11 +01:00
ClearStdWindowAndFrame ( 0 , FALSE ) ;
2019-01-02 23:55:50 +01:00
HideCoinsWindow ( ) ;
ScriptContext2_Disable ( ) ;
DestroyTask ( taskId ) ;
}
2020-07-29 10:46:58 +02:00
static void Task_NotEnoughForMinBet ( u8 taskId )
2019-01-02 23:55:50 +01:00
{
gTasks [ taskId ] . data [ 0 ] + + ;
2020-07-29 10:46:58 +02:00
if ( JOY_NEW ( A_BUTTON | B_BUTTON ) )
2019-01-02 23:55:50 +01:00
{
gSpecialVar_0x8004 = 1 ;
HideCoinsWindow ( ) ;
2019-02-22 07:40:11 +01:00
ClearStdWindowAndFrame ( 0 , TRUE ) ;
2019-01-02 23:55:50 +01:00
ScriptContext2_Disable ( ) ;
DestroyTask ( taskId ) ;
}
}
2020-07-29 10:46:58 +02:00
static void Task_PrintMinBet ( u8 taskId )
2019-01-02 23:55:50 +01:00
{
2020-07-29 10:46:58 +02:00
if ( JOY_NEW ( A_BUTTON | B_BUTTON ) )
2019-01-02 23:55:50 +01:00
{
2020-07-29 10:46:58 +02:00
u32 minBet = sTableMinBets [ GET_TABLE_ID ( gSpecialVar_0x8004 ) ] ;
ConvertIntToDecimalStringN ( gStringVar1 , minBet , STR_CONV_MODE_LEADING_ZEROS , 1 ) ;
2019-10-07 08:00:16 +02:00
StringExpandPlaceholders ( gStringVar4 , Roulette_Text_PlayMinimumWagerIsX ) ;
2019-02-22 07:40:11 +01:00
DrawStdWindowFrame ( 0 , FALSE ) ;
2019-01-02 23:55:50 +01:00
AddTextPrinterParameterized ( 0 , 1 , gStringVar4 , 0 , 1 , TEXT_SPEED_FF , NULL ) ;
CopyWindowToVram ( 0 , 3 ) ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_ShowMinBetYesNo ;
2019-01-02 23:55:50 +01:00
}
}
2020-07-29 10:46:58 +02:00
static void Task_PrintRouletteEntryMsg ( u8 taskId )
2019-01-02 23:55:50 +01:00
{
2020-07-29 10:46:58 +02:00
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 )
2019-01-02 23:55:50 +01:00
{
2020-07-29 10:46:58 +02:00
if ( ( gSpecialVar_0x8004 & ROULETTE_SPECIAL_RATE ) & & ( gSpecialVar_0x8004 & 1 ) )
2019-01-02 23:55:50 +01:00
{
2020-07-29 10:46:58 +02:00
// Special rate for Game Corner service day (only at second table)
2019-02-22 07:40:11 +01:00
DrawStdWindowFrame ( 0 , FALSE ) ;
2019-10-07 08:00:16 +02:00
AddTextPrinterParameterized ( 0 , 1 , Roulette_Text_SpecialRateTable , 0 , 1 , TEXT_SPEED_FF , NULL ) ;
2019-01-02 23:55:50 +01:00
CopyWindowToVram ( 0 , 3 ) ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_PrintMinBet ;
2019-01-02 23:55:50 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
// Print minimum bet
2019-10-07 08:00:16 +02:00
StringExpandPlaceholders ( gStringVar4 , Roulette_Text_PlayMinimumWagerIsX ) ;
2019-02-22 07:40:11 +01:00
DrawStdWindowFrame ( 0 , FALSE ) ;
2019-01-02 23:55:50 +01:00
AddTextPrinterParameterized ( 0 , 1 , gStringVar4 , 0 , 1 , TEXT_SPEED_FF , NULL ) ;
CopyWindowToVram ( 0 , 3 ) ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_ShowMinBetYesNo ;
2019-01-02 23:55:50 +01:00
}
}
else
{
2020-07-29 10:46:58 +02:00
// Not enough for minimum bet
2019-10-07 08:00:16 +02:00
StringExpandPlaceholders ( gStringVar4 , Roulette_Text_NotEnoughCoins ) ;
2019-02-22 07:40:11 +01:00
DrawStdWindowFrame ( 0 , FALSE ) ;
2019-01-02 23:55:50 +01:00
AddTextPrinterParameterized ( 0 , 1 , gStringVar4 , 0 , 1 , TEXT_SPEED_FF , NULL ) ;
CopyWindowToVram ( 0 , 3 ) ;
2020-07-29 10:46:58 +02:00
gTasks [ taskId ] . func = Task_NotEnoughForMinBet ;
gTasks [ taskId ] . tCoins = 0 ;
2019-01-02 23:55:50 +01:00
gTasks [ taskId ] . data [ 0 ] = 0 ;
}
}
void PlayRoulette ( void )
{
u8 taskId ;
ScriptContext2_Enable ( ) ;
ShowCoinsWindow ( GetCoins ( ) , 1 , 1 ) ;
2020-07-29 10:46:58 +02:00
taskId = CreateTask ( Task_PrintRouletteEntryMsg , 0 ) ;
gTasks [ taskId ] . tCoins = GetCoins ( ) ;
2019-01-02 23:55:50 +01:00
}
2020-07-29 10:46:58 +02:00
static void LoadOrFreeMiscSpritePalettesAndSheets ( bool8 free )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
if ( ! free )
2019-01-01 01:07:29 +01:00
{
FreeAllSpritePalettes ( ) ;
2020-07-29 10:46:58 +02:00
LoadSpritePalettes ( sSpritePalettes ) ;
LoadCompressedSpriteSheet ( & sSpriteSheet_Ball ) ;
LoadCompressedSpriteSheet ( & sSpriteSheet_ShroomishTaillow ) ;
LoadCompressedSpriteSheet ( & sSpriteSheet_Shadow ) ;
2019-01-01 01:07:29 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
// Unused
FreeSpriteTilesByTag ( GFXTAG_SHADOW ) ;
FreeSpriteTilesByTag ( GFXTAG_SHROOMISH_TAILLOW ) ;
FreeSpriteTilesByTag ( GFXTAG_BALL ) ;
2019-01-01 01:07:29 +01:00
FreeAllSpritePalettes ( ) ;
}
}
2020-07-29 10:46:58 +02:00
static u8 CreateBoardIconSprite ( const struct SpriteTemplate * r0 , u8 r1 , u16 * r2 )
2019-01-01 01:07:29 +01:00
{
u16 temp ;
u8 spriteId = CreateSprite ( r0 , 116 , 80 , r0 - > oam - > y ) ;
2020-07-29 10:46:58 +02:00
gSprites [ spriteId ] . data [ 0 ] = * r2 ;
gSprites [ spriteId ] . data [ 1 ] = r1 ;
2019-01-01 01:07:29 +01:00
gSprites [ spriteId ] . coordOffsetEnabled = TRUE ;
2020-07-29 10:46:58 +02:00
gSprites [ spriteId ] . animPaused = TRUE ;
gSprites [ spriteId ] . affineAnimPaused = TRUE ;
2019-01-01 01:07:29 +01:00
temp = * r2 ;
* r2 + = 30 ;
if ( * r2 > = 360 )
* r2 = temp - 330 ;
return spriteId ;
}
2020-07-29 10:46:58 +02:00
static void CreateGridSprites ( void )
2019-01-01 01:07:29 +01:00
{
u8 i , j ;
u8 spriteId ;
struct SpriteSheet s ;
2020-07-29 10:46:58 +02:00
LZ77UnCompWram ( sSpriteSheet_Headers . data , gDecompressionBuffer ) ;
2019-01-01 01:07:29 +01:00
s . data = gDecompressionBuffer ;
2020-07-29 10:46:58 +02:00
s . size = sSpriteSheet_Headers . size ;
s . tag = sSpriteSheet_Headers . tag ;
2019-01-01 01:07:29 +01:00
LoadSpriteSheet ( & s ) ;
2020-07-29 10:46:58 +02:00
LZ77UnCompWram ( sSpriteSheet_PokeIcons . data , gDecompressionBuffer ) ;
2019-01-01 01:07:29 +01:00
s . data = gDecompressionBuffer ;
2020-07-29 10:46:58 +02:00
s . size = sSpriteSheet_PokeIcons . size ;
s . tag = sSpriteSheet_PokeIcons . tag ;
2019-01-01 01:07:29 +01:00
LoadSpriteSheet ( & s ) ;
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < NUM_BOARD_COLORS ; i + + )
2019-01-01 01:07:29 +01:00
{
u8 o = i * 24 ;
2020-07-29 10:46:58 +02:00
for ( j = 0 ; j < NUM_BOARD_POKES ; j + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
spriteId = sRoulette - > spriteIds [ ( i * NUM_BOARD_POKES ) + SPR_GRID_ICONS + j ] = CreateSprite ( & sSpriteTemplate_GridIcons [ j ] , ( j * 24 ) + 148 , o + 92 , 30 ) ;
2019-01-01 01:07:29 +01:00
gSprites [ spriteId ] . animPaused = TRUE ;
o + = 24 ;
if ( o > = 72 )
o = 0 ;
}
}
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < ARRAY_COUNT ( sSpriteTemplates_PokeHeaders ) ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
spriteId = sRoulette - > spriteIds [ i + SPR_POKE_HEADER_1 ] = CreateSprite ( & sSpriteTemplates_PokeHeaders [ i ] , ( i * 24 ) + 148 , 70 , 30 ) ;
2019-01-01 01:07:29 +01:00
gSprites [ spriteId ] . animPaused = TRUE ;
}
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < ARRAY_COUNT ( sSpriteTemplates_ColorHeaders ) ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
spriteId = sRoulette - > spriteIds [ i + SPR_COLOR_HEADER_1 ] = CreateSprite ( & sSpriteTemplates_ColorHeaders [ i ] , 126 , ( i * 24 ) + 92 , 30 ) ;
2019-01-01 01:07:29 +01:00
gSprites [ spriteId ] . animPaused = TRUE ;
}
}
2020-07-29 10:46:58 +02:00
// Unused
static void DestroyGridSprites ( void )
2019-01-01 01:07:29 +01:00
{
u8 i ;
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < NUM_ROULETTE_SLOTS ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
DestroySprite ( & gSprites [ sRoulette - > spriteIds [ i + SPR_GRID_ICONS ] ] ) ;
2019-01-01 01:07:29 +01:00
}
}
2020-07-29 10:46:58 +02:00
static void ShowHideGridIcons ( bool8 hideAll , u8 hideSquare )
2019-01-01 01:07:29 +01:00
{
u8 i ;
2020-07-29 10:46:58 +02:00
switch ( hideAll )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
case TRUE :
// Hide grid icons and headers
for ( i = 0 ; i < NUM_GRID_SELECTIONS ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
gSprites [ sRoulette - > spriteIds [ i + SPR_GRID_ICONS ] ] . invisible = TRUE ;
2019-01-01 01:07:29 +01:00
}
break ;
2020-07-29 10:46:58 +02:00
case FALSE :
for ( i = 0 ; i < NUM_ROULETTE_SLOTS ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
else
2020-07-29 10:46:58 +02:00
gSprites [ sRoulette - > spriteIds [ i + SPR_GRID_ICONS ] ] . invisible = FALSE ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
// Always show grid headers
for ( ; i < NUM_GRID_SELECTIONS ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
gSprites [ sRoulette - > spriteIds [ i + SPR_GRID_ICONS ] ] . invisible = FALSE ;
2019-01-01 01:07:29 +01:00
}
break ;
}
}
2020-07-29 10:46:58 +02:00
static void CreateGridBallSprites ( void )
2019-01-01 01:07:29 +01:00
{
u8 i ;
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < BALLS_PER_ROUND ; i + + )
{
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 ) ;
2019-01-01 01:07:29 +01:00
}
}
2020-07-29 10:46:58 +02:00
static void ShowHideGridBalls ( bool8 hideAll , u8 hideBallId )
2019-01-01 01:07:29 +01:00
{
u8 i = 0 ;
2020-07-29 10:46:58 +02:00
if ( hideAll )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
for ( ; i < BALLS_PER_ROUND ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
gSprites [ sRoulette - > spriteIds [ i + SPR_GRID_BALL_1 ] ] . invisible = TRUE ;
2019-01-01 01:07:29 +01:00
}
}
else
{
2020-07-29 10:46:58 +02:00
for ( ; i < BALLS_PER_ROUND ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
if ( ! sRoulette - > hitSquares [ i ] | | i = = hideBallId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
gSprites [ sRoulette - > spriteIds [ i + SPR_GRID_BALL_1 ] ] . invisible = TRUE ;
2019-01-01 01:07:29 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
}
}
}
}
2020-07-29 10:46:58 +02:00
static void ShowHideWinSlotCursor ( u8 selectionId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
if ( selectionId = = 0 )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
gSprites [ sRoulette - > spriteIds [ SPR_WIN_SLOT_CURSOR ] ] . invisible = TRUE ;
2019-01-01 01:07:29 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
}
}
2020-07-29 10:46:58 +02:00
static void CreateBoardIconSprites ( void )
2019-01-01 01:07:29 +01:00
{
u8 i , j ;
u16 k ;
struct SpriteSheet s ;
2020-07-29 10:46:58 +02:00
LZ77UnCompWram ( sSpriteSheet_BoardIcons . data , gDecompressionBuffer ) ;
2019-01-01 01:07:29 +01:00
s . data = gDecompressionBuffer ;
2020-07-29 10:46:58 +02:00
s . size = sSpriteSheet_BoardIcons . size ;
s . tag = sSpriteSheet_BoardIcons . tag ;
2019-01-01 01:07:29 +01:00
LoadSpriteSheet ( & s ) ;
k = 15 ;
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < NUM_BOARD_COLORS ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
for ( j = 0 ; j < NUM_BOARD_POKES ; j + + )
2019-01-01 01:07:29 +01:00
{
u8 spriteId ;
2020-07-29 10:46:58 +02:00
spriteId = sRoulette - > spriteIds [ ( i * NUM_BOARD_POKES ) + SPR_BOARD_ICONS + j ] = CreateBoardIconSprite ( & sSpriteTemplates_BoardIcons [ i * NUM_BOARD_POKES + j ] , 40 , & k ) ;
2019-01-01 01:07:29 +01:00
gSprites [ spriteId ] . animPaused = TRUE ;
gSprites [ spriteId ] . affineAnimPaused = TRUE ;
}
}
}
2020-07-29 10:46:58 +02:00
static void SpriteCB_BoardIcon ( struct Sprite * sprite )
2019-01-01 01:07:29 +01:00
{
s16 cos ;
s16 sin ;
u32 matrixNum ;
2020-07-29 10:46:58 +02:00
s16 angle = sRoulette - > var24 + sprite - > data [ 0 ] ;
2019-01-01 01:07:29 +01:00
if ( angle > = 360 )
angle - = 360 ;
sin = Sin2 ( angle ) ;
cos = Cos2 ( angle ) ;
sprite - > pos2 . x = sin * sprite - > data [ 1 ] > > 12 ;
sprite - > pos2 . y = - cos * sprite - > data [ 1 ] > > 12 ;
matrixNum = sprite - > oam . matrixNum ;
sin / = 16 ;
gOamMatrices [ matrixNum ] . d = cos / = 16 ;
gOamMatrices [ matrixNum ] . a = cos ;
gOamMatrices [ matrixNum ] . b = sin ;
gOamMatrices [ matrixNum ] . c = - sin ;
}
2020-07-29 10:46:58 +02:00
static void CreateInterfaceSprites ( void )
2019-01-01 01:07:29 +01:00
{
u8 i ;
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < ARRAY_COUNT ( sSpriteSheets_Interface ) - 1 ; i + + )
2019-01-01 01:07:29 +01:00
{
struct SpriteSheet s ;
2020-07-29 10:46:58 +02:00
LZ77UnCompWram ( sSpriteSheets_Interface [ i ] . data , gDecompressionBuffer ) ;
2019-01-01 01:07:29 +01:00
s . data = gDecompressionBuffer ;
2020-07-29 10:46:58 +02:00
s . size = sSpriteSheets_Interface [ i ] . size ;
s . tag = sSpriteSheets_Interface [ i ] . tag ;
2019-01-01 01:07:29 +01:00
LoadSpriteSheet ( & s ) ;
}
2020-07-29 10:46:58 +02:00
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 + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
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 + + )
{
// 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 ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
}
2020-07-29 10:46:58 +02:00
static void SetCreditDigits ( u16 r0 )
2019-01-01 01:07:29 +01:00
{
u8 i ;
u16 d = 1000 ;
bool8 v = FALSE ;
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < MAX_COIN_DIGITS ; i + + )
2019-01-01 01:07:29 +01:00
{
u8 t = r0 / d ;
2020-07-29 10:46:58 +02:00
gSprites [ sRoulette - > spriteIds [ i + SPR_CREDIT_DIG_1 ] ] . invisible = TRUE ;
if ( t > 0 | | v | | i = = MAX_COIN_DIGITS - 1 )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
v = TRUE ;
}
r0 = r0 % d ;
d = d / 10 ;
}
}
2020-07-29 10:46:58 +02:00
// Identical to GetMultiplier but with different data array
static u8 GetMultiplierAnimId ( u8 selectionId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
u8 animIds [ 5 ] = { 0 , 1 , 2 , 3 , 4 } ;
2019-01-02 23:40:40 +01:00
2020-07-29 10:46:58 +02:00
if ( selectionId > NUM_GRID_SELECTIONS )
selectionId = 0 ;
switch ( sGridSelections [ selectionId ] . baseMultiplier )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
case NUM_BOARD_COLORS :
selectionId = selectionId / 5 - 1 ;
if ( sRoulette - > colorHits [ selectionId ] > 3 )
2019-01-01 01:07:29 +01:00
return 0 ;
2020-07-29 10:46:58 +02:00
return animIds [ sRoulette - > colorHits [ selectionId ] + 1 ] ;
case NUM_BOARD_POKES :
selectionId - - ;
if ( sRoulette - > pokeHits [ selectionId ] > 2 )
2019-01-01 01:07:29 +01:00
return 0 ;
2020-07-29 10:46:58 +02:00
return animIds [ sRoulette - > pokeHits [ selectionId ] + 2 ] ;
case NUM_ROULETTE_SLOTS :
if ( sRoulette - > hitFlags & sGridSelections [ selectionId ] . flag )
2019-01-01 01:07:29 +01:00
return 0 ;
2020-07-29 10:46:58 +02:00
return animIds [ 4 ] ;
2019-01-01 01:07:29 +01:00
}
return 0 ;
}
2020-07-29 10:46:58 +02:00
static void SetMultiplierSprite ( u8 selectionId )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
struct Sprite * s = & gSprites [ sRoulette - > spriteIds [ SPR_MULTIPLIER ] ] ;
s - > animCmdIndex = GetMultiplierAnimId ( selectionId ) ;
2019-01-01 01:07:29 +01:00
s - > oam . tileNum = s - > sheetTileStart + ( * s - > anims + s - > animCmdIndex ) - > type ;
}
2020-07-29 10:46:58 +02:00
static void SetBallCounterNumLeft ( u8 numBalls )
2019-01-01 01:07:29 +01:00
{
u8 i ;
u8 t = 0 ;
2020-07-29 10:46:58 +02:00
if ( sRoulette - > minBet = = 1 )
2019-01-01 01:07:29 +01:00
t = 2 ;
2020-07-29 10:46:58 +02:00
switch ( numBalls )
2019-01-01 01:07:29 +01:00
{
case 6 :
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < BALLS_PER_ROUND / 2 ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
}
break ;
case 5 :
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
break ;
case 4 :
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
break ;
case 3 :
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
break ;
case 2 :
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
break ;
case 1 :
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
break ;
case 0 :
default :
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < BALLS_PER_ROUND / 2 ; i + + )
2019-01-01 01:07:29 +01:00
{
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 01:07:29 +01:00
}
}
}
2019-01-01 02:39:41 +01:00
2020-07-29 10:46:58 +02:00
static void SpriteCB_GridSquare ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
sprite - > pos2 . x = sRoulette - > var26 ;
2019-01-01 02:39:41 +01:00
}
2020-07-29 10:46:58 +02:00
static void CreateBoardCenterSprite ( void )
2019-01-01 02:39:41 +01:00
{
u8 spriteId ;
struct SpriteSheet s ;
2020-07-29 10:46:58 +02:00
LZ77UnCompWram ( sSpriteSheet_BoardCenter . data , gDecompressionBuffer ) ;
2019-01-01 02:39:41 +01:00
s . data = gDecompressionBuffer ;
2020-07-29 10:46:58 +02:00
s . size = sSpriteSheet_BoardCenter . size ;
s . tag = sSpriteSheet_BoardCenter . tag ;
2019-01-01 02:39:41 +01:00
LoadSpriteSheet ( & s ) ;
2020-07-29 10:46:58 +02:00
spriteId = CreateSprite ( & sSpriteTemplate_BoardCenter , 116 , 80 , 81 ) ;
gSprites [ spriteId ] . data [ 0 ] = sRoulette - > var24 ;
2019-01-01 02:39:41 +01:00
gSprites [ spriteId ] . data [ 1 ] = 0 ;
gSprites [ spriteId ] . animPaused = TRUE ;
gSprites [ spriteId ] . affineAnimPaused = TRUE ;
gSprites [ spriteId ] . coordOffsetEnabled = TRUE ;
}
2020-07-29 10:46:58 +02:00
static void SpriteCB_BoardCenter ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
u32 t = sprite - > oam . matrixNum ;
struct OamMatrix * m = & gOamMatrices [ 0 ] ;
2020-07-29 10:46:58 +02:00
m [ t ] . d = sRoulette - > var2C . a ;
m [ t ] . a = sRoulette - > var2C . a ;
m [ t ] . b = sRoulette - > var2C . b ;
m [ t ] . c = sRoulette - > var2C . c ;
2019-01-01 02:39:41 +01:00
}
2020-07-29 10:46:58 +02:00
static void CreateBoardBallSprites ( void )
2019-01-01 02:39:41 +01:00
{
u8 i ;
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < BALLS_PER_ROUND ; i + + )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
sRoulette - > spriteIds [ i ] = CreateSprite ( & sSpriteTemplate_Ball , 116 , 80 , 57 - i ) ;
if ( sRoulette - > spriteIds [ i ] ! = MAX_SPRITES )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
gSprites [ sRoulette - > spriteIds [ i ] ] . invisible = TRUE ;
gSprites [ sRoulette - > spriteIds [ i ] ] . coordOffsetEnabled = TRUE ;
2019-01-01 02:39:41 +01:00
}
}
}
2020-07-29 10:46:58 +02:00
static void HideBoardBalls ( void )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
u8 t = sRoulette - > spriteIds [ SPR_BALL_1 ] ;
2019-01-01 02:39:41 +01:00
u8 i ;
2020-07-29 10:46:58 +02:00
for ( i = 0 ; i < BALLS_PER_ROUND ; i + + )
2019-01-01 02:39:41 +01:00
{
u8 j ;
gSprites [ t ] . invisible = TRUE ;
gSprites [ t ] . callback = & SpriteCallbackDummy ;
StartSpriteAnim ( & gSprites [ t ] , 0 ) ;
for ( j = 0 ; j < 8 ; j + + )
{
gSprites [ t ] . data [ j ] = 0 ;
}
t + + ;
}
}
2019-01-02 23:55:50 +01:00
static s16 sub_8143AC8 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var24 > sprite - > data [ 3 ] )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
sprite - > data [ 6 ] = 360 - sRoulette - > var24 + sprite - > data [ 3 ] ;
2019-01-01 02:39:41 +01:00
if ( sprite - > data [ 6 ] > = 360 )
sprite - > data [ 6 ] - = 360 ;
}
else
{
2020-07-29 10:46:58 +02:00
sprite - > data [ 6 ] = sprite - > data [ 3 ] - sRoulette - > var24 ;
2019-01-01 02:39:41 +01:00
}
return sprite - > data [ 6 ] ;
}
2019-01-02 23:55:50 +01:00
static u8 sub_8143B14 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
sRoulette - > var7E = sub_8143AC8 ( sprite ) / 30.0f ;
return sRoulette - > var7E ;
2019-01-01 02:39:41 +01:00
}
2019-01-02 23:55:50 +01:00
static s16 sub_8143B48 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
s16 t = sub_8143AC8 ( sprite ) % 30 ;
u16 z ;
if ( t = = 14 )
{
z = 0 ;
return sprite - > data [ 2 ] = z ;
}
else if ( t > 13 )
{
z = 43 - t ;
return sprite - > data [ 2 ] = z ;
}
else
{
z = 14 - t ;
return sprite - > data [ 2 ] = z ;
}
}
2019-01-02 23:55:50 +01:00
static void sub_8143B84 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
s16 sin , cos ;
2020-07-29 10:46:58 +02:00
sRoulette - > var8C + = sRoulette - > var90 ;
sRoulette - > var88 + = sRoulette - > var8C ;
2019-01-01 02:39:41 +01:00
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var88 > = 360 )
sRoulette - > var88 - = 360.0f ;
else if ( sRoulette - > var88 < 0.0f )
sRoulette - > var88 + = 360.0f ;
2019-01-01 02:39:41 +01:00
2020-07-29 10:46:58 +02:00
sprite - > data [ 3 ] = sRoulette - > var88 ;
sRoulette - > var98 + = sRoulette - > var9C ;
sRoulette - > var94 + = sRoulette - > var98 ;
sprite - > data [ 4 ] = sRoulette - > var94 ;
2019-01-01 02:39:41 +01:00
sin = Sin2 ( sprite - > data [ 3 ] ) ;
cos = Cos2 ( sprite - > data [ 3 ] ) ;
sprite - > pos2 . x = sin * sprite - > data [ 4 ] > > 12 ;
sprite - > pos2 . y = - cos * sprite - > data [ 4 ] > > 12 ;
if ( IsSEPlaying ( ) )
{
m4aMPlayPanpotControl ( & gMPlayInfo_SE1 , 0xFFFF , sprite - > pos2 . x ) ;
m4aMPlayPanpotControl ( & gMPlayInfo_SE2 , 0xFFFF , sprite - > pos2 . x ) ;
}
}
2019-01-02 23:55:50 +01:00
static void sub_8143C90 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
s16 sin , cos ;
2020-07-29 10:46:58 +02:00
sprite - > data [ 3 ] = sRoulette - > var24 + sprite - > data [ 6 ] ;
2019-01-01 02:39:41 +01:00
if ( sprite - > data [ 3 ] > = 360 )
sprite - > data [ 3 ] - = 360 ;
sin = Sin2 ( sprite - > data [ 3 ] ) ;
cos = Cos2 ( sprite - > data [ 3 ] ) ;
sprite - > pos2 . x = sin * sprite - > data [ 4 ] > > 12 ;
sprite - > pos2 . y = - cos * sprite - > data [ 4 ] > > 12 ;
sprite - > pos2 . y + = gSpriteCoordOffsetY ;
}
2019-01-02 23:55:50 +01:00
static void sub_8143CFC ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
sub_8143B84 ( sprite ) ;
sprite - > data [ 2 ] + + ;
if ( sprite - > data [ 4 ] < - 132 | | sprite - > data [ 4 ] > 80 )
sprite - > invisible = TRUE ;
else
sprite - > invisible = FALSE ;
if ( sprite - > data [ 2 ] > = 30 )
{
if ( ! sprite - > data [ 0 ] )
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var94 < = sRoulette - > varA0 - 2.0f )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
sRoulette - > var7D = 0xFF ;
sRoulette - > var03_7 = FALSE ;
2019-01-01 02:39:41 +01:00
StartSpriteAnim ( sprite , sprite - > animCmdIndex + 0x3 ) ;
sub_8143B14 ( sprite ) ;
sprite - > data [ 4 ] = 30 ;
sub_8143AC8 ( sprite ) ;
sprite - > data [ 6 ] = ( sprite - > data [ 6 ] / 30 ) * 30 + 15 ;
sprite - > callback = sub_8143C90 ;
m4aSongNumStartOrChange ( SE_HASHI ) ;
2020-07-29 10:46:58 +02:00
sRoulette - > var9C = sRoulette - > var98 = 0.0f ;
sRoulette - > var8C = - 1.0f ;
2019-01-01 02:39:41 +01:00
}
}
else
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var94 > = sRoulette - > varA0 - 2.0f )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
sRoulette - > var7D = 0xFF ;
sRoulette - > var03_7 = FALSE ;
2019-01-01 02:39:41 +01:00
StartSpriteAnim ( sprite , sprite - > animCmdIndex + 3 ) ;
sub_8143B14 ( sprite ) ;
sprite - > data [ 4 ] = 30 ;
sub_8143AC8 ( sprite ) ;
sprite - > data [ 6 ] = ( sprite - > data [ 6 ] / 30 ) * 30 + 15 ;
sprite - > callback = sub_8143C90 ;
m4aSongNumStartOrChange ( SE_HASHI ) ;
2020-07-29 10:46:58 +02:00
sRoulette - > var9C = sRoulette - > var98 = 0.0f ;
sRoulette - > var8C = - 1.0f ;
2019-01-01 02:39:41 +01:00
}
}
}
}
2020-07-29 10:46:58 +02:00
static void SpriteCB_Shroomish ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
float f0 , f1 , f2 ;
sub_8143B84 ( sprite ) ;
switch ( sprite - > data [ 3 ] )
{
case 0 :
if ( sprite - > data [ 0 ] ! = 1 )
{
f0 = sprite - > data [ 7 ] ;
2020-07-29 10:46:58 +02:00
f1 = ( f0 * gUnknown_085B6348 [ sRoulette - > tableId ] . var01 + ( gUnknown_085B6348 [ sRoulette - > tableId ] . var02 - 1 ) ) ;
f2 = ( f0 / gUnknown_085B6348 [ sRoulette - > tableId ] . var0C ) ;
2019-01-01 02:39:41 +01:00
}
else
{
return ;
}
break ;
case 180 :
if ( sprite - > data [ 0 ] ! = 0 )
{
f0 = sprite - > data [ 7 ] ;
2020-07-29 10:46:58 +02:00
f1 = ( f0 * gUnknown_085B6348 [ sRoulette - > tableId ] . var01 + ( gUnknown_085B6348 [ sRoulette - > tableId ] . var02 - 1 ) ) ;
f2 = - ( f0 / gUnknown_085B6348 [ sRoulette - > tableId ] . var0C ) ;
2019-01-01 02:39:41 +01:00
}
else
{
return ;
}
break ;
default :
return ;
}
2020-07-29 10:46:58 +02:00
sRoulette - > varA0 = sRoulette - > var94 ;
sRoulette - > var98 = f2 ;
sRoulette - > var9C = - ( ( f2 * 2.0f ) / f1 + ( 2.0f / ( f1 * f1 ) ) ) ;
sRoulette - > var8C = 0.0f ;
2019-01-01 02:39:41 +01:00
sprite - > animPaused = FALSE ;
sprite - > animNum = 0 ;
sprite - > animBeginning = TRUE ;
sprite - > animEnded = FALSE ;
sprite - > callback = sub_8143CFC ;
sprite - > data [ 2 ] = 0 ;
}
2019-01-02 23:55:50 +01:00
static void sub_8143FA4 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
sprite - > pos2 . y = ( s16 ) ( sprite - > data [ 2 ] * 0.05f * sprite - > data [ 2 ] ) - 45 ;
sprite - > data [ 2 ] + + ;
if ( sprite - > data [ 2 ] > 29 & & sprite - > pos2 . y > = 0 )
{
2020-07-29 10:46:58 +02:00
sRoulette - > var7D = 0xFF ;
sRoulette - > var03_7 = FALSE ;
2019-01-01 02:39:41 +01:00
StartSpriteAnim ( sprite , sprite - > animCmdIndex + 3 ) ;
sub_8143B14 ( sprite ) ;
sprite - > data [ 4 ] = 30 ;
sub_8143AC8 ( sprite ) ;
sprite - > data [ 6 ] = ( sprite - > data [ 6 ] / 30 ) * 30 + 15 ;
sprite - > callback = sub_8143C90 ;
m4aSongNumStartOrChange ( SE_HASHI ) ;
2020-07-29 10:46:58 +02:00
sRoulette - > var03_6 = TRUE ;
2019-01-01 02:39:41 +01:00
}
}
2019-01-02 23:55:50 +01:00
static void sub_8144050 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
if ( sprite - > data [ 2 ] + + < 45 )
{
sprite - > pos2 . y - - ;
if ( sprite - > data [ 2 ] = = 45 )
{
2020-07-29 10:46:58 +02:00
if ( gSprites [ sRoulette - > spriteIds [ SPR_CLEAR_MON ] ] . animCmdIndex = = 1 )
2019-01-01 02:39:41 +01:00
sprite - > pos2 . y + + ;
}
}
else
{
if ( sprite - > data [ 2 ] < sprite - > data [ 7 ] )
{
2020-07-29 10:46:58 +02:00
if ( gSprites [ sRoulette - > spriteIds [ SPR_CLEAR_MON ] ] . animDelayCounter = = 0 )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
if ( gSprites [ sRoulette - > spriteIds [ SPR_CLEAR_MON ] ] . animCmdIndex = = 1 )
2019-01-01 02:39:41 +01:00
sprite - > pos2 . y + + ;
else
sprite - > pos2 . y - - ;
}
}
else
{
sprite - > animPaused = FALSE ;
sprite - > animNum = 1 ;
sprite - > animBeginning = TRUE ;
sprite - > animEnded = FALSE ;
sprite - > data [ 2 ] = 0 ;
sprite - > callback = sub_8143FA4 ;
m4aSongNumStart ( SE_NAGERU ) ;
}
}
}
2019-01-02 23:55:50 +01:00
static void sub_8144128 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
sub_8143B84 ( sprite ) ;
switch ( sprite - > data [ 3 ] )
{
case 90 :
if ( sprite - > data [ 0 ] ! = 1 )
{
sprite - > callback = & sub_8144050 ;
sprite - > data [ 2 ] = 0 ;
}
break ;
case 270 :
if ( sprite - > data [ 0 ] ! = 0 )
{
sprite - > callback = & sub_8144050 ;
sprite - > data [ 2 ] = 0 ;
}
break ;
}
}
2020-07-29 10:46:58 +02:00
static void CreateClearSpeciesSprite ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
sub_8143B84 ( sprite ) ;
2020-07-29 10:46:58 +02:00
switch ( sRoulette - > useTaillow )
2019-01-01 02:39:41 +01:00
{
default :
2020-07-29 10:46:58 +02:00
case FALSE :
CreateShroomishSprite ( sprite ) ;
sprite - > callback = SpriteCB_Shroomish ;
2019-01-01 02:39:41 +01:00
break ;
2020-07-29 10:46:58 +02:00
case TRUE :
CreateTaillowSprite ( sprite ) ;
2019-01-01 02:39:41 +01:00
sprite - > callback = sub_8144128 ;
break ;
}
}
2019-01-02 23:55:50 +01:00
static void prev_quest_read_x24_hm_usage ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
sub_8143B84 ( sprite ) ;
if ( sprite - > data [ 2 ] - - = = 16 )
2020-07-29 10:46:58 +02:00
sRoulette - > var98 * = - 1.0f ;
2019-01-01 02:39:41 +01:00
if ( sprite - > data [ 2 ] = = 0 )
{
if ( ! sprite - > data [ 0 ] )
{
2020-07-29 10:46:58 +02:00
sRoulette - > var7D = 0xFF ;
sRoulette - > var03_7 = FALSE ;
2019-01-01 02:39:41 +01:00
StartSpriteAnim ( sprite , sprite - > animCmdIndex + 3 ) ;
sub_8143B14 ( sprite ) ;
sprite - > data [ 4 ] = 30 ;
sub_8143AC8 ( sprite ) ;
sprite - > data [ 6 ] = ( sprite - > data [ 6 ] / 30 ) * 30 + 15 ;
sprite - > callback = sub_8143C90 ;
m4aSongNumStartOrChange ( SE_HASHI ) ;
}
else
{
sprite - > animPaused = TRUE ;
m4aSongNumStart ( SE_KON ) ;
sub_8144A24 ( sprite ) ;
}
}
}
2019-01-02 23:55:50 +01:00
static void sub_8144264 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
sub_8143B84 ( sprite ) ;
sprite - > data [ 2 ] = 0 ;
sub_8143B14 ( sprite ) ;
2020-07-29 10:46:58 +02:00
if ( ! ( sRouletteSlots [ sRoulette - > var7E ] . flag & sRoulette - > hitFlags ) )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
sRoulette - > var7D = 0xFF ;
sRoulette - > var03_7 = FALSE ;
2019-01-01 02:39:41 +01:00
StartSpriteAnim ( sprite , sprite - > animCmdIndex + 3 ) ;
sub_8143B14 ( sprite ) ;
sprite - > data [ 4 ] = 30 ;
sub_8143AC8 ( sprite ) ;
sprite - > data [ 6 ] = ( sprite - > data [ 6 ] / 30 ) * 30 + 15 ;
sprite - > callback = sub_8143C90 ;
m4aSongNumStartOrChange ( SE_HASHI ) ;
}
else
{
2020-07-29 10:46:58 +02:00
u8 slotId ;
2019-01-01 02:39:41 +01:00
u32 z ;
m4aSongNumStart ( SE_KON ) ;
z = Random ( ) & 1 ;
if ( z )
{
2020-07-29 10:46:58 +02:00
sRoulette - > var8C = 0.0f ;
sRoulette - > var7F = slotId = ( sRoulette - > var7E + 1 ) % NUM_ROULETTE_SLOTS ;
2019-01-01 02:39:41 +01:00
}
else
{
float temp ;
2020-07-29 10:46:58 +02:00
sRoulette - > var8C = ( temp = gUnknown_085B6348 [ sRoulette - > tableId ] . var1C ) * 2.0f ;
slotId = ( sRoulette - > var7E + NUM_ROULETTE_SLOTS - 1 ) % NUM_ROULETTE_SLOTS ;
sRoulette - > var7F = sRoulette - > var7E ;
2019-01-01 02:39:41 +01:00
}
2020-07-29 10:46:58 +02:00
if ( sRouletteSlots [ slotId ] . flag & sRoulette - > hitFlags )
2019-01-01 02:39:41 +01:00
{
sprite - > data [ 0 ] = 1 ;
2020-07-29 10:46:58 +02:00
sprite - > data [ 2 ] = gUnknown_085B6348 [ sRoulette - > tableId ] . var02 ;
2019-01-01 02:39:41 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
sprite - > data [ 0 ] = sRouletteSlots [ slotId ] . flag & sRoulette - > hitFlags ;
if ( sRoulette - > tableId )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
sprite - > data [ 2 ] = gUnknown_085B6348 [ sRoulette - > tableId ] . var01 ;
2019-01-01 02:39:41 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
sprite - > data [ 2 ] = gUnknown_085B6348 [ sRoulette - > tableId ] . var02 ;
2019-01-01 02:39:41 +01:00
if ( z )
2020-07-29 10:46:58 +02:00
sRoulette - > var8C = 0.5f ;
2019-01-01 02:39:41 +01:00
else
2020-07-29 10:46:58 +02:00
sRoulette - > var8C = - 1.5f ;
2019-01-01 02:39:41 +01:00
}
}
2020-07-29 10:46:58 +02:00
sRoulette - > var98 = 0.085f ;
2019-01-01 02:39:41 +01:00
sprite - > callback = prev_quest_read_x24_hm_usage ;
sprite - > data [ 1 ] = 5 ;
}
}
2019-01-02 23:55:50 +01:00
static void sub_8144410 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
sub_8143B84 ( sprite ) ;
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var8C > 0.5f )
2019-01-01 02:39:41 +01:00
return ;
sub_8143B14 ( sprite ) ;
if ( ! sub_8143B48 ( sprite ) )
{
2020-07-29 10:46:58 +02:00
sRoulette - > var90 = 0.0f ;
sRoulette - > var8C - = ( float ) ( gUnknown_085B6348 [ sRoulette - > tableId ] . var03 )
/ ( gUnknown_085B6348 [ sRoulette - > tableId ] . var04 + 1 ) ;
2019-01-01 02:39:41 +01:00
sprite - > data [ 1 ] = 4 ;
sprite - > callback = sub_8144264 ;
}
else
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var90 ! = 0.0f )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var8C < 0.0f )
2019-01-01 02:39:41 +01:00
{
2020-07-29 10:46:58 +02:00
sRoulette - > var90 = 0.0f ;
sRoulette - > var8C = 0.0f ;
sRoulette - > var98 / = 1.2 ;
2019-01-01 02:39:41 +01:00
}
}
}
}
2019-01-02 23:55:50 +01:00
static void sub_8144514 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
sub_8143B84 ( sprite ) ;
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var94 > 40.f )
2019-01-01 02:39:41 +01:00
return ;
2020-07-29 10:46:58 +02:00
sRoulette - > var98 = - ( 4.0f / ( float ) ( sRoulette - > var86 ) ) ;
sRoulette - > var90 = - ( sRoulette - > var8C / ( float ) ( sRoulette - > var86 ) ) ;
2019-01-01 02:39:41 +01:00
sprite - > animNum = 2 ;
sprite - > animBeginning = TRUE ;
sprite - > animEnded = FALSE ;
sprite - > data [ 1 ] = 3 ;
sprite - > callback = sub_8144410 ;
}
2019-01-02 23:55:50 +01:00
static void sub_81445D8 ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
sub_8143B84 ( sprite ) ;
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var94 > 60.0f )
2019-01-01 02:39:41 +01:00
return ;
m4aSongNumStartOrChange ( SE_TAMAKORO_E ) ;
2020-07-29 10:46:58 +02:00
sRoulette - > var98 = - ( 20.0f / ( float ) ( sRoulette - > var84 ) ) ;
sRoulette - > var90 = ( ( 1.0f - sRoulette - > var8C ) / ( float ) ( sRoulette - > var84 ) ) ;
2019-01-01 02:39:41 +01:00
sprite - > animNum = 1 ;
sprite - > animBeginning = TRUE ;
sprite - > animEnded = FALSE ;
sprite - > data [ 1 ] = 2 ;
sprite - > callback = sub_8144514 ;
}
2019-01-02 23:55:50 +01:00
static void sub_81446AC ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
sprite - > data [ 1 ] = 1 ;
sprite - > data [ 2 ] = 0 ;
sub_8143B84 ( sprite ) ;
sprite - > invisible = FALSE ;
sprite - > callback = sub_81445D8 ;
}
2020-07-29 10:46:58 +02:00
static void CreateShroomishSprite ( struct Sprite * sprite )
2019-01-01 02:39:41 +01:00
{
u16 t ;
u8 i ;
2019-01-02 23:40:40 +01:00
s16 s [ 2 ] [ 2 ] = {
{ 116 , 44 } ,
{ 116 , 112 }
} ;
2019-01-01 02:39:41 +01:00
struct Roulette * p ;
t = sprite - > data [ 7 ] - 2 ;
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 02:39:41 +01:00
for ( i = 0 ; i < 3 ; i + + )
{
2020-07-29 10:46:58 +02:00
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 ) ;
2019-01-01 02:39:41 +01:00
}
2020-07-29 10:46:58 +02:00
gSprites [ sRoulette - > spriteIds [ SPR_CLEAR_MON_SHADOW_1 ] ] . coordOffsetEnabled = TRUE ;
sRoulette - > var38 = sprite ;
2019-01-01 02:39:41 +01:00
}
2019-01-01 22:25:52 +01:00
2020-07-29 10:46:58 +02:00
static void CreateTaillowSprite ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
u8 i = 0 ;
s16 t ;
2019-01-02 23:40:40 +01:00
s16 s [ 2 ] [ 2 ] = {
{ 256 , 84 } ,
{ - 16 , 84 }
} ;
2019-01-01 22:25:52 +01:00
t = sprite - > data [ 7 ] - 2 ;
2020-07-29 10:46:58 +02:00
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 ) ;
2019-01-01 22:25:52 +01:00
for ( ; i < 2 ; i + + )
{
2020-07-29 10:46:58 +02:00
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 ;
2019-01-01 22:25:52 +01:00
}
2020-07-29 10:46:58 +02:00
sRoulette - > var38 = sprite ;
2019-01-01 22:25:52 +01:00
}
2019-01-02 23:55:50 +01:00
static void sub_8144A24 ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
u8 z ;
u16 o ;
2019-04-11 12:05:56 +02:00
u8 h = 0 ;
u8 j = 5 ;
u8 p = 0 ;
u8 i = 0 ;
u8 val ;
u8 s [ 10 ] = { } ;
u16 rand = Random ( ) ;
2019-01-01 22:25:52 +01:00
2020-07-29 10:46:58 +02:00
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 ;
2019-04-11 12:05:56 +02:00
2020-07-29 10:46:58 +02:00
o = ( sRoulette - > tableId * 30 + 33 ) + ( 1 - sRoulette - > useTaillow ) * 15 ;
2019-01-01 22:25:52 +01:00
for ( i = 0 ; i < 4 ; i + + )
{
if ( o < sprite - > data [ 3 ] & & sprite - > data [ 3 ] < = o + 90 )
{
sprite - > data [ 0 ] = i / 2 ;
2020-07-29 10:46:58 +02:00
sRoulette - > useTaillow = i % 2 ;
2019-01-01 22:25:52 +01:00
break ;
}
if ( i = = 3 )
{
sprite - > data [ 0 ] = 1 ;
2020-07-29 10:46:58 +02:00
sRoulette - > useTaillow = TRUE ;
2019-01-01 22:25:52 +01:00
break ;
}
o + = 90 ;
}
2019-04-11 12:05:56 +02:00
2020-07-29 10:46:58 +02:00
if ( sRoulette - > useTaillow )
2019-01-01 22:25:52 +01:00
{
if ( sprite - > data [ 0 ] )
PlayCry1 ( SPECIES_TAILLOW , - 63 ) ;
else
PlayCry1 ( SPECIES_TAILLOW , 63 ) ;
}
else
{
PlayCry1 ( SPECIES_SHROOMISH , - 63 ) ;
}
2019-04-11 12:05:56 +02:00
val = 2 ;
2020-07-29 10:46:58 +02:00
z = ( sRoulette - > var7F + 2 ) % 12 ;
2019-04-11 12:05:56 +02:00
2020-07-29 10:46:58 +02:00
if ( sRoulette - > useTaillow = = TRUE & & sRoulette - > tableId = = 1 )
2019-01-01 22:25:52 +01:00
j + = 6 ;
else
2019-04-11 12:05:56 +02:00
j + = val ;
for ( i = val ; i < j ; i + + )
2019-01-01 22:25:52 +01:00
{
2020-07-29 10:46:58 +02:00
if ( ! ( sRoulette - > hitFlags & sRouletteSlots [ z ] . flag ) )
2019-01-01 22:25:52 +01:00
{
s [ h + + ] = i ;
2020-07-29 10:46:58 +02:00
if ( p = = 0 & & ( sRouletteSlots [ z ] . flag & sGridSelections [ sRoulette - > betSelection [ sRoulette - > curBallNum ] ] . inSelectionFlags ) )
2019-01-01 22:25:52 +01:00
p = i ;
}
2020-07-29 10:46:58 +02:00
z = ( z + 1 ) % 12 ;
2019-01-01 22:25:52 +01:00
}
2019-04-11 12:05:56 +02:00
2020-07-29 10:46:58 +02:00
if ( ( sRoulette - > useTaillow + 1 ) & sRoulette - > partySpeciesFlags )
2019-01-01 22:25:52 +01:00
{
2019-04-11 12:05:56 +02:00
if ( p & & ( rand & 0xFF ) < 0xc0 )
2019-01-01 22:25:52 +01:00
sprite - > data [ 7 ] = p ;
else
2019-04-11 12:05:56 +02:00
sprite - > data [ 7 ] = s [ rand % h ] ;
2019-01-01 22:25:52 +01:00
}
else
{
2019-04-11 12:05:56 +02:00
sprite - > data [ 7 ] = s [ rand % h ] ;
2019-01-01 22:25:52 +01:00
}
2019-04-11 12:05:56 +02:00
2020-07-29 10:46:58 +02:00
sprite - > callback = CreateClearSpeciesSprite ;
2019-01-01 22:25:52 +01:00
}
2019-01-02 23:55:50 +01:00
static const u16 gUnknown_085B7B1A [ ] = {
2019-01-02 23:40:40 +01:00
0x907 ,
0x808 ,
0x709 ,
0x60A ,
0x50B ,
0x40C ,
0x30D ,
0x20E ,
0x10F ,
0x010 ,
} ;
2019-01-02 23:55:50 +01:00
static void sub_8144C70 ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
if ( sprite - > data [ 1 ] + + > = sprite - > data [ 3 ] )
{
sprite - > pos1 . x - = 2 ;
if ( sprite - > pos1 . x < - 16 )
{
2020-07-29 10:46:58 +02:00
if ( ! sRoulette - > var03_6 )
sRoulette - > var03_6 = TRUE ;
2019-01-01 22:25:52 +01:00
DestroySprite ( sprite ) ;
2020-07-29 10:46:58 +02:00
sRoulette - > var01 = 0 ;
sRoulette - > var34 = gUnknown_085B7B1A [ 0 ] ;
2019-01-01 22:25:52 +01:00
}
}
}
2019-01-02 23:55:50 +01:00
static void sub_8144CD0 ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
int p ;
2019-01-02 23:40:40 +01:00
u16 t [ ] [ 4 ] = {
{ - 1 , 0 , 1 , 0 } ,
{ - 2 , 0 , 2 , 0 } ,
{ - 3 , 0 , 3 , 0 } ,
} ;
2019-01-01 22:25:52 +01:00
if ( sprite - > data [ 1 ] + + < sprite - > data [ 3 ] )
{
if ( sprite - > data [ 1 ] & 1 )
{
gSpriteCoordOffsetY = t [ sprite - > data [ 2 ] / 2 ] [ sprite - > data [ 7 ] ] ;
p = sprite - > data [ 7 ] + 1 ;
sprite - > data [ 7 ] = p - ( ( p / 4 ) * 4 ) ;
}
sprite - > invisible ^ = 1 ;
}
else
{
gSpriteCoordOffsetY = 0 ;
2020-07-29 10:46:58 +02:00
gSprites [ sRoulette - > spriteIds [ SPR_CLEAR_MON ] ] . animPaused = FALSE ;
2019-01-01 22:25:52 +01:00
DestroySprite ( sprite ) ;
}
}
2019-01-02 23:55:50 +01:00
static void sub_8144D94 ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
float t ;
sprite - > data [ 1 ] + + ;
t = sprite - > data [ 1 ] ;
sprite - > pos2 . y = t * 0.039f * t ;
2020-07-29 10:46:58 +02:00
sRoulette - > var34 = gUnknown_085B7B1A [ ( sRoulette - > var01 - 1 ) / 2 ] ;
if ( sRoulette - > var01 < 19 )
sRoulette - > var01 + + ;
2019-01-01 22:25:52 +01:00
if ( sprite - > data [ 1 ] > 60 )
{
sprite - > data [ 1 ] = 0 ;
sprite - > callback = sub_8144C70 ;
gSprites [ sprite - > data [ 6 ] ] . callback = sub_8144C70 ;
gSprites [ sprite - > data [ 6 ] ] . data [ 1 ] = - 2 ;
gSprites [ sprite - > data [ 5 ] ] . invisible = FALSE ;
gSprites [ sprite - > data [ 5 ] ] . callback = sub_8144CD0 ;
m4aSongNumStart ( SE_W070 ) ;
}
}
2019-01-02 23:55:50 +01:00
static void sub_8144E60 ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
if ( sprite - > data [ 7 ] = = 0 )
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var38 - > data [ 0 ] = = 0 )
2019-01-01 22:25:52 +01:00
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var38 - > data [ 3 ] ! = gUnknown_085B6348 [ sRoulette - > tableId ] . var08 )
2019-01-01 22:25:52 +01:00
return ;
}
else
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var38 - > data [ 3 ] ! = gUnknown_085B6348 [ sRoulette - > tableId ] . var08 + 180 )
2019-01-01 22:25:52 +01:00
return ;
}
sprite - > invisible = FALSE ;
sprite - > data [ 7 ] + + ;
m4aSongNumStart ( SE_RU_HYUU ) ;
2020-07-29 10:46:58 +02:00
sRoulette - > var01 = 1 ;
sRoulette - > var34 = gUnknown_085B7B1A [ 0 ] ;
2019-01-01 22:25:52 +01:00
}
else
{
2020-07-29 10:46:58 +02:00
sRoulette - > var34 = gUnknown_085B7B1A [ ( sRoulette - > var01 - 1 ) / 2 ] ;
if ( sRoulette - > var01 < 19 )
sRoulette - > var01 + + ;
2019-01-01 22:25:52 +01:00
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var38 - > data [ 0 ] = = 0 )
2019-01-01 22:25:52 +01:00
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var38 - > data [ 3 ] ! = gUnknown_085B6348 [ sRoulette - > tableId ] . var0A )
2019-01-01 22:25:52 +01:00
return ;
}
else
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var38 - > data [ 3 ] ! = gUnknown_085B6348 [ sRoulette - > tableId ] . var0A + 180 )
2019-01-01 22:25:52 +01:00
return ;
}
gSprites [ sprite - > data [ 4 ] ] . callback = sub_8144D94 ;
gSprites [ sprite - > data [ 4 ] ] . invisible = FALSE ;
sprite - > callback = & SpriteCallbackDummy ;
sprite - > data [ 7 ] = 0 ;
}
}
2019-01-02 23:55:50 +01:00
static void sub_8144F94 ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
sprite - > invisible ^ = 1 ;
}
2019-01-02 23:55:50 +01:00
static void sub_8144FB0 ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
if ( sprite - > pos1 . y > - 16 )
{
sprite - > pos1 . y - - ;
}
else
{
sprite - > callback = SpriteCallbackDummy ;
sprite - > invisible = TRUE ;
sprite - > animPaused = TRUE ;
m4aSongNumStop ( SE_BASABASA ) ;
DestroySprite ( sprite ) ;
2020-07-29 10:46:58 +02:00
FreeOamMatrix ( gSprites [ sRoulette - > spriteIds [ SPR_CLEAR_MON_SHADOW_1 ] ] . oam . matrixNum ) ;
DestroySprite ( & gSprites [ sRoulette - > spriteIds [ SPR_CLEAR_MON_SHADOW_1 ] ] ) ;
2019-01-01 22:25:52 +01:00
}
}
2019-01-02 23:55:50 +01:00
static void sub_8145030 ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
if ( sprite - > data [ 1 ] > = 0 )
{
sprite - > data [ 1 ] - - ;
sprite - > pos1 . y - - ;
if ( sprite - > data [ 1 ] = = 0 & & sprite - > animCmdIndex = = 1 )
sprite - > pos2 . y + + ;
}
else
{
if ( sprite - > data [ 3 ] > = 0 )
{
sprite - > data [ 3 ] - - ;
if ( sprite - > animDelayCounter = = 0 )
{
if ( sprite - > animCmdIndex = = 1 )
sprite - > pos2 . y + + ;
else
sprite - > pos2 . y - - ;
}
}
else
{
m4aSongNumStart ( SE_RU_HYUU ) ;
2020-07-29 10:46:58 +02:00
StartSpriteAnim ( sprite , sRoulette - > var38 - > data [ 0 ] + 4 ) ;
2019-01-01 22:25:52 +01:00
sprite - > callback = sub_8144FB0 ;
gSprites [ sprite - > data [ 6 ] ] . affineAnimPaused = FALSE ;
}
}
}
2019-01-02 23:55:50 +01:00
static void sub_81450D8 ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
2019-01-02 23:40:40 +01:00
s8 t [ 2 ] = { - 1 , 1 } ;
s8 z [ ] [ 2 ] = {
{ 2 , 0 } ,
{ 2 , 0 } ,
{ 2 , - 1 } ,
{ 2 , - 1 } ,
{ 2 , - 1 } ,
{ 2 , - 1 } ,
{ 2 , - 2 } ,
{ 2 , - 2 } ,
} ;
2019-01-01 22:25:52 +01:00
if ( sprite - > data [ 1 ] - - > 7 )
{
2020-07-29 10:46:58 +02:00
sprite - > pos1 . x + = t [ sRoulette - > var38 - > data [ 0 ] ] * 2 ;
2019-01-01 22:25:52 +01:00
if ( IsSEPlaying ( ) )
{
s8 pan = - ( ( 116 - sprite - > pos1 . x ) / 2 ) ;
m4aMPlayPanpotControl ( & gMPlayInfo_SE1 , 0xFFFF , pan ) ;
m4aMPlayPanpotControl ( & gMPlayInfo_SE2 , 0xFFFF , pan ) ;
}
}
else
{
if ( sprite - > data [ 1 ] > = 0 )
{
2020-07-29 10:46:58 +02:00
sprite - > pos1 . x + = t [ sRoulette - > var38 - > data [ 0 ] ] * z [ 7 - sprite - > data [ 1 ] ] [ 0 ] ;
2019-01-01 22:25:52 +01:00
sprite - > pos1 . y + = z [ 7 - sprite - > data [ 1 ] ] [ 1 ] ;
}
else
{
m4aSongNumStartOrChange ( SE_BASABASA ) ;
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var38 - > data [ 0 ] = = 0 )
2019-01-01 22:25:52 +01:00
PlayCry1 ( SPECIES_TAILLOW , 63 ) ;
else
PlayCry1 ( SPECIES_TAILLOW , - 63 ) ;
2020-07-29 10:46:58 +02:00
StartSpriteAnim ( sprite , sRoulette - > var38 - > data [ 0 ] + 2 ) ;
2019-01-01 22:25:52 +01:00
sprite - > data [ 1 ] = 45 ;
sprite - > callback = sub_8145030 ;
}
}
}
2019-01-02 23:55:50 +01:00
static void sub_8145218 ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
2019-01-02 23:40:40 +01:00
s8 t [ 2 ] = { - 1 , 1 } ;
2019-04-11 12:05:56 +02:00
2019-01-01 22:25:52 +01:00
if ( sprite - > data [ 1 ] - - > = 0 )
{
2020-07-29 10:46:58 +02:00
sprite - > pos1 . x + = t [ sRoulette - > var38 - > data [ 0 ] ] * 2 ;
2019-01-01 22:25:52 +01:00
gSprites [ sprite - > data [ 6 ] ] . invisible ^ = 1 ;
}
else
{
sprite - > callback = sub_8144F94 ;
}
}
2020-07-29 10:46:58 +02:00
static void SpriteCB_Taillow ( struct Sprite * sprite )
2019-01-01 22:25:52 +01:00
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var38 - > data [ 0 ] = = 0 )
2019-01-01 22:25:52 +01:00
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var38 - > data [ 3 ] = = gUnknown_085B6348 [ sRoulette - > tableId ] . var12 + 90 )
2019-01-01 22:25:52 +01:00
{
gSprites [ sprite - > data [ 6 ] ] . data [ 1 ] = 52 ;
gSprites [ sprite - > data [ 4 ] ] . data [ 1 ] = 52 ;
}
else
{
return ;
}
}
else
{
2020-07-29 10:46:58 +02:00
if ( sRoulette - > var38 - > data [ 3 ] = = gUnknown_085B6348 [ sRoulette - > tableId ] . var14 + 270 )
2019-01-01 22:25:52 +01:00
{
gSprites [ sprite - > data [ 6 ] ] . data [ 1 ] = 46 ;
gSprites [ sprite - > data [ 4 ] ] . data [ 1 ] = 46 ;
}
else
{
return ;
}
}
gSprites [ sprite - > data [ 6 ] ] . callback = sub_8145218 ;
gSprites [ sprite - > data [ 4 ] ] . callback = sub_81450D8 ;
m4aSongNumStart ( SE_RU_HYUU ) ;
}