shithub: pokecrystal

Download patch

ref: e23f34125879e680e1a6ee263cb3dbb579cc5135
parent: eb9fc6676cfed0460d19ce441134dbcdfce49b0d
author: yenatch <[email protected]>
date: Fri Jun 13 18:53:20 EDT 2014

Battle type constants in the wild.

Also add constants for trap and Celebi event battles.

--- a/battle/core.asm
+++ b/battle/core.asm
@@ -58,7 +58,7 @@
 	ld a, [BattleType]
 	cp $2
 	jp z, Function3c0e2
-	cp $3
+	cp BATTLETYPE_TUTORIAL
 	jp z, Function3c0e2
 	xor a
 	ld [CurPartyMon], a
@@ -2459,7 +2459,7 @@
 	ld c, $28
 	call DelayFrames
 	ld a, [BattleType]
-	cp $1
+	cp BATTLETYPE_CANLOSE
 	jr nz, .asm_3cfe8
 	ld a, $2
 	call Predef
@@ -3717,13 +3717,13 @@
 	ld [$cfca], a
 	ld [$c689], a
 	call SetEnemyTurn
-	ld de, $0101
+	ld de, ANIM_SEND_OUT_MON
 	call Function3ee17
 	call Function3da79
 	jr nc, .asm_3d800
 	ld a, $1
 	ld [$c689], a
-	ld de, $0101
+	ld de, ANIM_SEND_OUT_MON
 	call Function3ee17
 
 .asm_3d800
@@ -3773,7 +3773,7 @@
 	ld [$c731], a
 	ld [EnemyTurnsTaken], a
 	ld hl, PlayerSubStatus5
-	res 7, [hl]
+	res SUBSTATUS_CANT_RUN, [hl]
 	ret
 ; 3d867
 
@@ -3793,7 +3793,7 @@
 	ld e, a
 	xor a
 	ld hl, PartyMon1HP
-	ld bc, $002f
+	ld bc, PartyMon2 - (PartyMon1 + 1)
 .asm_3d87e
 	or [hl]
 	inc hl
@@ -3842,13 +3842,13 @@
 	jp z, .asm_3d9a2
 	cp $6
 	jp z, .asm_3d9a2
-	cp $9
+	cp BATTLETYPE_TRAP
 	jp z, .asm_3d98d
-	cp $b
+	cp BATTLETYPE_CELEBI
 	jp z, .asm_3d98d
-	cp $7
+	cp BATTLETYPE_SHINY
 	jp z, .asm_3d98d
-	cp $c
+	cp BATTLETYPE_SUICUNE
 	jp z, .asm_3d98d
 
 	ld a, [InLinkBattle]
@@ -3860,7 +3860,7 @@
 	jp nz, .asm_3d992
 
 	ld a, [EnemySubStatus5]
-	bit 7, a
+	bit SUBSTATUS_CANT_RUN, a
 	jp nz, .asm_3d98d
 
 	ld a, [$c730]
@@ -5093,7 +5093,7 @@
 	ld a, [BattleType]
 	cp $2
 	jr z, .asm_3e156
-	cp $3
+	cp BATTLETYPE_TUTORIAL
 	jr z, .asm_3e156
 	call EmptyBattleTextBox
 	call UpdateBattleHuds
@@ -5173,7 +5173,7 @@
 	jp nz, Function3e22b
 	call Function1d6e
 	ld a, [BattleType]
-	cp $3
+	cp BATTLETYPE_TUTORIAL
 	jr z, .asm_3e1f1
 	cp $6
 	jr z, .asm_3e201
@@ -5234,7 +5234,7 @@
 	call Function3ed9f
 	call ClearSprites
 	ld a, [BattleType]
-	cp $3
+	cp BATTLETYPE_TUTORIAL
 	jr z, .asm_3e25d
 	call Function3f43d
 
@@ -9527,8 +9527,8 @@
 	ld hl, PokemonFellFromTreeText
 	cp BATTLETYPE_TREE
 	jr z, .asm_3fd0e
