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
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
}
;;
psp)
# use newlib
- LDFLAGS="$LDFLAGS -lc -lpspuser -lpspkernel"
+ SYSLIBS="-lc -lpspuser -lpspkernel"
CFLAGS="$CFLAGS -D__PSP__"
ARCH=mipsel
;;
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 },
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;
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();
};
-/* 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;
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)
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();
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;
return i;
}
-static const struct {
- short key;
- short pbtn;
+static struct {
+ unsigned key;
+ int pbtn;
} key_pbtn_map[] =
{
{ PSP_CTRL_UP, PBTN_UP },
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;
}
.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";
struct in_default_bind;
-void in_psp_init(const struct in_default_bind *defbinds);
+void in_psp_init(struct in_default_bind *defbinds);
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;