Skip to content

Commit

Permalink
v5 decomp style revision defines
Browse files Browse the repository at this point in the history
  • Loading branch information
MegAmi24 committed Apr 7, 2024
1 parent dd2e45e commit 0ef1532
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 30 deletions.
12 changes: 10 additions & 2 deletions RSDKv4/Drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3201,7 +3201,7 @@ void DrawSpriteScaled(int direction, int XPos, int YPos, int pivotX, int pivotY,
}
#endif
}
#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
void DrawScaledChar(int direction, int XPos, int YPos, int pivotX, int pivotY, int scaleX, int scaleY, int width, int height, int sprX, int sprY,
int sheetID)
{
Expand Down Expand Up @@ -4215,7 +4215,11 @@ void DrawTexturedFace(void *v, byte sheetID)
}
ushort *fbPtr = &frameBufferPtr[startX];
frameBufferPtr += GFX_LINESIZE;
#if RETRO_REV02
int counter = posDifference;
#else
int counter = posDifference + 1;
#endif
while (counter--) {
if (UPos < 0)
UPos = 0;
Expand Down Expand Up @@ -4344,7 +4348,11 @@ void DrawTexturedFaceBlended(void *v, byte sheetID)
}
ushort *fbPtr = &frameBufferPtr[startX];
frameBufferPtr += GFX_LINESIZE;
#if RETRO_REV02
int counter = posDifference;
#else
int counter = posDifference + 1;
#endif
while (counter--) {
if (UPos < 0)
UPos = 0;
Expand All @@ -4363,7 +4371,7 @@ void DrawTexturedFaceBlended(void *v, byte sheetID)
#endif
}

