-
Notifications
You must be signed in to change notification settings - Fork 1
/
hires.c
165 lines (129 loc) · 3.21 KB
/
hires.c
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
162
163
164
165
void main()
{
romout(6);
bank(1);
saveregs();
lda( 0x00 );
uint plotDigitBindex;
lda( 0x01 );
uint plotDigitX;
uint plotDigitY;
uint plotDigitColourValue11;
uint plotDigitColourValue1001 = 0x0E;
data digits = {
0, 52, 221, 221, 221, 221, 221, 52,
0, 52, 52, 52, 52, 52, 52, 52,
0, 52, 221, 13, 52, 208, 208, 253,
0, 253, 13, 52, 13, 221, 221, 52,
0, 13, 221, 221, 221, 253, 13, 13,
0, 253, 208, 244, 13, 13, 221, 52,
0, 52, 221, 208, 244, 221, 221, 52,
0, 253, 13, 13, 52, 52, 52, 52,
0, 52, 221, 221, 48, 221, 221, 52,
0, 52, 221, 221, 61, 13, 221, 52,
// space
0, 0, 0, 0, 0, 0, 0, 0
};
word plotDigitAddr = digits;
clearhires();
// set multicolour bitmap mode
poke( 0xD011, 59 );
poke( 0xD016, 24 );
poke( 0xD018, 24 );
// set border and background colours to black
poke( 0xD020, 6 );
poke( 0xD021, 6 );
word score = 0xFF00;
for( word j = 0x0000; j < 0x0F00; j = j + 0x0001 )
{
score = score + rnd();
eraseScore();
updateScore();
}
pause();
clearkb();
restoreregs();
bank(0);
romin();
return;
}
void clearhires()
{
// Colours
// 0 - Black 1 - White 2 - Red 3 - Cyan 4 - Purple 5 - Green 6 - Dark Blue
// 7 - Yellow 8 - Orange 9 - Brown A - Pink B - Dark Grey C - Grey D - Bright Green
// E - Light Blue F - Light Grey
word mem1 = 0x0000;
// this is for the single colour (11) -- this is ALWAYS at 0xD800
for( mem1 = 0xD800; mem1 < 0xDBFF; mem1 = mem1 + 1 )
{
poke( mem1, 0 );
}
// this is for the colours for 01 and 10 of the bitmap
for( mem1 = 0x4400; mem1 < 0x47F0; mem1 = mem1 + 1 )
{
poke( mem1, 0x26 );
}
// the pixels
for( mem1 = 0x6000; mem1 < 0x7FF8; mem1 = mem1 + 1 )
{
poke( mem1, 0 );
}
return;
}
void eraseScore()
{
plotDigitY = 24;
for( uint xI = 5; xI < 10; inc( xI ) )
{
plotDigitX = xI;
plotDigitBindex = 0x50;
plotDigit();
}
return;
}
void updateScore()
{
word num = score;
plotDigitY = 24;
plotDigitX = 10;
plotNumber();
return;
}
void plotNumber()
{
uint ten = 0x0A;
while( num > 0x0000 )
{
num = num / ten;
uint rem = peek( 0x0002 );
plotDigitBindex = rem;
asl( plotDigitBindex );
asl( plotDigitBindex );
asl( plotDigitBindex );
plotDigit();
dec(plotDigitX);
}
return;
}
void plotDigit()
{
word plotDigitOffset = plotDigitY;
plotDigitOffset = plotDigitOffset * 40;
plotDigitOffset = plotDigitOffset + plotDigitX;
word plotDigitColor1 = plotDigitOffset + 0xD800;
word plotDigitColors2And3 = plotDigitOffset + 0x4400;
poke( plotDigitColor1, plotDigitColourValue11 );
poke( plotDigitColors2And3, plotDigitColourValue1001 );
asl( plotDigitOffset );
asl( plotDigitOffset );
asl( plotDigitOffset );
word plotDigitPixels = plotDigitOffset + 0x6000;
for( uint plotDigitI = 0; plotDigitI < 8; inc( plotDigitI ) )
{
poke( plotDigitPixels, (plotDigitAddr)[plotDigitBindex] );
plotDigitPixels = plotDigitPixels + 1;
inc( plotDigitBindex );
}
return;
}