mirror of
https://github.com/HarbourMasters/Starship
synced 2026-09-03 11:01:36 -04:00
fix partial starfield
This commit is contained in:
+36
-16
@@ -372,29 +372,31 @@ void Background_DrawPartialStarfield(s32 yMin, s32 yMax) { // Stars that are in
|
||||
f32* sp5C;
|
||||
u32* sp58;
|
||||
|
||||
yMin += 245;
|
||||
yMax += 245;
|
||||
|
||||
// Get current screen dimensions
|
||||
float currentScreenWidth = gCurrentScreenWidth;
|
||||
float currentScreenHeight = gCurrentScreenHeight;
|
||||
float starfieldWidth = 1.0f * currentScreenWidth;
|
||||
float starfieldHeight = 1.0f * currentScreenHeight;
|
||||
|
||||
// Graphics pipeline setup
|
||||
gDPPipeSync(gMasterDisp++);
|
||||
gDPSetCycleType(gMasterDisp++, G_CYC_FILL);
|
||||
gDPSetCombineMode(gMasterDisp++, G_CC_SHADE, G_CC_SHADE);
|
||||
gDPSetRenderMode(gMasterDisp++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
|
||||
// Set projection to orthographic before drawing stars
|
||||
Lib_InitOrtho(&gMasterDisp);
|
||||
|
||||
if (gStarfieldX >= 1.5f * currentScreenWidth) {
|
||||
gStarfieldX -= 1.5f * currentScreenWidth;
|
||||
gSPDisplayList(gMasterDisp++, starSetupDL);
|
||||
|
||||
if (gStarfieldX >= starfieldWidth) {
|
||||
gStarfieldX -= starfieldWidth;
|
||||
}
|
||||
if (gStarfieldY >= 1.5f * currentScreenHeight) {
|
||||
gStarfieldY -= 1.5f * currentScreenHeight;
|
||||
if (gStarfieldY >= starfieldHeight) {
|
||||
gStarfieldY -= starfieldHeight;
|
||||
}
|
||||
if (gStarfieldX < 0.0f) {
|
||||
gStarfieldX += 1.5f * currentScreenWidth;
|
||||
gStarfieldX += starfieldWidth;
|
||||
}
|
||||
if (gStarfieldY < 0.0f) {
|
||||
gStarfieldY += 1.5f * currentScreenHeight;
|
||||
gStarfieldY += starfieldHeight;
|
||||
}
|
||||
|
||||
spf68 = gStarfieldX;
|
||||
@@ -405,19 +407,33 @@ void Background_DrawPartialStarfield(s32 yMin, s32 yMax) { // Stars that are in
|
||||
sp58 = gStarFillColors;
|
||||
var_s2 = 500;
|
||||
|
||||
var_s2 = var_s2 * 3; // Adjust multiplier as needed
|
||||
|
||||
cos = __cosf(gStarfieldRoll);
|
||||
sin = __sinf(gStarfieldRoll);
|
||||
|
||||
for (i = 0; i < var_s2; i++, sp5C++, sp60++, sp58++) {
|
||||
bx = *sp60 + spf68;
|
||||
by = *sp5C + spf64;
|
||||
if (bx >= starfieldWidth * 1.25f) {
|
||||
bx -= 1.5f * starfieldWidth;
|
||||
|
||||
// Wrapping logic for individual stars along X-axis
|
||||
if (bx >= starfieldWidth) {
|
||||
bx -= starfieldWidth;
|
||||
}
|
||||
if (bx < 0.0f) {
|
||||
bx += starfieldWidth;
|
||||
}
|
||||
|
||||
// Wrapping logic for individual stars along Y-axis
|
||||
if (by >= starfieldHeight) {
|
||||
by -= starfieldHeight;
|
||||
}
|
||||
if (by < 0.0f) {
|
||||
by += starfieldHeight;
|
||||
}
|
||||
|
||||
// Center the positions
|
||||
bx -= starfieldWidth / 2.0f;
|
||||
if (by >= starfieldHeight * 1.25f) {
|
||||
by -= 1.5f * starfieldHeight;
|
||||
}
|
||||
by -= starfieldHeight / 2.0f;
|
||||
|
||||
// Apply rotation
|
||||
@@ -454,6 +470,10 @@ void Background_DrawPartialStarfield(s32 yMin, s32 yMax) { // Stars that are in
|
||||
FrameInterpolation_RecordCloseChild();
|
||||
}
|
||||
}
|
||||
// Restore original perspective after drawing stars
|
||||
Lib_InitPerspective(&gMasterDisp);
|
||||
|
||||
// Finalize rendering state
|
||||
gDPPipeSync(gMasterDisp++);
|
||||
gDPSetColorDither(gMasterDisp++, G_CD_MAGICSQ);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user