paulo@0: #include "ljpc.h" paulo@0: paulo@0: void debriefDrawPage(const char *page, size_t pageNumber) { paulo@0: int y = 40; paulo@0: char line[256]; paulo@0: int linePos = 0; paulo@0: int done = 0; paulo@0: paulo@0: acquire_screen(); paulo@0: clear_to_color(screen, bgColor); paulo@0: textout_centre_ex(screen, aver32, "GAME OVER", paulo@0: SCREEN_W / 2, y, fgColor, -1); paulo@0: textprintf_right_ex(screen, aver32, paulo@0: SCREEN_W - 40, y, fgColor, -1, paulo@0: "Page %u", (unsigned int)pageNumber + 1); paulo@0: textout_centre_ex(screen, aver32, paulo@0: "Left/Right: Change; Rotate: close", paulo@0: SCREEN_W / 2, SCREEN_H - 40, fgColor, -1); paulo@0: paulo@0: while (!done) { 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: // Draw blank and parenthetical lines in smaller font paulo@0: const FONT *f = (linePos == 0 || line[0] == '(') paulo@0: ? aver16 paulo@0: : aver32; paulo@0: int lineH = text_height(f); paulo@0: paulo@0: // Terminate the line of text and print it paulo@0: line[linePos] = 0; paulo@0: textout_ex(screen, f, line, 40, y, fgColor, -1); paulo@0: paulo@0: linePos = 0; // Carriage return paulo@0: y += lineH * 6 / 5; // Line feed 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: release_screen(); paulo@0: } paulo@0: paulo@0: extern volatile char redrawWholeScreen; paulo@0: paulo@0: LJBits debriefHandleKeys(void) { paulo@0: int keys = menuReadPad(); paulo@0: paulo@0: while (keypressed()) { paulo@0: int scancode; paulo@0: ureadkey(&scancode); paulo@0: paulo@0: if (scancode == KEY_PRTSCR) { paulo@0: saveScreen(-1); paulo@0: } paulo@0: } paulo@0: paulo@0: if (wantsClose) { paulo@0: keys |= VKEY_ROTL; paulo@0: } paulo@0: paulo@0: if (!(keys & (VKEY_ROTL | VKEY_ROTR))) { paulo@0: rest(30); paulo@0: } paulo@0: return keys; paulo@0: }