shithub: pokecrystal

Download patch

ref: 25a3960646548c40af70f9f59bed544f4ce8d472
parent: 05d49f7d752b03cbccb2fdcca2781a8a5de85425
author: Remy Oukaour <[email protected]>
date: Sat Dec 16 14:00:50 EST 2017

Move some more main.asm routines into individual files

--- a/Makefile
+++ b/Makefile
@@ -17,19 +17,20 @@
 
 
 crystal_obj := \
-wram.o \
-main.o \
-lib/mobile/main.o \
-home.o \
 audio.o \
+home.o \
+main.o \
 maps.o \
-engine/events.o \
-engine/credits.o \
+wram.o \
+data/pokemon/dex_entries.o \
 data/pokemon/egg_moves.o \
 data/pokemon/evos_attacks.o \
-data/pokemon/dex_entries.o \
-text/common_text.o \
-gfx/pics.o
+engine/credits.o \
+engine/events.o \
+gfx/pics.o \
+gfx/sprites.o \
+lib/mobile/main.o \
+text/common_text.o
 
 crystal11_obj := $(crystal_obj:.o=11.o)
 
--- /dev/null
+++ b/data/text_buffers.asm
@@ -1,0 +1,9 @@
+StringBufferPointers:: ; 24000
+; entries correspond to arguments for text_buffer (TX_STRINGBUFFER)
+	dw StringBuffer3 ; 0
+	dw StringBuffer4 ; 1
+	dw StringBuffer5 ; 2
+	dw StringBuffer2 ; 3
+	dw StringBuffer1 ; 4
+	dw EnemyMonNick  ; 5
+	dw BattleMonNick ; 6
--- /dev/null
+++ b/engine/check_battle_scene.asm
@@ -1,0 +1,47 @@
+CheckBattleScene: ; 4ea44
+; Return carry if battle scene is turned off.
+
+	ld a, 0
+	ld hl, wLinkMode
+	call GetFarWRAMByte
+	cp LINK_MOBILE
+	jr z, .mobile
+
+	ld a, [Options]
+	bit BATTLE_SCENE, a
+	jr nz, .off
+
+	and a
+	ret
+
+.mobile
+	ld a, [wcd2f]
+	and a
+	jr nz, .from_wram
+
+	ld a, $4
+	call GetSRAMBank
+	ld a, [$a60c]
+	ld c, a
+	call CloseSRAM
+
+	ld a, c
+	bit 0, c
+	jr z, .off
+
+	and a
+	ret
+
+.from_wram
+	ld a, $5
+	ld hl, w5_dc00
+	call GetFarWRAMByte
+	bit 0, a
+	jr z, .off
+
+	and a
+	ret
+
+.off
+	scf
+	ret
--- a/engine/collision_stdscripts.asm
+++ /dev/null
@@ -1,29 +1,0 @@
-CheckFacingTileForStd:: ; 1365b
-; Checks to see if the tile you're facing has a std script associated with it.  If so, executes the script and returns carry.
-	ld a, c
-	ld de, 3
-	ld hl, TileCollisionStdScripts
-	call IsInArray
-	jr nc, .notintable
-
-	ld a, jumpstd_command
-	ld [wJumpStdScriptBuffer], a
-	inc hl
-	ld a, [hli]
-	ld [wJumpStdScriptBuffer + 1], a
-	ld a, [hli]
-	ld [wJumpStdScriptBuffer + 2], a
-	ld a, BANK(Script_JumpStdFromRAM)
-	ld hl, Script_JumpStdFromRAM
-	call CallScript
-	scf
-	ret
-
-.notintable
-	xor a
-	ret
-
-INCLUDE "data/collision_stdscripts.asm"
-
-Script_JumpStdFromRAM: ; 0x1369a
-	jump wJumpStdScriptBuffer
--- /dev/null
+++ b/engine/get_breedmon_growth.asm
@@ -1,0 +1,27 @@
+GetBreedMon1LevelGrowth: ; e698
+	ld hl, wBreedMon1Stats
+	ld de, TempMon
+	ld bc, BOXMON_STRUCT_LENGTH
+	call CopyBytes
+	callab CalcLevel
+	ld a, [wBreedMon1Level]
+	ld b, a
+	ld a, d
+	ld e, a
+	sub b
+	ld d, a
+	ret
+
+GetBreedMon2LevelGrowth: ; e6b3
+	ld hl, wBreedMon2Stats
+	ld de, TempMon
+	ld bc, BOXMON_STRUCT_LENGTH
+	call CopyBytes
+	callab CalcLevel
+	ld a, [wBreedMon2Level]
+	ld b, a
+	ld a, d
+	ld e, a
+	sub b
+	ld d, a
+	ret
--- /dev/null
+++ b/engine/knows_move.asm
@@ -1,0 +1,25 @@
+KnowsMove: ; f9ea
+	ld a, MON_MOVES
+	call GetPartyParamLocation
+	ld a, [wPutativeTMHMMove]
+	ld b, a
+	ld c, NUM_MOVES
+.loop
+	ld a, [hli]
+	cp b
+	jr z, .knows_move
+	dec c
+	jr nz, .loop
+	and a
+	ret
+
+.knows_move
+	ld hl, .Text_knows
+	call PrintText
+	scf
+	ret
+
+.Text_knows: ; 0xfa06
+	; knows @ .
+	text_jump UnknownText_0x1c5ea8
+	db "@"
--- a/engine/pack.asm
+++ b/engine/pack.asm
@@ -1315,10 +1315,10 @@
 ; 108cc
 
 PackGFXPointers: ; 108cc
-	dw PackGFX + $f0 * 1
-	dw PackGFX + $f0 * 3
-	dw PackGFX + $f0 * 0
-	dw PackGFX + $f0 * 2
+	dw PackGFX + (15 tiles) * 1
+	dw PackGFX + (15 tiles) * 3
+	dw PackGFX + (15 tiles) * 0
+	dw PackGFX + (15 tiles) * 2
 ; 108d4
 
 Pack_InterpretJoypad: ; 108d4 (4:48d4)
