gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/targets/z80/sms/palette.s
1 ;; SMS palette routines
2
3 .include "global.s"
4
5 .title "CRAM SMS Palettes"
6 .module CRAMUtils
7 .area _HOME
8
9 ; void set_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) __z88dk_callee;
10 _set_palette_entry::
11 pop de
12 pop bc
13
14 ld hl, #.VDP_CRAM
15 bit 0, c
16 jr z, 1$
17 set 4, b
18 1$:
19 ld c, b
20 ld b, #0
21 add hl, bc
22 pop bc
23
24 ld a, l
25 di
26 out (#.VDP_CMD), a
27 ld a, h
28 out (#.VDP_CMD), a
29 ld a, c
30 ei
31 out (#.VDP_DATA), a
32
33 ex de, hl
34 jp (hl)
35
36 ; void set_palette(uint8_t first_palette, uint8_t nb_palettes, uint16_t *rgb_data) __z88dk_callee;
37 _set_palette::
38 pop de
39 pop bc
40
41 DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
42
43 ld hl, #.VDP_CRAM
44 bit 0, c
45 ld a, b
46 ld bc, #0
47 jr z, 1$
48 ld c, #0x10
49 1$:
50 add hl, bc
51
52 ld c, a
53
54 ld a, l
55 di
56 out (#.VDP_CMD), a
57 ld a, h
58 ei
59 out (#.VDP_CMD), a
60 ld a, c
61 or a
62 jr z, 3$
63
64 pop hl
65 ld c, #.VDP_DATA
66 5$:
67 ld b, #0x10
68 4$:
69 outi
70 jr nz, 4$
71
72 dec a
73 jr nz, 5$
74 3$:
75 ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
76
77 ex de, hl
78 jp (hl)
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.