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

WRTVRM = 0x004d
SP_PATTERNS = 0x3800

_ubox_set_sprite_pat16_flip::
	ld e, l
	ld d, h

	ld hl, #2
	add hl, sp
	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

	pop hl
	inc sp
	jp (hl)

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