shithub: pokecrystal

Download patch

ref: 6730600d9b960f6f5583f4430a827f318c043df9
parent: 975efb28aec9faf9409cbf85fc636ac2e4219138
author: JimB16 <f1@jimb.de>
date: Thu Oct 8 16:53:39 EDT 2015

found CalcPkmnStats-function

--- a/battle/core.asm
+++ b/battle/core.asm
@@ -3738,7 +3738,7 @@
 	call GetBaseData
 	ld a, OTPARTYMON
 	ld [MonType], a
-	predef Function5084a
+	predef CopyPkmnToTempMon
 	call Function3f47c
 
 	xor a
@@ -6514,7 +6514,7 @@
 	ld de, EnemyMonMaxHP
 	ld b, $00
 	ld hl, LinkBattleRNs + 7 ; ?
-	predef Functione167
+	predef CalcPkmnStats
 
 ; If we're in a trainer battle,
 ; get the rest of the parameters from the party struct
@@ -7561,7 +7561,7 @@
 .asm_3ef74
 	xor a
 	ld [MonType], a
-	predef Function5084a
+	predef CopyPkmnToTempMon
 	callab Function50e1b
 	pop bc
 	ld hl, PartyMon1Level - PartyMon1
@@ -7597,7 +7597,7 @@
 	add hl, bc
 	push bc
 	ld b, $1
-	predef Functione167
+	predef CalcPkmnStats
 	pop bc
 	pop de
 	ld hl, $0025
@@ -7673,7 +7673,7 @@
 .asm_3f057
 	xor a
 	ld [MonType], a
-	predef Function5084a
+	predef CopyPkmnToTempMon
 	hlcoord 9, 0
 	ld b, $a
 	ld c, $9
@@ -7828,7 +7828,7 @@
 	ld [DefaultFlypoint], a
 	xor a
 	ld [MonType], a
-	predef Function5084a
+	predef CopyPkmnToTempMon
 	ld a, [TempMonLevel]
 	ld b, a
 	ld e, a
--- a/engine/predef.asm
+++ b/engine/predef.asm
@@ -38,11 +38,11 @@
 	add_predef FillPP
 	add_predef Functiond88c
 	add_predef Functionda96
-	add_predef Functiondb3f ; $8
+	add_predef SentGetPkmnIntoFromBox
 	add_predef SentPkmnIntoBox
 	add_predef GiveEgg
 	add_predef Functionc6e0
-	add_predef Functione167
+	add_predef CalcPkmnStats
 	add_predef Functione17b
 	add_predef CanLearnTMHMMove
 	add_predef GetTMHMMove
@@ -61,7 +61,7 @@
 	add_predef Function421e6
 	add_predef Function28f63
 	add_predef Function28f24
-	add_predef Function5084a
+	add_predef CopyPkmnToTempMon
 	add_predef ListMoves ; $20
 	add_predef Function50d2e
 	add_predef Function50cdb
--- a/items/item_effects.asm
+++ b/items/item_effects.asm
@@ -1288,7 +1288,7 @@
 	ld a, PartyMon1HPExp - 1 - PartyMon1
 	call GetPartyParamLocation
 	ld b, $1
-	predef_jump Functione167
+	predef_jump CalcPkmnStats
 ; ee9f
 
 Functionee9f: ; ee9f
@@ -1427,7 +1427,7 @@
 
 	xor a
 	ld [MonType], a
-	predef Function5084a
+	predef CopyPkmnToTempMon
 
 	hlcoord 9, 0
 	ld b, 10
--- a/main.asm
+++ b/main.asm
@@ -8204,7 +8204,7 @@
 	ld bc, $000a
 	add hl, bc
 	ld b, $0
-	call Functione167
+	call CalcPkmnStats
 
 .asm_da45
 	ld a, [MonType]
@@ -8263,6 +8263,7 @@
 	cp PARTY_LENGTH
 	scf
 	ret z
+
 	inc a
 	ld [hl], a
 	ld c, a
@@ -8336,30 +8337,37 @@
 
 	and a
 	ret
-; db3f
 
-Functiondb3f: ; db3f
+
+SentGetPkmnIntoFromBox: ; db3f
+; Sents/Gets Pkmn into/from Box depending on Parameter
+; wd10b == 0: get Pkmn into Party
+; wd10b == 1: sent Pkmn into Box
+
 	ld a, BANK(sBoxCount)
 	call GetSRAMBank
 	ld a, [wd10b]
 	and a
-	jr z, .asm_db60
+	jr z, .check_IfPartyIsFull
 	cp $2
