eliminate texrels, part 3
authornotaz <notasas@gmail.com>
Sun, 6 Aug 2017 19:25:26 +0000 (22:25 +0300)
committertwinaphex <libretro@gmail.com>
Fri, 18 Aug 2017 03:12:04 +0000 (05:12 +0200)
16 files changed:
pico/32x/32x_draw.c
pico/debug.c
pico/draw.c
pico/draw2.c
pico/draw2_arm.S
pico/draw_arm.S
pico/mode4.c
pico/pico.c
pico/pico.h
pico/pico_int.h
pico/pico_int_o32.h
platform/gizmondo/emu.c
platform/gp2x/emu.c
platform/linux/emu.c
platform/psp/emu.c
tools/mkoffsets.c

index 171a696..e33cb37 100644 (file)
@@ -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;
 }
 
index 7cc3c32..efcd3fd 100644 (file)
@@ -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;
   }
 
index e4bff25..cf638e9 100644 (file)
@@ -1161,8 +1161,6 @@ void BackFill(int reg7, int sh, struct PicoEState *est)
 \r
 // --------------------------------------------\r
 \r
-unsigned short HighPal[0x100];\r
-\r
 #ifndef _ASM_DRAW_C\r
 void PicoDoHighPal555(int sh, int line, struct PicoEState *est)\r
 {\r
@@ -1172,7 +1170,7 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
   Pico.m.dirtyPal = 0;\r
 \r
   spal = (void *)Pico.cram;\r
-  dpal = (void *)HighPal;\r
+  dpal = (void *)est->HighPal;\r
 \r
   for (i = 0; i < 0x40 / 2; i++) {\r
     t = spal[i];\r
@@ -1206,7 +1204,7 @@ void FinalizeLine555(int sh, int line, struct PicoEState *est)
 {\r
   unsigned short *pd=est->DrawLineDest;\r
   unsigned char  *ps=est->HighCol+8;\r
-  unsigned short *pal=HighPal;\r
+  unsigned short *pal=est->HighPal;\r
   int len;\r
 \r
   if (Pico.m.dirtyPal)\r
@@ -1253,9 +1251,9 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est)
     rs |= PDRAW_SONIC_MODE;\r
     est->rendstatus = rs;\r
     if (dirty_count == 3) {\r
-      blockcpy(HighPal, Pico.cram, 0x40*2);\r
+      blockcpy(est->HighPal, Pico.cram, 0x40*2);\r
     } else if (dirty_count == 11) {\r
-      blockcpy(HighPal+0x40, Pico.cram, 0x40*2);\r
+      blockcpy(est->HighPal+0x40, Pico.cram, 0x40*2);\r
     }\r
   }\r
 \r
@@ -1496,15 +1494,16 @@ void PicoDrawSync(int to, int blank_last_line)
 // also works for fast renderer\r
 void PicoDrawUpdateHighPal(void)\r
 {\r
+  struct PicoEState *est = &Pico.est;\r
   int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight?\r
   if (PicoOpt & POPT_ALT_RENDERER)\r
     sh = 0; // no s/h support\r
 \r
   PicoDoHighPal555(sh, 0, &Pico.est);\r
-  if (Pico.est.rendstatus & PDRAW_SONIC_MODE) {\r
+  if (est->rendstatus & PDRAW_SONIC_MODE) {\r
     // FIXME?\r
-    memcpy(HighPal + 0x40, HighPal, 0x40*2);\r
-    memcpy(HighPal + 0x80, HighPal, 0x40*2);\r
+    memcpy(est->HighPal + 0x40, est->HighPal, 0x40*2);\r
+    memcpy(est->HighPal + 0x80, est->HighPal, 0x40*2);\r
   }\r
 }\r
 \r
index 5730d7b..1b8cdf5 100644 (file)
@@ -21,7 +21,6 @@
 #endif\r
 \r
 static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];\r
-unsigned char *PicoDraw2FB = PicoDraw2FB_;\r
 \r
 static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers\r
 static int HighCache2B[41*(TILE_ROWS+1)+1+1];\r
@@ -32,11 +31,12 @@ void (*PicoPrepareCram)()=0;            // prepares PicoCramHigh for renderer to
 \r
 // stuff available in asm:\r
 #ifdef _ASM_DRAW_C\r
-void BackFillFull(int reg7);\r
-void DrawLayerFull(int plane, int *hcache, int planestart, int planeend);\r
-void DrawTilesFromCacheF(int *hc);\r
-void DrawWindowFull(int start, int end, int prio);\r
-void DrawSpriteFull(unsigned int *sprite);\r
+void BackFillFull(void *dst, int reg7);\r
+void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,\r
+                   struct PicoEState *est);\r
+void DrawTilesFromCacheF(int *hc, struct PicoEState *est);\r
+void DrawWindowFull(int start, int end, int prio, struct PicoEState *est);\r
+void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est);\r
 #else\r
 \r
 \r
