From 4981de9ce79d0aa80222f8583667bf2fbf2265f2 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Aug 2017 19:23:20 +0300 Subject: [PATCH] eliminate texrels (wip2) --- pico/32x/32x_draw.c | 12 +++--- pico/debug.c | 5 +-- pico/draw.c | 68 +++++++++++++++-------------- pico/draw_arm.S | 95 +++++++++-------------------------------- pico/mode4.c | 16 +++---- pico/pico.c | 3 ++ pico/pico.h | 2 - pico/pico_int.h | 7 ++- pico/pico_int_o32.h | 8 +++- platform/gizmondo/emu.c | 11 +---- platform/gp2x/emu.c | 10 ++--- platform/psp/emu.c | 8 ++-- tools/mkoffsets.c | 4 ++ 13 files changed, 102 insertions(+), 147 deletions(-) diff --git a/pico/32x/32x_draw.c b/pico/32x/32x_draw.c index 007ef20..171a696 100644 --- a/pico/32x/32x_draw.c +++ b/pico/32x/32x_draw.c @@ -85,9 +85,9 @@ static void convert_pal555(int invert_prio) // this is almost never used (Wiz and menu bg gen only) void FinalizeLine32xRGB555(int sh, int line, struct PicoEState *est) { - unsigned short *pd = DrawLineDest; + unsigned short *pd = est->DrawLineDest; unsigned short *pal = Pico32xMem->pal_native; - unsigned char *pmd = HighCol + 8; + unsigned char *pmd = est->HighCol + 8; unsigned short *dram, *p32x; unsigned char mdbg; @@ -130,7 +130,7 @@ void FinalizeLine32xRGB555(int sh, int line, struct PicoEState *est) #define PICOSCAN_PRE \ PicoScan32xBegin(l + (lines_sft_offs & 0xff)); \ - dst = DrawLineDest; \ + dst = Pico.est.DrawLineDest; \ #define PICOSCAN_POST \ PicoScan32xEnd(l + (lines_sft_offs & 0xff)); \ @@ -228,7 +228,7 @@ void PicoDraw32xLayer(int offs, int lines, int md_bg) int lines_sft_offs; int which_func; - DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; + Pico.est.DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; dram = Pico32xMem->dram[Pico32x.vdp_regs[0x0a/2] & P32XV_FS]; if (Pico32xDrawMode == PDM32X_BOTH) { @@ -266,7 +266,7 @@ do_it: if (Pico32x.vdp_regs[2 / 2] & P32XV_SFT) lines_sft_offs |= 1 << 8; - do_loop[which_func](DrawLineDest, dram, lines_sft_offs, md_bg); + do_loop[which_func](Pico.est.DrawLineDest, dram, lines_sft_offs, md_bg); } // mostly unused, games tend to keep 32X layer on @@ -292,7 +292,7 @@ void PicoDraw32xLayerMdOnly(int offs, int lines) for (l = 0; l < lines; l++) { if (have_scan) { PicoScan32xBegin(l + offs); - dst = (unsigned short*)DrawLineDest + poffs; + dst = (unsigned short*)Pico.est.DrawLineDest + poffs; } for (p = 0; p < plen; p += 4) { dst[p + 0] = pal[*pmd++]; diff --git a/pico/debug.c b/pico/debug.c index 91bff56..7cc3c32 100644 --- a/pico/debug.c +++ b/pico/debug.c @@ -20,13 +20,12 @@ char *PDebugMain(void) { struct PicoVideo *pv=&Pico.video; unsigned char *reg=pv->reg, r; - extern int HighPreSpr[]; int i, sprites_lo, sprites_hi; char *dstrp; sprites_lo = sprites_hi = 0; - for (i = 0; HighPreSpr[i] != 0; i+=2) - if (HighPreSpr[i+1] & 0x8000) + for (i = 0; Pico.est.HighPreSpr[i] != 0; i+=2) + if (Pico.est.HighPreSpr[i+1] & 0x8000) sprites_hi++; else sprites_lo++; diff --git a/pico/draw.c b/pico/draw.c index 76820a9..e4bff25 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -35,18 +35,16 @@ int (*PicoScanBegin)(unsigned int num) = NULL; int (*PicoScanEnd) (unsigned int num) = NULL; static unsigned char DefHighCol[8+320+8]; -unsigned char *HighCol = DefHighCol; static unsigned char *HighColBase = DefHighCol; static int HighColIncrement; static unsigned int DefOutBuff[320*2/2]; -void *DrawLineDest = DefOutBuff; // pointer to dest buffer where to draw this line to void *DrawLineDestBase = DefOutBuff; int DrawLineDestIncrement; static int HighCacheA[41+1]; // caches for high layers static int HighCacheB[41+1]; -int HighPreSpr[80*2+1]; // slightly preprocessed sprites +static int HighPreSpr[80*2+1]; // slightly preprocessed sprites #define SPRL_HAVE_HI 0x80 // have hi priority sprites #define SPRL_HAVE_LO 0x40 // *lo* @@ -100,7 +98,7 @@ void blockcpy_or(void *dst, void *src, size_t n, int pat) #define TileNormMaker(funcname,pix_func) \ static int funcname(int sx,int addr,int pal) \ { \ - unsigned char *pd = HighCol+sx; \ + unsigned char *pd = Pico.est.HighCol+sx; \ unsigned int pack=0; unsigned int t=0; \ \ pack=*(unsigned int *)(Pico.vram+addr); /* Get 8 pixels */ \ @@ -124,7 +122,7 @@ static int funcname(int sx,int addr,int pal) \ #define TileFlipMaker(funcname,pix_func) \ static int funcname(int sx,int addr,int pal) \ { \ - unsigned char *pd = HighCol+sx; \ + unsigned char *pd = Pico.est.HighCol+sx; \ unsigned int pack=0; unsigned int t=0; \ \ pack=*(unsigned int *)(Pico.vram+addr); /* Get 8 pixels */ \ @@ -515,7 +513,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh, pal=((code>>9)&0x30); if (prio) { - int *zb = (int *)(HighCol+8+(tilex<<3)); + int *zb = (int *)(est->HighCol+8+(tilex<<3)); *zb++ &= 0xbfbfbfbf; *zb &= 0xbfbfbfbf; } else { @@ -541,7 +539,7 @@ static void DrawTilesFromCacheShPrep(void) // as some layer has covered whole line with hi priority tiles, // we can process whole line and then act as if sh/hi mode was off, // but leave lo pri op sprite markers alone - int c = 320/4, *zb = (int *)(HighCol+8); + int c = 320/4, *zb = (int *)(Pico.est.HighCol+8); Pico.est.rendstatus |= PDRAW_SHHI_DONE; while (c--) { @@ -591,7 +589,7 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est addr=(code&0x7ff)<<4; addr+=(unsigned int)code>>25; // y offset into tile dx=(code>>16)&0x1ff; - zb = HighCol+dx; + zb = est->HighCol+dx; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; @@ -607,7 +605,7 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est last_cut_tile: { unsigned int t, pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels - unsigned char *pd = HighCol+dx; + unsigned char *pd = est->HighCol+dx; if (!pack) return; if (code&0x0800) { @@ -812,7 +810,7 @@ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est) int offs, delta, width, height, row; offs = (p[cnt] & 0x7f) * 2; - sprite = HighPreSpr + offs; + sprite = est->HighPreSpr + offs; code = sprite[1]; pal = (code>>9)&0x30; @@ -936,7 +934,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) /* nasty 1: remove 'sprite' flags */ { - int c = 320/4/4, *zb = (int *)(HighCol+8); + int c = 320/4/4, *zb = (int *)(Pico.est.HighCol+8); while (c--) { *zb++ &= 0x7f7f7f7f; *zb++ &= 0x7f7f7f7f; @@ -1147,7 +1145,7 @@ static void DrawAllSprites(unsigned char *sprited, int prio, int sh, // -------------------------------------------- -void BackFill(int reg7, int sh) +void BackFill(int reg7, int sh, struct PicoEState *est) { unsigned int back; @@ -1157,7 +1155,7 @@ void BackFill(int reg7, int sh) back|=back<<8; back|=back<<16; - memset32((int *)(HighCol+8), back, 320/4); + memset32((int *)(est->HighCol+8), back, 320/4); } #endif @@ -1204,10 +1202,10 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est) } } -void FinalizeLine555(int sh, int line) +void FinalizeLine555(int sh, int line, struct PicoEState *est) { - unsigned short *pd=DrawLineDest; - unsigned char *ps=HighCol+8; + unsigned short *pd=est->DrawLineDest; + unsigned char *ps=est->HighCol+8; unsigned short *pal=HighPal; int len; @@ -1242,7 +1240,7 @@ void FinalizeLine555(int sh, int line) static void FinalizeLine8bit(int sh, int line, struct PicoEState *est) { - unsigned char *pd = DrawLineDest; + unsigned char *pd = est->DrawLineDest; int len, rs = est->rendstatus; static int dirty_count; @@ -1271,12 +1269,12 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est) if (!sh && (rs & PDRAW_SONIC_MODE)) { if (dirty_count >= 11) { - blockcpy_or(pd, HighCol+8, len, 0x80); + blockcpy_or(pd, est->HighCol+8, len, 0x80); } else { - blockcpy_or(pd, HighCol+8, len, 0x40); + blockcpy_or(pd, est->HighCol+8, len, 0x40); } } else { - blockcpy(pd, HighCol+8, len); + blockcpy(pd, est->HighCol+8, len); } } @@ -1403,8 +1401,8 @@ PICO_INTERNAL void PicoFrameStart(void) rendstatus_old = Pico.est.rendstatus; } - HighCol = HighColBase + offs * HighColIncrement; - DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; + Pico.est.HighCol = HighColBase + offs * HighColIncrement; + Pico.est.DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; Pico.est.DrawScanline = 0; skip_next_line = 0; @@ -1421,7 +1419,7 @@ static void DrawBlankedLine(int line, int offs, int sh, int bgc) if (PicoScanBegin != NULL) PicoScanBegin(line + offs); - BackFill(bgc, sh); + BackFill(bgc, sh, &Pico.est); if (FinalizeLine != NULL) FinalizeLine(sh, line, &Pico.est); @@ -1429,8 +1427,8 @@ static void DrawBlankedLine(int line, int offs, int sh, int bgc) if (PicoScanEnd != NULL) PicoScanEnd(line + offs); - HighCol += HighColIncrement; - DrawLineDest = (char *)DrawLineDest + DrawLineDestIncrement; + Pico.est.HighCol += HighColIncrement; + Pico.est.DrawLineDest = (char *)Pico.est.DrawLineDest + DrawLineDestIncrement; } static void PicoLine(int line, int offs, int sh, int bgc) @@ -1452,7 +1450,7 @@ static void PicoLine(int line, int offs, int sh, int bgc) } // Draw screen: - BackFill(bgc, sh); + BackFill(bgc, sh, &Pico.est); if (Pico.video.reg[1]&0x40) DrawDisplay(sh); @@ -1462,8 +1460,8 @@ static void PicoLine(int line, int offs, int sh, int bgc) if (PicoScanEnd != NULL) skip_next_line = PicoScanEnd(line + offs); - HighCol += HighColIncrement; - DrawLineDest = (char *)DrawLineDest + DrawLineDestIncrement; + Pico.est.HighCol += HighColIncrement; + Pico.est.DrawLineDest = (char *)Pico.est.DrawLineDest + DrawLineDestIncrement; } void PicoDrawSync(int to, int blank_last_line) @@ -1539,7 +1537,7 @@ void PicoDrawSetOutBuf(void *dest, int increment) { DrawLineDestBase = dest; DrawLineDestIncrement = increment; - DrawLineDest = (unsigned char*)DrawLineDestBase + Pico.est.DrawScanline * increment; + Pico.est.DrawLineDest = (unsigned char*)DrawLineDestBase + Pico.est.DrawScanline * increment; } void PicoDrawSetInternalBuf(void *dest, int increment) @@ -1547,7 +1545,7 @@ void PicoDrawSetInternalBuf(void *dest, int increment) if (dest != NULL) { HighColBase = dest; HighColIncrement = increment; - HighCol = HighColBase + Pico.est.DrawScanline * increment; + Pico.est.HighCol = HighColBase + Pico.est.DrawScanline * increment; } else { HighColBase = DefHighCol; @@ -1572,4 +1570,12 @@ void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned in } } -// vim:ts=4:sw=4:expandtab +void PicoDrawInit(void) +{ + Pico.est.DrawLineDest = DefOutBuff; + Pico.est.HighCol = HighColBase; + Pico.est.HighPreSpr = HighPreSpr; + rendstatus_old = -1; +} + +// vim:ts=2:sw=2:expandtab diff --git a/pico/draw_arm.S b/pico/draw_arm.S index 2c1db10..23c522b 100644 --- a/pico/draw_arm.S +++ b/pico/draw_arm.S @@ -10,15 +10,7 @@ #include "pico_int_o32.h" -.extern PicoOpt -.extern HighCol -.extern HighSprZ -.extern HighPreSpr -.extern DrawLineDest .extern DrawStripInterlace -.extern HighCacheS_ptr - -.equiv OVERRIDE_HIGHCOL, 1 .equ PDRAW_SPRITES_MOVED, (1<<0) .equ PDRAW_WND_DIFF_PRIO, (1<<1) @@ -395,17 +387,12 @@ DrawLayer: sub r10,r10,r9, lsl #16 @ cells-=cellskip @ cache some stuff to avoid mem access -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol - mov r0, #0xf - ldr r11,[r11] -.else - ldr r11,=HighCol + ldr r11,[sp, #9*4] @ est mov r0, #0xf -.endif + ldr r11,[r11, #OFS_HighCol] mvn r9, #0 @ r9=prevcode=-1 - add r1, r11, r7 @ r1=pdest + add r1, r11, r7 @ r1=pdest @ r4 & r7 are scratch in this loop @@ -548,14 +535,9 @@ DrawLayer: add r10,r10,r9, lsl #16 @ cell+=cellskip @ cache some stuff to avoid mem access -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol - mov r0, #0xf - ldr r11,[r11] -.else - ldr r11,=HighCol + ldr r11,[sp, #9*4] @ est mov r0, #0xf -.endif + ldr r11,[r11, #OFS_HighCol] mvn r9, #0 @ r9=prevcode=-1 add r1, r11, r7 @ r1=pdest @@ -722,23 +704,17 @@ DrawLayer: @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@ void BackFill(int reg7, int sh, struct PicoEState *est) -.global BackFill @ int reg7, int sh +.global BackFill BackFill: stmfd sp!, {r4-r9,lr} -.if OVERRIDE_HIGHCOL - ldr lr, =HighCol mov r0, r0, lsl #26 - ldr lr, [lr] + ldr lr, [r2, #OFS_HighCol] mov r0, r0, lsr #26 add lr, lr, #8 -.else - ldr lr, =(HighCol+8) - mov r0, r0, lsl #26 - mov r0, r0, lsr #26 -.endif orr r0, r0, r1, lsl #6 orr r0, r0, r0, lsl #8 @@ -764,8 +740,8 @@ BackFill: stmia lr!, {r0-r7} stmia lr!, {r0-r7} - ldmfd sp!, {r4-r9,r12} - bx r12 + ldmfd sp!, {r4-r9,lr} + bx lr @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -778,14 +754,8 @@ DrawTilesFromCache: stmfd sp!, {r4-r9,r11,lr} @ cache some stuff to avoid mem access -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol + ldr r11,[r3, #OFS_HighCol] mov r12,#0xf - ldr r11,[r11] -.else - ldr r11,=HighCol - mov r12,#0xf -.endif ldr lr, [r3, #OFS_Pico_vram] mov r9, r3 @ est @@ -964,14 +934,8 @@ DrawSpritesSHi: add r10,r0, #3 @ r10=HighLnSpr end add r10,r10,r3 @ r10=HighLnSpr end -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol - mov r12,#0xf - ldr r11,[r11] -.else - ldr r11,=HighCol + ldr r11,[r1, #OFS_HighCol] mov r12,#0xf -.endif ldr lr, [r1, #OFS_Pico_vram] @@ -979,7 +943,7 @@ DrawSpriteSHi: @ draw next sprite ldrb r0, [r10,#-1]! ldr r7, [sp] @ est - ldr r1, =HighPreSpr + ldr r1, [r7, #OFS_HighPreSpr] cmp r0, #0xff ldmeqfd sp!, {r1,r4-r11,pc} @ end of list and r0, r0, #0x7f @@ -1159,14 +1123,8 @@ das_no_prep: add r10,r0, #3 add r10,r10,r2 @ r10=HighLnSpr end -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol - mov r12,#0xf - ldr r11,[r11] -.else - ldr r11,=HighCol + ldr r11,[r3, #OFS_HighCol] mov r12,#0xf -.endif ldr lr, [r3, #OFS_Pico_vram] @ + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size @@ -1182,7 +1140,7 @@ DrawSprite: ldmeqfd sp!, {r1,r3-r11,pc} @ end of list cmp r2, r8, lsr #1 bne DrawSprite @ wrong priority - ldr r1, =HighPreSpr + ldr r1, [r7, #OFS_HighPreSpr] and r0, r0, #0x7f add r0, r1, r0, lsl #3 @@ -1352,17 +1310,10 @@ DrawWindow: sub r8, r1, r0 @ cache some stuff to avoid mem access -.if OVERRIDE_HIGHCOL - ldr r11,=HighCol + ldr r11, [r11, #OFS_HighCol] mov r8, r8, lsl #1 @ cells - ldr r11,[r11] - mvn r9, #0 @ r9=prevcode=-1 add r11,r11,#8 -.else - ldr r11,=(HighCol+8) - mov r8, r8, lsl #1 @ cells mvn r9, #0 @ r9=prevcode=-1 -.endif add r1, r11, r0, lsl #4 @ r1=pdest mov r0, #0xf b .dwloop_enter @@ -1632,17 +1583,9 @@ FinalizeLineRGB555_pal_done: tstne r12,#PDRAW_ACC_SPRITES movne lr, #0x3f -.if OVERRIDE_HIGHCOL - ldr r1, =HighCol - ldr r0, =DrawLineDest - ldr r1, [r1] - ldr r0, [r0] + ldr r1, [r10, #OFS_HighCol] + ldr r0, [r10, #OFS_DrawLineDest] add r1, r1, #8 -.else - ldr r0, =DrawLineDest - ldr r1, =(HighCol+8) - ldr r0, [r0] -.endif ldrb r12, [r8, #12] mov lr, lr, lsl #1 @@ -1650,7 +1593,7 @@ FinalizeLineRGB555_pal_done: tst r12, #1 movne r2, #320/8 @ len bne .fl_no32colRGB555 - ldr r4, =PicoOpt + ldr r4, [r10, #OFS_PicoOpt] mov r2, #256/8 ldr r4, [r4] tst r4, #0x4000 diff --git a/pico/mode4.c b/pico/mode4.c index c945f6f..1f9adff 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -28,7 +28,7 @@ static int screen_offset; static int TileNormM4(int sx, int addr, int pal) { - unsigned char *pd = HighCol + sx; + unsigned char *pd = Pico.est.HighCol + sx; unsigned int pack, t; pack = *(unsigned int *)(Pico.vram + addr); /* Get 4 bitplanes / 8 pixels */ @@ -50,7 +50,7 @@ static int TileNormM4(int sx, int addr, int pal) static int TileFlipM4(int sx,int addr,int pal) { - unsigned char *pd = HighCol + sx; + unsigned char *pd = Pico.est.HighCol + sx; unsigned int pack, t; pack = *(unsigned int *)(Pico.vram + addr); /* Get 4 bitplanes / 8 pixels */ @@ -192,7 +192,7 @@ static void DrawDisplayM4(int scanline) if (pv->reg[0] & 0x20) // first column masked - ((int *)HighCol)[2] = ((int *)HighCol)[3] = 0xe0e0e0e0; + ((int *)Pico.est.HighCol)[2] = ((int *)Pico.est.HighCol)[3] = 0xe0e0e0e0; } void PicoFrameStartMode4(void) @@ -219,7 +219,7 @@ void PicoFrameStartMode4(void) rendlines = lines; } - DrawLineDest = (char *)DrawLineDestBase + screen_offset * DrawLineDestIncrement; + Pico.est.DrawLineDest = (char *)DrawLineDestBase + screen_offset * DrawLineDestIncrement; } void PicoLineMode4(int line) @@ -233,7 +233,7 @@ void PicoLineMode4(int line) skip_next_line = PicoScanBegin(line + screen_offset); // Draw screen: - BackFill(Pico.video.reg[7] & 0x0f, 0); + BackFill(Pico.video.reg[7] & 0x0f, 0, &Pico.est); if (Pico.video.reg[1] & 0x40) DrawDisplayM4(line); @@ -243,7 +243,7 @@ void PicoLineMode4(int line) if (PicoScanEnd != NULL) skip_next_line = PicoScanEnd(line + screen_offset); - DrawLineDest = (char *)DrawLineDest + DrawLineDestIncrement; + Pico.est.DrawLineDest = (char *)Pico.est.DrawLineDest + DrawLineDestIncrement; } void PicoDoHighPal555M4(void) @@ -282,12 +282,12 @@ static void FinalizeLineRGB555M4(int line) static void FinalizeLine8bitM4(int line) { - unsigned char *pd = DrawLineDest; + unsigned char *pd = Pico.est.DrawLineDest; if (!(PicoOpt & POPT_DIS_32C_BORDER)) pd += 32; - memcpy32((int *)pd, (int *)(HighCol+8), 256/4); + memcpy32((int *)pd, (int *)(Pico.est.HighCol+8), 256/4); } void PicoDrawSetOutputMode4(pdso_t which) diff --git a/pico/pico.c b/pico/pico.c index e14c503..b6a083d 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -39,6 +39,7 @@ void PicoInit(void) Pico.est.Pico_video = &Pico.video; Pico.est.Pico_vram = Pico.vram; + Pico.est.PicoOpt = &PicoOpt; // Init CPUs: SekInit(); @@ -47,6 +48,8 @@ void PicoInit(void) PicoInitMCD(); PicoSVPInit(); Pico32xInit(); + + PicoDrawInit(); } // to be called once on emu exit diff --git a/pico/pico.h b/pico/pico.h index d899b1a..98e4c78 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -172,8 +172,6 @@ typedef enum void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode); void PicoDrawSetOutBuf(void *dest, int increment); void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num)); -extern void *DrawLineDest; -extern unsigned char *HighCol; // utility #ifdef _ASM_DRAW_C void vidConvCpyRGB565(void *to, void *from, int pixels); diff --git a/pico/pico_int.h b/pico/pico_int.h index 427460e..b9a4418 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -338,8 +338,12 @@ struct PicoEState { int DrawScanline; int rendstatus; + void *DrawLineDest; // draw estination + unsigned char *HighCol; + int *HighPreSpr; void *Pico_video; void *Pico_vram; + int *PicoOpt; }; // some assembly stuff depend on these, do not touch! @@ -589,9 +593,10 @@ extern void (*PicoCartUnloadHook)(void); int CM_compareRun(int cyc, int is_sub); // draw.c +void PicoDrawInit(void); PICO_INTERNAL void PicoFrameStart(void); void PicoDrawSync(int to, int blank_last_line); -void BackFill(int reg7, int sh); +void BackFill(int reg7, int sh, struct PicoEState *est); void FinalizeLine555(int sh, int line, struct PicoEState *est); extern int (*PicoScanBegin)(unsigned int num); extern int (*PicoScanEnd)(unsigned int num); diff --git a/pico/pico_int_o32.h b/pico/pico_int_o32.h index 1cdc6b5..4094697 100644 --- a/pico/pico_int_o32.h +++ b/pico/pico_int_o32.h @@ -1,5 +1,9 @@ /* autogenerated by ./tools/mkoffsets, do not edit */ #define OFS_DrawScanline 0x00 #define OFS_rendstatus 0x04 -#define OFS_Pico_video 0x08 -#define OFS_Pico_vram 0x0c +#define OFS_DrawLineDest 0x08 +#define OFS_HighCol 0x0c +#define OFS_HighPreSpr 0x10 +#define OFS_Pico_video 0x14 +#define OFS_Pico_vram 0x18 +#define OFS_PicoOpt 0x1c diff --git a/platform/gizmondo/emu.c b/platform/gizmondo/emu.c index 3115ebd..3a6c861 100644 --- a/platform/gizmondo/emu.c +++ b/platform/gizmondo/emu.c @@ -94,7 +94,7 @@ void pemu_prep_defconfig(void) static int EmuScanBegin16(unsigned int num) { - DrawLineDest = (unsigned short *) giz_screen + 321 * num; + Pico.est.DrawLineDest = (unsigned short *) giz_screen + 321 * num; if ((currentConfig.EmuOpt&0x4000) && (num&1) == 0) // (Pico.m.frame_count&1)) return 1; // skip next line @@ -105,7 +105,7 @@ static int EmuScanBegin16(unsigned int num) static int EmuScanBegin8(unsigned int num) { // draw like the fast renderer - HighCol = gfx_buffer + 328 * num; + Pico.est.HighCol = gfx_buffer + 328 * num; return 0; } @@ -122,13 +122,6 @@ static void osd_text(int x, int y, const char *text) emu_text_out16(x, y, text); } -/* -void log1(void *p1, void *p2) -{ - lprintf("%p %p %p\n", p1, p2, DrawLineDest); -} -*/ - static void cd_leds(void) { static int old_reg = 0; diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 3121a6a..8db33a9 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -222,7 +222,7 @@ static unsigned char __attribute__((aligned(4))) rot_buff[320*4*2]; static int EmuScanBegin16_rot(unsigned int num) { - DrawLineDest = rot_buff + (num & 3) * 320 * 2; + Pico.est.DrawLineDest = rot_buff + (num & 3) * 320 * 2; return 0; } @@ -237,7 +237,7 @@ static int EmuScanEnd16_rot(unsigned int num) static int EmuScanBegin8_rot(unsigned int num) { - DrawLineDest = rot_buff + (num & 3) * 320; + Pico.est.DrawLineDest = rot_buff + (num & 3) * 320; return 0; } @@ -262,14 +262,14 @@ static int EmuScanBegin16_ld(unsigned int num) if (emu_scan_begin) return emu_scan_begin(ld_counter); else - DrawLineDest = (char *)g_screen_ptr + 320 * ld_counter * gp2x_current_bpp / 8; + Pico.est.DrawLineDest = (char *)g_screen_ptr + 320 * ld_counter * gp2x_current_bpp / 8; return 0; } static int EmuScanEnd16_ld(unsigned int num) { - void *oldline = DrawLineDest; + void *oldline = Pico.est.DrawLineDest; if (emu_scan_end) emu_scan_end(ld_counter); @@ -280,7 +280,7 @@ static int EmuScanEnd16_ld(unsigned int num) ld_left = ld_lines; EmuScanBegin16_ld(num); - memcpy32(DrawLineDest, oldline, 320 * gp2x_current_bpp / 8 / 4); + memcpy32(Pico.est.DrawLineDest, oldline, 320 * gp2x_current_bpp / 8 / 4); if (emu_scan_end) emu_scan_end(ld_counter); diff --git a/platform/psp/emu.c b/platform/psp/emu.c index 8deb7fd..cb16d26 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -242,8 +242,8 @@ static void do_slowmode_lines(int line_to) static void EmuScanPrepare(void) { - HighCol = (unsigned char *)VRAM_CACHED_STUFF + 8; - if (!(Pico.video.reg[1]&8)) HighCol += 8*512; + Pico.est.HighCol = (unsigned char *)VRAM_CACHED_STUFF + 8; + if (!(Pico.video.reg[1]&8)) Pico.est.HighCol += 8*512; if (dynamic_palette > 0) dynamic_palette--; @@ -258,7 +258,7 @@ static void EmuScanPrepare(void) static int EmuScanSlowBegin(unsigned int num) { if (!dynamic_palette) - HighCol = (unsigned char *)VRAM_CACHED_STUFF + num * 512 + 8; + Pico.est.HighCol = (unsigned char *)VRAM_CACHED_STUFF + num * 512 + 8; return 0; } @@ -276,7 +276,7 @@ static int EmuScanSlowEnd(unsigned int num) if (dynamic_palette) { int line_len = (Pico.video.reg[12]&1) ? 320 : 256; void *dst = (char *)VRAM_STUFF + 512*240 + 512*2*num; - amips_clut_f(dst, HighCol + 8, localPal, line_len); + amips_clut_f(dst, Pico.est.HighCol + 8, localPal, line_len); } return 0; diff --git a/tools/mkoffsets.c b/tools/mkoffsets.c index 4044ad3..e9eb3c5 100644 --- a/tools/mkoffsets.c +++ b/tools/mkoffsets.c @@ -23,8 +23,12 @@ int main(int argc, char *argv[]) fprintf(f, "/* autogenerated by %s, do not edit */\n", argv[0]); DUMP(f, DrawScanline); DUMP(f, rendstatus); + DUMP(f, DrawLineDest); + DUMP(f, HighCol); + DUMP(f, HighPreSpr); DUMP(f, Pico_video); DUMP(f, Pico_vram); + DUMP(f, PicoOpt); fclose(f); return 0; -- 2.39.2