shithub: pokered

Download patch

ref: 81bbab85ac7d7f4c2efe794a4b3cc1e51c0b2689
parent: 53ae0e93fad9f4c3eaef92f102b1eeb531e59d68
author: yenatch <yenatch@gmail.com>
date: Sat Jun 14 10:24:35 EDT 2014

Hall of Fame sram labels and related constants.

--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -10,5 +10,11 @@
 MAX_LEVEL EQU 100
 NUM_MOVES EQU 4
 
+PARTY_LENGTH EQU 6
+
 MONS_PER_BOX EQU 20
 NUM_BOXES    EQU 12
+
+HOF_MON       EQU $10
+HOF_TEAM      EQU PARTY_LENGTH * HOF_MON
+NUM_HOF_TEAMS EQU 50
--- a/constants/pokedex_constants.asm
+++ b/constants/pokedex_constants.asm
@@ -148,4 +148,6 @@
 DEX_DRAGONAIR  EQU 148
 DEX_DRAGONITE  EQU 149
 DEX_MEWTWO     EQU 150
-DEX_MEW        EQU 151
\ No newline at end of file
+DEX_MEW        EQU 151
+
+NUM_POKEMON    EQU 151
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -1,7 +1,7 @@
 AnimateHallOfFame: ; 701a0 (1c:41a0)
 	call Func_70423
 	call ClearScreen
-	ld c, $64
+	ld c, 100
 	call DelayFrames
 	call LoadFontTilePatterns
 	call LoadTextBoxTilePatterns
@@ -14,8 +14,8 @@
 	ld hl, rLCDC ; $ff40
 	set 3, [hl]
 	xor a
-	ld hl, wcc5b
-	ld bc, $60
+	ld hl, wHallOfFame
+	ld bc, HOF_TEAM
 	call FillMemory
 	xor a
 	ld [wcfcb], a
@@ -49,7 +49,7 @@
 	ld a, c
 	ld [wTrainerEngageDistance], a
 	ld hl, wPartyMon1Level ; wPartyMon1Level
-	ld bc, $2c
+	ld bc, wPartyMon2 - wPartyMon1
 	call AddNTimes
 	ld a, [hl]
 	ld [wTrainerFacingDirection], a
@@ -66,7 +66,7 @@
 	ld hl, Coord
 	ld de, HallOfFameText
 	call PlaceString
-	ld c, $b4
+	ld c, 180
 	call DelayFrames
 	call GBFadeOut2
 	pop bc
@@ -75,11 +75,11 @@
 .asm_70241
 	ld a, c
 	inc a
-	ld hl, wcc5b
-	ld bc, $10
+	ld hl, wHallOfFame
+	ld bc, HOF_MON
 	call AddNTimes
 	ld [hl], $ff
-	call Func_73b0d
+	call SaveHallOfFameTeams
 	xor a
 	ld [wWhichTrade], a ; wWhichTrade
 	inc a
@@ -283,8 +283,8 @@
 	db "@"
 
 Func_70404: ; 70404 (1c:4404)
-	ld hl, wcc5b
-	ld bc, $10
+	ld hl, wHallOfFame
+	ld bc, HOF_MON
 	ld a, [wTrainerEngageDistance]
 	call AddNTimes
 	ld a, [wWhichTrade] ; wWhichTrade
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -16,9 +16,9 @@
 	ld [wcd42], a
 	ld a, [wd5a2]
 	ld b, a
-	cp a, $33
+	cp NUM_HOF_TEAMS + 1
 	jr c, .first
-	ld b, $32
+	ld b, NUM_HOF_TEAMS
 	sub b
 	ld [wcd42], a
 .first
@@ -27,7 +27,7 @@
 	push bc
 	ld a, [wTrainerScreenX]
 	ld [wWhichTrade], a
-	callba Func_73b3f
+	callba LoadHallOfFameTeams
 	call Func_765e5
 	pop bc
 	jr c, .second
@@ -49,28 +49,28 @@
 	jp GBPalNormal
 
 Func_765e5: ; 765e5 (1d:65e5)
-	ld c, 6
-.third
+	ld c, PARTY_LENGTH
+.loop
 	push bc
 	call Func_76610
 	call WaitForTextScrollButtonPress
 	ld a, [hJoyHeld]
 	bit 1, a
-	jr nz, .fifth
-	ld hl, wcc6b
-	ld de, wcc5b
-	ld bc, $0050
+	jr nz, .exit
+	ld hl, wHallOfFame + HOF_MON
+	ld de, wHallOfFame
+	ld bc, HOF_TEAM - HOF_MON
 	call CopyData
 	pop bc
-	ld a, [wcc5b]
-	cp a, $FF
-	jr z, .fourth
+	ld a, [wHallOfFame + 0]
+	cp $ff
+	jr z, .done
 	dec c
-	jr nz, .third
-.fourth
+	jr nz, .loop
+.done
 	and a
 	ret
-.fifth
+.exit
 	pop bc
 	scf
 	ret
@@ -78,7 +78,7 @@
 Func_76610: ; 76610 (1d:6610)
 	call GBPalWhiteOutWithDelay3
 	call ClearScreen
-	ld hl, wcc5b
+	ld hl, wHallOfFame
 	ld a, [hli]
 	ld [wWhichTrade], a
 	ld [wcf91], a
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -628,38 +628,40 @@
 	ld [$0000],a
 	ret
 
-Func_73b0d: ; 73b0d (1c:7b0d)
+SaveHallOfFameTeams: ; 73b0d (1c:7b0d)
 	ld a, [wd5a2]
 	dec a
