From eb5a7afe2b4baef9b2f8ad1d3979aaccbe65aab1 Mon Sep 17 00:00:00 2001 From: Mr Wint Date: Wed, 2 Oct 2013 02:47:54 +0200 Subject: [PATCH] * more callab/callba macros --- battle/effect_commands.asm | 118 ++++++++++-------------------------- engine/fruit_trees.asm | 5 +- home/copy.asm | 24 ++------ home/map.asm | 32 +++------- home/map_objects.asm | 4 +- home/menu.asm | 12 +--- home/text.asm | 8 +-- home/time.asm | 4 +- items/item_descriptions.asm | 4 +- items/item_effects.asm | 116 +++++++++-------------------------- main.asm | 26 +++++++- predef/cgb.asm | 4 +- 12 files changed, 108 insertions(+), 249 deletions(-) diff --git a/battle/effect_commands.asm b/battle/effect_commands.asm index 16d03b5e9..b5a31f0bd 100644 --- a/battle/effect_commands.asm +++ b/battle/effect_commands.asm @@ -4469,9 +4469,7 @@ BattleCommand40: ; 35813 ret z ld b, a - ld hl, $45ec - ld a, $f - rst FarCall + callab Function3c5ec ld a, b cp $59 @@ -4668,9 +4666,7 @@ BattleCommand42: ; 35926 ld hl, $c4ca ld a, $b call Predef - ld a, $5e - ld hl, $4000 - rst FarCall + callba Function178000 ld hl, SharedPainText jp StdBattleTextBox @@ -5324,9 +5320,7 @@ PlayFXAnimID: ; 35d08 ld c, 3 call DelayFrames - ld hl, $40d6 - ld a, $33 - rst FarCall ; callab SafePlayBattleAnimation + callab Functioncc0d6 ret ; 35d1c @@ -5589,9 +5583,7 @@ BattleCommand14: ; 35e5c ld hl, FellAsleepText call StdBattleTextBox - ld a, $f - ld hl, $5de9 - rst FarCall + callba Function3dde9 jp z, Function0x34216 ret @@ -5666,9 +5658,7 @@ BattleCommand13: ; 35eee ld hl, WasPoisonedText call StdBattleTextBox - ld a, $f - ld hl, $5de9 - rst FarCall + callba Function3dde9 ret ; 35f2c @@ -5742,9 +5732,7 @@ BattleCommand2f: ; 35f2c call StdBattleTextBox .asm_35fb1 - ld a, $f - ld hl, $5de9 - rst FarCall + callba Function3dde9 ret .asm_35fb8 @@ -5940,9 +5928,7 @@ BattleCommand17: ; 3608c ld hl, WasBurnedText call StdBattleTextBox - ld a, $f - ld hl, $5de9 - rst FarCall + callba Function3dde9 ret ; 360dd @@ -6013,9 +5999,7 @@ BattleCommand18: ; 36102 ld hl, WasFrozenText call StdBattleTextBox - ld a, $f - ld hl, $5de9 - rst FarCall + callba Function3dde9 ret nz call Function0x34216 call EndRechargeOpp @@ -7300,9 +7284,7 @@ BattleCommand23: ; 3680f ld a, d inc a ld [$c718], a - ld hl, $54c3 - ld a, $f - rst FarCall + callab Function3d4c3 ld hl, DraggedOutText call StdBattleTextBox @@ -8509,9 +8491,7 @@ BattleCommand35: ; 36f9d BattleCommand36: ; 36fe1 call Function0x37e01 - ld a, $41 - ld hl, $60e5 - rst FarCall + callba Function1060e5 jp PrintNothingHappened ; 36fed @@ -8701,9 +8681,7 @@ BattleCommand1f: ; 3707f inc de ld [de], a ld [$d265], a - ld a, $14 - ld hl, $4964 - rst FarCall + callba GetTypeName call Function0x37e01 ld hl, TransformedTypeText jp StdBattleTextBox @@ -9137,9 +9115,7 @@ CheckSubstituteOpp: ; 37378 BattleCommand1a: ; 37380 - ld a, $41 - ld hl, $610d - rst FarCall + callba Function10610d ld a, $4 ld [$cfca], a ld c, $3 @@ -9163,12 +9139,8 @@ BattleCommand1a: ; 37380 res 6, [hl] call Function0x37ed5 ret nc - ld a, $f - ld hl, $5f58 - rst FarCall - ld a, $f - ld hl, $6043 - rst FarCall + callba DrawPlayerHUD + callba Function3e043 call $31f6 jp RefreshBattleHuds ; 373c9 @@ -9822,9 +9794,7 @@ Function0x377f5: ; 377f5 xor a ld [MonType], a - ld a, $14 - ld hl, $4bdd - rst FarCall + callba GetGender jr c, .asm_37849 ld b, 1 @@ -9848,9 +9818,7 @@ Function0x377f5: ; 377f5 ld [$d124], a ld a, 3 ld [MonType], a - ld a, $14 - ld hl, $4bdd - rst FarCall + callba GetGender pop bc jr c, .asm_37849 @@ -9948,13 +9916,13 @@ BattleCommand61: ; 37874 ld [$c689], a call Function0x37e01 call SwitchTurn - ld hl, $5246 + ld hl, AICheckPlayerMaxHP ld a, [hBattleTurn] and a jr z, .asm_378ce ; 378c9 $3 - ld hl, $5251 + ld hl, AICheckEnemyMaxHP .asm_378ce - ld a, $e + ld a, BANK(AICheckPlayerMaxHP) rst FarCall jr c, .asm_378f3 ; 378d1 $20 ld hl, $4c8e @@ -10132,19 +10100,13 @@ BattleCommand67: ; 379c9 call $1d6e - ld a, $f - ld hl, $52f7 - rst FarCall + callba Function3d2f7 - ld a, $f - ld hl, $5380 - rst FarCall + callba Function3d380 call $3317 - ld a, $f - ld hl, $6d9f - rst FarCall + callba Function3ed9f call $1c17 call $300b @@ -10158,9 +10120,7 @@ BattleCommand67: ; 379c9 call $32f9 call Function0x37a67 - ld a, $f - ld hl, $52e0 - rst FarCall + callba Function3d2e0 jp c, EndMoveEffect @@ -10182,9 +10142,7 @@ BattleCommand67: ; 379c9 call Function0x37e01 call Function0x37a82 - ld a, $f - ld hl, $52e0 - rst FarCall + callba Function3d2e0 jp c, EndMoveEffect xor a @@ -10484,9 +10442,7 @@ BattleCommand6a6c: ; 37b7e call Function0x37e01 call SwitchTurn - ld hl, $4cef - ld a, $f - rst FarCall ; callab 3ccef + callab Function3ccef call SwitchTurn call UpdateUserInParty @@ -10552,21 +10508,15 @@ BattleCommand95: ; 37c1a and a jr nz, .asm_37c4f - ld hl, $4c9f - ld a, $f - rst FarCall + callab GetHalfMaxHP - ld hl, $4cde - ld a, $f - rst FarCall + callab Function3ccde jr nc, .asm_37c4f push bc call Function0x37e01 pop bc - ld hl, $4c3f - ld a, $f - rst FarCall + callab Function3cc3f call UpdateUserInParty ld a, $5 @@ -10642,9 +10592,7 @@ BattleCommand9a: ; 37c95 and a ret z ld b, a - ld hl, $45ec - ld a, $f - rst FarCall + callab Function3c5ec ld a, b cp $90 ret z @@ -10965,9 +10913,7 @@ Function0x37e47: ; 37e47 push hl push de push bc - ld hl, $40d6 - ld a, $33 - rst FarCall ; callab SafePlayBattleAnimation + callab Functioncc0d6 pop bc pop de pop hl @@ -10988,9 +10934,7 @@ Function0x37e54: ; 37e54 push bc call SwitchTurn - ld hl, $40d6 - ld a, $33 - rst FarCall ; callab SafePlayBattleAnimation + callab Functioncc0d6 call SwitchTurn pop bc diff --git a/engine/fruit_trees.asm b/engine/fruit_trees.asm index 5890d6784..a8a3b797b 100644 --- a/engine/fruit_trees.asm +++ b/engine/fruit_trees.asm @@ -58,10 +58,7 @@ CheckFruitTree: ; 44055 ; 4405f PickedFruitTree: ; 4405f - ld a, $41 - ld hl, $609b - rst FarCall ; empty function - + callba Function10609b ; empty function ld b, 1 jp GetFruitTreeFlag ; 4406a diff --git a/home/copy.asm b/home/copy.asm index ad25c96e6..633c993be 100644 --- a/home/copy.asm +++ b/home/copy.asm @@ -106,44 +106,32 @@ Functiondfd: ; dfd Functione4a: ; e4a - ld a, $5 - ld hl, $4135 - rst FarCall + callba Function14135 ret ; e51 Functione51: ; e51 - ld a, $3e - ld hl, $7449 - rst FarCall + callba Functionfb449 ret ; e58 Functione58: ; e58 - ld a, $3e - ld hl, $74be - rst FarCall + callba Functionfb4be ret ; e5f Functione5f: ; e5f - ld a, $3e - ld hl, $748a - rst FarCall - ld a, $3e - ld hl, $74b0 - rst FarCall + callba Functionfb48a + callba Functionfb4b0 ret ; e6c Functione6c: ; e6c - ld a, $3e - ld hl, $74b0 - rst FarCall + callba Functionfb4b0 ret ; e73 diff --git a/home/map.asm b/home/map.asm index d4cfe1be9..3c2e0e645 100644 --- a/home/map.asm +++ b/home/map.asm @@ -696,9 +696,7 @@ Function248a: ; 248a call Function24ba .asm_24b3 - ld a, $41 - ld hl, $486d - rst FarCall + callba Function10486d ret ; 24ba @@ -1418,9 +1416,7 @@ Function2821: ; 2821 jr .asm_2875 .asm_286f - ld a, $7 - ld hl, $4000 - rst FarCall + callba Function1c000 .asm_2875 xor a @@ -1944,9 +1940,7 @@ FadeToMenu: ; 2b29 xor a ld [hBGMapMode], a call Function1d6e - ld a, $23 - ld hl, $4084 - rst FarCall + callba Function8c084 call ClearSprites call Function2ed3 ret @@ -1973,13 +1967,9 @@ Function2b4d: ; 2b4d Function2b5c: ; 2b5c ld b, $9 call GetSGBLayout - ld a, $12 - ld hl, $5409 - rst FarCall + callba Function49409 call Function3200 - ld a, $23 - ld hl, $4079 - rst FarCall + callba Function8c079 call Function2ee4 ret ; 2b74 @@ -2013,9 +2003,7 @@ Function2b74: ; 0x2b74 Function2bae: ; 2bae call DisableLCD call ClearSprites - ld a, $5 - ld hl, $4168 - rst FarCall + callba Function14168 call Functione51 call Functione5f ld a, [hROMBank] @@ -2025,9 +2013,7 @@ Function2bae: ; 2bae ld a, [MapNumber] ld c, a call Function2c24 - ld a, $23 - ld hl, $4001 - rst FarCall + callba Function8c001 call Function2173 call Function2821 ld a, $9 @@ -2278,9 +2264,7 @@ Function2cbd: ; 2cbd jr z, .asm_2cee bit 7, c jr nz, .asm_2cda - ld a, $22 - ld hl, $7342 - rst FarCall + callba Function8b342 ld e, c ld d, $0 .asm_2cd7 diff --git a/home/map_objects.asm b/home/map_objects.asm index 3ebc1b597..a803f6ee1 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -337,9 +337,7 @@ Function1956: ; 1956 call Function271e ld a, [hConnectionStripLength] call GetMapObject - ld a, $2 - ld hl, $40e7 - rst FarCall + callba Function80e7 ret ; 1967 diff --git a/home/menu.asm b/home/menu.asm index c761a927c..cf5958d95 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -561,9 +561,7 @@ Function201c: ; 201c Function202a: ; 202a ld a, [hROMBank] ld [$cf94], a - ld a, $9 - ld hl, $400e - rst FarCall + callba Function2400e ld a, [$cf88] ret ; 2039 @@ -571,9 +569,7 @@ Function202a: ; 202a Function2039: ; 2039 ld a, [hROMBank] ld [$cf94], a - ld a, $9 - ld hl, $4022 - rst FarCall + callba Function24022 ld a, [$cf88] ret ; 2048 @@ -581,9 +577,7 @@ Function2039: ; 2039 Function2048: ; 2048 ld a, [hROMBank] ld [$cf94], a - ld a, $9 - ld hl, $403c - rst FarCall + callba Function2403c ld a, [$cf88] ret ; 2057 diff --git a/home/text.asm b/home/text.asm index a0b1eb644..6833f3ddc 100644 --- a/home/text.asm +++ b/home/text.asm @@ -315,9 +315,7 @@ CheckDict: ; 1087 Function117b: ; 117b ld c, l ld b, h - ld a, $5f - ld hl, $7036 - rst FarCall + callba Function17f036 jp PlaceNextChar ; 1186 @@ -463,9 +461,7 @@ Function1205: ; 1205 ld de, String12a2 call PlaceString push bc - ld hl, $5939 - ld a, $e - rst FarCall + callab Function39939 pop hl ld de, StringBuffer1 jr .asm_126a ; 0x1246 $22 diff --git a/home/time.asm b/home/time.asm index bb2d8966b..f767dad04 100644 --- a/home/time.asm +++ b/home/time.asm @@ -204,9 +204,7 @@ Function658: ; 658 jr Function677 Function677 - ld a, $5 - ld hl, $40ed - rst FarCall + callba Function140ed ret ; 67e diff --git a/items/item_descriptions.asm b/items/item_descriptions.asm index 1c0b4f10f..ca88c0d1a 100644 --- a/items/item_descriptions.asm +++ b/items/item_descriptions.asm @@ -4,9 +4,7 @@ GetItemDescription: ; 0x1c8955 jr c, .nomovedesc ; if not a TM, use a predefined string ld [$d106], a push de - ld a, $b ; XXX replace this with BANK(label) - ld hl, $47b6 ; XXX replace this with label - rst FarCall + callba Function2c7b6 pop hl ld a, [$d265] ld [$cf60], a diff --git a/items/item_effects.asm b/items/item_effects.asm index 13d96f0a4..071c53fd7 100644 --- a/items/item_effects.asm +++ b/items/item_effects.asm @@ -150,9 +150,7 @@ ParkBall: ; e8a2 ld d, a push de ld a, [BattleMonItem] - ld a, $d - ld hl, $7dd0 - rst FarCall + callba GetItem ld a, b cp $46 @@ -258,9 +256,7 @@ ParkBall: ; e8a2 ld [CurPartySpecies], a ld a, [EnemyMonLevel] ld [CurPartyLevel], a - ld a, $f - ld hl, $68eb - rst FarCall + callba LoadEnemyMon pop af ld [EnemySubStatus5], a @@ -296,9 +292,7 @@ ParkBall: ; e8a2 ld a, [BattleType] cp $3 jp z, $6bd9 - ld a, $41 - ld hl, $607f - rst FarCall + callba Function10607f ld hl, $6dc9 call $1057 @@ -351,9 +345,7 @@ ParkBall: ; e8a2 ld a, $6 call Predef - ld a, $13 - ld hl, $5b49 - rst FarCall + callba Function4db49 ld a, [CurItem] cp $a4 @@ -392,9 +384,7 @@ ParkBall: ; e8a2 xor a ld [MonType], a ld b, $0 - ld a, $4 - ld hl, $56c1 - rst FarCall + callba Function116c1 call $04b6 @@ -412,9 +402,7 @@ ParkBall: ; e8a2 ld a, $9 call Predef - ld a, $13 - ld hl, $5b83 - rst FarCall + callba Function4db83 ld a, $1 call GetSRAMBank @@ -452,9 +440,7 @@ ParkBall: ; e8a2 ld [MonType], a ld de, $d050 ld b, $0 - ld a, $4 - ld hl, $56c1 - rst FarCall + callba Function116c1 ld a, $1 call GetSRAMBank @@ -490,9 +476,7 @@ ParkBall: ; e8a2 jr .asm_ebe2 - ld a, $3 - ld hl, $66ce - rst FarCall + callba Functione6ce jr .asm_ebe2 @@ -762,9 +746,7 @@ Function_0xed12: ; ed12 ld [MonType], a ld a, [CurBattleMon] ld [CurPartyMon], a - ld a, $14 - ld hl, $4bdd - rst FarCall + callba GetGender jr c, .asm_ed66 ld d, 0 @@ -777,9 +759,7 @@ Function_0xed12: ; ed12 ld [CurPartySpecies], a ld a, WILDMON ld [MonType], a - ld a, $14 - ld hl, $4bdd - rst FarCall + callba GetGender jr c, .asm_ed65 ld d, 0 @@ -875,17 +855,13 @@ INCBIN "baserom.gbc", $edab, $ee01 - $edab Item06: ; ee01 - ld a, $24 - ld hl, $5ae1 - rst FarCall + callba Function91ae1 ret ; ee08 Bicycle: ; ee08 - ld a, $3 - ld hl, $50b3 - rst FarCall + callba Functiond0b3 ret ; ee0f @@ -909,9 +885,7 @@ SunStone: ; ee0f jr z, .asm_ee35 ld a, $1 ld [$d1e9], a - ld a, $10 - ld hl, $61d8 - rst FarCall + callba Function421d8 ld a, [$d268] and a @@ -969,9 +943,7 @@ Calcium: ; ee3d call $1057 ld c, $2 - ld a, $1 - ld hl, $71c2 - rst FarCall + callba ChangeHappiness jp $7795 @@ -1005,9 +977,7 @@ RareCandy: ; ef14 ld [CurPartyLevel], a push de ld d, a - ld a, $14 - ld hl, $4e47 - rst FarCall + callba Function50e47 pop de ld a, $8 @@ -1045,9 +1015,7 @@ RareCandy: ; ef14 ld a, [hl] adc b ld [hl], a - ld a, $9 - ld hl, $709e - rst FarCall + callba Function2709e ld a, $f8 call $724a @@ -1078,9 +1046,7 @@ RareCandy: ; ef14 xor a ld [$d1e9], a - ld a, $10 - ld hl, $61d8 - rst FarCall + callba Function421d8 jp $7795 ; efad @@ -1097,9 +1063,7 @@ HealPowder: ; efad cp $0 jr nz, .asm_efc9 ld c, $f - ld a, $1 - ld hl, $71c2 - rst FarCall + callba ChangeHappiness call $77d6 @@ -1260,9 +1224,7 @@ RevivalHerb: ; f0a9 cp $0 jr nz, .asm_f0c5 ld c, $11 - ld a, $1 - ld hl, $71c2 - rst FarCall + callba ChangeHappiness call $77d6 @@ -1367,9 +1329,7 @@ Function_0xf192: ; f192 pop bc cp $0 jr nz, .asm_f1a6 - ld a, $1 - ld hl, $71c2 - rst FarCall + callba ChangeHappiness call $77d6 @@ -1803,9 +1763,7 @@ INCBIN "baserom.gbc",$f44a,$f44f - $f44a EscapeRope: ; f44f xor a ld [$d0ec], a - ld a, $3 - ld hl, $4b95 - rst FarCall + callba Functioncb95 ld a, [$d0ec] cp $1 @@ -1911,26 +1869,18 @@ XSpecial: ; f4c5 ld [hBattleTurn], a ld [AttackMissed], a ld [$c70d], a - ld a, $d - ld hl, $61ef - rst FarCall + callba Function0x361ef call WaitSFX - ld a, $d - ld hl, $63b8 - rst FarCall + callba BattleCommand8c - ld a, $d - ld hl, $644c - rst FarCall + callba BattleCommand8e ld a, [CurBattleMon] ld [CurPartyMon], a ld c, $3 - ld a, $1 - ld hl, $71c2 - rst FarCall + callba ChangeHappiness ret ; f504 @@ -2072,17 +2022,13 @@ SuperRod: ; f5ad ; f5b1 Function_0xf5b1: ; f5b1 - ld a, $3 - ld hl, $4f8e - rst FarCall + callba Functioncf8e ret ; f5b8 Itemfinder: ; f5b8 - ld a, $4 - ld hl, $6580 - rst FarCall + callba Function12580 ret ; f5bf @@ -2123,9 +2069,7 @@ Mysteryberry: ; f5bf ld [CurMoveNum], a ld a, $2 ld [$d235], a - ld a, $f - ld hl, $64bc - rst FarCall + callba Function3e4bc pop bc ld a, b @@ -2221,9 +2165,7 @@ GorgeousBox: ; f767 ; f769 Function_0xf769: ; f769 - ld a, $9 - ld hl, $6f02 - rst FarCall + callba Function26f02 ld hl, UnknownText_0xf778 call $1057 diff --git a/main.asm b/main.asm index 3d87ed6c0..0bb9ff29f 100644 --- a/main.asm +++ b/main.asm @@ -113339,6 +113339,7 @@ Function106095: ; 106095 jp Function10611d ; 10609b +Function10609b: ; 10609b ret ; 10609c (41:609c) @@ -113409,7 +113410,13 @@ Function1060df: ; 1060df ret ; 1060e0 -INCBIN "baserom.gbc",$1060e0,$1060fb - $1060e0 +INCBIN "baserom.gbc",$1060e0,$1060e5 - $1060e0 + +Function1060e5: ; 1060e5 + ret +; 1060e6 (41:60e6) + +INCBIN "baserom.gbc",$1060e6,$1060fb - $1060e6 Function1060fb: ; 1060fb @@ -122952,7 +122959,22 @@ INCLUDE "text/phone/extra3.asm" SECTION "bank5E",ROMX,BANK[$5E] -INCBIN "baserom.gbc",$178000,$17801f - $178000 +Function178000: + ld a, BANK(DrawPlayerHUD) + ld hl, DrawPlayerHUD + rst $8 ; ; indirect jump to DrawPlayerHUD (3df58 (f:5f58)) + ld hl, PlayerHPPal ; $cd99 + call SetHPPal + ld a, BANK(Function3e043) + ld hl, Function3e043 + rst $8 ; ; indirect jump to Function3e043 (3e043 (f:6043)) + ld hl, EnemyHPPal ; $cd9a + call SetHPPal + ld a, BANK(Function3ee27) + ld hl, Function3ee27 + rst $8 ; ; indirect jump to Function3ee27 (3ee27 (f:6e27)) + ret +; 17801f (5e:401f) ; Songs V diff --git a/predef/cgb.asm b/predef/cgb.asm index c51a327e7..460c0e917 100644 --- a/predef/cgb.asm +++ b/predef/cgb.asm @@ -158,9 +158,7 @@ Function8e23: ; 8e23 Function8e85: ; 8e85 - ld a, $40 - ld hl, $4dc0 - rst FarCall + callba Function100dc0 Function8e8b: ; 8e8b ld hl, $7311