shithub: pokered

Download patch

ref: 365ae68d80683deab0e2e721b8ff79dda4047513
parent: cf399a8c86a7340a8c3162400657dca1c5d3ba0a
author: yenatch <yenatch@gmail.com>
date: Fri Aug 22 19:17:47 EDT 2014

Use PARTY_LENGTH and related constants in menu and hud code.

This should allow reducing PARTY_LENGTH to work as intended.
Increasing it also works provided space is provided in wram, but breaks pc/saving.

--- a/engine/battle/e.asm
+++ b/engine/battle/e.asm
@@ -1407,7 +1407,7 @@
 	ld [hl], $20
 	ld a, $f8
 	ld [wTrainerEngageDistance], a
-	ld hl, wOAMBuffer + $18
+	ld hl, wOAMBuffer + PARTY_LENGTH * 4
 	jp Func_3a8e1
 
 SetupPokeballs: ; 0x3a8a6
@@ -1414,7 +1414,7 @@
 	ld a, [de]
 	push af
 	ld de, wBuffer
-	ld c, $6 ; max num of partymons
+	ld c, PARTY_LENGTH
 	ld a, $34 ; empty pokeball
 .emptyloop
 	ld [de], a
@@ -1462,7 +1462,7 @@
 
 Func_3a8e1: ; 3a8e1 (e:68e1)
 	ld de, wHPBarMaxHP
-	ld c, $6
+	ld c, PARTY_LENGTH
 .asm_3a8e6
 	ld a, [W_BASECOORDY] ; wd082
 	ld [hli], a
--- a/engine/give_pokemon.asm
+++ b/engine/give_pokemon.asm
@@ -3,10 +3,10 @@
 	xor a
 	ld [wccd3], a
 	ld a, [wPartyCount] ; wPartyCount
-	cp $6
+	cp PARTY_LENGTH
 	jr c, .asm_4fe01
 	ld a, [W_NUMINBOX] ; wda80
-	cp $14
+	cp MONS_PER_BOX
 	jr nc, .asm_4fdf9
 	xor a
 	ld [W_ENEMYBATTSTATUS3], a ; W_ENEMYBATTSTATUS3
@@ -18,18 +18,18 @@
 	ld hl, wcf4b
 	ld a, [wd5a0]
 	and $7f
-	cp $9
+	cp 9
 	jr c, .asm_4fdec
-	sub $9
-	ld [hl], $f7
+	sub 9
+	ld [hl], "1"
 	inc hl
-	add $f6
+	add "0"
 	jr .asm_4fdee
 .asm_4fdec
-	add $f7
+	add "1"
 .asm_4fdee
 	ld [hli], a
-	ld [hl], $50
+	ld [hl], "@"
 	ld hl, SetToBoxText
 	call PrintText
 	scf
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -110,10 +110,10 @@
 	dec a
 	jr z,.UseBall
 	ld a,[wPartyCount]	;is Party full?
-	cp a,6
+	cp a,PARTY_LENGTH
 	jr nz,.UseBall
 	ld a,[W_NUMINBOX]	;is Box full?
-	cp a,20
+	cp a,MONS_PER_BOX
 	jp z,BoxFullCannotThrowBall
 .UseBall	;$56a7
 ;ok, you can use a ball
@@ -421,7 +421,7 @@
 	predef ShowPokedexData
 .checkParty	;$58f4
 	ld a,[wPartyCount]
-	cp a,6		;is party full?
+	cp a,PARTY_LENGTH		;is party full?
 	jr z,.sendToBox
 	xor a
 	ld [wcc49],a
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -88,25 +88,13 @@
 	ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
 	ret
 
-SomeonesPCText: ; 2148b (8:548b)
-	db "SOMEONE's PC@"
+SomeonesPCText:   db "SOMEONE's PC@"
+BillsPCText:      db "BILL's PC@"
+PlayersPCText:    db "'s PC@"
+OaksPCText:       db "PROF.OAK's PC@"
+PKMNLeaguePCText: db $4a, "LEAGUE@"
+LogOffPCText:     db "LOG OFF@"
 
-BillsPCText: ; 21497 (8:5497)
-	db "BILL's PC@"
-
-PlayersPCText: ; 214a0 (8:54a0)
-	db "'s PC@"
-
-OaksPCText: ; 214a5 (8:54a5)
-	db "PROF.OAK's PC@"
-
-PKMNLeaguePCText: ; 214b2 (8:54b2)
-	db $4a,"LEAGUE@"
-
-LogOffPCText: ; 214ba (8:54ba)
-	db "LOG OFF@"
-
-Func_214c2:: ; 214c2 (8:54c2)
 BillsPC_:: ; 0x214c2
 	ld hl, wd730
 	set 6, [hl]
@@ -167,15 +155,15 @@
 	call TextBoxBorder
 	ld a, [wd5a0]
 	and $7f
-	cp $9
+	cp 9
 	jr c, .asm_2154f
-	sub $9
+	sub 9
 	hlCoord 17, 16
-	ld [hl], $f7
-	add $f6
+	ld [hl], "1"
+	add "0"
 	jr .asm_21551
 .asm_2154f
-	add $f7
+	add "1"
 .asm_21551
 	Coorda 18, 16
 	hlCoord 10, 16
@@ -227,7 +215,7 @@
 	jp BillsPCMenu
 .asm_215bb
 	ld a, [W_NUMINBOX] ; wda80
-	cp $14
+	cp MONS_PER_BOX
 	jr nz, .asm_215cb
 	ld hl, BoxFullText ; $5802
 	call PrintText
@@ -251,15 +239,15 @@
 	ld hl, wWhichTrade ; wWhichTrade
 	ld a, [wd5a0]
 	and $7f
-	cp $9
+	cp 9
 	jr c, .asm_2160a
-	sub $9
-	ld [hl], $f7
+	sub 9
+	ld [hl], "1"
 	inc hl
-	add $f6
+	add "0"
 	jr .asm_2160c
 .asm_2160a
-	add $f7
+	add "1"
 .asm_2160c
 	ld [hli], a
 	ld [hl], $50
@@ -276,7 +264,7 @@
 	jp Func_214e8
 .asm_21627
 	ld a, [wPartyCount] ; wPartyCount
-	cp $6
+	cp PARTY_LENGTH
 	jr nz, .asm_21637
 	ld hl, CantTakeMonText ; $5811
 	call PrintText
@@ -353,7 +341,12 @@
 	ret
 
 BillsPCMenuText: ; 216e1 (8:56e1)
-	db "WITHDRAW ",$4a,$4e,"DEPOSIT ",$4a,$4e,"RELEASE ",$4a,$4e,"CHANGE BOX",$4e,"SEE YA!@"
+	db   "WITHDRAW ", $4a
+	next "DEPOSIT ",  $4a
+	next "RELEASE ",  $4a
+	next "CHANGE BOX"
+	next "SEE YA!"
+	db "@"
 
 BoxNoPCText: ; 21713 (8:5713)
 	db "BOX No.@"
@@ -389,7 +382,7 @@
 	db SURF
 	db STRENGTH
 	db FLASH
-	db $ff
+	db -1
 
 Func_2174b: ; 2174b (8:574b)
 	hlCoord 9, 10
@@ -458,15 +451,12 @@
 	call LoadGBPal
 	jr .asm_2178f
 
-DepositPCText: ; 217cb (8:57cb)
-	db "DEPOSIT@"
+DepositPCText:  db "DEPOSIT@"
+WithdrawPCText: db "WITHDRAW@"
+StatsCancelPCText:
+	db   "STATS"
+	next "CANCEL@"
 
-WithdrawPCText: ; 217d3 (8:57d3)
-	db "WITHDRAW@"
-
-StatsCancelPCText: ; 217dc (8:57dc)
-	db "STATS",$4e,"CANCEL@"
-
 SwitchOnText: ; 0x217e9
 	TX_FAR _SwitchOnText
 	db "@"
@@ -523,7 +513,7 @@
 	cp $c
 	ret nz
 	ld a, [W_CURMAP]
-	cp $ef
+	cp BATTLE_CENTER
 	ld a, $2
 	jr z, .asm_2183a
 	inc a
@@ -541,7 +531,7 @@
 	cp $8
 	ret nz
 	ld a, [W_CURMAP]
-	cp $ef
+	cp BATTLE_CENTER
 	ld a, $2
 	jr z, .asm_2185a
 	inc a
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -445,15 +445,15 @@
 	res 2, [hl]
 	ld a, [wd5a0]
 	and $7f
-	cp $9
+	cp 9
 	jr c, .asm_739a6
-	sub $9
+	sub 9
 	hlCoord 8, 2
-	ld [hl], $f7
-	add $f6
+	ld [hl], "1"
+	add "0"
 	jr .asm_739a8
 .asm_739a6
-	add $f7
+	add "1"
 .asm_739a8
 	Coorda 9, 2
 	hlCoord 1, 2
--- a/main.asm
+++ b/main.asm
@@ -3419,7 +3419,7 @@
 .asm_f2f2
 	ld a, [de]
 	inc a
-	cp $7
+	cp PARTY_LENGTH + 1
 	ret nc
 	ld [de], a
 	ld a, [de]
@@ -3681,7 +3681,7 @@
 _AddEnemyMonToPlayerParty: ; f49d (3:749d)
 	ld hl, wPartyCount
 	ld a, [hl]
-	cp $6
+	cp PARTY_LENGTH
 	scf
 	ret z            ; party full, return failure
 	inc a
@@ -3750,13 +3750,13 @@
 	jr z, .asm_f575
 	ld hl, W_NUMINBOX ; wda80
 	ld a, [hl]
-	cp $14
+	cp MONS_PER_BOX
 	jr nz, .partyOrBoxNotFull
 	jr .boxFull
 .checkPartyMonSlots
 	ld hl, wPartyCount ; wPartyCount
 	ld a, [hl]
-	cp $6
+	cp PARTY_LENGTH
 	jr nz, .partyOrBoxNotFull
 .boxFull
 	scf
@@ -3899,7 +3899,7 @@
 	ld a, d
 	ld [W_CURENEMYLVL], a ; W_CURENEMYLVL
 	pop hl
-	ld bc, $21
+	ld bc, wBoxMon2 - wBoxMon1
 	add hl, bc
 	ld [hli], a
 	ld d, h
--- a/scripts/daycarem.asm
+++ b/scripts/daycarem.asm
@@ -67,9 +67,9 @@
 	call LoadMonData
 	callab Func_58f43
 	ld a, d
-	cp $64
+	cp MAX_LEVEL
 	jr c, .asm_56315
-	ld d, $64
+	ld d, MAX_LEVEL
 	callab CalcExperience
 	ld hl, wDayCareMonExp
 	ld a, [H_NUMTOPRINT]
@@ -78,7 +78,7 @@
 	ld [hli], a
 	ld a, [$ff98]
 	ld [hl], a
-	ld d, $64
+	ld d, MAX_LEVEL
 
 .asm_56315
 	xor a
@@ -100,7 +100,7 @@
 .asm_56333
 	call PrintText
 	ld a, [wPartyCount]
-	cp $6
+	cp PARTY_LENGTH
 	ld hl, DayCareMText_56440
 	jp z, .asm_56403
 	ld de, wTrainerFacingDirection
--- a/scripts/route5gate.asm
+++ b/scripts/route5gate.asm
@@ -27,11 +27,11 @@
 	xor a
 	ld [hJoyHeld], a
 	callba RemoveGuardDrink
-	ld a, [$ff00+$db]
+	ld a, [$ffdb]
 	and a
 	jr nz, .asm_1df82 ; 0x1df70 $10
 	ld a, $2
-	ld [$ff00+$8c], a
+	ld [$ff8c], a
 	call DisplayTextID
 	call Route5GateScript_1df43
 	ld a, $1
@@ -39,7 +39,7 @@
 	ret
 .asm_1df82
 	ld a, $3
-	ld [$ff00+$8c], a
+	ld [$ff8c], a
 	call DisplayTextID
 	ld hl, wd728
 	set 6, [hl]
@@ -74,7 +74,7 @@
 	bit 6, a
 	jr nz, .asm_88856 ; 0x1dfb0 $2c
 	callba RemoveGuardDrink
-	ld a, [$ff00+$db]
+	ld a, [$ffdb]
 	and a
 	jr nz, .asm_768a2 ; 0x1dfbd $11
 	ld hl, Route5GateText2