void SensorWidget::paintKeyStates() { const KeyStates& data = sensorView.keyStates; print("Key states:", ""); print(" Head front", printButton(data.pressed[KeyStates::headFront])); print(" Head middle", printButton(data.pressed[KeyStates::headMiddle])); print(" Head rear", printButton(data.pressed[KeyStates::headRear])); print(" Left hand back", printButton(data.pressed[KeyStates::lHandBack])); print(" Left hand left", printButton(data.pressed[KeyStates::lHandLeft])); print(" Left hand right", printButton(data.pressed[KeyStates::lHandRight])); print(" Right hand back", printButton(data.pressed[KeyStates::rHandBack])); print(" Right hand left", printButton(data.pressed[KeyStates::rHandLeft])); print(" Right hand right", printButton(data.pressed[KeyStates::rHandRight])); print(" Left foot left", printButton(data.pressed[KeyStates::leftFootLeft])); print(" Left foot right", printButton(data.pressed[KeyStates::leftFootRight])); print(" Right foot left", printButton(data.pressed[KeyStates::rightFootLeft])); print(" Right foot right", printButton(data.pressed[KeyStates::rightFootRight])); print(" Chest", printButton(data.pressed[KeyStates::chest])); }
toMain::toMain() : toMainWindow() { qApp->setMainWidget ( this ); setDockMenuEnabled ( true ); Edit = NULL; FileMenu = new QPopupMenu ( this ); FileMenu->insertItem ( QPixmap ( ( const char ** ) connect_xpm ), "&New Connection...", TO_NEW_CONNECTION ); FileMenu->insertItem ( QPixmap ( ( const char ** ) disconnect_xpm ), "&Close Connection", this, SLOT ( delConnection() ), 0, TO_CLOSE_CONNECTION ); FileMenu->insertSeparator(); FileMenu->insertItem ( QPixmap ( ( const char ** ) commit_xpm ), "&Commit Connection", TO_FILE_COMMIT ); FileMenu->insertItem ( QPixmap ( ( const char ** ) rollback_xpm ), "&Rollback Connection", TO_FILE_ROLLBACK ); FileMenu->insertItem ( "C&urrent Connection", TO_FILE_CURRENT ); FileMenu->insertItem ( QPixmap ( ( const char ** ) trash_xpm ), "Reread Object Cache", TO_FILE_CLEARCACHE ); FileMenu->insertSeparator(); FileMenu->insertItem ( QPixmap ( ( const char ** ) fileopen_xpm ), "&Open File...", TO_FILE_OPEN ); FileMenu->insertItem ( QPixmap ( ( const char ** ) filesave_xpm ), "&Save", TO_FILE_SAVE ); FileMenu->insertItem ( "Save A&s...", TO_FILE_SAVE_AS ); FileMenu->insertSeparator(); FileMenu->insertItem ( QPixmap ( ( const char ** ) print_xpm ), "&Print..", TO_FILE_PRINT ); FileMenu->insertSeparator(); FileMenu->insertItem ( "&Quit", TO_FILE_QUIT ); menuBar() ->insertItem ( "&File", FileMenu, TO_FILE_MENU ); FileMenu->setAccel ( Key_G | CTRL, TO_NEW_CONNECTION ); FileMenu->setAccel ( Key_O | CTRL, TO_FILE_OPEN ); FileMenu->setAccel ( Key_S | CTRL, TO_FILE_SAVE ); FileMenu->setAccel ( Key_W | CTRL, TO_FILE_COMMIT ); FileMenu->setAccel ( Key_R | CTRL, TO_FILE_ROLLBACK ); FileMenu->setAccel ( Key_U | CTRL, TO_FILE_CURRENT ); connect ( FileMenu, SIGNAL ( aboutToShow() ), this, SLOT ( editFileMenu() ) ); EditMenu = new QPopupMenu ( this ); EditMenu->insertItem ( QPixmap ( ( const char ** ) undo_xpm ), "&Undo", TO_EDIT_UNDO ); EditMenu->insertItem ( QPixmap ( ( const char ** ) redo_xpm ), "&Redo", TO_EDIT_REDO ); EditMenu->insertSeparator(); EditMenu->insertItem ( QPixmap ( ( const char ** ) cut_xpm ), "Cu&t", TO_EDIT_CUT ); EditMenu->insertItem ( QPixmap ( ( const char ** ) copy_xpm ), "&Copy", TO_EDIT_COPY ); EditMenu->insertItem ( QPixmap ( ( const char ** ) paste_xpm ), "&Paste", TO_EDIT_PASTE ); EditMenu->insertSeparator(); EditMenu->insertItem ( "&Search && Replace", TO_EDIT_SEARCH ); EditMenu->insertItem ( "Search &Next", TO_EDIT_SEARCH_NEXT ); EditMenu->insertItem ( "Select &All", TO_EDIT_SELECT_ALL ); EditMenu->insertItem ( "Read All &Items", TO_EDIT_READ_ALL ); EditMenu->insertSeparator(); EditMenu->insertItem ( "&Options...", TO_EDIT_OPTIONS ); EditMenu->setAccel ( Key_Z | CTRL, TO_EDIT_UNDO ); EditMenu->setAccel ( Key_Y | CTRL, TO_EDIT_REDO ); EditMenu->setAccel ( Key_X | CTRL, TO_EDIT_CUT ); EditMenu->setAccel ( Key_C | CTRL, TO_EDIT_COPY ); EditMenu->setAccel ( Key_V | CTRL, TO_EDIT_PASTE ); EditMenu->setAccel ( Key_F | CTRL, TO_EDIT_SEARCH ); EditMenu->setAccel ( Key_F3, TO_EDIT_SEARCH_NEXT ); connect ( EditMenu, SIGNAL ( aboutToShow() ), this, SLOT ( editFileMenu() ) ); menuBar() ->insertItem ( "&Edit", EditMenu, TO_EDIT_MENU ); std::map<QString, toTool *> &tools = toTool::tools(); QToolBar *toolbar = toAllocBar ( this, "Application", QString::null ); LoadButton = new QToolButton ( QPixmap ( ( const char ** ) fileopen_xpm ), "Load file into editor", "Load file into editor", this, SLOT ( loadButton() ), toolbar ); SaveButton = new QToolButton ( QPixmap ( ( const char ** ) filesave_xpm ), "Save file from editor", "Save file from editor", this, SLOT ( saveButton() ), toolbar ); PrintButton = new QToolButton ( QPixmap ( ( const char ** ) print_xpm ), "Print", "Print", this, SLOT ( printButton() ), toolbar ); PrintButton->setEnabled ( false ); LoadButton->setEnabled ( false ); SaveButton->setEnabled ( false ); toolbar->addSeparator(); UndoButton = new QToolButton ( QPixmap ( ( const char ** ) undo_xpm ), "Undo", "Undo", this, SLOT ( undoButton() ), toolbar ); RedoButton = new QToolButton ( QPixmap ( ( const char ** ) redo_xpm ), "Redo", "Redo", this, SLOT ( redoButton() ), toolbar ); CutButton = new QToolButton ( QPixmap ( ( const char ** ) cut_xpm ), "Cut to clipboard", "Cut to clipboard", this, SLOT ( cutButton() ), toolbar ); CopyButton = new QToolButton ( QPixmap ( ( const char ** ) copy_xpm ), "Copy to clipboard", "Copy to clipboard", this, SLOT ( copyButton() ), toolbar ); PasteButton = new QToolButton ( QPixmap ( ( const char ** ) paste_xpm ), "Paste from clipboard", "Paste from clipboard", this, SLOT ( pasteButton() ), toolbar ); UndoButton->setEnabled ( false ); RedoButton->setEnabled ( false ); CutButton->setEnabled ( false ); CopyButton->setEnabled ( false ); PasteButton->setEnabled ( false ); ToolsMenu = new QPopupMenu ( this ); #ifdef TOOL_TOOLBAR toolbar = new toAllocBar ( this, "Tools", QString::null ); #else toolbar->addSeparator(); #endif int toolID = TO_TOOLS; int lastPriorityPix = 0; int lastPriorityMenu = 0; SQLEditor = -1; DefaultTool = toolID; QString defName = toTool::globalConfig ( CONF_DEFAULT_TOOL, "" ); HelpMenu = new QPopupMenu ( this ); HelpMenu->insertItem ( "C&urrent Context", TO_HELP_CONTEXT ); HelpMenu->insertItem ( "&Contents", TO_HELP_CONTENTS ); HelpMenu->insertSeparator(); HelpMenu->insertItem ( "&About TOra", TO_HELP_ABOUT ); HelpMenu->insertItem ( "&License", TO_HELP_LICENSE ); HelpMenu->insertItem ( "&Quotes", TO_HELP_QUOTES ); HelpMenu->setAccel ( Key_F1, TO_HELP_CONTEXT ); if ( !toFreeware() ) { HelpMenu->insertSeparator(); HelpMenu->insertItem ( "&Register", TO_HELP_REGISTER ); } QPopupMenu *toolAbout = NULL; for ( std::map<QString, toTool *>::iterator i = tools.begin();i != tools.end();i++ ) { const QPixmap *pixmap = ( *i ).second->toolbarImage(); const char *toolTip = ( *i ).second->toolbarTip(); const char *menuName = ( *i ).second->menuItem(); QString tmp = ( *i ).second->name(); tmp += CONF_TOOL_ENABLE; if ( toTool::globalConfig ( tmp, "Yes" ).isEmpty() ) continue; if ( defName == menuName ) DefaultTool = toolID; int priority = ( *i ).second->priority(); if ( priority / 100 != lastPriorityPix / 100 && pixmap ) { toolbar->addSeparator(); lastPriorityPix = priority; } if ( priority / 100 != lastPriorityMenu / 100 && menuName ) { ToolsMenu->insertSeparator(); lastPriorityMenu = priority; } if ( pixmap ) { if ( !toolTip ) toolTip = ""; NeedConnection[new QToolButton ( *pixmap, toolTip, toolTip, ( *i ).second, SLOT ( createWindow ( void ) ), toolbar ) ] = ( *i ).second; } if ( menuName ) { if ( pixmap ) ToolsMenu->insertItem ( *pixmap, menuName, toolID ); else ToolsMenu->insertItem ( menuName, toolID ); ToolsMenu->setItemEnabled ( toolID, false ); } if ( ( *i ).second->hasAbout() && menuName ) { if ( !toolAbout ) { toolAbout = new QPopupMenu ( this ); HelpMenu->insertItem ( "Tools", toolAbout ); } if ( pixmap ) toolAbout->insertItem ( *pixmap, menuName, toolID + TO_ABOUT_ID_OFFSET ); else toolAbout->insertItem ( menuName, toolID + TO_ABOUT_ID_OFFSET ); } Tools[toolID] = ( *i ).second; toolID++; } #ifndef TOOL_TOOLBAR toolbar->setStretchableWidget ( new QLabel ( "", toolbar ) ); #endif new QToolButton ( QPixmap ( ( const char ** ) connect_xpm ), "Connect to database", "Connect to database", this, SLOT ( addConnection() ), toolbar ); DisconnectButton = new QToolButton ( QPixmap ( ( const char ** ) disconnect_xpm ), "Disconnect current connection", "Disconnect current connection", this, SLOT ( delConnection() ), toolbar ); DisconnectButton->setEnabled ( false ); toolbar->addSeparator(); NeedConnection[new QToolButton ( QPixmap ( ( const char ** ) commit_xpm ), "Commit connection", "Commit connection", this,SLOT ( commitButton() ),toolbar ) ] = NULL; NeedConnection[new QToolButton ( QPixmap ( ( const char ** ) rollback_xpm ), "Rollback connection", "Rollback connection", this,SLOT ( rollbackButton() ),toolbar ) ] = NULL; toolbar->addSeparator(); ConnectionSelection = new QComboBox ( toolbar ); ConnectionSelection->setFixedWidth ( 200 ); ConnectionSelection->setFocusPolicy ( NoFocus ); connect ( ConnectionSelection, SIGNAL ( activated ( int ) ), this, SLOT ( changeConnection() ) ); menuBar() ->insertItem ( "&Tools", ToolsMenu, TO_TOOLS_MENU ); WindowsMenu = new QPopupMenu ( this ); WindowsMenu->setCheckable ( true ); connect ( WindowsMenu, SIGNAL ( aboutToShow() ), this, SLOT ( windowsMenu() ) ); menuBar() ->insertItem ( "&Window", WindowsMenu, TO_WINDOWS_MENU ); menuBar() ->insertSeparator(); menuBar() ->insertItem ( "&Help", HelpMenu, TO_HELP_MENU ); char buffer[100]; sprintf ( buffer, DEFAULT_TITLE, TOVERSION ); setCaption ( buffer ); #ifdef TO_KDE KDockWidget *mainDock = createDockWidget ( buffer, QPixmap ( ( const char ** ) toramini_xpm ) ); Workspace = new QWorkspace ( mainDock ); mainDock->setWidget ( Workspace ); setView ( mainDock ); setMainDockWidget ( mainDock ); mainDock->setEnableDocking ( KDockWidget::DockNone ); #else Workspace = new QWorkspace ( this ); setCentralWidget ( Workspace ); #endif setIcon ( QPixmap ( ( const char ** ) toramini_xpm ) ); statusBar() ->message ( "Ready" ); menuBar() ->setItemEnabled ( TO_CLOSE_CONNECTION, false ); menuBar() ->setItemEnabled ( TO_FILE_COMMIT, false ); menuBar() ->setItemEnabled ( TO_FILE_ROLLBACK, false ); menuBar() ->setItemEnabled ( TO_FILE_CLEARCACHE, false ); DisconnectButton->setEnabled ( false ); for ( std::map<QToolButton *, toTool *>::iterator j = NeedConnection.begin(); j != NeedConnection.end();j++ ) ( *j ).first->setEnabled ( false ); connect ( menuBar(), SIGNAL ( activated ( int ) ), this, SLOT ( commandCallback ( int ) ) ); RowLabel = new QLabel ( statusBar() ); statusBar() ->addWidget ( RowLabel, 0, true ); RowLabel->setMinimumWidth ( 60 ); RowLabel->hide(); ColumnLabel = new QLabel ( statusBar() ); statusBar() ->addWidget ( ColumnLabel, 0, true ); ColumnLabel->setMinimumWidth ( 60 ); ColumnLabel->hide(); QToolButton *dispStatus = new toPopupButton ( statusBar() ); dispStatus->setIconSet ( QPixmap ( ( const char ** ) up_xpm ) ); statusBar() ->addWidget ( dispStatus, 0, true ); StatusMenu = new QPopupMenu ( dispStatus ); dispStatus->setPopup ( StatusMenu ); connect ( StatusMenu, SIGNAL ( aboutToShow() ), this, SLOT ( statusMenu() ) ); connect ( StatusMenu, SIGNAL ( activated ( int ) ), this, SLOT ( commandCallback ( int ) ) ); toolID = TO_TOOLS; for ( std::map<QString, toTool *>::iterator k = tools.begin();k != tools.end();k++ ) { ( *k ).second->customSetup ( toolID ); toolID++; } Search = NULL; if ( !toTool::globalConfig ( CONF_MAXIMIZE_MAIN, "Yes" ).isEmpty() ) showMaximized(); show(); QString welcome; do { welcome = toCheckLicense ( false ); } while ( welcome.isNull() ); toStatusMessage ( welcome, true ); connect ( &Poll, SIGNAL ( timeout() ), this, SLOT ( checkCaching() ) ); try { toNewConnection newConnection ( this, "First connection", true ); toConnection *conn; do { conn = NULL; if ( newConnection.exec() ) { conn = newConnection.makeConnection(); } else { break; } } while ( !conn ); if ( conn ) addConnection ( conn ); } TOCATCH connect ( toMainWidget() ->workspace(), SIGNAL ( windowActivated ( QWidget * ) ), this, SLOT ( windowActivated ( QWidget * ) ) ); }
void main(void) { uint8_t inputProgramType; char *inputProgram; uint16_t inputProgramSize; ti_var_t programSlot; uint8_t selectedProgram, amountOfPrograms, res = VALID, type; unsigned int programDataSize, offset, totalSize; uint8_t beginList, amountOfProgramsToDisplay; uint8_t relativeSelectedProgram; const char ICEheader[] = {tii, 0}; ti_var_t tempProg; char buf[30], *temp_name = "", var_name[9]; sk_key_t key = 0; void *search_pos; bool didCompile; // Install hooks ti_CloseAll(); if ((tempProg = ti_Open("ICEHOOKS", "r"))) { ti_SetArchiveStatus(true, tempProg); SetHooks(ti_GetDataPtr(tempProg)); } // Enable lowercase asm("ld iy, 0D00080h"); asm("set 3, (iy+024h)"); // check if a program was used as input ti_CloseAll(); ice.usingInputProgram = false; inputProgram = os_RclAns(&inputProgramType); if (inputProgram && inputProgramType == TI_STRING_TYPE && inputProgram[2] == tProg && (inputProgramSize = *(uint16_t*)inputProgram) < 10) { memset(var_name, 0, sizeof var_name); memcpy(var_name, inputProgram + 3, inputProgramSize - 1); programSlot = ti_OpenVar(var_name, "r", TI_PRGM_TYPE); if (programSlot) { ice.usingInputProgram = true; } } // Yay, GUI! :) displayMainScreen: gfx_Begin(); gfx_SetColor(189); gfx_FillRectangle_NoClip(0, 0, 320, 10); gfx_SetColor(0); gfx_SetTextFGColor(0); gfx_HorizLine_NoClip(0, 10, 320); gfx_PrintStringXY(infoStr, 12, 1); // Get all the programs that start with the [i] token selectedProgram = 0; didCompile = false; ti_CloseAll(); if (ice.usingInputProgram) { goto compile_program; } search_pos = NULL; while ((temp_name = ti_DetectAny(&search_pos, ICEheader, &type)) != NULL) { if (type == TI_PRGM_TYPE || type == TI_PPRGM_TYPE) { // Hidden programs if ((uint8_t)(*temp_name) < 64) { *temp_name += 64; } // Save the program name inputPrograms[selectedProgram] = malloc(9); strcpy(inputPrograms[selectedProgram++], temp_name); } if (selectedProgram >= NUMBEROFPROGRAM) { break; } } amountOfPrograms = selectedProgram; beginList = 0; amountOfProgramsToDisplay = (amountOfPrograms > PROGRAMPERSCREEN ? PROGRAMPERSCREEN : amountOfPrograms); // Check if there are ICE programs if (!amountOfPrograms) { gfx_PrintStringXY("No programs found!", 10, 13); goto stop; } // Display all the sorted programs qsort(inputPrograms, amountOfPrograms, sizeof(char *), myCompare); displayProgramList(beginList, amountOfProgramsToDisplay); // Display buttons gfx_PrintStringXY("Build", 4, 232); printButton(1); gfx_PrintStringXY("Debug", 66, 232); printButton(65); gfx_PrintStringXY("Quit", 285, 232); printButton(279); gfx_SetColor(0); // Select a program selectedProgram = 1; relativeSelectedProgram = 1; while ((key = os_GetCSC()) != sk_Enter && key != sk_2nd && key != sk_Yequ && key != sk_Window) { uint8_t selectionOffset = relativeSelectedProgram * 10 + 3; gfx_PrintStringXY(">", 1, selectionOffset); if (key) { gfx_SetColor(255); gfx_FillRectangle_NoClip(1, selectionOffset, 8, 8); // Stop and quit if (key == sk_Clear || key == sk_Graph) { goto err; } // Select the next program if (key == sk_Down) { if (selectedProgram != amountOfPrograms) { selectedProgram++; relativeSelectedProgram++; if (relativeSelectedProgram > PROGRAMPERSCREEN) { clearProgramList(); relativeSelectedProgram--; beginList++; displayProgramList(beginList, amountOfProgramsToDisplay); } } else { clearProgramList(); selectedProgram = 1; relativeSelectedProgram = 1; beginList = 0; displayProgramList(beginList, amountOfProgramsToDisplay); } } // Select the previous program if (key == sk_Up) { if (selectedProgram != 1) { selectedProgram--; relativeSelectedProgram--; if(relativeSelectedProgram == 0) { clearProgramList(); relativeSelectedProgram++; beginList--; displayProgramList(beginList, amountOfProgramsToDisplay); } } else { clearProgramList(); selectedProgram = amountOfPrograms; relativeSelectedProgram = (amountOfPrograms > PROGRAMPERSCREEN ? PROGRAMPERSCREEN : amountOfPrograms); beginList = (selectedProgram >= PROGRAMPERSCREEN ? selectedProgram - PROGRAMPERSCREEN : 0); displayProgramList(beginList, amountOfProgramsToDisplay); } } } } // Set some vars strcpy(var_name, inputPrograms[selectedProgram - 1]); for (selectedProgram = 0; selectedProgram < amountOfPrograms; selectedProgram++) { free(inputPrograms[selectedProgram]); } compile_program: // Erase screen gfx_SetColor(255); gfx_FillRectangle_NoClip(0, 11, 320, 210); gfx_FillRectangle_NoClip(0, 220, 270, 20); didCompile = true; memset(&ice, 0, sizeof ice); memset(&expr, 0, sizeof expr); memset(®, 0, sizeof reg); memset(&prescan, 0, sizeof prescan); memset(&debug, 0, sizeof debug); // Output debug appvar if (key == sk_Window) { ice.debug = true; } gfx_SetTextXY(1, 12); displayMessageLineScroll("Prescanning..."); displayLoadingBarFrame(); ice.inPrgm = _open(var_name); _seek(0, SEEK_END, ice.inPrgm); ice.programLength = _tell(ice.inPrgm); ice.programData = (uint8_t*)0xD52C00; ice.programPtr = ice.programData; ice.programDataData = ice.programData + 0xFFFF; ice.programDataPtr = ice.programDataData; // Get the name/icon/description _rewind(ice.inPrgm); if ((res = getNameIconDescription()) != VALID) { displayError(res); goto stop; } // Open debug appvar to store things to sprintf(buf, "%.5sDBG", ice.outName); debug.dbgPrgm = ti_Open(buf, "w"); if (ice.debug) { if (!debug.dbgPrgm) { displayError(E_NO_DBG_FILE); goto stop; } // Write version bytes to debug appvar ti_PutC(DEBUG_VERSION_MAJOR, debug.dbgPrgm); ti_PutC(DEBUG_VERSION_MINOR, debug.dbgPrgm); // Write amount of programs to debug appvar ti_PutC(0, debug.dbgPrgm); } else if (debug.dbgPrgm) { ti_Delete(buf); } // Prescan the program and output the header preScanProgram(); if ((res = parsePrescan()) != VALID) { displayError(res); goto stop; } if (prescan.amountOfVariablesUsed > 84) { gfx_SetTextFGColor(224); sprintf(buf, "Too much variables used: %d", prescan.amountOfVariablesUsed); displayMessageLineScroll(buf); didCompile = false; goto stop; } // Allow hidden programs from Cesium if (*var_name < 64) { *var_name += 64; } sprintf(buf, "Compiling program %s...", var_name); displayMessageLineScroll(buf); // Create or empty the output program if parsing succeeded if ((res = parseProgram()) == VALID) { unsigned int previousSize = 0; // Get the sizes of both stacks ice.programSize = (uintptr_t)ice.programPtr - (uintptr_t)ice.programData; programDataSize = (uintptr_t)ice.programDataData - (uintptr_t)ice.programDataPtr; // Change the pointers to the data as well, but first calculate the offset offset = PRGM_START + ice.programSize - (uintptr_t)ice.programDataPtr; while (ice.dataOffsetElements--) { unsigned int *tempDataOffsetStackPtr = ice.dataOffsetStack[ice.dataOffsetElements]; *tempDataOffsetStackPtr += offset; } totalSize = ice.programSize + programDataSize + 3; // Export the program ice.outPrgm = _open(ice.outName); if (ice.outPrgm) { // This program already exists if ((uint8_t)ti_GetC(ice.outPrgm) != 0xEF || (uint8_t)ti_GetC(ice.outPrgm) != 0x7B) { gfx_SetTextFGColor(224); displayMessageLineScroll("Output program already exists!"); displayMessageLineScroll("Delete program to continue."); didCompile = false; goto stop; } previousSize = ti_GetSize(ice.outPrgm); ti_Close(ice.outPrgm); } ice.outPrgm = _new(ice.outName); if (!ice.outPrgm) { displayMessageLineScroll("Failed to open output file"); goto stop; } // Write ASM header ti_PutC(tExtTok, ice.outPrgm); ti_PutC(tAsm84CeCmp, ice.outPrgm); // Write ICE header to be recognized by Cesium ti_PutC(0x7F, ice.outPrgm); // Write the header, main program, and data to output :D ti_Write(ice.programData, ice.programSize, 1, ice.outPrgm); if (programDataSize) ti_Write(ice.programDataPtr, programDataSize, 1, ice.outPrgm); _rewind(ice.outPrgm); // Write final CRC to debug program, as well as the ending line of the first program and the amount of total programs if (ice.debug) { uint16_t CRC; CRC = GetCRC(ti_GetDataPtr(ice.outPrgm), ti_GetSize(ice.outPrgm)); WriteWordToDebugProg(CRC); ti_Seek(3 + offsetof(debug_prog_t, endingLine), SEEK_SET, debug.dbgPrgm); WriteWordToDebugProg(debug.currentLine); ti_Seek(2, SEEK_SET, debug.dbgPrgm); ti_PutC(debug.amountOfPrograms + 1, debug.dbgPrgm); // +1 because the main program starts at 0 } // Yep, we are really done! gfx_SetTextFGColor(4); displayMessageLineScroll("Successfully compiled!"); if (ice.debug) { displayMessageLineScroll("Successfully exported debug appvar"); } // Skip line displayMessageLineScroll(" "); // Display the size gfx_SetTextFGColor(0); sprintf(buf, "Output size: %u bytes", totalSize); displayMessageLineScroll(buf); if (previousSize) { sprintf(buf, "Previous size: %u bytes", previousSize); displayMessageLineScroll(buf); } sprintf(buf, "Output program: %s", ice.outName); displayMessageLineScroll(buf); } else if (res != W_VALID) { displayError(res); } stop: gfx_SetTextFGColor(0); if (didCompile) { if (res == VALID) { gfx_PrintStringXY("Run", 9, 232); printButton(1); } else if (!ti_IsArchived(ice.inPrgm)) { gfx_PrintStringXY("Goto", 222, 232); printButton(217); } gfx_PrintStringXY("Back", 70, 232); printButton(65); gfx_PrintStringXY("Quit", 285, 232); printButton(279); } while (!(key = os_GetCSC())); err: gfx_End(); if (key != sk_Graph && didCompile) { if (key == sk_Yequ && res == VALID) { RunPrgm(ice.outName); } if (key == sk_Window) { // Erase screen gfx_SetColor(255); gfx_FillRectangle_NoClip(0, 11, 320, 229); goto displayMainScreen; } if (key == sk_Trace && res != VALID && !ti_IsArchived(ice.inPrgm)) { char buf[9]; ti_GetName(buf, ice.inPrgm); GotoEditor(buf, ti_Tell(ice.inPrgm) - 1); } } ti_CloseAll(); }
/**************************************************************************** Desc: Prints the web page for the SCacheHashTable ****************************************************************************/ RCODE F_SCacheHashTablePage::display( FLMUINT uiNumParams, const char ** ppszParams) { RCODE rc = FERR_OK; FLMBOOL bRefresh; FLMBOOL bHighlight = TRUE; FLMUINT uiLoop; FLMUINT uiHashTableSize; FLMUINT uiUsedEntries = 0; char szStart[10]; char szRefresh[] = "&Refresh"; FLMUINT uiStart; FLMUINT uiNewStart; char * pszTemp; #define NUM_ENTRIES 20 char * pszHTLinks[NUM_ENTRIES]; F_UNREFERENCED_PARM( uiNumParams); F_UNREFERENCED_PARM( ppszParams); // Check for the refresh parameter bRefresh = DetectParameter( uiNumParams, ppszParams, "Refresh"); if (!bRefresh) { szRefresh[0]='\0'; // Effectively turns szRefresh into a null string } // Get the starting entry number... if (RC_BAD( rc = ExtractParameter( uiNumParams, ppszParams, "Start", sizeof( szStart), szStart))) { flmAssert( 0); goto Exit; } uiStart = f_atoud( szStart); // Allocate space for the hyperlink text for (uiLoop = 0; uiLoop < NUM_ENTRIES; uiLoop++) { if( RC_BAD( rc = f_alloc( 250, &pszHTLinks[ uiLoop]))) { printErrorPage( rc, TRUE, (char *)"Failed to allocate temporary buffer"); goto Exit; } pszHTLinks[uiLoop][0] = '\0'; } if( RC_BAD( rc = f_alloc( 250, &pszTemp))) { printErrorPage( rc, TRUE, (char *)"Failed to allocate temporary buffer"); goto Exit; } // Lock the database f_mutexLock( gv_FlmSysData.hShareMutex); // Get the number of entries in the hash table uiHashTableSize = gv_FlmSysData.SCacheMgr.uiHashTblSize; // May need to modify starting number if it's out of range... if ((uiStart + NUM_ENTRIES) >= uiHashTableSize) { uiStart = uiHashTableSize - NUM_ENTRIES; } // Loop through the entire table counting the number of entries in use // If the entry is one of the one's we're going to display, store the // appropriate text in pszHTLinks for (uiLoop = 0; uiLoop < uiHashTableSize; uiLoop++) { if (gv_FlmSysData.SCacheMgr.ppHashTbl[uiLoop]) { uiUsedEntries++; } if ( (uiLoop >= uiStart) && (uiLoop < (uiStart + NUM_ENTRIES)) ) { // This is one of the entries that we will display if (gv_FlmSysData.SCacheMgr.ppHashTbl[uiLoop]) { flmBuildSCacheBlockString( pszHTLinks[uiLoop - uiStart], gv_FlmSysData.SCacheMgr.ppHashTbl[uiLoop]); } } } // Unlock the database f_mutexUnlock( gv_FlmSysData.hShareMutex); // Begin rendering the page... stdHdr(); printStyle(); fnPrintf( m_pHRequest, HTML_DOCTYPE "<html>\n"); // Determine if we are being requested to refresh this page or not. if (bRefresh) { fnPrintf( m_pHRequest, "<HEAD>" "<META http-equiv=\"refresh\" content=\"5; url=%s/SCacheHashTable?Start=%lu%s\">" "<TITLE>Database iMonitor - SCache Hash Table</TITLE>\n", m_pszURLString, uiStart, szRefresh); } else { fnPrintf( m_pHRequest, "<HEAD>\n"); } // If we are not to refresh this page, then don't include the // refresh meta command if (!bRefresh) { f_sprintf( (char *)pszTemp, "<A HREF=%s/SCacheHashTable?Start=%lu&Refresh>Start Auto-refresh (5 sec.)</A>", m_pszURLString, uiStart); } else { f_sprintf( (char *)pszTemp, "<A HREF=%s/SCacheHashTable?Start=%lu>Stop Auto-refresh</A>", m_pszURLString, uiStart); } // Print out a formal header and the refresh option. printTableStart("SCache Hash Table", 4); printTableRowStart(); printColumnHeading( "", JUSTIFY_LEFT, FLM_IMON_COLOR_PUTTY_1, 4, 1, FALSE); fnPrintf( m_pHRequest, "<A HREF=%s/SCacheHashTable?Start=%lu%s>Refresh</A>, %s\n", m_pszURLString, uiStart, szRefresh, pszTemp); printColumnHeadingClose(); printTableRowEnd(); printTableRowStart( (bHighlight = !bHighlight)); fnPrintf( m_pHRequest, "<TD>Table Size: %lu </TD>\n", uiHashTableSize); printTableRowEnd(); printTableRowStart( (bHighlight = !bHighlight)); fnPrintf( m_pHRequest, "<TD>Entries Used: %lu (%lu%%) </TD>\n", uiUsedEntries, ((uiUsedEntries * 100) / uiHashTableSize) ); printTableRowEnd(); // The rest of the table is going to be a single row with two columns: // one for the list of hash buckets and the other for everything else printTableRowStart( FALSE); fnPrintf( m_pHRequest, " <TD>\n"); // Print out the hash buckets for (uiLoop = 0; uiLoop < NUM_ENTRIES; uiLoop++) { if (pszHTLinks[uiLoop][0] != '\0') { fnPrintf( m_pHRequest, "<A HREF=%s%s>%lu</A> <br>\n", pszHTLinks[uiLoop], szRefresh, uiStart+uiLoop); } else { fnPrintf( m_pHRequest, "%lu<br>\n", uiStart+uiLoop); } } fnPrintf( m_pHRequest, "</ul>\n</TD>\n<TD>\n"); // Print out the other stuff... uiNewStart = (uiStart > 100)?(uiStart - 100):0; fnPrintf( m_pHRequest, "<A HREF=%s/SCacheHashTable?Start=%lu%s>Previous 100</A> <BR>\n", m_pszURLString, uiNewStart, szRefresh); uiNewStart = (uiStart > 10)?(uiStart - 10):0; fnPrintf( m_pHRequest, "<A HREF=%s/SCacheHashTable?Start=%lu%s>Previous 10</A> <BR>\n", m_pszURLString, uiNewStart, szRefresh); fnPrintf( m_pHRequest, "<BR>\n"); uiNewStart = (uiStart + 10); if (uiNewStart >= (uiHashTableSize - NUM_ENTRIES)) { uiNewStart = (uiHashTableSize - NUM_ENTRIES); } fnPrintf( m_pHRequest, "<A HREF=%s/SCacheHashTable?Start=%lu%s>Next 10</A> <BR>\n", m_pszURLString, uiNewStart, szRefresh); uiNewStart = (uiStart + 100); if (uiNewStart >= (uiHashTableSize - NUM_ENTRIES)) { uiNewStart = (uiHashTableSize - NUM_ENTRIES); } fnPrintf( m_pHRequest, "<A HREF=%s/SCacheHashTable?Start=%lu%s>Next 100</A> <BR>\n" "<form type=\"submit\" method=\"get\" action=\"/coredb/SCacheHashTable\">\n" "<BR> Jump to specific bucket:<BR> \n" "<INPUT type=\"text\" size=\"10\" maxlength=\"10\" name=\"Start\"></INPUT> <BR>\n", m_pszURLString, uiNewStart, szRefresh); printButton( "Jump", BT_Submit); // We use a hidden field to pass the refresh parameter back the the server if (bRefresh) { fnPrintf( m_pHRequest, "<INPUT type=\"hidden\" name=\"Refresh\"></INPUT>\n"); } fnPrintf( m_pHRequest, "</form>\n</TD>\n"); printTableRowEnd(); printTableEnd(); printDocEnd(); fnEmit(); Exit: // Free the space for the hyperlink text for (uiLoop = 0; uiLoop < NUM_ENTRIES; uiLoop++) { f_free( &pszHTLinks[uiLoop]); } f_free( &pszTemp); return( rc); }