@@ -134,11 +134,11 @@ static int TileXflipYflip(unsigned char *pd,int addr,unsigned char pal)
 \r
 \r
 // start: (tile_start<<16)|row_start, end: [same]\r
-static void DrawWindowFull(int start, int end, int prio)\r
+static void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)\r
 {\r
        struct PicoVideo *pvid=&Pico.video;\r
        int nametab, nametab_step, trow, tilex, blank=-1, code;\r
-       unsigned char *scrpos = PicoDraw2FB;\r
+       unsigned char *scrpos = est->Draw2FB;\r
        int tile_start, tile_end; // in cells\r
 \r
        // parse ranges\r
@@ -198,7 +198,8 @@ static void DrawWindowFull(int start, int end, int prio)
 }\r
 \r
 \r
-static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend)\r
+static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,\r
+                         struct PicoEState *est)\r
 {\r
        struct PicoVideo *pvid=&Pico.video;\r
        static char shift[4]={5,6,6,7}; // 32,64 or 128 sized tilemaps\r
@@ -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\r
        else          nametab=(pvid->reg[4]&0x07)<<12; // B\r
 \r
-       scrpos = PicoDraw2FB;\r
+       scrpos = est->Draw2FB;\r
        scrpos+=8*LINE_WIDTH*(planestart-START_ROW);\r
 \r
        // Get vertical scroll value:\r
@@ -305,14 +306,14 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend)
 }\r
 \r
 \r
-static void DrawTilesFromCacheF(int *hc)\r
+static void DrawTilesFromCacheF(int *hc, struct PicoEState *est)\r
 {\r
        int code, addr, zero = 0;\r
        unsigned int prevy=0xFFFFFFFF;\r
 //     unsigned short *pal;\r
        unsigned char pal;\r
        short blank=-1; // The tile we know is blank\r
-       unsigned char *scrpos = PicoDraw2FB, *pd = 0;\r
+       unsigned char *scrpos = est->Draw2FB, *pd = 0;\r
 \r
        // *hcache++ = code|(dx<<16)|(trow<<27); // cache it\r
        scrpos+=(*hc++)*LINE_WIDTH - START_ROW*LINE_WIDTH*8;\r
@@ -344,7 +345,7 @@ static void DrawTilesFromCacheF(int *hc)
 \r
 \r
 // sx and sy are coords of virtual screen with 8pix borders on top and on left\r
-static void DrawSpriteFull(unsigned int *sprite)\r
+static void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est)\r
 {\r
        int width=0,height=0;\r
 //     unsigned short *pal=NULL;\r
@@ -375,7 +376,7 @@ static void DrawSpriteFull(unsigned int *sprite)
        // goto first vertically visible tile\r
        while(sy <= START_ROW*8) { sy+=8; tile+=tdeltay; height--; }\r
 \r
-       scrpos = PicoDraw2FB;\r
+       scrpos = est->Draw2FB;\r
        scrpos+=(sy-START_ROW*8)*LINE_WIDTH;\r
 \r
        for (; height > 0; height--, sy+=8, tile+=tdeltay)\r
@@ -466,29 +467,29 @@ static void DrawAllSpritesFull(int prio, int maxwidth)
        }\r
 \r
        // Go through sprites backwards:\r