-	jr z, .asm_db60
+	jr z, .check_IfPartyIsFull
 	cp $3
 	ld hl, wBreedMon1Species
 	jr z, .asm_db9b
+
+    ; we want to sent a Pkmn into the Box
+    ; so check if there's enough space
 	ld hl, sBoxCount
 	ld a, [hl]
 	cp MONS_PER_BOX
 	jr nz, .asm_db69
-	jp Functiondcb1
+	jp CloseSRAM_And_SetCFlag
 
-.asm_db60
+.check_IfPartyIsFull
 	ld hl, PartyCount
 	ld a, [hl]
 	cp PARTY_LENGTH
-	jp z, Functiondcb1
+	jp z, CloseSRAM_And_SetCFlag
 
 .asm_db69
 	inc a
@@ -8387,7 +8395,7 @@
 	ld a, [sBoxCount]
 
 .asm_db97
-	dec a
+	dec a ; PartyCount - 1
 	call AddNTimes
 
 .asm_db9b
@@ -8490,7 +8498,7 @@
 	srl a
 	add $2
 	ld [MonType], a
-	predef Function5084a
+	predef CopyPkmnToTempMon
 	callab Function50e1b
 	ld a, d
 	ld [CurPartyLevel], a
@@ -8508,7 +8516,7 @@
 	add hl, bc
 	push bc
 	ld b, $1
-	call Functione167
+	call CalcPkmnStats
 	pop bc
 	ld a, [wd10b]
 	and a
@@ -8553,7 +8561,7 @@
 	ret
 ; dcb1
 
-Functiondcb1: ; dcb1
+CloseSRAM_And_SetCFlag: ; dcb1
 	call CloseSRAM
 	scf
 	ret
@@ -8561,7 +8569,6 @@
 
 
 Functiondcb6: ; dcb6
-
 	ld a, b
 	ld hl, sBoxMons
 	ld bc, sBoxMon1End - sBoxMon1
@@ -8725,7 +8732,7 @@
 	add hl, bc
 	push bc
 	ld b, $1
-	call Functione167
+	call CalcPkmnStats
 	ld hl, PartyMon1Moves
 	ld a, [PartyCount]
 	dec a
@@ -9039,7 +9046,7 @@
 	dec a
 	ld hl, PartyMonNicknames
 	call SkipNames
-	ld de, Stringe035
+	ld de, String_Egg
 	call CopyName2
 	ld a, [PartyCount]
 	dec a
@@ -9066,12 +9073,11 @@
 	ret
 ; e035
 
-Stringe035: ; e035
+String_Egg: ; e035
 	db "EGG@"
 ; e039
 
 Functione039: ; e039
-
 	ld hl, PartyCount
 
 	ld a, [wd10b]
@@ -9239,7 +9245,7 @@
 	ld a, PartyMon1Exp + 2 - PartyMon1
 	call GetPartyParamLocation
 	ld b, $1
-	call Functione167
+	call CalcPkmnStats
 	pop de
 	ld a, PartyMon1HP - PartyMon1
 	call GetPartyParamLocation
@@ -9251,7 +9257,12 @@
 	ret
 ; e167
 
-Functione167: ; e167
+CalcPkmnStats: ; e167
+; Calculates all 6 Stats of a Pkmn
+; b = 0 or 1
+; 'c' counts from 1-6 and points with 'BaseStats' to the base value
+; results in $ffb5 and $ffb6 are saved in [de]
+
 	ld c, $0
 .asm_e169
 	inc c
@@ -9269,6 +9280,8 @@
 ; e17b
 
 Functione17b: ; e17b
+; 'c' is 1-6 and points to the BaseStat
+
 	push hl
 	push de
 	push bc
@@ -9275,8 +9288,8 @@
 	ld a, b
 	ld d, a
 	push hl
-	ld hl, BaseHP
-	dec hl
+	ld hl, BaseStats
+	dec hl ; has to be decreased, because 'c' begins with 1
 	ld b, $0
 	add hl, bc
 	ld a, [hl]
@@ -14171,7 +14184,7 @@
 	hlcoord 5, 1
 	call PlaceString
 	push bc
-	callba Function5084a
+	callba CopyPkmnToTempMon
 	pop hl
 	call PrintLevel
 	ld hl, PlayerHPPal
@@ -14188,7 +14201,7 @@
 	ld [hBGMapMode], a
 	ld [wd0e3], a
 	ld [MonType], a
-	predef Function5084a
+	predef CopyPkmnToTempMon
 	ld hl, TempMonMoves
 	ld de, wd25e
 	ld bc, NUM_MOVES