--- /dev/null
+++ b/engine/player_gfx_2.asm
@@ -1,0 +1,5 @@
+ChrisBackpic: ; 2ba1a
+INCBIN "gfx/player/chris_back.2bpp.lz"
+
+DudeBackpic: ; 2bbaa
+INCBIN "gfx/battle/dude.2bpp.lz"
--- /dev/null
+++ b/engine/trademon_frontpic.asm
@@ -1,0 +1,38 @@
+GetTrademonFrontpic: ; 4d7fd
+	ld a, [wOTTrademonSpecies]
+	ld hl, wOTTrademonDVs
+	ld de, VTiles2
+	push de
+	push af
+	predef GetUnownLetter
+	pop af
+	ld [CurPartySpecies], a
+	ld [CurSpecies], a
+	call GetBaseData
+	pop de
+	predef FrontpicPredef
+	ret
+
+AnimateTrademonFrontpic: ; 4d81e
+	ld a, [wOTTrademonSpecies]
+	call IsAPokemon
+	ret c
+	callba ShowOTTrademonStats
+	ld a, [wOTTrademonSpecies]
+	ld [CurPartySpecies], a
+	ld a, [wOTTrademonDVs]
+	ld [TempMonDVs], a
+	ld a, [wOTTrademonDVs + 1]
+	ld [TempMonDVs + 1], a
+	ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS
+	call GetSGBLayout
+	ld a, %11100100 ; 3,2,1,0
+	call DmgToCgbBGPals
+	callba TradeAnim_ShowGetmonFrontpic
+	ld a, [wOTTrademonSpecies]
+	ld [CurPartySpecies], a
+	hlcoord 7, 2
+	ld d, $0
+	ld e, ANIM_MON_TRADE
+	predef AnimateFrontpic
+	ret
--- a/event/hidden_items.asm
+++ /dev/null
@@ -1,51 +1,0 @@
-RepelWoreOffScript:: ; 0x13619
-	opentext
-	writetext .text
-	waitbutton
-	closetext
-	end
-
-.text ; 0x13620
-	; REPEL's effect wore off.
-	text_jump UnknownText_0x1bd308
-	db "@"
-
-HiddenItemScript:: ; 0x13625
-	opentext
-	copybytetovar EngineBuffer3
-	itemtotext 0, 0
-	writetext .found_text
-	giveitem ITEM_FROM_MEM
-	iffalse .bag_full
-	callasm SetMemEvent
-	specialsound
-	itemnotify
-	jump .finish
-
-.bag_full ; 0x1363e
-	buttonsound
-	writetext .no_room_text
-	waitbutton
-
-.finish ; 13643
-	closetext
-	end
-
-.found_text ; 0x13645
-	; found @ !
-	text_jump UnknownText_0x1bd321
-	db "@"
-
-.no_room_text ; 0x1364a
-	; But   has no space left…
-	text_jump UnknownText_0x1bd331
-	db "@"
-
-SetMemEvent: ; 1364f
-	ld hl, EngineBuffer1
-	ld a, [hli]
-	ld d, [hl]
-	ld e, a
-	ld b, SET_FLAG
-	call EventFlagAction
-	ret
--- a/event/itemball.asm
+++ /dev/null
@@ -1,54 +1,0 @@
-FindItemInBallScript:: ; 0x122ce
-	callasm .TryReceiveItem
-	iffalse .no_room
-	disappear LAST_TALKED
-	opentext
-	writetext .text_found
-	playsound SFX_ITEM
-	pause 60
-	itemnotify
-	closetext
-	end
-; 0x122e3
-
-.no_room ; 0x122e3
-	opentext
-	writetext .text_found
-	waitbutton
-	writetext .text_bag_full
-	waitbutton
-	closetext
-	end
-; 0x122ee
-
-.text_found ; 0x122ee
-	; found @ !
-	text_jump UnknownText_0x1c0a1c
-	db "@"
-; 0x122f3
-
-.text_bag_full ; 0x122f3
-	; But   can't carry any more items.
-	text_jump UnknownText_0x1c0a2c
-	db "@"
-; 0x122f8
-
-.TryReceiveItem: ; 122f8
-	xor a
-	ld [ScriptVar], a
-	ld a, [EngineBuffer1]
-	ld [wNamedObjectIndexBuffer], a
-	call GetItemName
-	ld hl, StringBuffer3
-	call CopyName2
-	ld a, [EngineBuffer1]
-	ld [CurItem], a
-	ld a, [CurFruit]
-	ld [wItemQuantityChangeBuffer], a
-	ld hl, NumItems
-	call ReceiveItem
-	ret nc
-	ld a, $1
-	ld [ScriptVar], a
-	ret
-; 12324
--- /dev/null
+++ b/event/misc_scripts.asm
@@ -1,0 +1,62 @@
+Script_AbortBugContest: ; 0x122c1
+	checkflag ENGINE_BUG_CONTEST_TIMER
+	iffalse .finish
+	setflag ENGINE_DAILY_BUG_CONTEST
+	special ContestReturnMons
+.finish
+	end
+
+FindItemInBallScript:: ; 0x122ce
+	callasm .TryReceiveItem
+	iffalse .no_room
+	disappear LAST_TALKED
+	opentext
+	writetext .text_found
+	playsound SFX_ITEM
+	pause 60
+	itemnotify
+	closetext
+	end
+; 0x122e3
+
+.no_room ; 0x122e3
+	opentext
+	writetext .text_found
+	waitbutton
+	writetext .text_bag_full
+	waitbutton
+	closetext
+	end
+; 0x122ee
+
+.text_found ; 0x122ee
+	; found @ !
+	text_jump UnknownText_0x1c0a1c
+	db "@"
+; 0x122f3
+
+.text_bag_full ; 0x122f3
+	; But   can't carry any more items.
+	text_jump UnknownText_0x1c0a2c
+	db "@"
+; 0x122f8
+
+.TryReceiveItem: ; 122f8
+	xor a
+	ld [ScriptVar], a
+	ld a, [EngineBuffer1]
+	ld [wNamedObjectIndexBuffer], a
+	call GetItemName
+	ld hl, StringBuffer3
+	call CopyName2
+	ld a, [EngineBuffer1]
+	ld [CurItem], a
+	ld a, [CurFruit]
+	ld [wItemQuantityChangeBuffer], a
+	ld hl, NumItems
+	call ReceiveItem
+	ret nc
+	ld a, $1
+	ld [ScriptVar], a
+	ret
+; 12324
--- /dev/null
+++ b/event/misc_scripts_2.asm
@@ -1,0 +1,51 @@
+RepelWoreOffScript:: ; 0x13619
+	opentext
+	writetext .text
+	waitbutton
+	closetext
+	end
+
+.text ; 0x13620
+	; REPEL's effect wore off.
+	text_jump UnknownText_0x1bd308
+	db "@"
+
+HiddenItemScript:: ; 0x13625
+	opentext
+	copybytetovar EngineBuffer3
+	itemtotext 0, 0
+	writetext .found_text
+	giveitem ITEM_FROM_MEM
+	iffalse .bag_full
+	callasm SetMemEvent
+	specialsound
+	itemnotify
+	jump .finish
+
+.bag_full ; 0x1363e
+	buttonsound
+	writetext .no_room_text
+	waitbutton
+
+.finish ; 13643
+	closetext
+	end
+
+.found_text ; 0x13645
+	; found @ !
+	text_jump UnknownText_0x1bd321
+	db "@"
+
+.no_room_text ; 0x1364a
+	; But   has no space left…
+	text_jump UnknownText_0x1bd331
+	db "@"
+
+SetMemEvent: ; 1364f
+	ld hl, EngineBuffer1
+	ld a, [hli]
+	ld d, [hl]
+	ld e, a
+	ld b, SET_FLAG
+	call EventFlagAction
+	ret
--- /dev/null
+++ b/event/std_collision.asm
@@ -1,0 +1,29 @@
+CheckFacingTileForStd:: ; 1365b
+; Checks to see if the tile you're facing has a std script associated with it.  If so, executes the script and returns carry.
+	ld a, c
+	ld de, 3
+	ld hl, TileCollisionStdScripts
+	call IsInArray
+	jr nc, .notintable
+
+	ld a, jumpstd_command
+	ld [wJumpStdScriptBuffer], a
+	inc hl
+	ld a, [hli]
+	ld [wJumpStdScriptBuffer + 1], a
+	ld a, [hli]
+	ld [wJumpStdScriptBuffer + 2], a
+	ld a, BANK(Script_JumpStdFromRAM)
+	ld hl, Script_JumpStdFromRAM
+	call CallScript
+	scf
+	ret
+
+.notintable
+	xor a
+	ret
+
+INCLUDE "data/collision_stdscripts.asm"
+
+Script_JumpStdFromRAM: ; 0x1369a
+	jump wJumpStdScriptBuffer
--- a/gfx/sprites.asm
+++ b/gfx/sprites.asm
@@ -1,108 +1,108 @@
 SECTION "Sprites 1", ROMX
 
