Fix PSP asset loading: stale EBOOT.PBP packing, unreliable zip file reads
EBOOT.PBP packing was a POST_BUILD step with no dependency on the asset pak, so an assets-only rebuild could silently leave a stale dusk.dsk embedded. cmake/targets/psp.cmake now repacks EBOOT.PBP via a properly tracked custom command depending on the executable, PARAM.SFO, and dusk.dsk (and correctly embeds Dusk.prx rather than the raw ELF when BUILD_PRX is on). Separately, libzip's zip_source_filep_create (lazy seeked FILE* reads) proved unreliable on real PSP hardware, corrupting reads of the embedded PSAR (first EINVAL, then zlib data errors) even though the packaged data was verified byte-perfect. assetInitPBP now reads the whole PSAR into memory once and uses zip_source_buffer_create instead. Confirmed working on real hardware. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+47
-1
@@ -65,6 +65,23 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
)
|
||||
endif()
|
||||
|
||||
# Generate PARAM.SFO as a normal tracked build output (instead of letting
|
||||
# create_pbp_file() auto-generate + delete it) so it can be reused below by
|
||||
# a properly dependency-tracked EBOOT.PBP repack step.
|
||||
set(DUSK_PSP_PARAM_SFO "${DUSK_BUILD_DIR}/PARAM.SFO")
|
||||
add_custom_command(
|
||||
OUTPUT "${DUSK_PSP_PARAM_SFO}"
|
||||
COMMAND "$ENV{PSPDEV}/bin/mksfoex" "-d" "MEMSIZE=1" "-s" "APP_VER=01.00"
|
||||
"${DUSK_BINARY_TARGET_NAME}" "${DUSK_PSP_PARAM_SFO}"
|
||||
COMMENT "Generating PARAM.SFO for ${DUSK_BINARY_TARGET_NAME}"
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(DuskPspParamSfo DEPENDS "${DUSK_PSP_PARAM_SFO}")
|
||||
|
||||
# create_pbp_file()'s own POST_BUILD chain (below) also consumes
|
||||
# DUSK_PSP_PARAM_SFO, so make sure it exists before that chain runs.
|
||||
add_dependencies(${DUSK_BINARY_TARGET_NAME} DuskPspParamSfo)
|
||||
|
||||
# Postbuild, create .pbp file for PSP.
|
||||
create_pbp_file(
|
||||
TARGET "${DUSK_BINARY_TARGET_NAME}"
|
||||
@@ -74,4 +91,33 @@ create_pbp_file(
|
||||
TITLE "${DUSK_BINARY_TARGET_NAME}"
|
||||
PSAR_PATH ${DUSK_ASSETS_ZIP}
|
||||
VERSION 01.00
|
||||
)
|
||||
SFO_PATH "${DUSK_PSP_PARAM_SFO}"
|
||||
OUTPUT_DIR "${DUSK_BUILD_DIR}"
|
||||
)
|
||||
|
||||
# CreatePBP.cmake's pack-pbp step is a POST_BUILD command tied to the
|
||||
# executable target, so it only reruns when the ELF itself relinks. That
|
||||
# means regenerating dusk.dsk (assets) alone, without touching any C
|
||||
# source, silently leaves EBOOT.PBP embedding a stale asset pak. Repack it
|
||||
# here as a normal file-tracked custom command depending on both the
|
||||
# executable and the asset zip, so EBOOT.PBP always reflects the current
|
||||
# assets even when nothing else about the build changed.
|
||||
set(DUSK_PSP_EBOOT "${DUSK_BUILD_DIR}/EBOOT.PBP")
|
||||
if(BUILD_PRX)
|
||||
set(DUSK_PSP_EXECUTABLE "$<TARGET_FILE:${DUSK_BINARY_TARGET_NAME}>.prx")
|
||||
else()
|
||||
set(DUSK_PSP_EXECUTABLE "$<TARGET_FILE:${DUSK_BINARY_TARGET_NAME}>")
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT "${DUSK_PSP_EBOOT}"
|
||||
COMMAND "$ENV{PSPDEV}/bin/pack-pbp" "${DUSK_PSP_EBOOT}" "${DUSK_PSP_PARAM_SFO}"
|
||||
"NULL" "NULL" "NULL" "NULL" "NULL"
|
||||
"${DUSK_PSP_EXECUTABLE}" "${DUSK_ASSETS_ZIP}"
|
||||
DEPENDS
|
||||
"$<TARGET_FILE:${DUSK_BINARY_TARGET_NAME}>"
|
||||
"${DUSK_PSP_PARAM_SFO}"
|
||||
"${DUSK_ASSETS_ZIP}"
|
||||
COMMENT "Repacking EBOOT.PBP (tracks executable + asset pak freshness)"
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(DuskPspEbootRepack ALL DEPENDS "${DUSK_PSP_EBOOT}")
|
||||
Reference in New Issue
Block a user