mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
reworked palette and buffer handling due to some 32X bugs
This commit is contained in:
parent
23eef37f25
commit
b1a047c926
13 changed files with 236 additions and 130 deletions
|
@ -11,6 +11,9 @@ int (*PicoScan32xBegin)(unsigned int num);
|
|||
int (*PicoScan32xEnd)(unsigned int num);
|
||||
int Pico32xDrawMode;
|
||||
|
||||
void *DrawLineDestBase32x;
|
||||
int DrawLineDestIncrement32x;
|
||||
|
||||
static void convert_pal555(int invert_prio)
|
||||
{
|
||||
unsigned int *ps = (void *)Pico32xMem->pal;
|
||||
|
@ -228,13 +231,11 @@ void PicoDraw32xLayer(int offs, int lines, int md_bg)
|
|||
int lines_sft_offs;
|
||||
int which_func;
|
||||
|
||||
Pico.est.DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement;
|
||||
Pico.est.DrawLineDest = (char *)DrawLineDestBase32x + offs * DrawLineDestIncrement32x;
|
||||
dram = Pico32xMem->dram[Pico32x.vdp_regs[0x0a/2] & P32XV_FS];
|
||||
|
||||
if (Pico32xDrawMode == PDM32X_BOTH) {
|
||||
if (Pico.m.dirtyPal)
|
||||
PicoDrawUpdateHighPal();
|
||||
}
|
||||
if (Pico32xDrawMode == PDM32X_BOTH)
|
||||
PicoDrawUpdateHighPal();
|
||||
|
||||
if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 2)
|
||||
{
|
||||
|
@ -273,20 +274,21 @@ do_it:
|
|||
void PicoDraw32xLayerMdOnly(int offs, int lines)
|
||||
{
|
||||
int have_scan = PicoScan32xBegin != NULL && PicoScan32xEnd != NULL;
|
||||
unsigned short *dst = (void *)((char *)DrawLineDestBase + offs * DrawLineDestIncrement);
|
||||
unsigned short *dst = (void *)((char *)DrawLineDestBase32x + offs * DrawLineDestIncrement32x);
|
||||
unsigned char *pmd = Pico.est.Draw2FB + 328 * offs + 8;
|
||||
unsigned short *pal = Pico.est.HighPal;
|
||||
int poffs = 0, plen = 320;
|
||||
int l, p;
|
||||
|
||||
if (!(Pico.video.reg[12] & 1)) {
|
||||
// 32col mode
|
||||
// 32col mode. for some render modes MD pixel data carries an offset
|
||||
if (!(PicoIn.opt & (POPT_ALT_RENDERER|POPT_DIS_32C_BORDER)))
|
||||
pmd += 32;
|
||||
poffs = 32;
|
||||
plen = 256;
|
||||
}
|
||||
|
||||
if (Pico.m.dirtyPal)
|
||||
PicoDrawUpdateHighPal();
|
||||
PicoDrawUpdateHighPal();
|
||||
|
||||
dst += poffs;
|
||||
for (l = 0; l < lines; l++) {
|
||||
|
@ -300,7 +302,7 @@ void PicoDraw32xLayerMdOnly(int offs, int lines)
|
|||
dst[p + 2] = pal[*pmd++];
|
||||
dst[p + 3] = pal[*pmd++];
|
||||
}
|
||||
dst = (void *)((char *)dst + DrawLineDestIncrement);
|
||||
dst = (void *)((char *)dst + DrawLineDestIncrement32x);
|
||||
pmd += 328 - plen;
|
||||
if (have_scan)
|
||||
PicoScan32xEnd(l + offs);
|
||||
|
@ -314,16 +316,32 @@ void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode)
|
|||
Pico32xNativePal = Pico32xMem->pal_native;
|
||||
#endif
|
||||
|
||||
if (which == PDF_RGB555 && use_32x_line_mode) {
|
||||
// we'll draw via FinalizeLine32xRGB555 (rare)
|
||||
if (which == PDF_RGB555) {
|
||||
// need CLUT pixels in PicoDraw2FB for layer transparency
|
||||
PicoDrawSetInternalBuf(Pico.est.Draw2FB, 328);
|
||||
PicoDrawSetOutBufMD(DrawLineDestBase32x, DrawLineDestIncrement32x);
|
||||
} else {
|
||||
// use the same layout as alt renderer
|
||||
PicoDrawSetInternalBuf(NULL, 0);
|
||||
Pico32xDrawMode = PDM32X_OFF;
|
||||
return;
|
||||
PicoDrawSetOutBufMD(Pico.est.Draw2FB + 8, 328);
|
||||
}
|
||||
|
||||
// use the same layout as alt renderer
|
||||
PicoDrawSetInternalBuf(Pico.est.Draw2FB, 328);
|
||||
Pico32xDrawMode = (which == PDF_RGB555) ? PDM32X_32X_ONLY : PDM32X_BOTH;
|
||||
if (use_32x_line_mode)
|
||||
// we'll draw via FinalizeLine32xRGB555 (rare)
|
||||
Pico32xDrawMode = PDM32X_OFF;
|
||||
else
|
||||
// in RGB555 mode the 32x layer is drawn over the MD layer, in the other
|
||||
// modes 32x and MD layer are merged together by the 32x renderer
|
||||
Pico32xDrawMode = (which == PDF_RGB555) ? PDM32X_32X_ONLY : PDM32X_BOTH;
|
||||
}
|
||||
|
||||
void PicoDrawSetOutBuf32X(void *dest, int increment)
|
||||
{
|
||||
DrawLineDestBase32x = dest;
|
||||
DrawLineDestIncrement32x = increment;
|
||||
// in RGB555 mode this buffer is also used by the MD renderer
|
||||
if (Pico32xDrawMode != PDM32X_BOTH)
|
||||
PicoDrawSetOutBufMD(DrawLineDestBase32x, DrawLineDestIncrement32x);
|
||||
}
|
||||
|
||||
// vim:shiftwidth=2:ts=2:expandtab
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue