-
Notifications
You must be signed in to change notification settings - Fork 1
/
title.c
337 lines (289 loc) · 7.32 KB
/
title.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#ifndef NOTITLESCREEN
/***********************************************************************************
Title Screen
***********************************************************************************/
const unsigned char *titlestrings[] =
{
//12345678901234567890123456789012345678901234567890
" ##### ## ## ",
" ## ## ## ## ",
" ## ## ###### ## ## ##### ## ## #####",
" ##### ## ## ##### ## ##### ## ## ",
" ## ## ## ## ## ## ## ######",
"## ## ## ## ## ## ## ## ## ",
"## ###### ## ##### ## ## ##### ",
};
//12345678901234567890
const unsigned char *menustrings[] =
{
#if !defined(NOKEYBOARD)
"H show HiScores",
# if !defined(NOJOYSELECT)
"C toggles Controls",
# endif
# if !defined(NOQUIT)
"Q Quit Program",
# endif
"Press SPACE to start",
#else
"show HiScores",
# if !defined(NOJOYSELECT)
"toggle Controls",
# endif
# if !defined(NOQUIT)
"Quit Program",
# endif
"start new Game",
#endif
};
#define MENUITEMS (sizeof(menustrings) / sizeof(unsigned char*))
const unsigned char menukeys[MENUITEMS] =
{
'h',
#if !defined(NOJOYSELECT)
'c',
#endif
#if !defined(NOQUIT)
'q',
#endif
' '
};
unsigned char menuitem = (MENUITEMS - 1);
void title_printstring (unsigned char aaline, unsigned char nr, signed char off)
{
register unsigned char x;
register unsigned char c;
register unsigned char *ptr;
gotoxy (0, aaline);
ptr = (unsigned char *) titlestrings[nr];
if (off > 0) {
ptr += off;
}
x = 0;
while (x < (SCREENX)) {
if (off < 0) {
++off;
cputc (' ');
} else if ((c = *ptr) != '\0') {
cputc (c);
++ptr;
} else {
cputc (' ');
}
++x;
}
}
void title_printcontroller(unsigned char type)
{
unsigned char i, ii, l;
#if !defined (NOKEYBOARD)
unsigned char c, j;
#endif
gotoxy(0, TOFFS6); cclear(SCREENX);
gotoxy(0, TOFFS6 + 1); cclear(SCREENX);
// controller info
for(i = 0, l = 0; i < MAX_PLR; ++l) {
for(ii = 0; ii < (SCREENX / 20); ++ii, ++i) {
#ifdef CONIODYNSIZE
gotoxy((ii * 20) + 2, TOFFS6 + l);
#else
// VOOODOOOO!!! :o)
#if SCREENX < 40
gotoxy(((SCREENX / 2) - 10) + (((SCREENX / (SCREENX / (SCREENX / 2))) / 8)), TOFFS6 + l);
#elif SCREENX < 80
gotoxy((ii * 20) + (((SCREENX / (SCREENX / (SCREENX / 2))) / 8)), TOFFS6 + l);
#else
gotoxy((ii * 20) + 2, TOFFS6 + l);
#endif
#endif // CONIODYNSIZE
cprintf("plr %d:",i + 1);
if((type == 1) && (i < numjoysticks)) {
cprintf("joystick %d", i + 1);
} else {
#if !defined (NOKEYBOARD)
for(j = 0; j < 4; ++j) {
#if !defined (NO2DIMARRAYS)
c = joykeys[i][j];
#else
c = joykeys[(i * 4) + j];
#endif
if(c == ' ') {
cputs("space");
} else {
cputc(c);
}
cputc(' ');
}
#else
cputs("n/a");
#endif
}
}
}
}
// print the title screen
unsigned char title (void)
{
unsigned char i;
static unsigned char cnt;
static unsigned char ccnt;
signed char loff = 0;
#if !defined(NOKEYBOARD)
unsigned char c;
#endif
clrscr();
textcolor(COLOR_LIGHTRED);
// version
#ifdef CONIODYNSIZE
gotoxy(0,TOFFS2);
cprintf("v%s ", VERSION);
#if !defined(NOTVMODE)
if(get_tv() == TV_NTSC) {
cputs("(ntsc)");
} else {
cputs("(pal)");
}
#endif
cprintf(", %d players", MAX_PLR);
textcolor(COLOR_WHITE);
// copyright
gotoxy(0, TOFFS5);
cputs_c("(w) 2002-2020 by Groepaz/Solution");
#else // !CONIODYNSIZE
#if SCREENX > 23
gotoxy((SCREENX - 24) / 2, TOFFS2);
#elif SCREENX > 17
gotoxy((SCREENX - 17) / 2, TOFFS2);
#else
gotoxy(0, TOFFS2);
#endif
#if SCREENX > 23
cprintf("v%s ", VERSION);
#if !defined(NOTVMODE)
if(get_tv() == TV_NTSC) {
cputs("(ntsc)");
} else {
cputs("(pal)");
}
#endif
cprintf(", %d players", MAX_PLR);
#elif SCREENX > 17
cprintf("v%s", VERSION);
#if !defined(NOTVMODE)
if(get_tv() == TV_NTSC) {
cputs("(ntsc)");
} else {
cputs("(pal)");
}
#endif
cprintf(",%dplr", MAX_PLR);
#endif
textcolor(COLOR_WHITE);
// copyright
gotoxy(0, TOFFS5);
#if SCREENX < 26
/*1234567890123456789012345*/
cputs_c("(w)'03-'20 by GPZ/TSN");
#else
/*123456789012345678901234567890*/
cputs_c("(w) 2003-2020 by Groepaz/Solution");
#endif
#endif
gotoxy(0, TOFFS5 + 1);
/*123456789012345678901234567890*/
cputs_c("all rights reversed");
textcolor(COLOR_YELLOW);
title_printcontroller(usejoysticks);
while (1) {
cnt = ccnt;
++ccnt;
waitvsync();
flasher();
// portris logo
for(i = 0; i < 7; ++i) {
textcolor(colortable[cnt & 0xf]);
title_printstring(TOFFS1 + i, i, loff);
++cnt;
}
if (--loff == -SCREENX) {
// must match length of one line in the logo
loff = 48;
}
// print menu items
textcolor(COLOR_WHITE);
for(i = 0; i < MENUITEMS; ++i) {
gotoxy(0, TOFFS3 + i);
if(i == menuitem) {
textcolor(COLOR_YELLOW);
if((ccnt & 0x08) == 0x08) {
revers(1);
cputs_c(menustrings[i]);
revers(0);
} else {
#ifdef NOREVERS
cclear(SCREENX);
#else
cputs_c(menustrings[i]);
#endif
}
textcolor(COLOR_WHITE);
} else {
cputs_c(menustrings[i]);
}
}
// do background flashing
if((ccnt & 0x7f) == 0) {
flashit(15);
}
#if !defined(NOKEYBOARD)
if(kbhit()) {
#ifdef NOLOWERCASE
c = tolower(cgetc());
#else
c = cgetc();
#endif
switch(c) {
#if !defined(NOJOYSELECT)
case 'c':
#endif
case ' ':
case 'q':
case 'h':
domeltdown();
return(c);
default:
break;
}
}
else
#endif // NOKEYBOARD
{
#if !defined (NOJOYSTICKS)
poll_controller();
for(i = 0; i < MAX_PLR; ++i) {
switch(pf[i].key) {
case TKEY_DROP:
if(menuitem < (MENUITEMS - 1)) {
++menuitem;
}
break;
case TKEY_UP:
if(menuitem > 0) {
--menuitem;
}
break;
case TKEY_ROTATE:
domeltdown();
return(menukeys[menuitem]);
break;
}
}
#endif // NOJOYSTICKS
}
#if defined(CONIOUPDATE)
conio_update();
#endif
}
return ' '; /* this should never happen */
}
#endif