/*---------------------------------------------------------------------------* * The DMA load of the segment. *---------------------------------------------------------------------------*/ void loadSegment(u32 bg16seg, u32 bg8seg) { /* Load the Static segment. */ LoadSegment(static, _codeSegmentEnd); osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK); /* Loading of Bg and RGBA segments. */ LoadSegment(bg_rgba, (char *)bg16seg); osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK); /* Loading of Bg and CI segments. */ LoadSegment(bg_ci, (char *)bg8seg); osRecvMesg(&dmaMessageQ, NULL, OS_MESG_BLOCK); }
void CMagSnake:: DumpParameters(FILE * dat) { m_x0 = m_lfPos[0]; m_y0 = m_lfPos[1]; m_z0 = m_lfPos[2]; CMagObject::DumpParameters(dat); fprintf(dat,"Segmented pipe object:\n"); //for(int i=0; i<m_nNonLinearParams; i++) fprintf(dat,"#%d %lg\n", i, m_lfPos[i]); if(!m_bInduced) fprintf(dat,"# X Y Z Jx Jy Jz\n"); else fprintf(dat,"# X Y Z Jtotal\n"); fprintf(dat, "%lg %lg %lg\n", m_x0, m_y0, m_z0); for(int i=0; i<m_nSegments; i++) { fprintf(dat, "%lg %lg %lg ", m_x0, m_y0, m_z0); LoadSegment(i); if(m_bInduced) fprintf(dat,"%lg\n",m_lfJ[i]); else fprintf(dat,"%lg %lg %lg\n",m_lfJ[3*i], m_lfJ[3*i+1], m_lfJ[3*i+2]); m_pSegment->DumpParameters(dat); } }
void Main() { bseg1 = true; LoadSegment("test_seg1.c"); CreateClass("modelr"); CreateClass("dummy"); }
void ProcessControls() { string ControlName = GetEventData(); if( ControlName == "ILeft" && !bseg1 ) { UnloadSegment("test_seg2.c"); LoadSegment("test_seg1.c"); Event("ChangeSegment"); bseg1 = true; } if( ControlName == "IRight" && bseg1 ) { UnloadSegment("test_seg1.c"); LoadSegment("test_seg2.c"); Event("ChangeSegment"); bseg1 = false; } }
bool MapFile::EnumerateLines(char *Start, int Type) { int line = 0; char *ptr = Start; char *eol = nullptr; for (; *ptr; ptr++) { switch (*ptr) { case '\n': line++; case '\r': case ' ': case '\t': continue; } // Line #0 is the heading if (line < 1) continue; // Terminate the line eol = strchr(ptr, '\r'); if (!eol) eol = strchr(ptr, '\n'); if (eol) *eol = '\0'; // If the delimiter is not present, the line is not valid if (!strchr(ptr, ':')) break; if (Type == 'SEGM' && !LoadSegment(ptr)) break; if (Type == 'SYMB' && !LoadSymbol(ptr)) break; if (eol) ptr = eol + 1; } if (eol) *eol = '\r'; m_FileData = ptr; return true; }
int CMagSnake::GetNodes(double *pos, int size) { int j=0; if(size < 3*(m_nSegments+1)) return -1; pos[j++] = m_x0 = m_lfPos[0]; pos[j++] = m_y0 = m_lfPos[1]; pos[j++] = m_z0 = m_lfPos[2]; for(int i=0; i<m_nSegments; i++) { LoadSegment(i); pos[j++] = m_x0; pos[j++] = m_y0; pos[j++] = m_z0; } return 1; }
int CMagSnake::GetLinearDerivatives(FIELDTYPE type, double * add_params, double * deriv, int size, double * pos_deriv, double x_obs, double y_obs, double z_obs, double x0, double y0, double z0, double A, double B, double C, int n_pos, int *n_params, int * start) { if(!m_pSegment || !m_pLinearDeriv) return 0; m_x0 = m_lfPos[0]; m_y0 = m_lfPos[1]; m_z0 = m_lfPos[2]; int n_params_tmp = 0; int size_tmp, i, j; if(m_bInduced) size_tmp = 1; else size_tmp = 3; if(start) *start = m_iLinearStart; *n_params = 0; for(i=0; i<size_tmp*m_nSegments; i++) m_pLinearDeriv[i] = 0.; for(i=0; i<m_nSegments; i++) { LoadSegment(i); m_pSegment->GetLinearDerivatives(type, add_params, &m_pLinearDeriv[size_tmp*i], size_tmp, pos_deriv, x_obs, y_obs, z_obs, x0, y0, z0, A, B, C, n_pos, &n_params_tmp, NULL); } *n_params = 0; j=0; for(i=0; i<size_tmp*m_nSegments; i++) { if(!m_pJfixed[i]) { deriv[j] = m_pLinearDeriv[i]; j++; (*n_params)++; } } return 1; }
double CMagSnake::ComputeField(FIELDTYPE type, double * add_params, double x_obs, double y_obs, double z_obs, double x0, double y0, double z0, double A, double B, double C, int n_pos) { if(!m_pSegment) return 0; m_x0 = m_lfPos[0]; m_y0 = m_lfPos[1]; m_z0 = m_lfPos[2]; double T = 0; for(int i=0; i<m_nSegments; i++) { LoadSegment(i); T += m_pSegment->ComputeField(type, add_params, x_obs, y_obs, z_obs, x0, y0, z0, A, B, C, n_pos); } return T; }
/* LoadFile: load whole file or segments into segStore */ void LoadFile(char *fn) { BufferInfo info; char labfn[80]; Transcription *trans; long segStIdx,segEnIdx; static int segIdx=1; /* Between call handle on latest seg in segStore */ static int prevSegIdx=1; HTime tStart, tEnd; int i,k,s,ncas,nObs=0,segLen; LLink p; Observation obs; if((pbuf=OpenBuffer(&bufferStack, fn, 10, dff, FALSE_dup, FALSE_dup))==NULL) HError(2150,"LoadFile: Config parameters invalid"); GetBufferInfo(pbuf,&info); CheckData(fn,info); if (firstTime) InitSegStore(&info); if (segId == NULL) { /* load whole parameter file */ nObs = ObsInBuffer(pbuf); tStart = 0.0; tEnd = (info.tgtSampRate * nObs); LoadSegment(segStore, tStart, tEnd, pbuf); segIdx++; } else { /* load segment of parameter file */ MakeFN(fn,labDir,labExt,labfn); trans = LOpen(&transStack,labfn,lff); ncas = NumCases(trans->head,segId); if ( ncas > 0) { for (i=1,nObs=0; i<=ncas; i++) { p = GetCase(trans->head,segId,i); segStIdx = (long)(p->start/info.tgtSampRate); segEnIdx = (long)(p->end/info.tgtSampRate); if (segEnIdx >= ObsInBuffer(pbuf)) segEnIdx = ObsInBuffer(pbuf)-1; if (segEnIdx - segStIdx + 1 >= nStates-2) { LoadSegment(segStore, p->start, p->end, pbuf); if (trace&T_LD1) printf(" loading seg %s %f[%ld]->%f[%ld]\n",segId->name, p->start,segStIdx,p->end,segEnIdx); nObs += SegLength(segStore, segIdx); segIdx++; }else if (trace&T_LD1) printf(" seg %s %f->%f ignored\n",segId->name, p->start,p->end); } } } if (hset.hsKind == DISCRETEHS){ for (k=prevSegIdx; k<segIdx; k++){ segLen = SegLength(segStore, k); for (i=1; i<=segLen; i++){ obs = GetSegObs(segStore, k, i); for (s=1; s<=nStreams; s++){ if( (obs.vq[s] < 1) || (obs.vq[s] > maxMixInS[s])) HError(2150,"LoadFile: Discrete data value [ %d ] out of range in stream [ %d ] in file %s",obs.vq[s],s,fn); } } } prevSegIdx=segIdx; } if (trace&T_LD0) printf(" %d observations loaded from %s\n",nObs,fn); CloseBuffer(pbuf); ResetHeap(&transStack); }
void InitBaseInterfaces_main() { GameInterface.Scroll.current = 0; GameInterface.FourImage.current = 0; InterfaceStates.GameTime.sec = 0; InterfaceStates.GameTime.min = 0; InterfaceStates.GameTime.hour = 0; InterfaceStates.Buttons.New.enable = true; InterfaceStates.Buttons.Resume.enable = false; InterfaceStates.Buttons.Load.enable = false; InterfaceStates.Buttons.Save.enable = false; InterfaceStates.Buttons.Options.enable = true; InterfaceStates.Buttons.Credits.enable = true; InterfaceStates.Buttons.Quit.enable = true; InterfaceStates.Buttons.Controls.enable = true; InterfaceStates.BattleShow.FastCommand = true; InterfaceStates.BattleShow.LogString = true; InterfaceStates.BattleShow.Navigator = true; InterfaceStates.BattleShow.Command = true; InterfaceStates.BattleShow.Alarm = true; InterfaceStates.doUnFreeze = true; InterfaceStates.Launched = false; Interfaces[INTERFACE_CANNONS].SectionName = "interface\cannons.c"; Interfaces[INTERFACE_CANNONS].IniFile = "RESOURCE\INI\INTERFACES\cannons.ini"; Interfaces[INTERFACE_STORE].SectionName = "interface\store.c"; Interfaces[INTERFACE_STORE].IniFile = "RESOURCE\INI\INTERFACES\store.ini"; Interfaces[INTERFACE_SHIP_CHOOSE].SectionName = "interface\ship.c"; Interfaces[INTERFACE_SHIP_CHOOSE].IniFile = "RESOURCE\INI\INTERFACES\ship.ini"; Interfaces[INTERFACE_SHIPYARD].SectionName = "interface\shipyard.c"; Interfaces[INTERFACE_SHIPYARD].IniFile = "RESOURCE\INI\INTERFACES\shipyard.ini"; Interfaces[INTERFACE_CHARACTER].SectionName = "interface\character.c"; Interfaces[INTERFACE_CHARACTER].IniFile = "RESOURCE\INI\INTERFACES\character.ini"; Interfaces[INTERFACE_MAINMENU].SectionName = "interface\mainmenu.c"; Interfaces[INTERFACE_MAINMENU].IniFile = "RESOURCE\INI\INTERFACES\mainmenu.ini"; Interfaces[INTERFACE_SHIPHOLD].SectionName = "interface\shiphold.c"; Interfaces[INTERFACE_SHIPHOLD].IniFile = "RESOURCE\INI\INTERFACES\shiphold.ini"; Interfaces[INTERFACE_HIRECREW].SectionName = "interface\hirecrew.c"; Interfaces[INTERFACE_HIRECREW].IniFile = "RESOURCE\INI\INTERFACES\hirecrew.ini"; Interfaces[INTERFACE_PASSENGERS].SectionName = "interface\passengers.c"; Interfaces[INTERFACE_PASSENGERS].IniFile = "RESOURCE\INI\INTERFACES\passengers.ini"; Interfaces[INTERFACE_CHARACTER_SELECT].SectionName = "interface\selectCharacter.c"; Interfaces[INTERFACE_CHARACTER_SELECT].IniFile = "RESOURCE\INI\INTERFACES\selectCharacter.ini"; Interfaces[INTERFACE_QUESTBOOK].SectionName = "interface\questbook.c"; Interfaces[INTERFACE_QUESTBOOK].IniFile = "RESOURCE\INI\INTERFACES\questbook.ini"; Interfaces[INTERFACE_TRADEBOOK].SectionName = "interface\tradebook.c"; Interfaces[INTERFACE_TRADEBOOK].IniFile = "RESOURCE\INI\INTERFACES\tradebook.ini"; Interfaces[INTERFACE_NATIONRELATION].SectionName = "interface\NationRelation.c"; Interfaces[INTERFACE_NATIONRELATION].IniFile = "RESOURCE\INI\INTERFACES\NationRelation.ini"; Interfaces[INTERFACE_SAVELOAD].SectionName = "interface\save_load.c"; Interfaces[INTERFACE_SAVELOAD].IniFile = "RESOURCE\INI\INTERFACES\save_load.ini"; Interfaces[INTERFACE_ITEMS].SectionName = "interface\items.c"; Interfaces[INTERFACE_ITEMS].IniFile = "RESOURCE\INI\INTERFACES\items.ini"; Interfaces[INTERFACE_FORTCAPTURE].SectionName = "interface\fortcapture.c"; Interfaces[INTERFACE_FORTCAPTURE].IniFile = "RESOURCE\INI\INTERFACES\fortcapture.ini"; Interfaces[INTERFACE_ITEMSBOX].SectionName = "interface\itemsbox.c"; Interfaces[INTERFACE_ITEMSBOX].IniFile = "RESOURCE\INI\INTERFACES\itemsbox.ini"; Interfaces[INTERFACE_HELPSCREEN].SectionName = "interface\helpscreen.c"; Interfaces[INTERFACE_HELPSCREEN].IniFile = "RESOURCE\INI\INTERFACES\helpscreen.ini"; Interfaces[INTERFACE_OPTIONSCREEN].SectionName = "interface\option_screen.c"; Interfaces[INTERFACE_OPTIONSCREEN].IniFile = "RESOURCE\INI\INTERFACES\option_screen.ini"; Interfaces[INTERFACE_SELECTMENU].SectionName = "interface\select_menu.c"; Interfaces[INTERFACE_SELECTMENU].IniFile = "RESOURCE\INI\INTERFACES\select_menu.ini"; Interfaces[INTERFACE_ITEMSTRADE].SectionName = "interface\itemstrade.c"; Interfaces[INTERFACE_ITEMSTRADE].IniFile = "RESOURCE\INI\INTERFACES\itemstrade.ini"; Interfaces[INTERFACE_CONTROLS].SectionName = "interface\controls.c"; Interfaces[INTERFACE_CONTROLS].IniFile = "RESOURCE\INI\INTERFACES\controls.ini"; Interfaces[INTERFACE_PERKS].SectionName = "interface\perks.c"; Interfaces[INTERFACE_PERKS].IniFile = "RESOURCE\INI\INTERFACES\perks.ini"; Interfaces[INTERFACE_SALARY].SectionName = "interface\salary.c"; Interfaces[INTERFACE_SALARY].IniFile = "RESOURCE\INI\INTERFACES\salary.ini"; Interfaces[INTERFACE_PLAYGAME].SectionName = "interface\playgame.c"; Interfaces[INTERFACE_PLAYGAME].IniFile = "RESOURCE\INI\INTERFACES\playgame.ini"; Interfaces[INTERFACE_ENDGAME].SectionName = "interface\endgame.c"; Interfaces[INTERFACE_ENDGAME].IniFile = "RESOURCE\INI\INTERFACES\endgame.ini"; Interfaces[INTERFACE_RANSACK_JOIN].SectionName = "interface\ransack_join.c"; Interfaces[INTERFACE_RANSACK_JOIN].IniFile = "RESOURCE\INI\INTERFACES\ransack_join.ini"; Interfaces[INTERFACE_RANSACK_CREW].SectionName = "interface\ransack_crew.c"; Interfaces[INTERFACE_RANSACK_CREW].IniFile = "RESOURCE\INI\INTERFACES\ransack_crew.ini"; Interfaces[INTERFACE_RANSACK_CAPTAIN].SectionName = "interface\ransack_captain.c"; Interfaces[INTERFACE_RANSACK_CAPTAIN].IniFile = "RESOURCE\INI\INTERFACES\ransack_captain.ini"; Interfaces[INTERFACE_RANSACK_MAIN].SectionName = "interface\ransack_main.c"; Interfaces[INTERFACE_RANSACK_MAIN].IniFile = "RESOURCE\INI\INTERFACES\transfer_main.ini"; Interfaces[INTERFACE_TRANSFER_MAIN].SectionName = "interface\transfer_main.c"; Interfaces[INTERFACE_TRANSFER_MAIN].IniFile = "RESOURCE\INI\INTERFACES\transfer_main.ini"; Interfaces[INTERFACE_TRANSFER_GOODS].SectionName = "interface\transfer_goods.c"; Interfaces[INTERFACE_TRANSFER_GOODS].IniFile = "RESOURCE\INI\INTERFACES\transfer_goods.ini"; Interfaces[INTERFACE_TRANSFER_CHARACTER].SectionName = "interface\transfer_characters.c"; Interfaces[INTERFACE_TRANSFER_CHARACTER].IniFile = "RESOURCE\INI\INTERFACES\transfer_characters.ini"; Interfaces[INTERFACE_TRANSFER_CREW].SectionName = "interface\transfer_crew.c"; Interfaces[INTERFACE_TRANSFER_CREW].IniFile = "RESOURCE\INI\INTERFACES\transfer_crew.ini"; // boal --> Interfaces[INTERFACE_BOAL_MAP].SectionName = "interface\boal_map.c"; Interfaces[INTERFACE_BOAL_MAP].IniFile = "RESOURCE\INI\INTERFACES\boal_map.ini"; // boal <-- if( LoadSegment("battle_interface\fast_reload_table.c") ) { initFastReloadTable(); UnloadSegment("battle_interface\fast_reload_table.c"); } }
BOOL NewGetPathID(LPCTSTR szImageFile, LPCTSTR szOnePathString, DWORD *pdwPathID) { //-- for debug // AfxMessageBox("The PathString is:" + CString(OnePathString) ,MB_OK|MB_ICONINFORMATION,NULL ); //-- end debug CString OnePathString; OnePathString=szOnePathString; OnePathString.TrimRight(L"\\"); BOOL bPathFound; bPathFound=FALSE; DWORD dwSegmentNumber; dwSegmentNumber=0; DWORD dwSegmentSize; dwSegmentSize=SEGMENT_SIZE; DWORD dwPathIndex; // first found in the current segment // if not found, then found in other segment DWORD dwBeginOffset; dwBeginOffset=0; bPathFound = bPathInSegment( (LPCTSTR)OnePathString, g_SegmentInfo.PathArray, dwBeginOffset, &dwPathIndex ); if(bPathFound==TRUE) { CString strPathIndex; strPathIndex.Format(L"Segment: %d, PathOffset: %d, PathIndex: %d", g_SegmentInfo.dwCurrentSegment, g_SegmentInfo.dwCurrentOffset, g_SegmentInfo.dwCurrentSegment * dwSegmentSize + dwPathIndex); g_SegmentInfo.dwCurrentOffset = dwPathIndex; // AfxMessageBox( "Found in current segment, place " + strPathIndex ,MB_OK|MB_ICONINFORMATION,NULL); (*pdwPathID)=g_SegmentInfo.dwCurrentSegment * dwSegmentSize + dwPathIndex + 1; } DWORD dwCurrentSegment; dwCurrentSegment=g_SegmentInfo.dwCurrentSegment; if(bPathFound == FALSE) { dwSegmentNumber = dwCurrentSegment + 1; do { LoadSegment( szImageFile, g_SegmentInfo.PathArray, dwSegmentNumber, dwSegmentSize ); g_SegmentInfo.dwCurrentSegment = dwSegmentNumber; DWORD dwBeginOffset; dwBeginOffset=0; bPathFound = bPathInSegment( (LPCTSTR)OnePathString, g_SegmentInfo.PathArray, dwBeginOffset, &dwPathIndex ); if(bPathFound == TRUE) { CString strPathIndex; strPathIndex.Format(L"Segment: %d, PathOffset: %d, PathIndex: %d", g_SegmentInfo.dwCurrentSegment, g_SegmentInfo.dwCurrentOffset, g_SegmentInfo.dwCurrentSegment * dwSegmentSize + dwPathIndex); g_SegmentInfo.dwCurrentSegment = dwSegmentNumber; g_SegmentInfo.dwCurrentOffset = dwPathIndex; // AfxMessageBox( "Found in place " + strPathIndex,MB_OK|MB_ICONINFORMATION,NULL); (*pdwPathID)=g_SegmentInfo.dwCurrentSegment * dwSegmentSize + dwPathIndex + 1; break; } dwSegmentNumber++; }while(g_SegmentInfo.PathArray.GetSize()>0); } if(bPathFound == FALSE) { for( dwSegmentNumber = 0; dwSegmentNumber < dwCurrentSegment; dwSegmentNumber ++ ) { LoadSegment(g_RestoreInfo.szImageFile, g_SegmentInfo.PathArray, dwSegmentNumber,dwSegmentSize); g_SegmentInfo.dwCurrentSegment = dwSegmentNumber; DWORD dwBeginOffset; dwBeginOffset=0; bPathFound = bPathInSegment( (LPCTSTR)OnePathString, g_SegmentInfo.PathArray, dwBeginOffset, &dwPathIndex ); if(bPathFound == TRUE) { CString strPathIndex; strPathIndex.Format(L"Segment: %d, PathOffset: %d, PathIndex: %d", g_SegmentInfo.dwCurrentSegment, g_SegmentInfo.dwCurrentOffset, g_SegmentInfo.dwCurrentSegment * dwSegmentSize + dwPathIndex); g_SegmentInfo.dwCurrentSegment = dwSegmentNumber; g_SegmentInfo.dwCurrentOffset = dwPathIndex; // AfxMessageBox( "Found in place " + strPathIndex,MB_OK|MB_ICONINFORMATION,NULL); (*pdwPathID)=g_SegmentInfo.dwCurrentSegment * dwSegmentSize + dwPathIndex + 1; break; } } } if(bPathFound==TRUE) { return TRUE; } else { (*pdwPathID)=0; return FALSE; } }
BOOL CWZStep4::OnInitDialog() { CString csLine; CString csHeading; LV_COLUMN Column; CRect ListRect; CPropertyPageEx::OnInitDialog(); //-- load temp dir information begin // do not know MAX_PATH-1 or not, just use MAX_PATH -1 for safe GetTempPath(MAX_PATH-1,g_RestoreInfo.szTempDir); CString strTempDir; strTempDir=g_RestoreInfo.szTempDir; strTempDir.TrimRight(L"\\"); wcsncpy(g_RestoreInfo.szTempDir,(LPCTSTR)strTempDir,MAX_PATH-1); //-- load temp dir information end //-- the get more file will be placed in OnInitDialog begin // GetMoreFile(g_RestoreInfo.szImageFile); WCHAR szMainImageName[MAX_PATH]; memset(szMainImageName,0,sizeof(szMainImageName)); if( FALSE == GetLongMainName(g_RestoreInfo.szImageFile,szMainImageName) ) { TRACE(L"\nGetLongMainName error in OnInitDialog."); } else { GetSeperateFile(g_RestoreInfo.szImageFile, szMainImageName, g_RestoreInfo.szTempDir); } //-- the get more file will be placed in OnInitDialog end //-- create image will be placed in oninitdialog begin // here we just use m_ImageList // we needn't use "new" to create a ImageList m_ImageList.Create(IDB_DRIVER, 16, 1, RGB (255, 0, 255)); CBitmap FileBitmap; FileBitmap.LoadBitmap(IDB_FILE); m_ImageList.Add(&FileBitmap,RGB(255,0,255)); //-- create image will be placed in oninitdialog end m_TimeStamp.GetClientRect(ListRect); Column.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_FMT; Column.fmt = LVCFMT_LEFT; Column.cx = ListRect.right-ListRect.left; // if (g_nRestoreType) Column.cx /= 2; if(g_RestoreInfo.nRestoreType==RESTORE_PART) { Column.cx/=2; } csHeading.LoadString(IDS_TIME_STAMP); Column.pszText = csHeading.GetBuffer(0); Column.cchTextMax = 0; // ignored Column.iSubItem = 0; //-- for debug comment it // m_TimeStamp.InsertColumn(0,&Column); //--end for debug comment it switch (g_RestoreInfo.nRestoreType) { case RESTORE_ENTIRE: // 0 // total restore, do not show the information of the tree m_DirTree.EnableWindow(FALSE); break; case RESTORE_PART: // 1 // partial restore, show the information of the tree m_DirTree.EnableWindow(TRUE); csHeading.LoadString(IDS_STATE); Column.pszText = csHeading.GetBuffer(0); //-- for debug comment it // m_TimeStamp.InsertColumn(1,&Column); //-- end for debug comment it break; } // TODO: Add extra initialization here // now init the segment information DWORD dwSegmentSize; dwSegmentSize=SEGMENT_SIZE; g_SegmentInfo.dwCurrentOffset = 0; g_SegmentInfo.dwCurrentSegment = 0; LoadSegment( g_RestoreInfo.szImageFile, g_SegmentInfo.PathArray, g_SegmentInfo.dwCurrentSegment, dwSegmentSize ); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }