From edf42a54d5b95780725e50605672fec29a9936f1 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 7 Oct 2015 13:19:41 -0400 Subject: [PATCH 01/11] More labels, including fns responsible for partymon generation --- battle/ai/items.asm | 10 +- battle/anim_commands.asm | 4 +- battle/anim_objects.asm | 14 +- battle/bg_effects.asm | 146 ++++++++--------- battle/core.asm | 14 +- battle/effect_commands.asm | 86 +++++----- constants/wram_constants.asm | 4 + engine/events.asm | 8 +- engine/map_objects.asm | 20 +-- engine/map_setup.asm | 2 +- engine/predef.asm | 2 +- engine/scripting.asm | 14 +- home/joypad.asm | 18 +-- home/map.asm | 4 +- hram.asm | 1 + items/item_effects.asm | 4 +- main.asm | 305 ++++++++++++++++++----------------- misc/mobile_40.asm | 4 +- misc/mobile_5f.asm | 2 +- wram.asm | 4 +- 20 files changed, 340 insertions(+), 326 deletions(-) diff --git a/battle/ai/items.asm b/battle/ai/items.asm index 46f04bf65..c56f389ca 100644 --- a/battle/ai/items.asm +++ b/battle/ai/items.asm @@ -787,17 +787,17 @@ Function38511: ; 38511 ; 3851e Function3851e: ; 3851e - ld [hMultiplier], a + ld [hDivisor], a ld hl, EnemyMonMaxHP ld a, [hli] - ld [hProduct], a + ld [hDividend], a ld a, [hl] - ld [hMultiplicand], a + ld [hDividend + 1], a ld b, $2 call Divide - ld a, [$ffb6] + ld a, [hQuotient + 2] ld c, a - ld a, [$ffb5] + ld a, [hQuotient + 1] ld b, a ld hl, EnemyMonHP + 1 ld a, [hld] diff --git a/battle/anim_commands.asm b/battle/anim_commands.asm index a7cbd8236..80b9bf41d 100644 --- a/battle/anim_commands.asm +++ b/battle/anim_commands.asm @@ -240,14 +240,14 @@ Functioncc220: ; cc220 ld a, $80 ld [hBGMapAddress], a ld a, $9a - ld [$ffd7], a + ld [hBGMapAddress + 1], a call Function3200 ld a, $60 ld [hWY], a xor a ld [hBGMapAddress], a ld a, $98 - ld [$ffd7], a + ld [hBGMapAddress + 1], a call BattleAnimDelayFrame ret ; cc23d diff --git a/battle/anim_objects.asm b/battle/anim_objects.asm index 5bf3e7c01..5c4c43525 100644 --- a/battle/anim_objects.asm +++ b/battle/anim_objects.asm @@ -1696,9 +1696,9 @@ Functioncd677: ; cd677 (33:5677) ld a, $42 ld [hLCDStatCustom], a ; $ff00+$c6 ld a, $58 - ld [$ffc7], a + ld [hLCDStatCustom + 1], a ld a, $5e - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ret Functioncd687: ; cd687 (33:5687) @@ -1712,7 +1712,7 @@ Functioncd687: ; cd687 (33:5687) jr nc, .asm_cd69b call Functionce72c xor a - ld [$ffc7], a + ld [hLCDStatCustom + 1], a ret .asm_cd69b dec a @@ -1730,7 +1730,7 @@ Functioncd687: ; cd687 (33:5687) add [hl] sub $10 ret c - ld [$ffc7], a + ld [hLCDStatCustom + 1], a ld hl, $9 add hl, bc ld a, [hl] @@ -1754,8 +1754,8 @@ Functioncd6c6: ; cd6c6 (33:56c6) jr c, asm_cd6da xor a ld [hLCDStatCustom], a ; $ff00+$c6 - ld [$ffc7], a - ld [$ffc8], a + ld [hLCDStatCustom + 1], a + ld [hLCDStatCustom + 2], a Functioncd6d6: ; cd6d6 (33:56d6) call Functioncc9bd @@ -1767,7 +1767,7 @@ endr ld [hl], a sub $10 ret c - ld [$ffc7], a + ld [hLCDStatCustom + 1], a ret Functioncd6e3: ; cd6e3 (33:56e3) diff --git a/battle/bg_effects.asm b/battle/bg_effects.asm index a2fd9f731..5b22308f2 100644 --- a/battle/bg_effects.asm +++ b/battle/bg_effects.asm @@ -932,7 +932,7 @@ Functionc8565: ; c8565 (32:4565) ld hl, w5_d422 ld bc, $0 .asm_c8580 - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] cp e jr nc, .asm_c858b push hl @@ -969,9 +969,9 @@ Functionc85a2: ; c85a2 (32:45a2) ld a, $42 ld [hLCDStatCustom], a ; $ff00+$c6 xor a - ld [$ffc7], a + ld [hLCDStatCustom + 1], a ld a, $5e - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld de, $202 call Functionc8f2e ret @@ -1044,9 +1044,9 @@ Functionc8610: ; c8610 (32:4610) ld a, $43 ld [hLCDStatCustom], a ; $ff00+$c6 xor a - ld [$ffc7], a + ld [hLCDStatCustom + 1], a ld a, $5f - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld de, $605 call Functionc8f2e ld hl, $3 @@ -1140,9 +1140,9 @@ Functionc8698: ; c8698 (32:4698) call Functionc8eca ld a, $43 call Functionc8ede - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld hl, $2 add hl, bc ld [hl], $0 @@ -1196,9 +1196,9 @@ Functionc86ea: ; c86ea (32:46ea) inc a ld d, a ld h, $d2 - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] ld l, a - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] sub l srl a push af @@ -1238,7 +1238,7 @@ Functionc8712: ; c8712 (32:4712) ld d, $2 call Functionc8f2e ld h, $d2 - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] ld l, a ld [hl], $0 dec l @@ -1246,7 +1246,7 @@ Functionc8712: ; c8712 (32:4712) ret Functionc8732: ; c8732 (32:4732) - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] ld l, a ld h, $d2 ld e, l @@ -1256,11 +1256,11 @@ Functionc8732: ; c8732 (32:4732) ld a, [de] dec de ld [hld], a - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] cp l jr nz, .asm_c873a ld [hl], $90 - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] ld l, a ld a, [hl] cp $1 @@ -1296,9 +1296,9 @@ Functionc876a: ; c876a (32:476a) call Functionc8eca ld a, $42 call Functionc8ede - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld hl, $2 add hl, bc ld [hl], $1 @@ -1347,9 +1347,9 @@ Functionc87b2: ; c87b2 (32:47b2) call Functionc8eca ld a, $42 call Functionc8ede - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld hl, $2 add hl, bc ld [hl], $2 @@ -1371,9 +1371,9 @@ Functionc87cf: ; c87cf (32:47cf) call Functionc80e5 Functionc87de: ; c87de (32:47de) - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] ld l, a - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] sub l dec a ld hl, $2 @@ -1416,9 +1416,9 @@ Functionc8810: ; c8810 (32:4810) call Functionc8eca ld a, $43 call Functionc8ede - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld hl, $3 add hl, bc ld [hl], $0 @@ -1451,9 +1451,9 @@ Functionc8842: ; c8842 (32:4842) call Functionc8eca ld a, $43 call Functionc8ef4 - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld hl, $3 add hl, bc ld [hl], $0 @@ -1524,16 +1524,16 @@ Functionc88a5: ; c88a5 (32:48a5) pop af jp Functionc900b .asm_c88b7 - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] ld d, a - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] sub d ld d, a ld h, LYOverridesBackup / $100 ld a, [hSCY] ; $ff00+$d0 or a jr nz, .asm_c88d0 - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] or a jr z, .asm_c88d6 dec a @@ -1541,14 +1541,14 @@ Functionc88a5: ; c88a5 (32:48a5) ld [hl], $0 jr .asm_c88d6 .asm_c88d0 - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] dec a ld l, a ld [hl], $0 .asm_c88d6 ld a, [hSCY] ; $ff00+$d0 ld l, a - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] sub l jr nc, .asm_c88e0 xor a @@ -1581,9 +1581,9 @@ Functionc88f6: ; c88f6 (32:48f6) call Functionc8eca ld a, $43 call Functionc8ede - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld hl, $3 add hl, bc ld [hl], $0 @@ -1628,9 +1628,9 @@ Functionc8933: ; c8933 (32:4933) call Functionc8eca ld a, $43 call Functionc8ede - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld hl, $3 add hl, bc ld [hl], $0 @@ -1668,9 +1668,9 @@ Functionc896d: ; c896d (32:496d) call Functionc8eca ld a, $43 call Functionc8ede - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a + ld [hLCDStatCustom + 2], a xor a ld hl, $2 add hl, bc @@ -1767,9 +1767,9 @@ Functionc89f7: ; c89f7 (32:49f7) call Functionc8eca ld a, $42 call Functionc8ef4 - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld hl, $2 add hl, bc ld [hl], $1 @@ -1824,14 +1824,14 @@ Functionc8a49: ; c8a49 (32:4a49) call Functionc8ecb ld a, $47 call Functionc8ede - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a - ld a, [$ffc7] + ld [hLCDStatCustom + 2], a + ld a, [hLCDStatCustom + 1] ld l, a ld h, $d2 .asm_c8a60 - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] cp l jr z, .asm_c8a69 xor a @@ -1854,9 +1854,9 @@ Functionc8a70: ; c8a70 (32:4a70) ld hl, $3 add hl, bc ld [hl], $0 - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] inc a - ld [$ffc7], a + ld [hLCDStatCustom + 1], a call Functionc80e5 ret @@ -1864,7 +1864,7 @@ Functionc8a88: ; c8a88 (32:4a88) call Functionc8ab0 jr nc, .asm_c8a96 call Functionc8a9a - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] dec a ld l, a ld [hl], e @@ -1875,9 +1875,9 @@ Functionc8a88: ; c8a88 (32:4a88) Functionc8a9a: ; c8a9a (32:4a9a) ld e, a - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] ld l, a - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] sub l srl a ld h, $d2 @@ -1971,9 +1971,9 @@ Functionc8b0e: ; c8b0e (32:4b0e) ld a, $47 ld [hLCDStatCustom], a ; $ff00+$c6 xor a - ld [$ffc7], a + ld [hLCDStatCustom + 1], a ld a, $60 - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ret Functionc8b22: ; c8b22 (32:4b22) @@ -2221,9 +2221,9 @@ Functionc8c68: ; c8c68 (32:4c68) call Functionc8eca ld a, $43 call Functionc8ede - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld hl, $2 add hl, bc ld [hl], $1 @@ -2268,9 +2268,9 @@ Functionc8cab: ; c8cab (32:4cab) ld a, $43 ld [hLCDStatCustom], a ; $ff00+$c6 xor a - ld [$ffc7], a + ld [hLCDStatCustom + 1], a ld a, $37 - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld hl, $3 add hl, bc ld [hl], $0 @@ -2431,9 +2431,9 @@ Functionc8d8b: ; c8d8b (32:4d8b) call Functionc8ecb ld a, $47 call Functionc8ede - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] inc a - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ld hl, $3 add hl, bc ld a, [hl] @@ -2669,9 +2669,9 @@ Functionc8ede: ; c8ede (32:4ede) ld de, $2f5e .asm_c8eed ld a, d - ld [$ffc7], a + ld [hLCDStatCustom + 1], a ld a, e - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ret Functionc8ef4: ; c8ef4 (32:4ef4) @@ -2684,15 +2684,15 @@ Functionc8ef4: ; c8ef4 (32:4ef4) ld de, $2d5e .asm_c8f03 ld a, d - ld [$ffc7], a + ld [hLCDStatCustom + 1], a ld a, e - ld [$ffc8], a + ld [hLCDStatCustom + 2], a ret Functionc8f0a: ; c8f0a (32:4f0a) xor a - ld [$ffc7], a - ld [$ffc8], a + ld [hLCDStatCustom + 1], a + ld [hLCDStatCustom + 2], a call Functionc8eca xor a ld [hLCDStatCustom], a ; $ff00+$c6 @@ -2706,8 +2706,8 @@ Functionc8f19: ; c8f19 (32:4f19) ld [rBGP], a ; $ff00+$47 ld [wcfc7], a ld [wcfc9], a - ld [$ffc7], a - ld [$ffc8], a + ld [hLCDStatCustom + 1], a + ld [hLCDStatCustom + 2], a call Functionc8eca ret @@ -2723,10 +2723,10 @@ Functionc8f2e: ; c8f2e (32:4f2e) ld [BattleAnimTemps + 3], a ld bc, LYOverridesBackup .asm_c8f43 - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] cp c jr nc, .asm_c8f58 - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] cp c jr c, .asm_c8f58 ld a, [BattleAnimTemps + 2] @@ -2800,14 +2800,14 @@ Functionc8f9a: ; c8f9a (32:4f9a) call Functionc905d ld e, a pop hl - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] cp c jr c, .asm_c8fcf ld a, e ld [bc], a inc bc .asm_c8fcf - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] cp l jr nc, .asm_c8fd6 ld [hl], e @@ -2824,7 +2824,7 @@ Functionc8f9a: ; c8f9a (32:4f9a) ret Functionc8fe4: ; c8fe4 (32:4fe4) - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] ld e, a ld a, [BattleAnimTemps] add e @@ -2834,13 +2834,13 @@ Functionc8fe4: ; c8fe4 (32:4fe4) Functionc8fef: ; c8fef (32:4fef) push bc - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] ld l, a inc a ld e, a ld h, $d2 ld d, h - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] sub l and a jr z, .asm_c9009 @@ -2862,9 +2862,9 @@ Functionc8fef: ; c8fef (32:4fef) Functionc900b: ; c900b (32:500b) push af ld h, $d2 - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] ld l, a - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] sub l ld d, a pop af @@ -2877,14 +2877,14 @@ Functionc900b: ; c900b (32:500b) Functionc901b: ; c901b (32:501b) push af ld e, a - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] ld l, a - ld a, [$ffc8] + ld a, [hLCDStatCustom + 2] sub l sub e ld d, a ld h, $d2 - ld a, [$ffc7] + ld a, [hLCDStatCustom + 1] ld l, a ld a, $90 .asm_c902c diff --git a/battle/core.asm b/battle/core.asm index c7f0e7bb5..287ad4120 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -3233,7 +3233,7 @@ Function3d444: ; 3d444 Function3d490: ; 3d490 - ld [$ffaf], a + ld [hConnectionStripLength], a ld c, a .asm_3d493 push bc @@ -3257,7 +3257,7 @@ Function3d490: ; 3d490 ; 3d4ae Function3d4ae: ; 3d4ae - ld a, [$ffaf] + ld a, [hConnectionStripLength] ld c, a cp $8 jr nz, .back @@ -9442,7 +9442,7 @@ Function3fc30: ; 3fc30 Function3fc5b: ; 3fc5b ld hl, Sprites xor a - ld [$ffaf], a + ld [hConnectionStripLength], a ld b, $6 ld e, $a8 .asm_3fc65 @@ -9453,10 +9453,10 @@ Function3fc5b: ; 3fc5b inc hl ld [hl], e inc hl - ld a, [$ffaf] + ld a, [hConnectionStripLength] ld [hli], a inc a - ld [$ffaf], a + ld [hConnectionStripLength], a ld a, $1 ld [hli], a ld a, d @@ -9464,9 +9464,9 @@ Function3fc5b: ; 3fc5b ld d, a dec c jr nz, .asm_3fc69 - ld a, [$ffaf] + ld a, [hConnectionStripLength] add $3 - ld [$ffaf], a + ld [hConnectionStripLength], a ld a, e add $8 ld e, a diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index e0bd41859..1b8d8b9fc 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -1390,7 +1390,7 @@ BattleCommand07: ; 346d2 cp c jr z, .stab - jr .asm_3473a + jr .SkipStab .stab ld hl, CurDamage + 1 @@ -1412,13 +1412,13 @@ BattleCommand07: ; 346d2 ld hl, TypeModifier set 7, [hl] -.asm_3473a +.SkipStab ld a, BATTLE_VARS_MOVE_TYPE call GetBattleVar ld b, a ld hl, TypeMatchup -.asm_34743 +.TypesLoop ld a, [hli] cp $ff @@ -1426,38 +1426,39 @@ BattleCommand07: ; 346d2 ; foresight cp $fe - jr nz, .asm_34757 + jr nz, .SkipForesightCheck ld a, BATTLE_VARS_SUBSTATUS1_OPP call GetBattleVar bit SUBSTATUS_IDENTIFIED, a jr nz, .end - jr .asm_34743 + jr .TypesLoop -.asm_34757 +.SkipForesightCheck cp b - jr nz, .asm_347b3 + jr nz, .SkipType ld a, [hl] cp d - jr z, .asm_34763 + jr z, .GotMatchup cp e - jr z, .asm_34763 - jr .asm_347b3 + jr z, .GotMatchup + jr .SkipType -.asm_34763 +.GotMatchup push hl push bc inc hl ld a, [TypeModifier] and %10000000 ld b, a +; If the target is immune to the move, treat it as a miss and calculate the damage as 0 ld a, [hl] and a - jr nz, .asm_34775 + jr nz, .NotImmune inc a ld [AttackMissed], a xor a -.asm_34775 +.NotImmune ld [hMultiplier], a add b ld [TypeModifier], a @@ -1480,34 +1481,35 @@ BattleCommand07: ; 346d2 ld b, a ld a, [hProduct + 3] or b - jr z, .asm_347ab + jr z, .ok ; This is a very convoluted way to get back that we've essentially dealt no damage. - ld a, $a +; Take the product and divide it by 10. + ld a, 10 ld [hDivisor], a - ld b, $4 + ld b, 4 call Divide ld a, [hQuotient + 1] ld b, a ld a, [hQuotient + 2] or b - jr nz, .asm_347ab + jr nz, .ok - ld a, $1 - ld [$ffb6], a + ld a, 1 + ld [hMultiplicand + 2], a -.asm_347ab - ld a, [$ffb5] +.ok + ld a, [hMultiplicand + 1] ld [hli], a - ld a, [$ffb6] + ld a, [hMultiplicand + 2] ld [hl], a pop bc pop hl -.asm_347b3 +.SkipType rept 2 inc hl endr - jr .asm_34743 + jr .TypesLoop .end call Function347c8 @@ -1545,32 +1547,32 @@ Function347d3: ; 347d3 ld a, 10 ; 1.0 ld [wd265], a ld hl, TypeMatchup -.asm_347e7 +.TypesLoop ld a, [hli] cp $ff - jr z, .asm_3482f + jr z, .End cp $fe - jr nz, .asm_347fb + jr nz, .Next ld a, BATTLE_VARS_SUBSTATUS1_OPP call GetBattleVar bit SUBSTATUS_IDENTIFIED, a - jr nz, .asm_3482f - jr .asm_347e7 -.asm_347fb + jr nz, .End + jr .TypesLoop +.Next cp d - jr nz, .asm_34807 + jr nz, .Nope ld a, [hli] cp b - jr z, .asm_3480b + jr z, .Yup cp c - jr z, .asm_3480b - jr .asm_34808 -.asm_34807 + jr z, .Yup + jr .Nope2 +.Nope inc hl -.asm_34808 +.Nope2 inc hl - jr .asm_347e7 -.asm_3480b + jr .TypesLoop +.Yup xor a ld [hDividend + 0], a ld [hMultiplicand + 0], a @@ -1588,9 +1590,9 @@ Function347d3: ; 347d3 pop bc ld a, [hQuotient + 2] ld [wd265], a - jr .asm_347e7 + jr .TypesLoop -.asm_3482f +.End pop bc pop de pop hl @@ -1603,14 +1605,14 @@ BattleCommanda3: ; 34833 ld a, [wd265] and a ld a, 10 ; 1.0 - jr nz, .asm_3484a + jr nz, .skip call ResetDamage xor a ld [TypeModifier], a inc a ld [AttackMissed], a ret -.asm_3484a +.skip ld [wd265], a ret ; 3484e diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm index cb368ee0a..9bb72b2a2 100644 --- a/constants/wram_constants.asm +++ b/constants/wram_constants.asm @@ -72,3 +72,7 @@ PLAYER_SURF_PIKA EQU 8 OBJECT_STRUCT_LENGTH EQU 40 NUM_OBJECT_STRUCTS EQU 13 + +; After-Champion Spawn +SPAWN_LANCE EQU 1 +SPAWN_RED EQU 2 diff --git a/engine/events.asm b/engine/events.asm index 3fedf691d..cf8b4e647 100644 --- a/engine/events.asm +++ b/engine/events.asm @@ -121,7 +121,7 @@ StartMap: ; 96724 xor a ld [ScriptRunning], a ld hl, MapStatus - ld bc, $3e + ld bc, $3e ; 62 call ByteFill callba Function113e5 call ClearJoypad @@ -137,13 +137,13 @@ EnterMap: ; 9673e callba RunMapSetupScript call ClearAllScriptFlags3 - ld a, [$ff9f] + ld a, [hMapEntryMethod] cp $f7 jr nz, .dontset call SetAll_ScriptFlags3 .dontset - ld a, [$ff9f] + ld a, [hMapEntryMethod] cp $f3 jr nz, .dontresetpoison xor a @@ -151,7 +151,7 @@ EnterMap: ; 9673e .dontresetpoison xor a - ld [$ff9f], a + ld [hMapEntryMethod], a ld a, 2 ; HandleMap ld [MapStatus], a ret diff --git a/engine/map_objects.asm b/engine/map_objects.asm index 888952ab8..d9282d965 100644 --- a/engine/map_objects.asm +++ b/engine/map_objects.asm @@ -1499,7 +1499,7 @@ Function4af0: ; 4af0 add hl, bc ld [hl], 2 ld hl, wd4cf - ld a, [$ffaf] + ld a, [hConnectionStripLength] cp [hl] jr z, .ok ld hl, OBJECT_09 @@ -2508,7 +2508,7 @@ Function54b8: ; 54b8 ret z ld a, [wd4cd] ld d, a - ld a, [$ffaf] + ld a, [hConnectionStripLength] cp d ret nz ld a, e @@ -2651,7 +2651,7 @@ Function5565: ; 5565 Function5579: ; 5579 push bc - ld a, [$ffaf] + ld a, [hConnectionStripLength] ld c, a call Function5582 pop bc @@ -2712,7 +2712,7 @@ Function55b9: ; 55b9 ld [hli], a ld a, [de] ld [hli], a - ld a, [$ffaf] + ld a, [hConnectionStripLength] ld [hli], a push hl ld hl, OBJECT_MAP_X @@ -2737,7 +2737,7 @@ Function55e0:: ; 55e0 ld bc, ObjectStructs xor a .loop - ld [$ffaf], a + ld [hConnectionStripLength], a call GetObjectSprite jr z, .ok call Function565c @@ -2747,7 +2747,7 @@ Function55e0:: ; 55e0 add hl, bc ld b, h ld c, l - ld a, [$ffaf] + ld a, [hConnectionStripLength] inc a cp NUM_OBJECT_STRUCTS jr nz, .loop @@ -2801,13 +2801,13 @@ Function5645: ; 5645 xor a ld bc, ObjectStructs .loop - ld [$ffaf], a + ld [hConnectionStripLength], a call Function5680 ld hl, OBJECT_STRUCT_LENGTH add hl, bc ld b, h ld c, l - ld a, [$ffaf] + ld a, [hConnectionStripLength] inc a cp NUM_OBJECT_STRUCTS jr nz, .loop @@ -3032,7 +3032,7 @@ Function5781: ; 5781 ld bc, ObjectStructs xor a .loop - ld [$ffaf], a + ld [hConnectionStripLength], a call GetObjectSprite jr z, .next call Function437b @@ -3042,7 +3042,7 @@ Function5781: ; 5781 add hl, bc ld b, h ld c, l - ld a, [$ffaf] + ld a, [hConnectionStripLength] inc a cp NUM_OBJECT_STRUCTS jr nz, .loop diff --git a/engine/map_setup.asm b/engine/map_setup.asm index 9ac712872..f89d68a19 100644 --- a/engine/map_setup.asm +++ b/engine/map_setup.asm @@ -1,6 +1,6 @@ RunMapSetupScript:: ; 15363 - ld a, [$ff9f] + ld a, [hMapEntryMethod] and $f dec a ld c, a diff --git a/engine/predef.asm b/engine/predef.asm index 9ee46bf47..47bc2528a 100644 --- a/engine/predef.asm +++ b/engine/predef.asm @@ -36,7 +36,7 @@ PredefPointers:: ; 856b add_predef FlagPredef add_predef Functionc699 add_predef FillPP - add_predef Functiond88c + add_predef TryAddMonToParty add_predef Functionda96 add_predef Functiondb3f ; $8 add_predef SentPkmnIntoBox diff --git a/engine/scripting.asm b/engine/scripting.asm index 3ef1c3853..f5e1347b8 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -1258,7 +1258,7 @@ Script_appear: ; 0x972dd call GetScriptByte call GetScriptPerson call _CopyObjectStruct - ld a, [$ffaf] + ld a, [hConnectionStripLength] ld b, 0 ; clear call ApplyEventActionAppearDisappear ret @@ -1276,7 +1276,7 @@ Script_disappear: ; 0x972ee ld a, [hLastTalked] .ok call DeleteObjectStruct - ld a, [$ffaf] + ld a, [hConnectionStripLength] ld b, 1 ; set call ApplyEventActionAppearDisappear callba RefreshMapAppearDisappear @@ -1584,7 +1584,7 @@ Script_reloadmap: ; 0x97491 xor a ld [wd459], a ld a, $f3 - ld [$ff9f], a + ld [hMapEntryMethod], a ld a, $1 call LoadMapStatus call StopScript @@ -2839,7 +2839,7 @@ Script_warp: ; 0x97a1d ld a, -1 ld [wd001], a ld a, -15 - ld [$ff9f], a + ld [hMapEntryMethod], a ld a, 1 call LoadMapStatus call StopScript @@ -2851,7 +2851,7 @@ Script_warp: ; 0x97a1d ld a, -1 ld [wd001], a ld a, -5 - ld [$ff9f], a + ld [hMapEntryMethod], a ld a, 1 call LoadMapStatus call StopScript @@ -2994,7 +2994,7 @@ Script_newloadmap: ; 0x97b08 ; which_method (SingleByteParam) call GetScriptByte - ld [$ff9f], a + ld [hMapEntryMethod], a ld a, 1 call LoadMapStatus call StopScript @@ -3198,7 +3198,7 @@ Script_halloffame: ; 0x97bd5 Script_credits: ; 0x97bf3 ; script command 0xa2 - callba Function86455 + callba RedCredits ; fallthrough DisplayCredits: diff --git a/home/joypad.asm b/home/joypad.asm index 78a1ac143..c07157376 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -354,12 +354,12 @@ Functiona57:: ; a57 ; a80 Functiona80:: ; a80 - ld a, [$ffaf] + ld a, [hConnectionStripLength] push af ld a, [$ffb0] push af xor a - ld [$ffaf], a + ld [hConnectionStripLength], a ld a, $6 ld [$ffb0], a .asm_a8d @@ -374,7 +374,7 @@ Functiona80:: ; a80 pop af ld [$ffb0], a pop af - ld [$ffaf], a + ld [hConnectionStripLength], a ret ; aa5 @@ -452,9 +452,9 @@ Functionb06:: ; b06 cp b pop bc jr nz, .asm_b27 - ld a, [$ffaf] + ld a, [hConnectionStripLength] dec a - ld [$ffaf], a + ld [hConnectionStripLength], a ret nz ld a, [$ffb0] dec a @@ -463,20 +463,20 @@ Functionb06:: ; b06 ld a, $7a ld [hl], a ld a, $ff - ld [$ffaf], a + ld [hConnectionStripLength], a ld a, $6 ld [$ffb0], a ret .asm_b27 - ld a, [$ffaf] + ld a, [hConnectionStripLength] and a ret z dec a - ld [$ffaf], a + ld [hConnectionStripLength], a ret nz dec a - ld [$ffaf], a + ld [hConnectionStripLength], a ld a, [$ffb0] dec a ld [$ffb0], a diff --git a/home/map.asm b/home/map.asm index 8dccf51a0..1deb6c3d2 100644 --- a/home/map.asm +++ b/home/map.asm @@ -207,10 +207,10 @@ endr Function222a:: ; 222a ld a, $fa - ld [$ff9f], a + ld [hMapEntryMethod], a callba RunMapSetupScript xor a - ld [$ff9f], a + ld [hMapEntryMethod], a ret ; 2238 diff --git a/hram.asm b/hram.asm index 18bbd0218..92b8c53fe 100644 --- a/hram.asm +++ b/hram.asm @@ -17,6 +17,7 @@ hSeconds EQU $ff98 hROMBank EQU $ff9d hVBlank EQU $ff9e +hMapEntryMethod EQU $ff9f hJoypadReleased EQU $ffa2 hJoypadPressed EQU $ffa3 diff --git a/items/item_effects.asm b/items/item_effects.asm index 4978a54a1..2e9bfd516 100644 --- a/items/item_effects.asm +++ b/items/item_effects.asm @@ -562,7 +562,7 @@ endr ld [MonType], a call ClearSprites - predef Functiond88c + predef TryAddMonToParty callba Function4db49 @@ -691,7 +691,7 @@ endr jr .asm_ebe2 .asm_ebd1 - callba Functione6ce + callba BugContest_SetCaughtContestMon jr .asm_ebe2 .asm_ebd9 diff --git a/main.asm b/main.asm index 37213c669..bb8d7b66b 100644 --- a/main.asm +++ b/main.asm @@ -142,8 +142,8 @@ NewGame: ; 5b6b ld [wd001], a ld a, $f1 - ld [$ff9f], a - jp Function5e5d + ld [hMapEntryMethod], a + jp FinishContinueFunction ; 5b8f Function5b8f: ; 5b8f @@ -421,18 +421,18 @@ Continue: ; 5d65 ld [hBGMapMode], a ld c, $14 call DelayFrames - call Function5e34 - jr nc, .asm_5d8c + call ConfirmContinue + jr nc, .Check1Pass call WriteBackup jr .FailToLoad -.asm_5d8c +.Check1Pass call Function5e48 - jr nc, .asm_5d96 + jr nc, .Check2Pass call WriteBackup jr .FailToLoad -.asm_5d96 +.Check2Pass ld a, $8 ld [MusicFade], a ld a, MUSIC_NONE % $100 @@ -443,38 +443,38 @@ Continue: ; 5d65 call Function5df0 call WriteBackup call ClearTileMap - ld c, $14 + ld c, 20 call DelayFrames callba JumpRoamMons callba Function105091 callba Function140ae - ld a, [wd4b5] - cp $1 - jr z, .asm_5dd7 + ld a, [wSpawnAfterChampion] + cp SPAWN_LANCE + jr z, .SpawnAfterE4 ld a, $f2 - ld [$ff9f], a - jp Function5e5d + ld [hMapEntryMethod], a + jp FinishContinueFunction .FailToLoad ret -.asm_5dd7 +.SpawnAfterE4 ld a, SPAWN_NEW_BARK ld [wd001], a - call Function5de7 - jp Function5e5d + call PostCreditsSpawn + jp FinishContinueFunction ; 5de2 -Function5de2: ; 5de2 +SpawnAfterRed: ; 5de2 ld a, SPAWN_MT_SILVER ld [wd001], a ; 5de7 -Function5de7: ; 5de7 +PostCreditsSpawn: ; 5de7 xor a - ld [wd4b5], a + ld [wSpawnAfterChampion], a ld a, $f1 - ld [$ff9f], a + ld [hMapEntryMethod], a ret ; 5df0 @@ -506,40 +506,40 @@ Function5df0: ; 5df0 ret ; 5e34 -Function5e34: ; 5e34 -.asm_5e34 +ConfirmContinue: ; 5e34 +.loop call DelayFrame call GetJoypad ld hl, hJoyPressed bit 0, [hl] - jr nz, .asm_5e47 + jr nz, .PressA bit 1, [hl] - jr z, .asm_5e34 + jr z, .loop scf ret -.asm_5e47 +.PressA ret ; 5e48 Function5e48: ; 5e48 call Function6e3 and $80 - jr z, .asm_5e5b + jr z, .pass callba Function20021 ld a, c and a - jr z, .asm_5e5b + jr z, .pass scf ret -.asm_5e5b +.pass xor a ret ; 5e5d -Function5e5d: ; 5e5d -.asm_5e5d +FinishContinueFunction: ; 5e5d +.loop xor a ld [wc2c1], a ld [InLinkBattle], a @@ -549,14 +549,14 @@ Function5e5d: ; 5e5d ld hl, wd83e set 1, [hl] callba OverworldLoop - ld a, [wd4b5] - cp $2 - jr z, .asm_5e80 + ld a, [wSpawnAfterChampion] + cp SPAWN_RED + jr z, .AfterRed jp Reset -.asm_5e80 - call Function5de2 - jr .asm_5e5d +.AfterRed + call SpawnAfterRed + jr .loop ; 5e85 Function5e85: ; 5e85 @@ -2354,7 +2354,7 @@ CheckFacingObject:: ; 6fd9 .asm_6ff1 ld bc, ObjectStructs ; redundant ld a, 0 - ld [$ffaf], a + ld [hConnectionStripLength], a call Function7041 ret nc ld hl, OBJECT_DIRECTION_WALKING @@ -2382,7 +2382,7 @@ Function7009: ; 7009 ; 7015 Function7015: ; 7015 - ld a, [$ffaf] + ld a, [hConnectionStripLength] call GetObjectStruct call Function7021 call Function7041 @@ -2450,7 +2450,7 @@ Function7041: ; 7041 jr nz, .ok .ok2 - ld a, [$ffaf] + ld a, [hConnectionStripLength] ld l, a ld a, [$ffb0] cp l @@ -2467,7 +2467,7 @@ Function7041: ; 7041 ld a, [hl] cp e jr nz, .nope - ld a, [$ffaf] + ld a, [hConnectionStripLength] ld l, a ld a, [$ffb0] cp l @@ -2932,7 +2932,7 @@ SpecialGiveShuckle: ; 7305 ld a, 15 ld [CurPartyLevel], a - predef Functiond88c + predef TryAddMonToParty jr nc, .NotGiven ; Caught data. @@ -3205,7 +3205,7 @@ GetSpawnCoord: ; 8029 .ok ld [hl], e ld a, $0 - ld [$ffaf], a + ld [hConnectionStripLength], a ld bc, MapObjects ld a, $0 ld [$ffb0], a @@ -3262,7 +3262,7 @@ Function80a1:: ; 80a1 ld hl, OBJECT_MAP_Y add hl, bc ld e, [hl] - ld a, [$ffaf] + ld a, [hConnectionStripLength] ld b, a call Function807e and a @@ -3343,7 +3343,7 @@ Function811d: ; 811d ld hl, MAPOBJECT_OBJECT_STRUCT_ID add hl, bc ld [hl], a - ld a, [$ffaf] + ld a, [hConnectionStripLength] ld [wc2f0], a ld hl, MAPOBJECT_SPRITE add hl, bc @@ -3391,7 +3391,7 @@ Function8177: ; 8177 ld bc, MapObjects + OBJECT_LENGTH ld a, 1 .loop - ld [$ffaf], a + ld [hConnectionStripLength], a ld hl, MAPOBJECT_SPRITE add hl, bc ld a, [hl] @@ -3432,7 +3432,7 @@ Function8177: ; 8177 add hl, bc ld b, h ld c, l - ld a, [$ffaf] + ld a, [hConnectionStripLength] inc a cp NUM_OBJECTS jr nz, .loop @@ -3476,7 +3476,7 @@ Function81ea: ; 81ea ld bc, MapObjects + OBJECT_LENGTH ld a, 1 .loop - ld [$ffaf], a + ld [hConnectionStripLength], a ld hl, MAPOBJECT_SPRITE add hl, bc ld a, [hl] @@ -3511,7 +3511,7 @@ Function81ea: ; 81ea add hl, bc ld b, h ld c, l - ld a, [$ffaf] + ld a, [hConnectionStripLength] inc a cp NUM_OBJECTS jr nz, .loop @@ -3534,7 +3534,7 @@ Function823e: ; 823e ld bc, MapObjects + OBJECT_LENGTH ld a, 1 .loop - ld [$ffaf], a + ld [hConnectionStripLength], a ld hl, MAPOBJECT_SPRITE add hl, bc ld a, [hl] @@ -3569,7 +3569,7 @@ Function823e: ; 823e add hl, bc ld b, h ld c, l - ld a, [$ffaf] + ld a, [hConnectionStripLength] inc a cp NUM_OBJECTS jr nz, .loop @@ -7915,40 +7915,47 @@ Functiond839: ; d839 ; d88c -Functiond88c: ; d88c +TryAddMonToParty: ; d88c + ; Whose is it? ld de, PartyCount ld a, [MonType] and $f - jr z, .asm_d899 + jr z, .getpartylocation ld de, OTPartyCount -.asm_d899 +.getpartylocation + ; Do we have room for it? ld a, [de] inc a cp PARTY_LENGTH + 1 ret nc + ; Increase the party count ld [de], a - ld a, [de] - ld [$ffae], a + ld a, [de] ; Why are we doing this? + ld [$ffae], a ; HRAM backup add e ld e, a - jr nc, .asm_d8a7 + jr nc, .loadspecies inc d -.asm_d8a7 +.loadspecies + ; Load the species of the Pokemon into the party list. + ; The terminator is usually here, but it'll be back. ld a, [CurPartySpecies] ld [de], a + ; Load the terminator into the next slot. inc de - ld a, $ff + ld a, -1 ld [de], a + ; Now let's load the OT name. ld hl, PartyMonOT ld a, [MonType] and $f - jr z, .asm_d8bc + jr z, .loadOTname ld hl, OTPartyMonOT -.asm_d8bc - ld a, [$ffae] +.loadOTname + ld a, [$ffae] ; Restore index from backup dec a call SkipNames ld d, h @@ -7958,7 +7965,7 @@ Functiond88c: ; d88c call CopyBytes ld a, [MonType] and a - jr nz, .asm_d8f0 + jr nz, .skipnickname ld a, [CurPartySpecies] ld [wd265], a call GetPokemonName @@ -7972,19 +7979,19 @@ Functiond88c: ; d88c ld bc, PKMN_NAME_LENGTH call CopyBytes -.asm_d8f0 +.skipnickname ld hl, PartyMon1Species ld a, [MonType] and $f - jr z, .asm_d8fd + jr z, .initializeStats ld hl, OTPartyMon1Species -.asm_d8fd +.initializeStats ld a, [$ffae] dec a ld bc, PartyMon2 - PartyMon1 call AddNTimes -Functiond906: ; d906 +GeneratePartyMonStats: ; d906 ld e, l ld d, h push hl @@ -7997,10 +8004,10 @@ Functiond906: ; d906 ld a, [IsInBattle] and a ld a, $0 - jr z, .asm_d922 + jr z, .skipitem ld a, [EnemyMonItem] -.asm_d922 +.skipitem ld [de], a inc de push de @@ -8008,10 +8015,10 @@ Functiond906: ; d906 ld l, e ld a, [IsInBattle] and a - jr z, .asm_d943 + jr z, .randomlygeneratemoves ld a, [MonType] and a - jr nz, .asm_d943 + jr nz, .randomlygeneratemoves ld de, EnemyMonMoves rept NUM_MOVES + -1 ld a, [de] @@ -8020,9 +8027,9 @@ Functiond906: ; d906 endr ld a, [de] ld [hl], a - jr .asm_d950 + jr .next -.asm_d943 +.randomlygeneratemoves xor a rept NUM_MOVES + -1 ld [hli], a @@ -8031,7 +8038,7 @@ Functiond906: ; d906 ld [Buffer1], a predef FillMoves -.asm_d950 +.next pop de rept 4 inc de @@ -8058,22 +8065,22 @@ endr inc de xor a ld b, $a -.asm_d97a +.loop ld [de], a inc de dec b - jr nz, .asm_d97a + jr nz, .loop pop hl push hl ld a, [MonType] and $f - jr z, .asm_d992 + jr z, .generateDVs push hl callba GetTrainerDVs pop hl - jr .asm_d9b5 + jr .initializetrainermonstats -.asm_d992 +.generateDVs ld a, [CurPartySpecies] ld [wd265], a dec a @@ -8087,13 +8094,13 @@ endr push hl ld a, [IsInBattle] and a - jr nz, .asm_d9f3 + jr nz, .copywildmonstats call Random ld b, a call Random ld c, a -.asm_d9b5 +.initializetrainermonstats ld a, b ld [de], a inc de @@ -8111,7 +8118,7 @@ endr rept 4 inc de endr - ld a, $46 + ld a, 70 ld [de], a inc de xor a @@ -8129,7 +8136,7 @@ endr inc de ld [de], a inc de - ld bc, $000a + ld bc, 10 add hl, bc ld a, $1 ld c, a @@ -8141,9 +8148,9 @@ endr ld a, [$ffb6] ld [de], a inc de - jr .asm_da29 + jr .next2 -.asm_d9f3 +.copywildmonstats ld a, [EnemyMonDVs] ld [de], a inc de @@ -8154,12 +8161,12 @@ endr push hl ld hl, EnemyMonPP ld b, NUM_MOVES -.asm_da03 +.wildmonpploop ld a, [hli] ld [de], a inc de dec b - jr nz, .asm_da03 + jr nz, .wildmonpploop pop hl ld a, BASE_HAPPINESS @@ -8189,30 +8196,30 @@ endr ld [de], a inc de -.asm_da29 +.next2 ld a, [IsInBattle] dec a - jr nz, .asm_da3b + jr nz, .generatestats ld hl, EnemyMonMaxHP - ld bc, $000c + ld bc, 12 call CopyBytes pop hl - jr .asm_da45 + jr .next3 -.asm_da3b +.generatestats pop hl ld bc, $000a add hl, bc ld b, $0 call Functione167 -.asm_da45 +.next3 ld a, [MonType] and $f - jr nz, .asm_da6b + jr nz, .done ld a, [CurPartySpecies] cp UNOWN - jr nz, .asm_da6b + jr nz, .done ld hl, PartyMon1DVs ld a, [PartyCount] dec a @@ -8221,8 +8228,8 @@ endr predef GetUnownLetter callab Functionfba18 -.asm_da6b - scf +.done + scf ; When this function returns, the carry flag indicates success vs failure. ret ; da6d @@ -8992,7 +8999,7 @@ GiveEgg:: ; df8c push bc call CheckSeenMon push bc - call Functiond88c + call TryAddMonToParty pop bc ld a, c and a @@ -9463,8 +9470,8 @@ GivePoke:: ; e277 push bc xor a ld [MonType], a - call Functiond88c - jr nc, .asm_e2b0 + call TryAddMonToParty + jr nc, .failed ld hl, PartyMonNicknames ld a, [PartyCount] dec a @@ -9489,7 +9496,7 @@ GivePoke:: ; e277 ld [hl], a jr .asm_e2e1 -.asm_e2b0 +.failed ld a, [CurPartySpecies] ld [TempEnemyMonSpecies], a callab LoadEnemyMon @@ -10113,43 +10120,43 @@ Functione6b3: ; e6b3 ; e6ce -Functione6ce: ; e6ce - ld a, [wdf9c] +BugContest_SetCaughtContestMon: ; e6ce + ld a, [wContestMon] and a - jr z, .asm_e6ea + jr z, .firstcatch ld [wd265], a - callba Functioncc0c7 - callba Functioncc000 + callba DisplayAlreadyCaughtText + callba DisplayCaughtContestMonStats lb bc, 14, 7 call PlaceYesNoBox ret c -.asm_e6ea - call Functione6fd +.firstcatch + call .generatestats ld a, [TempEnemyMonSpecies] ld [wd265], a call GetPokemonName - ld hl, UnknownText_0xe71d + ld hl, .caughttext call PrintText ret ; e6fd -Functione6fd: ; e6fd +.generatestats: ; e6fd ld a, [TempEnemyMonSpecies] ld [CurSpecies], a ld [CurPartySpecies], a call GetBaseData xor a ld bc, PartyMon2 - PartyMon1 - ld hl, wdf9c + ld hl, wContestMon call ByteFill xor a ld [MonType], a - ld hl, wdf9c - jp Functiond906 + ld hl, wContestMon + jp GeneratePartyMonStats ; e71d -UnknownText_0xe71d: ; 0xe71d +.caughttext: ; 0xe71d ; Caught @ ! text_jump UnknownText_0x1c10c0 db "@" @@ -14837,7 +14844,7 @@ endr Special_GiveParkBalls: ; 135db xor a - ld [wdf9c], a + ld [wContestMon], a ld a, 20 ld [wdc79], a callba Function11490 @@ -15230,7 +15237,7 @@ Function13819: ; 13819 ld hl, wd00e ld a, 1 ld [hli], a - ld a, [wdf9c] + ld a, [wContestMon] ld [hli], a ld a, [hProduct] ld [hli], a @@ -24671,7 +24678,7 @@ Function24be7: ; 24be7 hlcoord 1, 1 ld de, String24c4b call PlaceString - ld a, [wdf9c] + ld a, [wContestMon] and a ld de, String24c59 jr z, .asm_24c1e @@ -24681,7 +24688,7 @@ Function24be7: ; 24be7 .asm_24c1e hlcoord 8, 1 call PlaceString - ld a, [wdf9c] + ld a, [wContestMon] and a jr z, .asm_24c3e hlcoord 1, 3 @@ -35216,7 +35223,7 @@ TrainerType1: ; 397eb ld a, OTPARTYMON ld [MonType], a push hl - predef Functiond88c + predef TryAddMonToParty pop hl jr .loop ; 39806 @@ -35237,7 +35244,7 @@ TrainerType2: ; 39806 ld [MonType], a push hl - predef Functiond88c + predef TryAddMonToParty ld a, [OTPartyCount] dec a ld hl, OTPartyMon1Moves @@ -35313,7 +35320,7 @@ TrainerType3: ; 39871 ld a, OTPARTYMON ld [MonType], a push hl - predef Functiond88c + predef TryAddMonToParty ld a, [OTPartyCount] dec a ld hl, OTPartyMon1Item @@ -35344,7 +35351,7 @@ TrainerType4: ; 3989d ld [MonType], a push hl - predef Functiond88c + predef TryAddMonToParty ld a, [OTPartyCount] dec a ld hl, OTPartyMon1Item @@ -44308,7 +44315,7 @@ Function4d9d3: ; 4d9d3 ; 4d9e5 CheckPartyFullAfterContest: ; 4d9e5 - ld a, [wdf9c] + ld a, [wContestMon] and a jp z, Function4db35 ld [CurPartySpecies], a @@ -44323,7 +44330,7 @@ CheckPartyFullAfterContest: ; 4d9e5 ld c, a ld b, $0 add hl, bc - ld a, [wdf9c] + ld a, [wContestMon] ld [hli], a ld [CurSpecies], a ld a, $ff @@ -44335,7 +44342,7 @@ CheckPartyFullAfterContest: ; 4d9e5 call AddNTimes ld d, h ld e, l - ld hl, wdf9c + ld hl, wContestMon ld bc, PartyMon2 - PartyMon1 call CopyBytes ld a, [PartyCount] @@ -44389,7 +44396,7 @@ CheckPartyFullAfterContest: ; 4d9e5 or b ld [hl], a xor a - ld [wdf9c], a + ld [wContestMon], a and a ld [ScriptVar], a ret @@ -44405,7 +44412,7 @@ Function4daa3: ; 4daa3 jr nc, .asm_4db08 xor a ld [CurPartyMon], a - ld hl, wdf9c + ld hl, wContestMon ld de, wd018 ld bc, sBoxMon2 - sBoxMon1 call CopyBytes @@ -44451,7 +44458,7 @@ Function4daa3: ; 4daa3 ld [hl], a call CloseSRAM xor a - ld [wdf9c], a + ld [wContestMon], a ld a, $1 ld [ScriptVar], a ret @@ -50505,7 +50512,7 @@ GetMovementAction: ; 802ec IsNPCInFront: ; 80341 ld a, 0 - ld [$ffaf], a + ld [hConnectionStripLength], a ld a, [MapX] ld d, a ld a, [WalkingX] @@ -53994,8 +54001,8 @@ HallOfFame:: ; 0x8640e ld a, 1 ld [wc2cd], a call Function2ed3 - ld a, 1 - ld [wd4b5], a + ld a, SPAWN_LANCE + ld [wSpawnAfterChampion], a ; Enable the Pokégear map to cycle through all of Kanto ld hl, StatusFlags @@ -54022,7 +54029,7 @@ HallOfFame:: ; 0x8640e ret ; 0x86455 -Function86455:: ; 86455 +RedCredits:: ; 86455 ld a, MUSIC_NONE % $100 ld [MusicFadeIDLo], a ld a, MUSIC_NONE / $100 @@ -54037,8 +54044,8 @@ Function86455:: ; 86455 ld c, $8 call DelayFrames call Function2ed3 - ld a, $2 - ld [wd4b5], a + ld a, SPAWN_RED + ld [wSpawnAfterChampion], a ld a, [StatusFlags] ld b, a callba Function109847 @@ -62349,8 +62356,8 @@ Function8c20f: ; 8c20f call DelayFrame xor a ld [hLCDStatCustom], a - ld [$ffc7], a - ld [$ffc8], a + ld [hLCDStatCustom + 1], a + ld [hLCDStatCustom + 2], a ld [hSCY], a ld a, $1 ld [rSVBK], a @@ -62600,9 +62607,9 @@ Function8c3e8: ; 8c3e8 (23:43e8) ld a, $43 ld [hLCDStatCustom], a ; $ff00+$c6 xor a - ld [$ffc7], a + ld [hLCDStatCustom + 1], a ld a, $90 - ld [$ffc8], a + ld [hLCDStatCustom + 2], a xor a ld [wcf64], a ld [wcf65], a @@ -63654,8 +63661,8 @@ Special_MagnetTrain: ; 8cc04 call WhiteBGMap xor a ld [hLCDStatCustom], a - ld [$ffc7], a - ld [$ffc8], a + ld [hLCDStatCustom + 1], a + ld [hLCDStatCustom + 2], a ld [hSCX], a ld [Requested2bppSource], a ld [Requested2bppSource + 1], a @@ -76437,7 +76444,7 @@ INCBIN "gfx/credits/theend.2bpp" SECTION "bank33", ROMX, BANK[$33] -Functioncc000: ; cc000 +DisplayCaughtContestMonStats: ; cc000 call WhiteBGMap call ClearTileMap @@ -76475,7 +76482,7 @@ Functioncc000: ; cc000 ld de, .Health call PlaceString - ld a, [wdf9c] + ld a, [wContestMon] ld [wd265], a call GetPokemonName ld de, StringBuffer1 @@ -76533,13 +76540,13 @@ SwitchMonText: ; cc0c2 db "@" ; cc0c7 -Functioncc0c7: ; cc0c7 +DisplayAlreadyCaughtText: ; cc0c7 call GetPokemonName - ld hl, AlreadyCaughtText + ld hl, .AlreadyCaughtText jp PrintText ; cc0d0 -AlreadyCaughtText: ; 0xcc0d0 +.AlreadyCaughtText: ; 0xcc0d0 ; You already caught a @ . text_jump UnknownText_0x1c10dd db "@" @@ -87300,7 +87307,7 @@ Functionfcc63: ; fcc63 ld [MonType], a ld [wd10b], a callab Functione039 - predef Functiond88c + predef TryAddMonToParty ld e, TRADE_DIALOG call GetTradeAttribute @@ -88399,10 +88406,10 @@ Function104263: ; 104263 (41:4263) ld c, $0 Function104265: ; 104265 (41:4265) - ld a, [$ffaf] + ld a, [hConnectionStripLength] push af ld a, c - ld [$ffaf], a + ld [hConnectionStripLength], a ld c, $12 .asm_10426d ld b, $14 @@ -88412,7 +88419,7 @@ Function104265: ; 104265 (41:4265) ld [hli], a dec b jr nz, .asm_10426f - ld a, [$ffaf] + ld a, [hConnectionStripLength] ld b, $c .asm_104279 ld [hli], a @@ -88421,7 +88428,7 @@ Function104265: ; 104265 (41:4265) dec c jr nz, .asm_10426d pop af - ld [$ffaf], a + ld [hConnectionStripLength], a ret diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm index fa3490f82..3fcd0969a 100644 --- a/misc/mobile_40.asm +++ b/misc/mobile_40.asm @@ -407,10 +407,10 @@ Function1002c9: ; 1002c9 Function1002dc: ; 1002dc ld a, $f8 - ld [$ff9f], a + ld [hMapEntryMethod], a callba RunMapSetupScript xor a - ld [$ff9f], a + ld [hMapEntryMethod], a call Functione51 ret ; 1002ed diff --git a/misc/mobile_5f.asm b/misc/mobile_5f.asm index 9c38fbb27..eb9231a18 100644 --- a/misc/mobile_5f.asm +++ b/misc/mobile_5f.asm @@ -2359,7 +2359,7 @@ Function17ded9: ; 17ded9 ld [MonType], a push hl push bc - predef Functiond88c + predef TryAddMonToParty callba Function4db49 pop bc pop hl diff --git a/wram.asm b/wram.asm index e862e3938..7850c2d5d 100644 --- a/wram.asm +++ b/wram.asm @@ -1842,7 +1842,7 @@ wd25e:: ds 4 wd262:: ds 1 wd263:: ds 1 wd264:: ds 1 -GetPokemonName_Parameter:: +wNamedObjectIndexBuffer:: wd265:: ds 1 wd266:: ds 1 wd267:: ds 1 @@ -1956,7 +1956,7 @@ RedsName:: ds NAME_LENGTH ; d49e GreensName:: ds NAME_LENGTH ; d4a9 wd4b4:: ds 1 -wd4b5:: ds 1 +wSpawnAfterChampion:: ds 1 ; init time set at newgame StartDay:: ; d4b6 From 96b0e448c4ce6a5dc43653a1c927a530fe64aece Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 7 Oct 2015 21:27:32 -0400 Subject: [PATCH 02/11] Labeling of AI item and wild encounter functions --- battle/ai/items.asm | 151 +++++++++++++++++++------------------ battle/core.asm | 16 ++-- battle/effect_commands.asm | 8 +- engine/events.asm | 18 ++--- engine/events_2.asm | 12 +-- engine/scripting.asm | 2 +- event/name_rater.asm | 2 +- items/item_effects.asm | 32 ++++---- main.asm | 4 +- wram.asm | 2 +- 10 files changed, 124 insertions(+), 123 deletions(-) diff --git a/battle/ai/items.asm b/battle/ai/items.asm index c56f389ca..7d847b9da 100644 --- a/battle/ai/items.asm +++ b/battle/ai/items.asm @@ -297,7 +297,7 @@ AI_Items: ; 39196 .FullHeal: ; 381be call .Status jp c, .DontUse - call Function383a3 + call EnemyUsedFullHeal jp .Use ; 381ca @@ -308,7 +308,7 @@ AI_Items: ; 39196 ld a, [bc] bit CONTEXT_USE_F, a - jr nz, .asm_381e7 + jr nz, .StatusCheckContext ld a, [bc] bit ALWAYS_USE_F, a jp nz, .Use @@ -317,17 +317,17 @@ AI_Items: ; 39196 jp c, .Use jp .DontUse -.asm_381e7 +.StatusCheckContext ld a, [EnemySubStatus5] bit SUBSTATUS_TOXIC, a - jr z, .asm_381fd + jr z, .FailToxicCheck ld a, [EnemyToxicCount] cp 4 - jr c, .asm_381fd + jr c, .FailToxicCheck call Random cp $80 jp c, .Use -.asm_381fd +.FailToxicCheck ld a, [EnemyMonStatus] and 1 << FRZ | SLP jp z, .DontUse @@ -336,58 +336,58 @@ AI_Items: ; 39196 .FullRestore: ; 38208 call .HealItem - jp nc, .asm_3821a + jp nc, .UseFullRestore ld a, [bc] bit CONTEXT_USE_F, a jp z, .DontUse call .Status jp c, .DontUse -.asm_3821a - call Function383b5 +.UseFullRestore + call EnemyUsedFullRestore jp .Use ; 38220 .MaxPotion: ; 38220 call .HealItem jp c, .DontUse - call Function383ae + call EnemyUsedMaxPotion jp .Use .HealItem: ; 3822c (e:422c) ld a, [bc] bit CONTEXT_USE_F, a - jr nz, .asm_38267 + jr nz, .CheckHalfOrQuarterHP callab AICheckEnemyHalfHP jp c, .DontUse ld a, [bc] bit UNKNOWN_USE_F, a - jp nz, .asm_38254 + jp nz, .CheckQuarterHP callab AICheckEnemyQuarterHP - jp nc, .asm_38281 + jp nc, .UseHealItem call Random cp $80 - jp c, .asm_38281 + jp c, .UseHealItem jp .DontUse -.asm_38254: ; 38254 (e:4254) +.CheckQuarterHP: ; 38254 (e:4254) callab AICheckEnemyQuarterHP jp c, .DontUse call Random - cp 50 + cp $32 jp c, .DontUse - jr .asm_38281 + jr .UseHealItem -.asm_38267: ; 38267 (e:4267) +.CheckHalfOrQuarterHP: ; 38267 (e:4267) callab AICheckEnemyHalfHP jp c, .DontUse callab AICheckEnemyQuarterHP - jp nc, .asm_38281 + jp nc, .UseHealItem call Random - cp 50 + cp $32 jp nc, .DontUse -.asm_38281: ; 38281 (e:4281) +.UseHealItem: ; 38281 (e:4281) jp .Use ; 38284 @@ -395,7 +395,7 @@ AI_Items: ; 39196 call .HealItem jp c, .DontUse ld b, 200 - call Function383f4 + call EnemyUsedHyperPotion jp .Use ; 38292 (e:4292) @@ -403,7 +403,7 @@ AI_Items: ; 39196 call .HealItem jp c, .DontUse ld b, 50 - call Function383ee + call EnemyUsedSuperPotion jp .Use ; 382a0 @@ -411,11 +411,11 @@ AI_Items: ; 39196 call .HealItem jp c, .DontUse ld b, 20 - call Function383e8 + call EnemyUsedPotion jp .Use ; 382ae -.asm_382ae: ; 382ae +.asm_382ae: ; This appears to be unused callab AICheckEnemyMaxHP jr c, .asm_382e4 push bc @@ -454,7 +454,7 @@ AI_Items: ; 39196 bit UNKNOWN_USE_F, a jp z, .DontUse call Random - cp 100 + cp $64 jp c, .Use jp .DontUse ; 382f9 @@ -462,56 +462,56 @@ AI_Items: ; 39196 .XAccuracy: ; 382f9 call .XItem jp c, .DontUse - call Function384f7 + call EnemyUsedXAccuracy jp .Use ; 38305 .GuardSpec: ; 38305 call .XItem jp c, .DontUse - call Function38504 + call EnemyUsedGuardSpec jp .Use ; 38311 .DireHit: ; 38311 call .XItem jp c, .DontUse - call Function38511 + call EnemyUsedDireHit jp .Use ; 3831d (e:431d) .XAttack: ; 3831d call .XItem jp c, .DontUse - call Function38541 + call EnemyUsedXAttack jp .Use ; 38329 .XDefend: ; 38329 call .XItem jp c, .DontUse - call Function38547 + call EnemyUsedXDefend jp .Use ; 38335 .XSpeed: ; 38335 call .XItem jp c, .DontUse - call Function3854d + call EnemyUsedXSpeed jp .Use ; 38341 .XSpecial: ; 38341 call .XItem jp c, .DontUse - call Function38553 + call EnemyUsedXSpecial jp .Use ; 3834d .XItem: ; 3834d (e:434d) ld a, [EnemyTurnsTaken] and a - jr nz, .asm_38372 + jr nz, .notfirstturnout ld a, [bc] bit ALWAYS_USE_F, a jp nz, .Use @@ -525,12 +525,12 @@ AI_Items: ; 39196 cp $80 jp c, .DontUse jp .Use -.asm_38372 +.notfirstturnout ld a, [bc] bit ALWAYS_USE_F, a jp z, .DontUse call Random - cp 50 + cp $32 jp nc, .DontUse jp .Use @@ -563,18 +563,18 @@ AIUsedItemSound: ; 3839a ; 383a3 -Function383a3: ; 383a3 (e:43a3) +EnemyUsedFullHeal: ; 383a3 (e:43a3) call AIUsedItemSound call AI_HealStatus ld a, FULL_HEAL jp PrintText_UsedItemOn_AND_AIUpdateHUD -Function383ae: ; 383ae (e:43ae) +EnemyUsedMaxPotion: ; 383ae (e:43ae) ld a, MAX_POTION ld [wd1f1], a - jr asm_383c6 + jr FullRestoreContinue -Function383b5: ; 383b5 (e:43b5) +EnemyUsedFullRestore: ; 383b5 (e:43b5) call AI_HealStatus ld a, FULL_RESTORE ld [wd1f1], a @@ -583,7 +583,7 @@ Function383b5: ; 383b5 (e:43b5) xor a ld [EnemyConfuseCount], a -asm_383c6: ; 383c6 +FullRestoreContinue: ; 383c6 ld de, wd1ec ld hl, EnemyMonHP + 1 ld a, [hld] @@ -602,24 +602,24 @@ asm_383c6: ; 383c6 ld [de], a ld [Buffer2], a ld [EnemyMonHP], a - jr Function38436 + jr EnemyPotionFinish ; 383e8 (e:43e8) -Function383e8: ; 383e8 +EnemyUsedPotion: ; 383e8 ld a, POTION ld b, 20 - jr Function383f8 + jr EnemyPotionContinue -Function383ee: ; 383ee +EnemyUsedSuperPotion: ; 383ee ld a, SUPER_POTION ld b, 50 - jr Function383f8 + jr EnemyPotionContinue -Function383f4: ; 383f4 (e:43f4) +EnemyUsedHyperPotion: ; 383f4 (e:43f4) ld a, HYPER_POTION ld b, 200 -Function383f8: ; 383f8 +EnemyPotionContinue: ; 383f8 ld [wd1f1], a ld hl, EnemyMonHP + 1 ld a, [hl] @@ -630,11 +630,11 @@ Function383f8: ; 383f8 ld a, [hl] ld [wd1ec + 1], a ld [wd1ee + 1], a - jr nc, .asm_38415 + jr nc, .ok inc a ld [hl], a ld [wd1ee + 1], a -.asm_38415 +.ok inc hl ld a, [hld] ld b, a @@ -648,7 +648,7 @@ Function383f8: ; 383f8 ld a, [de] ld [Buffer2], a sbc b - jr nc, .asm_38436 + jr nc, EnemyPotionFinish inc de ld a, [de] dec de @@ -657,9 +657,8 @@ Function383f8: ; 383f8 ld a, [de] ld [hl], a ld [wd1ef], a -.asm_38436 -Function38436: ; 38436 +EnemyPotionFinish: ; 38436 call PrintText_UsedItemOn hlcoord 2, 2 xor a @@ -670,24 +669,26 @@ Function38436: ; 38436 AI_TrySwitch: ; 3844b +; Determine whether the AI can switch based on how many Pokemon are still alive. +; If it can switch, it will. ld a, [OTPartyCount] ld c, a ld hl, OTPartyMon1HP ld d, 0 -.asm_38454 +.SwitchLoop ld a, [hli] ld b, a ld a, [hld] or b - jr z, .asm_3845b + jr z, .fainted inc d -.asm_3845b +.fainted push bc ld bc, PartyMon2 - PartyMon1 add hl, bc pop bc dec c - jr nz, .asm_38454 + jr nz, .SwitchLoop ld a, d cp 2 @@ -716,10 +717,10 @@ AI_Switch: ; 3846c ld bc, $0004 call CopyBytes pop af - jr c, .asm_384a3 + jr c, .skiptext ld hl, TextJump_EnemyWithdrew call PrintText -.asm_384a3 +.skiptext ld a, $1 ld [wd264], a callab NewEnemyMonStatus @@ -742,10 +743,10 @@ TextJump_EnemyWithdrew: ; 384d0 db "@" ; 384d5 -Function384d5: ; 384d5 +Function384d5: ; This appears to be unused call AIUsedItemSound call AI_HealStatus - ld a, FULL_HEAL_RED + ld a, X_SPEED jp PrintText_UsedItemOn_AND_AIUpdateHUD ; 384e0 @@ -762,7 +763,7 @@ AI_HealStatus: ; 384e0 ret ; 384f7 -Function384f7: ; 384f7 +EnemyUsedXAccuracy: ; 384f7 call AIUsedItemSound ld hl, EnemySubStatus4 set SUBSTATUS_X_ACCURACY, [hl] @@ -770,7 +771,7 @@ Function384f7: ; 384f7 jp PrintText_UsedItemOn_AND_AIUpdateHUD ; 38504 -Function38504: ; 38504 +EnemyUsedGuardSpec: ; 38504 call AIUsedItemSound ld hl, EnemySubStatus4 set SUBSTATUS_MIST, [hl] @@ -778,7 +779,7 @@ Function38504: ; 38504 jp PrintText_UsedItemOn_AND_AIUpdateHUD ; 38511 -Function38511: ; 38511 +EnemyUsedDireHit: ; 38511 call AIUsedItemSound ld hl, EnemySubStatus4 set SUBSTATUS_FOCUS_ENERGY, [hl] @@ -786,14 +787,14 @@ Function38511: ; 38511 jp PrintText_UsedItemOn_AND_AIUpdateHUD ; 3851e -Function3851e: ; 3851e +Function3851e: ; This appears to be unused ld [hDivisor], a ld hl, EnemyMonMaxHP ld a, [hli] ld [hDividend], a ld a, [hl] ld [hDividend + 1], a - ld b, $2 + ld b, 2 call Divide ld a, [hQuotient + 2] ld c, a @@ -812,25 +813,25 @@ Function3851e: ; 3851e ret ; 38541 -Function38541: ; 38541 +EnemyUsedXAttack: ; 38541 ld b, ATTACK ld a, X_ATTACK - jr Function38557 + jr EnemyUsedXItem ; 38547 -Function38547: ; 38547 +EnemyUsedXDefend: ; 38547 ld b, DEFENSE ld a, X_DEFEND - jr Function38557 + jr EnemyUsedXItem ; 3854d -Function3854d: ; 3854d +EnemyUsedXSpeed: ; 3854d ld b, SPEED ld a, X_SPEED - jr Function38557 + jr EnemyUsedXItem ; 38553 -Function38553: ; 38553 +EnemyUsedXSpecial: ; 38553 ld b, SP_ATTACK ld a, X_SPECIAL @@ -838,12 +839,12 @@ Function38553: ; 38553 ; Parameter ; a = ITEM_CONSTANT ; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION) -Function38557: +EnemyUsedXItem: ld [wd1f1], a push bc call PrintText_UsedItemOn pop bc - callba Function361ef + callba CheckIfStatCanBeRaised jp AIUpdateHUD ; 38568 diff --git a/battle/core.asm b/battle/core.asm index 287ad4120..e5679f16d 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -4821,7 +4821,7 @@ DrawPlayerHUD: ; 3df58 ; HP bar hlcoord 10, 9 ld b, 1 - xor a + xor a ; PARTYMON ld [MonType], a predef DrawPlayerHP @@ -4903,7 +4903,7 @@ PrintPlayerHUD: ; 3dfbf pop hl dec hl - ld a, $3 + ld a, BREEDMON ld [MonType], a callab GetGender ld a, " " @@ -4981,7 +4981,7 @@ DrawEnemyHUD: ; 3e043 ld a, [hl] ld [de], a - ld a, $3 + ld a, BREEDMON ld [MonType], a callab GetGender ld a, " " @@ -5358,7 +5358,7 @@ Function3e308: ; 3e308 call EnableLCD call ClearSprites call LowVolume - xor a + xor a ; PARTYMON ld [MonType], a callba Function4dc7b call MaxVolume @@ -7535,7 +7535,7 @@ endr ld [hld], a .asm_3ef74 - xor a + xor a ; PARTYMON ld [MonType], a predef Function5084a callab Function50e1b @@ -7647,7 +7647,7 @@ endr call Function309d .asm_3f057 - xor a + xor a ; PARTYMON ld [MonType], a predef Function5084a hlcoord 9, 0 @@ -7661,7 +7661,7 @@ endr call DelayFrames call Functiona80 call Function30b4 - xor a + xor a ; PARTYMON ld [MonType], a ld a, [CurSpecies] ld [wd265], a @@ -7802,7 +7802,7 @@ Function3f136: ; 3f136 push af xor a ld [DefaultFlypoint], a - xor a + xor a ; PARTYMON ld [MonType], a predef Function5084a ld a, [TempMonLevel] diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index 1b8d8b9fc..63e27359d 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -1036,13 +1036,13 @@ BattleCommand04: ; 34555 ld a, [hBattleTurn] and a - jr z, .asm_34570 + jr z, .proceed ld hl, EnemyMonPP ld de, EnemySubStatus3 ld bc, EnemyTurnsTaken -.asm_34570 +.proceed ; If we've gotten this far, this counts as a turn. ld a, [bc] @@ -6100,7 +6100,7 @@ BattleCommand7d: ; 361e0 jr BattleCommand1c BattleCommand1c: ; 361e4 ; statup - call Function361ef + call CheckIfStatCanBeRaised ld a, [FailedMessage] and a ret nz @@ -6108,7 +6108,7 @@ BattleCommand1c: ; 361e4 ; 361ef -Function361ef: ; 361ef +CheckIfStatCanBeRaised: ; 361ef ld a, b ld [LoweredStat], a ld hl, PlayerStatLevels diff --git a/engine/events.asm b/engine/events.asm index cf8b4e647..b0f9fb769 100644 --- a/engine/events.asm +++ b/engine/events.asm @@ -133,7 +133,7 @@ EnterMap: ; 9673e xor a ld [wd453], a ld [wd454], a - call Function968d1 + call SetUpFiveStepWildEncounterCooldown callba RunMapSetupScript call ClearAllScriptFlags3 @@ -382,9 +382,9 @@ CheckTileEvent: ; 96874 call CheckBit4_ScriptFlags3 jr z, .ok - call RockSmashEncounter + call RandomEncounter ret c - jr .ok + jr .ok ; pointless .ok xor a @@ -419,8 +419,8 @@ CheckTileEvent: ; 96874 ; 968c7 -Function968c7:: ; 968c7 - ld hl, wd452 +CheckWildEncounterCooldown:: ; 968c7 + ld hl, wWildEncounterCooldown ld a, [hl] and a ret z @@ -430,9 +430,9 @@ Function968c7:: ; 968c7 ret ; 968d1 -Function968d1: ; 968d1 +SetUpFiveStepWildEncounterCooldown: ; 968d1 ld a, 5 - ld [wd452], a + ld [wWildEncounterCooldown], a ret ; 968d7 @@ -441,11 +441,11 @@ Function968d7: ; 968d7 ; 968d8 Function968d8: ; 968d8 - ld a, [wd452] + ld a, [wWildEncounterCooldown] cp 2 ret nc ld a, 2 - ld [wd452], a + ld [wWildEncounterCooldown], a ret ; 968e4 diff --git a/engine/events_2.asm b/engine/events_2.asm index 5a8ce7c2c..96ebfb515 100644 --- a/engine/events_2.asm +++ b/engine/events_2.asm @@ -95,10 +95,10 @@ CheckFacingTileEvent:: ; 97c5f ; 97cc0 -RockSmashEncounter:: ; 97cc0 -; Rock Smash encounter +RandomEncounter:: ; 97cc0 +; Random encounter - call Function968c7 + call CheckWildEncounterCooldown jr c, .nope call CanUseSweetScent jr nc, .nope @@ -120,8 +120,8 @@ RockSmashEncounter:: ; 97cc0 ret .ok - ld a, BANK(RockSmashBattleScript) - ld hl, RockSmashBattleScript + ld a, BANK(WildBattleScript) + ld hl, WildBattleScript jr .done .ok_bug_contest @@ -135,7 +135,7 @@ RockSmashEncounter:: ; 97cc0 ret ; 97cf9 -RockSmashBattleScript: ; 97cf9 +WildBattleScript: ; 97cf9 battlecheck startbattle returnafterbattle diff --git a/engine/scripting.asm b/engine/scripting.asm index f5e1347b8..bc5a0e790 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -2656,7 +2656,7 @@ Script_giveegg: ; 0x97968 ; level (DecimalParam) ; if no room in the party, return 0 in ScriptVar; else, return 2 - xor a + xor a ; PARTYMON ld [ScriptVar], a ld [MonType], a call GetScriptByte diff --git a/event/name_rater.asm b/event/name_rater.asm index 62edbcbee..957d64efd 100644 --- a/event/name_rater.asm +++ b/event/name_rater.asm @@ -26,7 +26,7 @@ NameRater: ; fb6ed ld hl, NameRaterWhichNameText call PrintText ; Load the new nickname into StringBuffer2 - xor a + xor a ; PARTYMON ld [MonType], a ld a, [CurPartySpecies] ld [wd265], a diff --git a/items/item_effects.asm b/items/item_effects.asm index 2e9bfd516..d173165a7 100644 --- a/items/item_effects.asm +++ b/items/item_effects.asm @@ -558,7 +558,7 @@ endr cp PARTY_LENGTH jr z, .asm_eb3c - xor a + xor a ; PARTYMON ld [MonType], a call ClearSprites @@ -600,7 +600,7 @@ endr ld d, h ld e, l push de - xor a + xor a ; PARTYMON ld [MonType], a ld b, 0 callba Function116c1 @@ -980,7 +980,7 @@ LoveBallMultiplier: push bc ld a, [TempBattleMonSpecies] ld [CurPartySpecies], a - xor a + xor a ; PARTYMON ld [MonType], a ld a, [CurBattleMon] ld [CurPartyMon], a @@ -1425,7 +1425,7 @@ RareCandy: ; ef14 ld a, $f8 call Functionf24a - xor a + xor a ; PARTYMON ld [MonType], a predef Function5084a @@ -1440,7 +1440,7 @@ RareCandy: ; ef14 call Functiona80 - xor a + xor a ; PARTYMON ld [MonType], a ld a, [CurPartySpecies] ld [wd265], a @@ -2340,7 +2340,7 @@ endr ld [hBattleTurn], a ld [AttackMissed], a ld [EffectFailed], a - callba Function361ef + callba CheckIfStatCanBeRaised call WaitSFX callba BattleCommand8c @@ -2703,7 +2703,7 @@ Functionf6e0: ; f6e0 ; f6e8 Functionf6e8: ; f6e8 - xor a + xor a ; PARTYMON ld [MonType], a call Functionf8ec ld hl, PartyMon1PP @@ -3188,7 +3188,7 @@ Functionf8b9: ; f8b9 ld a, PartyMon1Moves - PartyMon1 call GetPartyParamLocation pop de - xor a + xor a ; PARTYMON ld [wcfa9], a ld [MonType], a ld c, NUM_MOVES @@ -3229,27 +3229,27 @@ Functionf8ec: ; f8ec ld hl, PartyMon1Moves ld bc, PartyMon2 - PartyMon1 - jr z, .asm_f91a + jr z, .asm_f91a ; PARTYMON ld hl, OTPartyMon1Moves dec a - jr z, .asm_f91a + jr z, .asm_f91a ; OTPARTYMON ld hl, TempMonMoves dec a - jr z, .asm_f915 + jr z, .asm_f915 ; BOXMON - ld hl, TempMonMoves + ld hl, TempMonMoves ; Wasted cycles dec a - jr z, .asm_f915 + jr z, .asm_f915 ; BREEDMON - ld hl, BattleMonMoves + ld hl, BattleMonMoves ; WILDMON -.asm_f915 +.asm_f915 ; BOXMON, BREEDMON, WILDMON call Functionf969 jr .asm_f91d -.asm_f91a +.asm_f91a ; PARTYMON, OTPARTYMON call Functionf963 .asm_f91d diff --git a/main.asm b/main.asm index bb8d7b66b..556ad5271 100644 --- a/main.asm +++ b/main.asm @@ -7920,7 +7920,7 @@ TryAddMonToParty: ; d88c ld de, PartyCount ld a, [MonType] and $f - jr z, .getpartylocation + jr z, .getpartylocation ; PARTYMON ld de, OTPartyCount .getpartylocation @@ -9468,7 +9468,7 @@ endr GivePoke:: ; e277 push de push bc - xor a + xor a ; PARTYMON ld [MonType], a call TryAddMonToParty jr nc, .failed diff --git a/wram.asm b/wram.asm index 7850c2d5d..88343cd1a 100644 --- a/wram.asm +++ b/wram.asm @@ -1914,7 +1914,7 @@ wd44e:: ds 1 wd44f:: ds 1 wd450:: ds 1 wd451:: ds 1 -wd452:: ds 1 +wWildEncounterCooldown:: ds 1 wd453:: ds 1 wd454:: ds 1 ds 4 From b68913a782baee1334e9614661c712ff27895e8e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 9 Oct 2015 23:09:03 -0400 Subject: [PATCH 03/11] More radio labels --- constants/misc_constants.asm | 3 + constants/radio_constants.asm | 99 ++++- engine/radio.asm | 766 +++++++++++++++++----------------- engine/radio2.asm | 404 ++++++++++++++++++ home/text.asm | 4 +- hram.asm | 1 + macros/charmap.asm | 2 + main.asm | 643 ++++++---------------------- wram.asm | 2 +- 9 files changed, 1006 insertions(+), 918 deletions(-) create mode 100644 engine/radio2.asm diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 425801e8e..13adacc8e 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -113,3 +113,6 @@ BATTLETOWER_NROFPKMNS EQU 3 BATTLETOWER_TRAINERDATALENGTH EQU $24 BATTLETOWER_NROFTRAINERS EQU 7 +NUM_WILDMONS_PER_AREA_TIME_OF_DAY EQU 7 +WILDMON_GRASS_STRUCTURE_LENGTH EQU 2 + 3 * (1 + 2 * NUM_WILDMONS_PER_AREA_TIME_OF_DAY) + diff --git a/constants/radio_constants.asm b/constants/radio_constants.asm index 76b48b1e7..46341c305 100644 --- a/constants/radio_constants.asm +++ b/constants/radio_constants.asm @@ -1,15 +1,92 @@ const_def - const OAKS_POKEMON_TALK - const POKEDEX_SHOW - const POKEMON_MUSIC - const LUCKY_CHANNEL - const BUENAS_PASSWORD - const PLACES_AND_PEOPLE - const LETS_ALL_SING - const ROCKET_RADIO - const POKE_FLUTE_RADIO - const UNOWN_RADIO - const EVOLUTION_RADIO + const OAKS_POKEMON_TALK ; $00 + const POKEDEX_SHOW ; $01 + const POKEMON_MUSIC ; $02 + const LUCKY_CHANNEL ; $03 + const BUENAS_PASSWORD ; $04 + const PLACES_AND_PEOPLE ; $05 + const LETS_ALL_SING ; $06 + const ROCKET_RADIO ; $07 + const POKE_FLUTE_RADIO ; $08 + const UNOWN_RADIO ; $09 + const EVOLUTION_RADIO ; $0a + const OAKS_POKEMON_TALK_2 ; $0b + const OAKS_POKEMON_TALK_3 ; $0c + const OAKS_POKEMON_TALK_4 ; $0d + const OAKS_POKEMON_TALK_5 ; $0e + const OAKS_POKEMON_TALK_6 ; $0f + const OAKS_POKEMON_TALK_7 ; $10 + const OAKS_POKEMON_TALK_8 ; $11 + const OAKS_POKEMON_TALK_9 ; $12 + const POKEDEX_SHOW_2 ; $13 + const POKEDEX_SHOW_3 ; $14 + const POKEDEX_SHOW_4 ; $15 + const POKEDEX_SHOW_5 ; $16 + const POKEMON_MUSIC_2 ; $17 + const POKEMON_MUSIC_3 ; $18 + const POKEMON_MUSIC_4 ; $19 + const POKEMON_MUSIC_5 ; $1a + const POKEMON_MUSIC_6 ; $1b + const POKEMON_MUSIC_7 ; $1c + const LETS_ALL_SING_2 ; $1d + const LUCKY_NUMBER_SHOW_2 ; $1e + const LUCKY_NUMBER_SHOW_3 ; $1f + const LUCKY_NUMBER_SHOW_4 ; $20 + const LUCKY_NUMBER_SHOW_5 ; $21 + const LUCKY_NUMBER_SHOW_6 ; $22 + const LUCKY_NUMBER_SHOW_7 ; $23 + const LUCKY_NUMBER_SHOW_8 ; $24 + const LUCKY_NUMBER_SHOW_9 ; $25 + const LUCKY_NUMBER_SHOW_10 ; $26 + const LUCKY_NUMBER_SHOW_11 ; $27 + const LUCKY_NUMBER_SHOW_12 ; $28 + const LUCKY_NUMBER_SHOW_13 ; $29 + const LUCKY_NUMBER_SHOW_14 ; $2a + const LUCKY_NUMBER_SHOW_15 ; $2b + const PLACES_AND_PEOPLE_2 ; $2c + const PLACES_AND_PEOPLE_3 ; $2d + const PLACES_AND_PEOPLE_4 ; $2e + const PLACES_AND_PEOPLE_5 ; $2f + const PLACES_AND_PEOPLE_6 ; $30 + const PLACES_AND_PEOPLE_7 ; $31 + const ROCKET_RADIO_2 ; $32 + const ROCKET_RADIO_3 ; $33 + const ROCKET_RADIO_4 ; $34 + const ROCKET_RADIO_5 ; $35 + const ROCKET_RADIO_6 ; $36 + const ROCKET_RADIO_7 ; $37 + const ROCKET_RADIO_8 ; $38 + const ROCKET_RADIO_9 ; $39 + const ROCKET_RADIO_10 ; $3a + const OAKS_POKEMON_TALK_10 ; $3b + const OAKS_POKEMON_TALK_11 ; $3c + const OAKS_POKEMON_TALK_12 ; $3d + const OAKS_POKEMON_TALK_13 ; $3e + const OAKS_POKEMON_TALK_14 ; $3f + const BUENAS_PASSWORD_2 ; $40 + const BUENAS_PASSWORD_3 ; $41 + const BUENAS_PASSWORD_4 ; $42 + const BUENAS_PASSWORD_5 ; $43 + const BUENAS_PASSWORD_6 ; $44 + const BUENAS_PASSWORD_7 ; $45 + const BUENAS_PASSWORD_8 ; $46 + const BUENAS_PASSWORD_9 ; $47 + const BUENAS_PASSWORD_10 ; $48 + const BUENAS_PASSWORD_11 ; $49 + const BUENAS_PASSWORD_12 ; $4a + const BUENAS_PASSWORD_13 ; $4b + const BUENAS_PASSWORD_14 ; $4c + const BUENAS_PASSWORD_15 ; $4d + const BUENAS_PASSWORD_16 ; $4e + const BUENAS_PASSWORD_17 ; $4f + const BUENAS_PASSWORD_18 ; $50 + const BUENAS_PASSWORD_19 ; $51 + const BUENAS_PASSWORD_20 ; $52 + const BUENAS_PASSWORD_21 ; $53 + const RADIO_SCROLL ; $54 + const POKEDEX_SHOW_6 ; $55 + const POKEDEX_SHOW_7 ; $56 + const POKEDEX_SHOW_8 ; $57 const_def const BUENA_MON diff --git a/engine/radio.asm b/engine/radio.asm index 3503ecc13..8e96239de 100644 --- a/engine/radio.asm +++ b/engine/radio.asm @@ -38,8 +38,8 @@ RadioJumptable: ; b863a (2e:463a) dw FernMonMusic1 ; $06 dw RocketRadio1 ; $07 dw PokeFluteRadio ; $08 - dw EvolutionRadio ; $09 - dw UnownRadio ; $0a + dw UnownRadio ; $09 + dw EvolutionRadio ; $0a ; OaksPkmnTalk dw OaksPkmnTalk2 ; $0b dw OaksPkmnTalk3 ; $0c @@ -49,10 +49,10 @@ RadioJumptable: ; b863a (2e:463a) dw OaksPkmnTalk7 ; $10 dw OaksPkmnTalk8 ; $11 dw OaksPkmnTalk9 ; $12 - dw OaksPkmnTalk10 ; $13 - dw OaksPkmnTalk11 ; $14 - dw OaksPkmnTalk12 ; $15 - dw OaksPkmnTalk13 ; $16 + dw PokedexShow2 ; $13 + dw PokedexShow3 ; $14 + dw PokedexShow4 ; $15 + dw PokedexShow5 ; $16 ; Ben Music dw BenMonMusic2 ; $17 dw BenMonMusic3 ; $18 @@ -76,12 +76,13 @@ RadioJumptable: ; b863a (2e:463a) dw LuckyNumberShow13 ; $29 dw LuckyNumberShow14 ; $2a dw LuckyNumberShow15 ; $2b - dw LuckyNumberShow16 ; $2c - dw LuckyNumberShow17 ; $2d - dw LuckyNumberShow18 ; $2e - dw LuckyNumberShow19 ; $2f - dw LuckyNumberShow20 ; $30 - dw LuckyNumberShow21 ; $31 +; People & Places + dw PeoplePlaces2 ; $2c + dw PeoplePlaces3 ; $2d + dw PeoplePlaces4 ; $2e + dw PeoplePlaces5 ; $2f + dw PeoplePlaces6 ; $30 + dw PeoplePlaces7 ; $31 ; Rocket Radio dw RocketRadio2 ; $32 dw RocketRadio3 ; $33 @@ -93,11 +94,11 @@ RadioJumptable: ; b863a (2e:463a) dw RocketRadio9 ; $39 dw RocketRadio10 ; $3a ; More Pokemon Channel stuff - dw OaksPkmnTalk14 ; $3b - dw OaksPkmnTalk15 ; $3c - dw OaksPkmnTalk16 ; $3d - dw OaksPkmnTalk17 ; $3e - dw OaksPkmnTalk18 ; $3f + dw OaksPkmnTalk10 ; $3b + dw OaksPkmnTalk11 ; $3c + dw OaksPkmnTalk12 ; $3d + dw OaksPkmnTalk13 ; $3e + dw OaksPkmnTalk14 ; $3f ; Buenas Password dw BuenasPassword2 ; $40 dw BuenasPassword3 ; $41 @@ -121,9 +122,9 @@ RadioJumptable: ; b863a (2e:463a) dw BuenasPassword21 ; $53 dw RadioScroll ; $54 ; More Pokemon Channel stuff - dw OaksPkmnTalk19 ; $55 - dw OaksPkmnTalk20 ; $56 - dw OaksPkmnTalk21 ; $57 + dw PokedexShow6 ; $55 + dw PokedexShow7 ; $56 + dw PokedexShow8 ; $57 PrintRadioLine: ; b86ea (2e:46ea) @@ -144,7 +145,7 @@ PrintRadioLine: ; b86ea (2e:46ea) .print call PrintTextBoxText .skip - ld a, $54 + ld a, RADIO_SCROLL ld [wd002], a ld a, $64 ld [wd004], a @@ -154,7 +155,7 @@ PrintRadioLine: ; b86ea (2e:46ea) Functionb8718: ; b8718 push hl ld b, SCREEN_WIDTH * 2 -.greater_than_10 +.loop ld a, [hl] cp "." jr nz, .next @@ -163,7 +164,7 @@ Functionb8718: ; b8718 .next inc hl dec b - jr nz, .greater_than_10 + jr nz, .loop pop hl ret ; b8728 @@ -188,26 +189,27 @@ OaksPkmnTalk1: ; b8742 (2e:4742) ld [wd006], a call StartRadioStation ld hl, UnknownText_0xb8820 - ld a, $b + ld a, OAKS_POKEMON_TALK_2 jp NextRadioLine OaksPkmnTalk2: ; b8752 (2e:4752) ld hl, UnknownText_0xb8825 - ld a, $c + ld a, OAKS_POKEMON_TALK_3 jp NextRadioLine OaksPkmnTalk3: ; b875a (2e:475a) ld hl, UnknownText_0xb882a - ld a, $d + ld a, OAKS_POKEMON_TALK_4 jp NextRadioLine OaksPkmnTalk4: ; b8762 (2e:4762) -; Choose a random root, and a random Pokemon from that route. +; Choose a random route, and a random Pokemon from that route. call Random and $1f cp $f jr nc, OaksPkmnTalk4 - ld hl, Unknown_b87f2 + ; We now have a number between 0 and 14. + ld hl, .routes ld c, a ld b, 0 rept 2 @@ -216,14 +218,16 @@ endr ld b, [hl] inc hl ld c, [hl] + ; bc now contains the chosen map's group and number indices. push bc + ; Search the JohtoGrassWildMons array for the chosen map. ld hl, JohtoGrassWildMons -.greater_than_10 +.loop ld a, BANK(JohtoGrassWildMons) call GetFarByte cp -1 - jr z, .done2 + jr z, .overflow inc hl cp b jr nz, .next @@ -233,62 +237,64 @@ endr jr z, .done .next dec hl - ld de, $2f + ld de, WILDMON_GRASS_STRUCTURE_LENGTH add hl, de - jr .greater_than_10 + jr .loop .done rept 4 inc hl endr - -.both_bits_set + ; Generate a number, either 0, 1, or 2, to choose a time of day. +.loop2 call Random and 3 cp 3 - jr z, .both_bits_set + jr z, .loop2 - ld bc, $e + ld bc, 2 * NUM_WILDMONS_PER_AREA_TIME_OF_DAY call AddNTimes -.greater_than_102 +.loop3 + ; Choose one of the middle three Pokemon. call Random - and 7 + and NUM_WILDMONS_PER_AREA_TIME_OF_DAY cp 2 - jr c, .greater_than_102 + jr c, .loop3 cp 5 - jr nc, .greater_than_102 + jr nc, .loop3 ld e, a ld d, 0 rept 2 add hl, de endr - inc hl + inc hl ; skip level ld a, BANK(JohtoGrassWildMons) call GetFarByte - ld [wd265], a + ld [wNamedObjectIndexBuffer], a ld [CurPartySpecies], a call GetPokemonName ld hl, StringBuffer1 ld de, wd050 - ld bc, $b + ld bc, PKMN_NAME_LENGTH call CopyBytes - + ; Now that we've chosen our wild Pokemon, + ; let's recover the map index info and get its name. pop bc call GetWorldMapLocation ld e, a callba GetLandmarkName ld hl, UnknownText_0xb882f call CopyRadioTextToRAM - ld a, $e + ld a, OAKS_POKEMON_TALK_5 jp PrintRadioLine -.done2 +.overflow pop bc ld a, $0 jp PrintRadioLine ; b87f2 (2e:47f2) -Unknown_b87f2: ; b87f2 +.routes: ; b87f2 map ROUTE_29 map ROUTE_46 map ROUTE_30 @@ -308,12 +314,12 @@ Unknown_b87f2: ; b87f2 OaksPkmnTalk5: ; b8810 (2e:4810) ld hl, UnknownText_0xb8834 - ld a, $f + ld a, OAKS_POKEMON_TALK_6 jp NextRadioLine OaksPkmnTalk6: ; b8818 (2e:4818) ld hl, UnknownText_0xb8839 - ld a, $10 + ld a, OAKS_POKEMON_TALK_7 jp NextRadioLine ; b8820 (2e:4820) @@ -358,7 +364,7 @@ OaksPkmnTalk7: ; b883e (2e:483e) ld [wd265], a call GetPokemonName ld hl, UnknownText_0xb884f - ld a, $11 + ld a, OAKS_POKEMON_TALK_8 jp NextRadioLine ; b884f (2e:484f) @@ -373,127 +379,127 @@ OaksPkmnTalk8: ; b8854 (2e:4854) and $f ld e, a ld d, 0 - ld hl, Unknown_b8869 + ld hl, .descriptors rept 2 add hl, de endr ld a, [hli] ld h, [hl] ld l, a - ld a, $12 + ld a, OAKS_POKEMON_TALK_9 jp NextRadioLine ; b8869 (2e:4869) -Unknown_b8869: ; b8869 - dw UnknownText_0xb8889 - dw UnknownText_0xb888e - dw UnknownText_0xb8893 - dw UnknownText_0xb8898 - dw UnknownText_0xb889d - dw UnknownText_0xb88a2 - dw UnknownText_0xb88a7 - dw UnknownText_0xb88ac - dw UnknownText_0xb88b1 - dw UnknownText_0xb88b6 - dw UnknownText_0xb88bb - dw UnknownText_0xb88c0 - dw UnknownText_0xb88c5 - dw UnknownText_0xb88ca - dw UnknownText_0xb88cf - dw UnknownText_0xb88d4 +.descriptors: ; b8869 + dw .sweetadorably + dw .wigglyslickly + dw .aptlynamed + dw .undeniablykindof + dw .unbearably + dw .wowimpressively + dw .almostpoisonously + dw .sensually + dw .mischievously + dw .topically + dw .addictively + dw .looksinwater + dw .evolutionmustbe + dw .provocatively + dw .flippedout + dw .heartmeltingly ; b8889 -UnknownText_0xb8889: ; 0xb8889 +.sweetadorably: ; 0xb8889 ; sweet and adorably text_jump UnknownText_0x1bc885 db "@" ; 0xb888e -UnknownText_0xb888e: ; 0xb888e +.wigglyslickly: ; 0xb888e ; wiggly and slickly text_jump UnknownText_0x1bc89a db "@" ; 0xb8893 -UnknownText_0xb8893: ; 0xb8893 +.aptlynamed: ; 0xb8893 ; aptly named and text_jump UnknownText_0x1bc8af db "@" ; 0xb8898 -UnknownText_0xb8898: ; 0xb8898 +.undeniablykindof: ; 0xb8898 ; undeniably kind of text_jump UnknownText_0x1bc8c1 db "@" ; 0xb889d -UnknownText_0xb889d: ; 0xb889d +.unbearably: ; 0xb889d ; so, so unbearably text_jump UnknownText_0x1bc8d6 db "@" ; 0xb88a2 -UnknownText_0xb88a2: ; 0xb88a2 +.wowimpressively: ; 0xb88a2 ; wow, impressively text_jump UnknownText_0x1bc8ea db "@" ; 0xb88a7 -UnknownText_0xb88a7: ; 0xb88a7 +.almostpoisonously: ; 0xb88a7 ; almost poisonously text_jump UnknownText_0x1bc8fe db "@" ; 0xb88ac -UnknownText_0xb88ac: ; 0xb88ac +.sensually: ; 0xb88ac ; ooh, so sensually text_jump UnknownText_0x1bc913 db "@" ; 0xb88b1 -UnknownText_0xb88b1: ; 0xb88b1 +.mischievously: ; 0xb88b1 ; so mischievously text_jump UnknownText_0x1bc927 db "@" ; 0xb88b6 -UnknownText_0xb88b6: ; 0xb88b6 +.topically: ; 0xb88b6 ; so very topically text_jump UnknownText_0x1bc93a db "@" ; 0xb88bb -UnknownText_0xb88bb: ; 0xb88bb +.addictively: ; 0xb88bb ; sure addictively text_jump UnknownText_0x1bc94e db "@" ; 0xb88c0 -UnknownText_0xb88c0: ; 0xb88c0 +.looksinwater: ; 0xb88c0 ; looks in water is text_jump UnknownText_0x1bc961 db "@" ; 0xb88c5 -UnknownText_0xb88c5: ; 0xb88c5 +.evolutionmustbe: ; 0xb88c5 ; evolution must be text_jump UnknownText_0x1bc975 db "@" ; 0xb88ca -UnknownText_0xb88ca: ; 0xb88ca +.provocatively: ; 0xb88ca ; provocatively text_jump UnknownText_0x1bc989 db "@" ; 0xb88cf -UnknownText_0xb88cf: ; 0xb88cf +.flippedout: ; 0xb88cf ; so flipped out and text_jump UnknownText_0x1bc999 db "@" ; 0xb88d4 -UnknownText_0xb88d4: ; 0xb88d4 +.heartmeltingly: ; 0xb88d4 ; heart-meltingly text_jump UnknownText_0x1bc9ae db "@" @@ -504,7 +510,7 @@ OaksPkmnTalk9: ; b88d9 (2e:48d9) and $f ld e, a ld d, 0 - ld hl, Unknown_b88fe + ld hl, .descriptors rept 2 add hl, de endr @@ -514,138 +520,138 @@ endr ld a, [wd006] dec a ld [wd006], a - ld a, $d - jr nz, .nope + ld a, OAKS_POKEMON_TALK_4 + jr nz, .ok ld a, $5 ld [wd006], a - ld a, $3b -.nope + ld a, OAKS_POKEMON_TALK_10 +.ok jp NextRadioLine ; b88fe (2e:48fe) -Unknown_b88fe: ; b88fe - dw UnknownText_0xb891e - dw UnknownText_0xb8923 - dw UnknownText_0xb8928 - dw UnknownText_0xb892d - dw UnknownText_0xb8932 - dw UnknownText_0xb8937 - dw UnknownText_0xb893c - dw UnknownText_0xb8941 - dw UnknownText_0xb8946 - dw UnknownText_0xb894b - dw UnknownText_0xb8950 - dw UnknownText_0xb8955 - dw UnknownText_0xb895a - dw UnknownText_0xb895f - dw UnknownText_0xb8964 - dw UnknownText_0xb8969 +.descriptors: ; b88fe + dw .cute + dw .weird + dw .pleasant + dw .boldsortof + dw .frightening + dw .suavedebonair + dw .powerful + dw .exciting + dw .groovy + dw .inspiring + dw .friendly + dw .hothothot + dw .stimulating + dw .guarded + dw .lovely + dw .speedy ; b891e -UnknownText_0xb891e: ; 0xb891e +.cute: ; 0xb891e ; cute. text_jump UnknownText_0x1bc9c0 db "@" ; 0xb8923 -UnknownText_0xb8923: ; 0xb8923 +.weird: ; 0xb8923 ; weird. text_jump UnknownText_0x1bc9c8 db "@" ; 0xb8928 -UnknownText_0xb8928: ; 0xb8928 +.pleasant: ; 0xb8928 ; pleasant. text_jump UnknownText_0x1bc9d1 db "@" ; 0xb892d -UnknownText_0xb892d: ; 0xb892d +.boldsortof: ; 0xb892d ; bold, sort of. text_jump UnknownText_0x1bc9dd db "@" ; 0xb8932 -UnknownText_0xb8932: ; 0xb8932 +.frightening: ; 0xb8932 ; frightening. text_jump UnknownText_0x1bc9ee db "@" ; 0xb8937 -UnknownText_0xb8937: ; 0xb8937 +.suavedebonair: ; 0xb8937 ; suave & debonair! text_jump UnknownText_0x1bc9fd db "@" ; 0xb893c -UnknownText_0xb893c: ; 0xb893c +.powerful: ; 0xb893c ; powerful. text_jump UnknownText_0x1bca11 db "@" ; 0xb8941 -UnknownText_0xb8941: ; 0xb8941 +.exciting: ; 0xb8941 ; exciting. text_jump UnknownText_0x1bca1d db "@" ; 0xb8946 -UnknownText_0xb8946: ; 0xb8946 +.groovy: ; 0xb8946 ; groovy! text_jump UnknownText_0x1bca29 db "@" ; 0xb894b -UnknownText_0xb894b: ; 0xb894b +.inspiring: ; 0xb894b ; inspiring. text_jump UnknownText_0x1bca33 db "@" ; 0xb8950 -UnknownText_0xb8950: ; 0xb8950 +.friendly: ; 0xb8950 ; friendly. text_jump UnknownText_0x1bca40 db "@" ; 0xb8955 -UnknownText_0xb8955: ; 0xb8955 +.hothothot: ; 0xb8955 ; hot, hot, hot! text_jump UnknownText_0x1bca4c db "@" ; 0xb895a -UnknownText_0xb895a: ; 0xb895a +.stimulating: ; 0xb895a ; stimulating. text_jump UnknownText_0x1bca5d db "@" ; 0xb895f -UnknownText_0xb895f: ; 0xb895f +.guarded: ; 0xb895f ; guarded. text_jump UnknownText_0x1bca6c db "@" ; 0xb8964 -UnknownText_0xb8964: ; 0xb8964 +.lovely: ; 0xb8964 ; lovely. text_jump UnknownText_0x1bca77 db "@" ; 0xb8969 -UnknownText_0xb8969: ; 0xb8969 +.speedy: ; 0xb8969 ; speedy. text_jump UnknownText_0x1bca81 db "@" ; 0xb896e -OaksPkmnTalk14: ; b896e (2e:496e) - callba Function91868 +OaksPkmnTalk10: ; b896e (2e:496e) + callba RadioMusicRestartPokemonChannel ld hl, UnknownText_0xb8993 call PrintText call WaitBGMap ld hl, UnknownText_0xb898e call PrintText - ld a, $3c + ld a, OAKS_POKEMON_TALK_11 ld [wd002], a ld a, $64 ld [wd004], a @@ -662,74 +668,74 @@ UnknownText_0xb8993: ; 0xb8993 db "@" ; 0xb8994 -OaksPkmnTalk15: ; b8994 (2e:4994) +OaksPkmnTalk11: ; b8994 (2e:4994) ld hl, wd004 dec [hl] ret nz hlcoord 9, 14 - ld de, String_b89a4 - ld a, $3d - jp Functionb8a00 + ld de, .pokemon_string + ld a, OAKS_POKEMON_TALK_12 + jp PlaceRadioString ; b89a4 (2e:49a4) -String_b89a4: +.pokemon_string: db "#MON@" ; b89a9 -OaksPkmnTalk16: ; b89a9 (2e:49a9) +OaksPkmnTalk12: ; b89a9 (2e:49a9) ld hl, wd004 dec [hl] ret nz hlcoord 1, 16 - ld de, String_b89b9 - ld a, $3e - jp Functionb8a00 + ld de, .pokemon_channel_string + ld a, OAKS_POKEMON_TALK_13 + jp PlaceRadioString ; b89b9 (2e:49b9) -String_b89b9: +.pokemon_channel_string: db "#MON Channel@" ; b89c6 -OaksPkmnTalk17: ; b89c6 (2e:49c6) +OaksPkmnTalk13: ; b89c6 (2e:49c6) ld hl, wd004 dec [hl] ret nz hlcoord 12, 16 - ld de, String_b89d6 - ld a, $3f - jp Functionb8a00 + ld de, .terminator + ld a, OAKS_POKEMON_TALK_14 + jp PlaceRadioString ; b89d6 (2e:49d6) -String_b89d6: +.terminator: db "@" ; b89d7 -OaksPkmnTalk18: ; b89d7 (2e:49d7) +OaksPkmnTalk14: ; b89d7 (2e:49d7) ld hl, wd004 dec [hl] ret nz ld de, $1d - callab RadioMusicNone - ld hl, UnknownText_0xb89ff + callab RadioMusicRestartDE + ld hl, .terminator call PrintText - ld a, $d + ld a, OAKS_POKEMON_TALK_4 ld [wd003], a xor a ld [wd005], a - ld a, $54 + ld a, RADIO_SCROLL ld [wd002], a - ld a, $a + ld a, 10 ld [wd004], a ret ; b89ff (2e:49ff) -UnknownText_0xb89ff: ; 0xb89ff +.terminator: ; 0xb89ff db "@" ; 0xb8a00 -Functionb8a00: ; b8a00 (2e:4a00) +PlaceRadioString: ; b8a00 (2e:4a00) ld [wd002], a - ld a, $64 + ld a, 100 ld [wd004], a jp PlaceString @@ -749,7 +755,7 @@ ClearBottomLine: ; b8a17 (2e:4a17) ld a, " " jp ByteFill -Functionb8a2d: ; b8a2d (2e:4a2d) +PokedexShow_GetDexEntryBank: ; b8a2d (2e:4a2d) push hl push de ld a, [CurPartySpecies] @@ -776,26 +782,26 @@ Functionb8a2d: ; b8a2d (2e:4a2d) PokedexShow1: ; b8a46 (2e:4a46) call StartRadioStation -.asm_b8a49 +.loop call Random cp CELEBI - jr nc, .asm_b8a49 + jr nc, .loop ld c, a push bc ld a, c call CheckCaughtMon pop bc - jr z, .asm_b8a49 + jr z, .loop inc c ld a, c ld [CurPartySpecies], a ld [wd265], a call GetPokemonName ld hl, UnknownText_0xb8b30 - ld a, $13 + ld a, POKEDEX_SHOW_2 jp NextRadioLine -OaksPkmnTalk10: ; b8a6c (2e:4a6c) +PokedexShow2: ; b8a6c (2e:4a6c) ld a, [CurPartySpecies] dec a ld hl, PokedexDataPointerTable @@ -806,17 +812,17 @@ rept 2 endr ld a, BANK(PokedexDataPointerTable) call GetFarHalfword - call Functionb8a2d + call PokedexShow_GetDexEntryBank push af push hl - call Functionb8af3 + call CopyDexEntryPart1 dec hl ld [hl], $57 ld hl, wd26b call CopyRadioTextToRAM pop hl pop af - call Functionb8b11 + call CopyDexEntryPart2 rept 4 inc hl endr @@ -824,40 +830,40 @@ endr ld [wd26b], a ld a, h ld [wd26c], a - ld a, $14 + ld a, POKEDEX_SHOW_3 jp PrintRadioLine -OaksPkmnTalk11: ; b8aa4 (2e:4aa4) - call Functionb8ad4 - ld a, $15 +PokedexShow3: ; b8aa4 (2e:4aa4) + call CopyDexEntry + ld a, POKEDEX_SHOW_4 jp PrintRadioLine -OaksPkmnTalk12: ; b8aac (2e:4aac) - call Functionb8ad4 - ld a, $16 +PokedexShow4: ; b8aac (2e:4aac) + call CopyDexEntry + ld a, POKEDEX_SHOW_5 jp PrintRadioLine -OaksPkmnTalk13: ; b8ab4 (2e:4ab4) - call Functionb8ad4 - ld a, $55 +PokedexShow5: ; b8ab4 (2e:4ab4) + call CopyDexEntry + ld a, POKEDEX_SHOW_6 jp PrintRadioLine -OaksPkmnTalk19: ; b8abc (2e:4abc) - call Functionb8ad4 - ld a, $56 +PokedexShow6: ; b8abc (2e:4abc) + call CopyDexEntry + ld a, POKEDEX_SHOW_7 jp PrintRadioLine -OaksPkmnTalk20: ; b8ac4 (2e:4ac4) - call Functionb8ad4 - ld a, $57 +PokedexShow7: ; b8ac4 (2e:4ac4) + call CopyDexEntry + ld a, POKEDEX_SHOW_8 jp PrintRadioLine -OaksPkmnTalk21: ; b8acc (2e:4acc) - call Functionb8ad4 - ld a, $1 +PokedexShow8: ; b8acc (2e:4acc) + call CopyDexEntry + ld a, POKEDEX_SHOW jp PrintRadioLine -Functionb8ad4: ; b8ad4 (2e:4ad4) +CopyDexEntry: ; b8ad4 (2e:4ad4) ld a, [wd26b] ld l, a ld a, [wd26c] @@ -865,48 +871,48 @@ Functionb8ad4: ; b8ad4 (2e:4ad4) ld a, [wd26d] push af push hl - call Functionb8af3 + call CopyDexEntryPart1 dec hl - ld [hl], $57 + ld [hl], "" ld hl, wd26b call CopyRadioTextToRAM pop hl pop af - call Functionb8b11 + call CopyDexEntryPart2 ret -Functionb8af3: ; b8af3 (2e:4af3) +CopyDexEntryPart1: ; b8af3 (2e:4af3) ld de, wd26d - ld bc, $13 + ld bc, SCREEN_WIDTH - 1 call FarCopyBytes ld hl, wd26b - ld [hl], $0 + ld [hl], "" inc hl - ld [hl], $4f + ld [hl], "" inc hl -.asm_b8b05 +.loop ld a, [hli] - cp $50 + cp "@" ret z - cp $4e + cp "" ret z - cp $5f + cp "" ret z - jr .asm_b8b05 + jr .loop -Functionb8b11: ; b8b11 (2e:4b11) +CopyDexEntryPart2: ; b8b11 (2e:4b11) ld d, a -.asm_b8b12 +.loop ld a, d call GetFarByte inc hl - cp $50 - jr z, .asm_b8b23 - cp $4e - jr z, .asm_b8b23 - cp $5f - jr nz, .asm_b8b12 -.asm_b8b23 + cp "@" + jr z, .okay + cp "" + jr z, .okay + cp "" + jr nz, .loop +.okay ld a, l ld [wd26b], a ld a, h @@ -923,70 +929,70 @@ UnknownText_0xb8b30: ; 0xb8b30 ; 0xb8b35 BenMonMusic1: ; b8b35 (2e:4b35) - call Functionb8b90 + call StartPokemonMusicChannel ld hl, UnknownText_0xb8baa - ld a, $17 + ld a, POKEMON_MUSIC_2 jp NextRadioLine BenMonMusic2: ; b8b40 (2e:4b40) ld hl, UnknownText_0xb8baf - ld a, $18 + ld a, POKEMON_MUSIC_3 jp NextRadioLine BenMonMusic3: ; b8b48 (2e:4b48) ld hl, UnknownText_0xb8bb4 - ld a, $19 + ld a, POKEMON_MUSIC_4 jp NextRadioLine FernMonMusic1: ; b8b50 (2e:4b50) - call Functionb8b90 + call StartPokemonMusicChannel ld hl, UnknownText_0xb8bb9 - ld a, $1d + ld a, LETS_ALL_SING_2 jp NextRadioLine FernMonMusic2: ; b8b5b (2e:4b5b) ld hl, UnknownText_0xb8bbe - ld a, $19 + ld a, POKEMON_MUSIC_4 jp NextRadioLine BenFernMusic4: ; b8b63 (2e:4b63) ld hl, UnknownText_0xb8bc3 - ld a, $1a + ld a, POKEMON_MUSIC_5 jp NextRadioLine BenFernMusic5: ; b8b6b (2e:4b6b) call GetWeekday and 1 ld hl, UnknownText_0xb8bc8 - jr z, .asm_b8b78 + jr z, .SunTueThurSun ld hl, UnknownText_0xb8bcd -.asm_b8b78 - ld a, $1b +.SunTueThurSun + ld a, POKEMON_MUSIC_6 jp NextRadioLine BenFernMusic6: ; b8b7d (2e:4b7d) call GetWeekday and 1 ld hl, UnknownText_0xb8bd2 - jr z, .asm_b8b8a + jr z, .SunTueThurSun ld hl, UnknownText_0xb8bd7 -.asm_b8b8a - ld a, $1c +.SunTueThurSun + ld a, POKEMON_MUSIC_7 jp NextRadioLine BenFernMusic7: ; b8b8f (2e:4b8f) ret -Functionb8b90: ; b8b90 (2e:4b90) +StartPokemonMusicChannel: ; b8b90 (2e:4b90) call RadioTerminator call PrintText ld de, MUSIC_POKEMON_MARCH call GetWeekday and 1 - jr z, .done + jr z, .SunTueThurSun ld de, MUSIC_POKEMON_LULLABY -.done - callab RadioMusicNone +.SunTueThurSun + callab RadioMusicRestartDE ret ; b8baa (2e:4baa) @@ -1057,37 +1063,37 @@ LuckyNumberShow1: ; b8bdc (2e:4bdc) callab Functionc422 .asm_b8bed ld hl, UnknownText_0xb8c7e - ld a, $1e + ld a, LUCKY_NUMBER_SHOW_2 jp NextRadioLine LuckyNumberShow2: ; b8bf5 (2e:4bf5) ld hl, UnknownText_0xb8c83 - ld a, $1f + ld a, LUCKY_NUMBER_SHOW_3 jp NextRadioLine LuckyNumberShow3: ; b8bfd (2e:4bfd) ld hl, UnknownText_0xb8c88 - ld a, $20 + ld a, LUCKY_NUMBER_SHOW_4 jp NextRadioLine LuckyNumberShow4: ; b8c05 (2e:4c05) ld hl, UnknownText_0xb8c8d - ld a, $21 + ld a, LUCKY_NUMBER_SHOW_5 jp NextRadioLine LuckyNumberShow5: ; b8c0d (2e:4c0d) ld hl, UnknownText_0xb8c92 - ld a, $22 + ld a, LUCKY_NUMBER_SHOW_6 jp NextRadioLine LuckyNumberShow6: ; b8c15 (2e:4c15) ld hl, UnknownText_0xb8c97 - ld a, $23 + ld a, LUCKY_NUMBER_SHOW_7 jp NextRadioLine LuckyNumberShow7: ; b8c1d (2e:4c1d) ld hl, UnknownText_0xb8c9c - ld a, $24 + ld a, LUCKY_NUMBER_SHOW_8 jp NextRadioLine LuckyNumberShow8: ; b8c25 (2e:4c25) @@ -1095,50 +1101,50 @@ LuckyNumberShow8: ; b8c25 (2e:4c25) ld de, wdc9f ld bc, $8205 call PrintNum - ld a, $50 + ld a, "@" ld [StringBuffer1 + 5], a ld hl, UnknownText_0xb8ca1 - ld a, $25 + ld a, LUCKY_NUMBER_SHOW_9 jp NextRadioLine LuckyNumberShow9: ; b8c3e (2e:4c3e) ld hl, UnknownText_0xb8ca6 - ld a, $26 + ld a, LUCKY_NUMBER_SHOW_10 jp NextRadioLine LuckyNumberShow10: ; b8c46 (2e:4c46) ld hl, UnknownText_0xb8c9c - ld a, $27 + ld a, LUCKY_NUMBER_SHOW_11 jp NextRadioLine LuckyNumberShow11: ; b8c4e (2e:4c4e) ld hl, UnknownText_0xb8ca1 - ld a, $28 + ld a, LUCKY_NUMBER_SHOW_12 jp NextRadioLine LuckyNumberShow12: ; b8c56 (2e:4c56) ld hl, UnknownText_0xb8cab - ld a, $29 + ld a, LUCKY_NUMBER_SHOW_13 jp NextRadioLine LuckyNumberShow13: ; b8c5e (2e:4c5e) ld hl, UnknownText_0xb8cb0 call Random and a - ld a, $3 - jr nz, .asm_b8c6b - ld a, $2a -.asm_b8c6b + ld a, LUCKY_CHANNEL + jr nz, .okay + ld a, LUCKY_NUMBER_SHOW_14 +.okay jp NextRadioLine LuckyNumberShow14: ; b8c6e (2e:4c6e) ld hl, UnknownText_0xb8cb5 - ld a, $2b + ld a, LUCKY_NUMBER_SHOW_15 jp NextRadioLine LuckyNumberShow15: ; b8c76 (2e:4c76) ld hl, UnknownText_0xb8cba - ld a, $3 + ld a, LUCKY_CHANNEL jp NextRadioLine ; b8c7e (2e:4c7e) @@ -1223,22 +1229,22 @@ UnknownText_0xb8cba: ; 0xb8cba PeoplePlaces1: ; b8cbf (2e:4cbf) call StartRadioStation ld hl, UnknownText_0xb8ce3 - ld a, $2c + ld a, PLACES_AND_PEOPLE_2 jp NextRadioLine -LuckyNumberShow16: ; b8cca (2e:4cca) +PeoplePlaces2: ; b8cca (2e:4cca) ld hl, UnknownText_0xb8ce8 - ld a, $2d + ld a, PLACES_AND_PEOPLE_3 jp NextRadioLine -LuckyNumberShow17: ; b8cd2 (2e:4cd2) +PeoplePlaces3: ; b8cd2 (2e:4cd2) ld hl, UnknownText_0xb8ced call Random - cp $7b - ld a, $2e - jr c, .asm_b8ce0 - ld a, $30 -.asm_b8ce0 + cp $7b ; 48 percent + ld a, PLACES_AND_PEOPLE_4 ; People + jr c, .ok + ld a, PLACES_AND_PEOPLE_6 ; Places +.ok jp NextRadioLine ; b8ce3 (2e:4ce3) @@ -1260,46 +1266,46 @@ UnknownText_0xb8ced: ; 0xb8ced db "@" ; 0xb8cf2 -LuckyNumberShow18: ; b8cf2 (2e:4cf2) +PeoplePlaces4: ; People call Random - and " " + and $7f inc a - cp $43 - jr nc, LuckyNumberShow18 + cp NUM_TRAINER_CLASSES - 1 + jr nc, PeoplePlaces4 push af - ld hl, Unknown_b8d3e + ld hl, .E4Names ld a, [StatusFlags] bit 6, a - jr z, .NotMet - ld hl, Unknown_b8d43 + jr z, .ok + ld hl, .KantoLeaderNames ld a, [KantoBadges] cp %11111111 - jr nz, .NotMet - ld hl, Unknown_b8d4b -.NotMet + jr nz, .ok + ld hl, .MiscNames +.ok pop af ld c, a - ld de, $1 + ld de, 1 push bc call IsInArray pop bc - jr c, LuckyNumberShow18 + jr c, PeoplePlaces4 push bc callab GetTrainerClassName ld de, StringBuffer1 call CopyName1 pop bc - ld b, $1 + ld b, 1 callab GetTrainerName ld hl, UnknownText_0xb8d51 - ld a, $2f + ld a, PLACES_AND_PEOPLE_5 jp NextRadioLine ; b8d3e (2e:4d3e) -Unknown_b8d3e: db $0b, $0d, $0e, $0f, $10 -Unknown_b8d43: db $11, $12, $13, $15, $1a, $23, $2e, $40 -Unknown_b8d4b: db $09, $0a, $0c, $2a, $3f - db $ff +.E4Names: db WILL, BRUNO, KAREN, KOGA, CHAMPION ; $0b, $0d, $0e, $0f, $10 +.KantoLeaderNames: db BROCK, MISTY, LT_SURGE, ERIKA, JANINE, SABRINA, BLAINE, BLUE ; $11, $12, $13, $15, $1a, $23, $2e, $40 +.MiscNames: db RIVAL1, POKEMON_PROF, CAL, RIVAL2, RED ; $09, $0a, $0c, $2a, $3f + db -1 ; b8d51 UnknownText_0xb8d51: ; 0xb8d51 @@ -1308,12 +1314,12 @@ UnknownText_0xb8d51: ; 0xb8d51 db "@" ; 0xb8d56 -LuckyNumberShow19: ; b8d56 (2e:4d56) +PeoplePlaces5: ; b8d56 (2e:4d56) call Random and $f ld e, a ld d, 0 - ld hl, Unknown_b8d7d + ld hl, .Descriptors rept 2 add hl, de endr @@ -1321,138 +1327,138 @@ endr ld h, [hl] ld l, a call Random - cp $a - ld a, $5 - jr c, .asm_b8d7a + cp $a ; 6.25 percent + ld a, PLACES_AND_PEOPLE + jr c, .ok call Random - cp $7b - ld a, $2e - jr c, .asm_b8d7a - ld a, $30 -.asm_b8d7a + cp $7b ; 48 percent + ld a, PLACES_AND_PEOPLE_4 ; People + jr c, .ok + ld a, PLACES_AND_PEOPLE_6 ; Places +.ok jp NextRadioLine ; b8d7d (2e:4d7d) -Unknown_b8d7d: ; b8d7d - dw UnknownText_0xb8d9d - dw UnknownText_0xb8da2 - dw UnknownText_0xb8da7 - dw UnknownText_0xb8dac - dw UnknownText_0xb8db1 - dw UnknownText_0xb8db6 - dw UnknownText_0xb8dbb - dw UnknownText_0xb8dc0 - dw UnknownText_0xb8dc5 - dw UnknownText_0xb8dca - dw UnknownText_0xb8dcf - dw UnknownText_0xb8dd4 - dw UnknownText_0xb8dd9 - dw UnknownText_0xb8dde - dw UnknownText_0xb8de3 - dw UnknownText_0xb8de8 +.Descriptors: ; b8d7d + dw PnP_cute + dw PnP_lazy + dw PnP_happy + dw PnP_noisy + dw PnP_precocious + dw PnP_bold + dw PnP_picky + dw PnP_sortofok + dw PnP_justsoso + dw PnP_actuallygreat + dw PnP_justmytype + dw PnP_socool + dw PnP_inspiring + dw PnP_weird + dw PnP_rightforme + dw PnP_odd ; b8d9d -UnknownText_0xb8d9d: ; 0xb8d9d +PnP_cute: ; 0xb8d9d ; is cute. text_jump UnknownText_0x1bcc80 db "@" ; 0xb8da2 -UnknownText_0xb8da2: ; 0xb8da2 +PnP_lazy: ; 0xb8da2 ; is sort of lazy. text_jump UnknownText_0x1bcc8b db "@" ; 0xb8da7 -UnknownText_0xb8da7: ; 0xb8da7 +PnP_happy: ; 0xb8da7 ; is always happy. text_jump UnknownText_0x1bcc9e db "@" ; 0xb8dac -UnknownText_0xb8dac: ; 0xb8dac +PnP_noisy: ; 0xb8dac ; is quite noisy. text_jump UnknownText_0x1bccb1 db "@" ; 0xb8db1 -UnknownText_0xb8db1: ; 0xb8db1 +PnP_precocious: ; 0xb8db1 ; is precocious. text_jump UnknownText_0x1bccc3 db "@" ; 0xb8db6 -UnknownText_0xb8db6: ; 0xb8db6 +PnP_bold: ; 0xb8db6 ; is somewhat bold. text_jump UnknownText_0x1bccd4 db "@" ; 0xb8dbb -UnknownText_0xb8dbb: ; 0xb8dbb +PnP_picky: ; 0xb8dbb ; is too picky! text_jump UnknownText_0x1bcce8 db "@" ; 0xb8dc0 -UnknownText_0xb8dc0: ; 0xb8dc0 +PnP_sortofok: ; 0xb8dc0 ; is sort of OK. text_jump UnknownText_0x1bccf8 db "@" ; 0xb8dc5 -UnknownText_0xb8dc5: ; 0xb8dc5 +PnP_justsoso: ; 0xb8dc5 ; is just so-so. text_jump UnknownText_0x1bcd09 db "@" ; 0xb8dca -UnknownText_0xb8dca: ; 0xb8dca +PnP_actuallygreat: ; 0xb8dca ; is actually great. text_jump UnknownText_0x1bcd1a db "@" ; 0xb8dcf -UnknownText_0xb8dcf: ; 0xb8dcf +PnP_justmytype: ; 0xb8dcf ; is just my type. text_jump UnknownText_0x1bcd2f db "@" ; 0xb8dd4 -UnknownText_0xb8dd4: ; 0xb8dd4 +PnP_socool: ; 0xb8dd4 ; is so cool, no? text_jump UnknownText_0x1bcd42 db "@" ; 0xb8dd9 -UnknownText_0xb8dd9: ; 0xb8dd9 +PnP_inspiring: ; 0xb8dd9 ; is inspiring! text_jump UnknownText_0x1bcd54 db "@" ; 0xb8dde -UnknownText_0xb8dde: ; 0xb8dde +PnP_weird: ; 0xb8dde ; is kind of weird. text_jump UnknownText_0x1bcd64 db "@" ; 0xb8de3 -UnknownText_0xb8de3: ; 0xb8de3 +PnP_rightforme: ; 0xb8de3 ; is right for me? text_jump UnknownText_0x1bcd78 db "@" ; 0xb8de8 -UnknownText_0xb8de8: ; 0xb8de8 +PnP_odd: ; 0xb8de8 ; is definitely odd! text_jump UnknownText_0x1bcd8b db "@" ; 0xb8ded -LuckyNumberShow20: ; b8ded (2e:4ded) +PeoplePlaces6: ; Places call Random - cp $9 - jr nc, LuckyNumberShow20 - ld hl, Unknown_b8e11 + cp 9 + jr nc, PeoplePlaces6 + ld hl, .Maps ld c, a ld b, 0 rept 2 @@ -1465,11 +1471,11 @@ endr ld e, a callba GetLandmarkName ld hl, UnknownText_0xb8e23 - ld a, $31 + ld a, PLACES_AND_PEOPLE_7 jp NextRadioLine ; b8e11 (2e:4e11) -Unknown_b8e11: ; b8e11 +.Maps: ; b8e11 map PALLET_TOWN map ROUTE_22 map PEWTER_CITY @@ -1487,12 +1493,12 @@ UnknownText_0xb8e23: ; 0xb8e23 db "@" ; 0xb8e28 -LuckyNumberShow21: ; b8e28 (2e:4e28) +PeoplePlaces7: ; b8e28 (2e:4e28) call Random and $f ld e, a ld d, 0 - ld hl, Unknown_b8e52 + ld hl, .descriptors rept 2 add hl, de endr @@ -1501,86 +1507,86 @@ endr ld l, a call CopyRadioTextToRAM call Random - cp $a - ld a, $5 - jr c, .asm_b8e4f + cp $a ; 6.25 percent + ld a, PLACES_AND_PEOPLE + jr c, .ok call Random - cp $7b - ld a, $2e - jr c, .asm_b8e4f - ld a, $30 -.asm_b8e4f + cp $7b ; 48 percent + ld a, PLACES_AND_PEOPLE_4 ; People + jr c, .ok + ld a, PLACES_AND_PEOPLE_6 ; Places +.ok jp PrintRadioLine ; b8e52 (2e:4e52) -Unknown_b8e52: ; b8e52 - dw UnknownText_0xb8d9d - dw UnknownText_0xb8da2 - dw UnknownText_0xb8da7 - dw UnknownText_0xb8dac - dw UnknownText_0xb8db1 - dw UnknownText_0xb8db6 - dw UnknownText_0xb8dbb - dw UnknownText_0xb8dc0 - dw UnknownText_0xb8dc5 - dw UnknownText_0xb8dca - dw UnknownText_0xb8dcf - dw UnknownText_0xb8dd4 - dw UnknownText_0xb8dd9 - dw UnknownText_0xb8dde - dw UnknownText_0xb8de3 - dw UnknownText_0xb8de8 +.descriptors: ; b8e52 + dw PnP_cute + dw PnP_lazy + dw PnP_happy + dw PnP_noisy + dw PnP_precocious + dw PnP_bold + dw PnP_picky + dw PnP_sortofok + dw PnP_justsoso + dw PnP_actuallygreat + dw PnP_justmytype + dw PnP_socool + dw PnP_inspiring + dw PnP_weird + dw PnP_rightforme + dw PnP_odd ; b8e72 RocketRadio1: ; b8e72 (2e:4e72) call StartRadioStation ld hl, UnknownText_0xb8ec5 - ld a, $32 + ld a, ROCKET_RADIO_2 jp NextRadioLine RocketRadio2: ; b8e7d (2e:4e7d) ld hl, UnknownText_0xb8eca - ld a, $33 + ld a, ROCKET_RADIO_3 jp NextRadioLine RocketRadio3: ; b8e85 (2e:4e85) ld hl, UnknownText_0xb8ecf - ld a, $34 + ld a, ROCKET_RADIO_4 jp NextRadioLine RocketRadio4: ; b8e8d (2e:4e8d) ld hl, UnknownText_0xb8ed4 - ld a, $35 + ld a, ROCKET_RADIO_5 jp NextRadioLine RocketRadio5: ; b8e95 (2e:4e95) ld hl, UnknownText_0xb8ed9 - ld a, $36 + ld a, ROCKET_RADIO_6 jp NextRadioLine RocketRadio6: ; b8e9d (2e:4e9d) ld hl, UnknownText_0xb8ede - ld a, $37 + ld a, ROCKET_RADIO_7 jp NextRadioLine RocketRadio7: ; b8ea5 (2e:4ea5) ld hl, UnknownText_0xb8ee3 - ld a, $38 + ld a, ROCKET_RADIO_8 jp NextRadioLine RocketRadio8: ; b8ead (2e:4ead) ld hl, UnknownText_0xb8ee8 - ld a, $39 + ld a, ROCKET_RADIO_9 jp NextRadioLine RocketRadio9: ; b8eb5 (2e:4eb5) ld hl, UnknownText_0xb8eed - ld a, $3a + ld a, ROCKET_RADIO_10 jp NextRadioLine RocketRadio10: ; b8ebd (2e:4ebd) ld hl, UnknownText_0xb8ef2 - ld a, $7 + ld a, ROCKET_RADIO jp NextRadioLine ; b8ec5 (2e:4ec5) @@ -1646,32 +1652,32 @@ UnknownText_0xb8ef2: ; 0xb8ef2 PokeFluteRadio: ; b8ef7 (2e:4ef7) call StartRadioStation - ld a, $1 + ld a, 1 ld [wd005], a ret -EvolutionRadio: ; b8f00 (2e:4f00) +UnownRadio: ; b8f00 (2e:4f00) call StartRadioStation - ld a, $1 + ld a, 1 ld [wd005], a ret -UnownRadio: ; b8f09 (2e:4f09) +EvolutionRadio: ; b8f09 (2e:4f09) call StartRadioStation - ld a, $1 + ld a, 1 ld [wd005], a ret BuenasPassword1: ; b8f12 (2e:4f12) ; Determine if we need to be here call BuenasPasswordCheckMidnight - jp nc, Functionb8f22 + jp nc, .PlayPassword ld a, [wd005] and a jp z, BuenasPassword20 jp BuenasPassword8 -Functionb8f22: ; b8f22 (2e:4f22) +.PlayPassword: ; b8f22 (2e:4f22) call StartRadioStation ld a, [hBGMapMode] ; $ff00+$d4 push af @@ -1683,19 +1689,19 @@ Functionb8f22: ; b8f22 (2e:4f22) pop af ld [hBGMapMode], a ; $ff00+$d4 ld hl, UnknownText_0xb9182 - ld a, $40 + ld a, BUENAS_PASSWORD_2 jp NextRadioLine BuenasPassword2: ; b8f3f (2e:4f3f) ld hl, UnknownText_0xb9187 - ld a, $41 + ld a, BUENAS_PASSWORD_3 jp NextRadioLine BuenasPassword3: ; b8f47 (2e:4f47) call BuenasPasswordCheckMidnight ld hl, UnknownText_0xb918c jp c, BuenasPasswordAfterMidnight - ld a, $42 + ld a, BUENAS_PASSWORD_4 jp NextRadioLine BuenasPassword4: ; b8f55 (2e:4f55) @@ -1731,7 +1737,7 @@ BuenasPassword4: ; b8f55 (2e:4f55) ld c, a call GetBuenasPassword ld hl, UnknownText_0xb9191 - ld a, $43 + ld a, BUENAS_PASSWORD_5 jp NextRadioLine GetBuenasPassword: ; b8f8f @@ -1859,19 +1865,19 @@ PasswordTable: ; b8ff9 BuenasPassword5: ; b909c (2e:509c) ld hl, UnknownText_0xb9196 - ld a, $44 + ld a, BUENAS_PASSWORD_6 jp NextRadioLine BuenasPassword6: ; b90a4 (2e:50a4) ld hl, UnknownText_0xb919b - ld a, $45 + ld a, BUENAS_PASSWORD_7 jp NextRadioLine BuenasPassword7: ; b90ac (2e:50ac) call BuenasPasswordCheckMidnight ld hl, UnknownText_0xb91a0 jr c, BuenasPasswordAfterMidnight - ld a, $4 + ld a, BUENAS_PASSWORD jp NextRadioLine BuenasPasswordAfterMidnight: ; b90b9 (2e:50b9) @@ -1879,69 +1885,69 @@ BuenasPasswordAfterMidnight: ; b90b9 (2e:50b9) ld hl, WeeklyFlags res 7, [hl] pop hl - ld a, $46 + ld a, BUENAS_PASSWORD_8 jp NextRadioLine BuenasPassword8: ; b90c5 (2e:50c5) ld hl, WeeklyFlags res 7, [hl] ld hl, UnknownText_0xb91d2 - ld a, $47 + ld a, BUENAS_PASSWORD_9 jp NextRadioLine BuenasPassword9: ; b90d2 (2e:50d2) ld hl, UnknownText_0xb91a5 - ld a, $48 + ld a, BUENAS_PASSWORD_10 jp NextRadioLine BuenasPassword10: ; b90da (2e:50da) ld hl, UnknownText_0xb91aa - ld a, $49 + ld a, BUENAS_PASSWORD_11 jp NextRadioLine BuenasPassword11: ; b90e2 (2e:50e2) ld hl, UnknownText_0xb91af - ld a, $4a + ld a, BUENAS_PASSWORD_12 jp NextRadioLine BuenasPassword12: ; b90ea (2e:50ea) ld hl, UnknownText_0xb91b4 - ld a, $4b + ld a, BUENAS_PASSWORD_13 jp NextRadioLine BuenasPassword13: ; b90f2 (2e:50f2) ld hl, UnknownText_0xb91b9 - ld a, $4c + ld a, BUENAS_PASSWORD_14 jp NextRadioLine BuenasPassword14: ; b90fa (2e:50fa) ld hl, UnknownText_0xb91be - ld a, $4d + ld a, BUENAS_PASSWORD_15 jp NextRadioLine BuenasPassword15: ; b9102 (2e:5102) ld hl, UnknownText_0xb91c3 - ld a, $4e + ld a, BUENAS_PASSWORD_16 jp NextRadioLine BuenasPassword16: ; b910a (2e:510a) ld hl, UnknownText_0xb91c8 - ld a, $4f + ld a, BUENAS_PASSWORD_17 jp NextRadioLine BuenasPassword17: ; b9112 (2e:5112) ld hl, UnknownText_0xb91cd - ld a, $50 + ld a, BUENAS_PASSWORD_18 jp NextRadioLine BuenasPassword18: ; b911a (2e:511a) ld hl, UnknownText_0xb91d2 - ld a, $51 + ld a, BUENAS_PASSWORD_19 jp NextRadioLine BuenasPassword19: ; b9122 (2e:5122) ld hl, UnknownText_0xb91d2 - ld a, $52 + ld a, BUENAS_PASSWORD_20 jp NextRadioLine BuenasPassword20: ; b912a (2e:512a) @@ -1958,7 +1964,7 @@ BuenasPassword20: ; b912a (2e:512a) xor a ld [wd005], a ld hl, UnknownText_0xb91d7 - ld a, $53 + ld a, BUENAS_PASSWORD_21 jp NextRadioLine BuenasPassword21: ; b9152 (2e:5152) @@ -1969,7 +1975,7 @@ BuenasPassword21: ; b9152 (2e:5152) call BuenasPasswordCheckMidnight jp nc, BuenasPassword1 ld hl, UnknownText_0xb91d7 - ld a, $53 + ld a, BUENAS_PASSWORD_21 jp NextRadioLine BuenasPasswordCheckMidnight: ; b9169 (2e:5169) @@ -2115,7 +2121,7 @@ endr ld e, [hl] inc hl ld d, [hl] - callab RadioMusicNone + callab RadioMusicRestartDE ret ; b920b (2e:520b) diff --git a/engine/radio2.asm b/engine/radio2.asm new file mode 100644 index 000000000..b843315d4 --- /dev/null +++ b/engine/radio2.asm @@ -0,0 +1,404 @@ +_UpdateRadioStation: ; 9163e (24:563e) + jr UpdateRadioStation + +Function91640: ; 91640 (24:5640) + push bc + call .TuningKnob + pop bc + ld a, [wRadioTuningKnob] + ld hl, $6 + add hl, bc + ld [hl], a + ret + +.TuningKnob: ; 9164e (24:564e) + ld hl, hJoyLast + ld a, [hl] + and D_DOWN + jr nz, .down + ld a, [hl] + and D_UP + jr nz, .up + ret + +.down + ld hl, wRadioTuningKnob + ld a, [hl] + and a + ret z +rept 2 + dec [hl] +endr + jr .update + +.up + ld hl, wRadioTuningKnob + ld a, [hl] + cp 80 + ret nc +rept 2 + inc [hl] +endr + +.update + +UpdateRadioStation: ; 9166f (24:566f) + ld hl, wRadioTuningKnob + ld d, [hl] + ld hl, RadioChannels +.loop + ld a, [hli] + cp -1 + jr z, .nostation + cp d + jr z, .foundstation +rept 2 + inc hl +endr + jr .loop + +.nostation + call NoRadioStation + ret + +.foundstation + ld a, [hli] + ld h, [hl] + ld l, a + ld de, .returnafterstation + push de + jp [hl] +.returnafterstation + ld a, [wc6d9] + and a + ret z + xor a + ld [hBGMapMode], a + hlcoord 2, 9 + call PlaceString + ld a, $1 + ld [hBGMapMode], a + ret +; 916a1 (24:56a1) + +Function916a1: ; 916a1 + ld [wc6d9], a + ld a, [hli] + ld [wc6da], a + ld a, [hli] + ld [wc6db], a + ret +; 916ad + + +RadioChannels: +; frequencies and the shows that play on them. +; frequency value given here = 4 × ingame_frequency − 2 + dbw 16, .PkmnTalkAndPokedexShow + dbw 28, .PokemonMusic + dbw 32, .LuckyChannel + dbw 40, .BuenasPassword + dbw 52, .RuinsOfAlphRadio + dbw 64, .PlacesAndPeople + dbw 72, .LetsAllSing + dbw 78, .PokeFluteRadio + dbw 80, .EvolutionRadio + db $ff + +.PkmnTalkAndPokedexShow +; Pokédex Show in the morning +; Oak's Pokémon Talk in the afternoon and evening + call .InJohto + jr nc, .NoSignal + ld a, [TimeOfDay] + and a + jp z, LoadStation_PokedexShow + jp LoadStation_OaksPokemonTalk + +.PokemonMusic + call .InJohto + jr nc, .NoSignal + jp LoadStation_PokemonMusic + +.LuckyChannel + call .InJohto + jr nc, .NoSignal + jp LoadStation_LuckyChannel + +.BuenasPassword + call .InJohto + jr nc, .NoSignal + jp LoadStation_BuenasPassword + +.RuinsOfAlphRadio + ld a, [wc6d8] + cp RUINS_OF_ALPH + jr nz, .NoSignal + jp LoadStation_UnownRadio + +.PlacesAndPeople + call .InJohto + jr c, .NoSignal + ld a, [wPokegearFlags] + bit 3, a + jr z, .NoSignal + jp LoadStation_PlacesAndPeople + +.LetsAllSing + call .InJohto + jr c, .NoSignal + ld a, [wPokegearFlags] + bit 3, a + jr z, .NoSignal + jp LoadStation_LetsAllSing + +.PokeFluteRadio + call .InJohto + jr c, .NoSignal + ld a, [wPokegearFlags] + bit 3, a + jr z, .NoSignal + jp LoadStation_PokeFluteRadio + +.EvolutionRadio +; This station airs in the Lake of Rage area when Rocket are still in Mahogany. + + ld a, [StatusFlags] + bit 4, a + jr z, .NoSignal + + ld a, [wc6d8] + cp MAHOGANY_TOWN + jr z, .ok + cp ROUTE_43 + jr z, .ok + cp LAKE_OF_RAGE + jr nz, .NoSignal +.ok + jp LoadStation_EvolutionRadio + +.NoSignal + call NoRadioStation + ret + +.InJohto +; if in Johto or on the S.S. Aqua, set carry +; otherwise clear carry + ld a, [wc6d8] + cp FAST_SHIP + jr z, .johto + cp KANTO_LANDMARK + jr c, .johto +.kanto + and a + ret +.johto + scf + ret + + + +LoadStation_OaksPokemonTalk: ; 91753 (24:5753) + xor a ; OAKS_POKEMON_TALK + ld [wd002], a + ld [wd005], a + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow + call Radio_BackUpFarCallParams + ld de, OaksPkmnTalkName + ret + +LoadStation_PokedexShow: ; 91766 (24:5766) + ld a, POKEDEX_SHOW + ld [wd002], a + xor a + ld [wd005], a + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow + call Radio_BackUpFarCallParams + ld de, PokedexShowName + ret + +LoadStation_PokemonMusic: ; 9177b (24:577b) + ld a, POKEMON_MUSIC + ld [wd002], a + xor a + ld [wd005], a + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow + call Radio_BackUpFarCallParams + ld de, PokemonMusicName + ret + +LoadStation_LuckyChannel: ; 91790 (24:5790) + ld a, LUCKY_CHANNEL + ld [wd002], a + xor a + ld [wd005], a + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow + call Radio_BackUpFarCallParams + ld de, LuckyChannelName + ret + +LoadStation_BuenasPassword: ; 917a5 (24:57a5) + ld a, BUENAS_PASSWORD + ld [wd002], a + xor a + ld [wd005], a + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow + call Radio_BackUpFarCallParams + ld de, NotBuenasPasswordName + ld a, [StatusFlags2] + bit 0, a + ret z + ld de, BuenasPasswordName + ret +; 917c3 (24:57c3) + +BuenasPasswordName: db "BUENA'S PASSWORD@" +NotBuenasPasswordName: db "@" + +LoadStation_UnownRadio: ; 917d5 (24:57d5) + ld a, UNOWN_RADIO + ld [wd002], a + xor a + ld [wd005], a + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow + call Radio_BackUpFarCallParams + ld de, UnknownStationName + ret + +LoadStation_PlacesAndPeople: ; 917ea (24:57ea) + ld a, PLACES_AND_PEOPLE + ld [wd002], a + xor a + ld [wd005], a + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow + call Radio_BackUpFarCallParams + ld de, PlacesAndPeopleName + ret + +LoadStation_LetsAllSing: ; 917ff (24:57ff) + ld a, LETS_ALL_SING + ld [wd002], a + xor a + ld [wd005], a + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow + call Radio_BackUpFarCallParams + ld de, LetsAllSingName + ret +; 91814 (24:5814) + +LoadStation_RocketRadio: ; 91814 + ld a, ROCKET_RADIO + ld [wd002], a + xor a + ld [wd005], a + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow + call Radio_BackUpFarCallParams + ld de, LetsAllSingName + ret +; 91829 + +LoadStation_PokeFluteRadio: ; 91829 (24:5829) + ld a, POKE_FLUTE_RADIO + ld [wd002], a + xor a + ld [wd005], a + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow + call Radio_BackUpFarCallParams + ld de, PokeFluteStationName + ret + +LoadStation_EvolutionRadio: ; 9183e (24:583e) + ld a, EVOLUTION_RADIO + ld [wd002], a + xor a + ld [wd005], a + ld a, BANK(PlayRadioShow) + ld hl, PlayRadioShow + call Radio_BackUpFarCallParams + ld de, UnknownStationName + ret +; 91853 (24:5853) + +LoadStation_Dummy: ; 91853 + ret + +RadioMusicRestartDE: ; 91854 (24:5854) + push de + ld a, e + ld [wc6dc], a + ld de, MUSIC_NONE + call PlayMusic + pop de + ld a, e + ld [wMapMusic], a + call PlayMusic + ret + +RadioMusicRestartPokemonChannel: ; 91868 (24:5868) + push de + ld a, $fe + ld [wc6dc], a + ld de, MUSIC_NONE + call PlayMusic + pop de + ld de, MUSIC_POKEMON_CHANNEL + call PlayMusic + ret + +Radio_BackUpFarCallParams: ; 9187c (24:587c) + ld [wc6d9], a + ld a, l + ld [wc6da], a + ld a, h + ld [wc6db], a + ret + +NoRadioStation: ; 91888 (24:5888) + call NoRadioMusic + call NoRadioName + xor a + ld [wc6d9], a + ld [wc6da], a + ld [wc6db], a + ld a, $1 + ld [hBGMapMode], a ; $ff00+$d4 + ret + +NoRadioMusic: ; 9189d (24:589d) + ld de, MUSIC_NONE + call PlayMusic + ld a, $ff + ld [wc6dc], a + ret + +NoRadioName: ; 918a9 (24:58a9) + xor a + ld [hBGMapMode], a ; $ff00+$d4 + hlcoord 1, 8 + ld bc, $312 + call ClearBox + hlcoord 0, 12 + ld bc, $412 + call TextBox + ret +; 918bf + +OaksPkmnTalkName: db "OAK's Talk@" +PokedexShowName: db "#DEX Show@" +PokemonMusicName: db "#MON Music@" +LuckyChannelName: db "Lucky Channel@" +UnknownStationName: db "?????@" +PlacesAndPeopleName: db "Places & People@" +LetsAllSingName: db "Let's All Sing!@" +PokeFluteStationName: db "# FLUTE@" +; 9191c diff --git a/home/text.asm b/home/text.asm index fdbafec22..1ddc72ea5 100644 --- a/home/text.asm +++ b/home/text.asm @@ -273,7 +273,7 @@ endm dict $24, PlacePOKE dict $25, NextChar dict2 $1f, " " - dict $5f, Char5F + dict "", PlaceDexEnd dict "", PlaceMoveTargetsName dict "", PlaceMoveUsersName dict "", PlaceEnemysName @@ -590,7 +590,7 @@ ContText:: ; 1345 ; 1356 -Char5F:: ; 1356 +PlaceDexEnd:: ; 1356 ; Legacy: ends a Pokédex entry (Red). ; Dex entries are now regular strings. ld [hl], "." diff --git a/hram.asm b/hram.asm index 92b8c53fe..6d87614f6 100644 --- a/hram.asm +++ b/hram.asm @@ -26,6 +26,7 @@ hJoypadSum EQU $ffa5 hJoyReleased EQU $ffa6 hJoyPressed EQU $ffa7 hJoyDown EQU $ffa8 +hJoyLast EQU $ffa9 hConnectionStripLength EQU $ffaf hConnectedMapWidth EQU $ffb0 diff --git a/macros/charmap.asm b/macros/charmap.asm index 48ef2cad3..bdee88a1b 100644 --- a/macros/charmap.asm +++ b/macros/charmap.asm @@ -301,3 +301,5 @@ charmap "", $5d charmap "", $5e charmap "<......>", $56 + charmap "", $00 + charmap "", $5f diff --git a/main.asm b/main.asm index 556ad5271..6b7700fef 100644 --- a/main.asm +++ b/main.asm @@ -9768,10 +9768,10 @@ MenuData2_0xe477: ; 0xe477 ; 0xe47f Strings_e47f: ; e47f - db "WITHDRAW ", $e1, $e2, "@" - db "DEPOSIT ", $e1, $e2, "@" + db "WITHDRAW @" + db "DEPOSIT @" db "CHANGE BOX@" - db "MOVE ", $e1, $e2, " W/O MAIL@" + db "MOVE W/O MAIL@" db "SEE YA!@" Jumptable_e4ba: ; e4ba (3:64ba) @@ -47515,22 +47515,22 @@ PartyMenuStrings: ; 0x504d2 ChooseAMonString: ; 0x504e4 db "Choose a #MON.@" UseOnWhichPKMNString: ; 0x504f3 - db "Use on which ", $e1, $e2, "?@" + db "Use on which ?@" WhichPKMNString: ; 0x50504 - db "Which ", $e1, $e2, "?@" + db "Which ?@" TeachWhichPKMNString: ; 0x5050e - db "Teach which ", $e1, $e2, "?@" + db "Teach which ?@" MoveToWhereString: ; 0x5051e db "Move to where?@" ChooseAFemalePKMNString: ; 0x5052d ; UNUSED - db "Choose a ♀", $e1, $e2, ".@" + db "Choose a ♀.@" ChooseAMalePKMNString: ; 0x5053b ; UNUSED - db "Choose a ♂", $e1, $e2, ".@" + db "Choose a ♂.@" ToWhichPKMNString: ; 0x50549 - db "To which ", $e1, $e2, "?@" + db "To which ?@" YouHaveNoPKMNString: ; 0x50556 - db "You have no ", $e1, $e2, "!@" + db "You have no !@" Function50566: ; 50566 @@ -66891,20 +66891,15 @@ Unknown_8e6a5: ; 8e6a5 Unknown_8e706: ; 8e706 - dbbw $80, $01, Unknown_8e72a - dbbw $80, $01, Unknown_8e72a - dbbw $80, $01, Unknown_8e72a - dbbw $80, $01, Unknown_8e72a - dbbw $10, $37, Unknown_8e72a - dbbw $10, $11, Unknown_8e72a - dbbw $10, $39, Unknown_8e72a - dbbw $10, $24, Unknown_8e72a - dbbw $10, $21, Unknown_8e72a - -Unknown_8e72a: -; 8e72a - - + dbbw $80, $01, Function8e72a + dbbw $80, $01, Function8e72a + dbbw $80, $01, Function8e72a + dbbw $80, $01, Function8e72a + dbbw $10, $37, Function8e72a + dbbw $10, $11, Function8e72a + dbbw $10, $39, Function8e72a + dbbw $10, $24, Function8e72a + dbbw $10, $21, Function8e72a Function8e72a: ; 8e72a add $10 @@ -69886,7 +69881,7 @@ Function910f9: ; 910f9 (24:50f9) ld hl, $3 add hl, bc ld [hl], $8 - call Function9163e + call _UpdateRadioStation ld hl, wcf63 inc [hl] ret @@ -70541,410 +70536,7 @@ ClockTilemapRLE: ; 915db INCBIN "gfx/unknown/0915db.tilemap.rle" ; 9163e -Function9163e: ; 9163e (24:563e) - jr UpdateRadioStation - -Function91640: ; 91640 (24:5640) - push bc - call Function9164e - pop bc - ld a, [wd958] - ld hl, $6 - add hl, bc - ld [hl], a - ret - -Function9164e: ; 9164e (24:564e) - ld hl, $ffa9 - ld a, [hl] - and D_DOWN - jr nz, .down - ld a, [hl] - and D_UP - jr nz, .up - ret - -.down - ld hl, wd958 - ld a, [hl] - and a - ret z -rept 2 - dec [hl] -endr - jr .update - -.up - ld hl, wd958 - ld a, [hl] - cp 80 - ret nc -rept 2 - inc [hl] -endr - -.update - -UpdateRadioStation: ; 9166f (24:566f) - ld hl, wd958 - ld d, [hl] - ld hl, RadioChannels -.asm_91676 - ld a, [hli] - cp $ff - jr z, .asm_91682 - cp d - jr z, .asm_91686 -rept 2 - inc hl -endr - jr .asm_91676 - -.asm_91682 - call NoRadioStation - ret - -.asm_91686 - ld a, [hli] - ld h, [hl] - ld l, a - ld de, .asm_9168e - push de - jp [hl] -.asm_9168e - ld a, [wc6d9] - and a - ret z - xor a - ld [hBGMapMode], a - hlcoord 2, 9 - call PlaceString - ld a, $1 - ld [hBGMapMode], a - ret -; 916a1 (24:56a1) - -Function916a1: ; 916a1 - ld [wc6d9], a - ld a, [hli] - ld [wc6da], a - ld a, [hli] - ld [wc6db], a - ret -; 916ad - - -RadioChannels: -; frequencies and the shows that play on them. -; frequency value given here = 4 × ingame_frequency − 2 - dbw 16, .PkmnTalkAndPokedexShow - dbw 28, .PokemonMusic - dbw 32, .LuckyChannel - dbw 40, .BuenasPassword - dbw 52, .RuinsOfAlphRadio - dbw 64, .PlacesAndPeople - dbw 72, .LetsAllSing - dbw 78, .PokeFluteRadio - dbw 80, .EvolutionRadio - db $ff - -.PkmnTalkAndPokedexShow -; Pokédex Show in the morning -; Oak's Pokémon Talk in the afternoon and evening - call .InJohto - jr nc, .NoSignal - ld a, [TimeOfDay] - and a - jp z, Function91766 - jp Function91753 - -.PokemonMusic - call .InJohto - jr nc, .NoSignal - jp Function9177b - -.LuckyChannel - call .InJohto - jr nc, .NoSignal - jp Function91790 - -.BuenasPassword - call .InJohto - jr nc, .NoSignal - jp Function917a5 - -.RuinsOfAlphRadio - ld a, [wc6d8] - cp RUINS_OF_ALPH - jr nz, .NoSignal - jp Function917d5 - -.PlacesAndPeople - call .InJohto - jr c, .NoSignal - ld a, [wPokegearFlags] - bit 3, a - jr z, .NoSignal - jp Function917ea - -.LetsAllSing - call .InJohto - jr c, .NoSignal - ld a, [wPokegearFlags] - bit 3, a - jr z, .NoSignal - jp Function917ff - -.PokeFluteRadio - call .InJohto - jr c, .NoSignal - ld a, [wPokegearFlags] - bit 3, a - jr z, .NoSignal - jp Function91829 - -.EvolutionRadio -; This station airs in the Lake of Rage area when Rocket are still in Mahogany. - - ld a, [StatusFlags] - bit 4, a - jr z, .NoSignal - - ld a, [wc6d8] - cp MAHOGANY_TOWN - jr z, .ok - cp ROUTE_43 - jr z, .ok - cp LAKE_OF_RAGE - jr nz, .NoSignal -.ok - jp Function9183e - -.NoSignal - call NoRadioStation - ret - -.InJohto -; if in Johto or on the S.S. Aqua, set carry -; otherwise clear carry - ld a, [wc6d8] - cp FAST_SHIP - jr z, .johto - cp KANTO_LANDMARK - jr c, .johto -.kanto - and a - ret -.johto - scf - ret - - - -Function91753: ; 91753 (24:5753) - xor a ; OAKS_POKEMON_TALK - ld [wd002], a - ld [wd005], a - ld a, BANK(PlayRadioShow) - ld hl, PlayRadioShow - call Function9187c - ld de, OaksPkmnTalkName - ret - -Function91766: ; 91766 (24:5766) - ld a, POKEDEX_SHOW - ld [wd002], a - xor a - ld [wd005], a - ld a, BANK(PlayRadioShow) - ld hl, PlayRadioShow - call Function9187c - ld de, PokedexShowName - ret - -Function9177b: ; 9177b (24:577b) - ld a, POKEMON_MUSIC - ld [wd002], a - xor a - ld [wd005], a - ld a, BANK(PlayRadioShow) - ld hl, PlayRadioShow - call Function9187c - ld de, PokemonMusicName - ret - -Function91790: ; 91790 (24:5790) - ld a, LUCKY_CHANNEL - ld [wd002], a - xor a - ld [wd005], a - ld a, BANK(PlayRadioShow) - ld hl, PlayRadioShow - call Function9187c - ld de, LuckyChannelName - ret - -Function917a5: ; 917a5 (24:57a5) - ld a, BUENAS_PASSWORD - ld [wd002], a - xor a - ld [wd005], a - ld a, BANK(PlayRadioShow) - ld hl, PlayRadioShow - call Function9187c - ld de, NotBuenasPasswordName - ld a, [StatusFlags2] - bit 0, a - ret z - ld de, BuenasPasswordName - ret -; 917c3 (24:57c3) - -BuenasPasswordName: db "BUENA'S PASSWORD@" -NotBuenasPasswordName: db "@" - -Function917d5: ; 917d5 (24:57d5) - ld a, UNOWN_RADIO - ld [wd002], a - xor a - ld [wd005], a - ld a, BANK(PlayRadioShow) - ld hl, PlayRadioShow - call Function9187c - ld de, UnknownStationName - ret - -Function917ea: ; 917ea (24:57ea) - ld a, PLACES_AND_PEOPLE - ld [wd002], a - xor a - ld [wd005], a - ld a, BANK(PlayRadioShow) - ld hl, PlayRadioShow - call Function9187c - ld de, PlacesAndPeopleName - ret - -Function917ff: ; 917ff (24:57ff) - ld a, LETS_ALL_SING - ld [wd002], a - xor a - ld [wd005], a - ld a, BANK(PlayRadioShow) - ld hl, PlayRadioShow - call Function9187c - ld de, LetsAllSingName - ret -; 91814 (24:5814) - -Function91814: ; 91814 - ld a, ROCKET_RADIO - ld [wd002], a - xor a - ld [wd005], a - ld a, BANK(PlayRadioShow) - ld hl, PlayRadioShow - call Function9187c - ld de, LetsAllSingName - ret -; 91829 - -Function91829: ; 91829 (24:5829) - ld a, POKE_FLUTE_RADIO - ld [wd002], a - xor a - ld [wd005], a - ld a, BANK(PlayRadioShow) - ld hl, PlayRadioShow - call Function9187c - ld de, PokeFluteStationName - ret - -Function9183e: ; 9183e (24:583e) - ld a, EVOLUTION_RADIO - ld [wd002], a - xor a - ld [wd005], a - ld a, BANK(PlayRadioShow) - ld hl, PlayRadioShow - call Function9187c - ld de, UnknownStationName - ret -; 91853 (24:5853) - -Function91853: ; 91853 - ret - -RadioMusicNone: ; 91854 (24:5854) - push de - ld a, e - ld [wc6dc], a - ld de, MUSIC_NONE - call PlayMusic - pop de - ld a, e - ld [wMapMusic], a - call PlayMusic - ret - -Function91868: ; 91868 (24:5868) - push de - ld a, $fe - ld [wc6dc], a - ld de, MUSIC_NONE - call PlayMusic - pop de - ld de, MUSIC_POKEMON_CHANNEL - call PlayMusic - ret - -Function9187c: ; 9187c (24:587c) - ld [wc6d9], a - ld a, l - ld [wc6da], a - ld a, h - ld [wc6db], a - ret - -NoRadioStation: ; 91888 (24:5888) - call NoRadioMusic - call NoRadioName - xor a - ld [wc6d9], a - ld [wc6da], a - ld [wc6db], a - ld a, $1 - ld [hBGMapMode], a ; $ff00+$d4 - ret - -NoRadioMusic: ; 9189d (24:589d) - ld de, MUSIC_NONE - call PlayMusic - ld a, $ff - ld [wc6dc], a - ret - -NoRadioName: ; 918a9 (24:58a9) - xor a - ld [hBGMapMode], a ; $ff00+$d4 - hlcoord 1, 8 - ld bc, $312 - call ClearBox - hlcoord 0, 12 - ld bc, $412 - call TextBox - ret -; 918bf - -OaksPkmnTalkName: db "OAK's ", $e1, $e2, " Talk@" -PokedexShowName: db "#DEX Show@" -PokemonMusicName: db "#MON Music@" -LuckyChannelName: db "Lucky Channel@" -UnknownStationName: db "?????@" -PlacesAndPeopleName: db "Places & People@" -LetsAllSingName: db "Let's All Sing!@" -PokeFluteStationName: db "# FLUTE@" -; 9191c +INCLUDE "engine/radio2.asm" Function9191c: ; 9191c ld hl, Options @@ -71181,14 +70773,14 @@ endr .StationPointers: ; 91ab9 dw Function91acb - dw Function91753 - dw Function91766 - dw Function9177b - dw Function91790 - dw Function917d5 - dw Function917ea - dw Function917ff - dw Function91814 + dw LoadStation_OaksPokemonTalk + dw LoadStation_PokedexShow + dw LoadStation_PokemonMusic + dw LoadStation_LuckyChannel + dw LoadStation_UnownRadio + dw LoadStation_PlacesAndPeople + dw LoadStation_LetsAllSing + dw LoadStation_RocketRadio ; 91acb Function91acb: ; 91acb @@ -71198,11 +70790,11 @@ Function91acb: ; 91acb call UpdateTime ld a, [TimeOfDay] and a - jp z, Function91766 - jp Function91753 + jp z, LoadStation_PokedexShow + jp LoadStation_OaksPokemonTalk .kanto - jp Function917ea + jp LoadStation_PlacesAndPeople ; 91ae1 Function91ae1: ; 91ae1 @@ -74428,11 +74020,14 @@ SECTION "bank2E", ROMX, BANK[$2E] ReturnFromMapSetupScript:: ; b8000 xor a ld [hBGMapMode], a - callba Functionb800a + ; For some reson, GameFreak chose to use a callba here instead of just falling through. + ; No other function in the game references the function at 2E:400A, here labeled + ; ReturnFromMapSetupScript.inefficientcallba. + callba .inefficientcallba ; this is a waste of 6 ROM bytes and 2 stack bytes ret ; b800a -Functionb800a: ; b800a +.inefficientcallba: ; b800a ld a, [MapGroup] ld b, a ld a, [MapNumber] @@ -74447,7 +74042,7 @@ Functionb800a: ; b800a jr nz, .asm_b8029 .asm_b8024 - ld a, $ff + ld a, -1 ld [wc2d9], a .asm_b8029 @@ -79976,7 +79571,7 @@ Functione23e9: ; e23e9 (38:63e9) call ClearSprites call Functione2d30 call Functione2a8e - ld de, String_e34dd + ld de, PCString_ChooseaPKMN call Functione2a6e ld a, $5 ld [wcb2d], a @@ -80041,7 +79636,7 @@ Functione245d: ; e245d (38:645d) ld [CurPartySpecies], a ld a, $17 call Functione33d0 - ld de, String_e34ea + ld de, PCString_WhatsUp call Functione2a6e ld a, $1 ld [wcfa9], a @@ -80088,7 +79683,7 @@ BillsPCDepositFuncDeposit: ; e24a9 (38:64a9) ld [wcb2a], a ret .asm_e24c1 - ld de, String_e34ea + ld de, PCString_WhatsUp call Functione2a6e ret @@ -80110,7 +79705,7 @@ BillsPCDepositFuncRelease: ; e24e0 (38:64e0) jr c, BillsPCDepositFuncCancel ld a, [wcfa9] push af - ld de, String_e34f4 + ld de, PCString_ReleasePKMN call Functione2a6e call Function1d6e lb bc, 14, 11 @@ -80136,7 +79731,7 @@ BillsPCDepositFuncRelease: ; e24e0 (38:64e0) pop af ret .asm_e252c - ld de, String_e34ea + ld de, PCString_WhatsUp call Functione2a6e pop af ld [wcfa9], a @@ -80220,15 +79815,15 @@ Functione2583: ; e2583 (38:6583) Functione25c8: ; e25c8 (38:65c8) ld a, [wcf63] - ld hl, Jumptable_e25d2 + ld hl, .jumptable call Functione33df jp [hl] -Jumptable_e25d2: ; e25d2 (38:65d2) +.jumptable: ; e25d2 (38:65d2) dw Functione25dc dw Functione2612 dw Functione2655 - dw Functione2675 + dw BillsPC_Withdraw dw Functione2992 @@ -80240,7 +79835,7 @@ Functione25dc: ; e25dc (38:65dc) call ClearSprites call Functione2d30 call Functione2a8e - ld de, String_e34dd + ld de, PCString_ChooseaPKMN call Functione2a6e ld a, $5 ld [wcb2d], a @@ -80306,26 +79901,26 @@ Functione2655: ; e2655 (38:6655) ld [CurPartySpecies], a ld a, $17 call Functione33d0 - ld de, String_e34ea + ld de, PCString_WhatsUp call Functione2a6e ld a, $1 ld [wcfa9], a call Functione298d ret -Functione2675: ; e2675 (38:6675) - ld hl, BillsPCWithdrawMenuDataHeader +BillsPC_Withdraw: ; e2675 (38:6675) + ld hl, .MenuDataHeader call CopyMenuDataHeader ld a, [wcfa9] call Function1d4b call InterpretMenu2 - jp c, BillsPCWithdrawFuncCancel + jp c, .cancel ld a, [wcfa9] dec a and 3 ld e, a ld d, 0 - ld hl, BillsPCWithdrawJumptable + ld hl, .jumptable rept 2 add hl, de endr @@ -80334,30 +79929,30 @@ endr ld l, a jp [hl] -BillsPCWithdrawJumptable: ; e2699 (38:6699) #mark - dw BillsPCWithdrawFuncWithdraw ; Withdraw - dw BillsPCWithdrawFuncStats ; Stats - dw BillsPCWithdrawFuncRelease ; Release - dw BillsPCWithdrawFuncCancel ; Cancel +.jumptable: ; e2699 (38:6699) #mark + dw .withdraw ; Withdraw + dw .stats ; Stats + dw .release ; Release + dw .cancel ; Cancel -BillsPCWithdrawFuncWithdraw: ; e26a1 (38:66a1) +.withdraw: ; e26a1 (38:66a1) call Functione2f18 - jp c, BillsPCWithdrawFuncCancel - call Functione30fa - jr c, .asm_e26b9 + jp c, .cancel + call TryWithdrawPokemon + jr c, .FailedWithdraw ld a, $0 ld [wcf63], a xor a ld [wcb2b], a ld [wcb2a], a ret -.asm_e26b9 - ld de, String_e34ea +.FailedWithdraw + ld de, PCString_WhatsUp call Functione2a6e ret -BillsPCWithdrawFuncStats: ; e26c0 (38:66c0) +.stats: ; e26c0 (38:66c0) call Function1d6e call Functione2f7e call ExitMenu @@ -80368,12 +79963,12 @@ BillsPCWithdrawFuncStats: ; e26c0 (38:66c0) call Functione33d0 ret -BillsPCWithdrawFuncRelease: ; e26d8 (38:66d8) +.release: ; e26d8 (38:66d8) ld a, [wcfa9] push af call Functione2f5f - jr c, .asm_e2720 - ld de, String_e34f4 + jr c, .FailedRelease + ld de, PCString_ReleasePKMN call Functione2a6e call Function1d6e lb bc, 14, 11 @@ -80382,7 +79977,7 @@ BillsPCWithdrawFuncRelease: ; e26d8 (38:66d8) dec a call ExitMenu and a - jr nz, .asm_e2720 + jr nz, .FailedRelease ld a, [wcb2b] ld hl, wcb2a add [hl] @@ -80398,28 +79993,28 @@ BillsPCWithdrawFuncRelease: ; e26d8 (38:66d8) ld [wcb2a], a pop af ret -.asm_e2720 - ld de, String_e34ea +.FailedRelease + ld de, PCString_WhatsUp call Functione2a6e pop af ld [wcfa9], a ret -BillsPCWithdrawFuncCancel: ; e272b (38:672b) +.cancel: ; e272b (38:672b) ld a, $0 ld [wcf63], a ret ; e2731 (38:6731) -BillsPCWithdrawMenuDataHeader: ; 0xe2731 +.MenuDataHeader: ; 0xe2731 db $40 ; flags db 04, 09 ; start coords db 13, 19 ; end coords - dw BillsPCWithdrawMenuData + dw .MenuData db 1 ; default option ; 0xe2739 -BillsPCWithdrawMenuData: ; 0xe2739 +.MenuData: ; 0xe2739 db $80 ; flags db 4 ; items db "WITHDRAW@" @@ -80491,7 +80086,7 @@ Functione27ba: ; e27ba ld [hBGMapMode], a call ClearSprites call Functione2d30 - ld de, String_e34dd + ld de, PCString_ChooseaPKMN call Functione2a6e ld a, $5 ld [wcb2d], a @@ -80567,7 +80162,7 @@ Functione283d: ; e283d ld [CurPartySpecies], a ld a, $17 call Functione33d0 - ld de, String_e34ea + ld de, PCString_WhatsUp call Functione2a6e ld a, $1 ld [wcfa9], a @@ -80655,7 +80250,7 @@ Functione28df: ; e28df xor a ld [hBGMapMode], a call Functione2d30 - ld de, String_e3500 + ld de, PCString_MoveToWhere call Functione2a6e ld a, $5 ld [wcb2d], a @@ -80967,7 +80562,7 @@ Functione2a8e: ; e2a8e (38:6a8e) ; e2abd (38:6abd) String_e2abd: - db "PARTY ", $e1, $e2, "@" + db "PARTY @" ; e2ac6 PCMonInfo: ; e2ac6 (38:6ac6) @@ -81594,7 +81189,7 @@ Functione2ee5: ; e2ee5 ret .asm_e2f02 - ld de, String_e3521 + ld de, PCString_TheresNoRoom call Functione2a6e ld de, SFX_WRONG call WaitPlaySFX @@ -81608,31 +81203,31 @@ Functione2ee5: ; e2ee5 Functione2f18: ; e2f18 (38:6f18) ld a, [wcb2e] and a - jr nz, .asm_e2f3d + jr nz, .Okay ld a, [wcb2c] cp $3 - jr c, .asm_e2f49 + jr c, .ItsYourLastPokemon ld a, [wcb2b] ld hl, wcb2a add [hl] ld [CurPartyMon], a callba Functione538 - jr c, .asm_e2f44 + jr c, .AllOthersFainted ld a, [wcb32] and a - jr nz, .asm_e2f3f -.asm_e2f3d + jr nz, .HasMail +.Okay and a ret -.asm_e2f3f - ld de, String_e3544 - jr .asm_e2f4c -.asm_e2f44 - ld de, String_e3531 - jr .asm_e2f4c -.asm_e2f49 - ld de, String_e350f -.asm_e2f4c +.HasMail + ld de, PCString_RemoveMail + jr .NotOkay +.AllOthersFainted + ld de, PCString_NoMoreUsablePKMN + jr .NotOkay +.ItsYourLastPokemon + ld de, PCString_ItsYourLastPKMN +.NotOkay call Functione2a6e ld de, SFX_WRONG call WaitPlaySFX @@ -81649,7 +81244,7 @@ Functione2f5f: ; e2f5f (38:6f5f) and a ret .asm_e2f68 - ld de, String_e3597 + ld de, PCString_NoReleasingEGGS call Functione2a6e ld de, SFX_WRONG call WaitPlaySFX @@ -81799,7 +81394,7 @@ Functione307c: ; e307c (38:707c) call TextBox call WaitBGMap hlcoord 1, 16 - ld de, String_e3563 + ld de, PCString_Stored call PlaceString ld l, c ld h, b @@ -81812,7 +81407,7 @@ Functione307c: ; e307c (38:707c) and a ret .asm_e30e4 - ld de, String_e3575 + ld de, PCString_BoxFull call Functione2a6e ld de, SFX_WRONG call WaitPlaySFX @@ -81822,7 +81417,7 @@ Functione307c: ; e307c (38:707c) scf ret -Functione30fa: ; e30fa (38:70fa) +TryWithdrawPokemon: ; e30fa (38:70fa) ld a, [wcb2b] ld hl, wcb2a add [hl] @@ -81836,7 +81431,7 @@ Functione30fa: ; e30fa (38:70fa) xor a ld [wd10b], a predef Functiondb3f - jr c, .asm_e316a + jr c, .PartyFull ld a, $1 ld [wd10b], a callba Functione039 @@ -81853,7 +81448,7 @@ Functione30fa: ; e30fa (38:70fa) call TextBox call WaitBGMap hlcoord 1, 16 - ld de, String_e356b + ld de, PCString_Got call PlaceString ld l, c ld h, b @@ -81865,8 +81460,8 @@ Functione30fa: ; e30fa (38:70fa) call DelayFrames and a ret -.asm_e316a - ld de, String_e3586 +.PartyFull + ld de, PCString_PartyFull call Functione2a6e ld de, SFX_WRONG call WaitPlaySFX @@ -81900,7 +81495,7 @@ Functione3180: ; e3180 (38:7180) ld [wd265], a call GetPokemonName hlcoord 1, 16 - ld de, String_e3551 + ld de, PCString_ReleasedPKMN call PlaceString ld c, 80 call DelayFrames @@ -81908,7 +81503,7 @@ Functione3180: ; e3180 (38:7180) ld bc, $112 call TextBox hlcoord 1, 16 - ld de, String_e355e + ld de, PCString_Bye call PlaceString ld l, c ld h, b @@ -82234,22 +81829,22 @@ PCSelectLZ: INCBIN "gfx/pc.2bpp.lz" PCMailGFX: INCBIN "gfx/pc_mail.2bpp" ; e34dd -String_e34dd: db "Choose a ", $e1, $e2, ".@" -String_e34ea: db "What's up?@" -String_e34f4: db "Release ", $e1, $e2, "?@" -String_e3500: db "Move to where?@" -String_e350f: db "It's your last ", $e1, $e2, "!@" -String_e3521: db "There's no room!@" -String_e3531: db "No more usable ", $e1, $e2, "!@" -String_e3544: db "Remove MAIL.@" -String_e3551: db "Released ", $e1, $e2, ".@" -String_e355e: db "Bye,@" -String_e3563: db "Stored @" -String_e356b: db "Got @" -String_e3570: db "Non.@" -String_e3575: db "The BOX is full.@" -String_e3586: db "The party's full!@" -String_e3597: db "No releasing EGGS!@" +PCString_ChooseaPKMN: db "Choose a .@" +PCString_WhatsUp: db "What's up?@" +PCString_ReleasePKMN: db "Release ?@" +PCString_MoveToWhere: db "Move to where?@" +PCString_ItsYourLastPKMN: db "It's your last !@" +PCString_TheresNoRoom: db "There's no room!@" +PCString_NoMoreUsablePKMN: db "No more usable !@" +PCString_RemoveMail: db "Remove MAIL.@" +PCString_ReleasedPKMN: db "Released .@" +PCString_Bye: db "Bye,@" +PCString_Stored: db "Stored @" +PCString_Got: db "Got @" +PCString_Non: db "Non.@" +PCString_BoxFull: db "The BOX is full.@" +PCString_PartyFull: db "The party's full!@" +PCString_NoReleasingEGGS: db "No releasing EGGS!@" ; e35aa Functione35aa: ; e35aa (38:75aa) diff --git a/wram.asm b/wram.asm index 88343cd1a..4913ddbe1 100644 --- a/wram.asm +++ b/wram.asm @@ -2150,7 +2150,7 @@ PCItemsEnd:: ds 1 wPokegearFlags:: ds 1 -wd958:: ds 1 +wRadioTuningKnob:: ds 1 wd959:: ds 2 WhichRegisteredItem:: ; d95b ds 1 From d42330ed8b591db79c43ef680edc5965d6a7b14b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 10 Oct 2015 17:03:04 -0400 Subject: [PATCH 04/11] Annotation of PrintNum arguments in bc, and radio functions --- battle/core.asm | 18 +- constants/misc_constants.asm | 3 + engine/diploma.asm | 4 +- engine/engine_flags.asm | 2 +- engine/pokedex.asm | 2 +- engine/radio.asm | 32 +-- engine/scripting.asm | 6 +- engine/specials.asm | 14 +- engine/time.asm | 22 +- event/poke_seer.asm | 2 +- hram.asm | 7 + main.asm | 439 ++++++++++++++++++----------------- maps/RadioTower1F.asm | 18 +- misc/mobile_40.asm | 4 +- misc/mobile_42.asm | 4 +- misc/mobile_45.asm | 4 +- misc/mobile_5f.asm | 2 +- sram.asm | 5 +- wram.asm | 20 +- 19 files changed, 315 insertions(+), 293 deletions(-) diff --git a/battle/core.asm b/battle/core.asm index e5679f16d..d8249bc98 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -5966,7 +5966,7 @@ Function3e75f: ; 3e75f .ok push hl ld de, StringBuffer1 - ld bc, $0102 + lb bc, 1, 2 call PrintNum pop hl rept 2 @@ -5974,8 +5974,8 @@ rept 2 endr ld [hl], "/" inc hl - ld de, wd265 - ld bc, $0102 + ld de, wNamedObjectIndexBuffer + lb bc, 1, 2 call PrintNum ret ; 3e786 @@ -8892,20 +8892,20 @@ Function3f85f: ; 3f85f add hl, de push hl ld de, wd00d - ld bc, $0204 + lb bc, 2, 4 call PrintNum pop hl ld de, $0005 add hl, de push hl ld de, wd00f - ld bc, $0204 + lb bc, 2, 4 call PrintNum pop hl ld de, $0005 add hl, de ld de, wd011 - ld bc, $0204 + lb bc, 2, 4 call PrintNum jr .asm_3f8cf @@ -8945,21 +8945,21 @@ Function3f85f: ; 3f85f call .asm_3f92b jr c, .asm_3f92a - ld bc, $0204 + lb bc, 2, 4 call PrintNum hlcoord 11, 4 ld de, sLinkBattleLosses call .asm_3f92b - ld bc, $0204 + lb bc, 2, 4 call PrintNum hlcoord 16, 4 ld de, sLinkBattleDraws call .asm_3f92b - ld bc, $0204 + lb bc, 2, 4 call PrintNum .asm_3f92a diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 13adacc8e..0306deb1e 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -116,3 +116,6 @@ BATTLETOWER_NROFTRAINERS EQU 7 NUM_WILDMONS_PER_AREA_TIME_OF_DAY EQU 7 WILDMON_GRASS_STRUCTURE_LENGTH EQU 2 + 3 * (1 + 2 * NUM_WILDMONS_PER_AREA_TIME_OF_DAY) +PRINTNUM_MONEY EQU %00100000 +PRINTNUM_RIGHTALIGN EQU %01000000 +PRINTNUM_LEADINGZEROS EQU %10000000 diff --git a/engine/diploma.asm b/engine/diploma.asm index 420bff7f1..f56e4ec00 100644 --- a/engine/diploma.asm +++ b/engine/diploma.asm @@ -70,12 +70,12 @@ Function1dd7ae: ; 1dd7ae call PlaceString hlcoord 12, 15 ld de, GameTimeHours - ld bc, $0204 + lb bc, 2, 4 call PrintNum ld [hl], $67 inc hl ld de, GameTimeMinutes - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ret ; 1dd7f0 diff --git a/engine/engine_flags.asm b/engine/engine_flags.asm index ff7948708..278c7c996 100644 --- a/engine/engine_flags.asm +++ b/engine/engine_flags.asm @@ -97,7 +97,7 @@ dwb VisitedSpawns + 3, %00000100 ; silver cave dwb VisitedSpawns + 3, %00010000 ; unused - dwb wdc9d, %00000001 ; lucky number show + dwb wLuckyNumberShowFlag, %00000001 ; lucky number show dwb StatusFlags2, %00001000 dwb DailyFlags, %00000001 ; kurt making balls ; $50 diff --git a/engine/pokedex.asm b/engine/pokedex.asm index 066653777..31a21cff0 100644 --- a/engine/pokedex.asm +++ b/engine/pokedex.asm @@ -1541,7 +1541,7 @@ Function40b6a: ; 40b6a (10:4b6a) ld de, -20 add hl, de ld de, wd265 - ld bc, $8103 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum pop hl ret diff --git a/engine/radio.asm b/engine/radio.asm index 8e96239de..4ebd0e1e8 100644 --- a/engine/radio.asm +++ b/engine/radio.asm @@ -147,12 +147,12 @@ PrintRadioLine: ; b86ea (2e:46ea) .skip ld a, RADIO_SCROLL ld [wd002], a - ld a, $64 + ld a, 100 ld [wd004], a ret ; b8718 (2e:4718) -Functionb8718: ; b8718 +ReplacePeriodsWithSpaces: ; b8718 push hl ld b, SCREEN_WIDTH * 2 .loop @@ -379,7 +379,7 @@ OaksPkmnTalk8: ; b8854 (2e:4854) and $f ld e, a ld d, 0 - ld hl, .descriptors + ld hl, .Descriptors rept 2 add hl, de endr @@ -390,7 +390,7 @@ endr jp NextRadioLine ; b8869 (2e:4869) -.descriptors: ; b8869 +.Descriptors: ; b8869 dw .sweetadorably dw .wigglyslickly dw .aptlynamed @@ -510,7 +510,7 @@ OaksPkmnTalk9: ; b88d9 (2e:48d9) and $f ld e, a ld d, 0 - ld hl, .descriptors + ld hl, .Descriptors rept 2 add hl, de endr @@ -529,7 +529,7 @@ endr jp NextRadioLine ; b88fe (2e:48fe) -.descriptors: ; b88fe +.Descriptors: ; b88fe dw .cute dw .weird dw .pleasant @@ -653,7 +653,7 @@ OaksPkmnTalk10: ; b896e (2e:496e) call PrintText ld a, OAKS_POKEMON_TALK_11 ld [wd002], a - ld a, $64 + ld a, 100 ld [wd004], a ret ; b898e (2e:498e) @@ -1058,10 +1058,10 @@ UnknownText_0xb8bd7: ; 0xb8bd7 LuckyNumberShow1: ; b8bdc (2e:4bdc) call StartRadioStation - callab Functionc434 - jr nc, .asm_b8bed - callab Functionc422 -.asm_b8bed + callab Special_CheckLuckyNumberShowFlag + jr nc, .dontreset + callab Special_ResetLuckyNumberShowFlag +.dontreset ld hl, UnknownText_0xb8c7e ld a, LUCKY_NUMBER_SHOW_2 jp NextRadioLine @@ -1098,8 +1098,8 @@ LuckyNumberShow7: ; b8c1d (2e:4c1d) LuckyNumberShow8: ; b8c25 (2e:4c25) ld hl, StringBuffer1 - ld de, wdc9f - ld bc, $8205 + ld de, wLuckyIDNumber + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum ld a, "@" ld [StringBuffer1 + 5], a @@ -1275,7 +1275,7 @@ PeoplePlaces4: ; People push af ld hl, .E4Names ld a, [StatusFlags] - bit 6, a + bit 6, a ; ENGINE_CREDITS_SKIP jr z, .ok ld hl, .KantoLeaderNames ld a, [KantoBadges] @@ -1498,7 +1498,7 @@ PeoplePlaces7: ; b8e28 (2e:4e28) and $f ld e, a ld d, 0 - ld hl, .descriptors + ld hl, .Descriptors rept 2 add hl, de endr @@ -1519,7 +1519,7 @@ endr jp PrintRadioLine ; b8e52 (2e:4e52) -.descriptors: ; b8e52 +.Descriptors: ; b8e52 dw PnP_cute dw PnP_lazy dw PnP_happy diff --git a/engine/scripting.asm b/engine/scripting.asm index bc5a0e790..f8ac4cc0c 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -2232,7 +2232,7 @@ Script_readmoney: ; 0x97732 call ResetStringBuffer1 call GetMoneyAccount ld hl, StringBuffer1 - ld bc, $4306 + lb bc, PRINTNUM_RIGHTALIGN | 3, 6 call PrintNum ld de, StringBuffer1 jp ConvertMemToText @@ -2246,7 +2246,7 @@ Script_readcoins: ; 0x97747 call ResetStringBuffer1 ld hl, StringBuffer1 ld de, Coins - ld bc, $4206 + lb bc, PRINTNUM_RIGHTALIGN | 2, 6 call PrintNum ld de, StringBuffer1 jp ConvertMemToText @@ -2260,7 +2260,7 @@ Script_RAM2MEM: ; 0x9775c call ResetStringBuffer1 ld de, ScriptVar ld hl, StringBuffer1 - ld bc, $4103 + lb bc, PRINTNUM_RIGHTALIGN | 1, 3 call PrintNum ld de, StringBuffer1 jp ConvertMemToText diff --git a/engine/specials.asm b/engine/specials.asm index 58cf5d646..5db616f61 100644 --- a/engine/specials.asm +++ b/engine/specials.asm @@ -102,9 +102,9 @@ SpecialsPointers:: ; c029 add_special Function24b25 add_special Function24b4e add_special Function24ae8 - add_special Function4d87a - add_special Functionc434 - add_special Functionc422 + add_special Special_CheckForLuckyNumberWinners + add_special Special_CheckLuckyNumberShowFlag + add_special Special_ResetLuckyNumberShowFlag add_special Function4d9d3 add_special Function88018 add_special SpecialNameRater @@ -522,15 +522,15 @@ SpecialCheckPokerus: ; c419 jp ScriptReturnCarry ; c422 -Functionc422: ; c422 +Special_ResetLuckyNumberShowFlag: ; c422 callba Function1152b - ld hl, wdc9d + ld hl, wLuckyNumberShowFlag res 0, [hl] - callba Function5d33 + callba LoadOrRegenerateLuckyIDNumber ret ; c434 -Functionc434: ; c434 +Special_CheckLuckyNumberShowFlag: ; c434 callba Function11542 jp ScriptReturnCarry ; c43d diff --git a/engine/time.asm b/engine/time.asm index d47c4fbaa..8b3f5d758 100755 --- a/engine/time.asm +++ b/engine/time.asm @@ -5,7 +5,7 @@ Function113d6: ; 113d6 Function113da: ; 113da xor a - ld [wdc2d], a + ld [wLuckyNumberDayBuffer], a ld [wdc3a], a ld [wdc1c], a ret @@ -242,28 +242,28 @@ Function11522: ; 11522 ; 1152b Function1152b: ; 1152b - call Function11534 - ld hl, wdc2d + call .GetDaysUntilNextFriday + ld hl, wLuckyNumberDayBuffer jp Function11415 ; 11534 -Function11534: ; 11534 +.GetDaysUntilNextFriday: ; 11534 call GetWeekday ld c, a - ld a, $5 + ld a, FRIDAY sub c - jr z, .asm_1153f - jr nc, .asm_11541 + jr z, .friday_saturday + jr nc, .earlier ; should've done "ret nc" -.asm_1153f - add $7 +.friday_saturday + add 7 -.asm_11541 +.earlier ret ; 11542 Function11542: ; 11542 - ld hl, wdc2d + ld hl, wLuckyNumberDayBuffer jp Function11420 ; 11548 diff --git a/event/poke_seer.asm b/event/poke_seer.asm index 3cb3806ca..cb1e23966 100644 --- a/event/poke_seer.asm +++ b/event/poke_seer.asm @@ -166,7 +166,7 @@ GetCaughtLevel: ; 4f18c ld [wd038 + 2], a ld hl, wd036 ld de, wd038 + 2 - ld bc, $4103 + lb bc, PRINTNUM_RIGHTALIGN | 1, 3 call PrintNum ret diff --git a/hram.asm b/hram.asm index 6d87614f6..10a96f4b8 100644 --- a/hram.asm +++ b/hram.asm @@ -44,6 +44,13 @@ hMultiplicand EQU $ffb4 ; 3 bytes long hMultiplier EQU $ffb7 ; 1 byte long hProduct EQU $ffb3 ; result (4 bytes long) +hPrintNum1 EQU $ffb3 +hPrintNum2 EQU $ffb4 +hPrintNum3 EQU $ffb5 +hPrintNum4 EQU $ffb6 +hPrintNum5 EQU $ffb7 +hPrintNum6 EQU $ffb8 +hPrintNum7 EQU $ffb9 hMathBuffer EQU $ffb8 hMoneyTemp EQU $ffc3 diff --git a/main.asm b/main.asm index 6b7700fef..3c68df818 100644 --- a/main.asm +++ b/main.asm @@ -248,7 +248,7 @@ _ResetWRAM: ; 5bae ld [hl], a call CloseSRAM - call Function5d33 + call LoadOrRegenerateLuckyIDNumber call InitializeRalphName xor a @@ -384,30 +384,30 @@ InitializeWorld: ; 5d23 ret ; 5d33 -Function5d33: ; 5d33 - ld a, BANK(s0_ac68) +LoadOrRegenerateLuckyIDNumber: ; 5d33 + ld a, BANK(sLuckyIDNumber) call GetSRAMBank ld a, [CurDay] inc a ld b, a - ld a, [s0_ac68] + ld a, [sLuckyNumberDay] cp b - ld a, [s0_ac6a] + ld a, [sLuckyIDNumber + 1] ld c, a - ld a, [s0_ac69] + ld a, [sLuckyIDNumber] jr z, .skip ld a, b - ld [s0_ac68], a + ld [sLuckyNumberDay], a call Random ld c, a call Random .skip - ld [wdc9f], a - ld [s0_ac69], a + ld [wLuckyIDNumber], a + ld [sLuckyIDNumber], a ld a, c - ld [wdca0], a - ld [s0_ac6a], a + ld [wLuckyIDNumber + 1], a + ld [sLuckyIDNumber + 1], a jp CloseSRAM ; 5d65 @@ -419,7 +419,7 @@ Continue: ; 5d65 call Function5e85 ld a, $1 ld [hBGMapMode], a - ld c, $14 + ld c, 20 call DelayFrames call ConfirmContinue jr nc, .Check1Pass @@ -4099,59 +4099,62 @@ INCLUDE "engine/specials.asm" _PrintNum:: ; c4c7 -; Print c digits of the b-byte value at hl. +; Print c digits of the b-byte value from de to hl. ; Allows 2 to 7 digits. For 1-digit numbers, add ; the value to char "0" instead of calling PrintNum. ; Some extra flags can be given in bits 5-7 of b. +; Bit 5: money if set (unless left-aligned without leading zeros) +; Bit 6: right-aligned if set +; Bit 7: print leading zeros if set push bc bit 5, b jr z, .main bit 7, b - jr nz, .bit_7 + jr nz, .moneyflag bit 6, b jr z, .main -.bit_7 - ld a, $f0 +.moneyflag ; 101xxxxx or 011xxxxx + ld a, "¥" ld [hli], a - res 5, b + res 5, b ; 100xxxxx or 010xxxxx .main xor a - ld [$ffb3], a - ld [$ffb4], a - ld [$ffb5], a + ld [hPrintNum1], a + ld [hPrintNum2], a + ld [hPrintNum3], a ld a, b and $f cp 1 jr z, .byte cp 2 jr z, .word - +; maximum 3 bytes .long ld a, [de] - ld [$ffb4], a + ld [hPrintNum2], a inc de ld a, [de] - ld [$ffb5], a + ld [hPrintNum3], a inc de ld a, [de] - ld [$ffb6], a + ld [hPrintNum4], a jr .start .word ld a, [de] - ld [$ffb5], a + ld [hPrintNum3], a inc de ld a, [de] - ld [$ffb6], a + ld [hPrintNum4], a jr .start .byte ld a, [de] - ld [$ffb6], a + ld [hPrintNum4], a .start push de @@ -4178,51 +4181,51 @@ _PrintNum:: ; c4c7 .seven ld a, 1000000 / $10000 % $100 - ld [$ffb7], a + ld [hPrintNum5], a ld a, 1000000 / $100 % $100 - ld [$ffb8], a + ld [hPrintNum6], a ld a, 1000000 % $100 - ld [$ffb9], a + ld [hPrintNum7], a call .PrintDigit call .AdvancePointer .six ld a, 100000 / $10000 % $100 - ld [$ffb7], a + ld [hPrintNum5], a ld a, 100000 / $100 % $100 - ld [$ffb8], a + ld [hPrintNum6], a ld a, 100000 % $100 - ld [$ffb9], a + ld [hPrintNum7], a call .PrintDigit call .AdvancePointer .five xor a - ld [$ffb7], a + ld [hPrintNum5], a ld a, 10000 / $100 - ld [$ffb8], a + ld [hPrintNum6], a ld a, 10000 % $100 - ld [$ffb9], a + ld [hPrintNum7], a call .PrintDigit call .AdvancePointer .four xor a - ld [$ffb7], a + ld [hPrintNum5], a ld a, 1000 / $100 - ld [$ffb8], a + ld [hPrintNum6], a ld a, 1000 % $100 - ld [$ffb9], a + ld [hPrintNum7], a call .PrintDigit call .AdvancePointer .three xor a - ld [$ffb7], a + ld [hPrintNum5], a xor a - ld [$ffb8], a + ld [hPrintNum6], a ld a, 100 - ld [$ffb9], a + ld [hPrintNum7], a call .PrintDigit call .AdvancePointer @@ -4230,11 +4233,11 @@ _PrintNum:: ; c4c7 dec e jr nz, .two_skip ld a, "0" - ld [$ffb3], a + ld [hPrintNum1], a .two_skip ld c, 0 - ld a, [$ffb6] + ld a, [hPrintNum4] .mod_10 cp 10 jr c, .modded_10 @@ -4244,7 +4247,7 @@ _PrintNum:: ; c4c7 .modded_10 ld b, a - ld a, [$ffb3] + ld a, [hPrintNum1] or c jr nz, .money call .PrintLeadingZero @@ -4257,7 +4260,7 @@ _PrintNum:: ; c4c7 add c ld [hl], a pop af - ld [$ffb3], a + ld [hPrintNum1], a inc e dec e jr nz, .money_leading_zero @@ -4278,7 +4281,7 @@ _PrintNum:: ; c4c7 .PrintYen: ; c5ba push af - ld a, [$ffb3] + ld a, [hPrintNum1] and a jr nz, .stop bit 5, d @@ -4296,68 +4299,68 @@ _PrintNum:: ; c4c7 dec e jr nz, .ok ld a, "0" - ld [$ffb3], a + ld [hPrintNum1], a .ok ld c, 0 .loop - ld a, [$ffb7] + ld a, [hPrintNum5] ld b, a - ld a, [$ffb4] + ld a, [hPrintNum2] ld [$ffba], a cp b jr c, .skip1 sub b - ld [$ffb4], a - ld a, [$ffb8] + ld [hPrintNum2], a + ld a, [hPrintNum6] ld b, a - ld a, [$ffb5] + ld a, [hPrintNum3] ld [$ffbb], a cp b jr nc, .skip2 - ld a, [$ffb4] + ld a, [hPrintNum2] or 0 jr z, .skip3 dec a - ld [$ffb4], a - ld a, [$ffb5] + ld [hPrintNum2], a + ld a, [hPrintNum3] .skip2 sub b - ld [$ffb5], a - ld a, [$ffb9] + ld [hPrintNum3], a + ld a, [hPrintNum7] ld b, a - ld a, [$ffb6] + ld a, [hPrintNum4] ld [$ffbc], a cp b jr nc, .skip4 - ld a, [$ffb5] + ld a, [hPrintNum3] and a jr nz, .skip5 - ld a, [$ffb4] + ld a, [hPrintNum2] and a jr z, .skip6 dec a - ld [$ffb4], a + ld [hPrintNum2], a xor a .skip5 dec a - ld [$ffb5], a - ld a, [$ffb6] + ld [hPrintNum3], a + ld a, [hPrintNum4] .skip4 sub b - ld [$ffb6], a + ld [hPrintNum4], a inc c jr .loop .skip6 ld a, [$ffbb] - ld [$ffb5], a + ld [hPrintNum3], a .skip3 ld a, [$ffba] - ld [$ffb4], a + ld [hPrintNum2], a .skip1 - ld a, [$ffb3] + ld a, [hPrintNum1] or c jr z, .PrintLeadingZero - ld a, [$ffb3] + ld a, [hPrintNum1] and a jr nz, .done bit 5, d @@ -4369,7 +4372,7 @@ _PrintNum:: ; c4c7 ld a, "0" add c ld [hl], a - ld [$ffb3], a + ld [hPrintNum1], a inc e dec e ret nz @@ -4391,7 +4394,7 @@ _PrintNum:: ; c4c7 jr nz, .inc bit 6, d ; left alignment or right alignment? jr z, .inc - ld a, [$ffb3] + ld a, [hPrintNum1] and a ret z .inc @@ -7758,7 +7761,7 @@ endr ld a, [wd1ed] ld [StringBuffer2], a ld de, StringBuffer2 - ld bc, $0203 + lb bc, 2, 3 call PrintNum pop hl ret @@ -14262,7 +14265,7 @@ Function13256: ; 13256 jr c, .asm_132a7 ld [wd265], a ld de, wd265 - ld bc, $0103 + lb bc, 1, 3 call PrintNum jr .asm_132ad @@ -20100,28 +20103,28 @@ Function1651a: ; 1651a xor a ld [hBGMapMode], a hlcoord 0, 0 - ld bc, $0612 + lb bc, 6, 18 call TextBox hlcoord 1, 2 ld de, String_16699 call PlaceString hlcoord 12, 2 ld de, wd851 - ld bc, $2306 + lb bc, PRINTNUM_MONEY | 3, 6 call PrintNum hlcoord 1, 4 ld de, String_166b0 call PlaceString hlcoord 12, 4 ld de, Money - ld bc, $2306 + lb bc, PRINTNUM_MONEY | 3, 6 call PrintNum hlcoord 1, 6 pop de call PlaceString hlcoord 12, 6 ld de, StringBuffer2 - ld bc, $a306 + lb bc, PRINTNUM_MONEY | PRINTNUM_LEADINGZEROS | 3, 6 call PrintNum call UpdateSprites call Function3238 @@ -20129,7 +20132,7 @@ Function1651a: ; 1651a ; 1656b Function1656b: ; 1656b - ld c, $a + ld c, 10 call DelayFrames ret ; 16571 @@ -20153,7 +20156,7 @@ Function16571: ; 16571 call ByteFill hlcoord 12, 6 ld de, StringBuffer2 - ld bc, $a306 + lb bc, PRINTNUM_MONEY | PRINTNUM_LEADINGZEROS | 3, 6 call PrintNum ld a, [$ff9b] and $10 @@ -24523,7 +24526,7 @@ Function24ac3: ; 0x24ac3 ld [hl], $f1 inc hl ld de, wcf75 - ld bc, $0102 + lb bc, 1, 2 call PrintNum .done @@ -24551,7 +24554,7 @@ Function24b01: ; 24b01 ld de, $0015 add hl, de ld de, Money - ld bc, $2306 + lb bc, PRINTNUM_MONEY | 3, 6 call PrintNum ret ; 24b15 @@ -24584,7 +24587,7 @@ Function24b25: ; 24b25 ld de, String24b8e call PlaceString ld de, Coins - ld bc, $0204 + lb bc, 2, 4 hlcoord 13, 1 call PrintNum ret @@ -24600,14 +24603,14 @@ Function24b4e: ; 24b4e call PlaceString hlcoord 12, 1 ld de, Money - ld bc, $2306 + lb bc, PRINTNUM_MONEY | 3, 6 call PrintNum hlcoord 6, 3 ld de, CoinString call PlaceString hlcoord 15, 3 ld de, Coins - ld bc, $0204 + lb bc, 2, 4 call PrintNum ret ; 24b83 @@ -24631,7 +24634,7 @@ Function24b8f: ; 24b8f call TextBox hlcoord 1, 1 ld de, wdc7a - ld bc, $0203 + lb bc, 2, 3 call PrintNum hlcoord 4, 1 ld de, String24bcf @@ -24641,7 +24644,7 @@ Function24b8f: ; 24b8f call PlaceString hlcoord 5, 3 ld de, wdc79 - ld bc, $0102 + lb bc, 1, 2 call PrintNum pop af ld [Options], a @@ -24673,7 +24676,7 @@ Function24be7: ; 24be7 call PlaceString hlcoord 8, 5 ld de, wdc79 - ld bc, $4102 + lb bc, PRINTNUM_RIGHTALIGN | 1, 2 call PrintNum hlcoord 1, 1 ld de, String24c4b @@ -25211,7 +25214,7 @@ Strings24f5f: ; 24f5f Function24f7c: ; 24f7c hlcoord 17, 13 ld de, wdc79 - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ret ; 24f89 @@ -25243,7 +25246,7 @@ Strings24f9a: ; 24f9a Function24fb2: ; 24fb2 hlcoord 13, 16 ld de, wdc79 - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ret ; 24fbf @@ -25388,7 +25391,7 @@ Function25072: ; 25072 ld [hl], $f1 inc hl ld de, wd10c - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ld a, [wcf86] ld e, a @@ -25460,7 +25463,7 @@ Function250d1: ; 250d1 pop hl inc hl ld de, hMoneyTemp - ld bc, $2306 + lb bc, PRINTNUM_MONEY | 3, 6 call PrintNum call WaitBGMap ret @@ -25724,11 +25727,11 @@ Function25299: ; 25299 (9:5299) call PlaceString hlcoord 5, 4 ld de, PlayerID - ld bc, $8205 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum hlcoord 7, 6 ld de, Money - ld bc, $2306 + lb bc, PRINTNUM_MONEY | 3, 6 call PrintNum hlcoord 1, 3 ld de, Tilemap_252fc @@ -25928,7 +25931,7 @@ Function25415: ; 25415 (9:5415) call PrintNum inc hl ld de, GameTimeMinutes - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ld a, [$ff9b] and $1f @@ -26172,7 +26175,7 @@ ClearOakRatingBuffer: ; 0x2665a ld bc, $000d call ByteFill pop hl - ld bc, $4103 + lb bc, PRINTNUM_RIGHTALIGN | 1, 3 call PrintNum ret ; 0x2666b @@ -30964,7 +30967,7 @@ Function295d8: ; 295d8 Function295e3: ; 295e3 hlcoord 10, 0 - ld bc, $8103 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum ld [hl], $7f ret @@ -31002,7 +31005,7 @@ Unknown_2960e: ; 2960e Function29611: ; 29611 hlcoord 7, 6 - ld bc, $8205 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum ret ; 2961b @@ -34388,7 +34391,7 @@ Function2c9e2: ; 2c9e2 (b:49e2) cp $33 jr nc, .asm_2ca22 ld de, wd265 - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum jr .asm_2ca38 .asm_2ca22 @@ -34398,7 +34401,7 @@ Function2c9e2: ; 2c9e2 (b:49e2) ld [hl], $87 inc hl ld de, wd265 - ld bc, $4102 + lb bc, PRINTNUM_RIGHTALIGN | 1, 2 call PrintNum pop af ld [wd265], a @@ -36618,7 +36621,7 @@ Function4424d: ; 4424d ld a, $5d ld [hli], a ld de, wd265 - ld bc, $8103 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum ld a, [wd265] dec a @@ -36648,7 +36651,7 @@ endr ld d, h ld e, l hlcoord 12, 7 - ld bc, $0224 + lb bc, 2, 36 call PrintNum hlcoord 14, 7 ld [hl], $5e @@ -36672,7 +36675,7 @@ endr ld d, h ld e, l hlcoord 11, 9 - ld bc, $0245 + lb bc, 2, 69 call PrintNum pop de @@ -40729,7 +40732,7 @@ Function49e3d: ; 49e3d ld [hl], ":" inc hl ld de, hMinutes - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ret ; 49e70 @@ -44081,62 +44084,62 @@ CheckPokerus: ; 4d860 ret ; 4d87a -Function4d87a: ; 4d87a +Special_CheckForLuckyNumberWinners: ; 4d87a xor a ld [ScriptVar], a - ld [wd265], a + ld [wFoundMatchingIDInParty], a ld a, [PartyCount] and a ret z ld d, a ld hl, PartyMon1ID ld bc, PartySpecies -.asm_4d88d +.PartyLoop ld a, [bc] inc bc cp EGG - call nz, Function4d939 + call nz, .CompareLuckyNumberToMonID push bc ld bc, PartyMon2 - PartyMon1 add hl, bc pop bc dec d - jr nz, .asm_4d88d - ld a, BANK(sBoxMon1ID) + jr nz, .PartyLoop + ld a, BANK(sBox) call GetSRAMBank ld a, [sBoxCount] and a - jr z, .asm_4d8c8 + jr z, .SkipOpenBox ld d, a ld hl, sBoxMon1ID ld bc, sBoxSpecies -.asm_4d8af +.OpenBoxLoop ld a, [bc] inc bc cp EGG - jr z, .asm_4d8bf - call Function4d939 - jr nc, .asm_4d8bf - ld a, $1 - ld [wd265], a + jr z, .SkipOpenBoxMon + call .CompareLuckyNumberToMonID + jr nc, .SkipOpenBoxMon + ld a, 1 + ld [wFoundMatchingIDInParty], a -.asm_4d8bf +.SkipOpenBoxMon push bc - ld bc, sBoxMon2 - sBoxMon1 + ld bc, sBoxMon2 - sBoxMon1 ; box_struct_length add hl, bc pop bc dec d - jr nz, .asm_4d8af + jr nz, .OpenBoxLoop -.asm_4d8c8 +.SkipOpenBox call CloseSRAM ld c, $0 -.asm_4d8cd +.BoxesLoop ld a, [wCurBox] and $f cp c - jr z, .asm_4d90b - ld hl, Unknown_4d99f + jr z, .SkipBox + ld hl, .BoxBankAddresses ld b, 0 rept 3 add hl, bc @@ -44145,91 +44148,91 @@ endr call GetSRAMBank ld a, [hli] ld h, [hl] - ld l, a + ld l, a ; hl now contains the address of the loaded box in SRAM ld a, [hl] and a - jr z, .asm_4d90b + jr z, .SkipBox ; no mons in this box push bc ld b, h ld c, l inc bc - ld de, $001c + ld de, MONS_PER_BOX + NUM_MOVES + 4 add hl, de ld d, a -.asm_4d8f1 +.BoxNLoop ld a, [bc] inc bc cp EGG - jr z, .asm_4d901 + jr z, .SkipBoxMon - call Function4d939 - jr nc, .asm_4d901 - ld a, $1 - ld [wd265], a + call .CompareLuckyNumberToMonID + jr nc, .SkipBoxMon + ld a, 1 + ld [wFoundMatchingIDInParty], a -.asm_4d901 +.SkipBoxMon push bc - ld bc, sBoxMon2 - sBoxMon1 + ld bc, sBoxMon2 - sBoxMon1 ; box_struct_length add hl, bc pop bc dec d - jr nz, .asm_4d8f1 + jr nz, .BoxNLoop pop bc -.asm_4d90b +.SkipBox inc c ld a, c cp NUM_BOXES - jr c, .asm_4d8cd + jr c, .BoxesLoop call CloseSRAM ld a, [ScriptVar] and a - ret z + ret z ; found nothing callba Function1060cd - ld a, [wd265] + ld a, [wFoundMatchingIDInParty] and a push af ld a, [CurPartySpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName - ld hl, UnknownText_0x4d9c9 + ld hl, .FoundPartymonText pop af - jr z, .asm_4d936 - ld hl, UnknownText_0x4d9ce + jr z, .print + ld hl, .FoundBoxmonText -.asm_4d936 +.print jp PrintText ; 4d939 -Function4d939: ; 4d939 +.CompareLuckyNumberToMonID: ; 4d939 push bc push de push hl ld d, h ld e, l ld hl, Buffer1 - ld bc, $8205 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum - ld hl, DefaultFlypoint - ld de, wdc9f - ld bc, $8205 + ld hl, LuckyNumberDigit1Buffer + ld de, wLuckyIDNumber + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum - ld b, $5 - ld c, $0 - ld hl, EndFlypoint - ld de, wd1ee -.asm_4d95d + ld b, 5 + ld c, 0 + ld hl, LuckyNumberDigit5Buffer + ld de, Buffer5 +.loop ld a, [de] cp [hl] - jr nz, .asm_4d967 + jr nz, .done dec de dec hl inc c dec b - jr nz, .asm_4d95d + jr nz, .loop -.asm_4d967 +.done pop hl push hl ld de, -6 @@ -44239,25 +44242,25 @@ Function4d939: ; 4d939 pop de push af ld a, c - ld b, $1 - cp $5 - jr z, .asm_4d984 - ld b, $2 - cp $3 - jr nc, .asm_4d984 - ld b, $3 - cp $2 - jr nz, .asm_4d99b + ld b, 1 + cp 5 + jr z, .okay + ld b, 2 + cp 3 + jr nc, .okay + ld b, 3 + cp 2 + jr nz, .nomatch -.asm_4d984 +.okay inc b ld a, [ScriptVar] and a - jr z, .asm_4d98e + jr z, .foundmatch cp b - jr c, .asm_4d99b + jr c, .nomatch -.asm_4d98e +.foundmatch dec b ld a, b ld [ScriptVar], a @@ -44268,14 +44271,14 @@ Function4d939: ; 4d939 scf ret -.asm_4d99b +.nomatch pop bc pop bc and a ret ; 4d99f -Unknown_4d99f: ; 4d99f +.BoxBankAddresses: ; 4d99f dbw BANK(sBox1), sBox1 dbw BANK(sBox2), sBox2 dbw BANK(sBox3), sBox3 @@ -44292,13 +44295,13 @@ Unknown_4d99f: ; 4d99f dbw BANK(sBox14), sBox14 ; 4d9c9 -UnknownText_0x4d9c9: ; 0x4d9c9 +.FoundPartymonText: ; 0x4d9c9 ; Congratulations! We have a match with the ID number of @ in your party. text_jump UnknownText_0x1c1261 db "@" ; 0x4d9ce -UnknownText_0x4d9ce: ; 0x4d9ce +.FoundBoxmonText: ; 0x4d9ce ; Congratulations! We have a match with the ID number of @ in your PC BOX. text_jump UnknownText_0x1c12ae db "@" @@ -44306,10 +44309,10 @@ UnknownText_0x4d9ce: ; 0x4d9ce Function4d9d3: ; 4d9d3 ld hl, StringBuffer3 - ld de, wdc9f - ld bc, $8205 + ld de, wLuckyIDNumber + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum - ld a, $50 + ld a, "@" ld [StringBuffer3 + 5], a ret ; 4d9e5 @@ -44323,7 +44326,7 @@ CheckPartyFullAfterContest: ; 4d9e5 call GetBaseData ld hl, PartyCount ld a, [hl] - cp $6 + cp 6 jp nc, Function4daa3 inc a ld [hl], a @@ -45085,7 +45088,7 @@ Function4deea: ; 4deea (13:5eea) ld [hl], "." inc hl hlcoord 10, 0 - ld bc, $8103 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 ld de, wd265 call PrintNum hlcoord 14, 0 @@ -45459,7 +45462,7 @@ Function4e1cc: ; 4e1cc (13:61cc) hlcoord 0, 12 call PlaceString hlcoord 2, 10 - ld bc, $8205 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 ld de, TempMonID call PrintNum ld hl, Unknown_4e216 @@ -46911,7 +46914,7 @@ Function50138: ; 50138 ld d, h pop hl push de - ld bc, $0203 + lb bc, 2, 3 call PrintNum pop de ld a, $f3 @@ -46919,7 +46922,7 @@ Function50138: ; 50138 rept 2 inc de endr - ld bc, $0203 + lb bc, 2, 3 call PrintNum .asm_5016b @@ -46960,7 +46963,7 @@ Function50176: ; 50176 ld [hli], a ld bc, $4102 .asm_501a1 - ld bc, $4103 + lb bc, PRINTNUM_RIGHTALIGN | 1, 3 call PrintNum .asm_501a7 @@ -48372,7 +48375,7 @@ DrawHP: ; 50b10 jr nz, .asm_50b66 ld de, TempMonMaxHP .asm_50b66 - ld bc, $0203 + lb bc, 2, 3 call PrintNum ld a, "/" @@ -48380,7 +48383,7 @@ DrawHP: ; 50b10 ; Print max HP ld de, TempMonMaxHP - ld bc, $0203 + lb bc, 2, 3 call PrintNum pop hl pop de @@ -48608,12 +48611,12 @@ endr ld l, e push hl ld de, StringBuffer1 + 4 - ld bc, $0102 + lb bc, 1, 2 call PrintNum ld a, $f3 ld [hli], a ld de, wd265 - ld bc, $0102 + lb bc, 1, 2 call PrintNum pop hl ld a, [Buffer1] @@ -51365,7 +51368,7 @@ Function81adb: ; 81adb ld [wd265], a hlcoord 0, 1 ld de, wd265 - ld bc, $8103 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum ld a, [DefaultFlypoint] and a @@ -54388,7 +54391,7 @@ Function86692: ; 86692 call PlaceString hlcoord 2, 2 ld de, wc608 - ld bc, $0103 + lb bc, 1, 3 call PrintNum hlcoord 11, 2 @@ -54494,7 +54497,7 @@ Function86748: ; 86748 ld [hl], $f2 hlcoord 3, 13 ld de, wd265 - ld bc, $8103 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum call GetBasePokemonName hlcoord 7, 13 @@ -54528,7 +54531,7 @@ Function86748: ; 86748 ld [hl], $f3 hlcoord 10, 16 ld de, TempMonID - ld bc, $8205 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum ret ; 86810 @@ -54599,19 +54602,19 @@ Function86810: ; 86810 ld [hl], $f3 hlcoord 4, 6 ld de, PlayerID - ld bc, $8205 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum hlcoord 1, 8 ld de, .PlayTime call PlaceString hlcoord 3, 9 ld de, GameTimeHours - ld bc, $0203 + lb bc, 2, 3 call PrintNum ld [hl], $63 inc hl ld de, GameTimeMinutes - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum call WaitBGMap callba Function26601 @@ -54808,7 +54811,7 @@ Function88126: ; 88126 ld [hl], $f1 inc hl ld de, wd10c - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 jp PrintNum ; 88139 @@ -56679,7 +56682,7 @@ Function898aa: ; 898aa push bc hlcoord 6, 1 ld de, MenuSelection - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum pop bc ret @@ -56732,7 +56735,7 @@ Function898f3: ; 898f3 call Function8934a jr c, .asm_8990a hlcoord 5, 5 - ld bc, $8205 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum jr .asm_89913 @@ -56892,7 +56895,7 @@ Function899b2: ; 899b2 (22:59b2) Function899c9: ; 899c9 (22:59c9) ld de, PlayerID - ld bc, $8205 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum ret @@ -60272,7 +60275,7 @@ Function8b09e: ; 8b09e ld [hli], a ld [hld], a pop de - ld bc, $0102 + lb bc, 1, 2 call PrintNum ret ; 8b0ca @@ -61668,7 +61671,7 @@ Function8b880: ; 8b880 ld h, d ld l, e ld de, MenuSelection - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ret ; 8b88c @@ -68628,7 +68631,7 @@ Function90867: ; 90867 (24:4867) ld [hli], a ld [hl], a pop hl - ld bc, $4102 + lb bc, PRINTNUM_RIGHTALIGN | 1, 2 call PrintNum ret ; 90874 (24:4874) @@ -68701,7 +68704,7 @@ UnknownText_0x908b8: ; 0x908b8 ld [hl], ":" inc hl ld de, BattleMonNick + 5 - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ld b, h ld c, l @@ -69046,17 +69049,17 @@ UnknownText_0x90b13: ; 0x90b13 ; 0x90b23 Function90b23: ; 90b23 - ld bc, $0103 + lb bc, 1, 3 call PrintNum ld [hl], "." inc hl inc de - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ld [hl], ":" inc hl inc de - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ret ; 90b3e @@ -72012,11 +72015,11 @@ Function927d4: ; 927d4 Function927f8: ; 927f8 (24:67f8) hlcoord 5, 1 ld de, Coins - ld bc, $8204 + lb bc, PRINTNUM_LEADINGZEROS | 2, 4 call PrintNum hlcoord 11, 1 ld de, wc711 - ld bc, $8204 + lb bc, PRINTNUM_LEADINGZEROS | 2, 4 call PrintNum ret ; 92811 (24:6811) @@ -76102,7 +76105,7 @@ DisplayCaughtContestMonStats: ; cc000 hlcoord 11, 4 ld de, wContestMonMaxHP - ld bc, $0203 + lb bc, 2, 3 call PrintNum hlcoord 11, 10 @@ -76858,7 +76861,7 @@ Functione049c: ; e049c call PlaceString hlcoord 15, 16 ld de, Coins - ld bc, $8204 + lb bc, PRINTNUM_LEADINGZEROS | 2, 4 call PrintNum ret ; e04bc @@ -81940,7 +81943,7 @@ Functione3632: ; e3632 ld [wd265], a hlcoord 13, 11 ld de, wd265 - ld bc, $0102 + lb bc, 1, 2 call PrintNum ld de, String_e3668 call PlaceString @@ -86393,12 +86396,12 @@ Functionfbbdb: ; fbbdb call Functionfbbae ld hl, StringBuffer1 ld de, Buffer1 - ld bc, $4102 + lb bc, PRINTNUM_RIGHTALIGN | 1, 2 call PrintNum ld [hl], $6e inc hl ld de, Buffer2 - ld bc, $4102 + lb bc, PRINTNUM_RIGHTALIGN | 1, 2 call PrintNum ld [hl], $6f inc hl @@ -92030,7 +92033,7 @@ Function1dc381: ; 1dc381 ld [hl], $71 inc hl ld de, TempMonMaxHP - ld bc, $0203 + lb bc, 2, 3 call PrintNum ld a, [CurPartySpecies] ld [wd265], a @@ -92050,7 +92053,7 @@ Function1dc381: ; 1dc381 ld [hl], $e8 inc hl ld de, wd265 - ld bc, $8103 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum hlcoord 1, 9 ld de, String1dc550 @@ -92064,7 +92067,7 @@ Function1dc381: ; 1dc381 call PlaceString hlcoord 4, 11 ld de, TempMonID - ld bc, $8205 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum hlcoord 1, 14 ld de, String1dc554 @@ -92146,7 +92149,7 @@ Function1dc47b: ; 1dc47b ; 1dc507 Function1dc507: ; 1dc507 - ld bc, $0203 + lb bc, 2, 3 call PrintNum ret ; 1dc50e @@ -92242,7 +92245,7 @@ Function1dd6a9: ; 1dd6a9 ld d, h ld e, l pop hl - ld bc, $8205 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum pop bc ret @@ -92280,7 +92283,7 @@ Function1dd6bb: ; 1dd6bb (77:56bb) push hl pop de pop hl - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum pop bc ld de, String_1dd6fc diff --git a/maps/RadioTower1F.asm b/maps/RadioTower1F.asm index ef9bbbfcd..04a6cc907 100644 --- a/maps/RadioTower1F.asm +++ b/maps/RadioTower1F.asm @@ -26,10 +26,10 @@ GentlemanScript_0x5cd3d: loadfont writetext UnknownText_0x5ceba keeptextopen - special Functionc434 - iffalse UnknownScript_0x5cd4c - special Functionc422 -UnknownScript_0x5cd4c: + special Special_CheckLuckyNumberShowFlag + iffalse .skip + special Special_ResetLuckyNumberShowFlag +.skip: special Function4d9d3 checkflag ENGINE_LUCKY_NUMBER_SHOW iftrue .GameOver @@ -45,7 +45,7 @@ UnknownScript_0x5cd4c: playsound SFX_DEX_FANFARE_20_49 waitbutton keeptextopen - special Function4d87a + special Special_CheckForLuckyNumberWinners loadmovesprites applymovement $6, MovementData_0x5ce74 loadfont @@ -66,7 +66,7 @@ UnknownScript_0x5cd4c: waitbutton keeptextopen giveitem MASTER_BALL, 1 - iffalse UnknownScript_0x5cdcf + iffalse .BagFull itemnotify setflag ENGINE_LUCKY_NUMBER_SHOW jump .GameOver @@ -77,7 +77,7 @@ UnknownScript_0x5cd4c: waitbutton keeptextopen giveitem EXP_SHARE, 1 - iffalse UnknownScript_0x5cdcf + iffalse .BagFull itemnotify setflag ENGINE_LUCKY_NUMBER_SHOW jump .GameOver @@ -88,7 +88,7 @@ UnknownScript_0x5cd4c: waitbutton keeptextopen giveitem PP_UP, 1 - iffalse UnknownScript_0x5cdcf + iffalse .BagFull itemnotify setflag ENGINE_LUCKY_NUMBER_SHOW jump .GameOver @@ -99,7 +99,7 @@ UnknownScript_0x5cd4c: loadmovesprites end -UnknownScript_0x5cdcf: +.BagFull: writetext UnknownText_0x5d0e6 closetext loadmovesprites diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm index 3fcd0969a..f60ce3bd1 100644 --- a/misc/mobile_40.asm +++ b/misc/mobile_40.asm @@ -1097,7 +1097,7 @@ Function100697: ; 100697 ret .asm_1006b4 - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ret @@ -1484,7 +1484,7 @@ Function100902: ; 100902 hlcoord 4, 11 call PlaceString hlcoord 8, 11 - ld bc, $0102 + lb bc, 1, 2 ld de, StringBuffer2 call PrintNum ld de, SFX_TWO_PC_BEEPS diff --git a/misc/mobile_42.asm b/misc/mobile_42.asm index b12fb29b3..a66e375ea 100644 --- a/misc/mobile_42.asm +++ b/misc/mobile_42.asm @@ -1343,7 +1343,7 @@ Function108a87: ; 108a87 Function108a92: ; 108a92 hlcoord 9, 0 - ld bc, $8103 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum ret ; 108a9c @@ -1380,7 +1380,7 @@ Unknown_108abb: ; 108abb Function108abe: ; 108abe hlcoord 8, 6 - ld bc, $8205 + lb bc, PRINTNUM_LEADINGZEROS | 2, 5 call PrintNum ret ; 108ac8 diff --git a/misc/mobile_45.asm b/misc/mobile_45.asm index 7ae4f8327..25d753edc 100644 --- a/misc/mobile_45.asm +++ b/misc/mobile_45.asm @@ -13368,11 +13368,11 @@ Function11a302: ; 11a302 call PlaceString hlcoord 9, 4 ld de, wcd68 - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum hlcoord 14, 4 ld de, wcd67 - ld bc, $8102 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ld a, $80 ld [wcd44], a diff --git a/misc/mobile_5f.asm b/misc/mobile_5f.asm index eb9231a18..e56cd83e5 100644 --- a/misc/mobile_5f.asm +++ b/misc/mobile_5f.asm @@ -5347,7 +5347,7 @@ Function17ff3c: ; 17ff3c ld [wc300], a hlcoord 14, 2 ld de, wc300 - ld bc, $8103 + lb bc, PRINTNUM_LEADINGZEROS | 1, 3 call PrintNum pop af ld [wc300], a diff --git a/sram.asm b/sram.asm index ce62cc240..1201925d9 100644 --- a/sram.asm +++ b/sram.asm @@ -27,9 +27,8 @@ s0_abe4End:: ds $30 s0_ac60:: ds 8 -s0_ac68:: ds 1 -s0_ac69:: ds 1 -s0_ac6a:: ds 1 +sLuckyNumberDay:: ds 1 +sLuckyIDNumber:: ds 2 ds $b200 - $ac6b diff --git a/wram.asm b/wram.asm index 4913ddbe1..128092942 100644 --- a/wram.asm +++ b/wram.asm @@ -4,7 +4,7 @@ flag_array: MACRO ds ((\1) + 7) / 8 ENDM -box_struct_length EQU 24 + NUM_MOVES * 2 +box_struct_length EQU 24 + NUM_MOVES * 2 ; 32 box_struct: MACRO \1Species:: db \1Item:: db @@ -30,6 +30,7 @@ box_struct: MACRO \1End:: ENDM +party_struct_length EQU box_struct_length + 16 party_struct: MACRO box_struct \1 \1Status:: db @@ -1352,17 +1353,22 @@ wd001:: ds 1 wd002:: PhoneScriptBank:: DefaultFlypoint:: ; d002 +LuckyNumberDigit1Buffer:: ds 1 wd003:: +LuckyNumberDigit2Buffer:: PhoneCallerLo:: ds 1 wd004:: +LuckyNumberDigit3Buffer:: PhoneCallerHi:: ds 1 wd005:: +LuckyNumberDigit4Buffer:: StartFlypoint:: ; d005 ds 1 wd006:: +LuckyNumberDigit5Buffer:: EndFlypoint:: ; d006 ds 1 @@ -1717,8 +1723,11 @@ MovementType:: Buffer2:: ; d1eb ds 1 +Buffer3:: wd1ec:: ds 1 +Buffer4:: wd1ed:: ds 1 +Buffer5:: wd1ee:: ds 1 wd1ef:: ds 1 wd1f0:: ds 1 @@ -1842,6 +1851,7 @@ wd25e:: ds 4 wd262:: ds 1 wd263:: ds 1 wd264:: ds 1 +wFoundMatchingIDInParty:: wNamedObjectIndexBuffer:: wd265:: ds 1 wd266:: ds 1 @@ -2384,7 +2394,8 @@ FruitTreeFlags:: ; dc27 ds 5 -wdc2d:: ds 4 +wLuckyNumberDayBuffer:: ds 2 + ds 2 wSpecialPhoneCallID:: ds 2 wdc33:: ds 2 wdc35:: ds 4 @@ -2416,9 +2427,8 @@ wdc77:: ds 2 wdc79:: ds 1 wdc7a:: ds 2 wdc7c:: ds 33 -wdc9d:: ds 2 -wdc9f:: ds 1 -wdca0:: ds 1 +wLuckyNumberShowFlag:: ds 2 +wLuckyIDNumber:: ds 2 wdca1:: ds 3 wdca4:: ds 1 From 327faac497b4195dbf1d3c8dbfeb2adcda9deb27 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 11 Oct 2015 12:15:03 -0400 Subject: [PATCH 05/11] Magikarp functions moved to event/magikarp.asm --- battle/misc.asm | 259 ++++ constants/misc_constants.asm | 11 +- engine/pokedex.asm | 26 +- .../magikarp_length.asm => event/magikarp.asm | 130 ++ event/mom.asm | 750 ++++++++++ home.asm | 6 +- home/joypad.asm | 4 +- home/text.asm | 2 +- macros/charmap.asm | 3 + main.asm | 1249 +---------------- misc/mobile_40.asm | 2 +- misc/mobile_5f.asm | 4 +- text/common_3.asm | 2 +- wram.asm | 7 +- 14 files changed, 1240 insertions(+), 1215 deletions(-) create mode 100644 battle/misc.asm rename battle/magikarp_length.asm => event/magikarp.asm (58%) create mode 100644 event/mom.asm diff --git a/battle/misc.asm b/battle/misc.asm new file mode 100644 index 000000000..a8dccca84 --- /dev/null +++ b/battle/misc.asm @@ -0,0 +1,259 @@ +Functionfbd54: ; fbd54 + xor a + ld [hBGMapMode], a ; $ff00+$d4 + ld a, [hBattleTurn] ; $ff00+$e4 + and a + jr z, .asm_fbd61 + call Functionfbd96 + jr .asm_fbd64 +.asm_fbd61 + call Functionfbd9d +.asm_fbd64 + call ClearBox + jr Functionfbd91 + +Functionfbd69: ; fbd69 (3e:7d69) + callba BattleCommanda6 + jr Functionfbd77 + +Functionfbd71: ; fbd71 (3e:7d71) + callba BattleCommanda7 + +Functionfbd77: ; fbd77 (3e:7d77) + xor a + ld [hBGMapMode], a ; $ff00+$d4 + ld a, [hBattleTurn] ; $ff00+$e4 + and a + jr z, .asm_fbd85 + call Functionfbd96 + xor a + jr .asm_fbd8a +.asm_fbd85 + call Functionfbd9d + ld a, $31 +.asm_fbd8a + ld [$ffad], a + predef FillBox +Functionfbd91: ; fbd91 (3e:7d91) + ld a, $1 + ld [hBGMapMode], a ; $ff00+$d4 + ret + +Functionfbd96: ; fbd96 (3e:7d96) + hlcoord 12, 0 + lb bc, 7, 7 + ret + +Functionfbd9d: ; fbd9d (3e:7d9d) + hlcoord 2, 6 + lb bc, 6, 6 + ret + + +DoWeatherModifiers: ; fbda4 + + ld de, .WeatherTypeModifiers + ld a, [Weather] + ld b, a + ld a, [wd265] ; move type + ld c, a + +.CheckWeatherType + ld a, [de] + inc de + cp $ff + jr z, .asm_fbdc0 + + cp b + jr nz, .NextWeatherType + + ld a, [de] + cp c + jr z, .ApplyModifier + +.NextWeatherType +rept 2 + inc de +endr + jr .CheckWeatherType + + +.asm_fbdc0 + ld de, .WeatherMoveModifiers + + ld a, BATTLE_VARS_MOVE_EFFECT + call GetBattleVar + ld c, a + +.CheckWeatherMove + ld a, [de] + inc de + cp $ff + jr z, .done + + cp b + jr nz, .NextWeatherMove + + ld a, [de] + cp c + jr z, .ApplyModifier + +.NextWeatherMove +rept 2 + inc de +endr + jr .CheckWeatherMove + +.ApplyModifier + xor a + ld [hMultiplicand + 0], a + ld hl, CurDamage + ld a, [hli] + ld [hMultiplicand + 1], a + ld a, [hl] + ld [hMultiplicand + 2], a + + inc de + ld a, [de] + ld [hMultiplier], a + + call Multiply + + ld a, 10 + ld [hDivisor], a + ld b, $4 + call Divide + + ld a, [hQuotient + 0] + and a + ld bc, -1 + jr nz, .Update + + ld a, [hQuotient + 1] + ld b, a + ld a, [hQuotient + 2] + ld c, a + or b + jr nz, .Update + + ld bc, 1 + +.Update + ld a, b + ld [CurDamage], a + ld a, c + ld [CurDamage + 1], a + +.done + ret + +.WeatherTypeModifiers + db WEATHER_RAIN, WATER, 15 + db WEATHER_RAIN, FIRE, 05 + db WEATHER_SUN, FIRE, 15 + db WEATHER_SUN, WATER, 05 + db $ff + +.WeatherMoveModifiers + db WEATHER_RAIN, EFFECT_SOLARBEAM, 05 + db $ff +; fbe24 + + +DoBadgeTypeBoosts: ; fbe24 + ld a, [InLinkBattle] + and a + ret nz + + ld a, [InBattleTowerBattle] + and a + ret nz + + ld a, [hBattleTurn] + and a + ret nz + + push de + push bc + + ld hl, .BadgeTypes + + ld a, [KantoBadges] + ld b, a + ld a, [JohtoBadges] + ld c, a + +.CheckBadge + ld a, [hl] + cp $ff + jr z, .done + + srl b + rr c + jr nc, .NextBadge + + ld a, [wd265] ; move type + cp [hl] + jr z, .ApplyBoost + +.NextBadge + inc hl + jr .CheckBadge + +.ApplyBoost + ld a, [CurDamage] + ld h, a + ld d, a + ld a, [CurDamage + 1] + ld l, a + ld e, a + + srl d + rr e + srl d + rr e + srl d + rr e + + ld a, e + or d + jr nz, .asm_fbe6f + ld e, 1 + +.asm_fbe6f + add hl, de + jr nc, .Update + + ld hl, $ffff + +.Update + ld a, h + ld [CurDamage], a + ld a, l + ld [CurDamage + 1], a + +.done + pop bc + pop de + ret + +.BadgeTypes + db FLYING ; zephyrbadge + db BUG ; hivebadge + db NORMAL ; plainbadge + db GHOST ; fogbadge + db STEEL ; mineralbadge + db FIGHTING ; stormbadge + db ICE ; glacierbadge + db DRAGON ; risingbadge + + db ROCK ; boulderbadge + db WATER ; cascadebadge + db ELECTRIC ; thunderbadge + db GRASS ; rainbowbadge + db POISON ; soulbadge + db PSYCHIC ; marshbadge + db FIRE ; volcanobadge + db GROUND ; earthbadge + db $ff +; fbe91 diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 0306deb1e..784163acb 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -116,6 +116,11 @@ BATTLETOWER_NROFTRAINERS EQU 7 NUM_WILDMONS_PER_AREA_TIME_OF_DAY EQU 7 WILDMON_GRASS_STRUCTURE_LENGTH EQU 2 + 3 * (1 + 2 * NUM_WILDMONS_PER_AREA_TIME_OF_DAY) -PRINTNUM_MONEY EQU %00100000 -PRINTNUM_RIGHTALIGN EQU %01000000 -PRINTNUM_LEADINGZEROS EQU %10000000 + +PRINTNUM_MONEY_F EQU 5 +PRINTNUM_RIGHTALIGN_F EQU 6 +PRINTNUM_LEADINGZEROS_F EQU 7 + +PRINTNUM_MONEY EQU 1 << PRINTNUM_MONEY_F +PRINTNUM_RIGHTALIGN EQU 1 << PRINTNUM_RIGHTALIGN_F +PRINTNUM_LEADINGZEROS EQU 1 << PRINTNUM_LEADINGZEROS_F diff --git a/engine/pokedex.asm b/engine/pokedex.asm index 31a21cff0..89ca48ba8 100644 --- a/engine/pokedex.asm +++ b/engine/pokedex.asm @@ -217,7 +217,7 @@ Function4013c: ; 4013c (10:413c) call ByteFill callba Function1de171 hlcoord 0, 17 - ld de, Unknown_407f2 + ld de, String_START_SEARCH call Function40acd ld a, $7 ld [wc7d3], a @@ -246,7 +246,7 @@ Function4013c: ; 4013c (10:413c) call Function41148 callba Function1de171 hlcoord 0, 17 - ld de, Unknown_407f2 + ld de, String_START_SEARCH call Function40acd ld a, $7 ld [wc7d3], a @@ -1068,7 +1068,7 @@ Function40741: ; 40741 Function4074c: ; 4074c (10:474c) hlcoord 0, 17 - ld de, Unknown_407f2 + ld de, String_START_SEARCH call Function40acd ld a, $32 hlcoord 0, 0 @@ -1081,27 +1081,27 @@ Function4074c: ; 4074c (10:474c) ld bc, $607 call Function40ad5 hlcoord 1, 11 - ld de, Unknown_407e1 + ld de, String_SEEN call Function40acd ld hl, PokedexSeen ; wdeb9 (aliases: EndPokedexSeen) ld b, EndPokedexSeen - PokedexSeen call CountSetBits ld de, wd265 hlcoord 5, 12 - ld bc, $103 + lb bc, 1, 3 call PrintNum hlcoord 1, 14 - ld de, Unknown_407e6 + ld de, String_OWN call Function40acd ld hl, PokedexCaught ld b, EndPokedexCaught - PokedexCaught call CountSetBits ld de, wd265 hlcoord 5, 15 - ld bc, $103 + lb bc, 1, 3 call PrintNum hlcoord 1, 17 - ld de, Unknown_407ea + ld de, String_SELECT_OPTION call Function40acd hlcoord 8, 1 ld b, $7 @@ -1123,13 +1123,13 @@ Function4074c: ; 4074c (10:474c) ret ; 407e1 (10:47e1) -Unknown_407e1: ; 407e1 +String_SEEN: ; 407e1 db "SEEN", $ff -Unknown_407e6: ; 407e6 +String_OWN: ; 407e6 db "OWN", $ff -Unknown_407ea: ; 407ea +String_SELECT_OPTION: ; 407ea db $3b, $48, $49, $4a, $44, $45, $46, $47 ; SELECT > OPTION -Unknown_407f2: ; 407f2 +String_START_SEARCH: ; 407f2 db $3c, $3b, $41, $42, $43, $4b, $4c, $4d, $4e, $3c, $ff ; START > SEARCH ; 407fd @@ -1270,7 +1270,7 @@ Function40962: ; 40962 (10:4962) call PlaceString ld de, wc7d7 hlcoord 1, 16 - ld bc, $103 + lb bc, 1, 3 call PrintNum hlcoord 8, 0 ld [hl], $59 diff --git a/battle/magikarp_length.asm b/event/magikarp.asm similarity index 58% rename from battle/magikarp_length.asm rename to event/magikarp.asm index 237450928..4f759d655 100644 --- a/battle/magikarp_length.asm +++ b/event/magikarp.asm @@ -1,3 +1,114 @@ + + +Special_CheckMagikarpLength: ; fbb32 + ; Returns 3 if you select a Magikarp that beats the previous record. + ; Returns 2 if you select a Magikarp, but the current record is longer. + ; Returns 1 if you press B in the Pokemon selection menu. + ; Returns 0 if the Pokemon you select is not a Magikarp. + + ; Let's start by selecting a Magikarp. + callba SelectMonFromParty + jr c, .declined + ld a, [CurPartySpecies] + cp MAGIKARP + jr nz, .not_magikarp + + ; Now let's compute its length based on its DVs and ID. + ld a, [CurPartyMon] + ld hl, PartyMon1Species + ld bc, PartyMon2 - PartyMon1 + call AddNTimes + push hl + ld bc, MON_DVS + add hl, bc + ld d, h + ld e, l + pop hl + ld bc, MON_ID + add hl, bc + ld b, h + ld c, l + call CalcMagikarpLength + call PrintMagikarpLength + callba MagikarpLength_Mobile + ld hl, .MeasureItText + call PrintText + + ; Did we beat the record? + ld hl, Buffer1 + ld de, wBestMagikarpLengthFeet + ld c, 2 + call StringCmp + jr nc, .not_long_enough + + ; NEW RECORD!!! Let's save that. + ld hl, Buffer1 + ld de, wBestMagikarpLengthFeet + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + ld [de], a + inc de + ld a, [CurPartyMon] + ld hl, PartyMonOT + call SkipNames + call CopyBytes + ld a, 3 + ld [ScriptVar], a + ret + +.not_long_enough + ld a, 2 + ld [ScriptVar], a + ret + +.declined + ld a, 1 + ld [ScriptVar], a + ret + +.not_magikarp + xor a + ld [ScriptVar], a + ret +; fbba9 + +.MeasureItText: ; 0xfbba9 + ; Let me measure that MAGIKARP. …Hm, it measures @ . + text_jump UnknownText_0x1c1203 + db "@" +; 0xfbbae + +Magikarp_LoadFeetInchesChars: ; fbbae + ld hl, VTiles2 + "" * $10 + ld de, .feetinchchars + lb bc, BANK(.feetinchchars), 2 + call Request2bpp + ret +; fbbbb + +.feetinchchars: ; fbbb +INCBIN "gfx/unknown/0fbbbb.2bpp" +; fbbdb + +PrintMagikarpLength: ; fbbdb + call Magikarp_LoadFeetInchesChars + ld hl, StringBuffer1 + ld de, Buffer1 + lb bc, PRINTNUM_RIGHTALIGN | 1, 2 + call PrintNum + ld [hl], "" + inc hl + ld de, Buffer2 + lb bc, PRINTNUM_RIGHTALIGN | 1, 2 + call PrintNum + ld [hl], "" + inc hl + ld [hl], "@" + ret +; fbbfc + CalcMagikarpLength: ; fbbfc ; Return Magikarp's length (in mm) at MagikarpLength (big endian). ; @@ -213,3 +324,22 @@ endr dwb 65410, 2 dwb 65510, 1 ; not used ; fbcd2 + + + +Special_MagikarpHouseSign: ; fbcd2 + ld a, [wBestMagikarpLengthFeet] + ld [Buffer1], a + ld a, [wBestMagikarpLengthInches] + ld [Buffer2], a + call PrintMagikarpLength + ld hl, .CurrentRecordtext + call PrintText + ret +; fbce8 + +.CurrentRecordtext: ; 0xfbce8 + ; "CURRENT RECORD" + text_jump UnknownText_0x1c123a + db "@" +; 0xfbced diff --git a/event/mom.asm b/event/mom.asm new file mode 100644 index 000000000..f6bccdc28 --- /dev/null +++ b/event/mom.asm @@ -0,0 +1,750 @@ +Special_BankOfMom: ; 16218 + ld a, [$ffaa] + push af + ld a, $1 + ld [$ffaa], a + xor a + ld [wcf63], a +.asm_16223 + ld a, [wcf63] + bit 7, a + jr nz, .asm_1622f + call Function16233 + jr .asm_16223 + +.asm_1622f + pop af + ld [$ffaa], a + ret +; 16233 + +Function16233: ; 16233 + ld a, [wcf63] + ld e, a + ld d, 0 + ld hl, Jumptable_16242 +rept 2 + add hl, de +endr + ld a, [hli] + ld h, [hl] + ld l, a + jp [hl] +; 16242 + +Jumptable_16242: ; 16242 + dw Function16254 + dw Function1626a + dw Function16290 + dw Function162a8 + dw Function162e0 + dw Function16373 + dw Function16406 + dw Function1642d + dw Function16433 +; 16254 + +Function16254: ; 16254 + ld a, [wd854] + bit 7, a + jr nz, .asm_16264 + set 7, a + ld [wd854], a + ld a, $1 + jr .asm_16266 + +.asm_16264 + ld a, $2 + +.asm_16266 + ld [wcf63], a + ret +; 1626a + +Function1626a: ; 1626a + ld hl, UnknownText_0x16649 + call PrintText + call YesNoBox + jr c, .asm_1627f + ld hl, UnknownText_0x1664e + call PrintText + ld a, $81 + jr .asm_16281 + +.asm_1627f + ld a, $80 + +.asm_16281 + ld [wd854], a + ld hl, UnknownText_0x16653 + call PrintText + ld a, $8 + ld [wcf63], a + ret +; 16290 + +Function16290: ; 16290 + ld hl, UnknownText_0x16658 + call PrintText + call YesNoBox + jr c, .asm_1629f + ld a, $3 + jr .asm_162a4 + +.asm_1629f + call DSTChecks + ld a, $7 + +.asm_162a4 + ld [wcf63], a + ret +; 162a8 + +Function162a8: ; 162a8 + ld hl, UnknownText_0x1665d + call PrintText + call Function1d6e + ld hl, MenuDataHeader_0x166b5 + call CopyMenuDataHeader + call InterpretMenu2 + call WriteBackup + jr c, .asm_162ce + ld a, [wcfa9] + cp $1 + jr z, .asm_162d2 + cp $2 + jr z, .asm_162d6 + cp $3 + jr z, .asm_162da + +.asm_162ce + ld a, $7 + jr .asm_162dc + +.asm_162d2 + ld a, $5 + jr .asm_162dc + +.asm_162d6 + ld a, $4 + jr .asm_162dc + +.asm_162da + ld a, $6 + +.asm_162dc + ld [wcf63], a + ret +; 162e0 + +Function162e0: ; 162e0 + ld hl, UnknownText_0x16662 + call PrintText + xor a + ld hl, StringBuffer2 +rept 2 + ld [hli], a +endr + ld [hl], a + ld a, $5 + ld [wcf64], a + call Function1d6e + call Function16517 + call Function1656b + call Function16571 + call WriteBackup + jr c, .asm_1636d + ld hl, StringBuffer2 + ld a, [hli] + or [hl] + inc hl + or [hl] + jr z, .asm_1636d + ld de, Money + ld bc, StringBuffer2 + callba CheckMoney + jr c, .asm_1635f + ld hl, StringBuffer2 + ld de, StringBuffer2 + 3 + ld bc, $0003 + call CopyBytes + ld bc, wd851 + ld de, StringBuffer2 + callba GiveMoney + jr c, .asm_16366 + ld bc, StringBuffer2 + 3 + ld de, Money + callba TakeMoney + ld hl, StringBuffer2 + ld de, wd851 + ld bc, $0003 + call CopyBytes + ld de, SFX_TRANSACTION + call PlaySFX + call WaitSFX + ld hl, UnknownText_0x1668a + call PrintText + ld a, $8 + jr .asm_1636f + +.asm_1635f + ld hl, UnknownText_0x1667b + call PrintText + ret + +.asm_16366 + ld hl, UnknownText_0x16680 + call PrintText + ret + +.asm_1636d + ld a, $7 + +.asm_1636f + ld [wcf63], a + ret +; 16373 + +Function16373: ; 16373 + ld hl, UnknownText_0x16667 + call PrintText + xor a + ld hl, StringBuffer2 +rept 2 + ld [hli], a +endr + ld [hl], a + ld a, $5 + ld [wcf64], a + call Function1d6e + call Function16512 + call Function1656b + call Function16571 + call WriteBackup + jr c, .asm_16400 + ld hl, StringBuffer2 + ld a, [hli] + or [hl] + inc hl + or [hl] + jr z, .asm_16400 + ld hl, StringBuffer2 + ld de, StringBuffer2 + 3 + ld bc, 3 + call CopyBytes + ld de, wd851 + ld bc, StringBuffer2 + callba CheckMoney + jr c, .asm_163f2 + ld bc, Money + ld de, StringBuffer2 + callba GiveMoney + jr c, .asm_163f9 + ld bc, StringBuffer2 + 3 + ld de, wd851 + callba TakeMoney + ld hl, StringBuffer2 + ld de, Money + ld bc, 3 + call CopyBytes + ld de, SFX_TRANSACTION + call PlaySFX + call WaitSFX + ld hl, UnknownText_0x1668f + call PrintText + ld a, $8 + jr .asm_16402 + +.asm_163f2 + ld hl, UnknownText_0x16671 + call PrintText + ret + +.asm_163f9 + ld hl, UnknownText_0x16676 + call PrintText + ret + +.asm_16400 + ld a, 7 + +.asm_16402 + ld [wcf63], a + ret +; 16406 + +Function16406: ; 16406 + ld hl, UnknownText_0x1666c + call PrintText + call YesNoBox + jr c, .asm_16422 + ld a, $81 + ld [wd854], a + ld hl, UnknownText_0x16685 + call PrintText + ld a, $8 + ld [wcf63], a + ret + +.asm_16422 + ld a, $80 + ld [wd854], a + ld a, $7 + ld [wcf63], a + ret +; 1642d + +Function1642d: ; 1642d + ld hl, UnknownText_0x16694 + call PrintText + +Function16433: ; 16433 + ld hl, wcf63 + set 7, [hl] + ret +; 16439 + +DSTChecks: ; 16439 +; check the time; avoid changing DST if doing so would change the current day + ld a, [wDST] + bit 7, a + ld a, [hHours] + jr z, .asm_16447 + and a ; within one hour of 00:00? + jr z, .LostBooklet + jr .loop + +.asm_16447 + cp 23 ; within one hour of 23:00? + jr nz, .loop + ; fallthrough + +.LostBooklet + call Function164ea + bccoord 1, 14 + ld hl, UnknownText_0x164f4 + call PlaceWholeStringInBoxAtOnce + call YesNoBox + ret c + call Function164ea + bccoord 1, 14 + ld hl, LostInstructionBookletText + call PlaceWholeStringInBoxAtOnce + ret + +.loop + call Function164ea + bccoord 1, 14 + ld a, [wDST] + bit 7, a + jr z, .asm_16497 + ld hl, UnknownText_0x16508 + call PlaceWholeStringInBoxAtOnce + call YesNoBox + ret c + ld a, [wDST] + res 7, a + ld [wDST], a + call Function164d1 + call Function164ea + bccoord 1, 14 + ld hl, UnknownText_0x1650d + call PlaceWholeStringInBoxAtOnce + ret + +.asm_16497 + ld hl, UnknownText_0x164fe + call PlaceWholeStringInBoxAtOnce + call YesNoBox + ret c + ld a, [wDST] + set 7, a + ld [wDST], a + call Function164b9 + call Function164ea + bccoord 1, 14 + ld hl, UnknownText_0x16503 + call PlaceWholeStringInBoxAtOnce + ret +; 164b9 + +Function164b9: ; 164b9 + ld a, [StartHour] + add 1 + sub 24 + jr nc, .asm_164c4 + add 24 +.asm_164c4 + ld [StartHour], a + ccf + ld a, [StartDay] + adc 0 + ld [StartDay], a + ret +; 164d1 + +Function164d1: ; 164d1 + ld a, [StartHour] + sub 1 + jr nc, .asm_164da + add 24 +.asm_164da + ld [StartHour], a + ld a, [StartDay] + sbc 0 + jr nc, .asm_164e6 + add 7 +.asm_164e6 + ld [StartDay], a + ret +; 164ea + +Function164ea: ; 164ea + hlcoord 1, 14 + ld bc, $0312 + call ClearBox + ret +; 164f4 + +UnknownText_0x164f4: ; 0x164f4 + ; Do you want to adjust your clock for Daylight Saving Time? + text_jump UnknownText_0x1c6095 + db "@" +; 0x164f9 + +LostInstructionBookletText: ; 0x164f9 + ; I lost the instruction booklet for the POKéGEAR. + ; Come back again in a while. + text_jump UnknownText_0x1c60d1 + db "@" +; 0x164fe + +UnknownText_0x164fe: ; 0x164fe + ; Do you want to switch to Daylight Saving Time? + text_jump UnknownText_0x1c6000 + db "@" +; 0x16503 + +UnknownText_0x16503: ; 0x16503 + ; I set the clock forward by one hour. + text_jump UnknownText_0x1c6030 + db "@" +; 0x16508 + +UnknownText_0x16508: ; 0x16508 + ; Is Daylight Saving Time over? + text_jump UnknownText_0x1c6056 + db "@" +; 0x1650d + +UnknownText_0x1650d: ; 0x1650d + ; I put the clock back one hour. + text_jump UnknownText_0x1c6075 + db "@" +; 0x16512 + +Function16512: ; 16512 + ld de, String_1669f + jr Function1651a + +Function16517: ; 16517 + ld de, String_166a8 + +Function1651a: ; 1651a + push de + xor a + ld [hBGMapMode], a + hlcoord 0, 0 + lb bc, 6, 18 + call TextBox + hlcoord 1, 2 + ld de, String_16699 + call PlaceString + hlcoord 12, 2 + ld de, wd851 + lb bc, PRINTNUM_MONEY | 3, 6 + call PrintNum + hlcoord 1, 4 + ld de, String_166b0 + call PlaceString + hlcoord 12, 4 + ld de, Money + lb bc, PRINTNUM_MONEY | 3, 6 + call PrintNum + hlcoord 1, 6 + pop de + call PlaceString + hlcoord 12, 6 + ld de, StringBuffer2 + lb bc, PRINTNUM_MONEY | PRINTNUM_LEADINGZEROS | 3, 6 + call PrintNum + call UpdateSprites + call Function3238 + ret +; 1656b + +Function1656b: ; 1656b + ld c, 10 + call DelayFrames + ret +; 16571 + +Function16571: ; 16571 +.loop + call Functiona57 + ld hl, hJoyPressed + ld a, [hl] + and B_BUTTON + jr nz, .pressedB + ld a, [hl] + and A_BUTTON + jr nz, .pressedA + call .dpadaction + xor a + ld [hBGMapMode], a + hlcoord 12, 6 + ld bc, 7 + ld a, " " + call ByteFill + hlcoord 12, 6 + ld de, StringBuffer2 + lb bc, PRINTNUM_MONEY | PRINTNUM_LEADINGZEROS | 3, 6 + call PrintNum + ld a, [$ff9b] + and $10 + jr nz, .skip + hlcoord 13, 6 + ld a, [wMomBankDigitCursorPosition] + ld c, a + ld b, 0 + add hl, bc + ld [hl], " " + +.skip + call WaitBGMap + jr .loop + +.pressedB + scf + ret + +.pressedA + and a + ret +; 165b9 + +.dpadaction: ; 165b9 + ld hl, hJoyLast + ld a, [hl] + and D_UP + jr nz, .incrementdigit + ld a, [hl] + and D_DOWN + jr nz, .decrementdigit + ld a, [hl] + and D_LEFT + jr nz, .movecursorleft + ld a, [hl] + and D_RIGHT + jr nz, .movecursorright + and a + ret + +.movecursorleft + ld hl, wMomBankDigitCursorPosition + ld a, [hl] + and a + ret z + dec [hl] + ret + +.movecursorright + ld hl, wMomBankDigitCursorPosition + ld a, [hl] + cp 5 + ret nc + inc [hl] + ret + +.incrementdigit + ld hl, .DigitQuantities + call .getdigitquantity + ld c, l + ld b, h + ld de, StringBuffer2 + callba GiveMoney + ret + +.decrementdigit + ld hl, .DigitQuantities + call .getdigitquantity + ld c, l + ld b, h + ld de, StringBuffer2 + callba TakeMoney + ret +; 16607 + +.getdigitquantity: ; 16607 + ld a, [wMomBankDigitCursorPosition] + push de + ld e, a + ld d, 0 +rept 3 + add hl, de +endr + pop de + ret +; 16613 + +.DigitQuantities: ; 16613 + dt 100000 + dt 10000 + dt 1000 + dt 100 + dt 10 + dt 1 + + dt 100000 + dt 10000 + dt 1000 + dt 100 + dt 10 + dt 1 + + dt 900000 + dt 90000 + dt 9000 + dt 900 + dt 90 + dt 9 +; 16649 + +UnknownText_0x16649: ; 0x16649 + ; Wow, that's a cute #MON. Where did you get it? … So, you're leaving on an adventure… OK! I'll help too. But what can I do for you? I know! I'll save money for you. On a long journey, money's important. Do you want me to save your money? + text_jump UnknownText_0x1bd77f + db "@" +; 0x1664e + +UnknownText_0x1664e: ; 0x1664e + ; OK, I'll take care of your money. + text_jump UnknownText_0x1bd868 + db "@" +; 0x16653 + +UnknownText_0x16653: ; 0x16653 + ; Be careful. #MON are your friends. You need to work as a team. Now, go on! + text_jump UnknownText_0x1bd88e + db "@" +; 0x16658 + +UnknownText_0x16658: ; 0x16658 + ; Hi! Welcome home! You're trying very hard, I see. I've kept your room tidy. Or is this about your money? + text_jump UnknownText_0x1bd8da + db "@" +; 0x1665d + +UnknownText_0x1665d: ; 0x1665d + ; What do you want to do? + text_jump UnknownText_0x1bd942 + db "@" +; 0x16662 + +UnknownText_0x16662: ; 0x16662 + ; How much do you want to save? + text_jump UnknownText_0x1bd95b + db "@" +; 0x16667 + +UnknownText_0x16667: ; 0x16667 + ; How much do you want to take? + text_jump UnknownText_0x1bd97a + db "@" +; 0x1666c + +UnknownText_0x1666c: ; 0x1666c + ; Do you want to save some money? + text_jump UnknownText_0x1bd999 + db "@" +; 0x16671 + +UnknownText_0x16671: ; 0x16671 + ; You haven't saved that much. + text_jump UnknownText_0x1bd9ba + db "@" +; 0x16676 + +UnknownText_0x16676: ; 0x16676 + ; You can't take that much. + text_jump UnknownText_0x1bd9d7 + db "@" +; 0x1667b + +UnknownText_0x1667b: ; 0x1667b + ; You don't have that much. + text_jump UnknownText_0x1bd9f1 + db "@" +; 0x16680 + +UnknownText_0x16680: ; 0x16680 + ; You can't save that much. + text_jump UnknownText_0x1bda0b + db "@" +; 0x16685 + +UnknownText_0x16685: ; 0x16685 + ; OK, I'll save your money. Trust me! , stick with it! + text_jump UnknownText_0x1bda25 + db "@" +; 0x1668a + +UnknownText_0x1668a: ; 0x1668a + ; Your money's safe here! Get going! + text_jump UnknownText_0x1bda5b + db "@" +; 0x1668f + +UnknownText_0x1668f: ; 0x1668f + ; , don't give up! + text_jump UnknownText_0x1bda7e + db "@" +; 0x16694 + +UnknownText_0x16694: ; 0x16694 + ; Just do what you can. + text_jump UnknownText_0x1bda90 + db "@" +; 0x16699 + +String_16699: ; 16699 + db "SAVED@" +; 1669f + +String_1669f: ; 1669f + db "WITHDRAW@" +; 166a8 + +String_166a8: ; 166a8 + db "DEPOSIT@" +; 166b0 + +String_166b0: ; 166b0 + db "HELD@" +; 166b5 + +MenuDataHeader_0x166b5: ; 0x166b5 + db $40 ; flags + db 00, 00 ; start coords + db 10, 10 ; end coords + dw MenuData2_0x166bd + db 1 ; default option +; 0x166bd + +MenuData2_0x166bd: ; 0x166bd + db $80 ; flags + db 4 ; items + db "GET@" + db "SAVE@" + db "CHANGE@" + db "CANCEL@" +; 0x166d6 diff --git a/home.asm b/home.asm index a03c60d63..a7218f26c 100644 --- a/home.asm +++ b/home.asm @@ -75,12 +75,12 @@ Function2ebb:: ; 2ebb ret ; 2ec6 -Function2ec6:: ; 2ec6 +xor_a:: ; 2ec6 xor a ret ; 2ec8 -Function2ec8:: ; 2ec8 +xor_a_dec_a:: ; 2ec8 xor a dec a ret @@ -1760,7 +1760,7 @@ Function383d:: ; 383d Function3842:: ; 3842 ld [wd265], a ld de, wd265 - ld b, 1 << 6 + 1 + ld b, PRINTNUM_RIGHTALIGN | 1 jp PrintNum ; 384d diff --git a/home/joypad.asm b/home/joypad.asm index c07157376..aa7d092af 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -331,7 +331,7 @@ Functiona57:: ; a57 jr z, .asm_a63 ld a, [hJoyDown] .asm_a63 - ld [$ffa9], a + ld [hJoyLast], a ld a, [hJoyPressed] and a jr z, .asm_a70 @@ -344,7 +344,7 @@ Functiona57:: ; a57 and a jr z, .asm_a7a xor a - ld [$ffa9], a + ld [hJoyLast], a ret .asm_a7a diff --git a/home/text.asm b/home/text.asm index 1ddc72ea5..fa8d3b23f 100644 --- a/home/text.asm +++ b/home/text.asm @@ -972,7 +972,7 @@ Text_09:: ; 14d2 ld a, b and $f0 swap a - set 6, a + set PRINTNUM_RIGHTALIGN_F, a ld b, a call PrintNum ld b, h diff --git a/macros/charmap.asm b/macros/charmap.asm index bdee88a1b..83ae5ab79 100644 --- a/macros/charmap.asm +++ b/macros/charmap.asm @@ -10,6 +10,9 @@ charmap "└", $7d charmap "┘", $7e charmap " ", $7f + charmap "", $6e + charmap "", $6f + charmap "A", $80 charmap "B", $81 diff --git a/main.asm b/main.asm index 3c68df818..d4ea3adf1 100644 --- a/main.asm +++ b/main.asm @@ -249,7 +249,7 @@ _ResetWRAM: ; 5bae call CloseSRAM call LoadOrRegenerateLuckyIDNumber - call InitializeRalphName + call InitializeMagikarpHouse xor a ld [MonType], a @@ -335,8 +335,8 @@ SetDefaultBoxNames: ; 5ca6 db "BOX@" ; 5cd3 -InitializeRalphName: ; 5cd3 - ld hl, wdfe8 +InitializeMagikarpHouse: ; 5cd3 + ld hl, wBestMagikarpLengthFeet ld a, $3 ld [hli], a ld a, $6 @@ -721,7 +721,7 @@ DisplayGameTime: ; 5f84 ld [hl], $6d inc hl ld de, GameTimeMinutes - lb bc, $81, 2 + lb bc, PRINTNUM_LEADINGZEROS | 1, 2 jp PrintNum ; 5f99 @@ -18724,7 +18724,7 @@ GetMartPrice: ; 15bf0 ld [StringBuffer2 + 1], a ld hl, StringBuffer1 ld de, StringBuffer2 - lb bc, $82, 6 ; 6 digits + lb bc, PRINTNUM_LEADINGZEROS | 2, 6 ; 6 digits call PrintNum pop hl @@ -19463,8 +19463,8 @@ MaxMoney: ; 15ff7 TakeMoney:: ; 15ffa - ld a, $3 - call Function16035 + ld a, 3 + call CheckMoney2 jr nc, .asm_16009 xor a ld [de], a @@ -19527,33 +19527,33 @@ CheckFunds: ; 1600d ret ; 16035 -Function16035: ; 16035 - ld a, $3 -Function16037: ; 16037 +CheckMoney2: ; 16035 + ld a, 3 +CheckFunds2: ; 16037 push hl push de push bc ld h, b ld l, c ld b, a - ld c, $0 -.asm_1603f + ld c, 0 +.loop dec a - jr z, .asm_16046 + jr z, .done inc de inc hl - jr .asm_1603f + jr .loop -.asm_16046 +.done and a -.asm_16047 +.loop2 ld a, [de] sbc [hl] ld [de], a dec de dec hl dec b - jr nz, .asm_16047 + jr nz, .loop2 pop bc pop de pop hl @@ -19593,14 +19593,14 @@ Function16055: ; 16055 ; 1606f GiveCoins:: ; 1606f - ld a, $2 + ld a, 2 ld de, Coins call Function16055 - ld a, $2 - ld bc, Unknown_1608d + ld a, 2 + ld bc, .maxcoins call CheckFunds jr c, .asm_1608b - ld hl, Unknown_1608d + ld hl, .maxcoins ld a, [hli] ld [de], a inc de @@ -19614,15 +19614,15 @@ GiveCoins:: ; 1606f ret ; 1608d -Unknown_1608d: ; 1608d +.maxcoins: ; 1608d bigdw 9999 ; 1608f TakeCoins:: ; 1608f - ld a, $2 + ld a, 2 ld de, Coins - call Function16037 + call CheckFunds2 jr nc, .asm_1609f xor a ld [de], a @@ -19645,757 +19645,7 @@ CheckCoins:: ; 160a1 INCLUDE "items/marts.asm" - -Special_BankOfMom: ; 16218 - ld a, [$ffaa] - push af - ld a, $1 - ld [$ffaa], a - xor a - ld [wcf63], a -.asm_16223 - ld a, [wcf63] - bit 7, a - jr nz, .asm_1622f - call Function16233 - jr .asm_16223 - -.asm_1622f - pop af - ld [$ffaa], a - ret -; 16233 - -Function16233: ; 16233 - ld a, [wcf63] - ld e, a - ld d, 0 - ld hl, Jumptable_16242 -rept 2 - add hl, de -endr - ld a, [hli] - ld h, [hl] - ld l, a - jp [hl] -; 16242 - -Jumptable_16242: ; 16242 - dw Function16254 - dw Function1626a - dw Function16290 - dw Function162a8 - dw Function162e0 - dw Function16373 - dw Function16406 - dw Function1642d - dw Function16433 -; 16254 - -Function16254: ; 16254 - ld a, [wd854] - bit 7, a - jr nz, .asm_16264 - set 7, a - ld [wd854], a - ld a, $1 - jr .asm_16266 - -.asm_16264 - ld a, $2 - -.asm_16266 - ld [wcf63], a - ret -; 1626a - -Function1626a: ; 1626a - ld hl, UnknownText_0x16649 - call PrintText - call YesNoBox - jr c, .asm_1627f - ld hl, UnknownText_0x1664e - call PrintText - ld a, $81 - jr .asm_16281 - -.asm_1627f - ld a, $80 - -.asm_16281 - ld [wd854], a - ld hl, UnknownText_0x16653 - call PrintText - ld a, $8 - ld [wcf63], a - ret -; 16290 - -Function16290: ; 16290 - ld hl, UnknownText_0x16658 - call PrintText - call YesNoBox - jr c, .asm_1629f - ld a, $3 - jr .asm_162a4 - -.asm_1629f - call DSTChecks - ld a, $7 - -.asm_162a4 - ld [wcf63], a - ret -; 162a8 - -Function162a8: ; 162a8 - ld hl, UnknownText_0x1665d - call PrintText - call Function1d6e - ld hl, MenuDataHeader_0x166b5 - call CopyMenuDataHeader - call InterpretMenu2 - call WriteBackup - jr c, .asm_162ce - ld a, [wcfa9] - cp $1 - jr z, .asm_162d2 - cp $2 - jr z, .asm_162d6 - cp $3 - jr z, .asm_162da - -.asm_162ce - ld a, $7 - jr .asm_162dc - -.asm_162d2 - ld a, $5 - jr .asm_162dc - -.asm_162d6 - ld a, $4 - jr .asm_162dc - -.asm_162da - ld a, $6 - -.asm_162dc - ld [wcf63], a - ret -; 162e0 - -Function162e0: ; 162e0 - ld hl, UnknownText_0x16662 - call PrintText - xor a - ld hl, StringBuffer2 -rept 2 - ld [hli], a -endr - ld [hl], a - ld a, $5 - ld [wcf64], a - call Function1d6e - call Function16517 - call Function1656b - call Function16571 - call WriteBackup - jr c, .asm_1636d - ld hl, StringBuffer2 - ld a, [hli] - or [hl] - inc hl - or [hl] - jr z, .asm_1636d - ld de, Money - ld bc, StringBuffer2 - callba CheckMoney - jr c, .asm_1635f - ld hl, StringBuffer2 - ld de, StringBuffer2 + 3 - ld bc, $0003 - call CopyBytes - ld bc, wd851 - ld de, StringBuffer2 - callba GiveMoney - jr c, .asm_16366 - ld bc, StringBuffer2 + 3 - ld de, Money - callba TakeMoney - ld hl, StringBuffer2 - ld de, wd851 - ld bc, $0003 - call CopyBytes - ld de, SFX_TRANSACTION - call PlaySFX - call WaitSFX - ld hl, UnknownText_0x1668a - call PrintText - ld a, $8 - jr .asm_1636f - -.asm_1635f - ld hl, UnknownText_0x1667b - call PrintText - ret - -.asm_16366 - ld hl, UnknownText_0x16680 - call PrintText - ret - -.asm_1636d - ld a, $7 - -.asm_1636f - ld [wcf63], a - ret -; 16373 - -Function16373: ; 16373 - ld hl, UnknownText_0x16667 - call PrintText - xor a - ld hl, StringBuffer2 -rept 2 - ld [hli], a -endr - ld [hl], a - ld a, $5 - ld [wcf64], a - call Function1d6e - call Function16512 - call Function1656b - call Function16571 - call WriteBackup - jr c, .asm_16400 - ld hl, StringBuffer2 - ld a, [hli] - or [hl] - inc hl - or [hl] - jr z, .asm_16400 - ld hl, StringBuffer2 - ld de, StringBuffer2 + 3 - ld bc, $0003 - call CopyBytes - ld de, wd851 - ld bc, StringBuffer2 - callba CheckMoney - jr c, .asm_163f2 - ld bc, Money - ld de, StringBuffer2 - callba GiveMoney - jr c, .asm_163f9 - ld bc, StringBuffer2 + 3 - ld de, wd851 - callba TakeMoney - ld hl, StringBuffer2 - ld de, Money - ld bc, $0003 - call CopyBytes - ld de, SFX_TRANSACTION - call PlaySFX - call WaitSFX - ld hl, UnknownText_0x1668f - call PrintText - ld a, $8 - jr .asm_16402 - -.asm_163f2 - ld hl, UnknownText_0x16671 - call PrintText - ret - -.asm_163f9 - ld hl, UnknownText_0x16676 - call PrintText - ret - -.asm_16400 - ld a, $7 - -.asm_16402 - ld [wcf63], a - ret -; 16406 - -Function16406: ; 16406 - ld hl, UnknownText_0x1666c - call PrintText - call YesNoBox - jr c, .asm_16422 - ld a, $81 - ld [wd854], a - ld hl, UnknownText_0x16685 - call PrintText - ld a, $8 - ld [wcf63], a - ret - -.asm_16422 - ld a, $80 - ld [wd854], a - ld a, $7 - ld [wcf63], a - ret -; 1642d - -Function1642d: ; 1642d - ld hl, UnknownText_0x16694 - call PrintText - -Function16433: ; 16433 - ld hl, wcf63 - set 7, [hl] - ret -; 16439 - -DSTChecks: ; 16439 -; check the time; avoid changing DST if doing so would change the current day - ld a, [wDST] - bit 7, a - ld a, [hHours] - jr z, .asm_16447 - and a ; within one hour of 00:00? - jr z, .LostBooklet - jr .loop - -.asm_16447 - cp 23 ; within one hour of 23:00? - jr nz, .loop - ; fallthrough - -.LostBooklet - call Function164ea - bccoord 1, 14 - ld hl, UnknownText_0x164f4 - call PlaceWholeStringInBoxAtOnce - call YesNoBox - ret c - call Function164ea - bccoord 1, 14 - ld hl, LostInstructionBookletText - call PlaceWholeStringInBoxAtOnce - ret - -.loop - call Function164ea - bccoord 1, 14 - ld a, [wDST] - bit 7, a - jr z, .asm_16497 - ld hl, UnknownText_0x16508 - call PlaceWholeStringInBoxAtOnce - call YesNoBox - ret c - ld a, [wDST] - res 7, a - ld [wDST], a - call Function164d1 - call Function164ea - bccoord 1, 14 - ld hl, UnknownText_0x1650d - call PlaceWholeStringInBoxAtOnce - ret - -.asm_16497 - ld hl, UnknownText_0x164fe - call PlaceWholeStringInBoxAtOnce - call YesNoBox - ret c - ld a, [wDST] - set 7, a - ld [wDST], a - call Function164b9 - call Function164ea - bccoord 1, 14 - ld hl, UnknownText_0x16503 - call PlaceWholeStringInBoxAtOnce - ret -; 164b9 - -Function164b9: ; 164b9 - ld a, [StartHour] - add 1 - sub 24 - jr nc, .asm_164c4 - add 24 -.asm_164c4 - ld [StartHour], a - ccf - ld a, [StartDay] - adc 0 - ld [StartDay], a - ret -; 164d1 - -Function164d1: ; 164d1 - ld a, [StartHour] - sub 1 - jr nc, .asm_164da - add 24 -.asm_164da - ld [StartHour], a - ld a, [StartDay] - sbc 0 - jr nc, .asm_164e6 - add 7 -.asm_164e6 - ld [StartDay], a - ret -; 164ea - -Function164ea: ; 164ea - hlcoord 1, 14 - ld bc, $0312 - call ClearBox - ret -; 164f4 - -UnknownText_0x164f4: ; 0x164f4 - ; Do you want to adjust your clock for Daylight Saving Time? - text_jump UnknownText_0x1c6095 - db "@" -; 0x164f9 - -LostInstructionBookletText: ; 0x164f9 - ; I lost the instruction booklet for the POKéGEAR. - ; Come back again in a while. - text_jump UnknownText_0x1c60d1 - db "@" -; 0x164fe - -UnknownText_0x164fe: ; 0x164fe - ; Do you want to switch to Daylight Saving Time? - text_jump UnknownText_0x1c6000 - db "@" -; 0x16503 - -UnknownText_0x16503: ; 0x16503 - ; I set the clock forward by one hour. - text_jump UnknownText_0x1c6030 - db "@" -; 0x16508 - -UnknownText_0x16508: ; 0x16508 - ; Is Daylight Saving Time over? - text_jump UnknownText_0x1c6056 - db "@" -; 0x1650d - -UnknownText_0x1650d: ; 0x1650d - ; I put the clock back one hour. - text_jump UnknownText_0x1c6075 - db "@" -; 0x16512 - -Function16512: ; 16512 - ld de, String_1669f - jr Function1651a - -Function16517: ; 16517 - ld de, String_166a8 - -Function1651a: ; 1651a - push de - xor a - ld [hBGMapMode], a - hlcoord 0, 0 - lb bc, 6, 18 - call TextBox - hlcoord 1, 2 - ld de, String_16699 - call PlaceString - hlcoord 12, 2 - ld de, wd851 - lb bc, PRINTNUM_MONEY | 3, 6 - call PrintNum - hlcoord 1, 4 - ld de, String_166b0 - call PlaceString - hlcoord 12, 4 - ld de, Money - lb bc, PRINTNUM_MONEY | 3, 6 - call PrintNum - hlcoord 1, 6 - pop de - call PlaceString - hlcoord 12, 6 - ld de, StringBuffer2 - lb bc, PRINTNUM_MONEY | PRINTNUM_LEADINGZEROS | 3, 6 - call PrintNum - call UpdateSprites - call Function3238 - ret -; 1656b - -Function1656b: ; 1656b - ld c, 10 - call DelayFrames - ret -; 16571 - -Function16571: ; 16571 -.asm_16571 - call Functiona57 - ld hl, hJoyPressed - ld a, [hl] - and $2 - jr nz, .asm_165b5 - ld a, [hl] - and $1 - jr nz, .asm_165b7 - call Function165b9 - xor a - ld [hBGMapMode], a - hlcoord 12, 6 - ld bc, $0007 - ld a, $7f - call ByteFill - hlcoord 12, 6 - ld de, StringBuffer2 - lb bc, PRINTNUM_MONEY | PRINTNUM_LEADINGZEROS | 3, 6 - call PrintNum - ld a, [$ff9b] - and $10 - jr nz, .asm_165b0 - hlcoord 13, 6 - ld a, [wcf64] - ld c, a - ld b, $0 - add hl, bc - ld [hl], $7f - -.asm_165b0 - call WaitBGMap - jr .asm_16571 - -.asm_165b5 - scf - ret - -.asm_165b7 - and a - ret -; 165b9 - -Function165b9: ; 165b9 - ld hl, $ffa9 - ld a, [hl] - and $40 - jr nz, .asm_165e3 - ld a, [hl] - and $80 - jr nz, .asm_165f5 - ld a, [hl] - and $20 - jr nz, .asm_165d2 - ld a, [hl] - and $10 - jr nz, .asm_165da - and a - ret - -.asm_165d2 - ld hl, wcf64 - ld a, [hl] - and a - ret z - dec [hl] - ret - -.asm_165da - ld hl, wcf64 - ld a, [hl] - cp $5 - ret nc - inc [hl] - ret - -.asm_165e3 - ld hl, Unknown_16613 - call Function16607 - ld c, l - ld b, h - ld de, StringBuffer2 - callba GiveMoney - ret - -.asm_165f5 - ld hl, Unknown_16613 - call Function16607 - ld c, l - ld b, h - ld de, StringBuffer2 - callba TakeMoney - ret -; 16607 - -Function16607: ; 16607 - ld a, [wcf64] - push de - ld e, a - ld d, 0 -rept 3 - add hl, de -endr - pop de - ret -; 16613 - -Unknown_16613: ; 16613 - dt 100000 - dt 10000 - dt 1000 - dt 100 - dt 10 - dt 1 - - dt 100000 - dt 10000 - dt 1000 - dt 100 - dt 10 - dt 1 - - dt 900000 - dt 90000 - dt 9000 - dt 900 - dt 90 - dt 9 -; 16649 - -UnknownText_0x16649: ; 0x16649 - ; Wow, that's a cute #MON. Where did you get it? … So, you're leaving on an adventure… OK! I'll help too. But what can I do for you? I know! I'll save money for you. On a long journey, money's important. Do you want me to save your money? - text_jump UnknownText_0x1bd77f - db "@" -; 0x1664e - -UnknownText_0x1664e: ; 0x1664e - ; OK, I'll take care of your money. - text_jump UnknownText_0x1bd868 - db "@" -; 0x16653 - -UnknownText_0x16653: ; 0x16653 - ; Be careful. #MON are your friends. You need to work as a team. Now, go on! - text_jump UnknownText_0x1bd88e - db "@" -; 0x16658 - -UnknownText_0x16658: ; 0x16658 - ; Hi! Welcome home! You're trying very hard, I see. I've kept your room tidy. Or is this about your money? - text_jump UnknownText_0x1bd8da - db "@" -; 0x1665d - -UnknownText_0x1665d: ; 0x1665d - ; What do you want to do? - text_jump UnknownText_0x1bd942 - db "@" -; 0x16662 - -UnknownText_0x16662: ; 0x16662 - ; How much do you want to save? - text_jump UnknownText_0x1bd95b - db "@" -; 0x16667 - -UnknownText_0x16667: ; 0x16667 - ; How much do you want to take? - text_jump UnknownText_0x1bd97a - db "@" -; 0x1666c - -UnknownText_0x1666c: ; 0x1666c - ; Do you want to save some money? - text_jump UnknownText_0x1bd999 - db "@" -; 0x16671 - -UnknownText_0x16671: ; 0x16671 - ; You haven't saved that much. - text_jump UnknownText_0x1bd9ba - db "@" -; 0x16676 - -UnknownText_0x16676: ; 0x16676 - ; You can't take that much. - text_jump UnknownText_0x1bd9d7 - db "@" -; 0x1667b - -UnknownText_0x1667b: ; 0x1667b - ; You don't have that much. - text_jump UnknownText_0x1bd9f1 - db "@" -; 0x16680 - -UnknownText_0x16680: ; 0x16680 - ; You can't save that much. - text_jump UnknownText_0x1bda0b - db "@" -; 0x16685 - -UnknownText_0x16685: ; 0x16685 - ; OK, I'll save your money. Trust me! , stick with it! - text_jump UnknownText_0x1bda25 - db "@" -; 0x1668a - -UnknownText_0x1668a: ; 0x1668a - ; Your money's safe here! Get going! - text_jump UnknownText_0x1bda5b - db "@" -; 0x1668f - -UnknownText_0x1668f: ; 0x1668f - ; , don't give up! - text_jump UnknownText_0x1bda7e - db "@" -; 0x16694 - -UnknownText_0x16694: ; 0x16694 - ; Just do what you can. - text_jump UnknownText_0x1bda90 - db "@" -; 0x16699 - -String_16699: ; 16699 - db "SAVED@" -; 1669f - -String_1669f: ; 1669f - db "WITHDRAW@" -; 166a8 - -String_166a8: ; 166a8 - db "DEPOSIT@" -; 166b0 - -String_166b0: ; 166b0 - db "HELD@" -; 166b5 - -MenuDataHeader_0x166b5: ; 0x166b5 - db $40 ; flags - db 00, 00 ; start coords - db 10, 10 ; end coords - dw MenuData2_0x166bd - db 1 ; default option -; 0x166bd - -MenuData2_0x166bd: ; 0x166bd - db $80 ; flags - db 4 ; items - db "GET@" - db "SAVE@" - db "CHANGE@" - db "CANCEL@" -; 0x166d6 +INCLUDE "event/mom.asm" Special_DayCareMan: ; 166d6 ld hl, wDaycareMan @@ -20497,11 +19747,11 @@ Function1678f: ; 1678f Function16798: ; 16798 ld a, [PartyCount] - cp $2 + cp 2 jr c, .asm_167e5 - ld a, $4 + ld a, 4 call Function1689b - ld b, $6 + ld b, 6 callba Function5001d jr c, .asm_167dd ld a, [CurPartySpecies] @@ -22274,10 +21524,10 @@ INCBIN "gfx/unknown/017393.2bpp" Function173b3: ; 173b3 (5:73b3) callba Function8cf53 ld hl, Unknown_173ef -.asm_173bc +.loop ld a, [hli] cp $ff - jr z, .asm_173e5 + jr z, .done ld e, a ld a, [hli] ld d, a @@ -22302,8 +21552,8 @@ Function173b3: ; 173b3 (5:73b3) add hl, bc ld [hl], d pop hl - jr .asm_173bc -.asm_173e5 + jr .loop +.done ld de, SFX_EGG_HATCH call PlaySFX call Function1727f @@ -23811,13 +23061,13 @@ Function2466f: ; 2466f Function24673: ; 24673 ld a, [wcf91] bit 7, a - jp z, Function2ec8 + jp z, xor_a_dec_a ld a, [wcfa9] dec a call Function248d5 ld a, [MenuSelection] cp $ff - jp z, Function2ec8 + jp z, xor_a_dec_a call Function246fc dec a ld [wcf77], a @@ -23829,7 +23079,7 @@ Function24673: ; 24673 Function24695: ; 24695 ld a, [wcf91] bit 6, a - jp z, Function2ec8 + jp z, xor_a_dec_a ld a, $8 scf ret @@ -23838,10 +23088,10 @@ Function24695: ; 24695 Function246a1: ; 246a1 ld hl, wcfa6 bit 7, [hl] - jp z, Function2ec8 + jp z, xor_a_dec_a ld a, [wcf91] bit 3, a - jp z, Function2ec8 + jp z, xor_a_dec_a ld a, $20 scf ret @@ -23850,10 +23100,10 @@ Function246a1: ; 246a1 Function246b5: ; 246b5 ld hl, wcfa6 bit 7, [hl] - jp z, Function2ec8 + jp z, xor_a_dec_a ld a, [wcf91] bit 2, a - jp z, Function2ec8 + jp z, xor_a_dec_a ld a, $10 scf ret @@ -23862,22 +23112,22 @@ Function246b5: ; 246b5 Function246c9: ; 246c9 ld hl, wcfa6 bit 7, [hl] - jp z, Function2ec6 + jp z, xor_a ld hl, wd0e4 ld a, [hl] and a jr z, .asm_246dc dec [hl] - jp Function2ec6 + jp xor_a .asm_246dc - jp Function2ec8 + jp xor_a_dec_a ; 246df Function246df: ; 246df ld hl, wcfa6 bit 7, [hl] - jp z, Function2ec6 + jp z, xor_a ld hl, wd0e4 ld a, [wcf92] add [hl] @@ -23886,10 +23136,10 @@ Function246df: ; 246df cp b jr c, .asm_246f9 inc [hl] - jp Function2ec6 + jp xor_a .asm_246f9 - jp Function2ec8 + jp xor_a_dec_a ; 246fc Function246fc: ; 246fc @@ -24577,8 +23827,8 @@ MenuDataHeader_0x24b1d: ; 0x24b1d Function24b25: ; 24b25 hlcoord 11, 0 - ld b, $1 - ld c, $7 + ld b, 1 + ld c, 7 call TextBox hlcoord 12, 0 ld de, CoinString @@ -25737,7 +24987,7 @@ Function25299: ; 25299 (9:5299) ld de, Tilemap_252fc call Function253a8 hlcoord 14, 1 - ld bc, $507 + lb bc, 5, 7 xor a ld [$ffad], a predef FillBox @@ -25768,7 +25018,7 @@ Function2530a: ; 2530a (9:530a) call CountSetBits ld de, wd265 hlcoord 15, 10 - ld bc, $103 + lb bc, 1, 3 call PrintNum call Function25415 hlcoord 2, 8 @@ -25927,7 +25177,7 @@ Function253f4: ; 253f4 (9:53f4) Function25415: ; 25415 (9:5415) hlcoord 11, 12 ld de, GameTimeHours - ld bc, $204 + lb bc, 2, 4 call PrintNum inc hl ld de, GameTimeMinutes @@ -34431,7 +33681,7 @@ Function2c9e2: ; 2c9e2 (b:49e2) ld a, b ld [wd265], a ld de, wd265 - ld bc, $102 + lb bc, 1, 2 call PrintNum .asm_2ca6f pop bc @@ -38300,12 +37550,12 @@ endr Function487ff: ; 487ff (12:47ff) push hl - ld a, $7f + ld a, " " ld [hli], a ld [hl], a pop hl - ld b, $81 - ld c, $3 + ld b, PRINTNUM_LEADINGZEROS | 1 + ld c, 3 call PrintNum ret ; 4880d (12:480d) @@ -45294,12 +44544,12 @@ Function4e013: ; 4e013 (13:6013) hlcoord 17, 14 call Function4e0d3 hlcoord 13, 10 - ld bc, $307 + lb bc, 3, 7 ld de, TempMonExp call PrintNum call Function4e0e7 hlcoord 13, 13 - ld bc, $307 + lb bc, 3, 7 ld de, Buffer1 ; wd1ea (aliases: MagikarpLength) call PrintNum ld de, String_4e136 @@ -48403,7 +47653,7 @@ PrintTempMonStats: ; 50b7b ld bc, SCREEN_WIDTH add hl, bc ld de, TempMonAttack - ld bc, $0203 + lb bc, 2, 3 call .PrintStat ld de, TempMonDefense call .PrintStat @@ -86312,384 +85562,11 @@ UnownWord25: unownword "YIELD" UnownWord26: unownword "ZOOM" ; fbb32 -Special_CheckMagikarpLength: ; fbb32 - callba SelectMonFromParty - jr c, .declined - ld a, [CurPartySpecies] - cp MAGIKARP - jr nz, .not_magikarp - ld a, [CurPartyMon] - ld hl, PartyMon1Species - ld bc, PartyMon2 - PartyMon1 - call AddNTimes - push hl - ld bc, MON_DVS - add hl, bc - ld d, h - ld e, l - pop hl - ld bc, MON_ID - add hl, bc - ld b, h - ld c, l - call CalcMagikarpLength - call Functionfbbdb - callba Function105f33 - ld hl, UnknownText_0xfbba9 - call PrintText - ld hl, Buffer1 - ld de, wdfe8 - ld c, $2 - call StringCmp - jr nc, .not_long_enough - ld hl, Buffer1 - ld de, wdfe8 - ld a, [hli] - ld [de], a - inc de - ld a, [hl] - ld [de], a - inc de - ld a, [CurPartyMon] - ld hl, PartyMonOT - call SkipNames - call CopyBytes - ld a, $3 - ld [ScriptVar], a - ret - -.not_long_enough - ld a, $2 - ld [ScriptVar], a - ret - -.declined - ld a, $1 - ld [ScriptVar], a - ret - -.not_magikarp - xor a - ld [ScriptVar], a - ret -; fbba9 - -UnknownText_0xfbba9: ; 0xfbba9 - ; Let me measure that MAGIKARP. …Hm, it measures @ . - text_jump UnknownText_0x1c1203 - db "@" -; 0xfbbae - -Functionfbbae: ; fbbae - ld hl, $96e0 - ld de, GFX_fbbbb - lb bc, BANK(GFX_fbbbb), $02 - call Request2bpp - ret -; fbbbb - -GFX_fbbbb: ; fbbb -INCBIN "gfx/unknown/0fbbbb.2bpp" -; fbbdb - -Functionfbbdb: ; fbbdb - call Functionfbbae - ld hl, StringBuffer1 - ld de, Buffer1 - lb bc, PRINTNUM_RIGHTALIGN | 1, 2 - call PrintNum - ld [hl], $6e - inc hl - ld de, Buffer2 - lb bc, PRINTNUM_RIGHTALIGN | 1, 2 - call PrintNum - ld [hl], $6f - inc hl - ld [hl], "@" - ret -; fbbfc - -INCLUDE "battle/magikarp_length.asm" - -Special_MagikarpHouseSign: ; fbcd2 - ld a, [wdfe8] - ld [Buffer1], a - ld a, [wdfe9] - ld [Buffer2], a - call Functionfbbdb - ld hl, UnknownText_0xfbce8 - call PrintText - ret -; fbce8 - -UnknownText_0xfbce8: ; 0xfbce8 - ; "CURRENT RECORD" - text_jump UnknownText_0x1c123a - db "@" -; 0xfbced +INCLUDE "event/magikarp.asm" INCLUDE "battle/hidden_power.asm" -Functionfbd54: ; fbd54 - xor a - ld [hBGMapMode], a ; $ff00+$d4 - ld a, [hBattleTurn] ; $ff00+$e4 - and a - jr z, .asm_fbd61 - call Functionfbd96 - jr .asm_fbd64 -.asm_fbd61 - call Functionfbd9d -.asm_fbd64 - call ClearBox - jr Functionfbd91 - -Functionfbd69: ; fbd69 (3e:7d69) - callba BattleCommanda6 - jr Functionfbd77 - -Functionfbd71: ; fbd71 (3e:7d71) - callba BattleCommanda7 - -Functionfbd77: ; fbd77 (3e:7d77) - xor a - ld [hBGMapMode], a ; $ff00+$d4 - ld a, [hBattleTurn] ; $ff00+$e4 - and a - jr z, .asm_fbd85 - call Functionfbd96 - xor a - jr .asm_fbd8a -.asm_fbd85 - call Functionfbd9d - ld a, $31 -.asm_fbd8a - ld [$ffad], a - predef FillBox -Functionfbd91: ; fbd91 (3e:7d91) - ld a, $1 - ld [hBGMapMode], a ; $ff00+$d4 - ret - -Functionfbd96: ; fbd96 (3e:7d96) - hlcoord 12, 0 - ld bc, $707 - ret - -Functionfbd9d: ; fbd9d (3e:7d9d) - hlcoord 2, 6 - ld bc, $606 - ret - - -DoWeatherModifiers: ; fbda4 - - ld de, .WeatherTypeModifiers - ld a, [Weather] - ld b, a - ld a, [wd265] ; move type - ld c, a - -.CheckWeatherType - ld a, [de] - inc de - cp $ff - jr z, .asm_fbdc0 - - cp b - jr nz, .NextWeatherType - - ld a, [de] - cp c - jr z, .ApplyModifier - -.NextWeatherType -rept 2 - inc de -endr - jr .CheckWeatherType - - -.asm_fbdc0 - ld de, .WeatherMoveModifiers - - ld a, BATTLE_VARS_MOVE_EFFECT - call GetBattleVar - ld c, a - -.CheckWeatherMove - ld a, [de] - inc de - cp $ff - jr z, .done - - cp b - jr nz, .NextWeatherMove - - ld a, [de] - cp c - jr z, .ApplyModifier - -.NextWeatherMove -rept 2 - inc de -endr - jr .CheckWeatherMove - -.ApplyModifier - xor a - ld [hMultiplicand + 0], a - ld hl, CurDamage - ld a, [hli] - ld [hMultiplicand + 1], a - ld a, [hl] - ld [hMultiplicand + 2], a - - inc de - ld a, [de] - ld [hMultiplier], a - - call Multiply - - ld a, 10 - ld [hDivisor], a - ld b, $4 - call Divide - - ld a, [hQuotient + 0] - and a - ld bc, $ffff - jr nz, .Update - - ld a, [hQuotient + 1] - ld b, a - ld a, [hQuotient + 2] - ld c, a - or b - jr nz, .Update - - ld bc, 1 - -.Update - ld a, b - ld [CurDamage], a - ld a, c - ld [CurDamage + 1], a - -.done - ret - -.WeatherTypeModifiers - db WEATHER_RAIN, WATER, 15 - db WEATHER_RAIN, FIRE, 05 - db WEATHER_SUN, FIRE, 15 - db WEATHER_SUN, WATER, 05 - db $ff - -.WeatherMoveModifiers - db WEATHER_RAIN, EFFECT_SOLARBEAM, 05 - db $ff -; fbe24 - - -DoBadgeTypeBoosts: ; fbe24 - ld a, [InLinkBattle] - and a - ret nz - - ld a, [InBattleTowerBattle] - and a - ret nz - - ld a, [hBattleTurn] - and a - ret nz - - push de - push bc - - ld hl, .BadgeTypes - - ld a, [KantoBadges] - ld b, a - ld a, [JohtoBadges] - ld c, a - -.CheckBadge - ld a, [hl] - cp $ff - jr z, .done - - srl b - rr c - jr nc, .NextBadge - - ld a, [wd265] ; move type - cp [hl] - jr z, .ApplyBoost - -.NextBadge - inc hl - jr .CheckBadge - -.ApplyBoost - ld a, [CurDamage] - ld h, a - ld d, a - ld a, [CurDamage + 1] - ld l, a - ld e, a - - srl d - rr e - srl d - rr e - srl d - rr e - - ld a, e - or d - jr nz, .asm_fbe6f - ld e, 1 - -.asm_fbe6f - add hl, de - jr nc, .Update - - ld hl, $ffff - -.Update - ld a, h - ld [CurDamage], a - ld a, l - ld [CurDamage + 1], a - -.done - pop bc - pop de - ret - -.BadgeTypes - db FLYING ; zephyrbadge - db BUG ; hivebadge - db NORMAL ; plainbadge - db GHOST ; fogbadge - db STEEL ; mineralbadge - db FIGHTING ; stormbadge - db ICE ; glacierbadge - db DRAGON ; risingbadge - - db ROCK ; boulderbadge - db WATER ; cascadebadge - db ELECTRIC ; thunderbadge - db GRASS ; rainbowbadge - db POISON ; soulbadge - db PSYCHIC ; marshbadge - db FIRE ; volcanobadge - db GROUND ; earthbadge - db $ff -; fbe91 - +INCLUDE "battle/misc.asm" SECTION "bank3F", ROMX, BANK[$3F] @@ -86732,7 +85609,7 @@ NPCTrade:: ; fcba8 jr c, .done ; Select givemon from party - ld b, $6 + ld b, 6 callba Function5001d ld a, TRADE_CANCEL jr c, .done @@ -90697,7 +89574,7 @@ Mobile_HallOfFame2:: mobile ; 0x105ef6 ret ; 105f33 -Function105f33: mobile ; 105f33 +MagikarpLength_Mobile: mobile ; 105f33 ld a, $5 call GetSRAMBank ld de, Buffer1 @@ -92253,7 +91130,7 @@ Function1dd6a9: ; 1dd6a9 Function1dd6bb: ; 1dd6bb (77:56bb) ld a, b - cp $c + cp 12 push af jr c, .asm_1dd6c7 jr z, .asm_1dd6cc @@ -92272,7 +91149,7 @@ Function1dd6bb: ; 1dd6bb (77:56bb) pop de pop hl ld [hl], $7f - ld bc, $102 + lb bc, 1, 2 call PrintNum ld [hl], $9c inc hl diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm index f60ce3bd1..3e000c054 100644 --- a/misc/mobile_40.asm +++ b/misc/mobile_40.asm @@ -1843,7 +1843,7 @@ Function100b9f: ; 100b9f callba Function3e786 ret z call Function100dd8 - jp c, Function2ec8 + jp c, xor_a_dec_a call Function100e72 call Function100bc2 push af diff --git a/misc/mobile_5f.asm b/misc/mobile_5f.asm index e56cd83e5..d722a59d4 100644 --- a/misc/mobile_5f.asm +++ b/misc/mobile_5f.asm @@ -4359,9 +4359,9 @@ Function17f382: ; 17f382 ld de, $b2f4 .asm_17f3ab - ld a, $82 + ld a, PRINTNUM_LEADINGZEROS | 2 ld b, a - ld a, $3 + ld a, 3 ld c, a call PrintNum call CloseSRAM diff --git a/text/common_3.asm b/text/common_3.asm index 02adfea43..cf5f9b4d8 100644 --- a/text/common_3.asm +++ b/text/common_3.asm @@ -1222,7 +1222,7 @@ UnknownText_0x1c123a: ; 1c123a text_from_ram StringBuffer1 text " caught by" line "@" - text_from_ram wdfe9 + 1 + text_from_ram wBestMagikarpLengthInches + 1 text_waitbutton db "@" ; 1c1260 diff --git a/wram.asm b/wram.asm index 128092942..85b8f6614 100644 --- a/wram.asm +++ b/wram.asm @@ -1191,6 +1191,7 @@ CurSpecies:: ; cf60 wcf61:: ds 2 wcf63:: ds 1 wNrOfBeatenBattleTowerTrainers:: +wMomBankDigitCursorPosition:: wcf64:: ds 1 IF !DEF(CRYSTAL11) wPokedexStatus:: @@ -2579,9 +2580,9 @@ wdfe4:: ds 1 wdfe5:: ds 1 wdfe6:: ds 1 wdfe7:: ds 1 -wdfe8:: ds 1 -wdfe9:: ds 1 - ds 1 +wBestMagikarpLengthFeet:: ds 1 +wBestMagikarpLengthInches:: ds 1 +wMagikarpRecordHoldersName:: ds 1 ds 1 wdfec:: ds 1 ds 3 From 0c39f6e273910be3b0ed9317e73c40615d789ae3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 12 Oct 2015 12:33:24 -0400 Subject: [PATCH 06/11] Happiness and Mystery Gift constants --- battle/core.asm | 25 +-- constants/deco_constants.asm | 15 +- constants/misc_constants.asm | 22 +++ engine/specials.asm | 6 +- home.asm | 4 +- items/item_effects.asm | 14 +- macros.asm | 12 ++ main.asm | 361 ++++++++++++++++++++-------------- maps/BluesHouse.asm | 2 +- maps/UndergroundWarehouse.asm | 4 +- maps/WarehouseEntrance.asm | 16 +- wram.asm | 1 + 12 files changed, 296 insertions(+), 186 deletions(-) diff --git a/battle/core.asm b/battle/core.asm index d8249bc98..5f355fc27 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -2815,21 +2815,22 @@ Function3d1aa: ; 3d1aa ld [hl], a ld [BattleMonStatus], a call UpdateBattleMonInParty - ld c, $6 + ld c, HAPPINESS_FAINTED + ; If TheirLevel > (YourLevel + 30), use a different parameter ld a, [BattleMonLevel] - add $1e + add 30 ld b, a ld a, [EnemyMonLevel] cp b jr c, .asm_3d1dc - ld c, $8 + ld c, HAPPINESS_BEATENBYSTRONGFOE .asm_3d1dc ld a, [CurBattleMon] ld [CurPartyMon], a callab ChangeHappiness ld a, [wd0ee] - and $c0 + and %11000000 add $1 ld [wd0ee], a ld a, [wc6f7] @@ -8526,28 +8527,28 @@ Function3f594: ; 3f594 ld [IsInBattle], a call IsJohtoGymLeader - jr nc, .asm_3f606 + jr nc, .done xor a ld [CurPartyMon], a ld a, [PartyCount] ld b, a -.asm_3f5ea +.partyloop push bc ld a, PartyMon1HP - PartyMon1 call GetPartyParamLocation ld a, [hli] or [hl] - jr z, .asm_3f5fc - ld c, $4 + jr z, .skipfaintedmon + ld c, HAPPINESS_GYMBATTLE callab ChangeHappiness -.asm_3f5fc +.skipfaintedmon pop bc dec b - jr z, .asm_3f606 + jr z, .done ld hl, CurPartyMon inc [hl] - jr .asm_3f5ea -.asm_3f606 + jr .partyloop +.done ret ; 3f607 diff --git a/constants/deco_constants.asm b/constants/deco_constants.asm index de8edb652..6f15b5f35 100644 --- a/constants/deco_constants.asm +++ b/constants/deco_constants.asm @@ -51,35 +51,36 @@ const_value = 1 const SET_UP_ORNAMENT const PUT_AWAY_ORNAMENT -const_value = 2 +const_value = 1 + const DECO_01 const DECO_FEATHERY_BED ; 2 const DECO_PINK_BED ; 3 const DECO_POLKADOT_BED ; 4 const DECO_PIKACHU_BED ; 5 -const_value = const_value + 1 + const DECO_06 const DECO_RED_CARPET ; 7 const DECO_BLUE_CARPET ; 8 const DECO_YELLOW_CARPET ; 9 const DECO_GREEN_CARPET ; a -const_value = const_value + 1 + const DECO_0B const DECO_MAGNAPLANT ; c const DECO_TROPICPLANT ; d const DECO_JUMBOPLANT ; e -const_value = const_value + 1 + const DECO_0F const DECO_TOWN_MAP ; 10 const DECO_PIKACHU_POSTER ; 11 const DECO_CLEFAIRY_POSTER ; 12 const DECO_JIGGLYPUFF_POSTER ; 13 -const_value = const_value + 1 + const DECO_14 const DECO_FAMICOM ; 15 const DECO_SNES ; 16 const DECO_N64 ; 17 const DECO_VIRTUAL_BOY ; 18 -const_value = const_value + 1 + const DECO_19 const DECO_BIG_SNORLAX_DOLL ; 1a const DECO_BIG_ONIX_DOLL ; 1b const DECO_BIG_LAPRAS_DOLL ; 1c -const_value = const_value + 1 + const DECO_1D const DECO_PIKACHU_DOLL ; 1e const DECO_SURF_PIKACHU_DOLL ; 1f const DECO_CLEFAIRY_DOLL ; 20 diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 784163acb..9678faf8a 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -124,3 +124,25 @@ PRINTNUM_LEADINGZEROS_F EQU 7 PRINTNUM_MONEY EQU 1 << PRINTNUM_MONEY_F PRINTNUM_RIGHTALIGN EQU 1 << PRINTNUM_RIGHTALIGN_F PRINTNUM_LEADINGZEROS EQU 1 << PRINTNUM_LEADINGZEROS_F + +const_value = 1 + const HAPPINESS_GAINLEVEL ; 01 + const HAPPINESS_USEDITEM ; 02 + const HAPPINESS_USEDXITEM ; 03 + const HAPPINESS_GYMBATTLE ; 04 + const HAPPINESS_LEARNMOVE ; 05 + const HAPPINESS_FAINTED ; 06 + const HAPPINESS_POISONFAINT ; 07 + const HAPPINESS_BEATENBYSTRONGFOE ; 08 + const HAPPINESS_YOUNGCUT1 ; 09 + const HAPPINESS_YOUNGCUT2 ; 0a + const HAPPINESS_YOUNGCUT3 ; 0b + const HAPPINESS_OLDERCUT1 ; 0c + const HAPPINESS_OLDERCUT2 ; 0d + const HAPPINESS_OLDERCUT3 ; 0e + const HAPPINESS_BITTERPOWDER ; 0f + const HAPPINESS_ENERGYROOT ; 10 + const HAPPINESS_REVIVALHERB ; 11 + const HAPPINESS_MASSAGE ; 12 + const HAPPINESS_GAINLEVELATHOME ; 13 + diff --git a/engine/specials.asm b/engine/specials.asm index 5db616f61..41b0d9e9a 100644 --- a/engine/specials.asm +++ b/engine/specials.asm @@ -117,9 +117,9 @@ SpecialsPointers:: ; c029 add_special RunCallback_04 add_special Functionfb841 add_special SpecialSnorlaxAwake - add_special Function7413 - add_special Function7418 - add_special Function741d + add_special Special_YoungerHaircutBrother + add_special Special_OlderHaircutBrother + add_special Special_DaisyMassage add_special Functionc472 add_special ProfOaksPCBoot add_special SpecialGameboyCheck diff --git a/home.asm b/home.asm index a7218f26c..ec4daa2d2 100644 --- a/home.asm +++ b/home.asm @@ -1115,7 +1115,7 @@ IsHMMove:: ; 34e7 db FLASH db WATERFALL db WHIRLPOOL - db $ff + db -1 ; 34f8 @@ -1125,7 +1125,7 @@ GetMoveName:: ; 34f8 ld a, MOVE_NAME ld [wcf61], a - ld a, [wd265] ; move id + ld a, [wNamedObjectIndexBuffer] ; move id ld [CurSpecies], a call GetName diff --git a/items/item_effects.asm b/items/item_effects.asm index d173165a7..fb76856ca 100644 --- a/items/item_effects.asm +++ b/items/item_effects.asm @@ -1259,7 +1259,7 @@ Calcium: ; ee3d ld h, [hl] ld l, a ld de, StringBuffer2 - ld bc, $000d + ld bc, ITEM_NAME_LENGTH call CopyBytes call Functionf780 @@ -1267,7 +1267,7 @@ Calcium: ; ee3d ld hl, UnknownText_0xeea6 call PrintText - ld c, $2 + ld c, HAPPINESS_USEDITEM callba ChangeHappiness jp Functionf795 @@ -1464,7 +1464,7 @@ HealPowder: ; efad cp $0 jr nz, .asm_efc9 - ld c, $f + ld c, HAPPINESS_BITTERPOWDER callba ChangeHappiness call LooksBitterMessage @@ -1632,7 +1632,7 @@ RevivalHerb: ; f0a9 cp 0 jr nz, .asm_f0c5 - ld c, $11 + ld c, HAPPINESS_REVIVALHERB callba ChangeHappiness call LooksBitterMessage ld a, 0 @@ -1780,12 +1780,12 @@ GoldBerry: ; f186 Energypowder: ; f18c - ld c, $f + ld c, HAPPINESS_BITTERPOWDER jr Functionf192 ; f190 EnergyRoot: ; f190 - ld c, $10 + ld c, HAPPINESS_ENERGYROOT ; f192 Functionf192: ; f192 @@ -2348,7 +2348,7 @@ endr ld a, [CurBattleMon] ld [CurPartyMon], a - ld c, $3 + ld c, HAPPINESS_USEDXITEM callba ChangeHappiness ret ; f504 diff --git a/macros.asm b/macros.asm index 4370886b2..ca62491eb 100644 --- a/macros.asm +++ b/macros.asm @@ -149,3 +149,15 @@ bcd: MACRO shift endr ENDM + +ln: MACRO + if _NARG == 5 + lb \1, \2 << 4 + \3, \4 << 4 + \5 + else + if _NARG == 3 + ld \1, \2 << 4 + \3 + else + fail "incorrect number of arguments for ln" + endc + endc +ENDM diff --git a/main.asm b/main.asm index d4ea3adf1..95d1ca829 100644 --- a/main.asm +++ b/main.asm @@ -2786,18 +2786,18 @@ endr db +3, +2, +1 ; Battled a Gym Leader db +1, +1, +0 ; Learned a move db -1, -1, -1 ; Lost to an enemy - db -5, -5, -10 + db -5, -5, -10 ; Fainted due to poison db -5, -5, -10 ; Lost to a much weaker enemy - db +1, +1, +1 - db +3, +3, +1 - db +5, +5, +2 - db +1, +1, +1 - db +3, +3, +1 - db +10, +10, +4 + db +1, +1, +1 ; Haircut? + db +3, +3, +1 ; Haircut? + db +5, +5, +2 ; Haircut? + db +1, +1, +1 ; Haircut? + db +3, +3, +1 ; Haircut? + db +10, +10, +4 ; Haircut? db -5, -5, -10 ; Used Heal Powder or Energypowder (bitter) db -10, -10, -15 ; Used Energy Root (bitter) db -15, -15, -20 ; Used Revival Herb (bitter) - db +3, +3, +1 + db +3, +3, +1 ; Massage? db +10, +6, +4 ; Gained a level in the place where it was caught ; 725a @@ -3081,18 +3081,18 @@ Function73f7: ; 73f7 ret ; 7413 -Function7413: ; 7413 - ld hl, Data7459 - jr Function7420 +Special_YoungerHaircutBrother: ; 7413 + ld hl, Data_YoungerHaircutBrother + jr MassageOrHaircut -Function7418: ; 7418 - ld hl, Data7462 - jr Function7420 +Special_OlderHaircutBrother: ; 7418 + ld hl, Data_OlderHaircutBrother + jr MassageOrHaircut -Function741d: ; 741d - ld hl, Data746b +Special_DaisyMassage: ; 741d + ld hl, Data_DaisyMassage -Function7420: ; 7420 +MassageOrHaircut: ; 7420 push hl callba SelectMonFromParty pop hl @@ -3105,6 +3105,13 @@ Function7420: ; 7420 call CopyPokemonName_Buffer1_Buffer3 pop hl call Random +; Bug: Subtracting $ff from $ff fails to set c. +; This can result in overflow into the next data array. +; In the case of getting a massage from Daisy, we bleed +; into CopyPokemonName_Buffer1_Buffer3, which passes +; $d0 to ChangeHappiness and returns $73 to the script. +; The end result is that there is a 0.4% chance your +; Pokemon's happiness will not change at all. .loop sub [hl] jr c, .ok @@ -3127,23 +3134,23 @@ endr ret .egg - ld a, $1 + ld a, 1 ld [ScriptVar], a ret ; 7459 -Data7459: ; 7459 - db $4c, $02, $09 - db $80, $03, $0a - db $ff, $04, $0b +Data_YoungerHaircutBrother: ; 7459 + db $4c, 2, HAPPINESS_YOUNGCUT1 ; 30% chance + db $80, 3, HAPPINESS_YOUNGCUT2 ; 20% chance + db $ff, 4, HAPPINESS_YOUNGCUT3 ; 50% chance -Data7462: ; 7462 - db $9a, $02, $0c - db $4c, $03, $0d - db $ff, $04, $0e +Data_OlderHaircutBrother: ; 7462 + db $9a, 2, HAPPINESS_OLDERCUT1 ; 60% chance + db $4c, 3, HAPPINESS_OLDERCUT2 ; 10% chance + db $ff, 4, HAPPINESS_OLDERCUT3 ; 30% chance -Data746b: ; 746b - db $ff, $02, $12 +Data_DaisyMassage: ; 746b + db $ff, 2, HAPPINESS_MASSAGE ; 99.6% chance ; 746e CopyPokemonName_Buffer1_Buffer3: ; 746e @@ -27048,9 +27055,9 @@ LevelUpHappinessMod: ; 2709e ld c, a call GetWorldMapLocation cp d - ld c, 1 + ld c, HAPPINESS_GAINLEVEL jr nz, .ok - ld c, 19 + ld c, HAPPINESS_GAINLEVELATHOME .ok callab ChangeHappiness @@ -33151,73 +33158,77 @@ Function2c642: ; 2c642 (b:4642) call CloseSRAM ld hl, OverworldMap ld de, wc950 - ld bc, $14 + ld bc, SCREEN_WIDTH jp CopyBytes Function2c6ac: ; 2c6ac (b:46ac) push de call Random - cp $19 - jr c, .asm_2c6cc + cp $19 ; 10 percent + jr c, .tenpercent call Random and $7 ld d, a rl d ld e, $80 -.asm_2c6be +.loop rlc e dec a - jr nz, .asm_2c6be + jr nz, .loop ld a, e and c - jr z, .asm_2c6c9 + jr z, .skip ld a, $1 -.asm_2c6c9 +.skip add d - jr .asm_2c706 -.asm_2c6cc + jr .done + +.tenpercent call Random - cp $32 - jr c, .asm_2c6ed + cp $32 ; 20 percent + jr c, .twopercent call Random and $3 ld d, a rl d ld e, $80 -.asm_2c6dd +.loop2 rlc e dec a - jr nz, .asm_2c6dd + jr nz, .loop2 ld a, e and b - jr z, .asm_2c6e8 + jr z, .skip2 ld a, $1 -.asm_2c6e8 +.skip2 add d add $10 - jr .asm_2c706 -.asm_2c6ed + jr .done + +.twopercent call Random - cp $32 - jr c, .asm_2c6fd + cp $32 ; 50 ; 20 percent + jr c, .pointfourpercent ld a, b swap a and $7 add $18 - jr .asm_2c706 -.asm_2c6fd + jr .done + +.pointfourpercent ld a, b and $80 ld a, $20 - jr z, .asm_2c706 + jr z, .done ld a, $21 -.asm_2c706 + +.done pop de ret -Function2c708: ; 2c708 (b:4708) +MysteryGiftGetItem: ; 2c708 (b:4708) ld a, c - cp $25 + cp $25 ; 37 jr nc, Function2c722 ld hl, Unknown_2c725 ld b, 0 @@ -33225,9 +33236,9 @@ Function2c708: ; 2c708 (b:4708) ld c, [hl] ret -Function2c715: ; 2c715 (b:4715) +MysteryGiftGetDecoration: ; 2c715 (b:4715) ld a, c - cp $25 + cp $25 ; 37 jr nc, Function2c722 ld hl, Unknown_2c74a ld b, 0 @@ -33236,32 +33247,90 @@ Function2c715: ; 2c715 (b:4715) ret Function2c722: ; 2c722 (b:4722) - ld c, $4 + ld c, DECO_POLKADOT_BED ; GREAT_BALL ret ; 2c725 (b:4725) Unknown_2c725: ; 2c725 ; May or may not be items. - db $ad, $4e, $54, $50, $4f - db $4a, $29, $33, $31, $53 - db $2c, $35, $21, $b9, $ba - db $bc, $6d, $ae, $27, $04 - db $2a, $2b, $41, $3f, $18 - db $16, $22, $17, $40, $15 - db $28, $8c, $1a, $3e, $20 - db $bb, $bd + db BERRY + db PRZCUREBERRY + db MINT_BERRY + db ICE_BERRY + db BURNT_BERRY + db PSNCUREBERRY + db GUARD_SPEC + db X_DEFEND + db X_ATTACK + db BITTER_BERRY + db DIRE_HIT + db X_SPECIAL + db X_ACCURACY + db EON_MAIL + db MORPH_MAIL + db MUSIC_MAIL + db MIRACLEBERRY + db GOLD_BERRY + db REVIVE + db GREAT_BALL + db SUPER_REPEL + db MAX_REPEL + db ELIXER + db ETHER + db WATER_STONE + db FIRE_STONE + db LEAF_STONE + db THUNDERSTONE + db MAX_ETHER + db MAX_ELIXER + db MAX_REVIVE + db SCOPE_LENS + db HP_UP + db PP_UP + db RARE_CANDY + db BLUESKY_MAIL + db MIRAGE_MAIL ; 2c74a Unknown_2c74a: ; 2c74a ; May or may not be items. - db $16, $1a, $1b, $1c, $1d - db $1e, $1f, $20, $21, $22 - db $0d, $0e, $10, $23, $25 - db $26, $08, $09, $0f, $11 - db $17, $19, $01, $02, $04 - db $05, $06, $07, $0a, $12 - db $29, $0c, $2a, $14, $03 - db $24, $27 + db DECO_SNES + db DECO_BIG_SNORLAX_DOLL + db DECO_BIG_ONIX_DOLL + db DECO_BIG_LAPRAS_DOLL + db DECO_1D + db DECO_PIKACHU_DOLL + db DECO_SURF_PIKACHU_DOLL + db DECO_CLEFAIRY_DOLL + db DECO_JIGGLYPUFF_DOLL + db DECO_BULBASAUR_DOLL + db DECO_TROPICPLANT + db DECO_JUMBOPLANT + db DECO_TOWN_MAP + db DECO_CHARMANDER_DOLL + db DECO_POLIWAG_DOLL + db DECO_DIGLETT_DOLL + db DECO_BLUE_CARPET + db DECO_YELLOW_CARPET + db DECO_0F + db DECO_PIKACHU_POSTER + db DECO_N64 + db DECO_19 + db DECO_01 + db DECO_FEATHERY_BED + db DECO_POLKADOT_BED + db DECO_PIKACHU_BED + db DECO_06 + db DECO_RED_CARPET + db DECO_GREEN_CARPET + db DECO_CLEFAIRY_POSTER + db DECO_ODDISH_DOLL + db DECO_MAGNAPLANT + db DECO_GENGAR_DOLL + db DECO_14 + db DECO_PINK_BED + db DECO_SQUIRTLE_DOLL + db DECO_STARMIE_DOLL ; 2c76f Function2c76f: ; 2c76f (b:476f) @@ -33294,16 +33363,16 @@ Function2c798: ; 2c798 (b:4798) ld [CurItem], a ret -Function2c7a7: ; 2c7a7 (b:47a7) +ConvertCurItemIntoCurTMHM: ; 2c7a7 (b:47a7) ld a, [CurItem] ld c, a callab GetTMHMNumber ld a, c - ld [wd265], a + ld [wCurTMHM], a ret GetTMHMItemMove: ; 2c7b6 (b:47b6) - call Function2c7a7 + call ConvertCurItemIntoCurTMHM predef GetTMHMMove ret @@ -33314,23 +33383,23 @@ Function2c7bf: ; 2c7bf (b:47bf) res 4, [hl] ld a, [CurItem] cp TM01 - jr c, .asm_2c7f5 + jr c, .NotTMHM call GetTMHMItemMove - ld a, [wd265] + ld a, [wCurTMHM] ld [wd262], a call GetMoveName call CopyName1 - ld hl, UnknownText_0x2c8bf + ld hl, UnknownText_0x2c8bf ; Booted up a TM ld a, [CurItem] cp HM01 - jr c, .asm_2c7e9 - ld hl, UnknownText_0x2c8c4 -.asm_2c7e9 + jr c, .TM + ld hl, UnknownText_0x2c8c4 ; Booted up an HM +.TM call PrintText ld hl, UnknownText_0x2c8c9 call PrintText call YesNoBox -.asm_2c7f5 +.NotTMHM pop bc ld a, b ld [Options], a @@ -33340,7 +33409,7 @@ Function2c7bf: ; 2c7bf (b:47bf) Function2c7fb: ; 2c7fb ld hl, StringBuffer2 ld de, wd066 - ld bc, $000c + ld bc, $c call CopyBytes call WhiteBGMap @@ -33350,7 +33419,7 @@ Function2c80a: ; 2c80a callba Function503e0 ld a, $3 ld [PartyMenuActionText], a -.asm_2c821 +.loopback callba WritePartyMenuTilemap callba PrintPartyMenuText call WaitBGMap @@ -33360,17 +33429,17 @@ Function2c80a: ; 2c80a push af ld a, [CurPartySpecies] cp EGG - pop bc - jr z, .asm_2c854 + pop bc ; now contains the former contents of af + jr z, .egg push bc ld hl, wd066 ld de, StringBuffer2 - ld bc, $000c + ld bc, $c call CopyBytes - pop af + pop af ; now contains the original contents of af ret -.asm_2c854 +.egg push hl push de push bc @@ -33382,7 +33451,7 @@ Function2c80a: ; 2c80a pop bc pop de pop hl - jr .asm_2c821 + jr .loopback ; 2c867 Function2c867: ; 2c867 @@ -33396,35 +33465,35 @@ Function2c867: ; 2c867 ld a, c and a - jr nz, .asm_2c88b + jr nz, .compatible push de ld de, SFX_WRONG call PlaySFX pop de ld hl, UnknownText_0x2c8ce call PrintText - jr .asm_2c8b6 -.asm_2c88b + jr .nope +.compatible callab KnowsMove - jr c, .asm_2c8b6 + jr c, .nope predef LearnMove ld a, b and a - jr z, .asm_2c8b6 + jr z, .nope callba Function106049 ld a, [CurItem] call IsHM ret c - ld c, $5 + ld c, HAPPINESS_LEARNMOVE callab ChangeHappiness call Function2cb0c jr .asm_2c8bd -.asm_2c8b6 +.nope and a ret @@ -33584,7 +33653,7 @@ Function2c9af: ; 2c9af (b:49af) Function2c9b1: ; 2c9b1 (b:49b1) ld a, b bit 7, a - jr nz, .asm_2c9c5 + jr nz, .skip ld hl, wd0e2 ld a, [hl] and a @@ -33592,19 +33661,20 @@ Function2c9b1: ; 2c9b1 (b:49b1) dec [hl] call Function2c9e2 jp Function2c946 -.asm_2c9c5 + +.skip call Function2cab5 ld b, $5 -.asm_2c9ca +.loop inc c ld a, c - cp $3a + cp NUM_TMS + NUM_HMS + 1 jp nc, Function2c915 ld a, [hli] and a - jr z, .asm_2c9ca + jr z, .loop dec b - jr nz, .asm_2c9ca + jr nz, .loop ld hl, wd0e2 inc [hl] call Function2c9e2 @@ -33617,18 +33687,18 @@ Function2c9e2: ; 2c9e2 (b:49e2) hlcoord 5, 2 ld bc, $a0f - ld a, $7f + ld a, " " call ClearBox call Function2cab5 ld d, $5 -.asm_2c9fa +.loop2 inc c ld a, c - cp $3a - jr nc, .asm_2ca77 + cp NUM_TMS + NUM_HMS + 1 + jr nc, .NotTMHM ld a, [hli] and a - jr z, .asm_2c9fa + jr z, .loop2 ld b, a ld a, c ld [wd265], a @@ -33638,24 +33708,25 @@ Function2c9e2: ; 2c9e2 (b:49e2) call Function2ca86 push hl ld a, [wd265] - cp $33 - jr nc, .asm_2ca22 + cp NUM_TMS + 1 + jr nc, .HM ld de, wd265 lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum - jr .asm_2ca38 -.asm_2ca22 + jr .okay + +.HM push af - sub $32 + sub NUM_TMS ld [wd265], a - ld [hl], $87 + ld [hl], "H" inc hl ld de, wd265 lb bc, PRINTNUM_RIGHTALIGN | 1, 2 call PrintNum pop af ld [wd265], a -.asm_2ca38 +.okay predef GetTMHMMove ld a, [wd265] ld [wd262], a @@ -33669,13 +33740,13 @@ Function2c9e2: ; 2c9e2 (b:49e2) pop bc ld a, c push bc - cp $33 - jr nc, .asm_2ca6f + cp NUM_TMS + 1 + jr nc, .hm2 ld bc, $1d add hl, bc ld [hl], $f1 inc hl - ld a, $f6 + ld a, "0" ; why are we doing this? pop bc push bc ld a, b @@ -33683,14 +33754,15 @@ Function2c9e2: ; 2c9e2 (b:49e2) ld de, wd265 lb bc, 1, 2 call PrintNum -.asm_2ca6f +.hm2 pop bc pop de pop hl dec d - jr nz, .asm_2c9fa - jr .asm_2ca85 -.asm_2ca77 + jr nz, .loop2 + jr .done + +.NotTMHM call Function2ca86 rept 3 inc hl @@ -33699,25 +33771,25 @@ endr ld de, String_2caae call PlaceString pop de -.asm_2ca85 +.done ret Function2ca86: ; 2ca86 (b:4a86) hlcoord 5, 0 ld bc, $28 - ld a, $6 + ld a, 6 sub d ld e, a -.asm_2ca90 +.loop add hl, bc dec e - jr nz, .asm_2ca90 + jr nz, .loop ret ; 2ca95 (b:4a95) Function2ca95: ; 2ca95 pop hl - ld bc, $0003 + ld bc, 3 add hl, bc predef GetTMHMMove ld a, [wd265] @@ -33738,14 +33810,14 @@ Function2cab5: ; 2cab5 (b:4ab5) ld a, [wd0e2] ld b, a inc b - ld c, $0 -.asm_2cabf + ld c, 0 +.loop inc c ld a, [hli] and a - jr z, .asm_2cabf + jr z, .loop dec b - jr nz, .asm_2cabf + jr nz, .loop dec hl dec c ret @@ -33767,7 +33839,7 @@ Function2cad6: ; 2cad6 (b:4ad6) ; 2cadf (b:4adf) Function2cadf: ; 2cadf - call Function2c7a7 + call ConvertCurItemIntoCurTMHM call Function2cafa ld hl, UnknownText_0x2caf0 jr nc, .asm_2caed @@ -33805,7 +33877,7 @@ Function2cafa: ; 2cafa ; 2cb0c Function2cb0c: ; 2cb0c (b:4b0c) - call Function2c7a7 + call ConvertCurItemIntoCurTMHM ld a, [wd265] dec a ld hl, TMsHMs @@ -38704,7 +38776,7 @@ Function492b9: ; 492b9 and a jr z, .didnt_learn - ld c, $5 + ld c, HAPPINESS_LEARNMOVE callab ChangeHappiness jr .learned @@ -47013,7 +47085,7 @@ Function5067b: ; 5067b ld a, [de] and 2 jr z, .asm_5069c - ld c, 7 + ld c, HAPPINESS_POISONFAINT callba ChangeHappiness callba GetPartyNick ld hl, PoisonFaintText @@ -87561,30 +87633,31 @@ DoMysteryGift: ; 1048ba (41:48ba) .asm_104963 ld a, [wc90f] and a - jr z, .asm_104990 + jr z, .item ld a, [wc911] ld c, a - callba Function2c715 + callba MysteryGiftGetDecoration push bc call Function105069 pop bc - jr nz, .asm_104990 + jr nz, .item callab GetDecorationName_c ld h, d ld l, e ld de, StringBuffer1 - ld bc, $d + ld bc, ITEM_NAME_LENGTH call CopyBytes ld hl, UnknownText_0x104a20 jr Function1049c5 -.asm_104990 + +.item call Function105106 ld a, [wc910] ld c, a - callba Function2c708 + callba MysteryGiftGetItem ld a, c ld [s0_abe4], a - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call CloseSRAM call GetItemName ld hl, UnknownText_0x104a1b diff --git a/maps/BluesHouse.asm b/maps/BluesHouse.asm index 60b9aa009..6639cbfc3 100644 --- a/maps/BluesHouse.asm +++ b/maps/BluesHouse.asm @@ -23,7 +23,7 @@ UnknownScript_0x19b0de: iffalse UnknownScript_0x19b124 writetext UnknownText_0x19b244 closetext - special Function741d + special Special_DaisyMassage if_equal 0, UnknownScript_0x19b124 if_equal 1, UnknownScript_0x19b12a setflag ENGINE_TEA_IN_BLUES_HOUSE diff --git a/maps/UndergroundWarehouse.asm b/maps/UndergroundWarehouse.asm index ba91e8684..bdc5d9bce 100644 --- a/maps/UndergroundWarehouse.asm +++ b/maps/UndergroundWarehouse.asm @@ -7,9 +7,9 @@ UndergroundWarehouse_MapScriptHeader: ; callbacks - dbw 5, UnknownScript_0x7d950 + dbw 5, .ResetSwitches -UnknownScript_0x7d950: +.ResetSwitches: clearevent EVENT_SWITCH_1 clearevent EVENT_SWITCH_2 clearevent EVENT_SWITCH_3 diff --git a/maps/WarehouseEntrance.asm b/maps/WarehouseEntrance.asm index 28416d159..7d30179da 100644 --- a/maps/WarehouseEntrance.asm +++ b/maps/WarehouseEntrance.asm @@ -194,7 +194,7 @@ OlderHaircutBrotherScript: if_equal $2, .NotEnoughMoney writetext UnknownText_0x7c69a keeptextopen - special Function7413 + special Special_YoungerHaircutBrother if_equal $0, .Refused if_equal $1, .Refused setflag ENGINE_GOLDENROD_UNDERGROUND_GOT_HAIRCUT @@ -277,7 +277,7 @@ YoungerHaircutBrotherScript: if_equal $2, .NotEnoughMoney writetext UnknownText_0x7c7f1 keeptextopen - special Function7418 + special Special_OlderHaircutBrother if_equal $0, .Refused if_equal $1, .Refused setflag ENGINE_GOLDENROD_UNDERGROUND_GOT_HAIRCUT @@ -342,21 +342,21 @@ YoungerHaircutBrotherScript: end UnknownScript_0x7c2bb: - writetext UnknownText_0x7c8bf + writetext HaircutBrosText_SlightlyHappier special Functionc472 closetext loadmovesprites end UnknownScript_0x7c2c4: - writetext UnknownText_0x7c8dc + writetext HaircutBrosText_Happier special Functionc472 closetext loadmovesprites end UnknownScript_0x7c2cd: - writetext UnknownText_0x7c8ee + writetext HaircutBrosText_MuchHappier special Functionc472 closetext loadmovesprites @@ -615,19 +615,19 @@ UnknownText_0x7c87b: line "done for today." done -UnknownText_0x7c8bf: +HaircutBrosText_SlightlyHappier: text_from_ram StringBuffer3 text " looks a" line "little happier." done -UnknownText_0x7c8dc: +HaircutBrosText_Happier: text_from_ram StringBuffer3 text " looks" line "happy." done -UnknownText_0x7c8ee: +HaircutBrosText_MuchHappier: text_from_ram StringBuffer3 text " looks" line "delighted!" diff --git a/wram.asm b/wram.asm index 85b8f6614..6c7d08f26 100644 --- a/wram.asm +++ b/wram.asm @@ -1854,6 +1854,7 @@ wd263:: ds 1 wd264:: ds 1 wFoundMatchingIDInParty:: wNamedObjectIndexBuffer:: +wCurTMHM:: wd265:: ds 1 wd266:: ds 1 wd267:: ds 1 From 8c2766e1b955b6b23a78d014340f51a281b2a114 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 13 Oct 2015 11:37:10 -0400 Subject: [PATCH 07/11] ldtile and dwtile macros added and globally implemented --- macros.asm | 15 +++++++ main.asm | 67 ++++++++++++++++-------------- misc/mobile_45.asm | 2 +- text/common_3.asm | 2 +- tilesets/animations.asm | 92 ++++++++++++++++++++--------------------- wram.asm | 8 +--- 6 files changed, 99 insertions(+), 87 deletions(-) diff --git a/macros.asm b/macros.asm index ca62491eb..a50c92b69 100644 --- a/macros.asm +++ b/macros.asm @@ -161,3 +161,18 @@ ln: MACRO endc endc ENDM + +dwtile: MACRO + dw (\1 << 4) + \2 + if _NARG > 2 + rept _NARG + -2 + dw \3 + shift + endr + endc +ENDM + +ldtile: MACRO + ld \1, (\2 << 4) + \3 +ENDM + diff --git a/main.asm b/main.asm index 95d1ca829..dd842038e 100644 --- a/main.asm +++ b/main.asm @@ -178,7 +178,7 @@ _ResetWRAM: ; 5bae call ByteFill ld hl, PlayerID - ld bc, wdff5 - PlayerID + ld bc, wPokemonDataEnd - PlayerID xor a call ByteFill @@ -2781,23 +2781,23 @@ endr .Actions db +5, +3, +2 ; Gained a level - db +5, +3, +2 ; Used a stat-boosting item (vitamin or X-item) - db +1, +1, +0 + db +5, +3, +2 ; Vitamin + db +1, +1, +0 ; X Item db +3, +2, +1 ; Battled a Gym Leader db +1, +1, +0 ; Learned a move db -1, -1, -1 ; Lost to an enemy db -5, -5, -10 ; Fainted due to poison - db -5, -5, -10 ; Lost to a much weaker enemy - db +1, +1, +1 ; Haircut? - db +3, +3, +1 ; Haircut? - db +5, +5, +2 ; Haircut? - db +1, +1, +1 ; Haircut? - db +3, +3, +1 ; Haircut? - db +10, +10, +4 ; Haircut? + db -5, -5, -10 ; Lost to a much stronger enemy + db +1, +1, +1 ; Haircut (Y1) + db +3, +3, +1 ; Haircut (Y2) + db +5, +5, +2 ; Haircut (Y3) + db +1, +1, +1 ; Haircut (O1) + db +3, +3, +1 ; Haircut (O2) + db +10, +10, +4 ; Haircut (O3) db -5, -5, -10 ; Used Heal Powder or Energypowder (bitter) db -10, -10, -15 ; Used Energy Root (bitter) db -15, -15, -20 ; Used Revival Herb (bitter) - db +3, +3, +1 ; Massage? + db +3, +3, +1 ; Grooming db +10, +6, +4 ; Gained a level in the place where it was caught ; 725a @@ -16846,51 +16846,51 @@ EmotesPointers: ; 144d dw ShockEmote db $40, BANK(ShockEmote) - dw $8f80 + dwtile $78, VTiles1 dw QuestionEmote db $40, BANK(QuestionEmote) - dw $8f80 + dwtile $78, VTiles1 dw HappyEmote db $40, BANK(HappyEmote) - dw $8f80 + dwtile $78, VTiles1 dw SadEmote db $40, BANK(SadEmote) - dw $8f80 + dwtile $78, VTiles1 dw HeartEmote db $40, BANK(HeartEmote) - dw $8f80 + dwtile $78, VTiles1 dw BoltEmote db $40, BANK(BoltEmote) - dw $8f80 + dwtile $78, VTiles1 dw SleepEmote db $40, BANK(SleepEmote) - dw $8f80 + dwtile $78, VTiles1 dw FishEmote db $40, BANK(FishEmote) - dw $8f80 + dwtile $78, VTiles1 dw FishingRodGFX + $00 db $10, BANK(FishingRodGFX) - dw $8fc0 + dwtile $7c, VTiles1 dw FishingRodGFX + $10 db $20, BANK(FishingRodGFX) - dw $8fc0 + dwtile $7c, VTiles1 dw FishingRodGFX + $30 db $20, BANK(FishingRodGFX) - dw $8fe0 + dwtile $7e, VTiles1 dw FishingRodGFX + $50 db $10, BANK(FishingRodGFX) - dw $8fe0 + dwtile $7e, VTiles1 ; 14495 @@ -66216,15 +66216,18 @@ Unknown_8e6a5: ; 8e6a5 Unknown_8e706: ; 8e706 - dbbw $80, $01, Function8e72a - dbbw $80, $01, Function8e72a - dbbw $80, $01, Function8e72a - dbbw $80, $01, Function8e72a - dbbw $10, $37, Function8e72a - dbbw $10, $11, Function8e72a - dbbw $10, $39, Function8e72a - dbbw $10, $24, Function8e72a - dbbw $10, $21, Function8e72a + dbbw $80, $01, Unknown_8e72a + dbbw $80, $01, Unknown_8e72a + dbbw $80, $01, Unknown_8e72a + dbbw $80, $01, Unknown_8e72a + dbbw $10, $37, Unknown_8e72a + dbbw $10, $11, Unknown_8e72a + dbbw $10, $39, Unknown_8e72a + dbbw $10, $24, Unknown_8e72a + dbbw $10, $21, Unknown_8e72a + +Unknown_8e72a: + ; nothing to see here Function8e72a: ; 8e72a add $10 diff --git a/misc/mobile_45.asm b/misc/mobile_45.asm index 25d753edc..7b4e8ca90 100644 --- a/misc/mobile_45.asm +++ b/misc/mobile_45.asm @@ -8345,7 +8345,7 @@ Function117bb6: ld a, [wd001] cp $f jr nz, .asm_117c16 ; 0x117c01 $13 - ld hl, wdfec + ld hl, wMagikarpRecordHoldersName + 2 ld de, wcd69 ld c, $10 .asm_117c0b diff --git a/text/common_3.asm b/text/common_3.asm index cf5f9b4d8..996678adf 100644 --- a/text/common_3.asm +++ b/text/common_3.asm @@ -1222,7 +1222,7 @@ UnknownText_0x1c123a: ; 1c123a text_from_ram StringBuffer1 text " caught by" line "@" - text_from_ram wBestMagikarpLengthInches + 1 + text_from_ram wMagikarpRecordHoldersName text_waitbutton db "@" ; 1c1260 diff --git a/tilesets/animations.asm b/tilesets/animations.asm index 8353cac30..58925161c 100644 --- a/tilesets/animations.asm +++ b/tilesets/animations.asm @@ -41,7 +41,7 @@ Tileset00Anim: ; 0xfc01b Tileset02Anim: ; 0xfc01b Tileset03Anim: ; 0xfc01b ; param, function - dw $9140, AnimateWaterTile + dwtile $14, VTiles2, AnimateWaterTile dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -56,9 +56,9 @@ Tileset03Anim: ; 0xfc01b Tileset25Anim: ; 0xfc047 ; param, function - dw $9140, AnimateWaterTile + dwtile $14, VTiles2, AnimateWaterTile dw NULL, WaitTileAnimation - dw $95f0, AnimateFountain + dwtile $5f, VTiles2, AnimateFountain dw NULL, WaitTileAnimation dw NULL, TileAnimationPalette dw NULL, WaitTileAnimation @@ -79,7 +79,7 @@ Tileset31Anim: ; 0xfc073 dw NULL, ForestTreeLeftAnimation2 dw NULL, ForestTreeRightAnimation2 dw NULL, AnimateFlowerTile - dw $9140, AnimateWaterTile + dwtile $14, VTiles2, AnimateWaterTile dw NULL, TileAnimationPalette dw NULL, NextTileFrame8 dw NULL, DoneTileAnimation @@ -87,7 +87,7 @@ Tileset31Anim: ; 0xfc073 Tileset01Anim: ; 0xfc0a3 ; param, function - dw $9140, AnimateWaterTile + dwtile $14, VTiles2, AnimateWaterTile dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation dw NULL, TileAnimationPalette @@ -104,9 +104,9 @@ Tileset01Anim: ; 0xfc0a3 TilesetAnimfc0d7: ; 0xfc0d7 ; param, function - dw $9030, WriteTileToBuffer + dwtile $03, VTiles2, WriteTileToBuffer dw wcf41, ScrollTileRightLeft - dw $9030, WriteTileFromBuffer + dwtile $03, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -119,9 +119,9 @@ TilesetAnimfc0d7: ; 0xfc0d7 TilesetAnimfc103: ; 0xfc103 ; param, function - dw $9140, WriteTileToBuffer + dwtile $14, VTiles2, WriteTileToBuffer dw wcf41, ScrollTileRightLeft - dw $9140, WriteTileFromBuffer + dwtile $14, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -134,7 +134,7 @@ TilesetAnimfc103: ; 0xfc103 Tileset09Anim: ; 0xfc12f ; param, function - dw $9140, AnimateWaterTile + dwtile $14, VTiles2, AnimateWaterTile dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -162,50 +162,50 @@ Tileset15Anim: ; 0xfc15f TilesetAnimfc17f: ; 0xfc17f ; param, function - dw $9530, WriteTileToBuffer + dwtile $53, VTiles2, WriteTileToBuffer dw wcf41, ScrollTileDown dw wcf41, ScrollTileDown - dw $9530, WriteTileFromBuffer - dw $9030, WriteTileToBuffer + dwtile $53, VTiles2, WriteTileFromBuffer + dwtile $03, VTiles2, WriteTileToBuffer dw wcf41, ScrollTileRightLeft - dw $9030, WriteTileFromBuffer - dw $9530, WriteTileToBuffer + dwtile $03, VTiles2, WriteTileFromBuffer + dwtile $53, VTiles2, WriteTileToBuffer dw wcf41, ScrollTileDown dw wcf41, ScrollTileDown - dw $9530, WriteTileFromBuffer + dwtile $53, VTiles2, WriteTileFromBuffer dw NULL, DoneTileAnimation ; 0xfc1af TilesetAnimfc1af: ; 0xfc1af ; param, function - dw $9540, WriteTileToBuffer + dwtile $54, VTiles2, WriteTileToBuffer dw wcf41, ScrollTileDown dw wcf41, ScrollTileDown - dw $9540, WriteTileFromBuffer + dwtile $54, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation - dw $9030, WriteTileToBuffer + dwtile $03, VTiles2, WriteTileToBuffer dw wcf41, ScrollTileRightLeft - dw $9030, WriteTileFromBuffer + dwtile $03, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation - dw $9540, WriteTileToBuffer + dwtile $54, VTiles2, WriteTileToBuffer dw wcf41, ScrollTileDown dw wcf41, ScrollTileDown - dw $9540, WriteTileFromBuffer + dwtile $54, VTiles2, WriteTileFromBuffer dw NULL, DoneTileAnimation ; 0xfc1e7 Tileset24Anim: ; 0xfc1e7 Tileset30Anim: ; 0xfc1e7 ; param, function - dw $9140, WriteTileToBuffer + dwtile $14, VTiles2, WriteTileToBuffer dw NULL, Functionfc71e dw wcf41, ScrollTileRightLeft dw NULL, Functionfc71e - dw $9140, WriteTileFromBuffer + dwtile $14, VTiles2, WriteTileFromBuffer dw NULL, Functionfc71e dw NULL, TileAnimationPalette dw NULL, Functionfc71e - dw $9400, WriteTileToBuffer + dwtile $40, VTiles2, WriteTileToBuffer dw NULL, Functionfc71e dw wcf41, ScrollTileDown dw NULL, Functionfc71e @@ -213,22 +213,22 @@ Tileset30Anim: ; 0xfc1e7 dw NULL, Functionfc71e dw wcf41, ScrollTileDown dw NULL, Functionfc71e - dw $9400, WriteTileFromBuffer + dwtile $40, VTiles2, WriteTileFromBuffer dw NULL, Functionfc71e dw NULL, DoneTileAnimation ; 0xfc233 Tileset29Anim: ; 0xfc233 ; param, function - dw $9350, WriteTileToBuffer + dwtile $35, VTiles2, WriteTileToBuffer dw NULL, Functionfc71e dw wcf41, ScrollTileRightLeft dw NULL, Functionfc71e - dw $9350, WriteTileFromBuffer + dwtile $35, VTiles2, WriteTileFromBuffer dw NULL, Functionfc71e dw NULL, TileAnimationPalette dw NULL, Functionfc71e - dw $9310, WriteTileToBuffer + dwtile $31, VTiles2, WriteTileToBuffer dw NULL, Functionfc71e dw wcf41, ScrollTileDown dw NULL, Functionfc71e @@ -236,7 +236,7 @@ Tileset29Anim: ; 0xfc233 dw NULL, Functionfc71e dw wcf41, ScrollTileDown dw NULL, Functionfc71e - dw $9310, WriteTileFromBuffer + dwtile $31, VTiles2, WriteTileFromBuffer dw NULL, Functionfc71e dw NULL, DoneTileAnimation ; 0xfc27f @@ -262,9 +262,9 @@ Tileset23Anim: ; 0xfc27f ; 0xfc2bf TilesetAnimfc2bf: ; 0xfc2bf - dw $94f0, WriteTileToBuffer + dwtile $4f, VTiles2, WriteTileToBuffer dw wcf41, ScrollTileRightLeft - dw $94f0, WriteTileFromBuffer + dwtile $4f, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -1043,16 +1043,16 @@ Functionfc71e: ; fc71e ; fc750 -SproutPillarTilePointer1: dw $92d0, SproutPillarTile1 -SproutPillarTilePointer2: dw $92f0, SproutPillarTile2 -SproutPillarTilePointer3: dw $93d0, SproutPillarTile3 -SproutPillarTilePointer4: dw $93f0, SproutPillarTile4 -SproutPillarTilePointer5: dw $93c0, SproutPillarTile5 -SproutPillarTilePointer6: dw $92c0, SproutPillarTile6 -SproutPillarTilePointer7: dw $94d0, SproutPillarTile7 -SproutPillarTilePointer8: dw $94f0, SproutPillarTile8 -SproutPillarTilePointer9: dw $95d0, SproutPillarTile9 -SproutPillarTilePointer10: dw $95f0, SproutPillarTile10 +SproutPillarTilePointer1: dwtile $2d, VTiles2, SproutPillarTile1 +SproutPillarTilePointer2: dwtile $2f, VTiles2, SproutPillarTile2 +SproutPillarTilePointer3: dwtile $3d, VTiles2, SproutPillarTile3 +SproutPillarTilePointer4: dwtile $3f, VTiles2, SproutPillarTile4 +SproutPillarTilePointer5: dwtile $3c, VTiles2, SproutPillarTile5 +SproutPillarTilePointer6: dwtile $2c, VTiles2, SproutPillarTile6 +SproutPillarTilePointer7: dwtile $4d, VTiles2, SproutPillarTile7 +SproutPillarTilePointer8: dwtile $4f, VTiles2, SproutPillarTile8 +SproutPillarTilePointer9: dwtile $5d, VTiles2, SproutPillarTile9 +SproutPillarTilePointer10: dwtile $5f, VTiles2, SproutPillarTile10 SproutPillarTile1: INCBIN "gfx/tilesets/sprout-pillar/1.2bpp" SproutPillarTile2: INCBIN "gfx/tilesets/sprout-pillar/2.2bpp" @@ -1067,10 +1067,10 @@ SproutPillarTile10: INCBIN "gfx/tilesets/sprout-pillar/10.2bpp" ; fca98 -WhirlpoolFrames1: dw $9320, WhirlpoolTiles1 -WhirlpoolFrames2: dw $9330, WhirlpoolTiles2 -WhirlpoolFrames3: dw $9420, WhirlpoolTiles3 -WhirlpoolFrames4: dw $9430, WhirlpoolTiles4 +WhirlpoolFrames1: dwtile $32, VTiles2, WhirlpoolTiles1 +WhirlpoolFrames2: dwtile $33, VTiles2, WhirlpoolTiles2 +WhirlpoolFrames3: dwtile $42, VTiles2, WhirlpoolTiles3 +WhirlpoolFrames4: dwtile $43, VTiles2, WhirlpoolTiles4 ; fcaa8 WhirlpoolTiles1: INCBIN "gfx/tilesets/whirlpool/1.2bpp" diff --git a/wram.asm b/wram.asm index 6c7d08f26..822676377 100644 --- a/wram.asm +++ b/wram.asm @@ -2583,17 +2583,11 @@ wdfe6:: ds 1 wdfe7:: ds 1 wBestMagikarpLengthFeet:: ds 1 wBestMagikarpLengthInches:: ds 1 -wMagikarpRecordHoldersName:: ds 1 - ds 1 -wdfec:: ds 1 - ds 3 - - ds 5 +wMagikarpRecordHoldersName:: ds NAME_LENGTH wdff5:: wPokemonDataEnd:: - SECTION "Pic Animations", WRAMX, BANK [2] w2_d000:: ds $168 From 88bc86b0bba2e789955d644fd26ae5b57bc85880 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 13 Oct 2015 12:46:40 -0400 Subject: [PATCH 08/11] Replace Functionfb8 with FillBoxWithByte --- engine/pokedex.asm | 2 +- home/text.asm | 2 +- misc/mobile_40.asm | 2 +- misc/mobile_45.asm | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/engine/pokedex.asm b/engine/pokedex.asm index 89ca48ba8..970863675 100644 --- a/engine/pokedex.asm +++ b/engine/pokedex.asm @@ -2360,7 +2360,7 @@ Function413f5: ; 413f5 (10:53f5) ret Function413fe: ; 413fe (10:53fe) - jp Functionfb8 + jp FillBoxWithByte Function41401: ; 41401 (10:5401) ld a, [rSVBK] ; $ff00+$70 diff --git a/home/text.asm b/home/text.asm index fa8d3b23f..79f85d38b 100644 --- a/home/text.asm +++ b/home/text.asm @@ -16,7 +16,7 @@ ClearBox:: ; fb6 ld a, " " -Functionfb8:: +FillBoxWithByte:: .col push bc push hl diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm index 3e000c054..64608d2a8 100644 --- a/misc/mobile_40.asm +++ b/misc/mobile_40.asm @@ -7557,7 +7557,7 @@ Function1034e0: ; 1034e0 add hl, bc pop bc ld a, $6 - call Functionfb8 + call FillBoxWithByte ret ; 1034f1 diff --git a/misc/mobile_45.asm b/misc/mobile_45.asm index 7b4e8ca90..17300348a 100644 --- a/misc/mobile_45.asm +++ b/misc/mobile_45.asm @@ -8345,7 +8345,7 @@ Function117bb6: ld a, [wd001] cp $f jr nz, .asm_117c16 ; 0x117c01 $13 - ld hl, wMagikarpRecordHoldersName + 2 + ld hl, $e000 - 20 ld de, wcd69 ld c, $10 .asm_117c0b @@ -15254,7 +15254,7 @@ Function11b22a: ; 11b22a ; 11b236 Function11b236: ; 11b236 - jp Functionfb8 + jp FillBoxWithByte ; 11b239 Function11b239: ; 11b239 From 12f9dca7a59afa64388ae3aebc6e04c383992da9 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 13 Oct 2015 14:29:34 -0400 Subject: [PATCH 09/11] Final descriptive label in tilesets/animations.asm --- engine/save.asm | 2 +- macros.asm | 1 - main.asm | 44 +++++++------ sram.asm | 1 + tilesets/animations.asm | 134 ++++++++++++++++++---------------------- wram.asm | 3 +- 6 files changed, 88 insertions(+), 97 deletions(-) diff --git a/engine/save.asm b/engine/save.asm index 92b65398b..ef1917c83 100644 --- a/engine/save.asm +++ b/engine/save.asm @@ -225,7 +225,7 @@ SaveTheGame_yesorno: ; 14baf Function14bcb: ; 14bcb ld a, BANK(sPlayerData) call GetSRAMBank - ld hl, sPlayerData + (PlayerID - wPlayerData) + ld hl, sPlayerID ld a, [hli] ld c, [hl] ld b, a diff --git a/macros.asm b/macros.asm index a50c92b69..e366ad498 100644 --- a/macros.asm +++ b/macros.asm @@ -175,4 +175,3 @@ ENDM ldtile: MACRO ld \1, (\2 << 4) + \3 ENDM - diff --git a/main.asm b/main.asm index dd842038e..b67f8aff9 100644 --- a/main.asm +++ b/main.asm @@ -173,12 +173,12 @@ _ResetWRAM: ; 5bae call ByteFill ld hl, wd000 - ld bc, PlayerID - wd000 + ld bc, wGameData - wd000 xor a call ByteFill - ld hl, PlayerID - ld bc, wPokemonDataEnd - PlayerID + ld hl, wGameData + ld bc, wGameDataEnd - wGameData xor a call ByteFill @@ -61427,11 +61427,15 @@ endr ret ; 8c0e5 +brightlevel: MACRO + db (\1 << 6) | (\2 << 4) | (\3 << 2) | \4 +ENDM + Function8c0e5: ; 8c0e5 - ld hl, Unknown_8c10f + ld hl, .BrightnessLevels ld a, [wc2d0] - cp $4 - jr z, .asm_8c0fc + cp $4 ; Dark cave, needs Flash + jr z, .DarkCave and $7 add l ld l, a @@ -61441,28 +61445,28 @@ Function8c0e5: ; 8c0e5 ld a, [hl] ld [wd847], a ret -.asm_8c0fc +.DarkCave ld a, [StatusFlags] bit 2, a - jr nz, .asm_8c109 - ld a, $ff + jr nz, .UsedFlash + ld a, $ff ; 3, 3, 3, 3 ld [wd847], a ret -.asm_8c109 - ld a, $aa +.UsedFlash + ld a, $aa ; 2, 2, 2, 2 ld [wd847], a ret ; 8c10f (23:410f) -Unknown_8c10f: ; 8c10f - db $e4 ; 3210 - db $55 ; 1111 - db $aa ; 2222 - db $00 ; 0000 - db $ff ; 3333 - db $e4 ; 3210 - db $e4 ; 3210 - db $e4 ; 3210 +.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 diff --git a/sram.asm b/sram.asm index 1201925d9..6903f10e3 100644 --- a/sram.asm +++ b/sram.asm @@ -58,6 +58,7 @@ sOptions:: ds OptionsEnd - Options s1_a008:: ds 1 sGameData:: +sPlayerID:: sPlayerData:: ds wPlayerDataEnd - wPlayerData sMapData:: ds wMapDataEnd - wMapData sPokemonData:: ds wPokemonDataEnd - wPokemonData diff --git a/tilesets/animations.asm b/tilesets/animations.asm index 58925161c..14b3376d6 100644 --- a/tilesets/animations.asm +++ b/tilesets/animations.asm @@ -36,11 +36,9 @@ endr jp [hl] ; fc01b - Tileset00Anim: ; 0xfc01b Tileset02Anim: ; 0xfc01b Tileset03Anim: ; 0xfc01b -; param, function dwtile $14, VTiles2, AnimateWaterTile dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -55,7 +53,6 @@ Tileset03Anim: ; 0xfc01b ; 0xfc047 Tileset25Anim: ; 0xfc047 -; param, function dwtile $14, VTiles2, AnimateWaterTile dw NULL, WaitTileAnimation dwtile $5f, VTiles2, AnimateFountain @@ -70,7 +67,6 @@ Tileset25Anim: ; 0xfc047 ; 0xfc073 Tileset31Anim: ; 0xfc073 -; param, function dw NULL, ForestTreeLeftAnimation dw NULL, ForestTreeRightAnimation dw NULL, WaitTileAnimation @@ -86,7 +82,6 @@ Tileset31Anim: ; 0xfc073 ; 0xfc0a3 Tileset01Anim: ; 0xfc0a3 -; param, function dwtile $14, VTiles2, AnimateWaterTile dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -103,9 +98,8 @@ Tileset01Anim: ; 0xfc0a3 ; 0xfc0d7 TilesetAnimfc0d7: ; 0xfc0d7 -; param, function dwtile $03, VTiles2, WriteTileToBuffer - dw wcf41, ScrollTileRightLeft + dw AttrMapEnd, ScrollTileRightLeft dwtile $03, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -118,9 +112,8 @@ TilesetAnimfc0d7: ; 0xfc0d7 ; 0xfc103 TilesetAnimfc103: ; 0xfc103 -; param, function dwtile $14, VTiles2, WriteTileToBuffer - dw wcf41, ScrollTileRightLeft + dw AttrMapEnd, ScrollTileRightLeft dwtile $14, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -133,7 +126,6 @@ TilesetAnimfc103: ; 0xfc103 ; 0xfc12f Tileset09Anim: ; 0xfc12f -; param, function dwtile $14, VTiles2, AnimateWaterTile dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -149,7 +141,6 @@ Tileset09Anim: ; 0xfc12f ; 0xfc15f Tileset15Anim: ; 0xfc15f -; param, function dw NULL, SafariFountainAnim2 dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -161,88 +152,83 @@ Tileset15Anim: ; 0xfc15f ; 0xfc17f TilesetAnimfc17f: ; 0xfc17f -; param, function dwtile $53, VTiles2, WriteTileToBuffer - dw wcf41, ScrollTileDown - dw wcf41, ScrollTileDown + dw AttrMapEnd, ScrollTileDown + dw AttrMapEnd, ScrollTileDown dwtile $53, VTiles2, WriteTileFromBuffer dwtile $03, VTiles2, WriteTileToBuffer - dw wcf41, ScrollTileRightLeft + dw AttrMapEnd, ScrollTileRightLeft dwtile $03, VTiles2, WriteTileFromBuffer dwtile $53, VTiles2, WriteTileToBuffer - dw wcf41, ScrollTileDown - dw wcf41, ScrollTileDown + dw AttrMapEnd, ScrollTileDown + dw AttrMapEnd, ScrollTileDown dwtile $53, VTiles2, WriteTileFromBuffer dw NULL, DoneTileAnimation ; 0xfc1af TilesetAnimfc1af: ; 0xfc1af -; param, function dwtile $54, VTiles2, WriteTileToBuffer - dw wcf41, ScrollTileDown - dw wcf41, ScrollTileDown + dw AttrMapEnd, ScrollTileDown + dw AttrMapEnd, ScrollTileDown dwtile $54, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dwtile $03, VTiles2, WriteTileToBuffer - dw wcf41, ScrollTileRightLeft + dw AttrMapEnd, ScrollTileRightLeft dwtile $03, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dwtile $54, VTiles2, WriteTileToBuffer - dw wcf41, ScrollTileDown - dw wcf41, ScrollTileDown + dw AttrMapEnd, ScrollTileDown + dw AttrMapEnd, ScrollTileDown dwtile $54, VTiles2, WriteTileFromBuffer dw NULL, DoneTileAnimation ; 0xfc1e7 Tileset24Anim: ; 0xfc1e7 Tileset30Anim: ; 0xfc1e7 -; param, function dwtile $14, VTiles2, WriteTileToBuffer - dw NULL, Functionfc71e - dw wcf41, ScrollTileRightLeft - dw NULL, Functionfc71e + dw NULL, FlickeringCaveEntrancePalette + dw AttrMapEnd, ScrollTileRightLeft + dw NULL, FlickeringCaveEntrancePalette dwtile $14, VTiles2, WriteTileFromBuffer - dw NULL, Functionfc71e + dw NULL, FlickeringCaveEntrancePalette dw NULL, TileAnimationPalette - dw NULL, Functionfc71e + dw NULL, FlickeringCaveEntrancePalette dwtile $40, VTiles2, WriteTileToBuffer - dw NULL, Functionfc71e - dw wcf41, ScrollTileDown - dw NULL, Functionfc71e - dw wcf41, ScrollTileDown - dw NULL, Functionfc71e - dw wcf41, ScrollTileDown - dw NULL, Functionfc71e + dw NULL, FlickeringCaveEntrancePalette + dw AttrMapEnd, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette + dw AttrMapEnd, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette + dw AttrMapEnd, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette dwtile $40, VTiles2, WriteTileFromBuffer - dw NULL, Functionfc71e + dw NULL, FlickeringCaveEntrancePalette dw NULL, DoneTileAnimation ; 0xfc233 Tileset29Anim: ; 0xfc233 -; param, function dwtile $35, VTiles2, WriteTileToBuffer - dw NULL, Functionfc71e - dw wcf41, ScrollTileRightLeft - dw NULL, Functionfc71e + dw NULL, FlickeringCaveEntrancePalette + dw AttrMapEnd, ScrollTileRightLeft + dw NULL, FlickeringCaveEntrancePalette dwtile $35, VTiles2, WriteTileFromBuffer - dw NULL, Functionfc71e + dw NULL, FlickeringCaveEntrancePalette dw NULL, TileAnimationPalette - dw NULL, Functionfc71e + dw NULL, FlickeringCaveEntrancePalette dwtile $31, VTiles2, WriteTileToBuffer - dw NULL, Functionfc71e - dw wcf41, ScrollTileDown - dw NULL, Functionfc71e - dw wcf41, ScrollTileDown - dw NULL, Functionfc71e - dw wcf41, ScrollTileDown - dw NULL, Functionfc71e + dw NULL, FlickeringCaveEntrancePalette + dw AttrMapEnd, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette + dw AttrMapEnd, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette + dw AttrMapEnd, ScrollTileDown + dw NULL, FlickeringCaveEntrancePalette dwtile $31, VTiles2, WriteTileFromBuffer - dw NULL, Functionfc71e + dw NULL, FlickeringCaveEntrancePalette dw NULL, DoneTileAnimation ; 0xfc27f Tileset23Anim: ; 0xfc27f -; param, function dw SproutPillarTilePointer9, AnimateSproutPillarTile dw SproutPillarTilePointer10, AnimateSproutPillarTile dw SproutPillarTilePointer7, AnimateSproutPillarTile @@ -263,7 +249,7 @@ Tileset23Anim: ; 0xfc27f TilesetAnimfc2bf: ; 0xfc2bf dwtile $4f, VTiles2, WriteTileToBuffer - dw wcf41, ScrollTileRightLeft + dw AttrMapEnd, ScrollTileRightLeft dwtile $4f, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -299,7 +285,6 @@ Tileset33Anim: ; 0xfc2e7 Tileset34Anim: ; 0xfc2e7 Tileset35Anim: ; 0xfc2e7 Tileset36Anim: ; 0xfc2e7 -; param, function dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -875,14 +860,14 @@ AnimateWhirlpoolTile: ; fc678 WriteTileFromBuffer: ; fc696 -; Write tiledata at wcf41 to de. -; wcf41 is loaded to sp for WriteTile. +; Write tiledata at AttrMapEnd to de. +; AttrMapEnd is loaded to sp for WriteTile. ld hl, [sp+0] ld b, h ld c, l - ld hl, wcf41 + ld hl, AttrMapEnd ld sp, hl ld h, d @@ -892,7 +877,7 @@ WriteTileFromBuffer: ; fc696 WriteTileToBuffer: ; fc6a2 -; Write tiledata de to wcf41. +; Write tiledata de to AttrMapEnd. ; de is loaded to sp for WriteTile. ld hl, [sp+0] @@ -903,7 +888,7 @@ WriteTileToBuffer: ; fc6a2 ld l, e ld sp, hl - ld hl, wcf41 + ld hl, AttrMapEnd ; fallthrough @@ -1002,36 +987,37 @@ TileAnimationPalette: ; fc6d7 ; fc71e -Functionfc71e: ; fc71e +FlickeringCaveEntrancePalette: ; fc71e +; No palette changes on DMG. ld a, [hCGB] and a ret z - +; We don't want to mess with non-standard palettes. ld a, [rBGP] - cp $e4 + cp %11100100 ret nz - +; We only want to be here if we're in a dark cave. ld a, [wd847] - cp $ff + cp $ff ; 3,3,3,3 ret nz ld a, [rSVBK] push af - - ld a, 5 + ld a, 5 ; wra5: gfx ld [rSVBK], a - ld a, $a0 +; Ready for BGPD input... + ld a, %10100000 ; auto-increment, index $20 (pal 4 color 0) ld [rBGPI], a ld a, [$ff9b] - and 2 - jr nz, .asm_fc743 - ld hl, Unkn1Pals + $20 - jr .asm_fc746 + and %00000010 + jr nz, .bit1set + ld hl, Unkn1Pals + $20 ; pal 4 color 0 + jr .okay -.asm_fc743 - ld hl, Unkn1Pals + $22 +.bit1set + ld hl, Unkn1Pals + $22 ; pal 4 color 2 -.asm_fc746 +.okay ld a, [hli] ld [rBGPD], a ld a, [hli] diff --git a/wram.asm b/wram.asm index 822676377..874dc0a4e 100644 --- a/wram.asm +++ b/wram.asm @@ -1956,8 +1956,8 @@ wCrystalDataEnd:: wd479:: ds 2 +wGameData:: wPlayerData:: - PlayerID:: ; d47b ds 2 @@ -2587,6 +2587,7 @@ wMagikarpRecordHoldersName:: ds NAME_LENGTH wdff5:: wPokemonDataEnd:: +wGameDataEnd:: SECTION "Pic Animations", WRAMX, BANK [2] From d338a092c5a54d73e3e0a186569cc3b84e61c4ae Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 13 Oct 2015 17:40:18 -0400 Subject: [PATCH 10/11] Revert sPlayerID --- engine/save.asm | 2 +- sram.asm | 1 - tilesets/animations.asm | 52 ++++++++++++++++++++--------------------- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/engine/save.asm b/engine/save.asm index ef1917c83..92b65398b 100644 --- a/engine/save.asm +++ b/engine/save.asm @@ -225,7 +225,7 @@ SaveTheGame_yesorno: ; 14baf Function14bcb: ; 14bcb ld a, BANK(sPlayerData) call GetSRAMBank - ld hl, sPlayerID + ld hl, sPlayerData + (PlayerID - wPlayerData) ld a, [hli] ld c, [hl] ld b, a diff --git a/sram.asm b/sram.asm index 6903f10e3..1201925d9 100644 --- a/sram.asm +++ b/sram.asm @@ -58,7 +58,6 @@ sOptions:: ds OptionsEnd - Options s1_a008:: ds 1 sGameData:: -sPlayerID:: sPlayerData:: ds wPlayerDataEnd - wPlayerData sMapData:: ds wMapDataEnd - wMapData sPokemonData:: ds wPokemonDataEnd - wPokemonData diff --git a/tilesets/animations.asm b/tilesets/animations.asm index 14b3376d6..8b8b7ab42 100644 --- a/tilesets/animations.asm +++ b/tilesets/animations.asm @@ -99,7 +99,7 @@ Tileset01Anim: ; 0xfc0a3 TilesetAnimfc0d7: ; 0xfc0d7 dwtile $03, VTiles2, WriteTileToBuffer - dw AttrMapEnd, ScrollTileRightLeft + dw wcf41, ScrollTileRightLeft dwtile $03, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -113,7 +113,7 @@ TilesetAnimfc0d7: ; 0xfc0d7 TilesetAnimfc103: ; 0xfc103 dwtile $14, VTiles2, WriteTileToBuffer - dw AttrMapEnd, ScrollTileRightLeft + dw wcf41, ScrollTileRightLeft dwtile $14, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -153,32 +153,32 @@ Tileset15Anim: ; 0xfc15f TilesetAnimfc17f: ; 0xfc17f dwtile $53, VTiles2, WriteTileToBuffer - dw AttrMapEnd, ScrollTileDown - dw AttrMapEnd, ScrollTileDown + dw wcf41, ScrollTileDown + dw wcf41, ScrollTileDown dwtile $53, VTiles2, WriteTileFromBuffer dwtile $03, VTiles2, WriteTileToBuffer - dw AttrMapEnd, ScrollTileRightLeft + dw wcf41, ScrollTileRightLeft dwtile $03, VTiles2, WriteTileFromBuffer dwtile $53, VTiles2, WriteTileToBuffer - dw AttrMapEnd, ScrollTileDown - dw AttrMapEnd, ScrollTileDown + dw wcf41, ScrollTileDown + dw wcf41, ScrollTileDown dwtile $53, VTiles2, WriteTileFromBuffer dw NULL, DoneTileAnimation ; 0xfc1af TilesetAnimfc1af: ; 0xfc1af dwtile $54, VTiles2, WriteTileToBuffer - dw AttrMapEnd, ScrollTileDown - dw AttrMapEnd, ScrollTileDown + dw wcf41, ScrollTileDown + dw wcf41, ScrollTileDown dwtile $54, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dwtile $03, VTiles2, WriteTileToBuffer - dw AttrMapEnd, ScrollTileRightLeft + dw wcf41, ScrollTileRightLeft dwtile $03, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dwtile $54, VTiles2, WriteTileToBuffer - dw AttrMapEnd, ScrollTileDown - dw AttrMapEnd, ScrollTileDown + dw wcf41, ScrollTileDown + dw wcf41, ScrollTileDown dwtile $54, VTiles2, WriteTileFromBuffer dw NULL, DoneTileAnimation ; 0xfc1e7 @@ -187,7 +187,7 @@ Tileset24Anim: ; 0xfc1e7 Tileset30Anim: ; 0xfc1e7 dwtile $14, VTiles2, WriteTileToBuffer dw NULL, FlickeringCaveEntrancePalette - dw AttrMapEnd, ScrollTileRightLeft + dw wcf41, ScrollTileRightLeft dw NULL, FlickeringCaveEntrancePalette dwtile $14, VTiles2, WriteTileFromBuffer dw NULL, FlickeringCaveEntrancePalette @@ -195,11 +195,11 @@ Tileset30Anim: ; 0xfc1e7 dw NULL, FlickeringCaveEntrancePalette dwtile $40, VTiles2, WriteTileToBuffer dw NULL, FlickeringCaveEntrancePalette - dw AttrMapEnd, ScrollTileDown + dw wcf41, ScrollTileDown dw NULL, FlickeringCaveEntrancePalette - dw AttrMapEnd, ScrollTileDown + dw wcf41, ScrollTileDown dw NULL, FlickeringCaveEntrancePalette - dw AttrMapEnd, ScrollTileDown + dw wcf41, ScrollTileDown dw NULL, FlickeringCaveEntrancePalette dwtile $40, VTiles2, WriteTileFromBuffer dw NULL, FlickeringCaveEntrancePalette @@ -209,7 +209,7 @@ Tileset30Anim: ; 0xfc1e7 Tileset29Anim: ; 0xfc233 dwtile $35, VTiles2, WriteTileToBuffer dw NULL, FlickeringCaveEntrancePalette - dw AttrMapEnd, ScrollTileRightLeft + dw wcf41, ScrollTileRightLeft dw NULL, FlickeringCaveEntrancePalette dwtile $35, VTiles2, WriteTileFromBuffer dw NULL, FlickeringCaveEntrancePalette @@ -217,11 +217,11 @@ Tileset29Anim: ; 0xfc233 dw NULL, FlickeringCaveEntrancePalette dwtile $31, VTiles2, WriteTileToBuffer dw NULL, FlickeringCaveEntrancePalette - dw AttrMapEnd, ScrollTileDown + dw wcf41, ScrollTileDown dw NULL, FlickeringCaveEntrancePalette - dw AttrMapEnd, ScrollTileDown + dw wcf41, ScrollTileDown dw NULL, FlickeringCaveEntrancePalette - dw AttrMapEnd, ScrollTileDown + dw wcf41, ScrollTileDown dw NULL, FlickeringCaveEntrancePalette dwtile $31, VTiles2, WriteTileFromBuffer dw NULL, FlickeringCaveEntrancePalette @@ -249,7 +249,7 @@ Tileset23Anim: ; 0xfc27f TilesetAnimfc2bf: ; 0xfc2bf dwtile $4f, VTiles2, WriteTileToBuffer - dw AttrMapEnd, ScrollTileRightLeft + dw wcf41, ScrollTileRightLeft dwtile $4f, VTiles2, WriteTileFromBuffer dw NULL, WaitTileAnimation dw NULL, WaitTileAnimation @@ -860,14 +860,14 @@ AnimateWhirlpoolTile: ; fc678 WriteTileFromBuffer: ; fc696 -; Write tiledata at AttrMapEnd to de. -; AttrMapEnd is loaded to sp for WriteTile. +; Write tiledata at wcf41 to de. +; wcf41 is loaded to sp for WriteTile. ld hl, [sp+0] ld b, h ld c, l - ld hl, AttrMapEnd + ld hl, wcf41 ld sp, hl ld h, d @@ -877,7 +877,7 @@ WriteTileFromBuffer: ; fc696 WriteTileToBuffer: ; fc6a2 -; Write tiledata de to AttrMapEnd. +; Write tiledata de to wcf41. ; de is loaded to sp for WriteTile. ld hl, [sp+0] @@ -888,7 +888,7 @@ WriteTileToBuffer: ; fc6a2 ld l, e ld sp, hl - ld hl, AttrMapEnd + ld hl, wcf41 ; fallthrough From f399315a489c7eff28ec1941c41d12264fb38039 Mon Sep 17 00:00:00 2001 From: IIMarckus Date: Tue, 13 Oct 2015 17:50:58 -0600 Subject: [PATCH 11/11] Unicode --- event/magikarp.asm | 16 ++++++++-------- macros/charmap.asm | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/event/magikarp.asm b/event/magikarp.asm index 4f759d655..46939ee97 100644 --- a/event/magikarp.asm +++ b/event/magikarp.asm @@ -81,7 +81,7 @@ Special_CheckMagikarpLength: ; fbb32 ; 0xfbbae Magikarp_LoadFeetInchesChars: ; fbbae - ld hl, VTiles2 + "" * $10 + ld hl, VTiles2 + "′" * $10 ld de, .feetinchchars lb bc, BANK(.feetinchchars), 2 call Request2bpp @@ -98,12 +98,12 @@ PrintMagikarpLength: ; fbbdb ld de, Buffer1 lb bc, PRINTNUM_RIGHTALIGN | 1, 2 call PrintNum - ld [hl], "" + ld [hl], "′" inc hl ld de, Buffer2 lb bc, PRINTNUM_RIGHTALIGN | 1, 2 call PrintNum - ld [hl], "" + ld [hl], "″" inc hl ld [hl], "@" ret @@ -127,9 +127,9 @@ CalcMagikarpLength: ; fbbfc ; bc = rrc(dv[0]) ++ rrc(dv[1]) ^ rrc(id) -; if bc < 10: [MagikarpLength] = c + 190 -; if bc >= $ff00: [MagikarpLength] = c + 1370 -; else: [MagikarpLength] = z * 100 + (bc - x) / y +; if bc < 10: [MagikarpLength] = c + 190 +; if bc ≥ $ff00: [MagikarpLength] = c + 1370 +; else: [MagikarpLength] = z × 100 + (bc − x) / y ; X, Y, and Z depend on the value of b as follows: @@ -216,7 +216,7 @@ CalcMagikarpLength: ; fbbfc ld a, [hQuotient + 2] ld c, a - ; de = c + 100 * (2 + i) + ; de = c + 100 × (2 + i) xor a ld [hMultiplicand + 0], a ld [hMultiplicand + 1], a @@ -249,7 +249,7 @@ CalcMagikarpLength: ; fbbfc ld e, l .done - ; hl = de * 10 + ; hl = de × 10 ld h, d ld l, e rept 2 diff --git a/macros/charmap.asm b/macros/charmap.asm index 83ae5ab79..de6519602 100644 --- a/macros/charmap.asm +++ b/macros/charmap.asm @@ -10,8 +10,8 @@ charmap "└", $7d charmap "┘", $7e charmap " ", $7f - charmap "", $6e - charmap "", $6f + charmap "′", $6e + charmap "″", $6f charmap "A", $80