From: kub Date: Fri, 5 Feb 2021 22:10:22 +0000 (+0100) Subject: fixes for platform support for PSP X-Git-Tag: v2.00~602 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfd66623701d7602ec23b39bb5576282c0f6eac1;p=picodrive.git fixes for platform support for PSP --- diff --git a/Makefile b/Makefile index a88e8978..febf4400 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/configure b/configure index f1e80c3f..f7f98256 100755 --- a/configure +++ b/configure @@ -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 ;; diff --git a/platform/psp/emu.c b/platform/psp/emu.c index 74008735..ef32bf26 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -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(); diff --git a/platform/psp/in_psp.c b/platform/psp/in_psp.c index 734e5e03..94e2d396 100644 --- a/platform/psp/in_psp.c +++ b/platform/psp/in_psp.c @@ -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<