git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

commit a51b4e04ccd781699217a74f05b3ea3dac932ed0
parent 04f758bba460e8a49ed1291779f6d135814f336c
Author: Toxa <untoxa@mail.ru>
Date:   Sun,  4 Jan 2026 00:21:34 +0300

GB: fix the crash_handler

Diffstat:
Mgbdk-lib/include/gb/crash_handler.h6+++++-
Mgbdk-lib/libc/targets/sm83/ap/crash_handler.s4++--
Mgbdk-lib/libc/targets/sm83/duck/crash_handler.s4++--
Mgbdk-lib/libc/targets/sm83/gb/crash_handler.s4++--
4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/gbdk-lib/include/gb/crash_handler.h b/gbdk-lib/include/gb/crash_handler.h @@ -15,11 +15,15 @@ #ifndef __CRASH_HANDLER_INCLUDE #define __CRASH_HANDLER_INCLUDE +#include <types.h> + /** Display the crash dump screen. See the intro for this file for more details. */ void __HandleCrash(void); -static void * __CRASH_HANDLER_INIT = &__HandleCrash; +#if defined(__SDCC) +static void __CRASH_HANDLER_INIT__(void) __naked { __asm__(".globl ___HandleCrash"); } +#endif #endif diff --git a/gbdk-lib/libc/targets/sm83/ap/crash_handler.s b/gbdk-lib/libc/targets/sm83/ap/crash_handler.s @@ -48,9 +48,9 @@ ___HandleCrash:: ld a, #LCDCF_ON ; LCDCF_ON Make sure the LCD is turned on to avoid waiting infinitely ldh (.LCDC), a ld a, #IEF_VBLANK ; IEF_VBLANK - ld (.IE), a + ldh (.IE), a ld a, #0 ; `xor a` would overwrite flags - ld (.IF), a ; No point in backing up that register, it's always changing + ldh (.IF), a ; No point in backing up that register, it's always changing halt ; With interrupts disabled, this will exit when `IE & IF != 0` nop ; Handle hardware bug if it becomes true *before* starting to execute the instruction (1-cycle window) diff --git a/gbdk-lib/libc/targets/sm83/duck/crash_handler.s b/gbdk-lib/libc/targets/sm83/duck/crash_handler.s @@ -43,9 +43,9 @@ ___HandleCrash:: ld a, #LCDCF_ON ; LCDCF_ON Make sure the LCD is turned on to avoid waiting infinitely ldh (.LCDC), a ld a, #IEF_VBLANK ; IEF_VBLANK - ld (.IE), a + ldh (.IE), a ld a, #0 ; `xor a` would overwrite flags - ld (.IF), a ; No point in backing up that register, it's always changing + ldh (.IF), a ; No point in backing up that register, it's always changing halt ; With interrupts disabled, this will exit when `IE & IF != 0` nop ; Handle hardware bug if it becomes true *before* starting to execute the instruction (1-cycle window) diff --git a/gbdk-lib/libc/targets/sm83/gb/crash_handler.s b/gbdk-lib/libc/targets/sm83/gb/crash_handler.s @@ -48,9 +48,9 @@ ___HandleCrash:: ld a, #LCDCF_ON ; LCDCF_ON Make sure the LCD is turned on to avoid waiting infinitely ldh (.LCDC), a ld a, #IEF_VBLANK ; IEF_VBLANK - ld (.IE), a + ldh (.IE), a ld a, #0 ; `xor a` would overwrite flags - ld (.IF), a ; No point in backing up that register, it's always changing + ldh (.IF), a ; No point in backing up that register, it's always changing halt ; With interrupts disabled, this will exit when `IE & IF != 0` nop ; Handle hardware bug if it becomes true *before* starting to execute the instruction (1-cycle window)

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.