\r
Changelog\r
---------\r
+1.35b\r
+ * PSP: mp3 code should no longer fail on 1.5 firmware.\r
+ + PSP: added gamma adjustment option.\r
+ * Fixed a sram bug in memhandlers (fixes Shining in the Darkness saves).\r
+ * PSP: fixed another bug in memhanlers, which crashed the emu for some games\r
+ (like NBA Jam).\r
+\r
1.35a\r
* PSP: fixed a bug which prevented to load any ROMs after testing the BIOS.\r
* PSP: fixed incorrect CZ80 memory map setup, which caused Z80 crashes and\r
//scaling_update();\r
// some sanity checks\r
if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 4096) currentConfig.CPUclock = 200;\r
+#ifdef PSP\r
+ if (currentConfig.gamma < -4 || currentConfig.gamma > 16) currentConfig.gamma = 0;\r
+#else\r
if (currentConfig.gamma < 10 || currentConfig.gamma > 300) currentConfig.gamma = 100;\r
+#endif\r
if (currentConfig.volume < 0 || currentConfig.volume > 99) currentConfig.volume = 50;\r
#ifdef __GP2X__\r
// if volume keys are unbound, bind them to volume control\r
MA_OPT3_PRES_FULLSCR,
MA_OPT3_FILTERING,
MA_OPT3_VSYNC,
+ MA_OPT3_GAMMAA,
MA_OPT3_DONE,
MA_CDOPT_TESTBIOS_USA,
MA_CDOPT_TESTBIOS_EUR,
LDFLAGS += `pkg-config --libs gthread-2.0`
# frontend
-OBJS += ../gp2x/main.o ../gp2x/menu.o ../gp2x/emu.o ../gp2x/usbjoy.o blit.o \
+OBJS += platform/gp2x/main.o platform/gp2x/menu.o platform/gp2x/emu.o platform/gp2x/usbjoy.o blit.o \
gp2x.o 940ctl_ym2612.o log_io.o
# common
-OBJS += ../common/emu.o ../common/menu.o ../common/fonts.o ../common/readpng.o ../common/mp3_helix.o
+OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o \
+ platform/common/readpng.o platform/common/mp3_helix.o
# Pico
-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
+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 - 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 \
- ../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/pcm.o ../../Pico/cd/buffering.o
+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 \
+ Pico/cd/Area.o Pico/cd/Misc.o Pico/cd/pcm.o Pico/cd/buffering.o
# Pico - sound
-OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o ../../Pico/sound/mix.o
+OBJS += Pico/sound/sound.o Pico/sound/sn76496.o Pico/sound/ym2612.o Pico/sound/mix.o
# zlib
-OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \
- ../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o
+OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \
+ zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o
# unzip
-OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o
+OBJS += unzip/unzip.o unzip/unzip_stream.o
# CPU cores
ifeq "$(use_musashi)" "1"
DEFINC += -DEMU_M68K
-OBJS += ../../cpu/musashi/m68kops.o ../../cpu/musashi/m68kcpu.o
+OBJS += cpu/musashi/m68kops.o cpu/musashi/m68kcpu.o
endif
ifeq "$(use_fame)" "1"
DEFINC += -DEMU_F68K
-OBJS += ../../cpu/fame/famec.o
+OBJS += cpu/fame/famec.o
endif
# z80
ifeq "$(use_mz80)" "1"
DEFINC += -D_USE_MZ80
-OBJS += ../../cpu/mz80/mz80.o
+OBJS += cpu/mz80/mz80.o
else
DEFINC += -D_USE_CZ80
-OBJS += ../../cpu/cz80/cz80.o
+OBJS += cpu/cz80/cz80.o
endif
# misc
ifeq "$(use_fame)" "1"
ifeq "$(use_musashi)" "1"
-OBJS += ../../Pico/Debug.o
-OBJS += ../../cpu/musashi/m68kdasm.o
+OBJS += Pico/Debug.o
+OBJS += cpu/musashi/m68kdasm.o
endif
endif
+vpath %.c = ../..
+DIRS = platform platform/gp2x platform/common Pico Pico/cd Pico/sound zlib unzip \
+ cpu cpu/musashi cpu/fame cpu/mz80 cpu/cz80
-all: PicoDrive
+all: mkdirs PicoDrive
clean: tidy
@$(RM) PicoDrive
tidy:
- @$(RM) $(OBJS)
+ $(RM) $(OBJS)
+ rm -rf $(DIRS)
@make -C ../../cpu/mz80/ clean
@make -C ../common/helix/ X86=1 clean
@echo ">>>" $@
$(GCC) $(COPT) $^ $(LDFLAGS) -lm -lpng -Wl,-Map=PicoDrive.map -o $@
+mkdirs:
+ mkdir -p $(DIRS)
../../cpu/musashi/m68kops.c :
@make -C ../../cpu/musashi
-../../cpu/mz80/mz80.o : ../../cpu/mz80/mz80.asm
+cpu/mz80/mz80.o : ../../cpu/mz80/mz80.asm
@echo $@
@nasm -f elf $< -o $@
$(GCC) $(COPT) $(DEFINC) -c $< -o $@
-../../Pico/sound/ym2612.o : ../../Pico/sound/ym2612.c
+Pico/sound/ym2612.o : ../../Pico/sound/ym2612.c
@echo ">>>" $@
$(GCC) $(COPT_COMMON) $(DEFINC) -c $< -o $@
-../../cpu/fame/famec.o : ../../cpu/fame/famec.c ../../cpu/fame/famec_opcodes.h
+cpu/fame/famec.o : ../../cpu/fame/famec.c ../../cpu/fame/famec_opcodes.h
@echo ">>>" $<
$(GCC) $(COPT) $(DEFINC) -Wno-unused -c $< -o $@
#use_musashi = 1\r
#use_mz80 = 1\r
amalgamate = 0\r
+for_15fw = 1\r
\r
\r
CFLAGS += -I../.. -I. -DNO_SYNC\r
else\r
CFLAGS += -ggdb\r
endif\r
+ifeq "$(for_15fw)" "1"\r
+CFLAGS += -DFW15\r
+endif\r
\r
\r
-# frontend\r
-OBJS += main.o emu.o mp3.o menu.o psp.o\r
+# frontend and stuff\r
+OBJS += main.o emu.o mp3.o menu.o psp.o asm_utils.o\r
\r
# common\r
OBJS += ../common/emu.o ../common/menu.o ../common/fonts.o ../common/readpng.o\r
PSP_EBOOT_TITLE = PicoDrive\r
PSP_EBOOT_ICON = data/icon.png\r
#PSP_EBOOT_PIC1 = .png\r
+ifneq "$(for_15fw)" "1"\r
BUILD_PRX = 1\r
+endif\r
\r
CUSTOM_CLEAN = myclean\r
\r
--- /dev/null
+// pointers must be word aligned
+void do_pal_convert(unsigned short *dest, unsigned short *src, int gammaa_val);
--- /dev/null
+# 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
+
#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"
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;
#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>
}
#endif
-int main()
+int pico_main(void)
{
lprintf("\nPicoDrive v" VERSION " " __DATE__ " " __TIME__ "\n");
psp_init();
switch (engineState)
{
case PGS_Menu:
-#if !GPROF
+#ifndef GPROF
menu_loop();
#else
strcpy(romFileName, currentConfig.lastRomFile);
case PGS_Running:
emu_Loop();
-#if GPROF
+#ifdef GPROF
goto endloop;
#endif
break;
mp3_deinit();
emu_Deinit();
-#if GPROF
+#ifdef GPROF
gprof_cleanup();
#endif
-#if !GCOV
+#ifndef GCOV
psp_finish();
#endif
{ 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 },
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)
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;
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;
}
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;
#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;
lprintf("power_callback: flags: 0x%08X: suspending\n", pwrflags);
engineState = PGS_Menu;
}
- sceDisplayWaitVblankStart();
+ //sceDisplayWaitVblankStart();
return 0;
}
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);
-#define VERSION "1.35a"\r
+#define VERSION "1.35b"\r
\r