bool CHuffman::readDictionaryNumber( const CExeFile& ExeFile, const int dictnum, const unsigned int dictOffset ) { uint8_t dictnumleft = dictnum; if( dictOffset == 0) // don't seek to offset { uint8_t *data_ptr = ExeFile.getRawData(); for( Uint32 i=0; i<ExeFile.getExeDataSize() ; i++ ) { if( memcmp(data_ptr, DICTSIG, DICT_SIG_BYTES) == 0 ) { if(dictnumleft == 0) { uint8_t *dictdata = data_ptr-(DICT_SIZE*sizeof(nodestruct))+DICT_SIG_BYTES; const Uint32 size = DICT_SIZE*sizeof(nodestruct); memcpy(m_nodes, dictdata, size); return true; } dictnumleft--; } data_ptr++; } return false; } else // Otherwise copy the dictionary normally { uint8_t *dictdata = (byte*)(ExeFile.getHeaderData())+dictOffset; memcpy(reinterpret_cast<char*>(m_nodes), dictdata, DICT_SIZE*sizeof(nodestruct)); return true; } }
CTileLoader::CTileLoader(CExeFile &Exefile) { m_episode = Exefile.getEpisode(); m_version = Exefile.getEXEVersion(); m_data = Exefile.getRawData(); m_offset = 0; setupOffsetMap(); }
bool COGGPlayer::loadMusicForLevel(const CExeFile& ExeFile, const int level) { // Now get the proper music slot reading the assignment table. Uint16 music_order = 0; const int Idx = ExeFile.getEpisode()-4; memcpy( &music_order, ExeFile.getRawData()+GalaxySongAssignments[Idx]+level*sizeof(Uint16), sizeof(Uint16)); if(music_order > 20) { g_pLogFile->textOut("Sorry, this track is invalid! Please report the developers."); return false; } m_filename = "slot" + itoa(music_order) + ".ogg"; m_filename = getResourceFilename(JoinPaths("music", m_filename), ExeFile.getDataDirectory(), false, false); if(m_filename.empty()) return false; return open(); }
bool CHuffman::readDictionaryNumber( const CExeFile& ExeFile, const int dictnum ) { uint8_t dictnumleft = dictnum; uint8_t *data_ptr = ExeFile.getRawData(); for( Uint32 i=0; i<ExeFile.getExeDataSize() ; i++ ) { if( memcmp(data_ptr,DICTSIG, DICT_SIG_BYTES) == 0 ) { if(dictnumleft == 0) { uint8_t *dictdata = data_ptr-(DICT_SIZE*sizeof(nodestruct))+DICT_SIG_BYTES; const Uint32 size = DICT_SIZE*sizeof(nodestruct); memcpy(m_nodes, dictdata, size); return true; } dictnumleft--; } data_ptr++; } return false; }
CHelp::CHelp(CExeFile &ExeFile, const std::string &type) : mp_TextViewer(NULL) { std::string Text; std::string DataDirectory = ExeFile.getDataDirectory(); char episode = ExeFile.getEpisode(); // Read the Storytext if(type == "Game") { if(episode==1) { // We suppose that we are using version 131. Maybe it must be extended std::string filename = DataDirectory; if(DataDirectory != "") filename += "/"; filename += "helptext.ck1"; std::ifstream File; OpenGameFileR(File, filename, std::ios::binary); if(!File) return; while(!File.eof()) Text.push_back(File.get()); File.close(); Text.erase(Text.size()-1); } else { // Here the Text file is within the EXE-File unsigned long startflag=0, endflag=0; unsigned char *text_data = NULL; if(!ExeFile.getHeaderData()) return; if(episode == 2) { startflag = 0x15DC0; endflag = 0x1659F; } else // Episode 3 { startflag = 0x17BD0; endflag = 0x1839B; } text_data = ExeFile.getRawData(); for(unsigned long i=startflag ; i<endflag ; i++ ) Text.push_back(text_data[i]); } } else { std::string filename = "HELPTEXT.CKP"; std::ifstream File; OpenGameFileR(File, filename, std::ios::binary); if(!File) return; while(!File.eof()) Text.push_back(File.get()); File.close(); Text.erase(Text.size()-1); } // Create the Text ViewerBox and stores the text there! mp_TextViewer = new CTextViewer(g_pVideoDriver->mp_VideoEngine->getFGLayerSurface(), 0, 8, 320, 160); mp_TextViewer->formatText(Text); }
COrderingInfo::COrderingInfo( CExeFile &ExeFile ) { std::string datadirectory = ExeFile.getDataDirectory(); char episode = ExeFile.getEpisode(); mp_Scrollsurface = g_pVideoDriver->mp_VideoEngine->getScrollSurface(); CMapLoader Maploader(&m_Map); Maploader.load(episode, 90, datadirectory); m_Map.gotoPos( 22<<4, 32 ); // Get the offset where in the data the info is... size_t offset = 0; switch(episode) { case 1: m_starty = 4; // start of y-coordinate in textheights m_numberoflines = 21; // numberof lines to print if(ExeFile.getEXEVersion() == 131) offset = 0x1652B-512; // Change the ugly lower Tiles which are seen, when using 320x240 base resolution for(int i=0; i<20 ; i++) { m_Map.changeTile(22+i, 15, 14*13); m_Map.changeTile(22+i, 16, 14*13+3); } break; case 2: m_starty = 3; // start of y-coordinate in textheights m_numberoflines = 19; // numberof lines to print m_Map.gotoPos( 22<<4, 28 ); if(ExeFile.getEXEVersion() == 131) offset = 0x1ACD9-512; break; case 3: m_starty = 4; // start of y-coordinate in textheights m_numberoflines = 17; // numberof lines to print if(ExeFile.getEXEVersion() == 131) offset = 0x1CDED-512; break; } m_Map.drawAll(); // Read the strings and save them the string array of the class if(offset) { char *data; data = (char*)ExeFile.getRawData() + offset; std::string buf; for(int i=0 ; i<m_numberoflines ; i++) { if(*data == '\0') { data++; while(*data == '\0') data++; } while(*data != '\n' and *data != '\0') // For the next line { buf.push_back(*data); data++; } data++; m_Textline.push_back(buf); buf.clear(); } } //This just makes them all line up exactly like in the original games. switch(episode) { case 1: m_Textline[1] = " " + m_Textline[1]; m_Textline[2] = m_Textline[2] + " "; m_Textline[3] = m_Textline[3] + " "; m_Textline[4] = " " + m_Textline[4]; m_Textline[5] = " " + m_Textline[5]; m_Textline[6] = " " + m_Textline[6]; m_Textline[8] = m_Textline[8] + " "; m_Textline[9] = m_Textline[9] + " "; m_Textline[10] = m_Textline[10] + " "; m_Textline[11] = m_Textline[11] + " "; m_Textline[13] = m_Textline[13] + " "; m_Textline[14] = m_Textline[14] + " "; m_Textline[15] = m_Textline[15] + " "; m_Textline[20] = m_Textline[20] + " "; break; case 2: m_Textline[2] = m_Textline[2] + " "; m_Textline[4] = m_Textline[4] + " "; m_Textline[5] = m_Textline[5] + " "; m_Textline[6] = m_Textline[6] + " "; m_Textline[7] = m_Textline[7] + " "; m_Textline[8] = m_Textline[8] + " "; m_Textline[10] = m_Textline[10] + " "; m_Textline[11] = m_Textline[11] + " "; m_Textline[12] = m_Textline[12] + " "; m_Textline[13] = m_Textline[13] + " "; m_Textline[15] = m_Textline[15] + " "; m_Textline[16] = m_Textline[16] + " "; break; case 3: m_Textline[0] = m_Textline[0] + " "; m_Textline[1] = m_Textline[1] + " "; m_Textline[2] = m_Textline[2] + " "; m_Textline[4] = m_Textline[4] + " "; m_Textline[5] = m_Textline[5] + " "; m_Textline[6] = m_Textline[6] + " "; m_Textline[7] = m_Textline[7] + " "; m_Textline[8] = m_Textline[8] + " "; m_Textline[10] = m_Textline[10] + " "; m_Textline[11] = m_Textline[11] + " "; m_Textline[12] = m_Textline[12] + " "; m_Textline[13] = m_Textline[13] + " "; m_Textline[16] = m_Textline[16] + " "; break; } }