MCPcopy Create free account
hub / github.com/RSDKModding/RSDKv4-Decompilation / ProcessScript

Function ProcessScript

RSDKv4/Script.cpp:3344–6460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3342}
3343
3344void ProcessScript(int scriptCodeStart, int jumpTableStart, byte scriptEvent)
3345{
3346 bool running = true;
3347 int scriptCodePtr = scriptCodeStart;
3348 jumpTableStackPos = 0;
3349 functionStackPos = 0;
3350 foreachStackPos = 0;
3351
3352 while (running) {
3353 int opcode = scriptCode[scriptCodePtr++];
3354 int opcodeSize = functions[opcode].opcodeSize;
3355 int scriptCodeOffset = scriptCodePtr;
3356
3357 scriptText[0] = '\0';
3358
3359 // Get Values
3360 for (int i = 0; i < opcodeSize; ++i) {
3361 int opcodeType = scriptCode[scriptCodePtr++];
3362
3363 if (opcodeType == SCRIPTVAR_VAR) {
3364 int arrayVal = 0;
3365 switch (scriptCode[scriptCodePtr++]) {
3366 case VARARR_NONE: arrayVal = objectEntityPos; break;
3367
3368 case VARARR_ARRAY:
3369 if (scriptCode[scriptCodePtr++] == 1)
3370 arrayVal = scriptEng.arrayPosition[scriptCode[scriptCodePtr++]];
3371 else
3372 arrayVal = scriptCode[scriptCodePtr++];
3373 break;
3374
3375 case VARARR_ENTNOPLUS1:
3376 if (scriptCode[scriptCodePtr++] == 1)
3377 arrayVal = scriptEng.arrayPosition[scriptCode[scriptCodePtr++]] + objectEntityPos;
3378 else
3379 arrayVal = scriptCode[scriptCodePtr++] + objectEntityPos;
3380 break;
3381
3382 case VARARR_ENTNOMINUS1:
3383 if (scriptCode[scriptCodePtr++] == 1)
3384 arrayVal = objectEntityPos - scriptEng.arrayPosition[scriptCode[scriptCodePtr++]];
3385 else
3386 arrayVal = objectEntityPos - scriptCode[scriptCodePtr++];
3387 break;
3388
3389 default: break;
3390 }
3391
3392#if RETRO_REV03 && !RETRO_USE_ORIGINAL_CODE
3393 bool inputCheck = true; // Default to true for mobile bytecode
3394 // If we're using the scripts or an Origins datafile, check the array value
3395 if (forceUseScripts || Engine.usingOrigins)
3396 inputCheck = arrayVal <= 1;
3397#endif
3398
3399 // Variables
3400 switch (scriptCode[scriptCodePtr++]) {
3401 default: break;

Callers 6

DrawObjectListFunction · 0.85
ProcessStartupObjectsFunction · 0.85
ProcessObjectsFunction · 0.85
ProcessPausedObjectsFunction · 0.85
ProcessFrozenObjectsFunction · 0.85
Process2PObjectsFunction · 0.85

Calls 15

Sin512Function · 0.85
Cos512Function · 0.85
Sin256Function · 0.85
Cos256Function · 0.85
ArcTanLookupFunction · 0.85
AddGraphicsFileFunction · 0.85
RemoveGraphicsFileFunction · 0.85
DrawSpriteFunction · 0.85
DrawTintRectangleFunction · 0.85
DrawTextMenuFunction · 0.85
LoadPaletteFunction · 0.85
RotatePaletteFunction · 0.85

Tested by

no test coverage detected