cscg22-gearboy

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

get_tile.s (975B)


      1.include "global.s"
      2
      3.area _CODE
      4
      5_get_vram_byte::
      6        ldhl    sp,#2
      7        ld      a,(hl+)
      8        ld      h,(hl)
      9        ld      l,a
     10        WAIT_STAT
     11        ld      e,(hl)
     12        ret
     13
     14_get_win_tile_xy::
     15        ldh     a,(.LCDC)
     16        and     #LCDCF_WIN9C00
     17        jr      z,.is98
     18        jr      .is9c
     19_get_bkg_tile_xy::
     20        ldh     a,(.LCDC)
     21        and     #LCDCF_BG9C00
     22        jr      nz,.is9c
     23.is98:
     24        ld      d,#0x98         ; DE = origin
     25        jr      .get_tile_xy
     26.is9c:
     27        ld      d,#0x9C         ; DE = origin
     28
     29.get_tile_xy:
     30        ldhl    sp,#3
     31
     32        ld      a, (hl-)
     33        ld      l, (hl)
     34
     35        ld      e, d
     36        swap    a
     37        rlca
     38        ld      h, a
     39        and     #0x03
     40        add     e
     41        ld      d, a
     42        ld      a, #0xE0
     43        and     h
     44        add     l
     45        ld      l, a
     46        ld      h, d            ; dest DE = BASE + 0x20 * Y + X
     47
     48        WAIT_STAT
     49        ld      e, (hl)
     50
     51        ret