Skip to content

Out of Bounds don't Crash the Game

YakiNeen edited this page Apr 28, 2023 · 5 revisions

Awesome for Debugging.

When you exit from map's limit, it will be infinitily repeated.

CheckMapConnections in home\overworld.asm

...
; if no matching warp was found
CheckMapConnections::
.checkWestMap
	ld a, [wXCoord]
	cp $ff
	jr nz, .checkEastMap
	ld a, [wWestConnectedMap]
+	cp $ff
+	jr z, .checkEastMap
	ld [wCurMap], a
	ld a, [wWestConnectedMapXAlignment] ; new X coordinate upon entering west map
	ld [wXCoord], a
...
...
	cp b
	jr nz, .checkNorthMap
	ld a, [wEastConnectedMap]
+	cp $ff
+	jr z, .checkNorthMap
	ld [wCurMap], a
	ld a, [wEastConnectedMapXAlignment] ; new X coordinate upon entering east map
	ld [wXCoord], a
...
...
	cp $ff
	jr nz, .checkSouthMap
	ld a, [wNorthConnectedMap]
+	cp $ff
+	jr z, .checkSouthMap
	ld [wCurMap], a
	ld a, [wNorthConnectedMapYAlignment] ; new Y coordinate upon entering north map
	ld [wYCoord], a
...
...
	cp b
	jr nz, .didNotEnterConnectedMap
	ld a, [wSouthConnectedMap]
+	cp $ff
+	jr z, .didNotEnterConnectedMap
	ld [wCurMap], a
	ld a, [wSouthConnectedMapYAlignment] ; new Y coordinate upon entering south map
	ld [wYCoord], a
...
Clone this wiki locally