Let's get this rendering on PSP and Dolphin.

This commit is contained in:
2026-03-08 15:46:38 -05:00
parent 5dd22fad6c
commit 4bf26dc818
9 changed files with 90 additions and 91 deletions

View File

@@ -4,56 +4,56 @@ module('scene')
module('locale') module('locale')
-- Default Input bindings. -- Default Input bindings.
-- if PLATFORM == "psp" then if PLATFORM == "psp" then
-- inputBind("up", INPUT_ACTION_UP) inputBind("up", INPUT_ACTION_UP)
-- inputBind("down", INPUT_ACTION_DOWN) inputBind("down", INPUT_ACTION_DOWN)
-- inputBind("left", INPUT_ACTION_LEFT) inputBind("left", INPUT_ACTION_LEFT)
-- inputBind("right", INPUT_ACTION_RIGHT) inputBind("right", INPUT_ACTION_RIGHT)
-- inputBind("circle", INPUT_ACTION_CANCEL) inputBind("circle", INPUT_ACTION_CANCEL)
-- inputBind("cross", INPUT_ACTION_ACCEPT) inputBind("cross", INPUT_ACTION_ACCEPT)
-- inputBind("select", INPUT_ACTION_RAGEQUIT) inputBind("select", INPUT_ACTION_RAGEQUIT)
-- inputBind("lstick_up", INPUT_ACTION_UP) inputBind("lstick_up", INPUT_ACTION_UP)
-- inputBind("lstick_down", INPUT_ACTION_DOWN) inputBind("lstick_down", INPUT_ACTION_DOWN)
-- inputBind("lstick_left", INPUT_ACTION_LEFT) inputBind("lstick_left", INPUT_ACTION_LEFT)
-- inputBind("lstick_right", INPUT_ACTION_RIGHT) inputBind("lstick_right", INPUT_ACTION_RIGHT)
-- elseif DOLPHIN then elseif DOLPHIN then
-- inputBind("up", INPUT_ACTION_UP) inputBind("up", INPUT_ACTION_UP)
-- inputBind("down", INPUT_ACTION_DOWN) inputBind("down", INPUT_ACTION_DOWN)
-- inputBind("left", INPUT_ACTION_LEFT) inputBind("left", INPUT_ACTION_LEFT)
-- inputBind("right", INPUT_ACTION_RIGHT) inputBind("right", INPUT_ACTION_RIGHT)
-- inputBind("b", INPUT_ACTION_CANCEL) inputBind("b", INPUT_ACTION_CANCEL)
-- inputBind("a", INPUT_ACTION_ACCEPT) inputBind("a", INPUT_ACTION_ACCEPT)
-- inputBind("z", INPUT_ACTION_RAGEQUIT) inputBind("z", INPUT_ACTION_RAGEQUIT)
-- inputBind("lstick_up", INPUT_ACTION_UP) inputBind("lstick_up", INPUT_ACTION_UP)
-- inputBind("lstick_down", INPUT_ACTION_DOWN) inputBind("lstick_down", INPUT_ACTION_DOWN)
-- inputBind("lstick_left", INPUT_ACTION_LEFT) inputBind("lstick_left", INPUT_ACTION_LEFT)
-- inputBind("lstick_right", INPUT_ACTION_RIGHT) inputBind("lstick_right", INPUT_ACTION_RIGHT)
-- else else
-- if INPUT_KEYBOARD then if INPUT_KEYBOARD then
-- inputBind("w", INPUT_ACTION_UP) inputBind("w", INPUT_ACTION_UP)
-- inputBind("s", INPUT_ACTION_DOWN) inputBind("s", INPUT_ACTION_DOWN)
-- inputBind("a", INPUT_ACTION_LEFT) inputBind("a", INPUT_ACTION_LEFT)
-- inputBind("d", INPUT_ACTION_RIGHT) inputBind("d", INPUT_ACTION_RIGHT)
-- inputBind("left", INPUT_ACTION_LEFT) inputBind("left", INPUT_ACTION_LEFT)
-- inputBind("right", INPUT_ACTION_RIGHT) inputBind("right", INPUT_ACTION_RIGHT)
-- inputBind("up", INPUT_ACTION_UP) inputBind("up", INPUT_ACTION_UP)
-- inputBind("down", INPUT_ACTION_DOWN) inputBind("down", INPUT_ACTION_DOWN)
-- inputBind("enter", INPUT_ACTION_ACCEPT) inputBind("enter", INPUT_ACTION_ACCEPT)
-- inputBind("e", INPUT_ACTION_ACCEPT) inputBind("e", INPUT_ACTION_ACCEPT)
-- inputBind("q", INPUT_ACTION_CANCEL) inputBind("q", INPUT_ACTION_CANCEL)
-- inputBind("escape", INPUT_ACTION_RAGEQUIT) inputBind("escape", INPUT_ACTION_RAGEQUIT)
-- end end
-- if INPUT_POINTER then if INPUT_POINTER then
-- inputBind("mouse_x", INPUT_ACTION_POINTERX) inputBind("mouse_x", INPUT_ACTION_POINTERX)
-- inputBind("mouse_y", INPUT_ACTION_POINTERY) inputBind("mouse_y", INPUT_ACTION_POINTERY)
-- end end
-- end end
-- sceneSet('scene/minesweeper.lua') sceneSet('scene/minesweeper.lua')