-ChrisSpriteGFX:               INCBIN "gfx/sprites/chris.2bpp" ; c0000
-ChrisBikeSpriteGFX:           INCBIN "gfx/sprites/chris_bike.2bpp" ; c0180
-GameboyKidSpriteGFX:          INCBIN "gfx/sprites/gameboy_kid.2bpp" ; c0300
-SilverSpriteGFX:              INCBIN "gfx/sprites/silver.2bpp" ; c03c0
-OakSpriteGFX:                 INCBIN "gfx/sprites/oak.2bpp" ; c0540
-RedSpriteGFX:                 INCBIN "gfx/sprites/red.2bpp" ; c06c0
-BlueSpriteGFX:                INCBIN "gfx/sprites/blue.2bpp" ; c0840
-BillSpriteGFX:                INCBIN "gfx/sprites/bill.2bpp" ; c09c0
-ElderSpriteGFX:               INCBIN "gfx/sprites/elder.2bpp" ; c0b40
-JanineSpriteGFX:              INCBIN "gfx/sprites/janine.2bpp" ; c0cc0
-KurtSpriteGFX:                INCBIN "gfx/sprites/kurt.2bpp" ; c0e40
-MomSpriteGFX:                 INCBIN "gfx/sprites/mom.2bpp" ; c0fc0
-BlaineSpriteGFX:              INCBIN "gfx/sprites/blaine.2bpp" ; c1140
-RedsMomSpriteGFX:             INCBIN "gfx/sprites/reds_mom.2bpp" ; c12c0
-DaisySpriteGFX:               INCBIN "gfx/sprites/daisy.2bpp" ; c1440
-ElmSpriteGFX:                 INCBIN "gfx/sprites/elm.2bpp" ; c15c0
-WillSpriteGFX:                INCBIN "gfx/sprites/will.2bpp" ; c1740
-FalknerSpriteGFX:             INCBIN "gfx/sprites/falkner.2bpp" ; c1800
-WhitneySpriteGFX:             INCBIN "gfx/sprites/whitney.2bpp" ; c1980
-BugsySpriteGFX:               INCBIN "gfx/sprites/bugsy.2bpp" ; c1b00
-MortySpriteGFX:               INCBIN "gfx/sprites/morty.2bpp" ; c1c80
-ChuckSpriteGFX:               INCBIN "gfx/sprites/chuck.2bpp" ; c1e00
-JasmineSpriteGFX:             INCBIN "gfx/sprites/jasmine.2bpp" ; c1f80
-PryceSpriteGFX:               INCBIN "gfx/sprites/pryce.2bpp" ; c2100
-ClairSpriteGFX:               INCBIN "gfx/sprites/clair.2bpp" ; c2280
-BrockSpriteGFX:               INCBIN "gfx/sprites/brock.2bpp" ; c2400
-KarenSpriteGFX:               INCBIN "gfx/sprites/karen.2bpp" ; c2580
-BrunoSpriteGFX:               INCBIN "gfx/sprites/bruno.2bpp" ; c2640
-MistySpriteGFX:               INCBIN "gfx/sprites/misty.2bpp" ; c27c0
-LanceSpriteGFX:               INCBIN "gfx/sprites/lance.2bpp" ; c2940
-SurgeSpriteGFX:               INCBIN "gfx/sprites/surge.2bpp" ; c2ac0
-ErikaSpriteGFX:               INCBIN "gfx/sprites/erika.2bpp" ; c2c40
-KogaSpriteGFX:                INCBIN "gfx/sprites/koga.2bpp" ; c2dc0
-SabrinaSpriteGFX:             INCBIN "gfx/sprites/sabrina.2bpp" ; c2f40
-CooltrainerMSpriteGFX:        INCBIN "gfx/sprites/cooltrainer_m.2bpp" ; c30c0
-CooltrainerFSpriteGFX:        INCBIN "gfx/sprites/cooltrainer_f.2bpp" ; c3240
-BugCatcherSpriteGFX:          INCBIN "gfx/sprites/bug_catcher.2bpp" ; c33c0
-TwinSpriteGFX:                INCBIN "gfx/sprites/twin.2bpp" ; c3540
-YoungsterSpriteGFX:           INCBIN "gfx/sprites/youngster.2bpp" ; c36c0
-LassSpriteGFX:                INCBIN "gfx/sprites/lass.2bpp" ; c3840
-TeacherSpriteGFX:             INCBIN "gfx/sprites/teacher.2bpp" ; c39c0
-BuenaSpriteGFX:               INCBIN "gfx/sprites/buena.2bpp" ; c3b40
-SuperNerdSpriteGFX:           INCBIN "gfx/sprites/super_nerd.2bpp" ; c3cc0
-RockerSpriteGFX:              INCBIN "gfx/sprites/rocker.2bpp" ; c3e40
+ChrisSpriteGFX::               INCBIN "gfx/sprites/chris.2bpp" ; c0000
+ChrisBikeSpriteGFX::           INCBIN "gfx/sprites/chris_bike.2bpp" ; c0180
+GameboyKidSpriteGFX::          INCBIN "gfx/sprites/gameboy_kid.2bpp" ; c0300
+SilverSpriteGFX::              INCBIN "gfx/sprites/silver.2bpp" ; c03c0
+OakSpriteGFX::                 INCBIN "gfx/sprites/oak.2bpp" ; c0540
+RedSpriteGFX::                 INCBIN "gfx/sprites/red.2bpp" ; c06c0
+BlueSpriteGFX::                INCBIN "gfx/sprites/blue.2bpp" ; c0840
+BillSpriteGFX::                INCBIN "gfx/sprites/bill.2bpp" ; c09c0
+ElderSpriteGFX::               INCBIN "gfx/sprites/elder.2bpp" ; c0b40
+JanineSpriteGFX::              INCBIN "gfx/sprites/janine.2bpp" ; c0cc0
+KurtSpriteGFX::                INCBIN "gfx/sprites/kurt.2bpp" ; c0e40
+MomSpriteGFX::                 INCBIN "gfx/sprites/mom.2bpp" ; c0fc0
+BlaineSpriteGFX::              INCBIN "gfx/sprites/blaine.2bpp" ; c1140
+RedsMomSpriteGFX::             INCBIN "gfx/sprites/reds_mom.2bpp" ; c12c0
+DaisySpriteGFX::               INCBIN "gfx/sprites/daisy.2bpp" ; c1440
+ElmSpriteGFX::                 INCBIN "gfx/sprites/elm.2bpp" ; c15c0
+WillSpriteGFX::                INCBIN "gfx/sprites/will.2bpp" ; c1740
+FalknerSpriteGFX::             INCBIN "gfx/sprites/falkner.2bpp" ; c1800
+WhitneySpriteGFX::             INCBIN "gfx/sprites/whitney.2bpp" ; c1980
+BugsySpriteGFX::               INCBIN "gfx/sprites/bugsy.2bpp" ; c1b00
+MortySpriteGFX::               INCBIN "gfx/sprites/morty.2bpp" ; c1c80
+ChuckSpriteGFX::               INCBIN "gfx/sprites/chuck.2bpp" ; c1e00
+JasmineSpriteGFX::             INCBIN "gfx/sprites/jasmine.2bpp" ; c1f80
+PryceSpriteGFX::               INCBIN "gfx/sprites/pryce.2bpp" ; c2100
+ClairSpriteGFX::               INCBIN "gfx/sprites/clair.2bpp" ; c2280
+BrockSpriteGFX::               INCBIN "gfx/sprites/brock.2bpp" ; c2400
+KarenSpriteGFX::               INCBIN "gfx/sprites/karen.2bpp" ; c2580
+BrunoSpriteGFX::               INCBIN "gfx/sprites/bruno.2bpp" ; c2640
+MistySpriteGFX::               INCBIN "gfx/sprites/misty.2bpp" ; c27c0
+LanceSpriteGFX::               INCBIN "gfx/sprites/lance.2bpp" ; c2940
+SurgeSpriteGFX::               INCBIN "gfx/sprites/surge.2bpp" ; c2ac0
+ErikaSpriteGFX::               INCBIN "gfx/sprites/erika.2bpp" ; c2c40
+KogaSpriteGFX::                INCBIN "gfx/sprites/koga.2bpp" ; c2dc0
+SabrinaSpriteGFX::             INCBIN "gfx/sprites/sabrina.2bpp" ; c2f40
+CooltrainerMSpriteGFX::        INCBIN "gfx/sprites/cooltrainer_m.2bpp" ; c30c0
+CooltrainerFSpriteGFX::        INCBIN "gfx/sprites/cooltrainer_f.2bpp" ; c3240
+BugCatcherSpriteGFX::          INCBIN "gfx/sprites/bug_catcher.2bpp" ; c33c0
+TwinSpriteGFX::                INCBIN "gfx/sprites/twin.2bpp" ; c3540
+YoungsterSpriteGFX::           INCBIN "gfx/sprites/youngster.2bpp" ; c36c0
+LassSpriteGFX::                INCBIN "gfx/sprites/lass.2bpp" ; c3840
+TeacherSpriteGFX::             INCBIN "gfx/sprites/teacher.2bpp" ; c39c0
+BuenaSpriteGFX::               INCBIN "gfx/sprites/buena.2bpp" ; c3b40
+SuperNerdSpriteGFX::           INCBIN "gfx/sprites/super_nerd.2bpp" ; c3cc0
+RockerSpriteGFX::              INCBIN "gfx/sprites/rocker.2bpp" ; c3e40
 
 
 SECTION "Sprites 2", ROMX
 
-PokefanMSpriteGFX:            INCBIN "gfx/sprites/pokefan_m.2bpp" ; c4000
-PokefanFSpriteGFX:            INCBIN "gfx/sprites/pokefan_f.2bpp" ; c4180
-GrampsSpriteGFX:              INCBIN "gfx/sprites/gramps.2bpp" ; c4300
-GrannySpriteGFX:              INCBIN "gfx/sprites/granny.2bpp" ; c4480
-SwimmerGuySpriteGFX:          INCBIN "gfx/sprites/swimmer_guy.2bpp" ; c4600
-SwimmerGirlSpriteGFX:         INCBIN "gfx/sprites/swimmer_girl.2bpp" ; c4780
-BigSnorlaxSpriteGFX:          INCBIN "gfx/sprites/big_snorlax.2bpp" ; c4900
-SurfingPikachuSpriteGFX:      INCBIN "gfx/sprites/surfing_pikachu.2bpp" ; c4980
-RocketSpriteGFX:              INCBIN "gfx/sprites/rocket.2bpp" ; c4b00
-RocketGirlSpriteGFX:          INCBIN "gfx/sprites/rocket_girl.2bpp" ; c4c80
-NurseSpriteGFX:               INCBIN "gfx/sprites/nurse.2bpp" ; c4e00
-LinkReceptionistSpriteGFX:    INCBIN "gfx/sprites/link_receptionist.2bpp" ; c4ec0
-ClerkSpriteGFX:               INCBIN "gfx/sprites/clerk.2bpp" ; c5040
-FisherSpriteGFX:              INCBIN "gfx/sprites/fisher.2bpp" ; c51c0
-FishingGuruSpriteGFX:         INCBIN "gfx/sprites/fishing_guru.2bpp" ; c5340
-ScientistSpriteGFX:           INCBIN "gfx/sprites/scientist.2bpp" ; c54c0
-KimonoGirlSpriteGFX:          INCBIN "gfx/sprites/kimono_girl.2bpp" ; c5640
-SageSpriteGFX:                INCBIN "gfx/sprites/sage.2bpp" ; c57c0
-UnusedGuySpriteGFX:           INCBIN "gfx/sprites/unused_guy.2bpp" ; c5940
-GentlemanSpriteGFX:           INCBIN "gfx/sprites/gentleman.2bpp" ; c5ac0
-BlackBeltSpriteGFX:           INCBIN "gfx/sprites/black_belt.2bpp" ; c5c40
-ReceptionistSpriteGFX:        INCBIN "gfx/sprites/receptionist.2bpp" ; c5dc0
-OfficerSpriteGFX:             INCBIN "gfx/sprites/officer.2bpp" ; c5f40
-CalSpriteGFX:                 INCBIN "gfx/sprites/cal.2bpp" ; c60c0
-SlowpokeSpriteGFX:            INCBIN "gfx/sprites/slowpoke.2bpp" ; c6240
-CaptainSpriteGFX:             INCBIN "gfx/sprites/captain.2bpp" ; c6280
-BigLaprasSpriteGFX:           INCBIN "gfx/sprites/big_lapras.2bpp" ; c6400
-GymGuySpriteGFX:              INCBIN "gfx/sprites/gym_guy.2bpp" ; c6480
-SailorSpriteGFX:              INCBIN "gfx/sprites/sailor.2bpp" ; c6600
-BikerSpriteGFX:               INCBIN "gfx/sprites/biker.2bpp" ; c6780
-PharmacistSpriteGFX:          INCBIN "gfx/sprites/pharmacist.2bpp" ; c6900
-MonsterSpriteGFX:             INCBIN "gfx/sprites/monster.2bpp" ; c6a80
-FairySpriteGFX:               INCBIN "gfx/sprites/fairy.2bpp" ; c6c00
-BirdSpriteGFX:                INCBIN "gfx/sprites/bird.2bpp" ; c6d80
-DragonSpriteGFX:              INCBIN "gfx/sprites/dragon.2bpp" ; c6f00
-BigOnixSpriteGFX:             INCBIN "gfx/sprites/big_onix.2bpp" ; c7080
-N64SpriteGFX:                 INCBIN "gfx/sprites/n64.2bpp" ; c7140
-SudowoodoSpriteGFX:           INCBIN "gfx/sprites/sudowoodo.2bpp" ; c7180
-SurfSpriteGFX:                INCBIN "gfx/sprites/surf.2bpp" ; c7200
-PokeBallSpriteGFX:            INCBIN "gfx/sprites/poke_ball.2bpp" ; c7380
-PokedexSpriteGFX:             INCBIN "gfx/sprites/pokedex.2bpp" ; c7500
-PaperSpriteGFX:               INCBIN "gfx/sprites/paper.2bpp" ; c7680
-VirtualBoySpriteGFX:          INCBIN "gfx/sprites/virtual_boy.2bpp" ; c7800
-OldLinkReceptionistSpriteGFX: INCBIN "gfx/sprites/old_link_receptionist.2bpp" ; c7840
-RockSpriteGFX:                INCBIN "gfx/sprites/rock.2bpp" ; c7880
-BoulderSpriteGFX:             INCBIN "gfx/sprites/boulder.2bpp" ; c78c0
-SnesSpriteGFX:                INCBIN "gfx/sprites/snes.2bpp" ; c7900
-FamicomSpriteGFX:             INCBIN "gfx/sprites/famicom.2bpp" ; c7940
-FruitTreeSpriteGFX:           INCBIN "gfx/sprites/fruit_tree.2bpp" ; c7980
-GoldTrophySpriteGFX:          INCBIN "gfx/sprites/gold_trophy.2bpp" ; c79c0
-SilverTrophySpriteGFX:        INCBIN "gfx/sprites/silver_trophy.2bpp" ; c7a00
-KrisSpriteGFX:                INCBIN "gfx/sprites/kris.2bpp" ; c7a40
-KrisBikeSpriteGFX:            INCBIN "gfx/sprites/kris_bike.2bpp" ; c7bc0
-KurtOutsideSpriteGFX:         INCBIN "gfx/sprites/kurt_outside.2bpp" ; c7d40
-SuicuneSpriteGFX:             INCBIN "gfx/sprites/suicune.2bpp" ; c7e00
-EnteiSpriteGFX:               INCBIN "gfx/sprites/entei.2bpp" ; c7e40
-RaikouSpriteGFX:              INCBIN "gfx/sprites/raikou.2bpp" ; c7e80
-StandingYoungsterSpriteGFX:   INCBIN "gfx/sprites/standing_youngster.2bpp" ; c7ec0
+PokefanMSpriteGFX::            INCBIN "gfx/sprites/pokefan_m.2bpp" ; c4000
+PokefanFSpriteGFX::            INCBIN "gfx/sprites/pokefan_f.2bpp" ; c4180
+GrampsSpriteGFX::              INCBIN "gfx/sprites/gramps.2bpp" ; c4300
+GrannySpriteGFX::              INCBIN "gfx/sprites/granny.2bpp" ; c4480
+SwimmerGuySpriteGFX::          INCBIN "gfx/sprites/swimmer_guy.2bpp" ; c4600
+SwimmerGirlSpriteGFX::         INCBIN "gfx/sprites/swimmer_girl.2bpp" ; c4780
+BigSnorlaxSpriteGFX::          INCBIN "gfx/sprites/big_snorlax.2bpp" ; c4900
+SurfingPikachuSpriteGFX::      INCBIN "gfx/sprites/surfing_pikachu.2bpp" ; c4980
+RocketSpriteGFX::              INCBIN "gfx/sprites/rocket.2bpp" ; c4b00
+RocketGirlSpriteGFX::          INCBIN "gfx/sprites/rocket_girl.2bpp" ; c4c80
+NurseSpriteGFX::               INCBIN "gfx/sprites/nurse.2bpp" ; c4e00
+LinkReceptionistSpriteGFX::    INCBIN "gfx/sprites/link_receptionist.2bpp" ; c4ec0
+ClerkSpriteGFX::               INCBIN "gfx/sprites/clerk.2bpp" ; c5040
+FisherSpriteGFX::              INCBIN "gfx/sprites/fisher.2bpp" ; c51c0
+FishingGuruSpriteGFX::         INCBIN "gfx/sprites/fishing_guru.2bpp" ; c5340
+ScientistSpriteGFX::           INCBIN "gfx/sprites/scientist.2bpp" ; c54c0
+KimonoGirlSpriteGFX::          INCBIN "gfx/sprites/kimono_girl.2bpp" ; c5640
+SageSpriteGFX::                INCBIN "gfx/sprites/sage.2bpp" ; c57c0
+UnusedGuySpriteGFX::           INCBIN "gfx/sprites/unused_guy.2bpp" ; c5940
+GentlemanSpriteGFX::           INCBIN "gfx/sprites/gentleman.2bpp" ; c5ac0
+BlackBeltSpriteGFX::           INCBIN "gfx/sprites/black_belt.2bpp" ; c5c40
+ReceptionistSpriteGFX::        INCBIN "gfx/sprites/receptionist.2bpp" ; c5dc0
+OfficerSpriteGFX::             INCBIN "gfx/sprites/officer.2bpp" ; c5f40
+CalSpriteGFX::                 INCBIN "gfx/sprites/cal.2bpp" ; c60c0
+SlowpokeSpriteGFX::            INCBIN "gfx/sprites/slowpoke.2bpp" ; c6240
+CaptainSpriteGFX::             INCBIN "gfx/sprites/captain.2bpp" ; c6280
+BigLaprasSpriteGFX::           INCBIN "gfx/sprites/big_lapras.2bpp" ; c6400
+GymGuySpriteGFX::              INCBIN "gfx/sprites/gym_guy.2bpp" ; c6480
+SailorSpriteGFX::              INCBIN "gfx/sprites/sailor.2bpp" ; c6600
+BikerSpriteGFX::               INCBIN "gfx/sprites/biker.2bpp" ; c6780
+PharmacistSpriteGFX::          INCBIN "gfx/sprites/pharmacist.2bpp" ; c6900
+MonsterSpriteGFX::             INCBIN "gfx/sprites/monster.2bpp" ; c6a80
+FairySpriteGFX::               INCBIN "gfx/sprites/fairy.2bpp" ; c6c00
+BirdSpriteGFX::                INCBIN "gfx/sprites/bird.2bpp" ; c6d80
+DragonSpriteGFX::              INCBIN "gfx/sprites/dragon.2bpp" ; c6f00
+BigOnixSpriteGFX::             INCBIN "gfx/sprites/big_onix.2bpp" ; c7080
+N64SpriteGFX::                 INCBIN "gfx/sprites/n64.2bpp" ; c7140
+SudowoodoSpriteGFX::           INCBIN "gfx/sprites/sudowoodo.2bpp" ; c7180
+SurfSpriteGFX::                INCBIN "gfx/sprites/surf.2bpp" ; c7200
+PokeBallSpriteGFX::            INCBIN "gfx/sprites/poke_ball.2bpp" ; c7380
+PokedexSpriteGFX::             INCBIN "gfx/sprites/pokedex.2bpp" ; c7500
+PaperSpriteGFX::               INCBIN "gfx/sprites/paper.2bpp" ; c7680
+VirtualBoySpriteGFX::          INCBIN "gfx/sprites/virtual_boy.2bpp" ; c7800
+OldLinkReceptionistSpriteGFX:: INCBIN "gfx/sprites/old_link_receptionist.2bpp" ; c7840
+RockSpriteGFX::                INCBIN "gfx/sprites/rock.2bpp" ; c7880
+BoulderSpriteGFX::             INCBIN "gfx/sprites/boulder.2bpp" ; c78c0
+SnesSpriteGFX::                INCBIN "gfx/sprites/snes.2bpp" ; c7900
+FamicomSpriteGFX::             INCBIN "gfx/sprites/famicom.2bpp" ; c7940
+FruitTreeSpriteGFX::           INCBIN "gfx/sprites/fruit_tree.2bpp" ; c7980
+GoldTrophySpriteGFX::          INCBIN "gfx/sprites/gold_trophy.2bpp" ; c79c0
+SilverTrophySpriteGFX::        INCBIN "gfx/sprites/silver_trophy.2bpp" ; c7a00
+KrisSpriteGFX::                INCBIN "gfx/sprites/kris.2bpp" ; c7a40
+KrisBikeSpriteGFX::            INCBIN "gfx/sprites/kris_bike.2bpp" ; c7bc0
+KurtOutsideSpriteGFX::         INCBIN "gfx/sprites/kurt_outside.2bpp" ; c7d40
+SuicuneSpriteGFX::             INCBIN "gfx/sprites/suicune.2bpp" ; c7e00
+EnteiSpriteGFX::               INCBIN "gfx/sprites/entei.2bpp" ; c7e40
+RaikouSpriteGFX::              INCBIN "gfx/sprites/raikou.2bpp" ; c7e80
+StandingYoungsterSpriteGFX::   INCBIN "gfx/sprites/standing_youngster.2bpp" ; c7ec0
--- a/home.asm
+++ b/home.asm
@@ -4,7 +4,10 @@
 SECTION "NULL", ROM0
 NULL::
 
+
 INCLUDE "rst.asm"
+
+
 INCLUDE "interrupts.asm"
 
 
--- a/main.asm
+++ b/main.asm
@@ -82,65 +82,12 @@
 INCLUDE "engine/anim_hp_bar.asm"
 INCLUDE "engine/move_mon.asm"
 INCLUDE "engine/billspctop.asm"
-
-GetBreedMon1LevelGrowth: ; e698
-	ld hl, wBreedMon1Stats
-	ld de, TempMon
-	ld bc, BOXMON_STRUCT_LENGTH
-	call CopyBytes
-	callab CalcLevel
-	ld a, [wBreedMon1Level]
-	ld b, a
-	ld a, d
-	ld e, a
-	sub b
-	ld d, a
-	ret
-
-GetBreedMon2LevelGrowth: ; e6b3
-	ld hl, wBreedMon2Stats
-	ld de, TempMon
-	ld bc, BOXMON_STRUCT_LENGTH
-	call CopyBytes
-	callab CalcLevel
-	ld a, [wBreedMon2Level]
-	ld b, a
-	ld a, d
-	ld e, a
-	sub b
-	ld d, a
-	ret
-
+INCLUDE "engine/get_breedmon_growth.asm"
 INCLUDE "event/bug_contest/caught_mon.asm"
 INCLUDE "engine/item_effects.asm"
