shithub: pokecrystal

Download patch

ref: 98f443f70c60f8fdbcf8621ab2c4f9dd37c66bde
parent: 2eeb78d1bcecf09b2a48035dc24c19a726c41819
author: pikalaxalt <PikalaxALT@gmail.com>
date: Tue May 17 04:40:42 EDT 2016

engine/events.asm labels finished

fixed palred/green/blue macros

--- a/engine/events.asm
+++ b/engine/events.asm
@@ -167,10 +167,10 @@
 	cp 2 ; HandleMap
 	ret nz
 
-	call Function967d1
+	call HandleMapObjects
 	call NextOverworldFrame
-	call Function967e1
-	call Function967f4
+	call HandleMapBackground
+	call CheckPlayerState
 	ret
 ; 96795
 
@@ -226,7 +226,7 @@
 	ret
 ; 967d1
 
-Function967d1: ; 967d1
+HandleMapObjects: ; 967d1
 	callba HandleNPCStep ; engine/map_objects.asm
 	callba _HandlePlayerStep
 	call _CheckObjectEnteringVisibleRange
@@ -233,7 +233,7 @@
 	ret
 ; 967e1
 
-Function967e1: ; 967e1
+HandleMapBackground: ; 967e1
 	callba _UpdateSprites
 	callba ScrollScreen
 	callba PlaceMapNameSign
@@ -240,7 +240,7 @@
 	ret
 ; 967f4
 
-Function967f4: ; 967f4
+CheckPlayerState: ; 967f4
 	ld a, [wPlayerStepFlags]
 	bit 5, a ; in the middle of step
 	jr z, .events
--- a/engine/events_2.asm
+++ b/engine/events_2.asm
@@ -458,7 +458,7 @@
 .okay
 	ld e, a
 	ld d, 0
-	ld hl, .Jumptable_ba
+	ld hl, .Jumptable
 	add hl, de
 	add hl, de
 	add hl, de
@@ -472,7 +472,7 @@
 	ret
 ; 97e94
 
-.Jumptable_ba: ; 97e94
+.Jumptable: ; 97e94
 	dba CmdQueue_Null
 	dba CmdQueue_Null2
 	dba CmdQueue_StoneTable
@@ -531,9 +531,9 @@
 	ld a, [hl]
 	dec a
 	ld [hl], a
-	jr z, .asm_97eee
+	jr z, .finish
 	and $1
-	jr z, .asm_97ee4
+	jr z, .add
 	ld hl, 2
 	add hl, bc
 	ld a, [hSCY]
@@ -541,7 +541,7 @@
 	ld [hSCY], a
 	ret
 
-.asm_97ee4
+.add
 	ld hl, 2
 	add hl, bc
 	ld a, [hSCY]
@@ -549,7 +549,7 @@
 	ld [hSCY], a
 	ret
 
-.asm_97eee
+.finish
 	ld hl, 4
 	add hl, bc
 	ld a, [hl]
--- a/engine/events_3.asm
+++ b/engine/events_3.asm
@@ -276,13 +276,13 @@
 ; Checks to see if there are hidden items on the screen that have not yet been found.  If it finds one, returns carry.
 	call GetMapScriptHeaderBank
 	ld [Buffer1], a
-; Get the coordinate of the bottom right corner of the screen, and load it in wd1ec/wd1ed.
+; Get the coordinate of the bottom right corner of the screen, and load it in Buffer3/Buffer4.
 	ld a, [XCoord]
 	add SCREEN_WIDTH / 4
-	ld [wd1ed], a
+	ld [Buffer4], a
 	ld a, [YCoord]
 	add SCREEN_HEIGHT / 4
-	ld [wd1ec], a
+	ld [Buffer3], a
 ; Get the pointer for the first signpost header in the map...
 	ld hl, wCurrentMapSignpostHeaderPointer
 	ld a, [hli]
@@ -301,7 +301,7 @@
 	call .GetFarByte
 	ld e, a
 ; Is the Y coordinate of the signpost on the screen?  If not, go to the next signpost.
-	ld a, [wd1ec]
+	ld a, [Buffer3]
 	sub e
 	jr c, .next
 	cp SCREEN_HEIGHT / 2
@@ -309,7 +309,7 @@
 ; Is the X coordinate of the signpost on the screen?  If not, go to the next signpost.
 	call .GetFarByte
 	ld d, a
-	ld a, [wd1ed]
+	ld a, [Buffer4]
 	sub d
 	jr c, .next
 	cp SCREEN_WIDTH / 2
