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/z80/set_tile.s

      1         .include        "global.s"
      2 
      3         .title  "VRAM utilities"
      4         .module VRAMUtils
      5 
      6         .globl  .coords_to_address
      7 
      8         .area   _HOME
      9 
     10 ; void set_vram_byte(uint8_t * addr, uint8_t v) __z88dk_callee __preserves_regs(iyh, iyl);
     11 _set_vram_byte::
     12         DISABLE_VBLANK_COPY
     13 
     14         pop de
     15         pop hl
     16         WRITE_VDP_CMD_HL
     17         ex de, hl
     18         dec sp
     19         ex (sp), hl
     20         ld a, h
     21         out (.VDP_DATA), a
     22 
     23         ENABLE_VBLANK_COPY
     24         ret
     25 
     26 ; uint8_t * set_attributed_tile_xy(uint8_t x, uint8_t y, uint16_t t) __z88dk_callee __preserves_regs(iyh, iyl);
     27 _set_attributed_tile_xy::
     28         DISABLE_VBLANK_COPY
     29 
     30         pop hl          ; HL = ret
     31         pop de          ; DE = YX
     32         ex (sp), hl     ; HL = data
     33 
     34         call .coords_to_address
     35         ex de, hl
     36 
     37         WRITE_VDP_CMD_HL
     38 
     39         ld c, #.VDP_DATA
     40         out (c), e
     41         VDP_DELAY
     42         out (c), d
     43 
     44         ex de, hl
     45         ENABLE_VBLANK_COPY
     46         ex de, hl
     47         ret
     48 
     49 ; uint8_t * set_tile_xy(uint8_t x, uint8_t y, uint8_t t) __z88dk_callee __preserves_regs(iyh, iyl);
     50 _set_tile_xy::
     51         DISABLE_VBLANK_COPY
     52 
     53         pop hl          ; HL = ret
     54         pop de          ; DE = YX
     55         dec sp
     56         ex (sp), hl     ; HL = data
     57 
     58         call .coords_to_address
     59         ex de, hl
     60 
     61         ld a, (.vdp_shift)
     62         ADD_A_REG16 h, l
     63 
     64         WRITE_VDP_CMD_HL
     65 
     66         ld a, d
     67         out (.VDP_DATA), a
     68 
     69         ex de, hl
     70         ENABLE_VBLANK_COPY
     71         ex de, hl
     72         ret
     73 
     74 ; uint8_t * set_attribute_xy(uint8_t x, uint8_t y, uint8_t a) __z88dk_callee __preserves_regs(iyh, iyl);
     75 _set_attribute_xy::
     76         DISABLE_VBLANK_COPY
     77 
     78         pop hl          ; HL = ret
     79         pop de          ; DE = YX
     80         dec sp
     81         ex (sp), hl     ; HL = data
     82 
     83         call .coords_to_address
     84         ex de, hl
     85 
     86         ld a, (.vdp_shift)
     87         ADD_A_REG16 h, l
     88 
     89         WRITE_VDP_CMD_HL
     90 
     91         in a, (.VDP_DATA)   ; skip tile index
     92         ld a, d
     93         out (.VDP_DATA), a
     94 
     95         ex de, hl
     96         ENABLE_VBLANK_COPY
     97         ex de, hl
     98         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.