From d12dd1b4ea38dad9366957a9f4308070ab5f4276 Mon Sep 17 00:00:00 2001 From: kub Date: Tue, 20 Feb 2024 22:01:47 +0100 Subject: [PATCH] psp, rendering fix, some build changes --- platform/base_readme.txt | 2 -- platform/psp/Makefile | 39 +++++++++++++++++---------------------- platform/psp/plat.c | 12 +++++++----- platform/psp/psp.c | 23 +++++------------------ platform/psp/psp.h | 12 +++++++----- 5 files changed, 36 insertions(+), 52 deletions(-) diff --git a/platform/base_readme.txt b/platform/base_readme.txt index 5925a472..d4575215 100644 --- a/platform/base_readme.txt +++ b/platform/base_readme.txt @@ -26,8 +26,6 @@ the root of SD, etc). If you are running a custom firmware, just copy the whole PicoDrive directory to /PSP/GAME or /PSP/GAMEXXX directory in your memory stick (it shouldn't matter which one GAME* directory to use). - -If you are on 1.5, there is a separate KXploited version for it. #endif #ifdef PANDORA Just copy the .pnd to /pandora/menu or /pandora/desktop. diff --git a/platform/psp/Makefile b/platform/psp/Makefile index 6231d1ea..2caf4aed 100644 --- a/platform/psp/Makefile +++ b/platform/psp/Makefile @@ -6,32 +6,27 @@ $(error need VER) endif endif +include ../../config.mak + +#PSPSDK ?= $(shell psp-config --pspsdk-path) +#include $(PSPSDK)/lib/build.mak + +#PSP_EBOOT_TITLE = PicoDrive +#PSP_EBOOT_ICON = data/icon.png + +#EBOOT.PBP: + ../../tools/textfilter: ../../tools/textfilter.c make -C ../../tools/ textfilter readme.txt: ../../tools/textfilter ../base_readme.txt ../../ChangeLog ../../tools/textfilter ../base_readme.txt $@ PSP -# ? rel: ../../EBOOT.PBP readme.txt ../game_def.cfg - mkdir -p PicoDrive/skin/ - cp $^ PicoDrive/ - cp skin/* PicoDrive/skin/ - zip -9 -r ../../PicoDrive_psp_$(VER).zip PicoDrive - rm -rf PicoDrive - mkdir bin_to_cso_mp3 - cp ../../tools/bin_to_cso_mp3/* bin_to_cso_mp3/ - zip -9 -r ../../PicoDrive_psp_$(VER).zip bin_to_cso_mp3 - rm -rf bin_to_cso_mp3 - -rel_kxploit: readme.txt ../game_def.cfg - mkdir -p PicoDrive/skin/ - cp $^ PicoDrive/ - cp skin/* PicoDrive/skin/ - zip -9 -r ../../PicoDrive_psp_$(VER)_kxploit.zip PicoDrive - zip -9 -r ../../PicoDrive_psp_$(VER)_kxploit.zip PicoDrive% - mkdir bin_to_cso_mp3 - cp ../../tools/bin_to_cso_mp3/* bin_to_cso_mp3/ - zip -9 -r ../../PicoDrive_psp_$(VER)_kxploit.zip bin_to_cso_mp3 - rm -rf bin_to_cso_mp3 - + mkdir -p out/PicoDrive/skin/ out/bin_to_cso_mp3 + cp $^ out/PicoDrive/ + cp ../../skin/* out/PicoDrive/skin/ + #mkdir -p out/bin_to_cso_mp3 + #cp ../../tools/bin_to_cso_mp3/* out/bin_to_cso_mp3/ + cd out && zip -9 -r ../../../PicoDrive_psp_$(VER).zip * + rm -rf out diff --git a/platform/psp/plat.c b/platform/psp/plat.c index 64ae0432..86b15e77 100644 --- a/platform/psp/plat.c +++ b/platform/psp/plat.c @@ -70,15 +70,16 @@ void plat_target_finish(void) /* display a completed frame buffer and prepare a new render buffer */ void plat_video_flip(void) { - int offs = (psp_screen == VRAM_FB0) ? VRAMOFFS_FB0 : VRAMOFFS_FB1; + unsigned long offs; g_menubg_src_ptr = psp_screen; sceGuSync(0, 0); // sync with prev - psp_video_flip(currentConfig.EmuOpt & EOPT_VSYNC, 0); + psp_video_flip(currentConfig.EmuOpt & EOPT_VSYNC); + offs = (unsigned long)psp_screen - VRAM_ADDR; // back buffer offset sceGuStart(GU_DIRECT, guCmdList); - sceGuDrawBuffer(GU_PSM_5650, (void *)offs, 512); // point to back buffer + sceGuDrawBuffer(GU_PSM_5650, (void *)offs, 512); sceGuClearColor(0); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT); @@ -87,7 +88,7 @@ void plat_video_flip(void) sceGuFinish(); - g_screen_ptr = VRAM_CACHED_STUFF + (psp_screen - VRAM_FB0); + g_screen_ptr = VRAM_CACHED_STUFF + offs; plat_video_set_buffer(g_screen_ptr); } @@ -100,6 +101,7 @@ void plat_video_wait_vsync(void) /* switch from emulation display to menu display */ void plat_video_menu_enter(int is_rom_loaded) { + g_screen_ptr = NULL; } /* start rendering a menu screen */ @@ -112,7 +114,7 @@ void plat_video_menu_begin(void) void plat_video_menu_end(void) { g_menuscreen_ptr = NULL; - psp_video_flip(1, 0); + psp_video_flip(1); } /* terminate menu display */ diff --git a/platform/psp/psp.c b/platform/psp/psp.c index 0a53cce7..f3ca9b3b 100644 --- a/platform/psp/psp.c +++ b/platform/psp/psp.c @@ -65,9 +65,7 @@ int psp_unhandled_suspend = 0; unsigned int __attribute__((aligned(16))) guCmdList[GU_CMDLIST_SIZE]; -void *psp_screen = VRAM_FB0; - -static int current_screen = 0; /* front bufer */ +void *psp_screen = VRAM_FB0; /* back buffer */ static SceUID main_thread_id = -1; @@ -145,7 +143,6 @@ void psp_init(void) /* video */ sceDisplaySetMode(0, 480, 272); sceDisplaySetFrameBuf(VRAM_FB1, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME); - current_screen = 1; psp_screen = VRAM_FB0; /* gu */ @@ -193,27 +190,17 @@ void psp_finish(void) sceKernelExitGame(); } -void psp_video_flip(int wait_vsync, int other) +void psp_video_flip(int wait_vsync) { - unsigned long fb = (unsigned long)psp_screen & ~0x40000000; - if (other) fb ^= 0x44000; if (wait_vsync) sceDisplayWaitVblankStart(); - sceDisplaySetFrameBuf((void *)fb, 512, PSP_DISPLAY_PIXEL_FORMAT_565, + sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_IMMEDIATE); - current_screen ^= 1; - psp_screen = current_screen ? VRAM_FB0 : VRAM_FB1; + psp_screen = (void *)((unsigned long)psp_screen ^ (VRAMOFFS_FB1 ^ VRAMOFFS_FB0)); } void *psp_video_get_active_fb(void) { - return current_screen ? VRAM_FB1 : VRAM_FB0; -} - -void psp_video_switch_to_single(void) -{ - psp_screen = VRAM_FB0; - sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME); - current_screen = 0; + return (void *)((unsigned long)psp_screen ^ (VRAMOFFS_FB1 ^ VRAMOFFS_FB0)); } void psp_msleep(int ms) diff --git a/platform/psp/psp.h b/platform/psp/psp.h index c8d4de82..c4c6404c 100644 --- a/platform/psp/psp.h +++ b/platform/psp/psp.h @@ -25,11 +25,13 @@ void psp_msleep(int ms); #define VRAMOFFS_DEPTH 0x00088000 #define VRAMOFFS_STUFF 0x000cc000 -#define VRAM_FB0 ((void *) (0x44000000+VRAMOFFS_FB0)) -#define VRAM_FB1 ((void *) (0x44000000+VRAMOFFS_FB1)) -#define VRAM_STUFF ((void *) (0x44000000+VRAMOFFS_STUFF)) +#define VRAM_ADDR 0x44000000 +#define VRAM_FB0 ((void *) (VRAM_ADDR+VRAMOFFS_FB0)) +#define VRAM_FB1 ((void *) (VRAM_ADDR+VRAMOFFS_FB1)) +#define VRAM_STUFF ((void *) (VRAM_ADDR+VRAMOFFS_STUFF)) -#define VRAM_CACHED_STUFF ((void *) (0x04000000+VRAMOFFS_STUFF)) +#define VRAM_CACHEDADDR 0x04000000 +#define VRAM_CACHED_STUFF ((void *) (VRAM_CACHEDADDR+VRAMOFFS_STUFF)) #define GU_CMDLIST_SIZE (16*1024) @@ -38,7 +40,7 @@ extern int psp_unhandled_suspend; void *psp_video_get_active_fb(void); void psp_video_switch_to_single(void); -void psp_video_flip(int wait_vsync, int other); +void psp_video_flip(int wait_vsync); extern void *psp_screen; unsigned int psp_pad_read(int blocking); -- 2.39.5