--- a/engine/map_setup.asm
+++ b/engine/map_setup.asm
@@ -258,8 +258,8 @@
 	dba LoadMapPalettes ; 11
 	dba LoadWildMonData ; 12
 	dba RefreshMapSprites ; 13
-	dba RunCallback_05_03 ; 14
-	dba RunCallback_03 ; 15
+	dba HandleNewMap ; 14
+	dba InitCommandQueue ; 15
 	dba LoadObjectsRunCallback_02 ; 16
 	dba LoadSpawnPoint ; 17
 	dba EnterMapConnection ; 18
--- a/engine/pokedex.asm
+++ b/engine/pokedex.asm
@@ -694,9 +694,9 @@
 .show_search_results
 	ld [wDexListingEnd], a
 	ld a, [wDexListingScrollOffset]
-	ld [wc7e0], a
+	ld [wDexListingScrollOffsetBackup], a
 	ld a, [wDexListingCursor]
-	ld [wc7e1], a
+	ld [wDexListingCursorBackup], a
 	ld a, [wLastDexEntry]
 	ld [wcf65], a
 	xor a
@@ -777,9 +777,9 @@
 	ret
 
 .return_to_search_screen
-	ld a, [wc7e0]
+	ld a, [wDexListingScrollOffsetBackup]
 	ld [wDexListingScrollOffset], a
-	ld a, [wc7e1]
+	ld a, [wDexListingCursorBackup]
 	ld [wDexListingCursor], a
 	ld a, [wcf65]
 	ld [wLastDexEntry], a
--- a/engine/warp_connection.asm
+++ b/engine/warp_connection.asm
@@ -1,5 +1,5 @@
 
-RunCallback_05_03: ; 1045b0
+HandleNewMap: ; 1045b0
 	call Clearwc7e8
 	call ResetMapBufferEventFlags
 	call ResetFlashIfOutOfCave
@@ -7,7 +7,7 @@
 	call ResetBikeFlags
 	ld a, MAPCALLBACK_NEWMAP
 	call RunMapCallback
-RunCallback_03: ; 1045c4
+InitCommandQueue: ; 1045c4
 	callba ClearCmdQueue
 	ld a, MAPCALLBACK_CMDQUEUE
 	call RunMapCallback
@@ -20,18 +20,16 @@
 ; Return carry if a connection has been entered.
 	ld a, [wPlayerStepDirection]
 	and a
-	jp z, EnterSouthConnection
-	cp 1
-	jp z, EnterNorthConnection
-	cp 2
-	jp z, EnterWestConnection
-	cp 3
-	jp z, EnterEastConnection
+	jp z, .south
+	cp UP
+	jp z, .north
+	cp LEFT
+	jp z, .west
+	cp RIGHT
+	jp z, .east
 	ret
-; 1045ed
 
-
-EnterWestConnection: ; 1045ed
+.west
 	ld a, [WestConnectedMapGroup]
 	ld [MapGroup], a
 	ld a, [WestConnectedMapNumber]
@@ -64,11 +62,9 @@
 	ld [wOverworldMapAnchor], a
 	ld a, h
 	ld [wOverworldMapAnchor + 1], a
-	jp EnteredConnection
-; 104629
+	jp .done
 
-
-EnterEastConnection: ; 104629
+.east
 	ld a, [EastConnectedMapGroup]
 	ld [MapGroup], a
 	ld a, [EastConnectedMapNumber]
@@ -85,27 +81,25 @@
 	ld h, [hl]
 	ld l, a
 	srl c
-	jr z, .skip_to_load
+	jr z, .skip_to_load2
 	ld a, [EastConnectedMapWidth]
 	add 6
 	ld e, a
 	ld d, 0
 
-.loop
+.loop2
 	add hl, de
 	dec c
-	jr nz, .loop
+	jr nz, .loop2
 
-.skip_to_load
+.skip_to_load2
 	ld a, l
 	ld [wOverworldMapAnchor], a
 	ld a, h
 	ld [wOverworldMapAnchor + 1], a
-	jp EnteredConnection
-; 104665
+	jp .done
 
-
-EnterNorthConnection: ; 104665
+.north
 	ld a, [NorthConnectedMapGroup]
 	ld [MapGroup], a
 	ld a, [NorthConnectedMapNumber]
@@ -128,11 +122,9 @@
 	ld [wOverworldMapAnchor], a
 	ld a, h
 	ld [wOverworldMapAnchor + 1], a
-	jp EnteredConnection
-; 104696
+	jp .done
 
-
-EnterSouthConnection: ; 104696
+.south
 	ld a, [SouthConnectedMapGroup]
 	ld [MapGroup], a
 	ld a, [SouthConnectedMapNumber]
@@ -155,10 +147,7 @@
 	ld [wOverworldMapAnchor], a
 	ld a, h
 	ld [wOverworldMapAnchor + 1], a
-	; fallthrough
-; 1046c4
-
-EnteredConnection: ; 1046c4
+.done
 	scf
 	ret
 ; 1046c6
@@ -239,11 +228,11 @@
 	callba ReplaceTimeOfDayPals
 	callba UpdateTimeOfDayPal
 	call OverworldTextModeSwitch
-	call Function104770
-	call Function1047a3
+	call .ClearBGMap
+	call .PushAttrMap
 	ret
 
-Function104770: ; 104770 (41:4770)
+.ClearBGMap: ; 104770 (41:4770)
 	ld a, VBGMap0 / $100
 	ld [wBGMapAnchor + 1], a
 	xor a
@@ -251,16 +240,20 @@
 	ld [hSCY], a
 	ld [hSCX], a
 	callba ApplyBGMapAnchorToObjects
+
 	ld a, [rVBK]
 	push af
 	ld a, $1
 	ld [rVBK], a
+
 	xor a
 	ld bc, VBGMap1 - VBGMap0
 	hlbgcoord 0, 0
 	call ByteFill
+
 	pop af
 	ld [rVBK], a
+
 	ld a, $60
 	ld bc, VBGMap1 - VBGMap0
 	hlbgcoord 0, 0
@@ -267,7 +260,7 @@
 	call ByteFill
 	ret
 
-Function1047a3: ; 1047a3 (41:47a3)
+.PushAttrMap: ; 1047a3 (41:47a3)
 	decoord 0, 0
 	call .copy
 	ld a, [hCGB]
--- a/macros.asm
+++ b/macros.asm
@@ -257,9 +257,9 @@
 bcbgcoord EQUS "bgcoord bc,"
 bgrows EQUS "* $20"
 
-palred EQUS "$0400 *"
+palred EQUS "$0001 *"
 palgreen EQUS "$0020 *"
-palblue EQUS "$0001 *"
+palblue EQUS "$0400 *"
 
 dsprite: MACRO
 ; conditional segment is there because not every instance of
--- a/main.asm
+++ b/main.asm
@@ -5129,10 +5129,10 @@
 	ld hl, BGPals
 	ld c, $20
 .loop
-; RGB 31, 21, 28
-	ld a, (palred 31 + palgreen 21 + palblue 28) % $100
+; RGB 28, 21, 31
+	ld a, (palred 28 + palgreen 21 + palblue 31) % $100
 	ld [hli], a
-	ld a, (palred 31 + palgreen 21 + palblue 28) / $100
+	ld a, (palred 28 + palgreen 21 + palblue 31) / $100
 	ld [hli], a
 	dec c
 	jr nz, .loop
@@ -5358,11 +5358,11 @@
 
 	ld hl, OverworldMap
 	ld de, sScratch
-	ld bc, $31 tiles
+	ld bc, 7 * 7 tiles
 	call CopyBytes
 	pop hl
 	ld de, sScratch
-	ld c, $31
+	ld c, 7 * 7
 	ld a, [hROMBank]
 	ld b, a
 	call Get2bpp
@@ -5774,7 +5774,8 @@
 
 .esults_D ; 1de23c
 ; (SEARCH R)
-	db   "ESULTS<NEXT>"
+	db   "ESULTS"
+	next ""
 ; (### FOUN)
 	next "D!@"
 
--- a/wram.asm
+++ b/wram.asm
@@ -875,8 +875,8 @@
 wDexCurrentUnownIndex:: ds 1
 wDexUnownCount:: ds 1
 wDexConvertedMonType:: ds 1 ; mon type converted from dex search mon type
-wc7e0:: ds 1
-wc7e1:: ds 1
+wDexListingScrollOffsetBackup:: ds 1
+wDexListingCursorBackup:: ds 1
 wBackupDexListingCursor::
 wc7e2:: ds 1
 wBackupDexListingPage::
@@ -896,7 +896,7 @@
 
 wMiscEnd::
 
-wc7e8:: ds 24
+wc7e8:: ds 24 ; ????
 
 SECTION "Overworld Map", WRAM0 [$c800]
 
@@ -1878,7 +1878,7 @@
 wd154:: ; d154
 	ds 31 ; 64
 
-wd173:: ds 1
+wd173:: ds 1 ; related to command queue type 3
 	ds 13
 wd181:: ds 1
 wd182:: ds 1