Skip to content

Commit

Permalink
Inaccuracy fixes (#11)
Browse files Browse the repository at this point in the history
* Remove RetroLanguages and RetroBytecodeFormat enums

* Fix some compiler warnings about redefined macros (RETRO_USE_ORIGINAL_CODE/RETRO_USE_MOD_LOADER)

* Fix ProcessSystemMenu, SELECT A PLAYER -> CHOOSE A PLAYER

* Fix remaining issues with Debug.cpp (InitSystemMenu/ProcessSystemMenu)

Added RETRO_USE_ORIGINAL_CODE checks for code that didn't originally exist, changed EXIT's Engine.running = false -> Engine.gameMode = ENGINE_EXITGAME

* Remove non-existent initErrorMessage from Debug.hpp

* Add TextMenuAlignments enum

* CalculateTrigAngles: Add RETRO_USE_ORIGINAL_CODE check for srand, fix 256 loop to use pre-increment instead of post-increment

* Move getPlayerHitbox from Collision.cpp -> Collision.hpp, Replace SetPlayerScreenPosition with proper decomp

* Replace SetPlayerScreenPositionCDStyle with proper decomp

* Remove non-existent SetPlayerHLockedScreenPosition function

* Replace SetPlayerLockedScreenPosition with proper decomp, add CameraStyles enum

* formatting

* more formatting... (this is VSC's fault)

* Fix incorrect player->YVelocity checks in DefaultAirMovement

* DefaultGravityTrue & DefaultGravityFalse fixes

* really small formatting change in ProcessPlayerAnimation

* Fix some ScriptEngine inaccuracies

* Fix incorrect sheetID size limit for AddGraphicsFile

* think that'll be it

* missed a spot
  • Loading branch information
Jdsle authored Nov 6, 2024
1 parent 17540a3 commit a9313e2
Show file tree
Hide file tree
Showing 13 changed files with 271 additions and 413 deletions.
5 changes: 0 additions & 5 deletions Nexus/Collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ int collisionBottom = 0;

CollisionSensor sensors[6];

inline Hitbox *getPlayerHitbox(PlayerScript *script)
{
return &hitboxList[script->animations[playerList[activePlayer].animation].frames[playerList[activePlayer].frame].hitboxID];
}

void FindFloorPosition(Player *player, CollisionSensor *sensor, int startY)
{
int c = 0;
Expand Down
5 changes: 5 additions & 0 deletions Nexus/Collision.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ extern int collisionBottom;

extern CollisionSensor sensors[6];

inline Hitbox *getPlayerHitbox(PlayerScript *script)
{
return &hitboxList[script->animations[playerList[activePlayer].animation].frames[playerList[activePlayer].frame].hitboxID];
}

void FindFloorPosition(Player *player, CollisionSensor *sensor, int startYPos);
void FindLWallPosition(Player *player, CollisionSensor *sensor, int startXPos);
void FindRoofPosition(Player *player, CollisionSensor *sensor, int startYPos);
Expand Down
77 changes: 54 additions & 23 deletions Nexus/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,33 @@ void InitSystemMenu()
ReleaseStageSfx();
fadeMode = 0;

#if !RETRO_USE_ORIGINAL_CODE
if (Engine.usingBinFile
|| ((Engine.startList_Game != 0xFF && Engine.startList_Game) || (Engine.startStage_Game != 0xFF && Engine.startStage_Game))) {
#else
if (Engine.usingBinFile) {
#endif
ClearGraphicsData();
for (int i = 0; i < PLAYER_COUNT; ++i) playerScriptList[i].scriptPath[0] = 0;
LoadPalette("Data/Palettes/MasterPalette.act", 0, 256);
LoadPlayerFromList(0, 0);
Engine.gameMode = ENGINE_MAINGAME;
stageMode = STAGEMODE_LOAD;
#if !RETRO_USE_ORIGINAL_CODE
activeStageList = Engine.startList_Game == 0xFF ? 0 : Engine.startList_Game;
stageListPosition = Engine.startStage_Game == 0xFF ? 0 : Engine.startStage_Game;
#else
activeStageList = 0;
stageListPosition = 0;
#endif
}
else {
Engine.gameMode = ENGINE_SYSMENU;
ClearGraphicsData();
LoadPalette("Data/Palettes/MasterPalette.act", 0, 256);
textMenuSurfaceNo = 0;
LoadGIFFile("Data/Game/SystemText.gif", 0);
stageMode = DEVMENU_MAIN;
SetupTextMenu(&gameMenu[0], 0);
AddTextMenuEntry(&gameMenu[0], "RETRO SONIC DEFAULT MENU");
AddTextMenuEntry(&gameMenu[0], " ");
Expand All @@ -45,25 +55,26 @@ void InitSystemMenu()
AddTextMenuEntry(&gameMenu[0], " ");
#endif
AddTextMenuEntry(&gameMenu[0], "QUIT");
stageMode = DEVMENU_MAIN;
gameMenu[0].alignment = 2;
gameMenu[0].alignment = MENU_ALIGN_CENTER;
gameMenu[0].selectionCount = 2;
gameMenu[0].selection1 = 0;
gameMenu[0].selection2 = 7;

ProcessSystemMenu();
}
}
void ProcessSystemMenu()
{
ClearScreen(0xF0);
#if !RETRO_USE_ORIGINAL_CODE
keyDown.start = false;
keyDown.B = false;
keyDown.up = false;
keyDown.down = false;
CheckKeyDown(&keyDown, 0xFF);
CheckKeyPress(&keyPress, 0xFF);

#else
CheckKeyPress(&keyPress, 0x83);
#endif

switch (stageMode) {
case DEVMENU_MAIN: // Main Menu
{
Expand All @@ -79,13 +90,17 @@ void ProcessSystemMenu()
gameMenu[0].selection2 = (RETRO_USE_MOD_LOADER ? 11 : 9);

DrawTextMenu(&gameMenu[0], SCREEN_CENTERX, 72);
#if !RETRO_USE_ORIGINAL_CODE
if (keyPress.start || keyPress.A) {
#else
if (keyPress.start) {
#endif
if (gameMenu[0].selection2 == 7) {
SetupTextMenu(&gameMenu[0], 0);
AddTextMenuEntry(&gameMenu[0], "SELECT A PLAYER");
AddTextMenuEntry(&gameMenu[0], "CHOOSE A PLAYER");
SetupTextMenu(&gameMenu[1], 0);
LoadConfigListText(&gameMenu[1], 0);
gameMenu[1].alignment = 0;
gameMenu[1].alignment = MENU_ALIGN_LEFT;
gameMenu[1].selectionCount = 1;
gameMenu[1].selection1 = 0;
stageMode = DEVMENU_PLAYERSEL;
Expand All @@ -107,19 +122,20 @@ void ProcessSystemMenu()
}

modOffset = 0;
gameMenu[1].alignment = 1;
gameMenu[1].alignment = MENU_ALIGN_RIGHT;
gameMenu[1].selectionCount = 3;
gameMenu[1].selection1 = 0;

gameMenu[0].alignment = 2;
gameMenu[0].alignment = MENU_ALIGN_CENTER;
gameMenu[0].selectionCount = 1;
stageMode = DEVMENU_MODMENU;
stageMode = DEVMENU_MODMENU;
}
#endif
else {
Engine.running = false;
Engine.gameMode = ENGINE_EXITGAME;
}
}
#if !RETRO_USE_ORIGINAL_CODE
else if (keyPress.B && Engine.usingBinFile) {
ClearGraphicsData();
ClearAnimationData();
Expand All @@ -129,6 +145,7 @@ void ProcessSystemMenu()
Engine.gameMode = ENGINE_MAINGAME;
stageListPosition = 0;
}
#endif
break;
}
case DEVMENU_PLAYERSEL: // Selecting Player
Expand All @@ -145,7 +162,11 @@ void ProcessSystemMenu()

DrawTextMenu(&gameMenu[0], SCREEN_CENTERX - 4, 72);
DrawTextMenu(&gameMenu[1], SCREEN_CENTERX - 40, 96);
#if !RETRO_USE_ORIGINAL_CODE
if (keyPress.start || keyPress.A) {
#else
if (keyPress.start) {
#endif
LoadPlayerFromList(gameMenu[1].selection1, 0);
SetupTextMenu(&gameMenu[0], 0);
AddTextMenuEntry(&gameMenu[0], "SELECT A STAGE LIST");
Expand All @@ -158,10 +179,11 @@ void ProcessSystemMenu()
AddTextMenuEntry(&gameMenu[0], " SPECIAL");
AddTextMenuEntry(&gameMenu[0], " ");
AddTextMenuEntry(&gameMenu[0], " BONUS");
gameMenu[0].alignment = 0;
gameMenu[0].alignment = MENU_ALIGN_LEFT;
gameMenu[0].selection2 = 3;
stageMode = DEVMENU_STAGELISTSEL;
}
#if !RETRO_USE_ORIGINAL_CODE
else if (keyPress.B) {
stageMode = DEVMENU_MAIN;
SetupTextMenu(&gameMenu[0], 0);
Expand All @@ -180,11 +202,12 @@ void ProcessSystemMenu()
#endif
AddTextMenuEntry(&gameMenu[0], "QUIT");
stageMode = DEVMENU_MAIN;
gameMenu[0].alignment = 2;
gameMenu[0].alignment = MENU_ALIGN_CENTER;
gameMenu[0].selectionCount = 2;
gameMenu[0].selection1 = 0;
gameMenu[0].selection2 = 7;
}
#endif
break;
}
case DEVMENU_STAGELISTSEL: // Selecting Category
Expand Down Expand Up @@ -226,30 +249,36 @@ void ProcessSystemMenu()
default: break;
}

#if !RETRO_USE_ORIGINAL_CODE
if ((keyPress.start || keyPress.A) && nextMenu) {
#else
if (keyPress.start && nextMenu) {
#endif
SetupTextMenu(&gameMenu[0], 0);
AddTextMenuEntry(&gameMenu[0], "SELECT A STAGE");
SetupTextMenu(&gameMenu[1], 0);
LoadConfigListText(&gameMenu[1], ((gameMenu[0].selection2 - 3) >> 1) + 1);
gameMenu[1].alignment = 1;
gameMenu[1].alignment = MENU_ALIGN_RIGHT;
gameMenu[1].selectionCount = 3;
gameMenu[1].selection1 = 0;

gameMenu[0].alignment = 2;
gameMenu[0].alignment = MENU_ALIGN_CENTER;
gameMenu[0].selectionCount = 1;
stageMode = DEVMENU_STAGESEL;
stageMode = DEVMENU_STAGESEL;
}
#if !RETRO_USE_ORIGINAL_CODE
else if (keyPress.B) {
SetupTextMenu(&gameMenu[0], 0);
AddTextMenuEntry(&gameMenu[0], "SELECT A PLAYER");
AddTextMenuEntry(&gameMenu[0], "CHOOSE A PLAYER");
SetupTextMenu(&gameMenu[1], 0);
LoadConfigListText(&gameMenu[1], 0);
gameMenu[0].alignment = 2;
gameMenu[1].alignment = 0;
gameMenu[0].alignment = MENU_ALIGN_CENTER;
gameMenu[1].alignment = MENU_ALIGN_LEFT;
gameMenu[1].selectionCount = 1;
gameMenu[1].selection1 = 0;
stageMode = DEVMENU_PLAYERSEL;
}
#endif
break;
}
case DEVMENU_STAGESEL: // Selecting Stage
Expand All @@ -271,6 +300,7 @@ void ProcessSystemMenu()
Engine.gameMode = ENGINE_MAINGAME;
stageListPosition = gameMenu[1].selection1;
}
#if !RETRO_USE_ORIGINAL_CODE
else if (keyPress.B) {
SetupTextMenu(&gameMenu[0], 0);
AddTextMenuEntry(&gameMenu[0], "SELECT A STAGE LIST");
Expand All @@ -283,12 +313,13 @@ void ProcessSystemMenu()
AddTextMenuEntry(&gameMenu[0], " SPECIAL");
AddTextMenuEntry(&gameMenu[0], " ");
AddTextMenuEntry(&gameMenu[0], " BONUS");
gameMenu[0].alignment = 0;
gameMenu[0].alignment = MENU_ALIGN_LEFT;
gameMenu[0].selection2 = (activeStageList << 1) + 3;
gameMenu[0].selection2 = gameMenu[0].selection2 == 7 ? 9 : gameMenu[0].selection2 == 9 ? 7 : gameMenu[0].selection2;
gameMenu[0].selectionCount = 2;
stageMode = DEVMENU_STAGELISTSEL;
}
#endif
break;
}
#if RETRO_USE_MOD_LOADER
Expand Down Expand Up @@ -323,11 +354,11 @@ void ProcessSystemMenu()
AddTextMenuEntry(&gameMenu[1], buffer);
}

gameMenu[1].alignment = 1;
gameMenu[1].alignment = MENU_ALIGN_RIGHT;
gameMenu[1].selectionCount = 3;
gameMenu[1].selection1 = 0;

gameMenu[0].alignment = 2;
gameMenu[0].alignment = MENU_ALIGN_CENTER;
gameMenu[0].selectionCount = 1;
stageMode = DEVMENU_MODMENU;
}
Expand Down Expand Up @@ -364,7 +395,7 @@ void ProcessSystemMenu()
AddTextMenuEntry(&gameMenu[0], " ");
AddTextMenuEntry(&gameMenu[0], "QUIT");
stageMode = DEVMENU_MAIN;
gameMenu[0].alignment = 2;
gameMenu[0].alignment = MENU_ALIGN_CENTER;
gameMenu[0].selectionCount = 2;
gameMenu[0].selection1 = 0;
gameMenu[0].selection2 = 7;
Expand Down
1 change: 0 additions & 1 deletion Nexus/Debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ enum DevMenuMenus {
};

void InitSystemMenu();
void initErrorMessage();
void ProcessSystemMenu();

#endif //!DEBUG_H
8 changes: 4 additions & 4 deletions Nexus/Drawing.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "RetroEngine.hpp"

int SCREEN_XSIZE = 320;
int SCREEN_CENTERX = 320 / 2;
int SCREEN_CENTERX = SCREEN_XSIZE / 2;

byte blendLookupTable[0x100 * 0x100];

Expand Down Expand Up @@ -2183,7 +2183,7 @@ void DrawTextMenu(void *menu, int XPos, int YPos)
}
}
switch (tMenu->alignment) {
case 0:
case MENU_ALIGN_LEFT:
for (int i = 0; i < tMenu->rowCount; ++i) {
switch (tMenu->selectionCount) {
case 1:
Expand All @@ -2210,7 +2210,7 @@ void DrawTextMenu(void *menu, int XPos, int YPos)
YPos += 8;
}
return;
case 1:
case MENU_ALIGN_RIGHT:
for (int i = 0; i < tMenu->rowCount; ++i) {
int textX = XPos - (tMenu->entrySize[i] << 3);
switch (tMenu->selectionCount) {
Expand Down Expand Up @@ -2238,7 +2238,7 @@ void DrawTextMenu(void *menu, int XPos, int YPos)
YPos += 8;
}
return;
case 2:
case MENU_ALIGN_CENTER:
for (int i = 0; i < tMenu->rowCount; ++i) {
int textX = XPos - (tMenu->entrySize[i] >> 1 << 3);
switch (tMenu->selectionCount) {
Expand Down
4 changes: 3 additions & 1 deletion Nexus/Math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ int cosVal256[256];

void CalculateTrigAngles()
{
#if !RETRO_USE_ORIGINAL_CODE
srand(time(NULL));
#endif

for (int i = 0; i < 0x200; ++i) {
float Val = sinf(((float)i / 256) * M_PI);
Expand All @@ -32,7 +34,7 @@ void CalculateTrigAngles()
sinVal512[256] = 0;
sinVal512[384] = -0x200;

for (int i = 0; i < 0x100; i++) {
for (int i = 0; i < 0x100; ++i) {
sinVal256[i] = (sinVal512[i * 2] >> 1);
cosVal256[i] = (cosVal512[i * 2] >> 1);
}
Expand Down
Loading

0 comments on commit a9313e2

Please sign in to comment.