-
Notifications
You must be signed in to change notification settings - Fork 823
/
map_palettes.asm
89 lines (83 loc) · 1.24 KB
/
map_palettes.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
_LoadOverworldAttrmapPals::
; Load wAttrmap palette numbers based on the tileset palettes of current map.
; This function is only used for the initial loading of the map; incremental
; loads while moving happen through ScrollBGMapPalettes.
hlcoord 0, 0
decoord 0, 0, wAttrmap
ld b, SCREEN_HEIGHT
.loop
push bc
ld c, SCREEN_WIDTH
.innerloop
ld a, [hl]
push hl
srl a
jr c, .UpperNybble
ld hl, wTilesetPalettes
add [hl]
ld l, a
ld a, [wTilesetPalettes + 1]
adc 0
ld h, a
ld a, [hl]
and $f
jr .next
.UpperNybble:
ld hl, wTilesetPalettes
add [hl]
ld l, a
ld a, [wTilesetPalettes + 1]
adc 0
ld h, a
ld a, [hl]
swap a
and $f
.next
pop hl
ld [de], a
res OAM_TILE_BANK + 4, [hl]
inc hl
inc de
dec c
jr nz, .innerloop
pop bc
dec b
jr nz, .loop
ret
_ScrollBGMapPalettes::
ld hl, wBGMapBuffer
ld de, wBGMapPalBuffer
.loop
ld a, [hl]
push hl
srl a
jr c, .UpperNybble
; .LowerNybble
ld hl, wTilesetPalettes
add [hl]
ld l, a
ld a, [wTilesetPalettes + 1]
adc 0
ld h, a
ld a, [hl]
and $f
jr .next
.UpperNybble:
ld hl, wTilesetPalettes
add [hl]
ld l, a
ld a, [wTilesetPalettes + 1]
adc 0
ld h, a
ld a, [hl]
swap a
and $f
.next
pop hl
ld [de], a
res OAM_TILE_BANK + 4, [hl]
inc hl
inc de
dec c
jr nz, .loop
ret