From 88adb6ddfb117c00f9ca6c248f6cf6046c276b68 Mon Sep 17 00:00:00 2001 From: vichoca9 Date: Thu, 15 Aug 2024 17:03:38 -0400 Subject: [PATCH 1/7] Add PSP changes --- Readme.PSP | 41 +++++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 29 ++++++++++++++++++++++++++++- src/data.h | 10 ++++++++++ src/iconPSP.png | Bin 0 -> 23301 bytes src/main.c | 6 ++++++ src/options.c | 2 ++ src/seg006.c | 7 +++++++ src/seg009.c | 13 +++++++------ src/types.h | 4 ++++ 9 files changed, 105 insertions(+), 7 deletions(-) create mode 100644 Readme.PSP create mode 100644 src/iconPSP.png diff --git a/Readme.PSP b/Readme.PSP new file mode 100644 index 00000000..798c776e --- /dev/null +++ b/Readme.PSP @@ -0,0 +1,41 @@ +# How to compile and run +Install latest PSPDEV toolchain, then go to src and run these commands: + +``` +mkdir build +cd build +psp-cmake .. +make +``` + +Then move the `EBOOT.PBP` file into a dir with the data/ files (WITH MUSIC!), +then finally load it into your PSP. + +## How to debug +Clean your dirs and run `psp-cmake .. -DBUILD_PRX=1` instead, then use +the debugging guide at PSPDEV's site. + +The process is like this: + +- Start `usbhostfs_pc` in a terminal at the prince.prx dir +- Start PSPLINK in your PSP, connected with a usb cable. +- Run `pspsh` in another terminal at the same prev. dir +- Run the command `debug ./prince.prx` inside pspsh +- In yet another terminal, run `psp-gdb ./prince -q`, then `target remote :10001` +- Start debugging as usual. + +You can skip the psp-gdb step, since PSPLINK lets you run the prx as is and +catch the exceptions and set breakpoints too. + +## Changes +- INI loading was disabled due to a bug that crashed the psp. Sane defaults were + provided instead. +- PSP has to run at full speed (333mhz) in order for the game to work. +- "iconPSP.png" was provided. +- Music was replaced for ogg ones (use the smaller ones!), + so make sure to grab them into data/music (see README.md) + +## Credits +- SDLPoP and others (Github) +- PSPDEV and others (toolchain) +- striga (fixing compilation for PSP) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df56218e..531c76ab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 2.8) project(SDLPoP) +find_package(SDL2 REQUIRED) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration") @@ -120,5 +121,31 @@ if(WIN32) elseif(APPLE) target_link_libraries(prince SDL2main SDL2 SDL2_image m) else() # Linux, *BSD, etc. - target_link_libraries(prince SDL2 SDL2_image m) + if(PSP) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") + target_include_directories(prince PRIVATE ${SDL2_INCLUDE_DIRS} ${PSPDEV}/psp/include) + target_link_libraries(prince PRIVATE + ${SDL2_LIBRARIES} + z + jpeg + SDL2main + SDL2 + SDL2_image + vorbis + vorbisfile + ogg + modplug + png + m + ) + create_pbp_file( + TARGET prince + ICON_PATH ${CMAKE_SOURCE_DIR}/iconPSP.png + BACKGROUND_PATH NULL + PREVIEW_PATH NULL + TITLE prince + ) + else() + target_link_libraries(prince SDL2 SDL2_image m) + endif() endif() diff --git a/src/data.h b/src/data.h index 6d398e25..a987a39a 100644 --- a/src/data.h +++ b/src/data.h @@ -710,9 +710,15 @@ extern byte is_validate_mode; extern dword curr_tick INIT(= 0); #endif // USE_REPLAY +#ifdef __PSP__ +extern byte start_fullscreen INIT(= 1); +extern word pop_window_width INIT(= 480); +extern word pop_window_height INIT(= 272); +#else extern byte start_fullscreen INIT(= 0); extern word pop_window_width INIT(= 640); extern word pop_window_height INIT(= 400); +#endif extern byte use_custom_levelset INIT(= 0); extern char levelset_name[POP_MAX_PATH]; extern char mod_data_path[POP_MAX_PATH]; @@ -733,7 +739,11 @@ extern char gamecontrollerdb_file[POP_MAX_PATH] INIT(= ""); extern byte enable_quicksave INIT(= 1); extern byte enable_quicksave_penalty INIT(= 1); extern byte enable_replay INIT(= 1); +#ifdef __PSP__ +extern byte use_hardware_acceleration INIT(= 1); +#else extern byte use_hardware_acceleration INIT(= 2); +#endif extern byte use_correct_aspect_ratio INIT(= 0); extern byte use_integer_scaling INIT(= 0); extern byte scaling_type INIT(= 0); diff --git a/src/iconPSP.png b/src/iconPSP.png new file mode 100644 index 0000000000000000000000000000000000000000..204e9f7483b4518f46e4f4801feaae55d9413b95 GIT binary patch literal 23301 zcmeI(ziVA}7{~FGrfJjsXf?J=Cdtr22s%3$Eh#l%LMYu_6dXE45J7M(-5i8Mp?`tU z%`Ba|2`)~8Lnc!k{2PQ$_2k0$b?)hNIQh2R+;7vIFV?)z_j$h0=X0O?B)#|C^rzjO zTgwZp3sqGuZ+*UbyZ-v1{x-_n|3g*(x4pf6cz9UH zYp5@4zWqV<_r1NfwYB=-FSkB=w*T|T-~Vw?Rqt0@o1fjeJ2$htzW-MpJATcibuO*h zw9bc>BC{#?Tsl2-yi#U{iZrMOKj(!cJDw?be42_hs1Alk?JL}&xwI~%wKSoX>Rm_* zbH|TMogv%#3He!4ki=l9-P=>%A1!wCqH<{3>fcEutO6B$oVKq?-IJ+llZh zel90J^F#+j?FOFC4*8zEl9thlkW#L+ANes??}T+Jt&SNQ3>~#AHR#gNq0w}O5$fuY z*E)XI8DWzfK~B#YNBMWdBFaXE#E3;7cH|6(^rQ`EsYBk`c+fyoR?@N~2N))^945Hg zcrPu3%SMHi2IP~U6+3dkU})5(Gua{U(#@B#(2odmj1FiyYF5i8qaqj{q!7NK3Xb;Sp0h1(agvYo-u zs8#wA;SKIkyn`0)$N8}1J_HalKXzheJ8X2^(vt*Kj2bIXf4}}={Tl~g9{nx=Qwe$w zDjs2S=8_Lz2ScN$P#ZJ`2*u|*K2vs@r_B9*pL<9GJsNy~o@509Q8pS7lMQ+__y9f0 z3Id{y4LSOg8Az-~;p|D+q`-K9HDf(4)Zz=t))(5M`qQ9~Sp~ zLhTy|kOx8$_#i>F@qxr-J0DBi;R6UoP>=*sHX0CibNOn9+EGJ1t8dQUyMIp(K=V)c+s7QnAU})6AX?Ez@gFpBF`}dnC zRkgnO_1^B?A7^H&^%q&ca=nq(qqGjvdLCAa9HiVw>GVd{)MO+nNP=jv^IS->;~7#} zDGHJxI{2wOShhc_X+2D<>)$QB&R(kbFe$9&jEiK)Uq`#^jDjQvKjVEm)&23DK2B@= zp-q;P!egRwkc1>p*28!;5<~|-r@cSE8OI;UNi)$nKSC$%VZ1)k!OwVG@SEQsuWfiP z0&IXHHi)tTgo*$gpok5kYyhDmz=pRlMQjjd0|*rXHb4;@MA-mBMSu-Z#0F6|yb~8H z0&IXHHi)tTgo*$gpok5kYyhDmz=j)2MQjjd0|*rXHb4;@MA-mBMSu-Z#0F6|fKU-& z0~E1Alno$M1lRyYY!GDw2o(V~{GcvkgD4w7s0gqDir65^1`sL&Y=9y*h_c~@v``UX z0~E1Alno$M1lRyYY!GDw2o(V~+~_D`gD4w7s0gqDir65^1`sL&Y=9y*h_c~>1GmcM zOaX|p0feStg9K4FfRN-V08uu8&=hQtAj$?1k~{?<$_DUJuMdAu&JPKqYyct2gCEVQ zVdzgi7@9ENnU`3O;h)qXDM;ca>CQ{Zjt_pu8#VN2yc;>}#fewl-cGtt0)!+xo}-nM zqaX>QYyct2j^}9QuaXvg0{gIXMcFAj$?1lI(bnR!)wBB#5#Bgd{tjqxH|u W#`XL6KK=G6ckAZP=C3!ty8l0VV^-q; literal 0 HcmV?d00001 diff --git a/src/main.c b/src/main.c index a32ee963..1ec2448f 100644 --- a/src/main.c +++ b/src/main.c @@ -26,9 +26,15 @@ static const char version[] = "\0$VER: SDLPoP " SDLPOP_VERSION " (" __AMIGADATE_ static const char stack[] = "$STACK:200000"; #endif +#ifdef __PSP__ +#include +#endif int main(int argc, char *argv[]) { + #ifdef __PSP__ + scePowerSetClockFrequency(333,333,166); + #endif g_argc = argc; g_argv = argv; pop_main(); diff --git a/src/options.c b/src/options.c index cb7c5271..11d78dcb 100644 --- a/src/options.c +++ b/src/options.c @@ -498,7 +498,9 @@ void set_options_to_default() { void load_global_options() { set_options_to_default(); + #ifndef __PSP__ //FIXME: ini_process_word crashes at "first_level" ini_load(locate_file("SDLPoP.ini"), global_ini_callback); // global configuration + #endif load_dos_exe_modifications("."); // read PRINCE.EXE in the current working directory } diff --git a/src/seg006.c b/src/seg006.c index af6ca1e8..7c1cdb50 100644 --- a/src/seg006.c +++ b/src/seg006.c @@ -591,7 +591,14 @@ void play_seq() { } // fallthrough! case SEQ_JMP: // jump + #ifdef __PSP__ + word command1 = (word)*(SEQTBL_0 + Char.curr_seq); + word command2 = (word)*(SEQTBL_0 + Char.curr_seq+1); + //for some reason, this works, but normal pointer cast crashes (?) + Char.curr_seq = SDL_SwapLE16(command1 | (command2<<8)); + #else Char.curr_seq = SDL_SwapLE16(*(const word*)(SEQTBL_0 + Char.curr_seq)); + #endif break; case SEQ_UP: // up --Char.curr_row; diff --git a/src/seg009.c b/src/seg009.c index eb89a228..490269fd 100644 --- a/src/seg009.c +++ b/src/seg009.c @@ -3371,14 +3371,14 @@ image_type* method_6_blit_img_to_scr(image_type* image,int xpos,int ypos,int bli } #ifndef USE_COMPAT_TIMER -int fps = 60; -float milliseconds_per_tick = (1000.0f / 60.0f); +int fps = BASE_FPS; +float milliseconds_per_tick = (1000.0f / (BASE_FPS*1.0f)); Uint64 timer_last_counter[NUM_TIMERS]; #endif int wait_time[NUM_TIMERS]; -#ifdef USE_COMPAT_TIMER +//#if defined(USE_COMPAT_TIMER) || defined(__PSP__) Uint32 timer_callback(Uint32 interval, void *param) { SDL_Event event; memset(&event, 0, sizeof(event)); @@ -3388,7 +3388,7 @@ Uint32 timer_callback(Uint32 interval, void *param) { SDL_PushEvent(&event); return interval; } -#endif +//#endif void reset_timer(int timer_index) { #ifndef USE_COMPAT_TIMER @@ -3845,7 +3845,7 @@ int do_wait(int timer_index) { } #ifdef USE_COMPAT_TIMER -SDL_TimerID global_timer = NULL; +SDL_TimerID global_timer = 0; #endif // seg009:78E9 void init_timer(int frequency) { @@ -3856,12 +3856,12 @@ void init_timer(int frequency) { perf_counters_per_tick = perf_frequency / fps; milliseconds_per_counter = 1000.0f / perf_frequency; #else + global_timer = SDL_AddTimer(1000/frequency, timer_callback, NULL); if (global_timer != 0) { if (!SDL_RemoveTimer(global_timer)) { sdlperror("init_timer: SDL_RemoveTimer"); } } - global_timer = SDL_AddTimer(1000/frequency, timer_callback, NULL); if (global_timer == 0) { sdlperror("init_timer: SDL_AddTimer"); quit(1); @@ -4251,6 +4251,7 @@ int has_timer_stopped(int timer_index) { #ifdef USE_REPLAY if ((replaying && skipping_replay) || is_validate_mode) return true; #endif + //PSP: overshoot always too big, 333mhz mandatory to read input! Uint64 current_counter = SDL_GetPerformanceCounter(); int ticks_elapsed = (int)((current_counter / perf_counters_per_tick) - (timer_last_counter[timer_index] / perf_counters_per_tick)); int overshoot = ticks_elapsed - wait_time[timer_index]; diff --git a/src/types.h b/src/types.h index 210407b5..568719f7 100644 --- a/src/types.h +++ b/src/types.h @@ -1349,7 +1349,11 @@ typedef struct custom_options_type { typedef struct directory_listing_type directory_listing_type; +#ifdef __PSP__ //for testing, PSP only reads input at 333mhz with 60 FPS #define BASE_FPS 60 +#else +#define BASE_FPS 60 +#endif #define FEATHER_FALL_LENGTH 18.75 From 3a4e9294ed6ca9d01d99a0fff90009657fe7f3b3 Mon Sep 17 00:00:00 2001 From: vichoca9 Date: Thu, 15 Aug 2024 17:20:07 -0400 Subject: [PATCH 2/7] Final changes, cleanup and PR --- src/iconPSP.png | Bin 23301 -> 23301 bytes src/seg009.c | 4 +++- src/types.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/iconPSP.png b/src/iconPSP.png index 204e9f7483b4518f46e4f4801feaae55d9413b95..c52bc8e1a9837307ca78368f30eee287e159d13e 100644 GIT binary patch literal 23301 zcmeI)&uU#&6bA5<*0gDww6(UAj!K3?rDF#cOG^xx5=y~=6P=`33VDJ` z9hqlv=twLW5RCW$zCcIy=xxE{kc5kft&RXAE-#Lrf3}uR_W%Fovz7PyFE_V7ym!0*`fS?S`J(Ip+uYp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go*$gpok5kYyhDmz=pRlMQjjd0|*rXHb4;@MA-mBMSu-Z#0F6|yb~8H z0&IXHHi)tTgo*$gpok5kYyhDmz=j)2MQjjd0|*rXHb4;@MA-mBMSu-Z#0F6|fKU-& z0~E1Alno$M1lRyYY!GDw2o(V~{GcvkgD4w7s0gqDir65^1`sL&Y=9y*h_c~@v``UX z0~E1Alno$M1lRyYY!GDw2o(V~+~_D`gD4w7s0gqDir65^1`sL&Y=9y*h_c~>1GmcM zOaX|p0feStg9K4FfRN-V08uu8&=hQtAj$?1k~{?<$_DUJuMdAu&JPKqYyct2gCEVQ zVdzgi7@9ENnU`3O;h)qXDM;ca>CQ{Zjt_pu8#VN2yc;>}#fewl-cGtt0)!+xo}-nM zqaX>QYyct2j^}9QuaXvg0{gIXMcFAj$?1lI(bnR!)wBB#5#Bgd{tjqxH|u W#`XL6KK=G6ckAZP=C3!ty8l0VV^-q; diff --git a/src/seg009.c b/src/seg009.c index 490269fd..a8ee4022 100644 --- a/src/seg009.c +++ b/src/seg009.c @@ -2389,7 +2389,9 @@ sound_buffer_type* convert_digi_sound(sound_buffer_type* digi_buffer) { converted_buffer->converted.length = expanded_length; byte* source = waveinfo.samples; - short* dest = converted_buffer->converted.samples; + //short* dest = converted_buffer->converted.samples; + short* dest = malloc(sizeof(short) * converted_buffer->converted.length); + converted_buffer->converted.samples = dest; for (int i = 0; i < expanded_frames; ++i) { float src_frame_float = i * freq_ratio; diff --git a/src/types.h b/src/types.h index 568719f7..40b85f0a 100644 --- a/src/types.h +++ b/src/types.h @@ -570,7 +570,7 @@ typedef struct ogg_type { typedef struct converted_audio_type { int length; - short samples[]; + short * samples; //FIXME: crash in PSP when using flexible arrays (??) } converted_audio_type; typedef struct sound_buffer_type { From 4dcaf612e88887f5c6a21bdb9fa61edf3c8510bf Mon Sep 17 00:00:00 2001 From: striga Date: Sun, 18 Aug 2024 14:43:50 -0400 Subject: [PATCH 3/7] Update src/CMakeLists.txt Use pkg_search and findpkgconfig Co-authored-by: Wouter Wijsman --- src/CMakeLists.txt | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 531c76ab..99138b06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -123,21 +123,14 @@ elseif(APPLE) else() # Linux, *BSD, etc. if(PSP) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") - target_include_directories(prince PRIVATE ${SDL2_INCLUDE_DIRS} ${PSPDEV}/psp/include) - target_link_libraries(prince PRIVATE - ${SDL2_LIBRARIES} - z - jpeg - SDL2main - SDL2 - SDL2_image - vorbis - vorbisfile - ogg - modplug - png - m - ) +include(FindPkgConfig) +pkg_search_module(SDL2 REQUIRED sdl2) + +target_include_directories(target PRIVATE ${SDL2_INCLUDE_DIRS}) + +target_link_libraries(target PRIVATE + ${SDL2_LIBRARIES} +) create_pbp_file( TARGET prince ICON_PATH ${CMAKE_SOURCE_DIR}/iconPSP.png From df4c0e22bc71c09445e489f38f0d63296d471106 Mon Sep 17 00:00:00 2001 From: vichoca9 Date: Sun, 18 Aug 2024 15:00:57 -0400 Subject: [PATCH 4/7] clean up CMakeLists --- src/CMakeLists.txt | 35 ++++++++++++++++------------------- src/seg009.c | 4 ++-- src/types.h | 4 ---- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 99138b06..400b0a2b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,25 +120,22 @@ if(WIN32) target_link_libraries(prince mingw32 SDL2main SDL2 SDL2_image) elseif(APPLE) target_link_libraries(prince SDL2main SDL2 SDL2_image m) -else() # Linux, *BSD, etc. - if(PSP) +elseif(PSP) # Linux, *BSD, etc. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") -include(FindPkgConfig) -pkg_search_module(SDL2 REQUIRED sdl2) - -target_include_directories(target PRIVATE ${SDL2_INCLUDE_DIRS}) - -target_link_libraries(target PRIVATE - ${SDL2_LIBRARIES} -) - create_pbp_file( - TARGET prince - ICON_PATH ${CMAKE_SOURCE_DIR}/iconPSP.png - BACKGROUND_PATH NULL - PREVIEW_PATH NULL - TITLE prince - ) - else() + include(FindPkgConfig) + pkg_search_module(SDL2 REQUIRED sdl2) + pkg_search_module(SDL2IMAGE REQUIRED SDL2_image) + target_include_directories(prince PRIVATE ${SDL2_INCLUDE_DIRS}) + target_link_libraries(prince PRIVATE + ${SDL2_LIBRARIES} ${SDL2IMAGE_LIBRARIES} + ) + create_pbp_file( + TARGET prince + ICON_PATH ${CMAKE_SOURCE_DIR}/iconPSP.png + BACKGROUND_PATH NULL + PREVIEW_PATH NULL + TITLE prince + ) +else() target_link_libraries(prince SDL2 SDL2_image m) - endif() endif() diff --git a/src/seg009.c b/src/seg009.c index a8ee4022..d5bcda9e 100644 --- a/src/seg009.c +++ b/src/seg009.c @@ -3380,7 +3380,7 @@ Uint64 timer_last_counter[NUM_TIMERS]; int wait_time[NUM_TIMERS]; -//#if defined(USE_COMPAT_TIMER) || defined(__PSP__) +#ifdef USE_COMPAT_TIMER Uint32 timer_callback(Uint32 interval, void *param) { SDL_Event event; memset(&event, 0, sizeof(event)); @@ -3390,7 +3390,7 @@ Uint32 timer_callback(Uint32 interval, void *param) { SDL_PushEvent(&event); return interval; } -//#endif +#endif void reset_timer(int timer_index) { #ifndef USE_COMPAT_TIMER diff --git a/src/types.h b/src/types.h index 40b85f0a..cd2c5a03 100644 --- a/src/types.h +++ b/src/types.h @@ -1349,11 +1349,7 @@ typedef struct custom_options_type { typedef struct directory_listing_type directory_listing_type; -#ifdef __PSP__ //for testing, PSP only reads input at 333mhz with 60 FPS #define BASE_FPS 60 -#else -#define BASE_FPS 60 -#endif #define FEATHER_FALL_LENGTH 18.75 From cfee2100e916d525b998884fb8a0b2695545f1cb Mon Sep 17 00:00:00 2001 From: vichoca9 Date: Sun, 18 Aug 2024 15:02:37 -0400 Subject: [PATCH 5/7] Readme.PSP credits --- Readme.PSP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.PSP b/Readme.PSP index 798c776e..b9175238 100644 --- a/Readme.PSP +++ b/Readme.PSP @@ -38,4 +38,4 @@ catch the exceptions and set breakpoints too. ## Credits - SDLPoP and others (Github) - PSPDEV and others (toolchain) -- striga (fixing compilation for PSP) +- striga, sharkwouter (fixing compilation for PSP) From 3ed4520e4a91a0a58fb51fa3f0f2b8d92e255b29 Mon Sep 17 00:00:00 2001 From: striga Date: Sun, 18 Aug 2024 15:08:51 -0400 Subject: [PATCH 6/7] Update src/CMakeLists.txt Co-authored-by: Wouter Wijsman --- src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 400b0a2b..5bae7465 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 2.8) project(SDLPoP) -find_package(SDL2 REQUIRED) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration") From 8bdb1b0185036ae0b30a4ff9be78d4d9a235a681 Mon Sep 17 00:00:00 2001 From: vichoca9 Date: Sun, 18 Aug 2024 16:22:24 -0400 Subject: [PATCH 7/7] Fix INI and auto_moves on PSP (misaligned data) --- Readme.PSP | 2 +- src/options.c | 2 -- src/types.h | 5 +++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Readme.PSP b/Readme.PSP index b9175238..b9a5ad3a 100644 --- a/Readme.PSP +++ b/Readme.PSP @@ -29,7 +29,7 @@ catch the exceptions and set breakpoints too. ## Changes - INI loading was disabled due to a bug that crashed the psp. Sane defaults were - provided instead. + provided instead (FIXED). - PSP has to run at full speed (333mhz) in order for the game to work. - "iconPSP.png" was provided. - Music was replaced for ogg ones (use the smaller ones!), diff --git a/src/options.c b/src/options.c index 11d78dcb..cb7c5271 100644 --- a/src/options.c +++ b/src/options.c @@ -498,9 +498,7 @@ void set_options_to_default() { void load_global_options() { set_options_to_default(); - #ifndef __PSP__ //FIXME: ini_process_word crashes at "first_level" ini_load(locate_file("SDLPoP.ini"), global_ini_callback); // global configuration - #endif load_dos_exe_modifications("."); // read PRINCE.EXE in the current working directory } diff --git a/src/types.h b/src/types.h index cd2c5a03..35e47790 100644 --- a/src/types.h +++ b/src/types.h @@ -1185,7 +1185,10 @@ names_list_type listname##_list = {.type=0, .names = {&listname, COUNT(listname) #define KEY_VALUE_LIST(listname, ...) const key_value_type listname[] = __VA_ARGS__; \ names_list_type listname##_list = {.type=1, .kv_pairs= {(key_value_type*)&listname, COUNT(listname)}} +//misaligned data == CRASH!! on PSP +#ifndef __PSP__ #pragma pack(push,1) +#endif typedef struct fixes_options_type { byte enable_crouch_after_climbing; byte enable_freeze_time_during_end_music; @@ -1345,7 +1348,9 @@ typedef struct custom_options_type { byte chomper_speed; } custom_options_type; +#ifndef __PSP__ #pragma pack(pop) +#endif typedef struct directory_listing_type directory_listing_type;