#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
void DrawBitmapText(void *menu, int XPos, int YPos, int scale, int spacing, int rowStart, int rowCount)
{
TextMenu *tMenu = (TextMenu *)menu;
Expand Down
4 changes: 2 additions & 2 deletions RSDKv4/Drawing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void DrawSpriteClipped(int XPos, int YPos, int width, int height, int sprX, int
void DrawSpriteFlipped(int XPos, int YPos, int width, int height, int sprX, int sprY, int direction, int sheetID);
void DrawSpriteScaled(int direction, int XPos, int YPos, int pivotX, int pivotY, int scaleX, int scaleY, int width, int height, int sprX, int sprY,
int sheetID);
#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
void DrawScaledChar(int direction, int XPos, int YPos, int pivotX, int pivotY, int scaleX, int scaleY, int width, int height, int sprX, int sprY,
int sheetID);
#endif
Expand All @@ -145,7 +145,7 @@ void DrawFadedFace(void *v, uint color, uint fogColor, int alpha);
void DrawTexturedFace(void *v, byte sheetID);
void DrawTexturedFaceBlended(void *v, byte sheetID);

#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
void DrawBitmapText(void *menu, int XPos, int YPos, int scale, int spacing, int rowStart, int rowCount);
#endif

Expand Down
20 changes: 8 additions & 12 deletions RSDKv4/RetroEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,26 +220,22 @@ typedef unsigned int uint;

#endif

// Timeline:
// 0 = S1 release RSDKv4 version
// 1 = S2 release RSDKv4 version
// 2 = S3 POC RSDKv4 version (I have no idea how we have this but woohoo apparently)
// 3 = Sonic Origins (Plus) version
// Determines which revision to use (see defines below for specifics). Datafiles from REV00 and REV01 builds will not work on later revisions and vice versa.
#ifndef RSDK_REVISION
#define RSDK_REVISION (3)
#endif

// reverts opcode list back to how it was in earliest S1 builds, fixes bugs on some datafiles
// Revision from early versions of Sonic 1
#define RETRO_REV00 (RSDK_REVISION == 0)

// reverts opcode list back to how it was in earliest S2 builds, fixes bugs on some datafiles
#define RETRO_REV01 (RSDK_REVISION == 1)
// Revision from early versions of Sonic 2
#define RETRO_REV01 (RSDK_REVISION >= 1)

// reverts opcode list back to how it was in the S3 POC, this is the most common opcode list
#define RETRO_REV02 (RSDK_REVISION == 2)
// Revision from the S3&K POC, this is also used in the Sega Forever versions of S1 & S2
#define RETRO_REV02 (RSDK_REVISION >= 2)

// the default, uses the Sonic Origins opcode list taken from RSDKv5U
#define RETRO_REV03 (RSDK_REVISION == 3)
// Revision included as part of RSDKv5U (Sonic Origins)
#define RETRO_REV03 (RSDK_REVISION >= 3)

enum RetroLanguages {
RETRO_EN = 0,
Expand Down
20 changes: 10 additions & 10 deletions RSDKv4/Script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,14 +517,14 @@ const FunctionInfo functions[] = {
FunctionInfo("ReadSaveRAM", 0),
FunctionInfo("WriteSaveRAM", 0),

#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
FunctionInfo("LoadFontFile", 1),
FunctionInfo("LoadTextFile", 3),
#else
FunctionInfo("LoadTextFile", 2),
#endif
FunctionInfo("GetTextInfo", 5),
#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
FunctionInfo("DrawText", 7),
#endif
FunctionInfo("GetVersionNumber", 2),
Expand All @@ -540,7 +540,7 @@ const FunctionInfo functions[] = {
FunctionInfo("CallNativeFunction4", 5),

FunctionInfo("SetObjectRange", 1),
#if !RETRO_REV00 && !RETRO_REV01
#if RETRO_REV02
FunctionInfo("GetObjectValue", 3),
FunctionInfo("SetObjectValue", 3),
FunctionInfo("CopyObject", 3),
Expand Down Expand Up @@ -1024,12 +1024,12 @@ enum ScrFunc {
FUNC_GETANIMATIONBYNAME,
FUNC_READSAVERAM,
FUNC_WRITESAVERAM,
#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
FUNC_LOADTEXTFONT,
#endif
FUNC_LOADTEXTFILE,
FUNC_GETTEXTINFO,
#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
FUNC_DRAWTEXT,
#endif
FUNC_GETVERSIONNUMBER,
Expand All @@ -1041,7 +1041,7 @@ enum ScrFunc {
FUNC_CALLNATIVEFUNCTION2,
FUNC_CALLNATIVEFUNCTION4,
FUNC_SETOBJECTRANGE,
#if !RETRO_REV00 && !RETRO_REV01
#if RETRO_REV02
FUNC_GETOBJECTVALUE,
FUNC_SETOBJECTVALUE,
FUNC_COPYOBJECT,
Expand Down Expand Up @@ -5333,7 +5333,7 @@ void ProcessScript(int scriptCodeStart, int jumpTableStart, byte scriptEvent)
opcodeSize = 0;
scriptEng.checkResult = WriteSaveRAMData();
break;
#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
case FUNC_LOADTEXTFONT: {
opcodeSize = 0;
LoadFontFile(scriptText);
Expand All @@ -5343,7 +5343,7 @@ void ProcessScript(int scriptCodeStart, int jumpTableStart, byte scriptEvent)
case FUNC_LOADTEXTFILE: {
opcodeSize = 0;
TextMenu *menu = &gameMenu[scriptEng.operands[0]];
#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
LoadTextFile(menu, scriptText, scriptEng.operands[2] != 0);
#else
LoadTextFile(menu, scriptText, false);
Expand All @@ -5361,7 +5361,7 @@ void ProcessScript(int scriptCodeStart, int jumpTableStart, byte scriptEvent)
}
break;
}
#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
case FUNC_DRAWTEXT: {
opcodeSize = 0;
textMenuSurfaceNo = scriptInfo->spriteSheetID;
Expand Down Expand Up @@ -5466,7 +5466,7 @@ void ProcessScript(int scriptCodeStart, int jumpTableStart, byte scriptEvent)
OBJECT_BORDER_X4 = scriptEng.operands[0] + 0x20 - offset;
break;
}
#if !RETRO_REV00 && !RETRO_REV01
#if RETRO_REV02
case FUNC_GETOBJECTVALUE: {
// FUNCTION PARAMS:
// scriptEng.operands[0] = result
Expand Down
4 changes: 2 additions & 2 deletions RSDKv4/Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ char playerListText[0x80][0x20];

BitmapFont fontList[FONTLIST_COUNT];

#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
FontCharacter fontCharacterList[FONTCHAR_COUNT];

void LoadFontFile(const char *filePath)
Expand Down Expand Up @@ -99,7 +99,7 @@ void LoadTextFile(TextMenu *menu, const char *filePath, byte mapCode)
menu->entryStart[menu->rowCount] = menu->textDataPos;
menu->entrySize[menu->rowCount] = 0;

#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
bool flag = false;
FileRead(&fileBuffer, 1);
if (fileBuffer == 0xFF) {
Expand Down
4 changes: 2 additions & 2 deletions RSDKv4/Text.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct TextMenu {
sbyte timer;
};

#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
#define FONTCHAR_COUNT (0x400)

struct FontCharacter {
Expand Down Expand Up @@ -73,7 +73,7 @@ extern char playerListText[0x80][0x20];

extern BitmapFont fontList[FONTLIST_COUNT];

#if RETRO_REV00 || RETRO_REV01
#if !RETRO_REV02
extern FontCharacter fontCharacterList[FONTCHAR_COUNT];

void LoadFontFile(const char *filePath);
Expand Down

0 comments on commit 0ef1532

Please sign in to comment.