00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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 &)
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
00088 "process target()",
00089 "Item::getNext()",
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()",
00098 "word Item::getGumpY()",
00099 "void Item::setGumpXY(word x, word y)",
00100 "Item::getPoint(WorldPoint*)",
00101 "uword Item::getType()",
00102 "void Item::setType(uword type)",
00103 "uword Item::getFrame()",
00104
00105 "void Item::setFrame(uword frame)",
00106 "uword Item::getQuality()",
00107 "uword Item::getUnkEggType()",
00108 "uword Item::getQuantity()",
00109 "Item::getContents()",
00110 "Item::getContainer()",
00111 "Item::getRootContainer()",
00112 "uword Item::getGlobNum()",
00113 "void Item::setGlobNum(uword)",
00114 "uword Item::getQ()",
00115 "void Item::setQ(uword)",
00116 "void Item::setQuality(word value)",
00117 "void Item::setUnkEggType(word value)",
00118 "void Item::setQuantity(word value)",
00119 "word Item::getFamily()",
00120 "bool Item::getTypeFlag(word bit)",
00121
00122 "word Item::getStatus()",
00123 "void Item::orStatus(word mask)",
00124 "void Item::andStatus(word mask)",
00125 "Item::getFootpad(word*, word*, word*)",
00126 "Item::touches(uword)",
00127 "Item::overlaps(uword)",
00128 "Item::overlapsXY(uword)",
00129 "Item::isOn(uword)",
00130 "Item::isCompletelyOn(uword)",
00131 "Item::isAbove(uword)",
00132 "Item::isUnder(uword)",
00133 "Item::ascend(word)",
00134 "Item::getWeight()",
00135 "Item::getWeightIncludingContents()",
00136 "Item::getSurfaceWeight()",
00137 "Item::getVolume()",
00138
00139 "Item::getCapacity()",
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*)",
00155
00156 "Item::legal_move(WorldPoint*, uword, uword)",
00157 "Item::legal_move(uword*, uword)",
00158 "Item::isNpc()",
00159 "Item::isInNpc()",
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)",
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()",
00171 "Item::getNpcArray()",
00172
00173 "Item::getMapArray()",
00174 "Item::setNpcArray(word)",
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)",
00181 "Item::getDirToCoords(uword, uword)",
00182 "Item::getDirFromCoords(uword, uword)",
00183 "Item::getDirToItem(uword)",
00184 "Item::getDirFromItem(uword)",
00185 "process Item::look()",
00186 "process Item::use()",
00187 "process Item::anim()",
00188 "process Item::cachein()",
00189
00190 "Item::hit(uword, word)",
00191 "process Item::gotHit(uword, word)",
00192 "process Item::release()",
00193 "process Item::equip()",
00194 "process Item::unequip()",
00195 "process Item::combine()",
00196 "process Item::calledFromAnim()",
00197 "process Item::enterFastArea()",
00198 "process Item::leaveFastArea()",
00199 "process Item::cast(uword)",
00200 "process Item::justMoved()",
00201 "process Item::AvatarStoleSomething(uword)",
00202 "process Item::animGetHit(uword)",
00203 "process Item::guardianBark(word)",
00204 "process Book::read(char*)",
00205 "process Scroll::read(char*)",
00206
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)",
00213 "Egg::getEggId()",
00214 "Egg::setEggId(uword)",
00215 "Egg::hatch()",
00216 "MonsterEgg::hatch()",
00217 "MonsterEgg::getMonId()",
00218 "MonsterEgg::getActivity()",
00219 "MonsterEgg::getShapeType()",
00220 "MonsterEgg::setMonId(word)",
00221 "MonsterEgg::setActivity(word)",
00222 "MonsterEgg::setShapeType(word)",
00223
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()",
00233 "Npc::setEnemyAlignment(ubyte)",
00234 "Npc::getEnemyAlignment()",
00235 "Npc::isEnemy(uword)",
00236 "Npc::isDead()",
00237 "Npc::setDead()",
00238 "Npc::clrDead()",
00239 "Npc::isImmortal()",
00240
00241 "Npc::setImmortal()",
00242 "Npc::clrImmortal()",
00243 "Npc::isWithstandDeath()",
00244 "Npc::setWithstandDeath()",
00245 "Npc::clrWithstandDeath()",
00246 "Npc::isFeignDeath()",
00247 "Npc::setFeignDeath()",
00248 "Npc::clrFeignDeath()",
00249 "Npc::freeEquip(uword)",
00250 "Npc::clearEquip()",
00251 "Npc::getNpcSlot()",
00252 "Npc::freeNpcSlot()",
00253 "Npc::getDir()",
00254 "Npc::getMap()",
00255 "Npc::teleport(uword, uword, ubyte, ubyte)",
00256 "process Npc::doAnim(AnimSet, word, word, ubyte)",
00257
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
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)",
00281 "urandom(word)",
00282 "rndRange(word,word)",
00283 "castGrantPeaceSpell()",
00284 "numToStr(uword)",
00285 "strToNum(char*)",
00286 "playMusic(byte)",
00287 "getName()",
00288 "igniteChaos(uword, uword, ubyte)",
00289 "Camera::setCenterOn(uword)",
00290 "Camera::move_to(uword, uword, ubyte, word)",
00291
00292 "Camera::move_rel(word, word, word)",
00293 "Camera::set_roof(word)",
00294 "Camera::roof()",
00295 "Camera::getX()",
00296 "Camera::getY()",
00297 "Camera::getZ()",
00298 "Camera::startQuake(word)",
00299 "Camera::stopQuake()",
00300 "Camera::invertScreen(ubyte)",
00301 "U8MousePointer::getDir()",
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
00309 "setAvatarInStasis(word)",
00310 "getEtherealTop()",
00311 "getCurrentTimerTick()",
00312 "canGetThere(uword, uword, uword)",
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()",
00320 "SetTimeInGameHours(word)",
00321 "SetTimeInMinutes(long)",
00322 "SetTimeInSeconds(long)",
00323 "process FadeToBlack()",
00324 "process FadeFromBlack()",
00325
00326 "process FadeToPalette(word, word)",
00327 "process LightningBolt()",
00328 "process FadeToWhite()",
00329 "process FadeFromWhite()",
00330 "playEndgame()",
00331 "FeedAvatar(word)",
00332 "AccumulateStrength(word)",
00333 "AccumulateIntelligence(word)",
00334 "AccumulateDexterity(word)",
00335 "ClrAvatarInCombat()",
00336 "SetAvatarInCombat()",
00337 "IsAvatarInCombat()",
00338 "playSFX(word)",
00339 "playSFX(word, ubyte)",
00340 "playSFX(word, word, uword)",
00341 "playAmbientSFX(word)",
00342
00343 "playAmbientSFX(word, word)",
00344 "playAmbientSFX(word, word, uword)",
00345 "isSFXPlaying(word)",
00346 "setVolumeSFX(word, word)",
00347 "stopSFX(word)",
00348 "stopSFX(word, uword)",
00349 "soundInit(word, word, word)",
00350 "soundDeInit()",
00351 "musicStop()",
00352 "musicSlowStop()",
00353 "musicPlay(word)",
00354 "TonysBalls(word, word, uword, uword, uword)",
00355 "AvatarCanCheat()",
00356 "MakeAvatarACheater()",
00357 "isGameRunning()",
00358 "unused",
00359
00360 "unused",
00361 0
00362 };
00363
00364 const char * const ConvertUsecodeU8::_event_names[] = {
00365 "look()",
00366 "use()",
00367 "anim()",
00368 "setActivity()",
00369 "cachein()",
00370 "hit(uword, word)",
00371 "gotHit(uword, word)",
00372 "hatch()",
00373 "schedule()",
00374 "release()",
00375 "equip()",
00376 "unequip()",
00377 "combine()",
00378 "func0D",
00379 "calledFromAnim()",
00380 "enterFastArea()",
00381
00382 "leaveFastArea()",
00383 "cast(uword)",
00384 "justMoved()",
00385 "AvatarStoleSomething(uword)",
00386 "animGetHit()",
00387 "guardianBark(word)",
00388 "func16",
00389 "func17",
00390 "func18",
00391 "func19",
00392 "func1A",
00393 "func1B",
00394 "func1C",
00395 "func1D",
00396 "func1E",
00397 "func1F",
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;
00406 uch.maxOffset = read4(ucfile) - 0x0C;
00407 perr << "maxoffset: " << std::setw(4) << maxOffset << endl;
00408 perr << "unknown2: " << std::setw(4) << read4(ucfile) << endl;
00409 curOffset = 0;
00410 #else
00411 read4(ucfile);
00412 uch.maxOffset = read4(ucfile) - 0x0C;
00413 read4(ucfile);
00414 curOffset = 0;
00415 #endif
00416 };
00417
00418 #endif