diff options
author | Zumi <13794376+ZoomTen@users.noreply.github.com> | 2021-01-26 10:29:07 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-25 22:29:07 -0500 |
commit | d9f52a57a604cc1204f6077e21d75e04cb954672 (patch) | |
tree | d1cfa2e3003c1bac1b74a3a289e01421dfcc387d | |
parent | 735e9f09a2bfc6c32ed596906c07ec501fb05070 (diff) |
Disassemble RTC setup dialog and slot machine minigame (bank $24) (#87)
Also identify SFX and cry pointers
28 files changed, 3077 insertions, 61 deletions
diff --git a/audio/cries.asm b/audio/cries.asm index e3a7a5d..89eef76 100644 --- a/audio/cries.asm +++ b/audio/cries.asm @@ -1,5 +1,46 @@ INCLUDE "constants.asm" -SECTION "audio/cries.asm", ROMX +SECTION "audio/cries.asm@Cry Header Pointers", ROMX +CryHeaderPointers:: + dba CryHeader_f17c5 + dba CryHeader_f17ce + dba CryHeader_f17d7 + dba CryHeader_f17e0 + dba CryHeader_f17e9 + dba CryHeader_f17f2 + dba CryHeader_f17fb + dba CryHeader_f1804 + dba CryHeader_f180d + dba CryHeader_f1816 + dba CryHeader_f181f + dba CryHeader_f1828 + dba CryHeader_f1831 + dba CryHeader_f183a + dba CryHeader_f1843 + dba CryHeader_f184c + dba CryHeader_f1855 + dba CryHeader_f185e + dba CryHeader_f1867 + dba CryHeader_f1870 + dba CryHeader_f1879 + dba CryHeader_f1882 + dba CryHeader_f188b + dba CryHeader_f1894 + dba CryHeader_f189d + dba CryHeader_f18a6 + dba CryHeader_f18af + dba CryHeader_f18b8 + dba CryHeader_f18c1 + dba CryHeader_f18ca + dba CryHeader_f18d3 + dba CryHeader_f18dc + dba CryHeader_f18e5 + dba CryHeader_f18ee + dba CryHeader_f18f7 + dba CryHeader_f1900 + dba CryHeader_f1909 + dba CryHeader_f1912 + +SECTION "audio/cries.asm@Cries", ROMX CryHeaders:: ; TODO: Rip the data, then INCBIN it diff --git a/audio/sfx.asm b/audio/sfx.asm new file mode 100644 index 0000000..2569499 --- /dev/null +++ b/audio/sfx.asm @@ -0,0 +1,112 @@ +INCLUDE "constants.asm" + +SECTION "audio/sfx.asm@SFX Pointers", ROMX +SFXPointers:: + dba Sfx_01 + dba Sfx_02 + dba Sfx_03 + dba Sfx_04 + dba Sfx_05 + dba Sfx_06 + dba Sfx_07 + dba Sfx_08 + dba Sfx_09 + dba Sfx_0a + dba Sfx_0b + dba Sfx_0c + dba Sfx_0d + dba Sfx_0e + dba Sfx_0f + dba Sfx_10 + dba Sfx_11 + dba Sfx_12 + dba Sfx_13 + dba Sfx_14 + dba Sfx_15 + dba Sfx_16 + dba Sfx_17 + dba Sfx_18 + dba Sfx_19 + dba Sfx_1a + dba Sfx_1b + dba Sfx_1c + dba Sfx_1d + dba Sfx_1e + dba Sfx_1f + dba Sfx_20 + dba Sfx_21 + dba Sfx_22 + dba Sfx_23 + dba Sfx_24 + dba Sfx_25 + dba Sfx_26 + dba Sfx_27 + dba Sfx_28 + dba Sfx_29 + dba Sfx_2a + dba Sfx_2b + dba Sfx_2c + dba Sfx_2d + dba Sfx_2e + dba Sfx_2f + dba Sfx_30 + dba Sfx_31 + dba Sfx_32 + dba Sfx_33 + dba Sfx_34 + dba Sfx_35 + dba Sfx_36 + dba Sfx_37 + dba Sfx_38 + dba Sfx_39 + dba Sfx_3a + dba Sfx_3b + dba Sfx_3c + dba Sfx_3d + dba Sfx_3e + dba Sfx_3f + dba Sfx_40 + dba Sfx_41 + dba Sfx_42 + dba Sfx_43 + dba Sfx_44 + dba Sfx_45 + dba Sfx_46 + dba Sfx_47 + dba Sfx_48 + dba Sfx_49 + dba Sfx_4a + dba Sfx_4b + dba Sfx_4c + dba Sfx_4d + dba Sfx_4e + dba Sfx_4f + dba Sfx_50 + dba Sfx_51 + dba Sfx_52 + dba Sfx_53 + dba Sfx_54 + dba Sfx_55 + dba Sfx_56 + dba Sfx_57 + dba Sfx_58 + dba Sfx_59 + dba Sfx_5a + dba Sfx_5b + dba Sfx_5c + dba Sfx_5d + dba Sfx_5e + dba Sfx_5f + dba Sfx_60 + dba Sfx_61 + dba Sfx_62 + dba Sfx_63 + dba Sfx_64 + dba Sfx_65 + dba Sfx_66 + dba Sfx_67 + dba Sfx_68 + dba Sfx_69 + dba Sfx_6a + dba Sfx_6b + dba Sfx_6c diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 0cc7ce3..f1bbe9e 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -5,3 +5,6 @@ TRUE EQU 1 ; RedrawRowOrColumn functions REDRAW_COL EQU 1 REDRAW_ROW EQU 2 + +; significant money values +MAX_COINS EQU 9999 diff --git a/constants/sfx_constants.asm b/constants/sfx_constants.asm index 1540c87..fcd1edf 100644 --- a/constants/sfx_constants.asm +++ b/constants/sfx_constants.asm @@ -1,6 +1,28 @@ ; TODO SFX_BOOT_PC EQU $0A +SFX_POTION EQU $01 +SFX_FULL_HEAL EQU $02 +SFX_MENU EQU $03 +SFX_READ_TEXT EQU $04 +SFX_READ_TEXT_2 EQU $05 +SFX_ESCAPE_ROPE EQU $0B ; player shrink +SFX_WRONG EQU $14 +SFX_SWITCH_POKEMON EQU $1B +SFX_POKEFLUTE EQU $21 +SFX_POKEDEX_REGISTRATION EQU $27 +SFX_TITLE_ENTRANCE EQU $2D SFX_PAY_DAY EQU $30 SFX_GAME_FREAK_LOGO_RG EQU $31 + +; R/G/B/Y fanfares +SFX_GET_ITEM_RG EQU $63 +SFX_UNUSED_FANFARE_1 EQU $64 +SFX_POKEDEX_EVALUATION_RG EQU $65 +SFX_LEVEL_UP_RG EQU $66 +SFX_EVOLUTION_COMPLETE_RG EQU $67 +SFX_GET_KEY_ITEM_RG EQU $68 +SFX_UNUSED_FANFARE_2 EQU $69 +SFX_CAUGHT_POKEMON_RG EQU $6A +SFX_UNUSED_FANFARE_3 EQU $6B diff --git a/constants/sprite_anim_constants.asm b/constants/sprite_anim_constants.asm index 3f6644c..9e30dd9 100755 --- a/constants/sprite_anim_constants.asm +++ b/constants/sprite_anim_constants.asm @@ -30,6 +30,8 @@ NUM_SPRITEANIMDICT_ENTRIES EQU 10 ; SpriteAnimSeqData indexes SPRITE_ANIM_INDEX_08 EQU $08 +SPRITE_ANIM_INDEX_20 EQU $20 + SPRITE_ANIM_INDEX_GS_INTRO_BUBBLE EQU $21 SPRITE_ANIM_INDEX_GS_INTRO_OMANYTE EQU $22 SPRITE_ANIM_INDEX_GS_INTRO_MAGIKARP EQU $23 @@ -38,6 +40,7 @@ SPRITE_ANIM_INDEX_GS_INTRO_LAPRAS EQU $25 SPRITE_ANIM_INDEX_GS_INTRO_NOTE EQU $26 SPRITE_ANIM_INDEX_GS_INTRO_SMALLER_NOTE EQU $27 SPRITE_ANIM_INDEX_GS_INTRO_JIGGLYPUFF EQU $28 +SPRITE_ANIM_INDEX_28 EQU $28 SPRITE_ANIM_INDEX_GS_INTRO_PIKACHU EQU $29 SPRITE_ANIM_INDEX_GS_INTRO_PIKACHU_TAIL EQU $2a SPRITE_ANIM_INDEX_GS_INTRO_FIREBALL EQU $2b @@ -55,8 +58,12 @@ SPRITE_ANIM_INDEX_39 EQU $39 SPRITE_ANIM_INDEX_GAMEFREAK_LOGO EQU $3a SPRITE_ANIM_INDEX_GS_INTRO_STAR EQU $3b SPRITE_ANIM_INDEX_GS_INTRO_SPARKLE EQU $3c +SPRITE_ANIM_INDEX_SLOTS_GOLEM EQU $3d +SPRITE_ANIM_INDEX_SLOTS_CHANSEY EQU $3e +SPRITE_ANIM_INDEX_SLOTS_EGG EQU $3f + SPRITE_ANIM_INDEX_40 EQU $40 SPRITE_ANIM_INDEX_41 EQU $41 + SPRITE_ANIM_INDEX_TRAINERGEAR_POINTER EQU $44 SPRITE_ANIM_INDEX_RADIO_TUNING_KNOB EQU $4b - diff --git a/engine/dumps/bank01.asm b/engine/dumps/bank01.asm index a420111..01f36da 100755 --- a/engine/dumps/bank01.asm +++ b/engine/dumps/bank01.asm @@ -3258,7 +3258,7 @@ Text6653: text_exit start_asm push de - ld de, $001b + ld de, SFX_SWITCH_POKEMON call PlaySFX pop de ld hl, Text6661 @@ -3727,7 +3727,7 @@ Function78f0: jr z, .sub_7956 .sub_7924 push de - ld de, $0005 + ld de, SFX_READ_TEXT_2 call PlaySFX pop de pop af diff --git a/engine/dumps/bank03.asm b/engine/dumps/bank03.asm index 0b507ce..519d2a1 100755 --- a/engine/dumps/bank03.asm +++ b/engine/dumps/bank03.asm @@ -3545,7 +3545,7 @@ Functioned00: ld a, $01 ld [wcab9], a push de - ld de, $0002 + ld de, SFX_FULL_HEAL call WaitPlaySFX call WaitSFX pop de @@ -3606,7 +3606,7 @@ Functioned37: ld de, wHPBarTempHP ld bc, $000a call CopyBytes - ld de, $0002 + ld de, SFX_FULL_HEAL call WaitPlaySFX ld hl, Textedcb call PrintText @@ -3839,7 +3839,7 @@ Functionef17: .sub_ef50 call Functionf7a2 push de - ld de, $0002 + ld de, SFX_FULL_HEAL call WaitPlaySFX pop de call Functionf0d8 @@ -4016,7 +4016,7 @@ Functionf0af: Functionf0b0: push de - ld de, $0001 + ld de, SFX_POTION call WaitPlaySFX pop de ld a, [wWhichPokemon] @@ -4522,7 +4522,7 @@ Functionf3fd: and a jr nz, .sub_f410 push de - ld de, $0021 + ld de, SFX_POKEFLUTE call WaitPlaySFX call WaitSFX pop de @@ -4543,7 +4543,7 @@ Textf424: line "@" Textf42f: - deciram wd15b, 2, 4 + deciram wCoins, 2, 4 text "まい" prompt @@ -4627,7 +4627,7 @@ Functionf49f: call Functionfab4 ld hl, Textf8c6 call PrintText - ld de, $0002 + ld de, SFX_FULL_HEAL call WaitPlaySFX ld c, $50 call DelayFrames @@ -4718,7 +4718,7 @@ Functionf550: ld bc, $0004 call CopyBytes .sub_f572 - ld de, $0002 + ld de, SFX_FULL_HEAL call WaitPlaySFX ld hl, Textf64c call PrintText @@ -4914,7 +4914,7 @@ Functionf678: ld a, c and a jr nz, .sub_f70c - ld de, $0014 + ld de, SFX_WRONG call WaitPlaySFX ld hl, Textf768 call PrintText @@ -4972,7 +4972,7 @@ Textf784: Functionf793: ld hl, Textf8c6 call PrintText - ld de, $0002 + ld de, SFX_FULL_HEAL call WaitPlaySFX call TextboxWaitPressAorB_BlinkCursor diff --git a/engine/dumps/bank23.asm b/engine/dumps/bank23.asm new file mode 100644 index 0000000..18302e8 --- /dev/null +++ b/engine/dumps/bank23.asm @@ -0,0 +1,29 @@ +INCLUDE "constants.asm" + +SECTION "engine/dumps/bank23.asm@AnimateTilesetImpl", ROMX + +AnimateTilesetImpl: + ldh a, [hMapAnims] + and a + ret z + + ld a, [wTilesetAnim] + ld e, a + ld a, [wTilesetAnim+1] + ld d, a + ldh a, [hTileAnimFrame] + ld l, a + inc a + ldh [hTileAnimFrame], a + ld h, 0 + add hl, hl + add hl, hl + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + inc hl + ld a, [hli] + ld h, [hl] + ld l, a + jp hl diff --git a/engine/games/slot_machine_game.asm b/engine/games/slot_machine_game.asm new file mode 100644 index 0000000..8b3e230 --- /dev/null +++ b/engine/games/slot_machine_game.asm @@ -0,0 +1,2214 @@ +INCLUDE "constants.asm" + +SECTION "engine/games/slot_machine_game.asm", ROMX + +SLOTS_NO_BIAS EQU -1 +SLOTS_NO_MATCH EQU -1 + +SLOTS_STARTING_COINS EQU 256 + +SLOTS_GFX_BLANK_TILE EQU $17 +SLOTS_GFX_ILLUMINATED_LIGHT EQU $14 +SLOTS_GFX_DEILLUMINATED_LIGHT EQU $23 +SLOTS_GFX_SEVEN_TILE_1 EQU $25 +SLOTS_GFX_SEVEN_TILE_2 EQU $41 + +SLOTS_SEVEN EQU $00 +SLOTS_POKEBALL EQU $04 +SLOTS_CHERRY EQU $08 +SLOTS_PIKACHU EQU $0c +SLOTS_SQUIRTLE EQU $10 +SLOTS_STARYU EQU $14 + +REEL_SIZE EQU 15 + +; SlotsJumptable constants + const_def + const SLOTS_INIT + const SLOTS_BET_AND_START + const SLOTS_WAIT_START + const SLOTS_WAIT_REEL1 + const SLOTS_WAIT_STOP_REEL1 + const SLOTS_WAIT_REEL2 + const SLOTS_WAIT_STOP_REEL2 + const SLOTS_WAIT_REEL3 + const SLOTS_WAIT_STOP_REEL3 + const SLOTS_NEXT_09 + const SLOTS_NEXT_0A + const SLOTS_NEXT_0B + const SLOTS_FLASH_IF_WIN + const SLOTS_FLASH_SCREEN + const SLOTS_GIVE_EARNED_COINS + const SLOTS_PAYOUT_TEXT_AND_ANIM + const SLOTS_PAYOUT_ANIM + const SLOTS_RESTART_OR_QUIT + const SLOTS_QUIT +SLOTS_END_LOOP_F EQU 7 + +; ReelActionJumptable constants + const_def + const REEL_ACTION_DO_NOTHING + const REEL_ACTION_STOP_REEL_IGNORE_JOYPAD + const REEL_ACTION_QUADRUPLE_RATE + const REEL_ACTION_DOUBLE_RATE + const REEL_ACTION_NORMAL_RATE + const REEL_ACTION_HALF_RATE + const REEL_ACTION_QUARTER_RATE + const REEL_ACTION_STOP_REEL1 + const REEL_ACTION_STOP_REEL2 + const REEL_ACTION_STOP_REEL3 + const REEL_ACTION_SET_UP_REEL2_SKIP_TO_7 + const REEL_ACTION_WAIT_REEL2_SKIP_TO_7 + const REEL_ACTION_FAST_SPIN_REEL2_UNTIL_LINED_UP_7S + const REEL_ACTION_0D + const REEL_ACTION_CHECK_DROP_REEL + const REEL_ACTION_WAIT_DROP_REEL + const REEL_ACTION_START_SLOW_ADVANCE_REEL3 + const REEL_ACTION_WAIT_SLOW_ADVANCE_REEL3 + const REEL_ACTION_INIT_GOLEM + const REEL_ACTION_WAIT_GOLEM + const REEL_ACTION_END_GOLEM + const REEL_ACTION_INIT_CHANSEY + const REEL_ACTION_WAIT_CHANSEY + const REEL_ACTION_WAIT_EGG + const REEL_ACTION_DROP_REEL + +; Constants for slot_reel offsets (see macros/wram.asm) +REEL_ACTION EQUS "(wReel1ReelAction - wReel1)" +REEL_TILEMAP_ADDR EQUS "(wReel1TilemapAddr - wReel1)" +REEL_POSITION EQUS "(wReel1Position - wReel1)" +REEL_SPIN_DISTANCE EQUS "(wReel1SpinDistance - wReel1)" +REEL_SPIN_RATE EQUS "(wReel1SpinRate - wReel1)" +REEL_OAM_ADDR EQUS "(wReel1OAMAddr - wReel1)" +REEL_X_COORD EQUS "(wReel1XCoord - wReel1)" +REEL_MANIP_COUNTER EQUS "(wReel1ManipCounter - wReel1)" +REEL_MANIP_DELAY EQUS "(wReel1ManipDelay - wReel1)" +REEL_FIELD_0B EQUS "(wReel1Field0b - wReel1)" +REEL_STOP_DELAY EQUS "(wReel1StopDelay - wReel1)" + +SlotMachineGame: +; Always start off with 256 coins + ld hl, wCoins + ld [hl], HIGH(SLOTS_STARTING_COINS) + inc hl + ld [hl], LOW(SLOTS_STARTING_COINS) + + ld hl, wce5f + set 4, [hl] + call SlotMachineGame_Init + call DelayFrame + +.loop + call SlotsLoop + jr nc, .loop + ld hl, wce5f + res 4, [hl] + ld hl, rLCDC + res rLCDC_SPRITE_SIZE, [hl] + ret + +SlotMachineGame_Init: + call DisableLCD + ld b, SGB_SLOT_MACHINE + call GetSGBLayout + callab InitEffectObject + ld hl, wSlots + ld bc, wSlotsDataEnd - wSlots + xor a + call ByteFill + + ld hl, SlotMachine2GFX + ld de, vSprites + ld bc, $80 tiles + ld a, BANK(SlotMachine2GFX) + call FarCopyData + + ld hl, SlotMachineGFX + ld de, vChars2 + ld bc, $25 tiles + ld a, BANK(SlotMachineGFX) + call FarCopyData + + ld hl, SlotMachine2GFX + ld de, vChars2 tile $25 + ld bc, $1c tiles + ld a, BANK(SlotMachine2GFX) + call FarCopyData + + ld hl, SlotMachine3GFX + ld de, vChars2 tile $41 + ld bc, $1c tiles + ld a, $24 + call FarCopyData + + ld hl, SlotsTilemap + decoord 0, 0 + ld bc, SCREEN_WIDTH * 12 +.init_tilemap + ld a, [hli] + ld [de], a + inc de + dec bc + ld a, c + or b + jr nz, .init_tilemap + + ld hl, rLCDC + set 2, [hl] + call EnableLCD + + xor a + ld hl, wSlots + ld c, wSlotsEnd - wSlots +.clear_ram + ld [hli], a + dec c + jr nz, .clear_ram + + call Slots_InitReelTiles + + ld a, %11100100 + ld [rBGP], a + ld [rOBP0], a + + ld a, %11000000 + ld [rOBP1], a + + ld a, SPRITE_ANIM_INDEX_28 + ld hl, wSpriteAnimDict + ld [hli], a + ld [hl], SPRITE_ANIM_INDEX_20 + + xor a + ld [wJumptableIndex], a + ld a, SLOTS_NO_BIAS + ld [wSlotBias], a + ret + +SlotsLoop: + ld a, [wJumptableIndex] + bit SLOTS_END_LOOP_F, a + jr nz, .done + call SlotsJumptable + call Slots_SpinReels + ld a, $60 + ld [wc4bd], a + callab DoNextFrameForFirst16Sprites + call Slots_PrintCoinsAndPayout + call Slots_FlashPaletteOnMatchingSevens + call Slots_AnimateReelSpritesAfterSpin + call Slots_DisplayBiasValue + call DelayFrame + and a + ret +.done + scf + ret + +Slots_FlashPaletteOnMatchingSevens: + ld a, [wReel1ReelAction] + and a + ret nz + ld a, [wReel2ReelAction] + and a + ret nz + ld a, [wFirstTwoReelsMatchingSevens] + and a + jr nz, .matching_sevens + ld a, %11100100 + ld [rBGP], a + ret + +.matching_sevens + ld a, [wVBlankJoyFrameCounter] + and 7 + ret nz + ld a, [rBGP] + xor %1100 + ld [rBGP], a + ret + +Slots_PrintCoinsAndPayout: + hlcoord 5, 1 + ld de, wCoins + lb bc, PRINTNUM_LEADINGZEROS | 2, 4 + call PrintNumber + hlcoord 11, 1 + ld de, wPayout + lb bc, PRINTNUM_LEADINGZEROS | 2, 4 + call PrintNumber + ret + +Slots_DisplayBiasValue: +; debug feature + ld a, [wSlotBias] + add 0 + daa + ld e, a + +; print second digit + and $f + add "0" + hlcoord 1, 0 + ld [hl], a + +; print first digit + ld a, e + swap a + and $F + add "0" + hlcoord 0, 0 + ld [hl], a + ret + +Slots_AnimateReelSpritesAfterSpin: + ld hl, wcb61 + ld a, [hl] + inc [hl] + and 7 + ret nz + hlcoord 5, 4 + ld a, [hl] + cp SLOTS_GFX_BLANK_TILE + call nz, .AnimateReelSprite + hlcoord 9, 4 + ld a, [hl] + cp SLOTS_GFX_BLANK_TILE + call nz, .AnimateReelSprite + hlcoord 13, 4 + ld a, [hl] + cp SLOTS_GFX_BLANK_TILE + call nz, .AnimateReelSprite + ret + +.AnimateReelSprite: + cp SLOTS_GFX_SEVEN_TILE_2 + jr c, .seven_tile + ld b, %11100100 + jr .continue +.seven_tile + ld b, $1C +.continue + ld de, $14 + ld c, 6 +.loop + ld a, [hl] + add b + ld [hli], a + ld a, [hl] + add b + ld [hld], a + add hl, de + dec c + jr nz, .loop + ret + +SlotsJumptable: + jumptable .Jumptable, wJumptableIndex + +.Jumptable: + dw SlotsAction_Init + dw SlotsAction_BetAndStart + dw SlotsAction_WaitStart + dw SlotsAction_WaitReel1 + dw SlotsAction_WaitStopReel1 + dw SlotsAction_WaitReel2 + dw SlotsAction_WaitStopReel2 + dw SlotsAction_WaitReel3 + dw SlotsAction_WaitStopReel3 + dw SlotsAction_Next + dw SlotsAction_Next + dw SlotsAction_Next + dw SlotsAction_FlashIfWin + dw SlotsAction_FlashScreen + dw SlotsAction_GiveEarnedCoins + dw SlotsAction_PayoutTextAndAnim + dw SlotsAction_PayoutAnim + dw SlotsAction_RestartOrQuit + dw SlotsAction_Quit + +SlotsAction_Next: + ld hl, wJumptableIndex + inc [hl] + ret + +SlotsAction_Init: + call SlotsAction_Next + xor a + ld [wFirstTwoReelsMatching], a + ld [wFirstTwoReelsMatchingSevens], a + ld a, SLOTS_NO_MATCH + ld [wSlotMatched], a + ret + +SlotsAction_BetAndStart: + call Slots_AskBet + jr nc, .proceed + ld a, SLOTS_QUIT + ld [wJumptableIndex], a + ret + +.proceed + call SlotsAction_Next + call Slots_IlluminateBetLights + call Slots_InitBias + ld a, 32 + ld [wSlotsDelay], a + ld a, REEL_ACTION_NORMAL_RATE + ld [wReel1ReelAction], a + ld [wReel2ReelAction], a + ld [wReel3ReelAction], a + ld a, 4 + ld [wReel1ManipCounter], a + ld [wReel2ManipCounter], a + ld [wReel3ManipCounter], a + ret + +SlotsAction_WaitStart: + ld hl, wSlotsDelay + ld a, [hl] + and a + jr z, .proceed + dec [hl] + ret + +.proceed + call SlotsAction_Next + xor a + ldh [hJoypadSum], a + ret + +SlotsAction_WaitReel1: + ld hl, hJoypadSum + ld a, [hl] + and A_BUTTON + ret z + call SlotsAction_Next + call Slots_StopReel1 + ld [wReel1ReelAction], a + +SlotsAction_WaitStopReel1: + ld a, [wReel1ReelAction] + cp REEL_ACTION_DO_NOTHING + ret nz + ld bc, wReel1 + ld de, wReel1Stopped + call Slots_LoadReelState + call SlotsAction_Next + xor a + ldh [hJoypadSum], a + +SlotsAction_WaitReel2: + ld hl, hJoypadSum + ld a, [hl] + and A_BUTTON + ret z + call SlotsAction_Next + call Slots_StopReel2 + ld [wReel2ReelAction], a + +SlotsAction_WaitStopReel2: + ld a, [wReel2ReelAction] + cp REEL_ACTION_DO_NOTHING + ret nz + ld bc, wReel2 + ld de, wReel2Stopped + call Slots_LoadReelState + call SlotsAction_Next + xor a + ldh [hJoypadSum], a + +SlotsAction_WaitReel3: + ld hl, hJoypadSum + ld a, [hl] + and A_BUTTON + ret z + call SlotsAction_Next + call Slots_StopReel3 + ld [wReel3ReelAction], a + +SlotsAction_WaitStopReel3: + ld a, [wReel3ReelAction] + cp REEL_ACTION_DO_NOTHING + ret nz + ld bc, wReel3 + ld de, wReel3Stopped + call Slots_LoadReelState + call SlotsAction_Next + xor a + ldh [hJoypadSum], a + call Function90822 + call Function90805 + ret + +SlotsAction_FlashIfWin: + ld a, [wSlotMatched] + cp SLOTS_NO_MATCH + jr nz, .matched + call SlotsAction_Next + call SlotsAction_Next + ret + +.matched + call SlotsAction_Next + ld a, 16 + ld [wSlotsDelay], a + +SlotsAction_FlashScreen: + ld hl, wSlotsDelay + ld a, [hl] + and a + jr z, .done + dec [hl] + srl a + ret z + + ld a, [rOBP0] + xor $ff + ld [rOBP0], a + ret + +.done + ld a, %11100100 + ld [rOBP0], a + call SlotsAction_Next + ret + +SlotsAction_GiveEarnedCoins: + xor a + ld [wFirstTwoReelsMatching], a + ld [wFirstTwoReelsMatchingSevens], a + ld a, %11100100 + ld [rBGP], a + call Slots_GetPayout + xor a + ld [wSlotsDelay], a + call SlotsAction_Next + ret + +SlotsAction_PayoutTextAndAnim: + call Slots_PayoutText + call SlotsAction_Next + ld bc, wReel1ReelAction + call Function907c8 + ld bc, wReel2ReelAction + call Function907c8 + ld bc, wReel3ReelAction + call Function907c8 + call WaitBGMap + ld hl, wVirtualOAM + ld e, $60 + xor a +.loop + ld [hli], a + dec e + jr nz, .loop + +SlotsAction_PayoutAnim: + ld hl, wSlotsDelay + ld a, [hl] + inc [hl] + and $1 + ret z + ld hl, wPayout + ld a, [hli] + ld d, a + or [hl] + jr z, .done + ld e, [hl] + dec de + ld [hl], e + dec hl + ld [hl], d + ld hl, wCoins + ld d, [hl] + inc hl + ld e, [hl] + call Slots_CheckCoinCaseFull + jr c, .okay + inc de +.okay + ld [hl], e + dec hl + ld [hl], d + ld a, [wSlotsDelay] + and 7 + ret z + ld de, $2F + call PlaySFX + ret +.done + call SlotsAction_Next + call Function90822 + call Function90805 + ret + +SlotsAction_RestartOrQuit: + call Slots_DeilluminateBetLights + call TextboxWaitPressAorB_BlinkCursor + call Slots_AskPlayAgain + jr c, .exit_slots + ld a, SLOTS_INIT + ld [wJumptableIndex], a + ret + +.exit_slots + ld a, SLOTS_QUIT + ld [wJumptableIndex], a + ret + +SlotsAction_Quit: + ld hl, wJumptableIndex + set SLOTS_END_LOOP_F, [hl] + ret + +Slots_LoadReelState: + push de + call Slots_GetCurrentReelState + pop de + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + ret + +Slots_CheckCoinCaseFull: + ld a, d + cp HIGH(MAX_COINS) + jr c, .not_full + ld a, e + cp LOW(MAX_COINS) + jr c, .not_full + scf + ret + +.not_full + and a + ret + +Slots_GetCurrentReelState: + ld hl, REEL_POSITION + add hl, bc + ld a, [hl] + and a + jr nz, .okay + ld a, $f + +.okay + dec a + and $f + ld e, a + ld d, 0 + ld hl, REEL_TILEMAP_ADDR + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + add hl, de + ret + +Slots_StopReel1: + ld a, REEL_ACTION_STOP_REEL1 + ret + +Slots_StopReel2: + ld a, [wSlotBias] + and a + jr z, .skip + cp SLOTS_NO_BIAS + jr nz, .dont_jump +.skip + call .CheckReel1ForASeven + jr nz, .dont_jump + call Random + cp 31 percent + 1 + jr nc, .dont_jump + ld a, REEL_ACTION_SET_UP_REEL2_SKIP_TO_7 + ret + +.dont_jump + ld a, REEL_ACTION_STOP_REEL2 + ret + +.CheckReel1ForASeven: + ld a, [wReel1Stopped] + and a + ret z + ld a, [wReel1Stopped + 1] + and a + ret z + ld a, [wReel1Stopped + 2] + and a + ret + +Slots_StopReel3: + ld a, [wFirstTwoReelsMatching] + and a + jr z, .stop + ld a, [wFirstTwoReelsMatchingSevens] + and a + jr z, .stop + ld a, [wSlotBias] + and a + jr nz, .biased + call Random + cp 71 percent - 1 + jr nc, .stop + cp 47 percent + 1 + jr nc, .slow_advance + cp 24 percent - 1 + jr nc, .golem + ld a, REEL_ACTION_INIT_CHANSEY + ret +.biased + call Random + cp 63 percent + jr nc, .stop + cp 31 percent + 1 + jr nc, .slow_advance +.golem + ld a, REEL_ACTION_INIT_GOLEM + ret +.slow_advance + ld a, REEL_ACTION_START_SLOW_ADVANCE_REEL3 + ret +.stop + ld a, REEL_ACTION_STOP_REEL3 + ret + +Slots_InitReelTiles: + ld bc, wReel1 + ld hl, REEL_OAM_ADDR + add hl, bc + ld de, wVirtualOAM + ld [hl], e + inc hl + ld [hl], d + ld hl, REEL_TILEMAP_ADDR + add hl, bc + ld de, Slots_Reel1Tilemap + ld [hl], e + inc hl + ld [hl], d + ld hl, REEL_X_COORD + add hl, bc + ld [hl], 6 * TILE_WIDTH + call .OAM + + ld bc, wReel2 + ld hl, REEL_OAM_ADDR + add hl, bc + ld de, wVirtualOAMSprite08 + ld [hl], e + inc hl + ld [hl], d + ld hl, REEL_TILEMAP_ADDR + add hl, bc + ld de, Slots_Reel2Tilemap + ld [hl], e + inc hl + ld [hl], d + ld hl, REEL_X_COORD + add hl, bc + ld [hl], 10 * TILE_WIDTH + call .OAM + + ld bc, wReel3 + ld hl, REEL_OAM_ADDR + add hl, bc + ld de, wVirtualOAMSprite16 + ld [hl], e + inc hl + ld [hl], d + ld hl, REEL_TILEMAP_ADDR + add hl, bc + ld de, Slots_Reel3Tilemap + ld [hl], e + inc hl + ld [hl], d + ld hl, REEL_X_COORD + add hl, bc + ld [hl], 14 * TILE_WIDTH + call .OAM + ret + +.OAM: + ld hl, REEL_ACTION + add hl, bc + ld [hl], REEL_ACTION_DO_NOTHING + ld hl, REEL_POSITION + add hl, bc + ld [hl], REEL_SIZE - 1 + ld hl, REEL_SPIN_DISTANCE + add hl, bc + ld [hl], REEL_ACTION_DO_NOTHING + call Slots_UpdateReelPositionAndOAM + ret + +Slots_SpinReels: + ld bc, wReel1 + call .SpinReel + ld bc, wReel2 + call .SpinReel + ld bc, wReel3 + call .SpinReel + ret + +.SpinReel: + ld hl, REEL_SPIN_DISTANCE + add hl, bc + ld a, [hl] + and $f + jr nz, .skip + call ReelActionJumptable + +.skip + ld hl, REEL_SPIN_RATE + add hl, bc + ld a, [hl] + and a + ret z + ld d, a + ld hl, REEL_SPIN_DISTANCE + add hl, bc + add [hl] + ld [hl], a + and $f + jr z, Slots_UpdateReelPositionAndOAM + ld hl, REEL_OAM_ADDR + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld e, 8 +.loop + ld a, [hl] + add d + ld [hli], a + inc hl + inc hl + inc hl + dec e + jr nz, .loop + ret + +Slots_UpdateReelPositionAndOAM: + ld hl, REEL_X_COORD + add hl, bc + ld a, [hl] + ld [wCurReelXCoord], a + ld a, 10 * TILE_WIDTH + ld [wCurReelYCoord], a + ld hl, REEL_POSITION + add hl, bc + ld e, [hl] + ld d, 0 + ld hl, REEL_TILEMAP_ADDR + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + add hl, de + ld e, l + ld d, h + call Slots_LoadOAM + ld hl, REEL_POSITION + add hl, bc + ld a, [hl] + inc a + and $f + cp REEL_SIZE + jr nz, .load + xor a +.load + ld [hl], a + ret + +Slots_LoadOAM: + ld hl, REEL_OAM_ADDR + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a +.loop +; set y and x coordinates + ld a, [wCurReelYCoord] + ld [hli], a + ld a, [wCurReelXCoord] + ld [hli], a +; set tile ID + ld a, [de] + ld [hli], a +; set priority behind BG, no attributes beyond it + ld a, (1 << OAM_PRIORITY) + ld [hli], a +; next OAM + ld a, [wCurReelYCoord] + ld [hli], a + ld a, [wCurReelXCoord] + add 8 + ld [hli], a + ld a, [de] + inc a + inc a + ld [hli], a + ld a, (1 << OAM_PRIORITY) + ld [hli], a + inc de + ld a, [wCurReelYCoord] + sub 2 * TILE_WIDTH + ld [wCurReelYCoord], a + cp 2 * TILE_WIDTH + jr nz, .loop + ret + +ReelActionJumptable: + ld hl, REEL_ACTION + add hl, bc + ld e, [hl] + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +.Jumptable: + dw ReelAction_DoNothing + dw ReelAction_StopReelIgnoreJoypad + dw ReelAction_QuadrupleRate + dw ReelAction_DoubleRate + dw ReelAction_NormalRate + dw ReelAction_HalfRate + dw ReelAction_QuarterRate + dw ReelAction_StopReel1 + dw ReelAction_StopReel2 + dw ReelAction_StopReel3 + dw ReelAction_SetUpReel2SkipTo7 + dw ReelAction_WaitReel2SkipTo7 + dw ReelAction_FastSpinReel2UntilLinedUp7s + dw ReelAction_0D + dw ReelAction_CheckDropReel + dw ReelAction_WaitDropReel + dw ReelAction_StartSlowAdvanceReel3 + dw ReelAction_WaitSlowAdvanceReel3 + dw ReelAction_InitGolem + dw ReelAction_WaitGolem + dw ReelAction_EndGolem + dw ReelAction_InitChansey + dw ReelAction_WaitChansey + dw ReelAction_WaitEgg + dw ReelAction_DropReel + +ReelAction_DoNothing: + ret + +ReelAction_QuadrupleRate: + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 16 + ret + +ReelAction_DoubleRate: + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 8 + ret + +ReelAction_NormalRate: + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 4 + ret + +ReelAction_HalfRate: + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 2 + ret + +ReelAction_QuarterRate: + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 1 + ret + +Slots_StopReel: + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 0 + ld hl, REEL_ACTION + add hl, bc + ld [hl], REEL_ACTION_STOP_REEL_IGNORE_JOYPAD + ld hl, REEL_STOP_DELAY + add hl, bc + ld [hl], 3 + call Function907c8 + +ReelAction_StopReelIgnoreJoypad: + ld hl, REEL_STOP_DELAY + add hl, bc + ld a, [hl] + and a + jr z, .EndReel + dec [hl] + ret + +.EndReel: + ld hl, REEL_OAM_ADDR + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld e, 32 + + xor a +.clear_reel_oam + ld [hli], a + dec e + jr nz, .clear_reel_oam + + ld hl, REEL_ACTION + add hl, bc + ld a, REEL_ACTION_DO_NOTHING + ld [hl], a + ret + +Function907c8: + ld hl, REEL_X_COORD + add hl, bc + ld a, [hl] + sub 6 * TILE_WIDTH + srl a + srl a + srl a + ld e, a + ld d, 0 + push bc + hlcoord 5, 4 + add hl, de + push hl + call Slots_GetCurrentReelState + ld e, l + ld d, h + inc de + inc de + pop hl + ld bc, $14 + call .asm907f6 + dec de + call .asm907f6 + dec de + call .asm907f6 + pop bc + ret +.asm907f6 + ld a, [de] + add SLOTS_GFX_SEVEN_TILE_1 + ld [hli], a + inc a + inc a + ld [hld], a + add hl, bc + dec a + ld [hli], a + inc a + inc a + ld [hld], a + add hl, bc + ret + +Function90805: + hlcoord 5, 4 + call .asm90814 + hlcoord 9, 4 + call .asm90814 + hlcoord 13, 4 + +.asm90814 + ld a, SLOTS_GFX_BLANK_TILE + ld de, $14 + ld c, 6 +.loop + ld [hli], a + ld [hld], a + add hl, de + dec c + jr nz, .loop + ret + +Function90822: + ld bc, wReel1 + ld hl, REEL_X_COORD + add hl, bc + ld a, [hl] + ld [wCurReelXCoord], a + ld a, 10 * TILE_WIDTH + ld [wCurReelYCoord], a + call Slots_GetCurrentReelState + ld e, l + ld d, h + call Slots_LoadOAM + + ld bc, wReel2 + ld hl, REEL_X_COORD + add hl, bc + ld a, [hl] + ld [wCurReelXCoord], a + ld a, 10 * TILE_WIDTH + ld [wCurReelYCoord], a + call Slots_GetCurrentReelState + ld e, l + ld d, h + call Slots_LoadOAM + + ld bc, wReel3 + ld hl, REEL_X_COORD + add hl, bc + ld a, [hl] + ld [wCurReelXCoord], a + ld a, 10 * TILE_WIDTH + ld [wCurReelYCoord], a + call Slots_GetCurrentReelState + ld e, l + ld d, h + call Slots_LoadOAM + ret + +ReelAction_StopReel1: + ld a, [wSlotBias] + cp SLOTS_NO_BIAS + jr z, .NoBias + ld hl, REEL_MANIP_COUNTER + add hl, bc + ld a, [hl] + and a + jr z, .NoBias + dec [hl] + call .CheckForBias + ret nz + +.NoBias: + call Slots_StopReel + ret + +.CheckForBias: + call Slots_GetCurrentReelState + ld a, [wSlotBias] + ld e, a + ld a, [hli] + cp e + ret z + ld a, [hli] + cp e + ret z + ld a, [hl] + cp e + ret + +ReelAction_StopReel2: + call Slots_CheckMatchedFirstTwoReels + jr nc, .nope + ld a, [wSlotBuildingMatch] + ld hl, wSlotBias + cp [hl] + jr z, .NoBias + +.nope + ld a, [wSlotBias] + cp SLOTS_NO_BIAS + jr z, .NoBias + ld hl, REEL_MANIP_COUNTER + add hl, bc + ld a, [hl] + and a + jr z, .NoBias + dec [hl] + ret + +.NoBias: + call Slots_StopReel + ret + +ReelAction_StopReel3: + call Slots_CheckMatchedAllThreeReels + jr nc, .NoMatch + ld hl, wSlotBias + cp [hl] + jr z, .NoBias + ld hl, REEL_MANIP_COUNTER + add hl, bc + ld a, [hl] + and a + ret z + dec [hl] + ret + +.NoMatch: + ld a, [wSlotBias] + cp SLOTS_NO_BIAS + jr z, .NoBias + ld hl, REEL_MANIP_COUNTER + add hl, bc + ld a, [hl] + and a + jr z, .NoBias + dec [hl] + ret + +.NoBias: + call Slots_StopReel + ret + +ReelAction_SetUpReel2SkipTo7: + call Slots_CheckMatchedFirstTwoReels + jr nc, .no_match + ld a, [wFirstTwoReelsMatchingSevens] + and a + jr z, .no_match + call Slots_StopReel + ret + +.no_match + ld hl, REEL_ACTION + add hl, bc + inc [hl] + ld hl, REEL_MANIP_DELAY + add hl, bc + ld [hl], 32 + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 0 + ret + +ReelAction_WaitReel2SkipTo7: + ld hl, REEL_MANIP_DELAY + add hl, bc + ld a, [hl] + and a + jr z, .no_delay + dec [hl] + ret + +.no_delay + ld hl, REEL_ACTION + add hl, bc + inc [hl] ; REEL_ACTION_FAST_SPIN_REEL2_UNTIL_LINED_UP_7S + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 8 + ret + +ReelAction_FastSpinReel2UntilLinedUp7s: + call Slots_CheckMatchedFirstTwoReels + ret nc + ld a, [wFirstTwoReelsMatchingSevens] + and a + ret z + call Slots_StopReel + ret + +ReelAction_InitGolem: + call Slots_CheckMatchedAllThreeReels + ret c + + ld hl, REEL_ACTION + add hl, bc + inc [hl] ; REEL_ACTION_WAIT_GOLEM + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 0 + call Slots_GetNumberOfGolems + push bc + push af + depixel 12, 13 + ld a, SPRITE_ANIM_INDEX_SLOTS_GOLEM + call InitSpriteAnimStruct + ld hl, SPRITEANIMSTRUCT_0E + add hl, bc + pop af + ld [hl], a + pop bc + xor a + ld [wSlotsDelay], a + +ReelAction_WaitGolem: + ld a, [wSlotsDelay] + cp 2 + jr z, .two + cp 1 + jr z, .one + ret + +.two + call Slots_CheckMatchedAllThreeReels + call Slots_StopReel + ret + +.one + ld hl, REEL_ACTION + add hl, bc + inc [hl] + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 8 + ret + +ReelAction_EndGolem: + xor a + ld [wSlotsDelay], a + ld hl, REEL_ACTION + add hl, bc + dec [hl] + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 0 + ret + +ReelAction_InitChansey: + call Slots_CheckMatchedAllThreeReels + ret c + ld hl, REEL_ACTION + add hl, bc + inc [hl] + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 0 + push bc + depixel 12, 0 + ld a, SPRITE_ANIM_INDEX_SLOTS_CHANSEY + call InitSpriteAnimStruct + pop bc + xor a + ld [wSlotsDelay], a + ret + +ReelAction_WaitChansey: + ld a, [wSlotsDelay] + and a + ret z + ld hl, REEL_ACTION + add hl, bc + inc [hl] ; REEL_ACTION_WAIT_EGG + ld a, 2 + ld [wSlotsDelay], a + +ReelAction_WaitEgg: + ld a, [wSlotsDelay] + cp 4 + ret c + ld hl, REEL_ACTION + add hl, bc + inc [hl] ; REEL_ACTION_DROP_REEL + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 16 + ld hl, REEL_MANIP_DELAY + add hl, bc + ld [hl], 17 + +ReelAction_DropReel: + ld hl, REEL_MANIP_DELAY + add hl, bc + ld a, [hl] + and a + jr z, .check_match + dec [hl] + ret + +.check_match + call Slots_CheckMatchedAllThreeReels + jr nc, .EggAgain + and a + jr nz, .EggAgain + ld a, 5 + ld [wSlotsDelay], a + call Slots_StopReel + ret + +.EggAgain: + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 0 + ld hl, REEL_ACTION + add hl, bc + dec [hl] + dec [hl] ; REEL_ACTION_WAIT_CHANSEY + ld a, 1 + ld [wSlotsDelay], a + ret + +ReelAction_0D: + call Slots_CheckMatchedAllThreeReels + ret c + ld hl, REEL_ACTION + add hl, bc + inc [hl] ; REEL_ACTION_CHECK_DROP_REEL + call Slots_GetNumberOfGolems + ld hl, REEL_MANIP_DELAY + add hl, bc + ld [hl], a + +ReelAction_CheckDropReel: + ld hl, REEL_MANIP_DELAY + add hl, bc + ld a, [hl] + and a + jr nz, .spin + call Slots_CheckMatchedAllThreeReels + call Slots_StopReel + ret + +.spin + dec [hl] + ld hl, REEL_ACTION + add hl, bc + inc [hl] ; REEL_ACTION_WAIT_DROP_REEL + ld hl, REEL_FIELD_0B + add hl, bc + ld [hl], 32 + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 0 + +ReelAction_WaitDropReel: + ld hl, REEL_FIELD_0B + add hl, bc + ld a, [hl] + and a + jr z, .DropReel + dec [hl] + ret + +.DropReel: + ld hl, REEL_ACTION + add hl, bc + dec [hl] + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 8 + ret + +ReelAction_StartSlowAdvanceReel3: + ld hl, REEL_SPIN_RATE + add hl, bc + ld [hl], 1 + ld hl, REEL_ACTION + add hl, bc + inc [hl] ; REEL_ACTION_WAIT_SLOW_ADVANCE_REEL3 + ld hl, REEL_MANIP_DELAY + add hl, bc + ld [hl], 16 + +ReelAction_WaitSlowAdvanceReel3: + ld hl, REEL_MANIP_DELAY + add hl, bc + ld a, [hl] + and a + jr z, .check1 + dec [hl] + ret + +.check1 + ld a, [wSlotBias] + and a + jr nz, .check2 + call Slots_CheckMatchedAllThreeReels + ret nc + and a + ret nz + call Slots_StopReel + ret + +.check2 + call Slots_CheckMatchedAllThreeReels + ret c + call Slots_StopReel + ret + +Slots_CheckMatchedFirstTwoReels: + xor a + ld [wFirstTwoReelsMatching], a + ld [wFirstTwoReelsMatchingSevens], a + call Slots_GetCurrentReelState + call Slots_CopyReelState + ld a, [wSlotBet] + and 3 + ld e, a + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + ld de, .return + push de + jp hl + +.return + ld a, [wFirstTwoReelsMatching] + and a + ret z + scf + ret + +.Jumptable: + dw .zero + dw .one + dw .two + dw .three + +.three + call .CheckUpwardsDiag + call .CheckDownwardsDiag + +.two + call .CheckBottomRow + call .CheckTopRow + +.one + call .CheckMiddleRow + +.zero + ret + +.CheckBottomRow: + ld hl, wCurReelStopped + ld a, [wReel1Stopped] + cp [hl] + call z, .StoreResult + ret + +.CheckUpwardsDiag: + ld hl, wCurReelStopped + 1 + ld a, [wReel1Stopped] + cp [hl] + call z, .StoreResult + ret + +.CheckMiddleRow: + ld hl, wCurReelStopped + 1 + ld a, [wReel1Stopped + 1] + cp [hl] + call z, .StoreResult + ret + +.CheckDownwardsDiag: + ld hl, wCurReelStopped + 1 + ld a, [wReel1Stopped + 2] + cp [hl] + call z, .StoreResult + ret + +.CheckTopRow: + ld hl, wCurReelStopped + 2 + ld a, [wReel1Stopped + 2] + cp [hl] + call z, .StoreResult + ret + +.StoreResult: + ld [wSlotBuildingMatch], a + and a + jr nz, .matching_sevens + ld a, 1 + ld [wFirstTwoReelsMatchingSevens], a + +.matching_sevens + ld a, 1 + ld [wFirstTwoReelsMatching], a + ret + +Slots_CheckMatchedAllThreeReels: + ld a, SLOTS_NO_MATCH + ld [wSlotMatched], a + call Slots_GetCurrentReelState + call Slots_CopyReelState + ld a, [wSlotBet] + and 3 + ld e, a + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + ld de, .return + push de + jp hl + +.return + ld a, [wSlotMatched] + cp SLOTS_NO_MATCH + jr nz, .matched_nontrivial + and a + ret + +.matched_nontrivial + scf + ret + +.Jumptable: + dw .zero + dw .one + dw .two + dw .three + +.three + call .CheckUpwardsDiag + call .CheckDownwardsDiag + +.two + call .CheckBottomRow + call .CheckTopRow + +.one + call .CheckMiddleRow + +.zero + ret + +.CheckBottomRow: + ld hl, wCurReelStopped + ld a, [wReel1Stopped] + cp [hl] + ret nz + ld hl, wReel2Stopped + cp [hl] + call z, .StoreResult + ret + +.CheckUpwardsDiag: + ld hl, wCurReelStopped + 2 + ld a, [wReel1Stopped] + cp [hl] + ret nz + ld hl, wReel2Stopped + 1 + cp [hl] + call z, .StoreResult + ret + +.CheckMiddleRow: + ld hl, wCurReelStopped + 1 + ld a, [wReel1Stopped + 1] + cp [hl] + ret nz + ld hl, wReel2Stopped + 1 + cp [hl] + call z, .StoreResult + ret + +.CheckDownwardsDiag: + ld hl, wCurReelStopped + ld a, [wReel1Stopped + 2] + cp [hl] + ret nz + ld hl, wReel2Stopped + 1 + cp [hl] + call z, .StoreResult + ret + +.CheckTopRow: + ld hl, wCurReelStopped + 2 + ld a, [wReel1Stopped + 2] + cp [hl] + ret nz + ld hl, wReel2Stopped + 2 + cp [hl] + call z, .StoreResult + ret + +.StoreResult: + ld [wSlotMatched], a + ret + +Slots_CopyReelState: + ld de, wCurReelStopped + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + ld [de], a + ret + +Slots_GetNumberOfGolems: + ld hl, REEL_POSITION + add hl, bc + ld a, [hl] + push af + push hl + call .Check7Bias + pop hl + pop af + ld [hl], a + ld a, e + ret + +.Check7Bias: + ld a, [wSlotBias] + and a + jr nz, .not_biased_to_seven + ld e, 0 + +.loop1 + ld hl, REEL_POSITION + add hl, bc + inc [hl] + inc e + push de + call Slots_CheckMatchedAllThreeReels + pop de + jr nc, .loop1 + and a + jr nz, .loop1 + ret + +.not_biased_to_seven + call Random + and 7 + cp 8 / 2 ; 50% + jr c, .not_biased_to_seven + ld e, a + +.loop2 + ld a, e + inc e + ld hl, REEL_POSITION + add hl, bc + add [hl] + ld [hl], a + push de + call Slots_CheckMatchedAllThreeReels + pop de + jr c, .loop2 + ret + +Slots_InitBias: + ld a, [wSlotBias] + and a + ret z + call Random + ld c, a + ld hl, .Biases + +.loop + ld a, [hli] + cp c + jr nc, .done + inc hl + jr .loop + +.done + ld a, [hl] + ld [$C509], a + ret + +.Biases: + db 1 percent - 1, SLOTS_SEVEN + db 1 percent + 1, SLOTS_POKEBALL + db 4 percent, SLOTS_STARYU + db 8 percent, SLOTS_SQUIRTLE + db 16 percent, SLOTS_PIKACHU + db 31 percent + 1, SLOTS_CHERRY + db 100 percent, SLOTS_NO_BIAS + +Slots_IlluminateBetLights: + ld b, SLOTS_GFX_ILLUMINATED_LIGHT + ld a, [wSlotBet] + dec a + jr z, Slot_Lights1OnOff + dec a + jr z, Slots_Lights2OnOff + jr Slots_Lights3OnOff + +Slots_DeilluminateBetLights: + ld b, SLOTS_GFX_DEILLUMINATED_LIGHT + +Slots_Lights3OnOff: + hlcoord 3, 2 + call Slots_TurnLightsOnOrOff + hlcoord 3, 10 + call Slots_TurnLightsOnOrOff + +Slots_Lights2OnOff: + hlcoord 3, 4 + call Slots_TurnLightsOnOrOff + hlcoord 3, 8 + call Slots_TurnLightsOnOrOff + +Slot_Lights1OnOff: + hlcoord 3, 6 + +Slots_TurnLightsOnOrOff: + ld a, b + ld [hl], a + ld de, SCREEN_WIDTH / 2 + 3 + add hl, de + ld [hl], a + ld de, SCREEN_WIDTH / 2 - 3 + add hl, de + inc a + ld [hl], a + ld de, SCREEN_WIDTH / 2 + 3 + add hl, de + ld [hl], a + ret + +Slots_AskBet: +.loop + ld hl, .BetHowManyCoinsText + call PrintText + ld hl, .MenuHeader + call LoadMenuHeader + call VerticalMenu + call CloseWindow + ret c + ld a, [wMenuCursorY] + ld b, a + ld a, 4 + sub b + ld [wSlotBet], a + ld hl, wCoins + ld c, a + ld a, [hli] + and a + jr nz, .Start + ld a, [hl] + cp c + jr nc, .Start + ld hl, .NotEnoughCoinsText + call PrintText + jr .loop + +.Start: + ld hl, wCoins+1 + ld a, [hl] + sub c + ld [hld], a + jr nc, .ok + dec [hl] + +.ok + ld de, SFX_PAY_DAY + call PlaySFX + ld hl, .SlotsStartText + call PrintText + and a + ret + +.BetHowManyCoinsText: + text "コインを" + line "なんまい かけますか?" + done + +.SlotsStartText: + text "スタート!" + done + +.NotEnoughCoinsText: + text "コインが たりません!" + prompt + +.MenuHeader: + db MENU_BACKUP_TILES ; flags + menu_coords 14, 10, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 + dw .MenuData + db 1 ; default option + +.MenuData: + db STATICMENU_CURSOR ; flags + db 3 ; items + db "3まい@" + db "2まい@" + db "1まい@" + +Slots_AskPlayAgain: + ld hl, wCoins + ld a, [hli] + or [hl] + jr nz, .have_coins + ld hl, .RanOutOfCoinsText + call PrintText + ld c, 60 + call DelayFrames + jr .exit_slots + +.have_coins + ld hl, .PlayAgainText + call PrintText + call YesNoBox + jr c, .exit_slots + and a + ret + +.exit_slots + scf + ret + +.RanOutOfCoinsText: + text "コインが" + line "なくなっちゃった<⋯⋯>" + done + +.PlayAgainText: + text "もう 1かい" + line "あそびますか?" + done + +Slots_GetPayout: + ld a, [wSlotMatched] + cp SLOTS_NO_MATCH + jr z, .no_win + srl a + ld e, a + ld d, 0 + ld hl, .PayoutTable + add hl, de + ld a, [hli] + ld [wPayout + 1], a + ld a, [hl] + ld [wPayout], a + ret + +.PayoutTable: + dw 300 + dw 50 + dw 6 + dw 8 + dw 10 + dw 15 + +.no_win + ld hl, wPayout + xor a + ld [hli], a + ld [hl], a + ret + +Slots_PayoutText: + ld a, [wSlotMatched] + cp SLOTS_NO_MATCH + jr nz, .matched + ld hl, .DarnText + call PrintText + ret + +.matched + srl a + ld e, a + ld d, 0 + ld hl, .PayoutStrings + add hl, de + add hl, de + add hl, de + ld de, wStringBuffer2 + ld c, 4 +.copy_string + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .copy_string + ld a, [hli] + ld h, [hl] + ld l, a + ld de, .return + push de + jp hl + +.return + ld hl, .Text_PrintPayout + call PrintText + ret + +.PayoutStrings: + dbw "300@", .ClearBias + dbw "50@@", .Blank + dbw "6@@@", .Blank + dbw "8@@@", .Blank + dbw "10@@", .Blank + dbw "15@@", .Blank + +.Text_PrintPayout: + start_asm + ld a, [wSlotMatched] + add $25 + ldcoord_a 2, 13 + inc a + ldcoord_a 2, 14 + inc a + ldcoord_a 3, 13 + inc a + ldcoord_a 3, 14 + hlcoord 18, 16 + ld [hl], "▼" + ld hl, .LinedUpText +rept 4 + inc bc +endr + ret + +.LinedUpText: + text "が そろった!" + line "コイン @" + text_from_ram wStringBuffer2 + text "まい いただき!" + done + +.DarnText: + text "はずれー" + done + +.ClearBias: + ld a, SLOTS_NO_BIAS + ld [wSlotBias], a + ret + +.Blank: + ret + +Slots_AnimateGolem: + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + ld e, [hl] + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +.Jumptable: + dw .init + dw .fall + dw .roll + +.init + ld hl, SPRITEANIMSTRUCT_0E + add hl, bc + ld a, [hl] + and a + jr nz, .retain + ld a, 2 + ld [wSlotsDelay], a + ld hl, SPRITEANIMSTRUCT_INDEX + add hl, bc + ld [hl], 0 + ret + +.retain + dec [hl] + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + inc [hl] + ld hl, SPRITEANIMSTRUCT_0C + add hl, bc + ld [hl], $30 + ld hl, SPRITEANIMSTRUCT_XOFFSET + add hl, bc + ld [hl], 0 + +.fall + ld hl, SPRITEANIMSTRUCT_0C + add hl, bc + ld a, [hl] + cp $20 + jr c, .landed + dec [hl] + ld e, a + ld d, 14 * 8 + callba BattleAnim_Sine_e + ld a, e + ld hl, SPRITEANIMSTRUCT_YOFFSET + add hl, bc + ld [hl], a + ret + +.landed + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + inc [hl] + ld hl, SPRITEANIMSTRUCT_0D + add hl, bc + ld [hl], 2 + ld a, 1 + ld [wSlotsDelay], a + ret + +.roll + ld hl, SPRITEANIMSTRUCT_XOFFSET + add hl, bc + ld a, [hl] + inc [hl] + inc [hl] + cp 9 * 8 + jr nc, .restart + and 3 + ret nz + ld hl, SPRITEANIMSTRUCT_0D + add hl, bc + ld a, [hl] + xor $ff + inc a + ld [hl], a + ldh [hSCY], a + ret + +.restart + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + xor a + ld [hl], a + ldh [hSCY], a + ret + +Slots_AnimateChansey: + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + ld e, [hl] + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +.Jumptable: + dw .walk + dw .one + dw .two + +.walk + ld hl, SPRITEANIMSTRUCT_XCOORD + add hl, bc + ld a, [hl] + inc [hl] + cp 13 * 8 + ret nz + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + inc [hl] + ld a, 1 + ld [wSlotsDelay], a + +.one + ld a, [wSlotsDelay] + cp 2 + jr z, .retain + cp 5 + ret nz + ld hl, SPRITEANIMSTRUCT_INDEX + add hl, bc + ld [hl], 0 + ret + +.retain + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + inc [hl] + ld hl, SPRITEANIMSTRUCT_0C + add hl, bc + ld [hl], 8 + +.two + ld hl, SPRITEANIMSTRUCT_0C + add hl, bc + ld a, [hl] + and a + jr z, .spawn_egg + dec [hl] + ret + +.spawn_egg + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + dec [hl] + push bc + depixel 12, 13, 0, 4 + ld a, SPRITE_ANIM_INDEX_SLOTS_EGG + call InitSpriteAnimStruct + pop bc + ret + +; The first three positions are repeated to +; avoid needing to check indices when copying. +Slots_Reel1Tilemap: + db SLOTS_SEVEN + db SLOTS_CHERRY + db SLOTS_STARYU + db SLOTS_PIKACHU + db SLOTS_SQUIRTLE + db SLOTS_SEVEN + db SLOTS_CHERRY + db SLOTS_STARYU + db SLOTS_PIKACHU + db SLOTS_SQUIRTLE + db SLOTS_POKEBALL + db SLOTS_CHERRY + db SLOTS_STARYU + db SLOTS_PIKACHU + db SLOTS_SQUIRTLE +; repeated + db SLOTS_SEVEN + db SLOTS_CHERRY + db SLOTS_STARYU + +Slots_Reel2Tilemap: + db SLOTS_SEVEN + db SLOTS_PIKACHU + db SLOTS_CHERRY + db SLOTS_SQUIRTLE + db SLOTS_STARYU + db SLOTS_POKEBALL + db SLOTS_PIKACHU + db SLOTS_CHERRY + db SLOTS_SQUIRTLE + db SLOTS_STARYU + db SLOTS_POKEBALL + db SLOTS_PIKACHU + db SLOTS_CHERRY + db SLOTS_SQUIRTLE + db SLOTS_STARYU +; repeated + db SLOTS_SEVEN + db SLOTS_PIKACHU + db SLOTS_CHERRY + +Slots_Reel3Tilemap: + db SLOTS_SEVEN + db SLOTS_PIKACHU + db SLOTS_CHERRY + db SLOTS_SQUIRTLE + db SLOTS_STARYU + db SLOTS_PIKACHU + db SLOTS_CHERRY + db SLOTS_SQUIRTLE + db SLOTS_STARYU + db SLOTS_PIKACHU + db SLOTS_POKEBALL + db SLOTS_CHERRY + db SLOTS_SQUIRTLE + db SLOTS_STARYU + db SLOTS_PIKACHU +; repeated + db SLOTS_SEVEN + db SLOTS_PIKACHU + db SLOTS_CHERRY + +SlotsTilemap: +INCBIN "gfx/minigames/slots_tilemap.bin" diff --git a/engine/menu/frame_type_dialog.asm b/engine/menu/frame_type_dialog.asm index 57bfeed..b36168d 100644 --- a/engine/menu/frame_type_dialog.asm +++ b/engine/menu/frame_type_dialog.asm @@ -14,7 +14,7 @@ FrameTypeDialog: dec a ld [wActiveFrame], a push de - ld de, 3 ; SFX_MENU + ld de, SFX_MENU call PlaySFX pop de call LoadFontExtra diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 7034904..dbe8b4e 100644 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -65,7 +65,7 @@ InitializeNewGameWRAM: ld [wMonType], a ld [wd163], a ld [wd164], a - ld [wd15b], a + ld [wCoins], a ld [wd15c], a ld [wd15d], a diff --git a/engine/menu/set_clock_dialog.asm b/engine/menu/set_clock_dialog.asm new file mode 100644 index 0000000..22f3ad1 --- /dev/null +++ b/engine/menu/set_clock_dialog.asm @@ -0,0 +1,348 @@ +INCLUDE "constants.asm" + +SECTION "engine/menu/set_clock_dialog.asm", ROMX + +UP_ARROW EQU $f0 +DOWN_ARROW EQU $ee + +SetClockDialog: + call SetClockDialog_Init + +.loop + call SetClockDialog_Run + jr nc, .loop + + ld hl, SetClockDialog_ConfirmTimeDate + call PrintText + + hlcoord 3, 13 + call SetClockDialog_PrintDayOfWeek + ld de, wHourBuffer + + hlcoord 8, 14 + call SetClockDialog_PrintNumber + ld de, wMinuteBuffer + + hlcoord 12, 14 + call SetClockDialog_PrintNumber + + call YesNoBox + jr c, SetClockDialog + call LoadFont + ret + +SetClockDialog_Init: + xor a + ld [wJumptableIndex], a + ld hl, wc408 + ld bc, 50 + call ByteFill + +; load days of week + ld de, HUD_GFX + ld hl, vChars2 tile $40 + lb bc, BANK(HUD_GFX), $20 + call Request1bpp + + ld de, UpArrowGFX + ld hl, vFont tile $70 + lb bc, BANK(UpArrowGFX), 1 + call Request1bpp + ret + +UpArrowGFX: +INCBIN "gfx/font/up_arrow.1bpp" + +SetClockDialog_Run: + ld a, [wJumptableIndex] + bit 7, a + jr nz, .done + + call SetClockDialog_RunFunction + call SetClockDialog_PrintUpDownArrows + call DelayFrame + and a + ret + +.done + scf + ret + +SetClockDialog_PrintUpDownArrows: + ld hl, wClockDialogArrowBlinkCounter + ld a, [hl] + inc [hl] + and 8 + jr nz, .clear_arrows + +; Print up arrow + hlcoord 18, 14 + ld [hl], UP_ARROW + +; Print down arrow + hlcoord 18, 16 + ld [hl], DOWN_ARROW + ret + +.clear_arrows + ld a, " " + hlcoord 18, 14 + ld [hl], a + hlcoord 18, 16 + ld [hl], a + ret + +SetClockDialog_RunFunction: + jumptable .Jumptable, wJumptableIndex + +.Jumptable: + dw SetClockDialog_AskDay + dw SetClockDialog_ChooseDayOfWeek + dw SetClockDialog_AskHour + dw SetClockDialog_ChooseHour + dw SetClockDialog_AskMinutes + dw SetClockDialog_ChooseMinutes + +SetClockDialog_AskDay: + ld hl, SetClockDialog_WhatDayIsIt + call PrintText + hlcoord 10, 16 + ld de, .DayString + call PlaceString + + ld hl, wJumptableIndex + inc [hl] + ret + +.DayString: + db "ようび@" + +SetClockDialog_ChooseDayOfWeek: + hlcoord 9, 15 + call SetClockDialog_PrintDayOfWeek + call GetJoypadDebounced + ld hl, hJoySum + ld a, [hl] + and A_BUTTON + jr nz, .a_pressed + ld a, [hl] + and D_UP + jr nz, .up_pressed + ld a, [hl] + and D_DOWN + jr nz, .down_pressed + ret + +.up_pressed + ld hl, wDayOfWeekBuffer + ld a, [hl] + and a + jr nz, .decrease + ld a, 7 + +.decrease + dec a + ld [hl], a + ret + +.down_pressed + ld hl, wDayOfWeekBuffer + ld a, [hl] + cp 6 + jr c, .increase + ld a, $ff + +.increase + inc a + ld [hl], a + ret + +.a_pressed + ld a, [wDayOfWeekBuffer] + ld [wStartDay], a + ld hl, wJumptableIndex + inc [hl] + ret + +SetClockDialog_AskHour: + ld hl, SetClockDialog_HowManyHours + call PrintText + + hlcoord 10, 16 + ld de, .HoursString + call PlaceString + ld hl, wJumptableIndex + inc [hl] + ret + +.HoursString: + db "じ@" + +SetClockDialog_ChooseHour: + ld de, wHourBuffer + hlcoord 8, 16 + call SetClockDialog_PrintNumber + call GetJoypadDebounced + ld hl, hJoySum + ld a, [hl] + and A_BUTTON + jr nz, .a_pressed + ld a, [hl] + and B_BUTTON + jr nz, .b_pressed + ld a, [hl] + and D_UP + jr nz, .up_pressed + ld a, [hl] + and D_DOWN + jr nz, .down_pressed + ret + +.up_pressed + ld hl, wHourBuffer + ld a, [hl] + and a + jr nz, .decrease + ld a, 24 + +.decrease + dec a + ld [hl], a + ret + +.down_pressed + ld hl, wHourBuffer + ld a, [hl] + cp 23 + jr c, .increase + ld a, $ff + +.increase + inc a + ld [hl], a + ret + +.a_pressed + ld a, [wHourBuffer] + ld [wStartHour], a + ld hl, wJumptableIndex + inc [hl] + ret + +.b_pressed + ld hl, wJumptableIndex + ld [hl], 0 + ret + +SetClockDialog_AskMinutes: + ld hl, SetClockDialog_HowManyMinutes + call PrintText + hlcoord 10, 16 + ld de, .MinutesString + call PlaceString + ld hl, wJumptableIndex + inc [hl] + ret + +.MinutesString: + db "ふん@" + +SetClockDialog_ChooseMinutes: + ld de, wMinuteBuffer + hlcoord 8, 16 + call SetClockDialog_PrintNumber + call GetJoypadDebounced + ld hl, hJoySum + ld a, [hl] + and A_BUTTON + jr nz, .a_pressed + ld a, [hl] + and B_BUTTON + jr nz, .b_pressed + ld a, [hl] + and D_UP + jr nz, .up_pressed + ld a, [hl] + and D_DOWN + jr nz, .down_pressed + ret + +.up_pressed + ld hl, wMinuteBuffer + ld a, [hl] + and a + jr nz, .decrease + ld a, 60 + +.decrease + dec a + ld [hl], a + ret + +.down_pressed + ld hl, wMinuteBuffer + ld a, [hl] + cp 59 + jr c, .increase + ld a, $ff + +.increase + inc a + ld [hl], a + ret + +.a_pressed + ld a, [wMinuteBuffer] + ld [wStartMinute], a + ld hl, wJumptableIndex + +; Display confirmation dialog + set 7, [hl] + ret + +.b_pressed + ld hl, wJumptableIndex + ld [hl], 2 + ret + +SetClockDialog_PrintDayOfWeek: +; Print top half + ld a, [wDayOfWeekBuffer] + sla a + add $40 + ld [hl], a + inc a + +; Move down one row and print the bottom half + ld de, SCREEN_WIDTH + add hl, de + ld [hl], a + ret + +SetClockDialog_PrintNumber: + push hl + ld a, $7f + ld [hli], a + ld [hl], a + pop hl + lb bc, 1, 2 + call PrintNumber + ret + +SetClockDialog_WhatDayIsIt: + text "きょうは なんようび だったかの?" + done + +SetClockDialog_HowManyHours: + text "いまは なんじ じゃ?" + done + +SetClockDialog_HowManyMinutes: + deciram wStartHour, 1, 2 + text "じ なんふん かな?" + done + +SetClockDialog_ConfirmTimeDate: + text " ようび じ ふん" + line "ほんとうに あっているかの?" + done diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm index 4bb1829..90bd04a 100644 --- a/engine/menu/start_menu.asm +++ b/engine/menu/start_menu.asm @@ -4,7 +4,7 @@ SECTION "engine/menu/start_menu.asm", ROMX DisplayStartMenu: call RefreshScreen - ld de, $0003 + ld de, SFX_MENU call PlaySFX ld hl, .StartMenuHeader call LoadMenuHeader @@ -863,7 +863,7 @@ RegisterItem: ld a, [wCurItem] ld [wRegisteredItemQuantity], a call LoadItemData - ld de, $0002 + ld de, SFX_FULL_HEAL call WaitPlaySFX ld hl, .RegisteredItemText call MenuTextBoxBackup diff --git a/engine/movie/oak_speech.asm b/engine/movie/oak_speech.asm index 5941f65..5d0e6af 100644 --- a/engine/movie/oak_speech.asm +++ b/engine/movie/oak_speech.asm @@ -88,7 +88,7 @@ GameStart:: ld [wMusicFadeIDLow], a ld a, d ld [wMusicFadeIDHigh], a - ld de, $000B ; should be a constant - shrink noise? + ld de, SFX_ESCAPE_ROPE call PlaySFX pop af call Bankswitch diff --git a/engine/movie/title.asm b/engine/movie/title.asm index d84d8c5..2323d38 100644 --- a/engine/movie/title.asm +++ b/engine/movie/title.asm @@ -267,7 +267,7 @@ TitleSeq_LoadPokemonLogo:: TitleSeq_Start:: call TitleSeq_IncreaseJumpTableIndex push de - ld de, $2D ; "swish" sound + ld de, SFX_TITLE_ENTRANCE call PlaySFX pop de ld a, $80 diff --git a/gfx/font/up_arrow.1bpp.png b/gfx/font/up_arrow.1bpp.png Binary files differnew file mode 100644 index 0000000..32a3c91 --- /dev/null +++ b/gfx/font/up_arrow.1bpp.png diff --git a/gfx/gfx.asm b/gfx/gfx.asm index 8c3fb8a..b4ed26d 100644 --- a/gfx/gfx.asm +++ b/gfx/gfx.asm @@ -407,9 +407,12 @@ SnorlaxIcon:: INCBIN "gfx/icons/snorlax.2bpp" SECTION "gfx.asm@Slot Machine GFX", ROMX SlotMachineGFX:: -INCBIN "gfx/minigames/slots.2bpp" +INCBIN "gfx/minigames/slots_1.2bpp" SlotMachine2GFX:: INCBIN "gfx/minigames/slots_2.2bpp" +INCBIN "gfx/minigames/slots_3.2bpp" +SlotMachine3GFX:: +INCBIN "gfx/minigames/slots_4.2bpp" SECTION "gfx.asm@Bank 30 Sprites 1", ROMX GoldSpriteGFX:: INCBIN "gfx/sprites/gold.2bpp" @@ -12,7 +12,10 @@ $(BUILD)/gfx/trainer_card/leaders.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/trainer_gear/town_map.2bpp: tools/gfx += --trim-trailing -$(BUILD)/gfx/minigames/slots.2bpp: tools/gfx += --trim-whitespace +$(BUILD)/gfx/minigames/slots_1.2bpp: tools/gfx += --trim-whitespace +$(BUILD)/gfx/minigames/slots_2.2bpp: tools/gfx += --interleave --png=$< +$(BUILD)/gfx/minigames/slots_3.2bpp: tools/gfx += --interleave --png=$< --remove-duplicates --keep-whitespace --remove-xflip +$(BUILD)/gfx/minigames/slots_4.2bpp: tools/gfx += --interleave --png=$< $(BUILD)/gfx/minigames/poker.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/intro/jigglypuff_pikachu.2bpp: tools/gfx += --trim-whitespace diff --git a/gfx/minigames/slots.png b/gfx/minigames/slots_1.png Binary files differindex 44993f6..44993f6 100644 --- a/gfx/minigames/slots.png +++ b/gfx/minigames/slots_1.png diff --git a/gfx/minigames/slots_2.png b/gfx/minigames/slots_2.png Binary files differindex cae4177..97d7fb7 100644 --- a/gfx/minigames/slots_2.png +++ b/gfx/minigames/slots_2.png diff --git a/gfx/minigames/slots_3.png b/gfx/minigames/slots_3.png Binary files differnew file mode 100644 index 0000000..9ce0a0d --- /dev/null +++ b/gfx/minigames/slots_3.png diff --git a/gfx/minigames/slots_4.png b/gfx/minigames/slots_4.png Binary files differnew file mode 100644 index 0000000..aa0c685 --- /dev/null +++ b/gfx/minigames/slots_4.png diff --git a/gfx/minigames/slots_tilemap.bin b/gfx/minigames/slots_tilemap.bin Binary files differnew file mode 100644 index 0000000..68807bb --- /dev/null +++ b/gfx/minigames/slots_tilemap.bin diff --git a/home/text.asm b/home/text.asm index 4b72fc0..807d9f3 100644 --- a/home/text.asm +++ b/home/text.asm @@ -656,13 +656,13 @@ Text_PlaySound:: jp NextTextCommand .soundTable: - dbw TX_SOUND_0B, $0063 - dbw TX_SOUND_12, $006B - dbw TX_SOUND_0E, $0066 - dbw TX_SOUND_0F, $0067 - dbw TX_SOUND_10, $0068 - dbw TX_SOUND_11, $0069 - dbw TX_SOUND_13, $0027 + dbw TX_SOUND_0B, SFX_GET_ITEM_RG + dbw TX_SOUND_12, SFX_UNUSED_FANFARE_3 + dbw TX_SOUND_0E, SFX_LEVEL_UP_RG + dbw TX_SOUND_0F, SFX_EVOLUTION_COMPLETE_RG + dbw TX_SOUND_10, SFX_GET_KEY_ITEM_RG + dbw TX_SOUND_11, SFX_UNUSED_FANFARE_2 + dbw TX_SOUND_13, SFX_POKEDEX_REGISTRATION dbw TX_CRY_14, MON_NIDORINA dbw TX_CRY_15, MON_PIDGEOT dbw TX_CRY_16, MON_DEWGONG diff --git a/layout.link b/layout.link index 32e2497..49120fe 100644 --- a/layout.link +++ b/layout.link @@ -368,6 +368,7 @@ ROMX $21 ROMX $23 org $4000 + "engine/dumps/bank23.asm@AnimateTilesetImpl" org $433e "engine/palettes.asm@Overworld fade" org $43d1 @@ -381,7 +382,8 @@ ROMX $23 ROMX $24 org $4000 - org $4fdb + "engine/menu/set_clock_dialog.asm" + "engine/games/slot_machine_game.asm" "gfx.asm@Slot Machine GFX" ROMX $25 @@ -912,6 +914,8 @@ ROMX $3a org $4000 "audio/engine.asm" "audio/songs/none.asm" + "audio/cries.asm@Cry Header Pointers" + "audio/sfx.asm@SFX Pointers" ROMX $3b org $4000 @@ -930,7 +934,7 @@ ROMX $3b ROMX $3c org $4000 org $51cb - "audio/cries.asm" + "audio/cries.asm@Cries" org $62fe "audio/songs/title.asm" diff --git a/macros/wram.asm b/macros/wram.asm index 094223d..b479113 100644 --- a/macros/wram.asm +++ b/macros/wram.asm @@ -250,13 +250,13 @@ slot_reel: MACRO \1SpinRate:: db \1OAMAddr:: dw \1XCoord:: db -\1Slot09:: ds 1 -\1Slot0a:: ds 1 -\1Slot0b:: ds 1 -\1Slot0c:: ds 1 -\1Slot0d:: ds 1 -\1Slot0e:: ds 1 -\1Slot0f:: ds 1 +\1ManipCounter:: db +\1ManipDelay:: db +\1Field0b:: db +\1Field0c:: db +\1Field0d:: db +\1Field0e:: db +\1StopDelay:: db endm object_struct: MACRO @@ -367,6 +367,13 @@ battle_bg_effect: MACRO \1_03:: ds 1 endm +sprite_oam_struct: MACRO +\1YCoord:: db +\1XCoord:: db +\1TileID:: db +\1Attributes:: db +ENDM + warp_struct: MACRO \1WarpNumber:: ds 1 \1MapGroup:: ds 1 diff --git a/ram/wram.asm b/ram/wram.asm index 5c10786..0979c19 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -89,7 +89,46 @@ wMusicInitEnd:: SECTION "OAM Buffer", WRAM0 wVirtualOAM:: - ds SPRITEOAMSTRUCT_LENGTH * NUM_SPRITE_OAM_STRUCTS +wVirtualOAMSprite00:: sprite_oam_struct wVirtualOAMSprite00 +wVirtualOAMSprite01:: sprite_oam_struct wVirtualOAMSprite01 +wVirtualOAMSprite02:: sprite_oam_struct wVirtualOAMSprite02 +wVirtualOAMSprite03:: sprite_oam_struct wVirtualOAMSprite03 +wVirtualOAMSprite04:: sprite_oam_struct wVirtualOAMSprite04 +wVirtualOAMSprite05:: sprite_oam_struct wVirtualOAMSprite05 +wVirtualOAMSprite06:: sprite_oam_struct wVirtualOAMSprite06 +wVirtualOAMSprite07:: sprite_oam_struct wVirtualOAMSprite07 +wVirtualOAMSprite08:: sprite_oam_struct wVirtualOAMSprite08 +wVirtualOAMSprite09:: sprite_oam_struct wVirtualOAMSprite09 +wVirtualOAMSprite10:: sprite_oam_struct wVirtualOAMSprite10 +wVirtualOAMSprite11:: sprite_oam_struct wVirtualOAMSprite11 +wVirtualOAMSprite12:: sprite_oam_struct wVirtualOAMSprite12 +wVirtualOAMSprite13:: sprite_oam_struct wVirtualOAMSprite13 +wVirtualOAMSprite14:: sprite_oam_struct wVirtualOAMSprite14 +wVirtualOAMSprite15:: sprite_oam_struct wVirtualOAMSprite15 +wVirtualOAMSprite16:: sprite_oam_struct wVirtualOAMSprite16 +wVirtualOAMSprite17:: sprite_oam_struct wVirtualOAMSprite17 +wVirtualOAMSprite18:: sprite_oam_struct wVirtualOAMSprite18 +wVirtualOAMSprite19:: sprite_oam_struct wVirtualOAMSprite19 +wVirtualOAMSprite20:: sprite_oam_struct wVirtualOAMSprite20 +wVirtualOAMSprite21:: sprite_oam_struct wVirtualOAMSprite21 +wVirtualOAMSprite22:: sprite_oam_struct wVirtualOAMSprite22 +wVirtualOAMSprite23:: sprite_oam_struct wVirtualOAMSprite23 +wVirtualOAMSprite24:: sprite_oam_struct wVirtualOAMSprite24 +wVirtualOAMSprite25:: sprite_oam_struct wVirtualOAMSprite25 +wVirtualOAMSprite26:: sprite_oam_struct wVirtualOAMSprite26 +wVirtualOAMSprite27:: sprite_oam_struct wVirtualOAMSprite27 +wVirtualOAMSprite28:: sprite_oam_struct wVirtualOAMSprite28 +wVirtualOAMSprite29:: sprite_oam_struct wVirtualOAMSprite29 +wVirtualOAMSprite30:: sprite_oam_struct wVirtualOAMSprite30 +wVirtualOAMSprite31:: sprite_oam_struct wVirtualOAMSprite31 +wVirtualOAMSprite32:: sprite_oam_struct wVirtualOAMSprite32 +wVirtualOAMSprite33:: sprite_oam_struct wVirtualOAMSprite33 +wVirtualOAMSprite34:: sprite_oam_struct wVirtualOAMSprite34 +wVirtualOAMSprite35:: sprite_oam_struct wVirtualOAMSprite35 +wVirtualOAMSprite36:: sprite_oam_struct wVirtualOAMSprite36 +wVirtualOAMSprite37:: sprite_oam_struct wVirtualOAMSprite37 +wVirtualOAMSprite38:: sprite_oam_struct wVirtualOAMSprite38 +wVirtualOAMSprite39:: sprite_oam_struct wVirtualOAMSprite39 wVirtualOAMEnd:: wTileMap:: @@ -102,7 +141,12 @@ wTileMapBackup:: NEXTU -wSpriteAnimDict:: ds 10 * 2 ; NUM_SPRITEANIMDICT_ENTRIES * 2 +wc408:: db +wc409:: db + +NEXTU + +wSpriteAnimDict:: ds NUM_SPRITEANIMDICT_ENTRIES * 2 wSpriteAnimationStructs:: ; field 0: index @@ -124,7 +168,7 @@ NEXTU ds 1 -wc409:: ds 1 +wClockDialogArrowBlinkCounter:: ds 1 wc40a:: ds 1 ; Monster or Trainer test? @@ -136,12 +180,21 @@ wc40c:: ds 1 wc40d:: ds 1 wc40e:: ds 1 - ds 11 + ds 3 -wc41a:: db +wDayOfWeekBuffer:: db - ds 165 + ds 7 +wc41a:: db + ds 1 +wHourBuffer:: db + ds 9 +wMinuteBuffer:: db + ds 150 + +wc4bd:: db + ds 2 wSpriteAnimIDBuffer:: db ds 6 @@ -163,9 +216,33 @@ wNamingScreenLastCharacter:: db wNamingScreenStringEntryCoordY:: db wNamingScreenStringEntryCoordX:: db - ds 64 +NEXTU + ds 200 + +wSlots:: +wReel1:: slot_reel wReel1 +wReel2:: slot_reel wReel2 +wReel3:: slot_reel wReel3 +wReel1Stopped:: ds 3 +wReel2Stopped:: ds 3 +wReel3Stopped:: ds 3 +wSlotBias:: db +wSlotBet:: db +wFirstTwoReelsMatching:: db +wFirstTwoReelsMatchingSevens:: db +wSlotMatched:: db +wCurReelStopped:: ds 3 +wPayout:: dw +wCurReelXCoord:: db +wCurReelYCoord:: db + ds 2 +wSlotBuildingMatch:: db +wSlotsDataEnd:: + ds 2 wc51a:: ds 1 + ds 25 +wSlotsEnd:: db ENDU @@ -434,6 +511,7 @@ wNamedObjectTypeBuffer:: db SECTION "CB5E", WRAM0[$CB5E] wJumptableIndex:: db +wSlotsDelay:: wFlyDestination:: wIntroSceneFrameCounter:: wTrainerGearPointerPosition:: @@ -1040,7 +1118,7 @@ wCurTimeOfDay:: db SECTION "D15B", WRAM0[$D15B] -wd15b:: db +wCoins:: db wd15c:: db @@ -1248,8 +1326,8 @@ wMapAttributesEnd:: wNorthMapConnection:: map_connection_struct wNorth wSouthMapConnection:: map_connection_struct wSouth -wWestMapConnection:: map_connection_struct wWest -wEastMapConnection:: map_connection_struct wEast +wWestMapConnection:: map_connection_struct wWest +wEastMapConnection:: map_connection_struct wEast wTileset:: @@ -1261,7 +1339,9 @@ wTilesetTilesAddress:: dw wTilesetCollisionAddress:: dw - ds 4 ; TODO +wTilesetAnim:: + dw + ds 2 ; TODO wTilesetEnd:: wPartyCount:: db @@ -1285,17 +1365,17 @@ wPartyMonNicknames:: ds PARTY_LENGTH * MON_NAME_LENGTH ; = $24 wPartyMonNicknamesEnd:: -wPokedexOwned:: +wPokedexOwned:: flag_array NUM_POKEMON wPokedexOwnedEnd:: -wPokedexSeen:: +wPokedexSeen:: flag_array NUM_POKEMON -wPokedexSeenEnd:: +wPokedexSeenEnd:: -wAnnonDex:: ds 26 +wAnnonDex:: ds 26 -wAnnonID:: ds 1 +wAnnonID:: ds 1 wd875:: ds 1 wd876:: ds 1 @@ -117,7 +117,6 @@ 14:4CD1 Function50cd1 14:4ED9 Function50ed9 -23:4000 AnimateTilesetImpl 23:42DC UpdateTimeOfDayPal 23:42E3 _TimeOfDayPals 23:4335 _UpdateTimePals @@ -128,6 +127,7 @@ 23:4CFD InitEffectObject 23:4D0C PlaySpriteAnimationsAndDelayFrame 23:4d13 EffectObjectJumpNoDelay +23:4D24 DoNextFrameForFirst16Sprites 23:4d52 _InitSpriteAnimStruct 23:60cc MenuMonIconGfx 23:70CC Function8f0cc @@ -135,9 +135,6 @@ 23:71CB Function_8f1cb 23:71F2 Function8f1f2 -24:4000 SetClockDialog -24:4239 SlotMachineGame - 32:76FF Functioncb6ff 32:7710 Functioncb710 32:7733 Functioncb733 @@ -155,8 +152,155 @@ 38:622B MemoryMinigame 38:6886 PicrossMinigame -3A:536D SFXPointers -3A:52FB CryHeaderPointers +; SFX shims +3C:43BE Sfx_01 +3C:43C1 Sfx_02 +3C:43C4 Sfx_03 +3C:43C7 Sfx_04 +3C:43CA Sfx_05 +3C:43CA Sfx_06 +3C:43CD Sfx_07 +3C:43D0 Sfx_08 +3C:43D3 Sfx_09 +3C:43D6 Sfx_0a +3C:43D9 Sfx_0b +3C:43DC Sfx_0c +3C:43DF Sfx_0d +3C:43E2 Sfx_0e +3C:43E5 Sfx_0f +3C:43E8 Sfx_10 +3C:43EB Sfx_11 +3C:43EE Sfx_12 +3C:43F1 Sfx_13 +3C:43F4 Sfx_14 +3C:43F7 Sfx_15 +3C:43FD Sfx_16 +3C:4400 Sfx_17 +3C:4403 Sfx_18 +3C:4409 Sfx_19 +3C:440C Sfx_1a +3C:440F Sfx_1b +3C:4412 Sfx_1c +3C:4418 Sfx_1d +3C:441E Sfx_1e +3C:4424 Sfx_1f +3C:4427 Sfx_20 +3C:442A Sfx_21 +3C:4430 Sfx_22 +3C:4433 Sfx_23 +3C:4436 Sfx_24 +3C:443C Sfx_25 +3C:4442 Sfx_26 +3C:4448 Sfx_27 +3C:444B Sfx_28 +3C:4451 Sfx_29 +3C:4454 Sfx_2a +3C:4457 Sfx_2b +3C:445A Sfx_2c +3C:445D Sfx_2d +3C:4460 Sfx_2e +3C:4463 Sfx_2f +3C:4466 Sfx_30 +3C:4469 Sfx_31 +3C:446F Sfx_32 +3C:4472 Sfx_33 +3C:4475 Sfx_34 +3C:4478 Sfx_35 +3C:447B Sfx_36 +3C:447E Sfx_37 +3C:4481 Sfx_38 +3C:4484 Sfx_39 +3C:4487 Sfx_3a +3C:448A Sfx_3b +3C:448D Sfx_3c +3C:4490 Sfx_3d +3C:4493 Sfx_3e +3C:4496 Sfx_3f +3C:4499 Sfx_40 +3C:449C Sfx_41 +3C:449F Sfx_42 +3C:44A2 Sfx_43 +3C:44A5 Sfx_44 +3C:44A8 Sfx_45 +3C:44AB Sfx_46 +3C:44AE Sfx_47 +3C:44B1 Sfx_48 +3C:44B4 Sfx_49 +3C:44B7 Sfx_4a +3C:44BD Sfx_4b +3C:44C0 Sfx_4c +3C:44C3 Sfx_4d +3C:44C6 Sfx_4e +3C:44C9 Sfx_4f +3C:44CC Sfx_50 +3C:44D2 Sfx_51 +3C:44D5 Sfx_52 +3C:44D8 Sfx_53 +3C:44E1 Sfx_54 +3C:44EA Sfx_55 +3C:44F0 Sfx_56 +3C:44F9 Sfx_57 +3C:44FF Sfx_58 +3C:4508 Sfx_59 +3C:4511 Sfx_5a +3C:451A Sfx_5b +3C:4523 Sfx_5c +3C:452C Sfx_5d +3C:4532 Sfx_5e +3C:4538 Sfx_5f +3C:453E Sfx_60 +3C:4547 Sfx_61 +3C:454D Sfx_62 +3C:4556 Sfx_63 +3C:4559 Sfx_64 +3C:4562 Sfx_65 +3C:456B Sfx_66 +3C:4574 Sfx_67 +3C:457D Sfx_68 +3C:4586 Sfx_69 +3C:458F Sfx_6a +3C:4598 Sfx_6b +3C:45A1 Sfx_6c + +; Cry header shims +3C:57C5 CryHeader_f17c5 +3C:57CE CryHeader_f17ce +3C:57D7 CryHeader_f17d7 +3C:57E0 CryHeader_f17e0 +3C:57E9 CryHeader_f17e9 +3C:57F2 CryHeader_f17f2 +3C:57FB CryHeader_f17fb +3C:5804 CryHeader_f1804 +3C:580D CryHeader_f180d +3C:5816 CryHeader_f1816 +3C:581F CryHeader_f181f +3C:5828 CryHeader_f1828 +3C:5831 CryHeader_f1831 +3C:583A CryHeader_f183a +3C:5843 CryHeader_f1843 +3C:584C CryHeader_f184c +3C:5855 CryHeader_f1855 +3C:585E CryHeader_f185e +3C:5867 CryHeader_f1867 +3C:5870 CryHeader_f1870 +3C:5879 CryHeader_f1879 +3C:5882 CryHeader_f1882 +3C:588B CryHeader_f188b +3C:5894 CryHeader_f1894 +3C:589D CryHeader_f189d +3C:58A6 CryHeader_f18a6 +3C:58AF CryHeader_f18af +3C:58B8 CryHeader_f18b8 +3C:58C1 CryHeader_f18c1 +3C:58CA CryHeader_f18ca +3C:58D3 CryHeader_f18d3 +3C:58DC CryHeader_f18dc +3C:58E5 CryHeader_f18e5 +3C:58EE CryHeader_f18ee +3C:58F7 CryHeader_f18f7 +3C:5900 CryHeader_f1900 +3C:5909 CryHeader_f1909 +3C:5912 CryHeader_f1912 3F:40E9 InGameDebugMenu 3F:4C24 Functionfcc24 @@ -166,4 +310,3 @@ 3F:64CE MonsterTest 3F:654E PicTest 3F:6750 PicTestMenu -;3F:6755 PicTestMenu.loop |