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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
;
; example.asm for TR8
;
.org 0
; address of the frame interrupt vector
.equ INT_VECT 0xff00
; setup an int handler so we
; can use the frame int to sync
ld a, >INT_VECT
ld x, <INT_VECT
ld b, <int_handler
ld [a : x], b
inc x
ld b, >int_handler
ld [a : x], b
; enable interrupts
cif
; loop filling the screen with one
; colour cycling the whole palette
ld b, 0
loop:
call fill
inc b
and b, 15
push b
call draw_sprite
pop b
; wait 1 second
ld x, 60
wait_loop:
halt
dec x
bnz
jmp wait_loop
jmp loop
; fill frame-buffer with a color in reg b
fill:
ld a, 0xbf
ld x, 0
ld y, 0x40
fill_loop:
ld [a : x], b
inc x
bno
jmp fill_loop
inc a
dec y
bnz
jmp fill_loop
ret
int_handler:
iret
draw_sprite:
push y
ld y, 16
ld [sp + 0], y
; src
ld a, >sprite
ld x, <sprite
; dst
ld b, 0xdb
ld y, 56
line:
push x
ld x, [a : x]
ld [b : y], x
pop x
inc x
bo
inc a
inc y
push y
ld y, [sp + 1]
dec y
ld [sp + 1], y
pop y
bnz
jmp line
add y, 112
bo
inc b
cmp x, <end_sprite
bnz
jmp next_row
cmp a, >end_sprite
bz
jmp done
next_row:
push y
ld y, 16
ld [sp + 1], y
pop y
jmp line
done:
pop y
ret
sprite:
.incpng "assets/icon.png"
end_sprite:
|