Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/slots/slot_machine.asm
1271 views
1
PromptUserToPlaySlots:
2
call SaveScreenTilesToBuffer2
3
ld a, BANK(DisplayTextIDInit)
4
ASSERT BANK(DisplayTextIDInit) == 1 << BIT_NO_AUTO_TEXT_BOX
5
ld [wAutoTextBoxDrawingControl], a ; 1 << BIT_NO_AUTO_TEXT_BOX
6
ld b, a ; BANK(DisplayTextIDInit)
7
ld hl, DisplayTextIDInit
8
call Bankswitch
9
ld hl, PlaySlotMachineText
10
call PrintText
11
call YesNoChoice
12
ld a, [wCurrentMenuItem]
13
and a
14
jr nz, .done ; if player chose No
15
dec a
16
ld [wUpdateSpritesEnabled], a
17
ld hl, wSlotMachineRerollCounter
18
xor a
19
ld [hli], a
20
ld [hl], SMILE_BUBBLE
21
predef EmotionBubble
22
call GBPalWhiteOutWithDelay3
23
call LoadSlotMachineTiles
24
call LoadFontTilePatterns
25
ld b, SET_PAL_SLOTS
26
call RunPaletteCommand
27
call GBPalNormal
28
ld a, $e4
29
ldh [rOBP0], a
30
ld hl, wStatusFlags5
31
set BIT_NO_TEXT_DELAY, [hl]
32
xor a
33
ld [wSlotMachineAllowMatchesCounter], a
34
ld hl, wStoppingWhichSlotMachineWheel
35
ld bc, $14
36
call FillMemory
37
call MainSlotMachineLoop
38
ld hl, wStatusFlags5
39
res BIT_NO_TEXT_DELAY, [hl]
40
xor a
41
ld [wSlotMachineAllowMatchesCounter], a
42
call GBPalWhiteOutWithDelay3
43
ld a, $1
44
ld [wUpdateSpritesEnabled], a
45
call RunDefaultPaletteCommand
46
call ReloadMapSpriteTilePatterns
47
call ReloadTilesetTilePatterns
48
.done
49
call LoadScreenTilesFromBuffer2
50
call Delay3
51
call GBPalNormal
52
ld a, [wSlotMachineSavedROMBank]
53
push af
54
jp CloseTextDisplay
55
56
PlaySlotMachineText:
57
text_far _PlaySlotMachineText
58
text_end
59
60
MainSlotMachineLoop:
61
call SlotMachine_PrintCreditCoins
62
xor a
63
ld hl, wPayoutCoins
64
ld [hli], a
65
ld [hl], a
66
call SlotMachine_PrintPayoutCoins
67
ld hl, BetHowManySlotMachineText
68
call PrintText
69
call SaveScreenTilesToBuffer1
70
.loop
71
ld a, PAD_A | PAD_B
72
ld [wMenuWatchedKeys], a
73
ld a, 2
74
ld [wMaxMenuItem], a
75
ld a, 12
76
ld [wTopMenuItemY], a
77
ld a, 15
78
ld [wTopMenuItemX], a
79
xor a
80
ld [wCurrentMenuItem], a
81
ld [wLastMenuItem], a
82
ld [wMenuWatchMovingOutOfBounds], a
83
hlcoord 14, 11
84
ld b, 5
85
ld c, 4
86
call TextBoxBorder
87
hlcoord 16, 12
88
ld de, CoinMultiplierSlotMachineText
89
call PlaceString
90
call HandleMenuInput
91
and PAD_B
92
jp nz, LoadScreenTilesFromBuffer1
93
ld a, [wCurrentMenuItem]
94
ld b, a
95
ld a, 3
96
sub b
97
ld [wSlotMachineBet], a
98
ld hl, wPlayerCoins
99
ld c, a
100
ld a, [hli]
101
and a
102
jr nz, .skip1
103
ld a, [hl]
104
cp c
105
jr nc, .skip1
106
ld hl, NotEnoughCoinsSlotMachineText
107
call PrintText
108
jr .loop
109
.skip1
110
call LoadScreenTilesFromBuffer1
111
call SlotMachine_SubtractBetFromPlayerCoins
112
call SlotMachine_LightBalls
113
call SlotMachine_SetFlags
114
ld a, 4
115
ld hl, wSlotMachineWheel1SlipCounter
116
ld [hli], a
117
ld [hli], a
118
ld [hl], a
119
call WaitForSoundToFinish
120
ld a, SFX_SLOTS_NEW_SPIN
121
call PlaySound
122
ld hl, StartSlotMachineText
123
call PrintText
124
call SlotMachine_SpinWheels
125
call SlotMachine_CheckForMatches
126
ld hl, wPlayerCoins
127
ld a, [hli]
128
or [hl]
129
jr nz, .skip2
130
ld hl, OutOfCoinsSlotMachineText
131
call PrintText
132
ld c, 60
133
jp DelayFrames
134
.skip2
135
ld hl, OneMoreGoSlotMachineText
136
call PrintText
137
hlcoord 14, 12
138
lb bc, 13, 15
139
xor a ; YES_NO_MENU
140
ld [wTwoOptionMenuID], a
141
ld a, TWO_OPTION_MENU
142
ld [wTextBoxID], a
143
call DisplayTextBoxID
144
ld a, [wCurrentMenuItem]
145
and a
146
ret nz
147
call SlotMachine_PutOutLitBalls
148
jp MainSlotMachineLoop
149
150
CoinMultiplierSlotMachineText:
151
db "×3"
152
next "×2"
153
next "×1@"
154
155
OutOfCoinsSlotMachineText:
156
text_far _OutOfCoinsSlotMachineText
157
text_end
158
159
BetHowManySlotMachineText:
160
text_far _BetHowManySlotMachineText
161
text_end
162
163
StartSlotMachineText:
164
text_far _StartSlotMachineText
165
text_end
166
167
NotEnoughCoinsSlotMachineText:
168
text_far _NotEnoughCoinsSlotMachineText
169
text_end
170
171
OneMoreGoSlotMachineText:
172
text_far _OneMoreGoSlotMachineText
173
text_end
174
175
SlotMachine_SetFlags:
176
ld hl, wSlotMachineFlags
177
bit BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR, [hl]
178
ret nz
179
ld a, [wSlotMachineAllowMatchesCounter]
180
and a
181
jr nz, .allowMatches
182
call Random
183
and a
184
jr z, .setAllowMatchesCounter ; 1/256 (~0.4%) chance
185
ld b, a
186
ld a, [wSlotMachineSevenAndBarModeChance]
187
cp b
188
jr c, .allowSevenAndBarMatches
189
ld a, 210
190
cp b
191
jr c, .allowMatches ; 55/256 (~21.5%) chance
192
ld [hl], 0
193
ret
194
.allowMatches
195
set BIT_SLOTS_CAN_WIN, [hl]
196
ret
197
.setAllowMatchesCounter
198
ld a, 60
199
ld [wSlotMachineAllowMatchesCounter], a
200
ret
201
.allowSevenAndBarMatches
202
set BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR, [hl]
203
ret
204
205
SlotMachine_SpinWheels:
206
ld c, 20
207
.loop1
208
push bc
209
call SlotMachine_AnimWheel1
210
call SlotMachine_AnimWheel2
211
call SlotMachine_AnimWheel3
212
ld c, 2
213
call DelayFrames
214
pop bc
215
dec c
216
jr nz, .loop1
217
xor a
218
ld [wStoppingWhichSlotMachineWheel], a
219
.loop2
220
call SlotMachine_HandleInputWhileWheelsSpin
221
call SlotMachine_StopOrAnimWheel1
222
call SlotMachine_StopOrAnimWheel2
223
call SlotMachine_StopOrAnimWheel3
224
ret c
225
ld a, [wOnSGB]
226
xor $1
227
inc a
228
ld c, a
229
call DelayFrames
230
jr .loop2
231
232
; Note that the wheels can only stop when a symbol is centred in the wheel
233
; and thus 3 full symbols rather than 2 full symbols and 2 half symbols are
234
; visible. The 3 functions below ensure this by checking if the wheel offset
235
; is even before stopping the wheel.
236
237
SlotMachine_StopOrAnimWheel1:
238
ld a, [wStoppingWhichSlotMachineWheel]
239
cp 1
240
jr c, .animWheel
241
ld de, wSlotMachineWheel1Offset
242
ld a, [de]
243
rra
244
jr nc, .animWheel ; check that a symbol is centred in the wheel
245
ld hl, wSlotMachineWheel1SlipCounter
246
ld a, [hl]
247
and a
248
ret z
249
dec [hl]
250
call SlotMachine_StopWheel1Early
251
ret nz
252
.animWheel
253
jp SlotMachine_AnimWheel1
254
255
SlotMachine_StopOrAnimWheel2:
256
ld a, [wStoppingWhichSlotMachineWheel]
257
cp 2
258
jr c, .animWheel
259
ld de, wSlotMachineWheel2Offset
260
ld a, [de]
261
rra
262
jr nc, .animWheel ; check that a symbol is centred in the wheel
263
ld hl, wSlotMachineWheel2SlipCounter
264
ld a, [hl]
265
and a
266
ret z
267
dec [hl]
268
call SlotMachine_StopWheel2Early
269
ret z
270
.animWheel
271
jp SlotMachine_AnimWheel2
272
273
SlotMachine_StopOrAnimWheel3:
274
ld a, [wStoppingWhichSlotMachineWheel]
275
cp 3
276
jr c, .animWheel
277
ld de, wSlotMachineWheel3Offset
278
ld a, [de]
279
rra
280
jr nc, .animWheel ; check that a symbol is centred in the wheel
281
; wheel 3 stops as soon as possible
282
scf
283
ret
284
.animWheel
285
call SlotMachine_AnimWheel3
286
and a
287
ret
288
289
SlotMachine_StopWheel1Early:
290
call SlotMachine_GetWheel1Tiles
291
ld hl, wSlotMachineWheel1BottomTile
292
ld a, [wSlotMachineFlags]
293
and 1 << BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR
294
jr nz, .sevenAndBarMode
295
; Stop early if the middle symbol is not a cherry.
296
inc hl
297
ld a, [hl]
298
cp HIGH(SLOTSCHERRY)
299
jr nz, .stopWheel
300
ret
301
; Bug: This looks intended to make the wheel stop when a
302
; 7 symbol was visible, but instead the wheel stops randomly.
303
.sevenAndBarMode
304
ld c, $3
305
.loop
306
ld a, [hli]
307
cp HIGH(SLOTS7)
308
jr c, .stopWheel ; condition never true
309
dec c
310
jr nz, .loop
311
ret
312
.stopWheel
313
inc a
314
ld hl, wSlotMachineWheel1SlipCounter
315
ld [hl], 0
316
ret
317
318
SlotMachine_StopWheel2Early:
319
call SlotMachine_GetWheel2Tiles
320
ld a, [wSlotMachineFlags]
321
and 1 << BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR
322
jr nz, .sevenAndBarMode
323
; Stop early if any symbols are lined up in the first two wheels.
324
call SlotMachine_FindWheel1Wheel2Matches
325
ret nz
326
jr .stopWheel
327
; Stop early if two 7 symbols or two bar symbols are lined up in the first two
328
; wheels OR if no symbols are lined up and the bottom symbol in wheel 2 is a
329
; 7 symbol or bar symbol. The second part could be a bug or a way to reduce the
330
; player's odds.
331
.sevenAndBarMode
332
call SlotMachine_FindWheel1Wheel2Matches
333
ld a, [de]
334
cp HIGH(SLOTSBAR) + 1
335
ret nc
336
.stopWheel
337
xor a
338
ld [wSlotMachineWheel2SlipCounter], a
339
ret
340
341
SlotMachine_FindWheel1Wheel2Matches:
342
; return whether wheel 1 and wheel 2's current positions allow a match (given
343
; that wheel 3 stops in a good position) in Z
344
ld hl, wSlotMachineWheel1BottomTile
345
ld de, wSlotMachineWheel2BottomTile
346
ld a, [de]
347
cp [hl] ; wheel 1 bottom, wheel 2 bottom
348
ret z
349
inc de
350
ld a, [de]
351
cp [hl] ; wheel 1 bottom, wheel 2 middle
352
ret z
353
inc hl
354
cp [hl] ; wheel 1 middle, wheel 2 middle
355
ret z
356
inc hl
357
cp [hl] ; wheel 1 top, wheel 2 middle
358
ret z
359
inc de
360
ld a, [de]
361
cp [hl] ; wheel 1 top, wheel 2 top
362
ret z
363
dec de
364
dec de
365
ret
366
367
SlotMachine_CheckForMatches:
368
call SlotMachine_GetWheel3Tiles
369
ld a, [wSlotMachineBet]
370
cp 2
371
jr z, .checkMatchesFor2CoinBet
372
cp 1
373
jr z, .checkMatchFor1CoinBet
374
; 3 coin bet allows diagonal matches (plus the matches for 1/2 coin bets)
375
ld hl, wSlotMachineWheel1BottomTile
376
ld de, wSlotMachineWheel2MiddleTile
377
ld bc, wSlotMachineWheel3TopTile
378
call SlotMachine_CheckForMatch
379
jp z, .foundMatch
380
ld hl, wSlotMachineWheel1TopTile
381
ld de, wSlotMachineWheel2MiddleTile
382
ld bc, wSlotMachineWheel3BottomTile
383
call SlotMachine_CheckForMatch
384
jr z, .foundMatch
385
; 2 coin bet allows top/bottom horizontal matches (plus the match for a 1 coin bet)
386
.checkMatchesFor2CoinBet
387
ld hl, wSlotMachineWheel1TopTile
388
ld de, wSlotMachineWheel2TopTile
389
ld bc, wSlotMachineWheel3TopTile
390
call SlotMachine_CheckForMatch
391
jr z, .foundMatch
392
ld hl, wSlotMachineWheel1BottomTile
393
ld de, wSlotMachineWheel2BottomTile
394
ld bc, wSlotMachineWheel3BottomTile
395
call SlotMachine_CheckForMatch
396
jr z, .foundMatch
397
; 1 coin bet only allows a middle horizontal match
398
.checkMatchFor1CoinBet
399
ld hl, wSlotMachineWheel1MiddleTile
400
ld de, wSlotMachineWheel2MiddleTile
401
ld bc, wSlotMachineWheel3MiddleTile
402
call SlotMachine_CheckForMatch
403
jr z, .foundMatch
404
ld a, [wSlotMachineFlags]
405
and (1 << BIT_SLOTS_CAN_WIN) | (1 << BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR)
406
jr z, .noMatch
407
ld hl, wSlotMachineRerollCounter
408
dec [hl]
409
jr nz, .rollWheel3DownByOneSymbol
410
.noMatch
411
ld hl, NotThisTimeText
412
call PrintText
413
.done
414
xor a
415
ld [wMuteAudioAndPauseMusic], a
416
ret
417
.rollWheel3DownByOneSymbol
418
call SlotMachine_AnimWheel3
419
call DelayFrame
420
call SlotMachine_AnimWheel3
421
call DelayFrame
422
jp SlotMachine_CheckForMatches
423
.foundMatch
424
ld a, [wSlotMachineFlags]
425
and (1 << BIT_SLOTS_CAN_WIN) | (1 << BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR)
426
jr z, .rollWheel3DownByOneSymbol ; roll wheel if player isn't allowed to win
427
and 1 << BIT_SLOTS_CAN_WIN_WITH_7_OR_BAR
428
jr nz, .acceptMatch
429
; if 7/bar matches aren't enabled and the match was a 7/bar symbol, roll wheel
430
ld a, [hl]
431
cp HIGH(SLOTSBAR) + 1
432
jr c, .rollWheel3DownByOneSymbol
433
.acceptMatch
434
ld a, [hl]
435
sub $2
436
ld [wSlotMachineWinningSymbol], a
437
ld hl, SlotRewardPointers
438
ld c, a
439
ld b, 0
440
add hl, bc
441
ld a, [hli]
442
ld e, a
443
ld a, [hli]
444
ld d, a
445
push de
446
ld a, [hli]
447
ld h, [hl]
448
ld l, a
449
ld de, wStringBuffer
450
ld bc, 4
451
call CopyData
452
pop hl
453
ld de, .flashScreenLoop
454
push de
455
jp hl
456
457
.flashScreenLoop
458
ldh a, [rBGP]
459
xor $40
460
ldh [rBGP], a
461
ld c, 5
462
call DelayFrames
463
dec b
464
jr nz, .flashScreenLoop
465
ld hl, wPayoutCoins
466
ld [hl], d
467
inc hl
468
ld [hl], e
469
call SlotMachine_PrintPayoutCoins
470
ld hl, SymbolLinedUpSlotMachineText
471
call PrintText
472
call WaitForTextScrollButtonPress
473
call SlotMachine_PayCoinsToPlayer
474
call SlotMachine_PrintPayoutCoins
475
ld a, $e4
476
ldh [rOBP0], a
477
jp .done
478
479
SymbolLinedUpSlotMachineText:
480
text_asm
481
push bc
482
call SlotMachine_PrintWinningSymbol
483
ld hl, LinedUpText
484
pop bc
485
inc bc
486
inc bc
487
inc bc
488
inc bc
489
ret
490
491
LinedUpText:
492
text_far _LinedUpText
493
text_end
494
495
SlotRewardPointers:
496
dw SlotReward300Func
497
dw SlotReward300Text
498
dw SlotReward100Func
499
dw SlotReward100Text
500
dw SlotReward8Func
501
dw SlotReward8Text
502
dw SlotReward15Func
503
dw SlotReward15Text
504
dw SlotReward15Func
505
dw SlotReward15Text
506
dw SlotReward15Func
507
dw SlotReward15Text
508
509
SlotReward300Text:
510
db "300@"
511
512
SlotReward100Text:
513
db "100@"
514
515
SlotReward8Text:
516
db "8@"
517
518
SlotReward15Text:
519
db "15@"
520
521
NotThisTimeText:
522
text_far _NotThisTimeText
523
text_end
524
525
; compares the slot machine tiles at bc, de, and hl
526
SlotMachine_CheckForMatch:
527
ld a, [de]
528
cp [hl]
529
ret nz
530
ld a, [bc]
531
cp [hl]
532
ret
533
534
SlotMachine_GetWheel3Tiles:
535
ld de, wSlotMachineWheel3BottomTile
536
ld hl, SlotMachineWheel3
537
ld a, [wSlotMachineWheel3Offset]
538
call SlotMachine_GetWheelTiles
539
540
SlotMachine_GetWheel2Tiles:
541
ld de, wSlotMachineWheel2BottomTile
542
ld hl, SlotMachineWheel2
543
ld a, [wSlotMachineWheel2Offset]
544
call SlotMachine_GetWheelTiles
545
546
SlotMachine_GetWheel1Tiles:
547
ld de, wSlotMachineWheel1BottomTile
548
ld hl, SlotMachineWheel1
549
ld a, [wSlotMachineWheel1Offset]
550
551
SlotMachine_GetWheelTiles:
552
ld c, a
553
ld b, 0
554
add hl, bc
555
ld c, 3
556
.loop
557
ld a, [hli]
558
ld [de], a
559
inc de
560
inc hl
561
dec c
562
jr nz, .loop
563
ret
564
565
SlotReward8Func:
566
ld hl, wSlotMachineAllowMatchesCounter
567
ld a, [hl]
568
and a
569
jr z, .skip
570
dec [hl]
571
.skip
572
ld b, $2
573
ld de, 8
574
ret
575
576
SlotReward15Func:
577
ld hl, wSlotMachineAllowMatchesCounter
578
ld a, [hl]
579
and a
580
jr z, .skip
581
dec [hl]
582
.skip
583
ld b, $4
584
ld de, 15
585
ret
586
587
SlotReward100Func:
588
ld a, SFX_GET_KEY_ITEM
589
call PlaySound
590
xor a
591
ld [wSlotMachineFlags], a
592
ld b, $8
593
ld de, 100
594
ret
595
596
SlotReward300Func:
597
ld hl, YeahText
598
call PrintText
599
ld a, SFX_GET_ITEM_2
600
call PlaySound
601
call Random
602
cp $80
603
ld a, 0
604
jr c, .skip
605
ld [wSlotMachineFlags], a
606
.skip
607
ld [wSlotMachineAllowMatchesCounter], a
608
ld b, $14
609
ld de, 300
610
ret
611
612
YeahText:
613
text_far _YeahText
614
text_pause
615
text_end
616
617
SlotMachine_PrintWinningSymbol:
618
; prints winning symbol and down arrow in text box
619
hlcoord 2, 14
620
ld a, [wSlotMachineWinningSymbol]
621
add $25
622
ld [hli], a
623
inc a
624
ld [hld], a
625
inc a
626
ld de, -SCREEN_WIDTH
627
add hl, de
628
ld [hli], a
629
inc a
630
ld [hl], a
631
hlcoord 18, 16
632
ld [hl], "▼"
633
ret
634
635
SlotMachine_SubtractBetFromPlayerCoins:
636
ld hl, wTempCoins2 + 1
637
ld a, [wSlotMachineBet]
638
ld [hld], a
639
xor a
640
ld [hli], a
641
ld de, wPlayerCoins + 1
642
ld c, $2
643
predef SubBCDPredef
644
645
SlotMachine_PrintCreditCoins:
646
hlcoord 5, 1
647
ld de, wPlayerCoins
648
ld c, 2
649
jp PrintBCDNumber
650
651
SlotMachine_PrintPayoutCoins:
652
hlcoord 11, 1
653
ld de, wPayoutCoins
654
lb bc, LEADING_ZEROES | 2, 4 ; 2 bytes, 4 digits
655
jp PrintNumber
656
657
SlotMachine_PayCoinsToPlayer:
658
ld a, TRUE
659
ld [wMuteAudioAndPauseMusic], a
660
call WaitForSoundToFinish
661
662
; Put 1 in the temp coins variable. This value is added to the player's coins
663
; repeatedly so the player can watch the value go up 1 coin at a time.
664
ld hl, wTempCoins1
665
xor a
666
ld [hli], a
667
inc a
668
ld [hl], a
669
670
ld a, 5
671
ld [wAnimCounter], a
672
673
; Subtract 1 from the payout amount and add 1 to the player's coins each
674
; iteration until the payout amount reaches 0.
675
.loop
676
ld a, [wPayoutCoins + 1]
677
ld l, a
678
ld a, [wPayoutCoins]
679
ld h, a
680
or l
681
ret z
682
ld de, -1
683
add hl, de
684
ld a, l
685
ld [wPayoutCoins + 1], a
686
ld a, h
687
ld [wPayoutCoins], a
688
ld hl, wTempCoins1 + 1
689
ld de, wPlayerCoins + 1
690
ld c, $2
691
predef AddBCDPredef
692
call SlotMachine_PrintCreditCoins
693
call SlotMachine_PrintPayoutCoins
694
ld a, SFX_SLOTS_REWARD
695
call PlaySound
696
ld a, [wAnimCounter]
697
dec a
698
jr nz, .skip1
699
ldh a, [rOBP0]
700
xor $40 ; make the slot wheel symbols flash
701
ldh [rOBP0], a
702
ld a, 5
703
.skip1
704
ld [wAnimCounter], a
705
ld a, [wSlotMachineWinningSymbol]
706
cp HIGH(SLOTSBAR) + 1
707
ld c, 8
708
jr nc, .skip2
709
srl c ; c = 4 (make the the coins transfer faster if the symbol was 7 or bar)
710
.skip2
711
call DelayFrames
712
jr .loop
713
714
SlotMachine_PutOutLitBalls:
715
ld a, $23
716
ld [wNewSlotMachineBallTile], a
717
jr SlotMachine_UpdateThreeCoinBallTiles
718
719
SlotMachine_LightBalls:
720
ld a, $14
721
ld [wNewSlotMachineBallTile], a
722
ld a, [wSlotMachineBet]
723
dec a
724
jr z, SlotMachine_UpdateOneCoinBallTiles
725
dec a
726
jr z, SlotMachine_UpdateTwoCoinBallTiles
727
728
SlotMachine_UpdateThreeCoinBallTiles:
729
hlcoord 3, 2
730
call SlotMachine_UpdateBallTiles
731
hlcoord 3, 10
732
call SlotMachine_UpdateBallTiles
733
734
SlotMachine_UpdateTwoCoinBallTiles:
735
hlcoord 3, 4
736
call SlotMachine_UpdateBallTiles
737
hlcoord 3, 8
738
call SlotMachine_UpdateBallTiles
739
740
SlotMachine_UpdateOneCoinBallTiles:
741
hlcoord 3, 6
742
743
SlotMachine_UpdateBallTiles:
744
ld a, [wNewSlotMachineBallTile]
745
ld [hl], a
746
ld bc, 13
747
add hl, bc
748
ld [hl], a
749
ld bc, 7
750
add hl, bc
751
inc a
752
ld [hl], a
753
ld bc, 13
754
add hl, bc
755
ld [hl], a
756
ret
757
758
SlotMachine_AnimWheel1:
759
ld bc, SlotMachineWheel1
760
ld de, wSlotMachineWheel1Offset
761
ld hl, wShadowOAMSprite00
762
ld a, $30
763
ld [wBaseCoordX], a
764
jr SlotMachine_AnimWheel
765
766
SlotMachine_AnimWheel2:
767
ld bc, SlotMachineWheel2
768
ld de, wSlotMachineWheel2Offset
769
ld hl, wShadowOAMSprite12
770
ld a, $50
771
ld [wBaseCoordX], a
772
jr SlotMachine_AnimWheel
773
774
SlotMachine_AnimWheel3:
775
ld bc, SlotMachineWheel3
776
ld de, wSlotMachineWheel3Offset
777
ld hl, wShadowOAMSprite24
778
ld a, $70
779
ld [wBaseCoordX], a
780
781
SlotMachine_AnimWheel:
782
ld a, $58
783
ld [wBaseCoordY], a
784
push de
785
ld a, [de]
786
ld d, b
787
add c
788
ld e, a
789
jr nc, .loop
790
inc d
791
.loop
792
ld a, [wBaseCoordY]
793
ld [hli], a
794
ld a, [wBaseCoordX]
795
ld [hli], a
796
ld a, [de]
797
ld [hli], a
798
ld a, $80
799
ld [hli], a
800
ld a, [wBaseCoordY]
801
ld [hli], a
802
ld a, [wBaseCoordX]
803
add $8
804
ld [hli], a
805
ld a, [de]
806
inc a
807
ld [hli], a
808
ld a, $80
809
ld [hli], a
810
inc de
811
ld a, [wBaseCoordY]
812
sub $8
813
ld [wBaseCoordY], a
814
cp $28
815
jr nz, .loop
816
pop de
817
ld a, [de]
818
inc a ; advance the offset so that the wheel animates
819
cp 30
820
jr nz, .skip
821
xor a ; wrap around to 0 when the offset reaches 30
822
.skip
823
ld [de], a
824
ret
825
826
SlotMachine_HandleInputWhileWheelsSpin:
827
call DelayFrame
828
call JoypadLowSensitivity
829
ldh a, [hJoy5]
830
and PAD_A
831
ret z
832
ld hl, wStoppingWhichSlotMachineWheel
833
ld a, [hl]
834
dec a
835
ld de, wSlotMachineWheel1SlipCounter
836
jr z, .skip
837
dec a
838
ld de, wSlotMachineWheel2SlipCounter
839
jr z, .skip
840
.loop
841
inc [hl]
842
ld a, SFX_SLOTS_STOP_WHEEL
843
jp PlaySound
844
.skip
845
ld a, [de]
846
and a
847
ret nz
848
jr .loop
849
850
LoadSlotMachineTiles:
851
call DisableLCD
852
ld hl, SlotMachineTiles2
853
ld de, vChars0
854
ld bc, $1c tiles ; should be SlotMachineTiles2End - SlotMachineTiles2, or $18 tiles
855
ld a, BANK(SlotMachineTiles2)
856
call FarCopyData2
857
ld hl, SlotMachineTiles1
858
ld de, vChars2
859
ld bc, SlotMachineTiles1End - SlotMachineTiles1
860
ld a, BANK(SlotMachineTiles1)
861
call FarCopyData2
862
ld hl, SlotMachineTiles2
863
ld de, vChars2 tile $25
864
ld bc, $1c tiles ; should be SlotMachineTiles2End - SlotMachineTiles2, or $18 tiles
865
ld a, BANK(SlotMachineTiles2)
866
call FarCopyData2
867
ld hl, SlotMachineMap
868
decoord 0, 0
869
ld bc, SlotMachineMapEnd - SlotMachineMap
870
call CopyData
871
call EnableLCD
872
ld hl, wSlotMachineWheel1Offset
873
ld a, $1c
874
ld [hli], a
875
ld [hli], a
876
ld [hl], a
877
call SlotMachine_AnimWheel1
878
call SlotMachine_AnimWheel2
879
jp SlotMachine_AnimWheel3
880
881
SlotMachineMap:
882
INCBIN "gfx/slots/slots.tilemap"
883
SlotMachineMapEnd:
884
885
INCLUDE "data/events/slot_machine_wheels.asm"
886
887
SlotMachineTiles1:
888
IF DEF(_RED)
889
INCBIN "gfx/slots/red_slots_1.2bpp"
890
ENDC
891
IF DEF(_BLUE)
892
INCBIN "gfx/slots/blue_slots_1.2bpp"
893
ENDC
894
SlotMachineTiles1End:
895
896