eliminate texrels, part 3

This commit is contained in:
notaz 2017-08-06 22:25:26 +03:00
parent 6027c719ba
commit 98a2714234
16 changed files with 125 additions and 112 deletions

View file

@ -141,9 +141,9 @@ static void do_loop_dc##name(unsigned short *dst, \
unsigned short *dram, int lines_sft_offs, int mdbg) \ unsigned short *dram, int lines_sft_offs, int mdbg) \
{ \ { \
int inv_bit = (Pico32x.vdp_regs[0] & P32XV_PRI) ? 0x8000 : 0; \ int inv_bit = (Pico32x.vdp_regs[0] & P32XV_PRI) ? 0x8000 : 0; \
unsigned char *pmd = PicoDraw2FB + \ unsigned char *pmd = Pico.est.Draw2FB + \
328 * (lines_sft_offs & 0xff) + 8; \ 328 * (lines_sft_offs & 0xff) + 8; \
unsigned short *palmd = HighPal; \ unsigned short *palmd = Pico.est.HighPal; \
unsigned short *p32x; \ unsigned short *p32x; \
int lines = lines_sft_offs >> 16; \ int lines = lines_sft_offs >> 16; \
int l; \ int l; \
@ -161,9 +161,9 @@ static void do_loop_pp##name(unsigned short *dst, \
unsigned short *dram, int lines_sft_offs, int mdbg) \ unsigned short *dram, int lines_sft_offs, int mdbg) \
{ \ { \
unsigned short *pal = Pico32xMem->pal_native; \ unsigned short *pal = Pico32xMem->pal_native; \
unsigned char *pmd = PicoDraw2FB + \ unsigned char *pmd = Pico.est.Draw2FB + \
328 * (lines_sft_offs & 0xff) + 8; \ 328 * (lines_sft_offs & 0xff) + 8; \
unsigned short *palmd = HighPal; \ unsigned short *palmd = Pico.est.HighPal; \
unsigned char *p32x; \ unsigned char *p32x; \
int lines = lines_sft_offs >> 16; \ int lines = lines_sft_offs >> 16; \
int l; \ int l; \
@ -182,9 +182,9 @@ static void do_loop_rl##name(unsigned short *dst, \
unsigned short *dram, int lines_sft_offs, int mdbg) \ unsigned short *dram, int lines_sft_offs, int mdbg) \
{ \ { \
unsigned short *pal = Pico32xMem->pal_native; \ unsigned short *pal = Pico32xMem->pal_native; \
unsigned char *pmd = PicoDraw2FB + \ unsigned char *pmd = Pico.est.Draw2FB + \
328 * (lines_sft_offs & 0xff) + 8; \ 328 * (lines_sft_offs & 0xff) + 8; \
unsigned short *palmd = HighPal; \ unsigned short *palmd = Pico.est.HighPal; \
unsigned short *p32x; \ unsigned short *p32x; \
int lines = lines_sft_offs >> 16; \ int lines = lines_sft_offs >> 16; \
int l; \ int l; \
@ -274,8 +274,8 @@ void PicoDraw32xLayerMdOnly(int offs, int lines)
{ {
int have_scan = PicoScan32xBegin != NULL && PicoScan32xEnd != NULL; int have_scan = PicoScan32xBegin != NULL && PicoScan32xEnd != NULL;
unsigned short *dst = (void *)((char *)DrawLineDestBase + offs * DrawLineDestIncrement); unsigned short *dst = (void *)((char *)DrawLineDestBase + offs * DrawLineDestIncrement);
unsigned char *pmd = PicoDraw2FB + 328 * offs + 8; unsigned char *pmd = Pico.est.Draw2FB + 328 * offs + 8;
unsigned short *pal = HighPal; unsigned short *pal = Pico.est.HighPal;
int poffs = 0, plen = 320; int poffs = 0, plen = 320;
int l, p; int l, p;
@ -322,7 +322,7 @@ void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode)
} }
// use the same layout as alt renderer // use the same layout as alt renderer
PicoDrawSetInternalBuf(PicoDraw2FB, 328); PicoDrawSetInternalBuf(Pico.est.Draw2FB, 328);
Pico32xDrawMode = (which == PDF_RGB555) ? PDM32X_32X_ONLY : PDM32X_BOTH; Pico32xDrawMode = (which == PDF_RGB555) ? PDM32X_32X_ONLY : PDM32X_BOTH;
} }

View file

