gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 3e7ce5d54b38681f8b3411f5e480f47288473de7 parent 5f8c5a6ec0aad2f78757b6d23df7df739d6cf920 Author: Toxa <untoxa@mail.ru> Date: Sun, 7 Sep 2025 01:00:20 +0300 GB: ability to dynamically allocate variables in HRAM on the SM83 targets Diffstat:
| M | gbdk-lib/libc/targets/sm83/ap/crt0.s | 18 | +++++++++++------- |
| M | gbdk-lib/libc/targets/sm83/duck/crt0.s | 18 | +++++++++++------- |
| M | gbdk-lib/libc/targets/sm83/gb/crt0.s | 18 | +++++++++++------- |
| M | gbdk-support/lcc/targets.c | 2 | +- |
4 files changed, 34 insertions(+), 22 deletions(-)
diff --git a/gbdk-lib/libc/targets/sm83/ap/crt0.s b/gbdk-lib/libc/targets/sm83/ap/crt0.s @@ -103,7 +103,7 @@ __standard_VBL_handler:: _refresh_OAM:: WAIT_STAT LD A, #>_shadow_OAM - JP .refresh_OAM + (.refresh_OAM_DMA - .start_refresh_OAM) + JP .refresh_OAM_DMA .clear_WRAM: XOR A @@ -132,7 +132,7 @@ _set_interrupts:: LDH A,(__shadow_OAM_base) OR A RET Z -.refresh_OAM_DMA: +.start_refresh_OAM_DMA: LDH (.DMA),A ; Put A into DMA registers LD A,#0x28 ; We need to wait 160 ns 1$: @@ -404,6 +404,8 @@ _add_VBL:: ;; For malloc .area _HEAP .area _HEAP_END + ;; High RAM area + .area _HRAM .area _DATA __cpu:: @@ -418,11 +420,13 @@ _sys_time:: .int_0x40:: .blkw 0x06 ; 5 interrupt handlers: 1 built-in + 4 user-defined - .area _HRAM (ABS) - - .org 0xFF90 -__current_bank:: ; Current bank - .ds 0x01 + .area _HRAM +.refresh_OAM:: + .ds (.start_refresh_OAM_DMA - .start_refresh_OAM) +.refresh_OAM_DMA: + .ds (.end_refresh_OAM - .start_refresh_OAM_DMA) +__current_bank:: + .ds 0x01 ; Current bank .vbl_done: __vbl_done:: .ds 0x01 ; Is VBL interrupt finished? diff --git a/gbdk-lib/libc/targets/sm83/duck/crt0.s b/gbdk-lib/libc/targets/sm83/duck/crt0.s @@ -104,7 +104,7 @@ __standard_VBL_handler:: _refresh_OAM:: WAIT_STAT LD A, #>_shadow_OAM - JP .refresh_OAM + (.refresh_OAM_DMA - .start_refresh_OAM) + JP .refresh_OAM_DMA .clear_WRAM: XOR A @@ -133,7 +133,7 @@ _set_interrupts:: LDH A,(__shadow_OAM_base) OR A RET Z -.refresh_OAM_DMA: +.start_refresh_OAM_DMA: LDH (.DMA),A ; Put A into DMA registers LD A,#0x28 ; We need to wait 160 ns 1$: @@ -346,6 +346,8 @@ _add_VBL:: ;; For malloc .area _HEAP .area _HEAP_END + ;; High RAM area + .area _HRAM .area _DATA __cpu:: @@ -360,11 +362,13 @@ _sys_time:: .int_0x40:: .blkw 0x06 ; 5 interrupt handlers: 1 built-in + 4 user-defined - .area _HRAM (ABS) - - .org 0xFF90 -__current_bank:: ; Current bank - .ds 0x01 + .area _HRAM +.refresh_OAM:: + .ds (.start_refresh_OAM_DMA - .start_refresh_OAM) +.refresh_OAM_DMA: + .ds (.end_refresh_OAM - .start_refresh_OAM_DMA) +__current_bank:: + .ds 0x01 ; Current bank .vbl_done: __vbl_done:: .ds 0x01 ; Is VBL interrupt finished? diff --git a/gbdk-lib/libc/targets/sm83/gb/crt0.s b/gbdk-lib/libc/targets/sm83/gb/crt0.s @@ -103,7 +103,7 @@ __standard_VBL_handler:: _refresh_OAM:: WAIT_STAT LD A, #>_shadow_OAM - JP .refresh_OAM + (.refresh_OAM_DMA - .start_refresh_OAM) + JP .refresh_OAM_DMA .clear_WRAM: XOR A @@ -132,7 +132,7 @@ _set_interrupts:: LDH A,(__shadow_OAM_base) OR A RET Z -.refresh_OAM_DMA: +.start_refresh_OAM_DMA: LDH (.DMA),A ; Put A into DMA registers LD A,#0x28 ; We need to wait 160 ns 1$: @@ -410,6 +410,8 @@ _add_VBL:: ;; For malloc .area _HEAP .area _HEAP_END + ;; High RAM area + .area _HRAM .area _DATA .start_crt_globals: @@ -428,11 +430,13 @@ _sys_time:: .end_crt_globals: - .area _HRAM (ABS) - - .org 0xFF90 -__current_bank:: ; Current bank - .ds 0x01 + .area _HRAM +.refresh_OAM:: + .ds (.start_refresh_OAM_DMA - .start_refresh_OAM) +.refresh_OAM_DMA: + .ds (.end_refresh_OAM - .start_refresh_OAM_DMA) +__current_bank:: + .ds 0x01 ; Current bank .vbl_done: __vbl_done:: .ds 0x01 ; Is VBL interrupt finished? diff --git a/gbdk-support/lcc/targets.c b/gbdk-support/lcc/targets.c @@ -13,9 +13,9 @@ arg_entry llist0_defaults_gb[] = { {.searchkey= "_shadow_OAM=", .addflag= "-g",.addvalue= "_shadow_OAM=0xC000", .found= false}, {.searchkey= ".STACK=", .addflag= "-g",.addvalue= ".STACK=0xE000", .found= false}, - {.searchkey= ".refresh_OAM=",.addflag= "-g",.addvalue= ".refresh_OAM=0xFF80",.found= false}, {.searchkey= "_DATA=", .addflag= "-b",.addvalue= "_DATA=0xC0A0", .found= false}, {.searchkey= "_CODE=", .addflag= "-b",.addvalue= "_CODE=0x0200", .found= false}, + {.searchkey= "_HRAM=", .addflag= "-b",.addvalue= "_HRAM=0xFF80", .found= false}, }; // SMS / GG
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.