X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fvideoport.c;h=fe96139f05c7158582c9a6593e5fe05ab09388f3;hb=12f89605e36fe5e901b28bf85f246faa128cbdfe;hp=3f26d581ecb13b56918b35e377d10edbea9836a4;hpb=0c7d1ba332b26f4ac67199e8ecbb826651f8512a;p=picodrive.git diff --git a/pico/videoport.c b/pico/videoport.c index 3f26d58..fe96139 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -29,6 +29,13 @@ static __inline void AutoIncrement(void) Pico.video.addr=(unsigned short)(Pico.video.addr+Pico.video.reg[0xf]); } +static NOINLINE void VideoWrite128(u32 a, u16 d) +{ + // nasty + a = ((a & 2) >> 1) | ((a & 0x400) >> 9) | (a & 0x3FC) | ((a & 0x1F800) >> 1); + ((u8 *)Pico.vram)[a] = d; +} + static void VideoWrite(u16 d) { unsigned int a=Pico.video.addr; @@ -43,6 +50,10 @@ static void VideoWrite(u16 d) case 3: Pico.m.dirtyPal = 1; Pico.cram [(a>>1)&0x003f]=d; break; // wraps (Desert Strike) case 5: Pico.vsram[(a>>1)&0x003f]=d; break; + case 0x81: + a |= Pico.video.addr_u << 16; + VideoWrite128(a, d); + break; //default:elprintf(EL_ANOMALY, "VDP write %04x with bad type %i", d, Pico.video.type); break; } @@ -186,6 +197,17 @@ static void DmaSlow(int len, unsigned int source) } break; + case 0x81: // vram 128k + a |= Pico.video.addr_u << 16; + for(; len; len--) + { + VideoWrite128(a, base[source++ & mask]); + // AutoIncrement + a = (a + inc) & 0x1ffff; + } + Pico.video.addr_u = a >> 16; + break; + default: if (Pico.video.type != 0 || (EL_LOGMASK & EL_VDPDMA)) elprintf(EL_VDPDMA|EL_ANOMALY, "DMA with bad type %i", Pico.video.type); @@ -303,20 +325,23 @@ static NOINLINE void CommandDma(void) Pico.video.reg[0x16] = source >> 8; } -static void CommandChange(void) +static NOINLINE void CommandChange(void) { - struct PicoVideo *pvid=&Pico.video; - unsigned int cmd=0,addr=0; + struct PicoVideo *pvid = &Pico.video; + unsigned int cmd, addr; - cmd=pvid->command; + cmd = pvid->command; // Get type of transfer 0xc0000030 (v/c/vsram read/write) - pvid->type=(unsigned char)(((cmd>>2)&0xc)|(cmd>>30)); + pvid->type = (u8)(((cmd >> 2) & 0xc) | (cmd >> 30)); + if (pvid->type == 1) // vram + pvid->type |= pvid->reg[1] & 0x80; // 128k // Get address 0x3fff0003 - addr =(cmd>>16)&0x3fff; - addr|=(cmd<<14)&0xc000; - pvid->addr=(unsigned short)addr; + addr = (cmd >> 16) & 0x3fff; + addr |= (cmd << 14) & 0xc000; + pvid->addr = (u16)addr; + pvid->addr_u = (u8)((cmd >> 2) & 1); } static void DrawSync(int blank_on) @@ -336,8 +361,9 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) // elprintf(EL_STATUS, "PicoVideoWrite [%06x] %04x", a, d); a&=0x1c; - if (a==0x00) // Data port 0 or 2 + switch (a) { + case 0x00: // Data port 0 or 2 // try avoiding the sync.. if (Pico.m.scanline < 224 && (pvid->reg[1]&0x40) && !(!pvid->pending && @@ -367,11 +393,9 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) if ((pvid->command&0x80) && (pvid->reg[1]&0x10) && (pvid->reg[0x17]>>6)==2) DmaFill(d); - return; - } + break; - if (a==0x04) // Control (command) port 4 or 6 - { + case 0x04: // Control (command) port 4 or 6 if (pvid->pending) { // Low word of command: @@ -448,6 +472,35 @@ update_irq: pvid->pending=1; } } + break; + + // case 0x08: // 08 0a - HV counter - lock up + // case 0x0c: // 0c 0e - HV counter - lock up + // case 0x10: // 10 12 - PSG - handled by caller + // case 0x14: // 14 16 - PSG - handled by caller + // case 0x18: // 18 1a - no effect? + case 0x1c: // 1c 1e - debug + pvid->debug = d; + pvid->debug_p = 0; + if (d & (1 << 6)) { + pvid->debug_p |= PVD_KILL_A | PVD_KILL_B; + pvid->debug_p |= PVD_KILL_S_LO | PVD_KILL_S_HI; + } + switch ((d >> 7) & 3) { + case 1: + pvid->debug_p &= ~(PVD_KILL_S_LO | PVD_KILL_S_HI); + pvid->debug_p |= PVD_FORCE_S; + break; + case 2: + pvid->debug_p &= ~PVD_KILL_A; + pvid->debug_p |= PVD_FORCE_A; + break; + case 3: + pvid->debug_p &= ~PVD_KILL_B; + pvid->debug_p |= PVD_FORCE_B; + break; + } + break; } }