shithub: pokecrystal

Download patch

ref: 80465fc6e6f1455f4ae65b5c0db54b9953ca0cc5
parent: 0a16a7aef04c60ff64dcbded28f7db9c45067125
parent: 821f2c2ea0f9dc482520f2cf9c45ccfaca8bbb29
author: Bryan Bishop <[email protected]>
date: Sat Feb 1 12:59:39 EST 2014

Merge pull request #227 from yenatch/master

Map setup scripts

--- a/engine/events.asm
+++ b/engine/events.asm
@@ -134,7 +134,7 @@
 	ld [$d453], a
 	ld [$d454], a
 	call Function968d1
-	callba Function15363
+	callba RunMapSetupScript
 	call Function966cb
 
 	ld a, [$ff9f]
--- a/home/map.asm
+++ b/home/map.asm
@@ -214,7 +214,7 @@
 Function222a: ; 222a
 	ld a, $fa
 	ld [$ff9f], a
-	callba Function15363
+	callba RunMapSetupScript
 	xor a
 	ld [$ff9f], a
 	ret
@@ -1489,7 +1489,7 @@
 .asm_28ce
 	ld b, $6
 	ld c, $4
-	jr .asm_28f7
+	jr Function28f7
 
 .asm_28d4
 	ld de, $dcba
@@ -1502,8 +1502,10 @@
 .asm_28dd
 	ld b, $5
 	ld c, $5
-	jr .asm_28f7
+	jr Function28f7
 
+
+Function28e3: ; 28e3
 	ld hl, $d194
 	ld a, [hli]
 	ld h, [hl]
@@ -1515,6 +1517,7 @@
 	ld b, $6
 	ld c, $5
 
+Function28f7: ; 28f7
 .asm_28f7
 	push bc
 	push hl
--- a/main.asm
+++ b/main.asm
@@ -9853,7 +9853,7 @@
 	ld d, a
 	ld a, [$dcb3]
 	ld e, a
-	callba Function15344
+	callba IsSpawnPoint
 	jr nc, .asm_cc99
 	ld a, c
 	ld [$d001], a
@@ -17429,7 +17429,7 @@
 	ld d, a
 	ld a, [$dcb3]
 	ld e, a
-	callba Function15344
+	callba IsSpawnPoint
 	ld a, c
 	jr c, .asm_12539
 	xor a
@@ -20391,13 +20391,13 @@
 
 Function14000: ; 14000
 	ld a, $a
-	ld [$0000], a
+	ld [MBC3SRamEnable], a
 	call LatchClock
 	ld a, $c
-	ld [Function14000], a
-	ld a, [$a000]
+	ld [MBC3SRamBank], a
+	ld a, [MBC3RTC]
 	set 6, a
-	ld [$a000], a
+	ld [MBC3RTC], a
 	call CloseSRAM
 	ret
 ; 14019
@@ -20406,13 +20406,13 @@
 
 Function14019: ; 14019
 	ld a, $a
-	ld [$0000], a
+	ld [MBC3SRamEnable], a
 	call LatchClock
 	ld a, $c
-	ld [Function14000], a
-	ld a, [$a000]
+	ld [MBC3SRamBank], a
+	ld a, [MBC3RTC]
 	res 6, a
-	ld [$a000], a
+	ld [MBC3RTC], a
 	call CloseSRAM
 	ret
 ; 14032
@@ -20472,14 +20472,14 @@
 
 Function1406a: ; 1406a
 	ld a, $a
-	ld [$0000], a
+	ld [MBC3SRamEnable], a
 	call LatchClock
-	ld hl, $a000
+	ld hl, MBC3RTC
 	ld a, $c
-	ld [Function14000], a
+	ld [MBC3SRamBank], a
 	res 7, [hl]
 	ld a, $0
-	ld [Function14000], a
+	ld [MBC3SRamBank], a
 	xor a
 	ld [$ac60], a
 	call CloseSRAM
@@ -23147,7 +23147,7 @@
 	db -1, -1, -1, -1
 
 
-Function1531f: ; 1531f
+LoadSpawnPoint: ; 1531f
 	push hl
 	push de
 	ld a, [$d001]
@@ -23174,7 +23174,7 @@
 ; 15344
 
 
-Function15344: ; 15344
+IsSpawnPoint: ; 15344
 	ld hl, SpawnPoints
 	ld c, 0
 .asm_15349
@@ -23206,44 +23206,284 @@
 ; 15363
 
 
