mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
core, handle background color DMA (arm asm)
This commit is contained in:
parent
492c47c4b8
commit
db1ee7a2df
3 changed files with 47 additions and 38 deletions
74
pico/draw.c
74
pico/draw.c
|
@ -1607,46 +1607,46 @@ static int BgcDMAlen, BgcDMAoffs;
|
|||
static
|
||||
#endif
|
||||
// handle DMA to background color
|
||||
int BgcDMA(u16 *pd, int len, struct PicoEState *est)
|
||||
void BgcDMA(struct PicoEState *est)
|
||||
{
|
||||
u16 *pd=est->DrawLineDest;
|
||||
int len = (est->Pico->video.reg[12]&1) ? 320 : 256;
|
||||
// TODO for now handles the line as all background.
|
||||
int xl = (len == 320 ? 38 : 33); // DMA slots during HSYNC
|
||||
int upscale = (est->rendstatus & PDRAW_SOFTSCALE) && len < 320;
|
||||
u16 *q = upscale ? DefOutBuff : pd;
|
||||
int i, l = len;
|
||||
u16 t;
|
||||
|
||||
if (BgcDMAlen > 0) {
|
||||
// BG color DMA under way. TODO for now handles the line as all background.
|
||||
int i, l = len;
|
||||
u16 *q = upscale ? DefOutBuff : pd;
|
||||
u16 t;
|
||||
if ((est->rendstatus & PDRAW_BORDER_32) && !upscale)
|
||||
q += (320-len) / 2;
|
||||
|
||||
if ((est->rendstatus & PDRAW_BORDER_32) && !upscale)
|
||||
q += (320-len) / 2;
|
||||
|
||||
BgcDMAlen -= (l>>1)+xl;
|
||||
if (BgcDMAlen < 0)
|
||||
// partial line
|
||||
l += 2*BgcDMAlen;
|
||||
|
||||
for (i = 0; i < l; i += 2) {
|
||||
// TODO use ps to overwrite only real bg pixels
|
||||
t = BgcDMAbase[BgcDMAsrc++ & BgcDMAmask];
|
||||
q[i] = q[i+1] = PXCONV(t);
|
||||
}
|
||||
BgcDMAsrc += xl; // HSYNC DMA
|
||||
|
||||
t = est->HighPal[Pico.video.reg[7] & 0x3f];
|
||||
while (i < len) q[i++] = t; // fill partial line with BG
|
||||
|
||||
if (upscale) {
|
||||
switch (PicoIn.filter) {
|
||||
case 3: h_upscale_bl4_4_5(pd, 320, q, 256, len, f_nop); break;
|
||||
case 2: h_upscale_bl2_4_5(pd, 320, q, 256, len, f_nop); break;
|
||||
case 1: h_upscale_snn_4_5(pd, 320, q, 256, len, f_nop); break;
|
||||
default: h_upscale_nn_4_5(pd, 320, q, 256, len, f_nop); break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
BgcDMAlen -= ((l-BgcDMAoffs)>>1)+xl;
|
||||
if (BgcDMAlen <= 0) {
|
||||
// partial line
|
||||
l += 2*BgcDMAlen;
|
||||
est->rendstatus &= ~PDRAW_BGC_DMA;
|
||||
}
|
||||
|
||||
for (i = BgcDMAoffs; i < l; i += 2) {
|
||||
// TODO use ps to overwrite only real bg pixels
|
||||
t = BgcDMAbase[BgcDMAsrc++ & BgcDMAmask];
|
||||
q[i] = q[i+1] = PXCONV(t);
|
||||
}
|
||||
BgcDMAsrc += xl; // HSYNC DMA
|
||||
BgcDMAoffs = 0;
|
||||
|
||||
t = est->HighPal[Pico.video.reg[7] & 0x3f];
|
||||
while (i < len) q[i++] = t; // fill partial line with BG
|
||||
|
||||
if (upscale) {
|
||||
switch (PicoIn.filter) {
|
||||
case 3: h_upscale_bl4_4_5(pd, 320, q, 256, len, f_nop); break;
|
||||
case 2: h_upscale_bl2_4_5(pd, 320, q, 256, len, f_nop); break;
|
||||
case 1: h_upscale_snn_4_5(pd, 320, q, 256, len, f_nop); break;
|
||||
default: h_upscale_nn_4_5(pd, 320, q, 256, len, f_nop); break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// --------------------------------------------
|
||||
|
@ -1747,8 +1747,8 @@ void FinalizeLine555(int sh, int line, struct PicoEState *est)
|
|||
else if ((PicoIn.AHW & PAHW_SMS) && (est->Pico->video.reg[0] & 0x20))
|
||||
len -= 8, ps += 8;
|
||||
|
||||
if (BgcDMA(pd, len, est))
|
||||
return;
|
||||
if (est->rendstatus & PDRAW_BGC_DMA)
|
||||
return BgcDMA(est);
|
||||
|
||||
if ((est->rendstatus & PDRAW_SOFTSCALE) && len < 320) {
|
||||
if (len >= 240 && len <= 256) {
|
||||
|
@ -2193,6 +2193,8 @@ void PicoDrawBgcDMA(u16 *base, u32 source, u32 mask, int dlen, int sl)
|
|||
BgcDMAlen -= (len>>1)+xl;
|
||||
BgcDMAoffs = 0;
|
||||
}
|
||||
if (BgcDMAlen > 0)
|
||||
est->rendstatus |= PDRAW_BGC_DMA;
|
||||
}
|
||||
|
||||
// also works for fast renderer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue