mirror of https://github.com/mgba-emu/mgba.git
PSP2: I hope this doesn't look terrible
This commit is contained in:
parent
dcfc31f82d
commit
f3b4855b06
|
@ -1,10 +1,11 @@
|
||||||
file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/psp2/*.c)
|
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 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})
|
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})
|
target_link_libraries(${BINARY_NAME}.elf ${BINARY_NAME} ${PLATFORM_LIBRARY})
|
||||||
set_target_properties(${BINARY_NAME}.elf PROPERTIES OUTPUT_NAME ${BINARY_NAME}.elf)
|
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)
|
add_custom_command(TARGET ${BINARY_NAME}.elf POST_BUILD COMMAND ${FIXUP} ${BINARY_NAME}.elf ${BINARY_NAME}.velf ${NIDDB} MAIN_DEPENDENCY ${BINARY_NAME}.elf)
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
|
@ -28,6 +28,13 @@
|
||||||
|
|
||||||
#include <vita2d.h>
|
#include <vita2d.h>
|
||||||
|
|
||||||
|
enum ScreenMode {
|
||||||
|
SM_BACKDROP,
|
||||||
|
SM_PLAIN,
|
||||||
|
SM_FULL,
|
||||||
|
SM_MAX
|
||||||
|
};
|
||||||
|
|
||||||
static struct GBAContext context;
|
static struct GBAContext context;
|
||||||
static struct GBAVideoSoftwareRenderer renderer;
|
static struct GBAVideoSoftwareRenderer renderer;
|
||||||
static vita2d_texture* tex;
|
static vita2d_texture* tex;
|
||||||
|
@ -37,7 +44,10 @@ static struct GBASceRotationSource {
|
||||||
struct SceMotionSensorState state;
|
struct SceMotionSensorState state;
|
||||||
} rotation;
|
} 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_INPUT 0x50535032
|
||||||
#define PSP2_SAMPLES 64
|
#define PSP2_SAMPLES 64
|
||||||
|
@ -141,6 +151,8 @@ void GBAPSP2Setup() {
|
||||||
rotation.d.readGyroZ = _readGyroZ;
|
rotation.d.readGyroZ = _readGyroZ;
|
||||||
context.gba->rotationSource = &rotation.d;
|
context.gba->rotationSource = &rotation.d;
|
||||||
|
|
||||||
|
backdrop = vita2d_load_PNG_buffer(_binary_backdrop_png_start);
|
||||||
|
|
||||||
printf("%s starting", projectName);
|
printf("%s starting", projectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +195,8 @@ void GBAPSP2Runloop(void) {
|
||||||
}
|
}
|
||||||
if (pad.buttons & PSP2_CTRL_SQUARE) {
|
if (pad.buttons & PSP2_CTRL_SQUARE) {
|
||||||
if (!fsToggle) {
|
if (!fsToggle) {
|
||||||
fullscreen = !fullscreen;
|
++screenMode;
|
||||||
|
screenMode %= SM_MAX;
|
||||||
}
|
}
|
||||||
fsToggle = true;
|
fsToggle = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -247,13 +260,20 @@ void GBAPSP2UnloadROM(void) {
|
||||||
void GBAPSP2Teardown(void) {
|
void GBAPSP2Teardown(void) {
|
||||||
GBAContextDeinit(&context);
|
GBAContextDeinit(&context);
|
||||||
vita2d_free_texture(tex);
|
vita2d_free_texture(tex);
|
||||||
|
vita2d_free_texture(backdrop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAPSP2Draw(void) {
|
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);
|
vita2d_draw_texture_scale(tex, 0, 0, 960.0f / 240.0f, 544.0f / 160.0f);
|
||||||
} else {
|
break;
|
||||||
vita2d_draw_texture_scale(tex, 120, 32, 3.0f, 3.0f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue