forked from pret/pokeemerald
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathslot_machine.c
7950 lines (7315 loc) · 238 KB
/
slot_machine.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "global.h"
#include "overworld.h"
#include "field_effect.h"
#include "random.h"
#include "sound.h"
#include "main.h"
#include "slot_machine.h"
#include "string_util.h"
#include "decompress.h"
#include "trig.h"
#include "graphics.h"
#include "palette.h"
#include "util.h"
#include "text.h"
#include "menu.h"
#include "malloc.h"
#include "bg.h"
#include "gpu_regs.h"
#include "coins.h"
#include "strings.h"
#include "tv.h"
#include "text_window.h"
#include "main_menu.h"
#include "bg.h"
#include "window.h"
#include "constants/coins.h"
#include "constants/rgb.h"
#include "constants/slot_machine.h"
#include "constants/songs.h"
#define SLOTMACHINE_GFX_TILES 233
#define MAX_BET 3
#define SYMBOLS_PER_REEL 21
#define REEL_SYMBOL_HEIGHT 24
#define REEL_HEIGHT (SYMBOLS_PER_REEL * REEL_SYMBOL_HEIGHT)
#define REELTIME_SYMBOLS 6
#define REELTIME_SYMBOL_HEIGHT 20
#define REELTIME_REEL_HEIGHT (REELTIME_SYMBOLS * REELTIME_SYMBOL_HEIGHT)
// There are three categories of biases: 7's, ReelTime, Regular
// - 7's: BIAS_STRAIGHT_7, BIAS_MIXED_7
// - ReelTime: BIAS_REELTIME
// - Regular: everything else
//
// The 7's and ReelTime biases can be grouped together as 'Special' biases.
//
// There can be at most two biases at a time. If there are two, one bias will be
// ReelTime and the other will be one of the Regular biases.
//
// A new bias is drawn every round, except during ReelTime. Bias towards 7's
// persists across rounds until you match 7's. All other biases are reset after
// the round.
#define BIAS_REPLAY (1 << 0)
#define BIAS_CHERRY (1 << 1)
#define BIAS_LOTAD (1 << 2)
#define BIAS_AZURILL (1 << 3)
#define BIAS_POWER (1 << 4)
#define BIAS_REELTIME (1 << 5)
#define BIAS_MIXED_7 (1 << 6)
#define BIAS_STRAIGHT_7 (1 << 7)
#define BIAS_7 (BIAS_STRAIGHT_7 | BIAS_MIXED_7)
#define BIAS_SPECIAL (BIAS_7 | BIAS_REELTIME)
#define BIAS_REGULAR (BIAS_REPLAY | BIAS_CHERRY | BIAS_LOATAD | BIAS_AZURILL | BIAS_POWER)
// The slot machine will try to manipulate the outcome by adding up to 4 extra
// turns to the reel after you press stop.
//
// The only exception is when it is stopping the third reel and it has decided
// you will lose. In this case, it adds as many turns as necessary to prevent a
// match.
#define MAX_EXTRA_TURNS 4
enum {
SYMBOL_7_RED,
SYMBOL_7_BLUE,
SYMBOL_AZURILL,
SYMBOL_LOTAD,
SYMBOL_CHERRY,
SYMBOL_POWER,
SYMBOL_REPLAY,
};
enum
{
GFXTAG_7_RED,
GFXTAG_7_BLUE,
GFXTAG_AZURILL,
GFXTAG_LOTAD,
GFXTAG_CHERRY,
GFXTAG_POWER,
GFXTAG_REPLAY,
GFXTAG_NUM_0,
GFXTAG_NUM_1,
GFXTAG_NUM_2,
GFXTAG_NUM_3,
GFXTAG_NUM_4,
GFXTAG_NUM_5,
GFXTAG_NUM_6,
GFXTAG_NUM_7,
GFXTAG_NUM_8,
GFXTAG_NUM_9,
GFXTAG_REEL_BG,
GFXTAG_STOP,
GFXTAG_BONUS,
GFXTAG_BIG,
GFXTAG_REG,
};
#define GFXTAG_SYMBOLS_START (GFXTAG_7_RED)
#define GFXTAG_NUMBERS_START (GFXTAG_NUM_0)
#define REEL_NORMAL_SPEED 8
#define REEL_HALF_SPEED 4
#define REEL_QUARTER_SPEED 2
enum {
PALTAG_REEL,
PALTAG_REEL_TIME_PIKACHU,
PALTAG_REEL_TIME_MISC,
PALTAG_REEL_TIME_MACHINE,
PALTAG_MISC,
PALTAG_EXPLOSION,
PALTAG_DIG_DISPLAY,
PALTAG_PIKA_AURA,
};
enum {
MATCH_CHERRY, // Cherry in center of first reel
MATCH_TOPBOT_CHERRY, // Cherry in top/bottom of first reel
MATCH_REPLAY,
MATCH_LOTAD,
MATCH_AZURILL,
MATCH_POWER,
MATCH_MIXED_7, // First two 7's are same color; last is other color
MATCH_RED_7,
MATCH_BLUE_7,
MATCH_NONE,
};
enum {
MATCH_MIDDLE_ROW,
MATCH_TOP_ROW,
MATCH_BOTTOM_ROW,
MATCH_NWSE_DIAG,
MATCH_NESW_DIAG,
NUM_MATCH_LINES,
};
enum {
LEFT_REEL,
MIDDLE_REEL,
RIGHT_REEL,
NUM_REELS,
};
enum {
SLOTTASK_UNFADE,
SLOTTASK_WAIT_FADE,
SLOTTASK_READY_NEW_SPIN,
SLOTTASK_READY_NEW_RT_SPIN,
SLOTTASK_ASK_INSERT_BET,
SLOTTASK_BET_INPUT,
SLOTTASK_MSG_NEED_3_COINS,
SLOTTASK_WAIT_MSG_NEED_3_COINS,
SLOTTASK_WAIT_INFO_BOX,
SLOTTASK_START_SPIN,
SLOTTASK_START_RT_SPIN,
SLOTTASK_RESET_BIAS_FAILURE,
SLOTTASK_WAIT_REEL_STOP,
SLOTTASK_WAIT_ALL_REELS_STOP,
SLOTTASK_CHECK_MATCHES,
SLOTTASK_WAIT_PAYOUT,
SLOTTASK_END_PAYOUT,
SLOTTASK_MATCHED_POWER,
SLOTTASK_WAIT_RT_ANIM,
SLOTTASK_RESET_BET_TILES,
SLOTTASK_NO_MATCHES,
SLOTTASK_ASK_QUIT,
SLOTTASK_HANDLE_QUIT_INPUT,
SLOTTASK_MSG_MAX_COINS,
SLOTTASK_WAIT_MSG_MAX_COINS,
SLOTTASK_MSG_NO_MORE_COINS,
SLOTTASK_WAIT_MSG_NO_MORE_COINS,
SLOTTASK_END,
SLOTTASK_FREE,
};
enum
{
PAYOUT_TASK_INIT,
PAYOUT_TASK_GIVE_PAYOUT,
PAYOUT_TASK_FREE,
};
enum {
REEL_TASK_STILL,
REEL_TASK_SPIN,
REEL_TASK_DECIDE_STOP,
REEL_TASK_STOP_MOVE,
REEL_TASK_STOP_SHAKE,
};
enum {
PIKABOLT_TASK_IDLE,
PIKABOLT_TASK_ADD_BOLT,
PIKABOLT_TASK_WAIT_ANIM,
PIKABOLT_TASK_CLEAR_ALL,
};
enum {
RT_TASK_INIT,
RT_TASK_WINDOW_ENTER,
RT_TASK_WAIT_START_PIKA,
RT_TASK_PIKA_SPEEDUP1,
RT_TASK_PIKA_SPEEDUP2,
RT_TASK_WAIT_REEL,
RT_TASK_CHECK_EXPLODE,
RT_TASK_LAND,
RT_TASK_PIKA_REACT,
RT_TASK_WAIT_CLEAR_POWER,
RT_TASK_CLOSE_WINDOW_SUCCESS,
RT_TASK_DESTROY_SPRITES,
RT_TASK_SET_REEL_SPEED,
RT_TASK_END_SUCCESS,
RT_TASK_EXPLODE,
RT_TASK_WAIT_EXPLODE,
RT_TASK_WAIT_SMOKE,
RT_TASK_CLOSE_WINDOW_FAILURE,
RT_TASK_END_FAILURE,
};
#define DIG_SPRITE_DUMMY {255, 0, 0}
// Sprite template IDs for the digital display in the right panel
enum {
DIG_SPRITE_REEL,
DIG_SPRITE_TIME,
DIG_SPRITE_INSERT,
DIG_SPRITE_WIN,
DIG_SPRITE_LOSE,
DIG_SPRITE_A_BUTTON,
DIG_SPRITE_SMOKE,
DIG_SPRITE_NUMBER,
DIG_SPRITE_POKE_BALL,
DIG_SPRITE_D_PAD,
DIG_SPRITE_STOP_S,
DIG_SPRITE_STOP_T,
DIG_SPRITE_STOP_O,
DIG_SPRITE_STOP_P,
DIG_SPRITE_BONUS_B,
DIG_SPRITE_BONUS_O,
DIG_SPRITE_BONUS_N,
DIG_SPRITE_BONUS_U,
DIG_SPRITE_BONUS_S,
DIG_SPRITE_BIG_B,
DIG_SPRITE_BIG_I,
DIG_SPRITE_BIG_G,
DIG_SPRITE_REG_R,
DIG_SPRITE_REG_E,
DIG_SPRITE_REG_G,
DIG_SPRITE_EMPTY,
NUM_DIG_DISPLAY_SPRITES
};
// IDs used by the digital display to set coords and callbacks for its sprites
enum {
DIG_DISPINFO_INSERT,
DIG_DISPINFO_STOP_S,
DIG_DISPINFO_STOP_T,
DIG_DISPINFO_STOP_O,
DIG_DISPINFO_STOP_P,
DIG_DISPINFO_A_BUTTON_STOP,
DIG_DISPINFO_POKE_BALL_ROCKING,
DIG_DISPINFO_WIN,
DIG_DISPINFO_LOSE,
DIG_DISPINFO_SMOKE_NW,
DIG_DISPINFO_SMOKE_NE,
DIG_DISPINFO_SMOKE_SW,
DIG_DISPINFO_SMOKE_SE,
DIG_DISPINFO_REEL,
DIG_DISPINFO_TIME,
DIG_DISPINFO_NUMBER,
DIG_DISPINFO_DPAD,
DIG_DISPINFO_POKE_BALL_SHINING,
DIG_DISPINFO_REG_R,
DIG_DISPINFO_REG_E,
DIG_DISPINFO_REG_G,
DIG_DISPINFO_REG_BONUS_B,
DIG_DISPINFO_REG_BONUS_O,
DIG_DISPINFO_REG_BONUS_N,
DIG_DISPINFO_REG_BONUS_U,
DIG_DISPINFO_REG_BONUS_S,
DIG_DISPINFO_BIG_B,
DIG_DISPINFO_BIG_I,
DIG_DISPINFO_BIG_G,
DIG_DISPINFO_BIG_BONUS_B,
DIG_DISPINFO_BIG_BONUS_O,
DIG_DISPINFO_BIG_BONUS_N,
DIG_DISPINFO_BIG_BONUS_U,
DIG_DISPINFO_BIG_BONUS_S,
DIG_DISPINFO_A_BUTTON_START
};
// IDs for digital display "scenes", i.e. each of the screens it can show made up of sprites
enum {
DIG_DISPLAY_INSERT_BET,
DIG_DISPLAY_STOP_REEL,
DIG_DISPLAY_WIN,
DIG_DISPLAY_LOSE,
DIG_DISPLAY_REEL_TIME,
DIG_DISPLAY_BONUS_REG,
DIG_DISPLAY_BONUS_BIG
};
// How ReelTime works
// ==================
// Entering ReelTime:
// - If the bias you draw at the start of the round is BIAS_REELTIME, the
// ReelTime lottery begins.
// - At the start of the lottery, the game selects how many ReelTime spins you
// will get, based on how many Power bolts you've collected and whether it
// is a lucky game.
// - The lottery machine rolls until it lands on the selected number. If it
// selected 0 spins, the lottery machine will mostly likely explode before
// landing on 0.
// - If you win:
// - You receive the selected number of ReelTime spins
// - You lose all the Power bolts you've collected thus far
// - The lottery window closes and ReelTime officially begins
//
// During ReelTime:
// - You still have to pay coins for bets.
// - The slot reels may spin slower than usual in ReelTime. The machine draws a
// reel speed at the beginning of each ReelTime spin. The more coins you've
// lost to the machine, and the more consecutive ReelTime spins you've done,
// the higher your chances of getting a slower reel speed.
// - In ReelTime, the reel stops exactly on your input. That is, it won't add
// extra turns to manipulate the outcome.
// - ReelTime ends early if you win red 7's or blue 7's.
// SlotMachine field explanations:
//
// luckyGame:
// Determined at random when you start playing. Some events modify this:
// - Blue 7 match: game becomes lucky
// - Red 7 match: game becomes normal
//
// Effectively, a lucky game inreases the odds of getting more ReelTime spins.
// If the game is lucky, you have a slightly higher chance of matching Power
// bolts (at the expense of Replays). This helps you fill your Power bolt
// gauge faster.
//
// During ReelTime, the more Power bolts you have, the greater your chances
// of drawing more ReelTime spins. In a lucky game, you have greater odds of
// drawing high yields (3+ RT spins). You also have greater odds of drawing 0
// RT spins. But drawing 0 lets you keep all your Power bolts, allowing you to
// fill your gauge further.
struct SlotMachine
{
/*0x00*/ u8 state;
/*0x01*/ u8 machineId;
/*0x02*/ u8 pikaPowerBolts;
/*0x03*/ bool8 luckyGame;
/*0x04*/ u8 machineBias;
/*0x05*/ u8 reelTimeDraw;
/*0x06*/ bool8 didNotFailBias;
/*0x07*/ u8 biasSymbol;
/*0x08*/ u16 matches;
/*0x0A*/ u8 reelTimeSpinsLeft;
/*0x0B*/ u8 reelTimeSpinsUsed;
/*0x0C*/ s16 coins;
/*0x0E*/ s16 payout;
/*0x10*/ s16 netCoinLoss; // never negative
/*0x12*/ s16 bet;
/*0x14*/ s16 reeltimePixelOffset;
/*0x16*/ s16 reeltimePosition;
/*0x18*/ s16 currentReel;
/*0x1A*/ s16 reelSpeed;
/*0x1C*/ s16 reelPixelOffsets[NUM_REELS];
/*0x22*/ u16 reelShockOffsets[NUM_REELS];
/*0x28*/ s16 reelPositions[NUM_REELS];
/*0x2E*/ s16 reelExtraTurns[NUM_REELS];
/*0x34*/ s16 winnerRows[NUM_REELS];
/*0x3A*/ u8 slotReelTasks[NUM_REELS];
/*0x3D*/ u8 digDisplayTaskId;
/*0x3E*/ u8 pikaPowerBoltTaskId;
/*0x3F*/ u8 reelTimePikachuSpriteId;
/*0x40*/ u8 reelTimeNumberGapSpriteId;
/*0x41*/ u8 reelTimeExplosionSpriteId;
/*0x42*/ u8 reelTimeBrokenMachineSpriteId;
/*0x43*/ u8 reelTimeSmokeSpriteId;
/*0x44*/ u8 flashMatchLineSpriteIds[NUM_MATCH_LINES];
/*0x49*/ u8 reelTimeMachineSpriteIds[2];
/*0x49*/ u8 reelTimeNumberSpriteIds[3];
/*0x4E*/ u8 reelTimeShadowSpriteIds[2];
/*0x50*/ u8 reelTimeBoltSpriteIds[2];
/*0x52*/ u8 reelTimePikachuAuraSpriteIds[2];
/*0x54*/ u8 reelTimeDuckSpriteIds[4];
/*0x58*/ u16 win0h;
/*0x5a*/ u16 win0v;
/*0x5c*/ u16 winIn;
/*0x5e*/ u16 winOut;
/*0x60*/ u16 backupMapMusic;
/*0x64*/ MainCallback prevMainCb;
};
struct DigitalDisplaySprite
{
/*0x00*/ u8 spriteTemplateId;
/*0x01*/ u8 dispInfoId;
/*0x02*/ s16 spriteId;
};
static void CB2_SlotMachineSetup(void);
static void CB2_SlotMachine(void);
static void PlaySlotMachine_Internal(u8, MainCallback);
static void SlotMachineDummyTask(u8);
static void SlotMachineSetup_InitBgsWindows(void);
static void SlotMachineSetup_InitVRAM(void);
static void SlotMachineSetup_InitOAM(void);
static void SlotMachineSetup_InitGpuRegs(void);
static void InitSlotMachine(void);
static void SlotMachineSetup_InitPalsSpritesTasks(void);
static void SlotMachineSetup_InitTilemaps(void);
static void SlotMachineSetup_LoadGfxAndTilemaps(void);
static void SlotMachineSetup_InitVBlank(void);
static void AllocDigitalDisplayGfx(void);
static void SetDigitalDisplayImagePtrs(void);
static void CreateSlotMachineSprites(void);
static void CreateGameplayTasks(void);
static void CreateSlotMachineTasks(void);
static void DestroyDigitalDisplayScene(void);
static void Task_SlotMachine(u8);
static bool8 SlotTask_UnfadeScreen(struct Task *);
static bool8 SlotTask_WaitUnfade(struct Task *);
static bool8 SlotTask_ReadyNewSpin(struct Task *);
static bool8 SlotTask_ReadyNewReelTimeSpin(struct Task *);
static bool8 SlotTask_AskInsertBet(struct Task *);
static bool8 SlotTask_HandleBetInput(struct Task *);
static bool8 SlotTask_PrintMsg_Need3Coins(struct Task *);
static bool8 SlotTask_WaitMsg_Need3Coins(struct Task *);
static bool8 SlotTask_WaitInfoBox(struct Task *);
static bool8 SlotTask_StartSpin(struct Task *);
static bool8 SlotTask_StartReelTimeSpin(struct Task *);
static bool8 SlotTask_ResetBiasFailure(struct Task *);
static bool8 SlotTask_WaitReelStop(struct Task *);
static bool8 SlotTask_WaitAllReelsStop(struct Task *);
static bool8 SlotTask_CheckMatches(struct Task *);
static bool8 SlotTask_WaitPayout(struct Task *);
static bool8 SlotTask_EndPayout(struct Task *);
static bool8 SlotTask_MatchedPower(struct Task *);
static bool8 SlotTask_WaitReelTimeAnim(struct Task *);
static bool8 SlotTask_ResetBetTiles(struct Task *);
static bool8 SlotTask_NoMatches(struct Task *);
static bool8 SlotTask_AskQuit(struct Task *);
static bool8 SlotTask_HandleQuitInput(struct Task *);
static bool8 SlotTask_PrintMsg_MaxCoins(struct Task *);
static bool8 SlotTask_WaitMsg_MaxCoins(struct Task *);
static bool8 SlotTask_PrintMsg_NoMoreCoins(struct Task *);
static bool8 SlotTask_WaitMsg_NoMoreCoins(struct Task *);
static bool8 SlotTask_EndGame(struct Task *);
static bool8 SlotTask_FreeDataStructures(struct Task *);
static void DrawMachineBias(void);
static void ResetBiasFailure(void);
static bool8 ShouldTrySpecialBias(void);
static u8 TrySelectBias_Special(void);
static u16 ReelTimeSpeed(void);
static u8 TrySelectBias_Regular(void);
static void CheckMatch(void);
static void CheckMatch_CenterRow(void);
static void CheckMatch_TopAndBottom(void);
static void CheckMatch_Diagonals(void);
static u8 GetMatchFromSymbols(u8, u8, u8);
static void AwardPayout(void);
static void Task_Payout(u8);
static bool8 IsFinalTask_Task_Payout(void);
static bool8 PayoutTask_Init(struct Task *);
static bool8 PayoutTask_GivePayout(struct Task *);
static bool8 PayoutTask_Free(struct Task *);
static u8 GetSymbolAtRest(u8, s16);
static void CreateReelTasks(void);
static void SpinSlotReel(u8);
static void StopSlotReel(u8);
static bool8 IsSlotReelMoving(u8);
static void Task_Reel(u8);
static bool8 ReelTask_StayStill(struct Task *);
static bool8 ReelTask_Spin(struct Task *);
static bool8 ReelTask_DecideStop(struct Task *);
static bool8 ReelTask_MoveToStop(struct Task *);
static bool8 ReelTask_ShakingStop(struct Task *);
static bool8 DecideStop_Bias_Reel1(void);
static bool8 DecideStop_Bias_Reel1_Bet1(u8, u8);
static bool8 DecideStop_Bias_Reel1_Bet2or3(u8, u8);
static bool8 DecideStop_Bias_Reel2(void);
static bool8 DecideStop_Bias_Reel2_Bet1or2(void);
static bool8 DecideStop_Bias_Reel2_Bet3(void);
static bool8 DecideStop_Bias_Reel3(void);
static bool8 DecideStop_Bias_Reel3_Bet1or2(u8);
static bool8 DecideStop_Bias_Reel3_Bet3(u8);
static void DecideStop_NoBias_Reel1(void);
static void DecideStop_NoBias_Reel2(void);
static void DecideStop_NoBias_Reel2_Bet1(void);
static void DecideStop_NoBias_Reel2_Bet2(void);
static void DecideStop_NoBias_Reel2_Bet3(void);
static void DecideStop_NoBias_Reel3(void);
static void DecideStop_NoBias_Reel3_Bet1(void);
static void DecideStop_NoBias_Reel3_Bet2(void);
static void DecideStop_NoBias_Reel3_Bet3(void);
static void PressStopReelButton(u8);
static void Task_PressStopReelButton(u8);
static void LightenBetTiles(u8);
static void StopReelButton_Press(struct Task *, u8);
static void StopReelButton_Wait(struct Task *, u8);
static void StopReelButton_Unpress(struct Task *, u8);
static void DarkenBetTiles(u8);
static void CreateInvisibleFlashMatchLineSprites(void);
static void FlashMatchLine(u8);
static bool8 IsMatchLineDoneFlashingBeforePayout(void);
static bool8 TryStopMatchLinesFlashing(void);
static bool8 TryStopMatchLineFlashing(u8);
static void SpriteCB_FlashMatchingLines(struct Sprite *);
static void FlashSlotMachineLights(void);
static bool8 TryStopSlotMachineLights(void);
static void Task_FlashSlotMachineLights(u8);
static void CreatePikaPowerBoltTask(void);
static void AddPikaPowerBolt(u8);
static bool8 IsPikaPowerBoltAnimating(void);
static void Task_CreatePikaPowerBolt(u8);
static void PikaPowerBolt_Idle(struct Task *);
static void PikaPowerBolt_AddBolt(struct Task *);
static void PikaPowerBolt_WaitAnim(struct Task *);
static void PikaPowerBolt_ClearAll(struct Task *);
static void ResetPikaPowerBoltTask(struct Task *);
static void LoadPikaPowerMeter(u8 );
static void BeginReelTime(void);
static bool8 IsReelTimeTaskDone(void);
static void Task_ReelTime(u8 );
static void ReelTime_Init(struct Task *);
static void ReelTime_WindowEnter(struct Task *);
static void ReelTime_WaitStartPikachu(struct Task *);
static void ReelTime_PikachuSpeedUp1(struct Task *);
static void ReelTime_PikachuSpeedUp2(struct Task *);
static void ReelTime_WaitReel(struct Task *);
static void ReelTime_CheckExplode(struct Task *);
static void ReelTime_LandOnOutcome(struct Task *);
static void ReelTime_PikachuReact(struct Task *);
static void ReelTime_WaitClearPikaPower(struct Task *);
static void ReelTime_CloseWindow(struct Task *);
static void ReelTime_DestroySprites(struct Task *);
static void ReelTime_SetReelSpeed(struct Task *);
static void ReelTime_EndSuccess(struct Task *);
static void ReelTime_ExplodeMachine(struct Task *);
static void ReelTime_WaitExplode(struct Task *);
static void ReelTime_WaitSmoke(struct Task *);
static void ReelTime_EndFailure(struct Task *);
static void LoadReelTimeWindowTilemap(s16, s16);
static void ClearReelTimeWindowTilemap(s16);
static void OpenInfoBox(u8);
static bool8 IsInfoBoxClosed(void);
static void Task_InfoBox(u8 );
static void InfoBox_FadeIn(struct Task *);
static void InfoBox_WaitFade(struct Task *);
static void InfoBox_DrawWindow(struct Task *);
static void InfoBox_WaitInput(struct Task *);
static void InfoBox_AddText(struct Task *);
static void InfoBox_LoadPikaPowerMeter(struct Task *);
static void InfoBox_LoadSlotMachineTilemap(struct Task *);
static void InfoBox_CreateDigitalDisplay(struct Task *);
static void InfoBox_FreeTask(struct Task *);
static void CreateDigitalDisplayTask(void);
static void CreateDigitalDisplayScene(u8 );
static bool8 IsDigitalDisplayAnimFinished(void);
static void DigitalDisplay_Idle(struct Task *);
static void Task_DigitalDisplay(u8);
static void CreateReelSymbolSprites(void);
static void CreateCreditPayoutNumberSprites(void);
static void CreateCoinNumberSprite(s16, s16, u8, s16);
static void CreateReelBackgroundSprite(void);
static void CreateReelTimePikachuSprite(void);
static void DestroyReelTimePikachuSprite(void);
static void CreateReelTimeMachineSprites(void);
static void CreateBrokenReelTimeMachineSprite(void);
static void CreateReelTimeNumberSprites(void);
static void CreateReelTimeShadowSprites(void);
static void CreateReelTimeNumberGapSprite(void);
static void DestroyReelTimeMachineSprites(void);
static void DestroyReelTimeShadowSprites(void);
static void DestroyBrokenReelTimeMachineSprite(void);
static void CreateReelTimeBoltSprites(void);
static void SetReelTimeBoltDelay(s16);
static void DestroyReelTimeBoltSprites(void);
static void CreateReelTimePikachuAuraSprites(void);
static void SetReelTimePikachuAuraFlashDelay(s16);
static void DestroyReelTimePikachuAuraSprites(void);
static void CreateReelTimeExplosionSprite(void);
static void DestroyReelTimeExplosionSprite(void);
static void CreateReelTimeDuckSprites(void);
static void DestroyReelTimeDuckSprites(void);
static void CreateReelTimeSmokeSprite(void);
static bool8 IsReelTimeSmokeAnimFinished(void);
static void DestroyReelTimeSmokeSprite(void);
static u8 CreatePikaPowerBoltSprite(s16, s16);
static void DestroyPikaPowerBoltSprite(u8);
static u8 CreateDigitalDisplaySprite(u8, void (*callback)(struct Sprite *), s16, s16, s16);
static void LoadSlotMachineGfx(void);
static void LoadReelBackground(void);
static void LoadMenuGfx(void);
static void LoadMenuAndReelOverlayTilemaps(void);
static void SetReelButtonTilemap(s16, u16, u16, u16, u16);
static void LoadInfoBoxTilemap(void);
static void LoadSlotMachineMenuTilemap(void);
static void LoadSlotMachineReelOverlay(void);
static u8 CreateStdDigitalDisplaySprite(u8, u8, s16);
static void SpriteCB_DigitalDisplay_Static(struct Sprite *);
static void SpriteCB_DigitalDisplay_Stop(struct Sprite *);
static void SpriteCB_DigitalDisplay_AButtonStop(struct Sprite *);
static void SpriteCB_DigitalDisplay_PokeballRocking(struct Sprite *);
static void SpriteCB_DigitalDisplay_Smoke(struct Sprite *);
static void SpriteCB_DigitalDisplay_SmokeNE(struct Sprite *);
static void SpriteCB_DigitalDisplay_SmokeSW(struct Sprite *);
static void SpriteCB_DigitalDisplay_SmokeSE(struct Sprite *);
static void SpriteCB_DigitalDisplay_Reel(struct Sprite *);
static void SpriteCB_DigitalDisplay_Time(struct Sprite *);
static void SpriteCB_DigitalDisplay_ReelTimeNumber(struct Sprite *);
static void SpriteCB_DigitalDisplay_PokeballShining(struct Sprite *);
static void SpriteCB_DigitalDisplay_RegBonus(struct Sprite *);
static void SpriteCB_DigitalDisplay_BigBonus(struct Sprite *);
static void SpriteCB_DigitalDisplay_AButtonStart(struct Sprite *);
static void EndDigitalDisplayScene_InsertBet(void);
static void EndDigitalDisplayScene_StopReel(void);
static void EndDigitalDisplayScene_Win(void);
static void EndDigitalDisplayScene_Dummy(void);
static void SpriteCB_ReelSymbol(struct Sprite *);
static void SpriteCB_CoinNumber(struct Sprite *);
static void SpriteCB_ReelTimePikachu(struct Sprite *);
static void SpriteCB_ReelTimeNumbers(struct Sprite *);
static void SpriteCB_ReelTimeBolt(struct Sprite *);
static void SpriteCB_ReelTimePikachuAura(struct Sprite *);
static void SpriteCB_ReelTimeExplosion(struct Sprite *);
static void SpriteCB_ReelTimeDuck(struct Sprite *);
static void SpriteCB_ReelTimeSmoke(struct Sprite *);
static void SpriteCB_PikaPowerBolt(struct Sprite *);
// Ewram variables
static EWRAM_DATA u16 *sMenuGfx = NULL;
static EWRAM_DATA u16 *sSelectedPikaPowerTile = NULL;
static EWRAM_DATA u16 *sReelOverlay_Tilemap = NULL;
static EWRAM_DATA u8 *sDigitalDisplayGfxPtr = NULL;
static EWRAM_DATA u8 *sReelTimeGfxPtr = NULL;
static EWRAM_DATA u16 *sReelButtonPress_Tilemap = NULL;
static EWRAM_DATA u8 *sReelBackground_Gfx = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_ReelTimePikachu = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_ReelTimeMachineAntennae = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_ReelTimeMachine = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_BrokenReelTimeMachine = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Reel = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Time = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Insert = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Stop = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Win = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Lose = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Bonus = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Big = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Reg = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_AButton = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Smoke = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Number = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_Pokeball = NULL;
static EWRAM_DATA struct SpriteFrameImage *sImageTable_DigitalDisplay_DPad = NULL;
static EWRAM_DATA struct SpriteSheet *sReelBackgroundSpriteSheet = NULL;
static EWRAM_DATA struct SpriteSheet *sSlotMachineSpritesheetsPtr = NULL;
static EWRAM_DATA struct SlotMachine *sSlotMachine = NULL;
// IWRAM bss
static struct SpriteFrameImage *sImageTables_DigitalDisplay[NUM_DIG_DISPLAY_SPRITES];
// Const rom data.
static const struct DigitalDisplaySprite *const sDigitalDisplayScenes[];
static const u16 sUnkPalette[];
static const u8 sSpecialDrawOdds[NUM_SLOT_MACHINE_IDS][MAX_BET];
static const u8 sBiasSymbols[];
static const u16 sBiasesSpecial[3];
static const u16 sBiasesRegular[5];
static const s16 sDigitalDisplay_SpriteCoords[][2];
static const SpriteCallback sDigitalDisplay_SpriteCallbacks[];
static const struct SpriteTemplate *const sSpriteTemplates_DigitalDisplay[NUM_DIG_DISPLAY_SPRITES];
static const struct SubspriteTable *const sSubspriteTables_DigitalDisplay[NUM_DIG_DISPLAY_SPRITES];
static const struct SpriteTemplate sSpriteTemplate_PikaPowerBolt;
static const struct SpriteTemplate sSpriteTemplate_ReelTimeSmoke;
static const struct SpriteTemplate sSpriteTemplate_ReelTimeDuck;
static const struct SpriteTemplate sSpriteTemplate_ReelTimeExplosion;
static const struct SpriteTemplate sSpriteTemplate_ReelTimePikachuAura;
static const u16 sReelTimeExplodeProbability[];
static const u16 *const sPokeballShiningPalTable[];
static const u16 sReelTimeSpeed_Probabilities[][2];
static const u16 sQuarterSpeed_ProbabilityBoost[];
static const u16 sSlotMatchFlags[];
static const u16 sSlotPayouts[];
static const u8 *const sReelBackground_Tilemap;
static const u32 sReelTimeGfx[];
static const struct SpriteSheet sSlotMachineSpriteSheets[22];
static const struct SpritePalette sSlotMachineSpritePalettes[];
static const u16 *const sDigitalDisplay_Pal;
static const s16 sInitialReelPositions[NUM_REELS][2];
static const u8 sBiasProbabilities_Special[][NUM_SLOT_MACHINE_IDS];
static const u8 sBiasProbabilities_Regular[][NUM_SLOT_MACHINE_IDS];
static const u8 sReelTimeProbabilities_NormalGame[][17];
static const u8 sReelTimeProbabilities_LuckyGame[][17];
static const u8 sSymbolToMatch[];
static const u8 sReelTimeSymbols[];
static const u8 sReelSymbols[NUM_REELS][SYMBOLS_PER_REEL];
static const u16 *const sLitMatchLinePalTable[NUM_MATCH_LINES];
static const u16 *const sDarkMatchLinePalTable[NUM_MATCH_LINES];
static const u8 sMatchLinePalOffsets[NUM_MATCH_LINES];
static const u8 sBetToMatchLineIds[MAX_BET][2];
static const u8 sMatchLinesPerBet[MAX_BET];
static const u16 *const sFlashingLightsPalTable[];
static const u16 *const sSlotMachineMenu_Pal;
static const u16 sReelTimeWindow_Tilemap[];
static const u16 sEmptyTilemap[];
static void (*const sDigitalDisplaySceneExitCallbacks[])(void);
static const struct SpriteTemplate sSpriteTemplate_ReelTimeBolt;
static const struct SpriteTemplate sSpriteTemplate_ReelTimeNumberGap;
static const struct SpriteTemplate sSpriteTemplate_ReelTimeShadow;
static const struct SpriteTemplate sSpriteTemplate_ReelTimeNumbers;
static const struct SpriteTemplate sSpriteTemplate_BrokenReelTimeMachine;
static const struct SpriteTemplate sSpriteTemplate_ReelTimeMachineAntennae;
static const struct SpriteTemplate sSpriteTemplate_ReelTimeMachine;
static const struct SpriteTemplate sSpriteTemplate_ReelBackground;
static const struct SpriteTemplate sSpriteTemplate_CoinNumber;
static const struct SpriteTemplate sSpriteTemplate_ReelSymbol;
static const struct SpriteTemplate sSpriteTemplate_ReelTimePikachu;
static const struct SubspriteTable sSubspriteTable_ReelTimeNumberGap[];
static const struct SubspriteTable sSubspriteTable_ReelTimeShadow[];
static const struct SubspriteTable sSubspriteTable_BrokenReelTimeMachine[];
static const struct SubspriteTable sSubspriteTable_ReelTimeMachineAntennae[];
static const struct SubspriteTable sSubspriteTable_ReelTimeMachine[];
static const struct SubspriteTable sSubspriteTable_ReelBackground[];
static const struct BgTemplate sBgTemplates[] =
{
{
.bg = 0,
.charBaseIndex = 2,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 28,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
},
{
.bg = 2,
.charBaseIndex = 1,
.mapBaseIndex = 29,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 1,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
},
};
static const struct WindowTemplate sWindowTemplates[] =
{
{
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 15,
.width = 27,
.height = 4,
.paletteNum = 15,
.baseBlock = 0x194
},
DUMMY_WIN_TEMPLATE
};
static const struct WindowTemplate sWindowTemplate_InfoBox =
{
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 3,
.width = 20,
.height = 13,
.paletteNum = 13,
.baseBlock = 1
};
static const u8 sColors_ReeltimeHelp[] = {TEXT_COLOR_LIGHT_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY};
static bool8 (*const sSlotTasks[])(struct Task *task) =
{
[SLOTTASK_UNFADE] = SlotTask_UnfadeScreen,
[SLOTTASK_WAIT_FADE] = SlotTask_WaitUnfade,
[SLOTTASK_READY_NEW_SPIN] = SlotTask_ReadyNewSpin,
[SLOTTASK_READY_NEW_RT_SPIN] = SlotTask_ReadyNewReelTimeSpin,
[SLOTTASK_ASK_INSERT_BET] = SlotTask_AskInsertBet,
[SLOTTASK_BET_INPUT] = SlotTask_HandleBetInput,
[SLOTTASK_MSG_NEED_3_COINS] = SlotTask_PrintMsg_Need3Coins,
[SLOTTASK_WAIT_MSG_NEED_3_COINS] = SlotTask_WaitMsg_Need3Coins,
[SLOTTASK_WAIT_INFO_BOX] = SlotTask_WaitInfoBox,
[SLOTTASK_START_SPIN] = SlotTask_StartSpin,
[SLOTTASK_START_RT_SPIN] = SlotTask_StartReelTimeSpin,
[SLOTTASK_RESET_BIAS_FAILURE] = SlotTask_ResetBiasFailure,
[SLOTTASK_WAIT_REEL_STOP] = SlotTask_WaitReelStop,
[SLOTTASK_WAIT_ALL_REELS_STOP] = SlotTask_WaitAllReelsStop,
[SLOTTASK_CHECK_MATCHES] = SlotTask_CheckMatches,
[SLOTTASK_WAIT_PAYOUT] = SlotTask_WaitPayout,
[SLOTTASK_END_PAYOUT] = SlotTask_EndPayout,
[SLOTTASK_MATCHED_POWER] = SlotTask_MatchedPower,
[SLOTTASK_WAIT_RT_ANIM] = SlotTask_WaitReelTimeAnim,
[SLOTTASK_RESET_BET_TILES] = SlotTask_ResetBetTiles,
[SLOTTASK_NO_MATCHES] = SlotTask_NoMatches,
[SLOTTASK_ASK_QUIT] = SlotTask_AskQuit,
[SLOTTASK_HANDLE_QUIT_INPUT] = SlotTask_HandleQuitInput,
[SLOTTASK_MSG_MAX_COINS] = SlotTask_PrintMsg_MaxCoins,
[SLOTTASK_WAIT_MSG_MAX_COINS] = SlotTask_WaitMsg_MaxCoins,
[SLOTTASK_MSG_NO_MORE_COINS] = SlotTask_PrintMsg_NoMoreCoins,
[SLOTTASK_WAIT_MSG_NO_MORE_COINS] = SlotTask_WaitMsg_NoMoreCoins,
[SLOTTASK_END] = SlotTask_EndGame,
[SLOTTASK_FREE] = SlotTask_FreeDataStructures,
};
static bool8 (*const sPayoutTasks[])(struct Task *task) =
{
[PAYOUT_TASK_INIT] = PayoutTask_Init,
[PAYOUT_TASK_GIVE_PAYOUT] = PayoutTask_GivePayout,
[PAYOUT_TASK_FREE] = PayoutTask_Free,
};
static bool8 (*const sReelTasks[])(struct Task *task) =
{
[REEL_TASK_STILL] = ReelTask_StayStill,
[REEL_TASK_SPIN] = ReelTask_Spin,
[REEL_TASK_DECIDE_STOP] = ReelTask_DecideStop,
[REEL_TASK_STOP_MOVE] = ReelTask_MoveToStop,
[REEL_TASK_STOP_SHAKE] = ReelTask_ShakingStop,
};
// Returns true if it is possible to match the bias symbol in the reel.
//
// Modifies the winnerRows and reelExtraTurns to indicate how to match the bias
// symbol.
static bool8 (*const sDecideStop_Bias[NUM_REELS])(void) =
{
DecideStop_Bias_Reel1,
DecideStop_Bias_Reel2,
DecideStop_Bias_Reel3,
};
// The player will always lose (barring a few rare circumstances that were not
// accounted for in implementation).
//
// Modifies the winnerRows and reelExtraTurns to indicate how to make the player
// lose.
static void (*const sDecideStop_NoBias[NUM_REELS])(void) =
{
DecideStop_NoBias_Reel1,
DecideStop_NoBias_Reel2,
DecideStop_NoBias_Reel3,
};
// The magnitude of the shock depends on how many extra turns are added.
static const u16 sReelStopShocks[] = {2, 4, 4, 4, 8};
static bool8 (*const sDecideStop_Bias_Reel1_Bets[MAX_BET])(u8 sym1, u8 sym2) =
{
DecideStop_Bias_Reel1_Bet1,
DecideStop_Bias_Reel1_Bet2or3,
DecideStop_Bias_Reel1_Bet2or3,
};
static bool8 (*const sDecideStop_Bias_Reel2_Bets[MAX_BET])(void) =
{
DecideStop_Bias_Reel2_Bet1or2,
DecideStop_Bias_Reel2_Bet1or2,
DecideStop_Bias_Reel2_Bet3,
};
static bool8 (*const sDecideStop_Bias_Reel3_Bets[MAX_BET])(u8 biasSymbol) =
{
DecideStop_Bias_Reel3_Bet1or2,
DecideStop_Bias_Reel3_Bet1or2,
DecideStop_Bias_Reel3_Bet3,
};
static void (*const sDecideStop_NoBias_Reel2_Bets[MAX_BET])(void) =
{
DecideStop_NoBias_Reel2_Bet1,
DecideStop_NoBias_Reel2_Bet2,
DecideStop_NoBias_Reel2_Bet3,
};
static void (*const sDecideStop_NoBias_Reel3_Bets[MAX_BET])(void) =
{
DecideStop_NoBias_Reel3_Bet1,
DecideStop_NoBias_Reel3_Bet2,
DecideStop_NoBias_Reel3_Bet3,
};
static void (*const sReelStopButtonTasks[])(struct Task *task, u8 taskId) =
{
StopReelButton_Press,
StopReelButton_Wait,
StopReelButton_Unpress,
};
static const s16 sReelButtonOffsets[NUM_REELS] = {5, 10, 15};
static void (*const sPikaPowerBoltTasks[])(struct Task *task) =
{
PikaPowerBolt_Idle,
PikaPowerBolt_AddBolt,
PikaPowerBolt_WaitAnim,
PikaPowerBolt_ClearAll,
};
static const u16 sPikaPowerTileTable[][2] =
{
{0x9e, 0x6e},
{0x9f, 0x6f},
{0xaf, 0x7f},
};
static void (*const sReelTimeTasks[])(struct Task *task) =
{
[RT_TASK_INIT] = ReelTime_Init,
[RT_TASK_WINDOW_ENTER] = ReelTime_WindowEnter,
[RT_TASK_WAIT_START_PIKA] = ReelTime_WaitStartPikachu,
[RT_TASK_PIKA_SPEEDUP1] = ReelTime_PikachuSpeedUp1,
[RT_TASK_PIKA_SPEEDUP2] = ReelTime_PikachuSpeedUp2,
[RT_TASK_WAIT_REEL] = ReelTime_WaitReel,
[RT_TASK_CHECK_EXPLODE] = ReelTime_CheckExplode,
[RT_TASK_LAND] = ReelTime_LandOnOutcome,
[RT_TASK_PIKA_REACT] = ReelTime_PikachuReact,
[RT_TASK_WAIT_CLEAR_POWER] = ReelTime_WaitClearPikaPower,
[RT_TASK_CLOSE_WINDOW_SUCCESS] = ReelTime_CloseWindow,
[RT_TASK_DESTROY_SPRITES] = ReelTime_DestroySprites,
[RT_TASK_SET_REEL_SPEED] = ReelTime_SetReelSpeed,
[RT_TASK_END_SUCCESS] = ReelTime_EndSuccess,
[RT_TASK_EXPLODE] = ReelTime_ExplodeMachine,
[RT_TASK_WAIT_EXPLODE] = ReelTime_WaitExplode,
[RT_TASK_WAIT_SMOKE] = ReelTime_WaitSmoke,
[RT_TASK_CLOSE_WINDOW_FAILURE] = ReelTime_CloseWindow,
[RT_TASK_END_FAILURE] = ReelTime_EndFailure,
};
static const u8 sReelTimePikachuAnimIds[] = {1, 1, 2, 2};
static const s16 sReelTimeBoltDelays[] = {64, 48, 24, 8};
static const s16 sPikachuAuraFlashDelays[] = {10, 8, 6, 4};
static void (*const sInfoBoxTasks[])(struct Task *task) =
{
// Go to Info screen
InfoBox_FadeIn,
InfoBox_WaitFade,
InfoBox_DrawWindow,
InfoBox_WaitFade,
InfoBox_AddText,
InfoBox_WaitFade,
// On Info screen
InfoBox_WaitInput,
// Exit Info screen
InfoBox_WaitFade,
InfoBox_LoadSlotMachineTilemap,
InfoBox_WaitFade,
InfoBox_CreateDigitalDisplay,
InfoBox_WaitFade,
InfoBox_LoadPikaPowerMeter,
InfoBox_WaitFade,
InfoBox_FreeTask,
};
// Just idles, digital display is handled by CreateDigitalDisplayScene and sprite callbacks
static void (*const sDigitalDisplayTasks[])(struct Task *task) =
{
DigitalDisplay_Idle,
};
#define tState data[0]