Ejemplo n.º 1
0
void __fastcall__ summaryScreen(void)
{
  // display kills, items, secrets, time
  // like this
  // MAP NAME
  // FINISHED
  // KILLS %
  // ITEMS %
  // SECRET %
  // TIME 00:00
  // PAR 00:00
  
  char kills = p_enemy_getKillPercentage();
  char items = getItemPercentage();
  char secret = (100*getNumVisitedSecrets())/getNumSecrets();
  int time = getMapTime();
  int par = getParTime();

  // clear screen
  clearScreen();
  
  textcolor(1);
  printCentered(caLevelNames[level-1], 1);
  textcolor(2);
  printCentered("finished", 2);
  cputsxy(4, 5, "kills");
  cputsxy(4, 7, "items");
  cputsxy(4, 9, "secret");
  cputsxy(4, 12, "time");
  cputsxy(4, 14, "par");

  setTextColor(2);
  POKE(198, 0);
  rollInPercentage(kills, 0x1000+22*5+14);
  waitASecond();
  rollInPercentage(items, 0x1000+22*7+14);
  waitASecond();
  rollInPercentage(secret, 0x1000+22*9+14);
  waitASecond();
  if (time > 10*60-1)
  {
    cputsxy(13,12,"sucks");
    playSound(SOUND_PISTOL);
  }
  else
  {
    rollInTime(time, 0x1000+22*12+13);
  }
  waitASecond();
  rollInTime(par, 0x1000+22*14+13);
  waitASecond();
  printCentered("press a key", 20);
  POKE(198, 0);
  while (PEEK(198) == 0) ;

  // clear screen
  clearScreen();
}
Ejemplo n.º 2
0
void printErrorStack(entry *e) {
    unsigned int i;
    char body[64];

    if (e->type == -1) {
        sprintf(body, "Error trace");
    } else if (e->type >= 253) {
        sprintf(body, "Error trace (%s)", types[e->type]);
    } else if (!e->key) {
        sprintf(body, "Error trace (%s: (unknown))", types[e->type]);
    } else {
        char tmp[41];
        strncpy(tmp, e->key, 40);

        /* display truncation at the last 3 chars */
        if (strlen(e->key) > 40) {
            memset(&tmp[37], '.', 3);
        }

        /* display unprintable characters as ? */
        for (i = 0; i < strlen(tmp); i++) {
            if (tmp[i] <= 32) tmp[i] = '?';
        }
        sprintf(body, "Error trace (%s: %s)", types[e->type], tmp);
    }

    printCentered(4, 80, body);

    /* display error stack */
    for (i = 0; i < errors.level; i++) {
        printf("0x%08lx - %s\n",
            (unsigned long) errors.offset[i], errors.error[i]);
    }
}
Ejemplo n.º 3
0
void printSkipped(uint64_t bytes, uint64_t offset)
{
    char body[80];
    sprintf(body, "Skipped %llu bytes (resuming at 0x%08llx)",
            (unsigned long long) bytes, (unsigned long long) offset);
    printCentered(4, 80, body);
}
Ejemplo n.º 4
0
void printValid(uint64_t ops, uint64_t bytes)
{
    char body[80];
    sprintf(body, "Processed %llu valid opcodes (in %llu bytes)",
            (unsigned long long) ops, (unsigned long long) bytes);
    printCentered(4, 80, body);
}
Ejemplo n.º 5
0
void __fastcall__ drawMenuItem(char i)
{
  char y = MENU_Y + (i<<1);
  char *itemStr = caMenus[menu][i];
  if (i != item)
  {
    textcolor(TEXT_COLOR);
    cputsxy(0, y, "                      ");
  }
  else
  {
    textcolor(HILITE_COLOR);
    cputsxy(0, y, "@                     ");
  }
  printCentered(itemStr, y);
}
Ejemplo n.º 6
0
void viewTOTPcode(totp* tkn) {
  unsigned short key = 0; int keyCol, keyRow;
  Bdisp_AllClr_VRAM();
  drawScreenTitle(tkn->name);
  int shown_since_beginning = 0;
  while(key != KEY_PRGM_EXIT && key != KEY_PRGM_LEFT) {
    int ThirtySecCode = computeTOTP(tkn);
    char buffer[10];
    itoa_zeropad(tkn->totpcode, buffer, 6);
    long long int ms_spent_ll = currentUTCUEBT() - (long long int)ThirtySecCode * 30LL * 1000LL;
    int ms_spent = (int)(ms_spent_ll);

    drawCircularCountdownIndicator(LCD_WIDTH_PX/2, 104, 44, COLOR_BLACK, COLOR_WHITE,
                                   (ms_spent*43)/30000, getCurrentSecond() < 30 ? 0 : 1);
    // fade in/out animation for text
    int val = 0;
    if(ms_spent >= 29000) {
      val += (-29000 + ms_spent)/4;
    } else if (ms_spent <= 1020) {
      val += (1020 - ms_spent)/4;
    }
    int color = drawRGB24toRGB565(val, val, val);
    printCentered(buffer, 164, color, COLOR_WHITE);
    if(ms_spent < 2500) shown_since_beginning = 1;
    else if(ms_spent < 15000 && shown_since_beginning)
      DefineStatusMessage((char*)totpHelpMessages[(ms_spent-2500)/2500], 1, 0, 0);
    else
      DefineStatusMessage((char*)"", 1, 0, 0);
    DisplayStatusArea();
    Bdisp_PutDisp_DD();
    key = PRGM_GetKey();
    if(key == KEY_PRGM_MENU)
      GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); //this is here to handle the Menu key
    if(key == KEY_PRGM_OPTN) {
      DefineStatusMessage((char*)"", 1, 0, 0);
      GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); // clear keybuffer
      RTCunadjustedWizard(0, 1);
      setTimezone();
      return; // so we don't have to redraw etc.
      // Also, this way the Shift+Menu instruction shown in the adjustment wizard becomes vali
      // immediately, which is great if the user wants to repeat the adjustment.
    }
  }
  DefineStatusMessage((char*)"", 1, 0, 0);
  // clear keybuffer:
  GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key);
}
Ejemplo n.º 7
0
int doMenu(Menu* menu, MenuItemIcon* icontable) { // returns code telling what user did. selection is on menu->selection. menu->selection starts at 1!
  int itemsStartY=menu->startY; // char Y where to start drawing the menu items. Having a title increases this by one
  int itemsHeight=menu->height;
  int showtitle = menu->title != NULL;
  if (showtitle) {
    itemsStartY++;
    itemsHeight--;
  }

  if(menu->selection > menu->scroll+(menu->numitems>itemsHeight ? itemsHeight : menu->numitems))
    menu->scroll = menu->selection -(menu->numitems>itemsHeight ? itemsHeight : menu->numitems);
  if(menu->selection-1 < menu->scroll)
    menu->scroll = menu->selection -1;
  
  while(1) {
    if(menu->statusText != NULL) DefineStatusMessage(menu->statusText, 1, 0, 0);
    // Clear the area of the screen we are going to draw on
    if(0 == menu->pBaRtR) drawRectangle(18*(menu->startX-1), 24*(menu->miniMiniTitle ? itemsStartY:menu->startY), 18*menu->width+(menu->scrollbar && menu->scrollout?6:0), 24*menu->height-(menu->miniMiniTitle ? 24:0), COLOR_WHITE);
    if (menu->numitems>0) {
      for(int curitem=0; curitem < menu->numitems; curitem++) {
        // print the menu item only when appropriate
        if(menu->scroll < curitem+1 && menu->scroll > curitem-itemsHeight) {
          char menuitem[70] = "";
          if(menu->type == MENUTYPE_MULTISELECT) strcpy(menuitem, "  "); //allow for the folder and selection icons on MULTISELECT menus (e.g. file browser)
          strncat(menuitem, menu->items[curitem].text, 68);
          if(menu->items[curitem].type != MENUITEM_SEPARATOR) {
            //make sure we have a string big enough to have background when item is selected:          
            // MB_ElementCount is used instead of strlen because multibyte chars count as two with strlen, while graphically they are just one char, making fillerRequired become wrong
            int fillerRequired = menu->width - MB_ElementCount(menu->items[curitem].text) - (menu->type == MENUTYPE_MULTISELECT ? 2 : 0);
            for(int i = 0; i < fillerRequired; i++) strcat(menuitem, " ");
            mPrintXY(menu->startX,curitem+itemsStartY-menu->scroll,(char*)menuitem, (menu->selection == curitem+1 ? TEXT_MODE_INVERT : TEXT_MODE_TRANSPARENT_BACKGROUND), menu->items[curitem].color);
          } else {
            /*int textX = (menu->startX-1) * 18;
            int textY = curitem*24+itemsStartY*24-menu->scroll*24-24+6;
            clearLine(menu->startX, curitem+itemsStartY-menu->scroll, (menu->selection == curitem+1 ? textColorToFullColor(menu->items[curitem].color) : COLOR_WHITE));
            drawLine(textX, textY+24-4, LCD_WIDTH_PX-2, textY+24-4, COLOR_GRAY);
            PrintMini(&textX, &textY, (unsigned char*)menuitem, 0, 0xFFFFFFFF, 0, 0, (menu->selection == curitem+1 ? COLOR_WHITE : textColorToFullColor(menu->items[curitem].color)), (menu->selection == curitem+1 ? textColorToFullColor(menu->items[curitem].color) : COLOR_WHITE), 1, 0);*/
          }
          // deal with menu items of type MENUITEM_CHECKBOX
          if(menu->items[curitem].type == MENUITEM_CHECKBOX) {
            mPrintXY(menu->startX+menu->width-1,curitem+itemsStartY-menu->scroll,
              (menu->items[curitem].value == MENUITEM_VALUE_CHECKED ? (char*)"\xe6\xa9" : (char*)"\xe6\xa5"),
              (menu->selection == curitem+1 ? TEXT_MODE_INVERT : (menu->pBaRtR == 1? TEXT_MODE_TRANSPARENT_BACKGROUND : TEXT_MODE_NORMAL)), menu->items[curitem].color);
          }
          // deal with multiselect menus
          if(menu->type == MENUTYPE_MULTISELECT) {
            if((curitem+itemsStartY-menu->scroll)>=itemsStartY &&
              (curitem+itemsStartY-menu->scroll)<=(itemsStartY+itemsHeight) &&
              icontable != NULL
            ) {
              if (menu->items[curitem].isfolder == 1) {
                // assumes first icon in icontable is the folder icon
                CopySpriteMasked(icontable[0].data, (menu->startX)*18, (curitem+itemsStartY-menu->scroll)*24, 0x12, 0x18, 0xf81f  );
              } else {
                if(menu->items[curitem].icon >= 0) CopySpriteMasked(icontable[menu->items[curitem].icon].data, (menu->startX)*18, (curitem+itemsStartY-menu->scroll)*24, 0x12, 0x18, 0xf81f  );
              }
            }
            if (menu->items[curitem].isselected) {
              if (menu->selection == curitem+1) {
                mPrintXY(menu->startX,curitem+itemsStartY-menu->scroll,(char*)"\xe6\x9b", TEXT_MODE_TRANSPARENT_BACKGROUND, (menu->items[curitem].color ==  TEXT_COLOR_GREEN ? TEXT_COLOR_BLUE : TEXT_COLOR_GREEN));
              } else {
                mPrintXY(menu->startX,curitem+itemsStartY-menu->scroll,(char*)"\xe6\x9b", TEXT_MODE_NORMAL, TEXT_COLOR_PURPLE);
              }
            }
          }
        }
      }
      if (menu->scrollbar) {
        TScrollbar sb;
        sb.I1 = 0;
        sb.I5 = 0;
        sb.indicatormaximum = menu->numitems;
        sb.indicatorheight = itemsHeight;
        sb.indicatorpos = menu->scroll;
        sb.barheight = itemsHeight*24;
        sb.bartop = (itemsStartY-1)*24;
        sb.barleft = menu->startX*18+menu->width*18 - 18 - (menu->scrollout ? 0 : 5);
        sb.barwidth = 6;
        Scrollbar(&sb);
      }
      //if(menu->type==MENUTYPE_MULTISELECT && menu->fkeypage == 0) drawFkeyLabels(0x0037); // SELECT (white)
    } else {
      printCentered((unsigned char*)menu->nodatamsg, (itemsStartY*24)+(itemsHeight*24)/2-12, COLOR_BLACK, COLOR_WHITE);
    }
    if(showtitle) {
      if(menu->miniMiniTitle) {
        int textX = 0, textY=(menu->startY-1)*24;
        PrintMiniMini( &textX, &textY, (unsigned char*)menu->title, 16, menu->titleColor, 0 );
      } else mPrintXY(menu->startX, menu->startY, menu->title, TEXT_MODE_TRANSPARENT_BACKGROUND, menu->titleColor);
      if(menu->subtitle != NULL) {
        int textX=(MB_ElementCount(menu->title)+menu->startX-1)*18+10, textY=6;
        PrintMini(&textX, &textY, (unsigned char*)menu->subtitle, 0, 0xFFFFFFFF, 0, 0, COLOR_BLACK, COLOR_WHITE, 1, 0);
      }
    }
    /*if(menu->darken) {
      DrawFrame(COLOR_BLACK);
      VRAMInvertArea(menu->startX*18-18, menu->startY*24, menu->width*18-(menu->scrollout || !menu->scrollbar ? 0 : 5), menu->height*24);
    }*/
    if(menu->type == MENUTYPE_NO_KEY_HANDLING) return MENU_RETURN_INSTANT; // we don't want to handle keys
    int key;
    GetKey(&key);
    switch(key) {
      case KEY_CTRL_DOWN:
        if(menu->selection == menu->numitems)
        {
          if(menu->returnOnInfiniteScrolling) {
            return MENU_RETURN_SCROLLING;
          } else {
            menu->selection = 1;
            menu->scroll = 0;
          }
        }
        else
        {
          menu->selection++;
          if(menu->selection > menu->scroll+(menu->numitems>itemsHeight ? itemsHeight : menu->numitems))
            menu->scroll = menu->selection -(menu->numitems>itemsHeight ? itemsHeight : menu->numitems);
        }
        if(menu->pBaRtR==1) return MENU_RETURN_INSTANT;
        break;
      case KEY_CTRL_UP:
        if(menu->selection == 1)
        {
          if(menu->returnOnInfiniteScrolling) {
            return MENU_RETURN_SCROLLING;
          } else {
            menu->selection = menu->numitems;
            menu->scroll = menu->selection-(menu->numitems>itemsHeight ? itemsHeight : menu->numitems);
          }
        }
        else
        {
          menu->selection--;
          if(menu->selection-1 < menu->scroll)
            menu->scroll = menu->selection -1;
        }
        if(menu->pBaRtR==1) return MENU_RETURN_INSTANT;
        break;
      case KEY_CTRL_F1:
        if(menu->type==MENUTYPE_MULTISELECT && menu->fkeypage == 0 && menu->numitems > 0) {
          /*if(menu->items[menu->selection-1].isselected) {
            menu->items[menu->selection-1].isselected=0;
            menu->numselitems = menu->numselitems-1;
          } else {
            menu->items[menu->selection-1].isselected=1;
            menu->numselitems = menu->numselitems+1;
          }
          return key; //return on F1 too so that parent subroutines have a chance to e.g. redraw fkeys*/
        } else if (menu->type == MENUTYPE_FKEYS) {
          return key;
        }
        break;
      case KEY_CTRL_F2:
      case KEY_CTRL_F3:
      case KEY_CTRL_F4:
      case KEY_CTRL_F5:
      case KEY_CTRL_F6:
        if (menu->type == MENUTYPE_FKEYS || menu->type==MENUTYPE_MULTISELECT) return key; // MULTISELECT also returns on Fkeys
        break;
      case KEY_CTRL_PASTE:
        if (menu->type==MENUTYPE_MULTISELECT) return key; // MULTISELECT also returns on paste
      case KEY_CTRL_OPTN:
        if (menu->type==MENUTYPE_FKEYS || menu->type==MENUTYPE_MULTISELECT) return key;
        break;
      case KEY_CTRL_FORMAT:
        if (menu->type==MENUTYPE_FKEYS) return key; // return on the Format key so that event lists can prompt to change event category
        break;
      case KEY_CTRL_RIGHT:
        if(menu->type != MENUTYPE_MULTISELECT) break;
        // else fallthrough
      case KEY_CTRL_EXE:
        if(menu->numitems>0) return MENU_RETURN_SELECTION;
        break;
      case KEY_CTRL_LEFT:
        if(menu->type != MENUTYPE_MULTISELECT) break;
        // else fallthrough
      case KEY_CTRL_EXIT: return MENU_RETURN_EXIT;
        break;
      case KEY_CHAR_1:
      case KEY_CHAR_2:
      case KEY_CHAR_3:
      case KEY_CHAR_4:
      case KEY_CHAR_5:
      case KEY_CHAR_6:
      case KEY_CHAR_7:
      case KEY_CHAR_8:
      case KEY_CHAR_9:
        if(menu->numitems>=(key-0x30)) {menu->selection = (key-0x30); return MENU_RETURN_SELECTION; }
        break;
      case KEY_CHAR_0:
        if(menu->numitems>=10) {menu->selection = 10; return MENU_RETURN_SELECTION; }
        break;
      case KEY_CTRL_XTT:
        if(menu->numitems>=11) {menu->selection = 11; return MENU_RETURN_SELECTION; }
        break;
      case KEY_CHAR_LOG:
        if(menu->numitems>=12) {menu->selection = 12; return MENU_RETURN_SELECTION; }
        break;
      case KEY_CHAR_LN:
        if(menu->numitems>=13) {menu->selection = 13; return MENU_RETURN_SELECTION; }
        break;
      case KEY_CHAR_SIN:
      case KEY_CHAR_COS:
      case KEY_CHAR_TAN:
        if(menu->numitems>=(key-115)) {menu->selection = (key-115); return MENU_RETURN_SELECTION; }
        break;
      case KEY_CHAR_FRAC:
        if(menu->numitems>=17) {menu->selection = 17; return MENU_RETURN_SELECTION; }
        break;
      case KEY_CTRL_FD:
        if(menu->numitems>=18) {menu->selection = 18; return MENU_RETURN_SELECTION; }
        break;
      case KEY_CHAR_LPAR:
      case KEY_CHAR_RPAR:
        if(menu->numitems>=(key-21)) {menu->selection = (key-21); return MENU_RETURN_SELECTION; }
        break;
      case KEY_CHAR_COMMA:
        if(menu->numitems>=21) {menu->selection = 21; return MENU_RETURN_SELECTION; }
        break;
      case KEY_CHAR_STORE:
        if(menu->numitems>=22) {menu->selection = 22; return MENU_RETURN_SELECTION; }
        break;
    }
  }
  return MENU_RETURN_EXIT;
}
Ejemplo n.º 8
0
void printSkipped(uint64_t bytes, uint64_t offset) {
    char body[80];
    sprintf(body, "Skipped %llu bytes (resuming at 0x%08llx)",
        (PORT_ULONGLONG) bytes, (PORT_ULONGLONG) offset);
    printCentered(4, 80, body);
}
Ejemplo n.º 9
0
void printValid(uint64_t ops, uint64_t bytes) {
    char body[80];
    sprintf(body, "Processed %llu valid opcodes (in %llu bytes)",
        (PORT_ULONGLONG) ops, (PORT_ULONGLONG) bytes);
    printCentered(4, 80, body);
}
Ejemplo n.º 10
0
/**
 * print the provided string and draw the bar with provided percent
 *
 * @param string:	the string to write to
 * @param y:		the y postion of the screen
 * @param color:	the color for the string
 */
void PrettyBoot::updateStatus(const char *string, int percent, uint8_t color)
{
	printCentered(KERNEL_NAME, 0, 32);
	printProgressBar(percent, color);
	printCentered(string, 20, 0x07);
}
Ejemplo n.º 11
0
/**
 * called in case of fail, print a red bar
 *
 * @param string:	the error string to print
 */
void PrettyBoot::fail(const char *string)
{
	printCentered(KERNEL_NAME, 0, 32);
	printProgressBar(100, 0xC0);
	printCentered(string, 20, RED);
}
Ejemplo n.º 12
0
static void printCopyright(FILE *fp)
{
    static const char * const Contributors[] = {
        "Emile Apol",
        "Rossen Apostolov",
        "Herman J.C. Berendsen",
        "Par Bjelkmar",
        "Aldert van Buuren",
        "Rudi van Drunen",
        "Anton Feenstra",
        "Sebastian Fritsch",
        "Gerrit Groenhof",
        "Christoph Junghans",
        "Peter Kasson",
        "Carsten Kutzner",
        "Per Larsson",
        "Justin A. Lemkul",
        "Magnus Lundborg",
        "Pieter Meulenhoff",
        "Erik Marklund",
        "Teemu Murtola",
        "Szilard Pall",
        "Sander Pronk",
        "Roland Schulz",
        "Alexey Shvetsov",
        "Michael Shirts",
        "Alfons Sijbers",
        "Peter Tieleman",
        "Christian Wennberg",
        "Maarten Wolf"
    };
    static const char * const CopyrightText[] = {
        "Copyright (c) 1991-2000, University of Groningen, The Netherlands.",
        "Copyright (c) 2001-2015, The GROMACS development team at",
        "Uppsala University, Stockholm University and",
        "the Royal Institute of Technology, Sweden.",
        "check out http://www.gromacs.org for more information."
    };
    static const char * const LicenseText[] = {
        "GROMACS is free software; you can redistribute it and/or modify it",
        "under the terms of the GNU Lesser General Public License",
        "as published by the Free Software Foundation; either version 2.1",
        "of the License, or (at your option) any later version."
    };

#define NCONTRIBUTORS (int)asize(Contributors)
#define NCR (int)asize(CopyrightText)

// FAH has an exception permission from LGPL to allow digital signatures in Gromacs.
#ifdef GMX_FAHCORE
#define NLICENSE 0
#else
#define NLICENSE (int)asize(LicenseText)
#endif

    printCentered(fp, 78, "GROMACS is written by:");
    fprintf(fp, "\n");
    for (int i = 0; i < NCONTRIBUTORS; )
    {
        for (int j = 0; j < 4 && i < NCONTRIBUTORS; ++j, ++i)
        {
            const int width = 18;
            char      buf[30];
            const int offset = centeringOffset(width, strlen(Contributors[i]));
            GMX_RELEASE_ASSERT(strlen(Contributors[i]) + offset < asize(buf),
                               "Formatting buffer is not long enough");
            std::fill(buf, buf+width, ' ');
            std::strcpy(buf+offset, Contributors[i]);
            fprintf(fp, " %-*s", width, buf);
        }
        fprintf(fp, "\n");
    }
    printCentered(fp, 78, "and the project leaders:");
    fprintf(fp, "\n");
    printCentered(fp, 78, "Mark Abraham, Berk Hess, Erik Lindahl, and David van der Spoel");
    fprintf(fp, "\n\n");
    for (int i = 0; i < NCR; ++i)
    {
        fprintf(fp, "%s\n", CopyrightText[i]);
    }
    fprintf(fp, "\n");
    for (int i = 0; i < NLICENSE; ++i)
    {
        fprintf(fp, "%s\n", LicenseText[i]);
    }
}