gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/targets/mos6502/nes/nes_palettes.s
1 .include "global.s"
2
3 .area GBDKOVR (PAG, OVR)
4 _set_bkg_palette_PARM_3::
5 _set_sprite_palette_PARM_3::
6 _set_bkg_palette_entry_PARM_3::
7 _set_sprite_palette_entry_PARM_3::
8 .ds 2
9 .num_entries: .ds 1
10 .define .src "_set_bkg_palette_PARM_3"
11
12 .area _HOME
13
14 ; void set_bkg_palette(uint8_t first_palette, uint8_t nb_palettes, palette_color_t *rgb_data) OLDCALL;
15 _set_bkg_palette::
16 clc
17 bcc .set_palette_impl
18 ; void set_sprite_palette(uint8_t first_palette, uint8_t nb_palettes, palette_color_t *rgb_data) OLDCALL;
19 _set_sprite_palette::
20 sec
21 .set_palette_impl:
22 ror *REGTEMP
23 pha
24 txa
25 asl
26 asl
27 sta *.num_entries
28 pla
29 asl
30 asl
31 bit *REGTEMP
32 bpl 0$
33 ora #0x10
34 0$:
35 tax
36 ldy #0
37 2$:
38 ; skip mirror entries
39 lda .paletteShadowLUT,x
40 bmi 1$
41 stx *.tmp
42 tax
43 lda [*.src],y
44 sta __crt0_paletteShadow,x
45 ldx *.tmp
46 1$:
47 inx
48 iny
49 cpy *.num_entries
50 bne 2$
51 rts
52
53 ; void set_bkg_palette_entry(uint8_t palette, uint8_t entry, palette_color_t rgb_data) OLDCALL;
54 _set_bkg_palette_entry::
55 clc
56 bcc .set_palette_entry
57 ; void set_sprite_palette_entry(uint8_t palette, uint8_t entry, palette_color_t rgb_data) OLDCALL;
58 _set_sprite_palette_entry::
59 sec
60 .set_palette_entry::
61 ror *REGTEMP
62 asl
63 asl
64 clc
65 adc .identity,x
66 tax
67 bit *REGTEMP
68 bpl 0$
69 ora #0x10
70 0$:
71 tay
72 lda .paletteShadowLUT,y
73 bpl 1$
74 rts
75 1$:
76 tax
77 lda *.src
78 sta __crt0_paletteShadow,x
79 rts
80
81 .paletteShadowLUT:
82 .db 0x00 ; UBC
83 .db 0x01
84 .db 0x02
85 .db 0x03
86 ;
87 .db 0xFF ; Skip BG1 entry 0
88 .db 0x04
89 .db 0x05
90 .db 0x06
91 ;
92 .db 0xFF ; Skip BG2 entry 0
93 .db 0x07
94 .db 0x08
95 .db 0x09
96 ;
97 .db 0xFF ; Skip BG3 entry 0
98 .db 0x0A
99 .db 0x0B
100 .db 0x0C
101 ;
102 .db 0xFF ; Skip SPR0 entry 0
103 .db 0x0D
104 .db 0x0E
105 .db 0x0F
106 ;
107 .db 0xFF ; Skip SPR1 entry 0
108 .db 0x10
109 .db 0x11
110 .db 0x12
111 ;
112 .db 0xFF ; Skip SPR2 entry 0
113 .db 0x13
114 .db 0x14
115 .db 0x15
116 ;
117 .db 0xFF ; Skip SPR3 entry 0
118 .db 0x16
119 .db 0x17
120 .db 0x18
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.