-
Notifications
You must be signed in to change notification settings - Fork 0
/
palette.asm
57 lines (53 loc) · 1.13 KB
/
palette.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
; x = palette address, darkens and writes to a+$12
LoadPalette: subroutine
ldx #$19
.loop ; first load the base palette
lda CastlePalette,x
sta basepalette,x
dex
bpl .loop
ldx #0
.loop2 ; then darken it step by step
lda basepalette,x
tay
and #$30
bne .ndark
tya
and #$f
tay
lda HueShift,y
bpl .found
.ndark
tya
sec
sbc #$10
.found
sta basepalette+25,x
inx
cpx #100
bne .loop2
rts
; set darkness equal to the value stored in "darkness", 0-5, 5 is black
SetDarkness: subroutine
ldy #$3f
sty PPU_ADDR
ldy darkness
ldx DarkTable,y
ldy #0
sty PPU_ADDR
.loop
lda $100,x ; some voodoo magic shit that skips mirrors in pallete addresses
sta PPU_DATA
inx
iny
tya
and #$3 ; if is divisible by 4, it's a mirror so skip to the next address
bne .loop
lda PPU_DATA
iny
cpy #$21
bne .loop
lda #$00
sta PPU_ADDR
sta PPU_ADDR
rts