#include "940shared.h"\r
\r
-/* this code assumes that we live @ 0x3000000 bank */\r
-//static volatile unsigned short *gp2x_memregs = (void *) 0x0xbd000000;\r
-//static volatile unsigned long *gp2x_memregl = (void *) 0x0xbd000000;\r
-\r
static _940_data_t *shared_data = (_940_data_t *) 0x100000;\r
static _940_ctl_t *shared_ctl = (_940_ctl_t *) 0x200000;\r
YM2612 *ym2612_940;\r
shared_ctl->vstarts[startvector]++;\r
asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0");\r
\r
- /* unmask IRQs */\r
\r
for (;; shared_ctl->loopc++)\r
{\r
+ int job_num;\r
/*\r
while (!shared_ctl->busy)\r
{\r
wait_irq();\r
}\r
\r
- switch (shared_ctl->job)\r
+ for (job_num = 0; job_num < MAX_940JOBS; job_num++)\r
{\r
- case JOB940_YM2612INIT:\r
- shared_ctl->writebuff0[0] = shared_ctl->writebuff1[0] = 0xffff;\r
- YM2612Init_(shared_ctl->baseclock, shared_ctl->rate);\r
- break;\r
+ switch (shared_ctl->jobs[job_num])\r
+ {\r
+ case JOB940_YM2612INIT:\r
+ shared_ctl->writebuff0[0] = shared_ctl->writebuff1[0] = 0xffff;\r
+ YM2612Init_(shared_ctl->baseclock, shared_ctl->rate);\r
+ break;\r
\r
- case JOB940_YM2612RESETCHIP:\r
- YM2612ResetChip_();\r
- break;\r
+ case JOB940_YM2612RESETCHIP:\r
+ YM2612ResetChip_();\r
+ break;\r
\r
- case JOB940_PICOSTATELOAD:\r
- YM2612PicoStateLoad_();\r
- break;\r
+ case JOB940_PICOSTATELOAD:\r
+ YM2612PicoStateLoad_();\r
+ break;\r
\r
- case JOB940_YM2612UPDATEONE: {\r
- int i, dw, *wbuff;\r
- if (shared_ctl->writebuffsel == 1) {\r
- wbuff = (int *) shared_ctl->writebuff1;\r
- } else {\r
- wbuff = (int *) shared_ctl->writebuff0;\r
- }\r
+ case JOB940_YM2612UPDATEONE: {\r
+ int i, dw, *wbuff;\r
+ if (shared_ctl->writebuffsel == 1) {\r
+ wbuff = (int *) shared_ctl->writebuff1;\r
+ } else {\r
+ wbuff = (int *) shared_ctl->writebuff0;\r
+ }\r
\r
- /* playback all writes */\r
- for (i = 2048/2; i > 0; i--) {\r
- UINT16 d;\r
- dw = *wbuff++;\r
- d = dw;\r
- if (d == 0xffff) break;\r
- YM2612Write_(d >> 8, d);\r
- d = (dw>>16);\r
- if (d == 0xffff) break;\r
- YM2612Write_(d >> 8, d);\r
- }\r
+ /* playback all writes */\r
+ for (i = 2048/2; i > 0; i--) {\r
+ UINT16 d;\r
+ dw = *wbuff++;\r
+ d = dw;\r
+ if (d == 0xffff) break;\r
+ YM2612Write_(d >> 8, d);\r
+ d = (dw>>16);\r
+ if (d == 0xffff) break;\r
+ YM2612Write_(d >> 8, d);\r
+ }\r
\r
- YM2612UpdateOne_(0, shared_ctl->length, shared_ctl->stereo);\r
-// cache_clean_flush();\r
- cache_clean();\r
-// asm volatile ("mov r0, #0" ::: "r0");\r
-// asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0"); /* drain write buffer, should be done on nonbuffered write */\r
- break;\r
+ YM2612UpdateOne_(0, shared_ctl->length, shared_ctl->stereo);\r
+ break;\r
+ }\r
}\r
}\r
\r
shared_ctl->busy = 0;\r
+// cache_clean_flush();\r
+ cache_clean();\r
+// asm volatile ("mov r0, #0" ::: "r0");\r
+// asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0"); /* drain write buffer, should be done on nonbuffered write */\r
}\r
}\r
+\r
}\r
\r
\r
-static void add_job_940(int job)\r
+static void add_job_940(int job0, int job1)\r
{\r
- shared_ctl->job = job;\r
+ shared_ctl->jobs[0] = job0;\r
+ shared_ctl->jobs[1] = job1;\r
shared_ctl->busy = 1;\r
gp2x_memregs[0x3B3E>>1] = 0xffff; // cause an IRQ for 940\r
}\r
\r
addr_A1 = old_A1;\r
\r
- add_job_940(JOB940_PICOSTATELOAD);\r
+ add_job_940(JOB940_PICOSTATELOAD, 0);\r
}\r
\r
\r
void YM2612Init_940(int baseclock, int rate)\r
{\r
printf("YM2612Init_940()\n");\r
- //printf("sizeof(*shared_data): %i (%x)\n", sizeof(*shared_data), sizeof(*shared_data));\r
- //printf("sizeof(*shared_ctl): %i (%x)\n", sizeof(*shared_ctl), sizeof(*shared_ctl));\r
+ printf("Mem usage: shared_data: %i, shared_ctl: %i\n", sizeof(*shared_data), sizeof(*shared_ctl));\r
\r
- Reset940(1);\r
+ Reset940(1, 2);\r
Pause940(1);\r
\r
gp2x_memregs[0x3B46>>1] = 0xffff; // clear pending DUALCPU interrupts for 940\r
\r
if (shared_mem == NULL)\r
{\r
- shared_mem = (unsigned char *) mmap(0, 0x210000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x3000000);\r
+ shared_mem = (unsigned char *) mmap(0, 0x210000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x2000000);\r
if(shared_mem == MAP_FAILED)\r
{\r
printf("mmap(shared_data) failed with %i\n", errno);\r
/* now cause 940 to init it's ym2612 stuff */\r
shared_ctl->baseclock = baseclock;\r
shared_ctl->rate = rate;\r
- shared_ctl->job = JOB940_YM2612INIT;\r
+ shared_ctl->jobs[0] = JOB940_YM2612INIT;\r
+ shared_ctl->jobs[1] = 0;\r
shared_ctl->busy = 1;\r
\r
/* start the 940 */\r
- Reset940(0);\r
+ Reset940(0, 2);\r
Pause940(0);\r
\r
// YM2612ResetChip_940(); // will be done on JOB940_YM2612INIT\r
\r
internal_reset();\r
\r
- add_job_940(JOB940_YM2612RESETCHIP);\r
+ add_job_940(JOB940_YM2612RESETCHIP, 0);\r
}\r
\r
\r
shared_ctl->writebuffsel ^= 1;\r
shared_ctl->length = length;\r
shared_ctl->stereo = stereo;\r
- add_job_940(JOB940_YM2612UPDATEONE);\r
+ add_job_940(JOB940_YM2612UPDATEONE, 0);\r
//spend_cycles(512);\r
//printf("SRCPND: %08lx, INTMODE: %08lx, INTMASK: %08lx, INTPEND: %08lx\n",\r
// gp2x_memregl[0x4500>>2], gp2x_memregl[0x4504>>2], gp2x_memregl[0x4508>>2], gp2x_memregl[0x4510>>2]);\r
b .Begin\r
.b_irq:\r
mov r12, #6\r
- mov sp, #0x100000 @ reset stack\r
- sub sp, sp, #4\r
- mov r1, #0xbd000000 @ assume we live @ 0x3000000 bank\r
+ mov sp, #0x100000 @ reset stack\r
+ sub sp, sp, #4\r
+ mov r1, #0xbe000000 @ assume we live @ 0x2000000 bank\r
orr r2, r1, #0x3B00\r
orr r2, r2, #0x0046\r
mvn r3, #0\r
b .Begin\r
\r
.Begin:\r
- mov sp, #0x100000 @ set the stack top (1M)\r
- sub sp, sp, #4 @ minus 4\r
+ mov sp, #0x100000 @ set the stack top (1M)\r
+ sub sp, sp, #4 @ minus 4\r
\r
- @ set up memory region 0 -- the whole 4GB address space\r
- mov r0, #(0x1f<<1)|1 @ region data\r
- mcr p15, 0, r0, c6, c0, 0 @ opcode2 ~ data/instr\r
- mcr p15, 0, r0, c6, c0, 1\r
+ @ set up memory region 0 -- the whole 4GB address space\r
+ mov r0, #(0x1f<<1)|1 @ region data\r
+ mcr p15, 0, r0, c6, c0, 0 @ opcode2 ~ data/instr\r
+ mcr p15, 0, r0, c6, c0, 1\r
\r
@ set up region 1 which is the first 2 megabytes.\r
- mov r0, #(0x14<<1)|1 @ region data\r
- mcr p15, 0, r0, c6, c1, 0\r
- mcr p15, 0, r0, c6, c1, 1\r
+ mov r0, #(0x14<<1)|1 @ region data\r
+ mcr p15, 0, r0, c6, c1, 0\r
+ mcr p15, 0, r0, c6, c1, 1\r
\r
@ set up region 2: 64k 0x200000-0x210000\r
- mov r0, #(0x0f<<1)|1\r
+ mov r0, #(0x0f<<1)|1\r
orr r0, r0, #0x200000\r
- mcr p15, 0, r0, c6, c2, 0\r
- mcr p15, 0, r0, c6, c2, 1\r
+ mcr p15, 0, r0, c6, c2, 0\r
+ mcr p15, 0, r0, c6, c2, 1\r
\r
- @ set up region 3: 64k 0xbd000000-0xbd010000 (hw control registers)\r
- mov r0, #(0x0f<<1)|1\r
- orr r0, r0, #0xbd000000\r
- mcr p15, 0, r0, c6, c3, 0\r
- mcr p15, 0, r0, c6, c3, 1\r
+ @ set up region 3: 64k 0xbe000000-0xbe010000 (hw control registers)\r
+ mov r0, #(0x0f<<1)|1\r
+ orr r0, r0, #0xbe000000\r
+ mcr p15, 0, r0, c6, c3, 0\r
+ mcr p15, 0, r0, c6, c3, 1\r
\r
@ set region 1 to be cacheable (so the first 2M will be cacheable)\r
- mov r0, #2\r
- mcr p15, 0, r0, c2, c0, 0\r
- mcr p15, 0, r0, c2, c0, 1\r
+ mov r0, #2\r
+ mcr p15, 0, r0, c2, c0, 0\r
+ mcr p15, 0, r0, c2, c0, 1\r
\r
@ set region 1 to be bufferable too (only data)\r
- mcr p15, 0, r0, c3, c0, 0\r
+ mcr p15, 0, r0, c3, c0, 0\r
\r
@ set protection, allow accsess only to regions 1 and 2\r
- mov r0, #(3<<6)|(3<<4)|(3<<2)|(0) @ data: [full, full, full, no access] for regions [3 2 1 0]\r
- mcr p15, 0, r0, c5, c0, 0\r
- mov r0, #(0<<6)|(0<<4)|(3<<2)|(0) @ instructions: [no access, no, full, no]\r
- mcr p15, 0, r0, c5, c0, 1\r
-\r
- mrc p15, 0, r0, c1, c0, 0 @ fetch current control reg\r
- orr r0, r0, #1 @ 0x00000001: enable protection unit\r
- orr r0, r0, #4 @ 0x00000004: enable D cache\r
- orr r0, r0, #0x1000 @ 0x00001000: enable I cache\r
- orr r0, r0, #0xC0000000 @ 0xC0000000: async+fastbus\r
- mcr p15, 0, r0, c1, c0, 0 @ set control reg\r
+ mov r0, #(3<<6)|(3<<4)|(3<<2)|(0) @ data: [full, full, full, no access] for regions [3 2 1 0]\r
+ mcr p15, 0, r0, c5, c0, 0\r
+ mov r0, #(0<<6)|(0<<4)|(3<<2)|(0) @ instructions: [no access, no, full, no]\r
+ mcr p15, 0, r0, c5, c0, 1\r
+\r
+ mrc p15, 0, r0, c1, c0, 0 @ fetch current control reg\r
+ orr r0, r0, #1 @ 0x00000001: enable protection unit\r
+ orr r0, r0, #4 @ 0x00000004: enable D cache\r
+ orr r0, r0, #0x1000 @ 0x00001000: enable I cache\r
+ orr r0, r0, #0xC0000000 @ 0xC0000000: async+fastbus\r
+ mcr p15, 0, r0, c1, c0, 0 @ set control reg\r
\r
@ flush (invalidate) the cache (just in case)\r
mov r0, #0\r
b .b_reserved\r
\r
.pool\r
+\r
+@ vim:filetype=ignored:\r
JOB940_NUMJOBS\r
};\r
\r
+#define MAX_940JOBS 2\r
\r
typedef struct\r
{\r
YM2612 ym2612; /* current state of the emulated YM2612 */\r
- int mix_buffer[44100/50*2]; /* this is where the YM2612 samples will be mixed to */\r
+ int mix_buffer[44100/50*2]; /* this is where the YM2612 samples will be mixed to */\r
+ short mp3_buffer[2][1152*2]; /* buffer for mp3 decoder's output */\r
} _940_data_t;\r
\r
\r
typedef struct\r
{\r
- int job; /* a job for second core */\r
+ int jobs[MAX_940JOBS]; /* jobs for second core */\r
int busy; /* busy status of the 940 core */\r
int length; /* number of samples to mix (882 max) */\r
int stereo; /* mix samples as stereo, doubles sample count automatically */\r
int baseclock; /* ym2612 settings */\r
int rate;\r
int writebuffsel; /* which write buffer to use (from 940 side) */\r
- UINT16 writebuff0[2048]; /* 1024 for savestates, 1024 extra */\r
+ UINT16 writebuff0[2048]; /* list of writes to ym2612, 1024 for savestates, 1024 extra */\r
UINT16 writebuff1[2048];\r
int vstarts[8]; /* debug: number of starts from each of 8 vectors */\r
int loopc; /* debug: main loop counter */\r
dprint = 1\r
#mz80 = 1\r
#debug_cyclone = 1\r
-asm_memory = 1\r
+asm_memory = 0 # TODO\r
asm_render = 1\r
asm_ym2612 = 1\r
#profile = 1\r
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.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\r
+ ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o\r
# asm stuff\r
ifeq "$(asm_render)" "1"\r
DEFINC += -D_ASM_DRAW_C\r
}\r
}\r
gettimeofday(¬iceMsgTime, 0);\r
-\r
+printf("PicoMCD: %x\n", PicoMCD);\r
// load SRAM for this ROM\r
if(currentConfig.EmuOpt & 1)\r
emu_SaveLoadGame(1, 1);\r
\r
static void cd_leds(void)\r
{\r
- static int old_reg = 0;\r
- if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change\r
+ // mmu problems?\r
+// static\r
+ int old_reg;\r
+// if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change\r
old_reg = Pico_mcd->s68k_regs[0];\r
\r
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
if(PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old || crashed_940) {\r
/* if 940 is turned off, we need it to be put back to sleep */\r
if (!(PicoOpt&0x200) && ((PicoOpt^PicoOpt_old)&0x200)) {\r
- Reset940(1);\r
+ Reset940(1, 2);\r
Pause940(1);\r
}\r
sound_rerate();\r
}\r
\r
\r
-void Reset940(int yes)\r
+void Reset940(int yes, int bank)\r
{\r
- gp2x_memregs[0x3B48>>1] = ((yes&1) << 7) | (0x03); /* bank=3 */\r
+ gp2x_memregs[0x3B48>>1] = ((yes&1) << 7) | (bank & 0x03); /* bank=3 */\r
}\r
\r
\r
\r
void gp2x_deinit(void)\r
{\r
- Reset940(1);\r
+ Reset940(1, 3);\r
Pause940(1);\r
\r
gp2x_video_changemode(15);\r
\r
/* 940 core */\r
void Pause940(int yes);\r
-void Reset940(int yes);\r
+void Reset940(int yes, int bank);\r
\r
\r
extern void *gp2x_screen;\r
mmuhack_status = ret;\r
}\r
cpuctrl_init();\r
- Reset940(1);\r
- Pause940(1);\r
+ // Reset940(1);\r
+ // Pause940(1);\r
if (currentConfig.EmuOpt&0x100) {\r
printf("setting RAM timings.. "); fflush(stdout);\r
// craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2\r
\r
case PGS_Quit:\r
goto endloop;\r
- \r
+\r
default:\r
printf("engine got into unknown state (%i), exitting\n", engineState);\r
goto endloop;\r
} else {\r
y += 30;\r
}\r
- gp2x_text_out8(tl_x, (y+=10), "Load new ROM");\r
+ gp2x_text_out8(tl_x, (y+=10), "Load new ROM/ISO");\r
gp2x_text_out8(tl_x, (y+=10), "Change options");\r
gp2x_text_out8(tl_x, (y+=10), "Configure controls");\r
gp2x_text_out8(tl_x, (y+=10), "Credits");\r
// pico.c\r
#define CAN_HANDLE_240_LINES 1\r
\r
-//#define dprintf(f,...) printf(f"\n",##__VA_ARGS__)\r
+//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)\r
#define dprintf(x...)\r
\r
#endif //PORT_CONFIG_H\r
-#define VERSION "0.965"\r
+#define VERSION "1.10"\r
\r
{
}
-void Reset940(int yes)
+void Reset940(int yes, int bank)
{
}