+INCLUDE "engine/knows_move.asm"
 
-KnowsMove: ; f9ea
-	ld a, MON_MOVES
-	call GetPartyParamLocation
-	ld a, [wPutativeTMHMMove]
-	ld b, a
-	ld c, NUM_MOVES
-.loop
-	ld a, [hli]
-	cp b
-	jr z, .knows_move
-	dec c
-	jr nz, .loop
-	and a
-	ret
 
-.knows_move
-	ld hl, .Text_knows
-	call PrintText
-	scf
-	ret
-
-.Text_knows: ; 0xfa06
-	; knows @ .
-	text_jump UnknownText_0x1c5ea8
-	db "@"
-
-
 SECTION "bank4", ROMX
 
 INCLUDE "engine/pack.asm"
@@ -147,16 +94,7 @@
 INCLUDE "engine/time.asm"
 INCLUDE "engine/tmhm.asm"
 INCLUDE "engine/namingscreen.asm"
-
-Script_AbortBugContest: ; 0x122c1
-	checkflag ENGINE_BUG_CONTEST_TIMER
-	iffalse .finish
-	setflag ENGINE_DAILY_BUG_CONTEST
-	special ContestReturnMons
-.finish
-	end
-
-INCLUDE "event/itemball.asm"
+INCLUDE "event/misc_scripts.asm"
 INCLUDE "event/heal_machine_anim.asm"
 INCLUDE "event/whiteout.asm"
 INCLUDE "event/forced_movement.asm"