View File

@@ -183,24 +183,30 @@ function sceneRender()
camera.bottom = screenGetHeight() camera.bottom = screenGetHeight()
camera.right = screenGetWidth() camera.right = screenGetWidth()
spriteBatchPush(
nil,
0, 0, 32, 32,
colorBlue()
)
-- Update mouse position -- Update mouse position
if INPUT_POINTER then -- if INPUT_POINTER then
mouseX = inputGetValue(INPUT_ACTION_POINTERX) * screenGetWidth() -- mouseX = inputGetValue(INPUT_ACTION_POINTERX) * screenGetWidth()
mouseY = inputGetValue(INPUT_ACTION_POINTERY) * screenGetHeight() -- mouseY = inputGetValue(INPUT_ACTION_POINTERY) * screenGetHeight()
-- Draw cursor -- -- Draw cursor
spriteBatchPush( -- spriteBatchPush(
nil, -- nil,
mouseX - 2, mouseY - 2, -- mouseX - 2, mouseY - 2,
mouseX + 2, mouseY + 2, -- mouseX + 2, mouseY + 2,
colorRed(), -- colorRed(),
0, 0, -- 0, 0,
1, 1 -- 1, 1
) -- )
end -- end
textDraw(10, 10, "Hello World") -- textDraw(10, 10, "Hello World")
-- centerX = math.floor(screenGetWidth() / 2) -- centerX = math.floor(screenGetWidth() / 2)
-- centerY = math.floor(screenGetHeight() / 2) -- centerY = math.floor(screenGetHeight() / 2)

View File

