From: notaz Date: Sun, 14 Jan 2007 22:40:03 +0000 (+0000) Subject: gfx chip faker, hint vector X-Git-Tag: v1.85~767 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1df87866b45a5ab9f1b6c6c8a40da6a3a777f83;p=picodrive.git gfx chip faker, hint vector git-svn-id: file:///home/notaz/opt/svn/PicoDrive@20 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index fa7f7ece..c85b99f7 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -161,6 +161,7 @@ struct PicoSRAM // MCD #include "cd/cd_sys.h" #include "cd/LC89510.h" +#include "cd/gfx_cd.h" struct mcd_misc { @@ -183,6 +184,7 @@ typedef struct CDD cdd; CDC cdc; _scd scd; + Rot_Comp rot_comp; struct mcd_misc m; } mcd_state; diff --git a/Pico/cd/Memory.c b/Pico/cd/Memory.c index 21cc12a8..58fb5c20 100644 --- a/Pico/cd/Memory.c +++ b/Pico/cd/Memory.c @@ -24,8 +24,8 @@ typedef unsigned int u32; //#define __debug_io //#define __debug_io2 -#define rdprintf dprintf -//#define rdprintf(...) +//#define rdprintf dprintf +#define rdprintf(...) // ----------------------------------------------------------------- @@ -61,7 +61,7 @@ static u32 m68k_reg_read16(u32 a) dprintf("m68k reserved read"); goto end; case 0xC: - dprintf("m68k stopwatch read"); + dprintf("m68k stopwatch timer read"); break; } @@ -118,9 +118,11 @@ static void m68k_reg_write8(u32 a, u32 d) return; case 6: *((char *)&Pico_mcd->m.hint_vector+1) = d; + Pico_mcd->bios[0x72 + 1] = d; // simple hint vector changer return; case 7: *(char *)&Pico_mcd->m.hint_vector = d; + Pico_mcd->bios[0x72] = d; return; case 0xe: //dprintf("m68k: comm flag: %02x", d); @@ -162,7 +164,10 @@ static u32 s68k_reg_read16(u32 a) d = Read_CDC_Host(1); // Gens returns 0 here on byte reads goto end; case 0xC: - dprintf("s68k stopwatch read"); + dprintf("s68k stopwatch timer read"); + break; + case 0x30: + dprintf("s68k int3 timer read"); break; case 0x34: // fader d = 0; // no busy bit @@ -210,6 +215,12 @@ static void s68k_reg_write8(u32 a, u32 d) case 0xa: dprintf("s68k set CDC dma addr"); break; + case 0xc: + dprintf("s68k set stopwatch timer"); + break; + case 0x31: + dprintf("s68k set int3 timer"); + break; case 0x33: // IRQ mask dprintf("s68k irq mask: %02x", d); if ((d&(1<<4)) && (Pico_mcd->s68k_regs[0x37]&4) && !(Pico_mcd->s68k_regs[0x33]&(1<<4))) { diff --git a/Pico/cd/Pico.c b/Pico/cd/Pico.c index 573322cd..9e87e9ed 100644 --- a/Pico/cd/Pico.c +++ b/Pico/cd/Pico.c @@ -32,6 +32,7 @@ int PicoResetMCD(int hard) { // clear everything except BIOS memset(Pico_mcd->prg_ram, 0, sizeof(mcd_state) - sizeof(Pico_mcd->bios)); + *(unsigned int *)(Pico_mcd->bios + 0x70) = 0xffffffff; // reset hint vector (simplest way to implement reg6) PicoMCD |= 2; // s68k reset pending Pico_mcd->s68k_regs[3] = 1; // 2M word RAM mode with m68k access after reset counter75hz = 0; @@ -209,6 +210,9 @@ static int PicoFrameHintsMCD(void) counter75hz -= counter75hz_lim; Check_CD_Command(); } + + if (Pico_mcd->rot_comp.Reg_58 & 0x8000) + gfx_cd_update(); } // draw a frame just after vblank in alternative render mode diff --git a/Pico/cd/gfx_cd.c b/Pico/cd/gfx_cd.c index f104f69f..4f393bd5 100644 --- a/Pico/cd/gfx_cd.c +++ b/Pico/cd/gfx_cd.c @@ -2,10 +2,83 @@ #include "../PicoInt.h" +#define rot_comp Pico_mcd->rot_comp + +static int Table_Rot_Time[] = +{ + 0x00054000, 0x00048000, 0x00040000, 0x00036000, //; 008-032 ; briefing - sprite + 0x0002E000, 0x00028000, 0x00024000, 0x00022000, //; 036-064 ; arbre souvent + 0x00021000, 0x00020000, 0x0001E000, 0x0001B800, //; 068-096 ; map thunderstrike + 0x00019800, 0x00017A00, 0x00015C00, 0x00013E00, //; 100-128 ; logo défoncé + + 0x00012000, 0x00011800, 0x00011000, 0x00010800, //; 132-160 ; briefing - map + 0x00010000, 0x0000F800, 0x0000F000, 0x0000E800, //; 164-192 + 0x0000E000, 0x0000D800, 0x0000D000, 0x0000C800, //; 196-224 + 0x0000C000, 0x0000B800, 0x0000B000, 0x0000A800, //; 228-256 ; batman visage + + 0x0000A000, 0x00009F00, 0x00009E00, 0x00009D00, //; 260-288 + 0x00009C00, 0x00009B00, 0x00009A00, 0x00009900, //; 292-320 + 0x00009800, 0x00009700, 0x00009600, 0x00009500, //; 324-352 + 0x00009400, 0x00009300, 0x00009200, 0x00009100, //; 356-384 + + 0x00009000, 0x00008F00, 0x00008E00, 0x00008D00, //; 388-416 + 0x00008C00, 0x00008B00, 0x00008A00, 0x00008900, //; 420-448 + 0x00008800, 0x00008700, 0x00008600, 0x00008500, //; 452-476 + 0x00008400, 0x00008300, 0x00008200, 0x00008100, //; 480-512 +}; + + +#if 1*0 +typedef struct +{ + unsigned int Reg_58; // Stamp_Size + unsigned int Reg_5A; + unsigned int Reg_5C; + unsigned int Reg_5E; + unsigned int Reg_60; + unsigned int Reg_62; + unsigned int Reg_64; // V_Dot + unsigned int Reg_66; + + unsigned int Stamp_Map_Adr; + unsigned int Buffer_Adr; + unsigned int Vector_Adr; + unsigned int Jmp_Adr; + unsigned int Float_Part; + unsigned int Draw_Speed; + + unsigned int XS; + unsigned int YS; + unsigned int DXS; + unsigned int DYS; + unsigned int XD; + unsigned int YD; + unsigned int XD_Mul; + unsigned int H_Dot; +} Rot_Comp; +#endif static void gfx_cd_start(void) { - dprintf("gfx_cd_start()"); + int upd_len; + + dprintf("gfx_cd_start()"); + + upd_len = (rot_comp.Reg_62 >> 3) & 0x3f; + upd_len = Table_Rot_Time[upd_len]; + + rot_comp.Draw_Speed = rot_comp.Float_Part = upd_len; + + rot_comp.Reg_58 |= 0x8000; // Stamp_Size, we start a new GFX operation + + gfx_cd_update(); +} + + +static void gfx_completed(void) +{ + rot_comp.Reg_58 &= 0x7fff; // Stamp_Size + rot_comp.Reg_64 = 0; if (Pico_mcd->s68k_regs[0x33] & (1<<1)) { dprintf("gfx_cd irq 1"); @@ -13,18 +86,70 @@ static void gfx_cd_start(void) } } + +//static void gfx_do(void) +//{ +//} + + void gfx_cd_update(void) { + unsigned char *V_Dot = (unsigned char *) &rot_comp.Reg_64; + int jobs; + + dprintf("gfx_cd_update, Reg_64 = %04x", rot_comp.Reg_64); + + if (!*V_Dot) + { + // ... + gfx_completed(); + return; + } + + jobs = rot_comp.Float_Part >> 16; + + if (!jobs) + { + rot_comp.Float_Part += rot_comp.Draw_Speed; + return; + } + + rot_comp.Float_Part &= 0xffff; + rot_comp.Float_Part += rot_comp.Draw_Speed; + + while (jobs--) + { + // jmp [Jmp_Adr]: + (*V_Dot)--; // dec byte [V_Dot] + + if (!*V_Dot) + { + // GFX_Completed: + gfx_completed(); + return; + } + } } unsigned int gfx_cd_read(unsigned int a) { - dprintf("gfx_cd_read(%x)", a); + unsigned int d = 0; + + switch (a) { + case 0x58: d = rot_comp.Reg_58; break; + case 0x5A: d = rot_comp.Reg_5A; break; + case 0x5C: d = rot_comp.Reg_5C; break; + case 0x5E: d = rot_comp.Reg_5E; break; + case 0x60: d = rot_comp.Reg_60; break; + case 0x62: d = rot_comp.Reg_62; break; + case 0x64: d = rot_comp.Reg_64; break; + case 0x66: break; + default: dprintf("gfx_cd_read: unexpected address: %02x", a); break; + } + + dprintf("gfx_cd_read(%02x) = %04x", a, d); -// switch (a) { -// case 2: -// return; return 0; } @@ -33,10 +158,42 @@ void gfx_cd_write(unsigned int a, unsigned int d) dprintf("gfx_cd_write(%x, %04x)", a, d); switch (a) { - case 0x66: + case 0x58: // .Reg_Stamp_Size + rot_comp.Reg_58 = d & 7; + return; + + case 0x5A: // .Reg_Stamp_Adr + rot_comp.Reg_5A = d & 0xffe0; + return; + + case 0x5C: // .Reg_IM_VCell_Size + rot_comp.Reg_5C = d & 0x1f; + return; + + case 0x5E: // .Reg_IM_Adr + rot_comp.Reg_5E = d & 0xFFF8; + return; + + case 0x60: // .Reg_IM_Offset + rot_comp.Reg_60 = d & 0x3f; + return; + + case 0x62: // .Reg_IM_HDot_Size + rot_comp.Reg_62 = d & 0x1ff; + return; + + case 0x64: // .Reg_IM_VDot_Size + rot_comp.Reg_64 = d & 0xff; // V_Dot, must be 32bit? + return; + + case 0x66: // .Reg_Vector_Adr + rot_comp.Reg_66 = d & 0xfffe; if (Pico_mcd->s68k_regs[3]&4) return; // can't do tanformations in 1M mode gfx_cd_start(); return; + + default: dprintf("gfx_cd_write: unexpected address: %02x", a); return; } } + diff --git a/Pico/cd/gfx_cd.h b/Pico/cd/gfx_cd.h index 848fd040..cc200ac9 100644 --- a/Pico/cd/gfx_cd.h +++ b/Pico/cd/gfx_cd.h @@ -1,3 +1,34 @@ +#ifndef _GFX_CD_H +#define _GFX_CD_H + + +typedef struct +{ + unsigned int Reg_58; // Stamp_Size + unsigned int Reg_5A; + unsigned int Reg_5C; + unsigned int Reg_5E; + unsigned int Reg_60; + unsigned int Reg_62; + unsigned int Reg_64; // V_Dot + unsigned int Reg_66; + + unsigned int Stamp_Map_Adr; + unsigned int Buffer_Adr; + unsigned int Vector_Adr; + unsigned int Jmp_Adr; + unsigned int Float_Part; + unsigned int Draw_Speed; + + unsigned int XS; + unsigned int YS; + unsigned int DXS; + unsigned int DYS; + unsigned int XD; + unsigned int YD; + unsigned int XD_Mul; + unsigned int H_Dot; +} Rot_Comp; void gfx_cd_update(void); @@ -5,3 +36,5 @@ void gfx_cd_update(void); unsigned int gfx_cd_read(unsigned int a); void gfx_cd_write(unsigned int a, unsigned int d); +#endif // _GFX_CD_H +