gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 770883b3bad87ce65c6a006a7ca25b8e93079826 parent 504a87df3d424bafdcd1b1c3e77a9f48f8a72b58 Author: Toxa <untoxa@mail.ru> Date: Sat, 28 May 2022 23:12:29 +0300 All targets: fix trampoline routines, make them compatible with __sdcccall(1) Diffstat:
7 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/gbdk-lib/libc/targets/sm83/___sdcc_bcall.s b/gbdk-lib/libc/targets/sm83/___sdcc_bcall.s @@ -21,7 +21,10 @@ banked_call:: ; Performs a long call. rst 0x20 banked_ret:: pop hl ; Get the return address - pop af ; Pop the old bank + pop bc ; Pop the old bank + ld c, a + ld a, b ldh (__current_bank),a ld (.MBC_ROM_PAGE),a + ld a, c ; we must preserve A for the new calling convention jp (hl) diff --git a/gbdk-lib/libc/targets/sm83/___sdcc_bcall_ehl.s b/gbdk-lib/libc/targets/sm83/___sdcc_bcall_ehl.s @@ -9,7 +9,10 @@ ___sdcc_bcall_ehl:: ; Performs a long call. ldh (__current_bank),a ld (.MBC_ROM_PAGE),a ; Perform the switch rst 0x20 - pop af ; Pop the old bank + pop bc ; Pop the old bank + ld c, a + ld a, b ldh (__current_bank),a ld (.MBC_ROM_PAGE),a + ld a, c ret diff --git a/gbdk-lib/libc/targets/z80/gg/__sdcc_bcall.s b/gbdk-lib/libc/targets/z80/gg/__sdcc_bcall.s @@ -41,8 +41,11 @@ ___sdcc_bcall_abc:: inc sp call ___sdcc_bjump_abc dec sp - pop af + pop bc + ld c, a + ld a, b ld (#.MAP_FRAME1), a + ld a, c ret ; ___sdcc_bjump_abc: @@ -63,6 +66,9 @@ ___sdcc_bcall_ehl:: ld (#.MAP_FRAME1), a CALL_HL dec sp - pop af + pop bc + ld c, a + ld a, b ld (#.MAP_FRAME1), a + ld a, c ret diff --git a/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall.s b/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall.s @@ -31,11 +31,13 @@ ___sdcc_bcall_ehl:: dec sp ex (sp), hl + ld c, a ld a, h ld (__current_bank), a ld h, #>__banks_remap_table ld l, a ld a, (hl) call .mapper_page_set + ld a, c pop hl ret diff --git a/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall_abc.s b/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall_abc.s @@ -45,12 +45,14 @@ ___sdcc_bcall_abc:: dec sp ex (sp), hl + ld c, a ld a, h ld (__current_bank), a ld h, #>__banks_remap_table ld l, a ld a, (hl) call .mapper_page_set + ld a, c pop hl ret ; diff --git a/gbdk-lib/libc/targets/z80/msxdos/crt0.s b/gbdk-lib/libc/targets/z80/msxdos/crt0.s @@ -202,7 +202,7 @@ _SWITCH_ROM:: ; Z88DK_FASTCALL : uint8_t parameter in l ld h, #>__banks_remap_table ld l, a ld a, (hl) -.mapper_page_set:: +.mapper_page_set:: ; must preserve C out (.MAP_FRAME1), a ret diff --git a/gbdk-lib/libc/targets/z80/sms/__sdcc_bcall.s b/gbdk-lib/libc/targets/z80/sms/__sdcc_bcall.s @@ -41,8 +41,11 @@ ___sdcc_bcall_abc:: inc sp call ___sdcc_bjump_abc dec sp - pop af + pop bc + ld c, a + ld a, b ld (#.MAP_FRAME1), a + ld a, c ret ; ___sdcc_bjump_abc: @@ -63,6 +66,9 @@ ___sdcc_bcall_ehl:: ld (#.MAP_FRAME1), a CALL_HL dec sp - pop af + pop bc + ld c, a + ld a, b ld (#.MAP_FRAME1), a + ld a, c ret
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.