rev |
line source |
paulo@0
|
1 /*
|
paulo@0
|
2 GBA/DS debrief code for LOCKJAW Tetromino Game
|
paulo@0
|
3
|
paulo@0
|
4 Copr. 2008 Damian Yerrick
|
paulo@0
|
5 also GPL
|
paulo@0
|
6
|
paulo@0
|
7 */
|
paulo@0
|
8 #include <stdio.h>
|
paulo@0
|
9 #ifdef ARM9
|
paulo@0
|
10 #include "ljds.h"
|
paulo@0
|
11 #define vwfOptions vwfTouch
|
paulo@0
|
12 #else
|
paulo@0
|
13 #include "ljgba.h"
|
paulo@0
|
14 #define vwfOptions vwfTop
|
paulo@0
|
15 #endif
|
paulo@0
|
16 #include "fontdraw.h"
|
paulo@0
|
17
|
paulo@0
|
18 void debriefDrawPage(const char *page, size_t pageNumber) {
|
paulo@0
|
19 int y = 0;
|
paulo@0
|
20 char line[256];
|
paulo@0
|
21 int linePos = 0;
|
paulo@0
|
22 int done = 0;
|
paulo@0
|
23 int scrW = vwfOptions.width * 8;
|
paulo@0
|
24 int scrH = vwfOptions.height * 8;
|
paulo@0
|
25
|
paulo@0
|
26 #ifdef ARM9
|
paulo@0
|
27 BG_PALETTE_SUB[0] = RGB5(31,31,31);
|
paulo@0
|
28 BG_PALETTE_SUB[1] = RGB5(21,21,21);
|
paulo@0
|
29 BG_PALETTE_SUB[2] = RGB5(0, 0, 0);
|
paulo@0
|
30 BG_PALETTE_SUB[3] = RGB5(0, 0, 0);
|
paulo@0
|
31 videoSetModeSub(MODE_0_2D
|
paulo@0
|
32 | DISPLAY_BG0_ACTIVE);
|
paulo@0
|
33 #else
|
paulo@0
|
34 BG_PALETTE[0] = RGB5(31,31,31);
|
paulo@0
|
35 BG_PALETTE[1] = RGB5(21,21,21);
|
paulo@0
|
36 BG_PALETTE[2] = RGB5(0, 0, 0);
|
paulo@0
|
37 BG_PALETTE[3] = RGB5(0, 0, 0);
|
paulo@0
|
38 REG_DISPCNT = 0 | BG0_ON;
|
paulo@0
|
39 #endif
|
paulo@0
|
40 vwfWinInit(&vwfOptions);
|
paulo@0
|
41 vwfPuts(&vwfOptions, "GAME OVER", (scrW - 64) / 2, y);
|
paulo@0
|
42 siprintf(line, "Page %u", (unsigned int)pageNumber + 1);
|
paulo@0
|
43 vwfPuts(&vwfOptions, line, scrW - 40, y);
|
paulo@0
|
44 vwfPuts(&vwfOptions, "Left/Right: change; Rotate: close",
|
paulo@0
|
45 4, scrH - 12);
|
paulo@0
|
46
|
paulo@0
|
47 while (!done && y <= scrH - 24) {
|
paulo@0
|
48 int c = *page++;
|
paulo@0
|
49
|
paulo@0
|
50 // Break at newline and at end of text
|
paulo@0
|
51 if (c == '\n' || c == 0) {
|
paulo@0
|
52
|
paulo@0
|
53 // Terminate the line of text and print it
|
paulo@0
|
54 line[linePos] = 0;
|
paulo@0
|
55 vwfPuts(&vwfOptions, line, 4, y);
|
paulo@0
|
56
|
paulo@0
|
57 y += linePos ? 12 : 6; // Line feed
|
paulo@0
|
58 linePos = 0; // Carriage return
|
paulo@0
|
59 } else {
|
paulo@0
|
60 if (linePos + 2 < sizeof(line)) {
|
paulo@0
|
61 line[linePos++] = c;
|
paulo@0
|
62 }
|
paulo@0
|
63 }
|
paulo@0
|
64 if (c == 0) {
|
paulo@0
|
65 done = 1;
|
paulo@0
|
66 }
|
paulo@0
|
67 }
|
paulo@0
|
68 }
|
paulo@0
|
69
|
paulo@0
|
70 LJBits debriefHandleKeys(void) {
|
paulo@0
|
71 int j = readPad(0);
|
paulo@0
|
72 if (j & (KEY_START << 16)) {
|
paulo@0
|
73 j |= VKEY_ROTR;
|
paulo@0
|
74 }
|
paulo@0
|
75 vsync();
|
paulo@0
|
76 return j;
|
paulo@0
|
77 }
|