shithub: pokecrystal

Download patch

ref: 4e2487c056c4dcddd3059a105e6ac89144137ab1
parent: ca01a92880a5d71bce2bec6caa7714c8e1cf0f17
author: pikalaxalt <[email protected]>
date: Mon Jun 13 18:53:33 EDT 2016

hLCDCPointer and InitList

--- a/battle/bg_effects.asm
+++ b/battle/bg_effects.asm
@@ -933,7 +933,7 @@
 	call InitSurfWaves
 
 .one
-	ld a, [hFFC6]
+	ld a, [hLCDCPointer]
 	and a
 	ret z
 	push bc
@@ -997,8 +997,8 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $42
-	ld [hFFC6], a
+	ld a, rSCY - $ff00
+	ld [hLCDCPointer], a
 	xor a
 	ld [hLYOverrideStart], a
 	ld a, $5e
@@ -1017,7 +1017,7 @@
 
 BattleBGEffect_30: ; c85c2 (32:45c2)
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $42
+	ld a, rSCY - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	call EndBattleBGEffect
 	ret
@@ -1071,8 +1071,8 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
-	ld [hFFC6], a
+	ld a, rSCX - $ff00
+	ld [hLCDCPointer], a
 	xor a
 	ld [hLYOverrideStart], a
 	ld a, $5f
@@ -1109,7 +1109,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
+	ld a, rSCX - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	lb de, 6, 5
 	call Functionc8f2e
@@ -1134,7 +1134,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $42
+	ld a, rSCY - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ld hl, BG_EFFECT_STRUCT_03
 	add hl, bc
@@ -1165,7 +1165,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
+	ld a, rSCX - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ld a, [hLYOverrideEnd]
 	inc a
@@ -1257,7 +1257,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $42
+	ld a, rSCY - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ld hl, BG_EFFECT_STRUCT_03
 	add hl, bc
@@ -1320,7 +1320,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $42
+	ld a, rSCY - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ld a, [hLYOverrideEnd]
 	inc a
@@ -1370,7 +1370,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $42
+	ld a, rSCY - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ld a, [hLYOverrideEnd]
 	inc a
@@ -1437,7 +1437,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
+	ld a, rSCX - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ld a, [hLYOverrideEnd]
 	inc a
@@ -1472,7 +1472,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
+	ld a, rSCX - $ff00
 	call BattleBGEffect_SetLCDStatCustoms2
 	ld a, [hLYOverrideEnd]
 	inc a
@@ -1604,7 +1604,7 @@
 BGEffect2d_2f_zero:
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
+	ld a, rSCX - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ld a, [hLYOverrideEnd]
 	inc a
@@ -1648,7 +1648,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
+	ld a, rSCX - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ld a, [hLYOverrideEnd]
 	inc a
@@ -1687,7 +1687,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
+	ld a, rSCX - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ld a, [hLYOverrideEnd]
 	inc a
@@ -1742,7 +1742,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
+	ld a, rSCX - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ret
 
@@ -1785,7 +1785,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $42
+	ld a, rSCY - $ff00
 	call BattleBGEffect_SetLCDStatCustoms2
 	ld a, [hLYOverrideEnd]
 	inc a
@@ -1944,7 +1944,7 @@
 .zero
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
+	ld a, rSCX - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ld hl, BG_EFFECT_STRUCT_BATTLE_TURN
 	add hl, bc
@@ -1986,8 +1986,8 @@
 	call BattleBGEffects_IncrementJumptable
 	ld a, $e4
 	call BattleBGEffects_SetLYOverrides
-	ld a, $47
-	ld [hFFC6], a
+	ld a, rBGP - $ff00
+	ld [hLCDCPointer], a
 	xor a
 	ld [hLYOverrideStart], a
 	ld a, $60
@@ -2221,7 +2221,7 @@
 .zero ; c8c68 (32:4c68)
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
+	ld a, rSCX - $ff00
 	call BattleBGEffect_SetLCDStatCustoms1
 	ld a, [hLYOverrideEnd]
 	inc a
@@ -2267,8 +2267,8 @@
 .zero ; c8cab (32:4cab)
 	call BattleBGEffects_IncrementJumptable
 	call BattleBGEffects_ClearLYOverrides
-	ld a, $43
-	ld [hFFC6], a
+	ld a, rSCX - $ff00
+	ld [hLCDCPointer], a
 	xor a
 	ld [hLYOverrideStart], a
 	ld a, $37
@@ -2655,7 +2655,7 @@
 BattleBGEffects_ClearLYOverrides: ; c8eca (32:4eca)
 	xor a
 BattleBGEffects_SetLYOverrides: ; c8ecb (32:4ecb)
-	ld hl, LYOverrides ; wd100
+	ld hl, LYOverrides ; wListPointer
 	ld e, $99
 .loop1
 	ld [hli], a
@@ -2670,7 +2670,7 @@
 	ret
 
 BattleBGEffect_SetLCDStatCustoms1: ; c8ede (32:4ede)
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	call BGEffect_CheckBattleTurn
 	jr nz, .player_turn
 	lb de, $00, $36
@@ -2686,7 +2686,7 @@
 	ret
 
 BattleBGEffect_SetLCDStatCustoms2: ; c8ef4 (32:4ef4)
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	call BGEffect_CheckBattleTurn
 	jr nz, .player_turn
 	lb de, $00, $36
@@ -2707,13 +2707,13 @@
 	ld [hLYOverrideEnd], a
 	call BattleBGEffects_ClearLYOverrides
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	call EndBattleBGEffect
 	ret
 
 BattleBGEffects_ResetVideoHRAM: ; c8f19 (32:4f19)
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ld a, %11100100
 	ld [rBGP], a
 	ld [wBGP], a
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -5124,7 +5124,6 @@
 	jr z, .skip_dude_pack_select
 	callba _DudeAutoInput_DownA
 .skip_dude_pack_select
-
 	call LoadBattleMenu2
 	ret c
 
--- a/battle/objects/functions.asm
+++ b/battle/objects/functions.asm
@@ -1150,8 +1150,8 @@
 	dw .four
 .zero
 	call BattleAnim_IncAnonJumptableIndex
-	ld a, $42
-	ld [hFFC6], a
+	ld a, rSCY - $ff00
+	ld [hLCDCPointer], a
 	ld a, $58
 	ld [hLYOverrideStart], a
 	ld a, $5e
@@ -1209,7 +1209,7 @@
 	cp $70
 	jr c, asm_cd6da
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ld [hLYOverrideStart], a
 	ld [hLYOverrideEnd], a
 .four
--- a/battle/sliding_intro.asm
+++ b/battle/sliding_intro.asm
@@ -5,10 +5,10 @@
 	ld [rSVBK], a
 	call .subfunction1
 	ld a, rSCX - $ff00
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	call .subfunction2
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	pop af
 	ld [rSVBK], a
 	ret
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -253,3 +253,9 @@
 	const FISHGROUP_QWILFISH
 	const FISHGROUP_REMORAID
 	const FISHGROUP_QWILFISH_NO_SWARM
+
+INIT_ENEMYOT_LIST    EQU 1
+INIT_BAG_ITEM_LIST   EQU 2
+INIT_OTHER_ITEM_LIST EQU 3
+INIT_PLAYEROT_LIST   EQU 4
+INIT_MON_LIST        EQU 5
--- a/engine/battle_start.asm
+++ b/engine/battle_start.asm
@@ -39,7 +39,7 @@
 	call DmgToCgbBGPals
 	call DelayFrame
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ld [hLYOverrideStart], a
 	ld [hLYOverrideEnd], a
 	ld [hSCY], a
@@ -302,8 +302,8 @@
 
 	call StartTrainerBattle_NextScene
 
-	ld a, $43
-	ld [hFFC6], a
+	ld a, rSCX - $ff00
+	ld [hLCDCPointer], a
 	xor a
 	ld [hLYOverrideStart], a
 	ld a, $90
--- a/engine/credits.asm
+++ b/engine/credits.asm
@@ -183,7 +183,7 @@
 	call ByteFill
 
 	ld a, rSCX - $ff00
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 
 	call GetCreditsPalette
 	call SetPalettes
@@ -211,7 +211,7 @@
 .exit_credits
 	call ClearBGPalettes
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ld [hBGMapAddress], a
 	pop af
 	ld [hVBlank], a
--- a/engine/crystal_intro.asm
+++ b/engine/crystal_intro.asm
@@ -621,7 +621,7 @@
 	call ClearTileMap
 	xor a
 	ld [hBGMapMode], a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ld a, $1
 	ld [rVBK], a
 	ld hl, IntroTilemap005
@@ -815,7 +815,7 @@
 IntroScene9: ; e4c04 (39:4c04)
 ; Set up the next scene (same bg).
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	call ClearSprites
 	hlcoord 0, 0, AttrMap
 	; first 12 rows have palette 1
@@ -889,7 +889,7 @@
 	call ClearTileMap
 	xor a
 	ld [hBGMapMode], a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ld a, $1
 	ld [rVBK], a
 	ld hl, IntroTilemap007
@@ -2093,8 +2093,8 @@
 
 	pop af
 	ld [rSVBK], a
-	ld a, $43
-	ld [hFFC6], a
+	ld a, rSCX - $ff00
+	ld [hLCDCPointer], a
 	ret
 
 Intro_PerspectiveScrollBG: ; e552f (39:552f)
--- a/engine/events_3.asm
+++ b/engine/events_3.asm
@@ -55,7 +55,7 @@
 	ld [rWY], a
 	ld [hWY], a
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ret
 ; b8064
 
@@ -126,7 +126,7 @@
 	ld [rWY], a
 	ld [hWY], a
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ret
 
 
--- a/engine/intro_menu.asm
+++ b/engine/intro_menu.asm
@@ -140,7 +140,7 @@
 	ld [wSecretID + 1], a
 
 	ld hl, PartyCount
-	call InitList
+	call .InitList
 
 	xor a
 	ld [wCurBox], a
@@ -151,20 +151,20 @@
 	ld a, BANK(sBoxCount)
 	call GetSRAMBank
 	ld hl, sBoxCount
-	call InitList
+	call .InitList
 	call CloseSRAM
 
 	ld hl, NumItems
-	call InitList
+	call .InitList
 
 	ld hl, NumKeyItems
-	call InitList
+	call .InitList
 
 	ld hl, NumBalls
-	call InitList
+	call .InitList
 
 	ld hl, PCItems
-	call InitList
+	call .InitList
 
 	xor a
 	ld [wRoamMon1Species], a
@@ -232,7 +232,7 @@
 	ret
 ; 5ca1
 
-InitList: ; 5ca1
+.InitList: ; 5ca1
 ; Loads 0 in the count and -1 in the first item or mon slot.
 	xor a
 	ld [hli], a
@@ -1041,7 +1041,7 @@
 	call ClearScreen
 	call WaitBGMap2
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ld [hSCX], a
 	ld [hSCY], a
 	ld a, $7
@@ -1172,7 +1172,7 @@
 	ld hl, wJumptableIndex
 	inc [hl]
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 
 ; Play the title screen music.
 	ld de, MUSIC_TITLE
--- a/engine/link.asm
+++ b/engine/link.asm
@@ -163,9 +163,9 @@
 	ld hl, wTimeCapsulePartyMon1Species
 	call Function2868a
 	ld a, OTPartyMonOT % $100
-	ld [wd102], a
+	ld [wUnusedD102], a
 	ld a, OTPartyMonOT / $100
-	ld [wd103], a
+	ld [wUnusedD102 + 1], a
 	ld de, MUSIC_NONE
 	call PlayMusic
 	ld a, [hLinkPlayerNumber]
@@ -404,9 +404,9 @@
 	ld bc, OTPartyDataEnd - OTPartyMons
 	call CopyBytes
 	ld a, OTPartyMonOT % $100
-	ld [wd102], a
+	ld [wUnusedD102], a
 	ld a, OTPartyMonOT / $100
-	ld [wd103], a
+	ld [wUnusedD102 + 1], a
 	ld de, MUSIC_NONE
 	call PlayMusic
 	ld a, [hLinkPlayerNumber]
@@ -1254,8 +1254,8 @@
 	bit A_BUTTON_F, a
 	jr z, .not_a_button
 	ld a, $1
-	ld [wd263], a
-	callab LoadAddrsForLinkMonStatsScreen
+	ld [wInitListType], a
+	callab InitList
 	ld hl, OTPartyMon1Species
 	callba LinkMonStatsScreen
 	jp LinkTradePartiesMenuMasterLoop
@@ -1447,8 +1447,8 @@
 	pop af
 	ld [wMenuCursorY], a
 	ld a, $4
-	ld [wd263], a
-	callab LoadAddrsForLinkMonStatsScreen
+	ld [wInitListType], a
+	callab InitList
 	callba LinkMonStatsScreen
 	call Call_LoadTempTileMapToTileMap
 	hlcoord 6, 1
--- a/engine/title.asm
+++ b/engine/title.asm
@@ -188,8 +188,8 @@
 	call ByteFill
 
 ; Let LCD Stat know we're messing around with SCX
-	ld a, rSCX - rJOYP
-	ld [hFFC6], a
+	ld a, rSCX - $ff00
+	ld [hLCDCPointer], a
 
 	pop af
 	ld [rSVBK], a
--- a/event/magnet_train.asm
+++ b/event/magnet_train.asm
@@ -61,7 +61,7 @@
 	ld [hVBlank], a
 	call ClearBGPalettes
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ld [hLYOverrideStart], a
 	ld [hLYOverrideEnd], a
 	ld [hSCX], a
@@ -251,8 +251,8 @@
 	ld bc, LYOverridesBackupEnd - LYOverridesBackup
 	ld a, [wMagnetTrainInitPosition]
 	call ByteFill
-	ld a, $43
-	ld [hFFC6], a
+	ld a, rSCX - $ff00
+	ld [hLCDCPointer], a
 	ret
 ; 8cdc3
 
--- a/home.asm
+++ b/home.asm
@@ -825,9 +825,9 @@
 
 .done
 	ld a, e
-	ld [wd102], a
+	ld [wUnusedD102], a
 	ld a, d
-	ld [wd103], a
+	ld [wUnusedD102 + 1], a
 
 	pop de
 	pop bc
@@ -1905,7 +1905,7 @@
 
 PushLYOverrides:: ; 3b0c
 
-	ld a, [hFFC6]
+	ld a, [hLCDCPointer]
 	and a
 	ret z
 
--- a/home/lcd.asm
+++ b/home/lcd.asm
@@ -3,7 +3,7 @@
 
 Function547:: ; 547
 ; Unreferenced
-	ld a, [hFFC6]
+	ld a, [hLCDCPointer]
 	cp rSCX - $ff00
 	ret nz
 	ld c, a
@@ -15,7 +15,7 @@
 
 LCD:: ; 552
 	push af
-	ld a, [hFFC6]
+	ld a, [hLCDCPointer]
 	and a
 	jr z, .done
 
@@ -26,7 +26,7 @@
 	ld b, LYOverrides >> 8
 	ld a, [bc]
 	ld b, a
-	ld a, [hFFC6]
+	ld a, [hLCDCPointer]
 	ld c, a
 	ld a, b
 	ld [$ff00+c], a
--- a/hram.asm
+++ b/hram.asm
@@ -82,7 +82,7 @@
 hMGJoypadPressed   EQU $ffc3
 hMGJoypadReleased  EQU $ffc4
 
-hFFC6              EQU $ffc6
+hLCDCPointer              EQU $ffc6
 hLYOverrideStart   EQU $ffc7
 hLYOverrideEnd     EQU $ffc8
 hMobileReceive     EQU $ffc9
--- a/main.asm
+++ b/main.asm
@@ -77,7 +77,7 @@
 
 .ReanchorBGMap:
 	xor a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ld [hBGMapMode], a
 	ld a, $90
 	ld [hWY], a
