Merge pull request #1121 from GriffinRichards/doc-roulette

Document roulette
This commit is contained in:
GriffinR 2020-08-10 17:18:09 -04:00 committed by GitHub
commit 8b95e1964b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 2786 additions and 2676 deletions

View File

@ -40,6 +40,7 @@
#include "constants/moves.h"
#include "constants/party_menu.h"
#include "constants/pokemon.h"
#include "constants/roulette.h"
#include "constants/script_menu.h"
#include "constants/secret_bases.h"
#include "constants/songs.h"

View File

@ -6,7 +6,7 @@ Roulette_EventScript_Table1:: @ 82A5AB1
getpricereduction POKENEWS_GAME_CORNER
compare VAR_RESULT, FALSE
goto_if_eq Roulette_EventScript_Play
addvar VAR_0x8004, 128
addvar VAR_0x8004, ROULETTE_SPECIAL_RATE
goto Roulette_EventScript_Play
end
@ -18,7 +18,7 @@ Roulette_EventScript_Table2:: @ 82A5ADF
getpricereduction POKENEWS_GAME_CORNER
compare VAR_RESULT, FALSE
goto_if_eq Roulette_EventScript_Play
addvar VAR_0x8004, 128
addvar VAR_0x8004, ROULETTE_SPECIAL_RATE
goto Roulette_EventScript_Play
end

View File

@ -1,259 +0,0 @@
JASC-PAL
0100
256
82 156 49
41 41 41
98 98 115
172 180 197
255 255 255
255 205 41
255 172 0
213 164 65
205 164 82
139 106 65
131 222 189
74 189 156
115 189 148
123 180 172
74 115 115
255 255 0
74 106 156
41 41 41
98 98 115
156 156 164
255 255 255
205 156 205
164 106 164
172 131 164
156 123 156
90 57 106
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
74 106 156
41 41 41
123 123 131
172 180 197
255 255 255
238 238 156
189 180 106
131 90 32
255 131 90
189 106 98
230 222 255
74 189 156
255 255 255
123 180 172
255 255 255
255 255 255
74 106 156
57 57 65
98 98 115
156 156 164
255 255 255
106 205 205
246 98 90
106 156 255
255 255 255
156 255 106
246 230 74
255 230 123
255 255 255
255 255 156
156 255 148
205 156 255
74 106 156
41 41 41
98 98 115
205 205 213
255 255 255
123 238 139
255 172 139
16 156 74
197 164 255
49 106 32
115 197 131
197 139 189
255 82 57
255 238 82
205 180 8
255 205 8
74 106 156
106 139 230
82 115 205
255 255 255
255 255 255
255 205 41
255 172 0
213 164 65
205 164 82
139 106 65
131 222 189
74 189 156
115 189 148
123 180 172
74 115 115
255 255 255
74 106 156
255 246 65
255 255 164
255 246 65
255 255 255
205 156 205
164 106 164
172 131 164
156 123 156
90 57 106
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
65 65 57
74 106 156
172 255 238
222 255 255
148 255 238
255 255 255
255 205 41
255 172 0
213 164 65
205 164 82
139 106 65
131 222 189
74 189 156
115 189 148
123 180 172
74 115 115
65 65 57
74 106 156
255 205 255
255 222 255
255 197 255
255 255 255
205 156 205
164 106 164
172 131 164
156 123 156
90 57 106
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
65 65 57
74 106 156
255 255 255
255 255 255
255 255 255
255 255 255
255 205 41
255 172 0
213 164 65
205 164 82
139 106 65
131 222 189
74 189 156
115 189 148
123 180 172
74 115 115
255 255 255
74 106 156
255 255 255
255 255 255
255 255 255
255 255 255
205 156 205
164 106 164
172 131 164
156 123 156
90 57 106
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
74 106 156
255 246 82
164 255 222
172 180 197
255 255 255
255 246 65
246 205 24
238 197 98
205 172 90
164 131 90
156 246 222
90 213 180
131 222 172
115 189 156
98 148 148
65 65 57
74 106 156
238 189 238
156 148 148
172 180 197
255 255 255
255 205 255
222 156 230
197 156 197
172 139 172
139 106 148
205 205 230
255 255 255
255 255 255
255 255 255
255 255 255
65 65 57
74 106 156
238 230 246
205 205 230
172 180 197
255 255 255
255 255 230
255 255 164
255 255 255
222 255 255
255 246 255
255 222 255
255 255 255
255 255 255
255 255 255
255 255 255
65 65 57
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255
255 255 255

View File

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 409 B

View File

@ -483,7 +483,7 @@ $(ROULETTEGFXDIR)/roulette_tilt.4bpp: $(ROULETTEGFXDIR)/shroomish.4bpp \
$(ROULETTEGFXDIR)/tailow.4bpp
@cat $^ >$@
$(ROULETTEGFXDIR)/poke_icons2.4bpp: $(ROULETTEGFXDIR)/wynaut.4bpp \
$(ROULETTEGFXDIR)/wheel_icons.4bpp: $(ROULETTEGFXDIR)/wynaut.4bpp \
$(ROULETTEGFXDIR)/azurill.4bpp \
$(ROULETTEGFXDIR)/skitty.4bpp \
$(ROULETTEGFXDIR)/makuhita.4bpp

View File

@ -2,5 +2,6 @@
#define GUARD_CONSTANTS_COINS_H
#define MAX_COINS 9999
#define MAX_COIN_DIGITS 4
#endif // GUARD_CONSTANTS_COINS_H

View File

@ -0,0 +1,7 @@
#ifndef GUARD_CONSTANTS_ROULETTE_H
#define GUARD_CONSTANTS_ROULETTE_H
// Flag set in gSpecialVar_0x8004 when playing Roulette on a Game Corner service day
#define ROULETTE_SPECIAL_RATE (1 << 7)
#endif // GUARD_CONSTANTS_ROULETTE_H

View File

@ -4918,13 +4918,13 @@ extern const u32 gPartyMenuPokeball_Pal[];
extern const u32 gStatusPal_Icons[];
// Roulette
extern const u32 gRouletteMenuTiles[];
extern const u32 gRouletteWheelTiles[];
extern const u32 gRouletteMenu_Gfx[];
extern const u32 gRouletteWheel_Gfx[];
extern const u32 gRouletteCenter_Gfx[];
extern const u32 gRouletteHeadersTiles[];
extern const u32 gRouletteCreditTiles[];
extern const u32 gRouletteNumbersTiles[];
extern const u32 gRouletteMultiplierTiles[];
extern const u32 gRouletteHeaders_Gfx[];
extern const u32 gRouletteCredit_Gfx[];
extern const u32 gRouletteNumbers_Gfx[];
extern const u32 gRouletteMultiplier_Gfx[];
// Contest util
extern const u32 gContestResults_Gfx[];

83
include/palette_util.h Normal file
View File

@ -0,0 +1,83 @@
#ifndef GUARD_PALETTE_UTIL_H
#define GUARD_PALETTE_UTIL_H
struct PulseBlendSettings
{
u16 blendColor;
u16 paletteOffset;
u8 numColors;
u8 delay;
u8 numFadeCycles;
s8 maxBlendCoeff:4;
s8 fadeType:2;
s8 restorePaletteOnUnload:1;
s8 unk7_7:1;
};
struct PulseBlendPalette
{
u8 paletteSelector;
u8 blendCoeff:4;
u8 fadeDirection:1;
s8 unk1_5:1;
s8 available:1;
u32 inUse:1;
u8 delayCounter;
u8 fadeCycleCounter;
struct PulseBlendSettings pulseBlendSettings;
};
struct PulseBlend
{
u16 usedPulseBlendPalettes;
struct PulseBlendPalette pulseBlendPalettes[16];
};
#define FLASHUTIL_USE_EXISTING_COLOR (1 << 15)
struct RouletteFlashSettings
{
u16 color;
u16 paletteOffset;
u8 numColors;
u8 delay;
s8 unk6; // Set but never used
s8 numFadeCycles:5;
s8 unk7_5:2; // Set but never used
s8 colorDeltaDir:1;
};
struct RouletteFlashPalette
{
u8 state:7;
bool8 available:1;
u8 delayCounter;
s8 fadeCycleCounter;
s8 colorDelta;
struct RouletteFlashSettings settings;
};
struct RouletteFlashUtil
{
u8 enabled;
u8 unused;
u16 flags;
struct RouletteFlashPalette palettes[16];
};
int InitPulseBlendPaletteSettings(struct PulseBlend *, const struct PulseBlendSettings *);
void InitPulseBlend(struct PulseBlend *);
void MarkUsedPulseBlendPalettes(struct PulseBlend *, u16, u8);
void UnloadUsedPulseBlendPalettes(struct PulseBlend *, u16, u8);
void UnmarkUsedPulseBlendPalettes(struct PulseBlend *, u16, u8);
void UpdatePulseBlend(struct PulseBlend *);
void ClearTilemapRect(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height);
void SetTilemapRect(u16 *dest, u16 *src, u8 left, u8 top, u8 width, u8 height);
void RouletteFlash_Run(struct RouletteFlashUtil *r0);
void RouletteFlash_Reset(struct RouletteFlashUtil *r0);
u8 RouletteFlash_Add(struct RouletteFlashUtil *r0, u8 r1, const struct RouletteFlashSettings *r2);
void RouletteFlash_Stop(struct RouletteFlashUtil *r0, u16 r1);
void RouletteFlash_Enable(struct RouletteFlashUtil *r0, u16 r1);
#endif // GUARD_PALETTE_UTIL_H

View File

@ -1,34 +1,6 @@
#ifndef GUARD_ROULETTE_H
#define GUARD_ROULETTE_H
struct UnkStruct1
{
u16 var00;
u16 var02;
u8 var04;
u8 var05;
u8 var06;
s8 var07_0:5;
s8 var07_5:2;
s8 var07_7:1;
};
struct UnkStruct3
{
u8 var00_0:7;
u8 var00_7:1;
u8 var01;
s8 var02;
s8 var03;
struct UnkStruct1 var04;
};
struct UnkStruct0
{
u8 var00;
u8 var01;
u16 var02; //flag for each UnkStruct3
struct UnkStruct3 var04[0x10];
};
void PlayRoulette(void);
#endif // GUARD_ROULETTE_H

View File

@ -1,52 +0,0 @@
#ifndef GUARD_ROULETTE_UTIL_H
#define GUARD_ROULETTE_UTIL_H
#include "roulette.h"
struct PulseBlendSettings
{
u16 blendColor;
u16 paletteOffset;
u8 numColors;
u8 delay;
u8 numFadeCycles;
s8 maxBlendCoeff:4;
s8 fadeType:2;
s8 restorePaletteOnUnload:1;
s8 unk7_7:1;
};
struct PulseBlendPalette
{
u8 paletteSelector;
u8 blendCoeff:4;
u8 fadeDirection:1;
s8 unk1_5:1;
s8 available:1;
u32 inUse:1;
u8 delayCounter;
u8 fadeCycleCounter;
struct PulseBlendSettings pulseBlendSettings;
};
struct PulseBlend
{
u16 usedPulseBlendPalettes;
struct PulseBlendPalette pulseBlendPalettes[16];
};
int InitPulseBlendPaletteSettings(struct PulseBlend *, const struct PulseBlendSettings *);
void InitPulseBlend(struct PulseBlend *);
void MarkUsedPulseBlendPalettes(struct PulseBlend *, u16, u8);
void UnloadUsedPulseBlendPalettes(struct PulseBlend *, u16, u8);
void UnmarkUsedPulseBlendPalettes(struct PulseBlend *, u16, u8);
void UpdatePulseBlend(struct PulseBlend *);
void sub_8152008(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height);
void sub_8152058(u16 *dest, u16 *src, u8 left, u8 top, u8 width, u8 height);
void task_tutorial_controls_fadein(struct UnkStruct0 *r0);
void sub_8151678(struct UnkStruct0 *r0);
u8 sub_815168C(struct UnkStruct0 *r0, u8 r1, const struct UnkStruct1 *r2);
void sub_8151A9C(struct UnkStruct0 *r0, u16 r1);
void sub_8151A48(struct UnkStruct0 *r0, u16 r1);
#endif // GUARD_ROULETTE_UTIL_H

