EXPORT WORD DIRECT::Include(double MKA[9], BYTE Type, WORD Qnt,WORD *Lst ) { DIRECT_LIST *pWork; DWORD l = (DWORD)sizeof(WORD) * Qnt; Read(); if ( Qnt == 0 ) return 0; if ( QuantityDirect == QuantityAllocDirect ) { QuantityAllocDirect += 20; DIRECT_LIST *pWork = (DIRECT_LIST *)Memory(QuantityAllocDirect,sizeof(DIRECT_LIST)); SpaceCopy(pWork,pDIRECT,(DWORD)QuantityDirect*sizeof(DIRECT_LIST)); MemoryFree(pDIRECT); pDIRECT = pWork; } pWork = &pDIRECT[QuantityDirect++]; memcpy(&pWork->MatrCos,MKA,9*sizeof(double)); pWork->Type = Type; pWork->Quantity = Qnt; pWork->List = (WORD*)Memory(l); SpaceCopy(pWork->List,Lst,l); Modify = 1; return QuantityDirect; }
void DIRECT::Read() { WORD i, n, k; DIRECT_LIST *Lst; if ( PosFile == NULL ) return; if ( *PosFile == 0 || pDIRECT ) return; File->SeekRead(*PosFile); File->Read(&n,sizeof(WORD)); QuantityDirect = QuantityAllocDirect = n; pDIRECT = (DIRECT_LIST *)Memory(sizeof(DIRECT_LIST),n); for ( i=0; i<n; i++ ) { Lst = &pDIRECT[i]; File->Read(Lst,sizeof(DIRECT_LIST)-sizeof(WORD*)); Lst->List = (WORD *)Memory(sizeof(WORD),Lst->Quantity); File->Read(Lst->List,(DWORD)sizeof(WORD)*Lst->Quantity); File->Read(&k,sizeof(WORD)); if ( k ) { Lst->Text = (LPSTR)Memory(k); File->Read(Lst->Text,k); } } }
void DIRECT::Compress(WORD QuantityElem) { WORD *ListAll; WORD *List; WORD i, j, k, n, m; DWORD l; DIRECT_LIST *pWork, *qWork; Read(); if ( QuantityDirect < 1 ) return; if ( QuantityElem == 0 ) for ( i=0; i<QuantityDirect; i++ ) for ( k=0; k<pDIRECT[i].Quantity; k++ ) { n = pDIRECT[i].List[k]; if ( QuantityElem < n ) QuantityElem = n; } List = (WORD*)Memory(QuantityElem+1,sizeof(WORD)); ListAll = (WORD*)Memory(QuantityElem+1,sizeof(WORD)); for ( i=0; i<QuantityDirect; i++ ) { pWork = (DIRECT_LIST*)&pDIRECT[i]; for ( k=0; k<pWork->Quantity; k++ ) if ( pWork->List[k] && pWork->List[k] <= QuantityElem ) ListAll[pWork->List[k]] = i + 1; } for ( i=1; i<=QuantityDirect; i++ ) { n = 0; pWork = (DIRECT_LIST*)&pDIRECT[i-1]; for ( k=1; k<=QuantityElem; k++ ) if ( ListAll[k] == i ) List[n++] = k; l = (DWORD)sizeof(WORD) * n; if ( pWork->Quantity != n ) m = 1; else m = SpaceCompare(pWork->List,List,l); if ( m && n ) { MemoryFree(pWork->List); pWork->List = (WORD*)Memory(l); SpaceCopy(pWork->List,List,l); } pWork->Quantity = n; } for ( i=QuantityDirect; i>0; i-- ) { pWork = (DIRECT_LIST*)&pDIRECT[i-1]; for ( j=0; j<9; j++ ) if ( pWork->MatrCos[j] ) break; if ( pWork->Quantity == 0 || pWork->Type == 0 && j == 9 ) Delete(i); else for ( k=0; k<i-1; k++ ) { qWork = (DIRECT_LIST*)&pDIRECT[k]; if ( qWork->Quantity && memcmp(pWork,qWork,6*sizeof(float)+1) == 0 ) { l = (DWORD)pWork->Quantity * sizeof(WORD); SpaceCopy(List,pWork->List,l); SpaceCopy(&List[pWork->Quantity],qWork->List,(DWORD)qWork->Quantity*sizeof(WORD)); l += (DWORD)qWork->Quantity * sizeof(WORD); MemoryFree(pWork->List); pWork->List = (WORD*)Memory(l); SpaceCopy(pWork->List,List,l); pWork->Quantity += qWork->Quantity; qWork->Quantity = 0; } } } MemoryFree(List); MemoryFree(ListAll); }
int main(int argc, char** argv) { Memory memory = Memory("witness64_d3d11.exe"); if (strcmp(argv[1], "pos") == 0) { if (argc == 5) { memory.SetPos(strtof(argv[2], nullptr), strtof(argv[3], nullptr), strtof(argv[4], nullptr)); } else { std::vector<float> pos = memory.GetPos(); std::cout << pos[0] << " " << pos[1] << " " << pos[2] << std::endl; } } else if (strcmp(argv[1], "angle") == 0) { if (argc == 4) { memory.SetAngle(strtof(argv[2], nullptr), strtof(argv[3], nullptr)); } else { std::vector<float> angle = memory.GetAngle(); std::cout << angle[0] << " " << angle[1] << std::endl; } } else if (strcmp(argv[1], "noclip") == 0) { if (argc == 3) { memory.SetNoclip(strcmp(argv[2], "1") == 0); } else { bool noclip = memory.GetNoclip(); std::cout << (noclip ? "1" : "0") << std::endl; } } }
void SlimeTraceSerializer::addPayload(Cursor & current, const TraceNode & node) { if (node.hasNote()) { current.setString(PAYLOAD, Memory(node.getNote())); } }
EXPORT void DIRECT::Change(WORD NumPP, double MKA[9], BYTE Type, WORD Qnt,WORD *Lst ) { DWORD l = (DWORD)sizeof(WORD) * Qnt; BYTE Mdf; Read(); if ( NumPP < 1 || NumPP > QuantityDirect ) return; DIRECT_LIST *pWork = &pDIRECT[NumPP-1]; if ( memcmp(MKA,&pWork->MatrCos,9*sizeof(double)) ) { memcpy(&pWork->MatrCos,MKA,9*sizeof(double)); Mdf = 1; } if ( pWork->Type != Type ) Mdf = 1; pWork->Type = Type; if ( pWork->Quantity != Qnt ) Mdf = 1; else if ( SpaceCompare(pWork->List,Lst,l) ) Mdf = 1; if ( Mdf ) { Modify = 1; MemoryFree(pWork->List); pWork->List = (WORD*)Memory(l); SpaceCopy(pWork->List,Lst,l); } pWork->Quantity = Qnt; }
//The copy constructor String::String(const String& s) { length_ = s.length_; Memory(); for (size_t i = 0; i <= length_; i++) { string_[i] = s.string_[i]; } }
void BrainUnit::load() { std::vector<Memory> _memories; std::ifstream is(BRAIN_UNIT_SAVE_FILE_PATH, std::ios::binary); std::string encodedMemory; while (std::getline(is, encodedMemory)) _memories.push_back(Memory(encodedMemory)); memories = _memories; }
//Constructor with size of line String::String(size_t n) { if ((n < 0) || (n>MAX_SIZE)) throw SizeWrongException(n); length_ = n; Memory(); string_[0] = '\0'; }
/* * 否定演算 */ void VMDriver::_not(){ bool result = false; Memory& src = this->createOrGetMemory(); if( src.value == 0 ){ result = true; } setMemory( src , Memory( result , "" ) ); }
MemoryStreamFixedExt CreateMemoryStream( uiw offset = 0 ) { ASSUME( IsOpened() ); if( IsWritable() ) { return MemoryStreamFixedExt( Memory(), Size(), offset ); } return MemoryStreamFixedExt( CMemory(), Size(), offset ); }
void prettyExecute() { srand(time(NULL)); BrainUnit brain = BrainUnit(); std::cout << "Brain unit has remembers the following programs:" << "\n"; if (constants::IS_PERSISTANCE_MODE) brain.printMemories(); ChromosomePopulation population; while (true) { std::cout << "Input an output to generate: "; std::string spec = ""; std::getline(std::cin, spec); std::vector<Chromosome> initialPopulation = brain.derivePopulation(spec); std::cout << "\n" << "Beginning evolution with derived population (excluding random generations):" << "\n"; for (int i = 0; i < initialPopulation.size(); i++) std::cout << initialPopulation[i].genome << "\n"; std::vector<GoalState> goalStates; goalStates.push_back(GoalState(spec)); Memory newMemory = Memory(ChromosomePopulation(initialPopulation, goalStates).evolve()); brain.remember(newMemory); // Brainfuck to Ook std::string ookVersion = ""; std::string optimalCandidate = newMemory.chromosome.genome; for (int i = 0; i < optimalCandidate.length(); i++) { switch (optimalCandidate[i]) { case '>': ookVersion += "Ook. Ook?"; break; case '<': ookVersion += "Ook? Ook."; break; case '+': ookVersion += "Ook. Ook."; break; case '-': ookVersion += "Ook! Ook!"; break; case '.': ookVersion += "Ook! Ook."; break; case ',': ookVersion += "Ook. Ook!"; break; case '[': ookVersion += "Ook! Ook?"; break; case ']': ookVersion += "Ook? Ook!"; break; default: break; } } std::cout << "\nOok version: " + ookVersion + "\n"; } }
bool nuiInit(void* OSHandle = NULL, nuiKernel* pKernel) { //printf("nuiInit(%d)\n", gNUIReferences); if (gNUIReferences == 0) { #ifdef WIN32 WSADATA wsaData; // if this doesn't work //WSAData wsaData; // then try this instead // MAKEWORD(1,1) for Winsock 1.1, MAKEWORD(2,0) for Winsock 2.0: int res = WSAStartup(MAKEWORD(1,1), &wsaData); #endif if (!App) { #ifdef _WIN32_ App = new nuiManualKernel(OSHandle, pKernel); #else App = new nuiManualKernel(pKernel); #endif App->CallOnInit(); } // On iOS, init an AutoReleasePool: #if defined(_UIKIT_) nui_autoreleasepool = [[NSAutoreleasePool alloc] init]; #endif // Init the texture manager: nuiTexture::InitTextures(); // Init the font manager: #if (defined _UIKIT_) && (!TARGET_IPHONE_SIMULATOR) nglIMemory Memory(gpnuiPhoneFontDB, gnuiPhoneFontDBSize); nuiFontManager::LoadManager(Memory, nglTime()); #else nglPath fontdb(ePathUserAppSettings); fontdb += nglString(NUI_FONTDB_PATH); if (fontdb.Exists() && fontdb.IsLeaf()) { nglIFile db(fontdb); nuiFontManager::LoadManager(db, fontdb.GetLastMod()); } else { nuiFontManager::GetManager(); } //#endif #endif nuiDecoration::InitDecorationEngine(); }
/* * 論理演算 && , || * logはLogic Operation(論理演算)から * 評価値 srcとdestのANDもしくはORの演算を行う。 * AND ... srcとdestが双方偽でないならば真 * OR ... srcとdestどちらかが偽でないならば真 */ void VMDriver::_log( int logType ){ bool result = 0; Memory& src = this->createOrGetMemory(); Memory& dest = this->createOrGetMemory(); switch( logType ){ case EMnemonic::LogOr : result = ( ( src != 0 ) || ( dest != 0 ) ); break; case EMnemonic::LogAnd : result = ( ( src != 0 ) && ( dest != 0 ) ); break; } setMemory( src , Memory( result , "" ) ); }
/* * メモリの取得に使用する。 * 先頭1バイトにはメモリ種類が含まれている。 * ・整数リテラル(double型) * ・文字列リテラル(string型) * ・レジスタ(Memory型) * ・ローカルもしくは静的領域(Memory型) */ Memory& VMDriver::createOrGetMemory(){ static Memory literalMemory; int location = this->currentAssembly()->moveU8( this->m_pc ); if( location == EMnemonic::LIT_VALUE ){ literalMemory.setMemory( Memory( this->currentAssembly()->moveDouble( this->m_pc ) , "" ) ); return literalMemory; } if( location == EMnemonic::LIT_STRING ){ literalMemory.setMemory( Memory( 0 , this->currentAssembly()->moveString( this->m_pc ) ) ); return literalMemory; } if( location == EMnemonic::REG ){ return R->getMemory( this->currentAssembly()->moveU8( this->m_pc ) ); } int address = 0; size_t size = this->currentAssembly()->moveU32( this->m_pc ); bool isVariable = false; if( location == EMnemonic::MEM_S ) isVariable = true; if( location == EMnemonic::MEM_L ) isVariable = true; if( isVariable ){ for( size_t i = 0 ; i < size ; i++ ){ int isArray = this->currentAssembly()->moveU8( this->m_pc ); int isRef = this->currentAssembly()->moveU8( this->m_pc ); int addr = this->currentAssembly()->moveU32( this->m_pc ); if( isArray ){ int sizeOf = this->currentAssembly()->moveU32( this->m_pc ); int RIndex = this->currentAssembly()->moveU32( this->m_pc ); int arrayindex = sizeOf * ((int)R->getMemory( RIndex ).value); addr += arrayindex; } if( isRef ){ Memory& m = this->getMemory( location , addr ); return this->getRefMemory( m.location , m.address , ++i , size ); } address += addr; } } return this->getMemory( location , address ); }
MMObject::MMObject(const char * type, ObjectDescriptor * descriptor) : _type(type) , _objectId(0) , _isShadow(false) , _descriptor(descriptor) { _memory = NEW Memory(_descriptor->CalcMemorySize()); descriptor->QueryTableModel([this](const s32 name, const TableDescriptor * model) { TableControl * table = NEW TableControl(name, model); _tables[name] = table; }); }
//The constructor with n times taken the symbol of symbol String::String(size_t nSymbols, char symbol) { if ((nSymbols < 0) || (nSymbols > MAX_SIZE)) throw SizeWrongException(nSymbols); length_ = nSymbols; Memory(); for (size_t i = 0; i < length_; i++) { string_[i] = symbol; } string_[length_] = '\0'; }
//Constructor with line String::String(const char* string) { length_ = 0; while (string[length_] != '\0') { //length of the string length_++; } if (length_ > MAX_SIZE) throw SizeWrongException(length_); Memory(); for (size_t i = 0; i <= length_; i++) { //The transfer of the corresponding elements string_[i] = string[i]; } }
/* * 比較命令 * cmpTypeに該当する比較命令を行い、各比較条件に合っていれば真を返す。 * @param cmpType ... 比較命令種類 * * geq ... srcがdestよりも大きいもしくは等しい * g ... srcがdestよりも大きい * leq ... srcがdestよりも小さいもしくは等しい * l ... srcがdestよりも小さい * eq ... srcとdestは等しい * neq ... srcとdestは等しくない */ void VMDriver::_cmp( int cmpType ){ bool result = 0; Memory& src = this->createOrGetMemory(); Memory& dest = this->createOrGetMemory(); switch( cmpType ){ case EMnemonic::CmpGeq : result = src >= dest; break; case EMnemonic::CmpG : result = src > dest; break; case EMnemonic::CmpLeq : result = src <= dest; break; case EMnemonic::CmpL : result = src < dest; break; case EMnemonic::CmpEq : result = src == dest; break; case EMnemonic::CmpNEq : result = src != dest; break; } setMemory( src , Memory( result , "" ) ); }
nat32 Node::TotalMemory() const { nat32 ret = Memory(); if (child) { Node * targ = child; do { ret += targ->TotalMemory(); targ = targ->Next(); } while (!targ->First()); } return ret; }
PackMemory* PackMemory::openFromAsset(AAssetManager* assetManager, const Char* path, s32 mode) { LASSERT(NULL != assetManager); LASSERT(NULL != path); AAsset* asset = AAssetManager_open(assetManager, path, mode); if(NULL == asset){ return NULL; } s32 pos = 0; s32 ret; PackHeader header; ret = AAsset_read(asset, &header, sizeof(PackHeader)); if(0>=ret){ AAsset_close(asset); return NULL; } pos += ret; FileEntry* entries = LIME_NEW FileEntry[header.numFiles_]; ret = AAsset_read(asset, entries, sizeof(FileEntry)*header.numFiles_); if(0>=ret){ LIME_DELETE_ARRAY(entries); AAsset_close(asset); return NULL; } pos += ret; //データサイズ計算 s32 dataTop = pos; u32 size = AAsset_getLength(asset) - dataTop; u8* memory = LIME_NEW u8[size]; ret = AAsset_read(asset, memory, size); AAsset_close(asset); if(0>=ret){ LIME_DELETE_ARRAY(memory); LIME_DELETE_ARRAY(entries); return NULL; } PackMemory* packMemory = LIME_NEW PackMemory(); packMemory->numFiles_ = header.numFiles_; packMemory->entries_ = entries; packMemory->memory_ = LIME_NEW Memory(size, memory); packMemory->memory_->addRef(); return packMemory; }
int main(int argc, char *argv[]){ bool DEBUG = checkForOption(argv, argv + argc, "debug"); bool LOG_EN = checkForOption(argv, argv + argc, "log"); Memory mem = Memory(); if (parseInput(mem, DEBUG)){ std::cout << "There were errors during preparation process, simulation aborted" << std::endl; return 1; } runSimulation(mem, LOG_EN); if (DEBUG) mem.memoryDump(); return 0; }
PackMemory* PackMemory::open(const Char* path) { LASSERT(NULL != path); FILE* f = NULL; #if defined(_WIN32) || defined(_WIN64) fopen_s(&f, path, "rb"); #else f = fopen(path, "rb"); #endif if(NULL == f){ return NULL; } PackHeader header; if(0>=fread(&header, sizeof(PackHeader), 1, f)){ fclose(f); return NULL; } FileEntry* entries = LIME_NEW FileEntry[header.numFiles_]; if(0>=fread(entries, sizeof(FileEntry)*header.numFiles_, 1, f)){ LIME_DELETE_ARRAY(entries); fclose(f); return NULL; } //データサイズ計算 s32 dataTop = ftell(f); fseek(f, 0, SEEK_END); u32 size = ftell(f) - dataTop; fseek(f, dataTop, SEEK_SET); u8* memory = LIME_NEW u8[size]; if(0>=fread(memory, size, 1, f)){ LIME_DELETE_ARRAY(memory); LIME_DELETE_ARRAY(entries); fclose(f); return NULL; } fclose(f); PackMemory* packMemory = LIME_NEW PackMemory(); packMemory->numFiles_ = header.numFiles_; packMemory->entries_ = entries; packMemory->memory_ = LIME_NEW Memory(size, memory); packMemory->memory_->addRef(); return packMemory; }
/* ============== idRenderModelMD5::List ============== */ void idRenderModelMD5::List() const { int i; const idMD5Mesh *mesh; int totalTris = 0; int totalVerts = 0; for( mesh = meshes.Ptr(), i = 0; i < meshes.Num(); i++, mesh++ ) { totalTris += mesh->numTris; totalVerts += mesh->NumVerts(); } common->Printf( " %4ik %3i %4i %4i %s(MD5)", Memory()/1024, meshes.Num(), totalVerts, totalTris, Name() ); if ( defaulted ) { common->Printf( " (DEFAULTED)" ); } common->Printf( "\n" ); }
EXPORT void SCHEMA:: RigidInFormat() { int i, k, n; WORD l; RIGID_LIST *pRgdLst; BYTE Control, TypeRigid; STRING_PROFILE *pSP; INFRGD *infrgd; infrgd = (INFRGD*)Memory(100,sizeof(INFRGD)); _Profile->SetUnit(Units[0],Units[1],Units[2]); for ( i=0; i<QuantityElem; i++ ) pFormat[i].TypeRigid = 0; _Rigid.Read(); for ( i=0; i<_Rigid.QuantityRigid; i++ ) { pRgdLst = (RIGID_LIST *)&_Rigid.pRigid[i]; pRgdLst->Icon = 0xFF; pRgdLst->Alfa = 0; RigidType(pRgdLst->QuantityRgd,pRgdLst->pRgd,infrgd,l,TypeRigid); if ( TypeRigid > 1 ) pRgdLst->Type = TypeRigid; if ( pRgdLst->Type == 1 ) { pSP = _Profile->GetInform(pRgdLst->pRgd,pRgdLst->QuantityRgd,Control); if ( pSP ) { pRgdLst->Icon = pSP->Group; pRgdLst->Alfa = pSP->Alfa; } } for ( k=0; k<pRgdLst->Quantity; k++ ) { n = pRgdLst->List[k]; if ( n && n <= QuantityElem ) pFormat[n-1].TypeRigid = pRgdLst->Num; } } MemoryFree(infrgd); }
BooleanValue strToBoolean (ConstMemory const value_mem) { if (value_mem.len() == 0) return Boolean_Default; Byte arr [32]; Memory mem; { Size len = sizeof (arr); if (len > value_mem.len()) len = value_mem.len(); memcpy (arr, value_mem.buf(), len); mem = Memory (arr, len); } for (Size i = 0; i < mem.len(); ++i) mem.mem() [i] = (Byte) tolower (mem.mem() [i]); if (equal (mem, "y") || equal (mem, "yes") || equal (mem, "on") || equal (mem, "true") || equal (mem, "1")) { return Boolean_True; } if (equal (mem, "n") || equal (mem, "no") || equal (mem, "off") || equal (mem, "false") || equal (mem, "0")) { return Boolean_False; } return Boolean_Invalid; }
#include "System.h" vector<Stage> System::stages(11, Stage(0)); vector<Register> System::registers(32, Register(0, 0)); bool System::forwardingEnabled = true; int System::programCounter = 1; int System::rStalls = 0; int System::sStalls = 0; int System::multSubStages = 4; bool System::fastBranching = false; Memory System::memory=Memory(); map<string, int> System::labelMap = *(new map<string , int>); bool System::programOver = false; int System::clockCycle = 0; bool System::branchChanged = false;
int main() { std::vector<params> Params; // TOFIX: // Params.push_back(params("kueken7_rgba_dxt1_srgb.dds", gli::FORMAT_RGBA_DXT1_SRGB_BLOCK8)); // Params.push_back(params("kueken7_bgrx8_unorm.dds", gli::FORMAT_BGR8_UNORM_PACK32)); //Params.push_back(params("kueken7_la8_unorm.dds", gli::FORMAT_LA8_UNORM_PACK8)); // GLI DDS extensions: //Params.push_back(params("kueken7_rgb_etc2_srgb.dds", gli::FORMAT_RGB_ETC2_SRGB_BLOCK8)); //Params.push_back(params("kueken7_rgb_etc2_unorm.dds", gli::FORMAT_RGB_ETC2_UNORM_BLOCK8)); //Params.push_back(params("kueken7_rgba_pvrtc2_4bpp_unorm.dds", gli::FORMAT_RGBA_PVRTC2_4X4_UNORM_BLOCK8)); Params.push_back(params("kueken7_rgb_dxt1_srgb.dds", gli::FORMAT_RGB_DXT1_SRGB_BLOCK8)); Params.push_back(params("kueken7_rgba_astc4x4_srgb.dds", gli::FORMAT_RGBA_ASTC_4X4_SRGB_BLOCK16)); Params.push_back(params("kueken7_bgra8_srgb.dds", gli::FORMAT_BGRA8_SRGB_PACK8)); Params.push_back(params("kueken7_r16_unorm.dds", gli::FORMAT_R16_UINT_PACK16)); Params.push_back(params("kueken7_r8_sint.dds", gli::FORMAT_R8_SINT_PACK8)); Params.push_back(params("kueken7_r8_uint.dds", gli::FORMAT_R8_UINT_PACK8)); Params.push_back(params("kueken7_rgba4_unorm.dds", gli::FORMAT_BGRA4_UNORM_PACK16)); Params.push_back(params("kueken7_r5g6b5_unorm.dds", gli::FORMAT_B5G6R5_UNORM_PACK16)); Params.push_back(params("kueken7_rgb5a1_unorm.dds", gli::FORMAT_BGR5A1_UNORM_PACK16)); Params.push_back(params("kueken7_rgba_dxt1_unorm.dds", gli::FORMAT_RGBA_DXT1_UNORM_BLOCK8)); Params.push_back(params("kueken8_rgba_dxt1_unorm.dds", gli::FORMAT_RGBA_DXT1_UNORM_BLOCK8)); Params.push_back(params("kueken7_rgba_dxt5_unorm.dds", gli::FORMAT_RGBA_DXT5_UNORM_BLOCK16)); Params.push_back(params("kueken7_rgba_dxt5_unorm1.dds", gli::FORMAT_RGBA_DXT5_UNORM_BLOCK16)); Params.push_back(params("kueken7_rgba_dxt5_unorm2.dds", gli::FORMAT_RGBA_DXT5_UNORM_BLOCK16)); Params.push_back(params("kueken7_rgba_dxt5_srgb.dds", gli::FORMAT_RGBA_DXT5_SRGB_BLOCK16)); Params.push_back(params("kueken7_rgb_etc1_unorm.dds", gli::FORMAT_RGB_ETC_UNORM_BLOCK8)); Params.push_back(params("kueken7_rgb_atc_unorm.dds", gli::FORMAT_RGB_ATC_UNORM_BLOCK8)); Params.push_back(params("kueken7_rgba_atc_explicit_unorm.dds", gli::FORMAT_RGBA_ATCA_UNORM_BLOCK16)); Params.push_back(params("kueken7_rgba_atc_interpolate_unorm.dds", gli::FORMAT_RGBA_ATCI_UNORM_BLOCK16)); Params.push_back(params("kueken7_rgb_pvrtc_2bpp_unorm.dds", gli::FORMAT_RGB_PVRTC1_16X8_UNORM_BLOCK32)); Params.push_back(params("kueken7_rgb_pvrtc_4bpp_unorm.dds", gli::FORMAT_RGB_PVRTC1_8X8_UNORM_BLOCK32)); Params.push_back(params("kueken7_r_ati1n_unorm.dds", gli::FORMAT_R_ATI1N_UNORM_BLOCK8)); Params.push_back(params("kueken7_rg_ati2n_unorm.dds", gli::FORMAT_RG_ATI2N_UNORM_BLOCK16)); Params.push_back(params("kueken7_bgr8_unorm.dds", gli::FORMAT_BGR8_UNORM_PACK8)); Params.push_back(params("kueken7_bgr8_srgb.dds", gli::FORMAT_BGR8_SRGB_PACK8)); Params.push_back(params("kueken7_rgba8_srgb.dds", gli::FORMAT_RGBA8_SRGB_PACK8)); Params.push_back(params("kueken7_bgra8_unorm.dds", gli::FORMAT_BGRA8_UNORM_PACK8)); Params.push_back(params("kueken7_a8_unorm.dds", gli::FORMAT_A8_UNORM_PACK8)); Params.push_back(params("kueken7_l8_unorm.dds", gli::FORMAT_L8_UNORM_PACK8)); Params.push_back(params("kueken7_rgb10a2_unorm.dds", gli::FORMAT_RGB10A2_UNORM_PACK32)); Params.push_back(params("kueken7_rgb10a2u.dds", gli::FORMAT_RGB10A2_UINT_PACK32)); Params.push_back(params("kueken7_rgba8_snorm.dds", gli::FORMAT_RGBA8_SNORM_PACK8)); Params.push_back(params("kueken7_rgba16_sfloat.dds", gli::FORMAT_RGBA16_SFLOAT_PACK16)); Params.push_back(params("kueken7_rg11b10_ufloat.dds", gli::FORMAT_RG11B10_UFLOAT_PACK32)); Params.push_back(params("kueken7_rgb9e5_ufloat.dds", gli::FORMAT_RGB9E5_UFLOAT_PACK32)); int Error(0); std::clock_t TimeFileStart = std::clock(); { for(std::size_t Index = 0; Index < Params.size(); ++Index) Error += load_file::test(Params[Index]); } std::clock_t TimeFileEnd = std::clock(); std::clock_t TimeMemStart = std::clock(); { for(std::size_t Index = 0; Index < Params.size(); ++Index) Error += load_mem::test(Params[Index]); } std::clock_t TimeMemEnd = std::clock(); std::clock_t TimeMemOnlyStart = 0; { std::vector<std::vector<char> > Memory(Params.size()); for(std::size_t Index = 0; Index < Params.size(); ++Index) { FILE* File = std::fopen(Params[Index].Filename.c_str(), "rb"); assert(File); long Beg = std::ftell(File); std::fseek(File, 0, SEEK_END); long End = std::ftell(File); std::fseek(File, 0, SEEK_SET); Memory[Index].resize(End - Beg); std::fread(&Memory[Index][0], 1, Memory[Index].size(), File); std::fclose(File); } TimeMemOnlyStart = std::clock(); for(std::size_t Index = 0; Index < Params.size(); ++Index) Error += load_mem_only::test(Memory[Index], Params[Index]); } std::clock_t TimeMemOnlyEnd = std::clock(); std::printf("File: %lu, Mem: %lu, Mem Only: %lu\n", TimeFileEnd - TimeFileStart, TimeMemEnd - TimeMemStart, TimeMemOnlyEnd - TimeMemOnlyStart); return Error; }
// 0x00 creates 4 full-size slots (higher slots are ignored): // 256, 256, 256, 256 // These examples are for 1k of EEPROM (ATmega328). int Addr = 0; int Size = 256; for (int Slot = 0; Slot < 8; Slot++) { if (Addr < kEEPROMSize && Size != 0) { m_pSlotStartAddr[Slot] = Addr; m_pSlotSize[Slot] = Size; } else { // run out m_pSlotStartAddr[Slot] = 0; m_pSlotSize[Slot] = 0; } Addr += Size; if (Map & (0x01 << Slot)) { Size /= 2; } } } Memory memory = Memory();
EXPORT void DATA_LOAD::Add( int QuantityElem, BYTE TypeElem[], FORCE_GROUP &FrcGrpInp, FORCE_VALUE *FrcVl, BYTE MaskQw, float Coef ) { int i, j, n, k, te, ne, net, m, qw, qn, kzpm, iqw; FORCE_LIST *FrcLst; FORCE_TYPE *FrcTp; FORCE_VALUE *FrcValue; float *ForceV; for ( i=0; i<FrcGrpInp.QuantityForceList; i++ ) { FrcLst = &FrcGrpInp.ForceList[i]; for ( j=0; j<FrcLst->QuantityForce; j++ ) { FrcTp = &FrcLst->Force[j]; qw = FrcTp->Qw; qn = FrcTp->Qn; if ( MaskQw != 0xFF && qw != MaskQw ) continue; FrcValue = (FORCE_VALUE*)&FrcVl[FrcTp->NumForceValue-1]; kzpm = FrcValue->QuantityValue; ForceV = (float*) Memory(kzpm+1,sizeof(float)); memcpy(ForceV,FrcValue->Value,kzpm*(long)sizeof(float)); if ( TypeElem == NULL ) { ForceV[0] *= Coef; goto _10; } if ( FrcLst->NumNodeFe == 0 || FrcLst->NumNodeFe > QuantityElem ) continue; ne = TypeElem[FrcLst->NumNodeFe-1]; net = ne % 100; te = ElemType(ne); iqw = qw % 10; if ( te == 4 ) { // стеpжни ForceV[0] *= Coef; goto _10; } if ( te == 1 || te == 4 ) { // стеpжни ForceV[0] *= Coef; if ( iqw == 7 && kzpm > 2 ) ForceV[2] *= Coef; if ( iqw == 8 && qn > 1 && kzpm > 1 ) ForceV[1] *= Coef; goto _10; } if ( te == 2 || te == 5 || te == 6 || te == 7 ) { // пластины if ( iqw == 9 || iqw == 0 ) { for ( k=2; k<kzpm; k++ ) ForceV[k] *= Coef; goto _10; } ForceV[0] *= Coef; if ( iqw < 7 ) goto _10; if ( iqw == 7 ) { for ( k=1; k<kzpm; k++ ) ForceV[k] *= Coef; goto _10; } if ( qw == 8 || qw == 18 ) { if ( net > 40 && net <= 50 && kzpm > 1 && qn == 0 ) ForceV[1] *= Coef; goto _10; } if ( qw == 28 ) { for ( k=1; k<kzpm-1; k++ ) ForceV[k] *= Coef; goto _10; } if ( qw == 38 ) { if ( net > 40 && net <= 50 && kzpm > 1 ) ForceV[1] *= Coef; goto _10; } if ( qw == 48 ) { for ( k=1; k<kzpm; k++ ) ForceV[k] *= Coef; goto _10; } if ( qw == 88 && kzpm > 1 ) { ForceV[1] *= Coef; goto _10; } } if ( te == 3 ) { ForceV[0] *= Coef; if ( iqw == 8 ) { m = 1; if ( qw == 18 ) m = 3; if ( qw == 38 || qw == 48 ) m = 0; if ( m < kzpm ) for ( k=1; k<kzpm-m; k++ ) ForceV[k] *= Coef; } goto _10; } _10: n = AddForceValue(1,kzpm,ForceV); if ( n ) Include(FrcLst->NumNodeFe,qw,qn,n); } } Modify = 1; }