| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133 |
- #include "ScriptFile.h"
- #include "../../common/Logger.h"
- Logger* export_script;
- std::vector< StackItem > stack;
- Ogre::String raw_script;
- u32 script_offset;
- u32 script_pointer;
- u32 script_stored_pointer;
- u32 script_pointer_end;
- u8 control;
- ScriptFile::ScriptFile(const Ogre::String &file):
- File(file)
- {
- }
- ScriptFile::ScriptFile(File *file, const u32 offset, const u32 length):
- File(file, offset, length)
- {
- }
- ScriptFile::ScriptFile(u8* buffer, const u32 offset, const u32 length):
- File(buffer, offset, length)
- {
- }
- ScriptFile::ScriptFile(File *file):
- File(file)
- {
- }
- ScriptFile::~ScriptFile()
- {
- }
- void
- ScriptFile::DumpScripts()
- {
- export_script = new Logger("scripts.txt");
- u32 number_of_entity = GetU8( 0x03 );
- for ( int entity = 0; entity < number_of_entity; ++entity )
- {
- if ( GetU16LE( 0x80 + entity * 0x8 + 0x2) == 0 )
- {
- continue;
- }
- export_script->Log( "ENTITY: entity_id = 0x" + HexToString( entity, 2, '0' ) + "\n" );
- script_offset = 0x80 + GetU16LE( 0x80 + entity * 0x8 );
- u32 number_of_scripts = GetU8(script_offset + 1);
- for ( int i = 0; i < number_of_scripts; ++i )
- {
- raw_script = "";
- u16 script_type = GetU16LE( script_offset + 2 + i * 0x4 );
- script_pointer = script_offset + 2 + GetU16LE( script_offset + 2 + i * 0x4 + 2 );
- script_pointer_end = script_pointer;
- export_script->Log( "SCRIPT: script_id = 0x" + HexToString( script_type, 2, '0' ) + "\n" );
- //export_script->Log( "script = w[8007aecc];\n" );
- //export_script->Log( "mask = 8007ae10;\n" );
- for( ; script_pointer <= script_pointer_end; )
- {
- u8 opcode = GetU8( script_pointer );
- raw_script += " " + HexToString( opcode, 2, '0' );
- //export_script->Log( "0x" + HexToString( script_pointer, 4, '0' ) + " 0x" + HexToString( script_pointer_end, 4, '0' ) + "\n" );
- if( opcode != 0x02 && opcode != 0x03 && opcode != 0x06 && opcode != 0x0b )
- {
- script_stored_pointer = script_pointer;
- }
- if( opcode != 0x05 )
- {
- export_script->Log( "0x" + HexToString( script_stored_pointer, 4, '0' ) );
- }
- // Jump
- if( opcode == 0x01 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
- s16 jump = GetU16LE( script_pointer + 1 ) + script_pointer + 3;
- AdvanceScript( 0, jump );
- script_pointer += 3;
- export_script->Log( " JumpTo( 0x" + HexToString( jump, 4, '0' ) + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- // Jump If False
- else if( opcode == 0x02 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
- s16 jump = GetU16LE( script_pointer + 1 ) + script_pointer + 3;
- AdvanceScript( 3, jump );
- export_script->Log(" JumpIf( " + GetStringFromStack() + " == false )To( 0x" + HexToString( jump, 4, '0' ) + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- // Jump If True
- else if( opcode == 0x03 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
- s16 jump = GetU16LE( script_pointer + 1 ) + script_pointer + 3;
- AdvanceScript( 3, jump );
- export_script->Log(" JumpIf( " + GetStringFromStack() + " == true )To( 0x" + HexToString( jump, 4, '0' ) + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- // Return
- else if( opcode == 0x04 )
- {
- export_script->Log(" Return(); //" + raw_script + "\n" );
- raw_script = "";
- script_pointer += 1;
- }
- // StackSubRoutine
- else if( opcode == 0x05 )
- {
- script_stored_pointer = script_pointer;
- AdvanceScript( 1 );
- StackOpcodeParse();
- u8 advance_op = GetU8( script_pointer );
- if ( advance_op != 0x02 && advance_op != 0x03 && advance_op != 0x06 && advance_op != 0x0b )
- {
- export_script->Log( "0x" + HexToString( script_stored_pointer, 4, '0' ) );
- export_script->Log( " " + GetStringFromStack() + "; //" + raw_script + "\n" );
- raw_script = "";
- }
- }
- else if (opcode == 0x06)
- {
- AdvanceScript( 1 );
- u8 case_option = GetU8( script_pointer );
- raw_script += " " + HexToString( case_option, 2, '0' );
- u16 default_jump = GetU16LE( script_pointer + 1 ) + script_pointer + 3;
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
- AdvanceScript( 0, default_jump );
- export_script->Log(" JumpSwitch( " + GetStringFromStack() + " )" );
- for ( int i = 0; i < case_option; ++i )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 3 + i * 4 + 0 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 3 + i * 4 + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 3 + i * 4 + 2 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 3 + i * 4 + 3 ), 2, '0' );
- u16 value = GetU16LE( script_pointer + 3 + i * 4 + 0);
- u16 jump = GetU16LE( script_pointer + 3 + i * 4 + 2) + script_pointer + 3;
- AdvanceScript( 0, jump );
- export_script->Log("( case " + HexToString( value, 4, '0' ) + ": jump_to:0x" + HexToString( jump, 4, '0' ) + ")" );
- }
- export_script->Log("( default: jump_to:0x" + HexToString( default_jump, 4, '0' ) + "); //" + raw_script + "\n" );
- raw_script = "";
- AdvanceScript( 3 + case_option * 4 );
- }
- else if( opcode == 0x07 )
- {
- Ogre::String data1 = HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- Ogre::String data2 = HexToString( GetU8( script_pointer + 2 ), 2, '0' );
- raw_script += " " + data1 + " " + data2;
- AdvanceScript( 3 );
- export_script->Log( " InitScriptEntity( entity_id = 0x" + data1 + ", shared_id = 0x" + data2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x08 )
- {
- Ogre::String data1 = HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- Ogre::String data2 = HexToString( GetU8( script_pointer + 2 ), 2, '0' );
- raw_script += " " + data1 + " " + data2;
- AdvanceScript( 3 );
- export_script->Log( " InitType3Entity( entity_id = 0x" + data1 + ", shared_id = 0x" + data2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x09 )
- {
- Ogre::String data1 = HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- Ogre::String data2 = HexToString( GetU8( script_pointer + 2 ), 2, '0' );
- raw_script += " " + data1 + " " + data2;
- AdvanceScript( 3 );
- export_script->Log( " InitModelEntity( entity_id = 0x" + data1 + ", shared_id = 0x" + data2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x0b )
- {
- AdvanceScript( 1 );
- u8 case_option = GetU8( script_pointer );
- s16 range_start = GetU16LE( script_pointer + 1 );
- u16 default_jump = GetU16LE( script_pointer + 3 ) + script_pointer;
- AdvanceScript( 0, default_jump );
- raw_script += " " + HexToString( case_option, 2, '0' );
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
- raw_script += " " + HexToString( GetU8( script_pointer + 3 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 4 ), 2, '0' );
- export_script->Log(" JumpSwitch( " + GetStringFromStack() + " )" );
- for ( int i = 0; i < case_option; ++i )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 5 + i * 2 + 0 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 5 + i * 2 + 1 ), 2, '0' );
- u16 jump = GetU16LE( script_pointer + 5 + i * 2) + script_pointer;
- AdvanceScript( 0, jump );
- export_script->Log("( case 0x" + HexToString( i + range_start, 4, '0' ) + ": jump_to:0x" + HexToString( jump, 4, '0' ) + ")" );
- }
- export_script->Log("( default: jump_to:0x" + HexToString( default_jump, 4, '0' ) + "); //" + raw_script + "\n" );
- raw_script = "";
- AdvanceScript( 5 + case_option * 2 );
- }/*
- // switch in row
- else if (opcode == 0x0d)
- {
- u16 case_option = GetU16LE(script_offset + script_pointer);
- s16 range_start = GetU16LE(script_offset + script_pointer + 2);
- u16 default_jump = GetU16LE(script_offset + script_pointer + 4);
- export_script->Log("\t0x0b_JumpSwitchInRow(range_start:0x%04x)(default:0x%04x)", range_start, script_offset + default_jump + script_pointer + 1);
- for (int i = 0; i < case_option; ++i)
- {
- u16 jump = GetU16LE(script_offset + script_pointer + 6 + i * 2);
- export_script->Log("(jump:0x%04x)", script_offset + jump + script_pointer + 1);
- }
- script_pointer += 6 + case_option * 2;
- export_script->Log("; // pop 1 value from stack\n");
- }*/
- else if( opcode == 0x10 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String priority = Get8Variable();
- Ogre::String entity_id = Get8Variable();
- raw_script += " " + HexToString( GetU8( script_pointer ), 2, '0' );
- Ogre::String script_id = HexToString( GetU8( script_pointer ), 2, '0' );
- AdvanceScript( 1 );
- export_script->Log( " RunScriptAsync( priority = " + priority + ", entity_id = " + entity_id + ", script_id = 0x" + script_id + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x14 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String priority = Get8Variable();
- Ogre::String entity_id = Get8Variable();
- raw_script += " " + HexToString( GetU8( script_pointer ), 2, '0' );
- Ogre::String script_id = HexToString( GetU8( script_pointer ), 2, '0' );
- AdvanceScript( 1 );
- export_script->Log( " RunScriptStartSync( priority = " + priority + ", entity_id = " + entity_id + ", script_id = 0x" + script_id + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x1c )
- {
- Ogre::String data = HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- Ogre::String entity_id = HexToString( GetU8( script_pointer + 2 ), 2, '0' );
- raw_script += " " + data + " " + entity_id;
- AdvanceScript( 3 );
- export_script->Log( " MoveScriptToEnd( entity_id = 0x" + entity_id + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x1d )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String x = Get16Variable();
- Ogre::String z = Get16Variable();
- export_script->Log( " SetEntityPositionByXZ( x = " + x + ", z = " + z + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x1f )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String window_id = Get8Variable();
- Ogre::String style = Get8Variable();
- Ogre::String text_id = Get16Variable();
- export_script->Log( " WindowSync( window_id = " + window_id + ", style = " + style + ", text_id = " + text_id + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x20 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String window_id = Get8Variable();
- Ogre::String style = Get8Variable();
- Ogre::String text_id = Get16Variable();
- export_script->Log( " WindowAsync( window_id = " + window_id + ", style = " + style + ", text_id = " + text_id + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x21 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- export_script->Log( " 0x21( " + Get8Variable() + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x22 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- export_script->Log( " Wait( " + Get8Variable() + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x23 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String x = Get16Variable();
- Ogre::String y = Get16Variable();
- export_script->Log( " MoveToPosition( x = " + x + ", y = " + y + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x25 )
- {
- AdvanceScript( 1 );
- export_script->Log( " ResetEntityData30_50_63_78(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x26 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get8Variable();
- export_script->Log( " SetEntityData5c( " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x27 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- export_script->Log( " Set800c9df1( " + Get8Variable() + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x29)
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- if( control & 0x01 )
- {
- export_script->Log( "ERROR uexpected situation in opcode 0x29" );
- break;
- }
- raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' );
- u8 number = GetU8( script_pointer + 0 );
- AdvanceScript( 1 );
- export_script->Log( " SetDataForType3Entity( number = " + HexToString( number, 2, '0' ) );
- for ( int i = 0; i < number; ++i )
- {
- Ogre::String value1 = Get16Variable();
- Ogre::String value2 = Get16Variable();
- export_script->Log(", " + value1 + ", " + value2 );
- }
- export_script->Log(" ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x2a )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get16Variable();
- export_script->Log( " 0x2a( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x2b )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get16Variable();
- export_script->Log( " 0x2b( " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x2c )
- {
- AdvanceScript( 1 );
- export_script->Log( " [ script + 0x16ed ] = h( GetCurrentEntityId() ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x2d )
- {
- AdvanceScript( 1 );
- export_script->Log( " 0x2d(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x2e )
- {
- AdvanceScript( 1 );
- export_script->Log( " 0x2e(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x2f )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get16Variable();
- Ogre::String value2 = Get8Variable();
- export_script->Log( " Set32and34inEntityStruct( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x33 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get16Variable();
- export_script->Log( " SetEntityData54( animation_id = " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x34 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get16Variable();
- export_script->Log( " SetEntityData56( animation_id = " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x35 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get16Variable();
- export_script->Log( " SetEntityData58( animation_id = " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x36 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String rot = Get8Variable();
- export_script->Log( " SetEntityRotation( rotation = " + rot + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x3a )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String entity_id = Get8Variable();
- Ogre::String value = Get8Variable();
- export_script->Log( " 0x3a( entity_id = " + entity_id + ", " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x3d )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- export_script->Log( " SetEntityData60and61( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x40 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String animation_id = Get16Variable();
- export_script->Log( " PlayEntityAnimation( animation_id = " + animation_id + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x41 )
- {
- AdvanceScript( 1 );
- export_script->Log( " WaitUntilAnimationComplete(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x43 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String entity_id = Get8Variable();
- export_script->Log( " InitAdditionalScriptEntityForCurrentEntity( entity_id = " + entity_id + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x47 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String flags = Get8Variable();
- export_script->Log( " SetEntityCollisionFlags( flags = " + flags + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x48 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get16Variable();
- Ogre::String value2 = Get8Variable();
- export_script->Log( " 0x48( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x4b )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get8Variable();
- Ogre::String solid = Get8Variable();
- Ogre::String talk = Get8Variable();
- export_script->Log( " SetEntityCollision( " + value + ", solid_radius = " + solid + ", talk_radius = " + talk + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x50 )
- {
- AdvanceScript( 1 );
- export_script->Log( " WaitUntilRotationComplete(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x51 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String entity_id = Get8Variable();
- Ogre::String steps = Get8Variable();
- export_script->Log( " SetEntityRotateToEntity( entity_id = " + entity_id + ", steps = " + steps + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x52 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get16Variable();
- export_script->Log( " SetEntityData74( " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x54 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get8Variable();
- export_script->Log( " 0x54( " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x55 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get8Variable();
- export_script->Log( " SetEntityData5f( " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x56 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String rotation = Get8Variable();
- Ogre::String steps = Get8Variable();
- export_script->Log( " SetEntityRotateToRotation( rotation = " + rotation + ", steps = " + steps + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x59 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- Ogre::String value3 = Get8Variable();
- Ogre::String value4 = Get8Variable();
- export_script->Log( " CallFuncc1368( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x5b )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- export_script->Log( " CallFuncc142c( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x61 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get16Variable();
- export_script->Log( " CallFuncc17f0( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x62 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String character_id = Get8Variable(); // must be less than 9 or else we must not read next value
- Ogre::String value1 = Get8Variable();
- export_script->Log( " CharacterSet34Flag00000200( character_id = " + character_id + ", " + value1 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x65 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- Ogre::String value3 = Get8Variable();
- export_script->Log( " CallFuncc18d4( " + value1 + ", " + value2 + ", " + value3 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x66 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get16Variable();
- export_script->Log( " Set8007bba8( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x67 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- export_script->Log( " Set16e8and16ea( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x68 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get8Variable();
- export_script->Log( " Set8007bbf4( " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x6a )
- {
- AdvanceScript( 1 );
- export_script->Log( " Set16f8to1(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x6f )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get16Variable();
- Ogre::String value2 = Get16Variable();
- Ogre::String value3 = Get8Variable();
- Ogre::String value4 = Get8Variable();
- export_script->Log( " CallFuncc0df4( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x75 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- export_script->Log( " 0x75( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x7a )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get16Variable();
- export_script->Log( " SetEntityData4c( animation_id = " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x7b )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get16Variable();
- export_script->Log( " SetEntityData4e( animation_id = " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x7e )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- export_script->Log( " CallFuncc0bcc( " + value1 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x7f )
- {
- AdvanceScript( 1 );
- export_script->Log( " 0x7f(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x80 )
- {
- AdvanceScript( 1 );
- export_script->Log( " 0x80(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x86 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- Ogre::String value3 = Get8Variable();
- Ogre::String value4 = Get8Variable();
- export_script->Log( " SetEntityData7c_7d_7e_7f( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x88 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get16Variable();
- Ogre::String value3 = Get16Variable();
- Ogre::String value4 = Get16Variable();
- export_script->Log( " CallFuncaba98( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x8b )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- export_script->Log( " SetEntityData6a_6b( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x8e )
- {
- AdvanceScript( 1 );
- export_script->Log( " 0x8e(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x8f )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String entity_id = Get8Variable();
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- Ogre::String value3 = Get8Variable();
- export_script->Log( " 0x8f( entity_id = " + entity_id + ", " + value1 + ", " + value2 + ", " + value3 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x90 )
- {
- AdvanceScript( 1 );
- export_script->Log( " [ script + 0x1700 ] = h( -1 ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x92 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get16Variable();
- Ogre::String value3 = Get8Variable();
- Ogre::String value4 = Get8Variable();
- Ogre::String value5 = Get8Variable();
- Ogre::String value6 = Get8Variable();
- Ogre::String value7 = Get8Variable();
- export_script->Log( " CallFuncc02d0( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", " + value5 + ", " + value6 + ", " + value7 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x93 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String flags = Get8Variable();
- export_script->Log( " SetEntityFlagsTo0f( flags = " + flags + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x94 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get16Variable();
- Ogre::String value2 = Get8Variable();
- Ogre::String value3 = Get8Variable();
- export_script->Log( " SetEntityData76_90_91( " + value1 + ", " + value2 + ", " + value3 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x9a )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get16Variable();
- Ogre::String value2 = Get8Variable();
- export_script->Log( " CallFuncc778c( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x9c )
- {
- AdvanceScript( 1 );
- export_script->Log( " Play76Animation(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x9d )
- {
- AdvanceScript( 1 );
- export_script->Log( " PlaySomeAnimation(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0x9f )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String entity_id = Get8Variable();
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- Ogre::String value3 = Get8Variable();
- export_script->Log( " 0x9f( entity_id = " + entity_id + ", " + value1 + ", " + value2 + ", " + value3 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xa1 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String x = Get16Variable();
- Ogre::String y = Get16Variable();
- Ogre::String z = Get16Variable();
- export_script->Log( " SetEntityPositionByXYZ( x = " + x + ", y = " + y + ", z = " + z + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xa8 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get8Variable();
- export_script->Log( " 0xa8( " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xa9 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get8Variable();
- export_script->Log( " Set8007ae2cAnd8007ae30WithScreenXYForEntity( " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xaa )
- {
- AdvanceScript( 1 );
- export_script->Log( " [80073998] = w(w[80073998] & fffbffff); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xab )
- {
- AdvanceScript( 1 );
- export_script->Log( " [80073998] = w(w[80073998] | 00040000); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xb3 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- Ogre::String value3 = Get16Variable();
- Ogre::String value4 = Get16Variable();
- Ogre::String value5 = Get16Variable();
- export_script->Log( " CallFuncafac0( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", " + value5 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xb4 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get16Variable();
- export_script->Log( " 0xb4( " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xc5 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get16Variable();
- Ogre::String value2 = Get16Variable();
- export_script->Log( " CallDynamic8006794c_1c_83c( " + value1 + ", " + value2 + ", 0x00, 0x00, 0x00 ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xc6 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get16Variable();
- Ogre::String value2 = Get16Variable();
- Ogre::String value3 = Get24Variable();
- export_script->Log( " CallDynamic8006794c_1c_83c( " + value1 + ", " + value2 + ", " + value3 + ", 0x00, 0x00 ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xc7 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get16Variable();
- Ogre::String value2 = Get16Variable();
- Ogre::String value3 = Get24Variable();
- Ogre::String value4 = Get8Variable();
- export_script->Log( " CallDynamic8006794c_1c_83c( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", 0x00 ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xc8 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get16Variable();
- Ogre::String value2 = Get16Variable();
- Ogre::String value3 = Get24Variable();
- Ogre::String value4 = Get8Variable();
- Ogre::String value5 = Get8Variable();
- export_script->Log( " CallDynamic8006794c_1c_83c( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", " + value5 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xca )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- export_script->Log( " CallFuncc196c( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xcb )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- export_script->Log( " CallFuncc47e4( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xce )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get24Variable();
- export_script->Log( " 0xce( " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xd7 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value = Get8Variable();
- export_script->Log( " Set8007bc14to0x2cIfValueEqual8007bc10( " + value + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xd9 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String character_id = Get8Variable();
- Ogre::String status_mask = Get8Variable();
- export_script->Log( " CharacterRemoveStatuses( character_id = " + character_id + ", status_mask = " + status_mask + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xda )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- Ogre::String value3 = Get8Variable();
- Ogre::String value4 = Get16Variable();
- Ogre::String value5 = Get16Variable();
- export_script->Log( " CallFuncafac0( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", " + value5 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xdc )
- {
- AdvanceScript( 1 );
- export_script->Log( " PerformJump(); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xdd )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String character_id = Get8Variable();
- export_script->Log( " PartyRemove( character_id = " + character_id + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xde )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String character_id = Get8Variable();
- Ogre::String string_id = Get16Variable();
- export_script->Log( " CharacterSetName( character_id = " + character_id + ", string_id = " + string_id + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xe2 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String x = Get16Variable();
- Ogre::String y = Get16Variable();
- Ogre::String z = Get16Variable();
- Ogre::String steps = Get8Variable();
- export_script->Log( " Jump( x = " + x + ", y = " + y + ", z = " + z + ", steps = " + steps + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xe3 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- export_script->Log( " Set8007bbd8( " + Get8Variable() + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xec )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- Ogre::String value3 = Get8Variable();
- Ogre::String value4 = Get8Variable();
- Ogre::String value5 = Get8Variable();
- Ogre::String value6 = Get8Variable();
- export_script->Log( " 0xec( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", " + value5 + ", " + value6 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xef )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- export_script->Log( " Set8007bbe0_8007bbe8( " + Get8Variable() + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xf1 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String character_id = Get8Variable();
- Ogre::String hp = Get16Variable();
- export_script->Log( " CharacterSetHP( character_id = " + character_id + ", hp = " + hp + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xf2 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String character_id = Get8Variable();
- Ogre::String mp = Get16Variable();
- export_script->Log( " CharacterSetMP( character_id = " + character_id + ", mp = " + mp + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xf7 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- export_script->Log( " CallFunc54fe0( " + value1 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xf8 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- Ogre::String value3 = Get8Variable();
- export_script->Log( " CallFunc54e88( " + value1 + ", " + value2 + ", " + value3 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xfd )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get16Variable();
- export_script->Log( " CallDynamic8006794c_1c_8bc( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else if( opcode == 0xfe )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- control = GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- Ogre::String character_id = Get8Variable();
- Ogre::String type = Get8Variable();
- Ogre::String preset_id = Get8Variable();
- Ogre::String value1 = Get8Variable();
- Ogre::String value2 = Get8Variable();
- export_script->Log( " CharacterInit( character_id = " + character_id + ", type = " + type + ", preset_id = " + preset_id + ", " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
- raw_script = "";
- }
- else
- {
- export_script->Log( " MISSING OPCODE 0x" + HexToString( opcode, 2, '0' ) + "\n" );
- break;
- }
- }
- export_script->Log( "\n" );
- }
- export_script->Log( "\n\n\n" );
- }
- delete export_script;
- }
- void
- ScriptFile::StackOpcodeParse()
- {
- Ogre::String result;
- stack.clear();
- for ( ;; )
- {
- u8 stack_opcode = GetU8( script_pointer );
- //export_script->Log( "StackOpcodeParse: 0x" + HexToString( script_pointer, 4, '0' ) + " opcode: 0x" + HexToString( stack_opcode, 2, '0' ) + "\n" );
- raw_script += " " + HexToString( stack_opcode, 2, '0' );
- AdvanceScript( 1 );
- if( stack_opcode == 0x04 )
- {
- Ogre::String value = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value + "++ )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x05 )
- {
- Ogre::String value = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value + "-- )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x0e)
- {
- Ogre::String value1 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value1 + " == false )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x11 )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value1 + " * " + value2 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x12 )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value1 + " / " + value2 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x13 )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value1 + " % " + value2 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x14 )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value1 + " + " + value2 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x15)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value1 + " - " + value2 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x16)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " << " + value1 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x17)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " >> " + value1 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x18)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " < " + value1 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x19)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " > " + value1 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x1a)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " <= " + value1 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x1b)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " >= " + value1 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x20)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " == " + value1 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x21)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " != " + value1 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x22)
- {
- Ogre::String value = GetStringFromStack();
- Ogre::String parameter = GetStringFromStack();
- Ogre::String mask = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "MultipleEqual( mask = " + mask + ", parameter = " + parameter + ", value = " + value + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x24)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " & " + value1 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x25)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " XOR " + value1 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x27)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " && " + value1 + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x28)
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " || " + value1 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x29 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' );
- u16 data = GetU8( script_pointer + 0 );
- AdvanceScript( 1 );
- StackItem item;
- item.value_int = 0x18000000 | data;
- item.value_string = "";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x2a )
- {
- Ogre::String value = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "CountActiveBits( " + value + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x2b)
- {
- Ogre::String parameter = GetStringFromStack();
- Ogre::String mask = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "GetUnitParameter( mask = " + mask + ", parameter = " + parameter + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x2c )
- {
- Ogre::String value = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = StoreVariableByStack( value );
- stack.push_back( item );
- }
- else if (stack_opcode == 0x2d)
- {
- Ogre::String value = GetStringFromStack();
- Ogre::String parameter = GetStringFromStack();
- Ogre::String mask = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "StoreUnitsParamsByMask( mask = " + mask + ", parameter = " + parameter + ", value = " + value + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x32 )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " += " + value1 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x33 )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " -= " + value1 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x35 )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " >>= " + value1 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x3d )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " &= " + value1 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x3e )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " ^= " + value1 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x3f )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "( " + value2 + " |= " + value1 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x4d )
- {
- Ogre::String value = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "PickRandomActiveBit( " + value + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x4f )
- {
- Ogre::String value = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "IsButtonPressed( " + value + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x52 )
- {
- Ogre::String value = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "GetCurrentHpForCharacter( " + value + " )";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x54)
- {
- Ogre::String value = GetStringFromStack();
- Ogre::String parameter = GetStringFromStack();
- Ogre::String mask = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "MultipleAnd( mask = " + mask + ", parameter = " + parameter + ", value = " + value + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x5d )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "GetCurrentEntityRotationTo( " + value2 + ", " + value1 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x62 )
- {
- Ogre::String value = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "GetSinByRotation( " + value + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x64 )
- {
- Ogre::String value = GetStringFromStack( 0 );
- StackItem item;
- item.value_int = 0;
- item.value_string = "0x64stack( " + value + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x66 )
- {
- Ogre::String value1 = GetStringFromStack();
- Ogre::String value2 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "GetRotationBy( " + value2 + ", " + value1 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x6b )
- {
- Ogre::String value1 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "CallFunc4b85c( " + value1 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x6d )
- {
- Ogre::String value1 = GetStringFromStack();
- StackItem item;
- item.value_int = 0;
- item.value_string = "CallFunc378c4( " + value1 + " )";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x78 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- u16 data = ( GetU8( script_pointer + 0 ) << 8 ) | GetU8( script_pointer + 1 );
- AdvanceScript( 2 );
- StackItem item;
- item.value_int = 0x10000000 | data;
- item.value_string = "";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x79 )
- {
- raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' );
- u16 data = GetU8( script_pointer + 0 );
- AdvanceScript( 1 );
- StackItem item;
- item.value_int = 0x14000000 | data;
- item.value_string = "";
- stack.push_back( item );
- }
- else if (stack_opcode == 0x7a)
- {
- raw_script += " " + HexToString( GetU8( script_pointer ), 2, '0' );
- u8 type = GetU8( script_pointer );
- AdvanceScript( 1 );
- StackItem item;
- item.value_int = 0;
- switch (type)
- {
- case 0x00: item.value_string = "GetRandomByte()"; break;
- case 0x02: item.value_string = "bu[script + 16ec]"; break;
- case 0x03: item.value_string = "funcb0124( 0xc00, 0xffffffff, 0, 0, 0 )"; break;
- case 0x06: item.value_string = "w[w[w[8006794c] + 1c] + 560]"; break;
- case 0x09: item.value_string = "Func4ecc4()"; break;
- case 0x0c: item.value_string = "w[8007ae2c]"; break;
- case 0x0d: item.value_string = "w[8007ae30]"; break;
- case 0x13: item.value_string = "Count80083248()"; break;
- default: item.value_string = "Unimplemented type 0x" + HexToString( type , 2, '0' ) + " for stack opcode 0x7a.";
- }
- stack.push_back( item );
- }
- else if( stack_opcode == 0x7d )
- {
- raw_script += " " + HexToString( GetU8( script_pointer ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- u16 data = GetU16LE( script_pointer );
- AdvanceScript( 2 );
- StackItem item;
- item.value_int = 0x1c000000 | data;
- item.value_string = "";
- stack.push_back( item );
- }
- else if( stack_opcode == 0x7e )
- {
- raw_script += " " + HexToString( GetU8( script_pointer ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 3 ), 2, '0' );
- u32 data = GetU32LE( script_pointer ) & 0x03ffffff;
- AdvanceScript( 4 );
- StackItem item;
- item.value_int = 0x1c000000 | data;
- item.value_string = "";
- stack.push_back( item );
- }
- // FinishSubRoutine
- else if( stack_opcode == 0x7f )
- {
- return;
- }
- // AddCommand
- else if( stack_opcode >= 0x80 )
- {
- StackItem item;
- item.value_int = StackOpcode80Parse( stack_opcode );
- item.value_string = "";
- stack.push_back( item );
- }
- else
- {
- //export_script->Log( "0x" + HexToString( script_position, 4, '0' ) );
- export_script->Log( " MISSING STACK OPCODE 0x" + HexToString( stack_opcode, 2, '0' ) + "; //" + raw_script + "\n" );
- raw_script = "";
- return;
- }
- }
- }
- u32
- ScriptFile::StackOpcode80Parse( u32 stack_opcode )
- {
- u32 command = stack_opcode & 0x03;
- command <<= 0x1a;
- u32 A1 = stack_opcode & 0x1c;
- A1 <<= 0x1b;
- command |= A1;
- u8 data = GetU8( script_pointer );
- raw_script += " " + HexToString( data, 2, '0' );
- AdvanceScript( 1 );
- command |= data;
- if (stack_opcode & 0x20)
- {
- data = GetU8( script_pointer );
- raw_script += " " + HexToString( data, 2, '0' );
- AdvanceScript( 1 );
- data <<= 0x8;
- command |= data;
- }
- //export_script->Log( "StackOpcode80Parse command: " + HexToString( command, 2, '0') + "\n" );
- return command;
- }
- Ogre::String
- ScriptFile::LoadVariable( const StackItem& item )
- {
- if( item.value_string != "" )
- {
- return "ERROR: LoadVariable must hanble top calue of stack as int. But value is \"" + stack.back().value_string + "\".";
- }
- u32 command = item.value_int;
- //export_script->Log( "Load with command: " + HexToString( command, 2, '0') + "\n" );
- if( ( command >> 0x18 ) == 0x10 )
- {
- switch (command & 0xff)
- {
- case 0x0: return "GetXPositionFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
- case 0x1: return "GetYPositionFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
- case 0x2: return "GetZPositionFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
- case 0x3: return "GetYRotationFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
- case 0x4: return "GetFlagsFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
- case 0x5: return "GetMainEntityIdFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
- case 0x6: return "GetCurrentScriptPriorityFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
- case 0x7: return "Get[3a]FromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
- default: return "Unimplemented 0x" + HexToString( ( command >> 0x18 ), 2, '0' ) + " with type 0x" + HexToString( ( command & 0xff ), 2, '0' ) + " load.";
- }
- }
- else if( ( command >> 0x18 ) == 0x14 )
- {
- Ogre::String ret = "Get";
- if( ( command & 0x7 ) == 2 )
- {
- ret += "Party";
- }
- else if( ( command & 0x7 ) == 3 )
- {
- ret += "Enemy";
- }
- else if( ( command & 0x7 ) == 4 )
- {
- ret += "Units";
- }
- else
- {
- ret += "Unknown" + HexToString( ( command & 0x7 ), 2, '0' );
- }
- ret += "Mask()";
- return ret;
- }
- else if( ( command >> 0x18 ) == 0x18 )
- {
- switch ( ( command << 6 ) >> 6 )
- {
- case 0x0: return "GetXPositionFromEntity()";
- case 0x1: return "GetYPositionFromEntity()";
- case 0x2: return "GetZPositionFromEntity()";
- case 0x3: return "GetYRotationFromEntity()";
- case 0x4: return "GetFlagsFromEntity()";
- case 0x5: return "GetMainEntityIdFromEntity()";
- case 0x6: return "GetCurrentScriptPriorityFromEntity()";
- case 0x7: return "Get[3a]FromEntity()";
- default: return "Unimplemented 0x" + HexToString( ( command >> 0x18 ), 2, '0' ) + " with type 0x" + HexToString( ( ( command << 6 ) >> 6 ), 2, '0' ) + " load.";
- }
- }
- else if( ( command >> 0x18 ) == 0x1c )
- {
- return "0x" + HexToString( ( command << 0x6 ) >> 0x6, 8, '0' );
- }
- else if( ( command >> 0x18 ) == 0x20 )
- {
- return "(bu[ 0x8007aef0 + 0x" + HexToString( ( command & 0xffff ) >> 0x3, 4, '0' ) + " ] >> 0x" + HexToString( command & 0x7, 2, '0' ) + ") & 1";
- }
- else if( ( command >> 0x18 ) == 0x24 )
- {
- return "(bu[ script + 0x" + HexToString( ( command & 0xffff ) >> 0x3, 4, '0' ) + " ] >> 0x" + HexToString( command & 0x7, 2, '0' ) + ") & 1";
- }
- else if( ( command >> 0x18 ) == 0x48 )
- {
- return "b3[ w[ 0x8007bcf8 ] + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
- }
- else if( ( command >> 0x18 ) == 0x80 )
- {
- return "b[ 0x8007aef0 + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
- }
- else if( ( command >> 0x18 ) == 0x88 )
- {
- return "b[ w[ 0x8007bcf8 ] + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
- }
- else if( ( command >> 0x18 ) == 0xa0 )
- {
- return "bu[ 0x8007aef0 + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
- }
- else if( ( command >> 0x18 ) == 0xa4 )
- {
- return "bu[ script + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
- }
- else if( ( command >> 0x18 ) == 0xa8 )
- {
- return "bu[ w[ 0x8007bcf8 ] + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
- }
- else if( ( command >> 0x18 ) == 0xc0 )
- {
- return "h[ 0x8007aef0 + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
- }
- else if( ( command >> 0x18 ) == 0xc4 )
- {
- return "h[ script + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
- }
- else if( ( command >> 0x18 ) == 0xe0 )
- {
- return "hu[ 0x8007aef0 + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
- }
- else if( ( command >> 0x18 ) == 0xe4 )
- {
- return "hu[ script + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
- }
- else if( ( command >> 0x18 ) == 0xe8 )
- {
- return "hu[ w[ 0x8007bcf8 ] + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
- }
- return "Unimplemented 0x" + HexToString( ( command >> 0x18 ), 2, '0' ) + " load.";
- }
- Ogre::String
- ScriptFile::GetStringFromStack( int position )
- {
- StackItem item;
- if( position >= 0 )
- {
- item = stack[ stack.size() - 1 - position ];
- }
- else
- {
- item = stack.back();
- stack.pop_back();
- }
- Ogre::String stack_result = "";
- if ( item.value_string != "" )
- {
- Ogre::String string = item.value_string;
- return string;
- }
- else
- {
- return LoadVariable( item );
- }
- }
- Ogre::String
- ScriptFile::StoreVariableByStack( const Ogre::String& value )
- {
- if ( stack.back().value_string != "" )
- {
- return "ERROR: StoreVariableByStack must hanble top calue of stack as int. But value is \"" + stack.back().value_string + "\".";
- }
- u32 command = stack.back().value_int;
- //export_script->Log( "Save with command: " + HexToString( command, 2, '0') + " value: " + value + "\n" );
- stack.pop_back();
- if ( ( command >> 0x18 ) == 0x14 )
- {
- return "[ masks + 0x" + HexToString( ( command & 0x7 ) * 2, 2, '0' ) + " ] = h( " + value + " )";
- }
- else if ( ( command >> 0x18 ) == 0x20 )
- {
- if ( value == "0x00000000" )
- {
- return "[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] = b( b[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] & 0x" + HexToString( 0xff ^ (1 << (command & 0x7)), 2, '0' ) + " )";
- }
- else
- {
- return "[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] = b( b[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] | 0x" + HexToString( 1 << (command & 0x7), 2, '0' ) + " )";
- }
- }
- else if ( ( command >> 0x18 ) == 0x24 )
- {
- if ( value == "0x00000000" )
- {
- return "[ script + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] = b( b[ script + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] & 0x" + HexToString( 0xff ^ (1 << (command & 0x7)), 2, '0' ) + " )";
- }
- else
- {
- return "[ script + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] = b( b[ script + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] | 0x" + HexToString( 1 << (command & 0x7), 2, '0' ) + " )";
- }
- }
- else if ( ( command >> 0x18 ) == 0x48 )
- {
- return "[ w[ 0x8007bcf8 ] + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = b3( " + value + " )";
- }
- else if ( ( command >> 0x18 ) == 0x88 )
- {
- return "[ w[ 0x8007bcf8 ] + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = b( " + value + " )";
- }
- else if ( ( command >> 0x18 ) == 0xa0 )
- {
- return "[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = b( " + value + " )";
- }
- else if ( ( command >> 0x18 ) == 0xa4 )
- {
- return "[ script + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = b( " + value + " )";
- }
- else if ( ( command >> 0x18 ) == 0xa8 )
- {
- return "[ w[ 0x8007bcf8 ] + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = b( " + value + " )";
- }
- else if ( ( command >> 0x18 ) == 0xc0 )
- {
- return "[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = h( " + value + " )";
- }
- else if ( ( command >> 0x18 ) == 0xc4 )
- {
- return "[ script + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = h( " + value + " )";
- }
- else if ( ( command >> 0x18 ) == 0xe0 )
- {
- return "[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = h( " + value + " )";
- }
- else if ( ( command >> 0x18 ) == 0xe4 )
- {
- return "[ script + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = h( " + value + " )";
- }
- else if ( ( command >> 0x18 ) == 0xe8 )
- {
- return "[ w[ 0x8007bcf8 ] + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = h( " + value + " )";
- }
- return "Unimplemented 0x" + HexToString( ( command >> 0x18 ), 2, '0' ) + " store.";
- }
- Ogre::String
- ScriptFile::Get8Variable()
- {
- if( control & 1 )
- {
- control >>= 1;
- StackOpcodeParse();
- return GetStringFromStack();
- }
- else
- {
- control >>= 1;
- u8 data = GetU8( script_pointer );
- raw_script += " " + HexToString( data, 2, '0' );
- AdvanceScript( 1 );
- return "0x" + HexToString( data, 2, '0' );
- }
- }
- Ogre::String
- ScriptFile::Get16Variable()
- {
- if (control & 1)
- {
- control >>= 1;
- StackOpcodeParse();
- return GetStringFromStack();
- }
- else
- {
- control >>= 1;
- u16 data = GetU16LE( script_pointer );
- raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
- AdvanceScript( 2 );
- return "0x" + HexToString( data, 4, '0' );
- }
- }
- Ogre::String
- ScriptFile::Get24Variable()
- {
- if (control & 1)
- {
- control >>= 1;
- StackOpcodeParse();
- return GetStringFromStack();
- }
- else
- {
- control >>= 1;
- u32 data = GetU16LE( script_pointer ) | ( GetU8( script_pointer + 2 ) << 0x10 );
- raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
- AdvanceScript( 3 );
- return "0x" + HexToString( data, 6, '0' );
- }
- }
- void
- ScriptFile::AdvanceScript( u32 value, u32 jump )
- {
- script_pointer += value;
- script_pointer_end = (script_pointer > script_pointer_end) ? script_pointer : script_pointer_end;
- script_pointer_end = ( jump > script_pointer_end ) ? jump : script_pointer_end;
- }
|