mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
FAME + some random stuff added
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@276 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
7d4906bfc9
commit
70357ce525
22 changed files with 45359 additions and 4395 deletions
46
Pico/Draw.c
46
Pico/Draw.c
|
@ -1186,35 +1186,49 @@ static void FinalizeLineRGB555(int sh)
|
||||||
unsigned short *pal=HighPal;
|
unsigned short *pal=HighPal;
|
||||||
int len, i, t, dirtyPal = Pico.m.dirtyPal;
|
int len, i, t, dirtyPal = Pico.m.dirtyPal;
|
||||||
|
|
||||||
if(dirtyPal) {
|
if (dirtyPal)
|
||||||
unsigned short *ppal=Pico.cram;
|
{
|
||||||
for(i = 0x3f; i >= 0; i--)
|
unsigned int *spal=(void *)Pico.cram;
|
||||||
pal[i] = (unsigned short) (((ppal[i]&0x00f)<<12)|((ppal[i]&0x0f0)<<3)|((ppal[i]&0xf00)>>7));
|
unsigned int *dpal=(void *)HighPal;
|
||||||
|
for (i = 0x3f/2; i >= 0; i--)
|
||||||
|
#ifdef USE_BGR555
|
||||||
|
dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4);
|
||||||
|
#else
|
||||||
|
dpal[i] = ((spal[i]&0x000f000f)<<12)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)>>7);
|
||||||
|
#endif
|
||||||
Pico.m.dirtyPal = 0;
|
Pico.m.dirtyPal = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pico.video.reg[12]&1) {
|
if (sh)
|
||||||
len = 320;
|
{
|
||||||
} else {
|
if (dirtyPal) {
|
||||||
if(!(PicoOpt&0x100)) pd+=32;
|
|
||||||
len = 256;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sh) {
|
|
||||||
if(dirtyPal) {
|
|
||||||
// shadowed pixels
|
// shadowed pixels
|
||||||
for(i = 0x3f; i >= 0; i--)
|
for (i = 0x3f; i >= 0; i--)
|
||||||
pal[0x40|i] = pal[0xc0|i] = (unsigned short)((pal[i]>>1)&0x738e);
|
pal[0x40|i] = pal[0xc0|i] = (unsigned short)((pal[i]>>1)&0x738e);
|
||||||
// hilighted pixels
|
// hilighted pixels
|
||||||
for(i = 0x3f; i >= 0; i--) {
|
for (i = 0x3f; i >= 0; i--) {
|
||||||
t=pal[i]&0xe71c;t+=0x4208;if(t&0x20)t|=0x1c;if(t&0x800)t|=0x700;if(t&0x10000)t|=0xe000;t&=0xe71c;
|
t=pal[i]&0xe71c;t+=0x4208;if(t&0x20)t|=0x1c;if(t&0x800)t|=0x700;if(t&0x10000)t|=0xe000;t&=0xe71c;
|
||||||
pal[0x80|i]=(unsigned short)t;
|
pal[0x80|i]=(unsigned short)t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < len; i++)
|
if (Pico.video.reg[12]&1) {
|
||||||
|
len = 320;
|
||||||
|
} else {
|
||||||
|
if (!(PicoOpt&0x100)) pd+=32;
|
||||||
|
len = 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef PSP
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
pd[i] = pal[ps[i]];
|
pd[i] = pal[ps[i]];
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
extern void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);
|
||||||
|
amips_clut(pd, ps, pal, len);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
1423
Pico/Draw_.s
1423
Pico/Draw_.s
File diff suppressed because it is too large
Load diff
42
Pico/Draw_amips.s
Normal file
42
Pico/Draw_amips.s
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
# vim:filetype=mips
|
||||||
|
|
||||||
|
# only CLUT for now..
|
||||||
|
|
||||||
|
.set noreorder # don't reorder any instructions
|
||||||
|
.set noat # don't use $at
|
||||||
|
|
||||||
|
|
||||||
|
# void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count)
|
||||||
|
|
||||||
|
.global amips_clut
|
||||||
|
|
||||||
|
amips_clut:
|
||||||
|
srl $a3, 2
|
||||||
|
amips_clut_loop:
|
||||||
|
lbu $t0, 0($a1) # tried lw here, no improvement noticed
|
||||||
|
lbu $t1, 1($a1)
|
||||||
|
lbu $t2, 2($a1)
|
||||||
|
lbu $t3, 3($a1)
|
||||||
|
sll $t0, 1
|
||||||
|
sll $t1, 1
|
||||||
|
sll $t2, 1
|
||||||
|
sll $t3, 1
|
||||||
|
addu $t0, $a2
|
||||||
|
addu $t1, $a2
|
||||||
|
addu $t2, $a2
|
||||||
|
addu $t3, $a2
|
||||||
|
lhu $t0, 0($t0)
|
||||||
|
lhu $t1, 0($t1)
|
||||||
|
lhu $t2, 0($t2)
|
||||||
|
lhu $t3, 0($t3)
|
||||||
|
ins $t0, $t1, 16, 16 # ins rt, rs, pos, size - Insert size bits starting
|
||||||
|
ins $t2, $t3, 16, 16 # from the LSB of rs into rt starting at position pos
|
||||||
|
sw $t0, 0($a0)
|
||||||
|
sw $t2, 4($a0)
|
||||||
|
addiu $a0, 8
|
||||||
|
addiu $a3, -1
|
||||||
|
bnez $a3, amips_clut_loop
|
||||||
|
addiu $a1, 4
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
1301
Pico/Draw_sh.c
1301
Pico/Draw_sh.c
File diff suppressed because it is too large
Load diff
1527
Pico/Draw_sh.s
1527
Pico/Draw_sh.s
File diff suppressed because it is too large
Load diff
|
@ -45,7 +45,7 @@ void log_io(unsigned int addr, int bits, int rw);
|
||||||
#define log_io(...)
|
#define log_io(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(EMU_C68K) || defined(EMU_A68K)
|
#if defined(EMU_C68K)
|
||||||
static __inline int PicoMemBase(u32 pc)
|
static __inline int PicoMemBase(u32 pc)
|
||||||
{
|
{
|
||||||
int membase=0;
|
int membase=0;
|
||||||
|
@ -69,10 +69,6 @@ static __inline int PicoMemBase(u32 pc)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef EMU_A68K
|
|
||||||
extern u8 *OP_ROM=NULL,*OP_RAM=NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static u32 CPU_CALL PicoCheckPc(u32 pc)
|
static u32 CPU_CALL PicoCheckPc(u32 pc)
|
||||||
{
|
{
|
||||||
u32 ret=0;
|
u32 ret=0;
|
||||||
|
@ -90,11 +86,6 @@ static u32 CPU_CALL PicoCheckPc(u32 pc)
|
||||||
PicoCpu.membase-=pc&0xff000000;
|
PicoCpu.membase-=pc&0xff000000;
|
||||||
|
|
||||||
ret = PicoCpu.membase+pc;
|
ret = PicoCpu.membase+pc;
|
||||||
#elif defined(EMU_A68K)
|
|
||||||
OP_ROM=(u8 *)PicoMemBase(pc);
|
|
||||||
|
|
||||||
// don't bother calling us back unless it's outside the 64k segment
|
|
||||||
M68000_regs.AsmBank=(pc>>16);
|
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -498,8 +489,8 @@ static void CPU_CALL PicoWrite32(u32 a,u32 d)
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
PICO_INTERNAL void PicoMemSetup(void)
|
PICO_INTERNAL void PicoMemSetup(void)
|
||||||
{
|
{
|
||||||
#ifdef EMU_C68K
|
|
||||||
// Setup memory callbacks:
|
// Setup memory callbacks:
|
||||||
|
#ifdef EMU_C68K
|
||||||
PicoCpu.checkpc=PicoCheckPc;
|
PicoCpu.checkpc=PicoCheckPc;
|
||||||
PicoCpu.fetch8 =PicoCpu.read8 =PicoRead8;
|
PicoCpu.fetch8 =PicoCpu.read8 =PicoRead8;
|
||||||
PicoCpu.fetch16=PicoCpu.read16=PicoRead16;
|
PicoCpu.fetch16=PicoCpu.read16=PicoRead16;
|
||||||
|
@ -508,43 +499,16 @@ PICO_INTERNAL void PicoMemSetup(void)
|
||||||
PicoCpu.write16=PicoWrite16;
|
PicoCpu.write16=PicoWrite16;
|
||||||
PicoCpu.write32=PicoWrite32;
|
PicoCpu.write32=PicoWrite32;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef EMU_F68K
|
||||||
|
PicoCpuM68k.read_byte =PicoRead8;
|
||||||
|
PicoCpuM68k.read_word =PicoRead16;
|
||||||
|
PicoCpuM68k.read_long =PicoRead32;
|
||||||
|
PicoCpuM68k.write_byte=PicoWrite8;
|
||||||
|
PicoCpuM68k.write_word=PicoWrite16;
|
||||||
|
PicoCpuM68k.write_long=PicoWrite32;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EMU_A68K
|
|
||||||
struct A68KInter
|
|
||||||
{
|
|
||||||
u32 unknown;
|
|
||||||
u8 (__fastcall *Read8) (u32 a);
|
|
||||||
u16 (__fastcall *Read16)(u32 a);
|
|
||||||
u32 (__fastcall *Read32)(u32 a);
|
|
||||||
void (__fastcall *Write8) (u32 a,u8 d);
|
|
||||||
void (__fastcall *Write16) (u32 a,u16 d);
|
|
||||||
void (__fastcall *Write32) (u32 a,u32 d);
|
|
||||||
void (__fastcall *ChangePc)(u32 a);
|
|
||||||
u8 (__fastcall *PcRel8) (u32 a);
|
|
||||||
u16 (__fastcall *PcRel16)(u32 a);
|
|
||||||
u32 (__fastcall *PcRel32)(u32 a);
|
|
||||||
u16 (__fastcall *Dir16)(u32 a);
|
|
||||||
u32 (__fastcall *Dir32)(u32 a);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct A68KInter a68k_memory_intf=
|
|
||||||
{
|
|
||||||
0,
|
|
||||||
PicoRead8,
|
|
||||||
PicoRead16,
|
|
||||||
PicoRead32,
|
|
||||||
PicoWrite8,
|
|
||||||
PicoWrite16,
|
|
||||||
PicoWrite32,
|
|
||||||
PicoCheckPc,
|
|
||||||
PicoRead8,
|
|
||||||
PicoRead16,
|
|
||||||
PicoRead32,
|
|
||||||
PicoRead16, // unused
|
|
||||||
PicoRead32, // unused
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
unsigned int m68k_read_pcrelative_CD8 (unsigned int a);
|
unsigned int m68k_read_pcrelative_CD8 (unsigned int a);
|
||||||
|
|
32
Pico/Misc.c
32
Pico/Misc.c
|
@ -316,8 +316,30 @@ PICO_INTERNAL void SRAMUpdPending(unsigned int a, unsigned int d)
|
||||||
|
|
||||||
|
|
||||||
#ifndef _ASM_MISC_C
|
#ifndef _ASM_MISC_C
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int b0;
|
||||||
|
int b1;
|
||||||
|
int b2;
|
||||||
|
int b3;
|
||||||
|
int b4;
|
||||||
|
int b5;
|
||||||
|
int b6;
|
||||||
|
int b7;
|
||||||
|
} intblock;
|
||||||
|
|
||||||
PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count)
|
PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count)
|
||||||
{
|
{
|
||||||
|
if (((int)dest & (int)src & 3) == 0)
|
||||||
|
{
|
||||||
|
if (count >= 32) {
|
||||||
|
memcpy32((int *)dest, (int *)src, count/2);
|
||||||
|
count&=1;
|
||||||
|
} else {
|
||||||
|
for (; count >= 2; count -= 2, dest+=2, src+=2)
|
||||||
|
*(int *)dest = *(int *)src;
|
||||||
|
}
|
||||||
|
}
|
||||||
while (count--)
|
while (count--)
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
}
|
}
|
||||||
|
@ -334,6 +356,12 @@ PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count)
|
||||||
|
|
||||||
PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count)
|
PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count)
|
||||||
{
|
{
|
||||||
|
intblock *bd = (intblock *) dest, *bs = (intblock *) src;
|
||||||
|
|
||||||
|
for (; count >= sizeof(*bd)/4; count -= sizeof(*bd)/4)
|
||||||
|
*bd++ = *bs++;
|
||||||
|
|
||||||
|
dest = (int *)bd; src = (int *)bs;
|
||||||
while (count--)
|
while (count--)
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
}
|
}
|
||||||
|
@ -341,6 +369,10 @@ PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count)
|
||||||
|
|
||||||
PICO_INTERNAL_ASM void memset32(int *dest, int c, int count)
|
PICO_INTERNAL_ASM void memset32(int *dest, int c, int count)
|
||||||
{
|
{
|
||||||
|
for (; count >= 8; count -= 8, dest += 8)
|
||||||
|
dest[0] = dest[1] = dest[2] = dest[3] =
|
||||||
|
dest[4] = dest[5] = dest[6] = dest[7] = c;
|
||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
*dest++ = c;
|
*dest++ = c;
|
||||||
}
|
}
|
||||||
|
|
14
Pico/Pico.c
14
Pico/Pico.c
|
@ -212,12 +212,10 @@ static __inline void SekRunM68k(int cyc)
|
||||||
PicoCpu.cycles=cyc_do;
|
PicoCpu.cycles=cyc_do;
|
||||||
CycloneRun(&PicoCpu);
|
CycloneRun(&PicoCpu);
|
||||||
SekCycleCnt+=cyc_do-PicoCpu.cycles;
|
SekCycleCnt+=cyc_do-PicoCpu.cycles;
|
||||||
#elif defined(EMU_A68K)
|
|
||||||
m68k_ICount=cyc_do;
|
|
||||||
M68000_RUN();
|
|
||||||
SekCycleCnt+=cyc_do-m68k_ICount;
|
|
||||||
#elif defined(EMU_M68K)
|
#elif defined(EMU_M68K)
|
||||||
SekCycleCnt+=m68k_execute(cyc_do);
|
SekCycleCnt+=m68k_execute(cyc_do);
|
||||||
|
#elif defined(EMU_F68K)
|
||||||
|
SekCycleCnt+=m68k_emulate(cyc_do);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,12 +230,10 @@ static __inline void SekStep(void)
|
||||||
PicoCpu.cycles=1;
|
PicoCpu.cycles=1;
|
||||||
CycloneRun(&PicoCpu);
|
CycloneRun(&PicoCpu);
|
||||||
SekCycleCnt+=1-PicoCpu.cycles;
|
SekCycleCnt+=1-PicoCpu.cycles;
|
||||||
#elif defined(EMU_A68K)
|
|
||||||
m68k_ICount=1;
|
|
||||||
M68000_RUN();
|
|
||||||
SekCycleCnt+=1-m68k_ICount;
|
|
||||||
#elif defined(EMU_M68K)
|
#elif defined(EMU_M68K)
|
||||||
SekCycleCnt+=m68k_execute(1);
|
SekCycleCnt+=m68k_execute(1);
|
||||||
|
#elif defined(EMU_F68K)
|
||||||
|
SekCycleCnt+=m68k_emulate(1);
|
||||||
#endif
|
#endif
|
||||||
SekCycleAim=realaim;
|
SekCycleAim=realaim;
|
||||||
}
|
}
|
||||||
|
@ -677,6 +673,8 @@ char *debugString(void)
|
||||||
}
|
}
|
||||||
#elif defined(EMU_M68K)
|
#elif defined(EMU_M68K)
|
||||||
sprintf(dstrp, "M68k: PC: %06x, cycles: %u, irql: %i\n", SekPc, SekCyclesDoneT(), PicoM68kCPU.int_level>>8); dstrp+=strlen(dstrp);
|
sprintf(dstrp, "M68k: PC: %06x, cycles: %u, irql: %i\n", SekPc, SekCyclesDoneT(), PicoM68kCPU.int_level>>8); dstrp+=strlen(dstrp);
|
||||||
|
#elif defined(EMU_F68K)
|
||||||
|
sprintf(dstrp, "M68k: PC: %06x, cycles: %u, irql: %i\n", SekPc, SekCyclesDoneT(), PicoCpuM68k.interrupts[0]); dstrp+=strlen(dstrp);
|
||||||
#endif
|
#endif
|
||||||
sprintf(dstrp, "z80Run: %i, pal: %i, frame#: %i\n", Pico.m.z80Run, Pico.m.pal, Pico.m.frame_count); dstrp+=strlen(dstrp);
|
sprintf(dstrp, "z80Run: %i, pal: %i, frame#: %i\n", Pico.m.z80Run, Pico.m.pal, Pico.m.frame_count); dstrp+=strlen(dstrp);
|
||||||
z80_debug(dstrp); dstrp+=strlen(dstrp);
|
z80_debug(dstrp); dstrp+=strlen(dstrp);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#define PICO_INTERNAL_ASM
|
#define PICO_INTERNAL_ASM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// to select core, define EMU_C68K, EMU_M68K or EMU_A68K in your makefile or project
|
// to select core, define EMU_C68K, EMU_M68K or EMU_F68K in your makefile or project
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -50,24 +50,28 @@ extern struct Cyclone PicoCpu, PicoCpuS68k;
|
||||||
#define SekSetStopS68k(x) { PicoCpuS68k.state_flags&=~1; if (x) { PicoCpuS68k.state_flags|=1; PicoCpuS68k.cycles=0; } }
|
#define SekSetStopS68k(x) { PicoCpuS68k.state_flags&=~1; if (x) { PicoCpuS68k.state_flags|=1; PicoCpuS68k.cycles=0; } }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EMU_A68K
|
#ifdef EMU_F68K
|
||||||
void __cdecl M68000_RUN();
|
#include "../cpu/fame/fame.h"
|
||||||
// The format of the data in a68k.asm (at the _M68000_regs location)
|
M68K_CONTEXT PicoCpuM68k, PicoCpuS68k;
|
||||||
struct A68KContext
|
#define SekCyclesLeftNoMCD PicoCpuM68k.io_cycle_counter
|
||||||
{
|
#define SekCyclesLeft \
|
||||||
unsigned int d[8],a[8];
|
(((PicoMCD&1) && (PicoOpt & 0x2000)) ? (SekCycleAim-SekCycleCnt) : SekCyclesLeftNoMCD)
|
||||||
unsigned int isp,srh,ccr,xc,pc,irq,sr;
|
#define SekCyclesLeftS68k \
|
||||||
int (*IrqCallback) (int nIrq);
|
((PicoOpt & 0x2000) ? (SekCycleAimS68k-SekCycleCntS68k) : PicoCpuS68k.io_cycle_counter)
|
||||||
unsigned int ppc;
|
#define SekSetCyclesLeftNoMCD(c) PicoCpuM68k.io_cycle_counter=c
|
||||||
void *pResetCallback;
|
#define SekSetCyclesLeft(c) { \
|
||||||
unsigned int sfc,dfc,usp,vbr;
|
if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \
|
||||||
unsigned int AsmBank,CpuVersion;
|
}
|
||||||
};
|
#define SekPc m68k_get_pc(&PicoCpuM68k)
|
||||||
struct A68KContext M68000_regs;
|
#define SekPcS68k m68k_get_pc(&PicoCpuS68k)
|
||||||
extern int m68k_ICount;
|
#define SekSetStop(x) { \
|
||||||
#define SekCyclesLeft m68k_ICount
|
PicoCpuM68k.execinfo &= ~M68K_HALTED; \
|
||||||
#define SekSetCyclesLeft(c) m68k_ICount=c
|
if (x) { PicoCpuM68k.execinfo |= M68K_HALTED; PicoCpuM68k.io_cycle_counter = 0; } \
|
||||||
#define SekPc M68000_regs.pc
|
}
|
||||||
|
#define SekSetStopS68k(x) { \
|
||||||
|
PicoCpuS68k.execinfo &= ~M68K_HALTED; \
|
||||||
|
if (x) { PicoCpuS68k.execinfo |= M68K_HALTED; PicoCpuS68k.io_cycle_counter = 0; } \
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
|
@ -137,10 +141,10 @@ extern int SekCycleAimS68k;
|
||||||
#define SekEndRun(c)
|
#define SekEndRun(c)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int PicoMCD;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
|
extern int PicoMCD;
|
||||||
|
|
||||||
// main oscillator clock which controls timing
|
// main oscillator clock which controls timing
|
||||||
#define OSC_NTSC 53693100
|
#define OSC_NTSC 53693100
|
||||||
// seems to be accurate, see scans from http://www.hot.ee/tmeeco/
|
// seems to be accurate, see scans from http://www.hot.ee/tmeeco/
|
||||||
|
|
115
Pico/Sek.c
115
Pico/Sek.c
|
@ -14,33 +14,23 @@ int SekCycleCnt=0; // cycles done in this frame
|
||||||
int SekCycleAim=0; // cycle aim
|
int SekCycleAim=0; // cycle aim
|
||||||
unsigned int SekCycleCntT=0;
|
unsigned int SekCycleCntT=0;
|
||||||
|
|
||||||
|
|
||||||
|
/* context */
|
||||||
|
// Cyclone 68000
|
||||||
#ifdef EMU_C68K
|
#ifdef EMU_C68K
|
||||||
// ---------------------- Cyclone 68000 ----------------------
|
|
||||||
struct Cyclone PicoCpu;
|
struct Cyclone PicoCpu;
|
||||||
#endif
|
#endif
|
||||||
|
// MUSASHI 68000
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
// ---------------------- MUSASHI 68000 ----------------------
|
m68ki_cpu_core PicoM68kCPU;
|
||||||
m68ki_cpu_core PicoM68kCPU; // MD's CPU
|
|
||||||
#endif
|
#endif
|
||||||
|
// FAME 68000
|
||||||
#ifdef EMU_A68K
|
#ifdef EMU_F68K
|
||||||
// ---------------------- A68K ----------------------
|
M68K_CONTEXT PicoCpuM68k;
|
||||||
|
|
||||||
void __cdecl M68000_RESET();
|
|
||||||
int m68k_ICount=0;
|
|
||||||
unsigned int mem_amask=0xffffff; // 24-bit bus
|
|
||||||
unsigned int mame_debug=0,cur_mrhard=0,m68k_illegal_opcode=0,illegal_op=0,illegal_pc=0,opcode_entry=0; // filler
|
|
||||||
|
|
||||||
static int IrqCallback(int i) { i; return -1; }
|
|
||||||
static int DoReset() { return 0; }
|
|
||||||
static int (*ResetCallback)()=DoReset;
|
|
||||||
|
|
||||||
#pragma warning (disable:4152)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* callbacks */
|
||||||
#ifdef EMU_C68K
|
#ifdef EMU_C68K
|
||||||
// interrupt acknowledgment
|
// interrupt acknowledgment
|
||||||
static int SekIntAck(int level)
|
static int SekIntAck(int level)
|
||||||
|
@ -75,7 +65,6 @@ static int SekUnrecognizedOpcode()
|
||||||
have_illegal = 1;
|
have_illegal = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//exit(1);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -97,6 +86,35 @@ static int SekTasCallback(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef EMU_F68K
|
||||||
|
static void setup_fame_fetchmap(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// be default, point everything to fitst 64k of ROM
|
||||||
|
for (i = 0; i < M68K_FETCHBANK1; i++)
|
||||||
|
PicoCpuM68k.Fetch[i] = (unsigned int)Pico.rom - (i<<(24-FAMEC_FETCHBITS));
|
||||||
|
// now real ROM
|
||||||
|
for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < Pico.romsize; i++)
|
||||||
|
PicoCpuM68k.Fetch[i] = (unsigned int)Pico.rom;
|
||||||
|
elprintf(EL_ANOMALY, "ROM end @ #%i %06x", i, (i<<(24-FAMEC_FETCHBITS)));
|
||||||
|
// .. and RAM (TODO)
|
||||||
|
for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)
|
||||||
|
PicoCpuM68k.Fetch[i] = (unsigned int)Pico.ram - (i<<(24-FAMEC_FETCHBITS));
|
||||||
|
|
||||||
|
elprintf(EL_ANOMALY, "rom = %p, ram = %p", Pico.rom, Pico.ram);
|
||||||
|
for (i = 0; i < M68K_FETCHBANK1; i++)
|
||||||
|
elprintf(EL_ANOMALY, "Fetch[%i] = %p", i, PicoCpuM68k.Fetch[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SekIntAckF68K(unsigned level)
|
||||||
|
{
|
||||||
|
if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); }
|
||||||
|
else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); }
|
||||||
|
PicoCpuM68k.interrupts[0] = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
PICO_INTERNAL int SekInit()
|
PICO_INTERNAL int SekInit()
|
||||||
{
|
{
|
||||||
|
@ -107,12 +125,6 @@ PICO_INTERNAL int SekInit()
|
||||||
PicoCpu.ResetCallback=SekResetAck;
|
PicoCpu.ResetCallback=SekResetAck;
|
||||||
PicoCpu.UnrecognizedCallback=SekUnrecognizedOpcode;
|
PicoCpu.UnrecognizedCallback=SekUnrecognizedOpcode;
|
||||||
#endif
|
#endif
|
||||||
#ifdef EMU_A68K
|
|
||||||
memset(&M68000_regs,0,sizeof(M68000_regs));
|
|
||||||
M68000_regs.IrqCallback=IrqCallback;
|
|
||||||
M68000_regs.pResetCallback=ResetCallback;
|
|
||||||
M68000_RESET(); // Init cpu emulator
|
|
||||||
#endif
|
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
{
|
{
|
||||||
void *oldcontext = m68ki_cpu_p;
|
void *oldcontext = m68ki_cpu_p;
|
||||||
|
@ -125,10 +137,21 @@ PICO_INTERNAL int SekInit()
|
||||||
m68k_set_context(oldcontext);
|
m68k_set_context(oldcontext);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef EMU_F68K
|
||||||
|
{
|
||||||
|
void *oldcontext = g_m68kcontext;
|
||||||
|
g_m68kcontext = &PicoCpuM68k;
|
||||||
|
memset(&PicoCpuM68k, 0, sizeof(PicoCpuM68k));
|
||||||
|
m68k_init();
|
||||||
|
PicoCpuM68k.iack_handler = SekIntAckF68K;
|
||||||
|
g_m68kcontext = oldcontext;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Reset the 68000:
|
// Reset the 68000:
|
||||||
PICO_INTERNAL int SekReset()
|
PICO_INTERNAL int SekReset()
|
||||||
{
|
{
|
||||||
|
@ -144,19 +167,21 @@ PICO_INTERNAL int SekReset()
|
||||||
PicoCpu.membase=0;
|
PicoCpu.membase=0;
|
||||||
PicoCpu.pc=PicoCpu.checkpc(PicoCpu.read32(4)); // Program Counter
|
PicoCpu.pc=PicoCpu.checkpc(PicoCpu.read32(4)); // Program Counter
|
||||||
#endif
|
#endif
|
||||||
#ifdef EMU_A68K
|
|
||||||
// Reset CPU: fetch SP and PC
|
|
||||||
M68000_regs.srh=0x27; // Supervisor mode
|
|
||||||
M68000_regs.a[7]=PicoRead32(0);
|
|
||||||
M68000_regs.pc =PicoRead32(4);
|
|
||||||
PicoInitPc(M68000_regs.pc);
|
|
||||||
#endif
|
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
m68k_set_context(&PicoM68kCPU); // if we ever reset m68k, we always need it's context to be set
|
m68k_set_context(&PicoM68kCPU); // if we ever reset m68k, we always need it's context to be set
|
||||||
m68ki_cpu.sp[0]=0;
|
m68ki_cpu.sp[0]=0;
|
||||||
m68k_set_irq(0);
|
m68k_set_irq(0);
|
||||||
m68k_pulse_reset();
|
m68k_pulse_reset();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef EMU_F68K
|
||||||
|
{
|
||||||
|
unsigned ret;
|
||||||
|
g_m68kcontext = &PicoCpuM68k;
|
||||||
|
setup_fame_fetchmap();
|
||||||
|
ret = m68k_reset();
|
||||||
|
/*if (ret)*/ elprintf(EL_ANOMALY, "m68k_reset returned %u", ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -174,9 +199,6 @@ PICO_INTERNAL int SekInterrupt(int irq)
|
||||||
#ifdef EMU_C68K
|
#ifdef EMU_C68K
|
||||||
PicoCpu.irq=irq;
|
PicoCpu.irq=irq;
|
||||||
#endif
|
#endif
|
||||||
#ifdef EMU_A68K
|
|
||||||
M68000_regs.irq=irq; // raise irq (gets lowered after taken)
|
|
||||||
#endif
|
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
{
|
{
|
||||||
void *oldcontext = m68ki_cpu_p;
|
void *oldcontext = m68ki_cpu_p;
|
||||||
|
@ -185,23 +207,23 @@ PICO_INTERNAL int SekInterrupt(int irq)
|
||||||
m68k_set_context(oldcontext);
|
m68k_set_context(oldcontext);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef EMU_F68K
|
||||||
|
PicoCpuM68k.interrupts[0]=irq;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//int SekPc() { return PicoCpu.pc-PicoCpu.membase; }
|
|
||||||
//int SekPc() { return M68000_regs.pc; }
|
|
||||||
//int SekPc() { return m68k_get_reg(NULL, M68K_REG_PC); }
|
|
||||||
|
|
||||||
PICO_INTERNAL void SekState(unsigned char *data)
|
PICO_INTERNAL void SekState(unsigned char *data)
|
||||||
{
|
{
|
||||||
#ifdef EMU_C68K
|
#ifdef EMU_C68K
|
||||||
memcpy(data,PicoCpu.d,0x44);
|
memcpy(data,PicoCpu.d,0x44);
|
||||||
#elif defined(EMU_A68K)
|
|
||||||
memcpy(data, M68000_regs.d, 0x40);
|
|
||||||
memcpy(data+0x40,&M68000_regs.pc,0x04);
|
|
||||||
#elif defined(EMU_M68K)
|
#elif defined(EMU_M68K)
|
||||||
memcpy(data, PicoM68kCPU.dar,0x40);
|
memcpy(data, PicoM68kCPU.dar, 0x40);
|
||||||
memcpy(data+0x40,&PicoM68kCPU.pc, 0x04);
|
*(int *)(data+0x40) = PicoM68kCPU.pc;
|
||||||
|
#elif defined(EMU_F68K)
|
||||||
|
memcpy(data, PicoCpuM68k.dreg, 0x40);
|
||||||
|
*(int *)(data+0x40) = PicoCpuM68k.pc;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,5 +232,8 @@ PICO_INTERNAL void SekSetRealTAS(int use_real)
|
||||||
#ifdef EMU_C68K
|
#ifdef EMU_C68K
|
||||||
CycloneSetRealTAS(use_real);
|
CycloneSetRealTAS(use_real);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef EMU_F68K
|
||||||
|
// TODO
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
186
cpu/fame/fame.h
Normal file
186
cpu/fame/fame.h
Normal file
|
@ -0,0 +1,186 @@
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* FAME Fast and Accurate Motorola 68000 Emulation Core */
|
||||||
|
/* (c) 2005 Oscar Orallo Pelaez */
|
||||||
|
/* Version: 1.24 */
|
||||||
|
/* Date: 08-20-2005 */
|
||||||
|
/* See FAME.HTML for documentation and license information */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __FAME_H__
|
||||||
|
#define __FAME_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// PicoDrive hacks
|
||||||
|
#define FAMEC_FETCHBITS 8
|
||||||
|
#define M68K_FETCHBANK1 (1 << FAMEC_FETCHBITS)
|
||||||
|
|
||||||
|
//#define M68K_RUNNING 0x01
|
||||||
|
#define M68K_HALTED 0x80
|
||||||
|
#define M68K_WAITING 0x04
|
||||||
|
#define M68K_DISABLE 0x20
|
||||||
|
#define M68K_FAULTED 0x40
|
||||||
|
#define M68K_EMULATE_GROUP_0 0x02
|
||||||
|
#define M68K_EMULATE_TRACE 0x08
|
||||||
|
#define M68K_DO_TRACE 0x10
|
||||||
|
|
||||||
|
|
||||||
|
/************************************/
|
||||||
|
/* General library defines */
|
||||||
|
/************************************/
|
||||||
|
|
||||||
|
#ifndef M68K_OK
|
||||||
|
#define M68K_OK 0
|
||||||
|
#endif
|
||||||
|
#ifndef M68K_RUNNING
|
||||||
|
#define M68K_RUNNING 1
|
||||||
|
#endif
|
||||||
|
#ifndef M68K_NO_SUP_ADDR_SPACE
|
||||||
|
#define M68K_NO_SUP_ADDR_SPACE 2
|
||||||
|
#endif
|
||||||
|
#ifndef M68K_DOUBLE_BUS_FAULT
|
||||||
|
#define M68K_DOUBLE_BUS_FAULT -1
|
||||||
|
#endif
|
||||||
|
#ifndef M68K_INV_REG
|
||||||
|
#define M68K_INV_REG -1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Hardware interrupt state */
|
||||||
|
|
||||||
|
#ifndef M68K_IRQ_LEVEL_ERROR
|
||||||
|
#define M68K_IRQ_LEVEL_ERROR -1
|
||||||
|
#endif
|
||||||
|
#ifndef M68K_IRQ_INV_PARAMS
|
||||||
|
#define M68K_IRQ_INV_PARAMS -2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Defines to specify hardware interrupt type */
|
||||||
|
|
||||||
|
#ifndef M68K_AUTOVECTORED_IRQ
|
||||||
|
#define M68K_AUTOVECTORED_IRQ -1
|
||||||
|
#endif
|
||||||
|
#ifndef M68K_SPURIOUS_IRQ
|
||||||
|
#define M68K_SPURIOUS_IRQ -2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef M68K_AUTO_LOWER_IRQ
|
||||||
|
#define M68K_AUTO_LOWER_IRQ 1
|
||||||
|
#endif
|
||||||
|
#ifndef M68K_MANUAL_LOWER_IRQ
|
||||||
|
#define M68K_MANUAL_LOWER_IRQ 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Defines to specify address space */
|
||||||
|
|
||||||
|
#ifndef M68K_SUP_ADDR_SPACE
|
||||||
|
#define M68K_SUP_ADDR_SPACE 0
|
||||||
|
#endif
|
||||||
|
#ifndef M68K_USER_ADDR_SPACE
|
||||||
|
#define M68K_USER_ADDR_SPACE 2
|
||||||
|
#endif
|
||||||
|
#ifndef M68K_PROG_ADDR_SPACE
|
||||||
|
#define M68K_PROG_ADDR_SPACE 0
|
||||||
|
#endif
|
||||||
|
#ifndef M68K_DATA_ADDR_SPACE
|
||||||
|
#define M68K_DATA_ADDR_SPACE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*******************/
|
||||||
|
/* Data definition */
|
||||||
|
/*******************/
|
||||||
|
|
||||||
|
/* M68K registers */
|
||||||
|
typedef enum {
|
||||||
|
M68K_REG_D0=0,
|
||||||
|
M68K_REG_D1,
|
||||||
|
M68K_REG_D2,
|
||||||
|
M68K_REG_D3,
|
||||||
|
M68K_REG_D4,
|
||||||
|
M68K_REG_D5,
|
||||||
|
M68K_REG_D6,
|
||||||
|
M68K_REG_D7,
|
||||||
|
M68K_REG_A0,
|
||||||
|
M68K_REG_A1,
|
||||||
|
M68K_REG_A2,
|
||||||
|
M68K_REG_A3,
|
||||||
|
M68K_REG_A4,
|
||||||
|
M68K_REG_A5,
|
||||||
|
M68K_REG_A6,
|
||||||
|
M68K_REG_A7,
|
||||||
|
M68K_REG_ASP,
|
||||||
|
M68K_REG_PC,
|
||||||
|
M68K_REG_SR
|
||||||
|
} m68k_register;
|
||||||
|
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
unsigned char B;
|
||||||
|
signed char SB;
|
||||||
|
unsigned short W;
|
||||||
|
signed short SW;
|
||||||
|
unsigned int D;
|
||||||
|
signed int SD;
|
||||||
|
} famec_union32;
|
||||||
|
|
||||||
|
/* The memory blocks must be in native (Motorola) format */
|
||||||
|
struct M68K_PROGRAM {
|
||||||
|
unsigned low_addr;
|
||||||
|
unsigned high_addr;
|
||||||
|
unsigned offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The memory blocks must be in native (Motorola) format */
|
||||||
|
struct M68K_DATA {
|
||||||
|
unsigned low_addr;
|
||||||
|
unsigned high_addr;
|
||||||
|
void *mem_handler;
|
||||||
|
void *data;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* M68K CPU CONTEXT */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned int (*read_byte )(unsigned int a);
|
||||||
|
unsigned int (*read_word )(unsigned int a);
|
||||||
|
unsigned int (*read_long )(unsigned int a);
|
||||||
|
void (*write_byte)(unsigned int a,unsigned char d);
|
||||||
|
void (*write_word)(unsigned int a,unsigned short d);
|
||||||
|
void (*write_long)(unsigned int a,unsigned int d);
|
||||||
|
void (*reset_handler)(void);
|
||||||
|
void (*iack_handler)(unsigned level);
|
||||||
|
famec_union32 dreg[8];
|
||||||
|
famec_union32 areg[8];
|
||||||
|
unsigned asp;
|
||||||
|
unsigned pc;
|
||||||
|
unsigned char interrupts[8];
|
||||||
|
unsigned short sr;
|
||||||
|
unsigned short execinfo;
|
||||||
|
// PD extension
|
||||||
|
int io_cycle_counter; // cycles left
|
||||||
|
unsigned int Fetch[M68K_FETCHBANK1];
|
||||||
|
} M68K_CONTEXT;
|
||||||
|
|
||||||
|
extern M68K_CONTEXT *g_m68kcontext;
|
||||||
|
|
||||||
|
/************************/
|
||||||
|
/* Function definition */
|
||||||
|
/************************/
|
||||||
|
|
||||||
|
/* General purpose functions */
|
||||||
|
void m68k_init(void);
|
||||||
|
int m68k_reset(void);
|
||||||
|
int m68k_emulate(int n);
|
||||||
|
|
||||||
|
unsigned m68k_get_pc(M68K_CONTEXT *context);
|
||||||
|
unsigned m68k_get_register(M68K_CONTEXT *context, m68k_register reg);
|
||||||
|
unsigned m68k_set_register(M68K_CONTEXT *context, m68k_register reg, unsigned value);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
5095
cpu/fame/famec.c
Normal file
5095
cpu/fame/famec.c
Normal file
File diff suppressed because it is too large
Load diff
39792
cpu/fame/famec_opcodes.h
Normal file
39792
cpu/fame/famec_opcodes.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define lprintf printf
|
#define lprintf printf
|
||||||
#elif defined(PSP)
|
#elif defined(PSP)
|
||||||
#if 0
|
#if 1
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define lprintf printf
|
#define lprintf printf
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
# settings
|
# settings
|
||||||
dprint = 1
|
use_fame = 1
|
||||||
|
|
||||||
# profile = 1
|
# profile = 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,8 +47,13 @@ OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/i
|
||||||
# unzip
|
# unzip
|
||||||
OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o
|
OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o
|
||||||
# CPU cores
|
# CPU cores
|
||||||
|
ifeq "$(use_fame)" "1"
|
||||||
|
DEFINC += -DEMU_F68K
|
||||||
|
OBJS += ../../cpu/fame/famec.o
|
||||||
|
else
|
||||||
DEFINC += -DEMU_M68K
|
DEFINC += -DEMU_M68K
|
||||||
OBJS += ../../cpu/musashi/m68kops.o ../../cpu/musashi/m68kcpu.o
|
OBJS += ../../cpu/musashi/m68kops.o ../../cpu/musashi/m68kcpu.o
|
||||||
|
endif
|
||||||
# mz80
|
# mz80
|
||||||
DEFINC += -D_USE_MZ80
|
DEFINC += -D_USE_MZ80
|
||||||
OBJS += ../../cpu/mz80/mz80.o
|
OBJS += ../../cpu/mz80/mz80.o
|
||||||
|
@ -95,3 +101,7 @@ PicoDrive : $(OBJS) ../common/helix/helix_mp3_x86.a
|
||||||
@echo $@
|
@echo $@
|
||||||
@$(GCC) $(COPT_COMMON) $(DEFINC) -c $< -o $@ # -mtune=arm940t -DEXTERNAL_YM2612
|
@$(GCC) $(COPT_COMMON) $(DEFINC) -c $< -o $@ # -mtune=arm940t -DEXTERNAL_YM2612
|
||||||
|
|
||||||
|
../../cpu/fame/famec.o : ../../cpu/fame/famec.c
|
||||||
|
@echo $<
|
||||||
|
@$(GCC) $(COPT) $(DEFINC) -Wno-unused -c $< -o $@
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
PSPSDK = $(shell psp-config --pspsdk-path)
|
PSPSDK = $(shell psp-config --pspsdk-path)
|
||||||
|
|
||||||
# settings
|
# settings
|
||||||
use_musashi = 1
|
#use_musashi = 1
|
||||||
use_mz80 = 1
|
use_mz80 = 1
|
||||||
amalgamate = 0
|
amalgamate = 0
|
||||||
#profile = 1
|
#profile = 1
|
||||||
|
@ -13,7 +13,7 @@ amalgamate = 0
|
||||||
CFLAGS += -I../.. -I. -D_UNZIP_SUPPORT -DNO_SYNC # -DBENCHMARK
|
CFLAGS += -I../.. -I. -D_UNZIP_SUPPORT -DNO_SYNC # -DBENCHMARK
|
||||||
CFLAGS += -Wall -Winline
|
CFLAGS += -Wall -Winline
|
||||||
ifeq ($(DEBUG),)
|
ifeq ($(DEBUG),)
|
||||||
CFLAGS += -O2 -G0 -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math
|
CFLAGS += -O2 -G0 -ftracer -fstrength-reduce -ffast-math
|
||||||
else
|
else
|
||||||
CFLAGS += -ggdb
|
CFLAGS += -ggdb
|
||||||
endif
|
endif
|
||||||
|
@ -37,7 +37,7 @@ OBJS += ../../PicoAll.o
|
||||||
else
|
else
|
||||||
OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Memory.o ../../Pico/Misc.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/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \
|
||||||
../../Pico/Patch.o
|
../../Pico/Patch.o ../../Pico/Draw_amips.o
|
||||||
# Pico - CD
|
# Pico - CD
|
||||||
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.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/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \
|
||||||
|
@ -59,6 +59,9 @@ OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o
|
||||||
ifeq "$(use_musashi)" "1"
|
ifeq "$(use_musashi)" "1"
|
||||||
CFLAGS += -DEMU_M68K
|
CFLAGS += -DEMU_M68K
|
||||||
OBJS += ../../cpu/musashi/m68kops.o ../../cpu/musashi/m68kcpu.o
|
OBJS += ../../cpu/musashi/m68kops.o ../../cpu/musashi/m68kcpu.o
|
||||||
|
else
|
||||||
|
CFLAGS += -DEMU_F68K
|
||||||
|
OBJS += ../../cpu/fame/famec.o
|
||||||
endif
|
endif
|
||||||
# z80
|
# z80
|
||||||
ifeq "$(use_mz80)" "1"
|
ifeq "$(use_mz80)" "1"
|
||||||
|
@ -69,7 +72,7 @@ $(error nothing here!)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
LIBS += -lpng -lm -lpspgu # -lpspaudio -lpspgu -lpsppower -lpsphprm -lz -lm -lstdc++
|
LIBS += -lpng -lm -lpspgu -lpsppower -Wl,-Map=PicoDrive.map # -lpspaudio -lpsphprm
|
||||||
|
|
||||||
# target
|
# target
|
||||||
TARGET = PicoDrive
|
TARGET = PicoDrive
|
||||||
|
@ -82,12 +85,17 @@ CUSTOM_CLEAN = myclean
|
||||||
|
|
||||||
include $(PSPSDK)/lib/build.mak
|
include $(PSPSDK)/lib/build.mak
|
||||||
|
|
||||||
|
|
||||||
# some additional rules
|
# some additional rules
|
||||||
.c.o:
|
.c.o:
|
||||||
@echo ">>>" $<
|
@echo ">>>" $<
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
AS := psp-as
|
||||||
|
|
||||||
|
.s.o:
|
||||||
|
@echo ">>>" $<
|
||||||
|
$(AS) -march=allegrex -mtune=allegrex $< -o $@
|
||||||
|
|
||||||
../../cpu/musashi/m68kops.c :
|
../../cpu/musashi/m68kops.c :
|
||||||
make -C ../../cpu/musashi
|
make -C ../../cpu/musashi
|
||||||
|
|
||||||
|
@ -97,6 +105,9 @@ readme.txt: ../../tools/textfilter ../base_readme.txt
|
||||||
../../tools/textfilter: ../../tools/textfilter.c
|
../../tools/textfilter: ../../tools/textfilter.c
|
||||||
make -C ../../tools/ textfilter
|
make -C ../../tools/ textfilter
|
||||||
|
|
||||||
|
../../cpu/fame/famec.o : ../../cpu/fame/famec.c
|
||||||
|
@echo ">>>" $<
|
||||||
|
$(CC) $(CFLAGS) -Wno-unused -c $< -o $@
|
||||||
|
|
||||||
# ?
|
# ?
|
||||||
up: EBOOT.PBP
|
up: EBOOT.PBP
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <sys/syslimits.h> // PATH_MAX
|
#include <sys/syslimits.h> // PATH_MAX
|
||||||
|
|
||||||
#include <pspthreadman.h>
|
#include <pspthreadman.h>
|
||||||
|
#include <pspdisplay.h>
|
||||||
|
|
||||||
#include "psp.h"
|
#include "psp.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
@ -121,6 +122,7 @@ void emu_setDefaultConfig(void)
|
||||||
currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP
|
currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP
|
||||||
currentConfig.Frameskip = -1; // auto
|
currentConfig.Frameskip = -1; // auto
|
||||||
currentConfig.volume = 50;
|
currentConfig.volume = 50;
|
||||||
|
currentConfig.CPUclock = 222;
|
||||||
currentConfig.KeyBinds[ 4] = 1<<0; // SACB RLDU
|
currentConfig.KeyBinds[ 4] = 1<<0; // SACB RLDU
|
||||||
currentConfig.KeyBinds[ 6] = 1<<1;
|
currentConfig.KeyBinds[ 6] = 1<<1;
|
||||||
currentConfig.KeyBinds[ 7] = 1<<2;
|
currentConfig.KeyBinds[ 7] = 1<<2;
|
||||||
|
@ -386,6 +388,9 @@ static void updateKeys(void)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
keys = psp_pad_read(0);
|
keys = psp_pad_read(0);
|
||||||
|
if (keys & PSP_CTRL_HOME)
|
||||||
|
sceDisplayWaitVblankStart();
|
||||||
|
|
||||||
if (keys & BTN_SELECT)
|
if (keys & BTN_SELECT)
|
||||||
engineState = PGS_Menu;
|
engineState = PGS_Menu;
|
||||||
|
|
||||||
|
@ -498,6 +503,13 @@ void emu_Loop(void)
|
||||||
|
|
||||||
fpsbuff[0] = 0;
|
fpsbuff[0] = 0;
|
||||||
|
|
||||||
|
if (currentConfig.CPUclock != psp_get_cpu_clock()) {
|
||||||
|
lprintf("setting cpu clock to %iMHz... ", currentConfig.CPUclock);
|
||||||
|
i = psp_set_cpu_clock(currentConfig.CPUclock);
|
||||||
|
lprintf(i ? "failed\n" : "done\n");
|
||||||
|
currentConfig.CPUclock = psp_get_cpu_clock();
|
||||||
|
}
|
||||||
|
|
||||||
// make sure we are in correct mode
|
// make sure we are in correct mode
|
||||||
vidResetMode();
|
vidResetMode();
|
||||||
Pico.m.dirtyPal = 1;
|
Pico.m.dirtyPal = 1;
|
||||||
|
|
|
@ -1032,6 +1032,7 @@ menu_entry opt_entries[] =
|
||||||
{ "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x0001, 0, 0, 1 },
|
{ "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x0001, 0, 0, 1 },
|
||||||
{ NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1 },
|
{ NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1 },
|
||||||
{ "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1 },
|
{ "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1 },
|
||||||
|
{ NULL, MB_NONE, MA_OPT_CPU_CLOCKS, NULL, 0, 0, 0, 1 },
|
||||||
{ "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1 },
|
{ "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1 },
|
||||||
{ "[advanced options]", MB_NONE, MA_OPT_ADV_OPTS, NULL, 0, 0, 0, 1 },
|
{ "[advanced options]", MB_NONE, MA_OPT_ADV_OPTS, NULL, 0, 0, 0, 1 },
|
||||||
{ NULL, MB_NONE, MA_OPT_SAVECFG, NULL, 0, 0, 0, 1 },
|
{ NULL, MB_NONE, MA_OPT_SAVECFG, NULL, 0, 0, 0, 1 },
|
||||||
|
@ -1102,6 +1103,9 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para
|
||||||
}
|
}
|
||||||
text_out16(x, y, "Confirm savestate %s", str);
|
text_out16(x, y, "Confirm savestate %s", str);
|
||||||
break;
|
break;
|
||||||
|
case MA_OPT_CPU_CLOCKS:
|
||||||
|
text_out16(x, y, "CPU/bus clock %3i/%3iMHz", currentConfig.CPUclock, currentConfig.CPUclock/2);
|
||||||
|
break;
|
||||||
case MA_OPT_SAVECFG:
|
case MA_OPT_SAVECFG:
|
||||||
str24[0] = 0;
|
str24[0] = 0;
|
||||||
if (config_slot != 0) sprintf(str24, " (profile: %i)", config_slot);
|
if (config_slot != 0) sprintf(str24, " (profile: %i)", config_slot);
|
||||||
|
@ -1250,6 +1254,14 @@ static int menu_loop_options(void)
|
||||||
} else {state_slot--; if (state_slot < 0) state_slot = 9;
|
} else {state_slot--; if (state_slot < 0) state_slot = 9;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case MA_OPT_CPU_CLOCKS:
|
||||||
|
while ((inp = psp_pad_read(0)) & (BTN_LEFT|BTN_RIGHT)) {
|
||||||
|
currentConfig.CPUclock += (inp & BTN_LEFT) ? -1 : 1;
|
||||||
|
if (currentConfig.CPUclock < 19) currentConfig.CPUclock = 19;
|
||||||
|
if (currentConfig.CPUclock > 333) currentConfig.CPUclock = 333;
|
||||||
|
draw_menu_options(menu_sel); // will wait vsync
|
||||||
|
}
|
||||||
|
break;
|
||||||
case MA_OPT_SAVECFG:
|
case MA_OPT_SAVECFG:
|
||||||
case MA_OPT_SAVECFG_GAME:
|
case MA_OPT_SAVECFG_GAME:
|
||||||
case MA_OPT_LOADCFG:
|
case MA_OPT_LOADCFG:
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#define CPU_CALL
|
#define CPU_CALL
|
||||||
|
|
||||||
// draw.c
|
// draw.c
|
||||||
|
#define USE_BGR555 1
|
||||||
#define OVERRIDE_HIGHCOL 0
|
#define OVERRIDE_HIGHCOL 0
|
||||||
|
|
||||||
// draw2.c
|
// draw2.c
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#include <pspiofilemgr.h>
|
#include <pspiofilemgr.h>
|
||||||
#include <pspdisplay.h>
|
#include <pspdisplay.h>
|
||||||
|
#include <psppower.h>
|
||||||
#include <pspgu.h>
|
#include <pspgu.h>
|
||||||
|
|
||||||
#include "psp.h"
|
#include "psp.h"
|
||||||
|
@ -76,7 +77,8 @@ void psp_finish(void)
|
||||||
void psp_video_flip(int wait_vsync)
|
void psp_video_flip(int wait_vsync)
|
||||||
{
|
{
|
||||||
if (wait_vsync) sceDisplayWaitVblankStart();
|
if (wait_vsync) sceDisplayWaitVblankStart();
|
||||||
sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME);
|
sceDisplaySetFrameBuf(psp_screen, 512, PSP_DISPLAY_PIXEL_FORMAT_565,
|
||||||
|
wait_vsync ? PSP_DISPLAY_SETBUF_IMMEDIATE : PSP_DISPLAY_SETBUF_NEXTFRAME);
|
||||||
current_screen ^= 1;
|
current_screen ^= 1;
|
||||||
psp_screen = current_screen ? PSP_VRAM_BASE0 : PSP_VRAM_BASE1;
|
psp_screen = current_screen ? PSP_VRAM_BASE0 : PSP_VRAM_BASE1;
|
||||||
}
|
}
|
||||||
|
@ -108,6 +110,19 @@ unsigned int psp_pad_read(int blocking)
|
||||||
return pad.Buttons;
|
return pad.Buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int psp_get_cpu_clock(void)
|
||||||
|
{
|
||||||
|
return scePowerGetCpuClockFrequencyInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
int psp_set_cpu_clock(int clock)
|
||||||
|
{
|
||||||
|
int ret = scePowerSetClockFrequency(clock, clock, clock/2);
|
||||||
|
if (ret != 0) lprintf("failed to set clock: %i\n", ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* alt logging */
|
/* alt logging */
|
||||||
#define LOG_FILE "log.log"
|
#define LOG_FILE "log.log"
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ extern void *psp_screen;
|
||||||
|
|
||||||
unsigned int psp_pad_read(int blocking);
|
unsigned int psp_pad_read(int blocking);
|
||||||
|
|
||||||
|
int psp_get_cpu_clock(void);
|
||||||
|
int psp_set_cpu_clock(int clock);
|
||||||
|
|
||||||
/* shorter btn names */
|
/* shorter btn names */
|
||||||
#define BTN_UP PSP_CTRL_UP
|
#define BTN_UP PSP_CTRL_UP
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 74 KiB |
Loading…
Add table
Add a link
Reference in a new issue