diff src/dsdebrief.c @ 0:c84446dfb3f5

initial add
author paulo@localhost
date Fri, 13 Mar 2009 00:39:12 -0700
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/dsdebrief.c	Fri Mar 13 00:39:12 2009 -0700
     1.3 @@ -0,0 +1,77 @@
     1.4 +/*
     1.5 +GBA/DS debrief code for LOCKJAW Tetromino Game
     1.6 +
     1.7 +Copr. 2008 Damian Yerrick
     1.8 +also GPL
     1.9 +
    1.10 +*/
    1.11 +#include <stdio.h>
    1.12 +#ifdef ARM9
    1.13 +#include "ljds.h"
    1.14 +#define vwfOptions vwfTouch
    1.15 +#else
    1.16 +#include "ljgba.h"
    1.17 +#define vwfOptions vwfTop
    1.18 +#endif
    1.19 +#include "fontdraw.h"
    1.20 +
    1.21 +void debriefDrawPage(const char *page, size_t pageNumber) {
    1.22 +  int y = 0;
    1.23 +  char line[256];
    1.24 +  int linePos = 0;
    1.25 +  int done = 0;
    1.26 +  int scrW = vwfOptions.width * 8;
    1.27 +  int scrH = vwfOptions.height * 8;
    1.28 +
    1.29 +#ifdef ARM9
    1.30 +  BG_PALETTE_SUB[0] = RGB5(31,31,31);
    1.31 +  BG_PALETTE_SUB[1] = RGB5(21,21,21);
    1.32 +  BG_PALETTE_SUB[2] = RGB5(0, 0, 0);
    1.33 +  BG_PALETTE_SUB[3] = RGB5(0, 0, 0);
    1.34 +  videoSetModeSub(MODE_0_2D
    1.35 +                 | DISPLAY_BG0_ACTIVE);
    1.36 +#else
    1.37 +  BG_PALETTE[0] = RGB5(31,31,31);
    1.38 +  BG_PALETTE[1] = RGB5(21,21,21);
    1.39 +  BG_PALETTE[2] = RGB5(0, 0, 0);
    1.40 +  BG_PALETTE[3] = RGB5(0, 0, 0);
    1.41 +  REG_DISPCNT = 0 | BG0_ON;
    1.42 +#endif
    1.43 +  vwfWinInit(&vwfOptions);
    1.44 +  vwfPuts(&vwfOptions, "GAME OVER", (scrW - 64) / 2, y);
    1.45 +  siprintf(line, "Page %u", (unsigned int)pageNumber + 1);
    1.46 +  vwfPuts(&vwfOptions, line, scrW - 40, y);
    1.47 +  vwfPuts(&vwfOptions, "Left/Right: change; Rotate: close",
    1.48 +          4, scrH - 12);
    1.49 +
    1.50 +  while (!done && y <= scrH - 24) {
    1.51 +    int c = *page++;
    1.52 +
    1.53 +    // Break at newline and at end of text
    1.54 +    if (c == '\n' || c == 0) {
    1.55 +
    1.56 +      // Terminate the line of text and print it
    1.57 +      line[linePos] = 0;
    1.58 +      vwfPuts(&vwfOptions, line, 4, y);
    1.59 +
    1.60 +      y += linePos ? 12 : 6;  // Line feed
    1.61 +      linePos = 0;  // Carriage return
    1.62 +    } else {
    1.63 +      if (linePos + 2 < sizeof(line)) {
    1.64 +        line[linePos++] = c;
    1.65 +      }
    1.66 +    }
    1.67 +    if (c == 0) {
    1.68 +      done = 1;
    1.69 +    }
    1.70 +  }
    1.71 +}
    1.72 +
    1.73 +LJBits debriefHandleKeys(void) {
    1.74 +  int j = readPad(0);
    1.75 +  if (j & (KEY_START << 16)) {
    1.76 +    j |= VKEY_ROTR;
    1.77 +  }
    1.78 +  vsync();
    1.79 +  return j;
    1.80 +}