-
Notifications
You must be signed in to change notification settings - Fork 801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PSP port #1918
PSP port #1918
Conversation
… that was already added by the psp.cmake
Source/utils/file_util.cpp
Outdated
@@ -111,6 +111,8 @@ bool ResizeFile(const char *path, std::uintmax_t size) | |||
} | |||
::CloseHandle(file); | |||
return true; | |||
#elif defined(__PSP__) | |||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some form of ResizeFile
is unfortunately required for save games to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it would obviously require more code, the PSP has its own save data utility accessible to all games. It is fairly trivial to implement, you can either call the SceUtility functions when saving the game or implement the save data dialog and let players choose files so they can scroll through the fancy icons ;)
https://github.com/pspdev/pspsdk/blob/master/src/samples/savedata/utility/main.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PSP libc is supposed to already support ftruncate
, not sure what's up with it missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the problem on pspdev/psptoolchain#108. C++ for some reason doesn't have the functions C does.
CMake/psp_defs.cmake
Outdated
# keeping the 3DS defaults for now | ||
# Streaming audio is broken on the 3DS as of 25 Mar 2021: | ||
# https://github.com/devkitPro/SDL/issues/72 | ||
set(DISABLE_STREAMING_MUSIC ON) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer needed, it was due to a bug that has since been resolved.
PSP does not have enough RAM to run non-streaming audio
//----------------------------------------------------------------------------- | ||
// Defines for PSP platform | ||
|
||
#if !defined(STORMLIB_PLATFORM_DEFINED) && defined(__PSP__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? These look like the defaults for an unknown platform
@@ -201,7 +201,6 @@ LCID WINAPI SFileSetLocale(LCID lcNewLocale) | |||
// dwPriority - When SFileOpenFileEx called, this contains the search priority for searched archives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this file look like formatting-only changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of those were leftovers from when I was debugging. I'll remove them.
Source/init.cpp
Outdated
HANDLE fh = nullptr; | ||
if (!SFileOpenFile("ui_art\\title.pcx", &fh)) | ||
if (!SFileOpenFile("ui_art\\title.pcx", &fh)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the formatting-only changes
Source/miniwin/misc_msg.cpp
Outdated
@@ -723,4 +723,26 @@ bool PostMessage(uint32_t type, int32_t wParam, int32_t lParam) | |||
return true; | |||
} | |||
|
|||
#ifdef __PSP__ | |||
int snprintf(char *s, size_t n, const char *format, ...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be best to fix this in the PSP libc instead
Source/utils/sdl2_to_1_2_backports.h
Outdated
@@ -22,6 +22,11 @@ | |||
|
|||
#define SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) | |||
|
|||
#ifdef __PSP__ | |||
// PSP has the wrong definition on SDL_config.h, so we use ours | |||
#define SDL_snprintf devilution::snprintf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be best to fix this in the PSP SDL instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its in draft mode so i think some hacks are expected for now :)
…sabling them), setting surfaces to 8 bits, and setting controls.
…; Setting to use larger memory block (PSP2000+); Fix A/B buttons being swapped; Force skip intro;
… adding more common compilation flags to psp build
@AJenbo @glebm still haven't gotten any more progress than being able to run on PPSSPP. On real hardware it crashes on We still have the issues @glebm linked on PSPSDK end (pspdev/newlib#1 and pspdev/newlib#2). For now I redirected snprintf to sprintf and vsnprintf to vsprintf without major issues, but even copying the whole code for those 2 methods didn't change anything. Also tried to use the PSPSDK sceIo* methods on Stormlib, but unfortunately sceIoRead is not returning the correct bytes read (and probably reading more than it should). I'm adding a list of things missing from this port as a checklist on the original PR comment to keep track. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
321
#ifdef __PSP__ | ||
#include "miniwin/miniwin.h" | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's needed for the SDL_snprintf redirect to work. SDL_snprintf calls snprintf, and we redirect snprintf to sprintf for now.
|
||
#if defined(__3DS__) | ||
retval = SDL_strdup("sdmc:/3ds/devilutionx/"); | ||
return retval; | ||
#endif | ||
#if defined(__PSP__) | ||
{ | ||
// replacement for strdup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully the newlib 3 branch has strdup
and other missing functions
@stefanmielke both StormLib, snprintf, and vsnprintf have been removed as dependencies so this should probably workout much better if rebased :) |
Things are now in a much better state so I did a fresh draft for this :) I have tested the game in the PPSSPP emulator but it still need to be test it on hardware. |
Draft PR for PSP support.
Got so far as to build and create the EBOOT. But it generates a corrupted file that can't be executed (crashes on real PSP, works fine on PPSSPP).
Also tested Linux build to see if any changes would affect it. Would be nice to review those, as I had to remove "std::to_string" support for it to build.