msx_fill_rect_xy.s (1997B)
1 .include "global.s" 2 3 .title "VRAM utilities" 4 .module VRAMUtils 5 6 .ez80 7 8 .area _HOME 9 10 ;; Set background tile table from (BC) at XY = DE of size WH = HL 11.fill_rect_xy:: 12 push hl 13 ld hl, #.VDP_TILEMAP 14 15 ;; Set background tile from (BC) at YX = DE, size WH on stack, to VRAM from address (HL) 16.fill_rect_xy_tt:: 17 push bc ; Store source 18 19 ld a, d 20 rrca ; rrca(3) == rlca(5) 21 rrca 22 rrca 23 ld d, a 24 and #0x07 25 add h 26 ld b, a 27 ld a, #0xE0 28 and d 29 add e 30 ld c, a ; dest BC = HL + ((0x20 * Y) + X 31 32 ld a, b 33 cp #>(.VDP_TILEMAP+0x0300) 34 jr c, 5$ 35 ld b, #>.VDP_TILEMAP 365$: 37 pop hl ; HL = source 38 pop de ; DE = HW 39 push ix ; save IX 40 push de ; store HW 41 ld ixh, b 42 ld ixl, c 43 push ix ; store dest 44 45 DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT 46 471$: ; copy H rows 48 VDP_WRITE_CMD ixh, ixl 49 ld c, #.VDP_DATA 502$: ; copy W tiles 51 out (c), l 52 53 ld a, ixl 54 and #0x1F 55 inc a 56 bit 5, a 57 jp z, 3$ 58 and #0x1F 59 ld b, a 60 ld a, ixl 61 and #0xE0 62 or b 63 ld ixl, a 64 VDP_WRITE_CMD ixh, ixl 65 dec e 66 jp nz, 2$ 67 jp 7$ 683$: 69 inc ixl 70 dec e 71 jp nz, 2$ 727$: 73 pop ix 74 pop de 75 76 dec d 77 jr z, 6$ 78 79 push de 80 81 ld bc, #0x20 82 add ix, bc 83 ld a, ixh 84 cp #>(.VDP_TILEMAP+0x0300) 85 jp c, 4$ 86 ld ixh, #>.VDP_TILEMAP 874$: 88 push ix 89 jp 1$ 906$: 91 ENABLE_VBLANK_COPY ; switch ON copy shadow SAT 92 pop ix ; restore IX 93 ret