-Function15363: ; 15363
+RunMapSetupScript: ; 15363
 	ld a, [$ff9f]
 	and $f
 	dec a
 	ld c, a
-	ld b, $0
-	ld hl, $5377
+	ld b, 0
+	ld hl, MapSetupScripts
 	add hl, bc
 	add hl, bc
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
-	call Function1541d
+	call ReadMapSetupScript
 	ret
 ; 15377
 
-INCBIN "baserom.gbc",$15377,$1541d - $15377
+MapSetupScripts: ; 15377
+	dw MapSetupScript1
+	dw MapSetupScript2
+	dw MapSetupScript3
+	dw MapSetupScript4
+	dw MapSetupScript5
+	dw MapSetupScript6
+	dw MapSetupScript7
+	dw MapSetupScript8
+	dw MapSetupScript9
+	dw MapSetupScript10
+	dw MapSetupScript11
+	dw MapSetupScript12
+; 1538f
 
 
-Function1541d: ; 1541d
-.asm_1541d
+; Command descriptions from Condensation water's scripting compendium.
+	const_def
+	const map_lcd_on              ; 00 = Turn LCD on
+	const map_lcd_off             ; 01 = Turn LCD off
+	const map_sound_off           ; 02 = Turn speakers off
+	const map_music               ; 03 = Music check for current map/ special check for bug catcher contest
+	const map_start_music         ; 04 = Start map music anew
+	const map_fade_music          ; 05 = Music check for current map / special check for Bug Contest/ music with FadeOut (old) and FadeIn
+	const map_fade                ; 06 = Fade out music + screen
+	const map_bike_music          ; 07 = If HIRO is on bike = bike music, else play map music
+	const map_music_force         ; 08 = Play map music
+	const map_max_volume          ; 09 = Turn music to highest volume
+	const map_load_blocks         ; 0A = Write map data to MapRAM
+	const map_connection_blocks   ; 0B = Compute map’s connection pars and write into MapRAM
+	const map_save_screen         ; 0C = Write current part of map into temporary memory
+	const map_buffer_screen       ; 0D = Write current part of map into read-from memory
+	const map_load_graphics       ; 0E = Write tileset header to ram/ load tileset/ load sprite tiles/ load special tiles
+	const map_load_tileset_header ; 0F = Write tileset header to ram
+	const map_time_of_day         ; 10 = Compute time of day/ Update screen
+	const map_palettes            ; 11 = Load map palettes
+	const map_wildmons            ; 12 = Load probabilities for wild Pokémon battles
+	const map_sprites             ; 13 = Delete sprite data and draw new sprites
+	const map_change_callback     ; 14 = Check 2nd script header for 05 and 03 callbacks
+	const map_start_callback      ; 15 = Check 2nd script header for 03 callbacks
+	const map_load_objects        ; 16 = Analyze people data anew and check 2nd script header for 02 callbacks
+	const map_load_spawn          ; 17 = Writes arrival data for arrival by flying/Blackout from table 05:5319 to ram
+	const map_load_connection     ; 18 = Writes arrival data for entering a map by connection to ram
+	const map_load_warp           ; 19 = Write warp data to ram when entering warp
+	const map_attributes          ; 1A = Load complete map data (primary, secondary, event, script headers)
+	const map_attributes_2        ; 1B = Same as 1A, but some settings aren’t loaded new from the rom, such as hide function of the people events
+	const map_clear_bg_palettes   ; 1C = Fill palette data with FFFF (=white)
+	const map_fade_out_palettes   ; 1D = All BG pallet color are converted to 0|0 (Pal0, Col0), all sprite colors to x|0 (FadeOut)
+	const map_fade_in_palettes    ; 1E = Palette FadeIn
+	const map_anchor_screen       ; 1F = Compute position of upper left-most block visible on screen
+	const map_warp_face           ; 20 = Position computation when HIRO leaves a warp
+	const map_face_down           ; 21 = Set HIRO’s facing to “down”
+	const map_spawn_coord         ; 22 = Prepare HIRO data for arrival by flight
+	const map_player_coord        ; 23 = Compute HIRO x/y data anew
+	const map_prolong_sprites     ; 24 = Prolong old sprites before removing them
+	const map_delay_sprites       ; 25 = Delay rendering new sprites
+	const map_update_roam         ; 26 = Compute chances to meet Raikou, Entei or Suicune
+	const map_keep_roam           ; 27 = Recover chances to meet Raikou, Entei or Suicune
+	const map_fade_out_music      ; 28 = Temporarily stop music playing
+	const map_animations_on       ; 29 = Activate animations
+	const map_animations_off      ; 2A = Deactivate animations
+	const map_keep_palettes       ; 2B = Recover all palettes
+	const map_text_scroll_off     ; 2C = Turn off text scroll (for town name overlays)
+	const map_stop_script         ; 2D = Deactivate code prolonging
+
+
+MapSetupScript4: ; 1538f
+	db map_prolong_sprites
+
+MapSetupScript12: ; 15390
+	db map_fade_out_palettes
+	db map_keep_roam
+
+MapSetupScript1: ; 15392
+	db map_lcd_off
+	db map_sound_off
+	db map_load_spawn
+	db map_attributes
+	db map_change_callback
+	db map_spawn_coord
+	db map_player_coord
+	db map_anchor_screen
+	db map_load_blocks
+	db map_buffer_screen
+	db map_load_graphics
+	db map_time_of_day
+	db map_load_objects
+	db map_lcd_on
+	db map_palettes
+	db map_face_down
+	db map_sprites
+	db map_bike_music
+	db map_max_volume
+	db map_fade_in_palettes
+	db map_animations_on
+	db map_wildmons
+	db -1
+
+MapSetupScript11: ; 153a9
+	db map_load_spawn
+	db map_attributes
+	db map_change_callback
+	db map_spawn_coord
+	db map_player_coord
+	db map_anchor_screen
+	db map_load_blocks
+	db map_buffer_screen
+	db map_lcd_off
+	db map_load_graphics
+	db map_time_of_day
+	db map_fade_out_music
+	db map_lcd_on
+	db map_load_objects
+	db map_palettes
+	db map_face_down
+	db map_sprites
+	db map_fade_music
+	db map_fade_in_palettes
+	db map_animations_on
+	db map_wildmons
+	db -1
+
+MapSetupScript7: ; 153bf
+	db map_animations_off
+	db map_load_connection
+	db map_attributes
+	db map_change_callback
+	db map_player_coord
+	db map_load_blocks
+	db map_load_tileset_header
+	db map_save_screen
+	db map_load_objects
+	db map_fade_music
+	db map_palettes
+	db map_stop_script
+	db map_keep_palettes
+	db map_wildmons
+	db map_update_roam
+	db map_animations_on
+	db -1
+
+MapSetupScript6: ; 153d0
+	db map_prolong_sprites
+
+MapSetupScript5: ; 153d1
+	db map_fade_out_palettes
+
+MapSetupScript9: ; 153d2
+	db map_load_warp
+	db map_attributes
+	db map_warp_face
+	db map_change_callback
+	db map_player_coord
+	db map_load_blocks
+	db map_buffer_screen
+	db map_lcd_off
+	db map_load_graphics
+	db map_time_of_day
+	db map_fade_out_music
+	db map_lcd_on
+	db map_load_objects
+	db map_palettes
+	db map_sprites
+	db map_fade_music
+	db map_fade_in_palettes
+	db map_animations_on
+	db map_wildmons
+	db map_update_roam
+	db -1
+
+MapSetupScript3: ; 153e7
+	db map_fade
+	db map_clear_bg_palettes
+	db map_lcd_off
+	db map_sound_off
+	db map_load_blocks
+	db map_connection_blocks
+	db map_load_graphics
+	db map_time_of_day
+	db map_lcd_on
+	db map_palettes
+	db map_sprites
+	db map_music_force
+	db map_fade_in_palettes
+	db map_animations_on
+	db map_wildmons
+	db -1
+
+MapSetupScript8: ; 153f7
+	db map_fade
+	db map_lcd_off
+	db map_sound_off
+	db map_change_callback
+	db map_load_blocks
+	db map_buffer_screen
+	db map_load_graphics
+	db map_time_of_day
+	db map_lcd_on
+	db map_palettes
+	db map_sprites
+	db map_bike_music
+	db map_fade_in_palettes
+	db map_animations_on
+	db map_wildmons
+	db map_text_scroll_off
+	db -1
+
+MapSetupScript2: ; 15408
+	db map_lcd_off
+	db map_sound_off
+	db map_attributes_2
+	db map_anchor_screen
+	db map_start_callback
+	db map_load_blocks
+	db map_connection_blocks
+	db map_buffer_screen
+	db map_load_graphics
+	db map_time_of_day
+	db map_lcd_on
+	db map_palettes
+	db map_sprites
+	db map_bike_music
+	db map_fade_in_palettes
+	db map_animations_on
+	db map_wildmons
+	db -1
+
+MapSetupScript10: ; 1541a
+	db map_load_blocks
+	db map_connection_blocks
+	db -1
+
+
+ReadMapSetupScript: ; 1541d
+.loop
 	ld a, [hli]
