Renders on PSP again
This commit is contained in:
@@ -10,8 +10,8 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
if(NOT DEFINED DUSK_TARGET_SYSTEM)
|
||||
set(DUSK_TARGET_SYSTEM "linux")
|
||||
# set(DUSK_TARGET_SYSTEM "psp")
|
||||
# set(DUSK_TARGET_SYSTEM "linux")
|
||||
set(DUSK_TARGET_SYSTEM "psp")
|
||||
endif()
|
||||
|
||||
# Prep cache
|
||||
|
@@ -7,4 +7,5 @@ add_asset(PALETTE first.palette.png)
|
||||
add_asset(IMAGE font_minogram.png type=ALPHA)
|
||||
add_asset(IMAGE entities.png type=PALETTIZED)
|
||||
add_asset(CONFIG init.dcf)
|
||||
add_asset(CONFIG init_psp.dcf)
|
||||
# add_asset(TILESET entities.tsx)
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -1,4 +1,5 @@
|
||||
echo " = Dawn Init = ";
|
||||
|
||||
bind ` toggleconsole;
|
||||
bind w up;
|
||||
bind s down;
|
||||
|
17
assets/init_psp.dcf
Normal file
17
assets/init_psp.dcf
Normal file
@@ -0,0 +1,17 @@
|
||||
echo " = Dawn PSP = ";
|
||||
|
||||
bind up up;
|
||||
bind down down;
|
||||
bind left left;
|
||||
bind right right;
|
||||
bind cross accept;
|
||||
bind circle cancel;
|
||||
bind select toggleconsole;
|
||||
bind start toggleconsole;
|
||||
|
||||
bind lstick_negative_y up;
|
||||
bind lstick_positive_y down;
|
||||
bind lstick_negative_x left;
|
||||
bind lstick_positive_x right;
|
||||
|
||||
fps 1;
|
@@ -14,7 +14,7 @@
|
||||
#define CONSOLE_VARIABLES_MAX 128
|
||||
#define CONSOLE_LINE_MAX 256
|
||||
#define CONSOLE_HISTORY_MAX 32
|
||||
#define CONSOLE_EXEC_BUFFER_MAX 16
|
||||
#define CONSOLE_EXEC_BUFFER_MAX 32
|
||||
#define CONSOLE_ALIAS_MAX 32
|
||||
|
||||
#define CONSOLE_VAR_NAME_MAX 32
|
||||
|
@@ -18,8 +18,8 @@ display_t DISPLAY;
|
||||
errorret_t displayInit(void) {
|
||||
#if DISPLAY_SDL2
|
||||
uint32_t flags = SDL_INIT_VIDEO;
|
||||
#if INPUT_SUPPORT_GAMEPAD
|
||||
flags |= SDL_INIT_GAMECONTROLLER;
|
||||
#if INPUT_GAMEPAD == 1
|
||||
flags |= SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK;
|
||||
#endif
|
||||
if(SDL_Init(flags) != 0) {
|
||||
errorThrow("SDL Failed to Initialize: %s", SDL_GetError());
|
||||
|
@@ -63,8 +63,8 @@ void sceneOverworldRenderMap(const map_t *map) {
|
||||
// Draw base layer
|
||||
|
||||
// Draw entities
|
||||
entity_t *start = &map->entities[0];
|
||||
entity_t *end = &map->entities[map->entityCount];
|
||||
const entity_t *start = &map->entities[0];
|
||||
const entity_t *end = &map->entities[map->entityCount];
|
||||
while(start < end) {
|
||||
// Render entity here.
|
||||
sceneOverworldRenderEntity(start);
|
||||
|
@@ -54,7 +54,7 @@ void uiRender(void) {
|
||||
cameraPushMatrix(&UI.camera);
|
||||
|
||||
uiConsoleRender();
|
||||
uiFPSRender();
|
||||
// uiFPSRender();
|
||||
|
||||
spriteBatchFlush();
|
||||
cameraPopMatrix();
|
||||
|
@@ -11,16 +11,17 @@
|
||||
|
||||
void uiConsoleRender(void) {
|
||||
if(!CONSOLE.visible) return;
|
||||
consolePrint("Test\n");
|
||||
|
||||
int32_t i = 0;
|
||||
int32_t i = CONSOLE_HISTORY_MAX - 1;
|
||||
char_t *line;
|
||||
do {
|
||||
line = CONSOLE.line[i];
|
||||
if(line[0] == '\0') {
|
||||
i++;
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
uiTextDraw(0, i * UI_TEXT_TILE_HEIGHT, line, COLOR_WHITE);
|
||||
i++;
|
||||
} while(i < CONSOLE_HISTORY_MAX);
|
||||
i--;
|
||||
} while(i > 0);
|
||||
}
|
@@ -12,16 +12,15 @@
|
||||
#include "util/string.h"
|
||||
|
||||
void uiFPSInit(void) {
|
||||
consoleRegVar("fps", "1", NULL);
|
||||
consoleRegVar("fps", "0", NULL);
|
||||
}
|
||||
|
||||
void uiFPSRender(void) {
|
||||
float_t fps = TIME.delta > 0.0f ? (1.0f / TIME.delta) : 0.0f;
|
||||
|
||||
if(stringCompare(consoleVarGet("fps")->value, "0") == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
float_t fps = TIME.delta > 0.0f ? (1.0f / TIME.delta) : 0.0f;
|
||||
char_t buffer[64];
|
||||
snprintf(
|
||||
buffer,
|
||||
|
@@ -31,7 +31,12 @@ errorret_t engineInit(void) {
|
||||
errorChain(displayInit());
|
||||
rpgInit();
|
||||
|
||||
consoleExec("exec init.dcf");
|
||||
// Init scripts
|
||||
#if PSP
|
||||
consoleExec("exec init_psp.dcf");
|
||||
#else
|
||||
consoleExec("exec init.dcf");
|
||||
#endif
|
||||
|
||||
errorOk();
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ if(DUSK_TARGET_SYSTEM STREQUAL "linux")
|
||||
elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
|
||||
target_compile_definitions(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
INPUT_SDL=1
|
||||
INPUT_SDL2=1
|
||||
INPUT_GAMEPAD=1
|
||||
)
|
||||
endif()
|
@@ -22,16 +22,23 @@ void inputInit(void) {
|
||||
INPUT.actions[i].currentValue = 0.0f;
|
||||
}
|
||||
|
||||
stringCopy(&INPUT_BUTTON_DATA[0].command[0], "echo \"test\";", CONSOLE_LINE_MAX);
|
||||
INPUT_BUTTON_DATA[0].actionType = INPUT_BUTTON_ACTION_TYPE_COMMAND;
|
||||
|
||||
INPUT_BUTTON_DATA[1].actionType = INPUT_BUTTON_ACTION_TYPE_ACTION;
|
||||
INPUT_BUTTON_DATA[1].action = INPUT_ACTION_UP;
|
||||
INPUT.deadzone = 0.1f;
|
||||
}
|
||||
|
||||
void inputUpdate(void) {
|
||||
#if INPUT_SDL2 == 1
|
||||
INPUT.keyboardState = SDL_GetKeyboardState(NULL);
|
||||
#if INPUT_GAMEPAD == 1
|
||||
INPUT.controller = NULL;
|
||||
|
||||
for(int32_t i = 0; i < SDL_NumJoysticks(); i++) {
|
||||
if(!SDL_IsGameController(i)) continue;
|
||||
INPUT.controller = SDL_GameControllerOpen(i);
|
||||
if(INPUT.controller) break;
|
||||
}
|
||||
#endif
|
||||
#if INPUT_KEYBOARD == 1
|
||||
INPUT.keyboardState = SDL_GetKeyboardState(NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Reset all actions
|
||||
|
@@ -12,7 +12,15 @@
|
||||
typedef struct {
|
||||
inputactiondata_t actions[INPUT_ACTION_COUNT];
|
||||
|
||||
#if INPUT_GAMEPAD == 1
|
||||
float_t deadzone;
|
||||
#endif
|
||||
|
||||
#if INPUT_SDL2 == 1
|
||||
#if INPUT_GAMEPAD == 1
|
||||
SDL_GameController *controller;
|
||||
#endif
|
||||
|
||||
#if INPUT_KEYBOARD == 1
|
||||
const uint8_t *keyboardState;
|
||||
#endif
|
||||
|
@@ -14,6 +14,23 @@ inputbuttondata_t INPUT_BUTTON_DATA[] = {
|
||||
#if INPUT_SDL2 == 1
|
||||
#if INPUT_GAMEPAD == 1
|
||||
#if PSP
|
||||
{ .name = "triangle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } },
|
||||
{ .name = "cross", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } },
|
||||
{ .name = "circle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_B } },
|
||||
{ .name = "square", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_X } },
|
||||
{ .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_START } },
|
||||
{ .name = "select", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_BACK } },
|
||||
{ .name = "up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_UP } },
|
||||
{ .name = "down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_DOWN } },
|
||||
{ .name = "left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_LEFT } },
|
||||
{ .name = "right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_RIGHT } },
|
||||
{ .name = "l", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } },
|
||||
{ .name = "r", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } },
|
||||
|
||||
{ .name = "lstick_positive_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = true } } },
|
||||
{ .name = "lstick_negative_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = false } } },
|
||||
{ .name = "lstick_positive_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = true } } },
|
||||
{ .name = "lstick_negative_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = false } } },
|
||||
#else
|
||||
#endif
|
||||
#endif
|
||||
@@ -145,11 +162,12 @@ inputbuttondata_t INPUT_BUTTON_DATA[] = {
|
||||
inputbutton_t inputButtonGetByName(const char_t *name) {
|
||||
assertNotNull(name, "name must not be NULL");
|
||||
|
||||
uint32_t len = sizeof(INPUT_BUTTON_DATA) / sizeof(inputbuttondata_t);
|
||||
|
||||
for(uint32_t i = 0; i < len; i++) {
|
||||
if(stringCompareInsensitive(INPUT_BUTTON_DATA[i].name, name) != 0) continue;
|
||||
return INPUT_BUTTON_DATA[i].button;
|
||||
inputbuttondata_t *data = INPUT_BUTTON_DATA;
|
||||
while(data->name != NULL) {
|
||||
if(stringCompareInsensitive(data->name, name) == 0) {
|
||||
return data->button;
|
||||
}
|
||||
data++;
|
||||
}
|
||||
|
||||
return (inputbutton_t){ .type = INPUT_BUTTON_TYPE_NONE };
|
||||
@@ -170,12 +188,23 @@ float_t inputButtonGetValue(const inputbutton_t button) {
|
||||
#if INPUT_GAMEPAD == 1
|
||||
case INPUT_BUTTON_TYPE_GAMEPAD: {
|
||||
#if INPUT_SDL2 == 1
|
||||
if(SDL_GameControllerGetButton(
|
||||
SDL_GameControllerFromInstanceID(0), button.gpButton
|
||||
)) return 1.0f;
|
||||
if(SDL_GameControllerGetButton(INPUT.controller, button.gpButton)) {
|
||||
return 1.0f;
|
||||
}
|
||||
#endif
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
case INPUT_BUTTON_TYPE_GAMEPAD_AXIS: {
|
||||
#if INPUT_SDL2 == 1
|
||||
Sint16 axis = SDL_GameControllerGetAxis(INPUT.controller, button.gpAxis.axis);
|
||||
if(!button.gpAxis.positive) axis = -axis;
|
||||
float_t value = (float_t)axis / 32767.0f;
|
||||
// Deadzone
|
||||
if(value < INPUT.deadzone) return 0.0f;
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
default: {
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#if INPUT_GAMEPAD == 1
|
||||
#if INPUT_SDL2 == 1
|
||||
typedef SDL_GameControllerButton inputgamepadbutton_t;
|
||||
typedef SDL_GameControllerAxis inputgamepadaxis_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -37,6 +38,7 @@ typedef enum {
|
||||
#endif
|
||||
#if INPUT_GAMEPAD == 1
|
||||
INPUT_BUTTON_TYPE_GAMEPAD,
|
||||
INPUT_BUTTON_TYPE_GAMEPAD_AXIS,
|
||||
#endif
|
||||
|
||||
INPUT_BUTTON_TYPE_COUNT
|
||||
@@ -48,6 +50,10 @@ typedef struct {
|
||||
union {
|
||||
#if INPUT_GAMEPAD == 1
|
||||
inputgamepadbutton_t gpButton;
|
||||
struct {
|
||||
inputgamepadaxis_t axis;
|
||||
bool_t positive;
|
||||
} gpAxis;
|
||||
#endif
|
||||
|
||||
#if INPUT_KEYBOARD == 1
|
||||
|
Reference in New Issue
Block a user