}\r
\r
/* these will be managed locally on our side */\r
-extern int *ym2612_dacen;\r
-extern INT32 *ym2612_dacout;\r
static UINT8 *REGS = 0; /* we will also keep local copy of regs for savestates and such */\r
static INT32 *addr_A1; /* address line A1 */\r
\r
static int dacen;\r
static INT32 dacout;\r
static UINT8 ST_address; /* address register */\r
-static UINT8 ST_status; /* status flag */\r
-static UINT8 ST_mode; /* mode CSM / 3SLOT */\r
-static int ST_TA; /* timer a */\r
-static int ST_TAC; /* timer a maxval */\r
-static int ST_TAT; /* timer a ticker */\r
-static UINT8 ST_TB; /* timer b */\r
-static int ST_TBC; /* timer b maxval */\r
-static int ST_TBT; /* timer b ticker */\r
\r
static int writebuff_ptr = 0;\r
\r
/* b2 = timer enable a */\r
/* b1 = load b */\r
/* b0 = load a */\r
- change = (ST_mode ^ v) & 0xc0;\r
- ST_mode = v;\r
+ change = (ym2612_st->mode ^ v) & 0xc0;\r
+ ym2612_st->mode = v;\r
\r
/* reset Timer b flag */\r
if( v & 0x20 )\r
- ST_status &= ~2;\r
+ ym2612_st->status &= ~2;\r
\r
/* reset Timer a flag */\r
if( v & 0x10 )\r
- ST_status &= ~1;\r
+ ym2612_st->status &= ~1;\r
\r
return change;\r
}\r
switch( addr )\r
{\r
case 0x24: { // timer A High 8\r
- int TAnew = (ST_TA & 0x03)|(((int)v)<<2);\r
- if(ST_TA != TAnew) {\r
+ int TAnew = (ym2612_st->TA & 0x03)|(((int)v)<<2);\r
+ if (ym2612_st->TA != TAnew) {\r
// we should reset ticker only if new value is written. Outrun requires this.\r
- ST_TA = TAnew;\r
- ST_TAC = (1024-TAnew)*18;\r
- ST_TAT = 0;\r
+ ym2612_st->TA = TAnew;\r
+ ym2612_st->TAC = (1024-TAnew)*18;\r
+ ym2612_st->TAT = 0;\r
}\r
return 0;\r
}\r
case 0x25: { // timer A Low 2\r
- int TAnew = (ST_TA & 0x3fc)|(v&3);\r
- if(ST_TA != TAnew) {\r
- ST_TA = TAnew;\r
- ST_TAC = (1024-TAnew)*18;\r
- ST_TAT = 0;\r
+ int TAnew = (ym2612_st->TA & 0x3fc)|(v&3);\r
+ if (ym2612_st->TA != TAnew) {\r
+ ym2612_st->TA = TAnew;\r
+ ym2612_st->TAC = (1024-TAnew)*18;\r
+ ym2612_st->TAT = 0;\r
}\r
return 0;\r
}\r
case 0x26: // timer B\r
- if(ST_TB != v) {\r
- ST_TB = v;\r
- ST_TBC = (256-v)<<4;\r
- ST_TBC *= 18;\r
- ST_TBT = 0;\r
+ if (ym2612_st->TB != v) {\r
+ ym2612_st->TB = v;\r
+ ym2612_st->TBC = (256-v)<<4;\r
+ ym2612_st->TBC *= 18;\r
+ ym2612_st->TBT = 0;\r
}\r
return 0;\r
case 0x27: /* mode, timer control */\r
return 0; // cause the engine to do updates once per frame only\r
}\r
\r
-UINT8 YM2612Read_940(void)\r
-{\r
- return ST_status;\r
-}\r
-\r
-\r
-int YM2612PicoTick_940(int n)\r
-{\r
- //int ret = 0;\r
-\r
- // timer A\r
- if(ST_mode & 0x01 && (ST_TAT+=64*n) >= ST_TAC) {\r
- ST_TAT -= ST_TAC;\r
- if(ST_mode & 0x04) ST_status |= 1;\r
- // CSM mode total level latch and auto key on\r
-/* FIXME\r
- if(ST_mode & 0x80) {\r
- CSMKeyControll( &(ym2612_940->CH[2]) ); // Vectorman2, etc.\r
- ret = 1;\r
- }\r
-*/\r
- }\r
-\r
- // timer B\r
- if(ST_mode & 0x02 && (ST_TBT+=64*n) >= ST_TBC) {\r
- ST_TBT -= ST_TBC;\r
- if(ST_mode & 0x08) ST_status |= 2;\r
- }\r
-\r
- return 0;\r
-}\r
-\r
\r
#define CHECK_BUSY(job) \\r
(gp2x_memregs[0x3b46>>1] & (1<<(job-1)))\r
static void internal_reset(void)\r
{\r
writebuff_ptr = 0;\r
- ST_mode = 0;\r
- ST_status = 0; /* normal mode */\r
- ST_TA = 0;\r
- ST_TAC = 0;\r
- ST_TB = 0;\r
- ST_TBC = 0;\r
+ ym2612_st->mode = 0;\r
+ ym2612_st->status = 0; /* normal mode */\r
+ ym2612_st->TA = 0;\r
+ ym2612_st->TAC = 0;\r
+ ym2612_st->TAT = 0;\r
+ ym2612_st->TB = 0;\r
+ ym2612_st->TBC = 0;\r
+ ym2612_st->TBT = 0;\r
dacen = 0;\r
dacout = 0;\r
ST_address= 0;\r
all: PicoDrive.gpe\r
\r
PicoDrive.gpe : $(OBJS) ../common/helix/helix_mp3.a\r
- @echo $@\r
- @$(GCC) -o $@ $(COPT) $^ -lm -lpng -Wl,-Map=PicoDrive.map\r
+ @echo ">>>" $@\r
+ $(GCC) -o $@ $(COPT) $^ -lm -lpng -Wl,-Map=PicoDrive.map\r
ifeq ($(DEBUG),)\r
- @$(STRIP) $@\r
-endif\r
-# @$(GCC) $(COPT) $(OBJS) -lm -o PicoDrive_.gpe\r
-# @gpecomp PicoDrive_.gpe $@\r
-ifeq "$(up)" "1"\r
- @cmd //C copy $@ \\\\10.0.1.2\\gp2x\\mnt\\sd\\games\\PicoDrive\\\r
+ $(STRIP) $@\r
endif\r
\r
up: PicoDrive.gpe\r
# @cmd //C copy PicoDrive.gpe \\\\10.0.1.2\\gp2x\\mnt\\sd\\games\\PicoDrive\\\r
\r
\r
-testrefr.gpe : test.o gp2x.o\r
- @echo $@\r
- @$(GCC) $(COPT) $^ -o $@\r
- @$(STRIP) $@\r
-\r
.c.o:\r
- @echo $<\r
- @$(GCC) $(COPT) $(DEFINC) -c $< -o $@\r
+ @echo ">>>" $<\r
+ $(GCC) $(COPT) $(DEFINC) -c $< -o $@\r
.s.o:\r
- @echo $<\r
- @$(GCC) $(COPT) $(DEFINC) -c $< -o $@\r
+ @echo ">>>" $<\r
+ $(GCC) $(COPT) $(DEFINC) -c $< -o $@\r
\r
../../Pico/draw_asm.o : ../../Pico/Draw.s\r
- @echo $<\r
- @$(AS) $(ASOPT) $< -o $@\r
+ @echo ">>>" $<\r
+ $(AS) $(ASOPT) $< -o $@\r
../../Pico/draw2_asm.o : ../../Pico/Draw2.s\r
- @echo $<\r
- @$(AS) $(ASOPT) $< -o $@\r
+ @echo ">>>" $<\r
+ $(AS) $(ASOPT) $< -o $@\r
../../Pico/memory_asm.o : ../../Pico/Memory.s\r
- @echo $<\r
- @$(AS) $(ASOPT) $< -o $@\r
+ @echo ">>>" $<\r
+ $(AS) $(ASOPT) $< -o $@\r
../../Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s\r
- @echo $<\r
- @$(AS) $(ASOPT) $< -o $@\r
+ @echo ">>>" $<\r
+ $(AS) $(ASOPT) $< -o $@\r
../../Pico/sound/mix_asm.o : ../../Pico/sound/mix.s\r
- @echo $<\r
- @$(AS) $(ASOPT) $< -o $@\r
+ @echo ">>>" $<\r
+ $(AS) $(ASOPT) $< -o $@\r
../../Pico/misc_asm.o : ../../Pico/Misc.s\r
- @echo $<\r
- @$(AS) $(ASOPT) $< -o $@\r
+ @echo ">>>" $<\r
+ $(AS) $(ASOPT) $< -o $@\r
../../Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s\r
- @echo $<\r
- @$(AS) $(ASOPT) $< -o $@\r
+ @echo ">>>" $<\r
+ $(AS) $(ASOPT) $< -o $@\r
../../Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s\r
- @echo $<\r
- @$(AS) $(ASOPT) $< -o $@\r
+ @echo ">>>" $<\r
+ $(AS) $(ASOPT) $< -o $@\r
../../Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s\r
- @echo $<\r
- @$(AS) $(ASOPT) $< -o $@\r
+ @echo ">>>" $<\r
+ $(AS) $(ASOPT) $< -o $@\r
\r
# build Cyclone\r
../../cpu/Cyclone/proj/Cyclone.s :\r
-#define VERSION "1.34"\r
+#define VERSION "1.35"\r
\r
return 0; // cause the engine to do updates once per frame only
}
-UINT8 YM2612Read_940(void)
-{
- return YM2612Read_();
-}
-
-
-int YM2612PicoTick_940(int n)
-{
- YM2612PicoTick_(n);
-
- return 0;
-}
-
void YM2612PicoStateLoad_940(void)
{
AS = gcc
ifeq "$(profile)" "1"
-COPT_COMMON = -s -O3 -ftracer -fstrength-reduce -Wall -funroll-loops -fomit-frame-pointer -fstrict-aliasing -ffast-math -fprofile-generate # -static
-COPT = $(COPT_COMMON) # -mtune=arm920t
+COPT_COMMON = -s -O3 -ftracer -fstrength-reduce -Wall -funroll-loops -fomit-frame-pointer -fstrict-aliasing -ffast-math -fprofile-generate
+COPT = $(COPT_COMMON)
else
COPT = -ggdb -Wall -fno-strict-aliasing # -pg -O3 -ftracer -fstrength-reduce -funroll-loops -fomit-frame-pointer -ffast-math
COPT_COMMON = $(COPT)
#use_musashi = 1\r
#use_mz80 = 1\r
amalgamate = 0\r
-#profile = 1\r
-#up = 1\r
\r
\r
CFLAGS += -I../.. -I. -DNO_SYNC -DLPRINTF_STDIO\r
CFLAGS += -Wall -Winline -G0\r
+CFLAGS += -DLPRINTF_STDIO\r
+#CFLAGS += -fprofile-generate\r
+#CFLAGS += -fprofile-use\r
+#CFLAGS += -pg\r
ifeq ($(DEBUG),)\r
CFLAGS += -O2 -ftracer -fstrength-reduce -ffast-math\r
else\r
CFLAGS += -ggdb\r
endif\r
-ifeq "$(profile)" "1"\r
-CFLAGS += -fprofile-generate\r
-endif\r
-ifeq "$(profile)" "2"\r
-CFLAGS += -fprofile-use\r
-endif\r
\r
\r
# frontend\r
else\r
OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Memory.o ../../Pico/Misc.o \\r
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \\r
- ../../Pico/Patch.o ../../Pico/Draw_amips.o ../../Pico/Memory_amips.o\r
+ ../../Pico/Patch.o ../../Pico/Draw_amips.o ../../Pico/Memory_amips.o ../../Pico/Misc_amips.o\r
# Pico - CD\r
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \\r
../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \\r
\r
\r
LIBS += -lpng -lm -lpspgu -lpsppower -lpspaudio -lpsprtc -lpspaudiocodec\r
+#LIBS += -lpspprof\r
LDFLAGS += -Wl,-Map=PicoDrive.map\r
\r
+\r
# target\r
TARGET = PicoDrive\r
EXTRA_TARGETS = EBOOT.PBP\r
\r
../../Pico/Draw.o : ../../Pico/Draw.c\r
@echo ">>>" $<\r
- $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_DRAW_C_MIPS\r
+ $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_DRAW_C_AMIPS\r
+\r
+../../Pico/Misc.o : ../../Pico/Misc.c\r
+ @echo ">>>" $<\r
+ $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_MISC_C_AMIPS\r
\r
readme.txt: ../../tools/textfilter ../base_readme.txt\r
../../tools/textfilter ../base_readme.txt $@ PSP\r
\r
# ?\r
rel: EBOOT.PBP readme.txt\r
- zip -9 -j ../../PicoDrive_$(VER).zip $^\r
-# zip -9 -r ../../PicoDrive_$(VER).zip skin -i \*.png -i \*.txt\r
+ zip -9 -r ../../PicoDrive_$(VER).zip skin -i \*.png -i \*.txt\r
\r
#include "psp.h"
#include "menu.h"
#include "emu.h"
+#include "mp3.h"
#include "../common/emu.h"
#include "../common/lprintf.h"
#include "../../Pico/PicoInt.h"
for (h = 0; h < 8; h++) {
p = (int *) (screen+x+512*(264+h));
p = (int *) ((int)p & ~3); // align
- memset32(p, 0, len);
+ memset32_uncached(p, 0, len);
}
if (is_active) { tmp = psp_screen; psp_screen = screen; } // nasty pointer tricks
emu_textOut16(x, 264, text);
{
memset(¤tConfig, 0, sizeof(currentConfig));
currentConfig.lastRomFile[0] = 0;
- currentConfig.EmuOpt = 0x1f | 0x680; // | confirm_save, cd_leds, 16bit rend
- currentConfig.PicoOpt = 0x0f | 0xc00; // | cd_pcm, cd_cdda
+ currentConfig.EmuOpt = 0x1d | 0x680; // | confirm_save, cd_leds, acc rend
+ currentConfig.PicoOpt = 0x0f | 0x1c00; // | gfx_cd, cd_pcm, cd_cdda
currentConfig.PsndRate = 22050;
currentConfig.PicoRegion = 0; // auto
currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP
static void set_scaling_params(void)
{
- int src_width, fbimg_width, fbimg_height, fbimg_xoffs, fbimg_yoffs;
+ int src_width, fbimg_width, fbimg_height, fbimg_xoffs, fbimg_yoffs, border_hack = 0;
g_vertices[0].x = g_vertices[0].y =
g_vertices[0].z = g_vertices[1].z = 0;
src_width = 256;
}
+ if (fbimg_width & 1) fbimg_width++; // make even
+ if (fbimg_height & 1) fbimg_height++;
+
if (fbimg_width >= 480) {
g_vertices[0].u = (fbimg_width-480)/2;
- g_vertices[1].u = src_width - (fbimg_width-480)/2;
+ g_vertices[1].u = src_width - (fbimg_width-480)/2 - 1;
+ if (fbimg_width == 480) border_hack = 1;
fbimg_width = 480;
fbimg_xoffs = 0;
} else {
g_vertices[1].y = fbimg_height;
if (fbimg_xoffs < 0) fbimg_xoffs = 0;
if (fbimg_yoffs < 0) fbimg_yoffs = 0;
+ if (border_hack) {
+ g_vertices[0].u++;
+ g_vertices[0].x++;
+ g_vertices[1].u--;
+ g_vertices[1].x--;
+ }
fbimg_offs = (fbimg_yoffs*512 + fbimg_xoffs) * 2; // dst is always 16bit
/*
*p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r;
}
-
+#if 0
static void dbg_text(void)
{
int *p, h, len;
for (h = 0; h < 8; h++) {
p = (int *) ((unsigned short *) psp_screen+2+512*(256+h));
p = (int *) ((int)p & ~3); // align
- memset32(p, 0, len);
+ memset32_uncached(p, 0, len);
}
emu_textOut16(2, 256, text);
}
-
+#endif
/* called after rendering is done, but frame emulation is not finished */
void blit1(void)
if (emu_opt & 2) osd_text(OSD_FPS_X, fps, 0, 0);
}
- dbg_text();
+ //dbg_text();
if ((emu_opt & 0x400) && (PicoMCD & 1))
cd_leds();
static void clearArea(int full)
{
if (full) {
- memset32(psp_screen, 0, 512*272*2/4);
+ memset32_uncached(psp_screen, 0, 512*272*2/4);
psp_video_flip(0);
- memset32(psp_screen, 0, 512*272*2/4);
+ memset32_uncached(psp_screen, 0, 512*272*2/4);
memset32(VRAM_CACHED_STUFF, 0xe0e0e0e0, 512*240/4);
memset32((int *)VRAM_CACHED_STUFF+512*240/4, 0, 512*240*2/4);
} else {
void *fb = psp_video_get_active_fb();
- memset32((int *)((char *)psp_screen + 512*264*2), 0, 512*8*2/4);
- memset32((int *)((char *)fb + 512*264*2), 0, 512*8*2/4);
+ memset32_uncached((int *)((char *)psp_screen + 512*264*2), 0, 512*8*2/4);
+ memset32_uncached((int *)((char *)fb + 512*264*2), 0, 512*8*2/4);
}
}
vidResetMode();
memset32(VRAM_CACHED_STUFF, 0xe0e0e0e0, 512*8/4); // borders
memset32((int *)VRAM_CACHED_STUFF + 512*232/4, 0xe0e0e0e0, 512*8/4);
- memset32((int *)psp_screen + 512*264*2/4, 0, 512*8*2/4);
+ memset32_uncached((int *)psp_screen + 512*264*2/4, 0, 512*8*2/4);
PicoDrawSetColorFormat(-1);
PicoScan = EmuScanSlow;
}
// clear fps counters and stuff
- memset32((int *)psp_video_get_active_fb() + 512*264*2/4, 0, 512*8*2/4);
+ memset32_uncached((int *)psp_video_get_active_fb() + 512*264*2/4, 0, 512*8*2/4);
}
void emu_msg_cb(const char *msg);
+// actually comes from Pico/Misc_amips.s
+void memset32_uncached(int *dest, int c, int count);
psp_video_switch_to_single();
if (rom_data) menu_draw_begin();
- else memset32(psp_screen, 0, 512*272*2/4);
+ else memset32_uncached(psp_screen, 0, 512*272*2/4);
smalltext_out16(1, 1, "Loading", 0xffff);
smalltext_out16_lim(1, 10, p, 0xffff, 80);
static void debug_menu_loop(void)
{
+ int ret = 0;
draw_debug();
- wait_for_input(BTN_X|BTN_CIRCLE, 0);
+ while (!(ret & (BTN_X|BTN_CIRCLE)))
+ ret = wait_for_input(BTN_X|BTN_CIRCLE, 0);
}
// ------------ patch/gg menu ------------
lprintf("uncompress returned %i\n", ret);
}
- memset32(psp_screen, 0, 512*272*2/4);
+ memset32_uncached(psp_screen, 0, 512*272*2/4);
emu_forcedFrame();
menu_prepare_bg(1, 0);
if (setting != NULL) {
while ((inp = psp_pad_read(0)) & (BTN_LEFT|BTN_RIGHT)) {
*setting += (inp & BTN_LEFT) ? -0.01 : 0.01;
+ if (*setting <= 0) *setting = 0.01;
menu_opt3_preview(is_32col);
draw_dispmenu_options(menu_sel); // will wait vsync
}
int i;
for (i = 272; i > 0; i--, dst += 480, src += 512)
menu_darken_bg(dst, src, 480, 1);
- //memset32((int *)(bg_buffer + 480*264), 0, 480*8*2/4);
+ //memset32_uncached((int *)(bg_buffer + 480*264), 0, 480*8*2/4);
}
else
{
// should really only happen once, on startup..
- memset32((int *)(void *)bg_buffer, 0, sizeof(bg_buffer)/4);
+ memset32_uncached((int *)(void *)bg_buffer, 0, sizeof(bg_buffer)/4);
readpng(bg_buffer, "skin/background.png", READPNG_BG);
}
sceKernelDcacheWritebackAll();
for (;;)
{
draw_menu_tray(menu_sel);
- inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_X, 0);
+ inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_CIRCLE, 0);
if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if(inp & BTN_CIRCLE) {
goto fail2;
}
- lprintf("thread_busy_sem: %08x, thread_job_sem: %08x\n", thread_busy_sem, thread_job_sem);
-
thread_exit = 0;
thid = sceKernelCreateThread("mp3decode_thread", decode_thread, 30, 0x2000, 0, 0); /* use slightly higher prio then main */
if (thid < 0) {
int mp3_get_bitrate(FILE *f, int size)
{
- int ret = -1, sample_rate, bitrate;
+ int ret, retval = -1, sample_rate, bitrate;
// filenames are stored instead handles in PSP, due to stupid max open file limit
char *fname = (char *)f;
}
/* looking good.. */
- ret = bitrate;
+ retval = bitrate;
end:
if (mp3_handle >= 0) sceIoClose(mp3_handle);
mp3_handle = -1;
mp3_fname = NULL;
psp_sem_unlock(thread_busy_sem);
- if (ret < 0) mp3_last_error = -1; // remember we had a problem..
- return ret;
+ if (retval < 0) mp3_last_error = -1; // remember we had a problem..
+ return retval;
}
--- /dev/null
+
+// additional stuff for PSP mp3 decoder implementation
+extern int mp3_last_error;
+
+int mp3_init(void);
+void mp3_deinit(void);
+
+
#include <pspgu.h>
#include "psp.h"
+#include "emu.h"
#include "../common/lprintf.h"
PSP_MODULE_INFO("PicoDrive", 0, 1, 34);
return 0;
}
+/* Power Callback */
+static int power_callback(int unknown, int pwrflags, void *common)
+{
+ /* check for power switch and suspending as one is manual and the other automatic */
+ if (pwrflags & PSP_POWER_CB_POWER_SWITCH || pwrflags & PSP_POWER_CB_SUSPENDING)
+ {
+ lprintf("power_callback: flags: 0x%08X: suspending\n", pwrflags);
+ engineState = PGS_Menu;
+ }
+ sceDisplayWaitVblankStart();
+ return 0;
+}
+
/* Callback thread */
static int callback_thread(SceSize args, void *argp)
{
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
+ cbid = sceKernelCreateCallback("Power Callback", power_callback, NULL);
+ scePowerRegisterCallback(0, cbid);
sceKernelSleepThreadCB();
-#define VERSION "1.34"\r
+#define VERSION "1.35"\r
\r