// This is part of Pico Library\r
\r
// (c) Copyright 2004 Dave, All rights reserved.\r
-// (c) Copyright 2006 notaz, All rights reserved.\r
+// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
@ assembly "optimized" version of some funtions from draw.c\r
@ this is highly specialized, be careful if changing related C code!\r
\r
-@ (c) Copyright 2006, notaz\r
+@ (c) Copyright 2007, Grazvydas "notaz" Ignotas\r
@ All Rights Reserved\r
\r
\r
// This is part of Pico Library\r
\r
-// (c) Copyright 2006 notaz, All rights reserved.\r
+// (c) Copyright 2007, Grazvydas "notaz" Ignotas\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
@ assembly optimized versions of most funtions from draw2.c\r
@ this is highly specialized, be careful if changing related C code!\r
\r
-@ (c) Copyright 2006, notaz\r
+@ (c) Copyright 2007, Grazvydas "notaz" Ignotas\r
@ All Rights Reserved\r
\r
\r
@ memory handlers with banking support for SSF II - The New Challengers\r
@ mostly based on Gens code\r
\r
-@ (c) Copyright 2006, notaz\r
+@ (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas\r
@ All Rights Reserved\r
\r
\r
-/* common code for Memory.c and cd/Memory.c */
+// common code for Memory.c and cd/Memory.c
+// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas
static int PadRead(int i)
{
\r
if (PicoMCD & 1) {\r
PicoResetMCD(hard);\r
- SRam.data = 0;\r
return 0;\r
}\r
\r
// Pico Library - Header File\r
\r
// (c) Copyright 2004 Dave, All rights reserved.\r
-// (c) Copyright 2006 notaz, All rights reserved.\r
+// (c) Copyright 2006-2007 notaz, All rights reserved.\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
// PicoOpt bits LSb->MSb:\r
// enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound,\r
// alt_renderer, 6button_gamepad, accurate_timing, accurate_sprites,\r
-// draw_no_32col_border, external_ym2612, enable_pcm, enable cdda\r
-// enable_cdgfx, cd_perfect_sync, soft_32col_scaling\r
+// draw_no_32col_border, external_ym2612, enable_cd_pcm, enable_cd_cdda\r
+// enable_cd_gfx, cd_perfect_sync, soft_32col_scaling, enable_cd_ramcart\r
extern int PicoOpt;\r
extern int PicoVer;\r
extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff\r
// Pico Library - Header File\r
\r
// (c) Copyright 2004 Dave, All rights reserved.\r
-// (c) Copyright 2006 notaz, All rights reserved.\r
+// (c) Copyright 2006,2007 Grazvydas "notaz" Ignotas, all rights reserved.\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
unsigned int counter75hz;\r
unsigned short audio_offset; // 0c: for savestates: play pointer offset (0-1023)\r
unsigned char audio_track; // playing audio track # (zero based)\r
- char pad1;\r
+ char pad1;\r
int timer_int3; // 10\r
unsigned int timer_stopwatch;\r
- int pad[10];\r
+ unsigned char bcram_reg; // 18: battery-backed RAM cart register\r
+ unsigned char pad2;\r
+ unsigned short pad3;\r
+ int pad[9];\r
};\r
\r
typedef struct\r
void SRAMUpdPending(unsigned int a, unsigned int d);\r
void memcpy16(unsigned short *dest, unsigned short *src, int count);\r
void memcpy16bswap(unsigned short *dest, void *src, int count);\r
-void memcpy32(int *dest, int *src, int count);\r
+void memcpy32(int *dest, int *src, int count); // 32bit word count\r
void memset32(int *dest, int c, int count);\r
\r
// cd/Misc.c\r
// This is part of Pico Library\r
\r
// (c) Copyright 2004 Dave, All rights reserved.\r
-// (c) Copyright 2006 notaz, All rights reserved.\r
+// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
-// This is part of Pico Library
-
-// (c) Copyright 2007 notaz, All rights reserved.
-// Free for non-commercial use.
-
-// For commercial use, separate licencing terms must be obtained.
+// Savestate handling for emulated Sega/Mega CD machine.
+// (c) Copyright 2007, Grazvydas "notaz" Ignotas
#include "../PicoInt.h"
/***********************************************************\r
* *\r
- * This source is taken from the Gens project *\r
+ * This source was taken from the Gens project *\r
* Written by Stéphane Dallongeville *\r
* Copyright (c) 2002 by Stéphane Dallongeville *\r
- * Modified/adapted for Picodrive by notaz, 2007 *\r
+ * Modified/adapted for PicoDrive by notaz, 2007 *\r
* *\r
***********************************************************/\r
\r
+/***********************************************************\r
+ * *\r
+ * This source was taken from the Gens project *\r
+ * Written by Stéphane Dallongeville *\r
+ * Copyright (c) 2002 by Stéphane Dallongeville *\r
+ * Modified/adapted for PicoDrive by notaz, 2007 *\r
+ * *\r
+ ***********************************************************/\r
+\r
#ifndef _LC89510_H\r
#define _LC89510_H\r
\r
-// This is part of Pico Library\r
-\r
-// (c) Copyright 2004 Dave, All rights reserved.\r
-// (c) Copyright 2007 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
+// Memory I/O handlers for Sega/Mega CD.\r
+// Loosely based on Gens code.\r
+// (c) Copyright 2007, Grazvydas "notaz" Ignotas\r
\r
// A68K no longer supported here\r
\r
Pico_mcd->s68k_regs[0xe] = d >> 8;\r
#ifdef USE_POLL_DETECT\r
if ((s68k_poll_adclk&0xfe) == 0xe && s68k_poll_cnt > POLL_LIMIT) {\r
- SekSetStopS68k(0); s68k_poll_adclk = -1;\r
+ SekSetStopS68k(0); s68k_poll_adclk = 0;\r
plprintf("s68k poll release, a=%02x\n", a);\r
}\r
#endif\r
@ vim:filetype=armasm
-@ Memory i/o handlers for Sega/Mega CD emulation
+@ Memory I/O handlers for Sega/Mega CD emulation
@ (c) Copyright 2007, Grazvydas "notaz" Ignotas
-@ All Rights Reserved
.long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ 0x280000 - 0x2fffff
.long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ 0x300000
.long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ - 0x3fffff
- .long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ 0x400000
+ .long m_m68k_&\on&\sz&_bcram_size @ 0x400000
+ .long m_&\on&_null, m_&\on&_null, m_&\on&_null @ 0x420000
.long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ - 0x4fffff
.long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ 0x500000
.long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ - 0x5fffff
- .long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ 0x600000
+ .long m_m68k_&\on&\sz&_bcram @ 0x600000
+ .long m_&\on&_null, m_&\on&_null, m_&\on&_null @ 0x620000
.long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ - 0x6fffff
.long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ 0x700000
- .long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ - 0x7fffff
+ .long m_&\on&_null, m_&\on&_null, m_&\on&_null @ - 0x7dffff
+ .long m_m68k_&\on&\sz&_bcram_reg @ 0x7e0000
.long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ 0x800000
.long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ - 0x8fffff
.long m_&\on&_null, m_&\on&_null, m_&\on&_null, m_&\on&_null @ 0x900000
streq r1, [r2, r0]
.endm
+@
+.macro bcram_reg_rw is_read addr_check
+ rsb r0, r0, #0x800000
+ ldr r2, =(Pico+0x22200)
+ cmp r0, #(0x800000-\addr_check)
+ ldreq r2, [r2]
+.if \is_read
+ movne r0, #0
+.endif
+ bxne lr
+ add r2, r2, #0x110000
+ add r2, r2, #0x002200
+.if \is_read
+ ldrb r0, [r2, #0x18]
+.else
+ strb r1, [r2, #0x18]
+.endif
+ bx lr
+.endm
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bx lr
+m_m68k_read8_bcram_size: @ 0x400000
+ sub r0, r0, #1
+ cmp r0, #0x400000
+ ldreq r1, =SRam
+ mov r0, #0
+ ldreq r1, [r1]
+ bxne lr
+ tst r1, r1
+ movne r0, #3 @ pretend to be a 64k cart (8<<3)
+ bx lr
+
+
+m_m68k_read8_bcram: @ 0x600000 - 0x61ffff
+ ldr r1, =SRam
+ bic r0, r0, #0xfe0000
+ ldr r1, [r1]
+ mov r0, r0, lsr #1
+ tst r1, r1
+ moveq r0, #0
+ bxeq lr
+ add r1, r1, #0x2000
+ ldrb r0, [r1, r0]
+ bx lr
+
+
+m_m68k_read8_bcram_reg: @ 0x7fffff
+ bcram_reg_rw 1, 0x7fffff
+
+
m_m68k_read8_system_io:
bic r2, r0, #0xfe0000
bic r2, r2, #0x3f
bx lr
+m_m68k_read16_bcram_size: @ 0x400000
+ cmp r0, #0x400000
+ ldreq r1, =SRam
+ mov r0, #0
+ ldreq r1, [r1]
+ bxne lr
+ tst r1, r1
+ movne r0, #3 @ pretend to be a 64k cart
+ bx lr
+
+
+@ m_m68k_read16_bcram: @ 0x600000 - 0x61ffff
+.equiv m_m68k_read16_bcram, m_m68k_read8_bcram
+
+
+m_m68k_read16_bcram_reg: @ 0x7fffff
+ bcram_reg_rw 1, 0x7ffffe
+
+
m_m68k_read16_system_io:
bic r1, r0, #0xfe0000
bic r1, r1, #0x3f
bx r12
+m_m68k_read32_bcram_size: @ 0x400000
+ cmp r0, #0x400000
+ ldreq r1, =SRam
+ mov r0, #0
+ ldreq r1, [r1]
+ bxne lr
+ tst r1, r1
+ movne r0, #0x30000 @ pretend to be a 64k cart
+ bx lr
+
+
+m_m68k_read32_bcram: @ 0x600000 - 0x61ffff, not likely to be called
+ mov r12,lr
+ add r3, r0, #2
+ bl m_m68k_read8_bcram
+ mov r1, r0
+ mov r0, r3
+ mov r3, r1
+ bl m_m68k_read8_bcram
+ orr r0, r0, r3, lsl #16
+ bx r12
+
+
+m_m68k_read32_bcram_reg: @ 0x7fffff
+ bcram_reg_rw 1, 0x7ffffc
+
+
@ it is not very practical to use long access on hw registers, so I assume it is not used too much.
m_m68k_read32_system_io:
bic r1, r0, #0xfe0000
m_write_null:
m_m68k_write8_bios:
+m_m68k_write8_bcram_size: @ 0x400000
bx lr
bx lr
+m_m68k_write8_bcram: @ 0x600000 - 0x61ffff
+ @ can't use r3 or r12, because of write32
+ ldr r2, =SRam
+ bic r0, r0, #0xfe0000
+ ldr r2, [r2]
+ tst r2, r2
+ bxeq lr
+ add r0, r2, r0, lsr #1
+ ldr r2, =(Pico+0x22200)
+ ldr r2, [r2]
+ add r0, r0, #0x2000
+ add r2, r2, #0x110000
+ add r2, r2, #0x002200
+ ldr r2, [r2, #0x18]
+ tst r2, #1 @ check bcram reg
+ bxeq lr
+ strb r1, [r0]
+ ldr r2, =SRam
+ mov r0, #1
+ strb r0, [r2, #0x0e] @ SRam.changed = 1
+ bx lr
+
+
+m_m68k_write8_bcram_reg: @ 0x7fffff
+ bcram_reg_rw 0, 0x7fffff
+
+
m_m68k_write8_system_io:
bic r2, r0, #0xfe0000
bic r2, r2, #0x3f
m_m68k_write16_bios:
+m_m68k_write16_bcram_size: @ 0x400000
bx lr
bx lr
+@ m_m68k_write16_bcram: @ 0x600000 - 0x61ffff
+.equiv m_m68k_write16_bcram, m_m68k_write8_bcram
+
+
+m_m68k_write16_bcram_reg: @ 0x7fffff
+ bcram_reg_rw 0, 0x7ffffe
+
+
m_m68k_write16_system_io:
bic r0, r0, #1
bic r2, r0, #0xfe0000
cmp r2, #0x012000
bne OtherWrite16
-m_m68k_write16_m68k_regs:
+m_m68k_write16_regs:
and r0, r0, #0x3e
cmp r0, #0x0e
beq m_m68k_write16_regs_spec
m_m68k_write32_bios:
+m_m68k_write32_bcram_size: @ 0x400000
bx lr
b m_m68k_write16_wordram1_1M_b1
+m_m68k_write32_bcram: @ 0x600000 - 0x61ffff, not likely to be called
+ mov r12,lr
+ add r3, r0, #2
+ mov r1, r1, ror #16
+ bl m_m68k_write8_bcram
+ mov r0, r3
+ mov r1, r1, ror #16
+ bl m_m68k_write8_bcram
+ bx r12
+
+
+m_m68k_write32_bcram_reg: @ 0x7fffff
+ bcram_reg_rw 0, 0x7ffffc
+
+
+
@ it is not very practical to use long access on hw registers, so I assume it is not used too much.
m_m68k_write32_system_io:
bic r2, r0, #0xfe0000
cmp r2, #0x012000
bne m_m68k_write32_misc
and r2, r0, #0x3e
- cmp r2, #0x10
- blt m_m68k_write32_regs
cmp r2, #0x20
bxge lr
- @ Handle the 0x10-0x1f range
- ldr r0, =(Pico+0x22200)
- mov r3, #0xff
- ldr r0, [r0]
- orr r3, r3, r3, lsl #16
- add r0, r0, #0x110000
- and r12,r3, r1, ror #16 @ data is big-endian to be written as little, have to byteswap
- and r1, r3, r1, ror #24
- orr r1, r1, r12,lsl #8 @ end of byteswap
- strh r1, [r2, r0]!
- cmp r2, #0x1e
- movne r1, r1, lsr #16
- strneh r1, [r2, #2]
- bx lr
+ cmp r2, #0x10
+ bge m_m68k_write32_regs_comm
+ cmp r2, #0x0c
+ bge m_m68k_write32_regs_spec @ hits the nasty comm reg qiurk
-m_m68k_write32_regs:
bic r0, r0, #1
stmfd sp!,{r0,r1,lr}
mov r1, r1, lsr #24
add r0, r0, #3
b m68k_reg_write8
+m_m68k_write32_regs_comm: @ Handle the 0x10-0x1f range
+ ldr r0, =(Pico+0x22200)
+ mov r3, #0xff
+ ldr r0, [r0]
+ orr r3, r3, r3, lsl #16
+ add r0, r0, #0x110000
+ and r12,r3, r1, ror #16 @ data is big-endian to be written as little, have to byteswap
+ and r1, r3, r1, ror #24
+ orr r1, r1, r12,lsl #8 @ end of byteswap
+ cmp r2, #0x1e
+ strh r1, [r2, r0]!
+ ldr r3, =s68k_poll_adclk
+ ldr r0, [r3]
+ movne r1, r1, lsr #16
+ strneh r1, [r2, #2]
+ cmp r0, #0x10
+ bxlt lr
+ ldr r0, =PicoCpuS68k @ remove poll detected state for s68k
+ mov r1, #0
+ str r1, [r0, #0x58]
+ str r1, [r3]
+ bx lr
+
m_m68k_write32_misc:
bic r0, r0, #1
stmfd sp!,{r0,r1,lr}
add r0, r0, #2
b OtherWrite16
+m_m68k_write32_regs_spec:
+ bic r0, r0, #1
+ stmfd sp!,{r0,r1,lr}
+ mov r1, r1, lsr #16
+ bl m_m68k_write16_regs
+ ldmfd sp!,{r0,r1,lr}
+ add r0, r0, #2
+ b m_m68k_write16_regs
+
m_m68k_write32_vdp:
tst r0, #0x70000
m_s68k_write32_pcm_reg:
mov r0, r0, lsr #1
- add r2, r0, #1
- mov r3, r1
- stmfd sp!,{r2,r3,lr}
+ stmfd sp!,{r0,r1,lr}
mov r1, r1, lsr #16
bl pcm_write
ldmfd sp!,{r0,r1,lr}
+ add r0, r0, #1
b pcm_write
bic r0, r0, #0x008000
bic r0, r0, #1
tst r0, #0x7e00
- movne r0, #0
bxne lr
sub r2, r0, #0x58
cmp r2, #0x10
blo m_s68k_write32_regs_gfx
+ and r2, r0, #0x1fc
+ cmp r2, #0x0c
+ beq m_s68k_write32_regs_spec @ hits 0x0f
+ and r2, r0, #0x1f0
+ cmp r2, #0x20
+ beq m_s68k_write32_regs_comm
stmfd sp!,{r0,r1,lr}
mov r1, r1, lsr #24
b s68k_reg_write8
m_s68k_write32_regs_gfx:
- mov r3, r1
- add r2, r0, #2
- stmfd sp!,{r2,r3,lr}
+ stmfd sp!,{r0,r1,lr}
mov r1, r1, lsr #16
bl gfx_cd_write16
ldmfd sp!,{r0,r1,lr}
+ add r0, r0, #2
b gfx_cd_write16
+m_s68k_write32_regs_comm: @ Handle the 0x20-0x2f range
+ ldr r2, =(Pico+0x22200)
+ mov r3, #0xff
+ ldr r2, [r2]
+ orr r3, r3, r3, lsl #16
+ add r2, r2, #0x110000
+ and r12,r3, r1, ror #16 @ data is big-endian to be written as little, have to byteswap
+ and r1, r3, r1, ror #24
+ orr r1, r1, r12,lsl #8 @ end of byteswap
+ cmp r0, #0x2e
+ strh r1, [r0, r2]!
+ movne r1, r1, lsr #16
+ strneh r1, [r0, #2]
+ bx lr
+
+m_s68k_write32_regs_spec:
+ stmfd sp!,{r0,r1,lr}
+ mov r1, r1, lsr #16
+ bl m_s68k_write16_regs
+ ldmfd sp!,{r0,r1,lr}
+ add r0, r0, #2
+ b m_s68k_write16_regs
+
+
+// Some misc stuff
+// (c) Copyright 2007, Grazvydas "notaz" Ignotas
unsigned char formatted_bram[4*0x10] =
// 128K | bit ] | bank0 |
// 256K | unused | bank1 |
+#ifndef _ASM_MISC_C
void wram_2M_to_1M(unsigned char *m)
{
unsigned short *m1M_b0, *m1M_b1;
*m2M++ = tmp;
}
}
+#endif
-// This is part of Pico Library
-
-// (c) Copyright 2004 Dave, All rights reserved.
// (c) Copyright 2007 notaz, All rights reserved.
-// Free for non-commercial use.
-
-// For commercial use, separate licencing terms must be obtained.
#include "../PicoInt.h"
//PicoMemResetCDdecode(1); // don't have to call this in 2M mode
#endif
+ // use SRam.data for RAM cart
+ if (SRam.data) free(SRam.data);
+ SRam.data = NULL;
+ if (PicoOpt&0x8000)
+ SRam.data = calloc(1, 0x12000);
+
return 0;
}
-// This is part of Pico Library
-
-// (c) Copyright 2004 Dave, All rights reserved.
// (c) Copyright 2006 notaz, All rights reserved.
-// Free for non-commercial use.
-
-// For commercial use, separate licencing terms must be obtained.
#include "../PicoInt.h"
+// Buffering handling
+// (c) Copyright 2007, Grazvydas "notaz" Ignotas
+
#include "../PicoInt.h"
//#include <stdlib.h>
+/***********************************************************
+ * *
+ * This source was taken from the Gens project *
+ * Written by Stéphane Dallongeville *
+ * Copyright (c) 2002 by Stéphane Dallongeville *
+ * Modified/adapted for PicoDrive by notaz, 2007 *
+ * *
+ ***********************************************************/
+
#include <sys/stat.h>
#include "cd_file.h"
+/***********************************************************\r
+ * *\r
+ * This source was taken from the Gens project *\r
+ * Written by Stéphane Dallongeville *\r
+ * Copyright (c) 2002 by Stéphane Dallongeville *\r
+ * Modified/adapted for PicoDrive by notaz, 2007 *\r
+ * *\r
+ ***********************************************************/\r
+\r
#include <stdio.h>\r
#include "cd_sys.h"\r
#include "cd_file.h"\r
#define PLAYING 0x0100 // PLAYING audio track CDD status\r
\r
\r
-/*\r
-int CDDA_Enable;\r
-\r
-int CD_Audio_Buffer_L[8192];\r
-int CD_Audio_Buffer_R[8192];\r
-int CD_Audio_Buffer_Read_Pos = 0;\r
-int CD_Audio_Buffer_Write_Pos = 2000;\r
-int CD_Audio_Starting;\r
-*/\r
-\r
static int CD_Present = 0;\r
-// int CD_Timer_Counter = 0; // TODO: check refs\r
-\r
\r
\r
#define CHECK_TRAY_OPEN \\r
}\r
\r
\r
-#if 0\r
-static void MSB2DWORD(unsigned int *d, unsigned char *b)\r
-{\r
- unsigned int retVal;\r
-\r
- retVal = (unsigned int )b[0];\r
- retVal = (retVal<<8) + (unsigned int )b[1];\r
- retVal = (retVal<<8) + (unsigned int )b[2];\r
- retVal = (retVal<<8) + (unsigned int )b[3];\r
-\r
- *d = retVal;\r
-}\r
-#endif\r
-\r
static int MSF_to_LBA(_msf *MSF)\r
{\r
return (MSF->M * 60 * 75) + (MSF->S * 75) + MSF->F - 150;\r
+/***********************************************************\r
+ * *\r
+ * This source was taken from the Gens project *\r
+ * Written by Stéphane Dallongeville *\r
+ * Copyright (c) 2002 by Stéphane Dallongeville *\r
+ * Modified/adapted for PicoDrive by notaz, 2007 *\r
+ * *\r
+ ***********************************************************/\r
+\r
#ifndef _CD_SYS_H\r
#define _CD_SYS_H\r
\r
+// Convert "cell arrange" address to normal address.
+// (c) Copyright 2007, Grazvydas "notaz" Ignotas
// 64 x32 x16 x8 x4 x4
static unsigned int cell_map(int celln)
+// This is a direct rewrite of gfx_cd.asm (x86 asm to C).
+// You can even find some x86 register names :)
+// Original code (c) 2002 by Stéphane Dallongeville
+
+// (c) Copyright 2007, Grazvydas "notaz" Ignotas
+
#include "../PicoInt.h"
--- /dev/null
+@ vim:filetype=armasm
+
+@ Memory converters for different modes
+@ (c) Copyright 2007, Grazvydas "notaz" Ignotas
+
+
+@ r10 is tmp, io1 is lsb halfword, io2 is msb
+@ | 0 1 | 2 3 | -> | 0 2 | 1 3 | (little endian)
+.macro _conv_reg io1 io2
+ mov r10, \io2, lsl #16
+ and \io2, \io2, r11, lsl #16
+ orr \io2, \io2, \io1, lsr #16
+ and \io1, \io1, r11
+ orr \io1, \io1, r10
+/*
+ mov \io2, \io2, ror #16
+ mov r10, \io1, lsl #16
+ orr r10, r10, \io2, lsr #16
+ mov \io1, \io1, lsr #16
+ orr \io1, \io1, \io2, lsl #16
+ mov \io2, r10, ror #16
+*/
+.endm
+
+
+.global wram_2M_to_1M
+wram_2M_to_1M:
+ stmfd sp!,{r4-r11,lr}
+ add r1, r0, #0x60000 @ m1M_b1
+ add r0, r0, #0x40000 @ m1M_b0
+ mov r2, r0 @ m2M
+
+ mov r11, #0xff
+ orr r11, r11, r11, lsl #8
+ mov r12, #(0x40000/8/4)
+
+_2Mto1M_loop:
+ ldmdb r2!,{r3-r9,lr}
+ _conv_reg r3,r4
+ _conv_reg r5,r6
+ _conv_reg r7,r8
+ _conv_reg r9,lr
+ subs r12, r12, #1
+ stmdb r0!,{r3,r5,r7,r9}
+ stmdb r1!,{r4,r6,r8,lr}
+ bne _2Mto1M_loop
+
+ ldmfd sp!,{r4-r11,pc}
+
+
+
+.global wram_1M_to_2M
+wram_1M_to_2M:
+ stmfd sp!,{r4-r11,lr}
+ mov r2, r0 @ m2M
+ add r1, r0, #0x40000 @ m1M_b1
+ add r0, r0, #0x20000 @ m1M_b0
+
+ mov r11, #0xff
+ orr r11, r11, r11, lsl #8
+ mov r12, #(0x40000/8/4)
+
+_1Mto2M_loop:
+ ldmia r0!,{r3,r5,r7,r9}
+ ldmia r1!,{r4,r6,r8,lr}
+ _conv_reg r3,r4
+ _conv_reg r5,r6
+ _conv_reg r7,r8
+ _conv_reg r9,lr
+ subs r12, r12, #1
+ stmia r2!,{r3-r9,lr}
+ bne _1Mto2M_loop
+
+ ldmfd sp!,{r4-r11,pc}
+
+
+// Emulation routines for the RF5C164 PCM chip.
+// Based on Gens code by Stéphane Dallongeville
+// (c) Copyright 2007, Grazvydas "notaz" Ignotas
+
#include "../PicoInt.h"
#include "pcm.h"
-
@ vim:filetype=armasm
+@ Generic memory routines.
+@ (c) Copyright 2007, Grazvydas "notaz" Ignotas
+
.global memcpy16 @ unsigned short *dest, unsigned short *src, int count
@ vim:filetype=armasm
+@ Generic routines for mixing audio samples
+@ (c) Copyright 2007, Grazvydas "notaz" Ignotas
+
@ this assumes src is word aligned
.global mix_16h_to_32 @ int *dest, short *src, int count
+// Code for communication with ARM940 and control of it.\r
+// (c) Copyright 2007, Grazvydas "notaz" Ignotas\r
+\r
#include <stdio.h>\r
#include <stdlib.h>\r
#include <string.h>\r
gp2x_memregs[0x3b46>>1], gp2x_memregl[0x4500>>2], gp2x_memregl[0x4510>>2]);\r
printf("last lr: %08x, lastjob: %i\n", shared_ctl->last_lr, shared_ctl->lastjob);\r
\r
- strcpy(menuErrorMsg, "940 crashed.");\r
+ strcpy(menuErrorMsg, "940 crashed, too much overclock?");\r
engineState = PGS_Menu;\r
crashed_940 = 1;\r
}\r
ifeq "$(asm_misc)" "1"\r
DEFINC += -D_ASM_MISC_C\r
OBJS += ../../Pico/misc_asm.o\r
+OBJS += ../../Pico/cd/misc_asm.o\r
endif\r
ifeq "$(asm_cdpico)" "1"\r
DEFINC += -D_ASM_CD_PICO_C\r
../../Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s\r
@echo $<\r
@$(AS) $(ASOPT) $< -o $@\r
+../../Pico/cd/misc_asm.o : ../../Pico/cd/misc.s\r
+ @echo $<\r
+ @$(AS) $(ASOPT) $< -o $@\r
\r
# build Cyclone\r
../../cpu/Cyclone/proj/Cyclone.s :\r
--- /dev/null
+[About]\r
+This is yet another Megadrive / Genesis / Sega CD / Mega CD emulator, which was written having ARM-based handheld devices in mind (such as PDAs, smartphones and handheld consoles like GP2X of course). The critical parts (renderer, 68K and Z80 cpu interpreters) and some other random code is written in ARM asm, other code is C. The base code originates from Dave's (fdave, finalburn) PicoDrive 0.30 for Pocket PC. The Sega/Mega CD code is roughly based on Stephane Dallongeville's Gens.\r
+\r
+\r
+For help / comments / questions visit GP32X boards at:\r
+http://www.gp32x.com/board/\r
+\r
+\r
+[How to make it run]\r
+Copy PicoDrive.gpe, code940.bin and mmuhack.o to any place in your filesystem (all 3 files must be in the same directory) and run PicoDrive.gpe. Then load a ROM and enjoy! ROMs can be in .smd or .bin format and can be zipped.\r
+\r
+If you have any problems (game does not boot, sound is glitchy, broken graphics), make sure you enable "Accurate timing", "Emulate Z80" and use "16bit accurate renderer". This way you will get the best compatibility this emulator can provide.\r
+\r
+\r
+[How to run Sega/Mega CD games]\r
+To play any game, you need BIOS files. These files must be copied to the same directory as PicoDrive.gpe. Files can be named as follows:\r
+US: us_scd1_9210.bin us_scd2_9306.bin SegaCDBIOS9303.bin\r
+EU: eu_mcd1_9210.bin eu_mcd2_9303.bin eu_mcd2_9306.bin\r
+JP: jp_mcd1_9112.bin jp_mcd1_9111.bin\r
+these files can also be zipped.\r
+\r
+The game must be dumped to ISO format, but BIN can be used too. If you want CD music, you must use ISO+mp3 files. Audio from BIN files won't be read at all due to SD access issues. Also BIN files are usually larger, so it's better to use ISO. ISO+mp3 files can be named similarly as for other emus.\r
+Here are some examples:\r
+\r
+SonicCD.iso\r
+SonicCD_02.mp3\r
+SonicCD_03.mp3\r
+...\r
+\r
+Sonic the Hedgehog CD (US) - Track 01.iso\r
+Sonic the Hedgehog CD (US) - Track 02.mp3\r
+Sonic the Hedgehog CD (US) - Track 03.mp3\r
+...\r
+\r
+ISO files can also be zipped (but not mp3 files, as they are already compressed). Note that this can cause very long loading times, which may take up to several minutes. File naming is similar as with uncompressed ISOs.\r
+Example:\r
+\r
+SonicCD.zip\r
+SonicCD_02.mp3\r
+SonicCD_03.mp3\r
+...\r
+\r
+Notes:\r
+If the game hangs after Sega logo, you may need to enable "better sync" and/or "Scale/Rot. fx" options, found in "Sega/Mega CD options" submenu, and then reset the game.\r
+If FMV game performance is poor, try adjusting "ReadAhead buffer" to something like 2048K.\r
+\r
+\r
+[Configuration]\r
+1. "Renderer"\r
+8bit fast:\r
+This enables alternative heavily optimized tile-based renderer, which renders pixels not line-by-line (this is what accurate renderers do), but in 8x8 tiles, which is much faster. But because of the way it works it can't render any mid-frame image changes (raster effects), so it is useful only with some games.\r
+\r
+Other two are accurate line-based renderers. The 8bit is faster but does not run well with some games like Street Racer.\r
+\r
+2. "Scaling"\r
+"hw" means GP2X hardware scaler, which causes no performance loss, but scaled image looks a bit blocky. "sw" means software scaling, which uses pixel averaging and may look a bit nicer, but blurry. Horizontal scaling is only for games which use so called "32 column mode" (256x224 or 256x240), and scales image width to 320 pixels. Vertical scales height to 240 for games which use height 224 (most of them).\r
+\r
+3. "Accurate timing"\r
+This adds some more emulation precision, but slows the emulation down. Without this option some games do not boot (Red Zone for example), others have sound problems. This options has no effect for Sega/Mega CD emulation.\r
+\r
+4. "Accurate sprites"\r
+This option improves emulation of sprite priorities, it also enables emulation of sprite collision bit. If you see one sprite being drawn incorrectly above the other (often seen in Sonic 3D Blast), you can enable this to fix the problem. This only works with the accurate renderers (see first option).\r
+\r
+5. "Show FPS"\r
+Self-explanatory. Format is XX/YY, where XX is the number of rendered frames and YY is the number of emulated frames per second.\r
+\r
+6. "Frameskip"\r
+How many frames to skip rendering before displaying another. "Auto" is recommended.\r
+\r
+7. "Enable sound"\r
+Does what it says. You must enable at least YM2612 or SN76496 (in advanced options, see below) for this to make sense.\r
+\r
+8. "Sound Quality"\r
+Sound rate and stereo mode. If you want 44100Hz sound, it is recommended to enable the second core (next option).\r
+\r
+9. "Use ARM940 core for sound"\r
+This option causes PicoDrive to use ARM940T core (GP2X's second CPU) for sound (i.e. to generate YM2612 samples) to improve performance noticeably.\r
+\r
+10. "6 button pad"\r
+If you enable this, games will think that 6 button gamepad is connected. If you go and reconfigure your keys, you will be able to bind X,Y,Z and mode actions.\r
+\r
+11. "Region"\r
+This option lets you force the game to think it is running on machine from the specified region, or just to set autodetection order. Also affects Sega/Mega CD.\r
+\r
+12. "Use SRAM/BRAM savestates"\r
+This will automatically read/write SRAM (or BRAM for Sega/Mega CD) savestates for games which are using them. SRAM is saved whenever you pause your game or exit the emulator.\r
+\r
+13. "Confirm savestate"\r
+Allows to enable confirmation on savestate saving (to prevent savestate overwrites), on loading (to prevent destroying current game progress), and on both or none.\r
+\r
+14. "GP2X CPU clocks"\r
+Here you can change clocks of both GP2X's CPUs. Larger values increase performance. There is no separate option for the second CPU because both CPUs use the same clock source. Setting this option to 200 will cause PicoDrive NOT to change GP2X's clocks at all (this is if you use external program to set clock).\r
+\r
+15. "[Sega/Mega CD options]"\r
+Enters Sega/Mega CD options menu (see below).\r
+\r
+16. "[advanced options]"\r
+Enters advanced options menu (see below).\r
+\r
+17. "Save cfg as default"\r
+If you save your config here it will be loaded on next ROM load, but only if there is no game specific config saved (which will be loaded in that case).\r
+\r
+18. "Save cfg for current game only"\r
+Whenever you load current ROM again these settings will be loaded (squidgehack and RAM settings will not take effect until emulator is restarted).\r
+\r
+\r
+Advanced configuration\r
+----------------------\r
+\r
+Enter [advanced options] in config menu to see these options.\r
+\r
+1. "Gamma correction"\r
+Alters image gamma through GP2X hardware. Larger values make image to look brighter, lower - darker (default is 1.0).\r
+\r
+2. "Emulate Z80"\r
+Enables emulation of Z80 chip, which was mostly used to drive the other sound chips. Some games do complex sync with it, so you must enable it even if you don't use sound to be able to play them.\r
+\r
+3. "Emulate YM2612 (FM)"\r
+This enables emulation of six-channel FM sound synthesizer chip, which was used to produce sound effects and music.\r
+\r
+4. "Emulate SN76496 (PSG)"\r
+This enables emulation of additional sound chip for additional effects.\r
+\r
+Note: if you change sound settings AFTER loading a ROM, you may need to reset game to get sound. This is because most games initialize sound chips on startup, and this data is lost when sound chips are being enabled/disabled.\r
+\r
+5. "gzip savestates"\r
+This will always apply gzip compression on your savestates, allowing you to save some space and load/save time.\r
+\r
+6. "Don't save last used ROM"\r
+This will disable writing last used ROM to config on exit (what might cause SD card corruption according to DaveC).\r
+\r
+7. "craigix's RAM timings"\r
+This overclocks the GP2X RAM chips, but may cause instability. Recommended if you use the second core for sound. Needs emulator restart to take effect.\r
+See this thread:\r
+http://www.gp32x.com/board/index.php?showtopic=32319\r
+\r
+8. "squidgehack"\r
+Well known way to improve the GP2X performance. You must restart the emulator for the change of this option to take effect.\r
+\r
+\r
+Sega/Mega CD options \r
+--------------------\r
+\r
+1,2,3. "USA/EUR/JAP BIOS"\r
+These options just show if your BIOS files were correctly detected by the emulator (it shows the filename it is using). If so, you can press Start to test your BIOS.\r
+\r
+4. "CD LEDs"\r
+The Sega/Mega CD unit had two blinking LEDs (red and green) on it. This option will display them on top-left corner of the screen.\r
+\r
+5. "CDDA audio (using mp3s)"\r
+This option enables CD audio playback.\r
+\r
+6. "PCM audio"\r
+This enables 8 channel PCM sound source. It is required for some games to run, because they monitor state of this audio chip.\r
+\r
+7. "ReadAhead buffer"\r
+This option is for dealing with slow SD card access in GP2X, which makes FMV games unplayable. It will allow emulator not to access SD card for longer periods of time, but it will take more time to fill the buffer.\r
+\r
+8. "Save RAM cart"\r
+Here you can enable 64K RAM cart. Format it in BIOS if you do.\r
+\r
+9. "Scale/Rot. fx"\r
+The Sega/Mega CD had scaling/rotation chip, which allows effects similar to "Mode 7" effects in SNES. Unfortunately emulating it is slow, and very few games used it, so it's better to disable this option, unless game really needs it.\r
+\r
+10. "Better sync"\r
+This option is similar to "Perfect synchro" in Gens. Some games require it to run, for example most (all?) Wolfteam games, and some other ones. Don't use it for games which don't need it, it will just slow them down.\r
+\r
+\r
+Key configuration\r
+-----------------\r
+\r
+When you select "Configure controls" from the menu, you enter a key configuration mode, where you use SELECT to change an action, and then press a key you like to bind to that action. You can press the same key again to unbind. Select "DONE" action and press any key to finish.\r
+\r
+\r
+[Other important stuff]\r
+When you use both GP2X CPUs, keep in mind that you can't overclock as high as when using ARM920 only. For example my GP2X when run singlecore can reach 280MHz, but with both cores it's about 250MHz. When overclocked too much, it may start hanging and producing random noise, or causing ARM940 crashes ("940 crashed" message displayed).\r
+\r
+PicoDrive is not a mp3 player, so all mp3s MUST be encoded at 44.1kHz stereo. Badly encoded mp3s can cause various kind of problems, like noises, incorrect playback speeds, not repeating music or even prevent game from starting. Use lower bitrate for better performance (96 or 128kbps CBRs recommended). Due to internal implementation mp3s must not be larger that ~15MB (15548416 bytes). Larger mp3s will not be fully loaded.\r
+\r
+RAM timings option is good for dualcore operation (it is disabled by default because it doesn't work on every GP2X, so enable it in advanced options).\r
+\r
+\r
+[Cheat support]\r
+To use GG/patch codes, you must type them into your favorite text editor, one per line. Comments may follow code after a whitespace. Only GameGenie and Genecyst patch formats are supported.\r
+Examples:\r
+\r
+Genecyst patch (this example is for Sonic):\r
+\r
+00334A:0005 Start with five lives\r
+012D24:0001 Keep invincibility until end of stage\r
+009C76:5478 each ring worth 2\r
+009C76:5678 each ring worth 3\r
+...\r
+\r
+Game Genie patch (for Sonic 2):\r
+\r
+ACLA-ATD4 Hidden palace instead of death egg in level select\r
+...\r
+\r
+Both GG and patch codes can be mixed in one file.\r
+\r
+When the file is ready, name it just like your ROM file, but with additional .pat extension, making sure that case matches.\r
+\r
+Examples:\r
+\r
+ROM: Sonic.zip\r
+PATCH FILE: Sonic.zip.pat\r
+\r
+ROM: Sonic 2.bin\r
+PATCH FILE: Sonic 2.bin.pat\r
+\r
+Put the file into your ROMs directory. Then load the .pat file as you would a ROM. Then Cheat Menu Option should appear in main menu.\r
+\r
+\r
+[What is emulated?]\r
+Genesis/MegaDrive:\r
+main 68k @ 7.6MHz: yes, Cyclone core\r
+z80 @ 3.6MHz: yes, DrZ80 core\r
+VDP: yes, except some quirks not used by games\r
+YM2612 FM: yes, optimized MAME core\r
+SN76489 PSG: yes, MAME core\r
+\r
+Sega/Mega CD:\r
+another 68k @ 12.5MHz: yes, Cyclone too\r
+gfx scaling/rotation chip (custom ASIC): yes\r
+PCM sound source: yes\r
+CD-ROM controller: yes (mostly)\r
+bram (internal backup RAM): yes\r
+RAM cartridge: yes\r
+\r
+\r
+[Problems / limitations]\r
+* 32x and SVP are not emulated.\r
+* Various VDP quirks (window bug, scroll size 2, etc.) are not emulated, as very few games use this (if any at all).\r
+* Some games don't work or have glitches because of inaccurate timing and sync between the emulated chips.\r
+\r
+\r
+[Credits]\r
+This emulator uses code from these people/projects:\r
+\r
+Dave\r
+Cyclone 68000 core, Pico emulation library\r
+Homepage: http://www.finalburn.com/\r
+\r
+notaz\r
+GP2X port, Cyclone 68000 hacks, lots of additional coding (see changelog).\r
+\r
+Reesy & FluBBa\r
+DrZ80, the Z80 emulator written in ARM assembly.\r
+Homepage: http://reesy.gp32x.de/\r
+\r
+Tatsuyuki Satoh, Jarek Burczynski, MultiArcadeMachineEmulator development software implementation of Yamaha FM sound generator\r
+\r
+MultiArcadeMachineEmulator (MAME) development\r
+Texas Instruments SN76489 / SN76496 programmable tone /noise generator\r
+Homepage: http://www.mame.net/\r
+\r
+Stephane Dallongeville\r
+Gens, MD/Mega CD/32X emulator. Most Sega CD code is based on this emu.\r
+\r
+Helix community\r
+Helix mp3 decoder\r
+\r
+\r
+[Additional thanks]\r
+* Charles MacDonald (http://cgfm2.emuviews.com/) for old but still very useful info about genesis hardware.\r
+* Steve Snake for all that he has done for Genesis emulation scene.\r
+* Bart Trzynadlowski for his SSFII and 68000 docs.\r
+* Haze for his research (http://haze.mameworld.info).\r
+* Mark and Jean-loup for zlib library.\r
+* rlyeh and all the other people behind the minimal library.\r
+* Squidge for his famous squidgehack(tm).\r
+* Dzz for his ARM940 sample code.\r
+* GnoStiC & Puck2099 for USB joystick support.\r
+* Hermes PS2R, god_at_hell for the CpuCtrl library.\r
+* craigix for supplying the GP2X hardware and making this port possible.\r
+* Alex for the icon.\r
+* Anyone else I forgot. You know who you are.\r
+\r
+\r
+[Disclaimer]\r
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
+\r
+SEGA/Genesis/MegaDrive/SEGA-CD/Mega-CD/32X are trademarks of Sega Enterprises Ltd.\r
+\r
+@ vim:filetype=armasm\r
@ some color conversion and blitting routines\r
\r
@ (c) Copyright 2006, notaz\r
+// The top-level functions for the ARM940\r
+// (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas\r
+\r
#include "940shared.h"\r
\r
static _940_data_t *shared_data = (_940_data_t *) 0x00100000;\r
@ vim:filetype=armasm:\r
\r
+@ ARM940 initialization.\r
+@ Based on ogg940 code by Dzz.\r
+@ (c) Copyright 2007, Grazvydas "notaz" Ignotas\r
\r
.equ mmsp2_regs, (0xc0000000-0x02000000) @ assume we live @ 0x2000000 bank\r
.equ shared_ctl, 0x00200000 @ this is where shared_ctl struncture is located\r
Other two are accurate line-based renderers. The 8bit is faster but does not\r
run well with some games like Street Racer.\r
\r
-2. "Accurate timing"\r
+2. "Scaling"\r
+"hw" means GP2X hardware scaler, which causes no performance loss, but scaled\r
+image looks a bit blocky. "sw" means software scaling, which uses pixel\r
+averaging and may look a bit nicer, but blurry. Horizontal scaling is only for\r
+games which use so called "32 column mode" (256x224 or 256x240), and scales\r
+image width to 320 pixels. Vertical scales height to 240 for games which use\r
+height 224 (most of them).\r
+\r
+3. "Accurate timing"\r
This adds some more emulation precision, but slows the emulation down. Without\r
this option some games do not boot (Red Zone for example), others have sound\r
problems. This options has no effect for Sega/Mega CD emulation.\r
\r
-3. "Accurate sprites"\r
+4. "Accurate sprites"\r
This option improves emulation of sprite priorities, it also enables emulation\r
of sprite collision bit. If you see one sprite being drawn incorrectly above\r
the other (often seen in Sonic 3D Blast), you can enable this to fix the problem.\r
-This only works with the default renderer (see first option).\r
+This only works with the accurate renderers (see first option).\r
\r
-4. "Show FPS"\r
+5. "Show FPS"\r
Self-explanatory. Format is XX/YY, where XX is the number of rendered frames and\r
YY is the number of emulated frames per second.\r
\r
-5. "Frameskip"\r
+6. "Frameskip"\r
How many frames to skip rendering before displaying another.\r
"Auto" is recommended.\r
\r
-6. "Enable sound"\r
+7. "Enable sound"\r
Does what it says. You must enable at least YM2612 or SN76496 (in advanced options,\r
see below) for this to make sense.\r
\r
-7. "Sound Quality"\r
+8. "Sound Quality"\r
Sound rate and stereo mode. If you want 44100Hz sound, it is recommended to enable\r
the second core (next option).\r
\r
-8. "Use ARM940 core for sound"\r
+9. "Use ARM940 core for sound"\r
This option causes PicoDrive to use ARM940T core (GP2X's second CPU) for sound \r
(i.e. to generate YM2612 samples) to improve performance noticeably.\r
\r
-9. "6 button pad"\r
+10. "6 button pad"\r
If you enable this, games will think that 6 button gamepad is connected. If you\r
go and reconfigure your keys, you will be able to bind X,Y,Z and mode actions.\r
\r
-10. "Genesis Region"\r
+11. "Region"\r
This option lets you force the game to think it is running on machine from the\r
specified region, or just to set autodetection order. Also affects Sega/Mega CD.\r
\r
-11. "Use SRAM/BRAM savestates"\r
+12. "Use SRAM/BRAM savestates"\r
This will automatically read/write SRAM (or BRAM for Sega/Mega CD) savestates for\r
games which are using them. SRAM is saved whenever you pause your game or exit the\r
emulator.\r
\r
-12. "GP2X CPU clocks"\r
+13. "Confirm savestate"\r
+Allows to enable confirmation on savestate saving (to prevent savestate overwrites),\r
+on loading (to prevent destroying current game progress), and on both or none.\r
+\r
+14. "GP2X CPU clocks"\r
Here you can change clocks of both GP2X's CPUs. Larger values increase performance.\r
There is no separate option for the second CPU because both CPUs use the same clock\r
source. Setting this option to 200 will cause PicoDrive NOT to change GP2X's clocks\r
at all (this is if you use external program to set clock).\r
\r
-13. "[Sega/Mega CD options]"\r
+15. "[Sega/Mega CD options]"\r
Enters Sega/Mega CD options menu (see below).\r
\r
-14. "[advanced options]"\r
+16. "[advanced options]"\r
Enters advanced options menu (see below).\r
\r
-15. "Save cfg as default"\r
+17. "Save cfg as default"\r
If you save your config here it will be loaded on next ROM load, but only if there\r
is no game specific config saved (which will be loaded in that case).\r
\r
-16. "Save cfg for current game only"\r
+18. "Save cfg for current game only"\r
Whenever you load current ROM again these settings will be loaded (squidgehack and\r
RAM settings will not take effect until emulator is restarted).\r
\r
\r
Enter [advanced options] in config menu to see these options.\r
\r
-1. "Scale 32 column mode"\r
-This enables hardware scaling for lower-res genesis mode (where width is\r
-32 8-pixel tiles, instead of 40 in other mode).\r
-\r
-2. "Gamma correction"\r
+1. "Gamma correction"\r
Alters image gamma through GP2X hardware. Larger values make image to look brighter,\r
lower - darker (default is 1.0).\r
\r
-3. "Emulate Z80"\r
+2. "Emulate Z80"\r
Enables emulation of Z80 chip, which was mostly used to drive the other sound chips.\r
Some games do complex sync with it, so you must enable it even if you don't use\r
sound to be able to play them.\r
\r
-4. "Emulate YM2612 (FM)"\r
+3. "Emulate YM2612 (FM)"\r
This enables emulation of six-channel FM sound synthesizer chip, which was used to\r
produce sound effects and music.\r
\r
-5. "Emulate SN76496 (PSG)"\r
+4. "Emulate SN76496 (PSG)"\r
This enables emulation of additional sound chip for additional effects.\r
\r
Note: if you change sound settings AFTER loading a ROM, you may need to reset\r
game to get sound. This is because most games initialize sound chips on\r
startup, and this data is lost when sound chips are being enabled/disabled.\r
\r
-6. "gzip savestates"\r
+5. "gzip savestates"\r
This will always apply gzip compression on your savestates, allowing you to\r
save some space and load/save time.\r
\r
-7. "Don't save config on exit"\r
-This will disable config autowrite on exit (which might cause SD card corruption\r
-according to DaveC).\r
+6. "Don't save last used ROM"\r
+This will disable writing last used ROM to config on exit (what might cause SD\r
+card corruption according to DaveC).\r
\r
-8. "craigix's RAM timings"\r
+7. "craigix's RAM timings"\r
This overclocks the GP2X RAM chips, but may cause instability. Recommended if you\r
use the second core for sound. Needs emulator restart to take effect.\r
See this thread:\r
http://www.gp32x.com/board/index.php?showtopic=32319\r
\r
-9. "squidgehack"\r
+8. "squidgehack"\r
Well known way to improve the GP2X performance. You must restart the emulator\r
for the change of this option to take effect.\r
\r
--------------------\r
\r
1,2,3. "USA/EUR/JAP BIOS"\r
-These options just shows if your BIOS files were correctly detected be the\r
-emulator (it shows the filename it is using). If so, you can press Start to test\r
-your BIOS.\r
+These options just show if your BIOS files were correctly detected by the\r
+emulator (it shows the filename it is using). If so, you can press Start to\r
+test your BIOS.\r
\r
4. "CD LEDs"\r
The Sega/Mega CD unit had two blinking LEDs (red and green) on it. This option\r
-will display them on left-top corner of the screen.\r
+will display them on top-left corner of the screen.\r
\r
5. "CDDA audio (using mp3s)"\r
This option enables CD audio playback.\r
\r
6. "PCM audio"\r
This enables 8 channel PCM sound source. It is required for some games to run,\r
-because they monitor state of the audio chip.\r
+because they monitor state of this audio chip.\r
\r
7. "ReadAhead buffer"\r
This option is for dealing with slow SD card access in GP2X, which makes FMV\r
games unplayable. It will allow emulator not to access SD card for longer periods\r
of time, but it will take more time to fill the buffer.\r
\r
-8. "Scale/Rot. fx"\r
+8. "Save RAM cart"\r
+Here you can enable 64K RAM cart. Format it in BIOS if you do.\r
+\r
+9. "Scale/Rot. fx"\r
The Sega/Mega CD had scaling/rotation chip, which allows effects similar to\r
"Mode 7" effects in SNES. Unfortunately emulating it is slow, and very few games\r
-used it, so it's better to disable this option.\r
+used it, so it's better to disable this option, unless game really needs it.\r
\r
-9. "Better sync"\r
+10. "Better sync"\r
This option is similar to "Perfect synchro" in Gens. Some games require it to run,\r
for example most (all?) Wolfteam games, and some other ones. Don't use it for\r
games which don't need it, it will just slow them down.\r
-// (c) Copyright 2006 notaz, All rights reserved.\r
+// (c) Copyright 2006-2007 notaz, All rights reserved.\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
\r
// detect wrong files (Pico crashes on very small files), also see if ROM EP is good\r
if(rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 ||\r
- ((*(unsigned short *)(rom_data+4)<<16)|(*(unsigned short *)(rom_data+6))) >= (int)rom_size) {\r
+ ((*(unsigned char *)(rom_data+4)<<16)|(*(unsigned short *)(rom_data+6))) >= (int)rom_size) {\r
if (rom_data) free(rom_data);\r
rom_data = 0;\r
sprintf(menuErrorMsg, "Not a ROM selected.");\r
// set default config\r
memset(¤tConfig, 0, sizeof(currentConfig));\r
currentConfig.lastRomFile[0] = 0;\r
- currentConfig.EmuOpt = 0x1f | 0x400; // | cd_leds\r
- currentConfig.PicoOpt = 0x0f | 0xe00; // | use_940 | cd_pcm | cd_cdda\r
+ currentConfig.EmuOpt = 0x1f | 0x600; // | confirm_save, cd_leds\r
+ currentConfig.PicoOpt = 0x0f | 0xe00; // | use_940, cd_pcm, cd_cdda\r
currentConfig.PsndRate = 22050; // 44100;\r
currentConfig.PicoRegion = 0; // auto\r
currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP\r
\r
// save SRAM\r
if((currentConfig.EmuOpt & 1) && SRam.changed) {\r
- osd_text(4, 232, "Writing SRAM/BRAM..");\r
+ emu_state_cb("Writing SRAM/BRAM..");\r
emu_SaveLoadGame(0, 1);\r
SRam.changed = 0;\r
}\r
FILE *sramFile;\r
int sram_size;\r
unsigned char *sram_data;\r
+ int truncate = 1;\r
if (PicoMCD&1) {\r
- sram_size = 0x2000;\r
- sram_data = Pico_mcd->bram;\r
+ if (PicoOpt&0x8000) { // MCD RAM cart?\r
+ sram_size = 0x12000;\r
+ sram_data = SRam.data;\r
+ if (sram_data)\r
+ memcpy32((int *)sram_data, (int *)Pico_mcd->bram, 0x2000/4);\r
+ } else {\r
+ sram_size = 0x2000;\r
+ sram_data = Pico_mcd->bram;\r
+ truncate = 0; // the .brm may contain RAM cart data after normal brm\r
+ }\r
} else {\r
sram_size = SRam.end-SRam.start+1;\r
if(SRam.reg_back & 4) sram_size=0x2000;\r
sram_data = SRam.data;\r
}\r
- if(!sram_data) return 0; // SRam forcefully disabled for this game\r
+ if (!sram_data) return 0; // SRam forcefully disabled for this game\r
\r
- if(load) {\r
+ if (load) {\r
sramFile = fopen(saveFname, "rb");\r
if(!sramFile) return -1;\r
fread(sram_data, 1, sram_size, sramFile);\r
fclose(sramFile);\r
+ if ((PicoMCD&1) && (PicoOpt&0x8000))\r
+ memcpy32((int *)Pico_mcd->bram, (int *)sram_data, 0x2000/4);\r
} else {\r
// sram save needs some special processing\r
// see if we have anything to save\r
- for(; sram_size > 0; sram_size--)\r
- if(sram_data[sram_size-1]) break;\r
+ for (; sram_size > 0; sram_size--)\r
+ if (sram_data[sram_size-1]) break;\r
\r
- if(sram_size) {\r
- sramFile = fopen(saveFname, "wb");\r
+ if (sram_size) {\r
+ sramFile = fopen(saveFname, truncate ? "wb" : "r+b");\r
ret = fwrite(sram_data, 1, sram_size, sramFile);\r
ret = (ret != sram_size) ? -1 : 0;\r
fclose(sramFile);\r
-// (c) Copyright 2006 notaz, All rights reserved.\r
+// (c) Copyright 2006-2007 notaz, All rights reserved.\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (currentConfig.PicoOpt&0x0800)?"ON":"OFF"); // 4\r
gp2x_text_out8(tl_x, (y+=10), "PCM audio %s", (currentConfig.PicoOpt&0x0400)?"ON":"OFF"); // 5\r
gp2x_text_out8(tl_x, (y+=10), "ReadAhead buffer %s", ra_buff); // 6\r
- gp2x_text_out8(tl_x, (y+=10), "Scale/Rot. fx (slow) %s", (currentConfig.PicoOpt&0x1000)?"ON":"OFF"); // 7\r
- gp2x_text_out8(tl_x, (y+=10), "Better sync (slow) %s", (currentConfig.PicoOpt&0x2000)?"ON":"OFF"); // 8\r
+ gp2x_text_out8(tl_x, (y+=10), "SaveRAM cart %s", (currentConfig.PicoOpt&0x8000)?"ON":"OFF"); // 7\r
+ gp2x_text_out8(tl_x, (y+=10), "Scale/Rot. fx (slow) %s", (currentConfig.PicoOpt&0x1000)?"ON":"OFF"); // 8\r
+ gp2x_text_out8(tl_x, (y+=10), "Better sync (slow) %s", (currentConfig.PicoOpt&0x2000)?"ON":"OFF"); // 9\r
gp2x_text_out8(tl_x, (y+=10), "Done");\r
\r
// draw cursor\r
\r
static void cd_menu_loop_options(void)\r
{\r
- int menu_sel = 0, menu_sel_max = 9;\r
+ int menu_sel = 0, menu_sel_max = 10;\r
unsigned long inp = 0;\r
char bios_us[32], bios_eu[32], bios_jp[32], *bios, *p;\r
\r
if (PicoCDBuffers > 8*1024) PicoCDBuffers = 8*1024; // 16M\r
}\r
break;\r
- case 7: currentConfig.PicoOpt^=0x1000; break;\r
- case 8: currentConfig.PicoOpt^=0x2000; break;\r
- case 9: return;\r
+ case 7: currentConfig.PicoOpt^=0x8000; break;\r
+ case 8: currentConfig.PicoOpt^=0x1000; break;\r
+ case 9: currentConfig.PicoOpt^=0x2000; break;\r
+ case 10: return;\r
}\r
}\r
if(inp & (GP2X_X|GP2X_A)) return;\r
gp2x_text_out8(tl_x, (y+=10), "Sound Quality: %5iHz %s", currentConfig.PsndRate, monostereo);\r
gp2x_text_out8(tl_x, (y+=10), "Use ARM940 core for sound %s", (currentConfig.PicoOpt&0x200)?"ON":"OFF"); // 8\r
gp2x_text_out8(tl_x, (y+=10), "6 button pad %s", (currentConfig.PicoOpt&0x020)?"ON":"OFF"); // 9\r
- gp2x_text_out8(tl_x, (y+=10), "Genesis Region: %s", region_name(currentConfig.PicoRegion));\r
+ gp2x_text_out8(tl_x, (y+=10), "Region: %s", region_name(currentConfig.PicoRegion));\r
gp2x_text_out8(tl_x, (y+=10), "Use SRAM/BRAM savestates %s", (currentConfig.EmuOpt &0x001)?"ON":"OFF"); // 11\r
gp2x_text_out8(tl_x, (y+=10), "Confirm savestate %s", strssconfirm); // 12\r
gp2x_text_out8(tl_x, (y+=10), "Save slot %i", state_slot); // 13\r
+// Some mp3 related code for Sega/Mega CD
+// (c) Copyright 2007, Grazvydas "notaz" Ignotas
+
#include <stdio.h>
#include <string.h>
+@ vim:filetype=armasm\r
+\r
@ .equiv START_ROW, 1\r
@ .equiv END_ROW, 27\r
@ one row means 8 pixels. If above example was used, (27-1)*8=208 lines would be rendered.\r
Then load a ROM and enjoy! ROMs can be in .smd or .bin format and can be zipped.\r
\r
If you have any problems (game does not boot, sound is glitchy, broken graphics),\r
-make sure you enable "Accurate timing", "Emulate Z80" and then disable\r
-"Fast renderer". This way you will get the best compatibility this emulator can\r
+make sure you enable "Accurate timing", "Emulate Z80" and use "16bit accurate\r
+renderer". This way you will get the best compatibility this emulator can\r
provide.\r
\r
\r
SonicCD_03.mp3\r
...\r
\r
+Notes:\r
+If the game hangs after Sega logo, you may need to enable "better sync"\r
+and/or "Scale/Rot. fx" options, found in "Sega/Mega CD options" submenu, and\r
+then reset the game.\r
+If FMV game performance is poor, try adjusting "ReadAhead buffer" to something\r
+like 2048K.\r
+\r
\r
Configuration\r
-------------\r
* When you use both GP2X CPUs, keep in mind that you can't overclock as high as\r
when using ARM920 only. For example my GP2X when run singlecore can reach\r
280MHz, but with both cores it's about 250MHz. When overclocked too much,\r
- it may start hanging and producing random noise.\r
+ it may start hanging and producing random noise, or causing ARM940 crashes\r
+ ("940 crashed" message displayed).\r
* PicoDrive is not a mp3 player, so all mp3s MUST be encoded at 44.1kHz stereo.\r
- Otherwise mp3s will play too fast or too slow.\r
+ Badly encoded mp3s can cause various kind of problems, like noises, incorrect\r
+ playback speeds, not repeating music or even prevent game from starting.\r
+* Use lower bitrate for better performance (96 or 128kbps CBRs recommended).\r
* Due to internal implementation mp3s must not be larger that ~15MB\r
(15548416 bytes). Larger mp3s will not be fully loaded.\r
-* Use lower bitrate for better performance (96 or 128kbps CBRs recommended).\r
* RAM timings option is good for dualcore operation (it is disabled by\r
default because it doesn't work on every GP2X, so enable it in advanced\r
options).\r
\r
Sega/Mega CD:\r
another 68k @ 12.5MHz: yes, Cyclone too\r
-gfx scaling/rotation chip (custom ASIC): not yet (faked only)\r
+gfx scaling/rotation chip (custom ASIC): yes\r
PCM sound source: yes\r
CD-ROM controller: yes (mostly)\r
bram (internal backup RAM): yes\r
* GnoStiC & Puck2099 for USB joystick support.\r
* Hermes PS2R, god_at_hell for the CpuCtrl library.\r
* craigix for supplying the GP2X hardware and making this port possible.\r
+* Alex for the icon.\r
\r
Symbian:\r
* Peter van Sebille for his various open-source Symbian projects to learn from.\r
---------\r
1.32\r
+ Added some new scaling options.\r
- + Added ability to reaload CD images while game is running (needed for games\r
+ + Added ability to reload CD images while game is running (needed for games\r
with multiple CDs, like Night Trap).\r
+ + Added RAM cart emulation.\r
* Fixed DMA timing emulation (caused lock-ups for some genesis games).\r
* Idle loop detection was picking up wrong code and causing glitches, fixed.\r
* The ym2612 code on 940 now can handle multiple updates per frame\r
Popful Mail, Silpheed).\r
* Improved z80 timing, should fix some sound problems.\r
* Fixed a bug with sram register (fixes Phantasy Star 4).\r
+ * ROM loader was incorrectly identifying some ROMs as invalid. Fixed.\r
* Added code for PRG ram write protection register (Dungeon Explorer).\r
* The memory mode register change in 1.31 was unsafe and caused some glitches in\r
AH-3 Thunderstrike. Fixed.\r
* Fixed a file descriptor leak.\r
+ * Updated documentation, added Gmenu2x manual.\r
\r
1.31\r
* Changed the way memory mode register is read (fixes Lunar 2, broken in 1.30).\r