paulo@0: /* paulo@0: GBA/DS debrief code for LOCKJAW Tetromino Game paulo@0: paulo@0: Copr. 2008 Damian Yerrick paulo@0: also GPL paulo@0: paulo@0: */ paulo@0: #include paulo@0: #ifdef ARM9 paulo@0: #include "ljds.h" paulo@0: #define vwfOptions vwfTouch paulo@0: #else paulo@0: #include "ljgba.h" paulo@0: #define vwfOptions vwfTop paulo@0: #endif paulo@0: #include "fontdraw.h" paulo@0: paulo@0: void debriefDrawPage(const char *page, size_t pageNumber) { paulo@0: int y = 0; paulo@0: char line[256]; paulo@0: int linePos = 0; paulo@0: int done = 0; paulo@0: int scrW = vwfOptions.width * 8; paulo@0: int scrH = vwfOptions.height * 8; paulo@0: paulo@0: #ifdef ARM9 paulo@0: BG_PALETTE_SUB[0] = RGB5(31,31,31); paulo@0: BG_PALETTE_SUB[1] = RGB5(21,21,21); paulo@0: BG_PALETTE_SUB[2] = RGB5(0, 0, 0); paulo@0: BG_PALETTE_SUB[3] = RGB5(0, 0, 0); paulo@0: videoSetModeSub(MODE_0_2D paulo@0: | DISPLAY_BG0_ACTIVE); paulo@0: #else paulo@0: BG_PALETTE[0] = RGB5(31,31,31); paulo@0: BG_PALETTE[1] = RGB5(21,21,21); paulo@0: BG_PALETTE[2] = RGB5(0, 0, 0); paulo@0: BG_PALETTE[3] = RGB5(0, 0, 0); paulo@0: REG_DISPCNT = 0 | BG0_ON; paulo@0: #endif paulo@0: vwfWinInit(&vwfOptions); paulo@0: vwfPuts(&vwfOptions, "GAME OVER", (scrW - 64) / 2, y); paulo@0: siprintf(line, "Page %u", (unsigned int)pageNumber + 1); paulo@0: vwfPuts(&vwfOptions, line, scrW - 40, y); paulo@0: vwfPuts(&vwfOptions, "Left/Right: change; Rotate: close", paulo@0: 4, scrH - 12); paulo@0: paulo@0: while (!done && y <= scrH - 24) { paulo@0: int c = *page++; paulo@0: paulo@0: // Break at newline and at end of text paulo@0: if (c == '\n' || c == 0) { paulo@0: paulo@0: // Terminate the line of text and print it paulo@0: line[linePos] = 0; paulo@0: vwfPuts(&vwfOptions, line, 4, y); paulo@0: paulo@0: y += linePos ? 12 : 6; // Line feed paulo@0: linePos = 0; // Carriage return paulo@0: } else { paulo@0: if (linePos + 2 < sizeof(line)) { paulo@0: line[linePos++] = c; paulo@0: } paulo@0: } paulo@0: if (c == 0) { paulo@0: done = 1; paulo@0: } paulo@0: } paulo@0: } paulo@0: paulo@0: LJBits debriefHandleKeys(void) { paulo@0: int j = readPad(0); paulo@0: if (j & (KEY_START << 16)) { paulo@0: j |= VKEY_ROTR; paulo@0: } paulo@0: vsync(); paulo@0: return j; paulo@0: }