loading msgs, bugfixes

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@69 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-03-16 20:59:11 +00:00
parent 7336a99a49
commit 66fdc0f0d5
13 changed files with 93 additions and 49 deletions

View file

@ -129,6 +129,11 @@ int pm_seek(pm_file *stream, long offset, int whence)
}
else if (stream->type == PMT_ZIP)
{
if (PicoMessage != NULL && offset > 6*1024*1024) {
long pos = gztell((gzFile) stream->param);
if (offset < pos || offset - pos > 6*1024*1024)
PicoMessage("Decompressing data...");
}
return gzseek((gzFile) stream->param, offset, whence);
}
else

View file

@ -384,7 +384,7 @@ m_read8_above_rom:
stmfd sp!,{r0,lr}
bic r0, r0, #1
mov r1, #8
bl UnusualRead16
bl OtherRead16End
ldmfd sp!,{r1,lr}
tst r1, #1
moveq r0, r0, lsr #8
@ -507,7 +507,7 @@ m_read16_ram:
m_read16_above_rom:
mov r1, #16
ldr r2, =UnusualRead16
ldr r2, =OtherRead16End
bic r0, r0, #1
bx r2
@ -657,13 +657,13 @@ m_read32_above_rom:
bic r0, r0, #1
stmfd sp!,{r0,lr}
mov r1, #32
bl UnusualRead16
bl OtherRead16End
mov r1, r0
ldmfd sp!,{r0}
stmfd sp!,{r1}
add r0, r0, #2
mov r1, #32
bl UnusualRead16
bl OtherRead16End
ldmfd sp!,{r1,lr}
orr r0, r0, r1, lsl #16
bx lr

View file

@ -98,15 +98,14 @@ u32 OtherRead16(u32 a, int realsize)
// |=0x80 for Shadow of the Beast & Super Offroad; rotate fakes next fetched instruction for Time Killers
if (a==0xa11100) { // z80 busreq
d=Pico.m.z80Run&1;
#if 0
if (!d) {
// do we need this?
// needed by buggy Terminator (Sega CD)
extern int z80stopCycle;
int stop_before = SekCyclesDone() - z80stopCycle;
if (stop_before > 0 && stop_before <= 16) // Gens uses 16 here
dprintf("stop before: %i", stop_before);
if (stop_before > 0 && stop_before <= 32) // Gens uses 16 here
d = 1; // bus not yet available
}
#endif
d=(d<<8)|0x8000|Pico.m.rotate++;
dprintf("get_zrun: %04x [%i|%i] @%06x", d, Pico.m.scanline, SekCyclesDone(), SekPc);
goto end;

View file

@ -636,19 +636,8 @@ int PicoFrame(void)
return 0;
}
static int DefaultCram(int cram)
{
int high=0x0841;
// Convert 0000bbbb ggggrrrr
// to rrrr1ggg g10bbbb1
high|=(cram&0x00f)<<12; // Red
high|=(cram&0x0f0)<< 3; // Green
high|=(cram&0xf00)>> 7; // Blue
return high;
}
// Function to convert Megadrive Cram into a native colour:
int (*PicoCram)(int cram)=DefaultCram;
// callback to output message from emu
void (*PicoMessage)(const char *msg)=NULL;
#if defined(__DEBUG_PRINT) || defined(WIN32)
// tmp debug: dump some stuff

View file

@ -42,8 +42,8 @@ void PicoExit(void);
int PicoReset(int hard);
int PicoFrame(void);
extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU
extern int (*PicoCram)(int cram); // Callback to convert colour ram 0000bbb0 ggg0rrr0
extern void (*PicoWriteSound)(int len); // called once per frame at the best time to send sound buffer (PsndOut) to hardware
extern void (*PicoMessage)(const char *msg); // callback to output text message from emu
int PicoFrameMCD(void);

View file

@ -27,6 +27,7 @@ typedef unsigned int u32;
//#define __debug_io
//#define __debug_io2
//#define rdprintf dprintf
#define rdprintf(...)
//#define wrdprintf dprintf
@ -106,18 +107,30 @@ static void m68k_reg_write8(u32 a, u32 d)
case 2:
Pico_mcd->s68k_regs[2] = d; // really use s68k side register
return;
case 3:
case 3: {
u32 dold = Pico_mcd->s68k_regs[3]&0x1f;
dprintf("m68k_regs w3: %02x @%06x", (u8)d, SekPc);
d &= 0xc2;
if ((Pico_mcd->s68k_regs[3]>>6) != ((d>>6)&3))
if ((dold>>6) != ((d>>6)&3))
dprintf("m68k: prg bank: %i -> %i", (Pico_mcd->s68k_regs[a]>>6), ((d>>6)&3));
//if ((Pico_mcd->s68k_regs[3]&4) != (d&4)) dprintf("m68k: ram mode %i mbit", (d&4) ? 1 : 2);
//if ((Pico_mcd->s68k_regs[3]&2) != (d&2)) dprintf("m68k: %s", (d&4) ? ((d&2) ? "word swap req" : "noop?") :
// ((d&2) ? "word ram to s68k" : "word ram to m68k"));
d |= Pico_mcd->s68k_regs[3]&0x1d;
if (!(d & 4) && (d & 2)) d &= ~1; // return word RAM to s68k in 2M mode
Pico_mcd->s68k_regs[3] = d; // really use s68k side register
if (dold & 4) {
d ^= 2; // writing 0 to DMNA actually sets it, 1 does nothing
} else {
//dold &= ~2; // ??
if (d & 2) dold &= ~1; // return word RAM to s68k in 2M mode
}
Pico_mcd->s68k_regs[3] = d | dold; // really use s68k side register
/*
d |= Pico_mcd->s68k_regs[3]&0x1d;
if (!(d & 4) && (d & 2)) d &= ~1; // return word RAM to s68k in 2M mode
Pico_mcd->s68k_regs[3] = d; // really use s68k side register
*/
return;
}
case 6:
Pico_mcd->bios[0x72 + 1] = d; // simple hint vector changer
return;

