summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlibjet <libj3t@gmail.com>2020-05-21 15:41:26 +0100
committerlibjet <libj3t@gmail.com>2020-05-21 15:41:26 +0100
commit76b9e5b98267c027b70a863e7f3df2dc86d8f705 (patch)
tree85454a64922becf14a2ebf005cebf11174fcbf15
parent92529391d8948f43c4f16e35a6024e9fa996a644 (diff)
Add engine/pokemon/tempmon.asm
-rwxr-xr-xengine/pokemon/tempmon.asm127
-rw-r--r--main.asm4
2 files changed, 129 insertions, 2 deletions
diff --git a/engine/pokemon/tempmon.asm b/engine/pokemon/tempmon.asm
new file mode 100755
index 00000000..97ce1ee7
--- /dev/null
+++ b/engine/pokemon/tempmon.asm
@@ -0,0 +1,127 @@
+CopyMonToTempMon:
+; gets the BaseData of a mon
+; and copies the party_struct to wTempMon
+
+ ld a, [wCurPartyMon]
+ ld e, a
+ call GetMonSpecies
+ ld a, [wCurPartySpecies]
+ ld [wCurSpecies], a
+ call GetBaseData
+
+ ld a, [wMonType]
+ ld hl, wPartyMon1Species
+ ld bc, PARTYMON_STRUCT_LENGTH
+ and a
+ jr z, .copywholestruct
+ ld hl, wOTPartyMon1Species
+ ld bc, PARTYMON_STRUCT_LENGTH
+ cp OTPARTYMON
+ jr z, .copywholestruct
+ ld bc, BOXMON_STRUCT_LENGTH
+ callfar CopyBoxmonToTempMon
+ jr .done
+
+.copywholestruct
+ ld a, [wCurPartyMon]
+ call AddNTimes
+ ld de, wTempMon
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call CopyBytes
+
+.done
+ ret
+
+CalcBufferMonStats:
+ ld bc, wBufferMon
+ jr _TempMonStatsCalculation
+
+CalcTempmonStats:
+ ld bc, wTempMon
+_TempMonStatsCalculation:
+ ld hl, MON_LEVEL
+ add hl, bc
+ ld a, [hl]
+ ld [wCurPartyLevel], a
+ ld hl, MON_MAXHP
+ add hl, bc
+ ld d, h
+ ld e, l
+ ld hl, MON_STAT_EXP - 1
+ add hl, bc
+ push bc
+ ld b, TRUE
+ predef CalcMonStats
+ pop bc
+ ld hl, MON_HP
+ add hl, bc
+ ld d, h
+ ld e, l
+ ld a, [wCurPartySpecies]
+ cp EGG
+ jr nz, .not_egg
+ xor a
+ ld [de], a
+ inc de
+ ld [de], a
+ jr .zero_status
+
+.not_egg
+ push bc
+ ld hl, MON_MAXHP
+ add hl, bc
+ ld bc, 2
+ call CopyBytes
+ pop bc
+
+.zero_status
+ ld hl, MON_STATUS
+ add hl, bc
+ xor a
+ ld [hli], a
+ ld [hl], a
+ ret
+
+GetMonSpecies:
+; [wMonType] has the type of the mon
+; e = Nr. of mon (i.e. [wCurPartyMon])
+
+ ld a, [wMonType]
+ and a ; PARTYMON
+ jr z, .partymon
+ cp OTPARTYMON
+ jr z, .otpartymon
+ cp BOXMON
+ jr z, .boxmon
+ cp TEMPMON
+ jr z, .breedmon
+ ; WILDMON
+
+.partymon
+ ld hl, wPartySpecies
+ jr .done
+
+.otpartymon
+ ld hl, wOTPartySpecies
+ jr .done
+
+.boxmon
+ ld a, BANK(sBoxSpecies)
+ call OpenSRAM
+ ld hl, sBoxSpecies
+ call .done
+ call CloseSRAM
+ ret
+
+.breedmon
+ ld a, [wBreedMon1Species]
+ jr .done2
+
+.done
+ ld d, 0
+ add hl, de
+ ld a, [hl]
+
+.done2
+ ld [wCurPartySpecies], a
+ ret
diff --git a/main.asm b/main.asm
index 0ceeff58..b6a88239 100644
--- a/main.asm
+++ b/main.asm
@@ -365,9 +365,8 @@ INCLUDE "engine/events/squirtbottle.asm"
INCLUDE "engine/events/card_key.asm"
INCLUDE "engine/events/basement_key.asm"
INCLUDE "engine/events/sacred_ash.asm"
+INCLUDE "engine/pokemon/tempmon.asm"
-CopyMonToTempMon::
- dr $5087d, $50940
PrintMonTypes::
dr $50940, $5096d
PrintMoveType::
@@ -376,6 +375,7 @@ PrintType::
dr $50986, $50997
GetTypeName::
dr $50997, $50b3d
+
DrawPlayerHP::
dr $50b3d, $50b41
DrawEnemyHP::