@ -196,29 +196,30 @@ void PDebugShowSpriteStats(unsigned short *screen, int stride)
void PDebugShowPalette(unsigned short *screen, int stride) void PDebugShowPalette(unsigned short *screen, int stride)
{ {
struct PicoEState *est = &Pico.est;
int x, y; int x, y;
Pico.m.dirtyPal = 1; Pico.m.dirtyPal = 1;
if (PicoAHW & PAHW_SMS) if (PicoAHW & PAHW_SMS)
PicoDoHighPal555M4(); PicoDoHighPal555M4();
else else
PicoDoHighPal555(1, 0, &Pico.est); PicoDoHighPal555(1, 0, est);
Pico.m.dirtyPal = 1; Pico.m.dirtyPal = 1;
screen += 16*stride+8; screen += 16*stride+8;
for (y = 0; y < 8*4; y++) for (y = 0; y < 8*4; y++)
for (x = 0; x < 8*16; x++) for (x = 0; x < 8*16; x++)
screen[x + y*stride] = HighPal[x/8 + (y/8)*16]; screen[x + y*stride] = est->HighPal[x/8 + (y/8)*16];
screen += 160; screen += 160;
for (y = 0; y < 8*4; y++) for (y = 0; y < 8*4; y++)
for (x = 0; x < 8*16; x++) for (x = 0; x < 8*16; x++)
screen[x + y*stride] = HighPal[(x/8 + (y/8)*16) | 0x40]; screen[x + y*stride] = est->HighPal[(x/8 + (y/8)*16) | 0x40];
screen += stride*48; screen += stride*48;
for (y = 0; y < 8*4; y++) for (y = 0; y < 8*4; y++)
for (x = 0; x < 8*16; x++) for (x = 0; x < 8*16; x++)
screen[x + y*stride] = HighPal[(x/8 + (y/8)*16) | 0x80]; screen[x + y*stride] = est->HighPal[(x/8 + (y/8)*16) | 0x80];
} }
#if defined(DRAW2_OVERRIDE_LINE_WIDTH) #if defined(DRAW2_OVERRIDE_LINE_WIDTH)
@ -263,9 +264,9 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
PicoFrameFull(); PicoFrameFull();
for (y = 0; y < 8*4; y++) for (y = 0; y < 8*4; y++)
{ {
unsigned char *ps = PicoDraw2FB + DRAW2_LINE_WIDTH*y + 8; unsigned char *ps = Pico.est.Draw2FB + DRAW2_LINE_WIDTH*y + 8;
for (x = 0; x < 8*4; x++) for (x = 0; x < 8*4; x++)
if (ps[x]) screen[x] = HighPal[ps[x]], ps[x] = 0; if (ps[x]) screen[x] = Pico.est.HighPal[ps[x]], ps[x] = 0;
screen += stride; screen += stride;
} }

View file

