diff options
author | JimB16 <f1@jimb.de> | 2015-10-26 03:26:53 +0100 |
---|---|---|
committer | JimB16 <f1@jimb.de> | 2015-10-26 03:26:53 +0100 |
commit | 9a9cb38e39c991e102a1c6da7e8e16b2a1c61e07 (patch) | |
tree | 46c064628b3d8015da22d6396b3c711e80646745 /engine | |
parent | 3b9a3cc3bee8934e45f5e4d3fd9704b3fa619560 (diff) | |
parent | 0d17d4a75866d053f5e0b48c66deb2508071d98b (diff) |
merge with newest update
Diffstat (limited to 'engine')
-rw-r--r-- | engine/battle_start.asm | 872 | ||||
-rw-r--r-- | engine/color.asm | 87 | ||||
-rw-r--r-- | engine/credits.asm | 24 | ||||
-rw-r--r-- | engine/engine_flags.asm | 378 | ||||
-rw-r--r-- | engine/events.asm | 156 | ||||
-rw-r--r-- | engine/events_2.asm | 66 | ||||
-rw-r--r-- | engine/fruit_trees.asm | 2 | ||||
-rw-r--r-- | engine/map_objects.asm | 12 | ||||
-rw-r--r-- | engine/map_setup.asm | 71 | ||||
-rw-r--r-- | engine/more_phone_scripts.asm | 2 | ||||
-rw-r--r-- | engine/pack.asm | 484 | ||||
-rw-r--r-- | engine/phone.asm | 884 | ||||
-rw-r--r-- | engine/phone_scripts.asm | 22 | ||||
-rw-r--r-- | engine/pokedex.asm | 76 | ||||
-rw-r--r-- | engine/predef.asm | 6 | ||||
-rw-r--r-- | engine/radio.asm | 6 | ||||
-rw-r--r-- | engine/save.asm | 4 | ||||
-rw-r--r-- | engine/scripting.asm | 82 | ||||
-rw-r--r-- | engine/specials.asm | 36 | ||||
-rw-r--r-- | engine/std_scripts.asm | 6 | ||||
-rwxr-xr-x | engine/time.asm | 342 | ||||
-rw-r--r-- | engine/timeofdaypals.asm | 414 | ||||
-rw-r--r-- | engine/title.asm | 96 |
23 files changed, 3152 insertions, 976 deletions
diff --git a/engine/battle_start.asm b/engine/battle_start.asm new file mode 100644 index 000000000..4b12bb632 --- /dev/null +++ b/engine/battle_start.asm @@ -0,0 +1,872 @@ +Predef_StartBattle: ; 8c20f + call Function8c26d + ld a, [rBGP] + ld [wcfc7], a + ld a, [rOBP0] + ld [wcfc8], a + ld a, [rOBP1] + ld [wcfc9], a + call DelayFrame + ld hl, hVBlank + ld a, [hl] + push af + ld [hl], $1 + +.loop + ld a, [wJumptableIndex] + bit 7, a + jr nz, .done + call FlashyTransitionToBattle + call DelayFrame + jr .loop + +.done + ld a, [rSVBK] + push af + ld a, $5 + ld [rSVBK], a + + ld hl, Unkn1Pals + ld bc, $0040 + xor a + call ByteFill + + pop af + ld [rSVBK], a + + ld a, %11111111 + ld [wcfc7], a + call DmgToCgbBGPals + call DelayFrame + xor a + ld [hLCDStatCustom], a + ld [hLCDStatCustom + 1], a + ld [hLCDStatCustom + 2], a + ld [hSCY], a + + ld a, $1 + ld [rSVBK], a + pop af + ld [hVBlank], a + call DelayFrame + ret +; 8c26d + +Function8c26d: ; 8c26d + ld a, [wLinkMode] + cp LINK_MOBILE + jr z, .mobile + callba Function6454 + call UpdateSprites + call DelayFrame + call Function8c2a0 + call Function8cf4f + jr .resume + +.mobile + call LoadTrainerBattlePokeballTiles + +.resume + ld a, SCREEN_HEIGHT_PX + ld [hWY], a + call DelayFrame + xor a + ld [hBGMapMode], a + ld hl, wJumptableIndex + xor a +rept 2 + ld [hli], a +endr + ld [hl], a + call WipeLYOverrides + ret +; 8c2a0 + +Function8c2a0: ; 8c2a0 + call LoadTrainerBattlePokeballTiles + ld hl, VBGMap0 + call Function8c2cf + ret +; 8c2aa + +LoadTrainerBattlePokeballTiles: +; Load the tiles used in the Pokeball Graphic that fills the screen +; at the start of every Trainer battle. + ld de, TrainerBattlePokeballTiles + ld hl, VTiles1 tile $7e + ld b, BANK(TrainerBattlePokeballTiles) + ld c, 2 + call Request2bpp + + ld a, [rVBK] + push af + ld a, $1 + ld [rVBK], a + + ld de, TrainerBattlePokeballTiles + ld hl, VTiles4 tile $7e + ld b, BANK(TrainerBattlePokeballTiles) + ld c, 2 + call Request2bpp + + pop af + ld [rVBK], a + ret +; 8c2cf + +Function8c2cf: ; 8c2cf + ld a, [rSVBK] + push af + ld a, $6 + ld [rSVBK], a + push hl + ld hl, w6_d000 + ld bc, $28 * $10 + +.loop + ld [hl], -1 + inc hl + dec bc + ld a, c + or b + jr nz, .loop + + pop hl + ld de, w6_d000 + ld b, BANK(Function8c2cf) ; BANK(@) + ld c, $28 + call Request2bpp + pop af + ld [rSVBK], a + ret +; 8c2f4 + +TrainerBattlePokeballTiles: ; 8c2f4 +INCBIN "gfx/overworld/trainer_battle_pokeball_tiles.2bpp" + + +FlashyTransitionToBattle: ; 8c314 + ld a, [wJumptableIndex] + ld e, a + ld d, 0 + ld hl, .jumptable +rept 2 + add hl, de +endr + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] +; 8c323 + +.jumptable: ; 8c323 (23:4323) + dw StartTrainerBattle_DetermineWhichAnimation ; 00 + + ; Animation 1: cave + dw StartTrainerBattle_LoadPokeBallGraphics ; 01 + dw StartTrainerBattle_SetUpBGMap ; 02 + dw StartTrainerBattle_Flash ; 03 + dw StartTrainerBattle_Flash ; 04 + dw StartTrainerBattle_Flash ; 05 + dw StartTrainerBattle_NextScene ; 06 + dw StartTrainerBattle_SetUpForWavyOutro ; 07 + dw StartTrainerBattle_SineWave ; 08 + + ; Animation 2: cave, stronger + dw StartTrainerBattle_LoadPokeBallGraphics ; 09 + dw StartTrainerBattle_SetUpBGMap ; 0a + dw StartTrainerBattle_Flash ; 0b + dw StartTrainerBattle_Flash ; 0c + dw StartTrainerBattle_Flash ; 0d + dw StartTrainerBattle_NextScene ; 0e + ; There is no setup for this one + dw StartTrainerBattle_ZoomToBlack ; 0f + + ; Animation 3: no cave + dw StartTrainerBattle_LoadPokeBallGraphics ; 10 + dw StartTrainerBattle_SetUpBGMap ; 11 + dw StartTrainerBattle_Flash ; 12 + dw StartTrainerBattle_Flash ; 13 + dw StartTrainerBattle_Flash ; 14 + dw StartTrainerBattle_NextScene ; 15 + dw StartTrainerBattle_SetUpForSpinOutro ; 16 + dw StartTrainerBattle_SpinToBlack ; 17 + + ; Animation 4: no cave, stronger + dw StartTrainerBattle_LoadPokeBallGraphics ; 18 + dw StartTrainerBattle_SetUpBGMap ; 19 + dw StartTrainerBattle_Flash ; 1a + dw StartTrainerBattle_Flash ; 1b + dw StartTrainerBattle_Flash ; 1c + dw StartTrainerBattle_NextScene ; 1d + dw StartTrainerBattle_SetUpForRandomScatterOutro ; 1e + dw StartTrainerBattle_SpeckleToBlack ; 1f + + ; All animations jump to here. + dw StartTrainerBattle_Finish ; 20 + + +StartTrainerBattle_DetermineWhichAnimation: ; 8c365 (23:4365) +; The screen flashes a different number of +; times depending on the level of your lead +; Pokemon relative to the opponent's. + ld de, 0 + ld a, [BattleMonLevel] + add 3 + ld hl, EnemyMonLevel + cp [hl] + jr nc, .okay + set 0, e +.okay + ld a, [wPermission] + cp CAVE + jr z, .okay2 + cp PERM_5 + jr z, .okay2 + cp DUNGEON + jr z, .okay2 + set 1, e +.okay2 + ld hl, .StartingPoints + add hl, de + ld a, [hl] + ld [wJumptableIndex], a + ret +; 8c38f (23:438f) + +.StartingPoints: ; 8c38f + db 1, 9 + db 16, 24 +; 8c393 + +StartTrainerBattle_Finish: ; 8c393 (23:4393) + call ClearSprites + ld a, $80 + ld [wJumptableIndex], a + ret + +StartTrainerBattle_NextScene: ; 8c39c (23:439c) + ld hl, wJumptableIndex + inc [hl] + ret + +StartTrainerBattle_SetUpBGMap: ; 8c3a1 (23:43a1) + call StartTrainerBattle_NextScene + xor a + ld [wcf64], a + ld [hBGMapMode], a ; $ff00+$d4 + ret + +StartTrainerBattle_Flash: ; 8c3ab (23:43ab) + call .DoFlashAnimation + ret nc + call StartTrainerBattle_NextScene + ret + +.DoFlashAnimation: ; 8c3b3 (23:43b3) + ld a, [wd847] + cp -1 + jr z, .done + ld hl, wcf64 + ld a, [hl] + inc [hl] + srl a + ld e, a + ld d, 0 + ld hl, .pals + add hl, de + ld a, [hl] + cp %00000001 + jr z, .done + ld [wcfc7], a + call DmgToCgbBGPals + and a + ret + +.done + xor a + ld [wcf64], a + scf + ret +; 8c3db (23:43db) + +.pals: ; 8c3db + db %11111001 ; 3321 + db %11111110 ; 3332 + db %11111111 ; 3333 + db %11111110 ; 3332 + db %11111001 ; 3321 + db %11100100 ; 3210 + db %10010000 ; 2100 + db %01000000 ; 1000 + db %00000000 ; 0000 + db %01000000 ; 1000 + db %10010000 ; 2100 + db %11100100 ; 3210 + db %00000001 ; 0001 +; 8c3e8 + +StartTrainerBattle_SetUpForWavyOutro: ; 8c3e8 (23:43e8) + callba Function5602 + ld a, $5 + ld [rSVBK], a ; $ff00+$70 + call StartTrainerBattle_NextScene + ld a, $43 + ld [hLCDStatCustom], a ; $ff00+$c6 + xor a + ld [hLCDStatCustom + 1], a + ld a, $90 + ld [hLCDStatCustom + 2], a + xor a + ld [wcf64], a + ld [wcf65], a + ret + +StartTrainerBattle_SineWave: ; 8c408 (23:4408) + ld a, [wcf64] + cp $60 + jr nc, .end + call .DoSineWave + ret + +.end + ld a, $20 + ld [wJumptableIndex], a + ret + +.DoSineWave: ; 8c419 (23:4419) + ld hl, wcf65 + ld a, [hl] + inc [hl] + ld hl, wcf64 + ld d, [hl] + add [hl] + ld [hl], a + ld a, $90 + ld bc, wd100 + ld e, $0 + +.loop + push af + push de + ld a, e + call StartTrainerBattle_DrawSineWave + ld [bc], a + inc bc + pop de + ld a, e + add $2 + ld e, a + pop af + dec a + jr nz, .loop + ret + +StartTrainerBattle_SetUpForSpinOutro: ; 8c43d (23:443d) + callba Function5602 + ld a, $5 + ld [rSVBK], a ; $ff00+$70 + call StartTrainerBattle_NextScene + xor a + ld [wcf64], a + ret + +spintable_entry: MACRO + db \1 + dw .wedge\2 + dwcoord \3, \4 +ENDM + +; quadrants + const_def + const UPPER_LEFT + const UPPER_RIGHT + const LOWER_LEFT + const LOWER_RIGHT + +StartTrainerBattle_SpinToBlack: ; 8c44f (23:444f) + xor a + ld [hBGMapMode], a ; $ff00+$d4 + ld a, [wcf64] + ld e, a + ld d, 0 + ld hl, .spintable +rept 5 + add hl, de +endr + ld a, [hli] + cp -1 + jr z, .end + ld [wcf65], a + call .load + ld a, $1 + ld [hBGMapMode], a ; $ff00+$d4 + call DelayFrame + call DelayFrame + ld hl, wcf64 + inc [hl] + ret + +.end + ld a, $1 + ld [hBGMapMode], a ; $ff00+$d4 + call DelayFrame + call DelayFrame + call DelayFrame + xor a + ld [hBGMapMode], a ; $ff00+$d4 + ld a, $20 + ld [wJumptableIndex], a + ret +; 8c490 (23:4490) + +.spintable: ; 8c490 + spintable_entry UPPER_LEFT, 1, 1, 6 + spintable_entry UPPER_LEFT, 2, 0, 3 + spintable_entry UPPER_LEFT, 3, 1, 0 + spintable_entry UPPER_LEFT, 4, 5, 0 + spintable_entry UPPER_LEFT, 5, 9, 0 + spintable_entry UPPER_RIGHT, 5, 10, 0 + spintable_entry UPPER_RIGHT, 4, 14, 0 + spintable_entry UPPER_RIGHT, 3, 18, 0 + spintable_entry UPPER_RIGHT, 2, 19, 3 + spintable_entry UPPER_RIGHT, 1, 18, 6 + spintable_entry LOWER_RIGHT, 1, 18, 11 + spintable_entry LOWER_RIGHT, 2, 19, 14 + spintable_entry LOWER_RIGHT, 3, 18, 17 + spintable_entry LOWER_RIGHT, 4, 14, 17 + spintable_entry LOWER_RIGHT, 5, 10, 17 + spintable_entry LOWER_LEFT, 5, 9, 17 + spintable_entry LOWER_LEFT, 4, 5, 17 + spintable_entry LOWER_LEFT, 3, 1, 17 + spintable_entry LOWER_LEFT, 2, 0, 14 + spintable_entry LOWER_LEFT, 1, 1, 11 + db -1 +; 8c4f5 + +.load: ; 8c4f5 (23:44f5) + ld a, [hli] + ld e, a + ld a, [hli] + ld d, a + ld a, [hli] + ld h, [hl] + ld l, a +.loop + push hl + ld a, [de] + ld c, a + inc de +.loop1 + ld [hl], $ff + ld a, [wcf65] + bit 0, a + jr z, .leftside + inc hl + jr .okay1 +.leftside + dec hl +.okay1 + dec c + jr nz, .loop1 + pop hl + ld a, [wcf65] + bit 1, a + ld bc, SCREEN_WIDTH + jr z, .upper + ld bc, -SCREEN_WIDTH +.upper + add hl, bc + ld a, [de] + inc de + cp -1 + ret z + and a + jr z, .loop + ld c, a +.loop2 + ld a, [wcf65] + bit 0, a + jr z, .leftside2 + dec hl + jr .okay2 +.leftside2 + inc hl +.okay2 + dec c + jr nz, .loop2 + jr .loop +; 8c538 (23:4538) + +.wedge1: db 2, 3, 5, 4, 9, -1 +.wedge2: db 1, 1, 2, 2, 4, 2, 4, 2, 3, -1 +.wedge3: db 2, 1, 3, 1, 4, 1, 4, 1, 4, 1, 3, 1, 2, 1, 1, 1, 1, -1 +.wedge4: db 4, 1, 4, 0, 3, 1, 3, 0, 2, 1, 2, 0, 1, -1 +.wedge5: db 4, 0, 3, 0, 3, 0, 2, 0, 2, 0, 1, 0, 1, 0, 1, -1 +; 8c578 + +StartTrainerBattle_SetUpForRandomScatterOutro: ; 8c578 (23:4578) + callba Function5602 + ld a, $5 + ld [rSVBK], a ; $ff00+$70 + call StartTrainerBattle_NextScene + ld a, $10 + ld [wcf64], a + ld a, $1 + ld [hBGMapMode], a ; $ff00+$d4 + ret + +StartTrainerBattle_SpeckleToBlack: ; 8c58f (23:458f) + ld hl, wcf64 + ld a, [hl] + and a + jr z, .done + dec [hl] + ld c, $c +.loop + push bc + call .BlackOutRandomTile + pop bc + dec c + jr nz, .loop + ret + +.done + ld a, $1 + ld [hBGMapMode], a ; $ff00+$d4 + call DelayFrame + call DelayFrame + call DelayFrame + xor a + ld [hBGMapMode], a ; $ff00+$d4 + ld a, $20 + ld [wJumptableIndex], a + ret + +.BlackOutRandomTile: ; 8c5b8 (23:45b8) +.y_loop + call Random + cp SCREEN_HEIGHT + jr nc, .y_loop + ld b, a + +.x_loop + call Random + cp SCREEN_WIDTH + jr nc, .x_loop + ld c, a + + hlcoord 0, -1 + ld de, SCREEN_WIDTH + inc b + +.row_loop + add hl, de + dec b + jr nz, .row_loop + add hl, bc + +; If the tile has already been blacked out, +; sample a new tile + ld a, [hl] + cp $ff + jr z, .y_loop + ld [hl], $ff + ret + +StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc) + ld a, [OtherTrainerClass] + and a + jp z, .nextscene + + xor a + ld [hBGMapMode], a ; $ff00+$d4 + hlcoord 0, 0, AttrMap + ld bc, SCREEN_HEIGHT * SCREEN_WIDTH + inc b + inc c + jr .enter_loop_midway + +.loop + ld a, [hl] + or %00000111 + ld [hli], a +.enter_loop_midway + dec c + jr nz, .loop + dec b + jr nz, .loop + + call .loadpokeballgfx ; load a, [OtherTrainerClass] \ ld de, PokeBallTransition + hlcoord 2, 1 + + ld b, SCREEN_WIDTH - 4 +.loop2 + push hl + ld c, 2 +.loop3 + push hl + ld a, [de] + inc de +.loop4 +; Loading is done bit by bit + and a + jr z, .done + sla a + jr nc, .no_load + ld [hl], $fe ; "8" +.no_load + inc hl + jr .loop4 + +.done + pop hl + push bc + ld bc, (SCREEN_WIDTH - 4) / 2 + add hl, bc + pop bc + dec c + jr nz, .loop3 + + pop hl + push bc + ld bc, SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .loop2 + + ld a, [hCGB] ; $ff00+$e6 + and a + jr nz, .cgb + ld a, $1 + ld [hBGMapMode], a ; $ff00+$d4 + call DelayFrame + call DelayFrame + jr .nextscene + +.cgb + ld hl, .daypals + ld a, [TimeOfDayPal] + and (1 << 2) - 1 + cp 3 + jr nz, .daytime + ld hl, .nightpals +.daytime + ld a, [rSVBK] ; $ff00+$70 + push af + ld a, $5 ; WRAM5 = palettes + ld [rSVBK], a ; $ff00+$70 + call .copypals + push hl + ld de, Unkn1Pals + 8 * 7 + ld bc, $8 + call CopyBytes + pop hl + ld de, BGPals + 8 * 7 + ld bc, $8 + call CopyBytes + pop af + ld [rSVBK], a ; $ff00+$70 + ld a, $1 + ld [hCGBPalUpdate], a ; $ff00+$e5 + call DelayFrame + call Function8cf4f + +.nextscene: ; 8c673 (23:4673) + call StartTrainerBattle_NextScene + ret + +.copypals: ; 8c677 (23:4677) + ld de, Unkn1Pals + 8 * 7 + call .copy + ld de, BGPals + 8 * 7 + call .copy + ld de, Unkn2Pals + 8 * 6 + call .copy + ld de, OBPals + 8 * 6 + call .copy + ld de, Unkn2Pals + 8 * 7 + call .copy + ld de, OBPals + 8 * 7 + +.copy: ; 8c698 (23:4698) + push hl + ld bc, $8 + call CopyBytes + pop hl + ret +; 8c6a1 (23:46a1) + +.daypals: ; 8c6a1 + RGB 31, 18, 29 + RGB 31, 11, 15 + RGB 31, 05, 05 + RGB 07, 07, 07 +; 8c6a9 + +.nightpals: ; 8c6a9 + RGB 31, 18, 29 + RGB 31, 05, 05 + RGB 31, 05, 05 + RGB 31, 05, 05 + +.loadpokeballgfx: + ld a, [OtherTrainerClass] + ld de, PokeBallTransition + ret + +PokeBallTransition: + db %00000011, %11000000 + db %00001111, %11110000 + db %00111100, %00111100 + db %00110000, %00001100 + db %01100000, %00000110 + db %01100011, %11000110 + db %11000110, %01100011 + db %11111100, %00111111 + db %11111100, %00111111 + db %11000110, %01100011 + db %01100011, %11000110 + db %01100000, %00000110 + db %00110000, %00001100 + db %00111100, %00111100 + db %00001111, %11110000 + db %00000011, %11000000 + +WipeLYOverrides: ; 8c6d8 + ld a, [rSVBK] + push af + ld a, $5 + ld [rSVBK], a + ld hl, LYOverrides + call .wipe + ld hl, LYOverridesBackup + call .wipe + pop af + ld [rSVBK], a + ret +; 8c6ef + +.wipe: ; 8c6ef + xor a + ld c, SCREEN_HEIGHT_PX +.loop + ld [hli], a + dec c + jr nz, .loop + ret +; 8c6f7 + + +StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7) + and (1 << 6) - 1 + cp 1 << 5 + jr nc, .okay + call .DoSineWave + ld a, h + ret + +.okay + and (1 << 5) - 1 + call .DoSineWave + ld a, h + xor -1 ; cpl + inc a + ret + +.DoSineWave: ; 8c70c (23:470c) + ld e, a + ld a, d + ld d, 0 + ld hl, .sinewave +rept 2 + add hl, de +endr + ld e, [hl] + inc hl + ld d, [hl] + ld hl, 0 +.loop + srl a + jr nc, .skip + add hl, de +.skip + sla e + rl d + and a + jr nz, .loop + ret +; 8c728 (23:4728) + +.sinewave: ; 8c728 + sine_wave $100 +; 8c768 + +zoombox: macro +; width, height, start y, start x + db \1, \2 + dwcoord \3, \4 +endm + +StartTrainerBattle_ZoomToBlack: ; 8c768 (23:4768) + callba Function5602 + ld de, .boxes + +.loop + ld a, [de] + cp -1 + jr z, .done + inc de + ld c, a + ld a, [de] + inc de + ld b, a + ld a, [de] + inc de + ld l, a + ld a, [de] + inc de + ld h, a + xor a + ld [hBGMapMode], a ; $ff00+$d4 + call .Copy + call WaitBGMap + jr .loop + +.done + ld a, $20 + ld [wJumptableIndex], a + ret +; 8c792 (23:4792) + +.boxes: ; 8c792 + zoombox 4, 2, 8, 8 + zoombox 6, 4, 7, 7 + zoombox 8, 6, 6, 6 + zoombox 10, 8, 5, 5 + zoombox 12, 10, 4, 4 + zoombox 14, 12, 3, 3 + zoombox 16, 14, 2, 2 + zoombox 18, 16, 1, 1 + zoombox 20, 18, 0, 0 + db -1 +; 8c7b7 + +.Copy: ; 8c7b7 (23:47b7) + ld a, $ff +.row + push bc + push hl +.col + ld [hli], a + dec c + jr nz, .col + pop hl + ld bc, SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .row + ret +; 8c7c9 (23:47c9) diff --git a/engine/color.asm b/engine/color.asm index 0e932f786..ed65f59df 100644 --- a/engine/color.asm +++ b/engine/color.asm @@ -83,7 +83,7 @@ Function8aa4: ; 8aa4 push bc ld hl, PalPacket_9ce6 ld de, wcda9 - ld bc, $0010 + ld bc, PalPacket_9cf6 - PalPacket_9ce6 call CopyBytes pop bc pop de @@ -105,7 +105,7 @@ Function8aa4: ; 8aa4 Function8ad1: ; 8ad1 ld hl, PalPacket_9c56 + 1 - call Function9610 + call CopyFourPalettes call Function971a call Function9699 ret @@ -196,8 +196,8 @@ Function8b4d: ; 8b4d .asm_8b5c ld de, Unkn2Pals ld a, $3b - call Function9625 - jp Function9630 + call GetAthPalletFromPalettes9df6 + jp LoadHLPaletteIntoDE ; 8b67 Function8b67: ; 8b67 @@ -212,8 +212,8 @@ Function8b67: ; 8b67 .asm_8b76 ld de, Unkn2Pals ld a, $3c - call Function9625 - jp Function9630 + call GetAthPalletFromPalettes9df6 + jp LoadHLPaletteIntoDE ; 8b81 Function8b81: ; 8b81 @@ -309,7 +309,7 @@ Function8bec: ; 8bec .asm_8c0b ld b, $0 add hl, bc - ld bc, $0604 + lb bc, 6, 4 ld a, [EnemySafeguardCount] and $3 call Function9663 @@ -386,7 +386,7 @@ endr jr .asm_8c7b .asm_8c82 - ld bc, $0208 + lb bc, 2, 8 ld a, e call Function9663 ret @@ -520,7 +520,7 @@ INCLUDE "predef/cgb.asm" Function95f0: ; 95f0 ld hl, Palette_9608 ld de, Unkn1Pals - ld bc, $0008 + ld bc, 8 ld a, $5 call FarCopyWRAM call Function96a4 @@ -537,28 +537,29 @@ Palette_9608: ; 9608 ; 9610 -Function9610: ; 9610 +CopyFourPalettes: ; 9610 ld de, Unkn1Pals ld c, $4 -Function9615: ; 9615 +CopyPalettes: ; 9615 +.loop push bc ld a, [hli] push hl - call Function9625 - call Function9630 + call GetAthPalletFromPalettes9df6 + call LoadHLPaletteIntoDE pop hl inc hl pop bc dec c - jr nz, Function9615 + jr nz, .loop ret ; 9625 -Function9625: ; 9625 +GetAthPalletFromPalettes9df6: ; 9625 ld l, a ld h, $0 -rept 3 +rept 3 ; multiply by 8 add hl, hl endr ld bc, Palettes_9df6 @@ -566,18 +567,18 @@ endr ret ; 9630 -Function9630: ; 9630 +LoadHLPaletteIntoDE: ; 9630 ld a, [rSVBK] push af ld a, $5 ld [rSVBK], a ld c, $8 -.asm_9639 +.loop ld a, [hli] ld [de], a inc de dec c - jr nz, .asm_9639 + jr nz, .loop pop af ld [rSVBK], a ret @@ -595,12 +596,12 @@ Function9643: ; 9643 ld [de], a inc de ld c, $4 -.asm_9654 +.loop ld a, [hli] ld [de], a inc de dec c - jr nz, .asm_9654 + jr nz, .loop xor a ld [de], a inc de @@ -612,19 +613,19 @@ Function9643: ; 9643 ; 9663 Function9663: ; 9663 -.asm_9663 +.row push bc push hl -.asm_9665 +.col ld [hli], a dec c - jr nz, .asm_9665 + jr nz, .col pop hl - ld bc, $0014 + ld bc, SCREEN_WIDTH add hl, bc pop bc dec b - jr nz, .asm_9663 + jr nz, .row ret ; 9673 @@ -743,7 +744,7 @@ Function96f3: ; 96f3 jr .asm_970b .asm_9712 - ld bc, $0208 + lb bc, 2, 8 ld a, e call Function9663 ret @@ -784,16 +785,16 @@ Function973a: ; 973a Function974b: ; 974b and a jp nz, Function97f9 - ld a, [wd45b] + ld a, [wPlayerSpriteSetupFlags] bit 2, a - jr nz, .asm_9760 + jr nz, .male ld a, [PlayerGender] and a - jr z, .asm_9760 + jr z, .male ld hl, KrisPalette ret -.asm_9760 +.male ld hl, PlayerPalette ret ; 9764 @@ -876,21 +877,21 @@ Function97cc: ; 97cc ld a, $90 ld [rOBPI], a ld a, $1c - call Function9625 + call GetAthPalletFromPalettes9df6 call Function97e5 ld a, $21 - call Function9625 + call GetAthPalletFromPalettes9df6 call Function97e5 ret ; 97e5 Function97e5: ; 97e5 ld c, $8 -.asm_97e7 +.loop ld a, [hli] ld [rOBPD], a dec c - jr nz, .asm_97e7 + jr nz, .loop ret ; 97ee @@ -935,32 +936,32 @@ Function981a: ; 981a and $7 ret z ld b, a -.asm_981f +.loop push bc xor a ld [rJOYP], a ld a, $30 ld [rJOYP], a ld b, $10 -.asm_9829 +.loop2 ld e, $8 ld a, [hli] ld d, a -.asm_982d +.loop3 bit 0, d ld a, $10 - jr nz, .asm_9835 + jr nz, .okay ld a, $20 -.asm_9835 +.okay ld [rJOYP], a ld a, $30 ld [rJOYP], a rr d dec e - jr nz, .asm_982d + jr nz, .loop3 dec b - jr nz, .asm_9829 + jr nz, .loop2 ld a, $20 ld [rJOYP], a ld a, $30 @@ -968,7 +969,7 @@ Function981a: ; 981a call Function9a7a pop bc dec b - jr nz, .asm_981f + jr nz, .loop ret ; 9853 diff --git a/engine/credits.asm b/engine/credits.asm index 524b97fb2..793891dd2 100644 --- a/engine/credits.asm +++ b/engine/credits.asm @@ -124,7 +124,7 @@ Function109847:: ; 109847 jr z, .asm_10984f ld a, $40 .asm_10984f - ld [wcf63], a + ld [wJumptableIndex], a ld a, [rSVBK] push af @@ -148,17 +148,17 @@ Function109847:: ; 109847 jr nz, .asm_10986a ld de, CreditsBorderGFX - ld hl, $9200 + ld hl, VTiles2 tile $20 lb bc, BANK(CreditsBorderGFX), $09 call Request2bpp ld de, CopyrightGFX - ld hl, $9600 + ld hl, VTiles2 tile $60 lb bc, BANK(CopyrightGFX), $1d call Request2bpp ld de, TheEndGFX - ld hl, $9400 + ld hl, VTiles2 tile $40 lb bc, BANK(TheEndGFX), $10 call Request2bpp @@ -193,7 +193,7 @@ Function109847:: ; 109847 ld a, $5 ld [hVBlank], a ld a, $1 - ld [$ffaa], a + ld [hInMenu], a xor a ld [hBGMapMode], a ld [CreditsPos], a @@ -225,7 +225,7 @@ Function1098fd: ; 1098fd ld a, [hJoypadDown] and $1 ret z - ld a, [wcf63] + ld a, [wJumptableIndex] bit 7, a ret ; 109908 @@ -234,7 +234,7 @@ Function109908: ; 109908 ld a, [hJoypadDown] and $2 ret z - ld a, [wcf63] + ld a, [wJumptableIndex] bit 6, a ret z ld hl, CreditsPos @@ -255,7 +255,7 @@ Function109908: ; 109908 ; 109926 Function109926: ; 109926 - ld a, [wcf63] + ld a, [wJumptableIndex] and $f ld e, a ld d, 0 @@ -287,12 +287,12 @@ Jumptable_109937: ; 109937 (42:5937) Function109951: ; 109951 (42:5951) - ld hl, wcf63 + ld hl, wJumptableIndex inc [hl] ret Function109956: ; 109956 (42:5956) - ld hl, wcf63 + ld hl, wJumptableIndex ld a, [hl] and $f0 ld [hl], a @@ -348,7 +348,7 @@ Function1099a3: ; 1099a3 (42:59a3) ParseCredits: ; 1099aa - ld hl, wcf63 + ld hl, wJumptableIndex bit 7, [hl] jp nz, .done @@ -488,7 +488,7 @@ endr .end ; Stop execution. - ld hl, wcf63 + ld hl, wJumptableIndex set 7, [hl] ld a, $20 ld [MusicFade], a diff --git a/engine/engine_flags.asm b/engine/engine_flags.asm index 278c7c996..5baa52cc4 100644 --- a/engine/engine_flags.asm +++ b/engine/engine_flags.asm @@ -1,198 +1,200 @@ ; All locations are in WRAM bank 1. - +engine_flag: MACRO + dwb \1, 1 << \2 +ENDM ; location, bit ; pokegear - dwb wPokegearFlags, %00000010 ; radio card ; $0 - dwb wPokegearFlags, %00000001 ; map card - dwb wPokegearFlags, %00000100 ; phone card - dwb wPokegearFlags, %00001000 ; expn card - dwb wPokegearFlags, %10000000 ; on/off - - ; wDaycareMan, %10000000 ; daycare 1 on - dwb wDaycareMan, %01000000 ; monster 1 and 2 are compatible - ; wDaycareMan, %00100000 ; egg is ready - dwb wDaycareMan, %00000001 ; monster 1 in daycare - - ; wDaycareLady, %10000000 = daycare 2 on - dwb wDaycareLady, %00000001 ; monster 2 in daycare - - dwb wMomSavingMoney, %00000001 ; mom saving money ; $8 - dwb wMomSavingMoney, %10000000 ; dst - - dwb wdc39, %00000001 - - dwb StatusFlags, %00000001 ; pokedex - dwb StatusFlags, %00000010 ; unown dex - dwb StatusFlags, %00001000 ; pokerus - dwb StatusFlags, %00010000 ; rocket signal on ch20 - dwb StatusFlags, %01000000 ; credits skip - dwb StatusFlags, %10000000 ; bug contest on ; $10 - dwb StatusFlags2, %00000100 ; bug contest timer - dwb StatusFlags2, %00000010 - dwb StatusFlags2, %00000001 ; rockets in radio tower - dwb StatusFlags2, %00010000 ; bike shop call enabled (1024 bike steps reqd) - dwb StatusFlags2, %00100000 ; give pokerus; berry -> berry juice when trading? - dwb StatusFlags2, %01000000 - dwb StatusFlags2, %10000000 ; rockets in mahogany - - dwb BikeFlags, %00000001 ; strength active ; $18 - dwb BikeFlags, %00000010 ; always on bike (cant surf) - dwb BikeFlags, %00000100 ; downhill (cycling road) - - dwb JohtoBadges, %00000001 ; zephyrbadge - dwb JohtoBadges, %00000010 ; hivebadge - dwb JohtoBadges, %00000100 ; plainbadge - dwb JohtoBadges, %00001000 ; fogbadge - dwb JohtoBadges, %00010000 ; mineralbadge - dwb JohtoBadges, %00100000 ; stormbadge ; $20 - dwb JohtoBadges, %01000000 ; glacierbadge - dwb JohtoBadges, %10000000 ; risingbadge - - dwb KantoBadges, %00000001 ; boulderbadge - dwb KantoBadges, %00000010 ; cascadebadge - dwb KantoBadges, %00000100 ; thunderbadge - dwb KantoBadges, %00001000 ; rainbowbadge - dwb KantoBadges, %00010000 ; soulbadge - dwb KantoBadges, %00100000 ; marshbadge ; $28 - dwb KantoBadges, %01000000 ; volcanobadge - dwb KantoBadges, %10000000 ; earthbadge + engine_flag wPokegearFlags, 1 ; radio card ; $0 + engine_flag wPokegearFlags, 0 ; map card + engine_flag wPokegearFlags, 2 ; phone card + engine_flag wPokegearFlags, 3 ; expn card + engine_flag wPokegearFlags, 7 ; on/off + + ; wDaycareMan, 7 ; daycare 1 on + engine_flag wDaycareMan, 6 ; monster 1 and 2 are compatible + ; wDaycareMan, 5 ; egg is ready + engine_flag wDaycareMan, 0 ; monster 1 in daycare + + ; wDaycareLady, 7 = daycare 2 on + engine_flag wDaycareLady, 0 ; monster 2 in daycare + + engine_flag wMomSavingMoney, 0 ; mom saving money ; $8 + engine_flag wMomSavingMoney, 7 ; dst + + engine_flag wdc39, 0 + + engine_flag StatusFlags, 0 ; pokedex + engine_flag StatusFlags, 1 ; unown dex + engine_flag StatusFlags, 3 ; pokerus + engine_flag StatusFlags, 4 ; rocket signal on ch20 + engine_flag StatusFlags, 6 ; credits skip + engine_flag StatusFlags, 7 ; bug contest on ; $10 + engine_flag StatusFlags2, 2 ; bug contest timer + engine_flag StatusFlags2, 1 + engine_flag StatusFlags2, 0 ; rockets in radio tower + engine_flag StatusFlags2, 4 ; bike shop call enabled (1024 bike steps reqd) + engine_flag StatusFlags2, 5 ; give pokerus + engine_flag StatusFlags2, 6 ; berry -> berry juice when trading? + engine_flag StatusFlags2, 7 ; rockets in mahogany + + engine_flag BikeFlags, 0 ; strength active ; $18 + engine_flag BikeFlags, 1 ; always on bike (cant surf) + engine_flag BikeFlags, 2 ; downhill (cycling road) + + engine_flag JohtoBadges, 0 ; zephyrbadge + engine_flag JohtoBadges, 1 ; hivebadge + engine_flag JohtoBadges, 2 ; plainbadge + engine_flag JohtoBadges, 3 ; fogbadge + engine_flag JohtoBadges, 4 ; mineralbadge + engine_flag JohtoBadges, 5 ; stormbadge ; $20 + engine_flag JohtoBadges, 6 ; glacierbadge + engine_flag JohtoBadges, 7 ; risingbadge + + engine_flag KantoBadges, 0 ; boulderbadge + engine_flag KantoBadges, 1 ; cascadebadge + engine_flag KantoBadges, 2 ; thunderbadge + engine_flag KantoBadges, 3 ; rainbowbadge + engine_flag KantoBadges, 4 ; soulbadge + engine_flag KantoBadges, 5 ; marshbadge ; $28 + engine_flag KantoBadges, 6 ; volcanobadge + engine_flag KantoBadges, 7 ; earthbadge ; unown sets - dwb UnlockedUnowns, %00000001 ; 1 - dwb UnlockedUnowns, %00000010 ; 2 - dwb UnlockedUnowns, %00000100 ; 3 - dwb UnlockedUnowns, %00001000 ; 4 - dwb UnlockedUnowns, %00010000 ; 5 - dwb UnlockedUnowns, %00100000 ; 6 ; $30 - dwb UnlockedUnowns, %01000000 ; 7 - dwb UnlockedUnowns, %10000000 ; 8 + engine_flag UnlockedUnowns, 0 ; 1 + engine_flag UnlockedUnowns, 1 ; 2 + engine_flag UnlockedUnowns, 2 ; 3 + engine_flag UnlockedUnowns, 3 ; 4 + engine_flag UnlockedUnowns, 4 ; 5 + engine_flag UnlockedUnowns, 5 ; 6 ; $30 + engine_flag UnlockedUnowns, 6 ; 7 + engine_flag UnlockedUnowns, 7 ; 8 ; fly - dwb VisitedSpawns, %00000001 ; your house - dwb VisitedSpawns, %00000010 ; viridian pokecenter - dwb VisitedSpawns, %00000100 ; pallet - dwb VisitedSpawns, %00001000 ; viridian - dwb VisitedSpawns, %00010000 ; pewter - dwb VisitedSpawns, %00100000 ; cerulean ; $38 - dwb VisitedSpawns, %01000000 ; rock tunnel - dwb VisitedSpawns, %10000000 ; vermilion - dwb VisitedSpawns + 1, %00000001 ; lavender - dwb VisitedSpawns + 1, %00000010 ; saffron - dwb VisitedSpawns + 1, %00000100 ; celadon - dwb VisitedSpawns + 1, %00001000 ; fuchsia - dwb VisitedSpawns + 1, %00010000 ; cinnabar - dwb VisitedSpawns + 1, %00100000 ; indigo plateau ; $40 - dwb VisitedSpawns + 1, %01000000 ; new bark - dwb VisitedSpawns + 1, %10000000 ; cherrygrove - dwb VisitedSpawns + 2, %00000001 ; violet - dwb VisitedSpawns + 2, %00000100 ; azalea - dwb VisitedSpawns + 2, %00001000 ; cianwood - dwb VisitedSpawns + 2, %00010000 ; goldenrod - dwb VisitedSpawns + 2, %00100000 ; olivine - dwb VisitedSpawns + 2, %01000000 ; ecruteak ; $48 - dwb VisitedSpawns + 2, %10000000 ; mahogany - dwb VisitedSpawns + 3, %00000001 ; lake of rage - dwb VisitedSpawns + 3, %00000010 ; blackthorn - dwb VisitedSpawns + 3, %00000100 ; silver cave - dwb VisitedSpawns + 3, %00010000 ; unused - - dwb wLuckyNumberShowFlag, %00000001 ; lucky number show - dwb StatusFlags2, %00001000 - - dwb DailyFlags, %00000001 ; kurt making balls ; $50 - dwb DailyFlags, %00000010 - dwb DailyFlags, %00000100 ; special wilddata? - dwb DailyFlags, %00001000 ; time capsule (24h wait) - dwb DailyFlags, %00010000 ; all fruit trees - dwb DailyFlags, %00100000 ; shuckle given - dwb DailyFlags, %01000000 ; goldenrod underground merchant closed - dwb DailyFlags, %10000000 ; fought in trainer hall today - - dwb WeeklyFlags, %00000001 ; mt moon square clefairy ; $58 - dwb WeeklyFlags, %00000010 ; union cave lapras - dwb WeeklyFlags, %00000100 ; goldenrod underground haircut used - dwb WeeklyFlags, %00001000 ; goldenrod mall happiness event floor05 person07 - dwb WeeklyFlags, %00010000 ; tea in blues house - dwb WeeklyFlags, %00100000 ; indigo plateau rival fight - dwb WeeklyFlags, %01000000 ; move tutor - dwb WeeklyFlags, %10000000 ; buenas password - - dwb SwarmFlags, %00000001 ; $60 - dwb SwarmFlags, %00000010 ; goldenrod dept store sale is on - - dwb GameTimerPause, %10000000 ; $62 - - dwb PlayerGender, %00000001 ; player is female - - dwb wdbf3, %00000100 ; have gs ball after kurt examined it + engine_flag VisitedSpawns, 0 ; your house + engine_flag VisitedSpawns, 1 ; viridian pokecenter + engine_flag VisitedSpawns, 2 ; pallet + engine_flag VisitedSpawns, 3 ; viridian + engine_flag VisitedSpawns, 4 ; pewter + engine_flag VisitedSpawns, 5 ; cerulean ; $38 + engine_flag VisitedSpawns, 6 ; rock tunnel + engine_flag VisitedSpawns, 7 ; vermilion + engine_flag VisitedSpawns + 1, 0 ; lavender + engine_flag VisitedSpawns + 1, 1 ; saffron + engine_flag VisitedSpawns + 1, 2 ; celadon + engine_flag VisitedSpawns + 1, 3 ; fuchsia + engine_flag VisitedSpawns + 1, 4 ; cinnabar + engine_flag VisitedSpawns + 1, 5 ; indigo plateau ; $40 + engine_flag VisitedSpawns + 1, 6 ; new bark + engine_flag VisitedSpawns + 1, 7 ; cherrygrove + engine_flag VisitedSpawns + 2, 0 ; violet + engine_flag VisitedSpawns + 2, 2 ; azalea + engine_flag VisitedSpawns + 2, 3 ; cianwood + engine_flag VisitedSpawns + 2, 4 ; goldenrod + engine_flag VisitedSpawns + 2, 5 ; olivine + engine_flag VisitedSpawns + 2, 6 ; ecruteak ; $48 + engine_flag VisitedSpawns + 2, 7 ; mahogany + engine_flag VisitedSpawns + 3, 0 ; lake of rage + engine_flag VisitedSpawns + 3, 1 ; blackthorn + engine_flag VisitedSpawns + 3, 2 ; silver cave + engine_flag VisitedSpawns + 3, 4 ; unused + + engine_flag wLuckyNumberShowFlag, 0 ; lucky number show + engine_flag StatusFlags2, 3 ; ???? + + engine_flag DailyFlags, 0 ; kurt making balls ; $50 + engine_flag DailyFlags, 1 ; ???? + engine_flag DailyFlags, 2 ; special wilddata? + engine_flag DailyFlags, 3 ; time capsule (24h wait) + engine_flag DailyFlags, 4 ; all fruit trees + engine_flag DailyFlags, 5 ; shuckle given + engine_flag DailyFlags, 6 ; goldenrod underground merchant closed + engine_flag DailyFlags, 7 ; fought in trainer hall today + + engine_flag WeeklyFlags, 0 ; mt moon square clefairy ; $58 + engine_flag WeeklyFlags, 1 ; union cave lapras + engine_flag WeeklyFlags, 2 ; goldenrod underground haircut used + engine_flag WeeklyFlags, 3 ; goldenrod mall happiness event floor05 person07 + engine_flag WeeklyFlags, 4 ; tea in blues house + engine_flag WeeklyFlags, 5 ; indigo plateau rival fight + engine_flag WeeklyFlags, 6 ; move tutor + engine_flag WeeklyFlags, 7 ; buenas password + + engine_flag SwarmFlags, 0 ; $60 + engine_flag SwarmFlags, 1 ; goldenrod dept store sale is on + + engine_flag GameTimerPause, 7 ; $62 + + engine_flag PlayerGender, 0 ; player is female + + engine_flag wCelebiEvent, 2 ; have gs ball after kurt examined it ; rematches - dwb wDailyRematchFlags, %00000001 ; jack - dwb wDailyRematchFlags, %00000010 ; huey - dwb wDailyRematchFlags, %00000100 ; gaven - dwb wDailyRematchFlags, %00001000 ; beth ; $68 - dwb wDailyRematchFlags, %00010000 ; jose - dwb wDailyRematchFlags, %00100000 ; reena - dwb wDailyRematchFlags, %01000000 ; joey - dwb wDailyRematchFlags, %10000000 ; wade - dwb wDailyRematchFlags + 1, %00000001 ; ralph - dwb wDailyRematchFlags + 1, %00000010 ; liz - dwb wDailyRematchFlags + 1, %00000100 ; anthony - dwb wDailyRematchFlags + 1, %00001000 ; todd ; $70 - dwb wDailyRematchFlags + 1, %00010000 ; gina - dwb wDailyRematchFlags + 1, %00100000 ; arnie - dwb wDailyRematchFlags + 1, %01000000 ; alan - dwb wDailyRematchFlags + 1, %10000000 ; dana - dwb wDailyRematchFlags + 2, %00000001 ; chad - dwb wDailyRematchFlags + 2, %00000010 ; tully - dwb wDailyRematchFlags + 2, %00000100 ; brent - dwb wDailyRematchFlags + 2, %00001000 ; tiffany ; $78 - dwb wDailyRematchFlags + 2, %00010000 ; vance - dwb wDailyRematchFlags + 2, %00100000 ; wilton - dwb wDailyRematchFlags + 2, %01000000 ; parry - dwb wDailyRematchFlags + 2, %10000000 ; erin - - dwb wDailyPhoneItemFlags, %00000001 ; beverly has nugget - dwb wDailyPhoneItemFlags, %00000010 ; jose has star piece - dwb wDailyPhoneItemFlags, %00000100 ; wade has item (see bittable1 $032b-e) - dwb wDailyPhoneItemFlags, %00001000 ; gina has leaf stone ; $80 - dwb wDailyPhoneItemFlags, %00010000 ; alan has fire stone - dwb wDailyPhoneItemFlags, %00100000 ; liz has thunderstone - dwb wDailyPhoneItemFlags, %01000000 ; derek has nugget - dwb wDailyPhoneItemFlags, %10000000 ; tully has water stone - - dwb wDailyPhoneItemFlags + 1, %00000001 ; tiffany has pink bow - dwb wDailyPhoneItemFlags + 1, %00000010 ; wilton has item (see bittable1 $032f-31) - - dwb wDailyPhoneTimeOfDayFlags, %00000001 - dwb wDailyPhoneTimeOfDayFlags, %00000010 ; $88 - dwb wDailyPhoneTimeOfDayFlags, %00000100 - dwb wDailyPhoneTimeOfDayFlags, %00001000 - dwb wDailyPhoneTimeOfDayFlags, %00010000 - dwb wDailyPhoneTimeOfDayFlags, %00100000 - dwb wDailyPhoneTimeOfDayFlags, %01000000 - dwb wDailyPhoneTimeOfDayFlags, %10000000 - - dwb wDailyPhoneTimeOfDayFlags + 1, %00000001 - dwb wDailyPhoneTimeOfDayFlags + 1, %00000010 ; $90 - dwb wDailyPhoneTimeOfDayFlags + 1, %00000100 - dwb wDailyPhoneTimeOfDayFlags + 1, %00001000 - dwb wDailyPhoneTimeOfDayFlags + 1, %00010000 - dwb wDailyPhoneTimeOfDayFlags + 1, %00100000 - dwb wDailyPhoneTimeOfDayFlags + 1, %01000000 - dwb wDailyPhoneTimeOfDayFlags + 1, %10000000 - - dwb wDailyPhoneTimeOfDayFlags + 2, %00000001 - dwb wDailyPhoneTimeOfDayFlags + 2, %00000010 ; $98 - dwb wDailyPhoneTimeOfDayFlags + 2, %00000100 - dwb wDailyPhoneTimeOfDayFlags + 2, %00001000 - dwb wDailyPhoneTimeOfDayFlags + 2, %00010000 - dwb wDailyPhoneTimeOfDayFlags + 2, %00100000 - dwb wDailyPhoneTimeOfDayFlags + 2, %01000000 - dwb wDailyPhoneTimeOfDayFlags + 2, %10000000 - - dwb wd45b, %00000100 ; female player has been transformed into male - - dwb SwarmFlags, %00000100 ; dunsparce swarm ; $a0 - dwb SwarmFlags, %00001000 ; yanma swarm + engine_flag wDailyRematchFlags, 0 ; jack + engine_flag wDailyRematchFlags, 1 ; huey + engine_flag wDailyRematchFlags, 2 ; gaven + engine_flag wDailyRematchFlags, 3 ; beth ; $68 + engine_flag wDailyRematchFlags, 4 ; jose + engine_flag wDailyRematchFlags, 5 ; reena + engine_flag wDailyRematchFlags, 6 ; joey + engine_flag wDailyRematchFlags, 7 ; wade + engine_flag wDailyRematchFlags + 1, 0 ; ralph + engine_flag wDailyRematchFlags + 1, 1 ; liz + engine_flag wDailyRematchFlags + 1, 2 ; anthony + engine_flag wDailyRematchFlags + 1, 3 ; todd ; $70 + engine_flag wDailyRematchFlags + 1, 4 ; gina + engine_flag wDailyRematchFlags + 1, 5 ; arnie + engine_flag wDailyRematchFlags + 1, 6 ; alan + engine_flag wDailyRematchFlags + 1, 7 ; dana + engine_flag wDailyRematchFlags + 2, 0 ; chad + engine_flag wDailyRematchFlags + 2, 1 ; tully + engine_flag wDailyRematchFlags + 2, 2 ; brent + engine_flag wDailyRematchFlags + 2, 3 ; tiffany ; $78 + engine_flag wDailyRematchFlags + 2, 4 ; vance + engine_flag wDailyRematchFlags + 2, 5 ; wilton + engine_flag wDailyRematchFlags + 2, 6 ; parry + engine_flag wDailyRematchFlags + 2, 7 ; erin + + engine_flag wDailyPhoneItemFlags, 0 ; beverly has nugget + engine_flag wDailyPhoneItemFlags, 1 ; jose has star piece + engine_flag wDailyPhoneItemFlags, 2 ; wade has item (see bittable1 $032b-e) + engine_flag wDailyPhoneItemFlags, 3 ; gina has leaf stone ; $80 + engine_flag wDailyPhoneItemFlags, 4 ; alan has fire stone + engine_flag wDailyPhoneItemFlags, 5 ; liz has thunderstone + engine_flag wDailyPhoneItemFlags, 6 ; derek has nugget + engine_flag wDailyPhoneItemFlags, 7 ; tully has water stone + + engine_flag wDailyPhoneItemFlags + 1, 0 ; tiffany has pink bow + engine_flag wDailyPhoneItemFlags + 1, 1 ; wilton has item (see bittable1 $032f-31) + + engine_flag wDailyPhoneTimeOfDayFlags, 0 + engine_flag wDailyPhoneTimeOfDayFlags, 1 ; $88 + engine_flag wDailyPhoneTimeOfDayFlags, 2 + engine_flag wDailyPhoneTimeOfDayFlags, 3 + engine_flag wDailyPhoneTimeOfDayFlags, 4 + engine_flag wDailyPhoneTimeOfDayFlags, 5 + engine_flag wDailyPhoneTimeOfDayFlags, 6 + engine_flag wDailyPhoneTimeOfDayFlags, 7 + + engine_flag wDailyPhoneTimeOfDayFlags + 1, 0 + engine_flag wDailyPhoneTimeOfDayFlags + 1, 1 ; $90 + engine_flag wDailyPhoneTimeOfDayFlags + 1, 2 + engine_flag wDailyPhoneTimeOfDayFlags + 1, 3 + engine_flag wDailyPhoneTimeOfDayFlags + 1, 4 + engine_flag wDailyPhoneTimeOfDayFlags + 1, 5 + engine_flag wDailyPhoneTimeOfDayFlags + 1, 6 + engine_flag wDailyPhoneTimeOfDayFlags + 1, 7 + + engine_flag wDailyPhoneTimeOfDayFlags + 2, 0 + engine_flag wDailyPhoneTimeOfDayFlags + 2, 1 ; $98 + engine_flag wDailyPhoneTimeOfDayFlags + 2, 2 + engine_flag wDailyPhoneTimeOfDayFlags + 2, 3 + engine_flag wDailyPhoneTimeOfDayFlags + 2, 4 + engine_flag wDailyPhoneTimeOfDayFlags + 2, 5 + engine_flag wDailyPhoneTimeOfDayFlags + 2, 6 + engine_flag wDailyPhoneTimeOfDayFlags + 2, 7 + + engine_flag wPlayerSpriteSetupFlags, 2 ; female player has been transformed into male + + engine_flag SwarmFlags, 2 ; dunsparce swarm ; $a0 + engine_flag SwarmFlags, 3 ; yanma swarm diff --git a/engine/events.asm b/engine/events.asm index e0770b7a0..0740da545 100644 --- a/engine/events.asm +++ b/engine/events.asm @@ -123,7 +123,7 @@ StartMap: ; 96724 ld hl, MapStatus ld bc, $3e ; 62 call ByteFill - callba Function113e5 + callba InitCallReceiveDelay call ClearJoypad ; fallthrough ; 9673e @@ -138,19 +138,19 @@ EnterMap: ; 9673e call ClearAllScriptFlags3 ld a, [hMapEntryMethod] - cp $f7 + cp MAPSETUP_07 jr nz, .dontset call SetAll_ScriptFlags3 .dontset ld a, [hMapEntryMethod] - cp $f3 + cp MAPSETUP_RELOADMAP jr nz, .dontresetpoison xor a ld [PoisonStepCount], a .dontresetpoison - xor a + xor a ; end map entry ld [hMapEntryMethod], a ld a, 2 ; HandleMap ld [MapStatus], a @@ -285,12 +285,12 @@ Function96812: ; 96812 PlayerEvents: ; 9681f xor a - +; If there's already a player event, don't interrupt it. ld a, [ScriptRunning] and a ret nz - call Function968e4 + call Dummy_CheckScriptFlags3Bit5 ; This is a waste of time call CheckTrainerBattle3 jr c, .ok @@ -298,13 +298,13 @@ PlayerEvents: ; 9681f call CheckTileEvent jr c, .ok - call Function97c30 + call RunMemScript jr c, .ok - call Function968ec + call DoMapTrigger jr c, .ok - call Function9693a + call CheckTimeEvents jr c, .ok call OWPlayerInput @@ -320,7 +320,7 @@ PlayerEvents: ; 9681f pop af ld [ScriptRunning], a - call Function96beb + call DoPlayerEvent ld a, [ScriptRunning] cp 4 jr z, .ok2 @@ -361,7 +361,7 @@ CheckTileEvent: ; 96874 callba CheckMovingOffEdgeOfMap jr c, .return4 - call Function2238 + call CheckWarpTile jr c, .return6 .bit2 @@ -436,11 +436,11 @@ SetUpFiveStepWildEncounterCooldown: ; 968d1 ret ; 968d7 -Function968d7: ; 968d7 +ret_968d7: ; 968d7 ret -; 968d8 +;968d8 -Function968d8: ; 968d8 +SetMinTwoStepWildEncounterCooldown: ; 968d8 ld a, [wWildEncounterCooldown] cp 2 ret nc @@ -449,15 +449,15 @@ Function968d8: ; 968d8 ret ; 968e4 -Function968e4: ; 968e4 +Dummy_CheckScriptFlags3Bit5: ; 968e4 call CheckBit5_ScriptFlags3 ret z - call Function2f3e + call ret_2f3e ret ; 968ec -Function968ec: ; 968ec - ld a, [wdc07] +DoMapTrigger: ; 968ec + ld a, [wCurrMapTriggerCount] and a jr z, .nope @@ -468,7 +468,7 @@ Function968ec: ; 968ec ld e, a ld d, 0 - ld hl, wdc07 + 1 + ld hl, wCurrMapTriggerHeaderPointer ld a, [hli] ld h, [hl] ld l, a @@ -505,23 +505,23 @@ endr ret ; 9693a -Function9693a: ; 9693a - ld a, [InLinkBattle] +CheckTimeEvents: ; 9693a + ld a, [wLinkMode] and a jr nz, .nothing ld hl, StatusFlags2 bit 2, [hl] - jr z, .asm_96951 + jr z, .do_daily - callba Function114a4 - jr c, .elevator + callba CheckBugContestTimer + jr c, .end_bug_contest xor a ret -.asm_96951 - callba Function11452 - callba Function114e7 +.do_daily + callba CheckDailyResetTimer + callba CheckPokerusTrick callba CheckPhoneCall ret c @@ -529,7 +529,7 @@ Function9693a: ; 9693a xor a ret -.elevator +.end_bug_contest ld a, BANK(BugCatchingContestOverScript) ld hl, BugCatchingContestOverScript call CallScript @@ -537,7 +537,7 @@ Function9693a: ; 9693a ret ; 96970 -Function96970: ; 96970 +.unused ; 96970 ld a, 8 scf ret @@ -856,7 +856,7 @@ PlayerMovement: ; 96af0 ; 96b10 .seven ; 96b10 - call Function968d7 ; empty + call ret_968d7 ; mobile xor a ld c, a ret @@ -898,7 +898,7 @@ PlayerMovement: ; 96af0 CheckMenuOW: ; 96b30 xor a - ld [$ffa0], a + ld [hMenuReturn], a ld [$ffa1], a ld a, [hJoyPressed] @@ -940,9 +940,9 @@ SelectMenuScript: ; 96b5f StartMenuCallback: SelectMenuCallback: ; 96b66 - copybytetovar $ffa0 - if_equal %10000000, .Script - if_equal -1, .Asm + copybytetovar hMenuReturn + if_equal HMENURETURN_SCRIPT, .Script + if_equal HMENURETURN_ASM, .Asm end ; 96b72 @@ -957,76 +957,86 @@ SelectMenuCallback: ; 96b66 CountStep: ; 96b79 - ld a, [InLinkBattle] + ; Don't count steps in link communication rooms. + ld a, [wLinkMode] and a jr nz, .done - callba Function90136 - jr c, .setminus1 + ; If there is a special phone call, don't count the step. + callba CheckSpecialPhoneCall + jr c, .doscript - call Function96bd7 - jr c, .setminus1 + ; If Repel wore off, don't count the step. + call DoRepelStep + jr c, .doscript + ; Count the step for poison and total steps ld hl, PoisonStepCount inc [hl] ld hl, StepCount inc [hl] - jr nz, .asm_96b9c + ; Every 256 steps, increase the happiness of all your Pokemon. + jr nz, .skip_happiness callba StepHappiness -.asm_96b9c +.skip_happiness + ; Every 256 steps, offset from the happiness incrementor by 128 steps, + ; decrease the hatch counter of all your eggs until you reach the first + ; one that is ready to hatch. ld a, [StepCount] cp $80 - jr nz, .asm_96bab + jr nz, .skip_egg - callba Function16f3e - jr nz, .set8 + callba DoEggStep + jr nz, .hatch -.asm_96bab +.skip_egg + ; Increase the EXP of (both) DayCare Pokemon by 1. callba DaycareStep + ; Every four steps, deal damage to all Poisoned Pokemon ld hl, PoisonStepCount ld a, [hl] cp 4 - jr c, .poisoned + jr c, .skip_poison ld [hl], 0 - callba Function505da - jr c, .setminus1 + callba DoPoisonStep + jr c, .doscript -.poisoned - callba Function97db3 +.skip_poison + callba DoBikeStep .done xor a ret -.setminus1 +.doscript ld a, -1 scf ret -.set8 +.hatch ld a, 8 scf ret ; 96bd3 -Function96bd3: ; 96bd3 +.unreferenced: ; 96bd3 ld a, 7 scf ret ; 96bd7 -Function96bd7: ; 96bd7 - ld a, [RepelStepsLeft] +DoRepelStep: ; 96bd7 + ld a, [wRepelEffect] and a ret z dec a - ld [RepelStepsLeft], a + ld [wRepelEffect], a ret nz ld a, BANK(RepelWoreOffScript) @@ -1036,11 +1046,11 @@ Function96bd7: ; 96bd7 ret ; 96beb -Function96beb: ; 96beb +DoPlayerEvent: ; 96beb ld a, [ScriptRunning] and a ret z - cp -1 + cp -1 ; run script ret z cp 10 ret nc @@ -1061,17 +1071,17 @@ endr ; 96c0c ScriptPointers96c0c: ; 96c0c - dbw BANK(Invalid_0x96c2d), Invalid_0x96c2d - dbw BANK(SeenByTrainerScript), SeenByTrainerScript - dbw BANK(TalkToTrainerScript), TalkToTrainerScript - dbw BANK(FindItemInBallScript), FindItemInBallScript - dbw BANK(UnknownScript_0x96c4d), UnknownScript_0x96c4d - dbw BANK(WarpToNewMapScript), WarpToNewMapScript - dbw BANK(FallIntoMapScript), FallIntoMapScript - dbw BANK(UnknownScript_0x124c8), UnknownScript_0x124c8 - dbw BANK(HatchEggScript), HatchEggScript - dbw BANK(UnknownScript_0x96c4f), UnknownScript_0x96c4f - dbw BANK(Invalid_0x96c2d), Invalid_0x96c2d + dba Invalid_0x96c2d + dba SeenByTrainerScript + dba TalkToTrainerScript + dba FindItemInBallScript + dba UnknownScript_0x96c4d + dba WarpToNewMapScript + dba FallIntoMapScript + dba UnknownScript_0x124c8 + dba HatchEggScript + dba UnknownScript_0x96c4f + dba Invalid_0x96c2d ; 96c2d Invalid_0x96c2d: ; 96c2d @@ -1089,16 +1099,16 @@ HatchEggScript: ; 96c2f WarpToNewMapScript: ; 96c34 warpsound - newloadmap $f5 + newloadmap MAPSETUP_05 end ; 96c38 FallIntoMapScript: ; 96c38 - newloadmap $f6 + newloadmap MAPSETUP_06 playsound SFX_KINESIS applymovement PLAYER, MovementData_0x96c48 playsound SFX_STRENGTH - scall UnknownScript_0x96c4a + scall LandAfterPitfallScript end ; 96c48 @@ -1107,7 +1117,7 @@ MovementData_0x96c48: ; 96c48 step_end ; 96c4a -UnknownScript_0x96c4a: ; 96c4a +LandAfterPitfallScript: ; 96c4a earthquake 16 end ; 96c4d diff --git a/engine/events_2.asm b/engine/events_2.asm index 494d796a3..966fa7d20 100644 --- a/engine/events_2.asm +++ b/engine/events_2.asm @@ -8,33 +8,39 @@ WarpToSpawnPoint:: ; 97c28 ret ; 97c30 -Function97c30:: ; 97c30 - ld a, [wd45c] +RunMemScript:: ; 97c30 +; If there is no script here, we don't need to be here. + ld a, [wMapReentryScriptQueueFlag] and a ret z - ld hl, wd45c + 2 +; Execute the script at (wMapReentryScriptBank):(wMapReentryScriptAddress). + ld hl, wMapReentryScriptAddress ld a, [hli] ld h, [hl] ld l, a - ld a, [wd45c + 1] + ld a, [wMapReentryScriptBank] call CallScript scf +; Clear the buffer for the next script. push af xor a - ld hl, wd45c + ld hl, wMapReentryScriptQueueFlag ld bc, 8 call ByteFill pop af ret ; 97c4f -Function97c4f:: ; 97c4f - ld hl, wd45c +LoadScriptBDE:: ; 97c4f +; If there's already a script here, don't overwrite. + ld hl, wMapReentryScriptQueueFlag ld a, [hl] and a ret nz +; Set the flag ld [hl], 1 inc hl +; Load the script pointer b:de into (wMapReentryScriptBank):(wMapReentryScriptAddress) ld [hl], b inc hl ld [hl], e @@ -262,46 +268,60 @@ ContestMons: ; 97d87 db -1, VENOMOTH, 30, 40 ; 97db3 -Function97db3:: ; 97db3 +DoBikeStep:: ; 97db3 nop nop - ; fallthrough -; 97db5 - -Function97db5: ; 97db5 + ; If the bike shop owner doesn't have our number, or + ; if we've already gotten the call, we don't have to + ; be here. ld hl, StatusFlags2 bit 4, [hl] jr z, .NoCall + + ; If we're not on the bike, we don't have to be here. ld a, [PlayerState] - cp 1 + cp PLAYER_BIKE jr nz, .NoCall + + ; If we're not in an area of phone service, we don't + ; have to be here. call GetMapHeaderPhoneServiceNybble and a jr nz, .NoCall - ld hl, wdca2 + + ; Check the bike step count and check whether we've + ; taken 65536 of them yet. + ld hl, wBikeStep ld a, [hli] ld d, a ld e, [hl] - cp -1 - jr nz, .asm_97dd8 + cp 255 + jr nz, .increment ld a, e - cp -1 - jr z, .asm_97ddc + cp 255 + jr z, .dont_increment -.asm_97dd8 +.increment inc de ld [hl], e dec hl ld [hl], d -.asm_97ddc +.dont_increment + ; If we've taken at least 1024 steps, have the bike + ; shop owner try to call us. ld a, d - cp $4 + cp 1024 >> 8 jr c, .NoCall + + ; If a call has already been queued, don't overwrite + ; that call. ld a, [wSpecialPhoneCallID] and a jr nz, .NoCall - ld a, 6 + + ; Queue the call. + ld a, SPECIALCALL_BIKESHOP ld [wSpecialPhoneCallID], a xor a ld [wSpecialPhoneCallID + 1], a @@ -488,7 +508,7 @@ Function97eb7: ; 97eb7 ; 97eb8 Function97eb8: ; 97eb8 - call Function2f3e + call ret_2f3e ret ; 97ebc diff --git a/engine/fruit_trees.asm b/engine/fruit_trees.asm index 9404a5564..9002404fd 100644 --- a/engine/fruit_trees.asm +++ b/engine/fruit_trees.asm @@ -58,7 +58,7 @@ CheckFruitTree: ; 44055 ; 4405f PickedFruitTree: ; 4405f - callba Function10609b ; empty function + callba MobileFn_10609b ; empty function ld b, 1 jp GetFruitTreeFlag ; 4406a diff --git a/engine/map_objects.asm b/engine/map_objects.asm index d9282d965..d73ebd142 100644 --- a/engine/map_objects.asm +++ b/engine/map_objects.asm @@ -2196,7 +2196,7 @@ Function4ecd: ; 4ecd add hl, bc ld a, [hl] ld b, a - callba Function807e + callba CopyDECoordsToMapObject pop bc ld hl, OBJECT_FLAGS add hl, bc @@ -3064,7 +3064,7 @@ Function579d: ; 579d ; 57bc Function57bc: ; 57bc - ld hl, wd45b + ld hl, wPlayerSpriteSetupFlags bit 7, [hl] jr nz, .ok ret @@ -3076,10 +3076,10 @@ Function57bc: ; 57bc ; 57ca Function57ca: ; 57ca - ld hl, wd45b + ld hl, wPlayerSpriteSetupFlags bit 5, [hl] ret z - ld a, [wd45b] + ld a, [wPlayerSpriteSetupFlags] and 3 rept 2 add a @@ -3137,7 +3137,7 @@ Function5803:: ; 5803 Function5815: ; 5815 call Function18de ret c - ld a, [$ffb0] + ld a, [hConnectedMapWidth] ld [wd4cd], a ret ; 581f @@ -3166,7 +3166,7 @@ Function582c: ; 582c ld hl, OBJECT_09 add hl, bc ld [hl], 0 - ld a, [$ffb0] + ld a, [hConnectedMapWidth] ld [wd4ce], a ret ; 5847 diff --git a/engine/map_setup.asm b/engine/map_setup.asm index f89d68a19..8b1e3a7fe 100644 --- a/engine/map_setup.asm +++ b/engine/map_setup.asm @@ -31,57 +31,6 @@ MapSetupScripts: ; 15377 dw MapSetupScript12 ; 1538f - -; Command descriptions from Condensation water's scripting compendium. - const_def - const map_lcd_on ; 00 = Turn LCD on - const map_lcd_off ; 01 = Turn LCD off - const map_sound_off ; 02 = Turn speakers off - const map_music ; 03 = Music check for current map/ special check for bug catcher contest - const map_start_music ; 04 = Start map music anew - const map_fade_music ; 05 = Music check for current map / special check for Bug Contest/ music with FadeOut (old) and FadeIn - const map_fade ; 06 = Fade out music + screen - const map_bike_music ; 07 = If HIRO is on bike = bike music, else play map music - const map_music_force ; 08 = Play map music - const map_max_volume ; 09 = Turn music to highest volume - const map_load_blocks ; 0A = Write map data to MapRAM - const map_connection_blocks ; 0B = Compute map’s connection pars and write into MapRAM - const map_save_screen ; 0C = Write current part of map into temporary memory - const map_buffer_screen ; 0D = Write current part of map into read-from memory - const map_load_graphics ; 0E = Write tileset header to ram/ load tileset/ load sprite tiles/ load special tiles - const map_load_tileset_header ; 0F = Write tileset header to ram - const map_time_of_day ; 10 = Compute time of day/ Update screen - const map_palettes ; 11 = Load map palettes - const map_wildmons ; 12 = Load probabilities for wild Pokémon battles - const map_sprites ; 13 = Delete sprite data and draw new sprites - const map_change_callback ; 14 = Check 2nd script header for 05 and 03 callbacks - const map_start_callback ; 15 = Check 2nd script header for 03 callbacks - const map_load_objects ; 16 = Analyze people data anew and check 2nd script header for 02 callbacks - const map_load_spawn ; 17 = Writes arrival data for arrival by flying/Blackout from table 05:5319 to ram - const map_load_connection ; 18 = Writes arrival data for entering a map by connection to ram - const map_load_warp ; 19 = Write warp data to ram when entering warp - const map_attributes ; 1A = Load complete map data (primary, secondary, event, script headers) - const map_attributes_2 ; 1B = Same as 1A, but some settings aren’t loaded new from the rom, such as hide function of the people events - const map_clear_bg_palettes ; 1C = Fill palette data with FFFF (=white) - const map_fade_out_palettes ; 1D = All BG pallet color are converted to 0|0 (Pal0, Col0), all sprite colors to x|0 (FadeOut) - const map_fade_in_palettes ; 1E = Palette FadeIn - const map_anchor_screen ; 1F = Compute position of upper left-most block visible on screen - const map_warp_face ; 20 = Position computation when HIRO leaves a warp - const map_face_down ; 21 = Set HIRO’s facing to “down” - const map_spawn_coord ; 22 = Prepare HIRO data for arrival by flight - const map_player_coord ; 23 = Compute HIRO x/y data anew - const map_prolong_sprites ; 24 = Prolong old sprites before removing them - const map_delay_sprites ; 25 = Delay rendering new sprites - const map_update_roam ; 26 = Compute chances to meet Raikou, Entei or Suicune - const map_keep_roam ; 27 = Recover chances to meet Raikou, Entei or Suicune - const map_fade_out_music ; 28 = Temporarily stop music playing - const map_animations_on ; 29 = Activate animations - const map_animations_off ; 2A = Deactivate animations - const map_keep_palettes ; 2B = Recover all palettes - const map_text_scroll_off ; 2C = Turn off text scroll (for town name overlays) - const map_stop_script ; 2D = Deactivate code prolonging - - MapSetupScript4: ; 1538f db map_prolong_sprites @@ -112,7 +61,7 @@ MapSetupScript1: ; 15392 db map_fade_in_palettes db map_animations_on db map_wildmons - db -1 + db map_end_setup_script MapSetupScript11: ; 153a9 db map_load_spawn @@ -136,7 +85,7 @@ MapSetupScript11: ; 153a9 db map_fade_in_palettes db map_animations_on db map_wildmons - db -1 + db map_end_setup_script MapSetupScript7: ; 153bf db map_animations_off @@ -155,7 +104,7 @@ MapSetupScript7: ; 153bf db map_wildmons db map_update_roam db map_animations_on - db -1 + db map_end_setup_script MapSetupScript6: ; 153d0 db map_prolong_sprites @@ -184,7 +133,7 @@ MapSetupScript9: ; 153d2 db map_animations_on db map_wildmons db map_update_roam - db -1 + db map_end_setup_script MapSetupScript3: ; 153e7 db map_fade @@ -202,7 +151,7 @@ MapSetupScript3: ; 153e7 db map_fade_in_palettes db map_animations_on db map_wildmons - db -1 + db map_end_setup_script MapSetupScript8: ; 153f7 db map_fade @@ -221,7 +170,7 @@ MapSetupScript8: ; 153f7 db map_animations_on db map_wildmons db map_text_scroll_off - db -1 + db map_end_setup_script MapSetupScript2: ; 15408 db map_lcd_off @@ -241,12 +190,12 @@ MapSetupScript2: ; 15408 db map_fade_in_palettes db map_animations_on db map_wildmons - db -1 + db map_end_setup_script MapSetupScript10: ; 1541a db map_load_blocks db map_connection_blocks - db -1 + db map_end_setup_script ReadMapSetupScript: ; 1541d @@ -374,13 +323,13 @@ Function154ea: ; 154ea ; 154eb DelayClearingOldSprites: ; 154eb - ld hl, wd45b + ld hl, wPlayerSpriteSetupFlags set 7, [hl] ret ; 154f1 DelayLoadingNewSprites: ; 154f1 - ld hl, wd45b + ld hl, wPlayerSpriteSetupFlags set 6, [hl] ret diff --git a/engine/more_phone_scripts.asm b/engine/more_phone_scripts.asm index a2192514e..5bc1f1560 100644 --- a/engine/more_phone_scripts.asm +++ b/engine/more_phone_scripts.asm @@ -1656,5 +1656,5 @@ UnknownScript_0xa0b04: BikeShopPhoneScript: farwritetext UnknownText_0x174000 clearflag ENGINE_BIKE_SHOP_CALL_ENABLED - specialphonecall ELMCALL_NONE + specialphonecall SPECIALCALL_NONE end diff --git a/engine/pack.asm b/engine/pack.asm index 657a5bea3..35126ba16 100644 --- a/engine/pack.asm +++ b/engine/pack.asm @@ -4,8 +4,8 @@ Pack: ; 10000 set 4, [hl] call Function1068a .loop - call Functiona57 - ld a, [wcf63] + call JoyTextDelay + ld a, [wJumptableIndex] bit 7, a jr nz, .done call Function10026 @@ -21,7 +21,7 @@ Pack: ; 10000 ; 10026 Function10026: ; 10026 - ld a, [wcf63] + ld a, [wJumptableIndex] ld hl, Jumptable_10030 call Function1086b jp [hl] @@ -47,31 +47,31 @@ Function10046: ; 10046 (4:4046) ld [hBGMapMode], a ; $ff00+$d4 call Function10955 ld a, [wcf64] - ld [wcf63], a + ld [wJumptableIndex], a call Function10a40 ret Function10056: ; 10056 (4:4056) xor a ld [wcf65], a - call Function10a36 - call Function109bb - call Function1089a + call ClearPocketList + call DrawPocketName + call WaitBGMap_DrawPackGFX call Function10866 ret Function10067: ; 10067 (4:4067) ld hl, MenuDataHeader_0x10a4f call CopyMenuDataHeader - ld a, [wd0d9] - ld [wcf88], a + ld a, [wItemsPocketCursor] + ld [wPocketCursorBuffer], a ld a, [wd0df] ld [wd0e4], a call Function350c ld a, [wd0e4] ld [wd0df], a ld a, [wcfa9] - ld [wd0d9], a + ld [wItemsPocketCursor], a ld b, $7 ld c, $3 call Function108d4 @@ -82,24 +82,24 @@ Function10067: ; 10067 (4:4067) Function10094: ; 10094 (4:4094) ld a, $2 ld [wcf65], a - call Function10a36 - call Function109bb - call Function1089a + call ClearPocketList + call DrawPocketName + call WaitBGMap_DrawPackGFX call Function10866 ret Function100a6: ; 100a6 (4:40a6) ld hl, MenuDataHeader_0x10a7f call CopyMenuDataHeader - ld a, [wd0da] - ld [wcf88], a + ld a, [wKeyItemsPocketCursor] + ld [wPocketCursorBuffer], a ld a, [wd0e0] ld [wd0e4], a call Function350c ld a, [wd0e4] ld [wd0e0], a ld a, [wcfa9] - ld [wd0da], a + ld [wKeyItemsPocketCursor], a ld b, $3 ld c, $7 call Function108d4 @@ -110,11 +110,11 @@ Function100a6: ; 100a6 (4:40a6) Function100d3: ; 100d3 (4:40d3) ld a, $3 ld [wcf65], a - call Function10a36 - call Function109bb + call ClearPocketList + call DrawPocketName xor a ld [hBGMapMode], a ; $ff00+$d4 - call Function1089a + call WaitBGMap_DrawPackGFX call Function10866 ret @@ -125,7 +125,7 @@ Function100e8: ; 100e8 (4:40e8) call Function108d4 ret c callba _CheckTossableItem - ld a, [wd142] + ld a, [wItemAttributeParamBuffer] and a jr nz, .asm_1010a ld hl, MenuDataHeader_0x1013b @@ -205,31 +205,31 @@ Function10159: ; 10159 xor a ld [hBGMapMode], a ; $ff00+$d4 call Function10955 - call Function1089a + call WaitBGMap_DrawPackGFX call Function10a40 ret Function10186: ; 10186 (4:4186) ld a, $1 ld [wcf65], a - call Function10a36 - call Function109bb - call Function1089a + call ClearPocketList + call DrawPocketName + call WaitBGMap_DrawPackGFX call Function10866 ret Function10198: ; 10198 (4:4198) ld hl, MenuDataHeader_0x10aaf call CopyMenuDataHeader - ld a, [wd0db] - ld [wcf88], a + ld a, [wBallsPocketCursor] + ld [wPocketCursorBuffer], a ld a, [wd0e1] ld [wd0e4], a call Function350c ld a, [wd0e4] ld [wd0e1], a ld a, [wcfa9] - ld [wd0db], a + ld [wBallsPocketCursor], a ld b, $1 ld c, $5 call Function108d4 @@ -239,54 +239,62 @@ Function10198: ; 10198 (4:4198) Function101c5: ; 101c5 (4:41c5) callba _CheckTossableItem - ld a, [wd142] + ld a, [wItemAttributeParamBuffer] and a - jr nz, .asm_101f9 + jr nz, .tossable callba CheckSelectableItem - ld a, [wd142] + ld a, [wItemAttributeParamBuffer] and a - jr nz, .asm_101eb + jr nz, .selectable callba CheckItemMenu - ld a, [wd142] + ld a, [wItemAttributeParamBuffer] and a - jr nz, .asm_10207 - jr .asm_10227 -.asm_101eb + jr nz, .usable + jr .unusable + +.selectable callba CheckItemMenu - ld a, [wd142] + ld a, [wItemAttributeParamBuffer] and a - jr nz, .asm_1020f - jr .asm_1022f -.asm_101f9 + jr nz, .selectable_usable + jr .selectable_unusable + +.tossable callba CheckSelectableItem - ld a, [wd142] + ld a, [wItemAttributeParamBuffer] and a - jr nz, .asm_10217 - jr .asm_1021f -.asm_10207 + jr nz, .tossable_selectable + jr .tossable_unselectable + +.usable ld hl, MenuDataHeader_0x10249 ld de, Jumptable_1026a - jr .asm_10235 -.asm_1020f + jr .build_menu + +.selectable_usable ld hl, MenuDataHeader_0x10274 ld de, Jumptable_10291 - jr .asm_10235 -.asm_10217 + jr .build_menu + +.tossable_selectable ld hl, MenuDataHeader_0x10299 ld de, Jumptable_102ac - jr .asm_10235 -.asm_1021f + jr .build_menu + +.tossable_unselectable ld hl, MenuDataHeader_0x102b0 ld de, Jumptable_102c7 - jr .asm_10235 -.asm_10227 + jr .build_menu + +.unusable ld hl, MenuDataHeader_0x102cd ld de, Jumptable_102ea - jr .asm_10235 -.asm_1022f + jr .build_menu + +.selectable_unusable ld hl, MenuDataHeader_0x102f2 ld de, Jumptable_1030b -.asm_10235 +.build_menu push de call LoadMenuDataHeader call InterpretMenu2 @@ -350,7 +358,7 @@ Jumptable_10291: ; 10291 ; 10299 MenuDataHeader_0x10299: ; 0x10299 - db $40 ; flags + db %01000000 ; flags db 07, 13 ; start coords db 11, 19 ; end coords dw MenuData2_0x102a1 @@ -370,7 +378,7 @@ Jumptable_102ac: ; 102ac ; 102b0 MenuDataHeader_0x102b0: ; 0x102b0 - db $40 ; flags + db %01000000 ; flags db 05, 13 ; start coords db 11, 19 ; end coords dw MenuData2_0x102b8 @@ -439,54 +447,54 @@ Jumptable_1030b: ; 1030b Function10311: ; 10311 callba CheckItemMenu - ld a, [wd142] - ld hl, Jumptable_1031f + ld a, [wItemAttributeParamBuffer] + ld hl, .jumptable rst JumpTable ret ; 1031f -Jumptable_1031f: ; 1031f (4:431f) - dw Function1032d - dw Function1032d - dw Function1032d - dw Function1032d - dw Function10334 - dw Function10338 - dw Function10355 +.jumptable: ; 1031f (4:431f) + dw .Oak + dw .Oak + dw .Oak + dw .Oak + dw .Current + dw .Party + dw .Field ; 1035c -Function1032d: ; 1032d (4:432d) +.Oak: ; 1032d (4:432d) ld hl, UnknownText_0x10af3 call Function10889 ret -Function10334: ; 10334 (4:4334) +.Current: ; 10334 (4:4334) call DoItemEffect ret -Function10338: ; 10338 (4:4338) +.Party: ; 10338 (4:4338) ld a, [PartyCount] and a - jr z, .asm_1034e + jr z, .NoPokemon call DoItemEffect xor a ld [hBGMapMode], a ; $ff00+$d4 call Function10955 - call Function1089a + call WaitBGMap_DrawPackGFX call Function10a40 ret -.asm_1034e +.NoPokemon ld hl, TextJump_YouDontHaveAPkmn call Function10889 ret -Function10355: ; 10355 (4:4355) +.Field: ; 10355 (4:4355) call DoItemEffect ld a, [wd0ec] and a - jr z, Function1032d + jr z, .Oak ld a, $a - ld [wcf63], a + ld [wJumptableIndex], a ret ; 10364 (4:4364) @@ -529,26 +537,26 @@ Function1039d: ; 1039d .asm_103aa xor a - ld [wd0db], a + ld [wBallsPocketCursor], a ld [wd0e1], a ret .asm_103b2 xor a - ld [wd0d9], a + ld [wItemsPocketCursor], a ld [wd0df], a ret .asm_103ba xor a - ld [wd0da], a + ld [wKeyItemsPocketCursor], a ld [wd0e0], a ret ; 103c2 Function103c2: ; 103c2 callba CheckSelectableItem - ld a, [wd142] + ld a, [wItemAttributeParamBuffer] and a jr nz, .asm_103f6 ld a, [wcf65] @@ -608,7 +616,7 @@ Function103fd: ; 103fd jr .asm_10427 .asm_10453 - ld a, [wcf63] + ld a, [wJumptableIndex] push af ld a, [wcf64] push af @@ -621,14 +629,14 @@ Function103fd: ; 103fd pop af ld [wcf64], a pop af - ld [wcf63], a + ld [wJumptableIndex], a .asm_10475 pop af ld [Options], a xor a ld [hBGMapMode], a ; $ff00+$d4 call Function10955 - call Function1089a + call WaitBGMap_DrawPackGFX call Function10a40 ret @@ -654,8 +662,8 @@ BattlePack: ; 10493 set 4, [hl] call Function1068a .asm_1049b - call Functiona57 - ld a, [wcf63] + call JoyTextDelay + ld a, [wJumptableIndex] bit 7, a jr nz, .asm_104ad call Function104b9 @@ -671,7 +679,7 @@ BattlePack: ; 10493 ; 104b9 Function104b9: ; 104b9 - ld a, [wcf63] + ld a, [wJumptableIndex] ld hl, Jumptable_104c3 call Function1086b jp [hl] @@ -697,31 +705,31 @@ Function104d9: ; 104d9 (4:44d9) ld [hBGMapMode], a ; $ff00+$d4 call Function10955 ld a, [wcf64] - ld [wcf63], a + ld [wJumptableIndex], a call Function10a40 ret Function104e9: ; 104e9 (4:44e9) xor a ld [wcf65], a - call Function10a36 - call Function109bb - call Function1089a + call ClearPocketList + call DrawPocketName + call WaitBGMap_DrawPackGFX call Function10866 ret Function104fa: ; 104fa (4:44fa) ld hl, MenuDataHeader_0x10a4f call CopyMenuDataHeader - ld a, [wd0d9] - ld [wcf88], a + ld a, [wItemsPocketCursor] + ld [wPocketCursorBuffer], a ld a, [wd0df] ld [wd0e4], a call Function350c ld a, [wd0e4] ld [wd0df], a ld a, [wcfa9] - ld [wd0d9], a + ld [wItemsPocketCursor], a ld b, $7 ld c, $3 call Function108d4 @@ -732,24 +740,24 @@ Function104fa: ; 104fa (4:44fa) Function10527: ; 10527 (4:4527) ld a, $2 ld [wcf65], a - call Function10a36 - call Function109bb - call Function1089a + call ClearPocketList + call DrawPocketName + call WaitBGMap_DrawPackGFX call Function10866 ret Function10539: ; 10539 (4:4539) ld hl, MenuDataHeader_0x10a7f call CopyMenuDataHeader - ld a, [wd0da] - ld [wcf88], a + ld a, [wKeyItemsPocketCursor] + ld [wPocketCursorBuffer], a ld a, [wd0e0] ld [wd0e4], a call Function350c ld a, [wd0e4] ld [wd0e0], a ld a, [wcfa9] - ld [wd0da], a + ld [wKeyItemsPocketCursor], a ld b, $3 ld c, $7 call Function108d4 @@ -760,11 +768,11 @@ Function10539: ; 10539 (4:4539) Function10566: ; 10566 (4:4566) ld a, $3 ld [wcf65], a - call Function10a36 - call Function109bb + call ClearPocketList + call DrawPocketName xor a ld [hBGMapMode], a ; $ff00+$d4 - call Function1089a + call WaitBGMap_DrawPackGFX ld hl, UnknownText_0x10b0c call Function10889 call Function10866 @@ -783,24 +791,24 @@ Function10581: ; 10581 (4:4581) Function10594: ; 10594 (4:4594) ld a, $1 ld [wcf65], a - call Function10a36 - call Function109bb - call Function1089a + call ClearPocketList + call DrawPocketName + call WaitBGMap_DrawPackGFX call Function10866 ret Function105a6: ; 105a6 (4:45a6) ld hl, MenuDataHeader_0x10aaf call CopyMenuDataHeader - ld a, [wd0db] - ld [wcf88], a + ld a, [wBallsPocketCursor] + ld [wPocketCursorBuffer], a ld a, [wd0e1] ld [wd0e4], a call Function350c ld a, [wd0e4] ld [wd0e1], a ld a, [wcfa9] - ld [wd0db], a + ld [wBallsPocketCursor], a ld b, $1 ld c, $5 call Function108d4 @@ -810,18 +818,18 @@ Function105a6: ; 105a6 (4:45a6) Function105d3: ; 105d3 (4:45d3) callba CheckItemContext - ld a, [wd142] + ld a, [wItemAttributeParamBuffer] Function105dc: ; 105dc (4:45dc) and a - jr z, .asm_105e7 - ld hl, MenuDataHeader_0x10601 - ld de, Jumptable_10614 - jr .asm_105ed -.asm_105e7 - ld hl, MenuDataHeader_0x10618 - ld de, Jumptable_10627 -.asm_105ed + jr z, .NoUse + ld hl, .UsableMenuDataHeader + ld de, .UsableJumptable + jr .proceed +.NoUse + ld hl, .UnusableMenuDataHeader + ld de, .UnusableJumptable +.proceed push de call LoadMenuDataHeader call InterpretMenu2 @@ -834,113 +842,115 @@ Function105dc: ; 105dc (4:45dc) jp [hl] ; 10601 (4:4601) -MenuDataHeader_0x10601: ; 0x10601 +.UsableMenuDataHeader: ; 0x10601 db $40 ; flags db 07, 13 ; start coords db 11, 19 ; end coords - dw MenuData2_0x10609 + dw .UsableMenuData2 db 1 ; default option ; 0x10609 -MenuData2_0x10609: ; 0x10609 +.UsableMenuData2: ; 0x10609 db $c0 ; flags db 2 ; items db "USE@" db "QUIT@" ; 0x10614 -Jumptable_10614: ; 10614 - dw Function10629 - dw Function10689 +.UsableJumptable: ; 10614 + dw .Use + dw .Quit ; 10618 -MenuDataHeader_0x10618: ; 0x10618 +.UnusableMenuDataHeader: ; 0x10618 db $40 ; flags db 09, 13 ; start coords db 11, 19 ; end coords - dw MenuData2_0x10620 + dw .UnusableMenuData2 db 1 ; default option ; 0x10620 -MenuData2_0x10620: ; 0x10620 +.UnusableMenuData2: ; 0x10620 db $c0 ; flags db 1 ; items db "QUIT@" ; 0x10627 -Jumptable_10627: ; 10627 - dw Function10689 +.UnusableJumptable: ; 10627 + dw .Quit ; 10629 -Function10629: ; 10629 +.Use: ; 10629 callba CheckItemContext - ld a, [wd142] - ld hl, Jumptable_10637 + ld a, [wItemAttributeParamBuffer] + ld hl, .ItemFunctionJumptable rst JumpTable ret -Jumptable_10637: ; 10637 (4:4637) - dw Function10645 - dw Function10645 - dw Function10645 - dw Function10645 - dw Function1064c - dw Function10656 - dw Function10671 +.ItemFunctionJumptable: ; 10637 (4:4637) + dw .Oak + dw .Oak + dw .Oak + dw .Oak + dw .Unused + dw .BattleField + dw .BattleOnly -Function10645: ; 10645 (4:4645) +.Oak: ; 10645 (4:4645) ld hl, UnknownText_0x10af3 call Function10889 ret -Function1064c: ; 1064c (4:464c) +.Unused: ; 1064c (4:464c) call DoItemEffect ld a, [wd0ec] and a - jr nz, asm_1066c + jr nz, .asm_1066c ret -Function10656: ; 10656 (4:4656) +.BattleField: ; 10656 (4:4656) call DoItemEffect ld a, [wd0ec] and a - jr nz, asm_1067e + jr nz, .asm_1067e xor a ld [hBGMapMode], a ; $ff00+$d4 call Function10955 - call Function1089a + call WaitBGMap_DrawPackGFX call Function10a40 ret -asm_1066c: ; 1066c (4:466c) + +.asm_1066c: ; 1066c (4:466c) call WhiteBGMap - jr asm_1067e + jr .asm_1067e -Function10671: ; 10671 (4:4671) +.BattleOnly: ; 10671 (4:4671) call DoItemEffect ld a, [wd0ec] and a - jr z, Function10645 + jr z, .Oak cp $2 - jr z, asm_10684 -asm_1067e: ; 1067e (4:467e) + jr z, .asm_10684 +.asm_1067e: ; 1067e (4:467e) ld a, $a - ld [wcf63], a + ld [wJumptableIndex], a ret -asm_10684: ; 10684 (4:4684) + +.asm_10684: ; 10684 (4:4684) xor a ld [wd0ec], a ret ; 10689 (4:4689) -Function10689: ; 10689 +.Quit: ; 10689 ret ; 1068a Function1068a: ; 1068a xor a - ld [wcf63], a + ld [wJumptableIndex], a ld a, [wd0d6] and $3 ld [wcf65], a @@ -958,7 +968,7 @@ Function1068a: ; 1068a Function106a5: ; 106a5 xor a ld [hBGMapMode], a - ld [wcf63], a + ld [wJumptableIndex], a ld [wcf64], a ld [wcf65], a ld [wcf66], a @@ -977,7 +987,7 @@ Function106be: ; 106be ; 106c7 Function106c7: ; 106c7 - ld a, [wcf63] + ld a, [wJumptableIndex] ld hl, Jumptable_106d1 call Function1086b jp [hl] @@ -985,74 +995,74 @@ Function106c7: ; 106c7 Jumptable_106d1: ; 106d1 (4:46d1) - dw Function106d9 - dw Function1073b - dw Function106ff - dw Function10726 + dw .ItemsPocket + dw .BallsPocket + dw .KeyItemsPocket + dw .TMHMPocket -Function106d9: ; 106d9 (4:46d9) +.ItemsPocket: ; 106d9 (4:46d9) xor a - call Function10762 + call InitPocket ld hl, MenuDataHeader_0x10a67 call CopyMenuDataHeader - ld a, [wd0d9] - ld [wcf88], a + ld a, [wItemsPocketCursor] + ld [wPocketCursorBuffer], a ld a, [wd0df] ld [wd0e4], a call Function350c ld a, [wd0e4] ld [wd0df], a ld a, [wcfa9] - ld [wd0d9], a + ld [wItemsPocketCursor], a ret -Function106ff: ; 106ff (4:46ff) +.KeyItemsPocket: ; 106ff (4:46ff) ld a, $2 - call Function10762 + call InitPocket ld hl, MenuDataHeader_0x10a97 call CopyMenuDataHeader - ld a, [wd0da] - ld [wcf88], a + ld a, [wKeyItemsPocketCursor] + ld [wPocketCursorBuffer], a ld a, [wd0e0] ld [wd0e4], a call Function350c ld a, [wd0e4] ld [wd0e0], a ld a, [wcfa9] - ld [wd0da], a + ld [wKeyItemsPocketCursor], a ret -Function10726: ; 10726 (4:4726) +.TMHMPocket: ; 10726 (4:4726) ld a, $3 - call Function10762 - call Function1089a + call InitPocket + call WaitBGMap_DrawPackGFX callba Function2c76f ld a, [CurItem] ld [CurItem], a ret -Function1073b: ; 1073b (4:473b) +.BallsPocket: ; 1073b (4:473b) ld a, $1 - call Function10762 + call InitPocket ld hl, MenuDataHeader_0x10ac7 call CopyMenuDataHeader - ld a, [wd0db] - ld [wcf88], a + ld a, [wBallsPocketCursor] + ld [wPocketCursorBuffer], a ld a, [wd0e1] ld [wd0e4], a call Function350c ld a, [wd0e4] ld [wd0e1], a ld a, [wcfa9] - ld [wd0db], a + ld [wBallsPocketCursor], a ret -Function10762: ; 10762 (4:4762) +InitPocket: ; 10762 (4:4762) ld [wcf65], a - call Function10a36 - call Function109bb - call Function1089a + call ClearPocketList + call DrawPocketName + call WaitBGMap_DrawPackGFX ret @@ -1086,10 +1096,10 @@ Function1076f: ; 1076f ret .asm_10795 - ld a, [wcf63] + ld a, [wJumptableIndex] dec a and $3 - ld [wcf63], a + ld [wJumptableIndex], a push de ld de, SFX_UNKNOWN_62 call PlaySFX @@ -1098,10 +1108,10 @@ Function1076f: ; 1076f ret .asm_107a8 - ld a, [wcf63] + ld a, [wJumptableIndex] inc a and $3 - ld [wcf63], a + ld [wJumptableIndex], a push de ld de, SFX_UNKNOWN_62 call PlaySFX @@ -1115,7 +1125,7 @@ Function107bb: ; 107bb ld a, [InputType] or a jr z, .asm_107ca - callba Start_DudeAutoInput_RightA + callba _DudeAutoInput_RightA .asm_107ca call Function107d7 @@ -1127,7 +1137,7 @@ Function107bb: ; 107bb ; 107d7 Function107d7: ; 107d7 - ld a, [wcf63] + ld a, [wJumptableIndex] ld hl, Jumptable_107e1 call Function1086b jp [hl] @@ -1160,8 +1170,8 @@ MenuData2_0x107f7: ; 0x107f7 db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, OTPartyMons - dbw BANK(Function24ab4), Function24ab4 - dbw BANK(Function24ac3), Function24ac3 + dbw BANK(PlaceMenuItemName), PlaceMenuItemName + dbw BANK(PlaceMenuItemQuantity), PlaceMenuItemQuantity dbw BANK(Function244c3), Function244c3 ; 10807 @@ -1184,15 +1194,15 @@ MenuData2_0x10816: ; 0x10816 db 5, 8 ; rows, columns db 1 ; horizontal spacing dbw 0, OTPartyMon1Exp + 2 - dbw BANK(Function24ab4), Function24ab4 - dbw BANK(Function24ac3), Function24ac3 + dbw BANK(PlaceMenuItemName), PlaceMenuItemName + dbw BANK(PlaceMenuItemQuantity), PlaceMenuItemQuantity dbw BANK(Function244c3), Function244c3 ; 10826 Function10826: ; 10826 (4:4826) ld a, $3 - call Function10762 - call Function1089a + call InitPocket + call WaitBGMap_DrawPackGFX callba Function2c76f ld a, [CurItem] ld [CurItem], a @@ -1217,21 +1227,21 @@ MenuData2_0x1084a: ; 0x1084a db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, OTPartyMon1CaughtGender - dbw BANK(Function24ab4), Function24ab4 - dbw BANK(Function24ac3), Function24ac3 + dbw BANK(PlaceMenuItemName), PlaceMenuItemName + dbw BANK(PlaceMenuItemQuantity), PlaceMenuItemQuantity dbw BANK(Function244c3), Function244c3 ; 1085a Function1085a: ; 1085a (4:485a) push hl - call Function10762 + call InitPocket pop hl call CopyMenuDataHeader call Function350c ret Function10866: ; 10866 (4:4866) - ld hl, wcf63 + ld hl, wJumptableIndex inc [hl] ret @@ -1248,14 +1258,14 @@ endr ; 10874 Function10874: ; 10874 (4:4874) - ld hl, wcf63 + ld hl, wJumptableIndex set 7, [hl] xor a ld [wcf66], a ret Function1087e: ; 1087e (4:487e) - ld hl, wcf63 + ld hl, wJumptableIndex set 7, [hl] ld a, $1 ld [wcf66], a @@ -1271,23 +1281,23 @@ Function10889: ; 10889 (4:4889) ld [Options], a ret -Function1089a: ; 1089a (4:489a) +WaitBGMap_DrawPackGFX: ; 1089a (4:489a) call WaitBGMap -Function1089d: ; 1089d +DrawPackGFX: ; 1089d ld a, [wcf65] and $3 ld e, a ld d, $0 ld a, [BattleType] cp BATTLETYPE_TUTORIAL - jr z, .asm_108b3 + jr z, .male_dude ld a, [PlayerGender] bit 0, a - jr nz, .asm_108c5 + jr nz, .female -.asm_108b3 +.male_dude ld hl, PackGFXPointers rept 2 add hl, de @@ -1295,13 +1305,13 @@ endr ld a, [hli] ld e, a ld d, [hl] - ld hl, $9500 + ld hl, VTiles2 tile $50 lb bc, BANK(PackGFX), 15 call Request2bpp ret -.asm_108c5 - callba Function48e81 +.female + callba DrawKrisPackGFX ret ; 108cc @@ -1339,12 +1349,12 @@ Function108d4: ; 108d4 (4:48d4) ret .asm_108fa ld a, $9 - ld [wcf63], a + ld [wJumptableIndex], a scf ret .asm_10901 ld a, b - ld [wcf63], a + ld [wJumptableIndex], a ld [wcf64], a push de ld de, SFX_UNKNOWN_62 @@ -1354,7 +1364,7 @@ Function108d4: ; 108d4 (4:48d4) ret .asm_10912 ld a, c - ld [wcf63], a + ld [wJumptableIndex], a ld [wcf64], a push de ld de, SFX_UNKNOWN_62 @@ -1415,13 +1425,13 @@ Function10955: ; 10955 inc a dec c jr nz, .asm_1098a - call Function109bb + call DrawPocketName call Function109a5 hlcoord 0, 12 lb bc, 4, 18 call TextBox call EnableLCD - call Function1089d + call DrawPackGFX ret ; 109a5 @@ -1443,7 +1453,7 @@ Function109a5: ; 109a5 ret ; 109bb -Function109bb: ; 109bb +DrawPocketName: ; 109bb ld a, [wcf65] ; * 15 @@ -1453,30 +1463,30 @@ Function109bb: ; 109bb ld d, 0 ld e, a - ld hl, Tilemap_109e1 + ld hl, .tilemap add hl, de ld d, h ld e, l hlcoord 0, 7 ld c, 3 -.asm_109d0 +.row ld b, 5 -.asm_109d2 +.col ld a, [de] inc de ld [hli], a dec b - jr nz, .asm_109d2 + jr nz, .col ld a, c - ld c, 15 + ld c, SCREEN_WIDTH - 5 add hl, bc ld c, a dec c - jr nz, .asm_109d0 + jr nz, .row ret ; 109e1 -Tilemap_109e1: ; 109e1 +.tilemap: ; 109e1 db $00, $04, $04, $04, $01, $06, $07, $08, $09, $0a, $02, $05, $05, $05, $03 db $00, $04, $04, $04, $01, $15, $16, $17, $18, $19, $02, $05, $05, $05, $03 db $00, $04, $04, $04, $01, $0b, $0c, $0d, $0e, $0f, $02, $05, $05, $05, $03 @@ -1494,21 +1504,21 @@ Function10a1d: ; 10a1d Function10a2a: ; 10a2a hlcoord 0, 0 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, $7f + ld a, " " call ByteFill ret ; 10a36 -Function10a36: ; 10a36 (4:4a36) +ClearPocketList: ; 10a36 (4:4a36) hlcoord 5, 2 - ld bc, $a0f + lb bc, 10, SCREEN_WIDTH - 5 call ClearBox ret Function10a40: ; 10a40 call WaitBGMap - ld b, $14 + ld b, SCREEN_WIDTH call GetSGBLayout call SetPalettes call DelayFrame @@ -1528,8 +1538,8 @@ MenuData2_0x10a57: ; 0x10a57 db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumItems - dbw BANK(Function24ab4), Function24ab4 - dbw BANK(Function24ac3), Function24ac3 + dbw BANK(PlaceMenuItemName), PlaceMenuItemName + dbw BANK(PlaceMenuItemQuantity), PlaceMenuItemQuantity dbw BANK(Function244c3), Function244c3 ; 10a67 @@ -1546,8 +1556,8 @@ MenuData2_0x10a6f: ; 0x10a6f db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumItems - dbw BANK(Function24ab4), Function24ab4 - dbw BANK(Function24ac3), Function24ac3 + dbw BANK(PlaceMenuItemName), PlaceMenuItemName + dbw BANK(PlaceMenuItemQuantity), PlaceMenuItemQuantity dbw BANK(Function244c3), Function244c3 ; 10a7f @@ -1564,8 +1574,8 @@ MenuData2_0x10a87: ; 0x10a87 db 5, 8 ; rows, columns db 1 ; horizontal spacing dbw 0, NumKeyItems - dbw BANK(Function24ab4), Function24ab4 - dbw BANK(Function24ac3), Function24ac3 + dbw BANK(PlaceMenuItemName), PlaceMenuItemName + dbw BANK(PlaceMenuItemQuantity), PlaceMenuItemQuantity dbw BANK(Function244c3), Function244c3 ; 10a97 @@ -1582,8 +1592,8 @@ MenuData2_0x10a9f: ; 0x10a9f db 5, 8 ; rows, columns db 1 ; horizontal spacing dbw 0, NumKeyItems - dbw BANK(Function24ab4), Function24ab4 - dbw BANK(Function24ac3), Function24ac3 + dbw BANK(PlaceMenuItemName), PlaceMenuItemName + dbw BANK(PlaceMenuItemQuantity), PlaceMenuItemQuantity dbw BANK(Function244c3), Function244c3 ; 10aaf @@ -1600,8 +1610,8 @@ MenuData2_0x10ab7: ; 0x10ab7 db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumBalls - dbw BANK(Function24ab4), Function24ab4 - dbw BANK(Function24ac3), Function24ac3 + dbw BANK(PlaceMenuItemName), PlaceMenuItemName + dbw BANK(PlaceMenuItemQuantity), PlaceMenuItemQuantity dbw BANK(Function244c3), Function244c3 ; 10ac7 @@ -1618,8 +1628,8 @@ MenuData2_0x10acf: ; 0x10acf db 5, 8 ; rows, columns db 2 ; horizontal spacing dbw 0, NumBalls - dbw BANK(Function24ab4), Function24ab4 - dbw BANK(Function24ac3), Function24ac3 + dbw BANK(PlaceMenuItemName), PlaceMenuItemName + dbw BANK(PlaceMenuItemQuantity), PlaceMenuItemQuantity dbw BANK(Function244c3), Function244c3 ; 10adf diff --git a/engine/phone.asm b/engine/phone.asm new file mode 100644 index 000000000..0ba5cf6e1 --- /dev/null +++ b/engine/phone.asm @@ -0,0 +1,884 @@ +AddPhoneNumber:: ; 90000 + call _CheckCellNum + jr c, .cant_add + call Phone_FindOpenSlot + jr nc, .cant_add + ld [hl], c + xor a + ret + +.cant_add + scf + ret +; 9000f + + +DelCellNum:: ; 9000f + call _CheckCellNum + jr nc, .not_in_list + xor a + ld [hl], a + ret + +.not_in_list + scf + ret +; 90019 + +CheckCellNum:: ; 90019 + jp _CheckCellNum ; wtf +; 9001c + +_CheckCellNum: ; 9001c + ld hl, wPhoneList + ld b, CONTACT_LIST_SIZE +.loop + ld a, [hli] + cp c + jr z, .got_it + dec b + jr nz, .loop + xor a + ret + +.got_it + dec hl + scf + ret +; 9002d + +Phone_FindOpenSlot: ; 9002d + call GetRemainingSpaceInPhoneList + ld b, a + ld hl, wPhoneList +.loop + ld a, [hli] + and a + jr z, .FoundOpenSpace + dec b + jr nz, .loop + xor a + ret + +.FoundOpenSpace + dec hl + scf + ret +; 90040 + +GetRemainingSpaceInPhoneList: ; 90040 + xor a + ld [Buffer1], a + ld hl, PermanentNumbers +.loop + ld a, [hli] + cp -1 + jr z, .done + cp c + jr z, .elm_or_mom + push bc + push hl + ld c, a + call _CheckCellNum + jr c, .elm_or_mom_in_list + ld hl, Buffer1 + inc [hl] + +.elm_or_mom_in_list + pop hl + pop bc + +.elm_or_mom + jr .loop + +.done + ld a, CONTACT_LIST_SIZE + ld hl, Buffer1 + sub [hl] + ret +; 90066 + +PermanentNumbers: ; 90066 + db PHONECONTACT_MOM, PHONECONTACT_ELM, -1 +; 90069 + + +FarPlaceString: ; 90069 + ld a, [hROMBank] + push af + ld a, b + rst Bankswitch + + call PlaceString + + pop af + rst Bankswitch + ret +; 90074 + + +CheckPhoneCall:: ; 90074 (24:4074) +; Check if the phone is ringing in the overworld. + + call CheckStandingOnEntrance + jr z, .no_call + + call .timecheck + nop + jr nc, .no_call + + call Random + ld b, a + and 50 percent + cp b + jr nz, .no_call + + call GetMapHeaderPhoneServiceNybble + and a + jr nz, .no_call + + call GetAvailableCallers + call ChooseRandomCaller + jr nc, .no_call + + ld e, a + call LoadCallerScript + ld a, BANK(Script_ReceivePhoneCall) + ld hl, Script_ReceivePhoneCall + call CallScript + scf + ret + +.no_call + xor a + ret + +.timecheck: ; 900a6 (24:40a6) + callba CheckReceiveCallTimer + ret + +CheckPhoneContactTimeOfDay: ; 900ad (24:40ad) + push hl + push bc + push de + push af + + callba CheckTime + pop af + and (1 << MORN) + (1 << DAY) + (1 << NITE) + and c + + pop de + pop bc + pop hl + ret + +ChooseRandomCaller: ; 900bf (24:40bf) +; If no one is available to call, don't return anything. + ld a, [EngineBuffer3] + and a + jr z, .NothingToSample + +; Sample a random number between 0 and 31. + ld c, a + call Random + ld a, [hRandomAdd] ; $ff00+$e1 + swap a + and $1f +; Compute that number modulo the number of available callers. + call SimpleDivide +; Return the caller ID you just sampled. + ld c, a + ld b, 0 + ld hl, EngineBuffer4 + add hl, bc + ld a, [hl] + scf + ret + +.NothingToSample + xor a + ret + +GetAvailableCallers: ; 900de (24:40de) + callba CheckTime + ld a, c + ld [EngineBuffer1], a ; wd03e (aliases: MenuItemsList, CurFruitTree, CurInput) + ld hl, EngineBuffer3 + ld bc, 11 + xor a + call ByteFill + ld de, wPhoneList + ld a, CONTACT_LIST_SIZE + +.loop + ld [EngineBuffer2], a + ld a, [de] + and a + jr z, .not_good_for_call + ld hl, PhoneContacts + PHONE_CONTACT_SCRIPT2_TIME + ld bc, PHONE_TABLE_WIDTH + call AddNTimes + ld a, [EngineBuffer1] ; wd03e (aliases: MenuItemsList, CurFruitTree, CurInput) + and [hl] + jr z, .not_good_for_call + ld bc, PHONE_CONTACT_MAP_GROUP - PHONE_CONTACT_SCRIPT2_TIME + add hl, bc + ld a, [MapGroup] + cp [hl] + jr nz, .different_map + inc hl + ld a, [MapNumber] + cp [hl] + jr z, .not_good_for_call +.different_map + ld a, [EngineBuffer3] + ld c, a + ld b, $0 + inc a + ld [EngineBuffer3], a + ld hl, EngineBuffer4 + add hl, bc + ld a, [de] + ld [hl], a +.not_good_for_call + inc de + ld a, [EngineBuffer2] + dec a + jr nz, .loop + ret + +CheckSpecialPhoneCall:: ; 90136 (24:4136) + ld a, [wSpecialPhoneCallID] + and a + jr z, .NoPhoneCall + + dec a + ld c, a + ld b, 0 + ld hl, SpecialPhoneCallList + ld a, 6 + call AddNTimes + ld a, [hli] + ld h, [hl] + ld l, a + call _hl_ + jr nc, .NoPhoneCall + + call .DoSpecialPhoneCall +rept 2 + inc hl +endr + ld a, [hli] + ld e, a + push hl + call LoadCallerScript + pop hl + ld de, wd048 + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + ld a, BANK(.script) + ld hl, .script + call CallScript + scf + ret +.NoPhoneCall + xor a + ret +; 90173 (24:4173) + +.script: ; 0x90173 + pause 30 + jump Script_ReceivePhoneCall +; 0x90178 + +.DoSpecialPhoneCall: ; 90178 (24:4178) + ld a, [wSpecialPhoneCallID] + dec a + ld c, a + ld b, 0 + ld hl, SpecialPhoneCallList + ld a, 6 + call AddNTimes + ret + +SpecialCallOnlyWhenOutside: ; 90188 + ld a, [wPermission] + cp TOWN + jr z, .outside + cp ROUTE + jr z, .outside + xor a + ret + +.outside + scf + ret + +SpecialCallWhereverYouAre: ; 90197 + scf + ret + +Function90199: ; 90199 (24:4199) + ; Don't do the call if you're in a link communication + ld a, [wLinkMode] + and a + jr nz, .OutOfArea + ; If you're in an area without phone service, don't do the call + call GetMapHeaderPhoneServiceNybble + and a + jr nz, .OutOfArea + ; If the person can't take a call at that time, don't do the call + ld a, b + ld [wCurrentCaller], a + ld hl, PhoneContacts + ld bc, PHONE_TABLE_WIDTH + call AddNTimes + ld d, h + ld e, l + ld hl, PHONE_CONTACT_SCRIPT1_TIME + add hl, de + ld a, [hl] + call CheckPhoneContactTimeOfDay + jr z, .OutOfArea + ; If we're in the same map as the person we're calling, + ; use the "Just talk to that person" script. + ld hl, PHONE_CONTACT_MAP_GROUP + add hl, de + ld a, [MapGroup] + cp [hl] + jr nz, .GetPhoneScript + ld hl, PHONE_CONTACT_MAP_NUMBER + add hl, de + ld a, [MapNumber] + cp [hl] + jr nz, .GetPhoneScript + ld b, BANK(PhoneScript_JustTalkToThem) + ld hl, PhoneScript_JustTalkToThem + jr .DoPhoneCall + +.GetPhoneScript + ld hl, PHONE_CONTACT_SCRIPT1_BANK + add hl, de + ld b, [hl] + ld hl, PHONE_CONTACT_SCRIPT1_ADDR_LO + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jr .DoPhoneCall + +.OutOfArea + ld b, BANK(UnknownScript_0x90209) + ld de, UnknownScript_0x90209 + call ExecuteCallbackScript + ret + +.DoPhoneCall + ld a, b + ld [wd002], a + ld a, l + ld [wd003], a + ld a, h + ld [wd004], a + ld b, BANK(UnknownScript_0x90205) + ld de, UnknownScript_0x90205 + call ExecuteCallbackScript + ret +; 90205 (24:4205) + +UnknownScript_0x90205: ; 0x90205 + ptcall wd002 + return +; 0x90209 + +UnknownScript_0x90209: ; 0x90209 + scall UnknownScript_0x90657 + return +; 0x9020d + +LoadCallerScript: ; 9020d (24:420d) + nop + nop + ld a, e + ld [wCurrentCaller], a + and a + jr nz, .actualcaller + ld a, BANK(WrongNumber) + ld hl, WrongNumber + jr .proceed + +.actualcaller + ld hl, PhoneContacts + ld bc, 12 + ld a, e + call AddNTimes + ld a, BANK(PhoneContacts) +.proceed + ld de, EngineBuffer2 + ld bc, 12 + call FarCopyBytes + ret +; 90233 (24:4233) + +WrongNumber: ; 90233 + db TRAINER_NONE, PHONE_00 + dba .script +.script: + writetext .text + end +.text: + ; Huh? Sorry, wrong number! + text_jump UnknownText_0x1c5565 + db "@" +; 90241 + +Script_ReceivePhoneCall: ; 0x90241 + refreshscreen $0 + callasm RingTwice_StartCall + ptcall wd048 + closetext + callasm HangUp + loadmovesprites + callasm InitCallReceiveDelay + end +; 0x90255 + +Script_SpecialBillCall:: ; 0x90255 + callasm Function9025c + jump Script_ReceivePhoneCall +; 0x9025c + +Function9025c: ; 9025c + ld e, PHONE_BILL + jp LoadCallerScript +; 90261 + +UnknownScript_0x90261: ; 0x90261 + callasm Function9026a + pause 30 + jump Script_ReceivePhoneCall +; 0x9026a + +Function9026a: ; 9026a + ld e, PHONE_ELM + jp LoadCallerScript +; 9026f + +RingTwice_StartCall: ; 9026f + call .Ring + call .Ring + callba MobileFn_1060d3 + ret +; 9027c + +.Ring: ; 9027c (24:427c) + call Phone_StartRinging + call Phone_Wait20Frames + call Phone_CallerTextboxWithName + call Phone_Wait20Frames + call Phone_CallerTextbox + call Phone_Wait20Frames + call Phone_CallerTextboxWithName + ret + +Phone_CallerTextboxWithName: ; 90292 (24:4292) + ld a, [wCurrentCaller] + ld b, a + call Function90363 + ret + + +PhoneCall:: ; 9029a + ld a, b + ld [PhoneScriptBank], a + ld a, e + ld [PhoneCallerLo], a + ld a, d + ld [PhoneCallerHi], a + call Phone_FirstOfTwoRings + call Phone_FirstOfTwoRings + callba MobileFn_1060d3 + ret +; 902b3 + +Phone_FirstOfTwoRings: ; 902b3 + call Phone_StartRinging + call Phone_Wait20Frames + call Phone_CallerTextboxWithName2 + call Phone_Wait20Frames + call Phone_CallerTextbox + call Phone_Wait20Frames + call Phone_CallerTextboxWithName2 + ret +; 902c9 + +Phone_CallerTextboxWithName2: ; 902c9 + call Phone_CallerTextbox + hlcoord 1, 2 + ld [hl], $62 +rept 2 + inc hl +endr + ld a, [PhoneScriptBank] + ld b, a + ld a, [PhoneCallerLo] + ld e, a + ld a, [PhoneCallerHi] + ld d, a + call FarPlaceString + ret +; 902e3 + + +Phone_NoSignal: ; 902e3 (24:42e3) + ld de, SFX_NO_SIGNAL + call PlaySFX + jr Phone_CallEnd + +HangUp:: ; 902eb + call HangUp_Beep + call HangUp_Wait20Frames +Phone_CallEnd: + call HangUp_BoopOn + call HangUp_Wait20Frames + call HangUp_BoopOff + call HangUp_Wait20Frames + call HangUp_BoopOn + call HangUp_Wait20Frames + call HangUp_BoopOff + call HangUp_Wait20Frames + call HangUp_BoopOn + call HangUp_Wait20Frames + call HangUp_BoopOff + call HangUp_Wait20Frames + ret +; 90316 + +Function90316: ; 90316 + ld de, SFX_SHUT_DOWN_PC + call PlaySFX + ret +; 9031d + +HangUp_Beep: ; 9031d + ld hl, UnknownText_0x9032a + call PrintText + ld de, SFX_HANG_UP + call PlaySFX + ret +; 9032a + +UnknownText_0x9032a: ; 9032a + text_jump UnknownText_0x1c5580 + db "@" +; 9032f + + +HangUp_BoopOn: ; 9032f + ld hl, UnknownText_0x90336 + call PrintText + ret +; 90336 + +UnknownText_0x90336: ; 0x90336 + text_jump UnknownText_0x1c5588 + db "@" +; 0x9033b + + +HangUp_BoopOff: ; 9033b + call SpeechTextBox + ret +; 9033f + +Phone_StartRinging: ; 9033f + call WaitSFX + ld de, SFX_CALL + call PlaySFX + call Phone_CallerTextbox + call UpdateSprites + callba Function4d188 + ret +; 90355 + +HangUp_Wait20Frames: ; 90355 + jr Phone_Wait20Frames + +Phone_Wait20Frames + ld c, 20 + call DelayFrames + callba Function4d188 + ret +; 90363 + + +Function90363: ; 90363 (24:4363) + push bc + call Phone_CallerTextbox + hlcoord 1, 1 + ld [hl], $62 +rept 2 + inc hl +endr + ld d, h + ld e, l + pop bc + call Function90380 + ret + + +Phone_CallerTextbox: ; 90375 + hlcoord 0, 0 + ld b, 2 + ld c, SCREEN_WIDTH - 2 + call TextBox + ret +; 90380 + + +Function90380: ; 90380 (24:4380) + ld h, d + ld l, e + ld a, b + call GetCallerTrainerClass + call GetCallerName + ret + +Function9038a: ; 9038a (24:438a) + ld a, c + call GetCallerTrainerClass + ld a, c + ret nz + ld a, b + cp $1 + ret z + cp $4 + ret z + ld c, $1 + ret + +GetCallerTrainerClass: ; 9039a + push hl + ld hl, PhoneContacts + PHONE_CONTACT_TRAINER_CLASS + ld bc, PHONE_TABLE_WIDTH + call AddNTimes + ld a, [hli] + ld b, [hl] + ld c, a + pop hl + ret +; 903a9 + + +GetCallerName: ; 903a9 (24:43a9) + ld a, c + and a + jr z, .NotTrainer + + call Phone_GetTrainerName + push hl + push bc + call PlaceString + ld a, ":" + ld [bc], a + pop bc + pop hl + ld de, SCREEN_WIDTH + 3 + add hl, de + call Phone_GetTrainerClassName + call PlaceString + ret + +.NotTrainer + push hl + ld c, b + ld b, 0 + ld hl, NonTrainerCallerNames +rept 2 + add hl, bc +endr + ld a, [hli] + ld e, a + ld d, [hl] + pop hl + call PlaceString + ret +; 903d6 (24:43d6) + +NonTrainerCallerNames: ; 903d6 + dw .none + dw .mom + dw .bikeshop + dw .bill + dw .elm + dw .buena + +.none: db "----------@" +.mom: db "MOM:@" +.bill: db "BILL:@" +.elm: db "PROF.ELM:@" +.bikeshop: db "BIKE SHOP:@" +.buena: db "BUENA:", $22, " DISC JOCKEY@" +; 90423 + +Phone_GetTrainerName: ; 90423 (24:4423) + push hl + push bc + callba GetTrainerName + pop bc + pop hl + ret + +Phone_GetTrainerClassName: ; 9042e (24:442e) + push hl + push bc + callba GetTrainerClassName + pop bc + pop hl + ret + +GetCallerLocation: ; 90439 + ld a, [wCurrentCaller] + call GetCallerTrainerClass + ld d, c + ld e, b + push de + ld a, [wCurrentCaller] + ld hl, PhoneContacts + PHONE_CONTACT_MAP_GROUP + ld bc, PHONE_TABLE_WIDTH + call AddNTimes + ld b, [hl] + inc hl + ld c, [hl] + push bc + call GetWorldMapLocation + ld e, a + callba GetLandmarkName + pop bc + pop de + ret +; 9045f + +PhoneContacts: ; 9045f +phone: MACRO + db \1, \2 ; trainer + map \3 ; map + db \4 + dba \5 ; script 1 + db \6 + dba \7 ; script 2 +ENDM + + phone TRAINER_NONE, PHONE_00, N_A, 0, UnusedPhoneScript, 0, UnusedPhoneScript + phone TRAINER_NONE, PHONECONTACT_MOM, KRISS_HOUSE_1F, 7, MomPhoneScript, 0, UnusedPhoneScript + phone TRAINER_NONE, PHONECONTACT_BIKESHOP, OAKS_LAB, 0, UnusedPhoneScript, 0, UnusedPhoneScript + phone TRAINER_NONE, PHONECONTACT_BILL, N_A, 7, BillPhoneScript1, 0, BillPhoneScript2 + phone TRAINER_NONE, PHONECONTACT_ELM, ELMS_LAB, 7, ElmPhoneScript1, 0, ElmPhoneScript2 + phone SCHOOLBOY, JACK1, NATIONAL_PARK, 7, JackPhoneScript1, 7, JackPhoneScript2 + phone POKEFANF, BEVERLY1, NATIONAL_PARK, 7, BeverlyPhoneScript1, 7, BeverlyPhoneScript2 + phone SAILOR, HUEY1, OLIVINE_LIGHTHOUSE_2F, 7, HueyPhoneScript1, 7, HueyPhoneScript2 + phone TRAINER_NONE, PHONE_00, N_A, 0, UnusedPhoneScript, 0, UnusedPhoneScript + phone TRAINER_NONE, PHONE_00, N_A, 0, UnusedPhoneScript, 0, UnusedPhoneScript + phone TRAINER_NONE, PHONE_00, N_A, 0, UnusedPhoneScript, 0, UnusedPhoneScript + phone COOLTRAINERM, GAVEN3, ROUTE_26, 7, GavenPhoneScript1, 7, GavenPhoneScript2 + phone COOLTRAINERF, BETH1, ROUTE_26, 7, BethPhoneScript1, 7, BethPhoneScript2 + phone BIRD_KEEPER, JOSE2, ROUTE_27, 7, JosePhoneScript1, 7, JosePhoneScript2 + phone COOLTRAINERF, REENA1, ROUTE_27, 7, ReenaPhoneScript1, 7, ReenaPhoneScript2 + phone YOUNGSTER, JOEY1, ROUTE_30, 7, JoeyPhoneScript1, 7, JoeyPhoneScript2 + phone BUG_CATCHER, WADE1, ROUTE_31, 7, WadePhoneScript1, 7, WadePhoneScript2 + phone FISHER, RALPH1, ROUTE_32, 7, RalphPhoneScript1, 7, RalphPhoneScript2 + phone PICNICKER, LIZ1, ROUTE_32, 7, LizPhoneScript1, 7, LizPhoneScript2 + phone HIKER, ANTHONY2, ROUTE_33, 7, AnthonyPhoneScript1, 7, AnthonyPhoneScript2 + phone CAMPER, TODD1, ROUTE_34, 7, ToddPhoneScript1, 7, ToddPhoneScript2 + phone PICNICKER, GINA1, ROUTE_34, 7, GinaPhoneScript1, 7, GinaPhoneScript2 + phone JUGGLER, IRWIN1, ROUTE_35, 7, IrwinPhoneScript1, 7, IrwinPhoneScript2 + phone BUG_CATCHER, ARNIE1, ROUTE_35, 7, ArniePhoneScript1, 7, ArniePhoneScript2 + phone SCHOOLBOY, ALAN1, ROUTE_36, 7, AlanPhoneScript1, 7, AlanPhoneScript2 + phone TRAINER_NONE, PHONE_00, N_A, 0, UnusedPhoneScript, 0, UnusedPhoneScript + phone LASS, DANA1, ROUTE_38, 7, DanaPhoneScript1, 7, DanaPhoneScript2 + phone SCHOOLBOY, CHAD1, ROUTE_38, 7, ChadPhoneScript1, 7, ChadPhoneScript2 + phone POKEFANM, DEREK1, ROUTE_39, 7, DerekPhoneScript1, 7, DerekPhoneScript2 + phone FISHER, TULLY1, ROUTE_42, 7, TullyPhoneScript1, 7, TullyPhoneScript2 + phone POKEMANIAC, BRENT1, ROUTE_43, 7, BrentPhoneScript1, 7, BrentPhoneScript2 + phone PICNICKER, TIFFANY3, ROUTE_43, 7, TiffanyPhoneScript1, 7, TiffanyPhoneScript2 + phone BIRD_KEEPER, VANCE1, ROUTE_44, 7, VancePhoneScript1, 7, VancePhoneScript2 + phone FISHER, WILTON1, ROUTE_44, 7, WiltonPhoneScript1, 7, WiltonPhoneScript2 + phone BLACKBELT_T, KENJI3, ROUTE_45, 7, KenjiPhoneScript1, 7, KenjiPhoneScript2 + phone HIKER, PARRY1, ROUTE_45, 7, ParryPhoneScript1, 7, ParryPhoneScript2 + phone PICNICKER, ERIN1, ROUTE_46, 7, ErinPhoneScript1, 7, ErinPhoneScript2 + phone TRAINER_NONE, PHONECONTACT_BUENA, GOLDENROD_DEPT_STORE_ROOF, 7, BuenaPhoneScript1, 7, BuenaPhoneScript2 +; 90627 + +SpecialPhoneCallList: ; 90627 + dw SpecialCallOnlyWhenOutside + db PHONE_ELM + dba ElmPhoneScript2 + + dw SpecialCallOnlyWhenOutside + db PHONE_ELM + dba ElmPhoneScript2 + + dw SpecialCallOnlyWhenOutside + db PHONE_ELM + dba ElmPhoneScript2 + + dw SpecialCallOnlyWhenOutside + db PHONE_ELM + dba ElmPhoneScript2 + + dw SpecialCallWhereverYouAre + db PHONE_ELM + dba ElmPhoneScript2 + + dw SpecialCallWhereverYouAre + db PHONE_OAK ; ???????? + dba BikeShopPhoneScript ; bike shop + + dw SpecialCallWhereverYouAre + db PHONE_MOM + dba MomPhoneLectureScript + + dw SpecialCallOnlyWhenOutside + db PHONE_ELM + dba ElmPhoneScript2 +; 90657 + +UnknownScript_0x90657: ; 0x90657 + writetext UnknownText_0x9065b + end +; 0x9065b + +UnknownText_0x9065b: ; 0x9065b + ; That number is out of the area. + text_jump UnknownText_0x1c558b + db "@" +; 0x90660 + +PhoneScript_JustTalkToThem: ; 0x90660 + writetext UnknownText_0x90664 + end +; 0x90664 + +UnknownText_0x90664: ; 0x90664 + ; Just go talk to that person! + text_jump UnknownText_0x1c55ac + db "@" +; 0x90669 + +UnknownScript_0x90669: ; 0x90669 + writetext UnknownText_0x9066d + end +; 0x9066d + +UnknownText_0x9066d: ; 0x9066d + ; Thank you! + text_jump UnknownText_0x1c55ca + db "@" +; 0x90672 diff --git a/engine/phone_scripts.asm b/engine/phone_scripts.asm index 5be1c9a77..5d8afd028 100644 --- a/engine/phone_scripts.asm +++ b/engine/phone_scripts.asm @@ -141,7 +141,7 @@ MomPhoneNoGymQuestScript: ; 0xbcfac MomPhoneLectureScript: ; 0xbcfb1 setevent EVENT_TALKED_TO_MOM_AFTER_MYSTERY_EGG_QUEST setflag ENGINE_DST - specialphonecall ELMCALL_NONE + specialphonecall SPECIALCALL_NONE farwritetext MomPhoneLectureText yesorno iftrue MomPhoneSaveMoneyScript @@ -194,7 +194,7 @@ BillPhoneScript2: ; 0xbd007 ; Elm ElmPhoneScript1: ; 0xbd00d - checkcode VAR_POKERUS + checkcode VAR_SPECIALPHONECALL if_equal $1, .pokerus checkevent EVENT_SHOWED_TOGEPI_TO_ELM iftrue .discovery @@ -253,46 +253,46 @@ ElmPhoneScript1: ; 0xbd00d .pokerus ; 0xbd079 farwritetext ElmPhonePokerusText - specialphonecall ELMCALL_NONE + specialphonecall SPECIALCALL_NONE end ElmPhoneScript2: ; 0xbd081 - checkcode VAR_POKERUS + checkcode VAR_SPECIALPHONECALL if_equal $2, .disaster if_equal $3, .assistant if_equal $4, .rocket if_equal $5, .gift if_equal $8, .gift farwritetext ElmPhonePokerusText - specialphonecall ELMCALL_NONE + specialphonecall SPECIALCALL_NONE end .disaster ; 0xbd09f farwritetext ElmPhoneDisasterText - specialphonecall ELMCALL_NONE + specialphonecall SPECIALCALL_NONE setevent EVENT_ELM_CALLED_ABOUT_STOLEN_POKEMON end .assistant ; 0xbd0aa farwritetext ElmPhoneEggAssistantText - specialphonecall ELMCALL_NONE + specialphonecall SPECIALCALL_NONE clearevent EVENT_ELMS_AIDE_IN_VIOLET_POKEMON_CENTER setevent EVENT_ELMS_AIDE_IN_LAB end .rocket ; 0xbd0b8 farwritetext ElmPhoneRocketText - specialphonecall ELMCALL_NONE + specialphonecall SPECIALCALL_NONE end .gift ; 0xbd0c0 farwritetext ElmPhoneGiftText - specialphonecall ELMCALL_NONE + specialphonecall SPECIALCALL_NONE end .unused ; 0xbd0c8 farwritetext ElmPhoneUnusedText - specialphonecall ELMCALL_NONE + specialphonecall SPECIALCALL_NONE end ; bd0d0 @@ -833,7 +833,7 @@ UnknownScript_0xbd544: pokenamemem QWILFISH, $1 displaylocation ROUTE_32, $2 writebyte $1 - special Functionc3fc + special Special_ActivateFishingSwarm farjump UnknownScript_0xa05d6 UnknownScript_0xbd55c: diff --git a/engine/pokedex.asm b/engine/pokedex.asm index 970863675..dd58e940d 100644 --- a/engine/pokedex.asm +++ b/engine/pokedex.asm @@ -16,10 +16,10 @@ Pokedex: ; 40000 push af xor a ld [VramState], a - ld a, [$ffaa] + ld a, [hInMenu] push af ld a, $1 - ld [$ffaa], a + ld [hInMenu], a xor a ld [$ffde], a @@ -27,8 +27,8 @@ Pokedex: ; 40000 call DelayFrame .main - call Functiona57 - ld a, [wcf63] + call JoyTextDelay + ld a, [wJumptableIndex] bit 7, a jr nz, .exit call Function4010b @@ -44,7 +44,7 @@ Pokedex: ; 40000 ld [wd959], a pop af - ld [$ffaa], a + ld [hInMenu], a pop af ld [VramState], a pop af @@ -75,7 +75,7 @@ ENDC call ByteFill xor a - ld [wcf63], a + ld [wJumptableIndex], a ld [wcf64], a ld [wcf65], a ld [wcf66], a @@ -173,7 +173,7 @@ Function400ed: ; 400ed ; 4010b Function4010b: ; 4010b - ld a, [wcf63] + ld a, [wJumptableIndex] ld hl, Jumptable_40115 call Function41432 jp [hl] @@ -198,12 +198,12 @@ Jumptable_40115: ; 40115 (10:4115) Function40131: ; 40131 (10:4131) - ld hl, wcf63 + ld hl, wJumptableIndex inc [hl] ret Function40136: ; 40136 (10:4136) - ld hl, wcf63 + ld hl, wJumptableIndex set 7, [hl] ret @@ -283,7 +283,7 @@ Function401ae: ; 401ae (10:41ae) call Function40bd0 ret z ld a, $2 - ld [wcf63], a + ld [wJumptableIndex], a ld a, $0 ld [wcf64], a ret @@ -291,7 +291,7 @@ Function401ae: ; 401ae (10:41ae) .select call Function41401 ld a, $7 - ld [wcf63], a + ld [wJumptableIndex], a xor a ld [hSCX], a ; $ff00+$cf ld a, $a7 @@ -302,7 +302,7 @@ Function401ae: ; 401ae (10:41ae) .start call Function41401 ld a, $5 - ld [wcf63], a + ld [wJumptableIndex], a xor a ld [hSCX], a ; $ff00+$cf ld a, $a7 @@ -312,7 +312,7 @@ Function401ae: ; 401ae (10:41ae) .b ld a, $d - ld [wcf63], a + ld [wJumptableIndex], a ret Function40217: ; 40217 (10:4217) @@ -372,7 +372,7 @@ Function40258: ; 40258 (10:4258) .asm_40288 call MaxVolume ld a, [wcf64] - ld [wcf63], a + ld [wJumptableIndex], a ret ; 40292 (10:4292) @@ -408,7 +408,7 @@ Function402aa: ; 402aa (10:42aa) call Function41423 ld a, [CurPartySpecies] call PlayCry - ld hl, wcf63 + ld hl, wJumptableIndex dec [hl] ret ; 402e8 (10:42e8) @@ -478,11 +478,11 @@ Function4034f: ; 4034f push af ld a, [wcf64] push af - ld a, [wcf63] + ld a, [wJumptableIndex] push af callba Function8442c pop af - ld [wcf63], a + ld [wJumptableIndex], a pop af ld [wcf64], a pop af @@ -552,7 +552,7 @@ Function403be: ; 403be (10:43be) .asm_403ea call Function41401 ld a, $0 - ld [wcf63], a + ld [wJumptableIndex], a ret ; 403f3 (10:43f3) @@ -604,13 +604,13 @@ Function40417: ; 40417 (10:4417) .asm_40431 call Function41401 ld a, $0 - ld [wcf63], a + ld [wJumptableIndex], a ret Function4043a: ; 4043a (10:443a) call Function41401 ld a, $b - ld [wcf63], a + ld [wJumptableIndex], a ret Function40443: ; 40443 (10:4443) @@ -656,7 +656,7 @@ Function40471: ; 40471 (10:4471) .asm_40495 call Function41401 ld a, $0 - ld [wcf63], a + ld [wJumptableIndex], a ret ; 4049e (10:449e) @@ -710,14 +710,14 @@ Function404b7: ; 404b7 ld [wc7d1], a call Function41401 ld a, $9 - ld [wcf63], a + ld [wJumptableIndex], a ret ; 40501 Function40501: ; 40501 call Function41401 ld a, $0 - ld [wcf63], a + ld [wJumptableIndex], a ret ; 4050a @@ -779,7 +779,7 @@ Function40562: ; 40562 (10:4562) call Function40bd0 ret z ld a, $2 - ld [wcf63], a + ld [wJumptableIndex], a ld a, $9 ld [wcf64], a ret @@ -795,7 +795,7 @@ Function40562: ; 40562 (10:4562) call ClearSprites call Function40bdc ld a, $5 - ld [wcf63], a + ld [wJumptableIndex], a xor a ld [hSCX], a ; $ff00+$cf ld a, $a7 @@ -827,7 +827,7 @@ Function405df: ; 405df (10:45df) .asm_405eb call Function41401 ld a, $7 - ld [wcf63], a + ld [wJumptableIndex], a call DelayFrame call Function41a24 jr nz, .asm_40603 @@ -836,7 +836,7 @@ Function405df: ; 405df (10:45df) .asm_40603 ld hl, PokedexLZ - ld de, $9310 + ld de, VTiles2 tile $31 lb bc, BANK(PokedexLZ), $3a call Functione73 @@ -844,7 +844,7 @@ Function405df: ; 405df (10:45df) ret Function40610: ; 40610 (10:4610) - ld hl, $ffa9 + ld hl, hJoyLast ld a, [hl] and D_RIGHT jr nz, .right @@ -913,7 +913,7 @@ Function4066c: ; 4066c (10:466c) ld [wc7e2], a ld a, [wc7d0] ld [wc7e3], a - ld hl, $ffa9 + ld hl, hJoyLast ld a, [hl] and D_UP jr nz, .up @@ -964,7 +964,7 @@ Function406c5: ; 406c5 (10:46c5) ld d, a ld a, [wc7d2] ld e, a - ld hl, $ffa9 + ld hl, hJoyLast ld a, [hl] and D_UP jr nz, Function406ea @@ -1799,7 +1799,7 @@ Function40f4f: ; 40f4f (10:4f4f) ld a, [wc7d8] cp $2 jr nc, .asm_40f63 - ld hl, $ffa9 + ld hl, hJoyLast ld a, [hl] and $20 jr nz, .asm_40f65 @@ -2274,7 +2274,7 @@ Function4135a: ; 4135a (10:535a) jr nz, .asm_413c1 call Function413f5 jr c, .asm_413bf - ld hl, $ffa9 + ld hl, hJoyLast ld a, [hl] and D_LEFT | D_UP and b @@ -2460,7 +2460,7 @@ Function4147b: ; 4147b push hl ld e, l ld d, h - ld hl, $9620 + ld hl, VTiles2 tile $62 lb bc, BANK(Footprints), 2 call Request1bpp pop hl @@ -2472,7 +2472,7 @@ Function4147b: ; 4147b ld e, l ld d, h - ld hl, $9640 + ld hl, VTiles2 tile $64 lb bc, BANK(Footprints), 2 call Request1bpp @@ -2488,7 +2488,7 @@ Function414b7: ; 414b7 call ByteFill call Function414fb call Functione5f - ld hl, $9600 + ld hl, VTiles2 tile $60 ld bc, $0200 call Function41504 call Function41a24 @@ -2498,7 +2498,7 @@ Function414b7: ; 414b7 .asm_414e0 ld hl, PokedexLZ - ld de, $9310 + ld de, VTiles2 tile $31 call Decompress .asm_414e9 @@ -2554,7 +2554,7 @@ Function41a2c: ; 41a2c ld bc, $1b0 call Function41504 ld de, sScratch + $188 - ld hl, $9400 + ld hl, VTiles2 tile $40 lb bc, BANK(Function41a2c), $1b call Request2bpp call CloseSRAM @@ -2575,7 +2575,7 @@ Function41a58: ; 41a58 (10:5a58) ld a, UNOWN ld [CurPartySpecies], a call GetBaseData - ld de, $9000 + ld de, VTiles2 tile $00 predef GetFrontpic pop af ld [UnownLetter], a diff --git a/engine/predef.asm b/engine/predef.asm index 4284d5adf..9fa26875a 100644 --- a/engine/predef.asm +++ b/engine/predef.asm @@ -82,9 +82,9 @@ PredefPointers:: ; 856b add_predef Predef_LoadSGBLayout add_predef Function91d11 add_predef CheckContestMon - add_predef Function8c20f - add_predef Function8c000 - add_predef Function8c000_2 + add_predef Predef_StartBattle + add_predef Predef35 + add_predef Predef36 add_predef PlayBattleAnim add_predef Predef38 ; $38 add_predef Predef39 diff --git a/engine/radio.asm b/engine/radio.asm index 4ebd0e1e8..d833b66f5 100644 --- a/engine/radio.asm +++ b/engine/radio.asm @@ -1707,7 +1707,7 @@ BuenasPassword3: ; b8f47 (2e:4f47) BuenasPassword4: ; b8f55 (2e:4f55) call BuenasPasswordCheckMidnight jp c, BuenasPassword8 - ld a, [wdc4a] + ld a, [wBuenasPassword] ; If we already generated the password today, we don't need to generate a new one. ld hl, WeeklyFlags bit 7, [hl] @@ -1727,9 +1727,9 @@ BuenasPassword4: ; b8f55 (2e:4f55) and $3 cp $3 jr nc, .greater_than_three -; The high nybble of wdc4a will now contain the password group index, and the low nybble contains the actual password. +; The high nybble of wBuenasPassword will now contain the password group index, and the low nybble contains the actual password. add e - ld [wdc4a], a + ld [wBuenasPassword], a ; Set the flag so that we don't generate a new password this week. ld hl, WeeklyFlags set 7, [hl] diff --git a/engine/save.asm b/engine/save.asm index f47495b1d..fa9aeda12 100644 --- a/engine/save.asm +++ b/engine/save.asm @@ -380,7 +380,7 @@ ErasePreviousSave: ; 14cbb ld [sStackTop + 1], a call CloseSRAM ld a, $1 - ld [wd4b4], a + ld [wSavedAtLeastOnce], a ret ; 14ce2 @@ -486,7 +486,7 @@ Function14d93: ; 14d93 Function14da0: ; 14da0 - ld a, [wd4b4] + ld a, [wSavedAtLeastOnce] and a ret nz call ErasePreviousSave diff --git a/engine/scripting.asm b/engine/scripting.asm index f8ac4cc0c..2dadafee1 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -529,7 +529,7 @@ Script_interpretmenu: ; 0x96f41 ld a, [ScriptBank] ld hl, InterpretMenu rst FarCall - ld a, [wcf88] + ld a, [wPocketCursorBuffer] jr nc, .ok xor a .ok @@ -651,7 +651,7 @@ Script_specialsound: ; 0x96fe4 ; script command 0x88 callba CheckItemPocket - ld a, [wd142] + ld a, [wItemAttributeParamBuffer] cp TM_HM ld de, SFX_GET_TM jr z, .play @@ -665,7 +665,7 @@ Script_specialsound: ; 0x96fe4 GetPocketName: ; 96ffe callba CheckItemPocket - ld a, [wd142] + ld a, [wItemAttributeParamBuffer] dec a ld hl, .Pockets and 3 @@ -1338,12 +1338,12 @@ Script_moveperson: ; 0x97341 call GetScriptPerson ld b, a call GetScriptByte - add $4 + add 4 ld d, a call GetScriptByte - add $4 + add 4 ld e, a - callba Function807e + callba CopyDECoordsToMapObject ret ; 0x9735b @@ -1385,10 +1385,10 @@ Script_loademote: ; 0x97384 ; bubble (SingleByteParam) call GetScriptByte - cp $ff - jr nz, .asm_9738e ; 0x97389 $3 + cp -1 + jr nz, .not_var_emote ; 0x97389 $3 ld a, [ScriptVar] -.asm_9738e +.not_var_emote ld c, a callba Function1442f ret @@ -1417,7 +1417,7 @@ Script_showemote: ; 0x97396 ; 0x973b6 ShowEmoteScript: ; 973b6 - loademote $ff + loademote -1 applymovement2 .Show pause 0 applymovement2 .Hide @@ -1448,12 +1448,12 @@ Script_earthquake: ; 0x973c7 ld [wd003], a and $3f ld [wd005], a - ld b, BANK(UnknownScript_0x973e6) - ld de, UnknownScript_0x973e6 + ld b, BANK(.script) + ld de, .script jp ScriptCall ; 0x973e6 -UnknownScript_0x973e6: ; 973e6 +.script: ; 973e6 applymovement PLAYER, wd002 end ; 973eb @@ -1487,7 +1487,7 @@ Script_battlecheck: ; 0x973fb Script_loadtrainerdata: ; 0x97400 ; script command 0x5c - ld a, $81 + ld a, (1 << 7) | 1 ld [wd459], a ld a, [WalkingDirection] ld [OtherTrainerClass], a @@ -1502,7 +1502,7 @@ Script_loadpokedata: ; 0x97412 ; pokemon (PokemonParam) ; level (DecimalParam) - ld a, $80 + ld a, (1 << 7) ld [wd459], a call GetScriptByte ld [TempWildMonSpecies], a @@ -1517,7 +1517,7 @@ Script_loadtrainer: ; 0x97424 ; trainer_group (TrainerGroupParam) ; trainer_id (TrainerIdParam) - ld a, $81 + ld a, (1 << 7) | 1 ld [wd459], a call GetScriptByte ld [OtherTrainerClass], a @@ -1531,7 +1531,7 @@ Script_startbattle: ; 0x97436 call BufferScreen predef StartBattle - ld a, [wd0ee] + ld a, [wBattleResult] and $3f ld [ScriptVar], a ret @@ -1555,26 +1555,28 @@ Script_returnafterbattle: ; 0x97459 ld hl, wd459 ld d, [hl] ld [hl], $0 - ld a, [wd0ee] + ld a, [wBattleResult] and $3f cp $1 - jr nz, .asm_97470 ; 0x97466 $8 + jr nz, .notblackedout ; 0x97466 $8 ld b, BANK(UnknownScript_0x124c1) ld hl, UnknownScript_0x124c1 jp ScriptJump -.asm_97470 + +.notblackedout bit 0, d - jr z, .asm_9747c ; 0x97472 $8 - callba Functionfcfec - jr .asm_9748e ; 0x9747a $12 -.asm_9747c - ld a, [wd0ee] + jr z, .was_wild ; 0x97472 $8 + callba MomTriesToBuySomething + jr .done ; 0x9747a $12 + +.was_wild + ld a, [wBattleResult] bit 7, a - jr z, .asm_9748e ; 0x97481 $b - ld b, BANK(UnknownScript_0x90255) - ld de, UnknownScript_0x90255 - callba Function97c4f -.asm_9748e + jr z, .done ; 0x97481 $b + ld b, BANK(Script_SpecialBillCall) + ld de, Script_SpecialBillCall + callba LoadScriptBDE +.done jp Script_reloadmap ; 0x97491 @@ -1583,7 +1585,7 @@ Script_reloadmap: ; 0x97491 xor a ld [wd459], a - ld a, $f3 + ld a, MAPSETUP_RELOADMAP ld [hMapEntryMethod], a ld a, $1 call LoadMapStatus @@ -2202,7 +2204,7 @@ Script_name: ; 0x97716 ; memory (SingleByteParam) call GetScriptByte - ld [wcf61], a + ld [wNamedObjectTypeBuffer], a ContinueToGetName: ; 0x9771c call GetScriptByte @@ -2219,7 +2221,7 @@ Script_trainerclassname: ; 0x9772b ; memory (SingleByteParam) ld a, TRAINER_NAME - ld [wcf61], a + ld [wNamedObjectTypeBuffer], a jr ContinueToGetName ; 0x97730 $ea ; 0x97732 @@ -2811,10 +2813,10 @@ Script_warpfacing: ; 0x97a0e call GetScriptByte and $3 ld c, a - ld a, [wd45b] + ld a, [wPlayerSpriteSetupFlags] set 5, a or c - ld [wd45b], a + ld [wPlayerSpriteSetupFlags], a ; fall through Script_warp: ; 0x97a1d @@ -2838,7 +2840,7 @@ Script_warp: ; 0x97a1d ld [YCoord], a ld a, -1 ld [wd001], a - ld a, -15 + ld a, MAPSETUP_WARP ld [hMapEntryMethod], a ld a, 1 call LoadMapStatus @@ -2850,7 +2852,7 @@ Script_warp: ; 0x97a1d call GetScriptByte ld a, -1 ld [wd001], a - ld a, -5 + ld a, MAPSETUP_BADWARP ld [hMapEntryMethod], a ld a, 1 call LoadMapStatus @@ -2966,7 +2968,7 @@ Script_reloadmappart:: ; 0x97ae3 ; script command 0x7c xor a - ld [$ffd4], a + ld [hBGMapMode], a call Function2173 call Function2914 callba Function104061 @@ -3011,7 +3013,7 @@ Script_reloadandreturn: ; 0x97b16 Script_loadfont: ; 0x97b1c ; script command 0x47 - call Function2e08 + call LoadFont ret ; 0x97b20 @@ -3044,7 +3046,7 @@ Script_loadmovesprites: ; 0x97b2f ; script command 0x49 call Function2e20 - call Function2dcf + call LoadMoveSprites ret ; 0x97b36 diff --git a/engine/specials.asm b/engine/specials.asm index 41b0d9e9a..e9fe2987f 100644 --- a/engine/specials.asm +++ b/engine/specials.asm @@ -39,7 +39,7 @@ SpecialsPointers:: ; c029 add_special Special_GetMysteryGiftItem add_special Special_UnlockMysteryGift -; Bug Catching Contest +; Map Events add_special BugContestJudging add_special CheckPartyFullAfterContest add_special CheckFirstMonFainted @@ -88,25 +88,25 @@ SpecialsPointers:: ; c029 add_special Special_FindAtLeastThatHappy add_special Special_FindThatSpecies add_special Special_FindThatSpeciesYourTrainerID - add_special Functionc3ef - add_special Function17421 - add_special Function17440 + add_special Special_CheckUnusedTwoDayTimer ; unreferenced + add_special Special_DayCareMon1 + add_special Special_DayCareMon2 add_special Special_SelectRandomBugContestContestants - add_special Functionc3fc + add_special Special_ActivateFishingSwarm add_special ToggleMaptileDecorations add_special ToggleDecorationsVisibility add_special SpecialGiveShuckle add_special SpecialReturnShuckle - add_special Function73f7 + add_special Special_BillsGrandfather add_special SpecialCheckPokerus - add_special Function24b25 - add_special Function24b4e + add_special Special_DisplayCoinCaseBalance + add_special Special_DisplayMoneyAndCoinBalance add_special Function24ae8 add_special Special_CheckForLuckyNumberWinners add_special Special_CheckLuckyNumberShowFlag add_special Special_ResetLuckyNumberShowFlag - add_special Function4d9d3 - add_special Function88018 + add_special Special_PrintTodaysLuckyNumber + add_special Special_SelectApricornForKurt add_special SpecialNameRater add_special Functionc2da add_special GetFirstPokemonHappiness @@ -169,7 +169,7 @@ SpecialsPointers:: ; c029 add_special SpecialBuenasPassword add_special SpecialBuenaPrize add_special SpecialDratini - add_special Function11485 + add_special Special_SampleKenjiBreakCountdown add_special SpecialBeastsCheck add_special SpecialMonCheck add_special Functionc225 @@ -482,16 +482,16 @@ ScriptReturnCarry: ; c3e2 ret ; c3ef -Functionc3ef: ; c3ef - callba Function1150c - ld a, [wdc3a] +Special_CheckUnusedTwoDayTimer: ; c3ef + callba CheckUnusedTwoDayTimer + ld a, [wUnusedTwoDayTimer] ld [ScriptVar], a ret ; c3fc -Functionc3fc: ; c3fc +Special_ActivateFishingSwarm: ; c3fc ld a, [ScriptVar] - ld [wdfce], a + ld [wFishingSwarmFlag], a ret ; c403 @@ -523,7 +523,7 @@ SpecialCheckPokerus: ; c419 ; c422 Special_ResetLuckyNumberShowFlag: ; c422 - callba Function1152b + callba RestartLuckyNumberCountdown ld hl, wLuckyNumberShowFlag res 0, [hl] callba LoadOrRegenerateLuckyIDNumber @@ -531,7 +531,7 @@ Special_ResetLuckyNumberShowFlag: ; c422 ; c434 Special_CheckLuckyNumberShowFlag: ; c434 - callba Function11542 + callba CheckLuckyNumberShowFlag jp ScriptReturnCarry ; c43d diff --git a/engine/std_scripts.asm b/engine/std_scripts.asm index 95c91b647..5c0df0355 100644 --- a/engine/std_scripts.asm +++ b/engine/std_scripts.asm @@ -159,7 +159,7 @@ PokeCenterNurseScript: .pokerus_done setflag ENGINE_POKERUS - specialphonecall ELMCALL_POKERUS + specialphonecall SPECIALCALL_POKERUS end DifficultBookshelfScript: @@ -297,7 +297,7 @@ RadioTowerRocketsScript: clearevent EVENT_RADIO_TOWER_ROCKET_TAKEOVER clearevent EVENT_USED_THE_CARD_KEY_IN_THE_RADIO_TOWER setevent EVENT_MAHOGANY_TOWN_POKEFAN_M_BLOCKS_EAST - specialphonecall ELMCALL_WEIRDBROADCAST + specialphonecall SPECIALCALL_WEIRDBROADCAST domaptrigger MAHOGANY_TOWN, $1 end @@ -1809,7 +1809,7 @@ CoinVendor_IntroScript: ; 0xbcde0 farwritetext CoinVendor_IntroText CoinVendor_SellCoinsMenuScript: ; 0xbcde4 - special Function24b4e + special Special_DisplayMoneyAndCoinBalance loadmenudata CoinVendor_MenuDataHeader interpretmenu2 writebackup diff --git a/engine/time.asm b/engine/time.asm index 8b3f5d758..fce01ffac 100755 --- a/engine/time.asm +++ b/engine/time.asm @@ -1,104 +1,104 @@ -Function113d6: ; 113d6 - call Function114dd +_InitializeStartDay: ; 113d6 + call InitializeStartDay ret ; 113da -Function113da: ; 113da +ClearDailyTimers: ; 113da xor a ld [wLuckyNumberDayBuffer], a - ld [wdc3a], a - ld [wdc1c], a + ld [wUnusedTwoDayTimer], a + ld [wDailyResetTimer], a ret ; 113e5 -Function113e5:: ; 113e5 +InitCallReceiveDelay:: ; 113e5 xor a - ld [wd464], a + ld [wTimeCyclesSinceLastCall], a -Function113e9: ; 113e9 - ld a, [wd464] +NextCallReceiveDelay: ; 113e9 + ld a, [wTimeCyclesSinceLastCall] cp 3 - jr c, .asm_113f2 + jr c, .okay ld a, 3 -.asm_113f2 +.okay ld e, a ld d, 0 - ld hl, .data_113fd + ld hl, .ReceiveCallDelays add hl, de ld a, [hl] - jp Function1142e + jp RestartReceiveCallDelay ; 113fd -.data_113fd +.ReceiveCallDelays db 20, 10, 5, 3 ; 11401 -Function11401: ; 11401 - call Function1143c +CheckReceiveCallTimer: ; 11401 + call CheckReceiveCallDelay ; check timer ret nc - ld hl, wd464 + ld hl, wTimeCyclesSinceLastCall ld a, [hl] cp 3 - jr nc, .asm_1140e + jr nc, .ok inc [hl] -.asm_1140e - call Function113e9 +.ok + call NextCallReceiveDelay ; restart timer scf ret ; 11413 -Function11413: ; 11413 +InitOneDayCountdown: ; 11413 ld a, 1 -Function11415: ; 11415 +InitNDaysCountdown: ; 11415 ld [hl], a push hl call UpdateTime pop hl inc hl - call Function11621 + call CopyDayToHL ret ; 11420 -Function11420: ; 11420 +CheckDayDependentEventHL: ; 11420 inc hl push hl - call Function115cf - call Function115c8 + call CalcDaysSince + call GetDaysSince pop hl dec hl - call Function11586 + call UpdateTimeRemaining ret ; 1142e -Function1142e: ; 1142e - ld hl, wd465 +RestartReceiveCallDelay: ; 1142e + ld hl, wReceiveCallDelay_MinsRemaining ld [hl], a call UpdateTime - ld hl, wd466 - call Function1162e + ld hl, wReceiveCallDelay_StartTime + call CopyDayHourMinToHL ret ; 1143c -Function1143c: ; 1143c - ld hl, wd466 - call Function115d6 - call Function115ae - ld hl, wd465 - call Function11586 +CheckReceiveCallDelay: ; 1143c + ld hl, wReceiveCallDelay_StartTime + call CalcMinsHoursDaysSince + call GetMinutesSinceIfLessThan60 + ld hl, wReceiveCallDelay_MinsRemaining + call UpdateTimeRemaining ret ; 1144c -Function1144c: ; 1144c - ld hl, wdc1c - jp Function11413 +RestartDailyResetTimer: ; 1144c + ld hl, wDailyResetTimer + jp InitOneDayCountdown ; 11452 -Function11452:: ; 11452 - ld hl, wdc1c - call Function11420 +CheckDailyResetTimer:: ; 11452 + ld hl, wDailyResetTimer + call CheckDayDependentEventHL ret nc xor a ld hl, DailyFlags @@ -121,18 +121,19 @@ endr ld hl, wdc58 ld a, [hl] and a - jr z, .asm_11480 + jr z, .RestartKenjiBreakCountdown dec [hl] - jr nz, .asm_11483 + jr nz, .DontRestartKenjiBreakCountdown -.asm_11480 - call Function11485 +.RestartKenjiBreakCountdown + call Special_SampleKenjiBreakCountdown -.asm_11483 - jr Function1144c +.DontRestartKenjiBreakCountdown + jr RestartDailyResetTimer ; 11485 -Function11485: ; 11485 +Special_SampleKenjiBreakCountdown: ; 11485 +; Generate a random number between 3 and 5 call Random and 3 add 3 @@ -140,99 +141,101 @@ Function11485: ; 11485 ret ; 11490 -Function11490: ; 11490 - ld a, $14 - ld [wd46c], a - ld a, $0 - ld [wd46d], a +StartBugContestTimer: ; 11490 + ld a, 20 + ld [wBugContestMinsRemaining], a + ld a, 0 + ld [wBugContestSecsRemaining], a call UpdateTime - ld hl, wdc35 - call Function11613 + ld hl, wBugContestStartTime + call CopyDayHourMinSecToHL ret ; 114a4 -Function114a4:: ; 114a4 (4:54a4) - ld hl, wdc35 - call Function115db - ld a, [wcfd7] +CheckBugContestTimer:: ; 114a4 (4:54a4) + ld hl, wBugContestStartTime + call CalcSecsMinsHoursDaysSince + ld a, [wDaysSince] and a - jr nz, .asm_114d4 - ld a, [wcfd6] + jr nz, .timed_out + ld a, [wHoursSince] and a - jr nz, .asm_114d4 - ld a, [wcfd4] + jr nz, .timed_out + ld a, [wSecondsSince] ld b, a - ld a, [wd46d] + ld a, [wBugContestSecsRemaining] sub b - jr nc, .asm_114c2 - add $3c -.asm_114c2 - ld [wd46d], a - ld a, [wcfd5] + jr nc, .okay + add 60 + +.okay + ld [wBugContestSecsRemaining], a + ld a, [wMinutesSince] ld b, a - ld a, [wd46c] + ld a, [wBugContestMinsRemaining] sbc b - ld [wd46c], a - jr c, .asm_114d4 + ld [wBugContestMinsRemaining], a + jr c, .timed_out and a ret -.asm_114d4 + +.timed_out xor a - ld [wd46c], a - ld [wd46d], a + ld [wBugContestMinsRemaining], a + ld [wBugContestSecsRemaining], a scf ret -Function114dd: ; 114dd +InitializeStartDay: ; 114dd call UpdateTime - ld hl, wdc23 - call Function11621 + ld hl, wStartDay + call CopyDayToHL ret ; 114e7 -Function114e7:: ; 114e7 - ld hl, wdc23 - call Function115cf - call Function115c8 +CheckPokerusTrick:: ; 114e7 + ld hl, wStartDay + call CalcDaysSince + call GetDaysSince and a - jr z, .asm_114fa + jr z, .done ld b, a callba ApplyPokerusTick -.asm_114fa +.done xor a ret ; 114fc -Function114fc: ; 114fc - ld a, $2 - ld hl, wdc3a +SetUnusedTwoDayTimer: ; 114fc + ld a, 2 + ld hl, wUnusedTwoDayTimer ld [hl], a call UpdateTime - ld hl, wdc3b - call Function11621 + ld hl, wUnusedTwoDayTimerStartDate + call CopyDayToHL ret ; 1150c -Function1150c: ; 1150c - ld hl, wdc3b - call Function115cf - call Function115c8 - ld hl, wdc3a - call Function11586 +CheckUnusedTwoDayTimer: ; 1150c + ld hl, wUnusedTwoDayTimerStartDate + call CalcDaysSince + call GetDaysSince + ld hl, wUnusedTwoDayTimer + call UpdateTimeRemaining ret ; 1151c -Function1151c: ; 1151c +Function1151c: ; unreferenced ld hl, DailyFlags set 2, [hl] ret ; 11522 -Function11522: ; 11522 +Function11522: ; unreferenced and a ld hl, DailyFlags bit 2, [hl] @@ -241,10 +244,10 @@ Function11522: ; 11522 ret ; 1152b -Function1152b: ; 1152b +RestartLuckyNumberCountdown: ; 1152b call .GetDaysUntilNextFriday ld hl, wLuckyNumberDayBuffer - jp Function11415 + jp InitNDaysCountdown ; 11534 .GetDaysUntilNextFriday: ; 11534 @@ -262,172 +265,175 @@ Function1152b: ; 1152b ret ; 11542 -Function11542: ; 11542 +CheckLuckyNumberShowFlag: ; 11542 ld hl, wLuckyNumberDayBuffer - jp Function11420 + jp CheckDayDependentEventHL ; 11548 -Function11548: ; 11548 - ld a, BANK(s0_abfa) +DoMysteryGiftIfDayHasPassed: ; 11548 + ld a, BANK(sMysteryGiftTimer) call GetSRAMBank - ld hl, s0_abfa + ld hl, sMysteryGiftTimer ld a, [hli] ld [Buffer1], a ld a, [hl] ld [Buffer2], a call CloseSRAM + ld hl, Buffer1 - call Function11420 - jr nc, .asm_11572 + call CheckDayDependentEventHL + jr nc, .not_timed_out ld hl, Buffer1 - call Function11413 + call InitOneDayCountdown call CloseSRAM callba Function1050c8 -.asm_11572 - ld a, BANK(s0_abfa) +.not_timed_out + ld a, BANK(sMysteryGiftTimer) call GetSRAMBank ld hl, Buffer1 ld a, [hli] - ld [s0_abfa], a + ld [sMysteryGiftTimer], a ld a, [hl] - ld [s0_abfa + 1], a + ld [sMysteryGiftTimer + 1], a call CloseSRAM ret ; 11586 -Function11586: ; 11586 +UpdateTimeRemaining: ; 11586 +; If the amount of time elapsed exceeds the capacity of its +; unit, skip this part. cp -1 - jr z, .skip + jr z, .set_carry ld c, a - ld a, [hl] + ld a, [hl] ; time remaining sub c jr nc, .ok xor a .ok ld [hl], a - jr z, .skip + jr z, .set_carry xor a ret -.skip +.set_carry xor a ld [hl], a scf ret ; 11599 -Function11599: ; 11599 - ld a, [wcfd7] +GetSecondsSinceIfLessThan60: ; 11599 + ld a, [wDaysSince] and a - jr nz, Function115cc - ld a, [wcfd6] + jr nz, GetTimeElapsed_ExceedsUnitLimit + ld a, [wHoursSince] and a - jr nz, Function115cc - ld a, [wcfd5] - jr nz, Function115cc - ld a, [wcfd4] + jr nz, GetTimeElapsed_ExceedsUnitLimit + ld a, [wMinutesSince] + jr nz, GetTimeElapsed_ExceedsUnitLimit + ld a, [wSecondsSince] ret ; 115ae -Function115ae: ; 115ae - ld a, [wcfd7] +GetMinutesSinceIfLessThan60: ; 115ae + ld a, [wDaysSince] and a - jr nz, Function115cc - ld a, [wcfd6] + jr nz, GetTimeElapsed_ExceedsUnitLimit + ld a, [wHoursSince] and a - jr nz, Function115cc - ld a, [wcfd5] + jr nz, GetTimeElapsed_ExceedsUnitLimit + ld a, [wMinutesSince] ret ; 115be -Function115be: ; 115be - ld a, [wcfd7] +GetHoursSinceIfLessThan24: ; 115be + ld a, [wDaysSince] and a - jr nz, Function115cc - ld a, [wcfd6] + jr nz, GetTimeElapsed_ExceedsUnitLimit + ld a, [wHoursSince] ret ; 115c8 -Function115c8: ; 115c8 - ld a, [wcfd7] +GetDaysSince: ; 115c8 + ld a, [wDaysSince] ret ; 115cc -Function115cc: ; 115cc - ld a, $ff +GetTimeElapsed_ExceedsUnitLimit: ; 115cc + ld a, -1 ret ; 115cf -Function115cf: ; 115cf +CalcDaysSince: ; 115cf xor a - jr Function11605 + jr _CalcDaysSince ; 115d2 -Function115d2: ; 115d2 +CalcHoursDaysSince: ; 115d2 inc hl xor a - jr Function115f8 + jr _CalcHoursDaysSince ; 115d6 -Function115d6: ; 115d6 +CalcMinsHoursDaysSince: ; 115d6 rept 2 inc hl endr xor a - jr Function115eb + jr _CalcMinsHoursDaysSince ; 115db -Function115db: ; 115db +CalcSecsMinsHoursDaysSince: ; 115db rept 3 inc hl endr ld a, [hSeconds] ld c, a sub [hl] - jr nc, .asm_115e6 + jr nc, .skip add 60 -.asm_115e6 - ld [hl], c +.skip + ld [hl], c ; current seconds dec hl - ld [wcfd4], a + ld [wSecondsSince], a ; seconds since -Function115eb: ; 115eb +_CalcMinsHoursDaysSince: ; 115eb ld a, [hMinutes] ld c, a sbc [hl] - jr nc, .asm_115f3 + jr nc, .skip add 60 -.asm_115f3 - ld [hl], c +.skip + ld [hl], c ; current minutes dec hl - ld [wcfd5], a + ld [wMinutesSince], a ; minutes since -Function115f8: ; 115f8 +_CalcHoursDaysSince: ; 115f8 ld a, [hHours] ld c, a sbc [hl] - jr nc, .asm_11600 + jr nc, .skip add 24 -.asm_11600 - ld [hl], c +.skip + ld [hl], c ; current hours dec hl - ld [wcfd6], a + ld [wHoursSince], a ; hours since -Function11605 +_CalcDaysSince: ld a, [CurDay] ld c, a sbc [hl] jr nc, .skip add 20 * 7 .skip - ld [hl], c - ld [wcfd7], a + ld [hl], c ; current days + ld [wDaysSince], a ; days since ret ; 11613 -Function11613: ; 11613 +CopyDayHourMinSecToHL: ; 11613 ld a, [CurDay] ld [hli], a ld a, [hHours] @@ -439,13 +445,13 @@ Function11613: ; 11613 ret ; 11621 -Function11621: ; 11621 +CopyDayToHL: ; 11621 ld a, [CurDay] ld [hl], a ret ; 11626 -Function11626: ; 11626 +CopyDayHourToHL: ; 11626 ld a, [CurDay] ld [hli], a ld a, [hHours] @@ -453,7 +459,7 @@ Function11626: ; 11626 ret ; 1162e -Function1162e: ; 1162e +CopyDayHourMinToHL: ; 1162e ld a, [CurDay] ld [hli], a ld a, [hHours] diff --git a/engine/timeofdaypals.asm b/engine/timeofdaypals.asm new file mode 100644 index 000000000..bdfcc8b05 --- /dev/null +++ b/engine/timeofdaypals.asm @@ -0,0 +1,414 @@ +Function8c001:: ; 8c001 + call UpdateTime + ld a, [TimeOfDay] + ld [CurTimeOfDay], a + call GetTimePalette + ld [TimeOfDayPal], a + ret +; 8c011 + + +_TimeOfDayPals:: ; 8c011 +; return carry if pals are changed + +; forced pals? + ld hl, wd846 + bit 7, [hl] + jr nz, .dontchange + +; do we need to bother updating? + ld a, [TimeOfDay] + ld hl, CurTimeOfDay + cp [hl] + jr z, .dontchange + +; if so, the time of day has changed + ld a, [TimeOfDay] + ld [CurTimeOfDay], a + +; get palette id + call GetTimePalette + +; same palette as before? + ld hl, TimeOfDayPal + cp [hl] + jr z, .dontchange + +; update palette id + ld [TimeOfDayPal], a + + +; save bg palette 8 + ld hl, Unkn1Pals + 8 * 7 ; Unkn1Pals + 7 pals + +; save wram bank + ld a, [rSVBK] + ld b, a +; wram bank 5 + ld a, 5 + ld [rSVBK], a + +; push palette + ld c, 4 ; NUM_PAL_COLORS +.push + ld d, [hl] + inc hl + ld e, [hl] + inc hl + push de + dec c + jr nz, .push + +; restore wram bank + ld a, b + ld [rSVBK], a + + +; update sgb pals + ld b, $9 + call GetSGBLayout + + +; restore bg palette 8 + ld hl, Unkn2Pals - 1 ; last byte in Unkn1Pals + +; save wram bank + ld a, [rSVBK] + ld d, a +; wram bank 5 + ld a, 5 + ld [rSVBK], a + +; pop palette + ld e, 4 ; NUM_PAL_COLORS +.pop + pop bc + ld [hl], c + dec hl + ld [hl], b + dec hl + dec e + jr nz, .pop + +; restore wram bank + ld a, d + ld [rSVBK], a + +; update palettes + call _UpdateTimePals + call DelayFrame + +; successful change + scf + ret + +.dontchange +; no change occurred + and a + ret +; 8c070 + + +_UpdateTimePals:: ; 8c070 + ld c, $9 ; normal + call GetTimePalFade + call DmgToCgbTimePals + ret +; 8c079 + +FadeInBGMap:: ; 8c079 + ld c, $12 + call GetTimePalFade + ld b, $4 + call ConvertTimePalsDecHL + ret +; 8c084 + +FadeBlackBGMap:: ; 8c084 + call Function8c0c1 + ld c, $9 + call GetTimePalFade + ld b, $4 + call ConvertTimePalsIncHL + ret +; 8c092 + +Special_BattleTowerFade: ; 8c092 + call Function8c0c1 + ld c, $9 + call GetTimePalFade + ld b, $4 +.asm_8c09c + call DmgToCgbTimePals +rept 3 + inc hl +endr + ld c, $7 + call DelayFrames + dec b + jr nz, .asm_8c09c + ret +; 8c0ab + +Special_FadeInQuickly: ; 8c0ab + ld c, $0 + call GetTimePalFade + ld b, $4 + call ConvertTimePalsIncHL + ret +; 8c0b6 + +Special_FadeBlackQuickly: ; 8c0b6 + ld c, $9 + call GetTimePalFade + ld b, $4 + call ConvertTimePalsDecHL + ret +; 8c0c1 + + +Function8c0c1: ; 8c0c1 + ld a, [rSVBK] + push af + ld a, $5 + ld [rSVBK], a + ld hl, Unkn1Pals + ld a, [hli] + ld e, a + ld a, [hli] + ld d, a + ld hl, Unkn1Pals + 8 + ld c, $6 +.asm_8c0d4 + ld a, e + ld [hli], a + ld a, d + ld [hli], a +rept 6 + inc hl +endr + dec c + jr nz, .asm_8c0d4 + pop af + ld [rSVBK], a + ret +; 8c0e5 + +brightlevel: MACRO + db (\1 << 6) | (\2 << 4) | (\3 << 2) | \4 +ENDM + +Function8c0e5: ; 8c0e5 + ld hl, .BrightnessLevels + ld a, [wc2d0] + cp $4 ; Dark cave, needs Flash + jr z, .DarkCave + and $7 + add l + ld l, a + ld a, $0 + adc h + ld h, a + ld a, [hl] + ld [wd847], a + ret +.DarkCave + ld a, [StatusFlags] + bit 2, a + jr nz, .UsedFlash + ld a, $ff ; 3, 3, 3, 3 + ld [wd847], a + ret +.UsedFlash + ld a, $aa ; 2, 2, 2, 2 + ld [wd847], a + ret +; 8c10f (23:410f) + +.BrightnessLevels: ; 8c10f + brightlevel 3, 2, 1, 0 + brightlevel 1, 1, 1, 1 + brightlevel 2, 2, 2, 2 + brightlevel 0, 0, 0, 0 + brightlevel 3, 3, 3, 3 + brightlevel 3, 2, 1, 0 + brightlevel 3, 2, 1, 0 + brightlevel 3, 2, 1, 0 +; 8c117 + +GetTimePalette: ; 8c117 + ld a, [TimeOfDay] + ld e, a + ld d, 0 + ld hl, .TimePalettes +rept 2 + add hl, de +endr + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] +; 8c126 + +.TimePalettes + dw .MorningPalette + dw .DayPalette + dw .NitePalette + dw .DarknessPalette + +.MorningPalette + ld a, [wd847] + and %00000011 ; 0 + ret + +.DayPalette + ld a, [wd847] + and %00001100 ; 1 + srl a + srl a + ret + +.NitePalette + ld a, [wd847] + and %00110000 ; 2 + swap a + ret + +.DarknessPalette + ld a, [wd847] + and %11000000 ; 3 + rlca + rlca + ret +; 8c14e + + +DmgToCgbTimePals: ; 8c14e + push hl + push de + ld a, [hli] + call DmgToCgbBGPals + ld a, [hli] + ld e, a + ld a, [hli] + ld d, a + call DmgToCgbObjPals + pop de + pop hl + ret +; 8c15e + +ConvertTimePalsIncHL: ; 8c15e +.loop + call DmgToCgbTimePals +rept 3 + inc hl +endr + ld c, $2 + call DelayFrames + dec b + jr nz, .loop + ret +; 8c16d + +ConvertTimePalsDecHL: ; 8c16d +.loop + call DmgToCgbTimePals +rept 3 + dec hl +endr + ld c, $2 + call DelayFrames + dec b + jr nz, .loop + ret +; 8c17c + + +GetTimePalFade: ; 8c17c +; check cgb + ld a, [hCGB] + and a + jr nz, .cgb + +; else: dmg + +; index + ld a, [TimeOfDayPal] + and %11 + +; get fade table + push bc + ld c, a + ld b, $0 + ld hl, .dmgfades +rept 2 + add hl, bc +endr + ld a, [hli] + ld h, [hl] + ld l, a + pop bc + +; get place in fade table + ld b, $0 + add hl, bc + ret + +.cgb + ld hl, .cgbfade + ld b, $0 + add hl, bc + ret + +.dmgfades + dw .morn + dw .day + dw .nite + dw .darkness + +.morn + db %11111111, %11111111, %11111111 + db %11111110, %11111110, %11111110 + db %11111001, %11100100, %11100100 + db %11100100, %11010000, %11010000 + db %10010000, %10000000, %10000000 + db %01000000, %01000000, %01000000 + db %00000000, %00000000, %00000000 + +.day + db %11111111, %11111111, %11111111 + db %11111110, %11111110, %11111110 + db %11111001, %11100100, %11100100 + db %11100100, %11010000, %11010000 + db %10010000, %10000000, %10000000 + db %01000000, %01000000, %01000000 + db %00000000, %00000000, %00000000 + +.nite + db %11111111, %11111111, %11111111 + db %11111110, %11111110, %11111110 + db %11111001, %11100100, %11100100 + db %11101001, %11010000, %11010000 + db %10010000, %10000000, %10000000 + db %01000000, %01000000, %01000000 + db %00000000, %00000000, %00000000 + +.darkness + db %11111111, %11111111, %11111111 + db %11111110, %11111110, %11111111 + db %11111110, %11100100, %11111111 + db %11111101, %11010000, %11111111 + db %11111101, %10000000, %11111111 + db %00000000, %01000000, %00000000 + db %00000000, %00000000, %00000000 + +.cgbfade + db %11111111, %11111111, %11111111 + db %11111110, %11111110, %11111110 + db %11111001, %11111001, %11111001 + db %11100100, %11100100, %11100100 + db %10010000, %10010000, %10010000 + db %01000000, %01000000, %01000000 + db %00000000, %00000000, %00000000 +; 8c20f diff --git a/engine/title.asm b/engine/title.asm index 2e151c389..d29c90a23 100644 --- a/engine/title.asm +++ b/engine/title.asm @@ -9,7 +9,7 @@ _TitleScreen: ; 10ed67 ld [hBGMapMode], a ; Reset timing variables - ld hl, wcf63 + ld hl, wJumptableIndex ld [hli], a ; cf63 ; Scene? ld [hli], a ; cf64 ld [hli], a ; cf65 ; Timer lo @@ -53,27 +53,27 @@ _TitleScreen: ; 10ed67 ; Apply logo gradient: ; lines 3-4 - ld hl, $9860 ; (0,3) + ld hl, VBGMap0 tile $06 ; (0,3) ld bc, $0040 ; 2 rows ld a, 2 call ByteFill ; line 5 - ld hl, $98a0 ; (0,5) + ld hl, VBGMap0 tile $0a ; (0,5) ld bc, $0020 ; 1 row ld a, 3 call ByteFill ; line 6 - ld hl, $98c0 ; (0,6) + ld hl, VBGMap0 tile $0c ; (0,6) ld bc, $0020 ; 1 row ld a, 4 call ByteFill ; line 7 - ld hl, $98e0 ; (0,7) + ld hl, VBGMap0 tile $0e ; (0,7) ld bc, $0020 ; 1 row ld a, 5 call ByteFill ; lines 8-9 - ld hl, $9900 ; (0,8) + ld hl, VBGMap0 tile $10 ; (0,8) ld bc, $0040 ; 2 rows ld a, 6 call ByteFill @@ -86,7 +86,7 @@ _TitleScreen: ; 10ed67 call ByteFill ; Suicune gfx - ld hl, $9980 ; (0,12) + ld hl, VBGMap0 tile $18 ; (0,12) ld bc, $00c0 ; the rest of the screen ld a, 8 call ByteFill @@ -130,10 +130,10 @@ _TitleScreen: ; 10ed67 ; Initialize running Suicune? ld d, $0 - call Function10eed2 + call LoadSuicuneFrame ; Initialize background crystal - call Function10ef06 + call InitializeBackground ; Save WRAM bank ld a, [rSVBK] @@ -145,12 +145,12 @@ _TitleScreen: ; 10ed67 ; Update palette colors ld hl, TitleScreenPalettes ld de, Unkn1Pals - ld bc, $0080 + ld bc, 4 * 32 call CopyBytes ld hl, TitleScreenPalettes ld de, BGPals - ld bc, $0080 + ld bc, 4 * 32 call CopyBytes ; Restore WRAM bank @@ -220,7 +220,7 @@ _TitleScreen: ; 10ed67 ld [hBGMapMode], a xor a - ld [DefaultFlypoint], a + ld [Unkn1Pals + 2], a ; Play starting sound effect call SFXChannelsOff @@ -230,25 +230,28 @@ _TitleScreen: ; 10ed67 ret ; 10eea7 -Function10eea7: ; 10eea7 - ld hl, DefaultFlypoint +SuicuneFrameIterator: ; 10eea7 + ld hl, Unkn1Pals + 2 ld a, [hl] ld c, a inc [hl] - and $7 + +; Only do this once every eight frames + and (1 << 3) - 1 ret nz + ld a, c - and $18 + and 3 << 3 sla a swap a ld e, a ld d, $0 - ld hl, Unknown_10eece + ld hl, .Frames add hl, de ld d, [hl] xor a ld [hBGMapMode], a - call Function10eed2 + call LoadSuicuneFrame ld a, $1 ld [hBGMapMode], a ld a, $3 @@ -256,33 +259,36 @@ Function10eea7: ; 10eea7 ret ; 10eece -Unknown_10eece: ; 10eece - db $80, $88, $00, $08 +.Frames: ; 10eece + db $80 ; VTiles4 tile $00 + db $88 ; VTiles4 tile $08 + db $00 ; VTiles5 tile $00 + db $08 ; VTiles5 tile $08 ; 10eed2 -Function10eed2: ; 10eed2 +LoadSuicuneFrame: ; 10eed2 hlcoord 6, 12 - ld b, $6 -.asm_10eed7 - ld c, $8 -.asm_10eed9 + ld b, 6 +.row + ld c, 8 +.col ld a, d ld [hli], a inc d dec c - jr nz, .asm_10eed9 - ld a, $c + jr nz, .col + ld a, SCREEN_WIDTH - 8 add l ld l, a - ld a, $0 + ld a, 0 adc h ld h, a - ld a, $8 + ld a, 8 add d ld d, a dec b - jr nz, .asm_10eed7 + jr nz, .row ret ; 10eeef @@ -293,18 +299,18 @@ DrawTitleGraphic: ; 10eeef ; c: width ; d: tile to start drawing from ; e: number of tiles to advance for each row -.asm_10eeef +.row push de push bc push hl -.asm_10eef2 +.col ld a, d ld [hli], a inc d dec c - jr nz, .asm_10eef2 + jr nz, .col pop hl - ld bc, $0014 + ld bc, SCREEN_WIDTH add hl, bc pop bc pop de @@ -312,31 +318,31 @@ DrawTitleGraphic: ; 10eeef add d ld d, a dec b - jr nz, .asm_10eeef + jr nz, .row ret ; 10ef06 -Function10ef06: ; 10ef06 +InitializeBackground: ; 10ef06 ld hl, Sprites - ld d, $de + ld d, -$22 ld e, $0 - ld c, $5 -.asm_10ef0f + ld c, 5 +.loop push bc - call Function10ef1c + call .InitColumn pop bc ld a, $10 add d ld d, a dec c - jr nz, .asm_10ef0f + jr nz, .loop ret ; 10ef1c -Function10ef1c: ; 10ef1c +.InitColumn: ; 10ef1c ld c, $6 ld b, $40 -.asm_10ef20 +.loop2 ld a, d ld [hli], a ld a, b @@ -351,7 +357,7 @@ endr ld a, $80 ld [hli], a dec c - jr nz, .asm_10ef20 + jr nz, .loop2 ret ; 10ef32 @@ -363,7 +369,7 @@ AnimateTitleCrystal: ; 10ef32 ; y is really from the bottom of the sprite, which is two tiles high ld hl, Sprites ld a, [hl] - cp 6 + 16 + cp 6 + $10 ret z ; Move all 30 parts of the crystal down by 2 |