mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -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
28
pico/draw.c
28
pico/draw.c
|
@ -1607,31 +1607,34 @@ static int BgcDMAlen, BgcDMAoffs;
|
||||||
static
|
static
|
||||||
#endif
|
#endif
|
||||||
// handle DMA to background color
|
// 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 xl = (len == 320 ? 38 : 33); // DMA slots during HSYNC
|
||||||
int upscale = (est->rendstatus & PDRAW_SOFTSCALE) && len < 320;
|
int upscale = (est->rendstatus & PDRAW_SOFTSCALE) && len < 320;
|
||||||
|
|
||||||
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 *q = upscale ? DefOutBuff : pd;
|
||||||
|
int i, l = len;
|
||||||
u16 t;
|
u16 t;
|
||||||
|
|
||||||
if ((est->rendstatus & PDRAW_BORDER_32) && !upscale)
|
if ((est->rendstatus & PDRAW_BORDER_32) && !upscale)
|
||||||
q += (320-len) / 2;
|
q += (320-len) / 2;
|
||||||
|
|
||||||
BgcDMAlen -= (l>>1)+xl;
|
BgcDMAlen -= ((l-BgcDMAoffs)>>1)+xl;
|
||||||
if (BgcDMAlen < 0)
|
if (BgcDMAlen <= 0) {
|
||||||
// partial line
|
// partial line
|
||||||
l += 2*BgcDMAlen;
|
l += 2*BgcDMAlen;
|
||||||
|
est->rendstatus &= ~PDRAW_BGC_DMA;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < l; i += 2) {
|
for (i = BgcDMAoffs; i < l; i += 2) {
|
||||||
// TODO use ps to overwrite only real bg pixels
|
// TODO use ps to overwrite only real bg pixels
|
||||||
t = BgcDMAbase[BgcDMAsrc++ & BgcDMAmask];
|
t = BgcDMAbase[BgcDMAsrc++ & BgcDMAmask];
|
||||||
q[i] = q[i+1] = PXCONV(t);
|
q[i] = q[i+1] = PXCONV(t);
|
||||||
}
|
}
|
||||||
BgcDMAsrc += xl; // HSYNC DMA
|
BgcDMAsrc += xl; // HSYNC DMA
|
||||||
|
BgcDMAoffs = 0;
|
||||||
|
|
||||||
t = est->HighPal[Pico.video.reg[7] & 0x3f];
|
t = est->HighPal[Pico.video.reg[7] & 0x3f];
|
||||||
while (i < len) q[i++] = t; // fill partial line with BG
|
while (i < len) q[i++] = t; // fill partial line with BG
|
||||||
|
@ -1644,9 +1647,6 @@ int BgcDMA(u16 *pd, int len, struct PicoEState *est)
|
||||||
default: h_upscale_nn_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;
|
|
||||||
}
|
|
||||||
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))
|
else if ((PicoIn.AHW & PAHW_SMS) && (est->Pico->video.reg[0] & 0x20))
|
||||||
len -= 8, ps += 8;
|
len -= 8, ps += 8;
|
||||||
|
|
||||||
if (BgcDMA(pd, len, est))
|
if (est->rendstatus & PDRAW_BGC_DMA)
|
||||||
return;
|
return BgcDMA(est);
|
||||||
|
|
||||||
if ((est->rendstatus & PDRAW_SOFTSCALE) && len < 320) {
|
if ((est->rendstatus & PDRAW_SOFTSCALE) && len < 320) {
|
||||||
if (len >= 240 && len <= 256) {
|
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;
|
BgcDMAlen -= (len>>1)+xl;
|
||||||
BgcDMAoffs = 0;
|
BgcDMAoffs = 0;
|
||||||
}
|
}
|
||||||
|
if (BgcDMAlen > 0)
|
||||||
|
est->rendstatus |= PDRAW_BGC_DMA;
|
||||||
}
|
}
|
||||||
|
|
||||||
// also works for fast renderer
|
// also works for fast renderer
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
.equ PDRAW_SHHI_DONE, (1<<7)
|
.equ PDRAW_SHHI_DONE, (1<<7)
|
||||||
.equ PDRAW_BORDER_32, (1<<9)
|
.equ PDRAW_BORDER_32, (1<<9)
|
||||||
.equ PDRAW_32X_SCALE, (1<<12)
|
.equ PDRAW_32X_SCALE, (1<<12)
|
||||||
|
.equ PDRAW_BGC_DMA, (1<<14)
|
||||||
.equ PDRAW_SOFTSCALE, (1<<15)
|
.equ PDRAW_SOFTSCALE, (1<<15)
|
||||||
|
|
||||||
@ helpers
|
@ helpers
|
||||||
|
@ -1632,10 +1633,16 @@ PicoDoHighPal555_end:
|
||||||
FinalizeLine555:
|
FinalizeLine555:
|
||||||
stmfd sp!, {r4-r11,lr}
|
stmfd sp!, {r4-r11,lr}
|
||||||
mov r11,r2 @ est
|
mov r11,r2 @ est
|
||||||
ldr r8, [r11, #OFS_EST_Pico]
|
ldr r4, [r11, #OFS_EST_rendstatus]
|
||||||
|
|
||||||
bl PicoDrawUpdateHighPal
|
bl PicoDrawUpdateHighPal
|
||||||
|
|
||||||
|
tst r4, #PDRAW_BGC_DMA
|
||||||
|
movne r0, r11
|
||||||
|
ldmnefd sp!, {r4-r11,lr}
|
||||||
|
bne BgcDMA
|
||||||
|
|
||||||
|
ldr r8, [r11, #OFS_EST_Pico]
|
||||||
add r3, r11, #OFS_EST_HighPal
|
add r3, r11, #OFS_EST_HighPal
|
||||||
|
|
||||||
mov lr, #0xff
|
mov lr, #0xff
|
||||||
|
@ -1644,7 +1651,6 @@ FinalizeLine555:
|
||||||
ldr r5, [r11, #OFS_EST_PicoOpt]
|
ldr r5, [r11, #OFS_EST_PicoOpt]
|
||||||
ldr r1, [r11, #OFS_EST_HighCol]
|
ldr r1, [r11, #OFS_EST_HighCol]
|
||||||
ldr r0, [r11, #OFS_EST_DrawLineDest]
|
ldr r0, [r11, #OFS_EST_DrawLineDest]
|
||||||
ldr r4, [r11, #OFS_EST_rendstatus]
|
|
||||||
ldr r7, [r5, #OFS_PicoIn_AHW-OFS_PicoIn_opt]
|
ldr r7, [r5, #OFS_PicoIn_AHW-OFS_PicoIn_opt]
|
||||||
ldrb r12,[r8, #OFS_Pico_video_reg+12]
|
ldrb r12,[r8, #OFS_Pico_video_reg+12]
|
||||||
ldrb r6, [r8, #OFS_Pico_video_reg+0]
|
ldrb r6, [r8, #OFS_Pico_video_reg+0]
|
||||||
|
|
|
@ -235,6 +235,7 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est);
|
||||||
#define PDRAW_30_ROWS (1<<11) // 30 rows mode (240 lines)
|
#define PDRAW_30_ROWS (1<<11) // 30 rows mode (240 lines)
|
||||||
#define PDRAW_32X_SCALE (1<<12) // scale CLUT layer for 32X
|
#define PDRAW_32X_SCALE (1<<12) // scale CLUT layer for 32X
|
||||||
#define PDRAW_SMS_BLANK_1 (1<<13) // 1st column blanked
|
#define PDRAW_SMS_BLANK_1 (1<<13) // 1st column blanked
|
||||||
|
#define PDRAW_BGC_DMA (1<<14) // in background color DMA
|
||||||
#define PDRAW_SOFTSCALE (1<<15) // H32 upscaling
|
#define PDRAW_SOFTSCALE (1<<15) // H32 upscaling
|
||||||
#define PDRAW_SYNC_NEEDED (1<<16) // redraw needed
|
#define PDRAW_SYNC_NEEDED (1<<16) // redraw needed
|
||||||
#define PDRAW_SYNC_NEXT (1<<17) // redraw next frame
|
#define PDRAW_SYNC_NEXT (1<<17) // redraw next frame
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue