This repository has been archived by the owner on Jun 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmisc.h
162 lines (126 loc) · 1.62 KB
/
misc.h
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#ifndef _UTILS_H
#define _UTILS_H
void __FASTCALL__
fade_out(uint lines)
{
#asm
push hl
pop bc
ld hl, $5800
ld e, 7
.fade_out_all_loop0
push hl
push bc
halt
.fade_out_all_loop1
ld a, (hl)
and 7
jr z, no_fade_all_ink
dec a
.no_fade_all_ink
ld d, a
ld a, (hl)
and $38
jr z, no_fade_all_paper
sub 8
.no_fade_all_paper
or d
ld d, a
ld a, (hl)
and $c0
or d
ld (hl), a
inc hl
dec bc
ld a, b
or c
jr nz, fade_out_all_loop1
pop bc
pop hl
dec e
jr nz, fade_out_all_loop0
#endasm
}
void
pad_numbers(uchar *s, uint limit, uint number)
{
s += limit;
*s = 0;
while (limit--)
{
*--s = (number % 10) + '0';
number /= 10;
}
}
void __CALLEE__
setup_tiles(uchar *src, uchar base, uchar len)
{
/*
for (i = 0; i < len; ++i, src += 8)
sp1_TileEntry(base + i, src);
*/
#asm
pop hl
pop de ; len
pop bc ; base
ex (sp), hl ; src
ld b, e
; hl src, b len, c base
.setup_tiles_loop
push hl
push bc
ld b, 0
push bc
push hl
call sp1_TileEntry_callee
pop bc
pop hl
ld de, 8
add hl, de
inc c
djnz setup_tiles_loop
#endasm
}
void __CALLEE__
print(uchar x, uchar y, uchar attr, char *str)
{
/*
while(*str)
sp1_PrintAtInv(y, x++, attr, *str++);
*/
#asm
ld ix, 2
add ix, sp
ld l, (ix + 0)
ld h, (ix + 1)
.print_loop
push hl
push ix
ld d, 0
ld e, (ix + 4) ; y
push de
ld e, (ix + 6) ; x
push de
ld e, (ix + 2) ; attr
push de
ld e, (hl)
push de ; char
call sp1_PrintAtInv_callee
pop ix
pop hl
inc hl
ld a, (ix + 6)
inc a
ld (ix + 6), a
ld a, (hl)
or a
jr nz, print_loop
pop hl
pop af
pop af
pop af
pop af
push hl
#endasm
}
#endif