all repos — mgba @ f3b4855b06a69b60dbf4d134b0326b42b5e29831

mGBA Game Boy Advance Emulator

PSP2: I hope this doesn't look terrible
Jeffrey Pfau jeffrey@endrift.com
Sat, 29 Aug 2015 21:53:13 -0700
commit

f3b4855b06a69b60dbf4d134b0326b42b5e29831

parent

dcfc31f82d19990131d28f38077aea350290fa25

M src/platform/psp2/CMakeLists.txtsrc/platform/psp2/CMakeLists.txt

@@ -1,10 +1,11 @@

file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/psp2/*.c) execute_process(COMMAND ${OBJCOPY} -I binary -O elf32-littlearm -B arm font.png ${CMAKE_BINARY_DIR}/font.o WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/res) +execute_process(COMMAND ${OBJCOPY} -I binary -O elf32-littlearm -B arm backdrop.png ${CMAKE_BINARY_DIR}/backdrop.o WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) set(PLATFORM_LIBRARY -lvita2d -lSceCtrl_stub -lSceRtc_stub -lSceGxm_stub -lSceDisplay_stub -lSceAudio_stub -lSceMotion_stub -lScePower_stub -lpng -lz -l${M_LIBRARY}) -add_executable(${BINARY_NAME}.elf ${PLATFORM_SRC} ${GUI_SRC} ${CMAKE_BINARY_DIR}/font.o) +add_executable(${BINARY_NAME}.elf ${PLATFORM_SRC} ${GUI_SRC} ${CMAKE_BINARY_DIR}/font.o ${CMAKE_BINARY_DIR}/backdrop.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} ${BINARY_NAME}.elf ${BINARY_NAME}.velf ${NIDDB} MAIN_DEPENDENCY ${BINARY_NAME}.elf)
M src/platform/psp2/psp2-context.csrc/platform/psp2/psp2-context.c

@@ -28,6 +28,13 @@ #include <psp2/power.h>

#include <vita2d.h> +enum ScreenMode { + SM_BACKDROP, + SM_PLAIN, + SM_FULL, + SM_MAX +}; + static struct GBAContext context; static struct GBAVideoSoftwareRenderer renderer; static vita2d_texture* tex;

@@ -37,7 +44,10 @@ struct GBARotationSource d;

struct SceMotionSensorState state; } rotation; -static bool fullscreen = false; +static int screenMode = 0; + +extern const uint8_t _binary_backdrop_png_start[]; +static vita2d_texture* backdrop = 0; #define PSP2_INPUT 0x50535032 #define PSP2_SAMPLES 64

@@ -141,6 +151,8 @@ rotation.d.readTiltY = _readTiltY;

rotation.d.readGyroZ = _readGyroZ; context.gba->rotationSource = &rotation.d; + backdrop = vita2d_load_PNG_buffer(_binary_backdrop_png_start); + printf("%s starting", projectName); }

@@ -183,7 +195,8 @@ break;

} if (pad.buttons & PSP2_CTRL_SQUARE) { if (!fsToggle) { - fullscreen = !fullscreen; + ++screenMode; + screenMode %= SM_MAX; } fsToggle = true; } else {

@@ -247,13 +260,20 @@

void GBAPSP2Teardown(void) { GBAContextDeinit(&context); vita2d_free_texture(tex); + vita2d_free_texture(backdrop); } void GBAPSP2Draw(void) { - if (fullscreen) { + switch (screenMode) { + case SM_BACKDROP: + vita2d_draw_texture(backdrop, 0, 0); + // Fall through + case SM_PLAIN: + vita2d_draw_texture_part_scale(tex, 120, 32, 0, 0, 240, 160, 3.0f, 3.0f); + break; + case SM_FULL: vita2d_draw_texture_scale(tex, 0, 0, 960.0f / 240.0f, 544.0f / 160.0f); - } else { - vita2d_draw_texture_scale(tex, 120, 32, 3.0f, 3.0f); + break; } }