diff --git a/Nexus/Collision.cpp b/Nexus/Collision.cpp index 97b5f33..99e6003 100644 --- a/Nexus/Collision.cpp +++ b/Nexus/Collision.cpp @@ -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; diff --git a/Nexus/Collision.hpp b/Nexus/Collision.hpp index 9724be6..b04eebe 100644 --- a/Nexus/Collision.hpp +++ b/Nexus/Collision.hpp @@ -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); diff --git a/Nexus/Debug.cpp b/Nexus/Debug.cpp index 1ae2baf..93565b1 100644 --- a/Nexus/Debug.cpp +++ b/Nexus/Debug.cpp @@ -13,16 +13,25 @@ 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; @@ -30,6 +39,7 @@ void InitSystemMenu() 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], " "); @@ -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 { @@ -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; @@ -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(); @@ -129,6 +145,7 @@ void ProcessSystemMenu() Engine.gameMode = ENGINE_MAINGAME; stageListPosition = 0; } +#endif break; } case DEVMENU_PLAYERSEL: // Selecting Player @@ -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"); @@ -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); @@ -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 @@ -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 @@ -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"); @@ -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 @@ -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; } @@ -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; diff --git a/Nexus/Debug.hpp b/Nexus/Debug.hpp index 624e934..a97a691 100644 --- a/Nexus/Debug.hpp +++ b/Nexus/Debug.hpp @@ -39,7 +39,6 @@ enum DevMenuMenus { }; void InitSystemMenu(); -void initErrorMessage(); void ProcessSystemMenu(); #endif //!DEBUG_H diff --git a/Nexus/Drawing.cpp b/Nexus/Drawing.cpp index 2f350b2..5188a30 100644 --- a/Nexus/Drawing.cpp +++ b/Nexus/Drawing.cpp @@ -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]; @@ -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: @@ -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) { @@ -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) { diff --git a/Nexus/Math.cpp b/Nexus/Math.cpp index e1f04d6..ca59277 100644 --- a/Nexus/Math.cpp +++ b/Nexus/Math.cpp @@ -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); @@ -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); } diff --git a/Nexus/Player.cpp b/Nexus/Player.cpp index 53170b5..658d765 100644 --- a/Nexus/Player.cpp +++ b/Nexus/Player.cpp @@ -187,49 +187,45 @@ void SetMovementStats(PlayerMovementStats *stats) stats->rollingDeceleration = 0x2000; } -void DefaultAirMovement(Player *player) +void DefaultAirMovement(Player* player) { - if (player->YVelocity > -0x40000 && player->YVelocity < 0) - player->speed -= player->speed >> 5; - if (player->speed <= -player->stats.topSpeed) { - if (player->left) { + if (player->left) player->direction = FLIP_X; - } } - else { - if (player->left) { - player->speed -= player->stats.airAcceleration; - player->direction = FLIP_X; - } + else if (player->left) { + player->speed -= player->stats.airAcceleration; + player->direction = FLIP_X; } - if (player->speed >= player->stats.topSpeed) { if (player->right) player->direction = FLIP_NONE; } else if (player->right) { - player->direction = FLIP_NONE; player->speed += player->stats.airAcceleration; + player->direction = FLIP_NONE; } + + if (player->YVelocity > -0x40001 && player->YVelocity < 1) + player->speed -= player->speed >> 5; } void DefaultGravityFalse(Player *player) { player->trackScroll = false; - player->XVelocity = player->speed * cosVal256[player->angle] >> 8; - player->YVelocity = player->speed * sinVal256[player->angle] >> 8; + player->XVelocity = (player->speed * cosVal256[player->angle]) >> 8; + player->YVelocity = (player->speed * sinVal256[player->angle]) >> 8; } -void DefaultGravityTrue(Player *player) +void DefaultGravityTrue(Player* player) { player->trackScroll = true; player->YVelocity += player->stats.gravityStrength; - if (player->YVelocity >= -0x40000) { + if (player->YVelocity >= -0x33CB0) { player->timer = 0; } else if (!player->jumpHold && player->timer > 0) { - player->timer = 0; + player->timer = 0; player->YVelocity = -0x3C800; player->speed -= player->speed >> 5; } @@ -386,7 +382,6 @@ void DefaultJumpAction(Player *player) void DefaultRollingMovement(Player *player) { - if (player->right && player->speed < 0) player->speed += player->stats.rollingDeceleration; if (player->left && player->speed > 0) @@ -473,10 +468,10 @@ void ProcessPlayerAnimation(Player *player) break; } } - if ((signed int)player->animationSpeed <= 0) - player->animationTimer += script->animations[player->animation].speed; - else + if (player->animationSpeed) player->animationTimer += player->animationSpeed; + else + player->animationTimer += script->animations[player->animation].speed; if (player->animation != player->prevAnimation) { if (player->animation == ANI_JUMPING) player->YPos += (hitboxList[0].bottom[0] - hitboxList[1].bottom[0]) << 16; diff --git a/Nexus/RetroEngine.hpp b/Nexus/RetroEngine.hpp index a0adc65..de5011d 100644 --- a/Nexus/RetroEngine.hpp +++ b/Nexus/RetroEngine.hpp @@ -6,13 +6,18 @@ // Setting this to true removes (almost) ALL changes from the original code, the trade off is that a playable game cannot be built, it is advised to // be set to true only for preservation purposes +#ifndef RETRO_USE_ORIGINAL_CODE #define RETRO_USE_ORIGINAL_CODE (0) +#endif + +#ifndef RETRO_USE_MOD_LOADER #define RETRO_USE_MOD_LOADER (0) +#endif #if !RETRO_USE_ORIGINAL_CODE #undef RETRO_USE_MOD_LOADER #define RETRO_USE_MOD_LOADER (1) -#endif // !RETRO_USE_ORIGINAL_CODE +#endif // ================ // STANDARD LIBS @@ -94,8 +99,6 @@ typedef unsigned int uint; #define RETRO_USING_SDL2 (0) #endif -enum RetroLanguages { RETRO_EN = 0, RETRO_FR = 1, RETRO_IT = 2, RETRO_DE = 3, RETRO_ES = 4, RETRO_JP = 5 }; - enum RetroStates { ENGINE_SYSMENU = 0, ENGINE_MAINGAME = 1, @@ -103,11 +106,6 @@ enum RetroStates { ENGINE_EXITGAME = 3, }; -enum RetroBytecodeFormat { - BYTECODE_MOBILE = 0, - BYTECODE_PC = 1, -}; - // General Defines #define SCREEN_YSIZE (240) #define SCREEN_CENTERY (SCREEN_YSIZE / 2) diff --git a/Nexus/Scene.cpp b/Nexus/Scene.cpp index af1cf8d..d1f9510 100644 --- a/Nexus/Scene.cpp +++ b/Nexus/Scene.cpp @@ -12,7 +12,7 @@ SceneInfo stageList[STAGELIST_MAX][0x100]; int stageMode = STAGEMODE_LOAD; -int cameraStyle = 0; +int cameraStyle = CAMERASTYLE_FOLLOW; int cameraEnabled = false; int cameraAdjustY = 0; int xScrollOffset = 0; @@ -85,21 +85,15 @@ byte tilesetGFXData[TILESET_SIZE]; void ProcessStage(void) { switch (stageMode) { - case STAGEMODE_LOAD: // Startup - fadeMode = 0; - + case STAGEMODE_LOAD: cameraEnabled = true; - cameraAdjustY = 0; xScrollOffset = 0; yScrollOffset = 0; - yScrollA = 0; - yScrollB = SCREEN_YSIZE; - xScrollA = 0; - xScrollB = SCREEN_XSIZE; - yScrollMove = 0; - earthquakeX = 0; - earthquakeY = 0; - + pauseEnabled = false; + timeEnabled = false; + stageMilliseconds = 0; + stageSeconds = 0; + stageMinutes = 0; for (int i = 0; i < PLAYER_COUNT; ++i) { MEM_ZERO(playerList[i]); playerList[i].visible = true; @@ -107,17 +101,9 @@ void ProcessStage(void) playerList[i].tileCollisions = true; playerList[i].objectInteraction = true; } - pauseEnabled = false; - timeEnabled = false; - frameCounter = 0; - stageMilliseconds = 0; - stageSeconds = 0; - stageMinutes = 0; - Engine.frameCount = 0; - stageMode = STAGEMODE_NORMAL; - ResetBackgroundSettings(); LoadStageFiles(); - //fallthrough cuz it fixes a bug looool + stageMode = STAGEMODE_NORMAL; + break; case STAGEMODE_NORMAL: if (fadeMode > 0) fadeMode--; @@ -149,8 +135,8 @@ void ProcessStage(void) if (objectEntityList[0].type == OBJ_TYPE_PLAYER) { if (cameraEnabled) { switch (cameraStyle) { - case 0: SetPlayerScreenPosition(&playerList[0]); break; - case 1: SetPlayerScreenPositionCDStyle(&playerList[0]); break; + case CAMERASTYLE_FOLLOW: SetPlayerScreenPosition(&playerList[0]); break; + case CAMERASTYLE_EXTENDED: SetPlayerScreenPositionCDStyle(&playerList[0]); break; default: break; } } @@ -190,8 +176,8 @@ void ProcessStage(void) if (objectEntityList[0].type == OBJ_TYPE_PLAYER) { if (cameraEnabled) { switch (cameraStyle) { - case 0: SetPlayerScreenPosition(&playerList[0]); break; - case 1: SetPlayerScreenPositionCDStyle(&playerList[0]); break; + case CAMERASTYLE_FOLLOW: SetPlayerScreenPosition(&playerList[0]); break; + case CAMERASTYLE_EXTENDED: SetPlayerScreenPositionCDStyle(&playerList[0]); break; default: break; } } @@ -208,7 +194,6 @@ void ProcessStage(void) } break; } - Engine.frameCount++; } void LoadStageFiles(void) @@ -317,9 +302,9 @@ void LoadStageFiles(void) LoadActLayout(); ProcessStartupObjects(); xScrollA = (playerList[0].XPos >> 16) - SCREEN_CENTERX; - xScrollB = (playerList[0].XPos >> 16) - SCREEN_CENTERX + SCREEN_XSIZE; + xScrollB = (playerList[0].XPos >> 16) - SCREEN_CENTERX + SCREEN_XSIZE; yScrollA = (playerList[0].YPos >> 16) - SCREEN_SCROLL_UP; - yScrollB = (playerList[0].YPos >> 16) - SCREEN_SCROLL_UP + SCREEN_YSIZE; + yScrollB = (playerList[0].YPos >> 16) - SCREEN_SCROLL_UP + SCREEN_YSIZE; } int LoadActFile(const char *ext, int stageID, FileInfo *info) { @@ -861,8 +846,9 @@ void ResetBackgroundSettings() } } -void SetPlayerScreenPosition(Player *player) +void SetPlayerScreenPosition(Player* player) { + PlayerScript* script = &playerScriptList[player->type]; int playerXPos = player->XPos >> 16; int playerYPos = player->YPos >> 16; if (newYBoundary1 > yBoundary1) { @@ -896,91 +882,76 @@ void SetPlayerScreenPosition(Player *player) xBoundary1 = newXBoundary1; } if (newXBoundary1 < xBoundary1) { - if (xScrollOffset <= xBoundary1) { + if (xScrollOffset <= xBoundary1) --xBoundary1; - if (player->XVelocity < 0) { - xBoundary1 += player->XVelocity >> 16; - if (xBoundary1 < newXBoundary1) - xBoundary1 = newXBoundary1; - } - } - else { + else xBoundary1 = newXBoundary1; - } } if (newXBoundary2 < xBoundary2) { - if (SCREEN_XSIZE + xScrollOffset >= xBoundary2) - xBoundary2 = SCREEN_XSIZE + xScrollOffset; + if (xScrollOffset + SCREEN_XSIZE >= xBoundary2) + xBoundary2 = xScrollOffset + SCREEN_XSIZE; else xBoundary2 = newXBoundary2; } if (newXBoundary2 > xBoundary2) { - if (SCREEN_XSIZE + xScrollOffset >= xBoundary2) { + if (xScrollOffset + SCREEN_XSIZE >= xBoundary2) ++xBoundary2; - if (player->XVelocity > 0) { - xBoundary2 += player->XVelocity >> 16; - if (xBoundary2 > newXBoundary2) - xBoundary2 = newXBoundary2; - } - } - else { + else xBoundary2 = newXBoundary2; - } } - int xscrollA = xScrollA; - int xscrollB = xScrollB; - int scrollAmount = playerXPos - (SCREEN_CENTERX + xScrollA); - if (abs(playerXPos - (SCREEN_CENTERX + xScrollA)) >= 25) { + int xscrollA = xScrollA; + int xscrollB = xScrollB; + int scrollAmount = playerXPos - (xScrollA + SCREEN_CENTERX); + if (abs(scrollAmount) >= 25) { if (scrollAmount <= 0) xscrollA -= 16; else xscrollA += 16; - xscrollB = SCREEN_XSIZE + xscrollA; + xscrollB = xscrollA + SCREEN_XSIZE; } else { - if (playerXPos > SCREEN_SCROLL_RIGHT + xscrollA) { + if (playerXPos > xscrollA + SCREEN_SCROLL_RIGHT) { xscrollA = playerXPos - SCREEN_SCROLL_RIGHT; - xscrollB = SCREEN_XSIZE + playerXPos - SCREEN_SCROLL_RIGHT; + xscrollB = playerXPos - SCREEN_SCROLL_RIGHT + SCREEN_XSIZE; } - if (playerXPos < SCREEN_SCROLL_LEFT + xscrollA) { + if (playerXPos < xscrollA + SCREEN_SCROLL_LEFT) { xscrollA = playerXPos - SCREEN_SCROLL_LEFT; - xscrollB = SCREEN_XSIZE + playerXPos - SCREEN_SCROLL_LEFT; + xscrollB = playerXPos - SCREEN_SCROLL_LEFT + SCREEN_XSIZE; } } if (xscrollA < xBoundary1) { xscrollA = xBoundary1; - xscrollB = SCREEN_XSIZE + xBoundary1; + xscrollB = xBoundary1 + SCREEN_XSIZE; } if (xscrollB > xBoundary2) { xscrollB = xBoundary2; xscrollA = xBoundary2 - SCREEN_XSIZE; } - xScrollA = xscrollA; xScrollB = xscrollB; - if (playerXPos <= SCREEN_CENTERX + xscrollA) { + if (playerXPos <= xscrollA + SCREEN_CENTERX) { player->screenXPos = earthquakeX + playerXPos - xscrollA; - xScrollOffset = xscrollA - earthquakeX; + xScrollOffset = xscrollA - earthquakeX; } else { - xScrollOffset = earthquakeX + playerXPos - SCREEN_CENTERX; + xScrollOffset = playerXPos + earthquakeX - SCREEN_CENTERX; player->screenXPos = SCREEN_CENTERX - earthquakeX; if (playerXPos > xscrollB - SCREEN_CENTERX) { - player->screenXPos = earthquakeX + SCREEN_CENTERX + playerXPos - (xscrollB - SCREEN_CENTERX); - xScrollOffset = xscrollB - SCREEN_XSIZE - earthquakeX; + player->screenXPos = playerXPos - (xscrollB - SCREEN_CENTERX) + earthquakeX + SCREEN_CENTERX; + xScrollOffset = xscrollB - SCREEN_XSIZE - earthquakeX; } } - - int yscrollA = yScrollA; - int yscrollB = yScrollB; - int adjustYPos = cameraAdjustY + playerYPos; - int adjustAmount = player->lookPos + adjustYPos - (yscrollA + SCREEN_SCROLL_UP); + int yscrollA = yScrollA; + int yscrollB = yScrollB; + int hitboxDiff = hitboxList[0].left[0] - getPlayerHitbox(script)->left[0]; + int adjustYPos = playerYPos - hitboxDiff; + int adjustAmount = player->lookPos + adjustYPos - (yScrollA + SCREEN_SCROLL_UP); if (player->trackScroll) { yScrollMove = 32; } else { if (yScrollMove == 32) { - yScrollMove = 2 * ((SCREEN_SCROLL_UP - player->screenYPos - player->lookPos) >> 1); + yScrollMove = 2 * ((hitboxDiff + SCREEN_SCROLL_UP - player->screenYPos - player->lookPos) >> 1); if (yScrollMove > 32) yScrollMove = 32; if (yScrollMove < -32) @@ -990,8 +961,8 @@ void SetPlayerScreenPosition(Player *player) yScrollMove -= 6; yScrollMove += yScrollMove < 0 ? 6 : 0; } - - if (abs(adjustAmount) >= abs(yScrollMove) + 17) { + int absAdjust = abs(adjustAmount); + if (absAdjust >= abs(yScrollMove) + 17) { if (adjustAmount <= 0) yscrollA -= 16; else @@ -1012,6 +983,7 @@ void SetPlayerScreenPosition(Player *player) yscrollA = player->lookPos + adjustYPos + yScrollMove - SCREEN_SCROLL_UP; yscrollB = yscrollA + SCREEN_YSIZE; } + if (yscrollA < yBoundary1) { yscrollA = yBoundary1; yscrollB = yBoundary1 + SCREEN_YSIZE; @@ -1022,40 +994,31 @@ void SetPlayerScreenPosition(Player *player) } yScrollA = yscrollA; yScrollB = yscrollB; - if (player->lookPos + adjustYPos <= yScrollA + SCREEN_SCROLL_UP) { - player->screenYPos = adjustYPos - yScrollA - earthquakeY; - yScrollOffset = earthquakeY + yScrollA; - } - else { - yScrollOffset = earthquakeY + adjustYPos + player->lookPos - SCREEN_SCROLL_UP; - player->screenYPos = SCREEN_SCROLL_UP - player->lookPos - earthquakeY; - if (player->lookPos + adjustYPos > yScrollB - SCREEN_SCROLL_DOWN) { - player->screenYPos = adjustYPos - (yScrollB - SCREEN_SCROLL_DOWN) + earthquakeY + SCREEN_SCROLL_UP; - yScrollOffset = yScrollB - SCREEN_YSIZE - earthquakeY; - } - } - player->screenYPos -= cameraAdjustY; - - if (earthquakeX) { - if (earthquakeX <= 0) { - earthquakeX = ~earthquakeX; - } - else { - earthquakeX = -earthquakeX; - } - } if (earthquakeY) { - if (earthquakeY <= 0) { + if (earthquakeY <= 0) earthquakeY = ~earthquakeY; - } - else { + else earthquakeY = -earthquakeY; + } + + if (player->lookPos + adjustYPos <= yscrollA + SCREEN_SCROLL_UP) { + player->screenYPos = adjustYPos - yscrollA - earthquakeY; + yScrollOffset = earthquakeY + yscrollA; + } + else { + yScrollOffset = earthquakeY + adjustYPos + player->lookPos - SCREEN_SCROLL_UP; + player->screenYPos = SCREEN_SCROLL_UP - player->lookPos - earthquakeY; + if (player->lookPos + adjustYPos > yscrollB - SCREEN_SCROLL_DOWN) { + player->screenYPos = adjustYPos - (yscrollB - SCREEN_SCROLL_DOWN) + earthquakeY + SCREEN_SCROLL_UP; + yScrollOffset = yscrollB - SCREEN_YSIZE - earthquakeY; } } + player->screenYPos += hitboxDiff; } -void SetPlayerScreenPositionCDStyle(Player *player) +void SetPlayerScreenPositionCDStyle(Player* player) { + PlayerScript* script = &playerScriptList[player->type]; int playerXPos = player->XPos >> 16; int playerYPos = player->YPos >> 16; if (newYBoundary1 > yBoundary1) { @@ -1089,38 +1052,23 @@ void SetPlayerScreenPositionCDStyle(Player *player) xBoundary1 = newXBoundary1; } if (newXBoundary1 < xBoundary1) { - if (xScrollOffset <= xBoundary1) { + if (xScrollOffset <= xBoundary1) --xBoundary1; - if (player->XVelocity < 0) { - xBoundary1 += player->XVelocity >> 16; - if (xBoundary1 < newXBoundary1) - xBoundary1 = newXBoundary1; - } - } - else { + else xBoundary1 = newXBoundary1; - } } if (newXBoundary2 < xBoundary2) { - if (SCREEN_XSIZE + xScrollOffset >= xBoundary2) - xBoundary2 = SCREEN_XSIZE + xScrollOffset; + if (xScrollOffset + SCREEN_XSIZE >= xBoundary2) + xBoundary2 = xScrollOffset + SCREEN_XSIZE; else xBoundary2 = newXBoundary2; } if (newXBoundary2 > xBoundary2) { - if (SCREEN_XSIZE + xScrollOffset >= xBoundary2) { + if (xScrollOffset + SCREEN_XSIZE >= xBoundary2) ++xBoundary2; - if (player->XVelocity > 0) { - xBoundary2 += player->XVelocity >> 16; - if (xBoundary2 > newXBoundary2) - xBoundary2 = newXBoundary2; - } - } - else { + else xBoundary2 = newXBoundary2; - } } - if (!player->gravity) { if (player->direction) { if (player->animation == ANI_PEELOUT || player->animation == ANI_SPINDASH || player->speed < -0x5F5C2) { @@ -1143,31 +1091,29 @@ void SetPlayerScreenPositionCDStyle(Player *player) cameraLag -= 2; } } - - if (playerXPos <= cameraLag + SCREEN_CENTERX + xBoundary1) { + if (playerXPos <= xBoundary1 + cameraLag + SCREEN_CENTERX) { player->screenXPos = earthquakeX + playerXPos - xBoundary1; - xScrollOffset = xBoundary1 - earthquakeX; + xScrollOffset = xBoundary1 - earthquakeX; } else { - xScrollOffset = earthquakeX + playerXPos - SCREEN_CENTERX - cameraLag; + xScrollOffset = playerXPos + earthquakeX - SCREEN_CENTERX - cameraLag; player->screenXPos = cameraLag + SCREEN_CENTERX - earthquakeX; if (playerXPos - cameraLag > xBoundary2 - SCREEN_CENTERX) { - player->screenXPos = earthquakeX + SCREEN_CENTERX + playerXPos - (xBoundary2 - SCREEN_CENTERX); - xScrollOffset = xBoundary2 - SCREEN_XSIZE - earthquakeX; + player->screenXPos = playerXPos - (xBoundary2 - SCREEN_CENTERX) + earthquakeX + SCREEN_CENTERX; + xScrollOffset = xBoundary2 - SCREEN_XSIZE - earthquakeX; } } - xScrollA = xScrollOffset; - xScrollB = SCREEN_XSIZE + xScrollOffset; - int yscrollA = yScrollA; - int yscrollB = yScrollB; - int adjustY = cameraAdjustY + playerYPos; + int yscrollA = yScrollA; + int yscrollB = yScrollB; + int hitboxDiff = hitboxList[0].left[0] - getPlayerHitbox(script)->left[0]; + int adjustY = playerYPos - hitboxDiff; int adjustOffset = player->lookPos + adjustY - (yScrollA + SCREEN_SCROLL_UP); - if (player->trackScroll == 1) { + if (player->trackScroll) { yScrollMove = 32; } else { if (yScrollMove == 32) { - yScrollMove = 2 * ((SCREEN_SCROLL_UP - player->screenYPos - player->lookPos) >> 1); + yScrollMove = 2 * ((hitboxDiff + SCREEN_SCROLL_UP - player->screenYPos - player->lookPos) >> 1); if (yScrollMove > 32) yScrollMove = 32; if (yScrollMove < -32) @@ -1177,7 +1123,6 @@ void SetPlayerScreenPositionCDStyle(Player *player) yScrollMove -= 6; yScrollMove += yScrollMove < 0 ? 6 : 0; } - int absAdjust = abs(adjustOffset); if (absAdjust >= abs(yScrollMove) + 17) { if (adjustOffset <= 0) @@ -1210,210 +1155,94 @@ void SetPlayerScreenPositionCDStyle(Player *player) } yScrollA = yscrollA; yScrollB = yscrollB; - if (player->lookPos + adjustY <= yscrollA + SCREEN_SCROLL_UP) { - player->screenYPos = adjustY - yscrollA - earthquakeY; - yScrollOffset = earthquakeY + yscrollA; - } - else { - yScrollOffset = earthquakeY + adjustY + player->lookPos - SCREEN_SCROLL_UP; - player->screenYPos = SCREEN_SCROLL_UP - player->lookPos - earthquakeY; - if (player->lookPos + adjustY > yscrollB - SCREEN_SCROLL_DOWN) { - player->screenYPos = adjustY - (yscrollB - SCREEN_SCROLL_DOWN) + earthquakeY + SCREEN_SCROLL_UP; - yScrollOffset = yscrollB - SCREEN_YSIZE - earthquakeY; - } - } - player->screenYPos -= cameraAdjustY; - - if (earthquakeX) { - if (earthquakeX <= 0) { - earthquakeX = ~earthquakeX; - } - else { - earthquakeX = -earthquakeX; - } - } if (earthquakeY) { - if (earthquakeY <= 0) { + if (earthquakeY <= 0) earthquakeY = ~earthquakeY; - } - else { - earthquakeY = -earthquakeY; - } - } -} -void SetPlayerHLockedScreenPosition(Player *player) -{ - int playerXPos = player->XPos >> 16; - int playerYPos = player->YPos >> 16; - if (newYBoundary1 > yBoundary1) { - if (yScrollOffset <= newYBoundary1) - yBoundary1 = yScrollOffset; - else - yBoundary1 = newYBoundary1; - } - if (newYBoundary1 < yBoundary1) { - if (yScrollOffset <= yBoundary1) - --yBoundary1; - else - yBoundary1 = newYBoundary1; - } - if (newYBoundary2 < yBoundary2) { - if (yScrollOffset + SCREEN_YSIZE >= yBoundary2 || yScrollOffset + SCREEN_YSIZE <= newYBoundary2) - --yBoundary2; - else - yBoundary2 = yScrollOffset + SCREEN_YSIZE; - } - if (newYBoundary2 > yBoundary2) { - if (yScrollOffset + SCREEN_YSIZE >= yBoundary2) - ++yBoundary2; - else - yBoundary2 = newYBoundary2; - } - - int xscrollA = xScrollA; - int xscrollB = xScrollB; - if (playerXPos <= SCREEN_CENTERX + xScrollA) { - player->screenXPos = earthquakeX + playerXPos - xScrollA; - xScrollOffset = xscrollA - earthquakeX; - } - else { - xScrollOffset = earthquakeX + playerXPos - SCREEN_CENTERX; - player->screenXPos = SCREEN_CENTERX - earthquakeX; - if (playerXPos > xscrollB - SCREEN_CENTERX) { - player->screenXPos = earthquakeX + SCREEN_CENTERX + playerXPos - (xscrollB - SCREEN_CENTERX); - xScrollOffset = xscrollB - SCREEN_XSIZE - earthquakeX; - } - } - int yscrollA = yScrollA; - int yscrollB = yScrollB; - int adjustY = cameraAdjustY + playerYPos; - int lookOffset = player->lookPos + adjustY - (yScrollA + SCREEN_SCROLL_UP); - if (player->trackScroll == 1) { - yScrollMove = 32; - } - else { - if (yScrollMove == 32) { - yScrollMove = 2 * ((SCREEN_SCROLL_UP - player->screenYPos - player->lookPos) >> 1); - if (yScrollMove > 32) - yScrollMove = 32; - if (yScrollMove < -32) - yScrollMove = -32; - } - if (yScrollMove > 0) - yScrollMove -= 6; - yScrollMove += yScrollMove < 0 ? 6 : 0; - } - - int absLook = abs(lookOffset); - if (absLook >= abs(yScrollMove) + 17) { - if (lookOffset <= 0) - yscrollA -= 16; else - yscrollA += 16; - yscrollB = yscrollA + SCREEN_YSIZE; - } - else if (yScrollMove == 32) { - if (player->lookPos + adjustY > yscrollA + yScrollMove + SCREEN_SCROLL_UP) { - yscrollA = player->lookPos + adjustY - (yScrollMove + SCREEN_SCROLL_UP); - yscrollB = yscrollA + SCREEN_YSIZE; - } - if (player->lookPos + adjustY < yscrollA + SCREEN_SCROLL_UP - yScrollMove) { - yscrollA = player->lookPos + adjustY - (SCREEN_SCROLL_UP - yScrollMove); - yscrollB = yscrollA + SCREEN_YSIZE; - } - } - else { - yscrollA = player->lookPos + adjustY + yScrollMove - SCREEN_SCROLL_UP; - yscrollB = yscrollA + SCREEN_YSIZE; - } - if (yscrollA < yBoundary1) { - yscrollA = yBoundary1; - yscrollB = yBoundary1 + SCREEN_YSIZE; - } - if (yscrollB > yBoundary2) { - yscrollB = yBoundary2; - yscrollA = yBoundary2 - SCREEN_YSIZE; - } - yScrollA = yscrollA; - yScrollB = yscrollB; - - if (earthquakeY) { - if (earthquakeY <= 0) { - earthquakeY = -earthquakeY; - --earthquakeY; - } - else { earthquakeY = -earthquakeY; - } } if (player->lookPos + adjustY <= yscrollA + SCREEN_SCROLL_UP) { player->screenYPos = adjustY - yscrollA - earthquakeY; - yScrollOffset = earthquakeY + yscrollA; + yScrollOffset = earthquakeY + yscrollA; } else { - yScrollOffset = earthquakeY + adjustY + player->lookPos - SCREEN_SCROLL_UP; + yScrollOffset = earthquakeY + adjustY + player->lookPos - SCREEN_SCROLL_UP; player->screenYPos = SCREEN_SCROLL_UP - player->lookPos - earthquakeY; if (player->lookPos + adjustY > yscrollB - SCREEN_SCROLL_DOWN) { player->screenYPos = adjustY - (yscrollB - SCREEN_SCROLL_DOWN) + earthquakeY + SCREEN_SCROLL_UP; - yScrollOffset = yscrollB - SCREEN_YSIZE - earthquakeY; + yScrollOffset = yscrollB - SCREEN_YSIZE - earthquakeY; } } - player->screenYPos -= cameraAdjustY; + player->screenYPos += hitboxDiff; } -void SetPlayerLockedScreenPosition(Player *player) +void SetPlayerLockedScreenPosition(Player* player) { + PlayerScript* script = &playerScriptList[player->type]; int playerXPos = player->XPos >> 16; int playerYPos = player->YPos >> 16; - int xscrollA = xScrollA; - int xscrollB = xScrollB; - if (playerXPos <= SCREEN_CENTERX + xScrollA) { - player->screenXPos = earthquakeX + playerXPos - xScrollA; - xScrollOffset = xscrollA - earthquakeX; - } - else { - xScrollOffset = earthquakeX + playerXPos - SCREEN_CENTERX; - player->screenXPos = SCREEN_CENTERX - earthquakeX; - if (playerXPos > xscrollB - SCREEN_CENTERX) { - player->screenXPos = earthquakeX + SCREEN_CENTERX + playerXPos - (xscrollB - SCREEN_CENTERX); - xScrollOffset = xscrollB - SCREEN_XSIZE - earthquakeX; + switch (cameraStyle) { + case CAMERASTYLE_FOLLOW: + { + if (playerXPos <= xBoundary1 + cameraLag + SCREEN_CENTERX) { + player->screenXPos = earthquakeX + playerXPos - xBoundary1; + xScrollOffset = xBoundary1 - earthquakeX; + } + else { + xScrollOffset = playerXPos + earthquakeX - SCREEN_CENTERX - cameraLag; + player->screenXPos = cameraLag + SCREEN_CENTERX - earthquakeX; + if (playerXPos > xBoundary2 + cameraLag - SCREEN_CENTERX) { + player->screenXPos = cameraLag + playerXPos - (xBoundary2 - SCREEN_CENTERX) + earthquakeX + SCREEN_CENTERX; + xScrollOffset = xBoundary2 - SCREEN_XSIZE - earthquakeX - cameraLag; + } + } + break; + } + case CAMERASTYLE_EXTENDED: + { + int xscrollA = xScrollA; + int xscrollB = xScrollB; + if (playerXPos <= xScrollA + SCREEN_CENTERX) { + player->screenXPos = earthquakeX + playerXPos - xScrollA; + xScrollOffset = xscrollA - earthquakeX; + } + else { + xScrollOffset = playerXPos + earthquakeX - SCREEN_CENTERX; + player->screenXPos = SCREEN_CENTERX - earthquakeX; + if (playerXPos > xscrollB - SCREEN_CENTERX) { + player->screenXPos = playerXPos - (xscrollB - SCREEN_CENTERX) + earthquakeX + SCREEN_CENTERX; + xScrollOffset = xscrollB - SCREEN_XSIZE - earthquakeX; + } + } + break; } + default: break; + } + int yscrollA = yScrollA; + int yscrollB = yScrollB; + int hitboxDiff = hitboxList[0].left[0] - getPlayerHitbox(script)->left[0]; + int adjustY = playerYPos - hitboxDiff; + + if (earthquakeY) { + if (earthquakeY <= 0) + earthquakeY = ~earthquakeY; + else + earthquakeY = -earthquakeY; } - int yscrollA = yScrollA; - int yscrollB = yScrollB; - int adjustY = cameraAdjustY + playerYPos; if (player->lookPos + adjustY <= yScrollA + SCREEN_SCROLL_UP) { player->screenYPos = adjustY - yScrollA - earthquakeY; - yScrollOffset = earthquakeY + yscrollA; + yScrollOffset = earthquakeY + yscrollA; } else { - yScrollOffset = earthquakeY + adjustY + player->lookPos - SCREEN_SCROLL_UP; + yScrollOffset = earthquakeY + adjustY + player->lookPos - SCREEN_SCROLL_UP; player->screenYPos = SCREEN_SCROLL_UP - player->lookPos - earthquakeY; if (player->lookPos + adjustY > yscrollB - SCREEN_SCROLL_DOWN) { player->screenYPos = adjustY - (yscrollB - SCREEN_SCROLL_DOWN) + earthquakeY + SCREEN_SCROLL_UP; - yScrollOffset = yscrollB - SCREEN_YSIZE - earthquakeY; + yScrollOffset = yscrollB - SCREEN_YSIZE - earthquakeY; } } - player->screenYPos -= cameraAdjustY; - - if (earthquakeX) { - if (earthquakeX <= 0) { - earthquakeX = ~earthquakeX; - } - else { - earthquakeX = -earthquakeX; - } - } - - if (earthquakeY) { - if (earthquakeY <= 0) { - earthquakeY = ~earthquakeY; - } - else { - earthquakeY = -earthquakeY; - } - } -} + player->screenYPos += hitboxDiff; +} \ No newline at end of file diff --git a/Nexus/Scene.hpp b/Nexus/Scene.hpp index 71e0537..8115529 100644 --- a/Nexus/Scene.hpp +++ b/Nexus/Scene.hpp @@ -63,6 +63,11 @@ enum DeformationModes { DEFORM_BG_WATER = 3, }; +enum CameraStyles { + CAMERASTYLE_FOLLOW, + CAMERASTYLE_EXTENDED, +}; + struct SceneInfo { char name[0x40]; char folder[0x40]; diff --git a/Nexus/Script.cpp b/Nexus/Script.cpp index 04456e2..356d6fb 100644 --- a/Nexus/Script.cpp +++ b/Nexus/Script.cpp @@ -2473,12 +2473,30 @@ void ProcessScript(int scriptCodePtr, int jumpTablePtr, byte scriptSub) temp->values[7] = 0; break; } - case FUNC_DEFAULTGROUNDMOVEMENT: DefaultGroundMovement(&playerList[activePlayer]); break; - case FUNC_DEFAULTAIRMOVEMENT: DefaultAirMovement(&playerList[activePlayer]); break; - case FUNC_DEFAULTROLLINGMOVEMENT: DefaultRollingMovement(&playerList[activePlayer]); break; - case FUNC_DEFAULTGRAVITYTRUE: DefaultGravityTrue(&playerList[activePlayer]); break; - case FUNC_DEFAULTGRAVITYFALSE: DefaultGravityFalse(&playerList[activePlayer]); break; - case FUNC_DEFAULTJUMPACTION: DefaultJumpAction(&playerList[activePlayer]); break; + case FUNC_DEFAULTGROUNDMOVEMENT: + opcodeSize = 0; + DefaultGroundMovement(&playerList[activePlayer]); + break; + case FUNC_DEFAULTAIRMOVEMENT: + opcodeSize = 0; + DefaultAirMovement(&playerList[activePlayer]); + break; + case FUNC_DEFAULTROLLINGMOVEMENT: + opcodeSize = 0; + DefaultRollingMovement(&playerList[activePlayer]); + break; + case FUNC_DEFAULTGRAVITYTRUE: + opcodeSize = 0; + DefaultGravityTrue(&playerList[activePlayer]); + break; + case FUNC_DEFAULTGRAVITYFALSE: + opcodeSize = 0; + DefaultGravityFalse(&playerList[activePlayer]); + break; + case FUNC_DEFAULTJUMPACTION: + opcodeSize = 0; + DefaultJumpAction(&playerList[activePlayer]); + break; case FUNC_SETMUSICTRACK: opcodeSize = 0; SetMusicTrack(scriptText, scriptEng.operands[1], scriptEng.operands[2]); @@ -2505,33 +2523,19 @@ void ProcessScript(int scriptCodePtr, int jumpTablePtr, byte scriptSub) break; case FUNC_OBJECTTILECOLLISION: opcodeSize = 0; - switch (scriptEng.operands[0]) { - default: break; - case CSIDE_FLOOR: - ObjectFloorCollision(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); - break; - // case CSIDE_LWALL: ObjectLWallCollision(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break; - // case CSIDE_RWALL: ObjectRWallCollision(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break; - // case CSIDE_ROOF: ObjectRoofCollision(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break; - } + if (scriptEng.operands[0] == CSIDE_FLOOR) + ObjectFloorCollision(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break; case FUNC_OBJECTTILEGRIP: opcodeSize = 0; - switch (scriptEng.operands[0]) { - default: break; - case CSIDE_FLOOR: - ObjectFloorGrip(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); - break; - // case CSIDE_LWALL: ObjectLWallGrip(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break; - // case CSIDE_RWALL: ObjectRWallGrip(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break; - // case CSIDE_ROOF: ObjectRoofGrip(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break; - } + if (scriptEng.operands[0] == CSIDE_FLOOR) + ObjectFloorGrip(scriptEng.operands[1], scriptEng.operands[2], scriptEng.operands[3]); break; case FUNC_LOADVIDEO: opcodeSize = 0; - // PauseSound(); + PauseSound(); scriptInfo->spriteSheetID = AddGraphicsFile(scriptText); - // ResumeSound(); + ResumeSound(); break; case FUNC_NEXTVIDEOFRAME: opcodeSize = 0; @@ -2699,16 +2703,8 @@ void ProcessScript(int scriptCodePtr, int jumpTablePtr, byte scriptSub) case VAR_MENU2SELECTION: gameMenu[1].selection1 = scriptEng.operands[i]; break; case VAR_STAGEACTIVELIST: activeStageList = scriptEng.operands[i]; break; case VAR_STAGELISTPOS: stageListPosition = scriptEng.operands[i]; break; - case VAR_XSCROLLOFFSET: - xScrollOffset = scriptEng.operands[i]; - xScrollA = xScrollOffset; - xScrollB = SCREEN_XSIZE + xScrollOffset; - break; - case VAR_YSCROLLOFFSET: - yScrollOffset = scriptEng.operands[i]; - yScrollA = yScrollOffset; - yScrollB = SCREEN_YSIZE + yScrollOffset; - break; + case VAR_XSCROLLOFFSET: xScrollOffset = scriptEng.operands[i]; break; + case VAR_YSCROLLOFFSET: yScrollOffset = scriptEng.operands[i]; break; case VAR_GLOBAL: globalVariables[arrayVal] = scriptEng.operands[i]; break; case VAR_STAGETIMEENABLED: timeEnabled = scriptEng.operands[i]; break; case VAR_STAGEMILLISECONDS: stageMilliseconds = scriptEng.operands[i]; break; @@ -2923,7 +2919,7 @@ void ProcessScript(int scriptCodePtr, int jumpTablePtr, byte scriptSub) case VAR_SCREENCAMERAENABLED: cameraEnabled = scriptEng.operands[i]; break; case VAR_SCREENCAMERASTYLE: cameraStyle = scriptEng.operands[i]; break; case VAR_MUSICVOLUME: SetMusicVolume(scriptEng.operands[i]); break; - case VAR_MUSICCURRENTTRACK: break; + case VAR_MUSICCURRENTTRACK: trackID = scriptEng.operands[i]; break; case VAR_PLAYERVISIBLE: { playerList[activePlayer].visible = scriptEng.operands[i]; break; diff --git a/Nexus/Sprite.cpp b/Nexus/Sprite.cpp index 945659a..9d0041e 100644 --- a/Nexus/Sprite.cpp +++ b/Nexus/Sprite.cpp @@ -211,7 +211,7 @@ void ReadGifPictureData(int width, int height, bool interlaced, byte *gfxData, i int AddGraphicsFile(const char *filePath) { - char sheetPath[0x100]; + char sheetPath[!RETRO_USE_ORIGINAL_CODE ? 0x100 : 0x40]; StrCopy(sheetPath, "Data/Sprites/"); StrAdd(sheetPath, filePath); @@ -219,7 +219,9 @@ int AddGraphicsFile(const char *filePath) while (StrLength(gfxSurface[sheetID].fileName) > 0) { if (StrComp(gfxSurface[sheetID].fileName, sheetPath)) return sheetID; - if (++sheetID == SURFACE_MAX) // Max Sheet cnt + // NOTE + // This uses SPRITESHEETS_MAX (16), while RemoveGraphicsFile, uses SURFACE_MAX (24)... + if (++sheetID >= SPRITESHEETS_MAX) return 0; } byte fileExtension = (byte)sheetPath[(StrLength(sheetPath) - 1) & 0xFF]; diff --git a/Nexus/Text.hpp b/Nexus/Text.hpp index 496db9e..93e9807 100644 --- a/Nexus/Text.hpp +++ b/Nexus/Text.hpp @@ -8,6 +8,7 @@ #define FONTCHAR_COUNT (0x400) enum TextInfoTypes { TEXTINFO_TEXTDATA = 0, TEXTINFO_TEXTSIZE = 1, TEXTINFO_ROWCOUNT = 2 }; +enum TextMenuAlignments { MENU_ALIGN_LEFT, MENU_ALIGN_RIGHT, MENU_ALIGN_CENTER }; struct TextMenu { char textData[TEXTDATA_COUNT];