psp, rendering fix, some build changes
authorkub <derkub@gmail.com>
Tue, 20 Feb 2024 21:01:47 +0000 (22:01 +0100)
committerkub <derkub@gmail.com>
Sat, 2 Mar 2024 09:19:57 +0000 (10:19 +0100)
platform/base_readme.txt
platform/psp/Makefile
platform/psp/plat.c
platform/psp/psp.c
platform/psp/psp.h

index 5925a47..d457521 100644 (file)
@@ -26,8 +26,6 @@ the root of SD, etc).
 If you are running a custom firmware, just copy the whole PicoDrive directory to\r
 /PSP/GAME or /PSP/GAMEXXX directory in your memory stick (it shouldn't matter\r
 which one GAME* directory to use).\r
-\r
-If you are on 1.5, there is a separate KXploited version for it.\r
 #endif\r
 #ifdef PANDORA\r
 Just copy the .pnd to <sd card>/pandora/menu or <sd card>/pandora/desktop.\r
index 6231d1e..2caf4ae 100644 (file)
@@ -6,32 +6,27 @@ $(error need VER)
 endif\r
 endif\r
 \r
+include ../../config.mak\r
+\r
+#PSPSDK ?= $(shell psp-config --pspsdk-path)\r
+#include $(PSPSDK)/lib/build.mak\r
+\r
+#PSP_EBOOT_TITLE = PicoDrive\r
+#PSP_EBOOT_ICON = data/icon.png\r
+\r
+#EBOOT.PBP:\r
+\r
 ../../tools/textfilter: ../../tools/textfilter.c\r
        make -C ../../tools/ textfilter\r
 \r
 readme.txt: ../../tools/textfilter ../base_readme.txt ../../ChangeLog\r
        ../../tools/textfilter ../base_readme.txt $@ PSP\r
 \r
-# ?\r
 rel: ../../EBOOT.PBP readme.txt ../game_def.cfg\r
-       mkdir -p PicoDrive/skin/\r
-       cp $^ PicoDrive/\r
-       cp skin/* PicoDrive/skin/\r
-       zip -9 -r ../../PicoDrive_psp_$(VER).zip PicoDrive\r
-       rm -rf PicoDrive\r
-       mkdir bin_to_cso_mp3\r
-       cp ../../tools/bin_to_cso_mp3/* bin_to_cso_mp3/\r
-       zip -9 -r ../../PicoDrive_psp_$(VER).zip bin_to_cso_mp3\r
-       rm -rf bin_to_cso_mp3\r
-\r
-rel_kxploit: readme.txt ../game_def.cfg\r
-       mkdir -p PicoDrive/skin/\r
-       cp $^ PicoDrive/\r
-       cp skin/* PicoDrive/skin/\r
-       zip -9 -r ../../PicoDrive_psp_$(VER)_kxploit.zip PicoDrive\r
-       zip -9 -r ../../PicoDrive_psp_$(VER)_kxploit.zip PicoDrive%\r
-       mkdir bin_to_cso_mp3\r
-       cp ../../tools/bin_to_cso_mp3/* bin_to_cso_mp3/\r
-       zip -9 -r ../../PicoDrive_psp_$(VER)_kxploit.zip bin_to_cso_mp3\r
-       rm -rf bin_to_cso_mp3\r
-\r
+       mkdir -p out/PicoDrive/skin/ out/bin_to_cso_mp3\r
+       cp $^ out/PicoDrive/\r
+       cp ../../skin/* out/PicoDrive/skin/\r
+       #mkdir -p out/bin_to_cso_mp3\r
+       #cp ../../tools/bin_to_cso_mp3/* out/bin_to_cso_mp3/\r
+       cd out && zip -9 -r ../../../PicoDrive_psp_$(VER).zip *\r
+       rm -rf out\r
index 64ae043..86b15e7 100644 (file)
@@ -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 */
index 0a53cce..f3ca9b3 100644 (file)
@@ -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)
index c8d4de8..c4c6404 100644 (file)
@@ -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);