fixes for platform support for PSP

This commit is contained in:
kub 2021-02-05 23:10:22 +01:00
parent 4cc0fcaf15
commit bfd6662370
6 changed files with 33 additions and 22 deletions

View file

@ -168,9 +168,8 @@ PLATFORM_ZLIB = 1
endif
ifeq "$(PLATFORM)" "psp"
CFLAGS += -DUSE_BGR565 -G8 # -DLPRINTF_STDIO -DFW15
LDFLAGS := $(filter-out -lpsp%, $(LDFLAGS)) # collides with PSP image generation
LDLIBS += -lpspnet_inet -lpspgu -lpspge -lpsppower -lpspaudio -lpspdisplay
LDLIBS += -lpspaudiocodec -lpsprtc -lpspctrl -lpspsdk -lpspuser -lpspkernel
LDLIBS += -lpspgu -lpspge -lpsppower -lpspaudio -lpspdisplay -lpspaudiocodec
LDLIBS += -lpsprtc -lpspctrl -lpspsdk -lc -lpspnet_inet -lpspuser -lpspkernel
platform/common/main.o: CFLAGS += -Dmain=pico_main
OBJS += platform/psp/plat.o
OBJS += platform/psp/emu.o

4
configure vendored
View file

@ -17,7 +17,7 @@ compile_object()
compile_binary()
{
c="$CC $CFLAGS $TMPC -o $TMPB $LDFLAGS $@"
c="$CC $CFLAGS $TMPC -o $TMPB $LDFLAGS $@ $SYSLIBS"
echo $c >> config.log
$c >> config.log 2>&1
}
@ -116,7 +116,7 @@ set_platform()
;;
psp)
# use newlib
LDFLAGS="$LDFLAGS -lc -lpspuser -lpspkernel"
SYSLIBS="-lc -lpspuser -lpspkernel"
CFLAGS="$CFLAGS -D__PSP__"
ARCH=mipsel
;;

View file

@ -53,7 +53,7 @@ static int h32_mode = 0;
static int out_x, out_y;
static int out_w, out_h;
static const struct in_default_bind in_psp_defbinds[] =
static struct in_default_bind in_psp_defbinds[] =
{
{ PSP_CTRL_UP, IN_BINDTYPE_PLAYER12, GBTN_UP },
{ PSP_CTRL_DOWN, IN_BINDTYPE_PLAYER12, GBTN_DOWN },
@ -211,6 +211,7 @@ static void do_pal_update(void)
t |= (t >> 2) | ((t >> 4) & 0x08610861);
dpal[i] = t;
}
Pico.m.dirtyPal = 0;
} else if (PicoIn.opt & POPT_ALT_RENDERER) {
do_pal_convert(localPal, PicoMem.cram, currentConfig.gamma, currentConfig.gamma2);
Pico.m.dirtyPal = 0;
@ -263,7 +264,7 @@ static void blitscreen_clut(void)
sceGuTexMode(is_16bit_mode() ? GU_PSM_5650:GU_PSM_T8,0,0,0);
sceGuTexImage(0,512,512,512,g_screen_ptr);
if (Pico.m.dirtyPal)
if (!is_16bit_mode() && Pico.m.dirtyPal)
do_pal_update();
sceKernelDcacheWritebackAll();

View file

@ -36,9 +36,10 @@ static const char *in_psp_keys[IN_PSP_NBUTTONS] = {
};
/* credits to https://graphics.stanford.edu/~seander/bithacks.html */
/* calculate bit number from bit mask (logarithm to the basis 2) */
static int lg2(unsigned v)
{
/* credits to https://graphics.stanford.edu/~seander/bithacks.html */
int r, s;
r = (v > 0xFFFF) << 4; v >>= r;
@ -49,9 +50,9 @@ static int lg2(unsigned v)
return r;
}
static int in_psp_get_bits(void)
static unsigned in_psp_get_bits(void)
{
return psp_pad_read(0);
return psp_pad_read(0) & 0xf000ffff;
}
static void in_psp_probe(const in_drv_t *drv)
@ -75,7 +76,8 @@ in_psp_get_key_names(const in_drv_t *drv, int *count)
static int in_psp_update(void *drv_data, const int *binds, int *result)
{
int type_start = 0;
int i, t, keys;
int i, t;
unsigned keys;
keys = in_psp_get_bits();
@ -98,8 +100,8 @@ static int in_psp_update(void *drv_data, const int *binds, int *result)
int in_psp_update_keycode(void *data, int *is_down)
{
static int old_val = 0;
int val, diff, i;
static unsigned old_val = 0;
unsigned val, diff, i;
val = in_psp_get_bits();
diff = val ^ old_val;
@ -118,9 +120,9 @@ int in_psp_update_keycode(void *data, int *is_down)
return i;
}
static const struct {
short key;
short pbtn;
static struct {
unsigned key;
int pbtn;
} key_pbtn_map[] =
{
{ PSP_CTRL_UP, PBTN_UP },
@ -147,12 +149,12 @@ static int in_psp_menu_translate(void *drv_data, int keycode, char *charcode)
keycode = -keycode;
for (i = 0; i < KEY_PBTN_MAP_SIZE; i++)
if (key_pbtn_map[i].pbtn == keycode)
return lg2(key_pbtn_map[i].key);
return key_pbtn_map[i].key;
}
else
{
for (i = 0; i < KEY_PBTN_MAP_SIZE; i++)
if (key_pbtn_map[i].key == 1<<keycode)
if (key_pbtn_map[i].key == keycode)
return key_pbtn_map[i].pbtn;
}
@ -191,11 +193,19 @@ static const in_drv_t in_psp_drv = {
.menu_translate = in_psp_menu_translate,
};
void in_psp_init(const struct in_default_bind *defbinds)
void in_psp_init(struct in_default_bind *defbinds)
{
int i;
/* PSP keys have bit masks, Picodrive wants bit numbers */
for (i = 0; defbinds[i].code; i++)
defbinds[i].code = lg2(defbinds[i].code);
for (i = 0; i < KEY_PBTN_MAP_SIZE; i++)
key_pbtn_map[i].key = lg2(key_pbtn_map[i].key);
in_psp_combo_keys = in_psp_combo_acts = 0;
/* fill keys array, converting key bitmasks to indexes */
/* fill keys array, converting key bitmasks to bit numbers */
in_psp_keys[lg2(PSP_CTRL_UP)] = "Up";
in_psp_keys[lg2(PSP_CTRL_LEFT)] = "Left";
in_psp_keys[lg2(PSP_CTRL_DOWN)] = "Down";

View file

@ -1,4 +1,4 @@
struct in_default_bind;
void in_psp_init(const struct in_default_bind *defbinds);
void in_psp_init(struct in_default_bind *defbinds);

View file

@ -194,8 +194,9 @@ void psp_finish(void)
void psp_video_flip(int wait_vsync)
{
void *fb = (void *)((unsigned long)psp_screen & ~0x40000000);
if (wait_vsync) sceDisplayWaitVblankStart();
sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565,
sceDisplaySetFrameBuf(fb, 512, PSP_DISPLAY_PIXEL_FORMAT_565,
wait_vsync ? PSP_DISPLAY_SETBUF_IMMEDIATE : PSP_DISPLAY_SETBUF_NEXTFRAME);
current_screen ^= 1;
psp_screen = current_screen ? VRAM_FB0 : VRAM_FB1;