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

Function LoadBytecode

RSDKv4/Script.cpp:3075–3282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3073#endif
3074
3075void LoadBytecode(int stageListID, int scriptID)
3076{
3077 char scriptPath[0x40];
3078 switch (stageListID) {
3079 case STAGELIST_PRESENTATION:
3080 case STAGELIST_REGULAR:
3081 case STAGELIST_BONUS:
3082 case STAGELIST_SPECIAL:
3083 StrCopy(scriptPath, "Bytecode/");
3084 StrAdd(scriptPath, stageList[stageListID][stageListPosition].folder);
3085 StrAdd(scriptPath, ".bin");
3086 break;
3087 case 4: StrCopy(scriptPath, "Bytecode/GlobalCode.bin"); break;
3088 default: break;
3089 }
3090
3091 FileInfo info;
3092 if (LoadFile(scriptPath, &info)) {
3093 byte fileBuffer = 0;
3094 int *scriptCodePtr = &scriptCode[scriptCodePos];
3095 int *jumpTablePtr = &jumpTable[jumpTablePos];
3096
3097 FileRead(&fileBuffer, 1);
3098 int scriptCodeSize = fileBuffer;
3099 FileRead(&fileBuffer, 1);
3100 scriptCodeSize |= fileBuffer << 8;
3101 FileRead(&fileBuffer, 1);
3102 scriptCodeSize |= fileBuffer << 16;
3103 FileRead(&fileBuffer, 1);
3104 scriptCodeSize |= fileBuffer << 24;
3105
3106 while (scriptCodeSize > 0) {
3107 FileRead(&fileBuffer, 1);
3108 int blockSize = fileBuffer & 0x7F;
3109 if (fileBuffer >= 0x80) {
3110 while (blockSize > 0) {
3111 FileRead(&fileBuffer, 1);
3112 *scriptCodePtr = fileBuffer;
3113 FileRead(&fileBuffer, 1);
3114 *scriptCodePtr |= fileBuffer << 8;
3115 FileRead(&fileBuffer, 1);
3116 *scriptCodePtr |= fileBuffer << 16;
3117 FileRead(&fileBuffer, 1);
3118 *scriptCodePtr |= fileBuffer << 24;
3119
3120 ++scriptCodePtr;
3121 ++scriptCodePos;
3122 --scriptCodeSize;
3123 --blockSize;
3124 }
3125 }
3126 else {
3127 while (blockSize > 0) {
3128 FileRead(&fileBuffer, 1);
3129 *scriptCodePtr = fileBuffer;
3130
3131 ++scriptCodePtr;
3132 ++scriptCodePos;

Callers 1

Scene.cppFile · 0.85

Calls 4

StrCopyFunction · 0.85
StrAddFunction · 0.85
FileReadFunction · 0.85
CloseFileFunction · 0.85

Tested by

no test coverage detected