From c008977e8ec74b68cbccc017620a156cc39b79b2 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 25 Mar 2007 22:21:21 +0000 Subject: [PATCH] 1.31 release git-svn-id: file:///home/notaz/opt/svn/PicoDrive@80 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/Pico.c | 2 ++ Pico/cd/Memory.c | 33 +++++++------------ Pico/cd/Memory.s | 18 ++++++++-- Pico/cd/Pico.c | 2 +- Pico/cd/gfx_cd.c | 30 ++++++++--------- cpu/Cyclone/Cyclone.h | 3 ++ cpu/Cyclone/Main.cpp | 73 +++++++++++++++++++++++++++++++++++++++-- cpu/Cyclone/OpLogic.cpp | 17 ++++++++-- cpu/Cyclone/app.h | 2 +- platform/gp2x/menu.c | 23 +++++++++++-- platform/gp2x/version.h | 2 +- platform/readme.txt | 5 +++ 12 files changed, 160 insertions(+), 50 deletions(-) diff --git a/Pico/Pico.c b/Pico/Pico.c index a594ce3..4847f55 100644 --- a/Pico/Pico.c +++ b/Pico/Pico.c @@ -71,6 +71,8 @@ int PicoReset(int hard) else PicoMemSetup(); PicoMemReset(); SekReset(); + // s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games). + CycloneSetRealTAS(PicoMCD & 1); SekCycleCntT=0; z80_reset(); diff --git a/Pico/cd/Memory.c b/Pico/cd/Memory.c index fc25081..08a4486 100644 --- a/Pico/cd/Memory.c +++ b/Pico/cd/Memory.c @@ -52,7 +52,9 @@ static u32 m68k_reg_read16(u32 a) goto end; case 2: d = (Pico_mcd->s68k_regs[a]<<8) | (Pico_mcd->s68k_regs[a+1]&0xc7); - dprintf("m68k_regs r3: %02x @%06x", (u8)d, SekPc); + // the DMNA delay must only be visible on s68k side (Lunar2, Silpheed) + if (Pico_mcd->m.state_flags&2) { d &= ~1; d |= 2; } + //printf("m68k_regs r3: %02x @%06x\n", (u8)d, SekPc); goto end; case 4: d = Pico_mcd->s68k_regs[4]<<8; @@ -117,7 +119,7 @@ void m68k_reg_write8(u32 a, u32 d) return; case 3: { u32 dold = Pico_mcd->s68k_regs[3]&0x1f; - dprintf("m68k_regs w3: %02x @%06x", (u8)d, SekPc); + //printf("m68k_regs w3: %02x @%06x\n", (u8)d, SekPc); d &= 0xc2; if ((dold>>6) != ((d>>6)&3)) dprintf("m68k: prg bank: %i -> %i", (Pico_mcd->s68k_regs[a]>>6), ((d>>6)&3)); @@ -207,7 +209,7 @@ u32 s68k_reg_read16(u32 a) return ((Pico_mcd->s68k_regs[0]&3)<<8) | 1; // ver = 0, not in reset state case 2: d = (Pico_mcd->s68k_regs[a]<<8) | (Pico_mcd->s68k_regs[a+1]&0x1f); - dprintf("s68k_regs r3: %02x @%06x", (u8)d, SekPcS68k); + //printf("s68k_regs r3: %02x @%06x\n", (u8)d, SekPcS68k); goto poll_detect; case 6: return CDC_Read_Reg(); @@ -279,7 +281,7 @@ void s68k_reg_write8(u32 a, u32 d) return; // only m68k can change WP case 3: { int dold = Pico_mcd->s68k_regs[3]; - dprintf("s68k_regs w3: %02x @%06x", (u8)d, SekPcS68k); + //printf("s68k_regs w3: %02x @%06x\n", (u8)d, SekPcS68k); d &= 0x1d; d |= dold&0xc2; if (d&4) { @@ -482,7 +484,9 @@ static u16 PicoReadM68k16(u32 a) // prg RAM if ((a&0xfe0000)==0x020000 && (Pico_mcd->m.busreq&2)) { u8 *prg_bank = Pico_mcd->prg_ram_b[Pico_mcd->s68k_regs[3]>>6]; + wrdprintf("m68k_prgram r16: [%i,%06x] @%06x", Pico_mcd->s68k_regs[3]>>6, a, SekPc); d = *(u16 *)(prg_bank+(a&0x1fffe)); + wrdprintf("ret = %04x", d); goto end; } @@ -655,6 +659,7 @@ static void PicoWriteM68k16(u32 a,u16 d) // prg RAM if ((a&0xfe0000)==0x020000 && (Pico_mcd->m.busreq&2)) { u8 *prg_bank = Pico_mcd->prg_ram_b[Pico_mcd->s68k_regs[3]>>6]; + wrdprintf("m68k_prgram w16: [%i,%06x] %04x @%06x", Pico_mcd->s68k_regs[3]>>6, a, d, SekPc); *(u16 *)(prg_bank+(a&0x1fffe))=d; return; } @@ -863,7 +868,9 @@ static u16 PicoReadS68k16(u32 a) // prg RAM if (a < 0x80000) { + wrdprintf("s68k_prgram r16: [%06x] @%06x", a, SekPcS68k); d = *(u16 *)(Pico_mcd->prg_ram+a); + wrdprintf("ret = %04x", d); goto end; } @@ -979,7 +986,6 @@ static u32 PicoReadS68k32(u32 a) d = Pico_mcd->word_ram1M[bank][((a+0)^1)&0x1ffff] << 16; d |= Pico_mcd->word_ram1M[bank][((a+1)^1)&0x1ffff]; d |= d << 4; d &= 0x0f0f0f0f; - dprintf("FIXME: decode"); } else { // allow access in any mode, like Gens does u16 *pm=(u16 *)(Pico_mcd->word_ram2M+(a&0x3fffe)); d = (pm[0]<<16)|pm[1]; @@ -1058,8 +1064,6 @@ static void decode_write8(u32 a, u8 d, int r3) d &= 0x0f; if (!(a&1)) d <<= 4; - //dprintf("FIXME: decode, r3 = %02x", r3); - if (r3 == 8) { if ((!(*pd & (~oldmask))) && d) goto do_it; } else if (r3 > 8) { @@ -1097,15 +1101,11 @@ static void decode_write16(u32 a, u16 d, int r3) } else { *pd = d; } - - //dprintf("FIXME: decode"); } #endif // ----------------------------------------------------------------- -//void PicoWriteS68k8_(u32 a,u8 d); -//void PicoWriteS68k8__(u32 a,u8 d); #ifdef _ASM_CD_MEMORY_C void PicoWriteS68k8(u32 a,u8 d); #else @@ -1116,16 +1116,6 @@ static void PicoWriteS68k8(u32 a,u8 d) #endif a&=0xffffff; -#if 0 - PicoWriteS68k8_(a, d); -/* if ((a&0xfc0000)!=0x080000) { - PicoWriteS68k8_(a, d); - return; - } - printf("r3: %02x\n", Pico_mcd->s68k_regs[3]); - PicoWriteS68k8__(a,d);*/ - return; -#endif // prg RAM if (a < 0x80000) { @@ -1205,6 +1195,7 @@ static void PicoWriteS68k16(u32 a,u16 d) // prg RAM if (a < 0x80000) { + wrdprintf("s68k_prgram w16: [%06x] %04x @%06x", a, d, SekPcS68k); *(u16 *)(Pico_mcd->prg_ram+a)=d; return; } diff --git a/Pico/cd/Memory.s b/Pico/cd/Memory.s index 8e1c0a4..d10f1a5 100644 --- a/Pico/cd/Memory.s +++ b/Pico/cd/Memory.s @@ -489,7 +489,13 @@ m_m68k_read8_r02: m_m68k_read8_r03: add r1, r1, #0x110000 ldrb r0, [r1, #3] + add r1, r1, #0x002200 + ldr r1, [r1, #4] and r0, r0, #0xc7 + tst r1, #2 @ DMNA pending? + bxeq lr + bic r0, r0, #1 + orr r0, r0, #2 bx lr m_m68k_read8_r04: add r1, r1, #0x110000 @@ -677,9 +683,15 @@ m_m68k_read16_r00: m_m68k_read16_r02: add r1, r1, #0x110000 ldrb r0, [r1, #2] - ldrb r1, [r1, #3] - and r1, r1, #0xc7 - orr r0, r1, r0, lsl #8 + ldrb r2, [r1, #3] + add r1, r1, #0x002200 + ldr r1, [r1, #4] + and r2, r2, #0xc7 + orr r0, r2, r0, lsl #8 + tst r1, #2 @ DMNA pending? + bxeq lr + bic r0, r0, #1 + orr r0, r0, #2 bx lr m_m68k_read16_r04: add r1, r1, #0x110000 diff --git a/Pico/cd/Pico.c b/Pico/cd/Pico.c index c1c4421..00be7b6 100644 --- a/Pico/cd/Pico.c +++ b/Pico/cd/Pico.c @@ -68,7 +68,7 @@ int PicoResetMCD(int hard) memset(&Pico_mcd->m, 0, sizeof(Pico_mcd->m)); *(unsigned int *)(Pico_mcd->bios + 0x70) = 0xffffffff; // reset hint vector (simplest way to implement reg6) - Pico_mcd->m.state_flags |= 2; // s68k reset pending + Pico_mcd->m.state_flags |= 1; // s68k reset pending Pico_mcd->s68k_regs[3] = 1; // 2M word RAM mode with m68k access after reset Reset_CD(); diff --git a/Pico/cd/gfx_cd.c b/Pico/cd/gfx_cd.c index f902235..120b0dd 100644 --- a/Pico/cd/gfx_cd.c +++ b/Pico/cd/gfx_cd.c @@ -31,8 +31,6 @@ static void gfx_cd_start(void) { int upd_len; - dprintf("gfx_cd_start()"); - // rot_comp.XD_Mul = ((rot_comp.Reg_5C & 0x1f) + 1) * 4; // unused rot_comp.Function = (rot_comp.Reg_58 & 7) | (Pico_mcd->s68k_regs[3] & 0x18); // Jmp_Adr // rot_comp.Buffer_Adr = (rot_comp.Reg_5E & 0xfff8) << 2; // unused? @@ -61,6 +59,8 @@ static void gfx_cd_start(void) break; } + dprintf("gfx_cd_start, stamp_map_addr=%06x", rot_comp.Stamp_Map_Adr); + gfx_cd_update(); } @@ -95,6 +95,18 @@ static void gfx_do(unsigned int func, unsigned short *stamp_base, unsigned int H // MAKE_IMAGE_LINE while (H_Dot) { + // MAKE_IMAGE_PIXEL + if (!(func & 1)) // NOT TILED + { + int mask = (func & 4) ? 0x00800000 : 0x00f80000; + if ((ecx | edx) & mask) + { + if (func & 0x18) goto Next_Pixel; + pixel = 0; + goto Pixel_Out; + } + } + if (func & 2) // mode 32x32 dot { if (func & 4) // 16x16 screen @@ -122,19 +134,7 @@ static void gfx_do(unsigned int func, unsigned short *stamp_base, unsigned int H } } - // MAKE_IMAGE_PIXEL - if (!(func & 1)) // NOT TILED - { - int mask = (func & 4) ? 0x00800000 : 0x00f80000; - if ((ecx | edx) & mask) - { - if (func & 0x18) goto Next_Pixel; - pixel = 0; - goto Pixel_Out; - } - } - - edi = stamp_base[ebx];// | (stamp_base[ebx+1] << 16); + edi = stamp_base[ebx]; esi = (edi & 0x7ff) << 7; if (!esi) { pixel = 0; goto Pixel_Out; } edi >>= (11+1); diff --git a/cpu/Cyclone/Cyclone.h b/cpu/Cyclone/Cyclone.h index 8913c26..fe53bb8 100644 --- a/cpu/Cyclone/Cyclone.h +++ b/cpu/Cyclone/Cyclone.h @@ -53,6 +53,9 @@ void CycloneRun(struct Cyclone *pcy); void CycloneSetSr(struct Cyclone *pcy, unsigned int sr); // auto-swaps a7<->osp if detects supervisor change unsigned int CycloneGetSr(struct Cyclone *pcy); +// genesis: if 1, switch to normal TAS handlers +void CycloneSetRealTAS(int use_real); + #ifdef __cplusplus } // End of extern "C" #endif diff --git a/cpu/Cyclone/Main.cpp b/cpu/Cyclone/Main.cpp index 3bb129d..a85aebc 100644 --- a/cpu/Cyclone/Main.cpp +++ b/cpu/Cyclone/Main.cpp @@ -32,6 +32,51 @@ void ltorg() else ot(" .ltorg\n"); } +#if CYCLONE_FOR_GENESIS +// r12=ptr to tas in table, trashes r0,r1 +static void ChangeTAS(int norm) +{ + ot(" ldr r0,=Op4ad0%s\n",norm?"_":""); + ot(" mov r1,#8\n"); + ot("setrtas_loop%i0%s ;@ 4ad0-4ad7\n",norm,ms?"":":"); + ot(" subs r1,r1,#1\n"); + ot(" str r0,[r12],#4\n"); + ot(" bne setrtas_loop%i0\n",norm); + ot(" ldr r0,=Op4ad8%s\n",norm?"_":""); + ot(" mov r1,#7\n"); + ot("setrtas_loop%i1%s ;@ 4ad8-4ade\n",norm,ms?"":":"); + ot(" subs r1,r1,#1\n"); + ot(" str r0,[r12],#4\n"); + ot(" bne setrtas_loop%i1\n",norm); + ot(" ldr r0,=Op4adf%s\n",norm?"_":""); + ot(" str r0,[r12],#4\n"); + ot(" ldr r0,=Op4ae0%s\n",norm?"_":""); + ot(" mov r1,#7\n"); + ot("setrtas_loop%i2%s ;@ 4ae0-4ae6\n",norm,ms?"":":"); + ot(" subs r1,r1,#1\n"); + ot(" str r0,[r12],#4\n"); + ot(" bne setrtas_loop%i2\n",norm); + ot(" ldr r0,=Op4ae7%s\n",norm?"_":""); + ot(" str r0,[r12],#4\n"); + ot(" ldr r0,=Op4ae8%s\n",norm?"_":""); + ot(" mov r1,#8\n"); + ot("setrtas_loop%i3%s ;@ 4ae8-4aef\n",norm,ms?"":":"); + ot(" subs r1,r1,#1\n"); + ot(" str r0,[r12],#4\n"); + ot(" bne setrtas_loop%i3\n",norm); + ot(" ldr r0,=Op4af0%s\n",norm?"_":""); + ot(" mov r1,#8\n"); + ot("setrtas_loop%i4%s ;@ 4af0-4af7\n",norm,ms?"":":"); + ot(" subs r1,r1,#1\n"); + ot(" str r0,[r12],#4\n"); + ot(" bne setrtas_loop%i4\n",norm); + ot(" ldr r0,=Op4af8%s\n",norm?"_":""); + ot(" str r0,[r12],#4\n"); + ot(" ldr r0,=Op4af9%s\n",norm?"_":""); + ot(" str r0,[r12],#4\n"); +} +#endif + // trashes all temp regs static void PrintException(int ints) { @@ -259,6 +304,26 @@ static void PrintFramework() ot(" bx lr\n"); ot("\n"); + if (ms) ot("CycloneSetRealTAS\n"); + else ot("CycloneSetRealTAS:\n"); +#if CYCLONE_FOR_GENESIS + ot(" ldr r12,=CycloneJumpTab\n"); + ot(" tst r0,r0\n"); + ot(" add r12,r12,#0x4a00*4\n"); + ot(" add r12,r12,#0x00d0*4\n"); + ot(" beq setrtas_off\n"); + ChangeTAS(1); + ot(" bx lr\n"); + ot("setrtas_off%s\n",ms?"":":"); + ChangeTAS(0); + ot(" bx lr\n"); + ltorg(); + ot("\n"); +#else + ot(" bx lr\n"); + ot("\n"); +#endif + ot(";@ DoInterrupt - r0=IRQ number\n"); ot("CycloneDoInterrupt%s\n", ms?"":":"); ot(" stmdb sp!,{lr} ;@ Push ARM return address\n"); @@ -470,6 +535,9 @@ static void PrintJumpTable() ot(";@ -------------------------- Jump Table --------------------------\n"); + // space for decompressed table + ot(ms?" area |.data|, data\n":" .data\n .align 4\n\n"); + #if COMPRESS_JUMPTABLE int handlers=0,reps=0,*indexes,ip,u,out; // use some weird compression on the jump table @@ -477,9 +545,6 @@ static void PrintJumpTable() if(!indexes) { printf("ERROR: out of memory\n"); exit(1); } len=0x10000; - // space for decompressed table - ot(ms?" area |.data|, data\n":" .data\n .align 4\n\n"); - ot("CycloneJumpTab%s\n", ms?"":":"); if(ms) { for(i = 0; i < 0xa000/8; i++) @@ -607,6 +672,7 @@ static int CycloneMake() ot(" export CycloneRun\n"); ot(" export CycloneSetSr\n"); ot(" export CycloneGetSr\n"); + ot(" export CycloneSetRealTAS\n"); ot(" export CycloneVer\n"); ot("\n"); ot("CycloneVer dcd 0x%.4x\n",CycloneVer); @@ -617,6 +683,7 @@ static int CycloneMake() ot(" .global CycloneRun\n"); ot(" .global CycloneSetSr\n"); ot(" .global CycloneGetSr\n"); + ot(" .global CycloneSetRealTAS\n"); ot(" .global CycloneVer\n"); #ifdef CYCLONE_FOR_PICODRIVE ot(" .global CycloneDoInterrupt\n"); diff --git a/cpu/Cyclone/OpLogic.cpp b/cpu/Cyclone/OpLogic.cpp index 4a795e4..d0eafec 100644 --- a/cpu/Cyclone/OpLogic.cpp +++ b/cpu/Cyclone/OpLogic.cpp @@ -632,7 +632,7 @@ int OpAsrEa(int op) return 0; } -int OpTas(int op) +int OpTas(int op, int gen_special) { int ea=0; int use=0; @@ -645,7 +645,11 @@ int OpTas(int op) use=OpBase(op); if (op!=use) { OpUse(op,use); return 0; } // Use existing handler - OpStart(op); Cycles=4; + if (!gen_special) OpStart(op); + else + ot("Op%.4x_%s\n", op, ms?"":":"); + + Cycles=4; if(ea>=8) Cycles+=10; EaCalc (10,0x003f,ea,0,1); @@ -657,7 +661,7 @@ int OpTas(int op) #if CYCLONE_FOR_GENESIS // the original Sega hardware ignores write-back phase (to memory only) - if (ea < 0x10) { + if (ea < 0x10 || gen_special) { #endif ot(" orr r1,r1,#0x80000000 ;@ set bit7\n"); @@ -667,6 +671,13 @@ int OpTas(int op) #endif OpEnd(); + +#if CYCLONE_FOR_GENESIS + if (!gen_special && ea >= 0x10) { + OpTas(op, 1); + } +#endif + return 0; } diff --git a/cpu/Cyclone/app.h b/cpu/Cyclone/app.h index c260c2f..e8fb212 100644 --- a/cpu/Cyclone/app.h +++ b/cpu/Cyclone/app.h @@ -79,7 +79,7 @@ int OpExt(int op); int OpSet(int op); int OpAsr(int op); int OpAsrEa(int op); -int OpTas(int op); +int OpTas(int op, int gen_special=0); // OpMove.cpp int OpMove(int op); diff --git a/platform/gp2x/menu.c b/platform/gp2x/menu.c index 47b91b1..30f681a 100644 --- a/platform/gp2x/menu.c +++ b/platform/gp2x/menu.c @@ -286,6 +286,25 @@ static int scandir_cmp(const void *p1, const void *p2) return alphasort(d1, d2); } +static char *filter_exts[] = { ".mp3", ".MP3", ".srm", ".brm", "s.gz", ".mds", "bcfg", ".txt", ".htm", "html", ".gpe" }; + +static int scandir_filter(const struct dirent *ent) +{ + const char *p; + int i; + + if (ent == NULL || ent->d_name == NULL) return 0; + if (strlen(ent->d_name) < 5) return 1; + + p = ent->d_name + strlen(ent->d_name) - 4; + + for (i = 0; i < sizeof(filter_exts)/sizeof(filter_exts[0]); i++) + { + if (strcmp(p, filter_exts[i]) == 0) return 0; + } + + return 1; +} static char *romsel_loop(char *curr_path) { @@ -305,10 +324,10 @@ static char *romsel_loop(char *curr_path) fname = p+1; } - n = scandir(curr_path, &namelist, 0, scandir_cmp); + n = scandir(curr_path, &namelist, scandir_filter, scandir_cmp); if (n < 0) { // try root - n = scandir(curr_path, &namelist, 0, scandir_cmp); + n = scandir("/", &namelist, scandir_filter, scandir_cmp); if (n < 0) { // oops, we failed printf("dir: "); printf(curr_path); printf("\n"); diff --git a/platform/gp2x/version.h b/platform/gp2x/version.h index 7bb0de2..1725e8d 100644 --- a/platform/gp2x/version.h +++ b/platform/gp2x/version.h @@ -1,2 +1,2 @@ -#define VERSION "1.30" +#define VERSION "1.31" diff --git a/platform/readme.txt b/platform/readme.txt index 7a1ffea..c658bdd 100644 --- a/platform/readme.txt +++ b/platform/readme.txt @@ -214,6 +214,11 @@ Symbian: Changelog --------- +1.31 + * Changed the way memory mode register is read (fixes Lunar 2, broken in 1.30). + * Fixed TAS opcode on sub-68k side (fixes Batman games). + * File browser now filters out mp3s, saves and some other files, which are not ROMS. + 1.30 + ISO files now can be zipped. Note that this causes VERY long loading times. + Added data pre-buffering support, this allows to reduce frequency of short pauses -- 2.39.2