@@ -4258,10 +4258,10 @@
 .done
 	ret
 
-LoadAddrsForLinkMonStatsScreen: ; 50db9
-	ld a, [wd263]
+InitList: ; 50db9
+	ld a, [wInitListType]
 
-	cp $1
+	cp INIT_ENEMYOT_LIST
 	jr nz, .check_party_ot_name
 	ld hl, OTPartyCount
 	ld de, OTPartyMonOT
@@ -4269,7 +4269,7 @@
 	jr .done
 
 .check_party_ot_name
-	cp $4
+	cp INIT_PLAYEROT_LIST
 	jr nz, .check_mon_name
 	ld hl, PartyCount
 	ld de, PartyMonOT
@@ -4277,7 +4277,7 @@
 	jr .done
 
 .check_mon_name
-	cp $5
+	cp INIT_MON_LIST
 	jr nz, .check_item_name
 	ld hl, CurMart
 	ld de, PokemonNames
@@ -4285,7 +4285,7 @@
 	jr .done
 
 .check_item_name
-	cp $2
+	cp INIT_BAG_ITEM_LIST
 	jr nz, .check_ob_item_name
 	ld hl, NumItems
 	ld de, ItemNames
@@ -4299,18 +4299,18 @@
 .done
 	ld [wNamedObjectTypeBuffer], a ; d265
 	ld a, l
-	ld [wd100], a
+	ld [wListPointer], a
 	ld a, h
-	ld [wd101], a
+	ld [wListPointer + 1], a
 	ld a, e
-	ld [wd102], a
+	ld [wUnusedD102], a
 	ld a, d
-	ld [wd103], a
+	ld [wUnusedD102 + 1], a
 	ld bc, ItemAttributes ; ParseEnemyAction, HandleMapTimeAndJoypad, Music_LakeOfRage_Ch3, String_11a7c1 $67c1
 	ld a, c
-	ld [wd104], a
+	ld [wItemAttributesPtr], a
 	ld a, b
-	ld [wd105], a
+	ld [wItemAttributesPtr + 1], a
 	ret
 
 CalcLevel: ; 50e1b
--- a/misc/fixed_words.asm
+++ b/misc/fixed_words.asm
@@ -1199,7 +1199,7 @@
 	ret
 
 .asm_11c7e9
-	ld hl, wd100
+	ld hl, wListPointer
 	ld a, [wcd26]
 	ld e, a
 	add hl, de
@@ -1433,7 +1433,7 @@
 	add [hl]
 	ld c, a
 	ld b, $0
-	ld hl, wd100
+	ld hl, wListPointer
 	add hl, bc
 	ld a, [hl]
 	jr .asm_11c911
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -67,7 +67,7 @@
 	ld [BGMapBuffer], a
 	xor a
 	ld [hMapAnims], a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ret
 ; 100082
 
@@ -85,7 +85,7 @@
 	ld [rIE], a
 	xor a
 	ld [hMapAnims], a
-	ld [hFFC6], a
+	ld [hLCDCPointer], a
 	ld a, $01
 	ld [hMobileReceive], a
 	ld [hMobile], a
--- a/wram.asm
+++ b/wram.asm
@@ -1795,12 +1795,9 @@
 wMailboxEnd:: ds 1 ; d0fe
 	ds 2
 
-wd100:: ds 1
-wd101:: ds 1
-wd102:: ds 1
-wd103:: ds 1
-wd104:: ds 1
-wd105:: ds 1
+wListPointer:: dw ; d100
+wUnusedD102:: dw ; d102
+wItemAttributesPtr:: dw ; d104
 
 CurItem:: ds 1 ; d106
 CurItemQuantity:: ; d107
@@ -2180,7 +2177,7 @@
 wWaterEncounterRate:: ds 1 ; d25d
 wListMoves_MoveIndicesBuffer:: ds NUM_MOVES
 wPutativeTMHMMove:: ds 1
-wd263:: ds 1
+wInitListType:: ds 1
 wAISwitch:: ds 1
 wFoundMatchingIDInParty::
 wNamedObjectIndexBuffer::