shithub: pokered

Download patch

ref: 5d9d26bd5c64a5b11021bdd46e2e0786ddef888d
parent: 8431fa7756dace97413f4c35aaa44cd92cf5b6df
author: U-Daniel-PC\Daniel <corrnondacqb@yahoo.com>
date: Fri Jul 3 11:13:35 EDT 2015

No more ldh

--- a/home.asm
+++ b/home.asm
@@ -2354,7 +2354,7 @@
 	ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN
 	ld [wJoyIgnore], a
 	xor a
-	ldh [$b4], a
+	ld [hJoyHeld], a
 	call TrainerWalkUpToPlayer_Bank0
 	ld hl, W_CURMAPSCRIPT
 	inc [hl]      ; increment map script index (next script function is usually DisplayEnemyTrainerTextAndStartBattle)
--- a/home/pic.asm
+++ b/home/pic.asm
@@ -57,13 +57,13 @@
 ; note that this is an endless loop which is terminated during a call to MoveToNextBufferPosition by manipulating the stack
 UncompressSpriteDataLoop:: ; 2556 (0:2556)
 	ld hl, S_SPRITEBUFFER1
-	ld a, [W_SPRITELOADFLAGS] 
+	ld a, [W_SPRITELOADFLAGS]
 	bit 0, a
 	jr z, .useSpriteBuffer1    ; check which buffer to use
 	ld hl, S_SPRITEBUFFER2
 .useSpriteBuffer1
 	call StoreSpriteOutputPointer
-	ld a, [W_SPRITELOADFLAGS] 
+	ld a, [W_SPRITELOADFLAGS]
 	bit 1, a
 	jr z, .startDecompression  ; check if last iteration
 	call ReadNextInputBit      ; if last chunk, read 1-2 bit unpacking mode
--- a/scripts/bikeshop.asm
+++ b/scripts/bikeshop.asm
@@ -24,7 +24,7 @@
 	call GiveItem
 	jr nc, .BagFull
 	ld a, BIKE_VOUCHER
-	ldh [$db], a
+	ld [$ffdb], a
 	callba RemoveItemByID
 	ld hl, wd75f
 	set 0, [hl]
--- a/scripts/celadongamecorner.asm
+++ b/scripts/celadongamecorner.asm
@@ -138,10 +138,10 @@
 	call Has9990Coins
 	jr nc, .asm_48d14
 	xor a
-	ldh [$9f], a
-	ldh [$a1], a
+	ld [$ff9f], a
+	ld [$ffa1], a
 	ld a, $10
-	ldh [$a0], a
+	ld [$ffa0], a
 	call HasEnoughMoney
 	jr nc, .asm_48cdb
 	ld hl, CeladonGameCornerText_48d31
@@ -148,19 +148,19 @@
 	jr .asm_48d1c
 .asm_48cdb
 	xor a
-	ldh [$9f], a
-	ldh [$a1], a
+	ld [$ff9f], a
+	ld [$ffa1], a
 	ld a, $10
-	ldh [$a0], a
+	ld [$ffa0], a
 	ld hl, $ffa1
 	ld de, wPlayerMoney + 2
 	ld c, $3
 	predef SubBCDPredef
 	xor a
-	ldh [$9f], a
-	ldh [$a0], a
+	ld [$ff9f], a
+	ld [$ffa0], a
 	ld a, $50
-	ldh [$a1], a
+	ld [$ffa1], a
 	ld de, wPlayerCoins + 1
 	ld hl, $ffa1
 	ld c, $2
@@ -225,10 +225,10 @@
 	call Has9990Coins
 	jr nc, .asm_48d8e
 	xor a
-	ldh [$9f], a
-	ldh [$a0], a
+	ld [$ff9f], a
+	ld [$ffa0], a
 	ld a, $10
-	ldh [$a1], a
+	ld [$ffa1], a
 	ld de, wPlayerCoins + 1
 	ld hl, $ffa1
 	ld c, $2
@@ -307,10 +307,10 @@
 	call Has9990Coins
 	jr nc, .asm_48e18
 	xor a
-	ldh [$9f], a
-	ldh [$a0], a
+	ld [$ff9f], a
+	ld [$ffa0], a
 	ld a, $20
-	ldh [$a1], a
+	ld [$ffa1], a
 	ld de, wPlayerCoins + 1
 	ld hl, $ffa1
 	ld c, $2
@@ -360,10 +360,10 @@
 	call Has9990Coins
 	jr z, .asm_48e7a
 	xor a
-	ldh [$9f], a
-	ldh [$a0], a
+	ld [$ff9f], a
+	ld [$ffa0], a
 	ld a, $20
-	ldh [$a1], a
+	ld [$ffa1], a
 	ld de, wPlayerCoins + 1
 	ld hl, $ffa1
 	ld c, $2
@@ -410,14 +410,14 @@
 	ld hl, CeladonGameCornerText_48ed3
 	ld de, CeladonGameCornerText_48ed3
 	call SaveEndBattleTextPointers
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	ld [wSpriteIndex], a
 	call EngageMapTrainer
 	call InitBattleEnemyParameters
 	xor a
