mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Add ability to disable aspect ratio adjustment
This commit is contained in:
parent
b6a396b0cd
commit
18a3b333e8
9 changed files with 106 additions and 1 deletions
|
|
@ -8828,6 +8828,17 @@ function get_vertex_color(index)
|
||||||
-- ...
|
-- ...
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param enable boolean
|
||||||
|
--- @return nil
|
||||||
|
function gfx_enable_adjust_for_aspect_ratio(enable)
|
||||||
|
-- ...
|
||||||
|
end
|
||||||
|
|
||||||
|
--- @return boolean
|
||||||
|
function gfx_get_adjust_for_aspect_ratio()
|
||||||
|
-- ...
|
||||||
|
end
|
||||||
|
|
||||||
--- @param type HudDisplayValue
|
--- @param type HudDisplayValue
|
||||||
--- @return integer
|
--- @return integer
|
||||||
function hud_get_value(type)
|
function hud_get_value(type)
|
||||||
|
|
|
||||||
|
|
@ -1192,6 +1192,44 @@
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [gfx_enable_adjust_for_aspect_ratio](#gfx_enable_adjust_for_aspect_ratio)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`gfx_enable_adjust_for_aspect_ratio(enable)`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
| Field | Type |
|
||||||
|
| ----- | ---- |
|
||||||
|
| enable | `boolean` |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- None
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`void gfx_enable_adjust_for_aspect_ratio(bool enable);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
## [gfx_get_adjust_for_aspect_ratio](#gfx_get_adjust_for_aspect_ratio)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`local booleanValue = gfx_get_adjust_for_aspect_ratio()`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
- None
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- `boolean`
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`bool gfx_get_adjust_for_aspect_ratio(void);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## [hud_get_value](#hud_get_value)
|
## [hud_get_value](#hud_get_value)
|
||||||
|
|
||||||
### Lua Example
|
### Lua Example
|
||||||
|
|
|
||||||
|
|
@ -1657,6 +1657,8 @@
|
||||||
- [get_time](functions-5.md#get_time)
|
- [get_time](functions-5.md#get_time)
|
||||||
- [get_ttc_speed_setting](functions-5.md#get_ttc_speed_setting)
|
- [get_ttc_speed_setting](functions-5.md#get_ttc_speed_setting)
|
||||||
- [get_vertex_color](functions-5.md#get_vertex_color)
|
- [get_vertex_color](functions-5.md#get_vertex_color)
|
||||||
|
- [gfx_enable_adjust_for_aspect_ratio](functions-5.md#gfx_enable_adjust_for_aspect_ratio)
|
||||||
|
- [gfx_get_adjust_for_aspect_ratio](functions-5.md#gfx_get_adjust_for_aspect_ratio)
|
||||||
- [hud_get_value](functions-5.md#hud_get_value)
|
- [hud_get_value](functions-5.md#hud_get_value)
|
||||||
- [hud_hide](functions-5.md#hud_hide)
|
- [hud_hide](functions-5.md#hud_hide)
|
||||||
- [hud_is_hidden](functions-5.md#hud_is_hidden)
|
- [hud_is_hidden](functions-5.md#hud_is_hidden)
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,8 @@ Color gVertexColor = { 255, 255, 255 };
|
||||||
Color gFogColor = { 255, 255, 255 };
|
Color gFogColor = { 255, 255, 255 };
|
||||||
f32 gFogIntensity = 1;
|
f32 gFogIntensity = 1;
|
||||||
|
|
||||||
|
bool gAdjustForAspectRatio = true;
|
||||||
|
|
||||||
// 4x4 pink-black checkerboard texture to indicate missing textures
|
// 4x4 pink-black checkerboard texture to indicate missing textures
|
||||||
#define MISSING_W 4
|
#define MISSING_W 4
|
||||||
#define MISSING_H 4
|
#define MISSING_H 4
|
||||||
|
|
@ -751,6 +753,8 @@ static void gfx_sp_pop_matrix(uint32_t count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static float gfx_adjust_x_for_aspect_ratio(float x) {
|
static float gfx_adjust_x_for_aspect_ratio(float x) {
|
||||||
|
if (!gAdjustForAspectRatio) return x * (4.0 / 3.0f) / (4.0f / 3.0f);
|
||||||
|
|
||||||
return x * (4.0f / 3.0f) / ((float)gfx_current_dimensions.width / (float)gfx_current_dimensions.height);
|
return x * (4.0f / 3.0f) / ((float)gfx_current_dimensions.width / (float)gfx_current_dimensions.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1816,7 +1820,7 @@ void gfx_start_frame(void) {
|
||||||
// Avoid division by zero
|
// Avoid division by zero
|
||||||
gfx_current_dimensions.height = 1;
|
gfx_current_dimensions.height = 1;
|
||||||
}
|
}
|
||||||
gfx_current_dimensions.aspect_ratio = (float)gfx_current_dimensions.width / (float)gfx_current_dimensions.height;
|
gfx_current_dimensions.aspect_ratio = gAdjustForAspectRatio ? ((float)gfx_current_dimensions.width / (float)gfx_current_dimensions.height) : (4.0f / 3.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_run(Gfx *commands) {
|
void gfx_run(Gfx *commands) {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ extern Color gVertexColor;
|
||||||
extern Color gFogColor;
|
extern Color gFogColor;
|
||||||
extern f32 gFogIntensity;
|
extern f32 gFogIntensity;
|
||||||
|
|
||||||
|
extern bool gAdjustForAspectRatio;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -29133,6 +29133,38 @@ int smlua_func_get_vertex_color(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int smlua_func_gfx_enable_adjust_for_aspect_ratio(lua_State* L) {
|
||||||
|
if (L == NULL) { return 0; }
|
||||||
|
|
||||||
|
int top = lua_gettop(L);
|
||||||
|
if (top != 1) {
|
||||||
|
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "gfx_enable_adjust_for_aspect_ratio", 1, top);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool enable = smlua_to_boolean(L, 1);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "gfx_enable_adjust_for_aspect_ratio"); return 0; }
|
||||||
|
|
||||||
|
gfx_enable_adjust_for_aspect_ratio(enable);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int smlua_func_gfx_get_adjust_for_aspect_ratio(UNUSED lua_State* L) {
|
||||||
|
if (L == NULL) { return 0; }
|
||||||
|
|
||||||
|
int top = lua_gettop(L);
|
||||||
|
if (top != 0) {
|
||||||
|
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "gfx_get_adjust_for_aspect_ratio", 0, top);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
lua_pushboolean(L, gfx_get_adjust_for_aspect_ratio());
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int smlua_func_hud_get_value(lua_State* L) {
|
int smlua_func_hud_get_value(lua_State* L) {
|
||||||
if (L == NULL) { return 0; }
|
if (L == NULL) { return 0; }
|
||||||
|
|
||||||
|
|
@ -32894,6 +32926,8 @@ void smlua_bind_functions_autogen(void) {
|
||||||
smlua_bind_function(L, "get_time", smlua_func_get_time);
|
smlua_bind_function(L, "get_time", smlua_func_get_time);
|
||||||
smlua_bind_function(L, "get_ttc_speed_setting", smlua_func_get_ttc_speed_setting);
|
smlua_bind_function(L, "get_ttc_speed_setting", smlua_func_get_ttc_speed_setting);
|
||||||
smlua_bind_function(L, "get_vertex_color", smlua_func_get_vertex_color);
|
smlua_bind_function(L, "get_vertex_color", smlua_func_get_vertex_color);
|
||||||
|
smlua_bind_function(L, "gfx_enable_adjust_for_aspect_ratio", smlua_func_gfx_enable_adjust_for_aspect_ratio);
|
||||||
|
smlua_bind_function(L, "gfx_get_adjust_for_aspect_ratio", smlua_func_gfx_get_adjust_for_aspect_ratio);
|
||||||
smlua_bind_function(L, "hud_get_value", smlua_func_hud_get_value);
|
smlua_bind_function(L, "hud_get_value", smlua_func_hud_get_value);
|
||||||
smlua_bind_function(L, "hud_hide", smlua_func_hud_hide);
|
smlua_bind_function(L, "hud_hide", smlua_func_hud_hide);
|
||||||
smlua_bind_function(L, "hud_is_hidden", smlua_func_hud_is_hidden);
|
smlua_bind_function(L, "hud_is_hidden", smlua_func_hud_is_hidden);
|
||||||
|
|
|
||||||
|
|
@ -628,6 +628,16 @@ bool get_coop_compatibility_enabled(void) {
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
||||||
|
bool gfx_get_adjust_for_aspect_ratio(void) {
|
||||||
|
return gAdjustForAspectRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_enable_adjust_for_aspect_ratio(bool enable) {
|
||||||
|
gAdjustForAspectRatio = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
|
||||||
const char* get_os_name(void) {
|
const char* get_os_name(void) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
return "Windows";
|
return "Windows";
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,9 @@ void set_override_envfx(s32 envfx);
|
||||||
|
|
||||||
bool get_coop_compatibility_enabled(void);
|
bool get_coop_compatibility_enabled(void);
|
||||||
|
|
||||||
|
bool gfx_get_adjust_for_aspect_ratio(void);
|
||||||
|
void gfx_enable_adjust_for_aspect_ratio(bool enable);
|
||||||
|
|
||||||
const char* get_os_name(void);
|
const char* get_os_name(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -672,6 +672,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect
|
||||||
gFogIntensity = 1;
|
gFogIntensity = 1;
|
||||||
gOverrideBackground = -1;
|
gOverrideBackground = -1;
|
||||||
gOverrideEnvFx = -1;
|
gOverrideEnvFx = -1;
|
||||||
|
gAdjustForAspectRatio = true;
|
||||||
gRomhackCameraAllowCentering = TRUE;
|
gRomhackCameraAllowCentering = TRUE;
|
||||||
gOverrideAllowToxicGasCamera = FALSE;
|
gOverrideAllowToxicGasCamera = FALSE;
|
||||||
gRomhackCameraAllowDpad = FALSE;
|
gRomhackCameraAllowDpad = FALSE;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue