made the savefile value an int, less computation overall
This commit is contained in:
parent
93cb25db64
commit
9ac42e4fad
|
@ -12,25 +12,11 @@
|
|||
#define GAMEPLAY_WIDTH 252
|
||||
#define GAMEPLAY_HEIGHT 124
|
||||
|
||||
#define SCROLL_TICKS 9
|
||||
#define SCROLL_TICKS PORTAL_RENDER_DEPTH_MAX - 1
|
||||
#define SCROLL_INTERVALS (SCROLL_TICKS - 1)
|
||||
|
||||
#define GAMEPLAY_X ((SCREEN_WD - GAMEPLAY_WIDTH) / 2)
|
||||
|
||||
void gameplayOptionsInit(struct GameplayOptions* gameplayOptions) {
|
||||
gameplayOptions->selectedItem = GameplayOptionMovingPortals;
|
||||
|
||||
gameplayOptions->movingPortals = menuBuildCheckbox(&gDejaVuSansFont, "Movable Portals", GAMEPLAY_X + 8, GAMEPLAY_Y + 8);
|
||||
gameplayOptions->wideScreen = menuBuildCheckbox(&gDejaVuSansFont, "Wide Screen", GAMEPLAY_X + 8, GAMEPLAY_Y + 28);
|
||||
|
||||
gameplayOptions->portalRenderDepthText = menuBuildText(&gDejaVuSansFont, "Portal Render Depth", GAMEPLAY_X + 8, GAMEPLAY_Y + 48);
|
||||
gameplayOptions->portalRenderDepth = menuBuildSlider(GAMEPLAY_X + 126, GAMEPLAY_Y + 48, 126, SCROLL_TICKS);
|
||||
|
||||
gameplayOptions->movingPortals.checked = (gSaveData.controls.flags & ControlSaveMoveablePortals) != 0;
|
||||
gameplayOptions->wideScreen.checked = (gSaveData.controls.flags & ControlSaveWideScreen) != 0;
|
||||
gameplayOptions->portalRenderDepth.value = (float)gSaveData.controls.portalRenderDepth / 0xFFFF;
|
||||
}
|
||||
|
||||
#define FULL_SCROLL_TIME 2.0f
|
||||
#define SCROLL_MULTIPLIER (int)(0xFFFF * FIXED_DELTA_TIME / (80 * FULL_SCROLL_TIME))
|
||||
#define SCROLL_CHUNK_SIZE (0x10000 / SCROLL_INTERVALS)
|
||||
|
@ -66,6 +52,22 @@ void gameplayOptionsHandleSlider(unsigned short* settingValue, float* sliderValu
|
|||
*sliderValue = (float)newValue / 0xFFFF;
|
||||
}
|
||||
|
||||
void gameplayOptionsInit(struct GameplayOptions* gameplayOptions) {
|
||||
gameplayOptions->selectedItem = GameplayOptionMovingPortals;
|
||||
|
||||
gameplayOptions->movingPortals = menuBuildCheckbox(&gDejaVuSansFont, "Movable Portals", GAMEPLAY_X + 8, GAMEPLAY_Y + 8);
|
||||
gameplayOptions->wideScreen = menuBuildCheckbox(&gDejaVuSansFont, "Wide Screen", GAMEPLAY_X + 8, GAMEPLAY_Y + 28);
|
||||
|
||||
gameplayOptions->portalRenderDepthText = menuBuildText(&gDejaVuSansFont, "Portal Render Depth", GAMEPLAY_X + 8, GAMEPLAY_Y + 48);
|
||||
gameplayOptions->portalRenderDepth = menuBuildSlider(GAMEPLAY_X + 126, GAMEPLAY_Y + 48, 126, SCROLL_TICKS);
|
||||
|
||||
gameplayOptions->movingPortals.checked = (gSaveData.controls.flags & ControlSaveMoveablePortals) != 0;
|
||||
gameplayOptions->wideScreen.checked = (gSaveData.controls.flags & ControlSaveWideScreen) != 0;
|
||||
gameplayOptions->portalRenderDepth.value = (float)(gSaveData.controls.portalRenderDepth / PORTAL_RENDER_DEPTH_MAX);
|
||||
gameplayOptions->render_depth = (0xFFFF/PORTAL_RENDER_DEPTH_MAX)* gSaveData.controls.portalRenderDepth;
|
||||
gameplayOptionsHandleSlider(&gameplayOptions->render_depth, &gameplayOptions->portalRenderDepth.value);
|
||||
}
|
||||
|
||||
enum MenuDirection gameplayOptionsUpdate(struct GameplayOptions* gameplayOptions) {
|
||||
int controllerDir = controllerGetDirectionDown(0);
|
||||
|
||||
|
@ -115,7 +117,9 @@ enum MenuDirection gameplayOptionsUpdate(struct GameplayOptions* gameplayOptions
|
|||
}
|
||||
}
|
||||
case GameplayOptionPortalRenderDepth:
|
||||
gameplayOptionsHandleSlider(&gSaveData.controls.portalRenderDepth, &gameplayOptions->portalRenderDepth.value);
|
||||
|
||||
gameplayOptionsHandleSlider(&gameplayOptions->render_depth, &gameplayOptions->portalRenderDepth.value);
|
||||
gSaveData.controls.portalRenderDepth = (int)((gameplayOptions->render_depth * (1.0f/0xFFFF) * PORTAL_RENDER_DEPTH_MAX));
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ struct GameplayOptions {
|
|||
struct MenuSlider portalRenderDepth;
|
||||
Gfx* portalRenderDepthText;
|
||||
short selectedItem;
|
||||
unsigned short render_depth;
|
||||
};
|
||||
|
||||
void gameplayOptionsInit(struct GameplayOptions* gameplayOptions);
|
||||
|
|
|
@ -94,7 +94,7 @@ void savefileNew() {
|
|||
gSaveData.controls.sensitivity = 0x4000;
|
||||
gSaveData.controls.acceleration = 0x4000;
|
||||
gSaveData.controls.deadzone = 0x4000;
|
||||
gSaveData.controls.portalRenderDepth = 0x4000;
|
||||
gSaveData.controls.portalRenderDepth = 2;
|
||||
|
||||
gSaveData.audio.soundVolume = 0xFF;
|
||||
gSaveData.audio.musicVolume = 0xFF;
|
||||
|
|
|
@ -47,7 +47,7 @@ struct ControlSaveState {
|
|||
unsigned short flags;
|
||||
unsigned short sensitivity;
|
||||
unsigned short acceleration;
|
||||
unsigned short portalRenderDepth;
|
||||
int portalRenderDepth;
|
||||
unsigned short deadzone;
|
||||
};
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ void dynamicRenderListPopulate(struct DynamicRenderDataList* list, struct Render
|
|||
continue;
|
||||
}
|
||||
|
||||
if (stages[stageIndex].currentDepth == ((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX)) && (object->flags & DYNAMIC_SCENE_OBJECT_SKIP_ROOT)) {
|
||||
if (stages[stageIndex].currentDepth == gSaveData.controls.portalRenderDepth && (object->flags & DYNAMIC_SCENE_OBJECT_SKIP_ROOT)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ void renderPropsInit(struct RenderProps* props, struct Camera* camera, float asp
|
|||
cameraSetupMatrices(camera, renderState, aspectRatio, &fullscreenViewport, 1, &props->cameraMatrixInfo);
|
||||
|
||||
props->viewport = &fullscreenViewport;
|
||||
props->currentDepth = ((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX));
|
||||
props->currentDepth = gSaveData.controls.portalRenderDepth;
|
||||
props->exitPortalIndex = NO_PORTAL;
|
||||
props->fromRoom = roomIndex;
|
||||
props->parentStageIndex = -1;
|
||||
|
@ -70,12 +70,12 @@ void renderPropscheckViewportSize(int* min, int* max, int screenSize) {
|
|||
}
|
||||
|
||||
int renderPropsZDistance(int currentDepth) {
|
||||
if (currentDepth >= ((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX))) {
|
||||
if (currentDepth >= gSaveData.controls.portalRenderDepth) {
|
||||
return 0;
|
||||
} else if (currentDepth < 0) {
|
||||
return G_MAXZ;
|
||||
} else {
|
||||
return G_MAXZ - (G_MAXZ >> (((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX)) - currentDepth));
|
||||
return G_MAXZ - (G_MAXZ >> (gSaveData.controls.portalRenderDepth - currentDepth));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ int renderShouldRenderOtherPortal(struct Scene* scene, int visiblePortal, struct
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ((scene->player.body.flags & (RigidBodyIsTouchingPortalA << visiblePortal)) != 0 && properties->currentDepth == ((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX))) {
|
||||
if ((scene->player.body.flags & (RigidBodyIsTouchingPortalA << visiblePortal)) != 0 && properties->currentDepth == gSaveData.controls.portalRenderDepth) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -415,9 +415,9 @@ void renderPlanFinishView(struct RenderPlan* renderPlan, struct Scene* scene, st
|
|||
}
|
||||
|
||||
void renderPlanAdjustViewportDepth(struct RenderPlan* renderPlan) {
|
||||
float depthWeight[((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX)) + 1];
|
||||
float depthWeight[gSaveData.controls.portalRenderDepth + 1];
|
||||
|
||||
for (int i = 0; i <= ((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX)); ++i) {
|
||||
for (int i = 0; i <= gSaveData.controls.portalRenderDepth; ++i) {
|
||||
depthWeight[i] = 0.0f;
|
||||
}
|
||||
|
||||
|
@ -431,21 +431,21 @@ void renderPlanAdjustViewportDepth(struct RenderPlan* renderPlan) {
|
|||
|
||||
float totalWeight = 0.0f;
|
||||
|
||||
for (int i = 0; i <= ((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX)); ++i) {
|
||||
for (int i = 0; i <= gSaveData.controls.portalRenderDepth; ++i) {
|
||||
totalWeight += depthWeight[i];
|
||||
}
|
||||
|
||||
// give the main view a larger slice of the depth buffer
|
||||
totalWeight += depthWeight[((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX))];
|
||||
depthWeight[((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX))] *= 2.0f;
|
||||
totalWeight += depthWeight[gSaveData.controls.portalRenderDepth];
|
||||
depthWeight[gSaveData.controls.portalRenderDepth] *= 2.0f;
|
||||
|
||||
float scale = (float)G_MAXZ / totalWeight;
|
||||
|
||||
short zBufferBoundary[((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX)) + 2];
|
||||
short zBufferBoundary[gSaveData.controls.portalRenderDepth + 2];
|
||||
|
||||
zBufferBoundary[((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX)) + 1] = 0;
|
||||
zBufferBoundary[gSaveData.controls.portalRenderDepth + 1] = 0;
|
||||
|
||||
for (int i = ((int)(gSaveData.controls.portalRenderDepth * (1.0f / 0xFFFF) * PORTAL_RENDER_DEPTH_MAX)); i >= 0; --i) {
|
||||
for (int i = gSaveData.controls.portalRenderDepth; i >= 0; --i) {
|
||||
zBufferBoundary[i] = (short)(scale * depthWeight[i]) + zBufferBoundary[i + 1];
|
||||
|
||||
zBufferBoundary[i] = MIN(zBufferBoundary[i], G_MAXZ);
|
||||
|
|
Loading…
Reference in a new issue