// ****************************************************************** // * EmuIXACTEngine_SetMasterVolume // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_SetMasterVolume ( X_XACTEngine* pThis, WORD wCategory, LONG lVolume ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_SetMasterVolume\n" "(\n" " pThis : 0x%.08X\n" " wCategory : 0x%.08X\n" " lVolume : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, wCategory, lVolume); EmuSwapFS(); return S_OK; }
void level_goto(game_t *p_game, level_t *p_level, point_t p) { MAP_HEADER *p_bgmap = &p_game->bgmap; int i = 0; int closest_dist = 10000; point_t closest; /* Dispose the old map */ vMapDispose(); /* Initialise the background map */ p_bgmap->width = p_level->w; p_bgmap->height = p_level->h; p_bgmap->mapoffset = (uint8_t*)p_level->p_level_data; p_bgmap->tiledata = (uint8_t*)p_game->p_tiles; p_bgmap->flag = 0; p_bgmap->format = BG_TILES_FORMAT; /* the format of the bitmaps */ p_game->p_cur_level = p_level; if ( !vMapInit(p_bgmap) ) error_msg("vMapInit failed"); while (p_level->bruce_spawn_points[i].x != -1) { int dist = abs(p_level->bruce_spawn_points[i].x - p.x) + abs(p_level->bruce_spawn_points[i].y - p.y); if (dist < closest_dist) { closest = p_level->bruce_spawn_points[i]; closest_dist = dist; DbgPrintf("Pt %d:%d closest\n\n", closest.x, closest.y); } i++; } p_game->player.sprite.pt = closest; sprite_set_state(&p_game->player.sprite, SPRITE_IDLE); place_lamps(p_game, p_level); }
// ****************************************************************** // * func: EmuXGIsSwizzledFormat // ****************************************************************** PVOID WINAPI XTL::EmuXGIsSwizzledFormat ( XTL::D3DFORMAT Format ) { // ****************************************************************** // * debug trace // ****************************************************************** #ifdef _DEBUG_TRACE { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXapi (0x%X): EmuXGIsSwizzledFormat\n" "(\n" " Format : 0x%.08X\n" ");\n", GetCurrentThreadId(), Format); EmuSwapFS(); // Xbox FS } #endif return FALSE; }
// ****************************************************************** // * func: EmuXACTEngineCreate // ****************************************************************** HRESULT WINAPI XTL::EmuXACTEngineCreate ( X_XACT_RUNTIME_PARAMETERS* pParams, X_XACTEngine** ppEngine ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuXACTEngineCreate\n" "(\n" " pParams : 0x%.08X\n" " ppEngine : 0x%.08X\n" ");\n", GetCurrentThreadId(), pParams, ppEngine); // TODO: Any other form of initialization? *ppEngine = (X_XACTEngine*) CxbxMalloc( sizeof( X_XACTEngine ) ); EmuSwapFS(); // Xbox FS return S_OK; }
// ****************************************************************** // * EmuIXACTEngine_CreateSoundSource // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_CreateSoundSource ( X_XACTEngine* pThis, DWORD dwFlags, X_XACTSoundSource** ppSoundSource ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_CreateSoundSource\n" "(\n" " pThis : 0x%.08X\n" " dwFlags : 0x%.08X\n" " ppSoundSource : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, dwFlags, ppSoundSource); *ppSoundSource = (X_XACTSoundSource*) CxbxMalloc( sizeof( X_XACTSoundSource ) ); EmuSwapFS(); return S_OK; }
// ****************************************************************** // * EmuIXACTSoundBank_Stop // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTSoundBank_Stop ( X_XACTSoundBank* pThis, DWORD dwSoundCueIndex, DWORD dwFlags, X_XACTSoundCue* pSoundCue ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTSoundBank_Stop\n" "(\n" " pThis : 0x%.08X\n" " dwSoundCueIndex : 0x%.08X\n" " dwFlags : 0x%.08X\n" " pSoundCue : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, dwSoundCueIndex, dwFlags, pSoundCue); EmuSwapFS(); return S_OK; }
void tH3000LinkRx::ProcessReceivedTableData(QByteArray& rxMessage) { DbgPrintf("**** ProcessReceivedTableData %s", rxMessage.constData()); // Split up the received message QList<QByteArray> split = rxMessage.split(','); if(split.size() > 3) { int row = split[2].toInt(); int count; for(count = 3; count < (split.size() - 1); count += 2) { int col = split[count].toInt(); float value = split[count + 1].toFloat(); tBandGCalibrationTableValue tableValue(row, col, value); if(m_GettingTableData) { m_pRxTableData->AddValue(tableValue); } else { emit H3000TableValueReceived(tableValue); } } } if(m_GettingTableData && m_pRxTableData->IsAddingComplete()) { emit H3000TableDataReceived(m_pRxTableData->GetTableType()); } }
// ****************************************************************** // * EmuIXACTEngine_GetNotification // ****************************************************************** HRESULT WINAPI XTL::EmuIXACTEngine_GetNotification ( X_XACTEngine* pThis, PCXACT_NOTIFICATION_DESCRIPTION pNotificationDesc, LPVOID pNotification ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXactEng (0x%X): EmuIXACTEngine_GetNotification\n" "(\n" " pThis : 0x%.08X\n" " pNotificationDesc : 0x%.08X\n" " pNotification : 0x%.08X\n" ");\n", GetCurrentThreadId(), pThis, pNotificationDesc, pNotification); // TODO: The contents of XACT_NOTIFICATION can vary from one XDK to the next. // The definition for 4627 is different than 5558. EmuSwapFS(); return S_OK; }
void tCougarIO::on_SPIDataProcessing_messageReceived(const tSPIDataProcessing::tMessage& msg) { Assert(tThread::CurrentThreadName() == "SonarMaster"); //DbgPrintf("MessageReceived = %d", msg.MessageID); switch(msg.MessageID) { case tSPIDataProcessing::MSG_ID_COLUMN_INFO: #ifdef USE_REPROGRAMMING_CODE //if(m_Reprogramming == false) #endif { //DbgPrintf("tCougarIO: m_Reprogramming = false"); tCSMSettingsXPtr xCSMSettings; tCSMSoftwareInfoXPtr xCSMSoftwareInfo; tCSMAnalogData csmAnalogData; GetCSMData(msg.data, xCSMSettings, xCSMSoftwareInfo, csmAnalogData); //~~~~~~ AC - Why would this happen? Need to make sure bogus messages are not sent! if(xCSMSettings->LowerLimitFt() <= xCSMSettings->UpperLimitFt()) { // This is normal when hiding the digital search with an upper limit... // Ignore the problem if the lower limit is like 0.5ft. if(xCSMSettings->LowerLimitFt() > 1) { //DbgPrintf("tCougarIO: LowerLimit(%f) <= UpperLimit(%f) !!!.....",xCSMSettings->LowerLimitFt(), xCSMSettings->UpperLimitFt() ); break; } } //DbgPrintf("Settings received...."); //xCSMSettings->DEBUG_PrintSettings(); //DbgPrintf("SonarIO: SIGNAL csmSettingsReceived"); //emit csmSettingsReceived(xCSMSettings); //DbgPrintf("SonarIO: SIGNAL DiagnosticsReceived"); emit SoftwareInfoReceived(xCSMSoftwareInfo); //DbgPrintf("SonarIO: SIGNAL NewAnalogData"); // Always emit these, the SonarClient is responsible for the logic on whether to use them. emit NewTemperature(csmAnalogData.m_TemperatureValue, csmAnalogData.m_ValidTemperature, SonarCommon::eWaterTemperatureInstance_1); emit NewSpeed(csmAnalogData.m_SpeedValue, csmAnalogData.m_ValidSpeed); emit NewTemperature(csmAnalogData.m_TemperatureValue, csmAnalogData.m_ValidTemperature, SonarCommon::eWaterTemperatureInstanceStructure); // Get SonarColumnNumber unsigned short SonarColumnNumber = 0; SonarColumnNumber |= ((msg.data.at(CSM_SNR_COLUMN_NUM_INDEX + 0) & 0xFF) << 0); SonarColumnNumber |= ((msg.data.at(CSM_SNR_COLUMN_NUM_INDEX + 1) & 0xFF) << 8); if(m_SonarColumnNumber != (SonarColumnNumber - 1)) { DbgPrintf("Lost Soundings = %d (%i,%i)", SonarColumnNumber - m_SonarColumnNumber, SonarColumnNumber, m_SonarColumnNumber); } m_SonarColumnNumber = SonarColumnNumber; // Get the CSM Chart Data tReceivedSonarInformation sonarInfo; tReceivedStructureInformation structureInfo; sonarInfo.m_ChartRangeCells.resize(CSM_CHART_DATA_SIZE); memcpy(sonarInfo.m_ChartRangeCells.data(), (msg.data.data() + CSM_CHART_DATA_INDEX), CSM_CHART_DATA_SIZE); Assert(xCSMSettings->UpperLimitFt() >= 0); Assert(xCSMSettings->LowerLimitFt() > xCSMSettings->UpperLimitFt()); sonarInfo.m_DigitalRangeCells.resize(CSM_DIGITAL_DATA_SIZE); memcpy(sonarInfo.m_DigitalRangeCells.data(), (msg.data.data() + CSM_DIGITAL_DATA_INDEX), CSM_DIGITAL_DATA_SIZE); sonarInfo.m_NoiseRangeCells.resize(CSM_NOISE_WINDOW_SIZE); memcpy(sonarInfo.m_NoiseRangeCells.data(), (msg.data.data() + CSM_NOISE_WINDOW_INDEX), CSM_NOISE_WINDOW_SIZE); bool PrimaryFreq = xCSMSettings->IsPrimaryFrequency(); sonarInfo.m_UpperLimit = xCSMSettings->UpperLimitFt(PrimaryFreq); sonarInfo.m_LowerLimit = xCSMSettings->LowerLimitFt(PrimaryFreq); sonarInfo.m_DigitalLimit = xCSMSettings->DigitalLimitFt(PrimaryFreq); sonarInfo.m_SonarFrequency = tSonarFrequencyAndChannel((eSonarFrequencyEnum)xCSMSettings->FrequencyIndex(PrimaryFreq), eSonarReceiver_High); sonarInfo.m_SonarChannel = PrimaryFreq ? eSonarChannel_Primary : eSonarChannel_Secondary; structureInfo.m_LeftRangecells.resize(CSM_SIDESCAN_DATA_SIZE); memcpy(structureInfo.m_LeftRangecells.data(), (msg.data.data() + CSM_LEFT_DATA_INDEX), CSM_SIDESCAN_DATA_SIZE); structureInfo.m_RightRangecells.resize(CSM_SIDESCAN_DATA_SIZE); memcpy(structureInfo.m_RightRangecells.data(), (msg.data.data() + CSM_RIGHT_DATA_INDEX), CSM_SIDESCAN_DATA_SIZE); structureInfo.m_DownRangecells.resize(CSM_DOWNSCAN_DATA_SIZE); memcpy(structureInfo.m_DownRangecells.data(), (msg.data.data() + CSM_DOWN_DATA_INDEX), CSM_DOWNSCAN_DATA_SIZE); structureInfo.m_DownRange = xCSMSettings->DownRangeFt(); structureInfo.m_SideRange = xCSMSettings->SideRangeFt(); structureInfo.m_StructureDownFrequency = tSonarFrequencyAndChannel((eSonarFrequencyEnum)xCSMSettings->StructureDownFrequency(), eSonarReceiver_High); structureInfo.m_StructureSideFrequency = tSonarFrequencyAndChannel((eSonarFrequencyEnum)xCSMSettings->StructureSideFrequency(), eSonarReceiver_High); structureInfo.m_XIDVoltage100x = xCSMSettings->StructureXIDVoltage100x(); //DbgPrintf("SonarIO: SIGNAL DataPacketReceived"); emit DataPacketReceived(xCSMSettings, sonarInfo, structureInfo); if(xCSMSettings->NoCompensationDataMode() == true) { emit UnmodulatedDataReceived(); } } break; #ifdef USE_REPROGRAMMING_CODE case MSG_ID_REPROGRAM_MSG: emit csmReprogramMessageBytesReceived(msg.data); break; #endif //USE_REPROGRAMMING_CODE // We'll only receive this message when the CSM is configured as StopSonar... CSM needs to keep transmitting data // because it's the master in the SPI bus case tSPIDataProcessing::MSG_ID_CSM_DATA: #ifdef USE_REPROGRAMMING_CODE //if(m_Reprogramming == false) #endif { tCSMSettingsXPtr xCSMSettings; tCSMSoftwareInfoXPtr xCSMSoftwareInfo; tCSMAnalogData csmAnalogData; GetCSMData(msg.data, xCSMSettings, xCSMSoftwareInfo, csmAnalogData); //~~~~~~ AC - Why would this happen? Need to make sure bogus messages are not sent! if(xCSMSettings->LowerLimitFt() <= xCSMSettings->UpperLimitFt()) break; emit csmSettingsReceived(xCSMSettings); emit SoftwareInfoReceived(xCSMSoftwareInfo); // Always emit these, the SonarClient is responsible for the logic on whether to use them. emit NewTemperature(csmAnalogData.m_TemperatureValue, csmAnalogData.m_ValidTemperature, SonarCommon::eWaterTemperatureInstance_1); emit NewSpeed(csmAnalogData.m_SpeedValue, csmAnalogData.m_ValidSpeed); emit NewTemperature(csmAnalogData.m_TemperatureValue, csmAnalogData.m_ValidTemperature, SonarCommon::eWaterTemperatureInstanceStructure); } break; default: DbgPrintf("Sonar - invalid msg id: %i", msg.MessageID); break; } }
//-------------------------------------------------------------------------------------- // Select the selected source in the tree as the selectedSource[instance] //-------------------------------------------------------------------------------------- void tDataSourcesDialog::Select() { DbgPrintf("**** tDataSourcesDialog::Select %d", m_pSourceSelection->GetSourceSettings()->DataIdIsLocalSetting(m_SelectedSource)); if (m_SelectedSource.IsValid() && // eliminate the categories m_SelectedSource.DataEngine() != DATA_ENGINE_PROXY_ACTIVE && // eliminate the DataType captions m_SelectedInstance >= 0) // eliminate the instance column; { // Now update the setting tDataType dataType = m_SelectedData; tDataId curSource; tDataSourceTreeModel::eSettingScope curScope = m_pDataModel->GetSourceSetting( m_SelectedSource.DataType(), m_SelectedInstance, curSource ); Assert( curScope == m_pScopeAct->Value() || curSource.IsValid() == false ); if (m_pSourceSelection->GetSourceSettings()->SettingCanBeLocalScope( dataType ) && curScope < tDataSourceTreeModel::eGlobalScope) { if (m_pSourceSelection->GetSourceSettings()->IsSameSourceSelection( m_SelectedSource, curSource )) { // this setting is the current setting so we must be unselecting it tDataId unselectSourceId( m_SelectedSource.DataType(), DATA_ENGINE_NO_SELECTION ); if (curScope == tDataSourceTreeModel::eSimradScope) { tNDP2kSimnetSelectedData::SetSimnetSelection( unselectSourceId, tGlobal<tNDP2k>::Instance()->Settings() ); } else { m_pSourceSelection->SetLocalSetting(dataType, unselectSourceId, false); } } else { if (curScope == tDataSourceTreeModel::eSimradScope) { tNDP2kSimnetSelectedData::SetSimnetSelection( m_SelectedSource, tGlobal<tNDP2k>::Instance()->Settings() ); } else { // not the current setting so we must be selecting it m_pSourceSelection->SetLocalSetting(dataType, m_SelectedSource, false); } } return; } else // Global { if(m_pSourceSelection->GetSourceSettings()->DataIdIsGlobalSetting(m_SelectedSource, m_SelectedSource.DataType(), m_SelectedInstance)) { // This setting is the current setting so we must be unselecting it tDataId unselectSourceId( m_SelectedSource.DataType(), m_SelectedInstance, DATA_ENGINE_NO_SELECTION ); m_pSourceSelection->UpdateGlobalSetting(dataType, unselectSourceId, m_SelectedInstance, true); // always update } else { bool done = false; switch( m_SelectedCategory ) { case DATA_CATEGORY_ENGINE: done = ChangeInstanceToSameSource( this, DATA_CATEGORY_ENGINE, m_SelectedInstance, m_SelectedSource, tr("Do you also want to select all other data provided by this source for this engine instance?") ); break; case DATA_CATEGORY_TRANSMISSION: done = ChangeInstanceToSameSource( this, DATA_CATEGORY_TRANSMISSION, m_SelectedInstance, m_SelectedSource, tr("Do you also want to select all other data provided by this source for this transmission instance?") ); break; case DATA_CATEGORY_BATTERY: done = ChangeInstanceToSameSource( this, DATA_CATEGORY_BATTERY, m_SelectedInstance, m_SelectedSource, tr("Do you also want to select all other data provided by this source for this battery instance?") ); break; case DATA_CATEGORY_RUDDER: done = ChangeInstanceToSameSource( this, DATA_CATEGORY_RUDDER, m_SelectedInstance, m_SelectedSource, tr("Do you also want to select all other data provided by this source for this rudder instance?") ); break; case DATA_CATEGORY_AC_INPUT: done = ChangeInstanceToSameSource( this, DATA_CATEGORY_AC_INPUT, m_SelectedInstance, m_SelectedSource, tr("Do you also want to select all other data provided by this source for this AC input instance?") ); break; case DATA_CATEGORY_AC_OUTPUT: done = ChangeInstanceToSameSource( this, DATA_CATEGORY_AC_OUTPUT, m_SelectedInstance, m_SelectedSource, tr("Do you also want to select all other data provided by this source for this AC output instance?") ); break; case DATA_CATEGORY_CHARGER: done = ChangeInstanceToSameSource( this, DATA_CATEGORY_CHARGER, m_SelectedInstance, m_SelectedSource, tr("Do you also want to select all other data provided by this source for this charger instance?") ); break; case DATA_CATEGORY_INVERTER: done = ChangeInstanceToSameSource( this, DATA_CATEGORY_INVERTER, m_SelectedInstance, m_SelectedSource, tr("Do you also want to select all other data provided by this source for this inverter instance?") ); break; case DATA_CATEGORY_GENERATOR: done = ChangeInstanceToSameSource( this, DATA_CATEGORY_GENERATOR, m_SelectedInstance, m_SelectedSource, tr("Do you also want to select all other data provided by this source for this generator instance?") ); break; default: //case DATA_CATEGORY_FUEL_TANK: // Only one data type for each of these - so no prompt break; } if( done ) { return; } // ChangeInstanceToSameSource not done... m_pSourceSelection->UpdateGlobalSetting(dataType, m_SelectedSource, m_SelectedInstance, true); // always update } return; } } // nothing done... expand tree instead. m_pTreeView->expand( m_pTreeView->currentIndex() ); }
static void miniShell() { static bool inMiniShell = false; // Stop if the user didn't ask for the minishell if (inMiniShell || Serial.available()==0) { //DbgPrintf("<No commands>"); return; } // If the command was not for a shell, exit unsigned char cmd = readValue(); if(cmd != SHELL_REQUESTED) { DbgPrintf("<error>Unknown command %i</error>", cmd); return; } else DbgPrintf("<ret v=\"OK\" />"); inMiniShell = true; // Enter the miniShell while(true) { // Get the command unsigned char cmd = readValue(); if(cmd == DIGITAL_READ) { unsigned char pin = readValue(); int pin_val = digitalRead(pin); const char* ret = (pin_val==HIGH?"HIGH":"LOW"); DbgPrintf("<ret v=\"%s\"/>", ret); } else if(cmd == DIGITAL_WRITE) { unsigned char pin = readValue(); unsigned char value = readValue(); digitalWrite(pin, value==1?HIGH:LOW); DbgPrintf("<ret v=\"OK\"/>"); } else if(cmd == ANALOG_READ) { unsigned char pin = readValue(); int pin_val = analogRead(pin); DbgPrintf("<ret v=\"%i\"/>", pin_val); } else if(cmd == ANALOG_WRITE) { unsigned char pin = readValue(); unsigned char value = readValue(); analogWrite(pin, value); DbgPrintf("<ret v=\"OK\"/>"); } else if(cmd == PIN_MODE) { unsigned char pin = readValue(); unsigned char mode = readValue(); pinMode(pin, mode==1?OUTPUT:INPUT); DbgPrintf("<ret v=\"OK\"/>"); } else if(cmd == VAR_WRITE) { DbgSendTrace("Will read string"); char* frameName=readString(); char* varName=readString(); char* value=readString(); DbgSendTrace("frame=%s, varName=%s, value=%s", frameName, varName, value); free(frameName); free(varName); free(value); DbgPrintf("<ret v=\"OK\"/>"); } else if(cmd == EXIT_SHELL) { DbgPrintf("<ret v=\"OK\"/>"); break; } else { DbgPrintf("<error>Unknown command %i</error>", cmd); //Empty the input buffer while (Serial.available()>0) Serial.read(); // Leave the minishell break; } } inMiniShell = false; }
CIN MgErr CINRun(LStrHandle Rtai_lxrt_t, int16 *Dynx, int16 *Size, int32 *Srq, LStrHandle Arg, LStrHandle Buffer, int32 *BufPosInArg, int32 *UnixErr, int32 *LVErr) { int DEBUG=0; union rtai_lxrt_t retval; int *iArg=NULL; char lbuf[LStrLen(*Buffer)+1]; // dynamically allocate on Stack; +1 if it is zero *UnixErr = 0; *LVErr = noErr; DEBUG=LStrLen(*Rtai_lxrt_t)+1; if (DEBUG>2) DEBUG=0; if (DEBUG) { DbgPrintf(NULL); /* Close window */ DbgPrintf("Debuglevel:%d, calling lxrt:%d\n", DEBUG, DEBUG-1); } // DbgPrintf("DEBUG=%d\n", DEBUG); /* set size of return string */ if ((*LVErr = NumericArrayResize( uB, 1L, (UHandle *)&Rtai_lxrt_t, sizeof(union rtai_lxrt_t)))) { goto out; } else { LStrLen(*Rtai_lxrt_t) = sizeof(union rtai_lxrt_t); } /* set size of argument string according to int[12], see rtai_rtai.h */ if ((*LVErr = NumericArrayResize( uB, 1L, (UHandle *)&Arg, sizeof(int[12])))) { goto out; } else { LStrLen(*Arg) = sizeof(int[12]); } iArg=(int*)LStrBuf(*Arg); /* do we have to insert a Buffer into the arguments? */ if ((*BufPosInArg > 0) && (*BufPosInArg < 12)) { if (DEBUG) DbgPrintf("Handling BufferAdr to inserted at PosInArg=%d with BufferLen=%d\n", *BufPosInArg, LStrLen(*Buffer)); /* copy Buffer to local mem on stack */ if (DEBUG) DbgPrintf("Doing memcpy(0x%x, 0x%x, %d)", lbuf, LStrBuf(*Buffer), LStrLen(*Buffer)); memcpy(lbuf, LStrBuf(*Buffer), LStrLen(*Buffer)); /* and insert &lbuf into *Arg */ ((int*)LStrBuf(*Arg))[*BufPosInArg] = (int)lbuf; } //*Size = (int16)LStrLen(*Arg); if (DEBUG) { /* print arguments */ DbgPrintf("(int) Arg[0...3]: 0x%x 0x%x 0x%x 0x%x\n", iArg[0],iArg[1],iArg[2],iArg[3]); DbgPrintf("(int) Arg[4...7]: 0x%x 0x%x 0x%x 0x%x\n", iArg[4],iArg[5],iArg[6],iArg[7]); DbgPrintf("(int) Arg[8..11]: 0x%x 0x%x 0x%x 0x%x\n", iArg[8],iArg[9],iArg[10],iArg[11]); if ((*BufPosInArg > 0) && (*BufPosInArg < 12)) { int i; DbgPrintf("Buffer string from Arg[%d]:", *BufPosInArg); for (i=0; i<LStrLen(*Buffer); i++) { DbgPrintf("0x%02x", (int) (((char*)(iArg[*BufPosInArg]))[i])); } } } if ((DEBUG==0) || (DEBUG==2)) { /* rtai_lxrt call */ if (DEBUG==2) { DbgPrintf("Calling rtai_lxrt(Dynx=%d, Size=%d, Srq=%d, int Arg[0..11])\n",(int) *Dynx, (int) *Size, (int) *Srq); } retval = rtai_lxrt( *Dynx, *Size, *Srq, LStrBuf(*Arg)); } /* copy retval back to first eight bytes of LStrBuf(*Rtai_lxrt_t) */ if (DEBUG==2) { DbgPrintf("Retval[0..1]: %x %x\n", retval.i[LOW], retval.i[HIGH]); } *((int32 *)LStrBuf(*Rtai_lxrt_t)) = retval.i[LOW]; *((int32 *)LStrBuf(*Rtai_lxrt_t)+1) = retval.i[HIGH]; /* if Buffer used copy back from Stack */ if ((*BufPosInArg > 0) && (*BufPosInArg < 12)) { int i; if (DEBUG) DbgPrintf("Doing memcpy(0x%x, 0x%x, %d)", LStrBuf(*Buffer), lbuf, LStrLen(*Buffer)); memcpy(LStrBuf(*Buffer), lbuf, LStrLen(*Buffer)); if (DEBUG) { DbgPrintf("Buffer contents now:"); for (i=0; i<LStrLen(*Buffer); i++) { DbgPrintf("0x%02x", (int) (((char*)LStrBuf(*Buffer))[i])); } } } *UnixErr = (int32) 0; //errno; *LVErr = (int32) 0; //UnixToLVErr(); out: return noErr; }
// ****************************************************************** // * func: EmuXGSwizzleRect // ****************************************************************** VOID WINAPI XTL::EmuXGSwizzleRect ( LPCVOID pSource, DWORD Pitch, LPCRECT pRect, LPVOID pDest, DWORD Width, DWORD Height, CONST LPPOINT pPoint, DWORD BytesPerPixel ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXapi (0x%X): EmuXGSwizzleRect\n" "(\n" " pSource : 0x%.08X\n" " Pitch : 0x%.08X\n" " pRect : 0x%.08X\n" " pDest : 0x%.08X\n" " Width : 0x%.08X\n" " Height : 0x%.08X\n" " pPoint : 0x%.08X\n" " BytesPerPixel : 0x%.08X\n" ");\n", GetCurrentThreadId(), pSource, Pitch, pRect, pDest, Width, Height, pPoint, BytesPerPixel); if(pRect == NULL && pPoint == NULL && Pitch == 0) { memcpy(pDest, pSource, Width*Height*BytesPerPixel); } else { if(pPoint != NULL && (pPoint->x != 0 || pPoint->y != 0)) CxbxKrnlCleanup("Temporarily unsupported swizzle (very easy fix)"); DWORD dwMaxY = Height; DWORD dwChunkSize = Width; uint08 *pSrc = (uint08*)pSource; uint08 *pDst = (uint08*)pDest; if(pRect != 0) { pSrc += pRect->top*Pitch; pSrc += pRect->left; dwMaxY = pRect->bottom - pRect->top; dwChunkSize = pRect->right - pRect->left; } for(DWORD y=0;y<dwMaxY;y++) { memcpy(pSrc, pDst, dwChunkSize); pSrc += Pitch; pDst += Pitch; } } EmuSwapFS(); // Xbox FS return; }
void menu_init(menu_t *p_menu, VMGPFONT *p_font, char *pp_msgs[], int16_t x1, int16_t y1, int16_t x2, int16_t y2) { int i; int j; p_menu->pp_msgs = pp_msgs; p_menu->p_font = p_font; p_menu->x1 = x1; p_menu->y1 = y1; p_menu->x2 = x2; p_menu->y2 = y2; p_menu->text_w = 0; p_menu->n_submenus = 0; for (p_menu->n_entries = 0; p_menu->pp_msgs[p_menu->n_entries]; p_menu->n_entries++) { int len; /* Is this a submenu? */ if (IS_SUBMENU(p_menu->pp_msgs[p_menu->n_entries])) { p_menu->n_submenus++; continue; /* Length of submenus is unimportant */ } for (len = 0; p_menu->pp_msgs[p_menu->n_entries][len]; len++); if (len * p_font->width > p_menu->text_w) p_menu->text_w = len * p_font->width; } if ( !(p_menu->p_submenus = vNewPtr(sizeof(submenu_t) * p_menu->n_submenus)) ) { DbgPrintf("vNewPtr failed!\n"); vTerminateVMGP(); } j=0; for (i=0; i<p_menu->n_submenus; i++) { for (; j < p_menu->n_entries; j++) { if (IS_SUBMENU(p_menu->pp_msgs[j])) { int n; DbgPrintf("Init submenu %d:%d\n", i, j); p_menu->p_submenus[i].index = j; p_menu->p_submenus[i].sel = 0; p_menu->p_submenus[i].n_entries = 0; for (n=0; p_menu->pp_msgs[j][n] != '\0'; n++) { if (p_menu->pp_msgs[j][n] == '|') p_menu->p_submenus[i].n_entries++; } } } } p_menu->text_h = p_menu->n_entries * (p_font->height+2); }
void tSonarSourceStateMachine::NewServerCommanded(tMacAddress NewServerMac, QHostAddress IP, bool GUICommand) { // Ignore all remote masters in offline mode if(tSonarSettings::Instance()->OfflineModeUsed(m_Class)) { // The state can be in the process of updating by another signal that is coming // after the sonar settings already received the simulator on command. //Assert(m_State == eSonarServerState_Server); return; } // NSW-26815: Ignore server change commands if we don't have the source on our list const QHostAddress broadcast(QHostAddress::Broadcast); if(IP == broadcast) { // Invalid IP received, means the source is on our list, ignore this command // until source is detected... return; } bool NeedClientEmit = false; tMacAddress ClientMac; { tWriteLocker Locker(m_Lock); m_SavedMaster = NewServerMac; m_pSettings->SetValue("ServerMac", m_SavedMaster.ToString()); if(!m_Simulating) { if(m_SavedMaster == m_MyMac) { // NSW-24004: Only set client/server mode to false when becoming the sidescan server if(m_Class == SonarCommon::eSonarServer_Sidescan) { tSonarSettings::Instance()->SetClientServerMode(false); } m_CurrentIP = m_MyIP; m_pSettings->SetValue("ServerIP", m_CurrentIP.toString()); DBG_SONAR_SOURCE_STATE(DbgPrintf("New server commanded, becoming server")); ChangeState(SonarCommon::eSonarServerState_Server); } else { QString classStr = tSonarSourceStateMachine::GetClassString(m_Class); DbgPrintf("New server(%s) - becoming client (%s)", classStr.toStdString().c_str(), IP.toString().toAscii().constData()); m_TimeoutCounter = m_cClientTimeout; m_CurrentMac = m_SavedMaster; m_CurrentIP = IP; m_pSettings->SetValue("ServerIP", m_CurrentIP.toString()); DBG_SONAR_SOURCE_STATE(DbgPrintf("New server commanded, becoming client")); ChangeState(SonarCommon::eSonarServerState_Client); NeedClientEmit = true; ClientMac = m_SavedMaster; // NSW-24004: Will set structure in client/server mode whenever we are not our own source, this will ensure that our // internal settings won't be affected by the setting changes made to the new source and vice-versa if(m_Class == SonarCommon::eSonarServer_Sidescan) { tSonarSettings::Instance()->SetClientServerMode(true); } } if(GUICommand && (m_Class != SonarCommon::eSonarServer_Sidescan)) { tThread::AssertGUIThread(); emit SendServerCommand(m_SavedMaster, m_Class); } } } emit UpdateServer(m_SavedMaster, m_Class); if(NeedClientEmit) { emit SetClientState(ClientMac, IP); } }
//------------------------------------------------------------------------------- // //------------------------------------------------------------------------------- void tFilesTreeNodeBuilder::AppendDirContents( tFilesTreeItem* pParent, const QString& baseDir, unsigned long& itemCount, const bool translateNames ) { // Sort files and directories by name QDir dir( baseDir ); QFileInfoList directories = dir.entryInfoList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name ); QFileInfoList files = dir.entryInfoList( QDir::Files ); // Append directories and subdirectories QListIterator<QFileInfo> directoriesIterator( directories ); while ( directoriesIterator.hasNext() ) { if ( m_Quit ) { return; } QFileInfo directoryInfo = directoriesIterator.next(); // Skipping Navionics chart directory due to large number of folders/files. if ( directoryInfo.fileName().compare( "Navionic", Qt::CaseInsensitive ) == 0 ) { DbgPrintf( "tFilesTreeModel::AppendDirContents: Skipping Navionics charts directory." ); continue; } tFilesTreeItem* pDirItem; if ( translateNames ) { pDirItem = new tFilesTreeItem( directoryInfo, TranslatedFileName( directoryInfo.fileName() ), pParent ); } else { pDirItem = new tFilesTreeItem( directoryInfo, directoryInfo.fileName(), pParent ); } pDirItem->SetIcon( qApp->style()->standardIcon( QStyle::SP_DirIcon ) ); pDirItem->SetOptionsIcon( qApp->style()->standardIcon( NIT(tNOSStyle::NIT_Options) ) ); pDirItem->SetAllowOptionsColumn( true ); m_pRootNode->SetAllowOptionsColumn( true ); pParent->AppendChild( pDirItem ); itemCount++; AppendDirContents( pDirItem, directoryInfo.filePath(), itemCount ); } // Append files from current directory QListIterator<QFileInfo> filesIterator( files ); while ( filesIterator.hasNext() ) { if ( m_Quit ) { return; } QFileInfo fileInfo = filesIterator.next(); tFilesTreeItem* pFileItem; if ( translateNames ) { pFileItem = new tFilesTreeItem( fileInfo, TranslatedFileName( fileInfo.fileName() ), pParent ); } else { pFileItem = new tFilesTreeItem( fileInfo, fileInfo.fileName(), pParent ); } pParent->AppendChild( pFileItem ); itemCount++; } }
void tH3000LinkRx::RxSerialData(const QByteArray& rxData) { bool messageReceived = false; // Receive buffer is a QByteArray // This could be optimised to be char array to reduce allocs and copies m_RxBuffer += rxData; int endIndex = m_RxBuffer.indexOf("\r\n"); while(endIndex != -1) { QByteArray RxMessage = m_RxBuffer.left(endIndex); if(RxMessage.size() > 0) { bool messageOk = false; #ifdef LOG_H3000_RX DbgPrintf("**** H3000 Rx %s", RxMessage.constData()); #endif // Check the checksum int checksumIndex = RxMessage.lastIndexOf('*'); if(checksumIndex != -1) { unsigned char calcChecksum = static_cast<unsigned char>( tH3000Command::CalculateChecksum( RxMessage.left( checksumIndex) ) ); unsigned char checksum = static_cast<unsigned char>( RxMessage.mid(checksumIndex + 1, 2).toInt(0, 16) ); if(checksum == calcChecksum) { messageOk = true; } } if(messageOk == true) { QByteArray strippedMessage = RxMessage.left(checksumIndex); if(RxMessage.at(0) == '#') { emit H3000ReceivedEchoResponse(RxMessage); } else if(RxMessage.at(0) == 'V') { ProcessReceivedValue(strippedMessage); } else if(RxMessage.at(0) == 'U') { ProcessReceivedTableData(strippedMessage); } else if(RxMessage.at(0) == 'L') { ProcessReceivedPosition(strippedMessage); } else if(RxMessage.at(0) == 'T') { ProcessReceivedUTC(strippedMessage); } else if(RxMessage.at(0) == 'M') { ProcessReceivedTrueMagSetting(strippedMessage); } messageReceived = true; } } m_RxBuffer = m_RxBuffer.mid(endIndex + 2); endIndex = m_RxBuffer.indexOf("\r\n"); } if((messageReceived) && (!m_DataReceived)) { m_DataReceived = true; emit H3000LinkDataReceived(); } }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void tAutopilotSelectedDeviceMenu::AddDevice( const tN2kName& name, bool selected, bool enabled ) { QString nameStr = tGlobal<tNDP2k>::Instance()->DeviceManager().DataSourceStr( name ); //DbgPrintf( QString("AddDevice nameStr=%1 value=%2").arg( nameStr ).arg( quint64( name.llValue() ) ) ); if( nameStr == "???" ) // incase the simnet selection is a device we have never seen... { // Get Simnet Nmea2k DevTag instead unsigned char devTag[16] = ""; // DEV_TAG_CHARS if( SystemData::bGetDevTag( (unsigned char*)name.ToByteArray().data(), 0, devTag ) ) { nameStr = QString((char *)devTag); } } bool insertDevice = false; // Sort names into order of decreasing name QList<tAction*> actionList = SubActions(); int i; for( i = 0; i < actionList.size(); ++i ) { quint64 nameInList = quint64( actionList[i]->data().toLongLong() ); //DbgPrintf( QString("AddDevice: index=%1 nameInList=%2").arg( i ).arg( nameInList ) ); if ( nameInList > 0 ) //If it's not one of the fixed items at the top or a separator { if( quint64( name.llValue() ) == nameInList ) { //Already in list - just update //DbgPrintf( "Device already in list" ); QAction* pAction = actionList[i]; pAction->setText( nameStr ); if ( pAction->isCheckable() ) { pAction->setChecked( selected ); } return; } else if( quint64( name.llValue() ) > nameInList ) { DbgPrintf( "Name greater than nameInList" ); insertDevice = true; break; } } } tAction* pAction = new tAction( nameStr, this ); pAction->setCheckable( true ); pAction->setChecked( selected ); pAction->setData( QVariant( name.llValue() ) ); pAction->setEnabled( enabled ); if( insertDevice ) { DbgPrintf( QString("Inserting action at index %1").arg( i ) ); InsertAction( actionList[i], pAction ); } else // Append { DbgPrintf( QString("Adding action %1").arg( nameStr ) ); AddAction( pAction ); } m_SelectDeviceActGroup.append( pAction ); Connect( pAction, SIGNAL( triggered( bool ) ), this, SLOT( SelectDevice( bool ) ) ); }
void Ep0Handler(void) { static int ep0SubState; int i; U8 ep0_csr; usbdevregs->INDEX_REG=0; ep0_csr=usbdevregs->EP0_CSR_IN_CSR1_REG; DbgPrintf("<0:%x]",ep0_csr); //DATAEND interrupt(ep0_csr==0x0) will be ignored //because ep0State==EP0_STATE_INIT when the DATAEND interrupt is issued. if(ep0_csr & EP0_SETUP_END) { // Host may end GET_DESCRIPTOR operation without completing the IN data stage. // If host does that, SETUP_END bit will be set. // OUT_PKT_RDY has to be also cleared because status stage sets OUT_PKT_RDY to 1. DbgPrintf("[SETUPEND]"); CLR_EP0_SETUP_END(); if(ep0_csr & EP0_OUT_PKT_READY) { FLUSH_EP0_FIFO(); //(???) //I think this isn't needed because EP0 flush is done automatically. CLR_EP0_OUT_PKT_RDY(); } ep0State=EP0_STATE_INIT; return; } //I think that EP0_SENT_STALL will not be set to 1. if(ep0_csr & EP0_SENT_STALL) { DbgPrintf("[STALL]"); CLR_EP0_SENT_STALL(); if(ep0_csr & EP0_OUT_PKT_READY) { CLR_EP0_OUT_PKT_RDY(); } ep0State=EP0_STATE_INIT; return; } if((ep0_csr & EP0_OUT_PKT_READY)) // && (ep0State==EP0_STATE_INIT)) { RdPktEp0((U8 *)&descSetup,EP0_PKT_SIZE); PrintEp0Pkt((U8 *)(&descSetup)); //DEBUG switch(descSetup.bRequest) { case GET_DESCRIPTOR: switch(descSetup.bValueH) { case DEVICE_TYPE: DbgPrintf("[GDD]"); CLR_EP0_OUT_PKT_RDY(); ep0State=EP0_STATE_GD_DEV_0; break; case CONFIGURATION_TYPE: DbgPrintf("[GDC]"); CLR_EP0_OUT_PKT_RDY(); if((descSetup.bLengthL+(descSetup.bLengthH<<8))>0x9) //bLengthH should be used for bLength=0x209 at WIN2K. ep0State=EP0_STATE_GD_CFG_0; //for WIN98,WIN2K else ep0State=EP0_STATE_GD_CFG_ONLY_0; //for WIN2K break; case STRING_TYPE: DbgPrintf("[GDS]"); CLR_EP0_OUT_PKT_RDY(); switch(descSetup.bValueL) { case 0: ep0State=EP0_STATE_GD_STR_I0; break; case 1: ep0State=EP0_STATE_GD_STR_I1; break; case 2: ep0State=EP0_STATE_GD_STR_I2; break; default: DbgPrintf("[UE:STRI?]"); break; } ep0SubState=0; break; case INTERFACE_TYPE: DbgPrintf("[GDI]"); CLR_EP0_OUT_PKT_RDY(); ep0State=EP0_STATE_GD_IF_ONLY_0; //for WIN98 break; case ENDPOINT_TYPE: DbgPrintf("[GDE]"); CLR_EP0_OUT_PKT_RDY(); switch(descSetup.bValueL&0xf) { case 0: ep0State=EP0_STATE_GD_EP0_ONLY_0; break; case 1: ep0State=EP0_STATE_GD_EP1_ONLY_0; break; default: DbgPrintf("[UE:GDE?]"); break; } break; default: DbgPrintf("[UE:GD?]"); break; } break; case SET_ADDRESS: DbgPrintf("[SA:%d]",descSetup.bValueL); usbdevregs->FUNC_ADDR_REG=descSetup.bValueL | 0x80; CLR_EP0_OUTPKTRDY_DATAEND(); //Because of no data control transfers. ep0State=EP0_STATE_INIT; break; case SET_CONFIGURATION: DbgPrintf("[SC]"); ConfigSet.ConfigurationValue=descSetup.bValueL; CLR_EP0_OUTPKTRDY_DATAEND(); //Because of no data control transfers. ep0State=EP0_STATE_INIT; isUsbdSetConfiguration=1; break; //////////////////////// For chapter 9 test //////////////////// case CLEAR_FEATURE: switch (descSetup.bmRequestType) { case DEVICE_RECIPIENT: if (descSetup.bValueL == 1) Rwuen = FALSE; break; case ENDPOINT_RECIPIENT: if (descSetup.bValueL == 0) { if((descSetup.bIndexL & 0x7f) == 0x00){ StatusGet.Endpoint0= 0; } if((descSetup.bIndexL & 0x8f) == 0x81){ // IN Endpoint 1 StatusGet.Endpoint1= 0; } if((descSetup.bIndexL & 0x8f) == 0x03){ // OUT Endpoint 3 StatusGet.Endpoint3= 0; } } break; default: break; } CLR_EP0_OUTPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; case GET_CONFIGURATION: CLR_EP0_OUT_PKT_RDY(); ep0State=EP0_CONFIG_SET; break; case GET_INTERFACE: CLR_EP0_OUT_PKT_RDY(); ep0State=EP0_INTERFACE_GET; break; case GET_STATUS: switch(descSetup.bmRequestType) { case (0x80): CLR_EP0_OUT_PKT_RDY(); StatusGet.Device=((U8)Rwuen<<1)|(U8)Selfpwr; ep0State=EP0_GET_STATUS0; break; case (0x81): CLR_EP0_OUT_PKT_RDY(); StatusGet.Interface=0; ep0State=EP0_GET_STATUS1; break; case (0x82): CLR_EP0_OUT_PKT_RDY(); if((descSetup.bIndexL & 0x7f) == 0x00){ ep0State=EP0_GET_STATUS2; } if((descSetup.bIndexL & 0x8f) == 0x81){ ep0State=EP0_GET_STATUS3; } if((descSetup.bIndexL & 0x8f) == 0x03){ ep0State=EP0_GET_STATUS4; } break; default: break; } break; case SET_DESCRIPTOR: CLR_EP0_OUTPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; case SET_FEATURE: switch (descSetup.bmRequestType) { case DEVICE_RECIPIENT: if (descSetup.bValueL == 1) Rwuen = TRUE; break; case ENDPOINT_RECIPIENT: if (descSetup.bValueL == 0) { if((descSetup.bIndexL & 0x7f) == 0x00){ StatusGet.Endpoint0= 1; } if((descSetup.bIndexL & 0x8f) == 0x81){ StatusGet.Endpoint1= 1; } if((descSetup.bIndexL & 0x8f) == 0x03){ StatusGet.Endpoint3= 1; } } break; default: break; } CLR_EP0_OUTPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; case SET_INTERFACE: InterfaceGet.AlternateSetting= descSetup.bValueL; CLR_EP0_OUTPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; case SYNCH_FRAME: ep0State=EP0_STATE_INIT; break; ////////////////////////////////////////////////////////////// default: DbgPrintf("[UE:SETUP=%x]",descSetup.bRequest); CLR_EP0_OUTPKTRDY_DATAEND(); //Because of no data control transfers. ep0State=EP0_STATE_INIT; break; } } switch(ep0State) { case EP0_STATE_INIT: break; //=== GET_DESCRIPTOR:DEVICE === case EP0_STATE_GD_DEV_0: DbgPrintf("[GDD0]"); WrPktEp0((U8 *)&descDev+0,8); //EP0_PKT_SIZE SET_EP0_IN_PKT_RDY(); ep0State=EP0_STATE_GD_DEV_1; break; case EP0_STATE_GD_DEV_1: DbgPrintf("[GDD1]"); WrPktEp0((U8 *)&descDev+0x8,8); SET_EP0_IN_PKT_RDY(); ep0State=EP0_STATE_GD_DEV_2; break; case EP0_STATE_GD_DEV_2: DbgPrintf("[GDD2]"); WrPktEp0((U8 *)&descDev+0x10,2); //8+8+2=0x12 SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; //=== GET_DESCRIPTOR:CONFIGURATION+INTERFACE+ENDPOINT0+ENDPOINT1 === //Windows98 gets these 4 descriptors all together by issuing only a request. //Windows2000 gets each descriptor seperately. case EP0_STATE_GD_CFG_0: DbgPrintf("[GDC0]"); WrPktEp0((U8 *)&descConf+0,8); //EP0_PKT_SIZE SET_EP0_IN_PKT_RDY(); ep0State=EP0_STATE_GD_CFG_1; break; case EP0_STATE_GD_CFG_1: DbgPrintf("[GDC1]"); WrPktEp0((U8 *)&descConf+8,1); WrPktEp0((U8 *)&descIf+0,7); SET_EP0_IN_PKT_RDY(); ep0State=EP0_STATE_GD_CFG_2; break; case EP0_STATE_GD_CFG_2: DbgPrintf("[GDC2]"); WrPktEp0((U8 *)&descIf+7,2); WrPktEp0((U8 *)&descEndpt0+0,6); SET_EP0_IN_PKT_RDY(); ep0State=EP0_STATE_GD_CFG_3; break; case EP0_STATE_GD_CFG_3: DbgPrintf("[GDC3]"); WrPktEp0((U8 *)&descEndpt0+6,1); WrPktEp0((U8 *)&descEndpt1+0,7); SET_EP0_IN_PKT_RDY(); ep0State=EP0_STATE_GD_CFG_4; break; case EP0_STATE_GD_CFG_4: DbgPrintf("[GDC4]"); //zero length data packit SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; //=== GET_DESCRIPTOR:CONFIGURATION ONLY=== case EP0_STATE_GD_CFG_ONLY_0: DbgPrintf("[GDCO0]"); WrPktEp0((U8 *)&descConf+0,8); //EP0_PKT_SIZE SET_EP0_IN_PKT_RDY(); ep0State=EP0_STATE_GD_CFG_ONLY_1; break; case EP0_STATE_GD_CFG_ONLY_1: DbgPrintf("[GDCO1]"); WrPktEp0((U8 *)&descConf+8,1); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; //=== GET_DESCRIPTOR:INTERFACE ONLY=== case EP0_STATE_GD_IF_ONLY_0: DbgPrintf("[GDI0]"); WrPktEp0((U8 *)&descIf+0,8); SET_EP0_IN_PKT_RDY(); ep0State=EP0_STATE_GD_IF_ONLY_1; break; case EP0_STATE_GD_IF_ONLY_1: DbgPrintf("[GDI1]"); WrPktEp0((U8 *)&descIf+8,1); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; //=== GET_DESCRIPTOR:ENDPOINT 0 ONLY=== case EP0_STATE_GD_EP0_ONLY_0: DbgPrintf("[GDE00]"); WrPktEp0((U8 *)&descEndpt0+0,7); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; //=== GET_DESCRIPTOR:ENDPOINT 1 ONLY=== case EP0_STATE_GD_EP1_ONLY_0: DbgPrintf("[GDE10]"); WrPktEp0((U8 *)&descEndpt1+0,7); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; //////////////////////////////////////////// case EP0_INTERFACE_GET: WrPktEp0((U8 *)&InterfaceGet+0,1); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; //=== GET_DESCRIPTOR:STRING === case EP0_STATE_GD_STR_I0: DbgPrintf("[GDS0_0]"); WrPktEp0((U8 *)descStr0, 4 ); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; ep0SubState=0; break; case EP0_STATE_GD_STR_I1: DbgPrintf("[GDS1_%d]",ep0SubState); if( (ep0SubState*EP0_PKT_SIZE+EP0_PKT_SIZE)<sizeof(descStr1) ) { WrPktEp0((U8 *)descStr1+(ep0SubState*EP0_PKT_SIZE),EP0_PKT_SIZE); SET_EP0_IN_PKT_RDY(); ep0State=EP0_STATE_GD_STR_I1; ep0SubState++; } else { WrPktEp0((U8 *)descStr1+(ep0SubState*EP0_PKT_SIZE), sizeof(descStr1)-(ep0SubState*EP0_PKT_SIZE)); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; ep0SubState=0; } break; case EP0_STATE_GD_STR_I2: DbgPrintf("[GDS2_%d]",ep0SubState); if( (ep0SubState*EP0_PKT_SIZE+EP0_PKT_SIZE)<sizeof(descStr2) ) { WrPktEp0((U8 *)descStr2+(ep0SubState*EP0_PKT_SIZE),EP0_PKT_SIZE); SET_EP0_IN_PKT_RDY(); ep0State=EP0_STATE_GD_STR_I2; ep0SubState++; } else { DbgPrintf("[E]"); WrPktEp0((U8 *)descStr2+(ep0SubState*EP0_PKT_SIZE), sizeof(descStr2)-(ep0SubState*EP0_PKT_SIZE)); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; ep0SubState=0; } break; case EP0_CONFIG_SET: WrPktEp0((U8 *)&ConfigSet+0,1); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; case EP0_GET_STATUS0: WrPktEp0((U8 *)&StatusGet+0,1); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; case EP0_GET_STATUS1: WrPktEp0((U8 *)&StatusGet+1,1); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; case EP0_GET_STATUS2: WrPktEp0((U8 *)&StatusGet+2,1); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; case EP0_GET_STATUS3: WrPktEp0((U8 *)&StatusGet+3,1); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; case EP0_GET_STATUS4: WrPktEp0((U8 *)&StatusGet+4,1); SET_EP0_INPKTRDY_DATAEND(); ep0State=EP0_STATE_INIT; break; default: DbgPrintf("UE:G?D"); break; } }
//----------------------------------------------------------------------------- //! Returns true and emits the SystemDateTimeLocalChanged() signal if successfully set. //----------------------------------------------------------------------------- bool tSystemDateTime::SetSystemDateTimeFromLocal(const QDateTime& dateTime, bool setValid /*= false */) { Q_UNUSED(setValid); DBG( DbgPrintf( "tSystemDateTime::SetSystemDateTimeFromLocal %s, %d", qPrintable( dateTime.toString(Qt::ISODate)), m_LocalTimeOffsetFromUtcInMinutes ); )
//! this seems to happen very rapid fire, perhaps every 10ms? void tSonarSourceStateMachine::timerEvent(QTimerEvent *) { if (tProductSettings::Instance().EthernetAllowed() == true) { // If we don't have a valid address, then tell the tSonar to check for a good one... if(m_MyIP == QHostAddress::LocalHost || m_MyMac.IsNull() || m_MyMac.IsBroadcast()) { tSonar::Instance()->ForceUpdateAddresses(); } } tWriteLocker Locker(m_Lock); //QString classStr = tSonarSourceStateMachine::GetClassString(m_Class); //DbgPrintf("tSonarSourceStateMachine(%s)::Timer event = %i - state %s", // classStr.toStdString().c_str(), m_TimeoutCounter, m_StateStrings[m_State]); bool haveInternalStructureScan = false; if((tSonarSettings::Instance()->GetLocalFrequencies() & eSonarFrequency_ScanningFrequencyBits) != 0) { haveInternalStructureScan = true; } switch(m_State) { case SonarCommon::eSonarServerState_TwoServers: // 05/24/12 - CGB: (NSW-10209) We don't want to be claiming the server if we have internal structurescan because it can overwrite the // source selected by another client specially Composer & Atlantis since those units don't output any command to let know the other // clients they have selected a specific source. if( (m_Class == SonarCommon::eSonarServer_Forwardscan) || (m_Class == SonarCommon::eSonarServer_Conventional) || !haveInternalStructureScan) { m_TimeoutCounter--; if(m_TimeoutCounter == 0) { DBG_SONAR_SOURCE_STATE(DbgPrintf("Two server timeout - changing to server (claim)")); emit ClaimServer(m_Class); ChangeState(SonarCommon::eSonarServerState_Server); } } break; case SonarCommon::eSonarServerState_Client: m_TimeoutCounter--; if(m_TimeoutCounter == 0 && !m_Simulating) { // NSW-25760 Luigi - StructureScan 3D source appearing in source list for lowrance products if (tSonar::Instance()->GetSaveAndKeepSourceSelected() == false) { DBG_SONAR_SOURCE_STATE(DbgPrintf("Server timeout, becoming server")); ChangeState(SonarCommon::eSonarServerState_Server); } else { if(m_SavedMaster.IsNull()) { DBG_SONAR_SOURCE_STATE(DbgPrintf("Server timeout, becoming server (saved master null)")); ChangeState(SonarCommon::eSonarServerState_Server); } else { DBG_SONAR_SOURCE_STATE(DbgPrintf("Server timeout, switching to no server mode")); ChangeState(SonarCommon::eSonarServerState_NoServer); } } } break; default: // Ignore timer event for other states... break; } }
void tSonarSourceStateMachine::RemoteMasterSeen(tMacAddress NewServerMac, QHostAddress IP) { //QString classStr = tSonarSourceStateMachine::GetClassString(m_Class); //DbgPrintf("RemoteMasterSeen (%s) - IP=%s", classStr.toStdString().c_str(), IP.toString().toAscii().constData() ); // Ignore all remote masters in offline mode if(tSonarSettings::Instance()->OfflineModeUsed(m_Class)) { return; } if(m_State == SonarCommon::eSonarServerState_Server) { // Can't be the server in these cases! // In the case of forwardscan we can have the forward but won't be outputting network data unless we detect forwardscan transducer connected if(!m_HaveHardware || (m_Class == SonarCommon::eSonarServer_Forwardscan && !tSonarSettings::Instance()->InternalForwardscanEnabled())) { m_State = SonarCommon::eSonarServerState_NoServer; } } bool NeedClientEmit = false; bool NeedNewServerCommanded = false; tMacAddress ClientMac; { tWriteLocker Locker(m_Lock); switch(m_State) { case SonarCommon::eSonarServerState_NoServer: if((NewServerMac == m_SavedMaster) || (m_SavedMaster.IsNull() == true)) { m_TimeoutCounter = m_cClientTimeout; m_CurrentMac = NewServerMac; m_CurrentIP = IP; m_pSettings->SetValue("ServerIP", m_CurrentIP.toString()); DBG_SONAR_SOURCE_STATE(DbgPrintf("Remote master seen (our server)")); ChangeState(SonarCommon::eSonarServerState_Client); NeedClientEmit = true; ClientMac = NewServerMac; emit UpdateServer(m_SavedMaster, m_Class); } else if(m_Class != SonarCommon::eSonarServer_Sidescan) { // If we are here it means we have a server previously saved, in order to prevent a legacy unit from claiming the server // then force it to switch its source to the one we had previously selected emit SendServerCommand(m_SavedMaster, m_Class); } break; case SonarCommon::eSonarServerState_Server: if(NewServerMac == m_SavedMaster) { if(NewServerMac != m_MyMac) { m_TimeoutCounter = m_cClientTimeout; m_CurrentMac = m_SavedMaster; m_CurrentIP = IP; m_pSettings->SetValue("ServerIP", m_CurrentIP.toString()); DBG_SONAR_SOURCE_STATE(DbgPrintf("Remote master seen (our server)")); ChangeState(SonarCommon::eSonarServerState_Client); NeedClientEmit = true; ClientMac = m_SavedMaster; // NSW-24004: Will set structure in client/server mode whenever we are not our own source, this will ensure that our // internal settings won't be affected by the setting changes made to the new source and vice-versa if(m_Class == SonarCommon::eSonarServer_Sidescan) { tSonarSettings::Instance()->SetClientServerMode(true); } emit UpdateServer(m_SavedMaster, m_Class); } } else { // NSW-17844: We allow multiple servers in sidescan and going into two server mode can prevent us from restoring // the user selected source when turning unit off and on. if(m_Class != SonarCommon::eSonarServer_Sidescan) { if(m_SavedMaster == m_MyMac ) { // We were set as the server and a new server has just been detected, it could be a new unit joining the network or // a legacy unit that doesn't support the sever saving and restoring requested in NSW-23903, in either of these cases // we need to re-claim the server status instead of going into two server mode emit ClaimServer(m_Class); DBG_SONAR_SOURCE_STATE(DbgPrintf("Claiming server")); } else { m_TimeoutCounter = m_cTwoServerTimeout;//~~~~~ + GetTimeSinceBoot() / 10; if(m_TimeoutCounter > 20) { m_TimeoutCounter = 20 + (qrand() % 10); } ChangeState(SonarCommon::eSonarServerState_TwoServers); DBG_SONAR_SOURCE_STATE(DbgPrintf("New server (%s) - going to two server mode", IP.toString().toAscii().constData())); } } } break; case SonarCommon::eSonarServerState_Client: //~~~~~~~~~~~ Captured on state diagram? if(m_CurrentMac.IsBroadcast()) { m_CurrentMac = NewServerMac; m_CurrentIP = IP; m_pSettings->SetValue("ServerIP", m_CurrentIP.toString()); } // Reset the timeout whenever we see our server... if(NewServerMac == m_CurrentMac || m_CurrentMac.IsBroadcast()) { m_TimeoutCounter = m_cClientTimeout; static const QHostAddress Broadcast(QHostAddress::Broadcast); if(m_CurrentIP == Broadcast) { // DbgPrintf("*****Sonar client updated server IP: %s", IP.toString().toAscii().constData()); m_CurrentIP = IP; m_pSettings->SetValue("ServerIP", m_CurrentIP.toString()); ClientMac = NewServerMac; NeedNewServerCommanded = true; } } else { // If this is the server we really want, the switch! if(NewServerMac == m_SavedMaster) { m_TimeoutCounter = m_cClientTimeout; m_CurrentMac = m_SavedMaster; m_CurrentIP = IP; m_pSettings->SetValue("ServerIP", m_CurrentIP.toString()); DBG_SONAR_SOURCE_STATE(DbgPrintf("Remote server (our server)")); ChangeState(SonarCommon::eSonarServerState_Client); NeedClientEmit = true; ClientMac = m_SavedMaster; emit UpdateServer(m_SavedMaster, m_Class); } } break; case SonarCommon::eSonarServerState_TwoServers: // Need to restore our server if it comes to network a little late and we are in two server mode already // If this is the server we really want, the switch! if(NewServerMac == m_SavedMaster) { m_TimeoutCounter = m_cClientTimeout; m_CurrentMac = m_SavedMaster; m_CurrentIP = IP; m_pSettings->SetValue("ServerIP", m_CurrentIP.toString()); DBG_SONAR_SOURCE_STATE(DbgPrintf("Remote server, two servers (our server)")); ChangeState(SonarCommon::eSonarServerState_Client); NeedClientEmit = true; ClientMac = m_SavedMaster; emit UpdateServer(m_SavedMaster, m_Class); } break; default: // All other cases ignore until they timeout break; } } if(NeedClientEmit) { emit SetClientState(ClientMac, IP); } if(NeedNewServerCommanded) { NewServerCommanded(ClientMac, IP, false); } }
/* * httpsSendStatusLine * * Sends a formatted response message to Sock with the given * status code and content type. The value of ContentType can * be NULL if no ContentType is required. */ void httpsSendStatusLine(WOLFSSL *ssl, int StatusCode, char *ContentType) { char Response[MAX_RESPONSE_SIZE]; int i; int sizeRemaining = MAX_RESPONSE_SIZE; /* Bound status code so that a very large code can't crash us */ if (StatusCode < 0 || StatusCode > 999) { StatusCode = 999; } /* * sizeRemaing will track available space in string. Its value includes the * '\0' null terminating character. */ sizeRemaining = sizeRemaining - NDK_sprintf(Response, "%s%3d", HTTP_VER, StatusCode); for (i = 0; codestr[i].code && codestr[i].code != StatusCode; i++); if (strlen(codestr[i].string) < sizeRemaining) { strcat(Response, codestr[i].string); sizeRemaining = sizeRemaining - strlen(codestr[i].string); } else { DbgPrintf(DBG_INFO, "httpsSendStatusLine: not enough space in Response array to build HTML string (1)\n"); } /* ensure there's room available in Response[] to write the code string */ if (strlen(CRLF) < sizeRemaining) { strcat(Response, CRLF); sizeRemaining = sizeRemaining - strlen(CRLF); } else { DbgPrintf(DBG_INFO, "httpsSendStatusLine: not enough space in Response array to build HTML string (2)\n"); } if( ContentType ) { /* ensure there's room available in Response[] to write the code string */ if (strlen(CONTENT_TYPE) < sizeRemaining) { strcat(Response, CONTENT_TYPE); sizeRemaining = sizeRemaining - strlen(CONTENT_TYPE); } else { DbgPrintf(DBG_INFO, "httpsSendStatusLine: not enough space in Response array to build HTML string (3)\n"); } /* ensure there's room available in Response[] to write the code string */ if (strlen(ContentType) < sizeRemaining) { strcat(Response, ContentType); sizeRemaining = sizeRemaining - strlen(ContentType); } else { DbgPrintf(DBG_INFO, "httpsSendStatusLine: not enough space in Response array to build HTML string (4)\n"); } /* ensure there's room available in Response[] to write the code string */ if (strlen(CRLF) < sizeRemaining) { strcat(Response, CRLF); sizeRemaining = sizeRemaining - strlen(CRLF); } else { DbgPrintf(DBG_INFO, "httpsSendStatusLine: not enough space in Response array to build HTML string (5)\n"); } } httpsSendClientStr( ssl, Response ); }
// ****************************************************************** // * 0x0042 - IoCreateFile() // ****************************************************************** XBSYSAPI EXPORTNUM(66) xboxkrnl::NTSTATUS NTAPI xboxkrnl::IoCreateFile ( OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG Disposition, IN ULONG CreateOptions, IN ULONG Options ) { LOG_FUNC_BEGIN LOG_FUNC_ARG_OUT(FileHandle) LOG_FUNC_ARG(DesiredAccess) LOG_FUNC_ARG(ObjectAttributes) LOG_FUNC_ARG_OUT(IoStatusBlock) LOG_FUNC_ARG(AllocationSize) LOG_FUNC_ARG(FileAttributes) LOG_FUNC_ARG(ShareAccess) LOG_FUNC_ARG_TYPE(CREATE_DISPOSITION, Disposition) LOG_FUNC_ARG_TYPE(CREATE_OPTION, CreateOptions) LOG_FUNC_ARG(Options) LOG_FUNC_END; NativeObjectAttributes nativeObjectAttributes; // If we are NOT accessing a directory, and we match a partition path, we need to redirect to a partition.bin file bool isDirectPartitionAccess = false; std::string objectName = std::string(ObjectAttributes->ObjectName->Buffer, ObjectAttributes->ObjectName->Length); if ((CreateOptions & FILE_DIRECTORY_FILE) == 0 && _strnicmp(objectName.c_str(), DeviceHarddisk0PartitionPrefix.c_str(), DeviceHarddisk0PartitionPrefix.length()) == 0 && objectName.length() <= DeviceHarddisk0PartitionPrefix.length() + 2) { isDirectPartitionAccess = true; } NTSTATUS ret = CxbxObjectAttributesToNT(ObjectAttributes, /*OUT*/nativeObjectAttributes, "IoCreateFile", isDirectPartitionAccess); // When a Synchronous CreateOption is specified, DesiredAccess must have SYNCHRONIZE set if ((CreateOptions & FILE_SYNCHRONOUS_IO_NONALERT) != 0 || (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT) != 0) { DesiredAccess |= SYNCHRONIZE; } // Force ShareAccess to all ShareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; if (SUCCEEDED(ret)) { // redirect to NtCreateFile ret = NtDll::NtCreateFile( FileHandle, DesiredAccess | GENERIC_READ, nativeObjectAttributes.NtObjAttrPtr, NtDll::PIO_STATUS_BLOCK(IoStatusBlock), NtDll::PLARGE_INTEGER(AllocationSize), FileAttributes, ShareAccess, Disposition, CreateOptions, NULL, 0); if (CxbxDebugger::CanReport()) { CxbxDebugger::ReportFileOpened(*FileHandle, nativeObjectAttributes.NtUnicodeString.Buffer, SUCCEEDED(ret)); } } if (FAILED(ret)) { EmuWarning("KRNL: IoCreateFile Failed! (%s)\n", NtStatusToString(ret)); } else { DbgPrintf("KRNL: IoCreateFile = 0x%.8X\n", *FileHandle); } RETURN(ret); }
/* Exported function that registers a HandlerRoutine to accept missing * Win9x CTRL_EVENTs from the tty window, as NT does without a hassle. * If add is 1 or 2, register the handler, if 2 also mark it as a service. * If add is 0 deregister the handler, and unmark if a service */ BOOL __declspec(dllexport) WINAPI FixConsoleCtrlHandler( PHANDLER_ROUTINE phandler, INT add) { HWND parent; if (add) { HANDLE hThread; DWORD tid; /* NOTE: this is static so the module can continue to * access these args while we go on to other things */ static tty_info tty; EnumWindows(EnumttyWindow, (LPARAM)&parent); if (!parent) { #ifdef DBG DbgPrintf("A EnumttyWindow failed (%d)\r\n", GetLastError()); #endif return FALSE; } tty.instance = GetModuleHandle(NULL); tty.phandler = phandler; tty.parent = parent; tty.type = add; if (add == 2) { tty.name = "ttyService"; RegisterWindows9xService(TRUE); } else tty.name = "ttyMonitor"; hThread = CreateThread(NULL, 0, ttyConsoleCtrlThread, (LPVOID)&tty, 0, &tid); if (!hThread) return FALSE; CloseHandle(hThread); hmodHook = LoadLibrary("Win9xConHook.dll"); if (hmodHook) { hhkGetMessage = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)GetProcAddress(hmodHook, "GetMsgProc"), hmodHook, 0); //hhkCallWndProc = SetWindowsHookEx(WH_CALLWNDPROC, // (HOOKPROC)GetProcAddress(hmodHook, "CallWndProc"), hmodHook, 0); } return TRUE; } else /* remove */ { if (monitor_hwnd) { SendMessage(monitor_hwnd, WM_DESTROY, 0, 0); } if (hmodHook) { if (hhkGetMessage) { UnhookWindowsHookEx(hhkGetMessage); hhkGetMessage = NULL; } //if (hhkCallWndProc) { // UnhookWindowsHookEx(hhkCallWndProc); // hhkCallWndProc = NULL; //} FreeLibrary(hmodHook); hmodHook = NULL; } if (is_service) RegisterWindows9xService(FALSE); return TRUE; } return FALSE; }
void tRenderer::Render() { if (m_xRenderSystem != 0) { if (m_RenderSystemInitialized == false) { InitializeScene(); } m_xRenderSystem->BeginScene(); #ifdef DEBUG_RENDER_TIMING DbgPrintf("Time to execute m_xRenderSystem->BeginScene(): %lf", timer.ElapsedMs()); timer.Reset(); #endif // Render the Scene. m_xRenderSystem->SetViewport(m_pRenderTarget->x(), m_pRenderTarget->y(), m_pRenderTarget->width(), m_pRenderTarget->height()); RenderScene(); // Render Cursor if (m_CursorRenderFunction != 0) { m_CursorRenderFunction(); #ifdef DEBUG_RENDER_TIMING m_xRenderSystem->Flush(); DbgPrintf("Time to Render Cursor: %lf", timer.ElapsedMs()); timer.Reset(); #endif } if (m_OverlaysUpdated == true) { UpdateSceneOverlays(); } // Draw Overlays if (m_Overlays.size() > 0) { m_xRenderSystem->SetOrthographicProjection(m_pRenderTarget->x(), m_pRenderTarget->y(), m_pRenderTarget->width(), m_pRenderTarget->height()); unsigned long numRenderables = static_cast<unsigned long>(m_Overlays.size()); for (unsigned long renderIndex = 0; renderIndex < numRenderables; ++renderIndex) { RenderOverlay(m_Overlays[renderIndex]); #ifdef DEBUG_RENDER_TIMING m_xRenderSystem->Flush(); DbgPrintf("Time to Render Overlay #%d: %lf", renderIndex, timer.ElapsedMs()); timer.Reset(); #endif } } m_xRenderSystem->EndScene(); } emit RenderCompleted(); }
// ****************************************************************** // * func: EmuXGSwizzleBox // ****************************************************************** VOID WINAPI XTL::EmuXGSwizzleBox ( LPCVOID pSource, DWORD RowPitch, DWORD SlicePitch, CONST D3DBOX *pBox, LPVOID pDest, DWORD Width, DWORD Height, DWORD Depth, CONST XGPOINT3D *pPoint, DWORD BytesPerPixel ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXapi (0x%X): EmuXGSwizzleBox\n" "(\n" " pSource : 0x%.08X\n" " RowPitch : 0x%.08X\n" " SlicePitch : 0x%.08X\n" " pBox : 0x%.08X\n" " pDest : 0x%.08X\n" " Width : 0x%.08X\n" " Height : 0x%.08X\n" " Depth : 0x%.08X\n" " pPoint : 0x%.08X\n" " BytesPerPixel : 0x%.08X\n" ");\n", GetCurrentThreadId(), pSource, RowPitch, SlicePitch, pBox, pDest, Width, Height, Depth, pPoint, BytesPerPixel); if(pDest != (LPVOID) 0x80000000) { if(pBox == NULL && pPoint == NULL && RowPitch == 0 && SlicePitch == 0) { memcpy(pDest, pSource, Width*Height*Depth*BytesPerPixel); } else { if(pPoint != NULL && (pPoint->u != 0 || pPoint->v != 0 || pPoint->w != 0)) CxbxKrnlCleanup("Temporarily unsupported swizzle (very easy fix)"); DWORD dwMaxY = Height; DWORD dwMaxZ = Depth; DWORD dwChunkSize = Width; uint08 *pSrc = (uint08*)pSource; uint08 *pDst = (uint08*)pDest; if(pBox != 0) { pSrc += pBox->Top*RowPitch; pSrc += pBox->Left; dwMaxY = pBox->Bottom - pBox->Top; dwChunkSize = pBox->Right - pBox->Left; } for(DWORD y=0;y<dwMaxY;y++) { memcpy(pSrc, pDst, dwChunkSize); pSrc += RowPitch; pDst += RowPitch; } } } EmuSwapFS(); // Xbox FS return; }
/* This is the WndProc procedure for our invisible window. * When our subclasssed tty window receives the WM_CLOSE, WM_ENDSESSION, * or WM_QUERYENDSESSION messages, the message is dispatched to our hidden * window (this message process), and we call the installed HandlerRoutine * that was registered by the app. */ static LRESULT CALLBACK ttyConsoleCtrlWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_CREATE) { tty_info *tty = (tty_info*)(((LPCREATESTRUCT)lParam)->lpCreateParams); SetWindowLong(hwnd, gwltty_phandler, (LONG)tty->phandler); SetWindowLong(hwnd, gwltty_ttywnd, (LONG)tty->parent); #ifdef DBG DbgPrintf("A proc %8.8x created %8.8x %s for tty wnd %8.8x\r\n", GetCurrentProcessId(), hwnd, tty->name, tty->parent); #endif if (tty->parent) { SetProp(tty->parent, hookwndprop, hwnd); PostMessage(tty->parent, hookwndmsg, tty->type, (LPARAM)tty->parent); } return 0; } else if (msg == WM_DESTROY) { HWND parent = (HWND)GetWindowLong(hwnd, gwltty_ttywnd); #ifdef DBG DbgPrintf("A proc %8.8x destroyed %8.8x ttyConHookChild\r\n", GetCurrentProcessId(), hwnd); #endif if (parent) { RemoveProp(parent, hookwndprop); SendMessage(parent, hookwndmsg, 0, (LPARAM)parent); } monitor_hwnd = NULL; } else if (msg == WM_CLOSE) { PHANDLER_ROUTINE phandler = (PHANDLER_ROUTINE)GetWindowLong(hwnd, gwltty_phandler); LRESULT rv = phandler(CTRL_CLOSE_EVENT); #ifdef DBG DbgPrintf("A proc %8.8x invoked CTRL_CLOSE_EVENT " "returning %d\r\n", GetCurrentProcessId(), rv); #endif if (rv) return !rv; } else if ((msg == WM_QUERYENDSESSION) || (msg == WM_ENDSESSION)) { if (lParam & ENDSESSION_LOGOFF) { PHANDLER_ROUTINE phandler = (PHANDLER_ROUTINE)GetWindowLong(hwnd, gwltty_phandler); LRESULT rv = phandler(CTRL_LOGOFF_EVENT); #ifdef DBG DbgPrintf("A proc %8.8x invoked CTRL_LOGOFF_EVENT " "returning %d\r\n", GetCurrentProcessId(), rv); #endif if (rv) return ((msg == WM_QUERYENDSESSION) ? rv : !rv); } else { PHANDLER_ROUTINE phandler = (PHANDLER_ROUTINE)GetWindowLong(hwnd, gwltty_phandler); LRESULT rv = phandler(CTRL_SHUTDOWN_EVENT); #ifdef DBG DbgPrintf("A proc %8.8x invoked CTRL_SHUTDOWN_EVENT " "returning %d\r\n", GetCurrentProcessId(), rv); #endif if (rv) return ((msg == WM_QUERYENDSESSION) ? rv : !rv); } } return (DefWindowProc(hwnd, msg, wParam, lParam)); }
void UsbMouseEp0Handler() { static int ep0State = EP0_STATE_INIT; static int ep0SubState; U8 ep0_csr; INDEX_REG = 0; ep0_csr = EP0_CSR; //END POINT0 CONTROL STATUS REGISTER (EP0_CSR) //DbgPrintf("[ep0 handler, ep0 csr : %x]",ep0_csr); if(ep0_csr & EP0_SETUP_END) //Set by the USB when a control transfer ends before DATA_END is set. { DbgPrintf("[SETUPEND]"); CLR_EP0_SETUP_END(); if(ep0_csr & EP0_OUT_PKT_READY) { /* *Set by the USB when a control transfer ends before DATA_END is set. *When the USB sets this bit, an interrupt is generated to the MCU. *When such a condition occurs, the USB flushes the FIFO and invalidates MCU access to the FIFO. */ CLR_EP0_OUT_PKT_RDY(); } ep0State=EP0_STATE_INIT; return; } if(ep0_csr & EP0_SENT_STALL) { DbgPrintf("[STALL]"); CLR_EP0_SENT_STALL(); if(ep0_csr & EP0_OUT_PKT_READY) { CLR_EP0_OUT_PKT_RDY(); } ep0State=EP0_STATE_INIT; return; } //Set by the USB once a valid token is written to the FIFO if((ep0_csr & EP0_OUT_PKT_READY) && (ep0State == EP0_STATE_INIT)) { //DbgPrintf("[EP0_OUT_PKT_READY]"); RdPktEp0((U8 *)&descSetup,EP0_PKT_SIZE); if(((descSetup.bmRequestType & REQ_TYPE_MASK)>>5) == CLASS_REQ) { printf("[CLASS %d]",descSetup.bRequest); switch(descSetup.bRequest) { case GET_REPORT: { break; } case SET_IDLE: { DbgPrintf("[SET_IDLE]"); CLR_EP0_OUTPKTRDY_DATAEND(); break; } } } if(((descSetup.bmRequestType & REQ_TYPE_MASK)>>5) == STANDARD_REQ) { switch(descSetup.bRequest) { case GET_DESCRIPTOR: { switch(descSetup.bValueH) { case DEVICE_TYPE: { DbgPrintf("[DT]"); CLR_EP0_OUT_PKT_RDY(); //write a "1" to this bit to clear OUT_PKT_RDY ep0State = EP0_STATE_GD_DEV_0; break; } case CONFIGURATION_TYPE: { CLR_EP0_OUT_PKT_RDY(); //write a "1" to this bit to clear OUT_PKT_RDY if((descSetup.bLengthL+(descSetup.bLengthH<<8))>0x9) { ep0State=EP0_STATE_GD_CFG_0; //win10 DbgPrintf("[CT0]"); } else { ep0State=EP0_STATE_GD_CFG_ONLY_0; //ubuntu12.04 DbgPrintf("[CT1]"); } break; } case STRING_TYPE: { DbgPrintf("[STRING_TYPE%d]",descSetup.bValueL); CLR_EP0_OUT_PKT_RDY(); switch(descSetup.bValueL) { case 0: ep0State = EP0_STATE_GD_STR_I0; break; case 1: ep0State = EP0_STATE_GD_STR_I1; break; case 2: ep0State = EP0_STATE_GD_STR_I2; break; case 3: ep0State = EP0_STATE_GD_STR_I3; break; default: DbgPrintf("[UE:STRI?%d]",descSetup.bValueL); break; } ep0SubState = 0; break; } case HID_DESCRIPTION_TYPES: { CLR_EP0_OUT_PKT_RDY(); DbgPrintf("[HID_DES_TYPES]"); ep0State = EP0_HID_REPORT_DES_STR; ep0SubState = 0; break; } } break; } case SET_ADDRESS: { DbgPrintf("[SAD:%d]",descSetup.bValueL); FUNC_ADDR_REG=descSetup.bValueL | 0x80; //bit 7 must set 1 CLR_EP0_OUTPKTRDY_DATAEND(); //Because of no data control transfers. ep0State=EP0_STATE_INIT; break; } case SET_CONFIGURATION: { DbgPrintf("[SC]"); ConfigSet.ConfigurationValue=descSetup.bValueL; CLR_EP0_OUTPKTRDY_DATAEND(); //Because of no data control transfers. ep0State=EP0_STATE_INIT; isUsbdSetConfiguration = 1; break; } } } }
// ****************************************************************** // * func: EmuXGSetTextureHeader // ****************************************************************** VOID WINAPI XTL::EmuXGSetTextureHeader ( UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, X_D3DTexture* pTexture, UINT Data, UINT Pitch ) { EmuSwapFS(); // Win2k/XP FS DbgPrintf("EmuXapi (0x%X): EmuXGSetTextureHeader\n" "(\n" " Width : 0x%.08X\n" " Height : 0x%.08X\n" " Levels : 0x%.08X\n" " Usage : 0x%.08X\n" " Format : 0x%.08X\n" " Pool : 0x%.08X\n" " pTexture : 0x%.08X\n" " Data : 0x%.08X\n" " Pitch : 0x%.08X\n" ");\n", GetCurrentThreadId(), Width, Height, Levels, Usage, Format, Pool, pTexture, Data, Pitch); // NOTES: This function simply creates a texture that needs to be registered // via D3DDevice_Register afterwards. So, do I just create the texture via // EmuIDirect3DDevice8_CreateTexture, or just fill in the interface and let // EmuIDirect3DDevice8_Register do the rest? Trial and error. X_D3DTexture* pTempTexture = NULL; DWORD l2w = (DWORD) log( (float)Width ) / log(2.0f); DWORD l2h = (DWORD) log( (float)Height ) / log(2.0f); /*if( Data != 0 ) CxbxKrnlCleanup( "Data != 0 (XGSetTextureHeader)" ); if( Pitch != 0 ) CxbxKrnlCleanup( "Pitch != 0 (XGSetTextureHeader)" );*/ // Generate a temporary texture and fill in the necessary fields within // the X_D3DTexture interface (lazy, I know). EmuSwapFS(); pTempTexture = (X_D3DTexture*) XTL::EmuIDirect3DDevice8_CreateTexture2(Width, Height, 0, Levels, Usage, Format, XTL::D3DRTYPE_TEXTURE); EmuSwapFS(); pTexture->Data = pTempTexture->Data; pTexture->Common = X_D3DCOMMON_TYPE_TEXTURE; //pTempTexture->Common; // pTexture->Format = pTempTexture->Format; pTexture->Lock = pTempTexture->Lock; // 0; pTexture->Size = pTempTexture->Size; EmuSwapFS(); XTL::EmuIDirect3DResource8_Release(pTempTexture); EmuSwapFS(); // Manually fill in Format parameters /*pTexture->Format |= ( ( ( Width >> 1 ) & 0xF ) << X_D3DFORMAT_USIZE_SHIFT ) | // Width ( ( ( Height>> 1 ) & 0xF ) << X_D3DFORMAT_VSIZE_SHIFT ) | // Height ( ( ( Levels ) & 0xF ) << X_D3DFORMAT_MIPMAP_SHIFT ) | // Mip Levels // ( ( ( ((DWORD)Format)) & 0xFF ) << X_D3DFORMAT_FORMAT_SHIFT ) | // Format (Already set) ( ( ( 2 ) & 0xF ) << X_D3DFORMAT_DIMENSION_SHIFT ); // Dimensions */ pTexture->Format |= ( ( l2w & 0xF ) << X_D3DFORMAT_USIZE_SHIFT ); pTexture->Format |= ( ( l2h & 0xF ) << X_D3DFORMAT_VSIZE_SHIFT ); pTexture->Format |= ( ( Levels & 0xF ) << X_D3DFORMAT_MIPMAP_SHIFT ); pTexture->Format |= ( ( ( ((DWORD)Format)) & 0xFF ) << X_D3DFORMAT_FORMAT_SHIFT ); pTexture->Format |= ( ( 2 & 0xF ) << X_D3DFORMAT_DIMENSION_SHIFT ); // D3DCOLOR_XRGB( DbgPrintf( "pTexture->Format:= 0x%.08X\n", pTexture->Format ); EmuSwapFS(); // Xbox FS }