-	cp $ff
+	cp -1
 	ret z
+
 	push hl
+
 	ld c, a
-	ld b, $0
-	ld hl, $5440
+	ld b, 0
+	ld hl, MapSetupCommands
 	add hl, bc
 	add hl, bc
 	add hl, bc
+
+	; bank
 	ld b, [hl]
 	inc hl
+
+	; address
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
+
+	; Bit 7 of the bank indicates a parameter.
+	; This is left unused.
 	bit 7, b
-	jr z, .asm_15439
+	jr z, .go
+
 	pop de
 	ld a, [de]
 	ld c, a
@@ -23250,25 +23490,80 @@
 	inc de
 	push de
 
-.asm_15439
+.go
 	ld a, b
 	and $7f
 	rst FarCall
+
 	pop hl
-	jr .asm_1541d
+	jr .loop
 ; 15440
 
-INCBIN "baserom.gbc",$15440,$154cf - $15440
+MapSetupCommands: ; 15440
+	dbw BANK(EnableLCD), EnableLCD
+	dbw BANK(DisableLCD), DisableLCD
+	dbw BANK(SoundRestart), SoundRestart
+	dbw BANK(Function3cdf), Function3cdf
+	dbw BANK(Function3d47), Function3d47
+	dbw BANK(Function3cbc), Function3cbc
+	dbw BANK(Function15574), Function15574
+	dbw BANK(Function3d03), Function3d03
+	dbw BANK(Function15587), Function15587
+	dbw BANK(Function3cae), Function3cae
+	dbw BANK(Function24cd), Function24cd
+	dbw BANK(Function28e3), Function28e3
+	dbw BANK(Function289d), Function289d
+	dbw BANK(Function2879), Function2879
+	dbw BANK(Function1047cf), Function1047cf
+	dbw BANK(LoadTilesetHeader), LoadTilesetHeader
+	dbw BANK(Function104750), Function104750
+	dbw BANK(Function1047eb), Function1047eb
+	dbw BANK(Function29ff8), Function29ff8
+	dbw BANK(Function1047f0), Function1047f0
+	dbw BANK(Function1045b0), Function1045b0
+	dbw BANK(Function1045c4), Function1045c4
+	dbw BANK(Function154d7), Function154d7
+	dbw BANK(LoadSpawnPoint), LoadSpawnPoint
+	dbw BANK(EnterMapConnection), EnterMapConnection
+	dbw BANK(Function1046c6), Function1046c6
+	dbw BANK(Function2309), Function2309
+	dbw BANK(Function2317), Function2317
+	dbw BANK(WhiteBGMap), WhiteBGMap
+	dbw BANK(Function8c084), Function8c084
+	dbw BANK(Function8c079), Function8c079
+	dbw BANK(Function10486d), Function10486d
+	dbw BANK(Function248a), Function248a
+	dbw BANK(Function57d9), Function57d9
+	dbw BANK(Function8029), Function8029
+	dbw BANK(Function80b8), Function80b8
+	dbw BANK(Function154eb), Function154eb
+	dbw BANK(Function154f1), Function154f1
+	dbw BANK(Function2a30d), Function2a30d
+	dbw BANK(Function2a394), Function2a394
+	dbw BANK(Function15567), Function15567
+	dbw BANK(Function154cf), Function154cf
+	dbw BANK(Function154d3), Function154d3
+	dbw BANK(Function1556d), Function1556d
+	dbw BANK(Function154ca), Function154ca
+	dbw BANK(Functionb8000), Functionb8000
+; 154ca
 