-	cp $32
+	cp NUM_HOF_TEAMS
 	jr nc, .asm_73b28
-	ld hl, $a598
-	ld bc, $60
+	ld hl, sHallOfFame
+	ld bc, HOF_TEAM
 	call AddNTimes
 	ld e, l
 	ld d, h
 	ld hl, wcc5b
-	ld bc, $60
-	jr CopyToSRAM0
+	ld bc, HOF_TEAM
+	jr HallOfFame_Copy
+
 .asm_73b28
-	ld hl, $a5f8
-	ld de, $a598
-	ld bc, $1260
-	call CopyToSRAM0
+	ld hl, sHallOfFame + HOF_TEAM
+	ld de, sHallOfFame
+	ld bc, HOF_TEAM * (NUM_HOF_TEAMS - 1)
+	call HallOfFame_Copy
 	ld hl, wcc5b
-	ld de, $b7f8
-	ld bc, $60
-	jr CopyToSRAM0
+	ld de, sHallOfFame + HOF_TEAM * (NUM_HOF_TEAMS - 1)
+	ld bc, HOF_TEAM
+	jr HallOfFame_Copy
 
-Func_73b3f: ; 73b3f (1c:7b3f)
-	ld hl, $a598
-	ld bc, $60
+LoadHallOfFameTeams: ; 73b3f (1c:7b3f)
+	ld hl, sHallOfFame
+	ld bc, HOF_TEAM
 	ld a, [wWhichTrade] ; wWhichTrade
 	call AddNTimes
 	ld de, wcc5b
-	ld bc, $60
+	ld bc, HOF_TEAM
 	; fallthrough
-CopyToSRAM0: ; 73b51 (1c:7b51)
+
+HallOfFame_Copy: ; 73b51 (1c:7b51)
 	ld a, $a
 	ld [$0], a
 	ld a, $1
--- a/home.asm
+++ b/home.asm
@@ -284,7 +284,7 @@
 	and a
 	pop hl
 	jr z, .invalidDexNumber  ; dex #0 invalid
-	cp 151 + 1
+	cp NUM_POKEMON + 1
 	jr c, .validDexNumber    ; dex >#151 invalid
 .invalidDexNumber
 	ld a, RHYDON ; $1
--- a/wram.asm
+++ b/wram.asm
@@ -287,10 +287,13 @@
 
 wcc57:: ds 1
 wcc58:: ds 3
+
+wHallOfFame:: ; cc5b
 wcc5b:: ds 1
 wcc5c:: ds 1
 wcc5d:: ds 1
 wcc5e:: ds 13
+
 wcc6b:: ds 14
 wcc79:: ds 30
 wcc97:: ds 10
@@ -1066,7 +1069,7 @@
 	ds 11
 
 wPartyCount::   ds 1 ; d163
-wPartySpecies:: ds 6 ; d164
+wPartySpecies:: ds PARTY_LENGTH ; d164
 wPartyEnd::     ds 1 ; d16a
 
 wPartyMons::
@@ -1077,16 +1080,16 @@
 wPartyMon5:: party_struct wPartyMon5 ; d21b
 wPartyMon6:: party_struct wPartyMon6 ; d247
 
-wPartyMonOT::    ds 11 * 6 ; d273
-wPartyMonNicks:: ds 11 * 6 ; d2b5
+wPartyMonOT::    ds 11 * PARTY_LENGTH ; d273
+wPartyMonNicks:: ds 11 * PARTY_LENGTH ; d2b5
 
 
 wPokedexOwned:: ; d2f7
-	flag_array 151
+	flag_array NUM_POKEMON
 wPokedexOwnedEnd::
 
 wPokedexSeen:: ; d30a
-	flag_array 151
+	flag_array NUM_POKEMON
 wPokedexSeenEnd::
 
 
@@ -1744,7 +1747,7 @@
 
 
 wEnemyPartyCount:: ds 1     ; d89c
-wEnemyPartyMons::  ds 6 + 1 ; d89d
+wEnemyPartyMons::  ds PARTY_LENGTH + 1 ; d89d
 
 wEnemyMons:: ; d8a4
 wEnemyMon1:: party_struct wEnemyMon1
@@ -1754,8 +1757,8 @@
 wEnemyMon5:: party_struct wEnemyMon5
 wEnemyMon6:: party_struct wEnemyMon6
 
-wEnemyMonOT::    ds 11 * 6 ; d9ac
-wEnemyMonNicks:: ds 11 * 6 ; d9ee
+wEnemyMonOT::    ds 11 * PARTY_LENGTH ; d9ac
+wEnemyMonNicks:: ds 11 * PARTY_LENGTH ; d9ee
 
 
 W_TRAINERHEADERPTR:: ; da30
@@ -1815,12 +1818,13 @@
 	ds -$100
 
 
-SECTION "Sprite Buffers", SRAM
+SECTION "Sprite Buffers", SRAM, BANK[0]
 
-S_SPRITEBUFFER0:: ; a000
-	ds SPRITEBUFFERSIZE
-S_SPRITEBUFFER1:: ; a188
-	ds SPRITEBUFFERSIZE
-S_SPRITEBUFFER2:: ; a310
-	ds SPRITEBUFFERSIZE
+S_SPRITEBUFFER0:: ds SPRITEBUFFERSIZE ; a000
+S_SPRITEBUFFER1:: ds SPRITEBUFFERSIZE ; a188
+S_SPRITEBUFFER2:: ds SPRITEBUFFERSIZE ; a310
+
+	ds $100
+
+sHallOfFame:: ds HOF_TEAM * NUM_HOF_TEAMS ; a598