Skip to content

Remove the filler bytes from map scripts

Grate Oracle Lewot edited this page Jul 15, 2026 · 1 revision

First, edit home/map.asm to no longer skip over two bytes when reading map scripts:

...

ReadMapEvents::
	push af
	ld hl, wMapEventsPointer
	ld a, [hli]
	ld h, [hl]
	ld l, a
-	inc hl
-	inc hl
	call ReadWarpEvents
	call ReadCoordEvents
	call ReadBGEvents

	pop af
	and a ; skip object events?
	ret nz

	call ReadObjectEvents
	ret

...

GetWarpDestCoords::
	call GetMapScriptsBank
	rst Bankswitch

	ld hl, wMapEventsPointer
	ld a, [hli]
	ld h, [hl]
	ld l, a
-rept 3 ; get to the warp coords
-	inc hl
-endr
+	inc hl ; get to the warp coords
	ld a, [wWarpNumber]
	dec a
	ld c, a
	ld b, 0
	ld a, WARP_EVENT_SIZE
	call AddNTimes
	ld a, [hli]
	ld [wYCoord], a
	ld a, [hli]
	ld [wXCoord], a
	; destination warp number
	ld a, [hli]
	cp -1
	jr nz, .skip
	call .backup

.skip
	farcall GetMapScreenCoords
	ret

.backup
	ld a, [wPrevWarp]
	ld [wBackupWarpNumber], a
	ld a, [wPrevMapGroup]
	ld [wBackupMapGroup], a
	ld a, [wPrevMapNumber]
	ld [wBackupMapNumber], a
	ret

...

This allows you to remove the two filler bytes in each map script, seen as db 0, 0 ; filler after its *_MapEvents:, like this example from Azalea Gym:

...

AzaleaGym_MapEvents:
-	db 0, 0 ; filler
-
	def_warp_events
	warp_event  4, 15, AZALEA_TOWN, 5
	warp_event  5, 15, AZALEA_TOWN, 5

	...

You'll have to do this for EVERY map script.

Anyone who understands Python, feel free to edit this tutorial to provide a script that will do that automatically.

You've now freed up 2 bytes per map, which is a decent chunk of space overall. If you don't need that space, then there's no real reason to do this, but if you're adding a lot of content, you'll find out quickly that every byte counts.

Clone this wiki locally