-       for (i-- ;i>=0; i--)\r
+       for (i--; i >= 0; i--)\r
        {\r
-               DrawSpriteFull(sprites[i]);\r
+               DrawSpriteFull(sprites[i], &Pico.est);\r
        }\r
 }\r
 \r
 #ifndef _ASM_DRAW_C\r
-static void BackFillFull(int reg7)\r
+static void BackFillFull(void *dst, int reg7)\r
 {\r
        unsigned int back;\r
 \r
        // Start with a background color:\r
-//     back=PicoCramHigh[reg7&0x3f];\r
        back=reg7&0x3f;\r
        back|=back<<8;\r
        back|=back<<16;\r
 \r
-       memset32((int *)PicoDraw2FB, back, LINE_WIDTH*(8+(END_ROW-START_ROW)*8)/4);\r
+       memset32(dst, back, LINE_WIDTH*(8+(END_ROW-START_ROW)*8)/4);\r
 }\r
 #endif\r
 \r
 static void DrawDisplayFull(void)\r
 {\r
+       struct PicoEState *est = &Pico.est;\r
        struct PicoVideo *pvid=&Pico.video;\r
        int win, edge=0, hvwin=0; // LSb->MSb: hwin&plane, vwin&plane, full\r
        int planestart=START_ROW, planeend=END_ROW; // plane A start/end when window shares display with plane A (in tile rows or columns)\r
@@ -551,55 +552,55 @@ static void DrawDisplayFull(void)
 \r
        HighCache2A[1] = HighCache2B[1] = 0;\r
        if (PicoDrawMask & PDRAW_LAYERB_ON)\r
-               DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW);\r
+               DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW, est);\r
        if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin)\r
        {\r
                case 4:\r
                // fullscreen window\r
-               DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0);\r
+               DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0, est);\r
                break;\r
 \r
                case 3:\r
                // we have plane A and both v and h windows\r
-               DrawLayerFull(0, HighCache2A, planestart, planeend);\r
-               DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0); // h\r
-               DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0);    // v\r
+               DrawLayerFull(0, HighCache2A, planestart, planeend, est);\r
+               DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0, est); // h\r
+               DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0, est);    // v\r
                break;\r
 \r
                case 2:\r
                case 1:\r
                // both window and plane A visible, window is vertical XOR horizontal\r
-               DrawLayerFull(0, HighCache2A, planestart, planeend);\r
-               DrawWindowFull(winstart, winend, 0);\r
+               DrawLayerFull(0, HighCache2A, planestart, planeend, est);\r
+               DrawWindowFull(winstart, winend, 0, est);\r
                break;\r
 \r
                default:\r
                // fullscreen plane A\r
-               DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW);\r
+               DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW, est);\r
                break;\r
        }\r
        if (PicoDrawMask & PDRAW_SPRITES_LOW_ON)\r
                DrawAllSpritesFull(0, maxw);\r
 \r
-       if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B);\r
-       if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A);\r
+       if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B, est);\r
+       if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A, est);\r
        if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin)\r
        {\r
                case 4:\r
                // fullscreen window\r
-               DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 1);\r
+               DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 1, est);\r
                break;\r
 \r
                case 3:\r
                // we have plane A and both v and h windows\r
-               DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 1); // h\r
-               DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 1);    // v\r
+               DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 1, est); // h\r
+               DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 1, est);    // v\r
                break;\r
 \r
                case 2:\r
                case 1:\r
                // both window and plane A visible, window is vertical XOR horizontal\r
-               DrawWindowFull(winstart, winend, 1);\r
+               DrawWindowFull(winstart, winend, 1, est);\r
                break;\r
        }\r
        if (PicoDrawMask & PDRAW_SPRITES_HI_ON)\r