@@ -15726,7 +15739,7 @@
 	ld hl, PartyMon1Exp + 2 - PartyMon1
 	add hl, bc
 	ld b, $1
-	predef Functione167
+	predef CalcPkmnStats
 	pop hl
 	ld bc, PartyMon2 - PartyMon1
 	add hl, bc
@@ -20929,7 +20942,7 @@
 	pop hl
 	push bc
 	ld b, $0
-	predef Functione167
+	predef CalcPkmnStats
 	pop bc
 	ld hl, PartyMon1HP - PartyMon1
 	add hl, bc
@@ -21733,7 +21746,7 @@
 	ld bc, PartyMon1Exp + 2 - PartyMon1
 	add hl, bc
 	ld b, $0
-	predef Functione167
+	predef CalcPkmnStats
 	pop bc
 	ld hl, PartyMon1MaxHP - PartyMon1
 	add hl, bc
@@ -35655,7 +35668,7 @@
 	push hl
 	xor a
 	ld [MonType], a
-	predef Function5084a
+	predef CopyPkmnToTempMon
 	pop hl
 
 .asm_42230
@@ -35865,7 +35878,7 @@
 	ld hl, TempMonExp + 2
 	ld de, TempMonMaxHP
 	ld b, $1
-	predef Functione167
+	predef CalcPkmnStats
 
 	ld a, [CurPartyMon]
 	ld hl, PartyMons
@@ -44935,7 +44948,7 @@
 	call CopyBytes
 	jr .asm_4de2a
 .asm_4de10
-	callba Function5084a
+	callba CopyPkmnToTempMon
 	ld a, [CurPartySpecies]
 	cp EGG
 	jr z, .asm_4de2a
@@ -48065,10 +48078,13 @@
 	db "@"
 ; 0x5084a
 
-Function5084a: ; 5084a
+CopyPkmnToTempMon: ; 5084a
+; gets the BaseData of a Pkmn
+; and copys the PkmnStructure to TempMon
+
 	ld a, [CurPartyMon]
 	ld e, a
-	call Function508d5
+	call GetPkmnSpecies
 	ld a, [CurPartySpecies]
 	ld [CurSpecies], a
 	call GetBaseData
@@ -48089,7 +48105,7 @@
 .copywholestruct
 	ld a, [CurPartyMon]
 	call AddNTimes
-	ld de, TempMonSpecies
+	ld de, TempMon
 	ld bc, PartyMon2 - PartyMon1
 	call CopyBytes
 
@@ -48121,7 +48137,7 @@
 	add hl, bc
 	push bc
 	ld b, $1
-	predef Functione167
+	predef CalcPkmnStats
 	pop bc
 	ld hl, TempMonHP - TempMon
 	add hl, bc
@@ -48153,7 +48169,10 @@
 	ret
 ; 508d5
 
-Function508d5: ; 508d5
+GetPkmnSpecies: ; 508d5
+; [MonType] has the type of the Pkmn
+; e = Nr. of Pkmn (i.e. [CurPartyMon])
+
 	ld a, [MonType]
 	and a ; PARTYMON
 	jr z, .partymon
@@ -48656,7 +48675,7 @@
 	call GetNick
 	pop hl
 	call PlaceString
-	call Function5084a
+	call CopyPkmnToTempMon
 	pop hl
 	ld a, [CurPartySpecies]
 	cp EGG
@@ -48877,15 +48896,15 @@
 	call Function50e47
 	push hl
 	ld hl, TempMonExp + 2
-	ld a, [$ffb6]
+	ld a, [hMultiplicand + 2]
 	ld c, a
 	ld a, [hld]
 	sub c
-	ld a, [$ffb5]
+	ld a, [hMultiplicand + 1]
 	ld c, a
 	ld a, [hld]
 	sbc c
-	ld a, [hMultiplicand]
+	ld a, [hMultiplicand + 0]
 	ld c, a
 	ld a, [hl]
 	sbc c
@@ -49131,12 +49150,12 @@
 	ld bc, $30
 	call CopyBytes
 	ld a, [Buffer2] ; wd1eb (aliases: MovementType)
-	ld hl, PartyMonOT ; wddff (aliases: PartyMonOT)
+	ld hl, PartyMonOT
 	call SkipNames
 	push hl
 	call Function51036
 	ld a, [wd1ec]
-	ld hl, PartyMonOT ; wddff (aliases: PartyMonOT)
+	ld hl, PartyMonOT
 	call SkipNames
 	pop de
 	push hl
@@ -81727,7 +81746,7 @@
 	call Functione3357
 	ld hl, PartyMonNicknames
 	call Functione3363
