From bf014ea5ec60567d55431257f7b86f96a7835a09 Mon Sep 17 00:00:00 2001 From: KuroiIeWa5Da Date: Mon, 23 Jan 2012 11:18:45 -0600 Subject: Finished Cities1 Music Data Channel 1 hg-commit-id: f0ef90711f9c --- music.asm | 323 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 320 insertions(+), 3 deletions(-) diff --git a/music.asm b/music.asm index 5aa15f53..409b88bf 100644 --- a/music.asm +++ b/music.asm @@ -2801,7 +2801,7 @@ branch_A4A8: mus_note noteC#, note8 mus_note noteB, note8 mus_note noteC#, note8 - mus_jump 0, $64A8 + mus_jump 0, branch_A4A8 ; A5EF ;No end byte until indigo plateu channel 1 @@ -3975,12 +3975,329 @@ branch_a9d8: ; AA6F mus_tempo 0, 232 - mus_jump 0, $6A79 ;;Leads into city music not dugout yet + mus_jump 0, branch_aa79 ; AA75 ;Viridian City, Pewter City, Saffron City Cities1_md_1: ;AA76 - AB91 -INCBIN "baserom.gbc",$aa76,$ab92 - $aa76 + ; AA76 + mus_tempo 0, 144 + +branch_aa79: + mus_volume 119 + mus_mod 8, 2, 4 + mus_duty duty75 +branch_aa80: + mus_vel 12, 5 + + mus_octave oct2 + mus_note noteG#, note4 + mus_note noteF#, note4 + mus_note noteE, note8 + mus_note noteE, note8 + mus_note noteF#, note8 + mus_note noteD#, note8 + mus_note noteE, note8 + mus_note noteE, note8 + mus_note noteD#, note8 + mus_note noteC#, note4 + mus_note noteD#, note4 + mus_note noteE, note8 + mus_note noteD#, note4 + mus_note noteC#, note8 + mus_note noteE, note8 + mus_note noteE, note4 + mus_vel 10, 5 + mus_note noteC#, note4 + + mus_octave oct1 + mus_note noteB, note4_8 + + mus_octave oct2 + mus_note noteC#, note8 + mus_note noteC#, note4 + + mus_octave oct1 + mus_note noteB, note4 + mus_vel 12, 5 + mus_call branch_ab7d + + mus_octave oct2 + mus_note noteD#, note4_8 + mus_note noteE, note8 + + mus_octave oct1 + mus_note noteB, note4 + mus_vel 10, 5 + + mus_octave oct2 + mus_note noteC#, note8 + + mus_octave oct1 + mus_note noteB, note8 + mus_note noteA, note4 + mus_note noteB, note4 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteC#, note8 + mus_note noteD#, note8 + mus_note noteE, note8 + mus_note noteD#, note8 + mus_note noteC#, note8 + mus_note noteD#, note8 + mus_vel 12, 5 + mus_note noteG#, note8 + mus_note noteE, note8 + mus_note noteF#, note8 + mus_note noteE, note8 + mus_note noteE, note4 + mus_note noteF#, note8 + mus_note noteD#, note8 + mus_note noteE, note4 + mus_note noteD#, note8 + mus_note noteC#, note4 + mus_note noteD#, note4 + mus_note noteE, note8 + mus_note noteD#, note8 + mus_note noteC#, note8 + mus_note noteC#, note8 + mus_note noteE, note8 + mus_note noteE, note4 + mus_vel 10, 5 + mus_note noteC#, note8 + + mus_octave oct1 + mus_note noteA, note8 + mus_note noteB, note4_8 + + mus_octave oct2 + mus_note noteC#, note8 + mus_note noteC#, note8 + + mus_octave oct1 + mus_note noteB, note8 + mus_note noteB, note4 + mus_vel 12, 5 + mus_call branch_ab7d + + mus_octave oct2 + mus_note noteD#, note4 + mus_note noteD#, note8 + mus_note noteE, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteC#, note8 + mus_note noteG#, note8 + mus_note noteE, note4 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteE, note8 + mus_vel 10, 5 + mus_note noteC#, note4 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteD#, note4 + mus_note noteC#, note8 + mus_note noteE, note4 + mus_vel 11, 3 + mus_call branch_ab8a + mus_note noteA, note8 + mus_note noteB, note8 + mus_note noteA, note8 + mus_note noteG#, note8 + mus_note noteA, note4 + mus_note noteF#, note4 + mus_note noteG#, note8 + mus_note noteE, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteE, note4 + mus_note noteG#, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteE, note8 + mus_note noteE, note8 + mus_note noteF#, note8 + mus_note noteE, note8 + mus_note noteD#, note8 + mus_note noteE, note8 + mus_note noteD#, note8 + mus_note noteC#, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 +branch_ab12: + mus_note noteC#, note8 + mus_note noteD#, note8 + mus_note noteC#, note8 + + mus_octave oct1 + mus_note noteB, note4 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteC#, note8 + mus_note noteD#, note8 + mus_jump 2, branch_ab12 + mus_note noteE, note8 + + mus_octave oct1 + mus_note noteB, note4 + + mus_octave oct2 + mus_note noteE, note4 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteC#, note8 + mus_note noteG#, note8 + mus_note noteG#, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteF#, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteE, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteD#, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_call branch_ab8a + mus_note noteA, note8 + mus_note noteE, note8 + mus_note noteA, note8 + mus_note noteB, note8 + mus_note noteA, note8 + mus_note noteG#, note8 + mus_note noteA, note8 + mus_note noteF#, note8 + mus_note noteG#, note8 + mus_note noteE, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteE, note8 + mus_note noteC#, note8 + mus_note noteG#, note8 + mus_note noteC#, note8 + mus_note noteD#, note8 + mus_note noteB, note8 + mus_note noteE, note8 + mus_note noteG#, note8 + mus_note noteE, note8 + mus_note noteF#, note8 + mus_note noteE, note4 + mus_note noteG#, note8 + mus_note noteF#, note8 + mus_note noteD#, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteD#, note4 + mus_note noteF#, note8 + mus_note noteD#, note8 + mus_note noteD#, note8 + mus_note noteF#, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteE, note8 + + mus_octave oct1 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteD#, note8 + + mus_octave oct1 + mus_note noteB, note8 + mus_note noteB, note8 + + mus_octave oct2 + mus_note noteD#, note8 + mus_vel 11, 6 + mus_note noteF#, note2 + mus_note noteF#, note4 + mus_note noteD#, note4 + mus_note noteE, note2 + mus_vel 8, 4 + + mus_octave oct1 + mus_note noteB, note4 + + mus_octave oct2 + mus_note noteE, note8 + mus_note noteF#, note8 + mus_jump 0, branch_aa80 + +branch_ab7d: + mus_octave oct2 + mus_note noteF#, note8 + mus_note noteD#, note4 + mus_note noteE, note8 + mus_note noteD#, note4 + mus_note noteC#, note4 + + mus_octave oct1 + mus_note noteB, note4 + + mus_octave oct2 + mus_note noteC#, note8 + mus_note noteD#, note8 + mus_note noteC#, note8 + mus_end + ; AB89 + + ; AB8A +branch_ab8a: + mus_note noteA, note8 + mus_note noteE, note8 + mus_note noteC#, note8 + mus_note noteE, note4 + mus_note noteA, note8 + mus_note noteC#, note8 + mus_note noteE, note8 + mus_end + ; AB91 Cities1_md_2: ;AB92 - AC02 INCBIN "baserom.gbc",$ab92,$ac32 - $ab92 -- cgit v1.2.3 From 438aa49e28e00ff0dd7c83153e3f7850e4d5690d Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 23 Jan 2012 13:34:33 -0800 Subject: added battle-related constants hg-commit-id: d312b8d039b0 --- constants.asm | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/constants.asm b/constants.asm index 573e97e5..18eea507 100644 --- a/constants.asm +++ b/constants.asm @@ -89,6 +89,9 @@ TX_RAM: MACRO ; wram locations +W_PLAYERSELECTEDMOVE EQU $CCDC +W_ENEMYSELECTEDMOVE EQU $CCDD + W_AICOUNT EQU $CCDF ; number of times remaining that AI action can occur W_WHICHTRADE EQU $CD3D ; which entry from TradeMons to select @@ -97,6 +100,20 @@ W_WHICHPOKEMON EQU $CF92 ; which pokemon you selected W_WALKCOUNTER EQU $CFC5 ; walk animation counter +W_ENEMYMOVENUM EQU $CFCC +W_ENEMYMOVEEFFECT EQU $CFCD +W_ENEMYMOVEPOWER EQU $CFCE +W_ENEMYMOVETYPE EQU $CFCF +W_ENEMYMOVEACCURACY EQU $CFD0 +W_ENEMYMOVEMAXPP EQU $CFD1 + +W_PLAYERMOVENUM EQU $CFD2 +W_PLAYERMOVEEFFECT EQU $CFD3 +W_PLAYERMOVEPOWER EQU $CFD4 +W_PLAYERMOVETYPE EQU $CFD5 +W_PLAYERMOVEACCURACY EQU $CFD6 +W_PLAYERMOVEMAXPP EQU $CFD7 + W_OPPONENTHP EQU $CFE6 ; active opponent's hp (16 bits) W_OPPONENTNUMBER EQU $CFE8 ; active opponent's position in team (0 to 5) W_OPPONENTSTATUS EQU $CFE9 ; active opponent's status condition @@ -119,9 +136,6 @@ W_CURMONSTATUS EQU $D018 ; the status of the player’s current monster ; bit 6 par ; unused? (XXX confirm) -W_CURMONBATTSTATUS EQU $D067 ; various battle statuses - ; bit 5 held in place (Bind, Clamp, etc.) - W_TRAINERCLASS EQU $D031 W_ISINBATTLE EQU $D057 ; no battle, this is 0 @@ -138,6 +152,46 @@ W_BATTLETYPE EQU $D05A ; in normal battle, this is 0 W_LONEATTACKNO EQU $D05C ; which entry in LoneAttacks to use W_TRAINERNO EQU $D05D ; which instance of [youngster, lass, etc] is this? +; not entirely sure that all these bits are 100% correct +; Battle Status Byte 1 +; bit 0 - bide +; bit 1 - thrash / petal dance +; bit 2 - attacking multiple times (e.g. double kick) +; bit 3 - flinch +; bit 4 - charging up for attack +; bit 5 - using multi-turn move (e.g. wrap) +; bit 6 - invulnerable to normal attack (using fly/dig) +; bit 7 - confusion + +; Battle Status Byte 2 +; bit 0 - X Accuracy effect +; bit 1 - protected by "mist" +; bit 2 - focus energy effect +; bit 4 - has a substitute +; bit 5 - need to recharge +; bit 6 - rage +; bit 7 - leech seeded + +; Battle Status Byte 3 +; bit 0 - toxic +; bit 1 - light screen +; bit 2 - reflect +; bit 3 - tranformed + +W_PLAYERBATTSTATUS1 EQU $D062 +W_PLAYERBATTSTATUS2 EQU $D063 +W_PLAYERBATTSTATUS3 EQU $D062 + +W_ENEMYBATTSTATUS1 EQU $D067 +W_ENEMYBATTSTATUS2 EQU $D068 +W_ENEMYBATTSTATUS3 EQU $D069 + +W_PLAYERTOXICCOUNTER EQU $D06C +W_PLAYERDISABLEDMOVE EQU $D06D + +W_ENEMYTOXICCOUNTER EQU $D071 +W_ENEMYDISABLEDMOVE EQU $D072 + W_NUMHITS EQU $D074 ; number of hits in attacks like Doubleslap, etc. ; List type -- cgit v1.2.3 From 9bae391ba0d433671eda07d6807db33528bed948 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 23 Jan 2012 13:42:39 -0800 Subject: move missed constant hg-commit-id: 229b952d44c7 --- constants.asm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/constants.asm b/constants.asm index 18eea507..1ea3d67e 100644 --- a/constants.asm +++ b/constants.asm @@ -152,6 +152,8 @@ W_BATTLETYPE EQU $D05A ; in normal battle, this is 0 W_LONEATTACKNO EQU $D05C ; which entry in LoneAttacks to use W_TRAINERNO EQU $D05D ; which instance of [youngster, lass, etc] is this? +W_MOVEMISSED EQU $D05F + ; not entirely sure that all these bits are 100% correct ; Battle Status Byte 1 ; bit 0 - bide -- cgit v1.2.3 From 08912369ed34ea74e1f0913840ca4a12beb368f3 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 23 Jan 2012 13:58:31 -0800 Subject: fix constant hg-commit-id: 1a095dae2a66 --- common.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.asm b/common.asm index 8d15cea6..3d13f50d 100644 --- a/common.asm +++ b/common.asm @@ -24238,7 +24238,7 @@ Function5854: ; 5854 jp $5A37 .HeldInPlaceCheck\@ - ld a,[W_CURMONBATTSTATUS] + ld a,[W_ENEMYBATTSTATUS1] bit 5,a jp z,FlinchedCheck ld hl,CantMoveText -- cgit v1.2.3 From 505e717d07dbe8e9a2afc3322b68f703d1c7ec62 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 23 Jan 2012 14:17:17 -0800 Subject: changed some addresses to the new constants hg-commit-id: bc038ee359b8 --- common.asm | 74 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/common.asm b/common.asm index 3d13f50d..ea9b1051 100644 --- a/common.asm +++ b/common.asm @@ -23788,7 +23788,7 @@ EnemySendOut: ; 490E ld [hl],a dec a ld [W_AICOUNT],a - ld hl,$D062 + ld hl,W_PLAYERBATTSTATUS1 res 5,[hl] ld hl,$C3B2 ld a,8 @@ -23994,7 +23994,7 @@ UnnamedText_3d430: ; 0x3d430 INCBIN "baserom.gbc",$3d435,$274 ; in-battle stuff - ld hl,$D062 + ld hl,W_PLAYERBATTSTATUS1 res 4,[hl] res 6,[hl] call $5AF5 @@ -24002,17 +24002,17 @@ INCBIN "baserom.gbc",$3d435,$274 ld de,$CCDC ; pointer to the move just used ld b,BANK(DecrementPP) call Bankswitch - ld a,[$CFD3] ; effect of the move just used + ld a,[W_PLAYERMOVEEFFECT] ; effect of the move just used ld hl,EffectsArray1 ld de,1 call IsInArray jp c,$7132 - ld a,[$CFD3] + ld a,[W_PLAYERMOVEEFFECT] ld hl,EffectsArray5B ld de,1 call IsInArray call c,$7132 - ld a,[$CFD3] + ld a,[W_PLAYERMOVEEFFECT] ld hl,EffectsArray2 ld de,1 call IsInArray @@ -24027,33 +24027,33 @@ INCBIN "baserom.gbc",$3d435,$274 call $6687 call $656B .next11\@ - ld a,[$D05F] + ld a,[W_MOVEMISSED] and a jr z,.next\@ - ld a,[$CFD3] + ld a,[W_PLAYERMOVEEFFECT] sub a,7 jr z,.next2\@ jr .next3\@ ; 574B .next\@ - ld a,[$CFD3] + ld a,[W_PLAYERMOVEEFFECT] and a ld a,4 jr z,.next2\@ ld a,5 .next2\@ push af - ld a,[$D063] + ld a,[W_PLAYERBATTSTATUS2] bit 4,a ld hl,$5747 ld b,$1E call nz,Bankswitch pop af ld [$CC5B],a - ld a,[$CFD2] + ld a,[W_PLAYERMOVENUM] call $6F07 call $6ED3 call $4D60 - ld a,[$D063] + ld a,[W_PLAYERBATTSTATUS2] bit 4,a ld hl,$5771 ld b,$1E @@ -24062,7 +24062,7 @@ INCBIN "baserom.gbc",$3d435,$274 .next3\@ ld c,$1E call $3739 - ld a,[$CFD3] + ld a,[W_PLAYERMOVEEFFECT] cp a,$2B jr z,.next5\@ cp a,$27 ; XXX SLP | FRZ ? @@ -24074,7 +24074,7 @@ INCBIN "baserom.gbc",$3d435,$274 ld a,$A7 call $6F07 .next4\@ - ld a,[$CFD3] + ld a,[W_PLAYERMOVEEFFECT] cp a,9 jr nz,.next6\@ ; 577A call $62FD @@ -24088,16 +24088,16 @@ INCBIN "baserom.gbc",$3d435,$274 call $6348 jp $569A .next7\@ - ld a,[$CFD3] + ld a,[W_PLAYERMOVEEFFECT] ld hl,EffectsArray3 ld de,1 call IsInArray jp c,$7132 - ld a,[$D05F] + ld a,[W_MOVEMISSED] and a jr z,.next8\@ ; 57A6 call $5BE2 - ld a,[$CFD3] + ld a,[W_PLAYERMOVEEFFECT] cp a,7 jr z,.next9\@ ; 57B9 jp Function580A @@ -24110,7 +24110,7 @@ INCBIN "baserom.gbc",$3d435,$274 ld a,1 ld [$CCF4],a .next9\@ - ld a,[$CFD3] + ld a,[W_PLAYERMOVEEFFECT] ld hl,EffectsArray4 ld de,1 call IsInArray @@ -24122,7 +24122,7 @@ INCBIN "baserom.gbc",$3d435,$274 ret z call $62B6 - ld hl,$D062 + ld hl,W_PLAYERBATTSTATUS1 bit 2,[hl] jr z,.next10\@ ; 57EF ld a,[$D06A] @@ -24136,7 +24136,7 @@ INCBIN "baserom.gbc",$3d435,$274 xor a ld [W_NUMHITS],a ; reset .next10\@ - ld a,[$CFD3] + ld a,[W_PLAYERMOVEEFFECT] and a jp z,Function580A ld hl,EffectsArray5 @@ -24247,7 +24247,7 @@ Function5854: ; 5854 jp $5A37 FlinchedCheck: ; 58AC - ld hl,$D062 + ld hl,W_PLAYERBATTSTATUS1 bit 3,[hl] jp z,HyperBeamCheck res 3,[hl] @@ -24257,7 +24257,7 @@ FlinchedCheck: ; 58AC jp $5A37 HyperBeamCheck: ; 58C2 - ld hl,$D063 + ld hl,W_PLAYERBATTSTATUS2 bit 5,[hl] jr z,.next\@ ; 58D7 res 5,[hl] @@ -24279,13 +24279,13 @@ HyperBeamCheck: ; 58C2 ld hl,DisabledNoMoreText call PrintText .next2\@ - ld a,[$D062] + ld a,[W_PLAYERBATTSTATUS1] add a jr nc,.next3\@ ; 5929 ld hl,$D06B dec [hl] jr nz,.next4\@ ; 5907 - ld hl,$D062 + ld hl,W_PLAYERBATTSTATUS1 res 7,[hl] ld hl,ConfusedNoMoreText call PrintText @@ -24300,7 +24300,7 @@ HyperBeamCheck: ; 58C2 call $6E9B cp a,$80 jr c,.next3\@ - ld hl,$D062 + ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] and a,$80 ld [hl],a @@ -24326,11 +24326,11 @@ HyperBeamCheck: ; 58C2 ld hl,FullyParalyzedText call PrintText .next5\@ - ld hl,$D062 + ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] and a,$CC ld [hl],a - ld a,[$CFD3] + ld a,[W_PLAYERMOVEEFFECT] cp a,$2B jr z,.next8\@ ; 5966 cp a,$27 @@ -24345,11 +24345,11 @@ HyperBeamCheck: ; 58C2 ld hl,$580A jp $5A37 .next7\@ - ld hl,$D062 + ld hl,W_PLAYERBATTSTATUS1 bit 0,[hl] jr z,.next10\@ ; 59D0 xor a - ld [$CFD2],a + ld [W_PLAYERMOVENUM],a ld hl,$D0D7 ld a,[hli] ld b,a @@ -24367,7 +24367,7 @@ HyperBeamCheck: ; 58C2 ld hl,$580A jp $5A37 .next11\@ - ld hl,$D062 + ld hl,W_PLAYERBATTSTATUS1 res 0,[hl] ld hl,UnleashedEnergyText call PrintText @@ -24384,20 +24384,20 @@ HyperBeamCheck: ; 58C2 or b jr nz,.next12\@ ; 59C2 ld a,1 - ld [$D05F],a + ld [W_MOVEMISSED],a .next12\@ xor a ld [hli],a ld [hl],a ld a,$75 - ld [$CFD2],a + ld [W_PLAYERMOVENUM],a ld hl,$5705 jp $5A37 .next10\@ bit 1,[hl] jr z,.next13\@ ; 59FF ld a,$25 - ld [$CFD2],a + ld [W_PLAYERMOVENUM],a ld hl,ThrashingAboutText call PrintText ld hl,$D06A @@ -24405,7 +24405,7 @@ HyperBeamCheck: ; 58C2 ld hl,$56DC jp nz,$5A37 push hl - ld hl,$D062 + ld hl,W_PLAYERBATTSTATUS1 res 1,[hl] set 7,[hl] call $6E9B ; random number? @@ -47177,12 +47177,12 @@ DecrementPP: ; 0x68000 cp a, STRUGGLE ret z ; if the pokemon is using "struggle", there's nothing to do ; we don't decrement PP for "struggle" - ld hl, $D062 - ld a, [hli] ; load the $D062 pokemon status flags and increment hl to load the - ; $D063 status flags later + ld hl, W_PLAYERBATTSTATUS1 + ld a, [hli] ; load the W_PLAYERBATTSTATUS1 pokemon status flags and increment hl to load the + ; W_PLAYERBATTSTATUS2 status flags later and a, 7 ; check to see if bits 0, 1, or 2 are set ret nz ; if any of these statuses are true, don't decrement PP - bit 6, [hl] ; check 6th bit status flag on $D063 + bit 6, [hl] ; check 6th bit status flag on W_PLAYERBATTSTATUS2 ret nz ; and return if it is set ld hl, $D02D ; PP of first move (in battle) call .DecrementPP\@ -- cgit v1.2.3 From 5ec8c853a61ccc082309ac494e3a7394e2bc9344 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 23 Jan 2012 14:43:48 -0800 Subject: add missing labels hg-commit-id: f6c8feae4f1f --- common.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common.asm b/common.asm index ea9b1051..3d346345 100644 --- a/common.asm +++ b/common.asm @@ -597,8 +597,8 @@ OverworldLoopLessDelay: jr nz,.oddLoop\@ ld a,[$d52a] ld [$d528],a - call $0683 - jp c,$0637 + call NewBattle + jp c,.battleOccurred\@ jp OverworldLoop .noDirectionChange\@ ld a,[$d52a] ; current direction @@ -690,7 +690,7 @@ OverworldLoopLessDelay: ld hl,$d736 res 2,[hl] jp nc,CheckWarpsNoCollision ; check for warps if there was no battle -; if a battle occurred +.battleOccurred\@ ld hl,$d72d res 6,[hl] ld hl,$d733 -- cgit v1.2.3 From 7b2f040234d2d36d5b1c381eaa3a5abc636057c7 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 23 Jan 2012 18:26:45 -0800 Subject: disasm of some battle code hg-commit-id: a650d8e5b82a --- common.asm | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- constants.asm | 15 ++++-- 2 files changed, 143 insertions(+), 15 deletions(-) diff --git a/common.asm b/common.asm index 1ebbda95..84fb9ff1 100644 --- a/common.asm +++ b/common.asm @@ -21225,7 +21225,7 @@ CooltrainerFAI: BrockAI: ; if his active monster has a status condition, use a full heal - ld a,[W_OPPONENTSTATUS] + ld a,[W_ENEMYMONSTATUS] and a ret z jp AIUseFullHeal @@ -21351,7 +21351,7 @@ AIUseFullRestore: ; 0x3a6a0 ld a,[hl] ld [de],a ld [$CEEA],a - ld [W_OPPONENTHP],a + ld [W_ENEMYMONCURHP],a jr Function6718 ; 0x3a6ca @@ -21456,13 +21456,13 @@ Function674B: ; 674B ; prepare to withdraw the active monster: copy hp, number, and status to roster - ld a,[W_OPPONENTNUMBER] + ld a,[W_ENEMYMONNUMBER] ld hl,W_ENEMYMON1HP ld bc,$2C call AddNTimes ld d,h ld e,l - ld hl,W_OPPONENTHP + ld hl,W_ENEMYMONCURHP ld bc,4 call CopyData @@ -21495,13 +21495,13 @@ AIUseFullHeal: ; 0x3a786 AICureStatus: ; 0x3a791 ; cures the status of enemy's active pokemon - ld a,[W_OPPONENTNUMBER] + ld a,[W_ENEMYMONNUMBER] ld hl,$D8A8 ld bc,$2C call AddNTimes xor a ld [hl],a ; clear status in enemy team roster - ld [W_OPPONENTSTATUS],a ; clear status of active enemy + ld [W_ENEMYMONSTATUS],a ; clear status of active enemy ld hl,$D069 res 0,[hl] ret @@ -24362,7 +24362,7 @@ Function5811: ; 0x3d811 5811 ld a,[H_WHOSETURN] and a jr nz,.Ghost\@ - ld a,[W_CURMONSTATUS] ; player’s turn + ld a,[W_PLAYERMONSTATUS] ; player’s turn and a,SLP | FRZ ret nz ld hl,ScaredText @@ -24401,13 +24401,13 @@ Function583A: ; 0x3d83a 583A ret Function5854: ; 5854 - ld hl,W_CURMONSTATUS + ld hl,W_PLAYERMONSTATUS ld a,[hl] and a,SLP jr z,.FrozenCheck\@ ; to 5884 dec a - ld [W_CURMONSTATUS],a ; decrement sleep count + ld [W_PLAYERMONSTATUS],a ; decrement sleep count and a jr z,.WakeUp\@ ; to 5874 @@ -24517,7 +24517,7 @@ HyperBeamCheck: ; 58C2 ld hl,$580A jp $5A37 .ParalysisCheck\@ - ld hl,W_CURMONSTATUS + ld hl,W_PLAYERMONSTATUS bit 6,[hl] jr z,.next7\@ ; 5975 call $6E9B ; random number? @@ -24844,7 +24844,128 @@ HighCriticalMoves: ; 0x3e08e db $FF ; 0x3e093 -INCBIN "baserom.gbc",$3e093,$3e2ac - $3e093 +INCBIN "baserom.gbc",$3e093,$3e0df - $3e093 + +ApplyDamageToEnemyPokemon: ; 60DF + ld a,[W_PLAYERMOVEEFFECT] + cp a,$26 ; OHKO + jr z,.applyDamage\@ + cp a,$28 ; super fang's effect + jr z,.superFangEffect\@ + cp a,$29 ; special damage (fixed or random damage) + jr z,.specialDamage\@ + ld a,[W_PLAYERMOVEPOWER] + and a + jp z,.done\@ + jr .applyDamage\@ +.superFangEffect\@ +; set the damage to half the target's HP + ld hl,W_ENEMYMONCURHP + ld de,W_DAMAGE + ld a,[hli] + srl a + ld [de],a + inc de + ld b,a + ld a,[hl] + rr a + ld [de],a + or b + jr nz,.applyDamage\@ +; make sure Super Fang's damage is always at least 1 + ld a,$01 + ld [de],a + jr .applyDamage\@ +.specialDamage\@ + ld hl,W_PLAYERMONLEVEL + ld a,[hl] + ld b,a + ld a,[W_PLAYERMOVENUM] + cp a,SEISMIC_TOSS + jr z,.storeDamage\@ + cp a,NIGHT_SHADE + jr z,.storeDamage\@ + ld b,$14 ; Sonic Boom damage + cp a,SONICBOOM + jr z,.storeDamage\@ + ld b,$28 ; Dragon Rage damage + cp a,DRAGON_RAGE + jr z,.storeDamage\@ +; Psywave + ld a,[hl] + ld b,a + srl a + add b + ld b,a ; b = level * 1.5 +; loop until a random number between 1 and b is found +.loop\@ + call $6e9b ; random number + and a + jr z,.loop\@ + cp b + jr nc,.loop\@ + ld b,a +.storeDamage\@ + ld hl,W_DAMAGE + xor a + ld [hli],a + ld a,b + ld [hl],a +.applyDamage\@ + ld hl,W_DAMAGE + ld a,[hli] + ld b,a + ld a,[hl] + or b + jr z,.done\@ ; we're done if damage is 0 + ld a,[W_ENEMYBATTSTATUS2] + bit 4,a ; does the enemy have a substitute? + jp nz,$625e +; subtract the damage from the pokemon's current HP +; also, save the current HP at $CEEB + ld a,[hld] + ld b,a + ld a,[W_ENEMYMONCURHP + 1] + ld [$ceeb],a + sub b + ld [W_ENEMYMONCURHP + 1],a + ld a,[hl] + ld b,a + ld a,[W_ENEMYMONCURHP] + ld [$ceec],a + sbc b + ld [W_ENEMYMONCURHP],a + jr nc,.animateHpBar\@ +; if more damage was done than the current HP, zero the HP and set the damage +; equal to how HP the pokemon had before fainting + ld a,[$ceec] + ld [hli],a + ld a,[$ceeb] + ld [hl],a + xor a + ld hl,W_ENEMYMONCURHP + ld [hli],a + ld [hl],a +.animateHpBar\@ + ld hl,W_ENEMYMONMAXHP + ld a,[hli] + ld [$ceea],a + ld a,[hl] + ld [$cee9],a + ld hl,W_ENEMYMONCURHP + ld a,[hli] + ld [$ceee],a + ld a,[hl] + ld [$ceed],a + ld hl,$c3ca + xor a + ld [$cf94],a + ld a,$48 + call Predef ; animate the HP bar shortening +.done\@ + jp $4d5a ; redraw pokemon names and HP bars + +INCBIN "baserom.gbc",$3e1a0,$3e2ac - $3e1a0 UnnamedText_3e2ac: ; 0x3e2ac TX_FAR _UnnamedText_3e2ac diff --git a/constants.asm b/constants.asm index 1ea3d67e..8cb95bcd 100644 --- a/constants.asm +++ b/constants.asm @@ -114,9 +114,9 @@ W_PLAYERMOVETYPE EQU $CFD5 W_PLAYERMOVEACCURACY EQU $CFD6 W_PLAYERMOVEMAXPP EQU $CFD7 -W_OPPONENTHP EQU $CFE6 ; active opponent's hp (16 bits) -W_OPPONENTNUMBER EQU $CFE8 ; active opponent's position in team (0 to 5) -W_OPPONENTSTATUS EQU $CFE9 ; active opponent's status condition +W_ENEMYMONCURHP EQU $CFE6 ; active opponent's hp (16 bits) +W_ENEMYMONNUMBER EQU $CFE8 ; active opponent's position in team (0 to 5) +W_ENEMYMONSTATUS EQU $CFE9 ; active opponent's status condition ; bit 0 slp ; bit 1 slp ; bit 2 slp @@ -125,8 +125,11 @@ W_OPPONENTSTATUS EQU $CFE9 ; active opponent's status condition ; bit 5 frz ; bit 6 par ; unused? (XXX confirm) +W_ENEMYMONLEVEL EQU $CFF3 +W_ENEMYMONMAXHP EQU $CFF4 ; (16 bits) -W_CURMONSTATUS EQU $D018 ; the status of the player’s current monster +W_PLAYERMONCURHP EQU $D015 ; active opponent's hp (16 bits) +W_PLAYERMONSTATUS EQU $D018 ; the status of the player’s current monster ; bit 0 slp ; bit 1 slp ; bit 2 slp @@ -135,6 +138,8 @@ W_CURMONSTATUS EQU $D018 ; the status of the player’s current monster ; bit 5 frz ; bit 6 par ; unused? (XXX confirm) +W_PLAYERMONLEVEL EQU $D022 +W_PLAYERMONMAXHP EQU $D023 ; (16 bits) W_TRAINERCLASS EQU $D031 @@ -196,6 +201,8 @@ W_ENEMYDISABLEDMOVE EQU $D072 W_NUMHITS EQU $D074 ; number of hits in attacks like Doubleslap, etc. +W_DAMAGE EQU $D0D7 + ; List type ; used in $D0B6 MONSTER_NAME EQU 1 -- cgit v1.2.3 From 9a3a6c1b53deaae0236aa8ee85d384f2d29032bb Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 23 Jan 2012 18:31:27 -0800 Subject: fixed typo hg-commit-id: aade1ab573e4 --- common.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.asm b/common.asm index 84fb9ff1..4d56b420 100644 --- a/common.asm +++ b/common.asm @@ -24937,7 +24937,7 @@ ApplyDamageToEnemyPokemon: ; 60DF ld [W_ENEMYMONCURHP],a jr nc,.animateHpBar\@ ; if more damage was done than the current HP, zero the HP and set the damage -; equal to how HP the pokemon had before fainting +; equal to how much HP the pokemon had before fainting ld a,[$ceec] ld [hli],a ld a,[$ceeb] -- cgit v1.2.3