cscg22-gearboy

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

metasprites_hide_spr.s (1303B)


      1        .include    "global.s"
      2
      3        .title  "Metasprites"
      4        .module Metasprites
      5
      6        .globl  ___render_shadow_OAM
      7
      8        .area   _CODE
      9
     10; void hide_sprites_range(UINT8 from, UINT8 to)
     11
     12_hide_sprites_range::
     13        ldhl    sp, #2
     14        ld      a, (hl+)
     15
     16        cp      #40
     17        ret     nc
     18
     19        add     a
     20        add     a
     21        ld      e, a
     22
     23        ld      a, (hl-)
     24        sub     (hl)
     25
     26        ret     c
     27        ret     z
     28
     29        ld      hl, #___render_shadow_OAM
     30        ld      h, (hl)
     31        ld      l, e
     32
     33        ld      de, #4
     34
     35        rra                     ; carry is never set here, because of ret c above
     36        jr      nc, 0$
     37
     38        ld      (hl), d
     39        add     hl, de          ; carry is reset here because hl can't overflow
     40
     41        ret     z               ; z is not affected by 16-bit add
     42
     430$:
     44        srl     a
     45        jr      nc, 1$
     46
     47        ld      (hl), d
     48        add     hl, de
     49
     50        ld      (hl), d
     51        add     hl, de
     52
     53        ret     z               ; z is not affected by 16-bit add
     54
     551$:
     56        ld      (hl), d
     57        add     hl, de
     58
     59        ld      (hl), d
     60        add     hl, de
     61
     62        ld      (hl), d
     63        add     hl, de
     64
     65        ld      (hl), d
     66        add     hl, de
     67
     68        dec     a
     69        jr      nz, 1$
     70
     71        ret