Skip to content

Commit

Permalink
revise parallax fix to match original engine fr
Browse files Browse the repository at this point in the history
  • Loading branch information
LittlePlanetCD committed Mar 22, 2024
1 parent bf8e3a1 commit 7a23c39
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
4 changes: 3 additions & 1 deletion RSDKv3/Drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,7 @@ void DrawHLineScrollLayer(int layerID)
int fullLayerwidth = layerwidth << 7;
for (int i = 0; i < hParallax.entryCount; ++i) {
hParallax.linePos[i] = xScrollOffset * hParallax.parallaxFactor[i] >> 8;
hParallax.scrollPos[i] += hParallax.scrollSpeed[i];
if (hParallax.scrollPos[i] > fullLayerwidth << 16)
hParallax.scrollPos[i] -= fullLayerwidth << 16;
if (hParallax.scrollPos[i] < 0)
Expand Down Expand Up @@ -2648,6 +2649,7 @@ void DrawHLineScrollLayer(int layerID)
layerWidth = layerWidth << 7;
for (int i = 0; i < hParallax.entryCount; i++) {
hParallax.linePos[i] = hParallax.parallaxFactor[i] * xScrollOffset >> 8;
hParallax.scrollPos[i] = hParallax.scrollPos[i] + hParallax.scrollSpeed[i];
if (hParallax.scrollPos[i] > layerWidth << 16) {
hParallax.scrollPos[i] = hParallax.scrollPos[i] - (layerWidth << 16);
}
Expand Down Expand Up @@ -3458,7 +3460,7 @@ void DrawVLineScrollLayer(int layerID)
int fullLayerheight = layerheight << 7;
for (int i = 0; i < vParallax.entryCount; ++i) {
vParallax.linePos[i] = yScrollOffset * vParallax.parallaxFactor[i] >> 8;

vParallax.scrollPos[i] += vParallax.scrollSpeed[i];
vParallax.scrollPos[i] += vParallax.scrollPos[i] << 16;
if (vParallax.scrollPos[i] > fullLayerheight << 16)
vParallax.scrollPos[i] -= fullLayerheight << 16;
Expand Down
11 changes: 2 additions & 9 deletions RSDKv3/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ void ProcessStage(void)

// Update
ProcessObjects();
ProcessParallaxAutoScroll();

if (cameraTarget > -1) {
if (cameraEnabled == 1) {
Expand Down Expand Up @@ -339,12 +338,6 @@ void ProcessStage(void)
Engine.frameCount++;
}

void ProcessParallaxAutoScroll()
{
for (int i = 0; i < hParallax.entryCount; ++i) hParallax.scrollPos[i] += hParallax.scrollSpeed[i];
for (int i = 0; i < vParallax.entryCount; ++i) vParallax.scrollPos[i] += vParallax.scrollSpeed[i];
}

void LoadStageFiles(void)
{
StopAllSfx();
Expand Down Expand Up @@ -755,7 +748,7 @@ void LoadStageBackground()
FileRead(&fileBuffer, 1);
hParallax.parallaxFactor[i] = fileBuffer << 8;
FileRead(&fileBuffer, 1);
hParallax.parallaxFactor[i] |= fileBuffer;
hParallax.parallaxFactor[i] += fileBuffer;

FileRead(&fileBuffer, 1);
hParallax.scrollSpeed[i] = fileBuffer << 10;
Expand All @@ -770,7 +763,7 @@ void LoadStageBackground()
FileRead(&fileBuffer, 1);
vParallax.parallaxFactor[i] = fileBuffer << 8;
FileRead(&fileBuffer, 1);
vParallax.parallaxFactor[i] |= fileBuffer;
vParallax.parallaxFactor[i] += fileBuffer;

FileRead(&fileBuffer, 1);
vParallax.scrollSpeed[i] = fileBuffer << 10;
Expand Down
1 change: 0 additions & 1 deletion RSDKv3/Scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ extern bool drawStageGFXHQ;

void InitFirstStage();
void ProcessStage();
void ProcessParallaxAutoScroll();

void ResetBackgroundSettings();
inline void ResetCurrentStageFolder() { strcpy(currentStageFolder, ""); }
Expand Down

0 comments on commit 7a23c39

Please sign in to comment.