TAPCOM_Channel TAPCOM_GetChannel (dword param1, dword *CallerID, dword *ServiceID, dword *ParamBlockVersion, void **ParamBlock) { TAPCOM_InternalMesBuf *mesBuf = (TAPCOM_InternalMesBuf *) param1; if (!isValidChannel (mesBuf)) return NULL; if (mesBuf->tapcomVersion >= TAPCOM_REQVERSION) { if ((mesBuf->ToID == __tap_ud__) || (mesBuf->ToID == TAPCOM_App_BROADCAST)) { // die Nachricht ist für mich oder Broadcast if (CallerID != NULL) *CallerID = mesBuf->FromID; if (ServiceID != NULL) *ServiceID = mesBuf->ServiceID; if (ParamBlockVersion != NULL) *ParamBlockVersion = mesBuf->ParamBlockVersion; if (ParamBlock != NULL) *ParamBlock = mesBuf->ParamBlock; // Infos aus Message-Buffer holen //Falls es sich um keinen Broadcast handelt, den Block auf bestätigt setzen if (mesBuf->ToID != TAPCOM_App_BROADCAST) mesBuf->Status = TAPCOM_Status_ACKNOWLEDGED; } else return NULL; } else { mesBuf->Status = TAPCOM_Status_VERSIONMISMATCH; mesBuf->ReturnVal = TAPCOM_REQVERSION; } //Server-Timeout zurücksetzen mesBuf->ServerAlive = TAP_GetTick(); return (TAPCOM_Channel) mesBuf; }
// // Write a string to the logfile. // void appendToLogfile(const char* text, int logLevel) { word mjd; byte hour; byte min; byte sec; word year; byte month; byte day; byte weekday; char str[20]; dword tempTick; if (logLevel > LOGLEVEL) return; if (logFD != NULL) { TAP_GetTime( &mjd, &hour, &min, &sec); TAP_ExtractMjd(mjd, &year, &month, &day, &weekday); tempTick = TAP_GetTick(); //sprintf(str,"%02d-%02d-%04d %02d:%02d:%02d - ", day, month, year, hour, min, sec); sprintf(str,"%02d:%02d:%02d %i - ", hour, min, sec, tempTick); TAP_Hdd_Fwrite((void*)str, strlen(str), 1, logFD); TAP_Hdd_Fwrite((void*)text, strlen(text), 1, logFD); TAP_Hdd_Fwrite((void*)"\r\n", strlen("\r\n"), 1, logFD); logByteCount += strlen(text) + strlen("\r\n"); } }
void TAPCOM_Finish(TAPCOM_Channel Channel, int val) { TRACEENTER(); TAPCOM_InternalMesBuf *buf = (TAPCOM_InternalMesBuf *) Channel; if(isValidChannel(Channel)) { buf->Status = TAPCOM_Status_FINISHED; buf->ReturnVal = val; //Server-Timeout zurücksetzen buf->ServerAlive = TAP_GetTick(); } TRACEEXIT(); }
void OSDMenuWaitSpinnerInit(void) { TRACEENTER(); if(InfoBoxOSDRgn && WaitSpinnerRgn == 0) { WaitSpinnerRgn = TAP_Osd_Create(0, 0, _WaitSpinner_All_Gd.width, _WaitSpinner_All_Gd.height, 0, OSD_Flag_MemRgn); if(WaitSpinnerRgn) { TAP_Osd_PutGd(WaitSpinnerRgn, 0, 0, &_WaitSpinner_All_Gd, FALSE); TAP_Osd_Copy(WaitSpinnerRgn, InfoBoxOSDRgn, 0, 0, 50, 50, 15, 130, FALSE); WaitSpinnerIndex = 0; WaitSpinnerTimeout = TAP_GetTick() + 10; TAP_Osd_Sync(); } } TRACEEXIT(); }
void LoadPlayData( void ) { int i; char str[200]; appendToLogfile("LoadPlayData: Started.", INFO); if ( !ReadDatFile() ) // If we can't find/read the data file, create an empty one. { appendToLogfile("LoadPlayData: Call to ReadDatFile returned FALSE.", ERR); numberOfPlayedFiles = 1; playedFiles[0] = TAP_MemAlloc( sizeof (*playedFiles[0])); playedFiles[0]->startCluster = 0; // Store the disk start cluster. playedFiles[0]->currentBlock = 0; // Store the current block position. playedFiles[0]->totalBlock = 1; // Store the total block size. Set to 1 to ensure no division by 0 errors. strcpy(playedFiles[0]->name,"Placeholder for last played file.rec"); // Store the file name. playedFiles[1] = TAP_MemAlloc( sizeof (*playedFiles[1])); playedFiles[1]->startCluster = 12345678; // Store the disk start cluster. playedFiles[1]->currentBlock = 9876543; // Store the current block position. playedFiles[1]->totalBlock = 9999999; // Store the total block size. strcpy(playedFiles[1]->name,"This is a dummy filename.rec"); // Store the file name. appendToLogfile("LoadPlayData: Calling SaveDataToFile for new file.", ERR); SaveDatToFile(); } playbackInfoTick = TAP_GetTick(); // Set timer to indicate when we retrieved the playback information. playinfoChanged = FALSE; // We've just loaded the data, so it hasn't changed yet. /* TAP_Print("\r\n from loading numberOfPlayedFiles=%d \r\n",numberOfPlayedFiles); for (i = 1; i<=numberOfPlayedFiles; i ++) { TAP_Print("%d<< %d<< %d<<\r\n", playedFiles[i]->startCluster, playedFiles[i]->currentBlock, playedFiles[i]->totalBlock); TAP_Print("%s<<\r\n", playedFiles[i]->name); } */ appendToLogfile("LoadPlayData: Finished.", INFO); }
PerformanceTimer::~PerformanceTimer(void) { dword endTick = TAP_GetTick(); TRACE2("%s timed at %d milliseconds\n", m_sTitle.c_str(), (endTick-m_dwStartTick) * 10); }
PerformanceTimer::PerformanceTimer(const string& title) : m_sTitle(title) { m_dwStartTick = TAP_GetTick(); }
bool SDS(void) { TRACEENTER(); static dword Timeout = 0; static tHookHandlerState LastHHS = HHS_Exit; static dword EF00FilterTimeout = 0; if(LastHHS != HookHandlerState) { switch(HookHandlerState) { case HHS_Init: WriteLog("HHS_Init"); break; case HHS_Idle: WriteLog("HHS_Idle"); break; case HHS_EF00Received: WriteLog("HHS_EF00Received"); break; case HHS_PowerOffCancel: WriteLog("HHS_PowerOffCancel"); break; case HHS_ShutdownTimerDiags: WriteLog("HHS_ShutdownTimerDiags"); break; case HHS_Shutdown: WriteLog("HHS_Shutdown"); break; case HHS_Exit: WriteLog("HHS_Exit"); break; } LastHHS = HookHandlerState; } switch(HookHandlerState) { case HHS_Init: { char *TAPFileName; tTAPInfo TAPInfo; CreateRootDir(); //Init some firmware routines if(!__DevFront_PowerOffReply) { __DevFront_PowerOffReply = (void*)FIS_fwDevFront_PowerOffReply(); if(!__DevFront_PowerOffReply) { if(LastStatus != -1) WriteLog("Failed to resolve DevFront_PowerOffReply()"); LastStatus = -1; HookHandlerState = HHS_Exit; TRACEEXIT(); return FALSE; } } if(!__DevFront_PowerOffCancel) { __DevFront_PowerOffCancel = (void*)FIS_fwDevFront_PowerOffCancel(); if(!__DevFront_PowerOffCancel) { if(LastStatus != -2) WriteLog("Failed to resolve DevFront_PowerOffCancel()"); LastStatus = -2; HookHandlerState = HHS_Exit; TRACEEXIT(); return FALSE; } } //Modify the handler pointer of the ef00 event queue if(!SetHandler(0xef00, Hooked_ApplEvent_CallHandler, (void*)&OrigHandler)) { TRACEEXIT(); return FALSE; } if(!LibInitialized && !InitTAPex()) { TRACEEXIT(); return FALSE; } if(HDD_TAP_GetFileNameByIndex(TAP_TableIndex, &TAPFileName)) { if(!HDD_TAP_GetInfo(TAPFileName, &TAPInfo)) strcpy(TAPInfo.TAPName, "???"); } else strcpy(TAPInfo.TAPName, "???"); TAP_SPrint(Log, "SDS has been activated by '%s'", TAPInfo.TAPName); WriteLog(Log); HookHandlerState = HHS_Idle; break; } case HHS_Idle: { if(EF00FilterTimeout && TAP_GetTick() > EF00FilterTimeout) EF00FilterTimeout = 0; if(ShutdownHooked) { HookHandlerState = HHS_EF00Received; ShutdownHooked = FALSE; } break; } case HHS_EF00Received: { __DevFront_PowerOffReply(); if(EF00FilterTimeout) { Timeout = TAP_GetTick() + 50; HookHandlerState = HHS_PowerOffCancel; } else { dword ret = HDD_TAP_SendEvent(0, TRUE, EVT_STOP, 2, 0); if(ret == 0) { if(LastStatus != -4) WriteLog("A TAP has intercepted the shutdown notfication"); LastStatus = -4; Timeout = TAP_GetTick() + 50; HookHandlerState = HHS_PowerOffCancel; } else { HookHandlerState = HHS_ShutdownTimerDiags; } } break; } case HHS_PowerOffCancel: { if(TAP_GetTick() > Timeout) { if(LastStatus != -5) WriteLog("The shutdown has been canceled"); LastStatus = -5; __DevFront_PowerOffCancel(); EF00FilterTimeout = TAP_GetTick() + 200; HookHandlerState = HHS_Idle; } break; } case HHS_ShutdownTimerDiags: { if(LastStatus != -6) WriteLog("Notifiying TimerDiags about the shutdown"); LastStatus = -6; HDD_TAP_SendEvent(0x8E0A4224, FALSE, EVT_STOP, 0, 0); Timeout = TAP_GetTick() + 200; HookHandlerState = HHS_Shutdown; break; } case HHS_Shutdown: { if(TAP_GetTick() > Timeout) { if(OrigHandler) { SetHandler(0xef00, OrigHandler, NULL); OrigHandler = NULL; } if(LastStatus != -7) WriteLog("Notifiying all TAPs about the shutdown"); LastStatus = -7; HDD_TAP_SendEvent(0, FALSE, EVT_STOP, 0, 0); //TAP_Exit(); if(LastStatus != -8) WriteLog("Enqueuing the shutdown event"); LastStatus = -8; Shutdown(TaskPower); HookHandlerState = HHS_Exit; } break; } case HHS_Exit: { if(OrigHandler) { SetHandler(0xef00, OrigHandler, NULL); OrigHandler = NULL; if(LastStatus != -9) WriteLog("SDS has been deactivated"); LastStatus = -9; } TRACEEXIT(); return FALSE; } } TRACEEXIT(); return TRUE; }
dword TAP_EventHandler( word event, dword param1, dword param2 ) { static int count = 0, err1, filelen; static byte flip = 0; int i, y; const int LINE_H = 21; const int STR_COUNT = 21; dword t1, t2; char strings[21][40] = { {"Test ajJsjjOjsj"}, {"qUIck tESt"}, {"ma"}, {"keяд"}, {"<< Nelonen >>"} , {"03:20 "}, {" leading SPACE"}, {"Test ajJsjjOjsj"}, {"qUIck tESt"}, {"ma"}, {"ke"}, {"<< Nelonen >>"} , {"03:20 "}, {" leading SPACE"}, {"Test ajJsjjOjsj"}, {"qUIck tESt"}, {"ma"}, {"ke"}, {"<< Nelonen >>"} , {"03:20 "}, {" leading SPACE"} }; char msg[64]; if( event == EVT_KEY ) { if ( param1 == RKEY_Exit) { TAP_Osd_SetTransparency(rgn, 0xFF - transparency_orig); Delete_Font(&font0); Delete_Font(&font1); Delete_Font(&font2); TAP_Osd_Delete( rgn ); #ifdef DLALLOC dlmalloc_exit(); #endif TAP_EnterNormal(); TAP_Exit(); return 0; } if ( param1 == RKEY_1) { TAP_ExitNormal(); TAP_Osd_FillBox(rgn, 30, 10, 620, 500, COLOR_DarkBlue); t1 = TAP_GetTick(); y = 20; for (i = 0; i < STR_COUNT; i++, y+=LINE_H) { TAP_Osd_PutS_Font(rgn, 50, y, 199, strings[i], COLOR_Red, COLOR_White, &font0, ALIGN_LEFT); TAP_Osd_PutS_Font(rgn, 200, y, 349, strings[i], COLOR_Red, COLOR_White, &font1, ALIGN_LEFT); TAP_Osd_PutS_Font(rgn, 350, y, 499, strings[i], COLOR_Red, COLOR_White, &font2, ALIGN_LEFT); } t2 = TAP_GetTick() - t1; TAP_SPrint(msg, "Ticks: %d", t2); TAP_Osd_PutS(rgn, 500, 500, 650, msg, COLOR_Green, COLOR_Black, 0, FNT_Size_1419, 0, ALIGN_LEFT); return 0; } if ( param1 == RKEY_2) { TAP_ExitNormal(); TAP_Osd_FillBox(rgn, 30, 10, 620, 500, COLOR_DarkBlue); t1 = TAP_GetTick(); y = 20; for (i = 0; i < STR_COUNT; i++, y+=LINE_H) { TAP_Osd_PutS_FontL(rgn, 50, y, 199, strings[i], &font0, ALIGN_LEFT); TAP_Osd_PutS_FontL(rgn, 200, y, 349, strings[i], &font1, ALIGN_LEFT); TAP_Osd_PutS_FontL(rgn, 350, y, 499, strings[i], &font2, ALIGN_LEFT); } t2 = TAP_GetTick() - t1; TAP_SPrint(msg, "Ticks: %d", t2); TAP_Osd_PutS(rgn, 500, 500, 650, msg, COLOR_Green, COLOR_Black, 0, FNT_Size_1419, 0, ALIGN_LEFT); return 0; } if ( param1 == RKEY_3) { TAP_ExitNormal(); TAP_Osd_FillBox(rgn, 30, 10, 620, 500, COLOR_DarkBlue); t1 = TAP_GetTick(); y = 20; for (i = 0; i < STR_COUNT; i++, y+=LINE_H) { TAP_Osd_PutS_FontEx(rgn, 50, y, 199, 19, 2, strings[i], COLOR_Red, COLOR_White, &font0, ALIGN_LEFT); TAP_Osd_PutS_FontEx(rgn, 200, y, 349, 19, 2, strings[i], COLOR_Red, COLOR_White, &font1, ALIGN_LEFT); TAP_Osd_PutS_FontEx(rgn, 350, y, 499, 19, 2, strings[i], COLOR_Red, COLOR_White, &font2, ALIGN_LEFT); } t2 = TAP_GetTick() - t1; TAP_SPrint(msg, "Ticks: %d", t2); TAP_Osd_PutS(rgn, 500, 500, 650, msg, COLOR_Green, COLOR_Black, 0, FNT_Size_1419, 0, ALIGN_LEFT); return 0; } if ( param1 == RKEY_4) { TAP_ExitNormal(); TAP_Osd_FillBox(rgn, 30, 10, 620, 500, COLOR_DarkBlue); t1 = TAP_GetTick(); y = 20; for (i = 0; i < STR_COUNT; i++, y+=LINE_H) { TAP_Osd_PutS(rgn, 50, y, 199, strings[i], COLOR_Red, COLOR_White, 0, FNT_Size_1419, 0, ALIGN_LEFT); TAP_Osd_PutS(rgn, 200, y, 349, strings[i], COLOR_Red, COLOR_White, 0, FNT_Size_1419, 0, ALIGN_LEFT); TAP_Osd_PutS(rgn, 350, y, 499, strings[i], COLOR_Red, COLOR_White, 0, FNT_Size_1419, 0, ALIGN_LEFT); } t2 = TAP_GetTick() - t1; TAP_SPrint(msg, "Ticks: %d", t2); TAP_Osd_PutS(rgn, 500, 500, 650, msg, COLOR_Green, COLOR_Black, 0, FNT_Size_1419, 0, ALIGN_LEFT); return 0; } } return param1;//event; }
dword My_IdleHandler(void) { dword currentTickTime = 0; static byte oldMin = 100, oldSec = 0; static byte schIdleHandlerSV = SCH_IDLE_HANDLER_INITIALISE; switch(schIdleHandlerSV) { /*--------------------------------------------------*/ case SCH_IDLE_HANDLER_INITIALISE: FindTapDir(); schMainDetermineChangeDirType(); schFileCreateSettingsFolder(); LoadConfiguration(); LoadLanguage(); CacheLogos(); schMainInitLcnToSvcNumMap(); schDispWindowInitialise(); schEditWindowInitialise(); initialiseMenu(); InitialiseConfigRoutines(); schShowWindowInitialise(); logInitialise(); schMainAlreadyRecordedInitialise(); schMainApiMoveAvailable = FALSE; schMainDebugMoveAvailable = FALSE; #ifndef WIN32 if( FirmwareCallsEnabled == TRUE ) { schMainApiMoveAvailable = fcCheckApiMoveAvailability(); if(schMainApiMoveAvailable == FALSE) { StartTAPExtensions(); schMainDebugMoveAvailable = fcCheckDebugMoveAvailability(); } } #else schMainApiMoveAvailable = TRUE; #endif schIdleHandlerSV = SCH_IDLE_HANDLER_SERVICE; break; /*--------------------------------------------------*/ case SCH_IDLE_HANDLER_SERVICE: currentTickTime = TAP_GetTick(); // only get the current tick time once if ( keyboardWindowShowing ) KeyboardCursorBlink( currentTickTime ); schObtainCurrentTime(); if ( (creditsShowing == FALSE) && (menuShowing == FALSE) && (schEditWindowShowing == FALSE) && (schDispWindowShowing == FALSE) && (schShowWindowShowing == FALSE) ) { schMainService(); if ( (FirmwareCallsEnabled == TRUE) && ( (schMainApiMoveAvailable == TRUE) || (schMainDebugMoveAvailable == TRUE) ) ) { schMoveService(); schKeepService(); } oldMin = 100; } else { if(schShowWindowShowing == TRUE) { schShowService(); } if ( schTimeMin != oldMin ) { oldMin = schTimeMin; if ( ( menuShowing == FALSE ) && ( creditsShowing == FALSE ) ) { UpdateListClock(); } } } if ( ( schTimeSec != oldSec ) && ( schStartUpCounter < 0xFF ) ) { oldSec = schTimeSec; schStartUpCounter++; } break; /*--------------------------------------------------*/ } }
void CallTraceExitResult(dword *Magic, char *Result) { char Spaces[101]; int i, j; dword t; byte *ISOText; extern dword __tap_ud__; if(CallTraceDoNotReenter) return; CallTraceDoNotReenter = TRUE; t = TAP_GetTick(); if(!CallTraceInitialized) CallTraceInit(); Spaces[0] = '\0'; if(CallLevel > 0) { CallLevel--; if(CallTraceEnabled && CallTraceStats && CallLevel < CTSTACKSIZE) { //Check if the proc name is already known by the stats array j = -1; for(i = 0; i < CallTraceStatsEntries; i++) if(CallTraceStats[i].ProcName == CallTraceStack[CallLevel].ProcName) { j = i; break; } //If not, use the next free entry if(j == -1) j = CallTraceStatsEntries; //Add the stats if(j < CTSTATENTRIES) { i = t - CallTraceStack[CallLevel].EntryTime; if(CallTraceStats[j].ProcName) { //Already known if((dword)i < CallTraceStats[j].MinTime) CallTraceStats[j].MinTime = i; if((dword)i > CallTraceStats[j].MaxTime) CallTraceStats[j].MaxTime = i; if(CallTraceStats[j].NrCalls < 0xffffffff) { CallTraceStats[j].TotalTime += i; CallTraceStats[j].NrCalls++; } } else { //New procedure CallTraceStats[j].ProcName = CallTraceStack[CallLevel].ProcName; CallTraceStats[j].MinTime = i; CallTraceStats[j].MaxTime = i; CallTraceStats[j].TotalTime = i; CallTraceStats[j].NrCalls = 1; CallTraceStatsEntries++; } } } } else LogEntryFBLibPrintf(TRUE, "CallLevel Underflow! (TAPID 0x%8.8x)", __tap_ud__); if((CallTraceEnabled || Magic) && Result) { memset(Spaces, ' ', CallLevel < CTSTACKSIZE ? CallLevel << 1 : 100); Spaces[CallLevel < CTSTACKSIZE ? CallLevel << 1 : 100] = '\0'; StrToISOAlloc(Result, &ISOText); if(ISOText && *ISOText) TAP_PrintNet("%s = %s\n", Spaces, ISOText); TAP_MemFree(ISOText); } if(Magic && *Magic != DEFAULTMAGIC) { TAP_PrintNet("%sINVALID MAGIC!\n", Spaces); *Magic = DEFAULTMAGIC; } CallTraceDoNotReenter = FALSE; }