bool WinFont::loadFromPE(const Common::String &fileName, const WinFontDirEntry &dirEntry) { Common::PEResources exe; if (!exe.loadFromEXE(fileName)) return false; // Let's pull out the font directory Common::SeekableReadStream *fontDirectory = exe.getResource(Common::kPEFontDir, Common::String("FONTDIR")); if (!fontDirectory) { warning("No font directory in '%s'", fileName.c_str()); return false; } uint32 fontId = getFontIndex(*fontDirectory, dirEntry); delete fontDirectory; // Couldn't match the face name if (fontId == 0xffffffff) { warning("Could not find face '%s' in '%s'", dirEntry.faceName.c_str(), fileName.c_str()); return false; } // Actually go get our font now... Common::SeekableReadStream *fontStream = exe.getResource(Common::kPEFont, fontId); if (!fontStream) { warning("Could not find font %d in %s", fontId, fileName.c_str()); return false; } bool ok = loadFromFNT(*fontStream); delete fontStream; return ok; }
PECursorManager::PECursorManager(const Common::String &appName) { Common::PEResources exe; if (!exe.loadFromEXE(appName)) { // Not all have cursors anyway, so this is not a problem return; } const Common::Array<Common::WinResourceID> cursorGroups = exe.getNameList(Common::kPEGroupCursor); _cursors.resize(cursorGroups.size()); for (uint i = 0; i < cursorGroups.size(); i++) { _cursors[i].id = cursorGroups[i].getID(); _cursors[i].cursorGroup = Graphics::WinCursorGroup::createCursorGroup(exe, cursorGroups[i]); } }
int main(int argc, char *argv[]) { if (argc != 3) { printf("Format: %s ST.exe titanic.dat\n", argv[0]); exit(0); } if (!inputFile.open(argv[1])) { error("Could not open input file"); } res.loadFromEXE(argv[1]); if (inputFile.size() == ENGLISH_10042C_FILESIZE) _version = ENGLISH_10042C; else if (inputFile.size() == ENGLISH_10042B_FILESIZE) _version = ENGLISH_10042B; else if (inputFile.size() == ENGLISH_10042_FILESIZE) _version = ENGLISH_10042; else { printf("Unknown version of ST.exe specified"); exit(0); } if (!outputFile.open(argv[2], Common::kFileWriteMode)) { error("Could not open output file"); } writeHeader(); writeData(); writeFinalEntryHeader(); inputFile.close(); outputFile.close(); return 0; }
void writeResource(const char *sectionStr, uint32 resId) { char nameBuffer[256]; sprintf(nameBuffer, "%s/%u", sectionStr, resId); Common::File *file = res.getResource(getResId(sectionStr), resId); assert(file); writeResource(nameBuffer, file); }
Common::Error PinkEngine::init() { debugC(10, kPinkDebugGeneral, "PinkEngine init"); initGraphics(640, 480); Common::PEResources exeResources; Common::String fileName = isPeril() ? "pptp.exe" : "hpp.exe"; if (!exeResources.loadFromEXE(fileName)) { return Common::kNoGameDataFoundError; } _console = new Console(this); _director = new Director(); initMenu(exeResources); Common::String orbName; Common::String broName; if (isPeril()) { orbName = "PPTP.ORB"; broName = "PPTP.BRO"; _bro = new BroFile; } else { orbName = "HPP.ORB"; } if (!_orb.open(orbName) || (_bro && !_bro->open(broName) && _orb.getTimestamp() == _bro->getTimestamp())) return Common::kNoGameDataFoundError; if (!loadCursors(exeResources)) return Common::kNoGameDataFoundError; setCursor(kLoadingCursor); _orb.loadGame(this); debugC(6, kPinkDebugGeneral, "Modules are loaded"); syncSoundSettings(); if (ConfMan.hasKey("save_slot")) loadGameState(ConfMan.getInt("save_slot")); else initModule(_modules[0]->getName(), "", nullptr); return Common::kNoError; }
void writeBitmap(const char *sectionStr, const char *resId) { char nameBuffer[256]; sprintf(nameBuffer, "%s/%s", sectionStr, resId); Common::File *file = res.getResource(getResId(sectionStr), Common::WinResourceID(resId)); assert(file); writeBitmap(nameBuffer, file); }
int main(int argc, char *argv[]) { if (argc < 2) { printf("Format: %s ST.exe [ST_german.exe] [titanic.dat]\n", argv[0]); exit(0); } if (!inputFile.open(argv[1])) { error("Could not open input file"); } resEng.loadFromEXE(argv[1]); if (argc >= 3) { resGer.loadFromEXE(argv[2]); } if (inputFile.size() == ENGLISH_10042C_FILESIZE) _version = ENGLISH_10042C; else if (inputFile.size() == ENGLISH_10042B_FILESIZE) _version = ENGLISH_10042B; else if (inputFile.size() == ENGLISH_10042_FILESIZE) _version = ENGLISH_10042; else if (inputFile.size() == GERMAN_10042D_FILESIZE) { printf("German version detected. You must use an English versoin " "for the primary input file\n"); exit(0); } else { printf("Unknown version of ST.exe specified\n"); exit(0); } if (!outputFile.open(argc == 4 ? argv[3] : "titanic.dat", Common::kFileWriteMode)) { printf("Could not open output file\n"); exit(0); } writeHeader(); writeData(); writeFinalEntryHeader(); inputFile.close(); outputFile.close(); return 0; }
void writeData() { for (int idx = 0; idx < (resGer.empty() ? 1 : 2); ++idx) { bool isEnglish = idx == 0; writeBitmap("Bitmap", "BACKDROP", isEnglish); writeBitmap("Bitmap", "EVILTWIN", isEnglish); writeBitmap("Bitmap", "RESTORED", isEnglish); writeBitmap("Bitmap", "RESTOREF", isEnglish); writeBitmap("Bitmap", "RESTOREU", isEnglish); writeBitmap("Bitmap", "STARTD", isEnglish); writeBitmap("Bitmap", "STARTF", isEnglish); writeBitmap("Bitmap", "STARTU", isEnglish); writeBitmap("Bitmap", "TITANIC", isEnglish); writeBitmap("Bitmap", 133, isEnglish); writeBitmap("Bitmap", 164, isEnglish); writeBitmap("Bitmap", 165, isEnglish); } writeResource("STFONT", 149); writeResource("STFONT", 151); writeResource("STFONT", 152); writeResource("STFONT", 153); writeResource("STARFIELD", 132); writeStarfieldPoints(); writeStarfieldPoints2(); writeResource("TEXT", "STVOCAB.TXT"); writeResource("TEXT", "JRQUOTES.TXT"); writeResource("TEXT", 155); writeStringArray("TEXT/ITEM_DESCRIPTIONS", ITEM_DESCRIPTIONS, 46); writeStringArray("TEXT/ITEM_NAMES", ITEM_NAMES, 46); writeStringArray("TEXT/ITEM_IDS", ITEM_IDS, 40); writeStringArray("TEXT/ROOM_NAMES", ROOM_NAMES, 34); writeStringArray("TEXT/STRINGS", STRINGS_EN, 58); writeStringArray("TEXT/STRINGS/DE", STRINGS_DE, 104); const int TEXT_PHRASES[3] = { 0x61D3C8, 0x618340, 0x61B1E0 }; const int TEXT_REPLACEMENTS1[3] = { 0x61D9B0, 0x61C788, 0x61B7C8 }; const int TEXT_REPLACEMENTS2[3] = { 0x61DD20, 0x61CAF8, 0x61BB38 }; const int TEXT_REPLACEMENTS3[3] = { 0x61F5C8, 0x61E3A0, 0x61D3E0 }; const int TEXT_PRONOUNS[3] = { 0x631318, 0x6300F8, 0x62F138 }; writeStringArray("TEXT/PHRASES", TEXT_PHRASES[_version], 376); writeStringArray("TEXT/REPLACEMENTS1", TEXT_REPLACEMENTS1[_version], 218); writeStringArray("TEXT/REPLACEMENTS2", TEXT_REPLACEMENTS2[_version], 1576); writeStringArray("TEXT/REPLACEMENTS3", TEXT_REPLACEMENTS3[_version], 82); writeStringArray("TEXT/PRONOUNS", TEXT_PRONOUNS[_version], 15); const int SENTENCES_DEFAULT[3] = { 0x5C0130, 0x5BEFC8, 0x5BE008 }; const int SENTENCES_BARBOT[2][3] = { { 0x5ABE60, 0x5AACF8, 0x5A9D38 }, { 0x5BD4E8, 0x5BC380, 0x5BB3C0 } }; const int SENTENCES_BELLBOT[20][3] = { { 0x5C2230, 0x5C10C8, 0X5C0108 }, { 0x5D1670, 0x5D0508, 0x5CF548 }, { 0x5D1A80, 0x5D0918, 0x5CF958 }, { 0x5D1AE8, 0x5D0980, 0x5CF9C0 }, { 0x5D1B88, 0x5D0A20, 0x5CFA60 }, { 0x5D2A60, 0x5D18F8, 0x5D0938 }, { 0x5D2CD0, 0x5D1B68, 0x5D0BA8 }, { 0x5D3488, 0x5D2320, 0x5D1360 }, { 0x5D3900, 0x5D2798, 0x5D17D8 }, { 0x5D3968, 0x5D2800, 0x5D1840 }, { 0x5D4668, 0x5D3500, 0x5D2540 }, { 0x5D47A0, 0x5D3638, 0x5D2678 }, { 0x5D4EC0, 0x5D3D58, 0x5D2D98 }, { 0x5D5100, 0x5D3F98, 0x5D2FD8 }, { 0x5D5370, 0x5D4208, 0x5D3248 }, { 0x5D5548, 0x5D43E0, 0x5D3420 }, { 0x5D56B8, 0x5D4550, 0x5D3590 }, { 0x5D57C0, 0x5D4658, 0x5D3698 }, { 0x5D5B38, 0x5D49D0, 0x5D3A10 }, { 0x5D61B8, 0x5D5050, 0x5D4090 } }; writeSentenceEntries("Sentences/Default", SENTENCES_DEFAULT[_version]); writeSentenceEntries("Sentences/Barbot", SENTENCES_BARBOT[0][_version]); writeSentenceEntries("Sentences/Barbot2", SENTENCES_BARBOT[1][_version]); writeSentenceEntries("Sentences/Bellbot", SENTENCES_BELLBOT[0][_version]); writeSentenceEntries("Sentences/Bellbot/1", SENTENCES_BELLBOT[1][_version]); writeSentenceEntries("Sentences/Bellbot/2", SENTENCES_BELLBOT[2][_version]); writeSentenceEntries("Sentences/Bellbot/3", SENTENCES_BELLBOT[3][_version]); writeSentenceEntries("Sentences/Bellbot/4", SENTENCES_BELLBOT[4][_version]); writeSentenceEntries("Sentences/Bellbot/5", SENTENCES_BELLBOT[5][_version]); writeSentenceEntries("Sentences/Bellbot/6", SENTENCES_BELLBOT[6][_version]); writeSentenceEntries("Sentences/Bellbot/7", SENTENCES_BELLBOT[7][_version]); writeSentenceEntries("Sentences/Bellbot/8", SENTENCES_BELLBOT[8][_version]); writeSentenceEntries("Sentences/Bellbot/9", SENTENCES_BELLBOT[9][_version]); writeSentenceEntries("Sentences/Bellbot/10", SENTENCES_BELLBOT[10][_version]); writeSentenceEntries("Sentences/Bellbot/11", SENTENCES_BELLBOT[11][_version]); writeSentenceEntries("Sentences/Bellbot/12", SENTENCES_BELLBOT[12][_version]); writeSentenceEntries("Sentences/Bellbot/13", SENTENCES_BELLBOT[13][_version]); writeSentenceEntries("Sentences/Bellbot/14", SENTENCES_BELLBOT[14][_version]); writeSentenceEntries("Sentences/Bellbot/15", SENTENCES_BELLBOT[15][_version]); writeSentenceEntries("Sentences/Bellbot/16", SENTENCES_BELLBOT[16][_version]); writeSentenceEntries("Sentences/Bellbot/17", SENTENCES_BELLBOT[17][_version]); writeSentenceEntries("Sentences/Bellbot/18", SENTENCES_BELLBOT[18][_version]); writeSentenceEntries("Sentences/Bellbot/19", SENTENCES_BELLBOT[19][_version]); const int SENTENCES_DESKBOT[3][3] = { { 0x5DCD10, 0x5DBBA8, 0x5DABE8 }, { 0x5E8E18, 0x5E7CB0, 0x5E6CF0 }, { 0x5E8BA8, 0x5E7A40, 0x5E6A80 } }; writeSentenceEntries("Sentences/Deskbot", SENTENCES_DESKBOT[0][_version]); writeSentenceEntries("Sentences/Deskbot/2", SENTENCES_DESKBOT[1][_version]); writeSentenceEntries("Sentences/Deskbot/3", SENTENCES_DESKBOT[2][_version]); const int SENTENCES_DOORBOT[12][3] = { { 0x5EC110, 0x5EAFA8, 0x5E9FE8 }, { 0x5FD930, 0x5FC7C8, 0x5FB808 }, { 0x5FDD0C, 0x5FCBA4, 0x5FBBE4 }, { 0x5FE668, 0x5FD500, 0x5FC540 }, { 0x5FDD40, 0x5FCBD8, 0X5FBC18 }, { 0x5FFF08, 0x5FEDA0, 0x5FDDE0 }, { 0x5FE3C0, 0x5FD258, 0x5FC298 }, { 0x5FF0C8, 0x5FDF60, 0x5FCFA0 }, { 0x5FF780, 0x5FE618, 0x5FD658 }, { 0x5FFAC0, 0x5FE958, 0x5FD998 }, { 0x5FFC30, 0x5FEAC8, 0x5FDB08 }, { 0x6000E0, 0x5FEF78, 0x5FDFB8 } }; writeSentenceEntries("Sentences/Doorbot", SENTENCES_DOORBOT[0][_version]); writeSentenceEntries("Sentences/Doorbot/2", SENTENCES_DOORBOT[1][_version]); writeSentenceEntries("Sentences/Doorbot/100", SENTENCES_DOORBOT[2][_version]); writeSentenceEntries("Sentences/Doorbot/101", SENTENCES_DOORBOT[3][_version]); writeSentenceEntries("Sentences/Doorbot/102", SENTENCES_DOORBOT[4][_version]); writeSentenceEntries("Sentences/Doorbot/107", SENTENCES_DOORBOT[5][_version]); writeSentenceEntries("Sentences/Doorbot/110", SENTENCES_DOORBOT[6][_version]); writeSentenceEntries("Sentences/Doorbot/111", SENTENCES_DOORBOT[7][_version]); writeSentenceEntries("Sentences/Doorbot/124", SENTENCES_DOORBOT[8][_version]); writeSentenceEntries("Sentences/Doorbot/129", SENTENCES_DOORBOT[9][_version]); writeSentenceEntries("Sentences/Doorbot/131", SENTENCES_DOORBOT[10][_version]); writeSentenceEntries("Sentences/Doorbot/132", SENTENCES_DOORBOT[11][_version]); const int SENTENCES_LIFTBOT[3] = { 0x6026B0, 0x601548, 0x600588 }; const int SENTENCES_MAITRED[2][3] = { { 0x60CFD8, 0x60BE70, 0x60AEB0 }, { 0x614288, 0x613120, 0x612160 } }; const int SENTENCES_PARROT[3] = { 0x615858, 0x6146F0, 0x613730 }; const int SENTENCES_SUCCUBUS[3] = { 0x616698, 0x615530, 0x614570 }; const int MAPPINGS_BARBOT[3] = { 0x5B28A0, 0x5B173E, 0x5B0778 }; const int MAPPINGS_BELLBOT[3] = { 0x5CD830, 0x5CC6C8, 0x5CB708 }; const int MAPPINGS_DESKBOT[3] = { 0x5E2BB8, 0x5E1A50, 0x5E0A90 }; const int MAPPINGS_DOORBOT[3] = { 0x5F7950, 0x5F67E8, 0x5F5828 }; const int MAPPINGS_LIFTBOT[3] = { 0x608660, 0x6074F8, 0x606538 }; const int MAPPINGS_MAITRED[3] = { 0x6125C8, 0x611460, 0x6104A0 }; const int MAPPINGS_PARROT[3] = { 0x615B68, 0x614A00, 0x613A40 }; const int MAPPINGS_SUCCUBUS[3] = { 0x6189F0, 0x617888, 0x6168C8 }; const int WORDS_BARBOT[3] = { 0x5BE2E0, 0x5BD178, 0x5BC1B8 }; const int WORDS_BELLBOT[3] = { 0x5D8230, 0x5D70C8, 0x5D6108 }; const int WORDS_DESKBOT[3] = { 0x5EAAA8, 0x5E9940, 0x5E8980 }; const int WORDS_DOORBOT[3] = { 0x601098, 0x5FFF30, 0x5FEF70 }; const int WORDS_LIFTBOT[3] = { 0x60C788, 0x60B620, 0x60A660 }; writeSentenceEntries("Sentences/Liftbot", SENTENCES_LIFTBOT[_version]); writeSentenceEntries("Sentences/MaitreD", SENTENCES_MAITRED[0][_version]); writeSentenceEntries("Sentences/MaitreD/1", SENTENCES_MAITRED[1][_version]); writeSentenceEntries("Sentences/Parrot", SENTENCES_PARROT[_version]); writeSentenceEntries("Sentences/SuccUBus", SENTENCES_SUCCUBUS[_version]); writeSentenceMappings("Mappings/Barbot", MAPPINGS_BARBOT[_version], 8); writeSentenceMappings("Mappings/Bellbot", MAPPINGS_BELLBOT[_version], 1); writeSentenceMappings("Mappings/Deskbot", MAPPINGS_DESKBOT[_version], 4); writeSentenceMappings("Mappings/Doorbot", MAPPINGS_DOORBOT[_version], 4); writeSentenceMappings("Mappings/Liftbot", MAPPINGS_LIFTBOT[_version], 4); writeSentenceMappings("Mappings/MaitreD", MAPPINGS_MAITRED[_version], 1); writeSentenceMappings("Mappings/Parrot", MAPPINGS_PARROT[_version], 1); writeSentenceMappings("Mappings/SuccUBus", MAPPINGS_SUCCUBUS[_version], 1); writeWords("Words/Barbot", WORDS_BARBOT[_version]); writeWords("Words/Bellbot", WORDS_BELLBOT[_version]); writeWords("Words/Deskbot", WORDS_DESKBOT[_version]); writeWords("Words/Doorbot", WORDS_DOORBOT[_version], 3); writeWords("Words/Liftbot", WORDS_LIFTBOT[_version]); writePhrases("Phrases/Bellbot", BELLBOT_COMMON_PHRASES); writeResponseTree(); writeNumbers(); writeAllScriptQuotes(); writeAllScriptResponses(); writeAllScriptRanges(); writeAllTagMappings(); writeAllUpdateStates(); writeAllScriptPreResponses(); writeBarbotFrameRanges(); writeMissiveOMatMessages(); writeBedheadData(); writeParrotLobbyLinkUpdaterEntries(); }