static\r
#endif\r
// handle DMA to background color\r
-int BgcDMA(u16 *pd, int len, struct PicoEState *est)\r
+void BgcDMA(struct PicoEState *est)\r
{\r
+ u16 *pd=est->DrawLineDest;\r
+ int len = (est->Pico->video.reg[12]&1) ? 320 : 256;\r
+ // TODO for now handles the line as all background.\r
int xl = (len == 320 ? 38 : 33); // DMA slots during HSYNC\r
int upscale = (est->rendstatus & PDRAW_SOFTSCALE) && len < 320;\r
+ u16 *q = upscale ? DefOutBuff : pd;\r
+ int i, l = len;\r
+ u16 t;\r
\r
- if (BgcDMAlen > 0) {\r
- // BG color DMA under way. TODO for now handles the line as all background.\r
- int i, l = len;\r
- u16 *q = upscale ? DefOutBuff : pd;\r
- u16 t;\r
-\r
- if ((est->rendstatus & PDRAW_BORDER_32) && !upscale)\r
- q += (320-len) / 2;\r
+ if ((est->rendstatus & PDRAW_BORDER_32) && !upscale)\r
+ q += (320-len) / 2;\r
\r
- BgcDMAlen -= (l>>1)+xl;\r
- if (BgcDMAlen < 0)\r
- // partial line\r
- l += 2*BgcDMAlen;\r
+ BgcDMAlen -= ((l-BgcDMAoffs)>>1)+xl;\r
+ if (BgcDMAlen <= 0) {\r
+ // partial line\r
+ l += 2*BgcDMAlen;\r
+ est->rendstatus &= ~PDRAW_BGC_DMA;\r
+ }\r
\r
- for (i = 0; i < l; i += 2) {\r
- // TODO use ps to overwrite only real bg pixels\r
- t = BgcDMAbase[BgcDMAsrc++ & BgcDMAmask];\r
- q[i] = q[i+1] = PXCONV(t);\r
- }\r
- BgcDMAsrc += xl; // HSYNC DMA\r
+ for (i = BgcDMAoffs; i < l; i += 2) {\r
+ // TODO use ps to overwrite only real bg pixels\r
+ t = BgcDMAbase[BgcDMAsrc++ & BgcDMAmask];\r
+ q[i] = q[i+1] = PXCONV(t);\r
+ }\r
+ BgcDMAsrc += xl; // HSYNC DMA\r
+ BgcDMAoffs = 0;\r
\r
- t = est->HighPal[Pico.video.reg[7] & 0x3f];\r
- while (i < len) q[i++] = t; // fill partial line with BG\r
+ t = est->HighPal[Pico.video.reg[7] & 0x3f];\r
+ while (i < len) q[i++] = t; // fill partial line with BG\r
\r
- if (upscale) {\r
- switch (PicoIn.filter) {\r
- case 3: h_upscale_bl4_4_5(pd, 320, q, 256, len, f_nop); break;\r
- case 2: h_upscale_bl2_4_5(pd, 320, q, 256, len, f_nop); break;\r
- case 1: h_upscale_snn_4_5(pd, 320, q, 256, len, f_nop); break;\r
- default: h_upscale_nn_4_5(pd, 320, q, 256, len, f_nop); break;\r
- }\r
+ if (upscale) {\r
+ switch (PicoIn.filter) {\r
+ case 3: h_upscale_bl4_4_5(pd, 320, q, 256, len, f_nop); break;\r
+ case 2: h_upscale_bl2_4_5(pd, 320, q, 256, len, f_nop); break;\r
+ case 1: h_upscale_snn_4_5(pd, 320, q, 256, len, f_nop); break;\r
+ default: h_upscale_nn_4_5(pd, 320, q, 256, len, f_nop); break;\r
}\r
- return 1;\r
}\r
- return 0;\r
}\r
\r
// --------------------------------------------\r
else if ((PicoIn.AHW & PAHW_SMS) && (est->Pico->video.reg[0] & 0x20))\r
len -= 8, ps += 8;\r
\r
- if (BgcDMA(pd, len, est))\r
- return;\r
+ if (est->rendstatus & PDRAW_BGC_DMA)\r
+ return BgcDMA(est);\r
\r
if ((est->rendstatus & PDRAW_SOFTSCALE) && len < 320) {\r
if (len >= 240 && len <= 256) {\r
BgcDMAlen -= (len>>1)+xl;\r
BgcDMAoffs = 0;\r
}\r
+ if (BgcDMAlen > 0)\r
+ est->rendstatus |= PDRAW_BGC_DMA;\r
}\r
\r
// also works for fast renderer\r
.equ PDRAW_SHHI_DONE, (1<<7)\r
.equ PDRAW_BORDER_32, (1<<9)\r
.equ PDRAW_32X_SCALE, (1<<12)\r
+.equ PDRAW_BGC_DMA, (1<<14)\r
.equ PDRAW_SOFTSCALE, (1<<15)\r
\r
@ helpers\r
FinalizeLine555:\r
stmfd sp!, {r4-r11,lr}\r
mov r11,r2 @ est\r
- ldr r8, [r11, #OFS_EST_Pico]\r
+ ldr r4, [r11, #OFS_EST_rendstatus]\r
\r
bl PicoDrawUpdateHighPal\r
\r
+ tst r4, #PDRAW_BGC_DMA\r
+ movne r0, r11\r
+ ldmnefd sp!, {r4-r11,lr}\r
+ bne BgcDMA\r
+\r
+ ldr r8, [r11, #OFS_EST_Pico]\r
add r3, r11, #OFS_EST_HighPal\r
\r
mov lr, #0xff\r
ldr r5, [r11, #OFS_EST_PicoOpt]\r
ldr r1, [r11, #OFS_EST_HighCol]\r
ldr r0, [r11, #OFS_EST_DrawLineDest]\r
- ldr r4, [r11, #OFS_EST_rendstatus]\r
ldr r7, [r5, #OFS_PicoIn_AHW-OFS_PicoIn_opt]\r
ldrb r12,[r8, #OFS_Pico_video_reg+12]\r
ldrb r6, [r8, #OFS_Pico_video_reg+0]\r