+
+Function154ca: ; 154ca
+	xor a
+	ld [$c2d7], a
+	ret
+; 154cf
+
 Function154cf: ; 154cf
 	ld a, $1
-	ld [$FF00+$de], a
+	ld [$ffde], a
 	ret
 ; 154d3
 
 Function154d3: ; 154d3
 	xor a
-	ld [$FF00+$de], a
+	ld [$ffde], a
 	ret
 ; 154d7
 
@@ -23368,19 +23663,30 @@
 .asm_15565
 	and a
 	ret
+; 15567
+
+Function15567: ; 15567
 	ld a, $6
 	call Function3cb4
 	ret
+; 1556d
+
+Function1556d: ; 1556d
 	callba _UpdateTimePals
 	ret
-	ld e, $0
+
+Function15574: ; 15574
+	ld e, 0
 	ld a, [MusicFadeIDLo] ; $c2a9
-	ld d, $0
+	ld d, 0
 	ld a, [MusicFadeIDHi] ; $c2aa
 	ld a, $4
 	ld [MusicFade], a ; $c2a7
 	call Function4b6
 	ret
+; 15587
+
+Function15587: ; 15587
 	ld a, [PlayerState] ; $d95d
 	cp $1
 	jr nz, .asm_15596
@@ -23390,7 +23696,9 @@
 .asm_15596
 	call Function3d2f
 	ret