@@ -615,10 +616,14 @@ PICO_INTERNAL void PicoFrameFull()
        if (PicoPrepareCram) PicoPrepareCram();\r
 \r
        // Draw screen:\r
-       BackFillFull(Pico.video.reg[7]);\r
+       BackFillFull(Pico.est.Draw2FB, Pico.video.reg[7]);\r
        if (Pico.video.reg[1] & 0x40)\r
                DrawDisplayFull();\r
 \r
        pprof_end(draw);\r
 }\r
 \r
+void PicoDraw2Init(void)\r
+{\r
+       Pico.est.Draw2FB = PicoDraw2FB_;\r
+}\r
index c37d059..6e7e1ac 100644 (file)
@@ -8,8 +8,7 @@
  * this is highly specialized, be careful if changing related C code!\r
  */\r
 \r
-.extern Pico\r
-.extern PicoDraw2FB\r
+#include "pico_int_o32.h"\r
 \r
 @ define these constants in your include file:\r
 @ .equiv START_ROW,            1\r
 .text\r
 .align 2\r
 \r
-.global BackFillFull @ int reg7\r
+@ void BackFillFull(void *dst, int reg7)\r
+\r
+.global BackFillFull\r
 \r
 BackFillFull:\r
     stmfd   sp!, {r4-r9,lr}\r
 \r
-    ldr     lr, =PicoDraw2FB      @ lr=PicoDraw2FB\r
-    mov     r0, r0, lsl #26\r
-    ldr     lr, [lr]\r
+    add     lr, r0, #328*8\r
+    mov     r0, r1, lsl #26\r
     mov     r0, r0, lsr #26\r
-    add     lr, lr, #328*8\r
 \r
     orr     r0, r0, r0, lsl #8\r
     orr     r0, r0, r0, lsl #16\r
@@ -67,8 +66,8 @@ BackFillFull:
 \r
     bne     .bff_loop\r
 \r
-    ldmfd   sp!, {r4-r9,r12}\r
-    bx      r12\r
+    ldmfd   sp!, {r4-r9,lr}\r
+    bx      lr\r
 \r
 .pool\r
 \r
@@ -343,17 +342,19 @@ BackFillFull:
 \r
 @ DrawLayerTiles(*hcache, *scrpos, (cells<<24)|(nametab<<9)|(vscroll&0x3ff)<<11|(shift[width]<<8)|planeend, (ymask<<24)|(planestart<<16)|[htab||hscroll]\r
 \r
-@static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend)\r
+@ void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,\r
+@                    struct PicoEState *est)\r
 \r
 .global DrawLayerFull\r
 \r
 DrawLayerFull:\r
+    ldr     r12,[sp]              @ est\r
     stmfd   sp!, {r4-r11,lr}\r
 \r
     mov     r6, r1        @ hcache\r
 \r