-	ld hl, WildPokemonAppearedText2
-	cp $b
+	ld hl, WildCelebiAppearedText
+	cp BATTLETYPE_CELEBI
 	jr z, .asm_3fd0e
 	ld hl, WildPokemonAppearedText
 
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -7083,7 +7083,7 @@
 	jr z, .asm_367b9
 	cp $9
 	jr z, .asm_367b9
-	cp $b
+	cp BATTLETYPE_CELEBI
 	jr z, .asm_367b9
 	cp BATTLETYPE_SUICUNE
 	jr z, .asm_367b9
@@ -7175,7 +7175,7 @@
 	jp z, .asm_36969
 	cp $9
 	jp z, .asm_36969
-	cp $b
+	cp BATTLETYPE_CELEBI
 	jp z, .asm_36969
 	cp BATTLETYPE_SUICUNE
 	jp z, .asm_36969
--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -48,7 +48,9 @@
 BATTLETYPE_ROAMING EQU $05
 BATTLETYPE_SHINY EQU $07
 BATTLETYPE_TREE EQU $08
+BATTLETYPE_TRAP EQU $09
 BATTLETYPE_FORCEITEM EQU $0a
+BATTLETYPE_CELEBI EQU $0b
 BATTLETYPE_SUICUNE EQU $0c
 
 ; battle variables
--- a/home.asm
+++ b/home.asm
@@ -1583,7 +1583,7 @@
 
 Function3718:: ; 3718
 	ld a, [BattleType]
-	cp $1
+	cp BATTLETYPE_CANLOSE
 	jr .asm_3724
 
 	ld hl, WalkingTile
--- a/items/item_effects.asm
+++ b/items/item_effects.asm
@@ -238,10 +238,10 @@
 	ld a, [EnemyMonCatchRate]
 	ld b, a
 	ld a, [BattleType]
-	cp $3
+	cp BATTLETYPE_TUTORIAL
 	jp z, .asm_e99c
 	ld a, [CurItem]
-	cp $1
+	cp MASTER_BALL
 	jp z, .asm_e99c
 	ld a, [CurItem]
 	ld c, a
--- a/main.asm
+++ b/main.asm
@@ -10585,7 +10585,7 @@
 	ld [$d22e], a
 	ld a, e
 	ld [CurPartyLevel], a
-	ld a, $4
+	ld a, BATTLETYPE_FISH
 	ld [BattleType], a
 	ld a, $2
 	ret
@@ -16003,7 +16003,7 @@
 	ld e, a
 	ld d, $0
 	ld a, [BattleType]
-	cp $3
+	cp BATTLETYPE_TUTORIAL
 	jr z, .asm_108b3
 	ld a, [PlayerGender]
 	bit 0, a
@@ -16127,7 +16127,7 @@
 	ld a, $24
 	call ByteFill
 	hlcoord 5, 1
-	ld bc, $0b0f
+	lb bc, 11, 15
 	call ClearBox
 	ld hl, TileMap
 	ld a, $28
@@ -16140,7 +16140,7 @@
 	call Function109bb
 	call Function109a5
 	hlcoord 0, 12
-	ld bc, $0412
+	lb bc, 4, 18
 	call TextBox
 	call EnableLCD
 	call Function1089d
@@ -36142,7 +36142,7 @@
 	call WhiteBGMap
 	call ClearTileMap
 	ld a, [BattleType]
-	cp $3
+	cp BATTLETYPE_TUTORIAL
 	jr z, .asm_27171
 	callba Function3f43d
 	jr .asm_27177
@@ -40583,7 +40583,7 @@
 	ret
 
 .asm_2a0f8
-	xor a
+	xor a ; BATTLETYPE_NORMAL
 	ld [$d22e], a
 	ld [BattleType], a
 	ld a, 1
@@ -40984,6 +40984,7 @@
 	ld [CurPartyLevel], a
 	ld a, BATTLETYPE_ROAMING
 	ld [BattleType], a
+
 	pop hl
 	scf
 	ret
@@ -42840,9 +42841,10 @@
 
 ; known jump sources: 2c8d6 (b:48d6), 2c915 (b:4915), 2c9bf (b:49bf), 2c9dc (b:49dc)
 Function2c9e2: ; 2c9e2 (b:49e2)
-	ld a, [BattleType] ; $d230
-	cp $3
+	ld a, [BattleType]
+	cp BATTLETYPE_TUTORIAL
 	jp z, Function2caca
+
 	hlcoord 5, 2
 	ld bc, $a0f
 	ld a, $7f
@@ -52591,7 +52593,7 @@
 ; 49bf3
 
 Function49bf3: ; 49bf3
-	ld a, $b
+	ld a, BATTLETYPE_CELEBI
 	ld [BattleType], a
 	ret
 ; 49bf9
@@ -58218,11 +58220,11 @@
 Function4e56a: ; 4e56a (13:656a)
 	ld hl, PlayerName ; $d47d
 	ld de, MomsName ; $d488
-	ld bc, $b
+	ld bc, NAME_LENGTH
 	call CopyBytes
 	ld hl, String_4e5da
 	ld de, PlayerName ; $d47d
-	ld bc, $b
+	ld bc, NAME_LENGTH
 	call CopyBytes
 	call Function4e5b7
 	xor a
@@ -58242,7 +58244,7 @@
 	ld [Options], a ; $cfcc
 	ld hl, MomsName ; $d488
 	ld de, PlayerName ; $d47d
-	ld bc, $b
+	ld bc, NAME_LENGTH
 	call CopyBytes
 	ret
 
@@ -63190,7 +63192,7 @@
 Function806c5: ; 806c5
 ; Caught mons.
 	ld hl, PokedexCaught
-	ld b, $20
+	ld b, EndPokedexCaught - PokedexCaught
 	call CountSetBits
 	ld a, [$d265]
 	jp Function8066c
@@ -63199,7 +63201,7 @@
 Function806d3: ; 806d3
 ; Seen mons.
 	ld hl, PokedexSeen
-	ld b, $20
+	ld b, EndPokedexSeen - PokedexSeen
 	call CountSetBits
 	ld a, [$d265]
 	jp Function8066c
@@ -63207,7 +63209,7 @@
 
 Function806e1: ; 806e1
 ; Number of owned badges.
-	ld hl, JohtoBadges ; $d857
+	ld hl, Badges ; $d857
 	ld b, 2
 	call CountSetBits
 	ld a, [$d265]
@@ -87330,7 +87332,7 @@
 	jr nc, .asm_b8214
 	call Functionb83e5
 	jr nc, .asm_b8214
-	ld a, $8
+	ld a, BATTLETYPE_TREE
 	ld [BattleType], a
 	ld a, $1
 	ld [ScriptVar], a
@@ -108250,7 +108252,7 @@
 
 Function106051: ; 106051
 	ld a, [BattleType]
-	cp $3
+	cp BATTLETYPE_TUTORIAL
 	ret z
 	ld hl, $a01b
 	jp Function10611d
@@ -108263,7 +108265,7 @@
 
 Function10605e: ; 10605e
 	ld a, [BattleType]
-	cp $3
+	cp BATTLETYPE_TUTORIAL
 	ret z
 	ld hl, $a01e
 	jp Function10611d
--- a/maps/CherrygroveCity.asm
+++ b/maps/CherrygroveCity.asm
@@ -130,7 +130,7 @@
 	winlosstext UnknownText_0x19c57f, UnknownText_0x19c5e6
 	setlasttalked $3
 	loadtrainer RIVAL1, RIVAL1_3
-	writecode $3, $1
+	writecode $3, BATTLETYPE_CANLOSE
 	startbattle
 	reloadmapmusic
 	reloadmap
@@ -142,7 +142,7 @@
 	winlosstext UnknownText_0x19c57f, UnknownText_0x19c5e6
 	setlasttalked $3
 	loadtrainer RIVAL1, RIVAL1_1
-	writecode $3, $1
+	writecode $3, BATTLETYPE_CANLOSE
 	startbattle
 	reloadmapmusic
 	reloadmap
@@ -154,7 +154,7 @@
 	winlosstext UnknownText_0x19c57f, UnknownText_0x19c5e6
 	setlasttalked $3
 	loadtrainer RIVAL1, RIVAL1_2
-	writecode $3, $1
+	writecode $3, BATTLETYPE_CANLOSE
 	startbattle
 	reloadmapmusic
 	reloadmap