-	ldh [$b4], a
-	ldh [$b3], a
-	ldh [$b2], a
+	ld [hJoyHeld], a
+	ld [hJoyPressed], a
+	ld [hJoyReleased], a
 	ld a, $1
 	ld [W_CELADONGAMECORNERCURSCRIPT], a
 	jp TextScriptEnd
--- a/scripts/celadongym.asm
+++ b/scripts/celadongym.asm
@@ -178,7 +178,7 @@
 	ld hl, CeladonGymText_48a63
 	ld de, CeladonGymText_48a63
 	call SaveEndBattleTextPointers
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	ld [wSpriteIndex], a
 	call EngageMapTrainer
 	call InitBattleEnemyParameters
--- a/scripts/ceruleancity.asm
+++ b/scripts/ceruleancity.asm
@@ -344,7 +344,7 @@
 
 CeruleanCityText7: ; 1970c (6:570c)
 	TX_ASM
-	ldh a, [$d3]
+	ld a, [hRandomAdd]
 	cp $b4
 	jr c, .asm_e9fc9
 	ld hl, CeruleanCityText_19730
--- a/scripts/ceruleangym.asm
+++ b/scripts/ceruleangym.asm
@@ -127,7 +127,7 @@
 	ld hl, CeruleanGymText_5c7d8
 	ld de, CeruleanGymText_5c7d8
 	call SaveEndBattleTextPointers
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	ld [wSpriteIndex], a
 	call EngageMapTrainer
 	call InitBattleEnemyParameters
@@ -134,7 +134,7 @@
 	ld a, $2
 	ld [W_GYMLEADERNO], a
 	xor a
-	ldh [$b4], a
+	ld [hJoyHeld], a
 	ld a, $3
 	ld [W_CERULEANGYMCURSCRIPT], a
 .asm_5c7bb
--- a/scripts/copycatshouse2f.asm
+++ b/scripts/copycatshouse2f.asm
@@ -30,7 +30,7 @@
 	ld hl, ReceivedTM31Text
 	call PrintText
 	ld a, POKE_DOLL
-	ldh [$db], a
+	ld [$ffdb], a
 	callba RemoveItemByID
 	ld hl, wd7af
 	set 0, [hl]
--- a/scripts/fightingdojo.asm
+++ b/scripts/fightingdojo.asm
@@ -148,7 +148,7 @@
 	ld hl, FightingDojoText_5ce93
 	ld de, FightingDojoText_5ce93
 	call SaveEndBattleTextPointers
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	ld [wSpriteIndex], a
 	call EngageMapTrainer
 	call InitBattleEnemyParameters
--- a/scripts/fuchsiagym.asm
+++ b/scripts/fuchsiagym.asm
@@ -167,7 +167,7 @@
 	ld hl, KogaAfterBattleText
 	ld de, KogaAfterBattleText
 	call SaveEndBattleTextPointers
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	ld [wSpriteIndex], a
 	call EngageMapTrainer
 	call InitBattleEnemyParameters
@@ -174,7 +174,7 @@
 	ld a, $5
 	ld [W_GYMLEADERNO], a
 	xor a
-	ldh [$b4], a
+	ld [hJoyHeld], a
 	ld a, $3
 	ld [W_FUCHSIAGYMCURSCRIPT], a
 .asm_e84c6
--- a/scripts/fuchsiahouse2.asm
+++ b/scripts/fuchsiahouse2.asm
@@ -34,7 +34,7 @@
 	ld hl, WardenTeethText1
 	call PrintText
 	ld a, GOLD_TEETH
-	ldh [$db], a
+	ld [$ffdb], a
 	callba RemoveItemByID
 	ld hl, wd78e
 	set 1, [hl]
@@ -98,7 +98,7 @@
 FuchsiaHouse2Text5: ; 75163 (1d:5163)
 FuchsiaHouse2Text4: ; 75163 (1d:5163)
 	TX_ASM
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	cp $4
 	ld hl, FuchsiaHouse2Text_7517b
 	jr nz, .asm_4c9a2
--- a/scripts/mtmoon3.asm
+++ b/scripts/mtmoon3.asm
@@ -229,7 +229,7 @@
 	ld hl, MtMoon3Text_49f8a
 	ld de, MtMoon3Text_49f8a
 	call SaveEndBattleTextPointers
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	ld [wSpriteIndex], a
 	call EngageMapTrainer
 	call InitBattleEnemyParameters
--- a/scripts/mtmoonpokecenter.asm
+++ b/scripts/mtmoonpokecenter.asm
@@ -35,10 +35,10 @@
 	ld a, [wCurrentMenuItem]
 	and a
 	jp nz, .asm_4934e
-	ldh [$9f], a
-	ldh [$a1], a
+	ld [$ff9f], a
+	ld [$ffa1], a
 	ld a, $5
-	ldh [$a0], a
+	ld [$ffa0], a
 	call HasEnoughMoney
 	jr nc, .asm_faa09
 	ld hl, MtMoonPokecenterText_49366