+; 1559a
 
+
 Function1559a: ; 1559a
 	call Function15650
 	ret c
@@ -24058,7 +24366,7 @@
 	ld hl, UnknownText_0x15f83
 	call Function15fcd
 	call Function15c62
-	ld hl, $5fb4
+	ld hl, UnknownText_0x15fb4
 	call Function15fcd
 	ret
 ; 15aee
@@ -24131,7 +24439,7 @@
 ; 15b6e
 
 Function15b6e: ; 15b6e
-	ld hl, $5f88
+	ld hl, MenuDataHeader_0x15f88
 	call Function1d3c
 	call Function1d81
 	jr c, .asm_15b84
@@ -24169,7 +24477,7 @@
 
 Function15ba3: ; 15ba3
 	call Function1c07
-	ld hl, $5fb4
+	ld hl, UnknownText_0x15fb4
 	call Function15fcd
 	ld a, $ff
 	ret
@@ -24529,9 +24837,11 @@
 ; 15e0e
 
 INCBIN "baserom.gbc",$15e0e,$15e30 - $15e0e
+
+Function15e30: ; 15e30
 	ld a, [$cf77]
 	ld c, a
-	ld b, $0
+	ld b, 0
 	ld hl, DefaultFlypoint ; $d002
 	add hl, bc
 	add hl, bc
@@ -24599,7 +24909,7 @@
 	ld a, [$d142]
 	and a
 	jr z, .asm_15f11
-	ld hl, $5faf
+	ld hl, UnknownText_0x15faf
 	call PrintText
 	and a
 	ret
@@ -24651,7 +24961,8 @@
 	db "@"
 ; 0x15f7d
 
-INCBIN "baserom.gbc",$15f7d,$15f83 - $15f7d
+String15f7d: ; 15f7d
+	db "!ダミー!@"
 
 UnknownText_0x15f83: ; 0x15f83
 	text_jump UnknownText_0x1c4f62
@@ -24658,8 +24969,52 @@
 	db "@"
 ; 0x15f88
 
-INCBIN "baserom.gbc",$15f88,$15fb9 - $15f88
+MenuDataHeader_0x15f88: ; 0x15f88
+	db $40 ; flags
+	db 00, 00 ; start coords
+	db 08, 07 ; end coords
+	dw MenuData2_0x15f90
+	db 1 ; default option
+; 0x15f90
 
+MenuData2_0x15f90: ; 0x15f90
+	db $80 ; flags
+	db 3 ; items
+	db "BUY@"
+	db "SELL@"
+	db "QUIT@"
+; 0x15f96
+
+UnknownText_0x15fa0: ; 0x15fa0
+	; Here you are. Thank you!
+	text_jump UnknownText_0x1c4f80
+	db "@"
+; 0x15fa5
+
+UnknownText_0x15fa5: ; 0x15fa5
+	; You don't have enough money.
+	text_jump UnknownText_0x1c4f9a
+	db "@"
+; 0x15faa
+
+UnknownText_0x15faa: ; 0x15faa
+	; You can't carry any more items.
+	text_jump UnknownText_0x1c4fb7
+	db "@"
+; 0x15faf
+
+UnknownText_0x15faf: ; 0x15faf
+	; Sorry, I can't buy that from you.
+	text_jump UnknownText_0x1c4fd7
+	db "@"
+; 0x15fb4
+
+UnknownText_0x15fb4: ; 0x15fb4
+	; Please come again!
+	text_jump UnknownText_0x1c4ff9
+	db "@"
+; 0x15fb9
+
 UnknownText_0x15fb9: ; 0x15fb9
 	text_jump UnknownText_0x1c500d
 	db "@"