--- a/maps/LakeofRage.asm
+++ b/maps/LakeofRage.asm
@@ -88,7 +88,7 @@
 	cry GYARADOS
 	loadmovesprites
 	loadpokedata GYARADOS, 30
-	writecode $3, $7
+	writecode $3, BATTLETYPE_SHINY
 	startbattle
 	if_equal $1, UnknownScript_0x7007a
 	disappear $a
--- a/maps/TeamRocketBaseB1F.asm
+++ b/maps/TeamRocketBaseB1F.asm
@@ -464,7 +464,7 @@
 	cry VOLTORB
 	special $0031
 	setlasttalked $ff
-	writecode $3, $9
+	writecode $3, BATTLETYPE_TRAP
 	loadpokedata VOLTORB, 23
 	startbattle
 	end
@@ -474,7 +474,7 @@
 	cry GEODUDE
 	special $0031
 	setlasttalked $ff
-	writecode $3, $9
+	writecode $3, BATTLETYPE_TRAP
 	loadpokedata GEODUDE, 21
 	startbattle
 	end
@@ -484,7 +484,7 @@
 	cry KOFFING
 	special $0031
 	setlasttalked $ff
-	writecode $3, $9
+	writecode $3, BATTLETYPE_TRAP
 	loadpokedata KOFFING, 21
 	startbattle
 	end
--- a/maps/TinTower1F.asm
+++ b/maps/TinTower1F.asm
@@ -122,7 +122,7 @@
 	cry SUICUNE
 	pause 20
 	loadpokedata SUICUNE, 40
-	writecode $3, $c
+	writecode $3, BATTLETYPE_SUICUNE
 	startbattle
 	reloadmapmusic
 	disappear $2
--- a/maps/TinTowerRoof.asm
+++ b/maps/TinTowerRoof.asm
@@ -36,7 +36,7 @@
 	pause 15
 	loadmovesprites
 	setevent EVENT_FOUGHT_HO_OH
-	writecode $3, $a
+	writecode $3, BATTLETYPE_FORCEITEM
 	loadpokedata HO_OH, 60
 	startbattle
 	disappear $2
--- a/maps/VermilionCity.asm
+++ b/maps/VermilionCity.asm
@@ -56,7 +56,7 @@
 	pause 15
 	cry SNORLAX
 	loadmovesprites
-	writecode $3, $a
+	writecode $3, BATTLETYPE_FORCEITEM
 	loadpokedata SNORLAX, 50
 	startbattle
 	disappear $6
--- a/maps/WhirlIslandLugiaChamber.asm
+++ b/maps/WhirlIslandLugiaChamber.asm
@@ -36,7 +36,7 @@
 	pause 15
 	loadmovesprites
 	setevent EVENT_FOUGHT_LUGIA
-	writecode $3, $a
+	writecode $3, BATTLETYPE_FORCEITEM
 	loadpokedata LUGIA, 60
 	startbattle
 	disappear $2
--- a/predef/cgb.asm
+++ b/predef/cgb.asm
@@ -840,11 +840,13 @@
 
 Function93d3: ; 93d3
 	ld a, [BattleType]
-	cp $3
+	cp BATTLETYPE_TUTORIAL
 	jr z, .asm_93e6
+
 	ld a, [PlayerGender]
 	bit 0, a
 	jr z, .asm_93e6
+
 	ld hl, Palettes_9469
 	jr .asm_93e9
 
--- a/text/battle.asm
+++ b/text/battle.asm
@@ -30,7 +30,7 @@
 	prompt
 ; 0x80793
 
-WildPokemonAppearedText2: ; 0x80793
+WildCelebiAppearedText: ; 0x80793
 	text "Wild @"
 	text_from_ram $c616
 	db $0
--- a/wram.asm
+++ b/wram.asm
@@ -1375,9 +1375,9 @@
 	
 Badges::
 JohtoBadges:: ; d857
-	ds 1
+	flag_array 8
 KantoBadges:: ; d858
-	ds 1
+	flag_array 8
 	
 SECTION "Items",WRAMX[$d859],BANK[1]
 TMsHMs:: ; d859