-    ldr     r11, =(Pico+0x22228)  @ Pico.video\r
-    ldr     r10, =(Pico+0x10000)  @ r10=Pico.vram\r
+    ldr     r11, [r12, #OFS_Pico_video]\r
+    ldr     r10, [r12, #OFS_Pico_vram]\r
     ldrb    r5, [r11, #13]        @ pvid->reg[13]\r
     ldrb    r7, [r11, #11]\r
 \r
@@ -402,9 +403,9 @@ DrawLayerFull:
     and     r4, r4, #7\r
     orr     lr, lr, r4, lsl #13   @ lr|=nametab_bits{3}<<13\r
 \r
-    ldr     r11, =PicoDraw2FB     @ r11=PicoDraw2FB\r
+    ldr     r11,[sp, #9*4]        @ est\r
     sub     r4, r9, #(START_ROW<<24)\r
-    ldr     r11, [r11]\r
+    ldr     r11, [r11, #OFS_Draw2FB]\r
     mov     r4, r4, asr #24\r
     mov     r7, #328*8\r
     mla     r11, r4, r7, r11      @ scrpos+=8*328*(planestart-START_ROW);\r
@@ -571,8 +572,9 @@ DrawLayerFull:
 .pool\r
 \r
 \r
+@ void DrawTilesFromCacheF(int *hc, struct PicoEState *est)\r
 \r
-.global DrawTilesFromCacheF @ int *hc\r
+.global DrawTilesFromCacheF\r
 \r
 DrawTilesFromCacheF:\r
     stmfd   sp!, {r4-r10,lr}\r
@@ -580,14 +582,13 @@ DrawTilesFromCacheF:
     mov     r9, #0xff000000 @ r9=prevcode=-1\r
     mvn     r6, #0          @ r6=prevy=-1\r
 \r
-    ldr     r4, =PicoDraw2FB  @ r4=PicoDraw2FB\r
-    ldr     r1, [r0], #4    @ read y offset\r
-    ldr     r4, [r4]\r
+    ldr     r4, [r1, #OFS_Draw2FB]\r
+    ldr     r2, [r0], #4    @ read y offset\r
     mov     r7, #328\r
-    mla     r1, r7, r1, r4\r
-    sub     r12, r1, #(328*8*START_ROW) @ r12=scrpos\r
+    mla     r2, r7, r2, r4\r
+    sub     r12, r2, #(328*8*START_ROW) @ r12=scrpos\r
 \r
-    ldr     r10, =(Pico+0x10000) @ r10=Pico.vram\r
+    ldr     r10, [r1, #OFS_Pico_vram]\r
     mov     r8, r0               @ hc\r
     mov     r0, #0xf\r
 \r
@@ -666,12 +667,14 @@ DrawTilesFromCacheF:
 @ @@@@@@@@@@@@@@@\r
 \r
 @ (tile_start<<16)|row_start\r
-.global DrawWindowFull @ int tstart, int tend, int prio\r
+@ void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)\r
+\r
+.global DrawWindowFull\r
 \r
 DrawWindowFull:\r
     stmfd   sp!, {r4-r11,lr}\r
 \r
-    ldr     r11, =(Pico+0x22228)  @ Pico.video\r
+    ldr     r11, [r3, #OFS_Pico_video]\r
     ldrb    r12, [r11, #3]        @ pvid->reg[3]\r
     mov     r12, r12, lsl #10\r
 \r
@@ -686,11 +689,11 @@ DrawWindowFull:
     and     r4, r0, #0xff\r
     mla     r12, r5, r4, r12      @ nametab += nametab_step*start;\r
 \r
+    ldr     r10, [r3, #OFS_Pico_vram]\r
     mov     r4, r0, lsr #16       @ r4=start_cell_h\r
     add     r7, r12, r4, lsl #1\r
 \r
     @ fetch the first code now\r
-    ldr     r10, =(Pico+0x10000)  @ lr=Pico.vram\r
     ldrh    r7, [r10, r7]\r
     cmp     r2, r7, lsr #15\r
     ldmnefd sp!, {r4-r11,pc}      @ hack: simply assume that whole window uses same priority\r
@@ -704,11 +707,10 @@ DrawWindowFull:
 \r
     mov     r9, #0xff000000       @ r9=prevcode=-1\r
 \r
-    ldr     r11, =PicoDraw2FB     @ r11=scrpos\r
+    ldr     r11, [r3, #OFS_Draw2FB]\r
     and     r4, r0, #0xff\r
-    ldr     r11, [r11]\r
-    sub     r4, r4, #START_ROW\r
     add     r11, r11, #328*8\r
+    sub     r4, r4, #START_ROW\r
     add     r11, r11, #8\r
 \r
     mov     r7, #328*8\r
@@ -873,8 +875,9 @@ DrawWindowFull:
     b       52b\r
 .endm\r
 \r
+@ void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est)\r
 \r
-.global DrawSpriteFull @ unsigned int *sprite\r
+.global DrawSpriteFull\r
 \r
 DrawSpriteFull:\r
     stmfd   sp!, {r4-r11,lr}\r
@@ -902,9 +905,8 @@ DrawSpriteFull:
     and     r3, lr, #0x6000\r
     mov     r3, r3, lsr #9  @ r3=pal=((code>>9)&0x30);\r
 \r
-    ldr     r11, =PicoDraw2FB     @ r11=scrpos\r
-    ldr     r10, =(Pico+0x10000)  @ r10=Pico.vram\r
-    ldr     r11, [r11]\r
+    ldr     r11, [r1, #OFS_Draw2FB]\r
+    ldr     r10, [r1, #OFS_Pico_vram]\r
     sub     r1, r12, #(START_ROW*8)\r
     mov     r0, #328\r
     mla     r11, r1, r0, r11      @ scrpos+=(sy-START_ROW*8)*328;\r
index 23c522b..71db183 100644 (file)
@@ -1497,7 +1497,7 @@ PicoDoHighPal555:
 PicoDoHighPal555_nopush:\r
     orr     r9, r1, r0, lsl #31  @ 0:called from FinalizeLine555, 31: s/h\r
 \r
-    ldr     r0, =HighPal\r
+    add     r0, r10, #OFS_HighPal\r
 \r
     mov     r1, #0\r
     strb    r1, [r8, #-0x1a]     @ 0x2220e ~ dirtyPal\r
@@ -1513,7 +1513,7 @@ PicoDoHighPal555_nopush:
     tst     r9, #(1<<31)\r
     beq     PicoDoHighPal555_end\r
 \r
-    ldr     r3, =HighPal\r
+    add     r3, r10, #OFS_HighPal\r
 \r
     @ shadowed pixels:\r
     mov     r12,    #0x008e\r
@@ -1575,7 +1575,7 @@ FinalizeLine555:
     bne     PicoDoHighPal555_nopush\r
 \r
 FinalizeLineRGB555_pal_done:\r
-    ldr     r3, =HighPal\r
+    add     r3, r10, #OFS_HighPal\r
 \r
     ldr     r12, [r10, #OFS_rendstatus]\r
     eors    r0, r0, #1           @ sh is 0\r
index 1f9adff..4abace6 100644 (file)
@@ -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)
index b6a083d..62994c1 100644 (file)
@@ -50,6 +50,7 @@ void PicoInit(void)
   Pico32xInit();\r
 \r
   PicoDrawInit();\r
+  PicoDraw2Init();\r
 }\r
 \r
 // to be called once on emu exit\r
index 98e4c78..a1aa96e 100644 (file)
@@ -195,7 +195,6 @@ extern int PicoDrawMask;
 #define PDRAW_32_COLS       (1<<8) // 32 column mode\r
 extern int rendstatus_old;\r
 extern int rendlines;\r
-extern unsigned short HighPal[0x100];\r
 \r
 // draw.c\r
 void PicoDrawUpdateHighPal(void);\r
@@ -203,7 +202,6 @@ void PicoDrawSetInternalBuf(void *dest, int line_increment);
 \r
 // draw2.c\r
 // stuff below is optional\r
-extern unsigned char  *PicoDraw2FB;  // buffer for fast renderer in format (8+320)x(8+224+8) (eights for borders)\r
 extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)\r
 extern void (*PicoPrepareCram)();    // prepares PicoCramHigh for renderer to use\r
 \r
index b9a4418..b562b2f 100644 (file)
@@ -338,12 +338,14 @@ struct PicoEState
 {\r
   int DrawScanline;\r
   int rendstatus;\r
-  void *DrawLineDest;          // draw estination\r
+  void *DrawLineDest;          // draw destination\r
   unsigned char *HighCol;\r
   int *HighPreSpr;\r
   void *Pico_video;\r
   void *Pico_vram;\r
   int  *PicoOpt;\r
+  unsigned char *Draw2FB;\r
+  unsigned short HighPal[0x100];\r
 };\r
 \r
 // some assembly stuff depend on these, do not touch!\r
@@ -606,6 +608,7 @@ extern void *DrawLineDestBase;
 extern int DrawLineDestIncrement;\r
 \r
 // draw2.c\r
+void PicoDraw2Init(void);\r
 PICO_INTERNAL void PicoFrameFull();\r
 \r
 // mode4.c\r
index 4094697..dc7aaa2 100644 (file)
@@ -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
index 3a6c861..30c6651 100644 (file)
@@ -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)) {
index 8db33a9..8e682f1 100644 (file)
@@ -7,8 +7,8 @@
  * - 8bpp tile renderer\r
  * In 32x mode:\r
  * - 32x layer is overlayed on top of 16bpp one\r
- * - line internal one done on PicoDraw2FB, then mixed with 32x\r
- * - tile internal one done on PicoDraw2FB, then mixed with 32x\r
+ * - line internal one done on .Draw2FB, then mixed with 32x\r
+ * - tile internal one done on .Draw2FB, then mixed with 32x\r
  */\r
 \r
 #include <stdio.h>\r
@@ -311,8 +311,8 @@ static int make_local_pal_md(int fast_mode)
                pallen = 0x100;\r
        }\r
        else if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes\r
-               bgr444_to_rgb32(localPal+0x40, HighPal);\r
-               bgr444_to_rgb32(localPal+0x80, HighPal+0x40);\r
+               bgr444_to_rgb32(localPal+0x40, Pico.est.HighPal);\r
+               bgr444_to_rgb32(localPal+0x80, Pico.est.HighPal+0x40);\r
        }\r
        else\r
                memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess\r
@@ -355,9 +355,9 @@ void pemu_finalize_frame(const char *fps, const char *notice)
                }\r
                // a hack for VR\r
                if (PicoAHW & PAHW_SVP)\r
-                       memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328);\r
+                       memset32((int *)(Pico.est.Draw2FB+328*8+328*223), 0xe0e0e0e0, 328);\r
                // do actual copy\r
-               vidcpyM2(g_screen_ptr, PicoDraw2FB+328*8,\r
+               vidcpyM2(g_screen_ptr, Pico.est.Draw2FB+328*8,\r
                        !(Pico.video.reg[12] & 1), !(PicoOpt & POPT_DIS_32C_BORDER));\r
        }\r
        else if (get_renderer() == RT_8BIT_ACC)\r
index c22f4fd..d90d610 100644 (file)
@@ -68,8 +68,8 @@ void pemu_finalize_frame(const char *fps, const char *notice)
 {\r
        if (currentConfig.renderer != RT_16BIT && !(PicoAHW & PAHW_32X)) {\r
                unsigned short *pd = (unsigned short *)g_screen_ptr + 8 * g_screen_width;\r
-               unsigned char *ps = PicoDraw2FB + 328*8 + 8;\r
-               unsigned short *pal = HighPal;\r
+               unsigned char *ps = Pico.est.Draw2FB + 328*8 + 8;\r
+               unsigned short *pal = Pico.est.HighPal;\r
                int i, x;\r
                if (Pico.m.dirtyPal)\r
                        PicoDrawUpdateHighPal();\r
@@ -99,7 +99,7 @@ static void apply_renderer(void)
        case RT_8BIT_ACC:\r
                PicoOpt &= ~POPT_ALT_RENDERER;\r
                PicoDrawSetOutFormat(PDF_8BIT, 0);\r
-               PicoDrawSetOutBuf(PicoDraw2FB + 8, 328);\r
+               PicoDrawSetOutBuf(Pico.est.Draw2FB + 8, 328);\r
                break;\r
        case RT_8BIT_FAST:\r
                PicoOpt |=  POPT_ALT_RENDERER;\r
index cb16d26..dd4381b 100644 (file)
@@ -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);
        }
 
index e9eb3c5..a5c475f 100644 (file)
@@ -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;