FAMEC idle loops, PSP port sync, minor adjustments

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@525 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-07-05 23:10:24 +00:00
parent b06778874d
commit c060a9ab9c
23 changed files with 408 additions and 155 deletions

View file

@ -1466,58 +1466,66 @@ void PicoDrawSetColorFormat(int which)
}
/* debug and fun */
#define GREEN1 0x0700
#ifdef USE_BGR555
#define YELLOW1 0x071c
#define BLUE1 0xf000
#define RED1 0x001e
#else
#define YELLOW1 0xe700
#define BLUE1 0x001e
#define RED1 0xf000
#endif
static void set16(unsigned short *p, unsigned short d, int cnt)
{
while (cnt-- > 0)
*p++ = d;
}
void PicoDrawShowSpriteStats(unsigned short *screen)
void PicoDrawShowSpriteStats(unsigned short *screen, int stride)
{
int lines, i, u, step;
unsigned short *dest;
unsigned char *p;
memset(screen, 0, 320*240*2);
step = (320-4*4-1) / MAX_LINE_SPRITES;
lines = 240;
if (!Pico.m.pal || !(Pico.video.reg[1]&8))
lines = 224, screen += 320*8;
lines = 224, screen += stride*8;
for (i = 0; i < lines; i++)
{
dest = screen + 320*i;
dest = screen + stride*i;
p = &HighLnSpr[i][0];
// sprite graphs
for (u = 0; u < (p[0] & 0x7f); u++) {
set16(dest, (p[3+u] & 0x80) ? 0xe700 : 0x0700, step);
set16(dest, (p[3+u] & 0x80) ? YELLOW1 : GREEN1, step);
dest += step;
}
// flags
dest = screen + 320*i + 320-4*4;
if (p[1] & SPRL_HAVE_LO) set16(dest+4*0, 0x0700, 4);
if (p[1] & SPRL_HAVE_HI) set16(dest+4*1, 0xe700, 4);
if (p[1] & SPRL_MAY_HAVE_OP) set16(dest+4*2, 0x001e, 4);
if (p[1] & SPRL_LO_ABOVE_HI) set16(dest+4*3, 0xf000, 4);
dest = screen + stride*i + 320-4*4;
if (p[1] & SPRL_HAVE_LO) set16(dest+4*0, GREEN1, 4);
if (p[1] & SPRL_HAVE_HI) set16(dest+4*1, YELLOW1, 4);
if (p[1] & SPRL_MAY_HAVE_OP) set16(dest+4*2, BLUE1, 4);
if (p[1] & SPRL_LO_ABOVE_HI) set16(dest+4*3, RED1, 4);
}
// draw grid
for (i = step*5; i <= 320-4*4-1; i += step*5) {
for (u = 0; u < lines; u++)
screen[i + u*320] = 0x182;
screen[i + u*stride] = 0x182;
}
}
void PicoDrawShowPalette(unsigned short *screen)
void PicoDrawShowPalette(unsigned short *screen, int stride)
{
unsigned int *spal=(void *)Pico.cram;
unsigned int *dpal=(void *)HighPal;
int x, y, i;
memset(screen, 0, 320*240*2);
for (i = 0x3f/2; i >= 0; i--)
#ifdef USE_BGR555
dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4);
@ -1531,20 +1539,20 @@ void PicoDrawShowPalette(unsigned short *screen)
HighPal[0x80|i] = (unsigned short)t;
}
screen += 16*320+8;
screen += 16*stride+8;
for (y = 0; y < 8*4; y++)
for (x = 0; x < 8*16; x++)
screen[x + y*320] = HighPal[x/8 + (y/8)*16];
screen[x + y*stride] = HighPal[x/8 + (y/8)*16];
screen += 160;
for (y = 0; y < 8*4; y++)
for (x = 0; x < 8*16; x++)
screen[x + y*320] = HighPal[(x/8 + (y/8)*16) | 0x40];
screen[x + y*stride] = HighPal[(x/8 + (y/8)*16) | 0x40];
screen += 320*48;
screen += stride*48;
for (y = 0; y < 8*4; y++)
for (x = 0; x < 8*16; x++)
screen[x + y*320] = HighPal[(x/8 + (y/8)*16) | 0x80];
screen[x + y*stride] = HighPal[(x/8 + (y/8)*16) | 0x80];
Pico.m.dirtyPal = 1;
}

View file

@ -345,7 +345,7 @@ PICO_INTERNAL_ASM u32 PicoRead8(u32 a)
if ((a&0xff4000)==0xa00000) { d=z80Read8(a); goto end; } // Z80 Ram
if ((a&0xe700e0)==0xc00000) { d=PicoVideoRead8(a); goto end; } // VDP
d=OtherRead16(a&~1, 8);
if ((a&1)==0) d>>=8;
@ -983,8 +983,7 @@ PICO_INTERNAL unsigned char z80_read(unsigned short a)
if ((a>>13)==2) // 0x4000-0x5fff (Charles MacDonald)
{
if (PicoOpt&POPT_EN_FM) ret = ym2612_read_local_z80();
return ret;
return ym2612_read_local_z80();
}
if (a>=0x8000)

View file

@ -386,10 +386,7 @@ m_read8_misc2:
cmp r2, #0x4000
mvnne r0, #0
bxne lr @ invalid
ldr r1, =PicoOpt
ldr r1, [r1]
tst r1, #1
bne ym2612_read_local_68k
b ym2612_read_local_68k
m_read8_fake_ym2612:
ldr r3, =(Pico+0x22200)

View file