View file

@ -83,8 +83,9 @@ schedule_s68k:
ldr r9, [r9]
sub r0, r9, r8
add r3, r3, r3, asr #1
add r3, r3, r3, asr #3 @ cycn_s68k = (cycn + cycn/2 + cycn/8)
mov r2, r3
add r3, r3, r2, asr #1
add r3, r3, r2, asr #3 @ cycn_s68k = (cycn + cycn/2 + cycn/8)
subs r5, r0, r3, asr #16
ble schedule_m68k @ s68k has not enough cycles
@ -148,31 +149,29 @@ CycloneRunLocal:
;@ r7 = Pointer to Cpu Context
;@ r8 = Current Opcode
ldrb r9,[r7,#0x46] ;@ r9 = Flags (NZCV)
ldr r0,[r7,#0x44]
mov r9,r9,lsl #28 ;@ r9 = Flags 0xf0000000, cpsr format
ldr r1,[r7,#0x44] ;@ get SR high and IRQ level
orr r9,r9,r9,lsl #28 ;@ r9 = Flags 0xf0000000, cpsr format
;@ r10 = Source value / Memory Base
;@ CheckInterrupt:
movs r0,r0,lsr #24 ;@ Get IRQ level
movs r0,r1,lsr #24 ;@ Get IRQ level
beq NoIntsLocal
cmp r0,#6 ;@ irq>6 ?
ldrleb r1,[r7,#0x44] ;@ Get SR high: T_S__III
andle r1,r1,#7 ;@ Get interrupt mask
cmple r0,r1 ;@ irq<=6: Is irq<=mask ?
blgt CycloneDoInterrupt
;@ Check if interrupt used up all the cycles:
subs r5,r5,#0
ldrlt r1,[r7,#0x54]
bxlt r1 ;@ jump to alternative CycloneEnd
ldrgt lr,[r7,#0x54] @ Interrupt will definitely use more cycles than our step,
bgt CycloneDoInterrupt @ so make this function return directly to CycloneEnd_*
NoIntsLocal:
;@ Check if our processor is in stopped state and jump to opcode handler if not
;@ Check if our processor is in stopped state and jump to opcode handler if not
ldr r0,[r7,#0x58]
ldrh r8,[r4],#2 ;@ Fetch first opcode
tst r0,r0 ;@ stopped?
andeq r9,r9,#0xf0000000
ldreq pc,[r6,r8,asl #2] ;@ Jump to opcode handler
@ stopped
sub r4,r4,#2
ldr r1,[r7,#0x54]
mov r5,#0
bx r1

View file

@ -49,7 +49,7 @@ void PicoCDBufferFree(void)
/* this is a try to fight slow SD access of GP2X */
void PicoCDBufferRead(void *dest, int lba)
{
int is_bin, offs, read_len;
int is_bin, offs, read_len, moved = 0;
reads++;
is_bin = Pico_mcd->TOC.Tracks[0].ftype == TYPE_BIN;
@ -84,15 +84,21 @@ void PicoCDBufferRead(void *dest, int lba)
if (lba < prev_lba && prev_lba - lba < PicoCDBuffers)
{
dprintf("CD buffer move");
read_len = prev_lba - lba;
dprintf("CD buffer move=%i, read_len=%i", PicoCDBuffers - read_len, read_len);
memmove(cd_buffer + read_len*2048, cd_buffer, (PicoCDBuffers - read_len)*2048);
moved = 1;
}
else
{
read_len = PicoCDBuffers;
}
if (PicoMessage != NULL && read_len >= 512)
{
PicoMessage("Buffering data...");
}
if (is_bin)
{
int i;
@ -108,5 +114,14 @@ void PicoCDBufferRead(void *dest, int lba)
}
memcpy32(dest, (int *) cd_buffer, 2048/4);
prev_lba = lba;
if (moved)
{
/* file pointer must point to the same data in file, as would-be data after our buffer */
int where_seek;
lba += PicoCDBuffers;
where_seek = is_bin ? (lba * 2352 + 16) : (lba << 11);
pm_seek(Pico_mcd->TOC.Tracks[0].F, where_seek, SEEK_SET);
}
}