--- a/scripts/pewtercity.asm
+++ b/scripts/pewtercity.asm
@@ -208,12 +208,12 @@
 	ld hl, PewterCityText_193fb
 	call PrintText
 	xor a
-	ldh [$b3], a
-	ldh [$b4], a
+	ld [hJoyPressed], a
+	ld [hJoyHeld], a
 	ld [wNPCMovementScriptFunctionNum], a
 	ld a, $2
 	ld [wNPCMovementScriptPointerTableNum], a
-	ldh a, [$b8]
+	ld a, [H_LOADEDROMBANK]
 	ld [wNPCMovementScriptBank], a
 	ld a, $3
 	ld [wSpriteIndex], a
@@ -273,11 +273,11 @@
 	ld hl, PewterCityText_1945d
 	call PrintText
 	xor a
-	ldh [$b4], a
+	ld [hJoyHeld], a
 	ld [wNPCMovementScriptFunctionNum], a
 	ld a, $3
 	ld [wNPCMovementScriptPointerTableNum], a
-	ldh a, [$b8]
+	ld a, [H_LOADEDROMBANK]
 	ld [wNPCMovementScriptBank], a
 	ld a, $5
 	ld [wSpriteIndex], a
--- a/scripts/pewtergym.asm
+++ b/scripts/pewtergym.asm
@@ -127,7 +127,7 @@
 	ld hl, PewterGymText_5c4bc
 	ld de, PewterGymText_5c4bc
 	call SaveEndBattleTextPointers
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	ld [wSpriteIndex], a
 	call EngageMapTrainer
 	call InitBattleEnemyParameters
@@ -134,7 +134,7 @@
 	ld a, $1
 	ld [W_GYMLEADERNO], a
 	xor a
-	ldh [$b4], a
+	ld [hJoyHeld], a
 	ld a, $3
 	ld [W_PEWTERGYMCURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
--- a/scripts/rockethideout4.asm
+++ b/scripts/rockethideout4.asm
@@ -131,12 +131,12 @@
 	ld hl, RocketHideout4Text_4557f
 	ld de, RocketHideout4Text_4557f
 	call SaveEndBattleTextPointers
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	ld [wSpriteIndex], a
 	call EngageMapTrainer
 	call InitBattleEnemyParameters
 	xor a
-	ldh [$b4], a
+	ld [hJoyHeld], a
 	ld a, $3
 	ld [W_ROCKETHIDEOUT4CURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
--- a/scripts/route2gate.asm
+++ b/scripts/route2gate.asm
@@ -11,9 +11,9 @@
 	bit 0, a
 	jr nz, .asm_5d60d
 	ld a, 10 ; pokemon needed
-	ldh [$db], a
+	ld [$ffdb], a
 	ld a, HM_05 ; oak's aide reward
-	ldh [$dc], a
+	ld [$ffdc], a
 	ld [wd11e], a
 	call GetItemName
 	ld hl, wcd6d
@@ -21,7 +21,7 @@
 	ld bc, $000d
 	call CopyData
 	predef OaksAideScript ; call oak's aide script
-	ldh a, [$db]
+	ld a, [$ffdb]
 	cp $1
 	jr nz, .asm_5d613
 	ld hl, wd7c2
--- a/scripts/saffrongym.asm
+++ b/scripts/saffrongym.asm
@@ -179,7 +179,7 @@
 	ld hl, SaffronGymText_5d167
 	ld de, SaffronGymText_5d167
 	call SaveEndBattleTextPointers
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	ld [wSpriteIndex], a
 	call EngageMapTrainer
 	call InitBattleEnemyParameters
--- a/scripts/ssanne6.asm
+++ b/scripts/ssanne6.asm
@@ -39,7 +39,7 @@
 	TX_ASM
 	ld hl, SSAnne6Text_61807
 	call PrintText
-	ldh a, [$d3]
+	ld a, [hRandomAdd]
 	bit 7, a
 	jr z, .asm_93eb1
 	ld hl, SSAnne6Text_6180c
--- a/scripts/vermiliongym.asm
+++ b/scripts/vermiliongym.asm
@@ -157,7 +157,7 @@
 	ld hl, ReceivedThunderbadgeText
 	ld de, ReceivedThunderbadgeText
 	call SaveEndBattleTextPointers
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	ld [wSpriteIndex], a
 	call EngageMapTrainer
 	call InitBattleEnemyParameters
@@ -164,7 +164,7 @@
 	ld a, $3
 	ld [W_GYMLEADERNO], a
 	xor a
-	ldh [$b4], a
+	ld [hJoyHeld], a
 	ld a, $3
 	ld [W_VERMILIONGYMCURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
--- a/scripts/viridiangym.asm
+++ b/scripts/viridiangym.asm
@@ -306,7 +306,7 @@
 	ld hl, ViridianGymText_74ad3
 	ld de, ViridianGymText_74ad3
 	call SaveEndBattleTextPointers
-	ldh a, [$8c]
+	ld a, [H_SPRITEINDEX]
 	ld [wSpriteIndex], a
 	call EngageMapTrainer
 	call InitBattleEnemyParameters