ConvertUsecodeU8.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2002-2005 The Pentagram Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifndef CONVERTUSECODEU8_H
00020 #define CONVERTUSECODEU8_H
00021 
00022 #ifndef INCLUDE_CONVERTUSECODEU8_WITHOUT_BRINGING_IN_FOLD
00023 #include "Convert.h"
00024 #else
00025 
00026 class ConvertUsecode
00027 {
00028 public:
00029                 virtual ~ConvertUsecode() { }   
00030                 class TempOp;
00031                 class Node;
00032                 typedef int DebugSymbol;
00033                 struct UsecodeHeader
00034                 {
00035                         uint32 maxOffset;
00036                 };
00037                 uint32 read4(IDataSource *) { return 0; }
00038                 uint32 curOffset;
00039 
00040                 virtual const char* const *intrinsics()=0;
00041                 virtual const char* const *event_names()=0;
00042                 virtual void readheader(IDataSource *ucfile, UsecodeHeader &uch, uint32 &curOffset)=0;
00043                 virtual void readevents(IDataSource *ucfile, const UsecodeHeader &uch)=0;
00044                 virtual void readOp(TempOp &op, IDataSource *ucfile, uint32 &dbg_symbol_offset, std::vector<DebugSymbol> &debugSymbols, bool &done)=0;
00045                 virtual Node *readOp(IDataSource *ucfile, uint32 &dbg_symbol_offset, std::vector<DebugSymbol> &debugSymbols, bool &done)=0;
00046                 void readOpGeneric(TempOp &, IDataSource *, uint32 &, std::vector<DebugSymbol> &,
00047                         bool &, const bool ) { }
00048                 Node *readOpGeneric(IDataSource *, uint32 &, std::vector<DebugSymbol> &,
00049                         bool &, const bool ) { return 0; }
00050 };
00051 
00052 #endif
00053 
00054 class ConvertUsecodeU8 : public ConvertUsecode
00055 {
00056         public:
00057                 const char* const *intrinsics()  { return _intrinsics;  };
00058                 const char* const *event_names() { return _event_names; };
00059                 void readheader(IDataSource *ucfile, UsecodeHeader &uch, uint32 &curOffset);
00060                 void readevents(IDataSource *ucfile, const UsecodeHeader &/*uch*/)
00061                 {
00062 #ifndef INCLUDE_CONVERTUSECODEU8_WITHOUT_BRINGING_IN_FOLD
00063                         EventMap.clear();
00064                         for (uint32 i=0; i<32; ++i)
00065                         {
00066                                 uint32 offset = read4(ucfile);
00067                                 EventMap[offset] = i;
00068 #ifdef DISASM_DEBUG
00069                                 pout << "Event " << i << ": " << std::hex << std::setw(4) << offset << std::dec << endl;
00070 #endif
00071                         }
00072 #endif
00073                 }
00074 
00075                 void readOp(TempOp &op, IDataSource *ucfile, uint32 &dbg_symbol_offset, std::vector<DebugSymbol> &debugSymbols, bool &done)
00076                 { readOpGeneric(op, ucfile, dbg_symbol_offset, debugSymbols, done, false); };
00077                 Node *readOp(IDataSource *ucfile, uint32 &dbg_symbol_offset, std::vector<DebugSymbol> &debugSymbols, bool &done)
00078                 { return readOpGeneric(ucfile, dbg_symbol_offset, debugSymbols, done, false); };
00079 
00080         
00081         private:
00082                 static const char* const _intrinsics[];
00083                 static const char* const _event_names[];
00084 };
00085 
00086 const char* const ConvertUsecodeU8::_intrinsics[] = {
00087         // 0000
00088         "process target()",
00089         "Item::getNext()",                                                      // Unused
00090         "Item::touch()",
00091         "word Item::getX()",
00092         "word Item::getY()",
00093         "word Item::getZ()",
00094         "word Item::getCX()",
00095         "word Item::getCY()",
00096         "word Item::getCZ()",
00097         "word Item::getGumpX()",                                        // Unused
00098         "word Item::getGumpY()",                                        // Unused
00099         "void Item::setGumpXY(word x, word y)",         // Unused
00100         "Item::getPoint(WorldPoint*)",
00101         "uword Item::getType()",
00102         "void Item::setType(uword type)",
00103         "uword Item::getFrame()",
00104         // 0010
00105         "void Item::setFrame(uword frame)",
00106         "uword Item::getQuality()",                                     // Get Q (Not generic familiy)
00107         "uword Item::getUnkEggType()",                          // Get Q (UnkEgg family)
00108         "uword Item::getQuantity()",                            // Get Q (Quantity or Reagent family)
00109         "Item::getContents()",                                          // Unused
00110         "Item::getContainer()",
00111         "Item::getRootContainer()",
00112         "uword Item::getGlobNum()",                                     // Get Q (GlobEgg family) - Unused
00113         "void Item::setGlobNum(uword)",                         // Set Q (GlobEgg family) - Unused
00114         "uword Item::getQ()",                                           // Get Q
00115         "void Item::setQ(uword)",                                       // Set Q
00116         "void Item::setQuality(word value)",            // Set Q (Not generic familiy)
00117         "void Item::setUnkEggType(word value)",         // Set Q (UnkEgg family) - Unused
00118         "void Item::setQuantity(word value)",           // Set Q (Quantity and Reagent families)
00119         "word Item::getFamily()",
00120         "bool Item::getTypeFlag(word bit)",                     // Get TypeFlag (0 to 63 - not a mask!)
00121         // 0020
00122         "word Item::getStatus()",                                       // Get Status Flags
00123         "void Item::orStatus(word mask)",                       // Status |= mask;
00124         "void Item::andStatus(word mask)",                      // Status &= mask;
00125         "Item::getFootpad(word*, word*, word*)",
00126         "Item::touches(uword)",                                         // Unused
00127         "Item::overlaps(uword)",                                        // boundingbox Overlap in 3d
00128         "Item::overlapsXY(uword)",                                      // Unused
00129         "Item::isOn(uword)",                                            // 3dxy overlaps && other->ztop == this->zbot ???
00130         "Item::isCompletelyOn(uword)",                          // Unused
00131         "Item::isAbove(uword)",                                         // Unused
00132         "Item::isUnder(uword)",                                         // Unused
00133         "Item::ascend(word)",                                           // used once
00134         "Item::getWeight()",
00135         "Item::getWeightIncludingContents()",
00136         "Item::getSurfaceWeight()",
00137         "Item::getVolume()",                                            // Unused
00138         // 0030
00139         "Item::getCapacity()",                                          // Unuses
00140         "Item::legal_create(uword, uword, uword, uword, uword)",
00141         "Item::create(uword, uword)",
00142         "Item::legal_create(uword, uword, WorldPoint*)",
00143         "Item::legal_create(uword, uword, uword, word)",
00144         "Item::push()",
00145         "Item::pop(uword, uword, ubyte)",
00146         "Item::pop(uword)",
00147         "Item::pop()",
00148         "Item::popToEnd(uword)",
00149         "Item::destroy()",
00150         "Item::removeContents()",
00151         "Item::destroyContents()",
00152         "Item::isExplosive()",
00153         "Item::move(uword, uword, ubyte)",
00154         "Item::move(WorldPoint*)",                                      // Unused
00155         // 0040
00156         "Item::legal_move(WorldPoint*, uword, uword)",
00157         "Item::legal_move(uword*, uword)",
00158         "Item::isNpc()",
00159         "Item::isInNpc()",                                                      // Unused
00160         "process Item::hurl(word, word, word, word)",
00161         "Item::shoot(WorldPoint*, word, word)",
00162         "Item::fall()",
00163         "Item::grab()",
00164         "Item::findTarget(word, word)",                         // Unused
00165         "process Item::bark(char* str)",
00166         "strptr process Item::ask(uword slist)",
00167         "word Item::getSliderInput(word min, word max, word step)",
00168         "Item::openGump(word)",
00169         "Item::closeGump()",
00170         "Item::isGumpOpen()",                                           // Unused
00171         "Item::getNpcArray()",                                          // Unused
00172         // 0050
00173         "Item::getMapArray()",
00174         "Item::setNpcArray(word)",                                      // Unused
00175         "Item::setMapArray(word)",
00176         "Item::receiveHit(uword, byte, word, uword)",
00177         "Item::explode()",
00178         "Item::canReach(uword, word)",
00179         "Item::getRange(uword)",
00180         "Item::getRange(uword, uword, uword)",          // Unused
00181         "Item::getDirToCoords(uword, uword)",
00182         "Item::getDirFromCoords(uword, uword)",
00183         "Item::getDirToItem(uword)",
00184         "Item::getDirFromItem(uword)",
00185         "process Item::look()",                                         // Call event 0x0
00186         "process Item::use()",                                          // Call event 0x1
00187         "process Item::anim()",                                         // Unused
00188         "process Item::cachein()",                                      // Unused
00189         // 0060
00190         "Item::hit(uword, word)",                                       // Unused
00191         "process Item::gotHit(uword, word)",            // Call event ???
00192         "process Item::release()",                                      // Unused
00193         "process Item::equip()",                                        // Unused
00194         "process Item::unequip()",                                      // Unused
00195         "process Item::combine()",                                      // Unused
00196         "process Item::calledFromAnim()",                       // Unused
00197         "process Item::enterFastArea()",                        // Call event 0xF
00198         "process Item::leaveFastArea()",                        // Unused
00199         "process Item::cast(uword)",                            // Unused
00200         "process Item::justMoved()",                            // Unused
00201         "process Item::AvatarStoleSomething(uword)",// Unused
00202         "process Item::animGetHit(uword)",                      // Unused
00203         "process Item::guardianBark(word)",                     // Call event 0x15
00204         "process Book::read(char*)",
00205         "process Scroll::read(char*)",
00206         // 0070
00207         "process Grave::read(word,char*)",
00208         "process Plaque::read(word,char*)",
00209         "Egg::getEggXRange()",
00210         "Egg::getEggYRange()",
00211         "Egg::setEggXRange(uword)",
00212         "Egg::setEggYRange(uword)",                                     // Unused
00213         "Egg::getEggId()",
00214         "Egg::setEggId(uword)",
00215         "Egg::hatch()",                                                         // Unused
00216         "MonsterEgg::hatch()",
00217         "MonsterEgg::getMonId()",
00218         "MonsterEgg::getActivity()",                            // Unused
00219         "MonsterEgg::getShapeType()",                           // Unused
00220         "MonsterEgg::setMonId(word)",                           // Unused
00221         "MonsterEgg::setActivity(word)",                        // Unused
00222         "MonsterEgg::setShapeType(word)",                       // Unused
00223         // 0080
00224         "Npc::isBusy()",
00225         "Npc::areEnemiesNear()",
00226         "Npc::isInCombat()",
00227         "Npc::setInCombat()",
00228         "Npc::clrInCombat()",
00229         "Npc::setTarget(uword)",
00230         "Npc::getTarget()",
00231         "Npc::setAlignment(ubyte)",
00232         "Npc::getAlignment()",                                          // Unused
00233         "Npc::setEnemyAlignment(ubyte)",
00234         "Npc::getEnemyAlignment()",                                     // Unused
00235         "Npc::isEnemy(uword)",
00236         "Npc::isDead()",
00237         "Npc::setDead()",
00238         "Npc::clrDead()",
00239         "Npc::isImmortal()",                                            // Unused
00240         // 0090
00241         "Npc::setImmortal()",
00242         "Npc::clrImmortal()",
00243         "Npc::isWithstandDeath()",                                      // Unused
00244         "Npc::setWithstandDeath()",
00245         "Npc::clrWithstandDeath()",
00246         "Npc::isFeignDeath()",                                          // Unused
00247         "Npc::setFeignDeath()",
00248         "Npc::clrFeignDeath()",                                         // Unused
00249         "Npc::freeEquip(uword)",                                        // Unused
00250         "Npc::clearEquip()",                                            // Unused
00251         "Npc::getNpcSlot()",                                            // Unused
00252         "Npc::freeNpcSlot()",                                           // Unused
00253         "Npc::getDir()",
00254         "Npc::getMap()",
00255         "Npc::teleport(uword, uword, ubyte, ubyte)",
00256         "process Npc::doAnim(AnimSet, word, word, ubyte)",
00257         // 00A0
00258         "Npc::getLastAnimSet()",
00259         "process Npc::pathfind(uword, uword, uword, uword)",
00260         "process Npc::pathfind(uword, uword)",
00261         "byte Npc::getStr()",
00262         "byte Npc::getInt()",
00263         "byte Npc::getDex()",
00264         "ubyte Npc::getHp()",
00265         "word Npc::getMana()",
00266         "void Npc::setStr(byte str)",
00267         "void Npc::setInt(byte int)",
00268         "void Npc::setDex(byte dex)",
00269         "void Npc::setHp(ubyte hp)",
00270         "void Npc::setMana(word mana)",
00271         "Npc::create(uword, uword)",
00272         "process Npc::cSetActivity(Activity)",
00273         "Npc::setAirWalkEnabled(ubyte)",
00274         // 00B0
00275         "Npc::getAirWalkEnabled()",
00276         "Npc::schedule(ulong)",
00277         "Npc::getEquip(word)",
00278         "Npc::setEquip(word, uword)",
00279         "closeAllGumps()",
00280         "process Camera::scrollTo(uword, uword, ubyte, word)",  // probably x, y, z, 'time'
00281         "urandom(word)",
00282         "rndRange(word,word)",
00283         "castGrantPeaceSpell()",
00284         "numToStr(uword)",
00285         "strToNum(char*)",                                                      // Unused
00286         "playMusic(byte)",
00287         "getName()",                                                            // Returns the Avatar's name
00288         "igniteChaos(uword, uword, ubyte)",
00289         "Camera::setCenterOn(uword)",
00290         "Camera::move_to(uword, uword, ubyte, word)",
00291         // 00C0
00292         "Camera::move_rel(word, word, word)",           // Unused
00293         "Camera::set_roof(word)",                                       // Unused
00294         "Camera::roof()",                                                       // Unused
00295         "Camera::getX()",                                                       // Unused
00296         "Camera::getY()",                                                       // Unused
00297         "Camera::getZ()",                                                       // Unused
00298         "Camera::startQuake(word)",
00299         "Camera::stopQuake()",
00300         "Camera::invertScreen(ubyte)",
00301         "U8MousePointer::getDir()",                                     // Unused
00302         "Kernel::getNumProcesses(uword, ProcessType)",
00303         "Kernel::resetRef(uword, ProcessType)",
00304         "process teleportToEgg(word, word, ubyte)",
00305         "resetRef(uword, uword)",
00306         "setRef(uword, uword, uword)",
00307         "getAvatarInStasis()",
00308         // 00D0
00309         "setAvatarInStasis(word)",
00310         "getEtherealTop()",
00311         "getCurrentTimerTick()",
00312         "canGetThere(uword, uword, uword)",                     // Unused
00313         "canExistAt(uword, uword, uword, uword, ubyte, uword, word)",
00314         "createSprite(word, word, word, word, word, word, uword, uword, ubyte)",
00315         "createSprite(word, word, word, word, uword, uword, ubyte)",
00316         "word getFamilyOfType(uword type)",
00317         "TimeInGameHours()",
00318         "TimeInMinutes()",
00319         "TimeInSeconds()",                                                      // Unused
00320         "SetTimeInGameHours(word)",
00321         "SetTimeInMinutes(long)",                                       // Unused
00322         "SetTimeInSeconds(long)",                                       // unused
00323         "process FadeToBlack()",
00324         "process FadeFromBlack()",
00325         // 00E0
00326         "process FadeToPalette(word, word)",
00327         "process LightningBolt()",
00328         "process FadeToWhite()",
00329         "process FadeFromWhite()",
00330         "playEndgame()",
00331         "FeedAvatar(word)",
00332         "AccumulateStrength(word)",                                     // Unused
00333         "AccumulateIntelligence(word)",
00334         "AccumulateDexterity(word)",
00335         "ClrAvatarInCombat()",
00336         "SetAvatarInCombat()",
00337         "IsAvatarInCombat()",                                           // Unused
00338         "playSFX(word)",
00339         "playSFX(word, ubyte)",
00340         "playSFX(word, word, uword)",
00341         "playAmbientSFX(word)",                                         // Unused
00342         // 00F0
00343         "playAmbientSFX(word, word)",                           // Unused
00344         "playAmbientSFX(word, word, uword)",
00345         "isSFXPlaying(word)",
00346         "setVolumeSFX(word, word)",
00347         "stopSFX(word)",
00348         "stopSFX(word, uword)",
00349         "soundInit(word, word, word)",                          // Unused
00350         "soundDeInit()",                                                        // Unused
00351         "musicStop()",
00352         "musicSlowStop()",                                                      // Unused
00353         "musicPlay(word)",                                                      // Unused
00354         "TonysBalls(word, word, uword, uword, uword)",
00355         "AvatarCanCheat()",
00356         "MakeAvatarACheater()",
00357         "isGameRunning()",
00358         "unused",
00359         // 0100
00360         "unused",
00361         0
00362 };
00363 
00364 const char * const ConvertUsecodeU8::_event_names[] = {
00365         "look()",                                               // 0x00
00366         "use()",                                                // 0x01
00367         "anim()",                                               // 0x02
00368         "setActivity()",                                // 0x03
00369         "cachein()",                                    // 0x04
00370         "hit(uword, word)",                             // 0x05
00371         "gotHit(uword, word)",                  // 0x06
00372         "hatch()",                                              // 0x07
00373         "schedule()",                                   // 0x08
00374         "release()",                                    // 0x09
00375         "equip()",                                              // 0x0A
00376         "unequip()",                                    // 0x0B
00377         "combine()",                                    // 0x0C
00378         "func0D",                                               // 0x0D
00379         "calledFromAnim()",                             // 0x0E
00380         "enterFastArea()",                              // 0x0F
00381 
00382         "leaveFastArea()",                              // 0x10
00383         "cast(uword)",                                  // 0x11
00384         "justMoved()",                                  // 0x12
00385         "AvatarStoleSomething(uword)",  // 0x13
00386         "animGetHit()",                                 // 0x14
00387         "guardianBark(word)",                   // 0x15
00388         "func16",                                               // 0x16
00389         "func17",                                               // 0x17
00390         "func18",                                               // 0x18
00391         "func19",                                               // 0x19
00392         "func1A",                                               // 0x1A
00393         "func1B",                                               // 0x1B
00394         "func1C",                                               // 0x1C
00395         "func1D",                                               // 0x1D
00396         "func1E",                                               // 0x1E
00397         "func1F",                                               // 0x1F
00398         0
00399 };
00400 
00401 void ConvertUsecodeU8::readheader(IDataSource *ucfile, UsecodeHeader &uch, uint32 &curOffset)
00402 {
00403         #ifdef DISASM_DEBUG
00404         perr << std::setfill('0') << std::hex;
00405         perr << "unknown1: " << std::setw(4) << read4(ucfile) << endl; // unknown
00406         uch.maxOffset = read4(ucfile) - 0x0C; // file size
00407         perr << "maxoffset: " << std::setw(4) << maxOffset << endl;
00408         perr << "unknown2: " << std::setw(4) << read4(ucfile) << endl; // unknown
00409         curOffset = 0;
00410         #else
00411         read4(ucfile); // unknown
00412         uch.maxOffset = read4(ucfile) - 0x0C; // file size
00413         read4(ucfile); // unknown
00414         curOffset = 0;
00415         #endif
00416 };
00417 
00418 #endif

Generated on Fri Jul 27 22:27:12 2007 for pentagram by  doxygen 1.4.7