cscg22-gearboy

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

set_tile.s (1522B)


      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        pop de
     13        pop hl
     14        DISABLE_VBLANK_COPY
     15        WRITE_VDP_CMD_HL
     16        ex de, hl
     17        dec sp
     18        ex (sp), hl
     19        ld a, h
     20        out (.VDP_DATA), a
     21        ENABLE_VBLANK_COPY
     22        ret
     23
     24; uint8_t * set_attributed_tile_xy(uint8_t x, uint8_t y, uint16_t t) __z88dk_callee __preserves_regs(iyh, iyl);
     25_set_attributed_tile_xy::
     26        pop hl          ; HL = ret
     27        pop de          ; DE = YX
     28        ex (sp), hl     ; HL = data
     29
     30        ld a, d
     31
     32        ld bc, #.VDP_TILEMAP
     33        call .coords_to_address
     34        ex de, hl
     35
     36        DISABLE_VBLANK_COPY
     37        WRITE_VDP_CMD_HL
     38
     39        ld c, #.VDP_DATA
     40        out (c), e
     41        VDP_DELAY
     42        out (c), d
     43
     44        ENABLE_VBLANK_COPY
     45        ret
     46
     47; uint8_t * set_tile_xy(uint8_t x, uint8_t y, uint8_t t) __z88dk_callee __preserves_regs(iyh, iyl);
     48_set_tile_xy::
     49        pop hl          ; HL = ret
     50        pop de          ; DE = YX
     51        dec sp
     52        ex (sp), hl     ; HL = data
     53
     54        ld a, d
     55
     56        ld bc, #.VDP_TILEMAP
     57        call .coords_to_address
     58        ex de, hl
     59
     60        ld a, (.vdp_shift)
     61        ADD_A_REG16 h, l
     62
     63        DISABLE_VBLANK_COPY
     64        WRITE_VDP_CMD_HL
     65
     66        ld a, d
     67        out (.VDP_DATA), a
     68
     69        ENABLE_VBLANK_COPY
     70        ret