aboutsummaryrefslogtreecommitdiff
path: root/src/ubox/ubox_set_sprite_pat16_flip.z80
blob: 52f4ab7827646facdd776198aad732d937aabaaa (plain)
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
.globl _ubox_set_sprite_pat16_flip

WRTVRM = 0x004d
SP_PATTERNS = 0x3800

_ubox_set_sprite_pat16_flip::
	ld hl, #2
	add hl, sp

	ld e, (hl)
	inc hl
	ld d, (hl)
	inc hl

	ld l, (hl)
	ld h, #0
	add hl, hl
	add hl, hl
	add hl, hl
	add hl, hl
	add hl, hl
	ld bc, #SP_PATTERNS
	add hl, bc

	push de
	ld bc, #16
	ex de, hl
	add hl, bc
	ex de, hl
	call flip

	pop de
	call flip

	ret

flip:
	ld b, #16
flip0:
	call flip_and_copy
	inc hl
	inc de
	djnz flip0
	ret

flip_and_copy:
	ld a, (de)
	ld c, a
	rlca
	rlca
	xor c
	and #0xaa
	xor c
	ld c, a
	rlca
	rlca
	rlca
	rrc c
	xor c
	and #0x66
	xor c

	jp WRTVRM