ref: 1eab7959f4458dafe488997772881ac94e24da26
parent: d93d17b43b0c45d2e22bb9e3d0b0d036d2a5ff0b
author: yenatch <[email protected]>
date: Tue Sep 3 16:30:13 EDT 2013
formatting in the map engine
--- a/main.asm
+++ b/main.asm
@@ -665,28 +665,11 @@
ld a, [TilesetBlocksAddress]
add l
ld l, a
- ld a, [$d1de]
+ ld a, [TilesetBlocksAddress + 1]
adc h
ld h, a
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
- ld a, e
- add $14
- ld e, a
- jr nc, .asm_21d8
- inc d
-.asm_21d8
+rept 3
ld a, [hli]
ld [de], a
inc de
@@ -699,32 +682,15 @@
ld a, [hli]
ld [de], a
inc de
- ld a, e
- add $14
- ld e, a
- jr nc, .asm_21eb
- inc d
-.asm_21eb
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
ld a, e
- add $14
+ add 20
ld e, a
- jr nc, .asm_21fe
+ jr nc, .next\@
inc d
+.next\@
+endr
-.asm_21fe
ld a, [hli]
ld [de], a
inc de
@@ -737,6 +703,7 @@
ld a, [hli]
ld [de], a
inc de
+
pop hl
ld de, $0004
add hl, de
@@ -764,9 +731,7 @@
Function222a: ; 222a
ld a, $fa
ld [$ff9f], a
- ld a, $5
- ld hl, $5363
- rst FarCall
+ callba Function15363
xor a
ld [$ff9f], a
ret
@@ -776,9 +741,7 @@
call Function2252
ret nc
push bc
- ld a, $5
- ld hl, $49af
- rst FarCall
+ callba Function149af
pop bc
ret nc
call Function22a7
@@ -796,18 +759,18 @@
; 2252
Function2252: ; 2252
- ld a, $5
- ld hl, $499a
- rst FarCall
+ callba Function1499a
ret nc
+
ld a, [hROMBank]
push af
+
call Function2c52
call Function2266
+
pop de
ld a, d
rst Bankswitch
-
ret
; 2266
@@ -872,11 +835,12 @@
Function22a7: ; 22a7
ld a, [hROMBank]
push af
+
call Function2c52
call Function22b4
+
pop af
rst Bankswitch
-
scf
ret
; 22b4
@@ -936,16 +900,16 @@
ret
; 2300
-
Function2300: ; 2300
- cp $3
+ cp INDOOR
ret z
- cp $6
+ cp GATE
ret z
cp $5
ret
; 2309
+
Function2309: ; 2309
call Function2326
call Function2c52
@@ -964,8 +928,6 @@
ret
; 2326
-
-
Function2326: ; 2326
call Function2c3d
call Function2c1c
@@ -1021,29 +983,31 @@
ld [SouthConnectedMapGroup], a
ld [WestConnectedMapGroup], a
ld [EastConnectedMapGroup], a
+
ld a, [$d1a8]
ld b, a
+
bit 3, b
jr z, .asm_2384
- ld de, NorthConnectedMapGroup
+ ld de, NorthMapConnection
call GetMapConnection
.asm_2384
bit 2, b
jr z, .asm_238e
- ld de, SouthConnectedMapGroup
+ ld de, SouthMapConnection
call GetMapConnection
.asm_238e
bit 1, b
jr z, .asm_2398
- ld de, WestConnectedMapGroup
+ ld de, WestMapConnection
call GetMapConnection
.asm_2398
bit 0, b
jr z, .asm_23a2
- ld de, EastConnectedMapGroup
+ ld de, EastMapConnection
call GetMapConnection
.asm_23a2
@@ -1051,7 +1015,6 @@
; 23a3
-
GetMapConnection: ; 23a3
; Load map connection struct at hl into de.
ld c, SouthMapConnection - NorthMapConnection
@@ -1513,6 +1476,7 @@
ret
; 261f
+
CallScript: ; 261f
; Call a script at a:hl.
@@ -1521,10 +1485,10 @@
ld [ScriptPos], a
ld a, h
ld [ScriptPos + 1], a
-
+
ld a, $ff
ld [ScriptRunning], a
-
+
scf
ret
; 2631
@@ -1543,7 +1507,8 @@
push af
call Function2c52
call Function2653
- jr nc, .asm_2650
+ jr nc, .done
+
call GetMapEventBank
ld b, a
ld d, h
@@ -1550,10 +1515,9 @@
ld e, l
call Function2674
-.asm_2650
+.done
pop af
rst Bankswitch
-
ret
; 2653
@@ -1614,7 +1578,7 @@
push hl
call SpeechTextBox
call Function2e31
- ld a, $1
+ ld a, 1
ld [hOAMUpdate], a
call Function321c
pop hl
@@ -1628,6 +1592,8 @@
; 26b7
Function26b7: ; 26b7
+; Call a:de.
+
ld [hBuffer], a
ld a, [hROMBank]
push af
@@ -1634,14 +1600,13 @@
ld a, [hBuffer]
rst Bankswitch
- call Function26c5
+ call .de
+
pop af
rst Bankswitch
-
ret
-; 26c5
-Function26c5: ; 26c5
+.de
push de
ret
; 26c7
@@ -1654,10 +1619,10 @@
ld a, c
call Function19e9
+
pop hl
ld a, h
rst Bankswitch
-
ret
; 26d4
@@ -1667,10 +1632,8 @@
push hl
push bc
-
ld a, [hROMBank]
push af
-
ld a, [ScriptBank]
rst Bankswitch
@@ -1690,7 +1653,6 @@
pop af
rst Bankswitch
ld a, b
-
pop bc
pop hl
ret
@@ -57849,9 +57811,7 @@
ld [$d453], a
ld [$d454], a
call Function968d1
- ld a, $5
- ld hl, $5363
- rst FarCall
+ callba Function15363
call Function966cb
ld a, [$ff9f]
cp $f7