View File

@ -84,6 +84,19 @@ extern const u8 gText_SoSo[];
extern const u8 gText_Bad[];
extern const u8 gText_TheWorst[];
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[];
extern const u8 gText_Slots[];
extern const u8 gText_Roulette[];
extern const u8 gText_Jackpot[];

View File

@ -237,7 +237,7 @@ SECTIONS {
src/battle_message.o(.text);
src/cable_car.o(.text);
src/math_util.o(.text);
src/roulette_util.o(.text);
src/palette_util.o(.text);
src/confetti_util.o(.text);
src/save.o(.text);
src/mystery_event_script.o(.text);

View File

@ -14,7 +14,7 @@ void PrintCoinsString(u32 coinAmount)
{
u32 xAlign;
ConvertIntToDecimalStringN(gStringVar1, coinAmount, STR_CONV_MODE_RIGHT_ALIGN, 4);
ConvertIntToDecimalStringN(gStringVar1, coinAmount, STR_CONV_MODE_RIGHT_ALIGN, MAX_COIN_DIGITS);
StringExpandPlaceholders(gStringVar4, gText_Coins);
xAlign = GetStringRightAlignXOffset(1, gStringVar4, 0x40);

View File

@ -1227,13 +1227,14 @@ const u32 gCableCar_Gfx[] = INCBIN_U32("graphics/misc/cable_car.4bpp.lz");
const u32 gCableCarDoor_Gfx[] = INCBIN_U32("graphics/misc/cable_car_door.4bpp.lz");
const u32 gCableCarCord_Gfx[] = INCBIN_U32("graphics/misc/cable_car_cord.4bpp.lz");
const u32 gRouletteMenuTiles[] = INCBIN_U32("graphics/roulette/window.4bpp.lz");
const u32 gRouletteWheelTiles[] = INCBIN_U32("graphics/roulette/wheel.8bpp.lz");
// Roulette
const u32 gRouletteMenu_Gfx[] = INCBIN_U32("graphics/roulette/window.4bpp.lz");
const u32 gRouletteWheel_Gfx[] = INCBIN_U32("graphics/roulette/wheel.8bpp.lz");
const u32 gRouletteCenter_Gfx[] = INCBIN_U32("graphics/roulette/center.4bpp.lz");
const u32 gRouletteHeadersTiles[] = INCBIN_U32("graphics/roulette/headers.4bpp.lz");
const u32 gRouletteCreditTiles[] = INCBIN_U32("graphics/roulette/credit.4bpp.lz");
const u32 gRouletteNumbersTiles[] = INCBIN_U32("graphics/roulette/numbers.4bpp.lz");
const u32 gRouletteMultiplierTiles[] = INCBIN_U32("graphics/roulette/multiplier.4bpp.lz");
const u32 gRouletteHeaders_Gfx[] = INCBIN_U32("graphics/roulette/headers.4bpp.lz");
const u32 gRouletteCredit_Gfx[] = INCBIN_U32("graphics/roulette/credit.4bpp.lz");
const u32 gRouletteNumbers_Gfx[] = INCBIN_U32("graphics/roulette/numbers.4bpp.lz");
const u32 gRouletteMultiplier_Gfx[] = INCBIN_U32("graphics/roulette/multiplier.4bpp.lz");
#include "data/graphics/mail.h"

View File

@ -8,7 +8,7 @@
#include "gpu_regs.h"
#include "menu.h"
#include "random.h"
#include "roulette_util.h"
#include "palette_util.h"
#include "script.h"
#include "sound.h"
#include "sprite.h"

View File

@ -1,208 +1,217 @@
#include "global.h"
#include "palette.h"
#include "roulette.h"
#include "roulette_util.h"
#include "palette_util.h"
#include "util.h"
void sub_8151678(struct UnkStruct0 *r0)
// "RouletteFlash" is more accurately a general flashing/fading util
// this file handles fading the palettes for the color/icon selections on the Roulette wheel
// but it also handles the "pulse blend" effect of Mirage Tower
void RouletteFlash_Reset(struct RouletteFlashUtil *flash)
{
r0->var00 = 0;
r0->var02 = 0;
memset(&r0->var04, 0, sizeof(r0->var04));
flash->enabled = 0;
flash->flags = 0;
memset(&flash->palettes, 0, sizeof(flash->palettes));
}
u8 sub_815168C(struct UnkStruct0 *r0, u8 r1, const struct UnkStruct1 *r2)
u8 RouletteFlash_Add(struct RouletteFlashUtil *flash, u8 id, const struct RouletteFlashSettings *settings)
{
if (!(r1 < 16) || (r0->var04[r1].var00_7))
if (id >= ARRAY_COUNT(flash->palettes) || flash->palettes[id].available)
return 0xFF;
r0->var04[r1].var04.var00 = r2->var00;
r0->var04[r1].var04.var02 = r2->var02;
r0->var04[r1].var04.var04 = r2->var04;
r0->var04[r1].var04.var05 = r2->var05;
r0->var04[r1].var04.var06 = r2->var06;
r0->var04[r1].var04.var07_0 = r2->var07_0;
r0->var04[r1].var04.var07_5 = r2->var07_5;
r0->var04[r1].var04.var07_7 = r2->var07_7;
r0->var04[r1].var00_0 = 0;
r0->var04[r1].var00_7 = 1;
r0->var04[r1].var02 = 0;
r0->var04[r1].var01 = 0;
if (r0->var04[r1].var04.var07_7 < 0)
r0->var04[r1].var03 = 0xFF;
flash->palettes[id].settings.color = settings->color;
flash->palettes[id].settings.paletteOffset = settings->paletteOffset;
flash->palettes[id].settings.numColors = settings->numColors;
flash->palettes[id].settings.delay = settings->delay;
flash->palettes[id].settings.unk6 = settings->unk6;
flash->palettes[id].settings.numFadeCycles = settings->numFadeCycles;
flash->palettes[id].settings.unk7_5 = settings->unk7_5;
flash->palettes[id].settings.colorDeltaDir = settings->colorDeltaDir;
flash->palettes[id].state = 0;
flash->palettes[id].available = TRUE;
flash->palettes[id].fadeCycleCounter = 0;
flash->palettes[id].delayCounter = 0;
if (flash->palettes[id].settings.colorDeltaDir < 0)
flash->palettes[id].colorDelta = -1;
else
r0->var04[r1].var03 = 1;
flash->palettes[id].colorDelta = 1;
return r1;
return id;
}
u8 sub_8151710(struct UnkStruct0 *r0, u8 r1)
// Unused
static u8 RouletteFlash_Remove(struct RouletteFlashUtil *flash, u8 id)
{
if (r1 >= 16)
if (id >= ARRAY_COUNT(flash->palettes))
return 0xFF;
if (!r0->var04[r1].var00_7)
if (!flash->palettes[id].available)
return 0xFF;
memset(&r0->var04[r1], 0, sizeof(r0->var04[r1]));
return r1;
memset(&flash->palettes[id], 0, sizeof(flash->palettes[id]));
return id;
}
u8 sub_8151744(struct UnkStruct3 *r0)
static u8 RouletteFlash_FadePalette(struct RouletteFlashPalette *pal)
{
u8 i;
u8 returnval;
for (i = 0; i < r0->var04.var04; i++)
for (i = 0; i < pal->settings.numColors; i++)
{
struct PlttData *faded = (struct PlttData *)&gPlttBufferFaded[r0->var04.var02 + i];
struct PlttData *unfaded = (struct PlttData *)&gPlttBufferUnfaded[r0->var04.var02 + i];
struct PlttData *faded = (struct PlttData *)&gPlttBufferFaded[pal->settings.paletteOffset + i];
struct PlttData *unfaded = (struct PlttData *)&gPlttBufferUnfaded[pal->settings.paletteOffset + i];
switch (r0->var00_0)
switch (pal->state)
{
case 1:
if (faded->r + r0->var03 >= 0 && faded->r + r0->var03 < 32)
faded->r += r0->var03;
if (faded->g + r0->var03 >= 0 && faded->g + r0->var03 < 32)
faded->g += r0->var03;
if (faded->b + r0->var03 >= 0 && faded->b + r0->var03 < 32)
faded->b += r0->var03;
// Fade color
if (faded->r + pal->colorDelta >= 0 && faded->r + pal->colorDelta < 32)
faded->r += pal->colorDelta;
if (faded->g + pal->colorDelta >= 0 && faded->g + pal->colorDelta < 32)
faded->g += pal->colorDelta;
if (faded->b + pal->colorDelta >= 0 && faded->b + pal->colorDelta < 32)
faded->b += pal->colorDelta;
break;
case 2:
if (r0->var03 < 0)
// Fade back to original color
if (pal->colorDelta < 0)
{
if (faded->r + r0->var03 >= unfaded->r)
faded->r += r0->var03;
if (faded->g + r0->var03 >= unfaded->g)
faded->g += r0->var03;
if (faded->b + r0->var03 >= unfaded->b)
faded->b += r0->var03;
if (faded->r + pal->colorDelta >= unfaded->r)
faded->r += pal->colorDelta;
if (faded->g + pal->colorDelta >= unfaded->g)
faded->g += pal->colorDelta;
if (faded->b + pal->colorDelta >= unfaded->b)
faded->b += pal->colorDelta;
}
else
{
if (faded->r + r0->var03 <= unfaded->r)
faded->r += r0->var03;
if (faded->g + r0->var03 <= unfaded->g)
faded->g += r0->var03;
if (faded->b + r0->var03 <= unfaded->b)
faded->b += r0->var03;
if (faded->r + pal->colorDelta <= unfaded->r)
faded->r += pal->colorDelta;
if (faded->g + pal->colorDelta <= unfaded->g)
faded->g += pal->colorDelta;
if (faded->b + pal->colorDelta <= unfaded->b)
faded->b += pal->colorDelta;
}
break;
}
}
if ((u32)r0->var02++ != r0->var04.var07_0)
if ((u32)pal->fadeCycleCounter++ != pal->settings.numFadeCycles)
{
returnval = 0;
}
else
{
r0->var02 = 0;
r0->var03 *= -1;
if (r0->var00_0 == 1)
r0->var00_0++;
pal->fadeCycleCounter = 0;
pal->colorDelta *= -1;
if (pal->state == 1)
pal->state++;
else
r0->var00_0--;
pal->state--;
returnval = 1;
}
return returnval;
}
u8 sub_815194C(struct UnkStruct3 *r0)
static u8 RouletteFlash_FlashPalette(struct RouletteFlashPalette *pal)
{
u8 rg2 = 0;
switch (r0->var00_0)
u8 i = 0;
switch (pal->state)
{
case 1:
for (rg2 = 0; rg2 < r0->var04.var04; rg2++)
gPlttBufferFaded[r0->var04.var02 + rg2] = r0->var04.var00;
r0->var00_0++;
// Flash to color
for (; i < pal->settings.numColors; i++)
gPlttBufferFaded[pal->settings.paletteOffset + i] = pal->settings.color;
pal->state++;
break;
case 2:
for (rg2 = 0; rg2 < r0->var04.var04; rg2++)
gPlttBufferFaded[r0->var04.var02 + rg2] = gPlttBufferUnfaded[r0->var04.var02 + rg2];
r0->var00_0--;
// Restore to original color
for (; i < pal->settings.numColors; i++)
gPlttBufferFaded[pal->settings.paletteOffset + i] = gPlttBufferUnfaded[pal->settings.paletteOffset + i];
pal->state--;
break;
}
return 1;
}
void task_tutorial_controls_fadein(struct UnkStruct0 *r0)
void RouletteFlash_Run(struct RouletteFlashUtil *flash)
{
u8 i = 0;
if (r0->var00)
if (flash->enabled)
{
for (i = 0; i < 16; i++)
for (i = 0; i < ARRAY_COUNT(flash->palettes); i++)
{
if ((r0->var02 >> i) & 1)
if ((flash->flags >> i) & 1)
{
if (--r0->var04[i].var01 == 0xFF) // if underflow ?
if (--flash->palettes[i].delayCounter == (u8)-1)
{
if (r0->var04[i].var04.var00 & 0x8000) // PlttData->unused_15 ?
sub_8151744(&r0->var04[i]);
if (flash->palettes[i].settings.color & FLASHUTIL_USE_EXISTING_COLOR)
RouletteFlash_FadePalette(&flash->palettes[i]);
else
sub_815194C(&r0->var04[i]);
RouletteFlash_FlashPalette(&flash->palettes[i]);
r0->var04[i].var01 = r0->var04[i].var04.var05;
flash->palettes[i].delayCounter = flash->palettes[i].settings.delay;
}
}
}
}
}
void sub_8151A48(struct UnkStruct0 *r0, u16 r1)
void RouletteFlash_Enable(struct RouletteFlashUtil *flash, u16 flags)
{
u8 i = 0;
r0->var00++;
for (i = 0; i < 16; i++)
flash->enabled++;
for (i = 0; i < ARRAY_COUNT(flash->palettes); i++)
{
if ((r1 >> i) & 1)
if ((flags >> i) & 1)
{
if (r0->var04[i].var00_7)
if (flash->palettes[i].available)
{
r0->var02 |= 1 << i;
r0->var04[i].var00_0 = 1;
flash->flags |= 1 << i;
flash->palettes[i].state = 1;
}
}
}
}
void sub_8151A9C(struct UnkStruct0 *r0, u16 r1)
void RouletteFlash_Stop(struct RouletteFlashUtil *flash, u16 flags)
{
u8 i;
for (i = 0; i < 16; i++)
for (i = 0; i < ARRAY_COUNT(flash->palettes); i++)
{
if ((r0->var02 >> i) & 1)
if ((flash->flags >> i) & 1)
{
if (r0->var04[i].var00_7)
if (flash->palettes[i].available)
{
if ((r1 >> i) & 1)
if ((flags >> i) & 1)
{
u32 offset = r0->var04[i].var04.var02;
u32 offset = flash->palettes[i].settings.paletteOffset;
u16 *faded = &gPlttBufferFaded[offset];
u16 *unfaded = &gPlttBufferUnfaded[offset];
memcpy(faded, unfaded, r0->var04[i].var04.var04 * 2);
r0->var04[i].var00_0 = 0;
r0->var04[i].var02 = 0;
r0->var04[i].var01 = 0;
if (r0->var04[i].var04.var07_7 < 0)
r0->var04[i].var03 = 0xFF;
memcpy(faded, unfaded, flash->palettes[i].settings.numColors * 2);
flash->palettes[i].state = 0;
flash->palettes[i].fadeCycleCounter = 0;
flash->palettes[i].delayCounter = 0;
if (flash->palettes[i].settings.colorDeltaDir < 0)
flash->palettes[i].colorDelta = -1;
else
r0->var04[i].var03 = 0x1;
flash->palettes[i].colorDelta = 1;
}
}
}
}
if (r1 == 0xFFFF)
if (flags == 0xFFFF)
{
r0->var00 = 0;
r0->var02 = 0;
// Stopped all
flash->enabled = 0;
flash->flags = 0;
}
else
{
r0->var02 = r0->var02 & ~r1;
flash->flags &= ~flags;
}
}
@ -429,7 +438,8 @@ void UpdatePulseBlend(struct PulseBlend *pulseBlend)
}
}
void sub_8152008(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height)
// Below used for the Roulette grid
void ClearTilemapRect(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height)
{
u16 *_dest;
u8 i;
@ -446,7 +456,7 @@ void sub_8152008(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height)
}
}
void sub_8152058(u16 *dest, u16 *src, u8 left, u8 top, u8 width, u8 height)
void SetTilemapRect(u16 *dest, u16 *src, u8 left, u8 top, u8 width, u8 height)
{
u16 *_dest;
u16 *_src = src;

File diff suppressed because it is too large Load Diff