@ -113,11 +113,8 @@ u32 OtherRead16(u32 a, int realsize)
if (Pico.m.z80Run&1)
elprintf(EL_ANOMALY, "68k z80 read with no bus! [%06x] @ %06x", a, SekPc);
if ((a&0x4000)==0x0000) { d=z80Read8(a); d|=d<<8; goto end; } // Z80 ram (not byteswaped)
if ((a&0x6000)==0x4000) { // 0x4000-0x5fff, Fudge if disabled
if (PicoOpt&POPT_EN_FM) d=ym2612_read_local_68k();
else d=Pico.m.rotate++&3;
goto end;
}
if ((a&0x6000)==0x4000) { d=ym2612_read_local_68k(); goto end; } // 0x4000-0x5fff
elprintf(EL_ANOMALY, "68k bad read [%06x]", a);
d=0xffff;
goto end;

View file

@ -417,11 +417,8 @@ m_read8_misc3:
m_read8_z80_misc:
addiu $t0, 0xc000 # expecting 0x4000 to get 0
bnez $t0, m_read_neg1 # invalid
lui $t0, %hi(PicoOpt)
lw $t0, %lo(PicoOpt)($t0)
andi $t0, 1
bnez $t0, ym2612_read_local_68k
nop
j ym2612_read_local_68k
nop
m_read8_fake_ym2612:

View file

@ -250,7 +250,7 @@ static __inline void SekRunM68k(int cyc)
#elif defined(EMU_M68K)
SekCycleCnt+=m68k_execute(cyc_do);
#elif defined(EMU_F68K)
SekCycleCnt+=fm68k_emulate(cyc_do+1, 0);
SekCycleCnt+=fm68k_emulate(cyc_do+1, 0, 0);
#endif
}
@ -313,7 +313,7 @@ int idle_hit_counter = 0;
void PicoFrame(void)
{
#if 0
#if 1
if ((Pico.m.frame_count&0x3f) == 0) {
elprintf(EL_STATUS, "ihits: %i", idle_hit_counter);
idle_hit_counter = 0;

View file

@ -182,6 +182,7 @@ PICO_INTERNAL void SekSetRealTAS(int use_real)
static int *idledet_addrs = NULL;
static int idledet_count = 0, idledet_bads = 0;
int idledet_start_frame = 0;
int jumptab[0x10000];
static unsigned char *rom_verify = NULL;
@ -202,6 +203,10 @@ void SekInitIdleDet(void)
#ifdef EMU_C68K
CycloneInitIdle();
#endif
#ifdef EMU_F68K
{ extern void *get_jumptab(void); memcpy(jumptab, get_jumptab(), sizeof(jumptab)); }
fm68k_emulate(0, 0, 1);
#endif
}
int SekIsIdleCode(unsigned short *dst, int bytes)
@ -275,6 +280,9 @@ void SekFinishIdleDet(void)
int done_something = idledet_count > 0;
#ifdef EMU_C68K
CycloneFinishIdle();
#endif
#ifdef EMU_F68K
fm68k_emulate(0, 0, 2);
#endif
while (idledet_count > 0)
{
@ -291,10 +299,15 @@ void SekFinishIdleDet(void)
if (done_something)
{
int i;
int i, *jt;
extern void *get_jumptab(void);
for (i = 0; i < Pico.romsize; i++)
if (rom_verify[i] != Pico.rom[i])
printf("ROM corruption @ %06x!\n", i), exit(1);
jt = get_jumptab();
for (i = 0; i < 0x10000; i++)
if (jumptab[i] != jt[i]) { printf("jumptab broken @ %04x\n", i); exit(1); }
}
}

View file

@ -104,7 +104,7 @@ static __inline void SekRunM68k(int cyc)
SekCycleCnt+=m68k_execute(cyc_do);
#elif defined(EMU_F68K)
g_m68kcontext=&PicoCpuFM68k;
SekCycleCnt+=fm68k_emulate(cyc_do, 0);
SekCycleCnt+=fm68k_emulate(cyc_do, 0, 0);
#endif
}
@ -124,7 +124,7 @@ static __inline void SekRunS68k(int cyc)
SekCycleCntS68k+=m68k_execute(cyc_do);
#elif defined(EMU_F68K)
g_m68kcontext=&PicoCpuFS68k;
SekCycleCntS68k+=fm68k_emulate(cyc_do, 0);
SekCycleCntS68k+=fm68k_emulate(cyc_do, 0, 0);
#endif
}
@ -138,7 +138,7 @@ static __inline void SekRunPS(int cyc_m68k, int cyc_s68k)
{
SekCycleAim+=cyc_m68k;
SekCycleAimS68k+=cyc_s68k;
fm68k_emulate(0, 1);
fm68k_emulate(0, 1, 0);
}
#else
static __inline void SekRunPS(int cyc_m68k, int cyc_s68k)
@ -164,7 +164,7 @@ static __inline void SekRunPS(int cyc_m68k, int cyc_s68k)
SekCycleCnt += m68k_execute(cyc_do);
#elif defined(EMU_F68K)
g_m68kcontext = &PicoCpuFM68k;
SekCycleCnt += fm68k_emulate(cyc_do, 0);
SekCycleCnt += fm68k_emulate(cyc_do, 0, 0);
#endif
}
if ((cyc_do = SekCycleAimS68k-SekCycleCntS68k-cycn_s68k) > 0) {
@ -177,7 +177,7 @@ static __inline void SekRunPS(int cyc_m68k, int cyc_s68k)
SekCycleCntS68k += m68k_execute(cyc_do);
#elif defined(EMU_F68K)
g_m68kcontext = &PicoCpuFS68k;
SekCycleCntS68k += fm68k_emulate(cyc_do, 0);
SekCycleCntS68k += fm68k_emulate(cyc_do, 0, 0);
#endif
}
}