@@ -17,9 +17,9 @@ errorret_t screenInit() {
SCREEN.background = COLOR_CORNFLOWER_BLUE; SCREEN.background = COLOR_CORNFLOWER_BLUE;
#if DISPLAY_SIZE_DYNAMIC == 1 #ifdef DUSK_DISPLAY_SIZE_DYNAMIC
SCREEN.mode = SCREEN_MODE_FIXED_VIEWPORT_HEIGHT; SCREEN.mode = SCREEN_MODE_FIXED_VIEWPORT_HEIGHT;
SCREEN.fixedHeight.height = DISPLAY_SCREEN_HEIGHT_DEFAULT; SCREEN.fixedHeight.height = DUSK_DISPLAY_SCREEN_HEIGHT;
cameraInitOrthographic(&SCREEN.framebufferCamera); cameraInitOrthographic(&SCREEN.framebufferCamera);
SCREEN.framebufferCamera.viewType = CAMERA_VIEW_TYPE_2D; SCREEN.framebufferCamera.viewType = CAMERA_VIEW_TYPE_2D;
@@ -27,14 +27,14 @@ errorret_t screenInit() {
SCREEN.framebufferCamera._2d.position[1] = 0; SCREEN.framebufferCamera._2d.position[1] = 0;
SCREEN.framebufferCamera._2d.zoom = 1.0f; SCREEN.framebufferCamera._2d.zoom = 1.0f;
errorChain(quadBuffer( quadBuffer(
SCREEN.frameBufferMeshVertices, SCREEN.frameBufferMeshVertices,
0.0f, 0.0f, 0.0f, 0.0f,
1.0f, 1.0f, 1.0f, 1.0f,
COLOR_WHITE, COLOR_WHITE,
0.0f, 0.0f, 0.0f, 0.0f,
1.0f, 1.0f 1.0f, 1.0f
)); );
errorChain(meshInit( errorChain(meshInit(
&SCREEN.frameBufferMesh, &SCREEN.frameBufferMesh,
QUAD_PRIMITIVE_TYPE, QUAD_PRIMITIVE_TYPE,
@@ -57,7 +57,7 @@ void screenBind() {
SCREEN.height = frameBufferGetHeight(FRAMEBUFFER_BOUND); SCREEN.height = frameBufferGetHeight(FRAMEBUFFER_BOUND);
// No needd for a framebuffer. // No needd for a framebuffer.
#if DISPLAY_SIZE_DYNAMIC == 1 #ifdef DUSK_DISPLAY_SIZE_DYNAMIC
if(SCREEN.framebufferReady) { if(SCREEN.framebufferReady) {
frameBufferDispose(&SCREEN.framebuffer); frameBufferDispose(&SCREEN.framebuffer);
SCREEN.framebufferReady = false; SCREEN.framebufferReady = false;
@@ -66,7 +66,7 @@ void screenBind() {
break; break;
} }
#if DISPLAY_SIZE_DYNAMIC == 1 #ifdef DUSK_DISPLAY_SIZE_DYNAMIC
case SCREEN_MODE_FIXED_SIZE: { case SCREEN_MODE_FIXED_SIZE: {
SCREEN.width = SCREEN.fixedSize.width; SCREEN.width = SCREEN.fixedSize.width;
SCREEN.height = SCREEN.fixedSize.height; SCREEN.height = SCREEN.fixedSize.height;
@@ -270,7 +270,7 @@ void screenUnbind() {
case SCREEN_MODE_BACKBUFFER: case SCREEN_MODE_BACKBUFFER:
break; break;
#if DISPLAY_SIZE_DYNAMIC == 1 #ifdef DUSK_DISPLAY_SIZE_DYNAMIC
case SCREEN_MODE_ASPECT_RATIO: case SCREEN_MODE_ASPECT_RATIO:
case SCREEN_MODE_FIXED_HEIGHT: case SCREEN_MODE_FIXED_HEIGHT:
case SCREEN_MODE_FIXED_SIZE: case SCREEN_MODE_FIXED_SIZE:
@@ -293,7 +293,7 @@ void screenRender() {
return; return;
} }
#if DISPLAY_SIZE_DYNAMIC == 1 #ifdef DUSK_DISPLAY_SIZE_DYNAMIC
if(SCREEN.mode == SCREEN_MODE_FIXED_VIEWPORT_HEIGHT) { if(SCREEN.mode == SCREEN_MODE_FIXED_VIEWPORT_HEIGHT) {
glViewport(0, 0, SCREEN.width, SCREEN.height); glViewport(0, 0, SCREEN.width, SCREEN.height);
return; return;
@@ -369,7 +369,7 @@ void screenRender() {
} }
void screenDispose() { void screenDispose() {
#if DISPLAY_SIZE_DYNAMIC == 1 #ifdef DUSK_DISPLAY_SIZE_DYNAMIC
if(SCREEN.framebufferReady) { if(SCREEN.framebufferReady) {
frameBufferDispose(&SCREEN.framebuffer); frameBufferDispose(&SCREEN.framebuffer);
SCREEN.framebufferReady = false; SCREEN.framebufferReady = false;

View File

@@ -12,7 +12,7 @@
#include "display/mesh/quad.h" #include "display/mesh/quad.h"
#include "display/color.h" #include "display/color.h"
#if DUSK_DISPLAY_SIZE_DYNAMIC == 1 #ifdef DUSK_DISPLAY_SIZE_DYNAMIC
#ifndef DUSK_DISPLAY_SCREEN_HEIGHT #ifndef DUSK_DISPLAY_SCREEN_HEIGHT
#error "DUSK_DISPLAY_SCREEN_HEIGHT must be defined" #error "DUSK_DISPLAY_SCREEN_HEIGHT must be defined"
#endif #endif
@@ -47,7 +47,7 @@ typedef struct {
float_t aspect; float_t aspect;
color_t background; color_t background;
#if DISPLAY_SIZE_DYNAMIC == 1 #ifdef DUSK_DISPLAY_SIZE_DYNAMIC
framebuffer_t framebuffer; framebuffer_t framebuffer;
bool_t framebufferReady; bool_t framebufferReady;
camera_t framebufferCamera; camera_t framebufferCamera;

View File

@@ -14,7 +14,7 @@ typedef struct {
float_t lastValue; float_t lastValue;
float_t currentValue; float_t currentValue;
#if TIME_FIXED == 0 #ifdef DUSK_TIME_DYNAMIC
float_t lastDynamicValue; float_t lastDynamicValue;
float_t currentDynamicValue; float_t currentDynamicValue;
#endif #endif

View File

@@ -168,8 +168,8 @@ errorret_t mapPositionSet(const chunkpos_t newPos) {
} }
void mapUpdate() { void mapUpdate() {
#if TIME_FIXED == 0 #ifdef DUSK_TIME_DYNAMIC
if(!TIME.dynamicUpdate) return; if(!TIME.dynamicUpdate) return;
#endif #endif
} }

View File

@@ -21,10 +21,10 @@ errorret_t sceneInit(void) {
} }
errorret_t sceneUpdate(void) { errorret_t sceneUpdate(void) {
#if TIME_FIXED == 0 #ifdef DUSK_TIME_DYNAMIC
if(!TIME.dynamicUpdate) { if(!TIME.dynamicUpdate) {
errorOk(); errorOk();
} }
#endif #endif
lua_getglobal(SCENE.scriptContext.luaState, "sceneUpdate"); lua_getglobal(SCENE.scriptContext.luaState, "sceneUpdate");

View File

@@ -18,25 +18,18 @@ void moduleInput(scriptcontext_t *context) {
// Input values. // Input values.
scriptContextExec(context, scriptContextExec(context,
#if INPUT_KEYBOARD == 1 ""
#ifdef DUSK_INPUT_KEYBOARD
"INPUT_KEYBOARD = true\n" "INPUT_KEYBOARD = true\n"
#else
""
#endif #endif
#if INPUT_GAMEPAD == 1 #ifdef DUSK_INPUT_GAMEPAD
"INPUT_GAMEPAD = true\n" "INPUT_GAMEPAD = true\n"
#else
""
#endif #endif
#if INPUT_POINTER == 1 #ifdef DUSK_INPUT_POINTER
"INPUT_POINTER = true\n" "INPUT_POINTER = true\n"
#else
""
#endif #endif
#if INPUT_SDL2 == 1 #ifdef DUSK_INPUT_TOUCH
"INPUT_SDL2 = true\n" "INPUT_TOUCH = true\n"
#else
""
#endif #endif
); );

View File

@@ -15,7 +15,7 @@ typedef framebuffergl_t framebufferplatform_t;
#define frameBufferPlatformBind frameBufferGLBind #define frameBufferPlatformBind frameBufferGLBind
#define frameBufferPlatformClear frameBufferGLClear #define frameBufferPlatformClear frameBufferGLClear
#if DUSK_DISPLAY_SIZE_DYNAMIC #ifdef DUSK_DISPLAY_SIZE_DYNAMIC
#define frameBufferPlatformInit frameBufferGLInit #define frameBufferPlatformInit frameBufferGLInit
#define frameBufferPlatformDispose frameBufferGLDispose #define frameBufferPlatformDispose frameBufferGLDispose
#endif #endif