mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 14:57:46 -04:00
optimizations, fixes, hacks, psp, ...
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@295 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
60a10527f2
commit
5ecedd0cc2
13 changed files with 134 additions and 158 deletions
25
psp/Makefile
25
psp/Makefile
|
@ -6,23 +6,19 @@ PSPSDK = $(shell psp-config --pspsdk-path)
|
|||
#use_musashi = 1
|
||||
#use_mz80 = 1
|
||||
amalgamate = 0
|
||||
#profile = 1
|
||||
#up = 1
|
||||
|
||||
|
||||
CFLAGS += -I../.. -I. -DNO_SYNC -DLPRINTF_STDIO
|
||||
CFLAGS += -Wall -Winline -G0
|
||||
CFLAGS += -DLPRINTF_STDIO
|
||||
#CFLAGS += -fprofile-generate
|
||||
#CFLAGS += -fprofile-use
|
||||
#CFLAGS += -pg
|
||||
ifeq ($(DEBUG),)
|
||||
CFLAGS += -O2 -ftracer -fstrength-reduce -ffast-math
|
||||
else
|
||||
CFLAGS += -ggdb
|
||||
endif
|
||||
ifeq "$(profile)" "1"
|
||||
CFLAGS += -fprofile-generate
|
||||
endif
|
||||
ifeq "$(profile)" "2"
|
||||
CFLAGS += -fprofile-use
|
||||
endif
|
||||
|
||||
|
||||
# frontend
|
||||
|
@ -37,7 +33,7 @@ OBJS += ../../PicoAll.o
|
|||
else
|
||||
OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Memory.o ../../Pico/Misc.o \
|
||||
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \
|
||||
../../Pico/Patch.o ../../Pico/Draw_amips.o ../../Pico/Memory_amips.o
|
||||
../../Pico/Patch.o ../../Pico/Draw_amips.o ../../Pico/Memory_amips.o ../../Pico/Misc_amips.o
|
||||
# Pico - CD
|
||||
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \
|
||||
../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \
|
||||
|
@ -77,8 +73,10 @@ OBJS += data/bg32.o data/bg40.o
|
|||
|
||||
|
||||
LIBS += -lpng -lm -lpspgu -lpsppower -lpspaudio -lpsprtc -lpspaudiocodec
|
||||
#LIBS += -lpspprof
|
||||
LDFLAGS += -Wl,-Map=PicoDrive.map
|
||||
|
||||
|
||||
# target
|
||||
TARGET = PicoDrive
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
|
@ -114,7 +112,11 @@ AS := psp-as
|
|||
|
||||
../../Pico/Draw.o : ../../Pico/Draw.c
|
||||
@echo ">>>" $<
|
||||
$(CC) $(CFLAGS) -c $< -o $@ -D_ASM_DRAW_C_MIPS
|
||||
$(CC) $(CFLAGS) -c $< -o $@ -D_ASM_DRAW_C_AMIPS
|
||||
|
||||
../../Pico/Misc.o : ../../Pico/Misc.c
|
||||
@echo ">>>" $<
|
||||
$(CC) $(CFLAGS) -c $< -o $@ -D_ASM_MISC_C_AMIPS
|
||||
|
||||
readme.txt: ../../tools/textfilter ../base_readme.txt
|
||||
../../tools/textfilter ../base_readme.txt $@ PSP
|
||||
|
@ -152,6 +154,5 @@ endif
|
|||
|
||||
# ?
|
||||
rel: EBOOT.PBP readme.txt
|
||||
zip -9 -j ../../PicoDrive_$(VER).zip $^
|
||||
# zip -9 -r ../../PicoDrive_$(VER).zip skin -i \*.png -i \*.txt
|
||||
zip -9 -r ../../PicoDrive_$(VER).zip skin -i \*.png -i \*.txt
|
||||
|
||||
|
|
41
psp/emu.c
41
psp/emu.c
|
@ -11,6 +11,7 @@
|
|||
#include "psp.h"
|
||||
#include "menu.h"
|
||||
#include "emu.h"
|
||||
#include "mp3.h"
|
||||
#include "../common/emu.h"
|
||||
#include "../common/lprintf.h"
|
||||
#include "../../Pico/PicoInt.h"
|
||||
|
@ -57,7 +58,7 @@ static void osd_text(int x, const char *text, int is_active, int clear_all)
|
|||
for (h = 0; h < 8; h++) {
|
||||
p = (int *) (screen+x+512*(264+h));
|
||||
p = (int *) ((int)p & ~3); // align
|
||||
memset32(p, 0, len);
|
||||
memset32_uncached(p, 0, len);
|
||||
}
|
||||
if (is_active) { tmp = psp_screen; psp_screen = screen; } // nasty pointer tricks
|
||||
emu_textOut16(x, 264, text);
|
||||
|
@ -126,8 +127,8 @@ void emu_setDefaultConfig(void)
|
|||
{
|
||||
memset(¤tConfig, 0, sizeof(currentConfig));
|
||||
currentConfig.lastRomFile[0] = 0;
|
||||
currentConfig.EmuOpt = 0x1f | 0x680; // | confirm_save, cd_leds, 16bit rend
|
||||
currentConfig.PicoOpt = 0x0f | 0xc00; // | cd_pcm, cd_cdda
|
||||
currentConfig.EmuOpt = 0x1d | 0x680; // | confirm_save, cd_leds, acc rend
|
||||
currentConfig.PicoOpt = 0x0f | 0x1c00; // | gfx_cd, cd_pcm, cd_cdda
|
||||
currentConfig.PsndRate = 22050;
|
||||
currentConfig.PicoRegion = 0; // auto
|
||||
currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP
|
||||
|
@ -172,7 +173,7 @@ static int fbimg_offs = 0;
|
|||
|
||||
static void set_scaling_params(void)
|
||||
{
|
||||
int src_width, fbimg_width, fbimg_height, fbimg_xoffs, fbimg_yoffs;
|
||||
int src_width, fbimg_width, fbimg_height, fbimg_xoffs, fbimg_yoffs, border_hack = 0;
|
||||
g_vertices[0].x = g_vertices[0].y =
|
||||
g_vertices[0].z = g_vertices[1].z = 0;
|
||||
|
||||
|
@ -185,9 +186,13 @@ static void set_scaling_params(void)
|
|||
src_width = 256;
|
||||
}
|
||||
|
||||
if (fbimg_width & 1) fbimg_width++; // make even
|
||||
if (fbimg_height & 1) fbimg_height++;
|
||||
|
||||
if (fbimg_width >= 480) {
|
||||
g_vertices[0].u = (fbimg_width-480)/2;
|
||||
g_vertices[1].u = src_width - (fbimg_width-480)/2;
|
||||
g_vertices[1].u = src_width - (fbimg_width-480)/2 - 1;
|
||||
if (fbimg_width == 480) border_hack = 1;
|
||||
fbimg_width = 480;
|
||||
fbimg_xoffs = 0;
|
||||
} else {
|
||||
|
@ -211,6 +216,12 @@ static void set_scaling_params(void)
|
|||
g_vertices[1].y = fbimg_height;
|
||||
if (fbimg_xoffs < 0) fbimg_xoffs = 0;
|
||||
if (fbimg_yoffs < 0) fbimg_yoffs = 0;
|
||||
if (border_hack) {
|
||||
g_vertices[0].u++;
|
||||
g_vertices[0].x++;
|
||||
g_vertices[1].u--;
|
||||
g_vertices[1].x--;
|
||||
}
|
||||
fbimg_offs = (fbimg_yoffs*512 + fbimg_xoffs) * 2; // dst is always 16bit
|
||||
|
||||
/*
|
||||
|
@ -371,7 +382,7 @@ static void cd_leds(void)
|
|||
*p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void dbg_text(void)
|
||||
{
|
||||
int *p, h, len;
|
||||
|
@ -382,11 +393,11 @@ static void dbg_text(void)
|
|||
for (h = 0; h < 8; h++) {
|
||||
p = (int *) ((unsigned short *) psp_screen+2+512*(256+h));
|
||||
p = (int *) ((int)p & ~3); // align
|
||||
memset32(p, 0, len);
|
||||
memset32_uncached(p, 0, len);
|
||||
}
|
||||
emu_textOut16(2, 256, text);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* called after rendering is done, but frame emulation is not finished */
|
||||
void blit1(void)
|
||||
|
@ -415,7 +426,7 @@ static void blit2(const char *fps, const char *notice, int lagging_behind)
|
|||
if (emu_opt & 2) osd_text(OSD_FPS_X, fps, 0, 0);
|
||||
}
|
||||
|
||||
dbg_text();
|
||||
//dbg_text();
|
||||
|
||||
if ((emu_opt & 0x400) && (PicoMCD & 1))
|
||||
cd_leds();
|
||||
|
@ -431,15 +442,15 @@ static void blit2(const char *fps, const char *notice, int lagging_behind)
|
|||
static void clearArea(int full)
|
||||
{
|
||||
if (full) {
|
||||
memset32(psp_screen, 0, 512*272*2/4);
|
||||
memset32_uncached(psp_screen, 0, 512*272*2/4);
|
||||
psp_video_flip(0);
|
||||
memset32(psp_screen, 0, 512*272*2/4);
|
||||
memset32_uncached(psp_screen, 0, 512*272*2/4);
|
||||
memset32(VRAM_CACHED_STUFF, 0xe0e0e0e0, 512*240/4);
|
||||
memset32((int *)VRAM_CACHED_STUFF+512*240/4, 0, 512*240*2/4);
|
||||
} else {
|
||||
void *fb = psp_video_get_active_fb();
|
||||
memset32((int *)((char *)psp_screen + 512*264*2), 0, 512*8*2/4);
|
||||
memset32((int *)((char *)fb + 512*264*2), 0, 512*8*2/4);
|
||||
memset32_uncached((int *)((char *)psp_screen + 512*264*2), 0, 512*8*2/4);
|
||||
memset32_uncached((int *)((char *)fb + 512*264*2), 0, 512*8*2/4);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -659,7 +670,7 @@ void emu_forcedFrame(void)
|
|||
vidResetMode();
|
||||
memset32(VRAM_CACHED_STUFF, 0xe0e0e0e0, 512*8/4); // borders
|
||||
memset32((int *)VRAM_CACHED_STUFF + 512*232/4, 0xe0e0e0e0, 512*8/4);
|
||||
memset32((int *)psp_screen + 512*264*2/4, 0, 512*8*2/4);
|
||||
memset32_uncached((int *)psp_screen + 512*264*2/4, 0, 512*8*2/4);
|
||||
|
||||
PicoDrawSetColorFormat(-1);
|
||||
PicoScan = EmuScanSlow;
|
||||
|
@ -1036,7 +1047,7 @@ void emu_Loop(void)
|
|||
}
|
||||
|
||||
// clear fps counters and stuff
|
||||
memset32((int *)psp_video_get_active_fb() + 512*264*2/4, 0, 512*8*2/4);
|
||||
memset32_uncached((int *)psp_video_get_active_fb() + 512*264*2/4, 0, 512*8*2/4);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,4 +28,6 @@ void emu_forcedFrame(void);
|
|||
|
||||
void emu_msg_cb(const char *msg);
|
||||
|
||||
// actually comes from Pico/Misc_amips.s
|
||||
void memset32_uncached(int *dest, int c, int count);
|
||||
|
||||
|
|
15
psp/menu.c
15
psp/menu.c
|
@ -154,7 +154,7 @@ void menu_romload_prepare(const char *rom_name)
|
|||
|
||||
psp_video_switch_to_single();
|
||||
if (rom_data) menu_draw_begin();
|
||||
else memset32(psp_screen, 0, 512*272*2/4);
|
||||
else memset32_uncached(psp_screen, 0, 512*272*2/4);
|
||||
|
||||
smalltext_out16(1, 1, "Loading", 0xffff);
|
||||
smalltext_out16_lim(1, 10, p, 0xffff, 80);
|
||||
|
@ -453,8 +453,10 @@ static void draw_debug(void)
|
|||
|
||||
static void debug_menu_loop(void)
|
||||
{
|
||||
int ret = 0;
|
||||
draw_debug();
|
||||
wait_for_input(BTN_X|BTN_CIRCLE, 0);
|
||||
while (!(ret & (BTN_X|BTN_CIRCLE)))
|
||||
ret = wait_for_input(BTN_X|BTN_CIRCLE, 0);
|
||||
}
|
||||
|
||||
// ------------ patch/gg menu ------------
|
||||
|
@ -1059,7 +1061,7 @@ static void menu_opt3_preview(int is_32col)
|
|||
lprintf("uncompress returned %i\n", ret);
|
||||
}
|
||||
|
||||
memset32(psp_screen, 0, 512*272*2/4);
|
||||
memset32_uncached(psp_screen, 0, 512*272*2/4);
|
||||
emu_forcedFrame();
|
||||
menu_prepare_bg(1, 0);
|
||||
|
||||
|
@ -1119,6 +1121,7 @@ static void dispmenu_loop_options(void)
|
|||
if (setting != NULL) {
|
||||
while ((inp = psp_pad_read(0)) & (BTN_LEFT|BTN_RIGHT)) {
|
||||
*setting += (inp & BTN_LEFT) ? -0.01 : 0.01;
|
||||
if (*setting <= 0) *setting = 0.01;
|
||||
menu_opt3_preview(is_32col);
|
||||
draw_dispmenu_options(menu_sel); // will wait vsync
|
||||
}
|
||||
|
@ -1735,12 +1738,12 @@ static void menu_prepare_bg(int use_game_bg, int use_fg)
|
|||
int i;
|
||||
for (i = 272; i > 0; i--, dst += 480, src += 512)
|
||||
menu_darken_bg(dst, src, 480, 1);
|
||||
//memset32((int *)(bg_buffer + 480*264), 0, 480*8*2/4);
|
||||
//memset32_uncached((int *)(bg_buffer + 480*264), 0, 480*8*2/4);
|
||||
}
|
||||
else
|
||||
{
|
||||
// should really only happen once, on startup..
|
||||
memset32((int *)(void *)bg_buffer, 0, sizeof(bg_buffer)/4);
|
||||
memset32_uncached((int *)(void *)bg_buffer, 0, sizeof(bg_buffer)/4);
|
||||
readpng(bg_buffer, "skin/background.png", READPNG_BG);
|
||||
}
|
||||
sceKernelDcacheWritebackAll();
|
||||
|
@ -1814,7 +1817,7 @@ int menu_loop_tray(void)
|
|||
for (;;)
|
||||
{
|
||||
draw_menu_tray(menu_sel);
|
||||
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_X, 0);
|
||||
inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_CIRCLE, 0);
|
||||
if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
|
||||
if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
|
||||
if(inp & BTN_CIRCLE) {
|
||||
|
|
10
psp/mp3.c
10
psp/mp3.c
|
@ -181,8 +181,6 @@ int mp3_init(void)
|
|||
goto fail2;
|
||||
}
|
||||
|
||||
lprintf("thread_busy_sem: %08x, thread_job_sem: %08x\n", thread_busy_sem, thread_job_sem);
|
||||
|
||||
thread_exit = 0;
|
||||
thid = sceKernelCreateThread("mp3decode_thread", decode_thread, 30, 0x2000, 0, 0); /* use slightly higher prio then main */
|
||||
if (thid < 0) {
|
||||
|
@ -273,7 +271,7 @@ static int decode_thread(SceSize args, void *argp)
|
|||
|
||||
int mp3_get_bitrate(FILE *f, int size)
|
||||
{
|
||||
int ret = -1, sample_rate, bitrate;
|
||||
int ret, retval = -1, sample_rate, bitrate;
|
||||
// filenames are stored instead handles in PSP, due to stupid max open file limit
|
||||
char *fname = (char *)f;
|
||||
|
||||
|
@ -307,14 +305,14 @@ int mp3_get_bitrate(FILE *f, int size)
|
|||
}
|
||||
|
||||
/* looking good.. */
|
||||
ret = bitrate;
|
||||
retval = bitrate;
|
||||
end:
|
||||
if (mp3_handle >= 0) sceIoClose(mp3_handle);
|
||||
mp3_handle = -1;
|
||||
mp3_fname = NULL;
|
||||
psp_sem_unlock(thread_busy_sem);
|
||||
if (ret < 0) mp3_last_error = -1; // remember we had a problem..
|
||||
return ret;
|
||||
if (retval < 0) mp3_last_error = -1; // remember we had a problem..
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
|
8
psp/mp3.h
Normal file
8
psp/mp3.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
// additional stuff for PSP mp3 decoder implementation
|
||||
extern int mp3_last_error;
|
||||
|
||||
int mp3_init(void);
|
||||
void mp3_deinit(void);
|
||||
|
||||
|
16
psp/psp.c
16
psp/psp.c
|
@ -10,6 +10,7 @@
|
|||
#include <pspgu.h>
|
||||
|
||||
#include "psp.h"
|
||||
#include "emu.h"
|
||||
#include "../common/lprintf.h"
|
||||
|
||||
PSP_MODULE_INFO("PicoDrive", 0, 1, 34);
|
||||
|
@ -28,6 +29,19 @@ static int exit_callback(int arg1, int arg2, void *common)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Power Callback */
|
||||
static int power_callback(int unknown, int pwrflags, void *common)
|
||||
{
|
||||
/* check for power switch and suspending as one is manual and the other automatic */
|
||||
if (pwrflags & PSP_POWER_CB_POWER_SWITCH || pwrflags & PSP_POWER_CB_SUSPENDING)
|
||||
{
|
||||
lprintf("power_callback: flags: 0x%08X: suspending\n", pwrflags);
|
||||
engineState = PGS_Menu;
|
||||
}
|
||||
sceDisplayWaitVblankStart();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Callback thread */
|
||||
static int callback_thread(SceSize args, void *argp)
|
||||
{
|
||||
|
@ -38,6 +52,8 @@ static int callback_thread(SceSize args, void *argp)
|
|||
|
||||
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
|
||||
sceKernelRegisterExitCallback(cbid);
|
||||
cbid = sceKernelCreateCallback("Power Callback", power_callback, NULL);
|
||||
scePowerRegisterCallback(0, cbid);
|
||||
|
||||
sceKernelSleepThreadCB();
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define VERSION "1.34"
|
||||
#define VERSION "1.35"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue