mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-10-26 16:29:37 -04:00
vdp, improve save state handling (bg dma)
This commit is contained in:
parent
b1a6586688
commit
e45908d734
2 changed files with 31 additions and 14 deletions
|
|
@ -313,8 +313,8 @@ struct PicoVideo
|
||||||
unsigned char hint_cnt;
|
unsigned char hint_cnt;
|
||||||
unsigned char pad2;
|
unsigned char pad2;
|
||||||
unsigned short hv_latch; // latched hvcounter value
|
unsigned short hv_latch; // latched hvcounter value
|
||||||
signed int fifo_cnt; // pending xfers for current FIFO queue entry
|
signed int fifo_cnt; // pending xfers for blocking FIFO queue entries
|
||||||
unsigned char pad[0x04];
|
signed int fifo_bgcnt; // pending xfers for background FIFO queue entries
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PicoMisc
|
struct PicoMisc
|
||||||
|
|
|
||||||
|
|
@ -1138,9 +1138,18 @@ void PicoVideoSave(void)
|
||||||
int l, x;
|
int l, x;
|
||||||
|
|
||||||
// account for all outstanding xfers XXX kludge, entry attr's not saved
|
// account for all outstanding xfers XXX kludge, entry attr's not saved
|
||||||
pv->fifo_cnt = vf->fifo_cnt;
|
pv->fifo_cnt = pv->fifo_bgcnt = 0;
|
||||||
for (l = vf->fifo_ql, x = vf->fifo_qx + l-1; l > 1; l--, x--)
|
for (l = vf->fifo_ql, x = vf->fifo_qx + l-1; l > 1; l--, x--) {
|
||||||
pv->fifo_cnt += (vf->fifo_queue[x&7] >> 3) << (vf->fifo_queue[x&7] & FQ_BYTE);
|
int cnt = (vf->fifo_queue[x&7] >> 3) << (vf->fifo_queue[x&7] & FQ_BYTE);
|
||||||
|
if (vf->fifo_queue[x&7] & FQ_BGDMA)
|
||||||
|
pv->fifo_bgcnt += cnt;
|
||||||
|
else
|
||||||
|
pv->fifo_cnt += cnt;
|
||||||
|
}
|
||||||
|
if (vf->fifo_ql && (vf->fifo_queue[vf->fifo_qx] & FQ_BGDMA))
|
||||||
|
pv->fifo_bgcnt += vf->fifo_cnt;
|
||||||
|
else
|
||||||
|
pv->fifo_cnt += vf->fifo_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PicoVideoLoad(void)
|
void PicoVideoLoad(void)
|
||||||
|
|
@ -1151,23 +1160,31 @@ void PicoVideoLoad(void)
|
||||||
|
|
||||||
// convert former dma_xfers (why was this in PicoMisc anyway?)
|
// convert former dma_xfers (why was this in PicoMisc anyway?)
|
||||||
if (Pico.m.dma_xfers) {
|
if (Pico.m.dma_xfers) {
|
||||||
pv->status |= SR_DMA;
|
|
||||||
pv->fifo_cnt = Pico.m.dma_xfers << b;
|
pv->fifo_cnt = Pico.m.dma_xfers << b;
|
||||||
Pico.m.dma_xfers = 0;
|
Pico.m.dma_xfers = 0;
|
||||||
}
|
}
|
||||||
// make an entry in the FIFO if there are outstanding transfers
|
|
||||||
|
// fake entries in the FIFO if there are outstanding transfers
|
||||||
vf->fifo_ql = vf->fifo_qx = vf->fifo_total = 0;
|
vf->fifo_ql = vf->fifo_qx = vf->fifo_total = 0;
|
||||||
vf->fifo_cnt = pv->fifo_cnt;
|
|
||||||
if (pv->fifo_cnt) {
|
if (pv->fifo_cnt) {
|
||||||
int wc = (pv->fifo_cnt + b) >> b;
|
int wc = (pv->fifo_cnt + b) >> b;
|
||||||
pv->status |= PVS_FIFORUN|PVS_CPUWR;
|
pv->status |= PVS_FIFORUN|PVS_CPUWR;
|
||||||
if (!(pv->status & PVS_DMABG))
|
vf->fifo_total = wc;
|
||||||
vf->fifo_total = wc;
|
vf->fifo_queue[vf->fifo_qx + vf->fifo_ql] = (wc << 3) | b | FQ_FGDMA;
|
||||||
if ((pv->status & SR_DMA) && !(pv->status & PVS_DMAFILL))
|
vf->fifo_ql ++;
|
||||||
b |= (pv->status & PVS_DMABG) ? FQ_BGDMA : FQ_FGDMA;
|
vf->fifo_cnt = pv->fifo_cnt;
|
||||||
vf->fifo_queue[vf->fifo_qx] = (wc << 3) | b;
|
|
||||||
vf->fifo_ql = 1;
|
|
||||||
}
|
}
|
||||||
|
if (pv->fifo_bgcnt) {
|
||||||
|
int wc = pv->fifo_bgcnt;
|
||||||
|
if (!vf->fifo_ql) {
|
||||||
|
pv->status |= PVS_DMABG;
|
||||||
|
vf->fifo_cnt = pv->fifo_bgcnt;
|
||||||
|
}
|
||||||
|
vf->fifo_queue[vf->fifo_qx + vf->fifo_ql] = (wc << 3) | FQ_BGDMA;
|
||||||
|
vf->fifo_ql ++;
|
||||||
|
}
|
||||||
|
if (vf->fifo_ql)
|
||||||
|
pv->status |= SR_DMA;
|
||||||
PicoVideoCacheSAT();
|
PicoVideoCacheSAT();
|
||||||
}
|
}
|
||||||
// vim:shiftwidth=2:ts=2:expandtab
|
// vim:shiftwidth=2:ts=2:expandtab
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue