mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-06 23:28:04 -04:00
psp fixes, gamma
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@302 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
f3f1615e5e
commit
93c0d147a1
13 changed files with 237 additions and 55 deletions
10
psp/Makefile
10
psp/Makefile
|
@ -6,6 +6,7 @@ PSPSDK = $(shell psp-config --pspsdk-path)
|
|||
#use_musashi = 1
|
||||
#use_mz80 = 1
|
||||
amalgamate = 0
|
||||
for_15fw = 1
|
||||
|
||||
|
||||
CFLAGS += -I../.. -I. -DNO_SYNC
|
||||
|
@ -17,10 +18,13 @@ CFLAGS += -O2 -ftracer -fstrength-reduce -ffast-math
|
|||
else
|
||||
CFLAGS += -ggdb
|
||||
endif
|
||||
ifeq "$(for_15fw)" "1"
|
||||
CFLAGS += -DFW15
|
||||
endif
|
||||
|
||||
|
||||
# frontend
|
||||
OBJS += main.o emu.o mp3.o menu.o psp.o
|
||||
# frontend and stuff
|
||||
OBJS += main.o emu.o mp3.o menu.o psp.o asm_utils.o
|
||||
|
||||
# common
|
||||
OBJS += ../common/emu.o ../common/menu.o ../common/fonts.o ../common/readpng.o
|
||||
|
@ -81,7 +85,9 @@ EXTRA_TARGETS = EBOOT.PBP
|
|||
PSP_EBOOT_TITLE = PicoDrive
|
||||
PSP_EBOOT_ICON = data/icon.png
|
||||
#PSP_EBOOT_PIC1 = .png
|
||||
ifneq "$(for_15fw)" "1"
|
||||
BUILD_PRX = 1
|
||||
endif
|
||||
|
||||
CUSTOM_CLEAN = myclean
|
||||
|
||||
|
|
2
psp/asm_utils.h
Normal file
2
psp/asm_utils.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
// pointers must be word aligned
|
||||
void do_pal_convert(unsigned short *dest, unsigned short *src, int gammaa_val);
|
122
psp/asm_utils.s
Normal file
122
psp/asm_utils.s
Normal file
|
@ -0,0 +1,122 @@
|
|||
# vim:filetype=mips
|
||||
|
||||
# some asm utils
|
||||
# (c) Copyright 2007, Grazvydas "notaz" Ignotas
|
||||
# All Rights Reserved
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
|
||||
.data
|
||||
.align 4
|
||||
|
||||
.byte 0, 1, 6, 11, 16, 21, 26, 31 # -4
|
||||
.byte 0, 2, 7, 12, 16, 21, 26, 31 # -3
|
||||
.byte 0, 3, 7, 12, 17, 22, 26, 31 # -2
|
||||
.byte 0, 4, 8, 13, 17, 22, 26, 31 # -1
|
||||
gmtab:
|
||||
.byte 0, 5, 10, 15, 16, 21, 26, 31 # 0
|
||||
.byte 0, 6, 10, 15, 19, 23, 27, 31
|
||||
.byte 0, 7, 11, 15, 19, 23, 27, 31
|
||||
.byte 0, 8, 12, 16, 19, 23, 27, 31
|
||||
.byte 0, 9, 12, 16, 20, 24, 27, 31
|
||||
.byte 0, 10, 13, 17, 20, 24, 27, 31
|
||||
.byte 0, 10, 14, 17, 21, 24, 28, 31
|
||||
.byte 0, 11, 15, 18, 21, 24, 28, 31
|
||||
.byte 0, 12, 15, 18, 22, 25, 28, 31
|
||||
.byte 0, 13, 16, 19, 22, 25, 28, 31
|
||||
.byte 0, 14, 17, 20, 22, 25, 28, 31 # 10
|
||||
.byte 0, 15, 17, 20, 23, 26, 28, 31
|
||||
.byte 0, 16, 18, 21, 23, 26, 28, 31
|
||||
.byte 0, 16, 19, 21, 24, 26, 29, 31
|
||||
.byte 0, 17, 20, 22, 24, 26, 29, 31
|
||||
.byte 0, 18, 20, 22, 25, 27, 29, 31
|
||||
.byte 0, 19, 21, 23, 25, 27, 29, 31 # 16
|
||||
|
||||
.text
|
||||
.align 4
|
||||
|
||||
# bbbb bggg gggr rrrr
|
||||
|
||||
.global do_pal_convert # dest, src, gammaa_val
|
||||
|
||||
do_pal_convert:
|
||||
bnez $a2, dpc_gma
|
||||
li $t0, 64/2
|
||||
lui $t2, 0x00e
|
||||
ori $t2, 0x00e
|
||||
lui $t3, 0x006
|
||||
ori $t3, 0x006
|
||||
lui $t4, 0x0e0
|
||||
ori $t4, 0x0e0
|
||||
lui $t6, 0xe00
|
||||
ori $t6, 0xe00
|
||||
lui $t7, 0x600
|
||||
ori $t7, 0x600
|
||||
|
||||
dpc_loop:
|
||||
lw $v0, 0($a1)
|
||||
addiu $a1, 4
|
||||
and $v1, $v0, $t2 # r
|
||||
sll $v1, 1
|
||||
and $t9, $v0, $t3
|
||||
srl $t9, 1
|
||||
or $v1, $t9 # r
|
||||
and $t9, $v0, $t4 # g
|
||||
sll $t8, $t9, 3
|
||||
or $v1, $t8
|
||||
or $v1, $t9 # g
|
||||
and $t9, $v0, $t6 # b
|
||||
sll $t9, 4
|
||||
or $v1, $t9
|
||||
and $t9, $v0, $t7
|
||||
sll $t9, 2
|
||||
or $v1, $t9 # b
|
||||
sw $v1, 0($a0)
|
||||
addiu $t0, -1
|
||||
bnez $t0, dpc_loop
|
||||
addiu $a0, 4
|
||||
|
||||
jr $ra
|
||||
nop
|
||||
|
||||
dpc_gma:
|
||||
sll $a2, 3
|
||||
lui $t1, %hi(gmtab)
|
||||
addiu $t1, %lo(gmtab)
|
||||
addu $a2, $t1
|
||||
|
||||
dpc_gma_loop:
|
||||
lw $v0, 0($a1)
|
||||
addiu $a1, 4
|
||||
ext $v1, $v0, 1, 3
|
||||
addu $v1, $a2
|
||||
lb $v1, 0($v1)
|
||||
ext $t1, $v0, 5, 3
|
||||
addu $t1, $a2
|
||||
lb $t1, 0($t1)
|
||||
ext $t2, $v0, 9, 3
|
||||
addu $t2, $a2
|
||||
lb $t2, 0($t2)
|
||||
ext $t3, $v0, 17, 3
|
||||
addu $t3, $a2
|
||||
lb $t3, 0($t3)
|
||||
ext $t4, $v0, 21, 3
|
||||
addu $t4, $a2
|
||||
lb $t4, 0($t4)
|
||||
ext $t5, $v0, 25, 3
|
||||
addu $t5, $a2
|
||||
lb $t5, 0($t5)
|
||||
ins $v1, $t1, 6, 5
|
||||
ins $v1, $t2, 11, 5
|
||||
ins $v1, $t3, 16, 5
|
||||
ins $v1, $t4, 22, 5
|
||||
ins $v1, $t5, 27, 5
|
||||
sw $v1, 0($a0)
|
||||
addiu $t0, -1
|
||||
bnez $t0, dpc_gma_loop
|
||||
addiu $a0, 4
|
||||
|
||||
jr $ra
|
||||
nop
|
||||
|
19
psp/emu.c
19
psp/emu.c
|
@ -17,6 +17,7 @@
|
|||
#include "menu.h"
|
||||
#include "emu.h"
|
||||
#include "mp3.h"
|
||||
#include "asm_utils.h"
|
||||
#include "../common/emu.h"
|
||||
#include "../common/lprintf.h"
|
||||
#include "../../Pico/PicoInt.h"
|
||||
|
@ -239,25 +240,25 @@ static void set_scaling_params(void)
|
|||
|
||||
static void do_pal_update(int allow_sh)
|
||||
{
|
||||
unsigned int *spal=(void *)Pico.cram;
|
||||
unsigned int *dpal=(void *)localPal;
|
||||
int i;
|
||||
|
||||
for (i = 0x3f/2; i >= 0; i--)
|
||||
dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4);
|
||||
//for (i = 0x3f/2; i >= 0; i--)
|
||||
// dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4);
|
||||
do_pal_convert(localPal, Pico.cram, currentConfig.gamma);
|
||||
|
||||
if (allow_sh && (Pico.video.reg[0xC]&8)) // shadow/hilight?
|
||||
{
|
||||
// shadowed pixels
|
||||
for (i = 0x3f/2; i >= 0; i--)
|
||||
dpal[0x20|i] = dpal[0x60|i] = (dpal[i]>>1)&0x738e738e;
|
||||
dpal[0x20|i] = dpal[0x60|i] = (dpal[i]>>1)&0x7bcf7bcf;
|
||||
// hilighted pixels
|
||||
for (i = 0x3f; i >= 0; i--) {
|
||||
int t=localPal[i]&0xe71c;t+=0x4208;
|
||||
if (t&0x20) t|=0x1c;
|
||||
if (t&0x800) t|=0x700;
|
||||
if (t&0x10000) t|=0xe000;
|
||||
t&=0xe71c;
|
||||
int t=localPal[i]&0xf79e;t+=0x4208;
|
||||
if (t&0x20) t|=0x1e;
|
||||
if (t&0x800) t|=0x780;
|
||||
if (t&0x10000) t|=0xf000;
|
||||
t&=0xf79e;
|
||||
localPal[0x80|i]=(unsigned short)t;
|
||||
}
|
||||
localPal[0xe0] = 0;
|
||||
|
|
17
psp/main.c
17
psp/main.c
|
@ -13,14 +13,11 @@
|
|||
#include "../common/lprintf.h"
|
||||
#include "version.h"
|
||||
|
||||
#define GPROF 0
|
||||
#define GCOV 0
|
||||
|
||||
#if GPROF
|
||||
#ifdef GPROF
|
||||
#include <pspprof.h>
|
||||
#endif
|
||||
|
||||
#if GCOV
|
||||
#ifdef GCOV
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -32,7 +29,7 @@ void dummy(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
int pico_main(void)
|
||||
{
|
||||
lprintf("\nPicoDrive v" VERSION " " __DATE__ " " __TIME__ "\n");
|
||||
psp_init();
|
||||
|
@ -49,7 +46,7 @@ int main()
|
|||
switch (engineState)
|
||||
{
|
||||
case PGS_Menu:
|
||||
#if !GPROF
|
||||
#ifndef GPROF
|
||||
menu_loop();
|
||||
#else
|
||||
strcpy(romFileName, currentConfig.lastRomFile);
|
||||
|
@ -73,7 +70,7 @@ int main()
|
|||
|
||||
case PGS_Running:
|
||||
emu_Loop();
|
||||
#if GPROF
|
||||
#ifdef GPROF
|
||||
goto endloop;
|
||||
#endif
|
||||
break;
|
||||
|
@ -91,10 +88,10 @@ int main()
|
|||
|
||||
mp3_deinit();
|
||||
emu_Deinit();
|
||||
#if GPROF
|
||||
#ifdef GPROF
|
||||
gprof_cleanup();
|
||||
#endif
|
||||
#if !GCOV
|
||||
#ifndef GCOV
|
||||
psp_finish();
|
||||
#endif
|
||||
|
||||
|
|
15
psp/menu.c
15
psp/menu.c
|
@ -1005,7 +1005,8 @@ menu_entry opt3_entries[] =
|
|||
{ NULL, MB_NONE, MA_OPT3_SCALE, NULL, 0, 0, 0, 1 },
|
||||
{ NULL, MB_NONE, MA_OPT3_HSCALE32, NULL, 0, 0, 0, 1 },
|
||||
{ NULL, MB_NONE, MA_OPT3_HSCALE40, NULL, 0, 0, 0, 1 },
|
||||
{ NULL, MB_ONOFF, MA_OPT3_FILTERING, ¤tConfig.scaling, 1, 0, 0, 1 },
|
||||
{ NULL, MB_ONOFF, MA_OPT3_FILTERING, ¤tConfig.scaling, 1, 0, 0, 1 },
|
||||
{ NULL, MB_RANGE, MA_OPT3_GAMMAA, ¤tConfig.gamma, 0, -4, 16, 1 },
|
||||
{ NULL, MB_NONE, MA_OPT3_VSYNC, NULL, 0, 0, 0, 1 },
|
||||
{ "Set to unscaled centered", MB_NONE, MA_OPT3_PRES_NOSCALE, NULL, 0, 0, 0, 1 },
|
||||
{ "Set to 4:3 scaled", MB_NONE, MA_OPT3_PRES_SCALE43, NULL, 0, 0, 0, 1 },
|
||||
|
@ -1032,6 +1033,9 @@ static void menu_opt3_cust_draw(const menu_entry *entry, int x, int y, void *par
|
|||
case MA_OPT3_FILTERING:
|
||||
text_out16(x, y, "Bilinear filtering %s", currentConfig.scaling?"ON":"OFF");
|
||||
break;
|
||||
case MA_OPT3_GAMMAA:
|
||||
text_out16(x, y, "Gamma adjustment %2i", currentConfig.gamma);
|
||||
break;
|
||||
case MA_OPT3_VSYNC: {
|
||||
char *val = " never";
|
||||
if (currentConfig.EmuOpt & 0x2000)
|
||||
|
@ -1112,10 +1116,11 @@ static void dispmenu_loop_options(void)
|
|||
int tmp;
|
||||
me_process(opt3_entries, OPT3_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0);
|
||||
switch (selected_id) {
|
||||
case MA_OPT3_SCALE: setting = ¤tConfig.scale; break;
|
||||
case MA_OPT3_HSCALE40: setting = ¤tConfig.hscale40; is_32col = 0; break;
|
||||
case MA_OPT3_HSCALE32: setting = ¤tConfig.hscale32; is_32col = 1; break;
|
||||
case MA_OPT3_FILTERING:menu_opt3_preview(is_32col); break;
|
||||
case MA_OPT3_SCALE: setting = ¤tConfig.scale; break;
|
||||
case MA_OPT3_HSCALE40: setting = ¤tConfig.hscale40; is_32col = 0; break;
|
||||
case MA_OPT3_HSCALE32: setting = ¤tConfig.hscale32; is_32col = 1; break;
|
||||
case MA_OPT3_FILTERING:
|
||||
case MA_OPT3_GAMMAA: menu_opt3_preview(is_32col); break;
|
||||
case MA_OPT3_VSYNC: tmp = ((currentConfig.EmuOpt>>13)&1) | ((currentConfig.EmuOpt>>15)&2);
|
||||
tmp = (inp & BTN_LEFT) ? (tmp>>1) : ((tmp<<1)|1);
|
||||
if (tmp > 3) tmp = 3;
|
||||
|
|
|
@ -165,7 +165,8 @@ int mp3_init(void)
|
|||
mod = load_start_module("flash0:/kd/audiocodec.prx");
|
||||
else mod = load_start_module("flash0:/kd/avcodec.prx");
|
||||
if (mod < 0) {
|
||||
ret = mod = load_start_module("flash0:/kd/audiocodec_260.prx"); // last chance..
|
||||
ret = mod;
|
||||
mod = load_start_module("flash0:/kd/audiocodec_260.prx"); // last chance..
|
||||
if (mod < 0) goto fail;
|
||||
}
|
||||
|
||||
|
@ -204,8 +205,9 @@ int mp3_init(void)
|
|||
goto fail2;
|
||||
}
|
||||
|
||||
/* use slightly higher prio then main */
|
||||
thread_exit = 0;
|
||||
thid = sceKernelCreateThread("mp3decode_thread", decode_thread, 30, 0x2000, 0, 0); /* use slightly higher prio then main */
|
||||
thid = sceKernelCreateThread("mp3decode_thread", decode_thread, 30, 0x2000, 0, NULL);
|
||||
if (thid < 0) {
|
||||
lprintf("failed to create decode thread: %08x\n", thid);
|
||||
ret = thid;
|
||||
|
|
35
psp/psp.c
35
psp/psp.c
|
@ -14,14 +14,43 @@
|
|||
#include <psppower.h>
|
||||
#include <psprtc.h>
|
||||
#include <pspgu.h>
|
||||
#include <pspsdk.h>
|
||||
|
||||
#include "psp.h"
|
||||
#include "emu.h"
|
||||
#include "../common/lprintf.h"
|
||||
|
||||
PSP_MODULE_INFO("PicoDrive", 0, 1, 34);
|
||||
extern int pico_main(void);
|
||||
|
||||
#ifndef FW15
|
||||
|
||||
PSP_MODULE_INFO("PicoDrive", 0, 1, 35);
|
||||
PSP_HEAP_SIZE_MAX();
|
||||
|
||||
int main() { return pico_main(); } /* just a wrapper */
|
||||
|
||||
#else
|
||||
|
||||
PSP_MODULE_INFO("PicoDrive", 0x1000, 1, 35);
|
||||
PSP_MAIN_THREAD_ATTR(0);
|
||||
|
||||
int main()
|
||||
{
|
||||
SceUID thid;
|
||||
|
||||
/* this is the thing we need the kernel mode for */
|
||||
pspSdkInstallNoDeviceCheckPatch();
|
||||
|
||||
thid = sceKernelCreateThread("pico_main", (SceKernelThreadEntry) pico_main, 32, 0x2000, PSP_THREAD_ATTR_USER, NULL);
|
||||
if (thid >= 0)
|
||||
sceKernelStartThread(thid, 0, 0);
|
||||
sceKernelExitDeleteThread(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
unsigned int __attribute__((aligned(16))) guCmdList[GU_CMDLIST_SIZE];
|
||||
|
||||
void *psp_screen = VRAM_FB0;
|
||||
|
@ -47,7 +76,7 @@ static int power_callback(int unknown, int pwrflags, void *common)
|
|||
lprintf("power_callback: flags: 0x%08X: suspending\n", pwrflags);
|
||||
engineState = PGS_Menu;
|
||||
}
|
||||
sceDisplayWaitVblankStart();
|
||||
//sceDisplayWaitVblankStart();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -79,7 +108,7 @@ void psp_init(void)
|
|||
lprintf("entered psp_init, threadId %08x, priority %i\n", main_thread_id,
|
||||
sceKernelGetThreadCurrentPriority());
|
||||
|
||||
thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, 0, 0);
|
||||
thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, 0, NULL);
|
||||
if (thid >= 0)
|
||||
{
|
||||
sceKernelStartThread(thid, 0, 0);
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define VERSION "1.35a"
|
||||
#define VERSION "1.35b"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue