From 98a27142346e05a4cef4fe89469bc09d5560edc1 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 6 Aug 2017 22:25:26 +0300 Subject: [PATCH] eliminate texrels, part 3 --- pico/32x/draw.c | 18 +++++----- pico/debug.c | 13 ++++---- pico/draw.c | 17 +++++----- pico/draw2.c | 73 ++++++++++++++++++++++------------------- pico/draw2_arm.S | 64 +++++++++++++++++++----------------- pico/draw_arm.S | 6 ++-- pico/mode4.c | 4 +-- pico/pico.c | 1 + pico/pico.h | 2 -- pico/pico_int.h | 5 ++- pico/pico_int_o32.h | 2 ++ platform/gizmondo/emu.c | 6 ++-- platform/gp2x/emu.c | 12 +++---- platform/linux/emu.c | 6 ++-- platform/psp/emu.c | 6 ++-- tools/mkoffsets.c | 2 ++ 16 files changed, 125 insertions(+), 112 deletions(-) diff --git a/pico/32x/draw.c b/pico/32x/draw.c index e20238e..3e007ae 100644 --- a/pico/32x/draw.c +++ b/pico/32x/draw.c @@ -141,9 +141,9 @@ static void do_loop_dc##name(unsigned short *dst, \ unsigned short *dram, int lines_sft_offs, int mdbg) \ { \ 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; \ - unsigned short *palmd = HighPal; \ + unsigned short *palmd = Pico.est.HighPal; \ unsigned short *p32x; \ int lines = lines_sft_offs >> 16; \ 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 *pal = Pico32xMem->pal_native; \ - unsigned char *pmd = PicoDraw2FB + \ + unsigned char *pmd = Pico.est.Draw2FB + \ 328 * (lines_sft_offs & 0xff) + 8; \ - unsigned short *palmd = HighPal; \ + unsigned short *palmd = Pico.est.HighPal; \ unsigned char *p32x; \ int lines = lines_sft_offs >> 16; \ 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 *pal = Pico32xMem->pal_native; \ - unsigned char *pmd = PicoDraw2FB + \ + unsigned char *pmd = Pico.est.Draw2FB + \ 328 * (lines_sft_offs & 0xff) + 8; \ - unsigned short *palmd = HighPal; \ + unsigned short *palmd = Pico.est.HighPal; \ unsigned short *p32x; \ int lines = lines_sft_offs >> 16; \ int l; \ @@ -274,8 +274,8 @@ void PicoDraw32xLayerMdOnly(int offs, int lines) { int have_scan = PicoScan32xBegin != NULL && PicoScan32xEnd != NULL; unsigned short *dst = (void *)((char *)DrawLineDestBase + offs * DrawLineDestIncrement); - unsigned char *pmd = PicoDraw2FB + 328 * offs + 8; - unsigned short *pal = HighPal; + unsigned char *pmd = Pico.est.Draw2FB + 328 * offs + 8; + unsigned short *pal = Pico.est.HighPal; int poffs = 0, plen = 320; int l, p; @@ -322,7 +322,7 @@ void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode) } // use the same layout as alt renderer - PicoDrawSetInternalBuf(PicoDraw2FB, 328); + PicoDrawSetInternalBuf(Pico.est.Draw2FB, 328); Pico32xDrawMode = (which == PDF_RGB555) ? PDM32X_32X_ONLY : PDM32X_BOTH; } diff --git a/pico/debug.c b/pico/debug.c index 7cc3c32..efcd3fd 100644 --- a/pico/debug.c +++ b/pico/debug.c @@ -196,29 +196,30 @@ void PDebugShowSpriteStats(unsigned short *screen, int stride) void PDebugShowPalette(unsigned short *screen, int stride) { + struct PicoEState *est = &Pico.est; int x, y; Pico.m.dirtyPal = 1; if (PicoAHW & PAHW_SMS) PicoDoHighPal555M4(); else - PicoDoHighPal555(1, 0, &Pico.est); + PicoDoHighPal555(1, 0, est); Pico.m.dirtyPal = 1; screen += 16*stride+8; for (y = 0; y < 8*4; y++) 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; for (y = 0; y < 8*4; y++) 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; for (y = 0; y < 8*4; y++) 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) @@ -263,9 +264,9 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which) PicoFrameFull(); 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++) - 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; } diff --git a/pico/draw.c b/pico/draw.c index 7dbdc34..9ad32da 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -1161,8 +1161,6 @@ void BackFill(int reg7, int sh, struct PicoEState *est) // -------------------------------------------- -unsigned short HighPal[0x100]; - #ifndef _ASM_DRAW_C 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; spal = (void *)Pico.cram; - dpal = (void *)HighPal; + dpal = (void *)est->HighPal; for (i = 0; i < 0x40 / 2; i++) { t = spal[i]; @@ -1206,7 +1204,7 @@ void FinalizeLine555(int sh, int line, struct PicoEState *est) { unsigned short *pd=est->DrawLineDest; unsigned char *ps=est->HighCol+8; - unsigned short *pal=HighPal; + unsigned short *pal=est->HighPal; int len; if (Pico.m.dirtyPal) @@ -1253,9 +1251,9 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est) rs |= PDRAW_SONIC_MODE; est->rendstatus = rs; if (dirty_count == 3) { - blockcpy(HighPal, Pico.cram, 0x40*2); + blockcpy(est->HighPal, Pico.cram, 0x40*2); } 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 void PicoDrawUpdateHighPal(void) { + struct PicoEState *est = &Pico.est; int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight? if (PicoOpt & POPT_ALT_RENDERER) sh = 0; // no s/h support PicoDoHighPal555(sh, 0, &Pico.est); - if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { + if (est->rendstatus & PDRAW_SONIC_MODE) { // FIXME? - memcpy(HighPal + 0x40, HighPal, 0x40*2); - memcpy(HighPal + 0x80, HighPal, 0x40*2); + memcpy(est->HighPal + 0x40, est->HighPal, 0x40*2); + memcpy(est->HighPal + 0x80, est->HighPal, 0x40*2); } } diff --git a/pico/draw2.c b/pico/draw2.c index 5730d7b..1b8cdf5 100644 --- a/pico/draw2.c +++ b/pico/draw2.c @@ -21,7 +21,6 @@ #endif 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 HighCache2B[41*(TILE_ROWS+1)+1+1]; @@ -32,11 +31,12 @@ void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to // stuff available in asm: #ifdef _ASM_DRAW_C -void BackFillFull(int reg7); -void DrawLayerFull(int plane, int *hcache, int planestart, int planeend); -void DrawTilesFromCacheF(int *hc); -void DrawWindowFull(int start, int end, int prio); -void DrawSpriteFull(unsigned int *sprite); +void BackFillFull(void *dst, int reg7); +void DrawLayerFull(int plane, int *hcache, int planestart, int planeend, + struct PicoEState *est); +void DrawTilesFromCacheF(int *hc, struct PicoEState *est); +void DrawWindowFull(int start, int end, int prio, struct PicoEState *est); +void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est); #else @@ -134,11 +134,11 @@ static int TileXflipYflip(unsigned char *pd,int addr,unsigned char pal) // 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; 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 // 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; 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 else nametab=(pvid->reg[4]&0x07)<<12; // B - scrpos = PicoDraw2FB; + scrpos = est->Draw2FB; scrpos+=8*LINE_WIDTH*(planestart-START_ROW); // 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; unsigned int prevy=0xFFFFFFFF; // unsigned short *pal; unsigned char pal; 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 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 -static void DrawSpriteFull(unsigned int *sprite) +static void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est) { int width=0,height=0; // unsigned short *pal=NULL; @@ -375,7 +376,7 @@ static void DrawSpriteFull(unsigned int *sprite) // goto first vertically visible tile while(sy <= START_ROW*8) { sy+=8; tile+=tdeltay; height--; } - scrpos = PicoDraw2FB; + scrpos = est->Draw2FB; scrpos+=(sy-START_ROW*8)*LINE_WIDTH; for (; height > 0; height--, sy+=8, tile+=tdeltay) @@ -466,29 +467,29 @@ static void DrawAllSpritesFull(int prio, int maxwidth) } // 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 -static void BackFillFull(int reg7) +static void BackFillFull(void *dst, int reg7) { unsigned int back; // Start with a background color: -// back=PicoCramHigh[reg7&0x3f]; back=reg7&0x3f; back|=back<<8; 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 static void DrawDisplayFull(void) { + struct PicoEState *est = &Pico.est; struct PicoVideo *pvid=&Pico.video; 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) @@ -551,55 +552,55 @@ static void DrawDisplayFull(void) HighCache2A[1] = HighCache2B[1] = 0; 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) { case 4: // fullscreen window - DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0); + DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0, est); break; case 3: // we have plane A and both v and h windows - DrawLayerFull(0, HighCache2A, planestart, planeend); - DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0); // h - DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0); // v + DrawLayerFull(0, HighCache2A, planestart, planeend, est); + DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0, est); // h + DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0, est); // v break; case 2: case 1: // both window and plane A visible, window is vertical XOR horizontal - DrawLayerFull(0, HighCache2A, planestart, planeend); - DrawWindowFull(winstart, winend, 0); + DrawLayerFull(0, HighCache2A, planestart, planeend, est); + DrawWindowFull(winstart, winend, 0, est); break; default: // fullscreen plane A - DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW); + DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW, est); break; } if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) DrawAllSpritesFull(0, maxw); - if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B); - if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A); + if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B, est); + if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A, est); if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin) { case 4: // fullscreen window - DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 1); + DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 1, est); break; case 3: // we have plane A and both v and h windows - DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 1); // h - DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 1); // v + DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 1, est); // h + DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 1, est); // v break; case 2: case 1: // both window and plane A visible, window is vertical XOR horizontal - DrawWindowFull(winstart, winend, 1); + DrawWindowFull(winstart, winend, 1, est); break; } if (PicoDrawMask & PDRAW_SPRITES_HI_ON) @@ -615,10 +616,14 @@ PICO_INTERNAL void PicoFrameFull() if (PicoPrepareCram) PicoPrepareCram(); // Draw screen: - BackFillFull(Pico.video.reg[7]); + BackFillFull(Pico.est.Draw2FB, Pico.video.reg[7]); if (Pico.video.reg[1] & 0x40) DrawDisplayFull(); pprof_end(draw); } +void PicoDraw2Init(void) +{ + Pico.est.Draw2FB = PicoDraw2FB_; +} diff --git a/pico/draw2_arm.S b/pico/draw2_arm.S index c37d059..6e7e1ac 100644 --- a/pico/draw2_arm.S +++ b/pico/draw2_arm.S @@ -8,8 +8,7 @@ * this is highly specialized, be careful if changing related C code! */ -.extern Pico -.extern PicoDraw2FB +#include "pico_int_o32.h" @ define these constants in your include file: @ .equiv START_ROW, 1 @@ -25,16 +24,16 @@ .text .align 2 -.global BackFillFull @ int reg7 +@ void BackFillFull(void *dst, int reg7) + +.global BackFillFull BackFillFull: stmfd sp!, {r4-r9,lr} - ldr lr, =PicoDraw2FB @ lr=PicoDraw2FB - mov r0, r0, lsl #26 - ldr lr, [lr] + add lr, r0, #328*8 + mov r0, r1, lsl #26 mov r0, r0, lsr #26 - add lr, lr, #328*8 orr r0, r0, r0, lsl #8 orr r0, r0, r0, lsl #16 @@ -67,8 +66,8 @@ BackFillFull: bne .bff_loop - ldmfd sp!, {r4-r9,r12} - bx r12 + ldmfd sp!, {r4-r9,lr} + bx lr .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] -@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 DrawLayerFull: + ldr r12,[sp] @ est stmfd sp!, {r4-r11,lr} mov r6, r1 @ hcache - ldr r11, =(Pico+0x22228) @ Pico.video - ldr r10, =(Pico+0x10000) @ r10=Pico.vram + ldr r11, [r12, #OFS_Pico_video] + ldr r10, [r12, #OFS_Pico_vram] ldrb r5, [r11, #13] @ pvid->reg[13] ldrb r7, [r11, #11] @@ -402,9 +403,9 @@ DrawLayerFull: and r4, r4, #7 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) - ldr r11, [r11] + ldr r11, [r11, #OFS_Draw2FB] mov r4, r4, asr #24 mov r7, #328*8 mla r11, r4, r7, r11 @ scrpos+=8*328*(planestart-START_ROW); @@ -571,8 +572,9 @@ DrawLayerFull: .pool +@ void DrawTilesFromCacheF(int *hc, struct PicoEState *est) -.global DrawTilesFromCacheF @ int *hc +.global DrawTilesFromCacheF DrawTilesFromCacheF: stmfd sp!, {r4-r10,lr} @@ -580,14 +582,13 @@ DrawTilesFromCacheF: mov r9, #0xff000000 @ r9=prevcode=-1 mvn r6, #0 @ r6=prevy=-1 - ldr r4, =PicoDraw2FB @ r4=PicoDraw2FB - ldr r1, [r0], #4 @ read y offset - ldr r4, [r4] + ldr r4, [r1, #OFS_Draw2FB] + ldr r2, [r0], #4 @ read y offset mov r7, #328 - mla r1, r7, r1, r4 - sub r12, r1, #(328*8*START_ROW) @ r12=scrpos + mla r2, r7, r2, r4 + 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 r0, #0xf @@ -666,12 +667,14 @@ DrawTilesFromCacheF: @ @@@@@@@@@@@@@@@ @ (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: stmfd sp!, {r4-r11,lr} - ldr r11, =(Pico+0x22228) @ Pico.video + ldr r11, [r3, #OFS_Pico_video] ldrb r12, [r11, #3] @ pvid->reg[3] mov r12, r12, lsl #10 @@ -686,11 +689,11 @@ DrawWindowFull: and r4, r0, #0xff mla r12, r5, r4, r12 @ nametab += nametab_step*start; + ldr r10, [r3, #OFS_Pico_vram] mov r4, r0, lsr #16 @ r4=start_cell_h add r7, r12, r4, lsl #1 @ fetch the first code now - ldr r10, =(Pico+0x10000) @ lr=Pico.vram ldrh r7, [r10, r7] cmp r2, r7, lsr #15 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 - ldr r11, =PicoDraw2FB @ r11=scrpos + ldr r11, [r3, #OFS_Draw2FB] and r4, r0, #0xff - ldr r11, [r11] - sub r4, r4, #START_ROW add r11, r11, #328*8 + sub r4, r4, #START_ROW add r11, r11, #8 mov r7, #328*8 @@ -873,8 +875,9 @@ DrawWindowFull: b 52b .endm +@ void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est) -.global DrawSpriteFull @ unsigned int *sprite +.global DrawSpriteFull DrawSpriteFull: stmfd sp!, {r4-r11,lr} @@ -902,9 +905,8 @@ DrawSpriteFull: and r3, lr, #0x6000 mov r3, r3, lsr #9 @ r3=pal=((code>>9)&0x30); - ldr r11, =PicoDraw2FB @ r11=scrpos - ldr r10, =(Pico+0x10000) @ r10=Pico.vram - ldr r11, [r11] + ldr r11, [r1, #OFS_Draw2FB] + ldr r10, [r1, #OFS_Pico_vram] sub r1, r12, #(START_ROW*8) mov r0, #328 mla r11, r1, r0, r11 @ scrpos+=(sy-START_ROW*8)*328; diff --git a/pico/draw_arm.S b/pico/draw_arm.S index 23c522b..71db183 100644 --- a/pico/draw_arm.S +++ b/pico/draw_arm.S @@ -1497,7 +1497,7 @@ PicoDoHighPal555: PicoDoHighPal555_nopush: orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h - ldr r0, =HighPal + add r0, r10, #OFS_HighPal mov r1, #0 strb r1, [r8, #-0x1a] @ 0x2220e ~ dirtyPal @@ -1513,7 +1513,7 @@ PicoDoHighPal555_nopush: tst r9, #(1<<31) beq PicoDoHighPal555_end - ldr r3, =HighPal + add r3, r10, #OFS_HighPal @ shadowed pixels: mov r12, #0x008e @@ -1575,7 +1575,7 @@ FinalizeLine555: bne PicoDoHighPal555_nopush FinalizeLineRGB555_pal_done: - ldr r3, =HighPal + add r3, r10, #OFS_HighPal ldr r12, [r10, #OFS_rendstatus] eors r0, r0, #1 @ sh is 0 diff --git a/pico/mode4.c b/pico/mode4.c index 1f9adff..4abace6 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -249,7 +249,7 @@ void PicoLineMode4(int line) void PicoDoHighPal555M4(void) { unsigned int *spal=(void *)Pico.cram; - unsigned int *dpal=(void *)HighPal; + unsigned int *dpal=(void *)Pico.est.HighPal; unsigned int t; int i; @@ -267,7 +267,7 @@ void PicoDoHighPal555M4(void) t |= (t >> 4) & 0x08610861; *dpal = t; } - HighPal[0xe0] = 0; + Pico.est.HighPal[0xe0] = 0; } static void FinalizeLineRGB555M4(int line) diff --git a/pico/pico.c b/pico/pico.c index 4b05d6e..5951b59 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -49,6 +49,7 @@ void PicoInit(void) Pico32xInit(); PicoDrawInit(); + PicoDraw2Init(); } // to be called once on emu exit diff --git a/pico/pico.h b/pico/pico.h index 6eb1dc0..e2dde1b 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -194,7 +194,6 @@ extern int PicoDrawMask; #define PDRAW_32_COLS (1<<8) // 32 column mode extern int rendstatus_old; extern int rendlines; -extern unsigned short HighPal[0x100]; // draw.c void PicoDrawUpdateHighPal(void); @@ -202,7 +201,6 @@ void PicoDrawSetInternalBuf(void *dest, int line_increment); // draw2.c // 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 void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use diff --git a/pico/pico_int.h b/pico/pico_int.h index 4dbfa65..5d7bfbc 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -333,12 +333,14 @@ struct PicoEState { int DrawScanline; int rendstatus; - void *DrawLineDest; // draw estination + void *DrawLineDest; // draw destination unsigned char *HighCol; int *HighPreSpr; void *Pico_video; void *Pico_vram; int *PicoOpt; + unsigned char *Draw2FB; + unsigned short HighPal[0x100]; }; // some assembly stuff depend on these, do not touch! @@ -601,6 +603,7 @@ extern void *DrawLineDestBase; extern int DrawLineDestIncrement; // draw2.c +void PicoDraw2Init(void); PICO_INTERNAL void PicoFrameFull(); // mode4.c diff --git a/pico/pico_int_o32.h b/pico/pico_int_o32.h index 4094697..dc7aaa2 100644 --- a/pico/pico_int_o32.h +++ b/pico/pico_int_o32.h @@ -7,3 +7,5 @@ #define OFS_Pico_video 0x14 #define OFS_Pico_vram 0x18 #define OFS_PicoOpt 0x1c +#define OFS_Draw2FB 0x20 +#define OFS_HighPal 0x24 diff --git a/platform/gizmondo/emu.c b/platform/gizmondo/emu.c index 3a6c861..30c6651 100644 --- a/platform/gizmondo/emu.c +++ b/platform/gizmondo/emu.c @@ -155,11 +155,11 @@ static void blit(const char *fps, const char *notice) } // a hack for VR 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 (currentConfig.EmuOpt&0x4000) 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)) { @@ -187,7 +187,7 @@ static void blit(const char *fps, const char *notice) if (!(Pico.video.reg[12]&1)) lines_flags|=0x10000; if (currentConfig.EmuOpt&0x4000) 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)) { diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 683e267..c0bc71f 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -7,8 +7,8 @@ * - 8bpp tile renderer * In 32x mode: * - 32x layer is overlayed on top of 16bpp one - * - line internal one done on PicoDraw2FB, then mixed with 32x - * - tile internal one done on PicoDraw2FB, then mixed with 32x + * - line internal one done on .Draw2FB, then mixed with 32x + * - tile internal one done on .Draw2FB, then mixed with 32x */ #include @@ -311,8 +311,8 @@ static int make_local_pal_md(int fast_mode) pallen = 0x100; } else if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes - bgr444_to_rgb32(localPal+0x40, HighPal); - bgr444_to_rgb32(localPal+0x80, HighPal+0x40); + bgr444_to_rgb32(localPal+0x40, Pico.est.HighPal); + bgr444_to_rgb32(localPal+0x80, Pico.est.HighPal+0x40); } else 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 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 - 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)); } else if (get_renderer() == RT_8BIT_ACC) diff --git a/platform/linux/emu.c b/platform/linux/emu.c index 91115ad..5a97959 100644 --- a/platform/linux/emu.c +++ b/platform/linux/emu.c @@ -70,8 +70,8 @@ void pemu_finalize_frame(const char *fps, const char *notice) { if (currentConfig.renderer != RT_16BIT && !(PicoAHW & PAHW_32X)) { unsigned short *pd = (unsigned short *)g_screen_ptr + 8 * g_screen_width; - unsigned char *ps = PicoDraw2FB + 328*8 + 8; - unsigned short *pal = HighPal; + unsigned char *ps = Pico.est.Draw2FB + 328*8 + 8; + unsigned short *pal = Pico.est.HighPal; int i, x; if (Pico.m.dirtyPal) PicoDrawUpdateHighPal(); @@ -101,7 +101,7 @@ static void apply_renderer(void) case RT_8BIT_ACC: PicoOpt &= ~POPT_ALT_RENDERER; PicoDrawSetOutFormat(PDF_8BIT, 0); - PicoDrawSetOutBuf(PicoDraw2FB + 8, 328); + PicoDrawSetOutBuf(Pico.est.Draw2FB + 8, 328); break; case RT_8BIT_FAST: PicoOpt |= POPT_ALT_RENDERER; diff --git a/platform/psp/emu.c b/platform/psp/emu.c index cb16d26..dd4381b 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -36,7 +36,7 @@ int sceAudio_E0727056(int volume, void *buffer); // blocking output 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; #define PICO_PEN_ADJUST_X 4 @@ -400,9 +400,9 @@ void blit1(void) int i; unsigned char *pd; // 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); - 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); } diff --git a/tools/mkoffsets.c b/tools/mkoffsets.c index e9eb3c5..a5c475f 100644 --- a/tools/mkoffsets.c +++ b/tools/mkoffsets.c @@ -29,6 +29,8 @@ int main(int argc, char *argv[]) DUMP(f, Pico_video); DUMP(f, Pico_vram); DUMP(f, PicoOpt); + DUMP(f, Draw2FB); + DUMP(f, HighPal); fclose(f); return 0; -- 2.39.2