@@ -31107,7 +31462,7 @@
 	ld e, l
 	callba Function4d35b
 	ld hl, $c56c
-	ld de, $4419
+	ld de, String28419
 	call PlaceString
 	call Function28eff
 	call Function3200
@@ -31555,7 +31910,7 @@
 ; 283b2
 
 Function283b2: ; 283b2
-	ld de, $43ed
+	ld de, Unknown_283ed
 	ld b, $a
 .asm_283b7
 	call DelayFrame
@@ -31586,6 +31941,7 @@
 	ret
 ; 283ed
 
+Unknown_283ed:
 INCBIN "baserom.gbc",$283ed,$283f2 - $283ed
 
 Function283f2: ; 283f2
@@ -31622,7 +31978,9 @@
 	ret
 ; 28419
 
-INCBIN "baserom.gbc",$28419,$28426 - $28419
+String28419: ; 28419
+	db "PLEASE WAIT!@"
+; 28426
 
 Function28426: ; 28426
 	ld hl, OverworldMap
@@ -31815,11 +32173,11 @@
 .asm_28530
 	push bc
 	dec a
-	ld hl, $542b
-	ld bc, $0020
+	ld hl, BaseData + 7 ; type
+	ld bc, BaseData1 - BaseData0
 	call AddNTimes
-	ld bc, $0002
-	ld a, $14
+	ld bc, 2
+	ld a, BANK(BaseData)
 	call FarCopyBytes
 	pop bc
 
@@ -31827,7 +32185,7 @@
 	push bc
 	ld hl, $0001
 	add hl, bc
-	ld bc, OBJECT_SPRITE_Y_OFFSET
+	ld bc, $1a
 	call CopyBytes
 	pop bc
 	ld hl, $001f
@@ -31849,9 +32207,9 @@
 	push bc
 	ld b, $0
 	ld c, a
-	ld hl, $7656
+	ld hl, Unknown_fb656
 	add hl, bc
-	ld a, $3e
+	ld a, BANK(Unknown_fb656)
 	call GetFarByte
 	ld [BaseSpecialAttack], a
 	pop bc
@@ -32171,7 +32529,7 @@
 	and a
 	ret z
 	push hl
-	ld hl, $4785
+	ld hl, Unknown_28785
 .asm_28778
 	ld a, [hli]
 	and a
@@ -32189,6 +32547,7 @@
 	ret
 ; 28785
 
+Unknown_28785: ; 28785
 INCBIN "baserom.gbc",$28785,$2879e - $28785
 
 Function2879e: ; 2879e
@@ -32422,7 +32781,7 @@
 	ld c, $12
 	call Function28eef
 	ld hl, $c5e2
-	ld de, $4ab4
+	ld de, String28ab4
 	call PlaceString
 	callba Function4d354
 
@@ -32531,7 +32890,7 @@
 	ld c, $12
 	call Function28eef
 	callba Function4d354
-	ld hl, $4aaf
+	ld hl, UnknownText_0x28aaf
 	ld bc, $c5b9
 	call Function13e5
 	jr .asm_28a89
@@ -32553,7 +32912,7 @@
 	ld c, $12
 	call Function28eef
 	callba Function4d354
-	ld hl, $4ac4
+	ld hl, UnknownText_0x28ac4
 	ld bc, $c5b9
 	call Function13e5
 
@@ -32563,7 +32922,7 @@
 	ld c, $12
 	call Function28eef
 	ld hl, $c5b9
-	ld de, $4ece
+	ld de, String28ece
 	call PlaceString
 	ld a, $1
 	ld [$cf56], a
@@ -32573,8 +32932,23 @@
 	jp Function287e3
 ; 28aaf
 
-INCBIN "baserom.gbc",$28aaf,$28ac9 - $28aaf
 
+UnknownText_0x28aaf: ; 0x28aaf
+	; If you trade that #MON, you won't be able to battle.
+	text_jump UnknownText_0x1c41b1
+	db "@"
+; 0x28ab4
+
+String28ab4: ; 28ab4
+	db "STATS     TRADE@"
+
+UnknownText_0x28ac4: ; 0x28ac4
+	; Your friend's @  appears to be abnormal!
+	text_jump UnknownText_0x1c41e6
+	db "@"
+; 0x28ac9
+
+
 Function28ac9: ; 28ac9
 	ld a, [$cfa9]
 	cp $1