@@ -165,8 +103,8 @@
 INCLUDE "engine/select_menu.asm"
 INCLUDE "event/elevator.asm"
 INCLUDE "event/bug_contest/contest.asm"
-INCLUDE "event/hidden_items.asm"
-INCLUDE "engine/collision_stdscripts.asm"
+INCLUDE "event/misc_scripts_2.asm"
+INCLUDE "event/std_collision.asm"
 INCLUDE "event/bug_contest/judging.asm"
 INCLUDE "engine/pokerus_tick.asm"
 INCLUDE "event/bug_contest/contest_2.asm"
@@ -201,15 +139,7 @@
 
 SECTION "bank9", ROMX
 
-StringBufferPointers:: ; 24000
-	dw StringBuffer3
-	dw StringBuffer4
-	dw StringBuffer5
-	dw StringBuffer2
-	dw StringBuffer1
-	dw EnemyMonNick
-	dw BattleMonNick
-
+INCLUDE "data/text_buffers.asm"
 INCLUDE "engine/menu.asm"
 
 UpdateItemDescription: ; 0x244c3
@@ -296,14 +226,9 @@
 INCLUDE "engine/link.asm"
 INCLUDE "engine/wildmons.asm"
 INCLUDE "battle/link_result.asm"
+INCLUDE "engine/player_gfx_2.asm"
 
-ChrisBackpic: ; 2ba1a
-INCBIN "gfx/player/chris_back.2bpp.lz"
 
-DudeBackpic: ; 2bbaa
-INCBIN "gfx/battle/dude.2bpp.lz"
-
-
 SECTION "bankB", ROMX
 
 INCLUDE "battle/trainer_huds.asm"
@@ -704,46 +629,8 @@
 INCLUDE "engine/delete_save_change_clock.asm"
 INCLUDE "tilesets/tileset_headers.asm"
 INCLUDE "engine/flag_predef.asm"
+INCLUDE "engine/trademon_frontpic.asm"
 
