comparison src/dsdebrief.c @ 0:c84446dfb3f5

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