gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/targets/z80/gg/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 sla b
20 ld c, b
21 ld b, #0
22 add hl, bc
23 pop bc
24
25 ld a, l
26 di
27 out (#.VDP_CMD), a
28 ld a, h
29 out (#.VDP_CMD), a
30 ld a, c
31 out (#.VDP_DATA), a
32 jr 3$
33 3$:
34 ld a, b
35 ei
36 out (#.VDP_DATA), a
37
38 ex de, hl
39 jp (hl)
40
41 ; void set_palette(uint8_t first_palette, uint8_t nb_palettes, uint16_t *rgb_data) __z88dk_callee;
42 _set_palette::
43 pop de
44 pop bc
45
46 DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
47
48 ld hl, #.VDP_CRAM
49 bit 0, c
50 ld a, b
51 ld bc, #0
52 jr z, 1$
53 ld c, #0x20
54 1$:
55 add hl, bc
56
57 ld c, a
58
59 ld a, l
60 di
61 out (#.VDP_CMD), a
62 ld a, h
63 ei
64 out (#.VDP_CMD), a
65
66 ld a, c
67 or a
68 jr z, 3$
69
70 pop hl
71 ld c, #.VDP_DATA
72 5$:
73 ld b, #0x20
74 4$:
75 outi
76 jr nz, 4$
77
78 dec a
79 jr nz, 5$
80 3$:
81 ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
82
83 ex de, hl
84 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.