-GetTrademonFrontpic: ; 4d7fd
-	ld a, [wOTTrademonSpecies]
-	ld hl, wOTTrademonDVs
-	ld de, VTiles2
-	push de
-	push af
-	predef GetUnownLetter
-	pop af
-	ld [CurPartySpecies], a
-	ld [CurSpecies], a
-	call GetBaseData
-	pop de
-	predef FrontpicPredef
-	ret
-
-AnimateTrademonFrontpic: ; 4d81e
-	ld a, [wOTTrademonSpecies]
-	call IsAPokemon
-	ret c
-	callba ShowOTTrademonStats
-	ld a, [wOTTrademonSpecies]
-	ld [CurPartySpecies], a
-	ld a, [wOTTrademonDVs]
-	ld [TempMonDVs], a
-	ld a, [wOTTrademonDVs + 1]
-	ld [TempMonDVs + 1], a
-	ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS
-	call GetSGBLayout
-	ld a, %11100100 ; 3,2,1,0
-	call DmgToCgbBGPals
-	callba TradeAnim_ShowGetmonFrontpic
-	ld a, [wOTTrademonSpecies]
-	ld [CurPartySpecies], a
-	hlcoord 7, 2
-	ld d, $0
-	ld e, ANIM_MON_TRADE
-	predef AnimateFrontpic
-	ret
-
 CheckPokerus: ; 4d860
 ; Return carry if a monster in your party has Pokerus
 
@@ -780,55 +667,7 @@
 INCLUDE "mobile/get_trainer_class.asm"
 INCLUDE "battle/sliding_intro.asm"
 INCLUDE "mobile/print_opp_message.asm"
-
-CheckBattleScene: ; 4ea44
-; Return carry if battle scene is turned off.
-
-	ld a, 0
-	ld hl, wLinkMode
-	call GetFarWRAMByte
-	cp LINK_MOBILE
-	jr z, .mobile
-
-	ld a, [Options]
-	bit BATTLE_SCENE, a
-	jr nz, .off
-
-	and a
-	ret
-
-.mobile
-	ld a, [wcd2f]
-	and a
-	jr nz, .from_wram
-
-	ld a, $4
-	call GetSRAMBank
-	ld a, [$a60c]
-	ld c, a
-	call CloseSRAM
-
-	ld a, c
-	bit 0, c
-	jr z, .off
-
-	and a
-	ret
-
-.from_wram
-	ld a, $5
-	ld hl, w5_dc00
-	call GetFarWRAMByte
-	bit 0, a
-	jr z, .off
-
-	and a
-	ret
-
-.off
-	scf
-	ret
-
+INCLUDE "engine/check_battle_scene.asm"
 INCLUDE "engine/gbc_only.asm"
 INCLUDE "event/poke_seer.asm"
 
@@ -969,7 +808,6 @@
 INCLUDE "engine/std_scripts.asm"
 INCLUDE "engine/phone_scripts.asm"
 INCLUDE "engine/trainer_scripts.asm"
-INCLUDE "gfx/sprites.asm"
 
 
 SECTION "bank32", ROMX
@@ -1073,8 +911,6 @@
 INCLUDE "event/mom_phone.asm"
 
 
-SECTION "mobile_40", ROMX
-
 INCLUDE "mobile/mobile_40.asm"
 
 
@@ -1146,8 +982,12 @@
 	ret
 
 
+SECTION "mobile_5e", ROMX
+
 INCLUDE "mobile/mobile_5e.asm"
 
+
+SECTION "bank5F", ROMX
 
 INCLUDE "mobile/mobile_5f.asm"
 
--- a/mobile/mobile_40.asm
+++ b/mobile/mobile_40.asm
@@ -1,3 +1,5 @@
+SECTION "mobile_40", ROMX
+
 Function100000: ; 100000
 ; d: 1 or 2
 ; e: bank
--- a/mobile/mobile_41.asm
+++ b/mobile/mobile_41.asm
@@ -1,5 +1,3 @@
-SECTION "bank41_2", ROMX
-
 ; These functions deal with miscellaneous statistics
 ; which were used for Trainer Rankings in Pokémon News.
 
--- a/mobile/mobile_46.asm
+++ b/mobile/mobile_46.asm
@@ -3015,6 +3015,7 @@
 	db "Sun"
 ; 1196cd
 
+
 SECTION "bank46_2", ROMX
 ; A hack to use ascii above.
 
--- a/mobile/mobile_5e.asm
+++ b/mobile/mobile_5e.asm
@@ -1,9 +1,5 @@
-
-SECTION "Misc Crystal", ROMX
-
 MobileAdapterGFX::
 INCBIN "gfx/mobile/mobile_adapter.2bpp"
-
 
 Function17a68f:: ; 17a68f (5e:668f)
 	call Function17a6a8
--- a/mobile/mobile_5f.asm
+++ b/mobile/mobile_5f.asm
@@ -1,8 +1,4 @@
-
-SECTION "bank5F", ROMX
-
 Function17c000: ; 17c000
-
 	call DisableLCD
 
 	ld hl, VTiles2
--- a/pokecrystal.link
+++ b/pokecrystal.link
@@ -173,7 +173,6 @@
 	"bank40_3"
 ROMX $41
 	"bank41"
-	"bank41_2"
 ROMX $42
 	"mobile_42"
 	"Intro Logo"
@@ -243,7 +242,7 @@
 	"bank5E"
 	"Songs 5"
 	"Crystal Sound Effects"
-	"Misc Crystal"
+	"mobile_5e"
 ROMX $5f
 	"bank5F"
 ROMX $60
--- a/text/common_text.asm
+++ b/text/common_text.asm
@@ -1,12 +1,18 @@
 INCLUDE "includes.asm"
 
+
 SECTION "Text 1", ROMX
+
 INCLUDE "text/common_1.asm"
 
+
 SECTION "Text 2", ROMX
+
 INCLUDE "text/common_2.asm"
 INCLUDE "text/common_3.asm"
 
+
 SECTION "Text 3", ROMX
+
 INCLUDE "text/common_4.asm"
 INCLUDE "text/common_5.asm"