git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/libc/targets/sm83/get_tile.s

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