X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fvideoport.c;h=9ddc167953b40a3aa41725890e0b84d907259733;hb=ea38612fad50103e224a3d00492d40b7dcff9e94;hp=6d62029c112fad288d067a2de1a58435467f4376;hpb=ef090115c8ea74938ed44e36a42e4a53d4447a9e;p=picodrive.git diff --git a/pico/videoport.c b/pico/videoport.c index 6d62029..9ddc167 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -1,15 +1,15 @@ -// PicoDrive - -// (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006-2008, Grazvydas "notaz" Ignotas -// Free for non-commercial use. - -// For commercial use, separate licencing terms must be obtained. - +/* + * PicoDrive + * (c) Copyright Dave, 2004 + * (C) notaz, 2006-2009 + * + * This work is licensed under the terms of MAME license. + * See COPYING file in the top-level directory. + */ #include "pico_int.h" -#include "cd/gfx_cd.h" +int line_base_cycles; extern const unsigned char hcounts_32[]; extern const unsigned char hcounts_40[]; @@ -36,7 +36,7 @@ static void VideoWrite(u16 d) case 1: if(a&1) d=(u16)((d<<8)|(d>>8)); // If address is odd, bytes are swapped (which game needs this?) Pico.vram [(a>>1)&0x7fff]=d; if (a - ((unsigned)(Pico.video.reg[5]&0x7f) << 9) < 0x400) - rendstatus |= PDRAW_DIRTY_SPRITES; + Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES; break; case 3: Pico.m.dirtyPal = 1; Pico.cram [(a>>1)&0x003f]=d; break; // wraps (Desert Strike) @@ -93,8 +93,7 @@ static void DmaSlow(int len) SekCyclesDone(), SekPc); Pico.m.dma_xfers += len; - if ((PicoAHW & PAHW_MCD) && (PicoOpt & POPT_EN_MCD_PSYNC)) SekCyclesBurn(CheckDMA()); - else SekEndTimeslice(SekCyclesLeftNoMCD - CheckDMA()); + SekCyclesBurnRun(CheckDMA()); if ((source&0xe00000)==0xe00000) { // Ram pd=(u16 *)(Pico.ram+(source&0xfffe)); @@ -173,7 +172,7 @@ static void DmaSlow(int len) //if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM } } - rendstatus |= PDRAW_DIRTY_SPRITES; + Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES; break; case 3: // cram @@ -208,7 +207,8 @@ static void DmaSlow(int len) break; default: - elprintf(EL_VDPDMA|EL_ANOMALY, "DMA with bad type %i", Pico.video.type); + if (Pico.video.type != 0 || (EL_LOGMASK & EL_VDPDMA)) + elprintf(EL_VDPDMA|EL_ANOMALY, "DMA with bad type %i", Pico.video.type); break; } // remember addr @@ -241,7 +241,7 @@ static void DmaCopy(int len) } // remember addr Pico.video.addr=a; - rendstatus |= PDRAW_DIRTY_SPRITES; + Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES; } // check: Contra, Megaman @@ -280,7 +280,7 @@ static void DmaFill(int data) // update length Pico.video.reg[0x13] = Pico.video.reg[0x14] = 0; // Dino Dini's Soccer (E) (by Haze) - rendstatus |= PDRAW_DIRTY_SPRITES; + Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES; } static void CommandDma(void) @@ -316,10 +316,10 @@ static void CommandChange(void) if (cmd&0x80) CommandDma(); } -static __inline void DrawSync(int blank_on) +static void DrawSync(int blank_on) { if (Pico.m.scanline < 224 && !(PicoOpt & POPT_ALT_RENDERER) && - !PicoSkipFrame && DrawScanline <= Pico.m.scanline) { + !PicoSkipFrame && Pico.est.DrawScanline <= Pico.m.scanline) { //elprintf(EL_ANOMALY, "sync"); PicoDrawSync(Pico.m.scanline, blank_on); } @@ -361,8 +361,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) pvid->lwrite_cnt++; if (pvid->lwrite_cnt >= 4) pvid->status|=0x100; // FIFO full if (pvid->lwrite_cnt > 4) { - SekCyclesBurn(32); // penalty // 488/12-8 - if (SekCycleCnt>=SekCycleAim) SekEndRun(0); + SekCyclesBurnRun(32); // penalty // 488/12-8 } elprintf(EL_ASVDP, "VDP data write: %04x [%06x] {%i} #%i @ %06x", d, Pico.video.addr, Pico.video.type, pvid->lwrite_cnt, SekPc); @@ -397,7 +396,8 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) return; } - if (num == 1 && !(d&0x40) && SekCyclesLeft > 390) blank_on = 1; + if (num == 1 && !(d&0x40) && SekCyclesDone() - line_base_cycles <= 488-390) + blank_on = 1; DrawSync(blank_on); pvid->reg[num]=(unsigned char)d; switch (num) @@ -412,7 +412,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) goto update_irq; case 0x05: //elprintf(EL_STATUS, "spritep moved to %04x", (unsigned)(Pico.video.reg[5]&0x7f) << 9); - if (d^dold) rendstatus |= PDRAW_SPRITES_MOVED; + if (d^dold) Pico.est.rendstatus |= PDRAW_SPRITES_MOVED; break; case 0x0c: // renderers should update their palettes if sh/hi mode is changed @@ -424,7 +424,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) update_irq: #ifndef EMU_CORE_DEBUG // update IRQ level - if (!SekShouldInterrupt) // hack + if (!SekShouldInterrupt()) // hack { int lines, pints, irq=0; lines = (pvid->reg[1] & 0x20) | (pvid->reg[0] & 0x10); @@ -458,7 +458,8 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) unsigned int d; d=pv->status; //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast) - if (SekCyclesLeft < 84+4) d|=0x0004; // H-Blank (Sonic3 vs) + if (SekCyclesDone() - line_base_cycles >= 488-88) + d|=0x0004; // H-Blank (Sonic3 vs) d |= ((pv->reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled d |= (pv->pending_ints&0x20)<<2; // V-int pending? @@ -488,12 +489,11 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) if ((a&0x1c)==0x08) { unsigned int d; - int lineCycles; - lineCycles = (488-SekCyclesLeft)&0x1ff; + d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME if (Pico.video.reg[12]&1) - d = hcounts_40[lineCycles]; - else d = hcounts_32[lineCycles]; + d = hcounts_40[d]; + else d = hcounts_32[d]; elprintf(EL_HVCNT, "hv: %02x %02x (%i) @ %06x", d, Pico.video.v_counter, SekCyclesDone(), SekPc); return d | (Pico.video.v_counter << 8); @@ -527,7 +527,7 @@ unsigned int PicoVideoRead8(unsigned int a) //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast) d |= ((Pico.video.reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled d |= (Pico.video.pending_ints&0x20)<<2; // V-int pending? - if (SekCyclesLeft < 84+4) d |= 4; // H-Blank + if (SekCyclesDone() - line_base_cycles >= 488-88) d |= 4; // H-Blank Pico.video.pending = 0; elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc); return d; @@ -535,7 +535,7 @@ unsigned int PicoVideoRead8(unsigned int a) elprintf(EL_HVCNT, "vcounter: %02x (%i) @ %06x", Pico.video.v_counter, SekCyclesDone(), SekPc); return Pico.video.v_counter; case 9: - d = (488-SekCyclesLeft)&0x1ff; + d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME if (Pico.video.reg[12]&1) d = hcounts_40[d]; else d = hcounts_32[d]; @@ -545,3 +545,5 @@ unsigned int PicoVideoRead8(unsigned int a) return 0; } + +// vim:shiftwidth=2:ts=2:expandtab