Path: blob/master/RSDKv5/RSDK/Scene/Legacy/v3/ScriptLegacyv3.cpp
1177 views
1RSDK::Legacy::v3::ObjectScript RSDK::Legacy::v3::objectScriptList[LEGACY_v3_OBJECT_COUNT];23RSDK::Legacy::v3::ScriptFunction RSDK::Legacy::v3::scriptFunctionList[LEGACY_v3_FUNCTION_COUNT];4int32 RSDK::Legacy::v3::scriptFunctionCount = 0;56int32 RSDK::Legacy::v3::scriptCode[LEGACY_v3_SCRIPTDATA_COUNT];7int32 RSDK::Legacy::v3::jumpTable[LEGACY_v3_JUMPTABLE_COUNT];8int32 RSDK::Legacy::v3::jumpTableStack[LEGACY_v3_JUMPSTACK_COUNT];9int32 RSDK::Legacy::v3::functionStack[LEGACY_v3_FUNCSTACK_COUNT];1011int32 RSDK::Legacy::v3::scriptCodePos = 0;12int32 RSDK::Legacy::v3::scriptCodeOffset = 0;13int32 RSDK::Legacy::v3::jumpTablePos = 0;14int32 RSDK::Legacy::v3::jumpTableOffset = 0;15int32 RSDK::Legacy::v3::jumpTableStackPos = 0;16int32 RSDK::Legacy::v3::functionStackPos = 0;1718RSDK::Legacy::v3::ScriptEngine RSDK::Legacy::v3::scriptEng = Legacy::v3::ScriptEngine();19char RSDK::Legacy::v3::scriptText[0x100];2021#define LEGACY_v3_COMMONALIAS_COUNT (0x20)22#define LEGACY_v3_ALIAS_COUNT (LEGACY_v3_COMMONALIAS_COUNT + 0x60)23int32 RSDK::Legacy::v3::aliasCount = 0;2425int32 RSDK::Legacy::v3::lineID = 0;2627namespace RSDK28{2930namespace Legacy31{3233namespace v334{3536const char *scriptFile = "";3738#if LEGACY_RETRO_USE_COMPILER39struct AliasInfo {40AliasInfo()41{42StrCopy(name, "");43StrCopy(value, "");44}45AliasInfo(const char *aliasName, const char *aliasVal)46{47StrCopy(name, aliasName);48StrCopy(value, aliasVal);49}5051char name[0x20];52char value[0x20];53};54#endif5556struct FunctionInfo {57FunctionInfo()58{59StrCopy(name, "");60opcodeSize = 0;61}62FunctionInfo(const char *functionName, int32 opSize)63{64StrCopy(name, functionName);65opcodeSize = opSize;66}6768char name[0x20];69int32 opcodeSize;70};7172#if LEGACY_RETRO_USE_COMPILER73const char variableNames[][0x20] = {74"TempValue0",75"TempValue1",76"TempValue2",77"TempValue3",78"TempValue4",79"TempValue5",80"TempValue6",81"TempValue7",82"CheckResult",83"ArrayPos0",84"ArrayPos1",85"Global",86"Object.EntityNo",87"Object.Type",88"Object.PropertyValue",89"Object.XPos",90"Object.YPos",91"Object.iXPos",92"Object.iYPos",93"Object.State",94"Object.Rotation",95"Object.Scale",96"Object.Priority",97"Object.DrawOrder",98"Object.Direction",99"Object.InkEffect",100"Object.Alpha",101"Object.Frame",102"Object.Animation",103"Object.PrevAnimation",104"Object.AnimationSpeed",105"Object.AnimationTimer",106"Object.Value0",107"Object.Value1",108"Object.Value2",109"Object.Value3",110"Object.Value4",111"Object.Value5",112"Object.Value6",113"Object.Value7",114"Object.OutOfBounds",115"Player.State",116"Player.ControlMode",117"Player.ControlLock",118"Player.CollisionMode",119"Player.CollisionPlane",120"Player.XPos",121"Player.YPos",122"Player.iXPos",123"Player.iYPos",124"Player.ScreenXPos",125"Player.ScreenYPos",126"Player.Speed",127"Player.XVelocity",128"Player.YVelocity",129"Player.Gravity",130"Player.Angle",131"Player.Skidding",132"Player.Pushing",133"Player.TrackScroll",134"Player.Up",135"Player.Down",136"Player.Left",137"Player.Right",138"Player.JumpPress",139"Player.JumpHold",140"Player.FollowPlayer1",141"Player.LookPos",142"Player.Water",143"Player.TopSpeed",144"Player.Acceleration",145"Player.Deceleration",146"Player.AirAcceleration",147"Player.AirDeceleration",148"Player.GravityStrength",149"Player.JumpStrength",150"Player.JumpCap",151"Player.RollingAcceleration",152"Player.RollingDeceleration",153"Player.EntityNo",154"Player.CollisionLeft",155"Player.CollisionTop",156"Player.CollisionRight",157"Player.CollisionBottom",158"Player.Flailing",159"Player.Timer",160"Player.TileCollisions",161"Player.ObjectInteraction",162"Player.Visible",163"Player.Rotation",164"Player.Scale",165"Player.Priority",166"Player.DrawOrder",167"Player.Direction",168"Player.InkEffect",169"Player.Alpha",170"Player.Frame",171"Player.Animation",172"Player.PrevAnimation",173"Player.AnimationSpeed",174"Player.AnimationTimer",175"Player.Value0",176"Player.Value1",177"Player.Value2",178"Player.Value3",179"Player.Value4",180"Player.Value5",181"Player.Value6",182"Player.Value7",183"Player.Value8",184"Player.Value9",185"Player.Value10",186"Player.Value11",187"Player.Value12",188"Player.Value13",189"Player.Value14",190"Player.Value15",191"Player.OutOfBounds",192"Stage.State",193"Stage.ActiveList",194"Stage.ListPos",195"Stage.TimeEnabled",196"Stage.MilliSeconds",197"Stage.Seconds",198"Stage.Minutes",199"Stage.ActNo",200"Stage.PauseEnabled",201"Stage.ListSize",202"Stage.NewXBoundary1",203"Stage.NewXBoundary2",204"Stage.NewYBoundary1",205"Stage.NewYBoundary2",206"Stage.XBoundary1",207"Stage.XBoundary2",208"Stage.YBoundary1",209"Stage.YBoundary2",210"Stage.DeformationData0",211"Stage.DeformationData1",212"Stage.DeformationData2",213"Stage.DeformationData3",214"Stage.WaterLevel",215"Stage.ActiveLayer",216"Stage.MidPoint",217"Stage.PlayerListPos",218"Stage.ActivePlayer",219"Screen.CameraEnabled",220"Screen.CameraTarget",221"Screen.CameraStyle",222"Screen.DrawListSize",223"Screen.CenterX",224"Screen.CenterY",225"Screen.XSize",226"Screen.YSize",227"Screen.XOffset",228"Screen.YOffset",229"Screen.ShakeX",230"Screen.ShakeY",231"Screen.AdjustCameraY",232"TouchScreen.Down",233"TouchScreen.XPos",234"TouchScreen.YPos",235"Music.Volume",236"Music.CurrentTrack",237"KeyDown.Up",238"KeyDown.Down",239"KeyDown.Left",240"KeyDown.Right",241"KeyDown.ButtonA",242"KeyDown.ButtonB",243"KeyDown.ButtonC",244"KeyDown.Start",245"KeyPress.Up",246"KeyPress.Down",247"KeyPress.Left",248"KeyPress.Right",249"KeyPress.ButtonA",250"KeyPress.ButtonB",251"KeyPress.ButtonC",252"KeyPress.Start",253"Menu1.Selection",254"Menu2.Selection",255"TileLayer.XSize",256"TileLayer.YSize",257"TileLayer.Type",258"TileLayer.Angle",259"TileLayer.XPos",260"TileLayer.YPos",261"TileLayer.ZPos",262"TileLayer.ParallaxFactor",263"TileLayer.ScrollSpeed",264"TileLayer.ScrollPos",265"TileLayer.DeformationOffset",266"TileLayer.DeformationOffsetW",267"HParallax.ParallaxFactor",268"HParallax.ScrollSpeed",269"HParallax.ScrollPos",270"VParallax.ParallaxFactor",271"VParallax.ScrollSpeed",272"VParallax.ScrollPos",273"3DScene.NoVertices",274"3DScene.NoFaces",275"VertexBuffer.x",276"VertexBuffer.y",277"VertexBuffer.z",278"VertexBuffer.u",279"VertexBuffer.v",280"FaceBuffer.a",281"FaceBuffer.b",282"FaceBuffer.c",283"FaceBuffer.d",284"FaceBuffer.Flag",285"FaceBuffer.Color",286"3DScene.ProjectionX",287"3DScene.ProjectionY",288"Engine.State",289"Stage.DebugMode",290"Engine.Message",291"SaveRAM",292"Engine.Language",293"Object.SpriteSheet",294"Engine.OnlineActive",295"Engine.FrameSkipTimer",296"Engine.FrameSkipSetting",297"Engine.SFXVolume",298"Engine.BGMVolume",299"Engine.PlatformID",300"Engine.TrialMode",301"KeyPress.AnyStart",302#if LEGACY_RETRO_USE_HAPTICS303"Engine.HapticsEnabled",304#endif305};306#endif307308const FunctionInfo functions[] = {309FunctionInfo("End", 0),310FunctionInfo("Equal", 2),311FunctionInfo("Add", 2),312FunctionInfo("Sub", 2),313FunctionInfo("Inc", 1),314FunctionInfo("Dec", 1),315FunctionInfo("Mul", 2),316FunctionInfo("Div", 2),317FunctionInfo("ShR", 2),318FunctionInfo("ShL", 2),319FunctionInfo("And", 2),320FunctionInfo("Or", 2),321FunctionInfo("Xor", 2),322FunctionInfo("Mod", 2),323FunctionInfo("FlipSign", 1),324FunctionInfo("CheckEqual", 2),325FunctionInfo("CheckGreater", 2),326FunctionInfo("CheckLower", 2),327FunctionInfo("CheckNotEqual", 2),328FunctionInfo("IfEqual", 3),329FunctionInfo("IfGreater", 3),330FunctionInfo("IfGreaterOrEqual", 3),331FunctionInfo("IfLower", 3),332FunctionInfo("IfLowerOrEqual", 3),333FunctionInfo("IfNotEqual", 3),334FunctionInfo("else", 0),335FunctionInfo("endif", 0),336FunctionInfo("WEqual", 3),337FunctionInfo("WGreater", 3),338FunctionInfo("WGreaterOrEqual", 3),339FunctionInfo("WLower", 3),340FunctionInfo("WLowerOrEqual", 3),341FunctionInfo("WNotEqual", 3),342FunctionInfo("loop", 0),343FunctionInfo("switch", 2),344FunctionInfo("break", 0),345FunctionInfo("endswitch", 0),346FunctionInfo("Rand", 2),347FunctionInfo("Sin", 2),348FunctionInfo("Cos", 2),349FunctionInfo("Sin256", 2),350FunctionInfo("Cos256", 2),351FunctionInfo("SinChange", 5),352FunctionInfo("CosChange", 5),353FunctionInfo("ATan2", 3),354FunctionInfo("Interpolate", 4),355FunctionInfo("InterpolateXY", 7),356FunctionInfo("LoadSpriteSheet", 1),357FunctionInfo("RemoveSpriteSheet", 1),358FunctionInfo("DrawSprite", 1),359FunctionInfo("DrawSpriteXY", 3),360FunctionInfo("DrawSpriteScreenXY", 3),361FunctionInfo("DrawTintRect", 4),362FunctionInfo("DrawNumbers", 7),363FunctionInfo("DrawActName", 7),364FunctionInfo("DrawMenu", 3),365FunctionInfo("SpriteFrame", 6),366FunctionInfo("EditFrame", 7),367FunctionInfo("LoadPalette", 5),368FunctionInfo("RotatePalette", 3),369FunctionInfo("SetScreenFade", 4),370FunctionInfo("SetActivePalette", 3),371FunctionInfo("SetPaletteFade", 7),372FunctionInfo("CopyPalette", 2),373FunctionInfo("ClearScreen", 1),374FunctionInfo("DrawSpriteFX", 4),375FunctionInfo("DrawSpriteScreenFX", 4),376FunctionInfo("LoadAnimation", 1),377FunctionInfo("SetupMenu", 4),378FunctionInfo("AddMenuEntry", 3),379FunctionInfo("EditMenuEntry", 4),380FunctionInfo("LoadStage", 0),381FunctionInfo("DrawRect", 8),382FunctionInfo("ResetObjectEntity", 5),383FunctionInfo("PlayerObjectCollision", 5),384FunctionInfo("CreateTempObject", 4),385FunctionInfo("BindPlayerToObject", 2),386FunctionInfo("PlayerTileCollision", 0),387FunctionInfo("ProcessPlayerControl", 0),388FunctionInfo("ProcessAnimation", 0),389FunctionInfo("DrawObjectAnimation", 0),390FunctionInfo("DrawPlayerAnimation", 0),391FunctionInfo("SetMusicTrack", 3),392FunctionInfo("PlayMusic", 1),393FunctionInfo("StopMusic", 0),394FunctionInfo("PlaySfx", 2),395FunctionInfo("StopSfx", 1),396FunctionInfo("SetSfxAttributes", 3),397FunctionInfo("ObjectTileCollision", 4),398FunctionInfo("ObjectTileGrip", 4),399FunctionInfo("LoadVideo", 1),400FunctionInfo("NextVideoFrame", 0),401FunctionInfo("PlayStageSfx", 2),402FunctionInfo("StopStageSfx", 1),403FunctionInfo("Not", 1),404FunctionInfo("Draw3DScene", 0),405FunctionInfo("SetIdentityMatrix", 1),406FunctionInfo("MatrixMultiply", 2),407FunctionInfo("MatrixTranslateXYZ", 4),408FunctionInfo("MatrixScaleXYZ", 4),409FunctionInfo("MatrixRotateX", 2),410FunctionInfo("MatrixRotateY", 2),411FunctionInfo("MatrixRotateZ", 2),412FunctionInfo("MatrixRotateXYZ", 4),413FunctionInfo("TransformVertices", 3),414FunctionInfo("CallFunction", 1),415FunctionInfo("EndFunction", 0),416FunctionInfo("SetLayerDeformation", 6),417FunctionInfo("CheckTouchRect", 4),418FunctionInfo("GetTileLayerEntry", 4),419FunctionInfo("SetTileLayerEntry", 4),420FunctionInfo("GetBit", 3),421FunctionInfo("SetBit", 3),422FunctionInfo("PauseMusic", 0),423FunctionInfo("ResumeMusic", 0),424FunctionInfo("ClearDrawList", 1),425FunctionInfo("AddDrawListEntityRef", 2),426FunctionInfo("GetDrawListEntityRef", 3),427FunctionInfo("SetDrawListEntityRef", 3),428FunctionInfo("Get16x16TileInfo", 4),429FunctionInfo("Copy16x16Tile", 2),430FunctionInfo("Set16x16TileInfo", 4),431FunctionInfo("GetAnimationByName", 2),432FunctionInfo("ReadSaveRAM", 0),433FunctionInfo("WriteSaveRAM", 0),434FunctionInfo("LoadTextFont", 1),435FunctionInfo("LoadTextFile", 3),436FunctionInfo("DrawText", 7),437FunctionInfo("GetTextInfo", 5),438FunctionInfo("GetVersionNumber", 2),439FunctionInfo("SetAchievement", 2),440FunctionInfo("SetLeaderboard", 2),441FunctionInfo("LoadOnlineMenu", 1),442FunctionInfo("EngineCallback", 1),443#if LEGACY_RETRO_USE_HAPTICS444FunctionInfo("HapticEffect", 4),445#endif446};447448#if LEGACY_RETRO_USE_COMPILER449AliasInfo aliases[0x80] = { AliasInfo("true", "1"),450AliasInfo("false", "0"),451AliasInfo("FX_SCALE", "0"),452AliasInfo("FX_ROTATE", "1"),453AliasInfo("FX_ROTOZOOM", "2"),454AliasInfo("FX_INK", "3"),455AliasInfo("PRESENTATION_STAGE", "0"),456AliasInfo("REGULAR_STAGE", "1"),457AliasInfo("BONUS_STAGE", "2"),458AliasInfo("SPECIAL_STAGE", "3"),459AliasInfo("MENU_1", "0"),460AliasInfo("MENU_2", "1"),461AliasInfo("C_TOUCH", "0"),462AliasInfo("C_BOX", "1"),463AliasInfo("C_BOX2", "2"),464AliasInfo("C_PLATFORM", "3"),465AliasInfo("MAT_WORLD", "0"),466AliasInfo("MAT_VIEW", "1"),467AliasInfo("MAT_TEMP", "2"),468AliasInfo("FX_FLIP", "5"),469AliasInfo("FACING_LEFT", "1"),470AliasInfo("FACING_RIGHT", "0"),471AliasInfo("STAGE_PAUSED", "2"),472AliasInfo("STAGE_RUNNING", "1"),473AliasInfo("RESET_GAME", "2"),474AliasInfo("RETRO_WIN", "0"),475AliasInfo("RETRO_OSX", "1"),476AliasInfo("RETRO_XBOX_360", "2"),477AliasInfo("RETRO_PS3", "3"),478AliasInfo("RETRO_iOS", "4"),479AliasInfo("RETRO_ANDROID", "5"),480AliasInfo("RETRO_WP7", "6") };481482const char scriptEvaluationTokens[][0x4] = { "=", "+=", "-=", "++", "--", "*=", "/=", ">>=", "<<=", "&=",483"|=", "^=", "%=", "==", ">", ">=", "<", "<=", "!=" };484485enum ScriptReadModes { READMODE_NORMAL = 0, READMODE_STRING = 1, READMODE_COMMENTLINE = 2, READMODE_ENDLINE = 3, READMODE_EOF = 4 };486enum ScriptParseModes {487PARSEMODE_SCOPELESS = 0,488PARSEMODE_PLATFORMSKIP = 1,489PARSEMODE_FUNCTION = 2,490PARSEMODE_SWITCHREAD = 3,491PARSEMODE_ERROR = 0xFF492};493#endif494495enum ScriptVarTypes { SCRIPTVAR_VAR = 1, SCRIPTVAR_INTCONST = 2, SCRIPTVAR_STRCONST = 3 };496enum ScriptVarArrTypes { VARARR_NONE = 0, VARARR_ARRAY = 1, VARARR_ENTNOPLUS1 = 2, VARARR_ENTNOMINUS1 = 3 };497498enum ScrVariable {499VAR_TEMPVALUE0,500VAR_TEMPVALUE1,501VAR_TEMPVALUE2,502VAR_TEMPVALUE3,503VAR_TEMPVALUE4,504VAR_TEMPVALUE5,505VAR_TEMPVALUE6,506VAR_TEMPVALUE7,507VAR_CHECKRESULT,508VAR_ARRAYPOS0,509VAR_ARRAYPOS1,510VAR_GLOBAL,511VAR_OBJECTENTITYNO,512VAR_OBJECTTYPE,513VAR_OBJECTPROPERTYVALUE,514VAR_OBJECTXPOS,515VAR_OBJECTYPOS,516VAR_OBJECTIXPOS,517VAR_OBJECTIYPOS,518VAR_OBJECTSTATE,519VAR_OBJECTROTATION,520VAR_OBJECTSCALE,521VAR_OBJECTPRIORITY,522VAR_OBJECTDRAWORDER,523VAR_OBJECTDIRECTION,524VAR_OBJECTINKEFFECT,525VAR_OBJECTALPHA,526VAR_OBJECTFRAME,527VAR_OBJECTANIMATION,528VAR_OBJECTPREVANIMATION,529VAR_OBJECTANIMATIONSPEED,530VAR_OBJECTANIMATIONTIMER,531VAR_OBJECTVALUE0,532VAR_OBJECTVALUE1,533VAR_OBJECTVALUE2,534VAR_OBJECTVALUE3,535VAR_OBJECTVALUE4,536VAR_OBJECTVALUE5,537VAR_OBJECTVALUE6,538VAR_OBJECTVALUE7,539VAR_OBJECTOUTOFBOUNDS,540VAR_PLAYERSTATE,541VAR_PLAYERCONTROLMODE,542VAR_PLAYERCONTROLLOCK,543VAR_PLAYERCOLLISIONMODE,544VAR_PLAYERCOLLISIONPLANE,545VAR_PLAYERXPOS,546VAR_PLAYERYPOS,547VAR_PLAYERIXPOS,548VAR_PLAYERIYPOS,549VAR_PLAYERSCREENXPOS,550VAR_PLAYERSCREENYPOS,551VAR_PLAYERSPEED,552VAR_PLAYERXVELOCITY,553VAR_PLAYERYVELOCITY,554VAR_PLAYERGRAVITY,555VAR_PLAYERANGLE,556VAR_PLAYERSKIDDING,557VAR_PLAYERPUSHING,558VAR_PLAYERTRACKSCROLL,559VAR_PLAYERUP,560VAR_PLAYERDOWN,561VAR_PLAYERLEFT,562VAR_PLAYERRIGHT,563VAR_PLAYERJUMPPRESS,564VAR_PLAYERJUMPHOLD,565VAR_PLAYERFOLLOWPLAYER1,566VAR_PLAYERLOOKPOS,567VAR_PLAYERWATER,568VAR_PLAYERTOPSPEED,569VAR_PLAYERACCELERATION,570VAR_PLAYERDECELERATION,571VAR_PLAYERAIRACCELERATION,572VAR_PLAYERAIRDECELERATION,573VAR_PLAYERGRAVITYSTRENGTH,574VAR_PLAYERJUMPSTRENGTH,575VAR_PLAYERJUMPCAP,576VAR_PLAYERROLLINGACCELERATION,577VAR_PLAYERROLLINGDECELERATION,578VAR_PLAYERENTITYNO,579VAR_PLAYERCOLLISIONLEFT,580VAR_PLAYERCOLLISIONTOP,581VAR_PLAYERCOLLISIONRIGHT,582VAR_PLAYERCOLLISIONBOTTOM,583VAR_PLAYERFLAILING,584VAR_PLAYERTIMER,585VAR_PLAYERTILECOLLISIONS,586VAR_PLAYEROBJECTINTERACTION,587VAR_PLAYERVISIBLE,588VAR_PLAYERROTATION,589VAR_PLAYERSCALE,590VAR_PLAYERPRIORITY,591VAR_PLAYERDRAWORDER,592VAR_PLAYERDIRECTION,593VAR_PLAYERINKEFFECT,594VAR_PLAYERALPHA,595VAR_PLAYERFRAME,596VAR_PLAYERANIMATION,597VAR_PLAYERPREVANIMATION,598VAR_PLAYERANIMATIONSPEED,599VAR_PLAYERANIMATIONTIMER,600VAR_PLAYERVALUE0,601VAR_PLAYERVALUE1,602VAR_PLAYERVALUE2,603VAR_PLAYERVALUE3,604VAR_PLAYERVALUE4,605VAR_PLAYERVALUE5,606VAR_PLAYERVALUE6,607VAR_PLAYERVALUE7,608VAR_PLAYERVALUE8,609VAR_PLAYERVALUE9,610VAR_PLAYERVALUE10,611VAR_PLAYERVALUE11,612VAR_PLAYERVALUE12,613VAR_PLAYERVALUE13,614VAR_PLAYERVALUE14,615VAR_PLAYERVALUE15,616VAR_PLAYEROUTOFBOUNDS,617VAR_STAGESTATE,618VAR_STAGEACTIVELIST,619VAR_STAGELISTPOS,620VAR_STAGETIMEENABLED,621VAR_STAGEMILLISECONDS,622VAR_STAGESECONDS,623VAR_STAGEMINUTES,624VAR_STAGEACTNO,625VAR_STAGEPAUSEENABLED,626VAR_STAGELISTSIZE,627VAR_STAGENEWXBOUNDARY1,628VAR_STAGENEWXBOUNDARY2,629VAR_STAGENEWYBOUNDARY1,630VAR_STAGENEWYBOUNDARY2,631VAR_STAGEXBOUNDARY1,632VAR_STAGEXBOUNDARY2,633VAR_STAGEYBOUNDARY1,634VAR_STAGEYBOUNDARY2,635VAR_STAGEDEFORMATIONDATA0,636VAR_STAGEDEFORMATIONDATA1,637VAR_STAGEDEFORMATIONDATA2,638VAR_STAGEDEFORMATIONDATA3,639VAR_STAGEWATERLEVEL,640VAR_STAGEACTIVELAYER,641VAR_STAGEMIDPOINT,642VAR_STAGEPLAYERLISTPOS,643VAR_STAGEACTIVEPLAYER,644VAR_SCREENCAMERAENABLED,645VAR_SCREENCAMERATARGET,646VAR_SCREENCAMERASTYLE,647VAR_SCREENDRAWLISTSIZE,648VAR_SCREENCENTERX,649VAR_SCREENCENTERY,650VAR_SCREENXSIZE,651VAR_SCREENYSIZE,652VAR_SCREENXOFFSET,653VAR_SCREENYOFFSET,654VAR_SCREENSHAKEX,655VAR_SCREENSHAKEY,656VAR_SCREENADJUSTCAMERAY,657VAR_TOUCHSCREENDOWN,658VAR_TOUCHSCREENXPOS,659VAR_TOUCHSCREENYPOS,660VAR_MUSICVOLUME,661VAR_MUSICCURRENTTRACK,662VAR_KEYDOWNUP,663VAR_KEYDOWNDOWN,664VAR_KEYDOWNLEFT,665VAR_KEYDOWNRIGHT,666VAR_KEYDOWNBUTTONA,667VAR_KEYDOWNBUTTONB,668VAR_KEYDOWNBUTTONC,669VAR_KEYDOWNSTART,670VAR_KEYPRESSUP,671VAR_KEYPRESSDOWN,672VAR_KEYPRESSLEFT,673VAR_KEYPRESSRIGHT,674VAR_KEYPRESSBUTTONA,675VAR_KEYPRESSBUTTONB,676VAR_KEYPRESSBUTTONC,677VAR_KEYPRESSSTART,678VAR_MENU1SELECTION,679VAR_MENU2SELECTION,680VAR_TILELAYERXSIZE,681VAR_TILELAYERYSIZE,682VAR_TILELAYERTYPE,683VAR_TILELAYERANGLE,684VAR_TILELAYERXPOS,685VAR_TILELAYERYPOS,686VAR_TILELAYERZPOS,687VAR_TILELAYERPARALLAXFACTOR,688VAR_TILELAYERSCROLLSPEED,689VAR_TILELAYERSCROLLPOS,690VAR_TILELAYERDEFORMATIONOFFSET,691VAR_TILELAYERDEFORMATIONOFFSETW,692VAR_HPARALLAXPARALLAXFACTOR,693VAR_HPARALLAXSCROLLSPEED,694VAR_HPARALLAXSCROLLPOS,695VAR_VPARALLAXPARALLAXFACTOR,696VAR_VPARALLAXSCROLLSPEED,697VAR_VPARALLAXSCROLLPOS,698VAR_3DSCENENOVERTICES,699VAR_3DSCENENOFACES,700VAR_VERTEXBUFFERX,701VAR_VERTEXBUFFERY,702VAR_VERTEXBUFFERZ,703VAR_VERTEXBUFFERU,704VAR_VERTEXBUFFERV,705VAR_FACEBUFFERA,706VAR_FACEBUFFERB,707VAR_FACEBUFFERC,708VAR_FACEBUFFERD,709VAR_FACEBUFFERFLAG,710VAR_FACEBUFFERCOLOR,711VAR_3DSCENEPROJECTIONX,712VAR_3DSCENEPROJECTIONY,713VAR_ENGINESTATE,714VAR_STAGEDEBUGMODE,715VAR_ENGINEMESSAGE,716VAR_SAVERAM,717VAR_ENGINELANGUAGE,718VAR_OBJECTSPRITESHEET,719VAR_ENGINEONLINEACTIVE,720VAR_ENGINEFRAMESKIPTIMER,721VAR_ENGINEFRAMESKIPSETTING,722VAR_ENGINESFXVOLUME,723VAR_ENGINEBGMVOLUME,724VAR_ENGINEPLATFORMID,725VAR_ENGINETRIALMODE,726VAR_KEYPRESSANYSTART,727#if LEGACY_RETRO_USE_HAPTICS728VAR_ENGINEHAPTICSENABLED,729#endif730VAR_MAX_CNT731};732733enum ScrFunction {734FUNC_END,735FUNC_EQUAL,736FUNC_ADD,737FUNC_SUB,738FUNC_INC,739FUNC_DEC,740FUNC_MUL,741FUNC_DIV,742FUNC_SHR,743FUNC_SHL,744FUNC_AND,745FUNC_OR,746FUNC_XOR,747FUNC_MOD,748FUNC_FLIPSIGN,749FUNC_CHECKEQUAL,750FUNC_CHECKGREATER,751FUNC_CHECKLOWER,752FUNC_CHECKNOTEQUAL,753FUNC_IFEQUAL,754FUNC_IFGREATER,755FUNC_IFGREATEROREQUAL,756FUNC_IFLOWER,757FUNC_IFLOWEROREQUAL,758FUNC_IFNOTEQUAL,759FUNC_ELSE,760FUNC_ENDIF,761FUNC_WEQUAL,762FUNC_WGREATER,763FUNC_WGREATEROREQUAL,764FUNC_WLOWER,765FUNC_WLOWEROREQUAL,766FUNC_WNOTEQUAL,767FUNC_LOOP,768FUNC_SWITCH,769FUNC_BREAK,770FUNC_ENDSWITCH,771FUNC_RAND,772FUNC_SIN,773FUNC_COS,774FUNC_SIN256,775FUNC_COS256,776FUNC_SINCHANGE,777FUNC_COSCHANGE,778FUNC_ATAN2,779FUNC_INTERPOLATE,780FUNC_INTERPOLATEXY,781FUNC_LOADSPRITESHEET,782FUNC_REMOVESPRITESHEET,783FUNC_DRAWSPRITE,784FUNC_DRAWSPRITEXY,785FUNC_DRAWSPRITESCREENXY,786FUNC_DRAWTINTRECT,787FUNC_DRAWNUMBERS,788FUNC_DRAWACTNAME,789FUNC_DRAWMENU,790FUNC_SPRITEFRAME,791FUNC_EDITFRAME,792FUNC_LOADPALETTE,793FUNC_ROTATEPALETTE,794FUNC_SETSCREENFADE,795FUNC_SETACTIVEPALETTE,796FUNC_SETPALETTEFADE,797FUNC_COPYPALETTE,798FUNC_CLEARSCREEN,799FUNC_DRAWSPRITEFX,800FUNC_DRAWSPRITESCREENFX,801FUNC_LOADANIMATION,802FUNC_SETUPMENU,803FUNC_ADDMENUENTRY,804FUNC_EDITMENUENTRY,805FUNC_LOADSTAGE,806FUNC_DRAWRECT,807FUNC_RESETOBJECTENTITY,808FUNC_PLAYEROBJECTCOLLISION,809FUNC_CREATETEMPOBJECT,810FUNC_BINDPLAYERTOOBJECT,811FUNC_PLAYERTILECOLLISION,812FUNC_PROCESSPLAYERCONTROL,813FUNC_PROCESSANIMATION,814FUNC_DRAWOBJECTANIMATION,815FUNC_DRAWPLAYERANIMATION,816FUNC_SETMUSICTRACK,817FUNC_PLAYMUSIC,818FUNC_STOPMUSIC,819FUNC_PLAYSFX,820FUNC_STOPSFX,821FUNC_SETSFXATTRIBUTES,822FUNC_OBJECTTILECOLLISION,823FUNC_OBJECTTILEGRIP,824FUNC_LOADVIDEO,825FUNC_NEXTVIDEOFRAME,826FUNC_PLAYSTAGESFX,827FUNC_STOPSTAGESFX,828FUNC_NOT,829FUNC_DRAW3DSCENE,830FUNC_SETIDENTITYMATRIX,831FUNC_MATRIXMULTIPLY,832FUNC_MATRIXTRANSLATEXYZ,833FUNC_MATRIXSCALEXYZ,834FUNC_MATRIXROTATEX,835FUNC_MATRIXROTATEY,836FUNC_MATRIXROTATEZ,837FUNC_MATRIXROTATEXYZ,838FUNC_TRANSFORMVERTICES,839FUNC_CALLFUNCTION,840FUNC_ENDFUNCTION,841FUNC_SETLAYERDEFORMATION,842FUNC_CHECKTOUCHRECT,843FUNC_GETTILELAYERENTRY,844FUNC_SETTILELAYERENTRY,845FUNC_GETBIT,846FUNC_SETBIT,847FUNC_PAUSEMUSIC,848FUNC_RESUMEMUSIC,849FUNC_CLEARDRAWLIST,850FUNC_ADDDRAWLISTENTITYREF,851FUNC_GETDRAWLISTENTITYREF,852FUNC_SETDRAWLISTENTITYREF,853FUNC_GET16X16TILEINFO,854FUNC_COPY16X16TILE,855FUNC_SET16X16TILEINFO,856FUNC_GETANIMATIONBYNAME,857FUNC_READSAVERAM,858FUNC_WRITESAVERAM,859FUNC_LOADTEXTFONT,860FUNC_LOADTEXTFILE,861FUNC_DRAWTEXT,862FUNC_GETTEXTINFO,863FUNC_GETVERSIONNUMBER,864FUNC_SETACHIEVEMENT,865FUNC_SETLEADERBOARD,866FUNC_LOADONLINEMENU,867FUNC_ENGINECALLBACK,868#if LEGACY_RETRO_USE_HAPTICS869FUNC_HAPTICEFFECT,870#endif871FUNC_MAX_CNT872};873} // namespace v3874875} // namespace Legacy876877} // namespace RSDK878879#if LEGACY_RETRO_USE_COMPILER880void RSDK::Legacy::v3::CheckAliasText(char *text)881{882if (FindStringToken(text, "#alias", 1) != 0)883return;884885#if !RETRO_USE_ORIGINAL_CODE886if (aliasCount >= LEGACY_v3_ALIAS_COUNT) {887RSDK::PrintLog(PRINT_SCRIPTERR, "SCRIPT ERROR: Too many aliases\nFILE: %s", scriptFile);888gameMode = ENGINE_SCRIPTERROR;889return;890}891#endif892893int32 textPos = 6;894int32 aliasStrPos = 0;895int32 parseMode = 0;896897while (parseMode < 2) {898if (parseMode) {899if (parseMode == 1) {900aliases[aliasCount].name[aliasStrPos] = text[textPos];901if (text[textPos]) {902aliasStrPos++;903}904else {905aliasStrPos = 0;906++parseMode;907}908}909}910else if (text[textPos] == ':') {911aliases[aliasCount].value[aliasStrPos] = 0;912aliasStrPos = 0;913parseMode = 1;914}915else {916aliases[aliasCount].value[aliasStrPos++] = text[textPos];917}918++textPos;919}920921++aliasCount;922}923void RSDK::Legacy::v3::ConvertArithmaticSyntax(char *text)924{925int32 token = 0;926int32 offset = 0;927int32 findID = 0;928char dest[260];929930for (int32 i = FUNC_EQUAL; i <= FUNC_MOD; ++i) {931findID = FindStringToken(text, scriptEvaluationTokens[i - 1], 1);932if (findID > -1) {933offset = findID;934token = i;935}936}937938if (token > 0) {939StrCopy(dest, functions[token].name);940StrAdd(dest, "(");941findID = StrLength(dest);942for (int32 i = 0; i < offset; ++i) dest[findID++] = text[i];943if (functions[token].opcodeSize > 1) {944dest[findID] = ',';945int32 len = StrLength(scriptEvaluationTokens[token - 1]);946offset += len;947++findID;948while (text[offset]) dest[findID++] = text[offset++];949}950dest[findID] = 0;951StrAdd(dest, ")");952StrCopy(text, dest);953}954}955void RSDK::Legacy::v3::ConvertIfWhileStatement(char *text)956{957char dest[260];958int32 compareOp = -1;959int32 strPos = 0;960int32 destStrPos = 0;961962if (FindStringToken(text, "if", 1) == 0) {963for (int32 i = 0; i < 6; ++i) {964destStrPos = FindStringToken(text, scriptEvaluationTokens[i + FUNC_MOD], 1);965if (destStrPos > -1) {966strPos = destStrPos;967compareOp = i;968}969}970971if (compareOp > -1) {972text[strPos] = ',';973974StrCopy(dest, functions[compareOp + FUNC_IFEQUAL].name);975StrAdd(dest, "(");976AppendIntegerToString(dest, jumpTablePos - jumpTableOffset);977StrAdd(dest, ",");978979destStrPos = StrLength(dest);980for (int32 i = 2; text[i]; ++i) {981if (text[i] != '=' && text[i] != '(' && text[i] != ')')982dest[destStrPos++] = text[i];983}984dest[destStrPos] = 0;985986StrAdd(dest, ")");987StrCopy(text, dest);988989jumpTableStack[++jumpTableStackPos] = jumpTablePos;990jumpTable[jumpTablePos++] = -1;991jumpTable[jumpTablePos++] = 0;992}993}994else if (FindStringToken(text, "while", 1) == 0) {995for (int32 i = 0; i < 6; ++i) {996destStrPos = FindStringToken(text, scriptEvaluationTokens[i + FUNC_MOD], 1);997if (destStrPos > -1) {998strPos = destStrPos;999compareOp = i;1000}1001}10021003if (compareOp > -1) {1004text[strPos] = ',';10051006StrCopy(dest, functions[compareOp + FUNC_WEQUAL].name);1007StrAdd(dest, "(");1008AppendIntegerToString(dest, jumpTablePos - jumpTableOffset);1009StrAdd(dest, ",");10101011destStrPos = StrLength(dest);1012for (int32 i = 5; text[i]; ++i) {1013if (text[i] != '=' && text[i] != '(' && text[i] != ')')1014dest[destStrPos++] = text[i];1015}1016dest[destStrPos] = 0;10171018StrAdd(dest, ")");1019StrCopy(text, dest);10201021jumpTableStack[++jumpTableStackPos] = jumpTablePos;1022jumpTable[jumpTablePos++] = scriptCodePos - scriptCodeOffset;1023jumpTable[jumpTablePos++] = 0;1024}1025}1026}1027bool32 RSDK::Legacy::v3::ConvertSwitchStatement(char *text)1028{1029if (FindStringToken(text, "switch", 1))1030return false;10311032char switchText[260];1033StrCopy(switchText, "switch");1034StrAdd(switchText, "(");1035AppendIntegerToString(switchText, jumpTablePos - jumpTableOffset);1036StrAdd(switchText, ",");1037int32 pos = StrLength(switchText);1038for (int32 i = 6; text[i]; ++i) {1039if (text[i] != '=' && text[i] != '(' && text[i] != ')')1040switchText[pos++] = text[i];1041}1042switchText[pos] = 0;1043StrAdd(switchText, ")");1044StrCopy(text, switchText);10451046jumpTableStack[++jumpTableStackPos] = jumpTablePos;1047jumpTable[jumpTablePos++] = 0x10000;1048jumpTable[jumpTablePos++] = -0x10000;1049jumpTable[jumpTablePos++] = -1;1050jumpTable[jumpTablePos++] = 0;10511052return true;1053}1054void RSDK::Legacy::v3::ConvertFunctionText(char *text)1055{1056char arrayStr[128];1057char funcName[132];1058int32 opcode = 0;1059int32 opcodeSize = 0;1060int32 textPos = 0;10611062int32 namePos = 0;1063for (namePos = 0; text[namePos] != '(' && text[namePos]; ++namePos) funcName[namePos] = text[namePos];1064funcName[namePos] = 0;10651066for (int32 i = 0; i < FUNC_MAX_CNT; ++i) {1067if (StrComp(funcName, functions[i].name)) {1068opcode = i;1069opcodeSize = functions[i].opcodeSize;1070textPos = StrLength(functions[i].name);1071i = FUNC_MAX_CNT;1072}1073}10741075if (opcode <= 0) {1076RSDK::PrintLog(PRINT_SCRIPTERR, "SCRIPT ERROR: Opcode not found\nOPCODE: %s\nLINE: %d\nFILE: %s", funcName, lineID, scriptFile);10771078gameMode = ENGINE_SCRIPTERROR;1079}1080else {1081scriptCode[scriptCodePos++] = opcode;1082if (StrComp("else", functions[opcode].name))1083jumpTable[jumpTableStack[jumpTableStackPos]] = scriptCodePos - scriptCodeOffset;10841085if (StrComp("endif", functions[opcode].name) == 1) {1086int32 jPos = jumpTableStack[jumpTableStackPos];1087jumpTable[jPos + 1] = scriptCodePos - scriptCodeOffset;1088if (jumpTable[jPos] == -1)1089jumpTable[jPos] = (scriptCodePos - scriptCodeOffset) - 1;1090--jumpTableStackPos;1091}10921093if (StrComp("endswitch", functions[opcode].name)) {1094int32 jPos = jumpTableStack[jumpTableStackPos];1095jumpTable[jPos + 3] = scriptCodePos - scriptCodeOffset;1096if (jumpTable[jPos + 2] == -1) {1097jumpTable[jPos + 2] = (scriptCodePos - scriptCodeOffset) - 1;1098int32 caseCnt = abs(jumpTable[jPos + 1] - jumpTable[jPos]) + 1;10991100int32 jOffset = jPos + 4;1101for (int32 c = 0; c < caseCnt; ++c) {1102if (jumpTable[jOffset + c] < 0)1103jumpTable[jOffset + c] = jumpTable[jPos + 2];1104}1105}1106--jumpTableStackPos;1107}11081109if (StrComp("loop", functions[opcode].name)) {1110jumpTable[jumpTableStack[jumpTableStackPos--] + 1] = scriptCodePos - scriptCodeOffset;1111}11121113for (int32 i = 0; i < opcodeSize; ++i) {1114++textPos;1115int32 varNamePos = 0;1116int32 parseMode = 0;1117int32 arrayStrPos = 0;11181119while (text[textPos] != ',' && text[textPos] != ')' && text[textPos]) {1120if (parseMode) {1121if (text[textPos] == ']')1122parseMode = 0;1123else1124arrayStr[arrayStrPos++] = text[textPos];1125++textPos;1126}1127else {1128if (text[textPos] == '[')1129parseMode = 1;1130else1131funcName[varNamePos++] = text[textPos];1132++textPos;1133}1134}1135funcName[varNamePos] = 0;1136arrayStr[arrayStrPos] = 0;11371138// Eg: TempValue0 = FX_SCALE1139for (int32 a = 0; a < aliasCount; ++a) {1140if (StrComp(funcName, aliases[a].name)) {1141CopyAliasStr(funcName, aliases[a].value, 0);1142if (FindStringToken(aliases[a].value, "[", 1) > -1)1143CopyAliasStr(arrayStr, aliases[a].value, 1);1144}1145}11461147// Eg: TempValue0 = Game.Variable1148for (int32 v = 0; v < globalVariablesCount; ++v) {1149if (StrComp(funcName, globalVariables[v].name)) {1150StrCopy(funcName, "Global");1151arrayStr[0] = 0;1152AppendIntegerToString(arrayStr, v);1153}1154}11551156// Eg: TempValue0 = Function11157for (int32 f = 0; f < scriptFunctionCount; ++f) {1158if (StrComp(funcName, scriptFunctionList[f].name)) {1159funcName[0] = 0;1160AppendIntegerToString(funcName, f);1161}1162}11631164// Eg: TempValue0 = TypeName[PlayerObject]1165if (StrComp(funcName, "TypeName")) {1166funcName[0] = '0';1167funcName[1] = 0;11681169for (int32 o = 0; o < LEGACY_v3_OBJECT_COUNT; ++o) {1170if (StrComp(arrayStr, typeNames[o])) {1171funcName[0] = 0;1172AppendIntegerToString(funcName, o);1173}1174}1175}11761177#if RETRO_USE_MOD_LOADER1178// Eg: TempValue0 = SfxName[Jump]1179if (StrComp(funcName, "SfxName")) {1180funcName[0] = '0';1181funcName[1] = 0;11821183int32 s = 0;1184for (; s < globalSFXCount; ++s) {1185if (StrComp(arrayStr, globalSfxNames[s])) {1186funcName[0] = 0;1187AppendIntegerToString(funcName, s);1188break;1189}1190}11911192if (s == globalSFXCount) {1193s = 0;1194for (; s < stageSFXCount; ++s) {1195if (StrComp(arrayStr, stageSfxNames[s])) {1196funcName[0] = 0;1197AppendIntegerToString(funcName, s);1198break;1199}1200}12011202if (s == stageSFXCount)1203PrintLog(PRINT_NORMAL, "WARNING: Unknown SfxName \"%s\"", arrayStr);1204}1205}12061207// Eg: TempValue0 = AchievementName[ACH_RING_KING]1208if (StrComp(funcName, "AchievementName")) {1209funcName[0] = '0';1210funcName[1] = 0;12111212int32 a = 0;1213for (; a < (int32)achievementList.size(); ++a) {1214char buf[0x40];1215const char *str = achievementList[a].identifier.c_str();1216int32 pos = 0;12171218while (*str) {1219if (*str != ' ')1220buf[pos++] = *str;1221str++;1222}1223buf[pos] = 0;12241225if (StrComp(arrayStr, buf)) {1226funcName[0] = 0;1227AppendIntegerToString(funcName, a);1228break;1229}1230}12311232if (a == (int32)achievementList.size())1233PrintLog(PRINT_NORMAL, "WARNING: Unknown AchievementName \"%s\"", arrayStr);1234}12351236// Eg: TempValue0 = PlayerName[SONIC]1237if (StrComp(funcName, "PlayerName")) {1238funcName[0] = '0';1239funcName[1] = 0;12401241int32 p = 0;1242for (; p < LEGACY_PLAYERNAME_COUNT; ++p) {1243char buf[0x40];1244char *str = modSettings.playerNames[p];1245int32 pos = 0;12461247while (*str) {1248if (*str != ' ')1249buf[pos++] = *str;1250str++;1251}1252buf[pos] = 0;12531254if (StrComp(arrayStr, buf)) {1255funcName[0] = 0;1256AppendIntegerToString(funcName, p);1257break;1258}1259}12601261if (p == LEGACY_PLAYERNAME_COUNT)1262PrintLog(PRINT_NORMAL, "WARNING: Unknown PlayerName \"%s\", on line %d", arrayStr, lineID);1263}12641265// Eg: TempValue0 = StageName[R - PALMTREE PANIC ZONE 1 A]1266if (StrComp(funcName, "StageName")) {1267funcName[0] = '0';1268funcName[1] = 0;12691270int32 s = -1;1271if (StrLength(arrayStr) >= 2) {1272char list = arrayStr[0];1273switch (list) {1274case 'P': list = STAGELIST_PRESENTATION; break;1275case 'R': list = STAGELIST_REGULAR; break;1276case 'B': list = STAGELIST_BONUS; break;1277case 'S': list = STAGELIST_SPECIAL; break;1278}1279if (list <= 3) {1280char scnName[0x40];1281int32 scnPos = 0;1282int32 pos = 0;1283const char *sceneName = &arrayStr[2];12841285while (sceneName[scnPos]) {1286if (sceneName[scnPos] != ' ')1287scnName[pos++] = sceneName[scnPos];1288++scnPos;1289}1290scnName[pos] = 0;1291SceneListInfo *listCat = &sceneInfo.listCategory[list];1292int32 l = listCat->sceneOffsetStart;1293for (int32 c = 0; c < listCat->sceneCount; ++c) {1294char nameBuffer[0x40];12951296scnPos = 0;1297pos = 0;1298while (sceneInfo.listData[l].name[scnPos]) {1299if (sceneInfo.listData[l].name[scnPos] != ' ')1300nameBuffer[pos++] = sceneInfo.listData[l].name[scnPos];1301++scnPos;1302}1303nameBuffer[pos] = 0;13041305if (StrComp(scnName, nameBuffer)) {1306s = c;1307break;1308}1309l++;1310}1311}1312}13131314if (s == -1) {1315PrintLog(PRINT_NORMAL, "WARNING: Unknown StageName \"%s\", on line %d", arrayStr, lineID);1316s = 0;1317}13181319funcName[0] = 0;1320AppendIntegerToString(funcName, s);1321}1322#endif13231324int32 constant = 0;1325if (ConvertStringToInteger(funcName, &constant)) {1326scriptCode[scriptCodePos++] = SCRIPTVAR_INTCONST;1327scriptCode[scriptCodePos++] = constant;1328}1329else if (funcName[0] == '"') {1330scriptCode[scriptCodePos++] = SCRIPTVAR_STRCONST;1331scriptCode[scriptCodePos++] = StrLength(funcName) - 2;13321333int32 scriptTextPos = 1;1334arrayStrPos = 0;1335while (scriptTextPos > -1) {1336switch (arrayStrPos) {1337case 0:1338scriptCode[scriptCodePos] = funcName[scriptTextPos] << 24;1339++arrayStrPos;1340break;13411342case 1:1343scriptCode[scriptCodePos] += funcName[scriptTextPos] << 16;1344++arrayStrPos;1345break;13461347case 2:1348scriptCode[scriptCodePos] += funcName[scriptTextPos] << 8;1349++arrayStrPos;1350break;13511352case 3:1353scriptCode[scriptCodePos++] += funcName[scriptTextPos];1354arrayStrPos = 0;1355break;13561357default: break;1358}13591360if (funcName[scriptTextPos] == '"') {1361if (arrayStrPos > 0)1362++scriptCodePos;1363scriptTextPos = -1;1364}1365else {1366scriptTextPos++;1367}1368}1369}1370else {1371scriptCode[scriptCodePos++] = SCRIPTVAR_VAR;1372if (arrayStr[0]) {1373scriptCode[scriptCodePos] = VARARR_ARRAY;13741375if (arrayStr[0] == '+')1376scriptCode[scriptCodePos] = VARARR_ENTNOPLUS1;13771378if (arrayStr[0] == '-')1379scriptCode[scriptCodePos] = VARARR_ENTNOMINUS1;13801381++scriptCodePos;13821383if (arrayStr[0] == '-' || arrayStr[0] == '+') {1384for (int32 i = 0; i < StrLength(arrayStr); ++i) arrayStr[i] = arrayStr[i + 1];1385}13861387if (ConvertStringToInteger(arrayStr, &constant)) {1388scriptCode[scriptCodePos++] = 0;1389scriptCode[scriptCodePos++] = constant;1390}1391else {1392if (StrComp(arrayStr, "ArrayPos0"))1393constant = 0;1394if (StrComp(arrayStr, "ArrayPos1"))1395constant = 1;1396if (StrComp(arrayStr, "TempObjectPos"))1397constant = 2;13981399scriptCode[scriptCodePos++] = 1;1400scriptCode[scriptCodePos++] = constant;1401}1402}1403else {1404scriptCode[scriptCodePos++] = VARARR_NONE;1405}14061407constant = -1;1408for (int32 i = 0; i < VAR_MAX_CNT; ++i) {1409if (StrComp(funcName, variableNames[i]))1410constant = i;1411}14121413if (constant == -1 && gameMode != ENGINE_SCRIPTERROR) {1414PrintLog(PRINT_SCRIPTERR, "SCRIPT ERROR: Operand not found\nOPERAND: %s\nLINE: %d\nFILE: %s", funcName, lineID, scriptFile);14151416gameMode = ENGINE_SCRIPTERROR;1417constant = 0;1418}14191420scriptCode[scriptCodePos++] = constant;1421}1422}1423}1424}1425void RSDK::Legacy::v3::CheckCaseNumber(char *text)1426{1427if (FindStringToken(text, "case", 1) != 0)1428return;14291430char caseString[128];1431char caseChar = text[4];14321433int32 textPos = 5;1434int32 caseStrPos = 0;1435while (caseChar) {1436if (caseChar != ':')1437caseString[caseStrPos++] = caseChar;1438caseChar = text[textPos++];1439}1440caseString[caseStrPos] = 0;14411442for (int32 a = 0; a < aliasCount; ++a) {1443if (StrComp(aliases[a].name, caseString)) {1444StrCopy(caseString, aliases[a].value);1445break;1446}1447}14481449int32 caseID = 0;1450if (ConvertStringToInteger(caseString, &caseID)) {1451int32 stackValue = jumpTableStack[jumpTableStackPos];1452if (caseID < jumpTable[stackValue])1453jumpTable[stackValue] = caseID;1454stackValue++;1455if (caseID > jumpTable[stackValue])1456jumpTable[stackValue] = caseID;1457}1458else {1459PrintLog(PRINT_SCRIPTERR, "SCRIPT ERROR: Invalid switch case\nOPCODE: %s\nLINE: %d\nFILE: %s", caseString, lineID, scriptFile);1460gameMode = ENGINE_SCRIPTERROR;1461}1462}1463bool32 RSDK::Legacy::v3::ReadSwitchCase(char *text)1464{1465char caseText[0x80];1466if (FindStringToken(text, "case", 1) == 0) {1467int32 textPos = 4;1468int32 caseStringPos = 0;1469while (text[textPos]) {1470if (text[textPos] != ':')1471caseText[caseStringPos++] = text[textPos];1472++textPos;1473}1474caseText[caseStringPos] = 0;1475for (int32 a = 0; a < aliasCount; ++a) {1476if (StrComp(caseText, aliases[a].name))1477StrCopy(caseText, aliases[a].value);1478}14791480int32 val = 0;14811482int32 jPos = jumpTableStack[jumpTableStackPos];1483int32 jOffset = jPos + 4;1484if (ConvertStringToInteger(caseText, &val))1485jumpTable[val - jumpTable[jPos] + jOffset] = scriptCodePos - scriptCodeOffset;1486return true;1487}1488else if (FindStringToken(text, "default", 1) == 0) {1489int32 jumpTablepos = jumpTableStack[jumpTableStackPos];1490jumpTable[jumpTablepos + 2] = scriptCodePos - scriptCodeOffset;1491int32 cnt = abs(jumpTable[jumpTablepos + 1] - jumpTable[jumpTablepos]) + 1;14921493int32 jOffset = jumpTablepos + 4;1494for (int32 i = 0; i < cnt; ++i) {1495if (jumpTable[jOffset + i] < 0)1496jumpTable[jOffset + i] = scriptCodePos - scriptCodeOffset;1497}1498return true;1499}15001501return false;1502}1503void RSDK::Legacy::v3::AppendIntegerToString(char *text, int32 value)1504{1505int32 textPos = 0;1506while (text[textPos]) {1507++textPos;1508}15091510int32 cnt = 0;1511int32 v = value;1512while (v != 0) {1513v /= 10;1514cnt++;1515}15161517v = 0;1518for (int32 i = cnt - 1; i >= 0; --i) {1519v = (int32)(value / pow(10, i));1520v %= 10;15211522int32 strValue = v + '0';1523if (strValue < '0' || strValue > '9') {1524// what1525}1526text[textPos++] = strValue;1527}1528if (value == 0)1529text[textPos++] = '0';1530text[textPos] = 0;1531}1532void RSDK::Legacy::v3::CopyAliasStr(char *dest, char *text, bool32 arrayIndex)1533{1534int32 textPos = 0;1535int32 destPos = 0;1536bool32 arrayValue = false;15371538if (arrayIndex) {1539while (text[textPos]) {1540if (arrayValue) {1541if (text[textPos] == ']')1542arrayValue = false;1543else1544dest[destPos++] = text[textPos];1545++textPos;1546}1547else {1548if (text[textPos] == '[')1549arrayValue = true;1550++textPos;1551}1552}1553}1554else {1555while (text[textPos]) {1556if (arrayValue) {1557if (text[textPos] == ']')1558arrayValue = false;1559++textPos;1560}1561else {1562if (text[textPos] == '[')1563arrayValue = true;1564else1565dest[destPos++] = text[textPos];1566++textPos;1567}1568}1569}1570dest[destPos] = 0;1571}1572bool32 RSDK::Legacy::v3::CheckOpcodeType(char *text)1573{1574while (*text) {1575if (*text++ == '(')1576return false;1577}1578return true;1579}15801581void RSDK::Legacy::v3::ParseScriptFile(char *scriptName, int32 scriptID)1582{1583jumpTableStackPos = 0;1584lineID = 0;1585aliasCount = LEGACY_v3_COMMONALIAS_COUNT;1586for (int32 i = LEGACY_v3_COMMONALIAS_COUNT; i < LEGACY_v3_ALIAS_COUNT; ++i) {1587StrCopy(aliases[i].name, "");1588StrCopy(aliases[i].value, "");1589}15901591scriptFile = scriptName;15921593char scriptPath[0x40];1594StrCopy(scriptPath, "Data/Scripts/");1595StrAdd(scriptPath, scriptName);15961597FileInfo info;1598InitFileInfo(&info);15991600if (LoadFile(&info, scriptPath, FMODE_RB)) {1601int32 readMode = READMODE_NORMAL;1602int32 parseMode = PARSEMODE_SCOPELESS;1603int32 storedPos = 0;1604char prevChar = 0;1605char curChar = 0;1606int32 switchDeep = 0;16071608while (readMode < READMODE_EOF) {1609int32 textPos = 0;1610readMode = READMODE_NORMAL;1611while (readMode < READMODE_ENDLINE) {1612prevChar = curChar;1613curChar = ReadInt8(&info);16141615if (readMode == READMODE_STRING) {1616if (curChar == '\t' || curChar == '\r' || curChar == '\n' || curChar == ';' || readMode >= READMODE_COMMENTLINE) {1617if ((curChar == '\n' && prevChar != '\r') || (curChar == '\n' && prevChar == '\r')) {1618readMode = READMODE_ENDLINE;1619scriptText[textPos] = 0;1620}1621}1622else if (curChar != '/' || textPos <= 0) {1623scriptText[textPos++] = curChar;1624if (curChar == '"')1625readMode = READMODE_NORMAL;1626}1627else if (curChar == '/' && prevChar == '/') {1628readMode = READMODE_COMMENTLINE;1629scriptText[--textPos] = 0;1630}1631else {1632scriptText[textPos++] = curChar;1633}1634}1635else if (curChar == ' ' || curChar == '\t' || curChar == '\r' || curChar == '\n' || curChar == ';'1636|| readMode >= READMODE_COMMENTLINE) {1637if ((curChar == '\n' && prevChar != '\r') || (curChar == '\n' && prevChar == '\r')) {1638readMode = READMODE_ENDLINE;1639scriptText[textPos] = 0;1640}1641}1642else if (curChar != '/' || textPos <= 0) {1643scriptText[textPos++] = curChar;1644if (curChar == '"' && !readMode)1645readMode = READMODE_STRING;1646}1647else if (curChar == '/' && prevChar == '/') {1648readMode = READMODE_COMMENTLINE;1649scriptText[--textPos] = 0;1650}1651else {1652scriptText[textPos++] = curChar;1653}16541655if (info.readPos >= info.fileSize) {1656scriptText[textPos] = 0;1657readMode = READMODE_EOF;1658}1659}16601661switch (parseMode) {1662case PARSEMODE_SCOPELESS:1663++lineID;16641665CheckAliasText(scriptText);16661667if (StrComp(scriptText, "subObjectMain")) {1668parseMode = PARSEMODE_FUNCTION;1669objectScriptList[scriptID].subMain.scriptCodePtr = scriptCodePos;1670objectScriptList[scriptID].subMain.jumpTablePtr = jumpTablePos;1671scriptCodeOffset = scriptCodePos;1672jumpTableOffset = jumpTablePos;1673}16741675if (StrComp(scriptText, "subObjectPlayerInteraction")) {1676parseMode = PARSEMODE_FUNCTION;1677objectScriptList[scriptID].subPlayerInteraction.scriptCodePtr = scriptCodePos;1678objectScriptList[scriptID].subPlayerInteraction.jumpTablePtr = jumpTablePos;1679scriptCodeOffset = scriptCodePos;1680jumpTableOffset = jumpTablePos;1681}16821683if (StrComp(scriptText, "subObjectDraw")) {1684parseMode = PARSEMODE_FUNCTION;1685objectScriptList[scriptID].subDraw.scriptCodePtr = scriptCodePos;1686objectScriptList[scriptID].subDraw.jumpTablePtr = jumpTablePos;1687scriptCodeOffset = scriptCodePos;1688jumpTableOffset = jumpTablePos;1689}16901691if (StrComp(scriptText, "subObjectStartup")) {1692parseMode = PARSEMODE_FUNCTION;1693objectScriptList[scriptID].subStartup.scriptCodePtr = scriptCodePos;1694objectScriptList[scriptID].subStartup.jumpTablePtr = jumpTablePos;1695scriptCodeOffset = scriptCodePos;1696jumpTableOffset = jumpTablePos;1697}16981699if (FindStringToken(scriptText, "function", 1) == 0) { // regular decl.1700char funcName[0x20];1701for (textPos = 8; scriptText[textPos]; ++textPos) funcName[textPos - 8] = scriptText[textPos];1702funcName[textPos - 8] = 0;17031704int32 funcID = -1;1705for (int32 f = 0; f < scriptFunctionCount; ++f) {1706if (StrComp(funcName, scriptFunctionList[f].name))1707funcID = f;1708}17091710if (funcID <= -1) {1711if (scriptFunctionCount >= LEGACY_v3_FUNCTION_COUNT) {1712parseMode = PARSEMODE_SCOPELESS;1713}1714else {1715StrCopy(scriptFunctionList[scriptFunctionCount].name, funcName);1716scriptFunctionList[scriptFunctionCount].ptr.scriptCodePtr = scriptCodePos;1717scriptFunctionList[scriptFunctionCount].ptr.jumpTablePtr = jumpTablePos;1718scriptCodeOffset = scriptCodePos;1719jumpTableOffset = jumpTablePos;1720parseMode = PARSEMODE_FUNCTION;1721++scriptFunctionCount;1722}1723}1724else {1725StrCopy(scriptFunctionList[funcID].name, funcName);1726scriptFunctionList[funcID].ptr.scriptCodePtr = scriptCodePos;1727scriptFunctionList[funcID].ptr.jumpTablePtr = jumpTablePos;1728scriptCodeOffset = scriptCodePos;1729jumpTableOffset = jumpTablePos;1730parseMode = PARSEMODE_FUNCTION;1731}1732}1733else if (FindStringToken(scriptText, "function", 1) == 1) { // forward decl.1734char funcName[0x20];1735for (textPos = 9; scriptText[textPos]; ++textPos) funcName[textPos - 9] = scriptText[textPos];1736funcName[textPos - 9] = 0;17371738int32 funcID = -1;1739for (int32 f = 0; f < scriptFunctionCount; ++f) {1740if (StrComp(funcName, scriptFunctionList[f].name))1741funcID = f;1742}17431744if (scriptFunctionCount < LEGACY_v3_FUNCTION_COUNT && funcID == -1) {1745StrCopy(scriptFunctionList[scriptFunctionCount++].name, funcName);1746}17471748parseMode = PARSEMODE_SCOPELESS;1749}1750break;17511752case PARSEMODE_PLATFORMSKIP:1753++lineID;17541755if (FindStringToken(scriptText, "#endplatform", 1) == 0)1756parseMode = PARSEMODE_FUNCTION;1757break;17581759case PARSEMODE_FUNCTION:1760++lineID;17611762if (scriptText[0]) {1763if (StrComp(scriptText, "endsub")) {1764scriptCode[scriptCodePos++] = FUNC_END;1765parseMode = PARSEMODE_SCOPELESS;1766}1767else if (StrComp(scriptText, "endfunction")) {1768scriptCode[scriptCodePos++] = FUNC_ENDFUNCTION;1769parseMode = PARSEMODE_SCOPELESS;1770}1771else if (FindStringToken(scriptText, "#platform:", 1) == 0) {1772if (FindStringToken(scriptText, engine.gamePlatform, 1) == -11773&& FindStringToken(scriptText, engine.gameRenderType, 1) == -11774#if LEGACY_RETRO_USE_HAPTICS1775&& FindStringToken(scriptText, engine.gameHapticSetting, 1) == -11776#endif1777#if !RETRO_USE_ORIGINAL_CODE1778&& FindStringToken(scriptText, engine.releaseType, 1) == -1 // general flag for new stuff origins added1779#endif1780#if !RETRO_USE_ORIGINAL_CODE1781&& FindStringToken(scriptText, "Use_Decomp", 1) == -11782#endif1783#if RETRO_USE_MOD_LOADER1784&& FindStringToken(scriptText, "Use_Mod_Loader", 1) == -11785#endif1786) { // if NONE of these checks succeeded, then we skip everything until "end platform"1787parseMode = PARSEMODE_PLATFORMSKIP;1788}1789}1790else if (FindStringToken(scriptText, "#endplatform", 1) == -1) {1791ConvertIfWhileStatement(scriptText);17921793if (ConvertSwitchStatement(scriptText)) {1794parseMode = PARSEMODE_SWITCHREAD;1795storedPos = (int32)info.readPos;1796switchDeep = 0;1797}17981799ConvertArithmaticSyntax(scriptText);18001801if (!ReadSwitchCase(scriptText)) {1802ConvertFunctionText(scriptText);18031804if (gameMode == ENGINE_SCRIPTERROR) {1805parseMode = PARSEMODE_ERROR;1806}1807}1808}1809}1810break;18111812case PARSEMODE_SWITCHREAD:1813if (FindStringToken(scriptText, "switch", 1) == 0)1814++switchDeep;18151816if (switchDeep) {1817if (FindStringToken(scriptText, "endswitch", 1) == 0)1818--switchDeep;1819}1820else if (FindStringToken(scriptText, "endswitch", 1) == 0) {1821Seek_Set(&info, storedPos);1822parseMode = PARSEMODE_FUNCTION;1823int32 jPos = jumpTableStack[jumpTableStackPos];1824switchDeep = abs(jumpTable[jPos + 1] - jumpTable[jPos]) + 1;1825for (textPos = 0; textPos < switchDeep; ++textPos) jumpTable[jumpTablePos++] = -1;1826}1827else {1828CheckCaseNumber(scriptText);1829}1830break;18311832default: break;1833}1834}18351836CloseFile(&info);1837}1838}1839#endif18401841void RSDK::Legacy::v3::LoadBytecode(int32 scriptID, bool32 globalCode)1842{1843char scriptPath[0x40];1844if (globalCode) {1845StrCopy(scriptPath, "Data/Scripts/Bytecode/GlobalCode.bin");1846}1847else {1848StrCopy(scriptPath, "Data/Scripts/Bytecode/");1849StrAdd(scriptPath, sceneInfo.listData[sceneInfo.listPos].folder);1850StrAdd(scriptPath, ".bin");1851}18521853FileInfo info;1854InitFileInfo(&info);1855if (LoadFile(&info, scriptPath, FMODE_RB)) {1856int32 *scriptCodePtr = &scriptCode[scriptCodePos];1857int32 *jumpTablePtr = &jumpTable[jumpTablePos];18581859int32 scriptCodeSize = ReadInt8(&info);1860scriptCodeSize |= ReadInt8(&info) << 8;1861scriptCodeSize |= ReadInt8(&info) << 16;1862scriptCodeSize |= ReadInt8(&info) << 24;18631864while (scriptCodeSize > 0) {1865int32 fileBuffer = ReadInt8(&info);1866int32 blockSize = fileBuffer & 0x7F;18671868if (fileBuffer >= 0x80) {1869while (blockSize > 0) {1870*scriptCodePtr = ReadInt8(&info);1871*scriptCodePtr |= ReadInt8(&info) << 8;1872*scriptCodePtr |= ReadInt8(&info) << 16;1873*scriptCodePtr |= ReadInt8(&info) << 24;18741875++scriptCodePtr;1876++scriptCodePos;1877--scriptCodeSize;1878--blockSize;1879}1880}1881else {1882while (blockSize > 0) {1883*scriptCodePtr = ReadInt8(&info);18841885++scriptCodePtr;1886++scriptCodePos;1887--scriptCodeSize;1888--blockSize;1889}1890}1891}18921893int32 jumpTableSize = ReadInt8(&info);1894jumpTableSize |= ReadInt8(&info) << 8;1895jumpTableSize |= ReadInt8(&info) << 16;1896jumpTableSize |= ReadInt8(&info) << 24;18971898while (jumpTableSize > 0) {1899int32 fileBuffer = ReadInt8(&info);1900int32 blockSize = fileBuffer & 0x7F;19011902if (fileBuffer >= 0x80) {1903while (blockSize > 0) {1904*jumpTablePtr = ReadInt8(&info);1905*jumpTablePtr |= ReadInt8(&info) << 8;1906*jumpTablePtr |= ReadInt8(&info) << 16;1907*jumpTablePtr |= ReadInt8(&info) << 24;19081909++jumpTablePtr;1910++jumpTablePos;1911--jumpTableSize;1912--blockSize;1913}1914}1915else {1916while (blockSize > 0) {1917*jumpTablePtr = ReadInt8(&info);19181919++jumpTablePtr;1920++jumpTablePos;1921--jumpTableSize;1922--blockSize;1923}1924}1925}19261927int32 scriptCount = ReadInt8(&info);1928scriptCount |= ReadInt8(&info) << 8;19291930for (int32 s = 0; s < scriptCount; ++s) {1931ObjectScript *script = &objectScriptList[scriptID + s];19321933script->subMain.scriptCodePtr = ReadInt8(&info);1934script->subMain.scriptCodePtr |= ReadInt8(&info) << 8;1935script->subMain.scriptCodePtr |= ReadInt8(&info) << 16;1936script->subMain.scriptCodePtr |= ReadInt8(&info) << 24;19371938script->subPlayerInteraction.scriptCodePtr = ReadInt8(&info);1939script->subPlayerInteraction.scriptCodePtr |= ReadInt8(&info) << 8;1940script->subPlayerInteraction.scriptCodePtr |= ReadInt8(&info) << 16;1941script->subPlayerInteraction.scriptCodePtr |= ReadInt8(&info) << 24;19421943script->subDraw.scriptCodePtr = ReadInt8(&info);1944script->subDraw.scriptCodePtr |= ReadInt8(&info) << 8;1945script->subDraw.scriptCodePtr |= ReadInt8(&info) << 16;1946script->subDraw.scriptCodePtr |= ReadInt8(&info) << 24;19471948script->subStartup.scriptCodePtr = ReadInt8(&info);1949script->subStartup.scriptCodePtr |= ReadInt8(&info) << 8;1950script->subStartup.scriptCodePtr |= ReadInt8(&info) << 16;1951script->subStartup.scriptCodePtr |= ReadInt8(&info) << 24;1952}19531954for (int32 s = 0; s < scriptCount; ++s) {1955ObjectScript *script = &objectScriptList[scriptID + s];19561957script->subMain.jumpTablePtr = ReadInt8(&info);1958script->subMain.jumpTablePtr |= ReadInt8(&info) << 8;1959script->subMain.jumpTablePtr |= ReadInt8(&info) << 16;1960script->subMain.jumpTablePtr |= ReadInt8(&info) << 24;19611962script->subPlayerInteraction.jumpTablePtr = ReadInt8(&info);1963script->subPlayerInteraction.jumpTablePtr |= ReadInt8(&info) << 8;1964script->subPlayerInteraction.jumpTablePtr |= ReadInt8(&info) << 16;1965script->subPlayerInteraction.jumpTablePtr |= ReadInt8(&info) << 24;19661967script->subDraw.jumpTablePtr = ReadInt8(&info);1968script->subDraw.jumpTablePtr |= ReadInt8(&info) << 8;1969script->subDraw.jumpTablePtr |= ReadInt8(&info) << 16;1970script->subDraw.jumpTablePtr |= ReadInt8(&info) << 24;19711972script->subStartup.jumpTablePtr = ReadInt8(&info);1973script->subStartup.jumpTablePtr |= ReadInt8(&info) << 8;1974script->subStartup.jumpTablePtr |= ReadInt8(&info) << 16;1975script->subStartup.jumpTablePtr |= ReadInt8(&info) << 24;1976}19771978int32 functionCount = ReadInt8(&info);1979functionCount |= ReadInt8(&info) << 8;19801981for (int32 f = 0; f < functionCount; ++f) {1982ScriptFunction *function = &scriptFunctionList[f];19831984function->ptr.scriptCodePtr = ReadInt8(&info);1985function->ptr.scriptCodePtr |= ReadInt8(&info) << 8;1986function->ptr.scriptCodePtr |= ReadInt8(&info) << 16;1987function->ptr.scriptCodePtr |= ReadInt8(&info) << 24;1988}19891990for (int32 f = 0; f < functionCount; ++f) {1991ScriptFunction *function = &scriptFunctionList[f];19921993function->ptr.jumpTablePtr = ReadInt8(&info);1994function->ptr.jumpTablePtr |= ReadInt8(&info) << 8;1995function->ptr.jumpTablePtr |= ReadInt8(&info) << 16;1996function->ptr.jumpTablePtr |= ReadInt8(&info) << 24;1997}19981999CloseFile(&info);2000}2001}20022003void RSDK::Legacy::v3::ClearScriptData()2004{2005memset(scriptCode, 0, LEGACY_v3_SCRIPTDATA_COUNT * sizeof(int32));2006memset(jumpTable, 0, LEGACY_v3_JUMPTABLE_COUNT * sizeof(int32));20072008scriptFrameCount = 0;20092010scriptCodePos = 0;2011jumpTablePos = 0;2012jumpTableStackPos = 0;2013functionStackPos = 0;20142015scriptCodePos = 0;2016scriptCodeOffset = 0;2017jumpTablePos = 0;2018jumpTableOffset = 0;20192020#if LEGACY_RETRO_USE_COMPILER2021scriptFunctionCount = 0;2022#endif20232024aliasCount = LEGACY_v3_COMMONALIAS_COUNT;2025lineID = 0;20262027ClearGraphicsData();2028ClearAnimationData();20292030for (int32 p = 0; p < LEGACY_v3_PLAYER_COUNT; ++p) {2031playerList[p].animationFile = GetDefaultAnimationRef();2032playerList[p].boundEntity = &objectEntityList[p];2033}20342035for (int32 o = 0; o < LEGACY_v3_OBJECT_COUNT; ++o) {2036ObjectScript *scriptInfo = &objectScriptList[o];2037scriptInfo->subMain.scriptCodePtr = LEGACY_v3_SCRIPTDATA_COUNT - 1;2038scriptInfo->subMain.jumpTablePtr = LEGACY_v3_JUMPTABLE_COUNT - 1;2039scriptInfo->subPlayerInteraction.scriptCodePtr = LEGACY_v3_SCRIPTDATA_COUNT - 1;2040scriptInfo->subPlayerInteraction.jumpTablePtr = LEGACY_v3_JUMPTABLE_COUNT - 1;2041scriptInfo->subDraw.scriptCodePtr = LEGACY_v3_SCRIPTDATA_COUNT - 1;2042scriptInfo->subDraw.jumpTablePtr = LEGACY_v3_JUMPTABLE_COUNT - 1;2043scriptInfo->subStartup.scriptCodePtr = LEGACY_v3_SCRIPTDATA_COUNT - 1;2044scriptInfo->subStartup.jumpTablePtr = LEGACY_v3_JUMPTABLE_COUNT - 1;2045scriptInfo->frameListOffset = 0;2046scriptInfo->spriteSheetID = 0;2047scriptInfo->animFile = GetDefaultAnimationRef();2048typeNames[o][0] = 0;2049}20502051for (int32 f = 0; f < LEGACY_v3_FUNCTION_COUNT; ++f) {2052scriptFunctionList[f].ptr.scriptCodePtr = LEGACY_v3_SCRIPTDATA_COUNT - 1;2053scriptFunctionList[f].ptr.jumpTablePtr = LEGACY_v3_JUMPTABLE_COUNT - 1;2054}20552056SetObjectTypeName((char *)"Blank Object", 0);2057}20582059void RSDK::Legacy::v3::ProcessScript(int32 scriptCodeStart, int32 jumpTableStart, uint8 scriptSub)2060{2061bool running = true;2062int32 scriptCodePtr = scriptCodeStart;20632064jumpTableStackPos = 0;2065functionStackPos = 0;2066while (running) {2067int32 opcode = scriptCode[scriptCodePtr++];2068int32 opcodeSize = functions[opcode].opcodeSize;2069int32 scriptCodeOffset = scriptCodePtr;20702071// Get Values2072for (int32 i = 0; i < opcodeSize; ++i) {2073int32 opcodeType = scriptCode[scriptCodePtr++];20742075if (opcodeType == SCRIPTVAR_VAR) {2076int32 arrayVal = 0;2077switch (scriptCode[scriptCodePtr++]) {2078case VARARR_NONE: arrayVal = objectLoop; break;2079case VARARR_ARRAY:2080if (scriptCode[scriptCodePtr++] == 1)2081arrayVal = scriptEng.arrayPosition[scriptCode[scriptCodePtr++]];2082else2083arrayVal = scriptCode[scriptCodePtr++];2084break;2085case VARARR_ENTNOPLUS1:2086if (scriptCode[scriptCodePtr++] == 1)2087arrayVal = scriptEng.arrayPosition[scriptCode[scriptCodePtr++]] + objectLoop;2088else2089arrayVal = scriptCode[scriptCodePtr++] + objectLoop;2090break;2091case VARARR_ENTNOMINUS1:2092if (scriptCode[scriptCodePtr++] == 1)2093arrayVal = objectLoop - scriptEng.arrayPosition[scriptCode[scriptCodePtr++]];2094else2095arrayVal = objectLoop - scriptCode[scriptCodePtr++];2096break;2097default: break;2098}20992100// Variables2101switch (scriptCode[scriptCodePtr++]) {2102default: break;2103case VAR_TEMPVALUE0: scriptEng.operands[i] = scriptEng.tempValue[0]; break;2104case VAR_TEMPVALUE1: scriptEng.operands[i] = scriptEng.tempValue[1]; break;2105case VAR_TEMPVALUE2: scriptEng.operands[i] = scriptEng.tempValue[2]; break;2106case VAR_TEMPVALUE3: scriptEng.operands[i] = scriptEng.tempValue[3]; break;2107case VAR_TEMPVALUE4: scriptEng.operands[i] = scriptEng.tempValue[4]; break;2108case VAR_TEMPVALUE5: scriptEng.operands[i] = scriptEng.tempValue[5]; break;2109case VAR_TEMPVALUE6: scriptEng.operands[i] = scriptEng.tempValue[6]; break;2110case VAR_TEMPVALUE7: scriptEng.operands[i] = scriptEng.tempValue[7]; break;2111case VAR_CHECKRESULT: scriptEng.operands[i] = scriptEng.checkResult; break;2112case VAR_ARRAYPOS0: scriptEng.operands[i] = scriptEng.arrayPosition[0]; break;2113case VAR_ARRAYPOS1: scriptEng.operands[i] = scriptEng.arrayPosition[1]; break;2114case VAR_GLOBAL: scriptEng.operands[i] = globalVariables[arrayVal].value; break;2115case VAR_OBJECTENTITYNO: scriptEng.operands[i] = arrayVal; break;2116case VAR_OBJECTTYPE: {2117scriptEng.operands[i] = objectEntityList[arrayVal].type;2118break;2119}2120case VAR_OBJECTPROPERTYVALUE: {2121scriptEng.operands[i] = objectEntityList[arrayVal].propertyValue;2122break;2123}2124case VAR_OBJECTXPOS: {2125scriptEng.operands[i] = objectEntityList[arrayVal].XPos;2126break;2127}2128case VAR_OBJECTYPOS: {2129scriptEng.operands[i] = objectEntityList[arrayVal].YPos;2130break;2131}2132case VAR_OBJECTIXPOS: {2133scriptEng.operands[i] = objectEntityList[arrayVal].XPos >> 16;2134break;2135}2136case VAR_OBJECTIYPOS: {2137scriptEng.operands[i] = objectEntityList[arrayVal].YPos >> 16;2138break;2139}2140case VAR_OBJECTSTATE: {2141scriptEng.operands[i] = objectEntityList[arrayVal].state;2142break;2143}2144case VAR_OBJECTROTATION: {2145scriptEng.operands[i] = objectEntityList[arrayVal].rotation;2146break;2147}2148case VAR_OBJECTSCALE: {2149scriptEng.operands[i] = objectEntityList[arrayVal].scale;2150break;2151}2152case VAR_OBJECTPRIORITY: {2153scriptEng.operands[i] = objectEntityList[arrayVal].priority;2154break;2155}2156case VAR_OBJECTDRAWORDER: {2157scriptEng.operands[i] = objectEntityList[arrayVal].drawOrder;2158break;2159}2160case VAR_OBJECTDIRECTION: {2161scriptEng.operands[i] = objectEntityList[arrayVal].direction;2162break;2163}2164case VAR_OBJECTINKEFFECT: {2165scriptEng.operands[i] = objectEntityList[arrayVal].inkEffect;2166break;2167}2168case VAR_OBJECTALPHA: {2169scriptEng.operands[i] = objectEntityList[arrayVal].alpha;2170break;2171}2172case VAR_OBJECTFRAME: {2173scriptEng.operands[i] = objectEntityList[arrayVal].frame;2174break;2175}2176case VAR_OBJECTANIMATION: {2177scriptEng.operands[i] = objectEntityList[arrayVal].animation;2178break;2179}2180case VAR_OBJECTPREVANIMATION: {2181scriptEng.operands[i] = objectEntityList[arrayVal].prevAnimation;2182break;2183}2184case VAR_OBJECTANIMATIONSPEED: {2185scriptEng.operands[i] = objectEntityList[arrayVal].animationSpeed;2186break;2187}2188case VAR_OBJECTANIMATIONTIMER: {2189scriptEng.operands[i] = objectEntityList[arrayVal].animationTimer;2190break;2191}2192case VAR_OBJECTVALUE0: {2193scriptEng.operands[i] = objectEntityList[arrayVal].values[0];2194break;2195}2196case VAR_OBJECTVALUE1: {2197scriptEng.operands[i] = objectEntityList[arrayVal].values[1];2198break;2199}2200case VAR_OBJECTVALUE2: {2201scriptEng.operands[i] = objectEntityList[arrayVal].values[2];2202break;2203}2204case VAR_OBJECTVALUE3: {2205scriptEng.operands[i] = objectEntityList[arrayVal].values[3];2206break;2207}2208case VAR_OBJECTVALUE4: {2209scriptEng.operands[i] = objectEntityList[arrayVal].values[4];2210break;2211}2212case VAR_OBJECTVALUE5: {2213scriptEng.operands[i] = objectEntityList[arrayVal].values[5];2214break;2215}2216case VAR_OBJECTVALUE6: {2217scriptEng.operands[i] = objectEntityList[arrayVal].values[6];2218break;2219}2220case VAR_OBJECTVALUE7: {2221scriptEng.operands[i] = objectEntityList[arrayVal].values[7];2222break;2223}2224case VAR_OBJECTOUTOFBOUNDS: {2225int32 pos = objectEntityList[arrayVal].XPos >> 16;2226if (pos <= xScrollOffset - OBJECT_BORDER_X1 || pos >= OBJECT_BORDER_X2 + xScrollOffset) {2227scriptEng.operands[i] = 1;2228}2229else {2230int32 pos = objectEntityList[arrayVal].YPos >> 16;2231scriptEng.operands[i] = pos <= yScrollOffset - OBJECT_BORDER_Y1 || pos >= yScrollOffset + OBJECT_BORDER_Y2;2232}2233break;2234}2235case VAR_PLAYERSTATE: {2236scriptEng.operands[i] = playerList[activePlayer].boundEntity->state;2237break;2238}2239case VAR_PLAYERCONTROLMODE: {2240scriptEng.operands[i] = playerList[activePlayer].controlMode;2241break;2242}2243case VAR_PLAYERCONTROLLOCK: {2244scriptEng.operands[i] = playerList[activePlayer].controlLock;2245break;2246}2247case VAR_PLAYERCOLLISIONMODE: {2248scriptEng.operands[i] = playerList[activePlayer].collisionMode;2249break;2250}2251case VAR_PLAYERCOLLISIONPLANE: {2252scriptEng.operands[i] = playerList[activePlayer].collisionPlane;2253break;2254}2255case VAR_PLAYERXPOS: {2256scriptEng.operands[i] = playerList[activePlayer].XPos;2257break;2258}2259case VAR_PLAYERYPOS: {2260scriptEng.operands[i] = playerList[activePlayer].YPos;2261break;2262}2263case VAR_PLAYERIXPOS: {2264scriptEng.operands[i] = playerList[activePlayer].XPos >> 16;2265break;2266}2267case VAR_PLAYERIYPOS: {2268scriptEng.operands[i] = playerList[activePlayer].YPos >> 16;2269break;2270}2271case VAR_PLAYERSCREENXPOS: {2272scriptEng.operands[i] = playerList[activePlayer].screenXPos;2273break;2274}2275case VAR_PLAYERSCREENYPOS: {2276scriptEng.operands[i] = playerList[activePlayer].screenYPos;2277break;2278}2279case VAR_PLAYERSPEED: {2280scriptEng.operands[i] = playerList[activePlayer].speed;2281break;2282}2283case VAR_PLAYERXVELOCITY: {2284scriptEng.operands[i] = playerList[activePlayer].XVelocity;2285break;2286}2287case VAR_PLAYERYVELOCITY: {2288scriptEng.operands[i] = playerList[activePlayer].YVelocity;2289break;2290}2291case VAR_PLAYERGRAVITY: {2292scriptEng.operands[i] = playerList[activePlayer].gravity;2293break;2294}2295case VAR_PLAYERANGLE: {2296scriptEng.operands[i] = playerList[activePlayer].angle;2297break;2298}2299case VAR_PLAYERSKIDDING: {2300scriptEng.operands[i] = playerList[activePlayer].skidding;2301break;2302}2303case VAR_PLAYERPUSHING: {2304scriptEng.operands[i] = playerList[activePlayer].pushing;2305break;2306}2307case VAR_PLAYERTRACKSCROLL: {2308scriptEng.operands[i] = playerList[activePlayer].trackScroll;2309break;2310}2311case VAR_PLAYERUP: {2312scriptEng.operands[i] = playerList[activePlayer].up;2313break;2314}2315case VAR_PLAYERDOWN: {2316scriptEng.operands[i] = playerList[activePlayer].down;2317break;2318}2319case VAR_PLAYERLEFT: {2320scriptEng.operands[i] = playerList[activePlayer].left;2321break;2322}2323case VAR_PLAYERRIGHT: {2324scriptEng.operands[i] = playerList[activePlayer].right;2325break;2326}2327case VAR_PLAYERJUMPPRESS: {2328scriptEng.operands[i] = playerList[activePlayer].jumpPress;2329break;2330}2331case VAR_PLAYERJUMPHOLD: {2332scriptEng.operands[i] = playerList[activePlayer].jumpHold;2333break;2334}2335case VAR_PLAYERFOLLOWPLAYER1: {2336scriptEng.operands[i] = playerList[activePlayer].followPlayer1;2337break;2338}2339case VAR_PLAYERLOOKPOS: {2340scriptEng.operands[i] = playerList[activePlayer].lookPos;2341break;2342}2343case VAR_PLAYERWATER: {2344scriptEng.operands[i] = playerList[activePlayer].water;2345break;2346}2347case VAR_PLAYERTOPSPEED: {2348scriptEng.operands[i] = playerList[activePlayer].topSpeed;2349break;2350}2351case VAR_PLAYERACCELERATION: {2352scriptEng.operands[i] = playerList[activePlayer].acceleration;2353break;2354}2355case VAR_PLAYERDECELERATION: {2356scriptEng.operands[i] = playerList[activePlayer].deceleration;2357break;2358}2359case VAR_PLAYERAIRACCELERATION: {2360scriptEng.operands[i] = playerList[activePlayer].airAcceleration;2361break;2362}2363case VAR_PLAYERAIRDECELERATION: {2364scriptEng.operands[i] = playerList[activePlayer].airDeceleration;2365break;2366}2367case VAR_PLAYERGRAVITYSTRENGTH: {2368scriptEng.operands[i] = playerList[activePlayer].gravityStrength;2369break;2370}2371case VAR_PLAYERJUMPSTRENGTH: {2372scriptEng.operands[i] = playerList[activePlayer].jumpStrength;2373break;2374}2375case VAR_PLAYERJUMPCAP: {2376scriptEng.operands[i] = playerList[activePlayer].jumpCap;2377break;2378}2379case VAR_PLAYERROLLINGACCELERATION: {2380scriptEng.operands[i] = playerList[activePlayer].rollingAcceleration;2381break;2382}2383case VAR_PLAYERROLLINGDECELERATION: {2384scriptEng.operands[i] = playerList[activePlayer].rollingDeceleration;2385break;2386}2387case VAR_PLAYERENTITYNO: {2388scriptEng.operands[i] = playerList[activePlayer].entityNo;2389break;2390}2391case VAR_PLAYERCOLLISIONLEFT: {2392AnimationFile *animFile = playerList[activePlayer].animationFile;2393Player *plr = &playerList[activePlayer];2394if (animFile) {2395int32 h = animFrames[animationList[animFile->aniListOffset + plr->boundEntity->animation].frameListOffset2396+ plr->boundEntity->frame]2397.hitboxID;23982399scriptEng.operands[i] = hitboxList[animFile->hitboxListOffset + h].left[0];2400}2401else {2402scriptEng.operands[i] = 0;2403}2404break;2405}2406case VAR_PLAYERCOLLISIONTOP: {2407AnimationFile *animFile = playerList[activePlayer].animationFile;2408Player *plr = &playerList[activePlayer];2409if (animFile) {2410int32 h = animFrames[animationList[animFile->aniListOffset + plr->boundEntity->animation].frameListOffset2411+ plr->boundEntity->frame]2412.hitboxID;24132414scriptEng.operands[i] = hitboxList[animFile->hitboxListOffset + h].top[0];2415}2416else {2417scriptEng.operands[i] = 0;2418}2419break;2420}2421case VAR_PLAYERCOLLISIONRIGHT: {2422AnimationFile *animFile = playerList[activePlayer].animationFile;2423Player *plr = &playerList[activePlayer];2424if (animFile) {2425int32 h = animFrames[animationList[animFile->aniListOffset + plr->boundEntity->animation].frameListOffset2426+ plr->boundEntity->frame]2427.hitboxID;24282429scriptEng.operands[i] = hitboxList[animFile->hitboxListOffset + h].right[0];2430}2431else {2432scriptEng.operands[i] = 0;2433}2434break;2435}2436case VAR_PLAYERCOLLISIONBOTTOM: {2437AnimationFile *animFile = playerList[activePlayer].animationFile;2438Player *plr = &playerList[activePlayer];2439if (animFile) {2440int32 h = animFrames[animationList[animFile->aniListOffset + plr->boundEntity->animation].frameListOffset2441+ plr->boundEntity->frame]2442.hitboxID;24432444scriptEng.operands[i] = hitboxList[animFile->hitboxListOffset + h].bottom[0];2445}2446else {2447scriptEng.operands[i] = 0;2448}2449break;2450}2451case VAR_PLAYERFLAILING: {2452scriptEng.operands[i] = playerList[activePlayer].flailing[arrayVal];2453break;2454}2455case VAR_PLAYERTIMER: {2456scriptEng.operands[i] = playerList[activePlayer].timer;2457break;2458}2459case VAR_PLAYERTILECOLLISIONS: {2460scriptEng.operands[i] = playerList[activePlayer].tileCollisions;2461break;2462}2463case VAR_PLAYEROBJECTINTERACTION: {2464scriptEng.operands[i] = playerList[activePlayer].objectInteractions;2465break;2466}2467case VAR_PLAYERVISIBLE: {2468scriptEng.operands[i] = playerList[activePlayer].visible;2469break;2470}2471case VAR_PLAYERROTATION: {2472scriptEng.operands[i] = playerList[activePlayer].boundEntity->rotation;2473break;2474}2475case VAR_PLAYERSCALE: {2476scriptEng.operands[i] = playerList[activePlayer].boundEntity->scale;2477break;2478}2479case VAR_PLAYERPRIORITY: {2480scriptEng.operands[i] = playerList[activePlayer].boundEntity->priority;2481break;2482}2483case VAR_PLAYERDRAWORDER: {2484scriptEng.operands[i] = playerList[activePlayer].boundEntity->drawOrder;2485break;2486}2487case VAR_PLAYERDIRECTION: {2488scriptEng.operands[i] = playerList[activePlayer].boundEntity->direction;2489break;2490}2491case VAR_PLAYERINKEFFECT: {2492scriptEng.operands[i] = playerList[activePlayer].boundEntity->inkEffect;2493break;2494}2495case VAR_PLAYERALPHA: {2496scriptEng.operands[i] = playerList[activePlayer].boundEntity->alpha;2497break;2498}2499case VAR_PLAYERFRAME: {2500scriptEng.operands[i] = playerList[activePlayer].boundEntity->frame;2501break;2502}2503case VAR_PLAYERANIMATION: {2504scriptEng.operands[i] = playerList[activePlayer].boundEntity->animation;2505break;2506}2507case VAR_PLAYERPREVANIMATION: {2508scriptEng.operands[i] = playerList[activePlayer].boundEntity->prevAnimation;2509break;2510}2511case VAR_PLAYERANIMATIONSPEED: {2512scriptEng.operands[i] = playerList[activePlayer].boundEntity->animationSpeed;2513break;2514}2515case VAR_PLAYERANIMATIONTIMER: {2516scriptEng.operands[i] = playerList[activePlayer].boundEntity->animationTimer;2517break;2518}2519case VAR_PLAYERVALUE0: {2520scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[0];2521break;2522}2523case VAR_PLAYERVALUE1: {2524scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[1];2525break;2526}2527case VAR_PLAYERVALUE2: {2528scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[2];2529break;2530}2531case VAR_PLAYERVALUE3: {2532scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[3];2533break;2534}2535case VAR_PLAYERVALUE4: {2536scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[4];2537break;2538}2539case VAR_PLAYERVALUE5: {2540scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[5];2541break;2542}2543case VAR_PLAYERVALUE6: {2544scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[6];2545break;2546}2547case VAR_PLAYERVALUE7: {2548scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[7];2549break;2550}2551case VAR_PLAYERVALUE8: {2552scriptEng.operands[i] = playerList[activePlayer].values[0];2553break;2554}2555case VAR_PLAYERVALUE9: {2556scriptEng.operands[i] = playerList[activePlayer].values[1];2557break;2558}2559case VAR_PLAYERVALUE10: {2560scriptEng.operands[i] = playerList[activePlayer].values[2];2561break;2562}2563case VAR_PLAYERVALUE11: {2564scriptEng.operands[i] = playerList[activePlayer].values[3];2565break;2566}2567case VAR_PLAYERVALUE12: {2568scriptEng.operands[i] = playerList[activePlayer].values[4];2569break;2570}2571case VAR_PLAYERVALUE13: {2572scriptEng.operands[i] = playerList[activePlayer].values[5];2573break;2574}2575case VAR_PLAYERVALUE14: {2576scriptEng.operands[i] = playerList[activePlayer].values[6];2577break;2578}2579case VAR_PLAYERVALUE15: {2580scriptEng.operands[i] = playerList[activePlayer].values[7];2581break;2582}2583case VAR_PLAYEROUTOFBOUNDS: {2584int32 pos = playerList[activePlayer].XPos >> 16;2585if (pos <= xScrollOffset - OBJECT_BORDER_X1 || pos >= OBJECT_BORDER_X2 + xScrollOffset) {2586scriptEng.operands[i] = 1;2587}2588else {2589int32 pos = playerList[activePlayer].YPos >> 16;2590scriptEng.operands[i] = pos <= yScrollOffset - OBJECT_BORDER_Y1 || pos >= yScrollOffset + OBJECT_BORDER_Y2;2591}2592break;2593}2594case VAR_STAGESTATE: scriptEng.operands[i] = stageMode; break;2595case VAR_STAGEACTIVELIST: scriptEng.operands[i] = sceneInfo.activeCategory; break;2596case VAR_STAGELISTPOS:2597scriptEng.operands[i] = sceneInfo.listPos - sceneInfo.listCategory[sceneInfo.activeCategory].sceneOffsetStart;2598break;2599case VAR_STAGETIMEENABLED: scriptEng.operands[i] = timeEnabled; break;2600case VAR_STAGEMILLISECONDS: scriptEng.operands[i] = stageMilliseconds; break;2601case VAR_STAGESECONDS: scriptEng.operands[i] = stageSeconds; break;2602case VAR_STAGEMINUTES: scriptEng.operands[i] = stageMinutes; break;2603case VAR_STAGEACTNO: scriptEng.operands[i] = actID; break;2604case VAR_STAGEPAUSEENABLED: scriptEng.operands[i] = pauseEnabled; break;2605case VAR_STAGELISTSIZE: scriptEng.operands[i] = sceneInfo.listCategory[RSDK::sceneInfo.activeCategory].sceneCount; break;2606case VAR_STAGENEWXBOUNDARY1: scriptEng.operands[i] = newXBoundary1; break;2607case VAR_STAGENEWXBOUNDARY2: scriptEng.operands[i] = newXBoundary2; break;2608case VAR_STAGENEWYBOUNDARY1: scriptEng.operands[i] = newYBoundary1; break;2609case VAR_STAGENEWYBOUNDARY2: scriptEng.operands[i] = newYBoundary2; break;2610case VAR_STAGEXBOUNDARY1: scriptEng.operands[i] = curXBoundary1; break;2611case VAR_STAGEXBOUNDARY2: scriptEng.operands[i] = curXBoundary2; break;2612case VAR_STAGEYBOUNDARY1: scriptEng.operands[i] = curYBoundary1; break;2613case VAR_STAGEYBOUNDARY2: scriptEng.operands[i] = curYBoundary2; break;2614case VAR_STAGEDEFORMATIONDATA0: scriptEng.operands[i] = bgDeformationData0[arrayVal]; break;2615case VAR_STAGEDEFORMATIONDATA1: scriptEng.operands[i] = bgDeformationData1[arrayVal]; break;2616case VAR_STAGEDEFORMATIONDATA2: scriptEng.operands[i] = bgDeformationData2[arrayVal]; break;2617case VAR_STAGEDEFORMATIONDATA3: scriptEng.operands[i] = bgDeformationData3[arrayVal]; break;2618case VAR_STAGEWATERLEVEL: scriptEng.operands[i] = waterLevel; break;2619case VAR_STAGEACTIVELAYER: scriptEng.operands[i] = activeTileLayers[arrayVal]; break;2620case VAR_STAGEMIDPOINT: scriptEng.operands[i] = tLayerMidPoint; break;2621case VAR_STAGEPLAYERLISTPOS: scriptEng.operands[i] = playerListPos; break;2622case VAR_STAGEACTIVEPLAYER: scriptEng.operands[i] = activePlayer; break;2623case VAR_SCREENCAMERAENABLED: scriptEng.operands[i] = currentCamera->enabled; break;2624case VAR_SCREENCAMERATARGET: scriptEng.operands[i] = currentCamera->target; break;2625case VAR_SCREENCAMERASTYLE: scriptEng.operands[i] = currentCamera->style; break;2626case VAR_SCREENDRAWLISTSIZE: scriptEng.operands[i] = drawListEntries[arrayVal].listSize; break;2627case VAR_SCREENCENTERX: scriptEng.operands[i] = SCREEN_CENTERX; break;2628case VAR_SCREENCENTERY: scriptEng.operands[i] = SCREEN_CENTERY; break;2629case VAR_SCREENXSIZE: scriptEng.operands[i] = SCREEN_XSIZE; break;2630case VAR_SCREENYSIZE: scriptEng.operands[i] = SCREEN_YSIZE; break;2631case VAR_SCREENXOFFSET: scriptEng.operands[i] = xScrollOffset; break;2632case VAR_SCREENYOFFSET: scriptEng.operands[i] = yScrollOffset; break;2633case VAR_SCREENSHAKEX: scriptEng.operands[i] = cameraShakeX; break;2634case VAR_SCREENSHAKEY: scriptEng.operands[i] = cameraShakeY; break;2635case VAR_SCREENADJUSTCAMERAY: scriptEng.operands[i] = currentCamera->adjustY; break;2636case VAR_TOUCHSCREENDOWN: scriptEng.operands[i] = touchInfo.down[arrayVal]; break;2637case VAR_TOUCHSCREENXPOS: scriptEng.operands[i] = (int32)(touchInfo.x[arrayVal] * SCREEN_XSIZE); break;2638case VAR_TOUCHSCREENYPOS: scriptEng.operands[i] = (int32)(touchInfo.y[arrayVal] * SCREEN_YSIZE); break;2639case VAR_MUSICVOLUME: scriptEng.operands[i] = musicVolume; break;2640case VAR_MUSICCURRENTTRACK: scriptEng.operands[i] = musicCurrentTrack; break;2641case VAR_KEYDOWNUP: scriptEng.operands[i] = controller[arrayVal].keyUp.down; break;2642case VAR_KEYDOWNDOWN: scriptEng.operands[i] = controller[arrayVal].keyDown.down; break;2643case VAR_KEYDOWNLEFT: scriptEng.operands[i] = controller[arrayVal].keyLeft.down; break;2644case VAR_KEYDOWNRIGHT: scriptEng.operands[i] = controller[arrayVal].keyRight.down; break;2645case VAR_KEYDOWNBUTTONA: scriptEng.operands[i] = controller[arrayVal].keyA.down; break;2646case VAR_KEYDOWNBUTTONB: scriptEng.operands[i] = controller[arrayVal].keyB.down; break;2647case VAR_KEYDOWNBUTTONC: scriptEng.operands[i] = controller[arrayVal].keyC.down; break;2648case VAR_KEYDOWNSTART: scriptEng.operands[i] = controller[arrayVal].keyStart.down; break;2649case VAR_KEYPRESSUP: scriptEng.operands[i] = controller[arrayVal].keyUp.press; break;2650case VAR_KEYPRESSDOWN: scriptEng.operands[i] = controller[arrayVal].keyDown.press; break;2651case VAR_KEYPRESSLEFT: scriptEng.operands[i] = controller[arrayVal].keyLeft.press; break;2652case VAR_KEYPRESSRIGHT: scriptEng.operands[i] = controller[arrayVal].keyRight.press; break;2653case VAR_KEYPRESSBUTTONA: scriptEng.operands[i] = controller[arrayVal].keyA.press; break;2654case VAR_KEYPRESSBUTTONB: scriptEng.operands[i] = controller[arrayVal].keyB.press; break;2655case VAR_KEYPRESSBUTTONC: scriptEng.operands[i] = controller[arrayVal].keyC.press; break;2656case VAR_KEYPRESSSTART: scriptEng.operands[i] = controller[arrayVal].keyStart.press; break;2657case VAR_MENU1SELECTION: scriptEng.operands[i] = gameMenu[0].selection1; break;2658case VAR_MENU2SELECTION: scriptEng.operands[i] = gameMenu[1].selection1; break;2659case VAR_TILELAYERXSIZE: scriptEng.operands[i] = stageLayouts[arrayVal].xsize; break;2660case VAR_TILELAYERYSIZE: scriptEng.operands[i] = stageLayouts[arrayVal].ysize; break;2661case VAR_TILELAYERTYPE: scriptEng.operands[i] = stageLayouts[arrayVal].type; break;2662case VAR_TILELAYERANGLE: scriptEng.operands[i] = stageLayouts[arrayVal].angle; break;2663case VAR_TILELAYERXPOS: scriptEng.operands[i] = stageLayouts[arrayVal].xpos; break;2664case VAR_TILELAYERYPOS: scriptEng.operands[i] = stageLayouts[arrayVal].ypos; break;2665case VAR_TILELAYERZPOS: scriptEng.operands[i] = stageLayouts[arrayVal].zpos; break;2666case VAR_TILELAYERPARALLAXFACTOR: scriptEng.operands[i] = stageLayouts[arrayVal].parallaxFactor; break;2667case VAR_TILELAYERSCROLLSPEED: scriptEng.operands[i] = stageLayouts[arrayVal].scrollSpeed; break;2668case VAR_TILELAYERSCROLLPOS: scriptEng.operands[i] = stageLayouts[arrayVal].scrollPos; break;2669case VAR_TILELAYERDEFORMATIONOFFSET: scriptEng.operands[i] = stageLayouts[arrayVal].deformationOffset; break;2670case VAR_TILELAYERDEFORMATIONOFFSETW: scriptEng.operands[i] = stageLayouts[arrayVal].deformationOffsetW; break;2671case VAR_HPARALLAXPARALLAXFACTOR: scriptEng.operands[i] = hParallax.parallaxFactor[arrayVal]; break;2672case VAR_HPARALLAXSCROLLSPEED: scriptEng.operands[i] = hParallax.scrollSpeed[arrayVal]; break;2673case VAR_HPARALLAXSCROLLPOS: scriptEng.operands[i] = hParallax.scrollPos[arrayVal]; break;2674case VAR_VPARALLAXPARALLAXFACTOR: scriptEng.operands[i] = vParallax.parallaxFactor[arrayVal]; break;2675case VAR_VPARALLAXSCROLLSPEED: scriptEng.operands[i] = vParallax.scrollSpeed[arrayVal]; break;2676case VAR_VPARALLAXSCROLLPOS: scriptEng.operands[i] = vParallax.scrollPos[arrayVal]; break;2677case VAR_3DSCENENOVERTICES: scriptEng.operands[i] = vertexCount; break;2678case VAR_3DSCENENOFACES: scriptEng.operands[i] = faceCount; break;2679case VAR_VERTEXBUFFERX: scriptEng.operands[i] = vertexBuffer[arrayVal].x; break;2680case VAR_VERTEXBUFFERY: scriptEng.operands[i] = vertexBuffer[arrayVal].y; break;2681case VAR_VERTEXBUFFERZ: scriptEng.operands[i] = vertexBuffer[arrayVal].z; break;2682case VAR_VERTEXBUFFERU: scriptEng.operands[i] = vertexBuffer[arrayVal].u; break;2683case VAR_VERTEXBUFFERV: scriptEng.operands[i] = vertexBuffer[arrayVal].v; break;2684case VAR_FACEBUFFERA: scriptEng.operands[i] = faceBuffer[arrayVal].a; break;2685case VAR_FACEBUFFERB: scriptEng.operands[i] = faceBuffer[arrayVal].b; break;2686case VAR_FACEBUFFERC: scriptEng.operands[i] = faceBuffer[arrayVal].c; break;2687case VAR_FACEBUFFERD: scriptEng.operands[i] = faceBuffer[arrayVal].d; break;2688case VAR_FACEBUFFERFLAG: scriptEng.operands[i] = faceBuffer[arrayVal].flag; break;2689case VAR_FACEBUFFERCOLOR: scriptEng.operands[i] = faceBuffer[arrayVal].color; break;2690case VAR_3DSCENEPROJECTIONX: scriptEng.operands[i] = projectionX; break;2691case VAR_3DSCENEPROJECTIONY: scriptEng.operands[i] = projectionY; break;2692case VAR_ENGINESTATE: scriptEng.operands[i] = gameMode; break;2693case VAR_STAGEDEBUGMODE: scriptEng.operands[i] = debugMode; break;2694case VAR_ENGINEMESSAGE: scriptEng.operands[i] = engineMessage; break;2695case VAR_SAVERAM: scriptEng.operands[i] = saveRAM[arrayVal]; break;2696case VAR_ENGINELANGUAGE: scriptEng.operands[i] = language; break;2697case VAR_OBJECTSPRITESHEET: {2698scriptEng.operands[i] = objectScriptList[objectEntityList[arrayVal].type].spriteSheetID;2699break;2700}2701case VAR_ENGINEONLINEACTIVE: scriptEng.operands[i] = onlineActive; break;2702case VAR_ENGINEFRAMESKIPTIMER: break;2703case VAR_ENGINEFRAMESKIPSETTING: break;2704case VAR_ENGINESFXVOLUME: scriptEng.operands[i] = sfxVolume; break;2705case VAR_ENGINEBGMVOLUME: scriptEng.operands[i] = bgmVolume; break;2706case VAR_ENGINEPLATFORMID: scriptEng.operands[i] = gamePlatformID; break;2707case VAR_ENGINETRIALMODE: scriptEng.operands[i] = trialMode; break;2708case VAR_KEYPRESSANYSTART: scriptEng.operands[i] = anyPress; break;2709#if LEGACY_RETRO_USE_HAPTICS2710case VAR_ENGINEHAPTICSENABLED: scriptEng.operands[i] = hapticsEnabled; break;2711#endif2712}2713}2714else if (opcodeType == SCRIPTVAR_INTCONST) { // int32 constant2715scriptEng.operands[i] = scriptCode[scriptCodePtr++];2716}2717else if (opcodeType == SCRIPTVAR_STRCONST) { // string constant2718int32 strLen = scriptCode[scriptCodePtr++];2719scriptText[strLen] = 0;2720for (int32 c = 0; c < strLen; ++c) {2721switch (c % 4) {2722case 0: {2723scriptText[c] = scriptCode[scriptCodePtr] >> 24;2724break;2725}2726case 1: {2727scriptText[c] = (0xFFFFFF & scriptCode[scriptCodePtr]) >> 16;2728break;2729}2730case 2: {2731scriptText[c] = (0xFFFF & scriptCode[scriptCodePtr]) >> 8;2732break;2733}2734case 3: {2735scriptText[c] = scriptCode[scriptCodePtr++];2736break;2737}2738default: break;2739}2740}2741scriptCodePtr++;2742}2743}27442745ObjectScript *scriptInfo = &objectScriptList[objectEntityList[objectLoop].type];2746Entity *entity = &objectEntityList[objectLoop];2747Player *player = &playerList[activePlayer];2748SpriteFrame *spriteFrame = nullptr;27492750// Functions2751switch (opcode) {2752default: break;2753case FUNC_END: running = false; break;2754case FUNC_EQUAL: scriptEng.operands[0] = scriptEng.operands[1]; break;2755case FUNC_ADD: scriptEng.operands[0] += scriptEng.operands[1]; break;2756case FUNC_SUB: scriptEng.operands[0] -= scriptEng.operands[1]; break;2757case FUNC_INC: ++scriptEng.operands[0]; break;2758case FUNC_DEC: --scriptEng.operands[0]; break;2759case FUNC_MUL: scriptEng.operands[0] *= scriptEng.operands[1]; break;2760case FUNC_DIV: scriptEng.operands[0] /= scriptEng.operands[1]; break;2761case FUNC_SHR: scriptEng.operands[0] >>= scriptEng.operands[1]; break;2762case FUNC_SHL: scriptEng.operands[0] <<= scriptEng.operands[1]; break;2763case FUNC_AND: scriptEng.operands[0] &= scriptEng.operands[1]; break;2764case FUNC_OR: scriptEng.operands[0] |= scriptEng.operands[1]; break;2765case FUNC_XOR: scriptEng.operands[0] ^= scriptEng.operands[1]; break;2766case FUNC_MOD: scriptEng.operands[0] %= scriptEng.operands[1]; break;2767case FUNC_FLIPSIGN: scriptEng.operands[0] = -scriptEng.operands[0]; break;2768case FUNC_CHECKEQUAL:2769scriptEng.checkResult = scriptEng.operands[0] == scriptEng.operands[1];2770opcodeSize = 0;2771break;2772case FUNC_CHECKGREATER:2773scriptEng.checkResult = scriptEng.operands[0] > scriptEng.operands[1];2774opcodeSize = 0;2775break;2776case FUNC_CHECKLOWER:2777scriptEng.checkResult = scriptEng.operands[0] < scriptEng.operands[1];2778opcodeSize = 0;2779break;2780case FUNC_CHECKNOTEQUAL:2781scriptEng.checkResult = scriptEng.operands[0] != scriptEng.operands[1];2782opcodeSize = 0;2783break;2784case FUNC_IFEQUAL:2785if (scriptEng.operands[1] != scriptEng.operands[2])2786scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0]];2787jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2788opcodeSize = 0;2789break;2790case FUNC_IFGREATER:2791if (scriptEng.operands[1] <= scriptEng.operands[2])2792scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0]];2793jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2794opcodeSize = 0;2795break;2796case FUNC_IFGREATEROREQUAL:2797if (scriptEng.operands[1] < scriptEng.operands[2])2798scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0]];2799jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2800opcodeSize = 0;2801break;2802case FUNC_IFLOWER:2803if (scriptEng.operands[1] >= scriptEng.operands[2])2804scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0]];2805jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2806opcodeSize = 0;2807break;2808case FUNC_IFLOWEROREQUAL:2809if (scriptEng.operands[1] > scriptEng.operands[2])2810scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0]];2811jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2812opcodeSize = 0;2813break;2814case FUNC_IFNOTEQUAL:2815if (scriptEng.operands[1] == scriptEng.operands[2])2816scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0]];2817jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2818opcodeSize = 0;2819break;2820case FUNC_ELSE:2821opcodeSize = 0;2822scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + jumpTableStack[jumpTableStackPos--] + 1];2823break;2824case FUNC_ENDIF:2825opcodeSize = 0;2826--jumpTableStackPos;2827break;2828case FUNC_WEQUAL:2829if (scriptEng.operands[1] != scriptEng.operands[2])2830scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0] + 1];2831else2832jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2833opcodeSize = 0;2834break;2835case FUNC_WGREATER:2836if (scriptEng.operands[1] <= scriptEng.operands[2])2837scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0] + 1];2838else2839jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2840opcodeSize = 0;2841break;2842case FUNC_WGREATEROREQUAL:2843if (scriptEng.operands[1] < scriptEng.operands[2])2844scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0] + 1];2845else2846jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2847opcodeSize = 0;2848break;2849case FUNC_WLOWER:2850if (scriptEng.operands[1] >= scriptEng.operands[2])2851scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0] + 1];2852else2853jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2854opcodeSize = 0;2855break;2856case FUNC_WLOWEROREQUAL:2857if (scriptEng.operands[1] > scriptEng.operands[2])2858scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0] + 1];2859else2860jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2861opcodeSize = 0;2862break;2863case FUNC_WNOTEQUAL:2864if (scriptEng.operands[1] == scriptEng.operands[2])2865scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0] + 1];2866else2867jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2868opcodeSize = 0;2869break;2870case FUNC_LOOP:2871opcodeSize = 0;2872scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + jumpTableStack[jumpTableStackPos--]];2873break;2874case FUNC_SWITCH:2875jumpTableStack[++jumpTableStackPos] = scriptEng.operands[0];2876if (scriptEng.operands[1] < jumpTable[jumpTableStart + scriptEng.operands[0]]2877|| scriptEng.operands[1] > jumpTable[jumpTableStart + scriptEng.operands[0] + 1])2878scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + scriptEng.operands[0] + 2];2879else2880scriptCodePtr = scriptCodeStart2881+ jumpTable[jumpTableStart + scriptEng.operands[0] + 42882+ (scriptEng.operands[1] - jumpTable[jumpTableStart + scriptEng.operands[0]])];2883opcodeSize = 0;2884break;2885case FUNC_BREAK:2886opcodeSize = 0;2887scriptCodePtr = scriptCodeStart + jumpTable[jumpTableStart + jumpTableStack[jumpTableStackPos--] + 3];2888break;2889case FUNC_ENDSWITCH:2890opcodeSize = 0;2891--jumpTableStackPos;2892break;2893case FUNC_RAND: scriptEng.operands[0] = rand() % scriptEng.operands[1]; break;2894case FUNC_SIN: {2895scriptEng.operands[0] = Sin512(scriptEng.operands[1]);2896break;2897}2898case FUNC_COS: {2899scriptEng.operands[0] = Cos512(scriptEng.operands[1]);2900break;2901}2902case FUNC_SIN256: {2903scriptEng.operands[0] = Sin256(scriptEng.operands[1]);2904break;2905}2906case FUNC_COS256: {2907scriptEng.operands[0] = Cos256(scriptEng.operands[1]);2908break;2909}2910case FUNC_SINCHANGE: {2911scriptEng.operands[0] = scriptEng.operands[3] + (Sin512(scriptEng.operands[1]) >> scriptEng.operands[2]) - scriptEng.operands[4];2912break;2913}2914case FUNC_COSCHANGE: {2915scriptEng.operands[0] = scriptEng.operands[3] + (Cos512(scriptEng.operands[1]) >> scriptEng.operands[2]) - scriptEng.operands[4];2916break;2917}2918case FUNC_ATAN2: {2919scriptEng.operands[0] = ArcTanLookup(scriptEng.operands[1], scriptEng.operands[2]);2920break;2921}2922case FUNC_INTERPOLATE:2923scriptEng.operands[0] =2924(scriptEng.operands[2] * (0x100 - scriptEng.operands[3]) + scriptEng.operands[3] * scriptEng.operands[1]) >> 8;2925break;2926case FUNC_INTERPOLATEXY:2927scriptEng.operands[0] =2928(scriptEng.operands[3] * (0x100 - scriptEng.operands[6]) >> 8) + ((scriptEng.operands[6] * scriptEng.operands[2]) >> 8);2929scriptEng.operands[1] =2930(scriptEng.operands[5] * (0x100 - scriptEng.operands[6]) >> 8) + (scriptEng.operands[6] * scriptEng.operands[4] >> 8);2931break;2932case FUNC_LOADSPRITESHEET:2933opcodeSize = 0;2934scriptInfo->spriteSheetID = AddGraphicsFile(scriptText);2935break;2936case FUNC_REMOVESPRITESHEET:2937opcodeSize = 0;2938RemoveGraphicsFile(scriptText, -1);2939break;2940case FUNC_DRAWSPRITE:2941opcodeSize = 0;2942spriteFrame = &scriptFrames[scriptInfo->frameListOffset + scriptEng.operands[0]];2943DrawSprite((entity->XPos >> 16) - xScrollOffset + spriteFrame->pivotX, (entity->YPos >> 16) - yScrollOffset + spriteFrame->pivotY,2944spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);2945break;2946case FUNC_DRAWSPRITEXY:2947opcodeSize = 0;2948spriteFrame = &scriptFrames[scriptInfo->frameListOffset + scriptEng.operands[0]];2949DrawSprite((scriptEng.operands[1] >> 16) - xScrollOffset + spriteFrame->pivotX,2950(scriptEng.operands[2] >> 16) - yScrollOffset + spriteFrame->pivotY, spriteFrame->width, spriteFrame->height,2951spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);2952break;2953case FUNC_DRAWSPRITESCREENXY:2954opcodeSize = 0;2955spriteFrame = &scriptFrames[scriptInfo->frameListOffset + scriptEng.operands[0]];2956DrawSprite(scriptEng.operands[1] + spriteFrame->pivotX, scriptEng.operands[2] + spriteFrame->pivotY, spriteFrame->width,2957spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);2958break;2959case FUNC_DRAWTINTRECT:2960opcodeSize = 0;2961DrawTintRectangle(scriptEng.operands[0], scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]);2962break;2963case FUNC_DRAWNUMBERS: {2964opcodeSize = 0;2965int32 i = 10;2966if (scriptEng.operands[6]) {2967while (scriptEng.operands[4] > 0) {2968int32 frameID = scriptEng.operands[3] % i / (i / 10) + scriptEng.operands[0];2969spriteFrame = &scriptFrames[scriptInfo->frameListOffset + frameID];2970DrawSprite(spriteFrame->pivotX + scriptEng.operands[1], spriteFrame->pivotY + scriptEng.operands[2], spriteFrame->width,2971spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);2972scriptEng.operands[1] -= scriptEng.operands[5];2973i *= 10;2974--scriptEng.operands[4];2975}2976}2977else {2978int32 extra = 10;2979if (scriptEng.operands[3])2980extra = 10 * scriptEng.operands[3];2981while (scriptEng.operands[4] > 0) {2982if (extra >= i) {2983int32 frameID = scriptEng.operands[3] % i / (i / 10) + scriptEng.operands[0];2984spriteFrame = &scriptFrames[scriptInfo->frameListOffset + frameID];2985DrawSprite(spriteFrame->pivotX + scriptEng.operands[1], spriteFrame->pivotY + scriptEng.operands[2], spriteFrame->width,2986spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);2987}2988scriptEng.operands[1] -= scriptEng.operands[5];2989i *= 10;2990--scriptEng.operands[4];2991}2992}2993break;2994}2995case FUNC_DRAWACTNAME: {2996opcodeSize = 0;2997int32 charID = 0;29982999switch (scriptEng.operands[3]) {3000default: break;30013002case 1: // Draw Word 13003charID = 0;30043005// Draw the first letter as a capital letter, the rest are lowercase (if scriptEng.operands[4] is true, otherwise they're all3006// uppercase)3007if (scriptEng.operands[4] == 1 && titleCardText[charID] != 0) {3008int32 character = titleCardText[charID];3009if (character == ' ')3010character = 0;3011if (character == '-')3012character = 0;3013if (character >= '0' && character <= '9')3014character -= 22;3015if (character > '9' && character < 'f')3016character -= 'A';30173018if (character <= -1) {3019scriptEng.operands[1] += scriptEng.operands[5] + scriptEng.operands[6]; // spaceWidth + spacing3020}3021else {3022character += scriptEng.operands[0];3023spriteFrame = &scriptFrames[scriptInfo->frameListOffset + character];3024DrawSprite(scriptEng.operands[1] + spriteFrame->pivotX, scriptEng.operands[2] + spriteFrame->pivotY,3025spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);3026scriptEng.operands[1] += spriteFrame->width + scriptEng.operands[6];3027}30283029scriptEng.operands[0] += 26;3030charID++;3031}30323033while (titleCardText[charID] != 0 && titleCardText[charID] != '-') {3034int32 character = titleCardText[charID];3035if (character == ' ')3036character = 0;3037if (character == '-')3038character = 0;3039if (character > '/' && character < ':')3040character -= 22;3041if (character > '9' && character < 'f')3042character -= 'A';30433044if (character <= -1) {3045scriptEng.operands[1] += scriptEng.operands[5] + scriptEng.operands[6]; // spaceWidth + spacing3046}3047else {3048character += scriptEng.operands[0];3049spriteFrame = &scriptFrames[scriptInfo->frameListOffset + character];3050DrawSprite(scriptEng.operands[1] + spriteFrame->pivotX, scriptEng.operands[2] + spriteFrame->pivotY,3051spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);3052scriptEng.operands[1] += spriteFrame->width + scriptEng.operands[6];3053}3054charID++;3055}3056break;30573058case 2: // Draw Word 23059charID = titleCardWord2;30603061// Draw the first letter as a capital letter, the rest are lowercase (if scriptEng.operands[4] is true, otherwise they're all3062// uppercase)3063if (scriptEng.operands[4] == 1 && titleCardText[charID] != 0) {3064int32 character = titleCardText[charID];3065if (character == ' ')3066character = 0;3067if (character == '-')3068character = 0;3069if (character >= '0' && character <= '9')3070character -= 22;3071if (character > '9' && character < 'f')3072character -= 'A';30733074if (character <= -1) {3075scriptEng.operands[1] += scriptEng.operands[5] + scriptEng.operands[6]; // spaceWidth + spacing3076}3077else {3078character += scriptEng.operands[0];3079spriteFrame = &scriptFrames[scriptInfo->frameListOffset + character];3080DrawSprite(scriptEng.operands[1] + spriteFrame->pivotX, scriptEng.operands[2] + spriteFrame->pivotY,3081spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);3082scriptEng.operands[1] += spriteFrame->width + scriptEng.operands[6];3083}3084scriptEng.operands[0] += 26;3085charID++;3086}30873088while (titleCardText[charID] != 0) {3089int32 character = titleCardText[charID];3090if (character == ' ')3091character = -1;3092if (character == '-')3093character = 0;3094if (character >= '0' && character <= '9')3095character -= 22;3096if (character > '9' && character < 'f')3097character -= 'A';30983099if (character <= -1) {3100scriptEng.operands[1] += scriptEng.operands[5] + scriptEng.operands[6]; // spaceWidth + spacing3101}3102else {3103character += scriptEng.operands[0];3104spriteFrame = &scriptFrames[scriptInfo->frameListOffset + character];3105DrawSprite(scriptEng.operands[1] + spriteFrame->pivotX, scriptEng.operands[2] + spriteFrame->pivotY,3106spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);3107scriptEng.operands[1] += spriteFrame->width + scriptEng.operands[6];3108}3109charID++;3110}3111break;3112}3113break;3114}3115case FUNC_DRAWMENU:3116opcodeSize = 0;3117textMenuSurfaceNo = scriptInfo->spriteSheetID;3118DrawTextMenu(&gameMenu[scriptEng.operands[0]], scriptEng.operands[1], scriptEng.operands[2]);3119break;3120case FUNC_SPRITEFRAME:3121opcodeSize = 0;3122if (scriptSub == SUB_SETUP && scriptFrameCount < LEGACY_SPRITEFRAME_COUNT) {3123scriptFrames[scriptFrameCount].pivotX = scriptEng.operands[0];3124scriptFrames[scriptFrameCount].pivotY = scriptEng.operands[1];3125scriptFrames[scriptFrameCount].width = scriptEng.operands[2];3126scriptFrames[scriptFrameCount].height = scriptEng.operands[3];3127scriptFrames[scriptFrameCount].sprX = scriptEng.operands[4];3128scriptFrames[scriptFrameCount].sprY = scriptEng.operands[5];3129++scriptFrameCount;3130}3131break;3132case FUNC_EDITFRAME: {3133opcodeSize = 0;3134spriteFrame = &scriptFrames[scriptInfo->frameListOffset + scriptEng.operands[0]];31353136spriteFrame->pivotX = scriptEng.operands[1];3137spriteFrame->pivotY = scriptEng.operands[2];3138spriteFrame->width = scriptEng.operands[3];3139spriteFrame->height = scriptEng.operands[4];3140spriteFrame->sprX = scriptEng.operands[5];3141spriteFrame->sprY = scriptEng.operands[6];3142break;3143}3144case FUNC_LOADPALETTE:3145opcodeSize = 0;3146LoadPalette(scriptText, scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3], scriptEng.operands[4]);3147break;3148case FUNC_ROTATEPALETTE:3149opcodeSize = 0;3150RotatePalette(scriptEng.operands[0], scriptEng.operands[1], scriptEng.operands[2]);3151break;3152case FUNC_SETSCREENFADE:3153opcodeSize = 0;3154SetFade(scriptEng.operands[0], scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]);3155break;3156case FUNC_SETACTIVEPALETTE:3157opcodeSize = 0;3158SetActivePalette(scriptEng.operands[0], scriptEng.operands[1], scriptEng.operands[2]);3159break;3160case FUNC_SETPALETTEFADE:3161opcodeSize = 0;3162SetLimitedFade(scriptEng.operands[0], scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3], scriptEng.operands[4],3163scriptEng.operands[5], scriptEng.operands[6]);3164break;3165case FUNC_COPYPALETTE:3166opcodeSize = 0;3167CopyPalette(scriptEng.operands[0], scriptEng.operands[1]);3168break;3169case FUNC_CLEARSCREEN:3170opcodeSize = 0;3171ClearScreen(scriptEng.operands[0]);3172break;3173case FUNC_DRAWSPRITEFX:3174opcodeSize = 0;3175spriteFrame = &scriptFrames[scriptInfo->frameListOffset + scriptEng.operands[0]];3176switch (scriptEng.operands[1]) {3177default: break;3178case FX_SCALE:3179DrawSpriteScaled(entity->direction, (scriptEng.operands[2] >> 16) - xScrollOffset,3180(scriptEng.operands[3] >> 16) - yScrollOffset, -spriteFrame->pivotX, -spriteFrame->pivotY, entity->scale,3181entity->scale, spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY,3182scriptInfo->spriteSheetID);3183break;3184case FX_ROTATE:3185DrawSpriteRotated(entity->direction, (scriptEng.operands[2] >> 16) - xScrollOffset,3186(scriptEng.operands[3] >> 16) - yScrollOffset, -spriteFrame->pivotX, -spriteFrame->pivotY,3187spriteFrame->sprX, spriteFrame->sprY, spriteFrame->width, spriteFrame->height, entity->rotation,3188scriptInfo->spriteSheetID);3189break;3190case FX_ROTOZOOM:3191DrawSpriteRotozoom(entity->direction, (scriptEng.operands[2] >> 16) - xScrollOffset,3192(scriptEng.operands[3] >> 16) - yScrollOffset, -spriteFrame->pivotX, -spriteFrame->pivotY,3193spriteFrame->sprX, spriteFrame->sprY, spriteFrame->width, spriteFrame->height, entity->rotation,3194entity->scale, scriptInfo->spriteSheetID);3195break;3196case FX_INK:3197switch (entity->inkEffect) {3198case INK_NONE:3199DrawSprite((scriptEng.operands[2] >> 16) - xScrollOffset + spriteFrame->pivotX,3200(scriptEng.operands[3] >> 16) - yScrollOffset + spriteFrame->pivotY, spriteFrame->width,3201spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);3202break;3203case INK_BLEND:3204DrawBlendedSprite((scriptEng.operands[2] >> 16) - xScrollOffset + spriteFrame->pivotX,3205(scriptEng.operands[3] >> 16) - yScrollOffset + spriteFrame->pivotY, spriteFrame->width,3206spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);3207break;3208case INK_ALPHA:3209DrawAlphaBlendedSprite((scriptEng.operands[2] >> 16) - xScrollOffset + spriteFrame->pivotX,3210(scriptEng.operands[3] >> 16) - yScrollOffset + spriteFrame->pivotY, spriteFrame->width,3211spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, entity->alpha,3212scriptInfo->spriteSheetID);3213break;3214case INK_ADD:3215DrawAdditiveBlendedSprite((scriptEng.operands[2] >> 16) - xScrollOffset + spriteFrame->pivotX,3216(scriptEng.operands[3] >> 16) - yScrollOffset + spriteFrame->pivotY, spriteFrame->width,3217spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, entity->alpha,3218scriptInfo->spriteSheetID);3219break;3220case INK_SUB:3221DrawSubtractiveBlendedSprite((scriptEng.operands[2] >> 16) - xScrollOffset + spriteFrame->pivotX,3222(scriptEng.operands[3] >> 16) - yScrollOffset + spriteFrame->pivotY, spriteFrame->width,3223spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, entity->alpha,3224scriptInfo->spriteSheetID);3225break;3226}3227break;3228case FX_TINT:3229if (entity->inkEffect == INK_ALPHA) {3230DrawScaledTintMask(entity->direction, (scriptEng.operands[2] >> 16) - xScrollOffset,3231(scriptEng.operands[3] >> 16) - yScrollOffset, -spriteFrame->pivotX, -spriteFrame->pivotY,3232entity->scale, entity->scale, spriteFrame->width, spriteFrame->height, spriteFrame->sprX,3233spriteFrame->sprY, scriptInfo->spriteSheetID);3234}3235else {3236DrawSpriteScaled(entity->direction, (scriptEng.operands[2] >> 16) - xScrollOffset,3237(scriptEng.operands[3] >> 16) - yScrollOffset, -spriteFrame->pivotX, -spriteFrame->pivotY, entity->scale,3238entity->scale, spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY,3239scriptInfo->spriteSheetID);3240}3241break;3242case FX_FLIP:3243switch (entity->direction) {3244default:3245case FLIP_NONE:3246DrawSpriteFlipped((scriptEng.operands[2] >> 16) - xScrollOffset + spriteFrame->pivotX,3247(scriptEng.operands[3] >> 16) - yScrollOffset + spriteFrame->pivotY, spriteFrame->width,3248spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, FLIP_NONE, scriptInfo->spriteSheetID);3249break;3250case FLIP_X:3251DrawSpriteFlipped((scriptEng.operands[2] >> 16) - xScrollOffset - spriteFrame->width - spriteFrame->pivotX,3252(scriptEng.operands[3] >> 16) - yScrollOffset + spriteFrame->pivotY, spriteFrame->width,3253spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, FLIP_X, scriptInfo->spriteSheetID);3254break;3255case FLIP_Y:3256DrawSpriteFlipped((scriptEng.operands[2] >> 16) - xScrollOffset + spriteFrame->pivotX,3257(scriptEng.operands[3] >> 16) - yScrollOffset - spriteFrame->height - spriteFrame->pivotY,3258spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, FLIP_Y,3259scriptInfo->spriteSheetID);3260break;3261case FLIP_XY:3262DrawSpriteFlipped((scriptEng.operands[2] >> 16) - xScrollOffset - spriteFrame->width - spriteFrame->pivotX,3263(scriptEng.operands[3] >> 16) - yScrollOffset - spriteFrame->height - spriteFrame->pivotY,3264spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, FLIP_XY,3265scriptInfo->spriteSheetID);3266break;3267}3268break;3269}3270break;3271case FUNC_DRAWSPRITESCREENFX:3272opcodeSize = 0;3273spriteFrame = &scriptFrames[scriptInfo->frameListOffset + scriptEng.operands[0]];3274switch (scriptEng.operands[1]) {3275default: break;3276case FX_SCALE:3277DrawSpriteScaled(entity->direction, scriptEng.operands[2], scriptEng.operands[3], -spriteFrame->pivotX, -spriteFrame->pivotY,3278entity->scale, entity->scale, spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY,3279scriptInfo->spriteSheetID);3280break;3281case FX_ROTATE:3282DrawSpriteRotated(entity->direction, scriptEng.operands[2], scriptEng.operands[3], -spriteFrame->pivotX, -spriteFrame->pivotY,3283spriteFrame->sprX, spriteFrame->sprY, spriteFrame->width, spriteFrame->height, entity->rotation,3284scriptInfo->spriteSheetID);3285break;3286case FX_ROTOZOOM:3287DrawSpriteRotozoom(entity->direction, scriptEng.operands[2], scriptEng.operands[3], -spriteFrame->pivotX,3288-spriteFrame->pivotY, spriteFrame->sprX, spriteFrame->sprY, spriteFrame->width, spriteFrame->height,3289entity->rotation, entity->scale, scriptInfo->spriteSheetID);3290break;3291case FX_INK:3292switch (entity->inkEffect) {3293case INK_NONE:3294DrawSprite(scriptEng.operands[2] + spriteFrame->pivotX, scriptEng.operands[3] + spriteFrame->pivotY,3295spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);3296break;3297case INK_BLEND:3298DrawBlendedSprite(scriptEng.operands[2] + spriteFrame->pivotX, scriptEng.operands[3] + spriteFrame->pivotY,3299spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY,3300scriptInfo->spriteSheetID);3301break;3302case INK_ALPHA:3303DrawAlphaBlendedSprite(scriptEng.operands[2] + spriteFrame->pivotX, scriptEng.operands[3] + spriteFrame->pivotY,3304spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, entity->alpha,3305scriptInfo->spriteSheetID);3306break;3307case INK_ADD:3308DrawAdditiveBlendedSprite(scriptEng.operands[2] + spriteFrame->pivotX, scriptEng.operands[3] + spriteFrame->pivotY,3309spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY,3310entity->alpha, scriptInfo->spriteSheetID);3311break;3312case INK_SUB:3313DrawSubtractiveBlendedSprite(scriptEng.operands[2] + spriteFrame->pivotX, scriptEng.operands[3] + spriteFrame->pivotY,3314spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY,3315entity->alpha, scriptInfo->spriteSheetID);3316break;3317}3318break;3319case FX_TINT:3320if (entity->inkEffect == INK_ALPHA) {3321DrawScaledTintMask(entity->direction, scriptEng.operands[2], scriptEng.operands[3], -spriteFrame->pivotX,3322-spriteFrame->pivotY, entity->scale, entity->scale, spriteFrame->width, spriteFrame->height,3323spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);3324}3325else {3326DrawSpriteScaled(entity->direction, scriptEng.operands[2], scriptEng.operands[3], -spriteFrame->pivotX,3327-spriteFrame->pivotY, entity->scale, entity->scale, spriteFrame->width, spriteFrame->height,3328spriteFrame->sprX, spriteFrame->sprY, scriptInfo->spriteSheetID);3329}3330break;3331case FX_FLIP:3332switch (entity->direction) {3333default:3334case FLIP_NONE:3335DrawSpriteFlipped(scriptEng.operands[2] + spriteFrame->pivotX, scriptEng.operands[3] + spriteFrame->pivotY,3336spriteFrame->width, spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, FLIP_NONE,3337scriptInfo->spriteSheetID);3338break;3339case FLIP_X:3340DrawSpriteFlipped(scriptEng.operands[2] - spriteFrame->width - spriteFrame->pivotX,3341scriptEng.operands[3] + spriteFrame->pivotY, spriteFrame->width, spriteFrame->height,3342spriteFrame->sprX, spriteFrame->sprY, FLIP_X, scriptInfo->spriteSheetID);3343break;3344case FLIP_Y:3345DrawSpriteFlipped(scriptEng.operands[2] + spriteFrame->pivotX,3346scriptEng.operands[3] - spriteFrame->height - spriteFrame->pivotY, spriteFrame->width,3347spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, FLIP_Y, scriptInfo->spriteSheetID);3348break;3349case FLIP_XY:3350DrawSpriteFlipped(scriptEng.operands[2] - spriteFrame->width - spriteFrame->pivotX,3351scriptEng.operands[3] - spriteFrame->height - spriteFrame->pivotY, spriteFrame->width,3352spriteFrame->height, spriteFrame->sprX, spriteFrame->sprY, FLIP_XY, scriptInfo->spriteSheetID);3353break;3354}3355break;3356}3357break;3358case FUNC_LOADANIMATION:3359opcodeSize = 0;3360scriptInfo->animFile = AddAnimationFile(scriptText);3361break;3362case FUNC_SETUPMENU: {3363opcodeSize = 0;3364TextMenu *menu = &gameMenu[scriptEng.operands[0]];3365SetupTextMenu(menu, scriptEng.operands[1]);3366menu->selectionCount = scriptEng.operands[2];3367menu->alignment = scriptEng.operands[3];3368break;3369}3370case FUNC_ADDMENUENTRY: {3371opcodeSize = 0;3372TextMenu *menu = &gameMenu[scriptEng.operands[0]];3373menu->entryHighlight[menu->rowCount] = scriptEng.operands[2];3374AddTextMenuEntry(menu, scriptText);3375break;3376}3377case FUNC_EDITMENUENTRY: {3378opcodeSize = 0;3379TextMenu *menu = &gameMenu[scriptEng.operands[0]];3380EditTextMenuEntry(menu, scriptText, scriptEng.operands[2]);3381menu->entryHighlight[scriptEng.operands[2]] = scriptEng.operands[3];3382break;3383}3384case FUNC_LOADSTAGE:3385opcodeSize = 0;3386stageMode = STAGEMODE_LOAD;3387break;3388case FUNC_DRAWRECT:3389opcodeSize = 0;3390DrawRectangle(scriptEng.operands[0], scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3], scriptEng.operands[4],3391scriptEng.operands[5], scriptEng.operands[6], scriptEng.operands[7]);3392break;3393case FUNC_RESETOBJECTENTITY: {3394opcodeSize = 0;3395Entity *newEnt = &objectEntityList[scriptEng.operands[0]];3396newEnt->type = scriptEng.operands[1];3397newEnt->propertyValue = scriptEng.operands[2];3398newEnt->XPos = scriptEng.operands[3];3399newEnt->YPos = scriptEng.operands[4];3400newEnt->direction = FLIP_NONE;3401newEnt->frame = 0;3402newEnt->priority = PRIORITY_BOUNDS;3403newEnt->rotation = 0;3404newEnt->state = 0;3405newEnt->drawOrder = 3;3406newEnt->scale = 512;3407newEnt->inkEffect = INK_NONE;3408newEnt->values[0] = 0;3409newEnt->values[1] = 0;3410newEnt->values[2] = 0;3411newEnt->values[3] = 0;3412newEnt->values[4] = 0;3413newEnt->values[5] = 0;3414newEnt->values[6] = 0;3415newEnt->values[7] = 0;3416break;3417}3418case FUNC_PLAYEROBJECTCOLLISION:3419opcodeSize = 0;3420switch (scriptEng.operands[0]) {3421default: break;3422case C_TOUCH:3423scriptEng.operands[5] = entity->XPos >> 16;3424scriptEng.operands[6] = entity->YPos >> 16;3425TouchCollision(scriptEng.operands[5] + scriptEng.operands[1], scriptEng.operands[6] + scriptEng.operands[2],3426scriptEng.operands[5] + scriptEng.operands[3], scriptEng.operands[6] + scriptEng.operands[4]);3427break;3428case C_BOX:3429BoxCollision(entity->XPos + (scriptEng.operands[1] << 16), entity->YPos + (scriptEng.operands[2] << 16),3430entity->XPos + (scriptEng.operands[3] << 16), entity->YPos + (scriptEng.operands[4] << 16));3431break;3432case C_BOX2:3433BoxCollision2(entity->XPos + (scriptEng.operands[1] << 16), entity->YPos + (scriptEng.operands[2] << 16),3434entity->XPos + (scriptEng.operands[3] << 16), entity->YPos + (scriptEng.operands[4] << 16));3435break;3436case C_PLATFORM:3437PlatformCollision(entity->XPos + (scriptEng.operands[1] << 16), entity->YPos + (scriptEng.operands[2] << 16),3438entity->XPos + (scriptEng.operands[3] << 16), entity->YPos + (scriptEng.operands[4] << 16));3439break;3440case C_BOX3:3441BoxCollision3(entity->XPos + (scriptEng.operands[1] << 16), entity->YPos + (scriptEng.operands[2] << 16),3442entity->XPos + (scriptEng.operands[3] << 16), entity->YPos + (scriptEng.operands[4] << 16));3443break;3444case C_ENEMY:3445scriptEng.operands[5] = entity->XPos >> 16;3446scriptEng.operands[6] = entity->YPos >> 16;3447EnemyCollision(scriptEng.operands[5] + scriptEng.operands[1], scriptEng.operands[6] + scriptEng.operands[2],3448scriptEng.operands[5] + scriptEng.operands[3], scriptEng.operands[6] + scriptEng.operands[4]);3449break;3450}3451break;3452case FUNC_CREATETEMPOBJECT: {3453opcodeSize = 0;3454if (objectEntityList[scriptEng.arrayPosition[2]].type > 0 && ++scriptEng.arrayPosition[2] == LEGACY_v3_ENTITY_COUNT)3455scriptEng.arrayPosition[2] = LEGACY_v3_TEMPENTITY_START;3456Entity *temp = &objectEntityList[scriptEng.arrayPosition[2]];3457temp->type = scriptEng.operands[0];3458temp->propertyValue = scriptEng.operands[1];3459temp->XPos = scriptEng.operands[2];3460temp->YPos = scriptEng.operands[3];3461temp->direction = FLIP_NONE;3462temp->frame = 0;3463temp->priority = PRIORITY_ACTIVE;3464temp->rotation = 0;3465temp->state = 0;3466temp->drawOrder = 3;3467temp->scale = 512;3468temp->inkEffect = INK_NONE;3469temp->alpha = 0;3470temp->animation = 0;3471temp->prevAnimation = 0;3472temp->animationSpeed = 0;3473temp->animationTimer = 0;3474temp->values[0] = 0;3475temp->values[1] = 0;3476temp->values[2] = 0;3477temp->values[3] = 0;3478temp->values[4] = 0;3479temp->values[5] = 0;3480temp->values[6] = 0;3481temp->values[7] = 0;3482break;3483}3484case FUNC_BINDPLAYERTOOBJECT: {3485opcodeSize = 0;3486Entity *pEnt = &objectEntityList[scriptEng.operands[1]];34873488playerList[scriptEng.operands[0]].animationFile = scriptInfo->animFile;3489playerList[scriptEng.operands[0]].boundEntity = pEnt;3490playerList[scriptEng.operands[0]].entityNo = scriptEng.operands[1];3491break;3492}3493case FUNC_PLAYERTILECOLLISION:3494opcodeSize = 0;3495if (player->tileCollisions) {3496ProcessPlayerTileCollisions(player);3497}3498else {3499player->XPos += player->XVelocity;3500player->YPos += player->YVelocity;3501}3502break;3503case FUNC_PROCESSPLAYERCONTROL:3504opcodeSize = 0;3505ProcessPlayerControl(player);3506break;3507case FUNC_PROCESSANIMATION:3508ProcessObjectAnimation(scriptInfo, entity);3509opcodeSize = 0;3510break;3511case FUNC_DRAWOBJECTANIMATION:3512opcodeSize = 0;3513DrawObjectAnimation(scriptInfo, entity, (entity->XPos >> 16) - xScrollOffset, (entity->YPos >> 16) - yScrollOffset);3514break;3515case FUNC_DRAWPLAYERANIMATION:3516opcodeSize = 0;3517if (player->visible) {3518if (currentCamera->target == activePlayer)3519DrawObjectAnimation(scriptInfo, entity, player->screenXPos, player->screenYPos);3520else3521DrawObjectAnimation(scriptInfo, entity, (player->XPos >> 16) - xScrollOffset, (player->YPos >> 16) - yScrollOffset);3522}3523break;3524case FUNC_SETMUSICTRACK:3525opcodeSize = 0;3526if (scriptEng.operands[2] <= 1)3527SetMusicTrack(scriptText, scriptEng.operands[1], scriptEng.operands[2], 0);3528else3529SetMusicTrack(scriptText, scriptEng.operands[1], true, scriptEng.operands[2]);3530break;3531case FUNC_PLAYMUSIC:3532opcodeSize = 0;3533PlayMusic(scriptEng.operands[0]);3534break;3535case FUNC_STOPMUSIC:3536opcodeSize = 0;3537StopMusic();3538break;3539case FUNC_PLAYSFX:3540opcodeSize = 0;3541PlaySfx(scriptEng.operands[0], scriptEng.operands[1]);3542break;3543case FUNC_STOPSFX:3544opcodeSize = 0;3545StopSfx(scriptEng.operands[0]);3546break;3547case FUNC_SETSFXATTRIBUTES: {3548opcodeSize = 0;3549int32 channelID = PlaySfx(scriptEng.operands[0], false);3550SetSfxAttributes(channelID, scriptEng.operands[1], scriptEng.operands[2]);3551break;3552}3553case FUNC_OBJECTTILECOLLISION:3554opcodeSize = 0;3555switch (scriptEng.operands[0]) {3556default: break;3557case CSIDE_FLOOR: ObjectFloorCollision(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3558case CSIDE_LWALL: ObjectLWallCollision(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3559case CSIDE_RWALL: ObjectRWallCollision(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3560case CSIDE_ROOF: ObjectRoofCollision(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3561}3562break;3563case FUNC_OBJECTTILEGRIP:3564opcodeSize = 0;3565switch (scriptEng.operands[0]) {3566default: break;3567case CSIDE_FLOOR: ObjectFloorGrip(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3568case CSIDE_LWALL: ObjectLWallGrip(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3569case CSIDE_RWALL: ObjectRWallGrip(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3570case CSIDE_ROOF: ObjectRoofGrip(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3571case CSIDE_ENTITY: ObjectEntityGrip(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3572}3573break;3574case FUNC_LOADVIDEO:3575opcodeSize = 0;3576StrAdd(scriptText, ".ogv");3577LoadVideo(scriptText, 0.0, VideoSkipCB);3578break;3579case FUNC_NEXTVIDEOFRAME: opcodeSize = 0; break;3580case FUNC_PLAYSTAGESFX:3581opcodeSize = 0;3582PlaySfx(globalSFXCount + scriptEng.operands[0], scriptEng.operands[1]);3583break;3584case FUNC_STOPSTAGESFX:3585opcodeSize = 0;3586StopSfx(globalSFXCount + scriptEng.operands[0]);3587break;3588case FUNC_NOT: scriptEng.operands[0] = ~scriptEng.operands[0]; break;3589case FUNC_DRAW3DSCENE:3590opcodeSize = 0;3591TransformVertexBuffer();3592Sort3DDrawList();3593Draw3DScene(scriptInfo->spriteSheetID);3594break;3595case FUNC_SETIDENTITYMATRIX:3596opcodeSize = 0;3597switch (scriptEng.operands[0]) {3598case MAT_WORLD: SetIdentityMatrix(&matWorld); break;3599case MAT_VIEW: SetIdentityMatrix(&matView); break;3600case MAT_TEMP: SetIdentityMatrix(&matTemp); break;3601}3602break;3603case FUNC_MATRIXMULTIPLY:3604opcodeSize = 0;3605switch (scriptEng.operands[0]) {3606case MAT_WORLD:3607switch (scriptEng.operands[1]) {3608case MAT_WORLD: MatrixMultiply(&matWorld, &matWorld); break;3609case MAT_VIEW: MatrixMultiply(&matWorld, &matView); break;3610case MAT_TEMP: MatrixMultiply(&matWorld, &matTemp); break;3611}3612break;3613case MAT_VIEW:3614switch (scriptEng.operands[1]) {3615case MAT_WORLD: MatrixMultiply(&matView, &matWorld); break;3616case MAT_VIEW: MatrixMultiply(&matView, &matView); break;3617case MAT_TEMP: MatrixMultiply(&matView, &matTemp); break;3618}3619break;3620case MAT_TEMP:3621switch (scriptEng.operands[1]) {3622case MAT_WORLD: MatrixMultiply(&matTemp, &matWorld); break;3623case MAT_VIEW: MatrixMultiply(&matTemp, &matView); break;3624case MAT_TEMP: MatrixMultiply(&matTemp, &matTemp); break;3625}3626break;3627}3628break;3629case FUNC_MATRIXTRANSLATEXYZ:3630opcodeSize = 0;3631switch (scriptEng.operands[0]) {3632case MAT_WORLD: MatrixTranslateXYZ(&matWorld, scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3633case MAT_VIEW: MatrixTranslateXYZ(&matView, scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3634case MAT_TEMP: MatrixTranslateXYZ(&matTemp, scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3635}3636break;3637case FUNC_MATRIXSCALEXYZ:3638opcodeSize = 0;3639switch (scriptEng.operands[0]) {3640case MAT_WORLD: MatrixScaleXYZ(&matWorld, scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3641case MAT_VIEW: MatrixScaleXYZ(&matView, scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3642case MAT_TEMP: MatrixScaleXYZ(&matTemp, scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3643}3644break;3645case FUNC_MATRIXROTATEX:3646opcodeSize = 0;3647switch (scriptEng.operands[0]) {3648case MAT_WORLD: MatrixRotateX(&matWorld, scriptEng.operands[1]); break;3649case MAT_VIEW: MatrixRotateX(&matView, scriptEng.operands[1]); break;3650case MAT_TEMP: MatrixRotateX(&matTemp, scriptEng.operands[1]); break;3651}3652break;3653case FUNC_MATRIXROTATEY:3654opcodeSize = 0;3655switch (scriptEng.operands[0]) {3656case MAT_WORLD: MatrixRotateY(&matWorld, scriptEng.operands[1]); break;3657case MAT_VIEW: MatrixRotateY(&matView, scriptEng.operands[1]); break;3658case MAT_TEMP: MatrixRotateY(&matTemp, scriptEng.operands[1]); break;3659}3660break;3661case FUNC_MATRIXROTATEZ:3662opcodeSize = 0;3663switch (scriptEng.operands[0]) {3664case MAT_WORLD: MatrixRotateZ(&matWorld, scriptEng.operands[1]); break;3665case MAT_VIEW: MatrixRotateZ(&matView, scriptEng.operands[1]); break;3666case MAT_TEMP: MatrixRotateZ(&matTemp, scriptEng.operands[1]); break;3667}3668break;3669case FUNC_MATRIXROTATEXYZ:3670opcodeSize = 0;3671switch (scriptEng.operands[0]) {3672case MAT_WORLD: MatrixRotateXYZ(&matWorld, scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3673case MAT_VIEW: MatrixRotateXYZ(&matView, scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3674case MAT_TEMP: MatrixRotateXYZ(&matTemp, scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break;3675}3676break;3677case FUNC_TRANSFORMVERTICES:3678opcodeSize = 0;3679switch (scriptEng.operands[0]) {3680case MAT_WORLD: TransformVerticies(&matWorld, scriptEng.operands[1], scriptEng.operands[2]); break;3681case MAT_VIEW: TransformVerticies(&matView, scriptEng.operands[1], scriptEng.operands[2]); break;3682case MAT_TEMP: TransformVerticies(&matTemp, scriptEng.operands[1], scriptEng.operands[2]); break;3683}3684break;3685case FUNC_CALLFUNCTION: {3686opcodeSize = 0;3687functionStack[functionStackPos++] = scriptCodePtr;3688functionStack[functionStackPos++] = jumpTableStart;3689functionStack[functionStackPos++] = scriptCodeStart;3690scriptCodeStart = scriptFunctionList[scriptEng.operands[0]].ptr.scriptCodePtr;3691jumpTableStart = scriptFunctionList[scriptEng.operands[0]].ptr.jumpTablePtr;3692scriptCodePtr = scriptCodeStart;3693} break;3694case FUNC_ENDFUNCTION:3695opcodeSize = 0;3696scriptCodeStart = functionStack[--functionStackPos];3697jumpTableStart = functionStack[--functionStackPos];3698scriptCodePtr = functionStack[--functionStackPos];3699break;3700case FUNC_SETLAYERDEFORMATION:3701opcodeSize = 0;3702SetLayerDeformation(scriptEng.operands[0], scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3], scriptEng.operands[4],3703scriptEng.operands[5]);3704break;3705case FUNC_CHECKTOUCHRECT:3706opcodeSize = 0;3707scriptEng.checkResult = -1;37083709for (int32 f = 0; f < touchInfo.count; ++f) {3710if (touchInfo.down[f]) {3711int32 touchX = (int32)(touchInfo.x[f] * SCREEN_XSIZE);3712int32 touchY = (int32)(touchInfo.y[f] * SCREEN_YSIZE);37133714if (touchX > scriptEng.operands[0] && touchX < scriptEng.operands[2] && touchY > scriptEng.operands[1]3715&& touchY < scriptEng.operands[3]) {3716scriptEng.checkResult = f;3717}3718}3719}3720break;3721case FUNC_GETTILELAYERENTRY:3722scriptEng.operands[0] = stageLayouts[scriptEng.operands[1]].tiles[scriptEng.operands[2] + 0x100 * scriptEng.operands[3]];3723break;3724case FUNC_SETTILELAYERENTRY:3725stageLayouts[scriptEng.operands[1]].tiles[scriptEng.operands[2] + 0x100 * scriptEng.operands[3]] = scriptEng.operands[0];3726break;3727case FUNC_GETBIT: scriptEng.operands[0] = (scriptEng.operands[1] & (1 << scriptEng.operands[2])) >> scriptEng.operands[2]; break;3728case FUNC_SETBIT:3729if (scriptEng.operands[2] <= 0)3730scriptEng.operands[0] &= ~(1 << scriptEng.operands[1]);3731else3732scriptEng.operands[0] |= 1 << scriptEng.operands[1];3733break;3734case FUNC_PAUSEMUSIC:3735opcodeSize = 0;3736PauseChannel(musicChannel);3737break;3738case FUNC_RESUMEMUSIC:3739opcodeSize = 0;3740ResumeChannel(musicChannel);3741break;3742case FUNC_CLEARDRAWLIST:3743opcodeSize = 0;3744drawListEntries[scriptEng.operands[0]].listSize = 0;3745break;3746case FUNC_ADDDRAWLISTENTITYREF: {3747opcodeSize = 0;3748drawListEntries[scriptEng.operands[0]].entityRefs[drawListEntries[scriptEng.operands[0]].listSize++] = scriptEng.operands[1];3749break;3750}3751case FUNC_GETDRAWLISTENTITYREF: scriptEng.operands[0] = drawListEntries[scriptEng.operands[1]].entityRefs[scriptEng.operands[2]]; break;3752case FUNC_SETDRAWLISTENTITYREF:3753opcodeSize = 0;3754drawListEntries[scriptEng.operands[1]].entityRefs[scriptEng.operands[2]] = scriptEng.operands[0];3755break;3756case FUNC_GET16X16TILEINFO: {3757scriptEng.operands[4] = scriptEng.operands[1] >> 7;3758scriptEng.operands[5] = scriptEng.operands[2] >> 7;3759scriptEng.operands[6] = stageLayouts[0].tiles[scriptEng.operands[4] + (scriptEng.operands[5] << 8)] << 6;3760scriptEng.operands[6] += ((scriptEng.operands[1] & 0x7F) >> 4) + 8 * ((scriptEng.operands[2] & 0x7F) >> 4);3761int32 index = tiles128x128.tileIndex[scriptEng.operands[6]];3762switch (scriptEng.operands[3]) {3763case TILEINFO_INDEX: scriptEng.operands[0] = tiles128x128.tileIndex[scriptEng.operands[6]]; break;3764case TILEINFO_DIRECTION: scriptEng.operands[0] = tiles128x128.direction[scriptEng.operands[6]]; break;3765case TILEINFO_VISUALPLANE: scriptEng.operands[0] = tiles128x128.visualPlane[scriptEng.operands[6]]; break;3766case TILEINFO_SOLIDITYA: scriptEng.operands[0] = tiles128x128.collisionFlags[0][scriptEng.operands[6]]; break;3767case TILEINFO_SOLIDITYB: scriptEng.operands[0] = tiles128x128.collisionFlags[1][scriptEng.operands[6]]; break;3768case TILEINFO_FLAGSA: scriptEng.operands[0] = collisionMasks[0].flags[index]; break;3769case TILEINFO_ANGLEA: scriptEng.operands[0] = collisionMasks[0].angles[index]; break;3770case TILEINFO_FLAGSB: scriptEng.operands[0] = collisionMasks[1].flags[index]; break;3771case TILEINFO_ANGLEB: scriptEng.operands[0] = collisionMasks[1].angles[index]; break;3772default: break;3773}3774break;3775}3776case FUNC_COPY16X16TILE:3777opcodeSize = 0;3778Copy16x16Tile(scriptEng.operands[0], scriptEng.operands[1]);3779break;3780case FUNC_SET16X16TILEINFO: {3781scriptEng.operands[4] = scriptEng.operands[1] >> 7;3782scriptEng.operands[5] = scriptEng.operands[2] >> 7;3783scriptEng.operands[6] = stageLayouts[0].tiles[scriptEng.operands[4] + (scriptEng.operands[5] << 8)] << 6;3784scriptEng.operands[6] += ((scriptEng.operands[1] & 0x7F) >> 4) + 8 * ((scriptEng.operands[2] & 0x7F) >> 4);3785switch (scriptEng.operands[3]) {3786case TILEINFO_INDEX:3787tiles128x128.tileIndex[scriptEng.operands[6]] = scriptEng.operands[0];3788tiles128x128.gfxDataPos[scriptEng.operands[6]] = scriptEng.operands[0] << 8;3789break;3790case TILEINFO_DIRECTION: tiles128x128.direction[scriptEng.operands[6]] = scriptEng.operands[0]; break;3791case TILEINFO_VISUALPLANE: tiles128x128.visualPlane[scriptEng.operands[6]] = scriptEng.operands[0]; break;3792case TILEINFO_SOLIDITYA: tiles128x128.collisionFlags[0][scriptEng.operands[6]] = scriptEng.operands[0]; break;3793case TILEINFO_SOLIDITYB: tiles128x128.collisionFlags[1][scriptEng.operands[6]] = scriptEng.operands[0]; break;3794case TILEINFO_FLAGSA: collisionMasks[1].flags[tiles128x128.tileIndex[scriptEng.operands[6]]] = scriptEng.operands[0]; break;3795case TILEINFO_ANGLEA: collisionMasks[1].angles[tiles128x128.tileIndex[scriptEng.operands[6]]] = scriptEng.operands[0]; break;3796default: break;3797}3798break;3799}3800case FUNC_GETANIMATIONBYNAME: {3801AnimationFile *animFile = scriptInfo->animFile;3802scriptEng.operands[0] = -1;3803int32 id = 0;3804while (scriptEng.operands[0] == -1) {3805SpriteAnimation *anim = &animationList[animFile->aniListOffset + id];3806if (StrComp(scriptText, anim->name))3807scriptEng.operands[0] = id;3808else if (++id == animFile->animCount)3809scriptEng.operands[0] = 0;3810}3811break;3812}3813case FUNC_READSAVERAM:3814opcodeSize = 0;3815scriptEng.checkResult = ReadSaveRAM();3816break;3817case FUNC_WRITESAVERAM:3818opcodeSize = 0;3819scriptEng.checkResult = WriteSaveRAM();3820break;3821case FUNC_LOADTEXTFONT:3822opcodeSize = 0;3823LoadFontFile(scriptText);3824break;3825case FUNC_LOADTEXTFILE: {3826opcodeSize = 0;3827TextMenu *menu = &gameMenu[scriptEng.operands[0]];3828LoadTextFile(menu, scriptText, scriptEng.operands[2] != 0);3829break;3830}3831case FUNC_DRAWTEXT: {3832opcodeSize = 0;3833textMenuSurfaceNo = scriptInfo->spriteSheetID;3834TextMenu *menu = &gameMenu[scriptEng.operands[0]];3835DrawBitmapText(menu, scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3], scriptEng.operands[4],3836scriptEng.operands[5], scriptEng.operands[6]);3837break;3838}3839case FUNC_GETTEXTINFO: {3840TextMenu *menu = &gameMenu[scriptEng.operands[1]];3841switch (scriptEng.operands[2]) {3842case TEXTINFO_TEXTDATA:3843scriptEng.operands[0] = menu->textData[menu->entryStart[scriptEng.operands[3]] + scriptEng.operands[4]];3844break;3845case TEXTINFO_TEXTSIZE: scriptEng.operands[0] = menu->entrySize[scriptEng.operands[3]]; break;3846case TEXTINFO_ROWCOUNT: scriptEng.operands[0] = menu->rowCount; break;3847}3848break;3849}3850case FUNC_GETVERSIONNUMBER: {3851opcodeSize = 0;3852TextMenu *menu = &gameMenu[scriptEng.operands[0]];3853menu->entryHighlight[menu->rowCount] = scriptEng.operands[1];3854AddTextMenuEntry(menu, gameVerInfo.version);3855break;3856}3857case FUNC_SETACHIEVEMENT:3858opcodeSize = 0;3859SetAchievement(scriptEng.operands[0], scriptEng.operands[1]);3860break;3861case FUNC_SETLEADERBOARD:3862opcodeSize = 0;3863SetLeaderboard(scriptEng.operands[0], scriptEng.operands[1]);3864break;3865case FUNC_LOADONLINEMENU:3866opcodeSize = 0;3867switch (scriptEng.operands[0]) {3868default: break;3869case 0: LoadAchievementsMenu(); break;3870case 1: LoadLeaderboardsMenu(); break;3871}3872break;3873case FUNC_ENGINECALLBACK:3874opcodeSize = 0;3875RetroEngineCallback(scriptEng.operands[0]);3876break;3877#if LEGACY_RETRO_USE_HAPTICS3878case FUNC_HAPTICEFFECT: opcodeSize = 0; break;3879#endif3880}38813882// Set Values3883if (opcodeSize > 0)3884scriptCodePtr -= scriptCodePtr - scriptCodeOffset;3885for (int32 i = 0; i < opcodeSize; ++i) {3886int32 opcodeType = scriptCode[scriptCodePtr++];3887if (opcodeType == SCRIPTVAR_VAR) {3888int32 arrayVal = 0;3889switch (scriptCode[scriptCodePtr++]) { // variable3890case VARARR_NONE: arrayVal = objectLoop; break;3891case VARARR_ARRAY:3892if (scriptCode[scriptCodePtr++] == 1)3893arrayVal = scriptEng.arrayPosition[scriptCode[scriptCodePtr++]];3894else3895arrayVal = scriptCode[scriptCodePtr++];3896break;3897case VARARR_ENTNOPLUS1:3898if (scriptCode[scriptCodePtr++] == 1)3899arrayVal = scriptEng.arrayPosition[scriptCode[scriptCodePtr++]] + objectLoop;3900else3901arrayVal = scriptCode[scriptCodePtr++] + objectLoop;3902break;3903case VARARR_ENTNOMINUS1:3904if (scriptCode[scriptCodePtr++] == 1)3905arrayVal = objectLoop - scriptEng.arrayPosition[scriptCode[scriptCodePtr++]];3906else3907arrayVal = objectLoop - scriptCode[scriptCodePtr++];3908break;3909default: break;3910}39113912// Variables3913switch (scriptCode[scriptCodePtr++]) {3914default: break;3915case VAR_TEMPVALUE0: scriptEng.tempValue[0] = scriptEng.operands[i]; break;3916case VAR_TEMPVALUE1: scriptEng.tempValue[1] = scriptEng.operands[i]; break;3917case VAR_TEMPVALUE2: scriptEng.tempValue[2] = scriptEng.operands[i]; break;3918case VAR_TEMPVALUE3: scriptEng.tempValue[3] = scriptEng.operands[i]; break;3919case VAR_TEMPVALUE4: scriptEng.tempValue[4] = scriptEng.operands[i]; break;3920case VAR_TEMPVALUE5: scriptEng.tempValue[5] = scriptEng.operands[i]; break;3921case VAR_TEMPVALUE6: scriptEng.tempValue[6] = scriptEng.operands[i]; break;3922case VAR_TEMPVALUE7: scriptEng.tempValue[7] = scriptEng.operands[i]; break;3923case VAR_CHECKRESULT: scriptEng.checkResult = scriptEng.operands[i]; break;3924case VAR_ARRAYPOS0: scriptEng.arrayPosition[0] = scriptEng.operands[i]; break;3925case VAR_ARRAYPOS1: scriptEng.arrayPosition[1] = scriptEng.operands[i]; break;3926case VAR_GLOBAL: globalVariables[arrayVal].value = scriptEng.operands[i]; break;3927case VAR_OBJECTENTITYNO: break;3928case VAR_OBJECTTYPE: {3929objectEntityList[arrayVal].type = scriptEng.operands[i];3930break;3931}3932case VAR_OBJECTPROPERTYVALUE: {3933objectEntityList[arrayVal].propertyValue = scriptEng.operands[i];3934break;3935}3936case VAR_OBJECTXPOS: {3937objectEntityList[arrayVal].XPos = scriptEng.operands[i];3938break;3939}3940case VAR_OBJECTYPOS: {3941objectEntityList[arrayVal].YPos = scriptEng.operands[i];3942break;3943}3944case VAR_OBJECTIXPOS: {3945objectEntityList[arrayVal].XPos = scriptEng.operands[i] << 16;3946break;3947}3948case VAR_OBJECTIYPOS: {3949objectEntityList[arrayVal].YPos = scriptEng.operands[i] << 16;3950break;3951}3952case VAR_OBJECTSTATE: {3953objectEntityList[arrayVal].state = scriptEng.operands[i];3954break;3955}3956case VAR_OBJECTROTATION: {3957objectEntityList[arrayVal].rotation = scriptEng.operands[i];3958break;3959}3960case VAR_OBJECTSCALE: {3961objectEntityList[arrayVal].scale = scriptEng.operands[i];3962break;3963}3964case VAR_OBJECTPRIORITY: {3965objectEntityList[arrayVal].priority = scriptEng.operands[i];3966break;3967}3968case VAR_OBJECTDRAWORDER: {3969objectEntityList[arrayVal].drawOrder = scriptEng.operands[i];3970break;3971}3972case VAR_OBJECTDIRECTION: {3973objectEntityList[arrayVal].direction = scriptEng.operands[i];3974break;3975}3976case VAR_OBJECTINKEFFECT: {3977objectEntityList[arrayVal].inkEffect = scriptEng.operands[i];3978break;3979}3980case VAR_OBJECTALPHA: {3981objectEntityList[arrayVal].alpha = scriptEng.operands[i];3982break;3983}3984case VAR_OBJECTFRAME: {3985objectEntityList[arrayVal].frame = scriptEng.operands[i];3986break;3987}3988case VAR_OBJECTANIMATION: {3989objectEntityList[arrayVal].animation = scriptEng.operands[i];3990break;3991}3992case VAR_OBJECTPREVANIMATION: {3993objectEntityList[arrayVal].prevAnimation = scriptEng.operands[i];3994break;3995}3996case VAR_OBJECTANIMATIONSPEED: {3997objectEntityList[arrayVal].animationSpeed = scriptEng.operands[i];3998break;3999}4000case VAR_OBJECTANIMATIONTIMER: {4001objectEntityList[arrayVal].animationTimer = scriptEng.operands[i];4002break;4003}4004case VAR_OBJECTVALUE0: {4005objectEntityList[arrayVal].values[0] = scriptEng.operands[i];4006break;4007}4008case VAR_OBJECTVALUE1: {4009objectEntityList[arrayVal].values[1] = scriptEng.operands[i];4010break;4011}4012case VAR_OBJECTVALUE2: {4013objectEntityList[arrayVal].values[2] = scriptEng.operands[i];4014break;4015}4016case VAR_OBJECTVALUE3: {4017objectEntityList[arrayVal].values[3] = scriptEng.operands[i];4018break;4019}4020case VAR_OBJECTVALUE4: {4021objectEntityList[arrayVal].values[4] = scriptEng.operands[i];4022break;4023}4024case VAR_OBJECTVALUE5: {4025objectEntityList[arrayVal].values[5] = scriptEng.operands[i];4026break;4027}4028case VAR_OBJECTVALUE6: {4029objectEntityList[arrayVal].values[6] = scriptEng.operands[i];4030break;4031}4032case VAR_OBJECTVALUE7: {4033objectEntityList[arrayVal].values[7] = scriptEng.operands[i];4034break;4035}4036case VAR_OBJECTOUTOFBOUNDS: break;4037case VAR_PLAYERSTATE: {4038playerList[activePlayer].boundEntity->state = scriptEng.operands[i];4039break;4040}4041case VAR_PLAYERCONTROLMODE: {4042playerList[activePlayer].controlMode = scriptEng.operands[i];4043break;4044}4045case VAR_PLAYERCONTROLLOCK: {4046playerList[activePlayer].controlLock = scriptEng.operands[i];4047break;4048}4049case VAR_PLAYERCOLLISIONMODE: {4050playerList[activePlayer].collisionMode = scriptEng.operands[i];4051break;4052}4053case VAR_PLAYERCOLLISIONPLANE: {4054playerList[activePlayer].collisionPlane = scriptEng.operands[i];4055break;4056}4057case VAR_PLAYERXPOS: {4058playerList[activePlayer].XPos = scriptEng.operands[i];4059break;4060}4061case VAR_PLAYERYPOS: {4062playerList[activePlayer].YPos = scriptEng.operands[i];4063break;4064}4065case VAR_PLAYERIXPOS: {4066playerList[activePlayer].XPos = scriptEng.operands[i] << 16;4067break;4068}4069case VAR_PLAYERIYPOS: {4070playerList[activePlayer].YPos = scriptEng.operands[i] << 16;4071break;4072}4073case VAR_PLAYERSCREENXPOS: {4074playerList[activePlayer].screenXPos = scriptEng.operands[i];4075break;4076}4077case VAR_PLAYERSCREENYPOS: {4078playerList[activePlayer].screenYPos = scriptEng.operands[i];4079break;4080}4081case VAR_PLAYERSPEED: {4082playerList[activePlayer].speed = scriptEng.operands[i];4083break;4084}4085case VAR_PLAYERXVELOCITY: {4086playerList[activePlayer].XVelocity = scriptEng.operands[i];4087break;4088}4089case VAR_PLAYERYVELOCITY: {4090playerList[activePlayer].YVelocity = scriptEng.operands[i];4091break;4092}4093case VAR_PLAYERGRAVITY: {4094playerList[activePlayer].gravity = scriptEng.operands[i];4095break;4096}4097case VAR_PLAYERANGLE: {4098playerList[activePlayer].angle = scriptEng.operands[i];4099break;4100}4101case VAR_PLAYERSKIDDING: {4102playerList[activePlayer].skidding = scriptEng.operands[i];4103break;4104}4105case VAR_PLAYERPUSHING: {4106playerList[activePlayer].pushing = scriptEng.operands[i];4107break;4108}4109case VAR_PLAYERTRACKSCROLL: {4110playerList[activePlayer].trackScroll = scriptEng.operands[i];4111break;4112}4113case VAR_PLAYERUP: {4114playerList[activePlayer].up = scriptEng.operands[i];4115break;4116}4117case VAR_PLAYERDOWN: {4118playerList[activePlayer].down = scriptEng.operands[i];4119break;4120}4121case VAR_PLAYERLEFT: {4122playerList[activePlayer].left = scriptEng.operands[i];4123break;4124}4125case VAR_PLAYERRIGHT: {4126playerList[activePlayer].right = scriptEng.operands[i];4127break;4128}4129case VAR_PLAYERJUMPPRESS: {4130playerList[activePlayer].jumpPress = scriptEng.operands[i];4131break;4132}4133case VAR_PLAYERJUMPHOLD: {4134playerList[activePlayer].jumpHold = scriptEng.operands[i];4135break;4136}4137case VAR_PLAYERFOLLOWPLAYER1: {4138playerList[activePlayer].followPlayer1 = scriptEng.operands[i];4139break;4140}4141case VAR_PLAYERLOOKPOS: {4142playerList[activePlayer].lookPos = scriptEng.operands[i];4143break;4144}4145case VAR_PLAYERWATER: {4146playerList[activePlayer].water = scriptEng.operands[i];4147break;4148}4149case VAR_PLAYERTOPSPEED: {4150playerList[activePlayer].topSpeed = scriptEng.operands[i];4151break;4152}4153case VAR_PLAYERACCELERATION: {4154playerList[activePlayer].acceleration = scriptEng.operands[i];4155break;4156}4157case VAR_PLAYERDECELERATION: {4158playerList[activePlayer].deceleration = scriptEng.operands[i];4159break;4160}4161case VAR_PLAYERAIRACCELERATION: {4162playerList[activePlayer].airAcceleration = scriptEng.operands[i];4163break;4164}4165case VAR_PLAYERAIRDECELERATION: {4166playerList[activePlayer].airDeceleration = scriptEng.operands[i];4167break;4168}4169case VAR_PLAYERGRAVITYSTRENGTH: {4170playerList[activePlayer].gravityStrength = scriptEng.operands[i];4171break;4172}4173case VAR_PLAYERJUMPSTRENGTH: {4174playerList[activePlayer].jumpStrength = scriptEng.operands[i];4175break;4176}4177case VAR_PLAYERJUMPCAP: {4178playerList[activePlayer].jumpCap = scriptEng.operands[i];4179break;4180}4181case VAR_PLAYERROLLINGACCELERATION: {4182scriptEng.operands[i] = playerList[activePlayer].rollingAcceleration = scriptEng.operands[i];4183break;4184}4185case VAR_PLAYERROLLINGDECELERATION: {4186scriptEng.operands[i] = playerList[activePlayer].rollingDeceleration = scriptEng.operands[i];4187break;4188}4189case VAR_PLAYERENTITYNO: break;4190case VAR_PLAYERCOLLISIONLEFT: break;4191case VAR_PLAYERCOLLISIONTOP: break;4192case VAR_PLAYERCOLLISIONRIGHT: break;4193case VAR_PLAYERCOLLISIONBOTTOM: break;4194case VAR_PLAYERFLAILING: {4195scriptEng.operands[i] = playerList[activePlayer].flailing[arrayVal] = scriptEng.operands[i];4196break;4197}4198case VAR_PLAYERTIMER: {4199playerList[activePlayer].timer = scriptEng.operands[i];4200break;4201}4202case VAR_PLAYERTILECOLLISIONS: {4203playerList[activePlayer].tileCollisions = scriptEng.operands[i];4204break;4205}4206case VAR_PLAYEROBJECTINTERACTION: {4207scriptEng.operands[i] = playerList[activePlayer].objectInteractions = scriptEng.operands[i];4208break;4209}4210case VAR_PLAYERVISIBLE: {4211playerList[activePlayer].visible = scriptEng.operands[i];4212break;4213}4214case VAR_PLAYERROTATION: {4215scriptEng.operands[i] = playerList[activePlayer].boundEntity->rotation = scriptEng.operands[i];4216break;4217}4218case VAR_PLAYERSCALE: {4219playerList[activePlayer].boundEntity->scale = scriptEng.operands[i];4220break;4221}4222case VAR_PLAYERPRIORITY: {4223scriptEng.operands[i] = playerList[activePlayer].boundEntity->priority = scriptEng.operands[i];4224break;4225}4226case VAR_PLAYERDRAWORDER: {4227scriptEng.operands[i] = playerList[activePlayer].boundEntity->drawOrder = scriptEng.operands[i];4228break;4229}4230case VAR_PLAYERDIRECTION: {4231scriptEng.operands[i] = playerList[activePlayer].boundEntity->direction = scriptEng.operands[i];4232break;4233}4234case VAR_PLAYERINKEFFECT: {4235scriptEng.operands[i] = playerList[activePlayer].boundEntity->inkEffect = scriptEng.operands[i];4236break;4237}4238case VAR_PLAYERALPHA: {4239playerList[activePlayer].boundEntity->alpha = scriptEng.operands[i];4240break;4241}4242case VAR_PLAYERFRAME: {4243playerList[activePlayer].boundEntity->frame = scriptEng.operands[i];4244break;4245}4246case VAR_PLAYERANIMATION: {4247scriptEng.operands[i] = playerList[activePlayer].boundEntity->animation = scriptEng.operands[i];4248break;4249}4250case VAR_PLAYERPREVANIMATION: {4251scriptEng.operands[i] = playerList[activePlayer].boundEntity->prevAnimation = scriptEng.operands[i];4252break;4253}4254case VAR_PLAYERANIMATIONSPEED: {4255scriptEng.operands[i] = playerList[activePlayer].boundEntity->animationSpeed = scriptEng.operands[i];4256break;4257}4258case VAR_PLAYERANIMATIONTIMER: {4259scriptEng.operands[i] = playerList[activePlayer].boundEntity->animationTimer = scriptEng.operands[i];4260break;4261}4262case VAR_PLAYERVALUE0: {4263scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[0] = scriptEng.operands[i];4264break;4265}4266case VAR_PLAYERVALUE1: {4267scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[1] = scriptEng.operands[i];4268break;4269}4270case VAR_PLAYERVALUE2: {4271scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[2] = scriptEng.operands[i];4272break;4273}4274case VAR_PLAYERVALUE3: {4275scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[3] = scriptEng.operands[i];4276break;4277}4278case VAR_PLAYERVALUE4: {4279scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[4] = scriptEng.operands[i];4280break;4281}4282case VAR_PLAYERVALUE5: {4283scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[5] = scriptEng.operands[i];4284break;4285}4286case VAR_PLAYERVALUE6: {4287scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[6] = scriptEng.operands[i];4288break;4289}4290case VAR_PLAYERVALUE7: {4291scriptEng.operands[i] = playerList[activePlayer].boundEntity->values[7] = scriptEng.operands[i];4292break;4293}4294case VAR_PLAYERVALUE8: {4295playerList[activePlayer].values[0] = scriptEng.operands[i];4296break;4297}4298case VAR_PLAYERVALUE9: {4299playerList[activePlayer].values[1] = scriptEng.operands[i];4300break;4301}4302case VAR_PLAYERVALUE10: {4303playerList[activePlayer].values[2] = scriptEng.operands[i];4304break;4305}4306case VAR_PLAYERVALUE11: {4307playerList[activePlayer].values[3] = scriptEng.operands[i];4308break;4309}4310case VAR_PLAYERVALUE12: {4311playerList[activePlayer].values[4] = scriptEng.operands[i];4312break;4313}4314case VAR_PLAYERVALUE13: {4315playerList[activePlayer].values[5] = scriptEng.operands[i];4316break;4317}4318case VAR_PLAYERVALUE14: {4319playerList[activePlayer].values[6] = scriptEng.operands[i];4320break;4321}4322case VAR_PLAYERVALUE15: {4323playerList[activePlayer].values[7] = scriptEng.operands[i];4324break;4325}4326case VAR_PLAYEROUTOFBOUNDS: break;4327case VAR_STAGESTATE: stageMode = scriptEng.operands[i]; break;4328case VAR_STAGEACTIVELIST: {4329int32 listSlots[] = { 0, 1, 3, 2 };43304331int32 listID = scriptEng.operands[i];4332if (listID <= 3)4333listID = listSlots[listID];4334else4335listID = 2; // BONUS_STAGE43364337if (listID < sceneInfo.categoryCount) {4338int32 listPos = sceneInfo.listPos - sceneInfo.listCategory[sceneInfo.activeCategory].sceneOffsetStart;43394340sceneInfo.activeCategory = listID;4341SceneListInfo *list = &sceneInfo.listCategory[sceneInfo.activeCategory];43424343sceneInfo.listPos = list->sceneOffsetStart + listPos;4344if (sceneInfo.listPos >= list->sceneOffsetEnd)4345sceneInfo.listPos = list->sceneOffsetEnd;4346}4347break;4348}4349case VAR_STAGELISTPOS: {4350SceneListInfo *list = &sceneInfo.listCategory[sceneInfo.activeCategory];43514352if (list->sceneOffsetStart + scriptEng.operands[i] <= list->sceneOffsetEnd)4353sceneInfo.listPos = list->sceneOffsetStart + scriptEng.operands[i];4354break;4355}4356case VAR_STAGETIMEENABLED: timeEnabled = scriptEng.operands[i]; break;4357case VAR_STAGEMILLISECONDS: stageMilliseconds = scriptEng.operands[i]; break;4358case VAR_STAGESECONDS: stageSeconds = scriptEng.operands[i]; break;4359case VAR_STAGEMINUTES: stageMinutes = scriptEng.operands[i]; break;4360case VAR_STAGEACTNO: actID = scriptEng.operands[i]; break;4361case VAR_STAGEPAUSEENABLED: pauseEnabled = scriptEng.operands[i]; break;4362case VAR_STAGELISTSIZE: break;4363case VAR_STAGENEWXBOUNDARY1: newXBoundary1 = scriptEng.operands[i]; break;4364case VAR_STAGENEWXBOUNDARY2: newXBoundary2 = scriptEng.operands[i]; break;4365case VAR_STAGENEWYBOUNDARY1: newYBoundary1 = scriptEng.operands[i]; break;4366case VAR_STAGENEWYBOUNDARY2: newYBoundary2 = scriptEng.operands[i]; break;4367case VAR_STAGEXBOUNDARY1:4368if (curXBoundary1 != scriptEng.operands[i]) {4369curXBoundary1 = scriptEng.operands[i];4370newXBoundary1 = scriptEng.operands[i];4371}4372break;4373case VAR_STAGEXBOUNDARY2:4374if (curXBoundary2 != scriptEng.operands[i]) {4375curXBoundary2 = scriptEng.operands[i];4376newXBoundary2 = scriptEng.operands[i];4377}4378break;4379case VAR_STAGEYBOUNDARY1:4380if (curYBoundary1 != scriptEng.operands[i]) {4381curYBoundary1 = scriptEng.operands[i];4382newYBoundary1 = scriptEng.operands[i];4383}4384break;4385case VAR_STAGEYBOUNDARY2:4386if (curYBoundary2 != scriptEng.operands[i]) {4387curYBoundary2 = scriptEng.operands[i];4388newYBoundary2 = scriptEng.operands[i];4389}4390break;4391case VAR_STAGEDEFORMATIONDATA0: bgDeformationData0[arrayVal] = scriptEng.operands[i]; break;4392case VAR_STAGEDEFORMATIONDATA1: bgDeformationData1[arrayVal] = scriptEng.operands[i]; break;4393case VAR_STAGEDEFORMATIONDATA2: bgDeformationData2[arrayVal] = scriptEng.operands[i]; break;4394case VAR_STAGEDEFORMATIONDATA3: bgDeformationData3[arrayVal] = scriptEng.operands[i]; break;4395case VAR_STAGEWATERLEVEL: waterLevel = scriptEng.operands[i]; break;4396case VAR_STAGEACTIVELAYER: activeTileLayers[arrayVal] = scriptEng.operands[i]; break;4397case VAR_STAGEMIDPOINT: tLayerMidPoint = scriptEng.operands[i]; break;4398case VAR_STAGEPLAYERLISTPOS: playerListPos = scriptEng.operands[i]; break;4399case VAR_STAGEACTIVEPLAYER: activePlayer = scriptEng.operands[i]; break;4400case VAR_SCREENCAMERAENABLED: currentCamera->enabled = scriptEng.operands[i]; break;4401case VAR_SCREENCAMERATARGET: currentCamera->target = scriptEng.operands[i]; break;4402case VAR_SCREENCAMERASTYLE: currentCamera->style = scriptEng.operands[i]; break;4403case VAR_SCREENDRAWLISTSIZE: drawListEntries[arrayVal].listSize = scriptEng.operands[i]; break;4404case VAR_SCREENCENTERX: break;4405case VAR_SCREENCENTERY: break;4406case VAR_SCREENXSIZE: break;4407case VAR_SCREENYSIZE: break;4408case VAR_SCREENXOFFSET:4409xScrollOffset = scriptEng.operands[i];4410xScrollA = xScrollOffset;4411xScrollB = SCREEN_XSIZE + xScrollOffset;4412break;4413case VAR_SCREENYOFFSET:4414yScrollOffset = scriptEng.operands[i];4415yScrollA = yScrollOffset;4416yScrollB = SCREEN_YSIZE + yScrollOffset;4417break;4418case VAR_SCREENSHAKEX: cameraShakeX = scriptEng.operands[i]; break;4419case VAR_SCREENSHAKEY: cameraShakeY = scriptEng.operands[i]; break;4420case VAR_SCREENADJUSTCAMERAY: currentCamera->adjustY = scriptEng.operands[i]; break;4421case VAR_TOUCHSCREENDOWN: break;4422case VAR_TOUCHSCREENXPOS: break;4423case VAR_TOUCHSCREENYPOS: break;4424case VAR_MUSICVOLUME: SetMusicVolume(scriptEng.operands[i]); break;4425case VAR_MUSICCURRENTTRACK: break;4426case VAR_KEYDOWNUP: controller[arrayVal].keyUp.down = scriptEng.operands[i]; break;4427case VAR_KEYDOWNDOWN: controller[arrayVal].keyDown.down = scriptEng.operands[i]; break;4428case VAR_KEYDOWNLEFT: controller[arrayVal].keyLeft.down = scriptEng.operands[i]; break;4429case VAR_KEYDOWNRIGHT: controller[arrayVal].keyRight.down = scriptEng.operands[i]; break;4430case VAR_KEYDOWNBUTTONA: controller[arrayVal].keyA.down = scriptEng.operands[i]; break;4431case VAR_KEYDOWNBUTTONB: controller[arrayVal].keyB.down = scriptEng.operands[i]; break;4432case VAR_KEYDOWNBUTTONC: controller[arrayVal].keyC.down = scriptEng.operands[i]; break;4433case VAR_KEYDOWNSTART: controller[arrayVal].keyStart.down = scriptEng.operands[i]; break;4434case VAR_KEYPRESSUP: controller[arrayVal].keyUp.press = scriptEng.operands[i]; break;4435case VAR_KEYPRESSDOWN: controller[arrayVal].keyDown.press = scriptEng.operands[i]; break;4436case VAR_KEYPRESSLEFT: controller[arrayVal].keyLeft.press = scriptEng.operands[i]; break;4437case VAR_KEYPRESSRIGHT: controller[arrayVal].keyRight.press = scriptEng.operands[i]; break;4438case VAR_KEYPRESSBUTTONA: controller[arrayVal].keyA.press = scriptEng.operands[i]; break;4439case VAR_KEYPRESSBUTTONB: controller[arrayVal].keyB.press = scriptEng.operands[i]; break;4440case VAR_KEYPRESSBUTTONC: controller[arrayVal].keyC.press = scriptEng.operands[i]; break;4441case VAR_KEYPRESSSTART: controller[arrayVal].keyStart.press = scriptEng.operands[i]; break;4442case VAR_MENU1SELECTION: gameMenu[0].selection1 = scriptEng.operands[i]; break;4443case VAR_MENU2SELECTION: gameMenu[1].selection1 = scriptEng.operands[i]; break;4444case VAR_TILELAYERXSIZE: stageLayouts[arrayVal].xsize = scriptEng.operands[i]; break;4445case VAR_TILELAYERYSIZE: stageLayouts[arrayVal].ysize = scriptEng.operands[i]; break;4446case VAR_TILELAYERTYPE: stageLayouts[arrayVal].type = scriptEng.operands[i]; break;4447case VAR_TILELAYERANGLE:4448stageLayouts[arrayVal].angle = scriptEng.operands[i];4449if (stageLayouts[arrayVal].angle < 0)4450stageLayouts[arrayVal].angle += 0x200;4451stageLayouts[arrayVal].angle &= 0x1FF;4452break;4453case VAR_TILELAYERXPOS: stageLayouts[arrayVal].xpos = scriptEng.operands[i]; break;4454case VAR_TILELAYERYPOS: stageLayouts[arrayVal].ypos = scriptEng.operands[i]; break;4455case VAR_TILELAYERZPOS: stageLayouts[arrayVal].zpos = scriptEng.operands[i]; break;4456case VAR_TILELAYERPARALLAXFACTOR: stageLayouts[arrayVal].parallaxFactor = scriptEng.operands[i]; break;4457case VAR_TILELAYERSCROLLSPEED: stageLayouts[arrayVal].scrollSpeed = scriptEng.operands[i]; break;4458case VAR_TILELAYERSCROLLPOS: stageLayouts[arrayVal].scrollPos = scriptEng.operands[i]; break;4459case VAR_TILELAYERDEFORMATIONOFFSET:4460stageLayouts[arrayVal].deformationOffset = scriptEng.operands[i];4461stageLayouts[arrayVal].deformationOffset &= 0xFFu;4462break;4463case VAR_TILELAYERDEFORMATIONOFFSETW:4464stageLayouts[arrayVal].deformationOffsetW = scriptEng.operands[i];4465stageLayouts[arrayVal].deformationOffsetW &= 0xFFu;4466break;4467case VAR_HPARALLAXPARALLAXFACTOR: hParallax.parallaxFactor[arrayVal] = scriptEng.operands[i]; break;4468case VAR_HPARALLAXSCROLLSPEED: hParallax.scrollSpeed[arrayVal] = scriptEng.operands[i]; break;4469case VAR_HPARALLAXSCROLLPOS: hParallax.scrollPos[arrayVal] = scriptEng.operands[i]; break;4470case VAR_VPARALLAXPARALLAXFACTOR: vParallax.parallaxFactor[arrayVal] = scriptEng.operands[i]; break;4471case VAR_VPARALLAXSCROLLSPEED: vParallax.scrollSpeed[arrayVal] = scriptEng.operands[i]; break;4472case VAR_VPARALLAXSCROLLPOS: vParallax.scrollPos[arrayVal] = scriptEng.operands[i]; break;4473case VAR_3DSCENENOVERTICES: vertexCount = scriptEng.operands[i]; break;4474case VAR_3DSCENENOFACES: faceCount = scriptEng.operands[i]; break;4475case VAR_VERTEXBUFFERX: vertexBuffer[arrayVal].x = scriptEng.operands[i]; break;4476case VAR_VERTEXBUFFERY: vertexBuffer[arrayVal].y = scriptEng.operands[i]; break;4477case VAR_VERTEXBUFFERZ: vertexBuffer[arrayVal].z = scriptEng.operands[i]; break;4478case VAR_VERTEXBUFFERU: vertexBuffer[arrayVal].u = scriptEng.operands[i]; break;4479case VAR_VERTEXBUFFERV: vertexBuffer[arrayVal].v = scriptEng.operands[i]; break;4480case VAR_FACEBUFFERA: faceBuffer[arrayVal].a = scriptEng.operands[i]; break;4481case VAR_FACEBUFFERB: faceBuffer[arrayVal].b = scriptEng.operands[i]; break;4482case VAR_FACEBUFFERC: faceBuffer[arrayVal].c = scriptEng.operands[i]; break;4483case VAR_FACEBUFFERD: faceBuffer[arrayVal].d = scriptEng.operands[i]; break;4484case VAR_FACEBUFFERFLAG: faceBuffer[arrayVal].flag = scriptEng.operands[i]; break;4485case VAR_FACEBUFFERCOLOR: faceBuffer[arrayVal].color = scriptEng.operands[i]; break;4486case VAR_3DSCENEPROJECTIONX: projectionX = scriptEng.operands[i]; break;4487case VAR_3DSCENEPROJECTIONY: projectionY = scriptEng.operands[i]; break;4488case VAR_ENGINESTATE: gameMode = scriptEng.operands[i]; break;4489case VAR_STAGEDEBUGMODE: debugMode = scriptEng.operands[i]; break;4490case VAR_ENGINEMESSAGE: break;4491case VAR_SAVERAM: saveRAM[arrayVal] = scriptEng.operands[i]; break;4492case VAR_ENGINELANGUAGE: language = scriptEng.operands[i]; break;4493case VAR_OBJECTSPRITESHEET: {4494objectScriptList[objectEntityList[arrayVal].type].spriteSheetID = scriptEng.operands[i];4495break;4496}4497case VAR_ENGINEONLINEACTIVE: break;4498case VAR_ENGINEFRAMESKIPTIMER: break;4499case VAR_ENGINEFRAMESKIPSETTING: break;4500case VAR_ENGINESFXVOLUME:4501sfxVolume = scriptEng.operands[i];4502// SetGameVolumes(bgmVolume, sfxVolume);4503break;4504case VAR_ENGINEBGMVOLUME:4505bgmVolume = scriptEng.operands[i];4506// SetGameVolumes(bgmVolume, sfxVolume);4507break;4508case VAR_ENGINEPLATFORMID: break;4509case VAR_ENGINETRIALMODE: break;4510case VAR_KEYPRESSANYSTART: break;4511#if LEGACY_RETRO_USE_HAPTICS4512case VAR_ENGINEHAPTICSENABLED: hapticsEnabled = scriptEng.operands[i]; break;4513#endif4514}4515}4516else if (opcodeType == SCRIPTVAR_INTCONST) { // int32 constant4517scriptCodePtr++;4518}4519else if (opcodeType == SCRIPTVAR_STRCONST) { // string constant4520int32 strLen = scriptCode[scriptCodePtr++];4521for (int32 c = 0; c < strLen; ++c) {4522switch (c % 4) {4523case 0: break;4524case 1: break;4525case 2: break;4526case 3: ++scriptCodePtr; break;4527default: break;4528}4529}4530scriptCodePtr++;4531}4532}4533}4534}453545364537