@@ -32699,7 +33073,7 @@
 	ld a, [hl]
 	ld [$d265], a
 	call GetPokemonName
-	ld hl, $4eb8
+	ld hl, UnknownText_0x28eb8
 	ld bc, $c5b9
 	call Function13e5
 	call Function1d6e
@@ -32707,7 +33081,7 @@
 	ld b, $3
 	ld c, $7
 	call Function28eef
-	ld de, $4eab
+	ld de, String28eab
 	ld hl, $c54c
 	call PlaceString
 	ld a, $8
@@ -32748,7 +33122,7 @@
 	ld c, $12
 	call Function28eef
 	ld hl, $c5b9
-	ld de, $4ece
+	ld de, String28ece
 	call PlaceString
 	callba Function16d6ce
 	jp Function28ea3
@@ -32765,7 +33139,7 @@
 	ld c, $12
 	call Function28eef
 	ld hl, $c5b9
-	ld de, $4ece
+	ld de, String28ece
 	call PlaceString
 	jp Function28ea3
 
@@ -32998,7 +33372,7 @@
 	ld c, $12
 	call Function28eef
 	ld hl, $c5b9
-	ld de, $4ebd
+	ld de, String28ebd
 	call PlaceString
 	callba Function4d354
 	ld c, $32
@@ -33010,13 +33384,27 @@
 ; 28ea3
 
 Function28ea3: ; 28ea3
-	ld c, $64
+	ld c, 100
 	call DelayFrames
 	jp Function287e3
 ; 28eab
 
-INCBIN "baserom.gbc",$28eab,$28eef - $28eab
+String28eab: ; 28eab
+	db "TRADE", $4e, "CANCEL@"
 
+UnknownText_0x28eb8: ; 0x28eb8
+	; Trade @ for @ ?
+	text_jump UnknownText_0x1c4212
+	db "@"
+; 0x28ebd
+
+String28ebd: ; 28ebd
+	db "Trade completed!@"
+
+String28ece: ; 28ece
+	db "Too bad! The trade", $4e, "was canceled!@"
+
+
 Function28eef: ; 28eef
 	ld d, h
 	ld e, l
@@ -33259,8 +33647,8 @@
 Function290a0: ; 290a0
 	ld a, [$cf63]
 	ld e, a
-	ld d, $0
-	ld hl, $50af
+	ld d, 0
+	ld hl, JumpTable290af
 	add hl, de
 	add hl, de
 	ld a, [hli]
@@ -33269,6 +33657,7 @@
 	jp [hl]
 ; 290af
 
+JumpTable290af: ; 290af
 INCBIN "baserom.gbc",$290af,$29491 - $290af
 
 Function29491: ; 29491
@@ -34010,6 +34399,8 @@
 ; 29f54
 
 INCBIN "baserom.gbc",$29f54,$29ff8 - $29f54
+
+Function29ff8: ; 29ff8
 	call Function2a205
 	jr c, .asm_2a006
 	ld hl, $d25a
@@ -34674,7 +35065,7 @@
 	ld l, e
 	call Random
 	and $1f
-	jr z, asm_2a3cd
+	jr z, Function2a3cd
 	and $3
 	cp [hl]
 	jr nc, .asm_2a36e
@@ -34702,36 +35093,37 @@
 	ld a, [RoamMon1MapGroup]
 	cp $ff
 	jr z, .asm_2a3a6
-	call asm_2a3cd
+	call Function2a3cd
 	ld a, b
 	ld [RoamMon1MapGroup], a
 	ld a, c
 	ld [RoamMon1MapNumber], a
-
 .asm_2a3a6
+
 	ld a, [RoamMon2MapGroup]
 	cp $ff
 	jr z, .asm_2a3b8
-	call asm_2a3cd
+	call Function2a3cd
 	ld a, b
 	ld [RoamMon2MapGroup], a
 	ld a, c
 	ld [RoamMon2MapNumber], a
-
 .asm_2a3b8
+
 	ld a, [RoamMon3MapGroup]
 	cp $ff
 	jr z, .asm_2a3ca
-	call asm_2a3cd
+	call Function2a3cd
 	ld a, b
 	ld [RoamMon3MapGroup], a
 	ld a, c
 	ld [RoamMon3MapNumber], a
-
 .asm_2a3ca
+
 	jp Function2a3f6
 
-asm_2a3cd
+Function2a3cd: ; 2a3cd
+.asm_2a3cd
 	ld hl, $640f
 .asm_2a3d0
 	call Random
