int main(void) { char key; timerInitTOD(); screenInit(); progressInit(); g_strFileName[0] = '\0'; g_nDrive = *(uint8_t*)0xba; if (g_nDrive < 8) g_nDrive = 8; internalCartType = INTERNAL_CART_TYPE_NONE; g_bFastLoaderEnabled = 1; updateFastLoaderText(); refreshMainScreen(); showAbout(); refreshMainScreen(); screenBing(); // this also makes visible 16kByte of flash memory checkFlashType(); checkRAM(); for (;;) { setStatus("Ready. Press <m> for Menu."); key = cgetc(); switch (key) { case 'm': execMenu(&menuMain); break; case 'o': execMenu(&menuOptions); break; case 'e': execMenu(&menuExpert); break; case 'h': execMenu(&menuHelp); break; } } return 0; }
/** * Return the string entered. The maximal length of the string is * FILENAME_MAX, i.e. 16+1. */ const char* __fastcall__ screenReadInput(const char* pStrTitle, const char* pStrDefault) { uint8_t len; static char strInput[FILENAME_MAX]; char c; screenBing(); strcpy(strInput, pStrDefault); len = strlen(strInput); screenPrintBox(2, 6, 36, 12); screenPrintSepLine(2, 37, 8); cputsxy(3, 7, pStrTitle); // the input field textcolor(COLOR_LIGHTFRAME); screenPrintBox(4, 10, 32, 3); textcolor(COLOR_FOREGROUND); screenPrintButton(30, 14, "Enter"); cursor(1); do { cputsxy(5, 11, strInput); cputc(' '); gotox(5 + len); c = cgetc(); if (len < sizeof(strInput) - 1 && ((c >= 32 && c < 128) || (c >= 192 && c < 224)) ) { strInput[len++] = c; strInput[len] = '\0'; } else if (c == CH_DEL) { if (len) strInput[--len] = '\0'; } } while (c != CH_ENTER); cursor(0); refreshMainScreen(); return strInput; }
/** * Print a dialog with some text lines and wait for a key if a flag is set. * The array of lines apStrLines must be terminated with a NULL pointer. * * flags may contain BUTTON_ENTER and/or BUTTON_STOP. * return the button which has been pressed */ uint8_t __fastcall__ screenPrintDialog(const char* apStrLines[], uint8_t flags) { uint8_t y, t; uint8_t nLines; uint8_t nLongestLength = 1; uint8_t xStart, xEnd, yStart, yEnd; for (y = 0; apStrLines[y]; ++y) { t = strlen(apStrLines[y]); if (t > nLongestLength) nLongestLength = t; } nLines = y; if (nLongestLength > 38) nLongestLength = 38; nLongestLength += 2; xStart = 20 - nLongestLength / 2; xEnd = 20 + nLongestLength / 2; yStart = 7 - nLines / 2; yEnd = 7 + nLines / 2 + 9; // Top line y = yStart; screenPrintTopLine(xStart, xEnd, y); screenPrintFreeLine(xStart, xEnd, ++y); cputsxy(xStart + 1, y, "EasyProg"); screenPrintSepLine(xStart, xEnd, ++y); // some lines for (++y; y < yEnd; ++y) screenPrintFreeLine(xStart, xEnd, y); // Bottom line screenPrintBottomLine(xStart, xEnd, y); // Write the text lines yStart += 4; ++xStart; for (y = 0; y < nLines; ++y) { t = strlen(apStrLines[y]); if (t > 38) continue; cputsxy(xStart, yStart++, apStrLines[y]); } y = yEnd - 3; if (flags & BUTTON_ENTER) screenPrintButton(xEnd - 7, yEnd - 3, "Enter"); if (flags & BUTTON_STOP) screenPrintButton(xStart, yEnd - 3, "Stop"); screenBing(); if (flags) return screenWaitKey(flags); return 0; }