-	ld hl, PartyMonOT ; wddff (aliases: PartyMonOT)
+	ld hl, PartyMonOT
 	call Functione3376
 	ld hl, PartyMons ; wdcdf (aliases: PartyMon1, PartyMon1Species)
 	ld bc, $30
@@ -81774,8 +81793,8 @@
 	call GetNick
 	ld a, $1
 	ld [wd10b], a
-	predef Functiondb3f
-	jr c, .asm_e30e4
+	predef SentGetPkmnIntoFromBox
+	jr c, .asm_boxisfull
 	xor a
 	ld [wd10b], a
 	callba Functione039
@@ -81792,7 +81811,7 @@
 	call TextBox
 	call WaitBGMap
 	hlcoord 1, 16
-	ld de, String_e3563
+	ld de, String_Stored
 	call PlaceString
 	ld l, c
 	ld h, b
@@ -81804,8 +81823,9 @@
 	call DelayFrames
 	and a
 	ret
-.asm_e30e4
-	ld de, String_e3575
+
+.asm_boxisfull
+	ld de, String_TheBoxIsFull
 	call Functione2a6e
 	ld de, SFX_WRONG
 	call WaitPlaySFX
@@ -81828,8 +81848,8 @@
 	call CloseSRAM
 	xor a
 	ld [wd10b], a
-	predef Functiondb3f
-	jr c, .asm_e316a
+	predef SentGetPkmnIntoFromBox
+	jr c, .party_is_full
 	ld a, $1
 	ld [wd10b], a
 	callba Functione039
@@ -81846,7 +81866,7 @@
 	call TextBox
 	call WaitBGMap
 	hlcoord 1, 16
-	ld de, String_e356b
+	ld de, String_Got
 	call PlaceString
 	ld l, c
 	ld h, b
@@ -81858,8 +81878,9 @@
 	call DelayFrames
 	and a
 	ret
-.asm_e316a
-	ld de, String_e3586
+
+.party_is_full
+	ld de, String_ThePartysFull
 	call Functione2a6e
 	ld de, SFX_WRONG
 	call WaitPlaySFX
@@ -81869,6 +81890,7 @@
 	scf
 	ret
 
+
 Functione3180: ; e3180 (38:7180)
 	hlcoord 0, 0
 	ld bc, $f08
@@ -82237,11 +82259,11 @@
 String_e3544: db "Remove MAIL.@"
 String_e3551: db "Released ", $e1, $e2, ".@"
 String_e355e: db "Bye,@"
-String_e3563: db "Stored @"
-String_e356b: db "Got @"
+String_Stored: db "Stored @"
+String_Got: db "Got @"
 String_e3570: db "Non.@"
-String_e3575: db "The BOX is full.@"
-String_e3586: db "The party's full!@"
+String_TheBoxIsFull: db "The BOX is full.@"
+String_ThePartysFull: db "The party's full!@"
 String_e3597: db "No releasing EGGS!@"
 ; e35aa
 
@@ -92417,7 +92439,7 @@
 
 	xor a
 	ld [MonType], a
-	callba Function5084a
+	callba CopyPkmnToTempMon
 	hlcoord 0, 7
 	ld b, $9
 	ld c, $12
@@ -92501,7 +92523,7 @@
 	call Functione58
 	xor a
 	ld [MonType], a
-	callba Function5084a
+	callba CopyPkmnToTempMon
 	hlcoord 0, 0
 	ld b, 15
 	ld c, 18
--- a/misc/mobile_45.asm
+++ b/misc/mobile_45.asm
@@ -15686,7 +15686,7 @@
 	pop de
 	push de
 	ld b, $1
-	predef Functione167
+	predef CalcPkmnStats
 	pop de
 	ld h, d
 	ld l, e
@@ -16102,7 +16102,7 @@
 	ld hl, $c616 + 1
 	ld de, $c62c + 5
 	ld b, $1
-	predef Functione167
+	predef CalcPkmnStats
 	ld de, $c62c + 5
 	ld hl, $c62c + 3
 	ld a, [de]
@@ -23076,7 +23076,7 @@
 	ld hl, $000a
 	add hl, bc
 	ld b, $1
-	predef Functione167
+	predef CalcPkmnStats
 	pop de
 	pop hl
 rept 2
--- a/misc/mobile_5f.asm
+++ b/misc/mobile_5f.asm
@@ -2465,7 +2465,7 @@
 	ld e, l
 	push hl
 	ld b, $0
-	callba Functione167
+	callba CalcPkmnStats
 	ld a, [PartyCount]
 	dec a
 	ld hl, PartyMon1HP