@ -1161,8 +1161,6 @@ void BackFill(int reg7, int sh, struct PicoEState *est)
// -------------------------------------------- // --------------------------------------------
unsigned short HighPal[0x100];
#ifndef _ASM_DRAW_C #ifndef _ASM_DRAW_C
void PicoDoHighPal555(int sh, int line, struct PicoEState *est) void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
{ {
@ -1172,7 +1170,7 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
Pico.m.dirtyPal = 0; Pico.m.dirtyPal = 0;
spal = (void *)Pico.cram; spal = (void *)Pico.cram;
dpal = (void *)HighPal; dpal = (void *)est->HighPal;
for (i = 0; i < 0x40 / 2; i++) { for (i = 0; i < 0x40 / 2; i++) {
t = spal[i]; t = spal[i];
@ -1206,7 +1204,7 @@ void FinalizeLine555(int sh, int line, struct PicoEState *est)
{ {
unsigned short *pd=est->DrawLineDest; unsigned short *pd=est->DrawLineDest;
unsigned char *ps=est->HighCol+8; unsigned char *ps=est->HighCol+8;
unsigned short *pal=HighPal; unsigned short *pal=est->HighPal;
int len; int len;
if (Pico.m.dirtyPal) if (Pico.m.dirtyPal)
@ -1253,9 +1251,9 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est)
rs |= PDRAW_SONIC_MODE; rs |= PDRAW_SONIC_MODE;
est->rendstatus = rs; est->rendstatus = rs;
if (dirty_count == 3) { if (dirty_count == 3) {
blockcpy(HighPal, Pico.cram, 0x40*2); blockcpy(est->HighPal, Pico.cram, 0x40*2);
} else if (dirty_count == 11) { } else if (dirty_count == 11) {
blockcpy(HighPal+0x40, Pico.cram, 0x40*2); blockcpy(est->HighPal+0x40, Pico.cram, 0x40*2);
} }
} }
@ -1496,15 +1494,16 @@ void PicoDrawSync(int to, int blank_last_line)
// also works for fast renderer // also works for fast renderer
void PicoDrawUpdateHighPal(void) void PicoDrawUpdateHighPal(void)
{ {
struct PicoEState *est = &Pico.est;
int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight? int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight?
if (PicoOpt & POPT_ALT_RENDERER) if (PicoOpt & POPT_ALT_RENDERER)
sh = 0; // no s/h support sh = 0; // no s/h support
PicoDoHighPal555(sh, 0, &Pico.est); PicoDoHighPal555(sh, 0, &Pico.est);
if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { if (est->rendstatus & PDRAW_SONIC_MODE) {
// FIXME? // FIXME?
memcpy(HighPal + 0x40, HighPal, 0x40*2); memcpy(est->HighPal + 0x40, est->HighPal, 0x40*2);
memcpy(HighPal + 0x80, HighPal, 0x40*2); memcpy(est->HighPal + 0x80, est->HighPal, 0x40*2);
} }
} }

View file

@ -21,7 +21,6 @@
#endif #endif
static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];
unsigned char *PicoDraw2FB = PicoDraw2FB_;
static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers
static int HighCache2B[41*(TILE_ROWS+1)+1+1]; static int HighCache2B[41*(TILE_ROWS+1)+1+1];
@ -32,11 +31,12 @@ void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to
// stuff available in asm: // stuff available in asm:
#ifdef _ASM_DRAW_C #ifdef _ASM_DRAW_C
void BackFillFull(int reg7); void BackFillFull(void *dst, int reg7);
void DrawLayerFull(int plane, int *hcache, int planestart, int planeend); void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
void DrawTilesFromCacheF(int *hc); struct PicoEState *est);
void DrawWindowFull(int start, int end, int prio); void DrawTilesFromCacheF(int *hc, struct PicoEState *est);
void DrawSpriteFull(unsigned int *sprite); void DrawWindowFull(int start, int end, int prio, struct PicoEState *est);
void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est);
#else #else
@ -134,11 +134,11 @@ static int TileXflipYflip(unsigned char *pd,int addr,unsigned char pal)
// start: (tile_start<<16)|row_start, end: [same] // start: (tile_start<<16)|row_start, end: [same]
static void DrawWindowFull(int start, int end, int prio) static void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)
{ {
struct PicoVideo *pvid=&Pico.video; struct PicoVideo *pvid=&Pico.video;
int nametab, nametab_step, trow, tilex, blank=-1, code; int nametab, nametab_step, trow, tilex, blank=-1, code;
unsigned char *scrpos = PicoDraw2FB; unsigned char *scrpos = est->Draw2FB;
int tile_start, tile_end; // in cells int tile_start, tile_end; // in cells
// parse ranges // parse ranges
@ -198,7 +198,8 @@ static void DrawWindowFull(int start, int end, int prio)
} }
static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend) static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
struct PicoEState *est)
{ {
struct PicoVideo *pvid=&Pico.video; struct PicoVideo *pvid=&Pico.video;
static char shift[4]={5,6,6,7}; // 32,64 or 128 sized tilemaps static char shift[4]={5,6,6,7}; // 32,64 or 128 sized tilemaps
@ -238,7 +239,7 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend)
if (plane==0) nametab=(pvid->reg[2]&0x38)<< 9; // A if (plane==0) nametab=(pvid->reg[2]&0x38)<< 9; // A
else nametab=(pvid->reg[4]&0x07)<<12; // B else nametab=(pvid->reg[4]&0x07)<<12; // B
scrpos = PicoDraw2FB; scrpos = est->Draw2FB;
scrpos+=8*LINE_WIDTH*(planestart-START_ROW); scrpos+=8*LINE_WIDTH*(planestart-START_ROW);
// Get vertical scroll value: // Get vertical scroll value:
@ -305,14 +306,14 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend)
} }
static void DrawTilesFromCacheF(int *hc) static void DrawTilesFromCacheF(int *hc, struct PicoEState *est)
{ {
int code, addr, zero = 0; int code, addr, zero = 0;
unsigned int prevy=0xFFFFFFFF; unsigned int prevy=0xFFFFFFFF;
// unsigned short *pal; // unsigned short *pal;
unsigned char pal; unsigned char pal;
short blank=-1; // The tile we know is blank short blank=-1; // The tile we know is blank
unsigned char *scrpos = PicoDraw2FB, *pd = 0; unsigned char *scrpos = est->Draw2FB, *pd = 0;
// *hcache++ = code|(dx<<16)|(trow<<27); // cache it // *hcache++ = code|(dx<<16)|(trow<<27); // cache it
scrpos+=(*hc++)*LINE_WIDTH - START_ROW*LINE_WIDTH*8; scrpos+=(*hc++)*LINE_WIDTH - START_ROW*LINE_WIDTH*8;
@ -344,7 +345,7 @@ static void DrawTilesFromCacheF(int *hc)
// sx and sy are coords of virtual screen with 8pix borders on top and on left // sx and sy are coords of virtual screen with 8pix borders on top and on left
static void DrawSpriteFull(unsigned int *sprite) static void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est)
{ {
int width=0,height=0; int width=0,height=0;
// unsigned short *pal=NULL; // unsigned short *pal=NULL;
@ -375,7 +376,7 @@ static void DrawSpriteFull(unsigned int *sprite)
// goto first vertically visible tile // goto first vertically visible tile
while(sy <= START_ROW*8) { sy+=8; tile+=tdeltay; height--; } while(sy <= START_ROW*8) { sy+=8; tile+=tdeltay; height--; }
scrpos = PicoDraw2FB; scrpos = est->Draw2FB;
scrpos+=(sy-START_ROW*8)*LINE_WIDTH; scrpos+=(sy-START_ROW*8)*LINE_WIDTH;
for (; height > 0; height--, sy+=8, tile+=tdeltay) for (; height > 0; height--, sy+=8, tile+=tdeltay)
@ -468,27 +469,27 @@ static void DrawAllSpritesFull(int prio, int maxwidth)
// Go through sprites backwards: // Go through sprites backwards:
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
{ {
DrawSpriteFull(sprites[i]); DrawSpriteFull(sprites[i], &Pico.est);
} }
} }
#ifndef _ASM_DRAW_C #ifndef _ASM_DRAW_C
static void BackFillFull(int reg7) static void BackFillFull(void *dst, int reg7)
{ {
unsigned int back; unsigned int back;
// Start with a background color: // Start with a background color:
// back=PicoCramHigh[reg7&0x3f];
back=reg7&0x3f; back=reg7&0x3f;
back|=back<<8; back|=back<<8;
back|=back<<16; back|=back<<16;
memset32((int *)PicoDraw2FB, back, LINE_WIDTH*(8+(END_ROW-START_ROW)*8)/4); memset32(dst, back, LINE_WIDTH*(8+(END_ROW-START_ROW)*8)/4);
} }
#endif #endif
static void DrawDisplayFull(void) static void DrawDisplayFull(void)
{ {
struct PicoEState *est = &Pico.est;
struct PicoVideo *pvid=&Pico.video; struct PicoVideo *pvid=&Pico.video;
int win, edge=0, hvwin=0; // LSb->MSb: hwin&plane, vwin&plane, full int win, edge=0, hvwin=0; // LSb->MSb: hwin&plane, vwin&plane, full
int planestart=START_ROW, planeend=END_ROW; // plane A start/end when window shares display with plane A (in tile rows or columns) int planestart=START_ROW, planeend=END_ROW; // plane A start/end when window shares display with plane A (in tile rows or columns)
@ -551,55 +552,55 @@ static void DrawDisplayFull(void)
HighCache2A[1] = HighCache2B[1] = 0; HighCache2A[1] = HighCache2B[1] = 0;
if (PicoDrawMask & PDRAW_LAYERB_ON) if (PicoDrawMask & PDRAW_LAYERB_ON)
DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW); DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW, est);
if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin) if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin)
{ {
case 4: case 4:
// fullscreen window // fullscreen window
DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0); DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0, est);
break; break;
case 3: case 3:
// we have plane A and both v and h windows // we have plane A and both v and h windows
DrawLayerFull(0, HighCache2A, planestart, planeend); DrawLayerFull(0, HighCache2A, planestart, planeend, est);
DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0); // h DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0, est); // h
DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0); // v DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0, est); // v
break; break;
case 2: case 2:
case 1: case 1:
// both window and plane A visible, window is vertical XOR horizontal // both window and plane A visible, window is vertical XOR horizontal
DrawLayerFull(0, HighCache2A, planestart, planeend); DrawLayerFull(0, HighCache2A, planestart, planeend, est);
DrawWindowFull(winstart, winend, 0); DrawWindowFull(winstart, winend, 0, est);
break; break;
default: default:
// fullscreen plane A // fullscreen plane A
DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW); DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW, est);
break; break;
} }
if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) if (PicoDrawMask & PDRAW_SPRITES_LOW_ON)
DrawAllSpritesFull(0, maxw); DrawAllSpritesFull(0, maxw);
if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B); if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B, est);
if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A); if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A, est);
if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin) if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin)
{ {
case 4: case 4:
// fullscreen window // fullscreen window
DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 1); DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 1, est);
break; break;
case 3: case 3:
// we have plane A and both v and h windows // we have plane A and both v and h windows
DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 1); // h DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 1, est); // h
DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 1); // v DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 1, est); // v
break; break;
case 2: case 2:
case 1: case 1:
// both window and plane A visible, window is vertical XOR horizontal // both window and plane A visible, window is vertical XOR horizontal
DrawWindowFull(winstart, winend, 1); DrawWindowFull(winstart, winend, 1, est);
break; break;
} }
if (PicoDrawMask & PDRAW_SPRITES_HI_ON) if (PicoDrawMask & PDRAW_SPRITES_HI_ON)
@ -615,10 +616,14 @@ PICO_INTERNAL void PicoFrameFull()
if (PicoPrepareCram) PicoPrepareCram(); if (PicoPrepareCram) PicoPrepareCram();
// Draw screen: // Draw screen:
BackFillFull(Pico.video.reg[7]); BackFillFull(Pico.est.Draw2FB, Pico.video.reg[7]);
if (Pico.video.reg[1] & 0x40) if (Pico.video.reg[1] & 0x40)
DrawDisplayFull(); DrawDisplayFull();
pprof_end(draw); pprof_end(draw);
} }
void PicoDraw2Init(void)
{
Pico.est.Draw2FB = PicoDraw2FB_;
}

View file

@ -8,8 +8,7 @@
* this is highly specialized, be careful if changing related C code! * this is highly specialized, be careful if changing related C code!
*/ */
.extern Pico #include "pico_int_o32.h"
.extern PicoDraw2FB
@ define these constants in your include file: @ define these constants in your include file:
@ .equiv START_ROW, 1 @ .equiv START_ROW, 1
@ -25,16 +24,16 @@
.text .text
.align 2 .align 2
.global BackFillFull @ int reg7 @ void BackFillFull(void *dst, int reg7)
.global BackFillFull
BackFillFull: BackFillFull:
stmfd sp!, {r4-r9,lr} stmfd sp!, {r4-r9,lr}
ldr lr, =PicoDraw2FB @ lr=PicoDraw2FB add lr, r0, #328*8
mov r0, r0, lsl #26 mov r0, r1, lsl #26
ldr lr, [lr]
mov r0, r0, lsr #26 mov r0, r0, lsr #26
add lr, lr, #328*8
orr r0, r0, r0, lsl #8 orr r0, r0, r0, lsl #8
orr r0, r0, r0, lsl #16 orr r0, r0, r0, lsl #16
@ -67,8 +66,8 @@ BackFillFull:
bne .bff_loop bne .bff_loop
ldmfd sp!, {r4-r9,r12} ldmfd sp!, {r4-r9,lr}
bx r12 bx lr
.pool .pool
@ -343,17 +342,19 @@ BackFillFull:
@ DrawLayerTiles(*hcache, *scrpos, (cells<<24)|(nametab<<9)|(vscroll&0x3ff)<<11|(shift[width]<<8)|planeend, (ymask<<24)|(planestart<<16)|[htab||hscroll] @ DrawLayerTiles(*hcache, *scrpos, (cells<<24)|(nametab<<9)|(vscroll&0x3ff)<<11|(shift[width]<<8)|planeend, (ymask<<24)|(planestart<<16)|[htab||hscroll]
@static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend) @ void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
@ struct PicoEState *est)
.global DrawLayerFull .global DrawLayerFull
DrawLayerFull: DrawLayerFull:
ldr r12,[sp] @ est
stmfd sp!, {r4-r11,lr} stmfd sp!, {r4-r11,lr}
mov r6, r1 @ hcache mov r6, r1 @ hcache
ldr r11, =(Pico+0x22228) @ Pico.video ldr r11, [r12, #OFS_Pico_video]
ldr r10, =(Pico+0x10000) @ r10=Pico.vram ldr r10, [r12, #OFS_Pico_vram]
ldrb r5, [r11, #13] @ pvid->reg[13] ldrb r5, [r11, #13] @ pvid->reg[13]
ldrb r7, [r11, #11] ldrb r7, [r11, #11]
@ -402,9 +403,9 @@ DrawLayerFull:
and r4, r4, #7 and r4, r4, #7
orr lr, lr, r4, lsl #13 @ lr|=nametab_bits{3}<<13 orr lr, lr, r4, lsl #13 @ lr|=nametab_bits{3}<<13
ldr r11, =PicoDraw2FB @ r11=PicoDraw2FB ldr r11,[sp, #9*4] @ est
sub r4, r9, #(START_ROW<<24) sub r4, r9, #(START_ROW<<24)
ldr r11, [r11] ldr r11, [r11, #OFS_Draw2FB]
mov r4, r4, asr #24 mov r4, r4, asr #24
mov r7, #328*8 mov r7, #328*8
mla r11, r4, r7, r11 @ scrpos+=8*328*(planestart-START_ROW); mla r11, r4, r7, r11 @ scrpos+=8*328*(planestart-START_ROW);
@ -571,8 +572,9 @@ DrawLayerFull:
.pool .pool
@ void DrawTilesFromCacheF(int *hc, struct PicoEState *est)
.global DrawTilesFromCacheF @ int *hc .global DrawTilesFromCacheF
DrawTilesFromCacheF: DrawTilesFromCacheF:
stmfd sp!, {r4-r10,lr} stmfd sp!, {r4-r10,lr}
@ -580,14 +582,13 @@ DrawTilesFromCacheF:
mov r9, #0xff000000 @ r9=prevcode=-1 mov r9, #0xff000000 @ r9=prevcode=-1
mvn r6, #0 @ r6=prevy=-1 mvn r6, #0 @ r6=prevy=-1
ldr r4, =PicoDraw2FB @ r4=PicoDraw2FB ldr r4, [r1, #OFS_Draw2FB]
ldr r1, [r0], #4 @ read y offset ldr r2, [r0], #4 @ read y offset
ldr r4, [r4]
mov r7, #328 mov r7, #328
mla r1, r7, r1, r4 mla r2, r7, r2, r4
sub r12, r1, #(328*8*START_ROW) @ r12=scrpos sub r12, r2, #(328*8*START_ROW) @ r12=scrpos
ldr r10, =(Pico+0x10000) @ r10=Pico.vram ldr r10, [r1, #OFS_Pico_vram]
mov r8, r0 @ hc mov r8, r0 @ hc
mov r0, #0xf mov r0, #0xf
@ -666,12 +667,14 @@ DrawTilesFromCacheF:
@ @@@@@@@@@@@@@@@ @ @@@@@@@@@@@@@@@
@ (tile_start<<16)|row_start @ (tile_start<<16)|row_start
.global DrawWindowFull @ int tstart, int tend, int prio @ void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)
.global DrawWindowFull
DrawWindowFull: DrawWindowFull:
stmfd sp!, {r4-r11,lr} stmfd sp!, {r4-r11,lr}
ldr r11, =(Pico+0x22228) @ Pico.video ldr r11, [r3, #OFS_Pico_video]
ldrb r12, [r11, #3] @ pvid->reg[3] ldrb r12, [r11, #3] @ pvid->reg[3]
mov r12, r12, lsl #10 mov r12, r12, lsl #10
@ -686,11 +689,11 @@ DrawWindowFull:
and r4, r0, #0xff and r4, r0, #0xff
mla r12, r5, r4, r12 @ nametab += nametab_step*start; mla r12, r5, r4, r12 @ nametab += nametab_step*start;
ldr r10, [r3, #OFS_Pico_vram]
mov r4, r0, lsr #16 @ r4=start_cell_h mov r4, r0, lsr #16 @ r4=start_cell_h
add r7, r12, r4, lsl #1 add r7, r12, r4, lsl #1
@ fetch the first code now @ fetch the first code now
ldr r10, =(Pico+0x10000) @ lr=Pico.vram
ldrh r7, [r10, r7] ldrh r7, [r10, r7]
cmp r2, r7, lsr #15 cmp r2, r7, lsr #15
ldmnefd sp!, {r4-r11,pc} @ hack: simply assume that whole window uses same priority ldmnefd sp!, {r4-r11,pc} @ hack: simply assume that whole window uses same priority
@ -704,11 +707,10 @@ DrawWindowFull:
mov r9, #0xff000000 @ r9=prevcode=-1 mov r9, #0xff000000 @ r9=prevcode=-1
ldr r11, =PicoDraw2FB @ r11=scrpos ldr r11, [r3, #OFS_Draw2FB]
and r4, r0, #0xff and r4, r0, #0xff
ldr r11, [r11]
sub r4, r4, #START_ROW
add r11, r11, #328*8 add r11, r11, #328*8
sub r4, r4, #START_ROW
add r11, r11, #8 add r11, r11, #8
mov r7, #328*8 mov r7, #328*8
@ -873,8 +875,9 @@ DrawWindowFull:
b 52b b 52b
.endm .endm
@ void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est)
.global DrawSpriteFull @ unsigned int *sprite .global DrawSpriteFull
DrawSpriteFull: DrawSpriteFull:
stmfd sp!, {r4-r11,lr} stmfd sp!, {r4-r11,lr}
@ -902,9 +905,8 @@ DrawSpriteFull:
and r3, lr, #0x6000 and r3, lr, #0x6000
mov r3, r3, lsr #9 @ r3=pal=((code>>9)&0x30); mov r3, r3, lsr #9 @ r3=pal=((code>>9)&0x30);
ldr r11, =PicoDraw2FB @ r11=scrpos ldr r11, [r1, #OFS_Draw2FB]
ldr r10, =(Pico+0x10000) @ r10=Pico.vram ldr r10, [r1, #OFS_Pico_vram]
ldr r11, [r11]
sub r1, r12, #(START_ROW*8) sub r1, r12, #(START_ROW*8)
mov r0, #328 mov r0, #328
mla r11, r1, r0, r11 @ scrpos+=(sy-START_ROW*8)*328; mla r11, r1, r0, r11 @ scrpos+=(sy-START_ROW*8)*328;

View file

@ -1497,7 +1497,7 @@ PicoDoHighPal555:
PicoDoHighPal555_nopush: PicoDoHighPal555_nopush:
orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h
ldr r0, =HighPal add r0, r10, #OFS_HighPal
mov r1, #0 mov r1, #0
strb r1, [r8, #-0x1a] @ 0x2220e ~ dirtyPal strb r1, [r8, #-0x1a] @ 0x2220e ~ dirtyPal
@ -1513,7 +1513,7 @@ PicoDoHighPal555_nopush:
tst r9, #(1<<31) tst r9, #(1<<31)
beq PicoDoHighPal555_end beq PicoDoHighPal555_end
ldr r3, =HighPal add r3, r10, #OFS_HighPal
@ shadowed pixels: @ shadowed pixels:
mov r12, #0x008e mov r12, #0x008e
@ -1575,7 +1575,7 @@ FinalizeLine555:
bne PicoDoHighPal555_nopush bne PicoDoHighPal555_nopush
FinalizeLineRGB555_pal_done: FinalizeLineRGB555_pal_done:
ldr r3, =HighPal add r3, r10, #OFS_HighPal
ldr r12, [r10, #OFS_rendstatus] ldr r12, [r10, #OFS_rendstatus]
eors r0, r0, #1 @ sh is 0 eors r0, r0, #1 @ sh is 0

View file

@ -249,7 +249,7 @@ void PicoLineMode4(int line)
void PicoDoHighPal555M4(void) void PicoDoHighPal555M4(void)
{ {
unsigned int *spal=(void *)Pico.cram; unsigned int *spal=(void *)Pico.cram;
unsigned int *dpal=(void *)HighPal; unsigned int *dpal=(void *)Pico.est.HighPal;
unsigned int t; unsigned int t;
int i; int i;
@ -267,7 +267,7 @@ void PicoDoHighPal555M4(void)
t |= (t >> 4) & 0x08610861; t |= (t >> 4) & 0x08610861;
*dpal = t; *dpal = t;
} }
HighPal[0xe0] = 0; Pico.est.HighPal[0xe0] = 0;
} }
static void FinalizeLineRGB555M4(int line) static void FinalizeLineRGB555M4(int line)

View file

@ -49,6 +49,7 @@ void PicoInit(void)
Pico32xInit(); Pico32xInit();
PicoDrawInit(); PicoDrawInit();
PicoDraw2Init();
} }
// to be called once on emu exit // to be called once on emu exit

View file

@ -194,7 +194,6 @@ extern int PicoDrawMask;
#define PDRAW_32_COLS (1<<8) // 32 column mode #define PDRAW_32_COLS (1<<8) // 32 column mode
extern int rendstatus_old; extern int rendstatus_old;
extern int rendlines; extern int rendlines;
extern unsigned short HighPal[0x100];
// draw.c // draw.c
void PicoDrawUpdateHighPal(void); void PicoDrawUpdateHighPal(void);
@ -202,7 +201,6 @@ void PicoDrawSetInternalBuf(void *dest, int line_increment);
// draw2.c // draw2.c
// stuff below is optional // stuff below is optional
extern unsigned char *PicoDraw2FB; // buffer for fast renderer in format (8+320)x(8+224+8) (eights for borders)
extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now) extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use

View file

@ -333,12 +333,14 @@ struct PicoEState
{ {
int DrawScanline; int DrawScanline;
int rendstatus; int rendstatus;
void *DrawLineDest; // draw estination void *DrawLineDest; // draw destination
unsigned char *HighCol; unsigned char *HighCol;
int *HighPreSpr; int *HighPreSpr;
void *Pico_video; void *Pico_video;
void *Pico_vram; void *Pico_vram;
int *PicoOpt; int *PicoOpt;
unsigned char *Draw2FB;
unsigned short HighPal[0x100];
}; };
// some assembly stuff depend on these, do not touch! // some assembly stuff depend on these, do not touch!
@ -601,6 +603,7 @@ extern void *DrawLineDestBase;
extern int DrawLineDestIncrement; extern int DrawLineDestIncrement;
// draw2.c // draw2.c
void PicoDraw2Init(void);
PICO_INTERNAL void PicoFrameFull(); PICO_INTERNAL void PicoFrameFull();
// mode4.c // mode4.c

View file

@ -7,3 +7,5 @@
#define OFS_Pico_video 0x14 #define OFS_Pico_video 0x14
#define OFS_Pico_vram 0x18 #define OFS_Pico_vram 0x18
#define OFS_PicoOpt 0x1c #define OFS_PicoOpt 0x1c
#define OFS_Draw2FB 0x20
#define OFS_HighPal 0x24

View file

@ -155,11 +155,11 @@ static void blit(const char *fps, const char *notice)
} }
// a hack for VR // a hack for VR
if (PicoAHW & PAHW_SVP) if (PicoAHW & PAHW_SVP)
memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328); memset32((int *)(Pico.est.Draw2FB+328*8+328*223), 0xe0e0e0e0, 328);
if (!(Pico.video.reg[12]&1)) lines_flags|=0x10000; if (!(Pico.video.reg[12]&1)) lines_flags|=0x10000;
if (currentConfig.EmuOpt&0x4000) if (currentConfig.EmuOpt&0x4000)
lines_flags|=0x40000; // (Pico.m.frame_count&1)?0x20000:0x40000; lines_flags|=0x40000; // (Pico.m.frame_count&1)?0x20000:0x40000;
vidCpy8to16((unsigned short *)giz_screen+321*8, PicoDraw2FB+328*8, localPal, lines_flags); vidCpy8to16((unsigned short *)giz_screen+321*8, Pico.est.Draw2FB+328*8, localPal, lines_flags);
} }
else if (!(emu_opt&0x80)) else if (!(emu_opt&0x80))
{ {
@ -187,7 +187,7 @@ static void blit(const char *fps, const char *notice)
if (!(Pico.video.reg[12]&1)) lines_flags|=0x10000; if (!(Pico.video.reg[12]&1)) lines_flags|=0x10000;
if (currentConfig.EmuOpt&0x4000) if (currentConfig.EmuOpt&0x4000)
lines_flags|=0x40000; // (Pico.m.frame_count&1)?0x20000:0x40000; lines_flags|=0x40000; // (Pico.m.frame_count&1)?0x20000:0x40000;
vidCpy8to16((unsigned short *)giz_screen+321*8, PicoDraw2FB+328*8, localPal, lines_flags); vidCpy8to16((unsigned short *)giz_screen+321*8, Pico.est.Draw2FB+328*8, localPal, lines_flags);
} }
if (notice || (emu_opt & 2)) { if (notice || (emu_opt & 2)) {

View file

@ -7,8 +7,8 @@
* - 8bpp tile renderer * - 8bpp tile renderer
* In 32x mode: * In 32x mode:
* - 32x layer is overlayed on top of 16bpp one * - 32x layer is overlayed on top of 16bpp one
* - line internal one done on PicoDraw2FB, then mixed with 32x * - line internal one done on .Draw2FB, then mixed with 32x
* - tile internal one done on PicoDraw2FB, then mixed with 32x * - tile internal one done on .Draw2FB, then mixed with 32x
*/ */
#include <stdio.h> #include <stdio.h>
@ -311,8 +311,8 @@ static int make_local_pal_md(int fast_mode)
pallen = 0x100; pallen = 0x100;
} }
else if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes else if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes
bgr444_to_rgb32(localPal+0x40, HighPal); bgr444_to_rgb32(localPal+0x40, Pico.est.HighPal);
bgr444_to_rgb32(localPal+0x80, HighPal+0x40); bgr444_to_rgb32(localPal+0x80, Pico.est.HighPal+0x40);
} }
else else
memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess
@ -355,9 +355,9 @@ void pemu_finalize_frame(const char *fps, const char *notice)
} }
// a hack for VR // a hack for VR
if (PicoAHW & PAHW_SVP) if (PicoAHW & PAHW_SVP)
memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328); memset32((int *)(Pico.est.Draw2FB+328*8+328*223), 0xe0e0e0e0, 328);
// do actual copy // do actual copy
vidcpyM2(g_screen_ptr, PicoDraw2FB+328*8, vidcpyM2(g_screen_ptr, Pico.est.Draw2FB+328*8,
!(Pico.video.reg[12] & 1), !(PicoOpt & POPT_DIS_32C_BORDER)); !(Pico.video.reg[12] & 1), !(PicoOpt & POPT_DIS_32C_BORDER));
} }
else if (get_renderer() == RT_8BIT_ACC) else if (get_renderer() == RT_8BIT_ACC)

