From b6d511be2dd6646891a47643f399e98040b0ee84 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 31 Dec 2024 16:35:49 +0100 Subject: [PATCH] map: Added basic panic handler that is called when the map ptr is NULL --- src/map.s | 7 ++++++- src/strings.s | 4 ++++ src/sys.s | 15 ++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/map.s b/src/map.s index 102469a..2558ad2 100644 --- a/src/map.s +++ b/src/map.s @@ -186,7 +186,12 @@ room_goto: ld e, a ld a, [hl] ld d, a - + + ; check if de is NULL + add a, e + cp a, 0 + call z, panic + call room_load_from ; its player's turn again diff --git a/src/strings.s b/src/strings.s index 4080d9d..6e01970 100644 --- a/src/strings.s +++ b/src/strings.s @@ -21,6 +21,10 @@ STR_MP: STR_GAME_OVER: .str "GAME OVER" +.db 0 + +STR_PANIC: +.str "PANIC" .db 0 ; print a string 0-terminated to the screen diff --git a/src/sys.s b/src/sys.s index 18314b0..c30a158 100644 --- a/src/sys.s +++ b/src/sys.s @@ -1,8 +1,21 @@ nohandler: ret + ; crashes the program + ; and displays debug information on screen panic: - ret + ; no more interrupts + call disableinterrutpts + + call next_vblank_wait + + ; print panic message + ld hl, STR_PANIC + ld de, SCRN0 + call puts + +@loop: + jp @loop enableinterrupts: ; enable interrupts -- 2.30.2