Fixed dolphin ratioing

This commit is contained in:
2026-06-25 22:21:12 -05:00
parent a74f1568e9
commit 454b8a91ba
7 changed files with 63 additions and 17 deletions
+5 -2
View File
@@ -7,8 +7,11 @@ set_property(CACHE DUSK_DOLPHIN_BUILD_TYPE PROPERTY STRINGS "DOL" "ISO")
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
DUSK_DOLPHIN DUSK_DOLPHIN
DUSK_INPUT_GAMEPAD DUSK_INPUT_GAMEPAD
DUSK_DISPLAY_WIDTH=640 # DUSK_DISPLAY_WIDTH=640
DUSK_DISPLAY_HEIGHT=480 # DUSK_DISPLAY_HEIGHT=480
DUSK_DISPLAY_WIDTH=320
DUSK_DISPLAY_HEIGHT=240
DUSK_DISPLAY_OVERSCAN=16
DUSK_THREAD_PTHREAD DUSK_THREAD_PTHREAD
DOL=1 DOL=1
ISO=2 ISO=2
+13 -1
View File
@@ -56,10 +56,15 @@ errorret_t screenBind() {
// Assume backbuffer is currently bound. // Assume backbuffer is currently bound.
switch(SCREEN.mode) { switch(SCREEN.mode) {
case SCREEN_MODE_BACKBUFFER: { case SCREEN_MODE_BACKBUFFER: {
// Screen mode backbuffer uses the full display size #if defined(DUSK_DISPLAY_WIDTH) && defined(DUSK_DISPLAY_HEIGHT)
SCREEN.width = DUSK_DISPLAY_WIDTH;
SCREEN.height = DUSK_DISPLAY_HEIGHT;
SCREEN.aspect = (float_t)DUSK_DISPLAY_WIDTH / (float_t)DUSK_DISPLAY_HEIGHT;
#else
SCREEN.width = frameBufferGetWidth(FRAMEBUFFER_BOUND); SCREEN.width = frameBufferGetWidth(FRAMEBUFFER_BOUND);
SCREEN.height = frameBufferGetHeight(FRAMEBUFFER_BOUND); SCREEN.height = frameBufferGetHeight(FRAMEBUFFER_BOUND);
SCREEN.aspect = frameBufferGetAspect(FRAMEBUFFER_BOUND); SCREEN.aspect = frameBufferGetAspect(FRAMEBUFFER_BOUND);
#endif
screenUpdateScan(); screenUpdateScan();
// No needd for a framebuffer. // No needd for a framebuffer.
@@ -407,10 +412,17 @@ errorret_t screenRender() {
} }
void screenUpdateScan(void) { void screenUpdateScan(void) {
#ifdef DUSK_DISPLAY_OVERSCAN
SCREEN.scanX = DUSK_DISPLAY_OVERSCAN;
SCREEN.scanY = DUSK_DISPLAY_OVERSCAN;
SCREEN.scanWidth = SCREEN.width - DUSK_DISPLAY_OVERSCAN * 2;
SCREEN.scanHeight = SCREEN.height - DUSK_DISPLAY_OVERSCAN * 2;
#else
SCREEN.scanX = 0; SCREEN.scanX = 0;
SCREEN.scanY = 0; SCREEN.scanY = 0;
SCREEN.scanWidth = SCREEN.width; SCREEN.scanWidth = SCREEN.width;
SCREEN.scanHeight = SCREEN.height; SCREEN.scanHeight = SCREEN.height;
#endif
#ifdef DUSK_DISPLAY_SIZE_DYNAMIC #ifdef DUSK_DISPLAY_SIZE_DYNAMIC
// Find the smallest standard ratio >= the screen aspect. // Find the smallest standard ratio >= the screen aspect.
+1 -1
View File
@@ -33,9 +33,9 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
ENGINE.version = DUSK_VERSION; ENGINE.version = DUSK_VERSION;
// Init systems. Order is important. // Init systems. Order is important.
errorChain(systemInit());
timeInit(); timeInit();
consoleInit(); consoleInit();
errorChain(systemInit());
errorChain(inputInit()); errorChain(inputInit());
errorChain(assetInit()); errorChain(assetInit());
// errorChain(saveInit()); // errorChain(saveInit());
+5 -3
View File
@@ -8,14 +8,16 @@
#pragma once #pragma once
#include "dusk.h" #include "dusk.h"
#define CHUNK_WIDTH 16 #define TILE_SIZE_PIXELS 24
#define CHUNK_HEIGHT CHUNK_WIDTH
#define CHUNK_WIDTH 12
#define CHUNK_HEIGHT 16
#define CHUNK_DEPTH 8 #define CHUNK_DEPTH 8
#define CHUNK_TILE_COUNT (CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_DEPTH) #define CHUNK_TILE_COUNT (CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_DEPTH)
#define MAP_CHUNK_WIDTH 5 #define MAP_CHUNK_WIDTH 5
#define MAP_CHUNK_HEIGHT 5 #define MAP_CHUNK_HEIGHT 4
#define MAP_CHUNK_DEPTH 3 #define MAP_CHUNK_DEPTH 3
#define MAP_CHUNK_COUNT (MAP_CHUNK_WIDTH * MAP_CHUNK_HEIGHT * MAP_CHUNK_DEPTH) #define MAP_CHUNK_COUNT (MAP_CHUNK_WIDTH * MAP_CHUNK_HEIGHT * MAP_CHUNK_DEPTH)
+13 -3
View File
@@ -58,12 +58,22 @@ errorret_t sceneOverworldRender(scenedata_t *sceneData) {
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, proj)); errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, proj));
// Camera Eye // Camera Eye
float_t pixelsPerUnit = 16.0f; float_t pixelsPerUnit = TILE_SIZE_PIXELS;
float_t worldH = (float)SCREEN.height / pixelsPerUnit; float_t worldH = (float_t)SCREEN.height / pixelsPerUnit;
float_t z = (worldH * 0.5f) / tanf(fov * 0.5f); float_t z = (worldH * 0.5f) / tanf(fov * 0.5f);
vec3 worldPosVec; vec3 worldPosVec;
rpgCameraGetPosition(worldPosVec); rpgCameraGetPosition(worldPosVec);
float_t offset = -16.0f; float_t offset = -32.0f * (worldH / TILE_SIZE_PIXELS);
// consolePrint(
// "FOV: %f, Aspect: %f, WorldH: %f, Z: %f, Offset: %f, ScreenH: %d",
// fov,
// (float_t)SCREEN.width / (float_t)SCREEN.height,
// worldH,
// z,
// offset,
// SCREEN.height
// );
glm_vec3_add(worldPosVec, (vec3){ 0.5f, 0.5f, 0.5f }, worldPosVec); glm_vec3_add(worldPosVec, (vec3){ 0.5f, 0.5f, 0.5f }, worldPosVec);
+4
View File
@@ -19,6 +19,10 @@ errorret_t uiCropInit(void) {
} }
errorret_t uiCropDraw(void) { errorret_t uiCropDraw(void) {
#ifndef DUSK_DISPLAY_SIZE_DYNAMIC
errorOk();
#endif
if( if(
SCREEN.scanX == 0 && SCREEN.scanX == 0 &&
SCREEN.scanY == 0 && SCREEN.scanY == 0 &&
+15
View File
@@ -9,8 +9,23 @@
#include "input/input.h" #include "input/input.h"
#include "util/string.h" #include "util/string.h"
#include "assert/assert.h" #include "assert/assert.h"
#include "console/console.h"
errorret_t systemInitDolphin(void) { errorret_t systemInitDolphin(void) {
char_t *names[] = {
"4:3",
"16:9",
"Unknown"
};
int32_t ratio = systemGetAspectRatioDolphin();
uint8_t i = (
ratio == CONF_ASPECT_4_3 ? 0 :
ratio == CONF_ASPECT_16_9 ? 1 :
2
);
consolePrint("Dolphin Aspect Ratio: %s", names[i]);
errorOk(); errorOk();
} }