diff --git a/adrenaline_compat.h b/adrenaline_compat.h index 790e945..5adee2d 100644 --- a/adrenaline_compat.h +++ b/adrenaline_compat.h @@ -182,6 +182,9 @@ typedef struct { #define ADRENALINE_SIZE 0x2000 #define ADRENALINE_ADDRESS 0xABCDE000 +#define DRAW_NATIVE 0xABCDEF00 +#define NATIVE_FRAMEBUFFER 0x0A000000 + #define CONVERT_ADDRESS(addr) (0x68000000 + (addr & 0x0FFFFFFF)) #endif diff --git a/cef/systemctrl/adrenaline.c b/cef/systemctrl/adrenaline.c index e081bf5..d9eb9f6 100644 --- a/cef/systemctrl/adrenaline.c +++ b/cef/systemctrl/adrenaline.c @@ -323,5 +323,7 @@ int initAdrenaline() { sceKernelStartThread(thid, 0, NULL); + *(u32 *)DRAW_NATIVE = 0; + return 0; } \ No newline at end of file diff --git a/cef/systemctrl/rebootex.h b/cef/systemctrl/rebootex.h index e9d7d81..8041ff0 100644 --- a/cef/systemctrl/rebootex.h +++ b/cef/systemctrl/rebootex.h @@ -35,16 +35,16 @@ static unsigned char rebootex[] __attribute__((aligned(16))) = { 0xf8, 0x08, 0x42, 0x8c, 0xf8, 0xff, 0xbd, 0x27, 0x04, 0x00, 0xbf, 0xaf, 0x00, 0x00, 0xb0, 0xaf, 0x09, 0xf8, 0x40, 0x00, 0x21, 0x80, 0xa0, 0x00, 0x04, 0x00, 0xbf, 0x8f, 0x40, 0x01, 0x02, 0x3c, 0x50, 0x00, 0x02, 0xae, 0x00, 0x8a, 0x02, 0x3c, 0x4c, 0x00, 0x02, 0xae, 0x00, 0x00, 0xb0, 0x8f, - 0x08, 0x00, 0xe0, 0x03, 0x08, 0x00, 0xbd, 0x27, 0xfc, 0x88, 0x03, 0x3c, 0xcc, 0x01, 0x63, 0x24, - 0xff, 0x03, 0x02, 0x3c, 0xff, 0xff, 0x42, 0x34, 0x82, 0x18, 0x03, 0x00, 0x24, 0x18, 0x62, 0x00, - 0x00, 0x0c, 0x02, 0x3c, 0x25, 0x18, 0x62, 0x00, 0x60, 0x14, 0x02, 0x3c, 0x03, 0x00, 0x49, 0x34, - 0xff, 0xf3, 0x02, 0x3c, 0xf0, 0xff, 0xbd, 0x27, 0xff, 0xff, 0x48, 0x34, 0x01, 0x88, 0x02, 0x3c, - 0x08, 0x00, 0xb1, 0xaf, 0x04, 0x00, 0xb0, 0xaf, 0x28, 0x00, 0x91, 0x8c, 0x21, 0x80, 0xa0, 0x00, - 0x0c, 0x00, 0xbf, 0xaf, 0x00, 0x40, 0x47, 0x34, 0x00, 0x88, 0x04, 0x3c, 0xfc, 0x88, 0x06, 0x3c, - 0x00, 0x80, 0x05, 0x3c, 0x00, 0x00, 0x82, 0x8c, 0x08, 0x00, 0x49, 0x54, 0x04, 0x00, 0x84, 0x24, - 0xe4, 0xff, 0x82, 0x8c, 0xe4, 0xff, 0x83, 0xac, 0x24, 0x10, 0x48, 0x00, 0x80, 0x10, 0x02, 0x00, - 0x25, 0x10, 0x45, 0x00, 0xf8, 0x08, 0xc2, 0xac, 0x04, 0x00, 0x84, 0x24, 0xf5, 0xff, 0x87, 0x14, - 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x3f, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x21, 0x28, 0x00, 0x02, + 0x08, 0x00, 0xe0, 0x03, 0x08, 0x00, 0xbd, 0x27, 0xfc, 0x88, 0x02, 0x3c, 0xfc, 0x88, 0x03, 0x3c, + 0xcc, 0x01, 0x63, 0x24, 0xf8, 0x08, 0x46, 0x8c, 0xff, 0x03, 0x02, 0x3c, 0xff, 0xff, 0x42, 0x34, + 0x82, 0x18, 0x03, 0x00, 0x24, 0x18, 0x62, 0x00, 0x00, 0x0c, 0x02, 0x3c, 0x25, 0x18, 0x62, 0x00, + 0x60, 0x14, 0x02, 0x3c, 0x03, 0x00, 0x49, 0x34, 0xff, 0xf3, 0x02, 0x3c, 0xf0, 0xff, 0xbd, 0x27, + 0xff, 0xff, 0x48, 0x34, 0x01, 0x88, 0x02, 0x3c, 0x08, 0x00, 0xb1, 0xaf, 0x04, 0x00, 0xb0, 0xaf, + 0x28, 0x00, 0x91, 0x8c, 0x21, 0x80, 0xa0, 0x00, 0x0c, 0x00, 0xbf, 0xaf, 0x00, 0x40, 0x47, 0x34, + 0x00, 0x88, 0x04, 0x3c, 0x00, 0x80, 0x05, 0x3c, 0x00, 0x00, 0x82, 0x8c, 0x07, 0x00, 0x49, 0x54, + 0x04, 0x00, 0x84, 0x24, 0xe4, 0xff, 0x82, 0x8c, 0xe4, 0xff, 0x83, 0xac, 0x24, 0x10, 0x48, 0x00, + 0x80, 0x10, 0x02, 0x00, 0x25, 0x30, 0x45, 0x00, 0x04, 0x00, 0x84, 0x24, 0xf6, 0xff, 0x87, 0x14, + 0xfc, 0x88, 0x02, 0x3c, 0x68, 0x00, 0x3f, 0x0e, 0xf8, 0x08, 0x46, 0xac, 0x21, 0x28, 0x00, 0x02, 0x21, 0xc8, 0x20, 0x02, 0x0c, 0x00, 0xbf, 0x8f, 0x08, 0x00, 0xb1, 0x8f, 0x04, 0x00, 0xb0, 0x8f, 0x04, 0x00, 0x04, 0x24, 0x08, 0x00, 0x20, 0x03, 0x10, 0x00, 0xbd, 0x27, 0xf0, 0xff, 0xbd, 0x27, 0x04, 0x00, 0xb0, 0xaf, 0x2d, 0xae, 0x02, 0x3c, 0x21, 0x80, 0x80, 0x00, 0x08, 0x00, 0xb1, 0xaf, diff --git a/cef/systemctrl/sysmodpatches.c b/cef/systemctrl/sysmodpatches.c index 1d7da6f..0739f99 100644 --- a/cef/systemctrl/sysmodpatches.c +++ b/cef/systemctrl/sysmodpatches.c @@ -330,9 +330,10 @@ void PatchImposeDriver(u32 text_addr) { if (sceKernelInitKeyConfig() == PSP_INIT_KEYCONFIG_POPS) { SetupCallbacks(); MAKE_DUMMY_FUNCTION(text_addr + 0x91C8, PSP_INIT_KEYCONFIG_GAME); - REDIRECT_FUNCTION(text_addr + 0x92B0, sceKernelWaitEventFlagPatched); } + REDIRECT_FUNCTION(text_addr + 0x92B0, sceKernelWaitEventFlagPatched); + ClearCaches(); } @@ -354,7 +355,7 @@ void PatchMediaSync(u32 text_addr) { } void SetSpeed(int cpu, int bus) { - if (cpu == 20 || cpu == 75 || cpu == 100 || cpu == 133 || cpu == 333 || cpu == 300 || cpu == 266 || cpu == 222) { + if (cpu == 20 || cpu == 75 || cpu == 100 || cpu == 133 || cpu == 333 || cpu == 300 || cpu == 266 || cpu == 222) { scePowerSetClockFrequency_k = (void *)FindPowerFunction(0x737486F2); scePowerSetClockFrequency_k(cpu, cpu, bus); diff --git a/user/CMakeLists.txt b/user/CMakeLists.txt index d697b46..50013ac 100644 --- a/user/CMakeLists.txt +++ b/user/CMakeLists.txt @@ -96,7 +96,7 @@ vita_create_self(adrenaline_user.suprx adrenaline_user CONFIG exports.yml UNSAFE vita_create_stubs(stubs adrenaline_user ${CMAKE_SOURCE_DIR}/exports.yml) add_custom_target(copy - COMMAND cp adrenaline_user.suprx H:/app/PSPEMUCFW/sce_module/adrenaline_user.suprx + COMMAND cp adrenaline_user.suprx F:/app/PSPEMUCFW/sce_module/adrenaline_user.suprx DEPENDS adrenaline_user.suprx ) diff --git a/user/flash0/kd/systemctrl.prx b/user/flash0/kd/systemctrl.prx index acf8cbc..22d95f2 100644 Binary files a/user/flash0/kd/systemctrl.prx and b/user/flash0/kd/systemctrl.prx differ diff --git a/user/menu.c b/user/menu.c index f6b737d..f2dc1b6 100644 --- a/user/menu.c +++ b/user/menu.c @@ -389,6 +389,10 @@ int AdrenalineDraw(SceSize args, void *argp) { vita2d_init(); font = vita2d_load_default_pgf(); + vita2d_texture *native_tex = vita2d_create_empty_texture_data(SCREEN_WIDTH, SCREEN_HEIGHT, CONVERT_ADDRESS(NATIVE_FRAMEBUFFER), SCE_GXM_TEXTURE_FORMAT_U5U6U5_BGR); + if (!native_tex) + return -1; + vita2d_texture *psp_tex = vita2d_create_empty_texture(PSP_SCREEN_LINE, PSP_SCREEN_HEIGHT); if (!psp_tex) return -1; @@ -471,6 +475,7 @@ int AdrenalineDraw(SceSize args, void *argp) { int lastPops = 0; while (1) { + int draw_native = *(uint32_t *)CONVERT_ADDRESS(DRAW_NATIVE); SceAdrenaline *adrenaline = (SceAdrenaline *)CONVERT_ADDRESS(ADRENALINE_ADDRESS); // pause/unpause pops once after switching from psp to pops mode @@ -541,7 +546,7 @@ int AdrenalineDraw(SceSize args, void *argp) { } // Do not draw if dialog is running - if (sceCommonDialogIsRunning() || (config.graphics_filtering == 0 && menu_open == 0)) { + if (sceCommonDialogIsRunning() || (config.graphics_filtering == 0 && menu_open == 0 && draw_native == 0)) { sceDisplayWaitVblankStart(); continue; } @@ -578,7 +583,7 @@ int AdrenalineDraw(SceSize args, void *argp) { vita2d_texture_set_filters(pops_tex, SCE_GXM_TEXTURE_FILTER_POINT, SCE_GXM_TEXTURE_FILTER_POINT); } - if (!adrenaline->pops_mode || adrenaline->draw_psp_screen_in_pops) { + if ((!adrenaline->pops_mode && !draw_native) || adrenaline->draw_psp_screen_in_pops) { // Copy PSP framebuffer sceDmacMemcpy(psp_data, (void *)SCE_PSPEMU_FRAMEBUFFER, SCE_PSPEMU_FRAMEBUFFER_SIZE); @@ -587,6 +592,8 @@ int AdrenalineDraw(SceSize args, void *argp) { float scale_y = 2.00f; getPspScreenScale(&scale_x, &scale_y); vita2d_draw_texture_scale_rotate_hotspot(psp_tex, 480.0f, 272.0f, scale_x, scale_y, 0.0, 240.0, 136.0); + } else if (draw_native) { + vita2d_draw_texture_scale_rotate_hotspot(native_tex, 480.0f, 272.0f, 1.0f, 1.0f, 0.0, 480.0, 272.0); } else { // Draw pops screen float scale_x = 1.0f; @@ -653,7 +660,7 @@ int AdrenalineDraw(SceSize args, void *argp) { frames++; // Sync - if (!adrenaline->pops_mode || adrenaline->draw_psp_screen_in_pops) + if ((!adrenaline->pops_mode && !draw_native) || adrenaline->draw_psp_screen_in_pops) sceCompatLCDCSync(); else sceDisplayWaitVblankStart(); diff --git a/user/states.c b/user/states.c index 621cb27..218eade 100644 --- a/user/states.c +++ b/user/states.c @@ -78,6 +78,19 @@ void makeSaveStatePath(char *path, int num) { extern void *pops_data; +static uint32_t convert565To8888(uint16_t color) { + uint8_t red_value = (color & 0xF800) >> 11; + uint8_t green_value = (color & 0x7E0) >> 5; + uint8_t blue_value = (color & 0x1F); + + uint8_t alpha = 0xFF; + uint8_t red = red_value << 3; + uint8_t green = green_value << 2; + uint8_t blue = blue_value << 3; + + return (alpha << 24) | (red << 16) | (green << 8) | blue; +} + int saveFrameBuffer(SceUID fd) { sceCompatLCDCSync(); @@ -87,9 +100,19 @@ int saveFrameBuffer(SceUID fd) { int i = 0; + int draw_native = *(uint32_t *)CONVERT_ADDRESS(DRAW_NATIVE); SceAdrenaline *adrenaline = (SceAdrenaline *)ScePspemuConvertAddress(ADRENALINE_ADDRESS, KERMIT_INPUT_MODE, ADRENALINE_SIZE); - if (adrenaline->pops_mode) { + if (draw_native) { + int y; + for (y = 0; y < SCREEN_HEIGHT; y += 4) { + int x; + for (x = 0; x < SCREEN_WIDTH; x += 4) { + uint16_t color = ((uint16_t *)CONVERT_ADDRESS(NATIVE_FRAMEBUFFER))[x + SCREEN_WIDTH * y]; + buf[i++] = convert565To8888(color); + } + } + } else if (adrenaline->pops_mode) { int y; for (y = 0; y < SCREEN_HEIGHT; y += 4) { int x;