@@ -34756,7 +35148,7 @@
 	inc hl
 	ld a, [MapNumber]
 	cp [hl]
-	jr z, asm_2a3cd
+	jr z, .asm_2a3cd
 	dec hl
 
 .asm_2a3f2
@@ -41650,7 +42042,7 @@
 	jr c, .asm_44860
 	ld a, [$cfa9]
 	dec a
-	ld hl, $4861
+	ld hl, .JumpTable
 	rst JumpTable
 
 .asm_44860
@@ -71101,6 +71493,7 @@
 	ld [$c2d9], a
 	call Functionb8089
 	jr z, .asm_b8024
+
 	call GetMapPermission
 	cp $6
 	jr nz, .asm_b8029
@@ -71114,12 +71507,15 @@
 	bit 1, [hl]
 	res 1, [hl]
 	jr nz, .asm_b8054
+
 	call Functionb8064
 	jr z, .asm_b8054
+
 	ld a, [$c2d9]
 	ld [$c2d8], a
 	call Functionb8070
 	jr z, .asm_b8054
+
 	ld a, $3c
 	ld [$c2da], a
 	call Functionb80c6
@@ -71149,19 +71545,19 @@
 ; b8070
 
 Functionb8070: ; b8070
-	cp $ff
+	cp -1
 	ret z
-	cp $0
+	cp SPECIAL_MAP
 	ret z
-	cp $11
+	cp RADIO_TOWER
 	ret z
-	cp $46
+	cp LAV_RADIO_TOWER
 	ret z
-	cp $3b
+	cp UNDERGROUND
 	ret z
-	cp $5a
+	cp INDIGO_PLATEAU
 	ret z
-	cp $44
+	cp POWER_PLANT
 	ret z
 	ld a, $1
 	and a
@@ -71170,12 +71566,12 @@
 
 Functionb8089: ; b8089
 	ld a, [MapGroup]
-	cp $a
+	cp GROUP_ROUTE_35_NATIONAL_PARK_GATE
 	ret nz
 	ld a, [MapNumber]
-	cp $f
+	cp MAP_ROUTE_35_NATIONAL_PARK_GATE
 	ret z
-	cp $11
+	cp MAP_ROUTE_36_NATIONAL_PARK_GATE
 	ret
 ; b8098
 
@@ -80123,6 +80519,7 @@
 	jr .asm_fb636
 ; fb656
 
+Unknown_fb656: ; fb656
 INCBIN "baserom.gbc",$fb656,$fb6ed - $fb656
 
 
@@ -81899,7 +82296,7 @@
 Function1002dc: ; 1002dc
 	ld a, $f8
 	ld [$ff9f], a
-	callba Function15363
+	callba RunMapSetupScript
 	xor a
 	ld [$ff9f], a
 	call Functione51
@@ -84545,9 +84942,11 @@
 	jr nz, .asm_10433c
 	ret
 
+
 INCBIN "gfx/ow/misc.2bpp"
 
 
+Function1045b0: ; 1045b0
 	call Function210f
 	call Function2e50
 	call Function2e5d
@@ -84555,6 +84954,8 @@
 	call Function2e56
 	ld a, $5
 	call Function263b
+
+Function1045c4: ; 1045c4
 	callba Function97df9
 	ld a, $3
 	call Function263b
@@ -84710,7 +85111,7 @@
 	ret
 ; 1046c6
 
-
+Function1046c6: ; 1046c6
 	call Function1046df
 	call Function104718
 	ld a, [$d146]
@@ -84779,6 +85180,8 @@
 	ld a, [$d14b]
 	ld [$dcb3], a
 	ret
+
+Function104750: ; 104750
 	ld hl, VramState ; $d0ed
 	res 6, [hl]
 	ld a, $1
@@ -84847,6 +85250,8 @@
 	ld a, $0
 	ld [rVBK], a ; $ff00+$4f
 	ret
+
+Function1047cf: ; 1047cf
 	call LoadTilesetHeader
 	call Function2821
 	xor a
@@ -84863,6 +85268,7 @@
 	jp GetSGBLayout
 ; 1047f0
 
+Function1047f0: ; 1047f0
 	call ClearSprites
 	callba Functionb8000
 	call Function2914
@@ -88198,7 +88604,7 @@
 
 Function114243: ; 114243
 	ld a, $a
-	ld [$0000], a
+	ld [MBC3SRamEnable], a
 	ld a, [$ff8c]
 	push af
 	push de