summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL.md14
-rw-r--r--Makefile9
-rw-r--r--constants.asm4
-rwxr-xr-xengine/events/overworld.asm6
-rwxr-xr-xengine/items/item_effects.asm14
-rwxr-xr-xengine/items/items.asm6
-rwxr-xr-xengine/items/pack.asm12
-rw-r--r--engine/menus/intro_menu.asm2
-rw-r--r--engine/menus/naming_screen.asm8
-rwxr-xr-xengine/movement_pattern.asm2
-rwxr-xr-xengine/overworld/map_object_action.asm2
-rwxr-xr-xengine/overworld/map_objects.asm12
-rwxr-xr-xengine/overworld/movement.asm8
-rwxr-xr-xengine/overworld/npc_movement.asm4
-rwxr-xr-xengine/overworld/player_object.asm4
-rwxr-xr-xengine/overworld/time.asm8
-rw-r--r--engine/pokemon/bills_pc_top.asm2
-rw-r--r--gfx/pics_gold.asm2
-rw-r--r--gfx/pics_silver.asm2
-rw-r--r--gfx/tileset_palette_maps.asm4
-rwxr-xr-xhome/header.asm20
-rw-r--r--home/init.asm2
-rw-r--r--home/text.asm2
-rwxr-xr-xmacros/coords.asm3
-rwxr-xr-xmacros/data.asm8
-rwxr-xr-xmacros/gfx.asm4
-rw-r--r--macros/legacy.asm2
-rwxr-xr-xmacros/rst.asm4
-rw-r--r--maps/EcruteakTinTowerEntrance.asm2
-rwxr-xr-xpredef/cgb.asm4
-rwxr-xr-xtools/sort_symfile.sh14
-rwxr-xr-xtools/unnamed.py114
32 files changed, 199 insertions, 105 deletions
diff --git a/INSTALL.md b/INSTALL.md
index b400b370..33d2dd0e 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -40,7 +40,7 @@ Double click on the text that says "**Skip**" next to each package to select the
Then download [**rgbds**](https://github.com/rednex/rgbds/releases/): the latest **win64.zip** or **win32.zip** release. Extract it and put all the `exe` and `dll` files individually in **C:\cygwin64\usr\local\bin**.
-**Note: If you already have an older rgbds, you will need to update to 0.3.10.** Ignore this if you have never installed rgbds before. If a version newer than 0.3.10 does not work, try downloading 0.3.10.
+**Note: If you already have an older rgbds, you will need to update to 0.4.0.** Ignore this if you have never installed rgbds before. If a version newer than 0.4.0 does not work, try downloading 0.4.0.
Now open the **Cygwin terminal** and enter the following commands.
@@ -86,8 +86,8 @@ To install **rgbds**:
```bash
sudo apt-get install pkg-config flex bison libpng-dev
-git clone -b v0.3.10 --depth=1 https://github.com/rednex/rgbds
-sudo make -C rgbds CFLAGS=-O2 install
+git clone -b v0.4.0 --depth=1 https://github.com/rednex/rgbds
+sudo make -C rgbds install
```
### OpenSUSE
@@ -102,8 +102,8 @@ To install **rgbds**:
```bash
sudo zypper install pkg-config flex bison libpng16-devel
-git clone -b v0.3.10 --depth=1 https://github.com/rednex/rgbds
-sudo make -C rgbds CFLAGS=-O2 install
+git clone -b v0.4.0 --depth=1 https://github.com/rednex/rgbds
+sudo make -C rgbds install
```
### Other distros
@@ -125,8 +125,8 @@ If `rgbds` is not available, you'll also need these:
To install **rgbds**:
```bash
-git clone -b v0.3.10 --depth=1 https://github.com/rednex/rgbds
-sudo make -C rgbds CFLAGS=-O2 install
+git clone -b v0.4.0 --depth=1 https://github.com/rednex/rgbds
+sudo make -C rgbds install
```
Now you're ready to [build **pokegold**](#build-pokegold).
diff --git a/Makefile b/Makefile
index a36266a3..042afa5c 100644
--- a/Makefile
+++ b/Makefile
@@ -63,15 +63,16 @@ tools:
$(MAKE) -C tools/
-$(gold_obj): RGBASMFLAGS = -D _GOLD
-$(silver_obj): RGBASMFLAGS = -D _SILVER
+RGBASMFLAGS = -L -Weverything
+$(gold_obj): RGBASMFLAGS += -D _GOLD
+$(silver_obj): RGBASMFLAGS += -D _SILVER
# The dep rules have to be explicit or else missing files won't be reported.
# As a side effect, they're evaluated immediately instead of when the rule is invoked.
# It doesn't look like $(shell) can be deferred so there might not be a better way.
define DEP
$1: $2 $$(shell tools/scan_includes $2)
- $$(RGBASM) $$(RGBASMFLAGS) -L -o $$@ $$<
+ $$(RGBASM) $$(RGBASMFLAGS) -o $$@ $$<
endef
# Build tools when building the rom.
@@ -95,12 +96,10 @@ endif
pokegold.gbc: $(gold_obj) pokegold.link
$(RGBLINK) -n pokegold.sym -m pokegold.map -l pokegold.link -o $@ $(gold_obj)
$(RGBFIX) -cjsv -i AAUE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t "POKEMON_GLD" $@
- tools/sort_symfile.sh pokegold.sym
pokesilver.gbc: $(silver_obj) pokesilver.link
$(RGBLINK) -n pokesilver.sym -m pokesilver.map -l pokesilver.link -o $@ $(silver_obj)
$(RGBFIX) -cjsv -i AAXE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t "POKEMON_SLV" $@
- tools/sort_symfile.sh pokesilver.sym
pngs:
find gfx -iname "*.lz" -exec $(gfx) unlz {} +
diff --git a/constants.asm b/constants.asm
index fe23415c..7b64627d 100644
--- a/constants.asm
+++ b/constants.asm
@@ -1,3 +1,7 @@
+if __RGBDS_MAJOR__ <= 0 && __RGBDS_MINOR__ < 4
+ fail "pokegold requires rgbds 0.4.0 or newer."
+endc
+
INCLUDE "charmap.asm"
INCLUDE "macros.asm"
diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm
index 2ec6d857..086587b2 100755
--- a/engine/events/overworld.asm
+++ b/engine/events/overworld.asm
@@ -721,7 +721,7 @@ EscapeRopeFunction:
DigFunction:
call FieldMoveBufferReset
ld a, $2
-asm_cbaa
+asm_cbaa:
ld [wBuffer2], a
.asm_cbad
ld hl, .Jumptable
@@ -943,11 +943,11 @@ Text_AlreadyUsingStrength:
text_far Text_AlreadyUsingStrength_
db "@"
-asm_cd09
+asm_cd09:
ld a, $80
ret
-asm_cd0c
+asm_cd0c:
ld hl, Script_StrengthFromMenu
call QueueScript
ld a, $81
diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm
index e270734d..cb441179 100755
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -1509,7 +1509,7 @@ Energypowder: ; f1e2 (3:71e2)
EnergyRoot: ; f1e6 (3:71e6)
ld c, $10
-asm_f1e8
+asm_f1e8:
push bc
call Functionf1ff
pop bc
@@ -1671,7 +1671,7 @@ Functionf310: ; f310 (3:7310)
Functionf319: ; f319 (3:7319)
call GetCurHPAnimMaxHP
-asm_f31c
+asm_f31c:
ld a, MON_HP
call GetPartyParamLocation
ld [hl], d
@@ -1950,7 +1950,7 @@ MaxRepel: ; f4bc (3:74bc)
Repel: ; f4c0 (3:74c0)
ld b, 100
-asm_f4c2
+asm_f4c2:
ld a, [wRepelSteps]
and a
ld hl, Text_RepelsEffectsStillLinger
@@ -2226,11 +2226,11 @@ PPUp: ; f606 (3:7606)
call Functionf7c7
ld hl, Text_PPsIncreased ; $777b
call PrintText
-asm_f693
+asm_f693:
call ClearPalettes
jp Functionf7dc
-asm_f699
+asm_f699:
ld a, [wBattleMode]
and a
jr z, .asm_f6b3
@@ -2412,7 +2412,7 @@ NormalBox: ; f7aa (3:77aa)
GorgeousBox: ; f7ae (3:77ae)
ld c, DECOFLAG_GOLD_TROPHY_DOLL
-asm_f7b0
+asm_f7b0:
farcall ReceiveDecorationC ; 9:70d5
ld hl, Text_TrophyInside ; $77bf
call PrintText
@@ -2591,7 +2591,7 @@ Functionf843:
Functionf848:
ld hl, Text_CantGetOnYourItemNow
-asm_f84b
+asm_f84b:
xor a
ld [wFieldMoveSucceeded], a
jp PrintText
diff --git a/engine/items/items.asm b/engine/items/items.asm
index 428f652e..7cd1de67 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -76,7 +76,7 @@ RemoveKeyItem:
RemoveNormalItem:
ld h, d
ld l, e
-remove_item_from_bag_or_pc
+remove_item_from_bag_or_pc:
jp RemoveItemAndQuantity
_CheckItem:: ; d251 (3:5251)
@@ -117,7 +117,7 @@ CheckKeyItem:
CheckNormalItem:
ld h, d
ld l, e
-check_item_in_bag_or_pc
+check_item_in_bag_or_pc:
jp CheckItemWithQuantity
CheckBagOrPC: ; d288 (3:5288)
@@ -531,7 +531,7 @@ GetItemAttr: ; d46d (3:546d)
pop hl
ret
-ItemAttr_ReturnCarry
+ItemAttr_ReturnCarry:
ld a, $1
ld [wItemAttributeParamBuffer], a
scf
diff --git a/engine/items/pack.asm b/engine/items/pack.asm
index 1f2d533d..8edd2555 100755
--- a/engine/items/pack.asm
+++ b/engine/items/pack.asm
@@ -866,23 +866,23 @@ Function10a86:
call Function10e5b
ret
-asm_10a9c
+asm_10a9c:
call ClearBGPalettes
jr asm_10aae
-Function10aa1
+Function10aa1:
call DoItemEffect
ld a, [wFieldMoveSucceeded]
and a
jr z, Function10a75
cp $2
jr z, asm_10ab4
-asm_10aae
+asm_10aae:
ld a, $a
ld [wce63], a
ret
-asm_10ab4
+asm_10ab4:
xor a
ld [wFieldMoveSucceeded], a
ret
@@ -918,7 +918,7 @@ DepositSellInitPackBuffers: ; 10ad5 (4:4ad5)
call Function10e5b
ret
-DepositSellPack
+DepositSellPack:
.loop
call Function10af7
call Function10b9f
@@ -1152,7 +1152,7 @@ TutorialBallsMenuDataHeader:
dba PlaceMenuItemQuantity
dba UpdateItemDescription
-asm_10c8a
+asm_10c8a:
push hl
call Function10b92
pop hl
diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm
index 40feb4ad..b9d0d316 100644
--- a/engine/menus/intro_menu.asm
+++ b/engine/menus/intro_menu.asm
@@ -979,7 +979,7 @@ MovePlayerPicRight: ; 617e (1:617e)
MovePlayerPicLeft: ; 6186 (1:6186)
hlcoord 13, 4
ld de, -1
-MovePlayerPic
+MovePlayerPic:
ld c, $8
.asm_618e
push bc
diff --git a/engine/menus/naming_screen.asm b/engine/menus/naming_screen.asm
index 2101cf84..d5b35a8e 100644
--- a/engine/menus/naming_screen.asm
+++ b/engine/menus/naming_screen.asm
@@ -208,7 +208,7 @@ Function11c48: ; 11c48 (4:5c48)
hlcoord 5, 4
jr asm_11c4f
-asm_11c4f
+asm_11c4f:
ld [wc5d3], a
ld a, l
ld [wc5d8], a
@@ -648,10 +648,10 @@ Function11ee4: ; 11ee4 (4:5ee4)
cp c
ret nc
ld a, [wc5d7]
-asm_11ef0
+asm_11ef0:
call Function11f9d
ld [hl], a
-asm_11ef4
+asm_11ef4:
ld hl, wc5d2
inc [hl]
call Function11f9d
@@ -666,7 +666,7 @@ asm_11ef4
scf
ret
-asm_11f06
+asm_11f06:
ld a, [wc5d2]
and a
ret z
diff --git a/engine/movement_pattern.asm b/engine/movement_pattern.asm
index 1909f480..29d09229 100755
--- a/engine/movement_pattern.asm
+++ b/engine/movement_pattern.asm
@@ -635,7 +635,7 @@ Function4aff: ; 4aff (1:4aff)
call Random
ldh a, [hRandomAdd]
and $1f
-asm_4b06
+asm_4b06:
ld hl, $a
add hl, bc
ld [hl], a
diff --git a/engine/overworld/map_object_action.asm b/engine/overworld/map_object_action.asm
index 553243c4..f895fe15 100755
--- a/engine/overworld/map_object_action.asm
+++ b/engine/overworld/map_object_action.asm
@@ -30,7 +30,7 @@ Pointers4460:
dw Function45b3, Function44a0
dw Function45c6, Function44a0
-Function44a0
+Function44a0:
ld hl, $d
add hl, bc
ld [hl], $ff
diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm
index 392cb86e..87f422d5 100755
--- a/engine/overworld/map_objects.asm
+++ b/engine/overworld/map_objects.asm
@@ -152,18 +152,18 @@ Function437c:
bit 5, [hl]
jr nz, asm_4449
ld de, Pointers4460
- jr asm_444e
+ jr _HandleObjectAction
Function4441:
ld hl, $4
add hl, bc
bit 0, [hl]
jr nz, Function44a0
-asm_4449
+asm_4449:
ld de, Pointers4460 + 2
- jr asm_444e
+ jr _HandleObjectAction
-asm_444e
+_HandleObjectAction:
INCLUDE "engine/overworld/map_object_action.asm"
CopyNextCoordsTileToStandingCoordsTile: ; 45d9 (1:45d9)
@@ -662,7 +662,7 @@ Function557f:: ; 557f (1:557f)
jr nz, .asm_5589
ret
-Function55a1
+Function55a1:
call Function55d8
ld a, $0
call Function55bc
@@ -962,7 +962,7 @@ Function5761: ; 5761 (1:5761)
Function5770: ; 5770 (1:5770)
ld a, $0
-asm_5772
+asm_5772:
ld bc, wObjectStructs
call SetSpriteDirection
ret
diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm
index d98b47ee..39f99480 100755
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -35,7 +35,7 @@ Function4fdf: ; 4fdf (1:4fdf)
ld hl, GetMovementPerson
jp Function4fe9
-GetMovementPerson
+GetMovementPerson:
ld a, [wMovementObject]
ret
@@ -358,7 +358,7 @@ Function51e1: ; 51e1 (1:51e1)
call Function5006
jr asm_51e6
-asm_51e6
+asm_51e6:
ld hl, $a
add hl, bc
ld [hl], a
@@ -470,7 +470,7 @@ Function5289: ; 5289 (1:5289)
ld a, $c
jr asm_528d
-asm_528d
+asm_528d:
ld hl, $8
add hl, bc
ld [hl], a
@@ -690,7 +690,7 @@ Function539b: ; 539b (1:539b)
ld a, $c
jr asm_539f
-asm_539f
+asm_539f:
ld hl, $1d
add hl, bc
ld [hl], a
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index 84235570..38fe15d0 100755
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -84,7 +84,7 @@ Function700b: ; 700b (1:700b)
scf
ret
-Function701d
+Function701d:
ld hl, $e
add hl, bc
ld a, [hl]
@@ -437,7 +437,7 @@ IsPersonMovingOffEdgeOfScreen: ; 71cc (1:71cc)
scf
ret
-Function71f2
+Function71f2:
ld a, [wPlayerStandingMapX]
ld d, a
ld a, [wPlayerStandingMapY]
diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm
index 26dbe9fd..5cde13e7 100755
--- a/engine/overworld/player_object.asm
+++ b/engine/overworld/player_object.asm
@@ -282,7 +282,7 @@ Function87ce:
Function87d5:
ld a, [wYCoord]
add $9
-asm_87da
+asm_87da:
ld d, a
ld a, [wXCoord]
ld e, a
@@ -337,7 +337,7 @@ Function8822:
Function8829:
ld a, [wXCoord]
add $a
-asm_882e
+asm_882e:
ld e, a
ld a, [wYCoord]
ld d, a
diff --git a/engine/overworld/time.asm b/engine/overworld/time.asm
index 01273a75..9cce323c 100755
--- a/engine/overworld/time.asm
+++ b/engine/overworld/time.asm
@@ -78,7 +78,7 @@ Function11857: ; 11857 (4:5857)
call Function11972
ret
-asm_11867
+asm_11867:
ld hl, wDailyResetTimer
jp Function1182e
@@ -282,7 +282,7 @@ Function119b4: ; 119b4 (4:59b4)
ld a, [wDaysSince]
ret
-asm_119b8
+asm_119b8:
ld a, $ff
ret
@@ -314,7 +314,7 @@ CalcSecsMinsHoursDaysSince: ; 119c7 (4:59c7)
ld [hl], c
dec hl
ld [wSecsSince], a
-CalcMinsHoursDaysSince_
+CalcMinsHoursDaysSince_:
ldh a, [hMinutes]
ld c, a
sbc [hl]
@@ -324,7 +324,7 @@ CalcMinsHoursDaysSince_
ld [hl], c
dec hl
ld [wMinsSince], a
-CalcHoursDaysSince_
+CalcHoursDaysSince_:
ldh a, [hHours]
ld c, a
sbc [hl]
diff --git a/engine/pokemon/bills_pc_top.asm b/engine/pokemon/bills_pc_top.asm
index 749718db..0ad87023 100644
--- a/engine/pokemon/bills_pc_top.asm
+++ b/engine/pokemon/bills_pc_top.asm
@@ -243,7 +243,7 @@ Functione566: ; e566 (3:6566)
call SetPalettes
ret
-CopyBoxmonToTempMon
+CopyBoxmonToTempMon:
ld a, [wCurPartyMon]
ld hl, sBoxMon1Species
ld bc, $20
diff --git a/gfx/pics_gold.asm b/gfx/pics_gold.asm
index 2a4b93c2..2fe86495 100644
--- a/gfx/pics_gold.asm
+++ b/gfx/pics_gold.asm
@@ -2,7 +2,7 @@ INCLUDE "constants.asm"
; PokemonPicPointers and UnownPicPointers are assumed to start at the same
-; address, but in different banks. This is enforced in pokecrystal.link.
+; address, but in different banks. This is enforced in pokegold.link.
SECTION "Pic Pointers", ROMX
diff --git a/gfx/pics_silver.asm b/gfx/pics_silver.asm
index c6d29f6c..8635699b 100644
--- a/gfx/pics_silver.asm
+++ b/gfx/pics_silver.asm
@@ -2,7 +2,7 @@ INCLUDE "constants.asm"
; PokemonPicPointers and UnownPicPointers are assumed to start at the same
-; address, but in different banks. This is enforced in pokecrystal.link.
+; address, but in different banks. This is enforced in pokesilver.link.
SECTION "Pic Pointers", ROMX
diff --git a/gfx/tileset_palette_maps.asm b/gfx/tileset_palette_maps.asm
index e814fbae..0398f29f 100644
--- a/gfx/tileset_palette_maps.asm
+++ b/gfx/tileset_palette_maps.asm
@@ -1,6 +1,4 @@
INCLUDE "gfx/tilesets/palette_maps.asm"
Unknown85d7:
- rept 26 ; NUM_MAP_GROUPS
- db PAL_BG_ROOF
- endr
+ ds 26, PAL_BG_ROOF
diff --git a/home/header.asm b/home/header.asm
index b1d30d02..75b43056 100755
--- a/home/header.asm
+++ b/home/header.asm
@@ -4,10 +4,12 @@ SECTION "rst0", ROM0[$0000]
di
jp Start
-SECTION "rst8", ROM0[$0008] ; rst FarCall
+SECTION "rst8", ROM0[$0008]
+FarCall::
jp FarCall_hl
-SECTION "rst10", ROM0[$0010] ; rst Bankswitch
+SECTION "rst10", ROM0[$0010]
+Bankswitch::
ldh [hROMBank], a
ld [MBC3RomBank], a
ret
@@ -18,7 +20,8 @@ SECTION "rst18", ROM0[$0018]
SECTION "rst20", ROM0[$0020]
rst $38
-SECTION "rst28", ROM0[$0028] ; rst JumpTable
+SECTION "rst28", ROM0[$0028]
+JumpTable::
push de
ld e, a
ld d, 0
@@ -53,14 +56,15 @@ SECTION "joypad", ROM0[$0060]
jp Joypad
-; Game Boy cartridge header
-
SECTION "Header", ROM0[$0100]
Start::
+; Nintendo requires all Game Boy ROMs to begin with a nop ($00) and a jp ($C3)
+; to the starting address.
nop
jp _Start
-; The cartridge header data is filled in by rgbfix.
-; This makes sure it doesn't get used.
- ds $0150 - $0104
+; The Game Boy cartridge header data is patched over by rgbfix.
+; This makes sure it doesn't get used for anything else.
+
+ ds $0150 - @, $00
diff --git a/home/init.asm b/home/init.asm
index a1e95d16..e82e4929 100644
--- a/home/init.asm
+++ b/home/init.asm
@@ -163,7 +163,7 @@ BlankBGMap::
FillBGMap::
ld a, l
-asm_69e
+asm_69e:
ld de, $400
ld l, e
.loop
diff --git a/home/text.asm b/home/text.asm
index 1480dd92..628bc0f6 100644
--- a/home/text.asm
+++ b/home/text.asm
@@ -812,7 +812,7 @@ Text_TX_SFX:: ; 1380 (0:1380)
pop bc
ret
-Text_TX_CRY
+Text_TX_CRY::
push de
ld e, [hl]
inc hl
diff --git a/macros/coords.asm b/macros/coords.asm
index 0fbf96cc..3ea6e415 100755
--- a/macros/coords.asm
+++ b/macros/coords.asm
@@ -28,8 +28,7 @@ dwcoord: MACRO
; x, y
rept _NARG / 2
dw (\2) * SCREEN_WIDTH + (\1) + wTilemap
- shift
- shift
+ shift 2
endr
ENDM
diff --git a/macros/data.asm b/macros/data.asm
index c0ada7f7..b9b4b0a9 100755
--- a/macros/data.asm
+++ b/macros/data.asm
@@ -32,18 +32,14 @@ ENDM
dn: MACRO ; nybbles
rept _NARG / 2
db ((\1) << 4) | (\2)
- shift
- shift
+ shift 2
endr
ENDM
dc: MACRO ; "crumbs"
rept _NARG / 4
db ((\1) << 6) | ((\2) << 4) | ((\3) << 2) | (\4)
- shift
- shift
- shift
- shift
+ shift 4
endr
ENDM
diff --git a/macros/gfx.asm b/macros/gfx.asm
index 2753373e..24c79e1f 100755
--- a/macros/gfx.asm
+++ b/macros/gfx.asm
@@ -1,9 +1,7 @@
RGB: MACRO
rept _NARG / 3
dw palred (\1) + palgreen (\2) + palblue (\3)
- shift
- shift
- shift
+ shift 3
endr
ENDM
diff --git a/macros/legacy.asm b/macros/legacy.asm
index 6234b834..ff6bf7c9 100644
--- a/macros/legacy.asm
+++ b/macros/legacy.asm
@@ -1,4 +1,4 @@
-; Legacy support for old pokecrystal.
+; Legacy support for old pokecrystal/pokegold.
; Allows porting scripts with as few edits as possible.
; Legacy support not in this file can be found by looking for the keyword: "LEGACY"
diff --git a/macros/rst.asm b/macros/rst.asm
index 773a5c60..c8b80aab 100755
--- a/macros/rst.asm
+++ b/macros/rst.asm
@@ -1,7 +1,3 @@
-FarCall EQU $08
-Bankswitch EQU $10
-JumpTable EQU $28
-
farcall: MACRO ; bank, address
ld a, BANK(\1)
ld hl, \1
diff --git a/maps/EcruteakTinTowerEntrance.asm b/maps/EcruteakTinTowerEntrance.asm
index f7a61d88..c775d6ac 100644
--- a/maps/EcruteakTinTowerEntrance.asm
+++ b/maps/EcruteakTinTowerEntrance.asm
@@ -40,7 +40,7 @@ EcruteakTinTowerEntrance_CoordEvent2:
EcruteakTinTowerEntrance_CoordEventEmpty:
end
-EcruteakTinTowerEntranceSageScript
+EcruteakTinTowerEntranceSageScript:
faceplayer
opentext
checkflag ENGINE_FOGBADGE
diff --git a/predef/cgb.asm b/predef/cgb.asm
index bd822607..cbc8d203 100755
--- a/predef/cgb.asm
+++ b/predef/cgb.asm
@@ -110,7 +110,7 @@ Function9399: ; 9399 (2:5399)
ld a, $1
ld [wColorLayoutPredefID], a
call Function9b28
-asm_93e1
+asm_93e1:
ld hl, TilesetBGPalette + 7 * 8
ld de, wTempBGPal7
ld bc, $8
@@ -327,7 +327,7 @@ Function95a8:
ld bc, wTempMonDVs
call Function9bcb
call Function9adb
-asm_95b1
+asm_95b1:
call Function9b1d
hlcoord 1, 1, wAttrmap
lb bc, 7, 7
diff --git a/tools/sort_symfile.sh b/tools/sort_symfile.sh
deleted file mode 100755
index a712b97c..00000000
--- a/tools/sort_symfile.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-TEMP_FILE=$(mktemp)
-sed \
- -e "s/^..:[0-3]/0_ROM0@&/g" \
- -e "s/^..:[4-7]/1_ROMX@&/g" \
- -e "s/^..:[8-9]/2_VRAM@&/g" \
- -e "s/^..:[A-Ba-b]/3_SRAM@&/g" \
- -e "s/^00:[C-Dc-d]/4_WRAM0@&/g" \
- -e "s/^..:[D-Dd-d]/5_WRAMX@&/g" \
- -e "s/^..:[F-Ff-f]/6_HRAM@&/g" \
- $1 \
-| sort \
-| sed -e "s/^.*@//g" > $TEMP_FILE
-mv $TEMP_FILE $1
diff --git a/tools/unnamed.py b/tools/unnamed.py
new file mode 100755
index 00000000..1c66a36d
--- /dev/null
+++ b/tools/unnamed.py
@@ -0,0 +1,114 @@
+#!/usr/bin/env python3
+
+import os, re
+from sys import stderr, exit
+from subprocess import Popen, PIPE
+from struct import unpack, calcsize
+from enum import Enum
+
+class symtype(Enum):
+ LOCAL = 0
+ IMPORT = 1
+ EXPORT = 2
+
+def unpack_file(fmt, file):
+ size = calcsize(fmt)
+ return unpack(fmt, file.read(size))
+
+def read_string(file):
+ buf = bytearray()
+ while True:
+ b = file.read(1)
+ if b is None or b == b'\0':
+ return buf.decode()
+ else:
+ buf += b
+
+
+# Fix broken pipe when using `head`
+from signal import signal, SIGPIPE, SIG_DFL
+signal(SIGPIPE,SIG_DFL)
+
+import argparse
+parser = argparse.ArgumentParser(description="Parse the symfile to find unnamed symbols")
+parser.add_argument('symfile', type=str, help="the filename with the list of symbols")
+parser.add_argument('-r', '--rootdir', type=str, help="scan the output files to obtain a list of files with unnamed symbols (NOTE: will rebuild objects as necessary)")
+args = parser.parse_args()
+
+# Get list of object files
+objects = None
+obj_suffix = '_obj := '
+m = re.match('poke(.*)\.sym', args.symfile)
+sym_game = m.group(1)
+def match_obj(game, line):
+ return (sym_game == game) and line.startswith(game + obj_suffix)
+if args.rootdir:
+ for line in Popen(["make", "-C", args.rootdir, "-s", "-p"],
+ stdout=PIPE).stdout.read().decode().split("\n"):
+ if match_obj('gold', line) or match_obj('silver', line):
+ offset = len(sym_game) + len(obj_suffix)
+ objects = line[offset:].strip().split()
+ break
+
+ else:
+ print("Error: Object files not found!", file=stderr)
+ exit(1)
+
+# Scan all unnamed symbols from the symfile
+symbols_total = 0
+symbols = set()
+for line in open(args.symfile, 'r'):
+ line = line.split(";")[0].strip()
+ split = line.split(" ")
+ if len(split) < 2:
+ continue
+
+ symbols_total += 1
+
+ symbol = " ".join(split[1:]).strip()
+ if symbol[-3:].lower() == split[0][-3:].lower():
+ symbols.add(symbol)
+
+# If no object files were provided, just print what we know and exit
+print("Unnamed symbols: %d (%.2f%% complete)" % (len(symbols),
+ (symbols_total - len(symbols)) / symbols_total * 100))
+if not objects:
+ for sym in symbols:
+ print(sym)
+ exit()
+
+# Count the amount of symbols in each file
+files = {}
+for objfile in objects:
+ f = open(objfile, "rb")
+ obj_ver = None
+
+ magic = unpack_file("4s", f)[0]
+ if magic == b'RGB6':
+ obj_ver = 6
+ elif magic == b'RGB9':
+ obj_ver = 10 + unpack_file("<I", f)[0]
+
+ if obj_ver not in [6, 10, 11, 12, 13]:
+ print("Error: File '%s' is of an unknown format." % objfile, file=stderr)
+ exit(1)
+
+ num_symbols = unpack_file("<II", f)[0]
+ for x in range(num_symbols):
+ sym_name = read_string(f)
+ sym_type = symtype(unpack_file("<B", f)[0] & 0x7f)
+ if sym_type == symtype.IMPORT:
+ continue
+ sym_filename = read_string(f)
+ unpack_file("<III", f)
+ if sym_name not in symbols:
+ continue
+
+ if sym_filename not in files:
+ files[sym_filename] = 0
+ files[sym_filename] += 1
+
+# Sort the files, the one with the most amount of symbols first
+files = sorted([(fname, files[fname]) for fname in files], key=lambda x: x[1], reverse=True)
+for f in files:
+ print("%s: %d" % (f[0], f[1]))