PSP2: Add support for vitasdk
Jeffrey Pfau jeffrey@endrift.com
Fri, 28 Aug 2015 19:44:12 -0700
6 files changed,
51 insertions(+),
14 deletions(-)
M
CMakeLists.txt
→
CMakeLists.txt
@@ -496,7 +496,7 @@ add_subdirectory(${CMAKE_SOURCE_DIR}/src/platform/wii ${CMAKE_BINARY_DIR})
endif() if(PSP2) - add_subdirectory(${CMAKE_SOURCE_DIR}/src/platform/psp2 ${CMAKE_BINARY_DIR}/psp2) + add_subdirectory(${CMAKE_SOURCE_DIR}/src/platform/psp2 ${CMAKE_BINARY_DIR}) endif() if(3DS)
M
src/gba/hardware.c
→
src/gba/hardware.c
@@ -277,7 +277,7 @@ } else {
t = time(0); } struct tm date; -#if defined(_WIN32) || defined(PSP2) +#ifdef _WIN32 localtime_s(&date, &t); #else localtime_r(&t, &date);
M
src/platform/psp2/CMakeLists.txt
→
src/platform/psp2/CMakeLists.txt
@@ -1,11 +1,10 @@
file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/psp2/*.c) -include_directories(${CMAKE_BINARY_DIR}) -execute_process(COMMAND ${RAW2C} ${CMAKE_SOURCE_DIR}/res/font.png) +execute_process(COMMAND ${OBJCOPY} -I binary -O elf32-littlearm -B arm font.png ${CMAKE_BINARY_DIR}/font.o WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/res) -set(PLATFORM_LIBRARY -lvita2d -lSceCtrl_stub -lSceRtc_stub -lSceGxm_stub -lSceDisplay_stub -lSceAudio_stub -lpng -lz -lm_stub) +set(PLATFORM_LIBRARY -lvita2d -lSceCtrl_stub -lSceRtc_stub -lSceGxm_stub -lSceDisplay_stub -lSceAudio_stub -lpng -lz -lm) -add_executable(${BINARY_NAME}.elf ${PLATFORM_SRC} ${GUI_SRC} ${CMAKE_BINARY_DIR}/font.c) +add_executable(${BINARY_NAME}.elf ${PLATFORM_SRC} ${GUI_SRC} ${CMAKE_BINARY_DIR}/font.o) target_link_libraries(${BINARY_NAME}.elf ${BINARY_NAME} ${PLATFORM_LIBRARY}) set_target_properties(${BINARY_NAME}.elf PROPERTIES OUTPUT_NAME ${BINARY_NAME}.elf) -add_custom_command(TARGET ${BINARY_NAME}.elf POST_BUILD COMMAND ${FIXUP} -q -S ${BINARY_NAME}.elf ${BINARY_NAME}.velf MAIN_DEPENDENCY ${BINARY_NAME}.elf) +add_custom_command(TARGET ${BINARY_NAME}.elf POST_BUILD COMMAND ${FIXUP} ${BINARY_NAME}.elf ${BINARY_NAME}.velf ${NIDDB} MAIN_DEPENDENCY ${BINARY_NAME}.elf)
M
src/platform/psp2/CMakeToolchain.txt
→
src/platform/psp2/CMakeToolchain.psp2sdk
@@ -44,8 +44,8 @@ set(CMAKE_SHARED_LINKER_FLAGS ${link_flags} CACHE INTERNAL "shared link flags")
set(PKG_CONFIG_EXECUTABLE "/dev/null" CACHE INTERNAL "" FORCE) -set(FIXUP ${toolchain_bin_dir}/psp2-fixup) -set(RAW2C ${DEVKITARM}/bin/raw2c) +set(FIXUP ${toolchain_bin_dir}/psp2-fixup -q -S) +set(OBJCOPY ${cross_prefix}objcopy) set(PSP2 ON) add_definitions(-DPSP2)
A
src/platform/psp2/CMakeToolchain.vitasdk
@@ -0,0 +1,37 @@
+if(DEFINED ENV{VITASDK}) + set(VITASDK $ENV{VITASDK}) +else() + message(FATAL_ERROR "Could not find VITASDK in environment") +endif() + +set(toolchain_dir ${VITASDK}) +set(toolchain_bin_dir ${toolchain_dir}/bin) +set(cross_prefix ${toolchain_bin_dir}/arm-vita-eabi-) +set(inc_flags -I${toolchain_dir}/include) +set(link_flags "-L${toolchain_dir}/lib -Wl,-q") + +set(CMAKE_SYSTEM_NAME Generic CACHE INTERNAL "system name") +set(CMAKE_SYSTEM_PROCESSOR arm CACHE INTERNAL "processor") +set(CMAKE_LIBRARY_ARCHITECTURE arm-none-eabi CACHE INTERNAL "abi") +set(CMAKE_AR ${cross_prefix}ar CACHE INTERNAL "archiver") +set(CMAKE_C_COMPILER ${cross_prefix}gcc CACHE INTERNAL "c compiler") +set(CMAKE_CXX_COMPILER ${cross_prefix}g++ CACHE INTERNAL "cxx compiler") +set(CMAKE_ASM_COMPILER ${cross_prefix}gcc CACHE INTERNAL "assembler") +set(common_flags "${inc_flags}") +set(CMAKE_C_FLAGS ${common_flags} CACHE INTERNAL "c compiler flags") +set(CMAKE_ASM_FLAGS ${common_flags} CACHE INTERNAL "c compiler flags") +set(CMAKE_CXX_FLAGS ${common_flags} CACHE INTERNAL "cxx compiler flags") +set(CMAKE_LINKER ${cross_prefix}ld CACHE INTERNAL "linker") + +set(CMAKE_EXE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "exe link flags") +set(CMAKE_MODULE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "module link flags") +set(CMAKE_SHARED_LINKER_FLAGS ${link_flags} CACHE INTERNAL "shared link flags") + +set(PKG_CONFIG_EXECUTABLE "/dev/null" CACHE INTERNAL "" FORCE) + +set(FIXUP ${toolchain_bin_dir}/vita-elf-create) +set(OBJCOPY ${cross_prefix}objcopy) +set(NIDDB ${VITASDK}/db.json) + +set(PSP2 ON) +add_definitions(-DPSP2)
M
src/platform/psp2/gui-font.c
→
src/platform/psp2/gui-font.c
@@ -5,25 +5,26 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "util/gui/font.h" #include "util/gui/font-metrics.h" -#include "font.h" #include <vita2d.h> #define CELL_HEIGHT 16 #define CELL_WIDTH 16 #define GLYPH_HEIGHT 12 + +extern const uint8_t _binary_font_png_start[]; struct GUIFont { vita2d_texture* tex; }; struct GUIFont* GUIFontCreate(void) { - struct GUIFont* guiFont = malloc(sizeof(struct GUIFont)); - if (!guiFont) { + struct GUIFont* font = malloc(sizeof(struct GUIFont)); + if (!font) { return 0; } - guiFont->tex = vita2d_load_PNG_buffer(font); - return guiFont; + font->tex = vita2d_load_PNG_buffer(_binary_font_png_start); + return font; } void GUIFontDestroy(struct GUIFont* font) {