cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

__sdcc_bcall_abc.s (1132B)


      1        .include "global.s"
      2
      3        .area   _CODE
      4
      5        .globl ___sdcc_bcall
      6        .globl ___sdcc_bcall_abc
      7
      8;
      9; trampoline to call banked functions
     10; used when legacy banking is enabled only
     11; Usage:
     12;   call ___sdcc_bcall
     13;   .dw  <function>
     14;   .dw  <function_bank>
     15;
     16___sdcc_bcall::
     17        ex (sp), hl
     18        ld c, (hl)
     19        inc hl
     20        ld b, (hl)
     21        inc hl
     22        ld a, (hl)
     23        inc hl
     24        inc  hl
     25        ex (sp), hl
     26;
     27; trampoline to call banked functions with __z88dk_fastcall calling convention
     28; Usage:
     29;  ld   a, #<function_bank>
     30;  ld   bc, #<function>
     31;  call ___sdcc_bcall_abc
     32;
     33___sdcc_bcall_abc::
     34        push hl
     35        ld l, a
     36        ld a, (__current_bank)
     37        ld h, #>__banks_remap_table
     38        ld l, (hl)
     39        ld h, a
     40        call .mapper_page_set
     41        ex (sp), hl
     42
     43        inc sp
     44        call ___sdcc_bjump_abc
     45        dec sp
     46
     47        ex (sp), hl
     48        ld a, h
     49        ld (__current_bank), a
     50        ld h, #>__banks_remap_table
     51        ld l, a
     52        ld a, (hl)
     53        call .mapper_page_set
     54        pop hl
     55        ret
     56;
     57___sdcc_bjump_abc:
     58        push bc
     59        ret