View file

@ -70,8 +70,8 @@ void pemu_finalize_frame(const char *fps, const char *notice)
{ {
if (currentConfig.renderer != RT_16BIT && !(PicoAHW & PAHW_32X)) { if (currentConfig.renderer != RT_16BIT && !(PicoAHW & PAHW_32X)) {
unsigned short *pd = (unsigned short *)g_screen_ptr + 8 * g_screen_width; unsigned short *pd = (unsigned short *)g_screen_ptr + 8 * g_screen_width;
unsigned char *ps = PicoDraw2FB + 328*8 + 8; unsigned char *ps = Pico.est.Draw2FB + 328*8 + 8;
unsigned short *pal = HighPal; unsigned short *pal = Pico.est.HighPal;
int i, x; int i, x;
if (Pico.m.dirtyPal) if (Pico.m.dirtyPal)
PicoDrawUpdateHighPal(); PicoDrawUpdateHighPal();
@ -101,7 +101,7 @@ static void apply_renderer(void)
case RT_8BIT_ACC: case RT_8BIT_ACC:
PicoOpt &= ~POPT_ALT_RENDERER; PicoOpt &= ~POPT_ALT_RENDERER;
PicoDrawSetOutFormat(PDF_8BIT, 0); PicoDrawSetOutFormat(PDF_8BIT, 0);
PicoDrawSetOutBuf(PicoDraw2FB + 8, 328); PicoDrawSetOutBuf(Pico.est.Draw2FB + 8, 328);
break; break;
case RT_8BIT_FAST: case RT_8BIT_FAST:
PicoOpt |= POPT_ALT_RENDERER; PicoOpt |= POPT_ALT_RENDERER;

View file

@ -36,7 +36,7 @@ int sceAudio_E0727056(int volume, void *buffer); // blocking output
int sceAudioOutput2GetRestSample(); int sceAudioOutput2GetRestSample();
//unsigned char *PicoDraw2FB = (unsigned char *)VRAM_CACHED_STUFF + 8; // +8 to be able to skip border with 1 quadword.. //unsigned char *Draw2FB = (unsigned char *)VRAM_CACHED_STUFF + 8; // +8 to be able to skip border with 1 quadword..
int engineStateSuspend; int engineStateSuspend;
#define PICO_PEN_ADJUST_X 4 #define PICO_PEN_ADJUST_X 4
@ -400,9 +400,9 @@ void blit1(void)
int i; int i;
unsigned char *pd; unsigned char *pd;
// clear top and bottom trash // clear top and bottom trash
for (pd = PicoDraw2FB+8, i = 8; i > 0; i--, pd += 512) for (pd = Pico.est.Draw2FB+8, i = 8; i > 0; i--, pd += 512)
memset32((int *)pd, 0xe0e0e0e0, 320/4); memset32((int *)pd, 0xe0e0e0e0, 320/4);
for (pd = PicoDraw2FB+512*232+8, i = 8; i > 0; i--, pd += 512) for (pd = Pico.est.Draw2FB+512*232+8, i = 8; i > 0; i--, pd += 512)
memset32((int *)pd, 0xe0e0e0e0, 320/4); memset32((int *)pd, 0xe0e0e0e0, 320/4);
} }

View file

@ -29,6 +29,8 @@ int main(int argc, char *argv[])
DUMP(f, Pico_video); DUMP(f, Pico_video);
DUMP(f, Pico_vram); DUMP(f, Pico_vram);
DUMP(f, PicoOpt); DUMP(f, PicoOpt);
DUMP(f, Draw2FB);
DUMP(f, HighPal);
fclose(f); fclose(f);
return 0; return 0;