}
// this is almost never used (Wiz and menu bg gen only)
-void FinalizeLine32xRGB555(int sh, int line)
+void FinalizeLine32xRGB555(int sh, int line, struct PicoEState *est)
{
unsigned short *pd = DrawLineDest;
unsigned short *pal = Pico32xMem->pal_native;
unsigned short *dram, *p32x;
unsigned char mdbg;
- FinalizeLine555(sh, line);
+ FinalizeLine555(sh, line, est);
if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 0 || // 32x blanking
// XXX: how is 32col mode hadled by real hardware?
// AutoIncrement
a=(u16)(a+inc);
}
- rendstatus |= PDRAW_SPRITES_MOVED;
+ Pico.est.rendstatus |= PDRAW_SPRITES_MOVED;
break;
case 3: // cram
if (PicoAHW & PAHW_SMS)
PicoDoHighPal555M4();
else
- PicoDoHighPal555(1);
+ PicoDoHighPal555(1, 0, &Pico.est);
Pico.m.dirtyPal = 1;
screen += 16*stride+8;
#define SPRL_LO_ABOVE_HI 0x10 // low priority sprites may be on top of hi\r
unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; // sprite_count, ^flags, tile_count, [spritep]...\r
\r
-int rendstatus, rendstatus_old;\r
+int rendstatus_old;\r
int rendlines;\r
-int DrawScanline;\r
int PicoDrawMask = -1;\r
\r
static int skip_next_line=0;\r
\r
// stuff available in asm:\r
#ifdef _ASM_DRAW_C\r
-void DrawWindow(int tstart, int tend, int prio, int sh);\r
-void DrawAllSprites(unsigned char *sprited, int prio, int sh);\r
-void DrawTilesFromCache(int *hc, int sh, int rlim);\r
-void DrawSpritesSHi(unsigned char *sprited);\r
-void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);\r
-void FinalizeLineBGR444(int sh, int line);\r
+void DrawWindow(int tstart, int tend, int prio, int sh,\r
+ struct PicoEState *est);\r
+void DrawAllSprites(unsigned char *sprited, int prio, int sh,\r
+ struct PicoEState *est);\r
+void DrawTilesFromCache(int *hc, int sh, int rlim,\r
+ struct PicoEState *est);\r
+void DrawSpritesSHi(unsigned char *sprited, struct PicoEState *est);\r
+void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,\r
+ struct PicoEState *est);\r
void *blockcpy(void *dst, const void *src, size_t n);\r
void blockcpy_or(void *dst, void *src, size_t n, int pat);\r
#else\r
// terminate the cache list\r
*ts->hc = 0;\r
// if oldcode wasn't changed, it means all layer is hi priority\r
- if (oldcode == -1) rendstatus |= PDRAW_PLANE_HI_PRIO;\r
+ if (oldcode == -1) Pico.est.rendstatus |= PDRAW_PLANE_HI_PRIO;\r
}\r
\r
// this is messy\r
{\r
int tilex,dx,code=0,addr=0,cell=0;\r
int oldcode=-1,blank=-1; // The tile we know is blank\r
- int pal=0,scan=DrawScanline;\r
+ int pal=0,scan=Pico.est.DrawScanline;\r
\r
// Draw tiles across screen:\r
tilex=(-ts->hscroll)>>3;\r
\r
// terminate the cache list\r
*ts->hc = 0;\r
- if (oldcode == -1) rendstatus |= PDRAW_PLANE_HI_PRIO;\r
+ if (oldcode == -1) Pico.est.rendstatus |= PDRAW_PLANE_HI_PRIO;\r
}\r
#endif\r
\r
// --------------------------------------------\r
\r
#ifndef _ASM_DRAW_C\r
-static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells)\r
+static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,\r
+ struct PicoEState *est)\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
const char shift[4]={5,6,5,7}; // 32,64 or 128 sized tilemaps (2 is invalid)\r
else ts.nametab=(pvid->reg[2]&0x38)<< 9; // A\r
\r
htab=pvid->reg[13]<<9; // Horizontal scroll table address\r
- if ( pvid->reg[11]&2) htab+=DrawScanline<<1; // Offset by line\r
+ if ( pvid->reg[11]&2) htab+=est->DrawScanline<<1; // Offset by line\r
if ((pvid->reg[11]&1)==0) htab&=~0xf; // Offset by tile\r
htab+=plane_sh&1; // A or B\r
\r
vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value\r
\r
// Find the line in the name table\r
- ts.line=(vscroll+(DrawScanline<<1))&((ymask<<1)|1);\r
+ ts.line=(vscroll+(est->DrawScanline<<1))&((ymask<<1)|1);\r
ts.nametab+=(ts.line>>4)<<shift[width];\r
\r
DrawStripInterlace(&ts);\r
vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value\r
\r
// Find the line in the name table\r
- ts.line=(vscroll+DrawScanline)&ymask;\r
+ ts.line=(vscroll+est->DrawScanline)&ymask;\r
ts.nametab+=(ts.line>>3)<<shift[width];\r
\r
DrawStrip(&ts, plane_sh, cellskip);\r
// --------------------------------------------\r
\r
// tstart & tend are tile pair numbers\r
-static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache\r
+static void DrawWindow(int tstart, int tend, int prio, int sh,\r
+ struct PicoEState *est)\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
int tilex,ty,nametab,code=0;\r
if (pvid->reg[12]&1)\r
{\r
nametab=(pvid->reg[3]&0x3c)<<9; // 40-cell mode\r
- nametab+=(DrawScanline>>3)<<6;\r
+ nametab+=(est->DrawScanline>>3)<<6;\r
}\r
else\r
{\r
nametab=(pvid->reg[3]&0x3e)<<9; // 32-cell mode\r
- nametab+=(DrawScanline>>3)<<5;\r
+ nametab+=(est->DrawScanline>>3)<<5;\r
}\r
\r
tilex=tstart<<1;\r
\r
- if (!(rendstatus & PDRAW_WND_DIFF_PRIO)) {\r
+ if (!(est->rendstatus & PDRAW_WND_DIFF_PRIO)) {\r
// check the first tile code\r
code=Pico.vram[nametab+tilex];\r
// if the whole window uses same priority (what is often the case), we may be able to skip this field\r
}\r
\r
tend<<=1;\r
- ty=(DrawScanline&7)<<1; // Y-Offset into tile\r
+ ty=(est->DrawScanline&7)<<1; // Y-Offset into tile\r
\r
// Draw tiles across screen:\r
if (!sh)\r
code=Pico.vram[nametab+tilex];\r
if (code==blank) continue;\r
if ((code>>15) != prio) {\r
- rendstatus |= PDRAW_WND_DIFF_PRIO;\r
+ est->rendstatus |= PDRAW_WND_DIFF_PRIO;\r
continue;\r
}\r
\r
code=Pico.vram[nametab+tilex];\r
if(code==blank) continue;\r
if((code>>15) != prio) {\r
- rendstatus |= PDRAW_WND_DIFF_PRIO;\r
+ est->rendstatus |= PDRAW_WND_DIFF_PRIO;\r
continue;\r
}\r
\r
// we can process whole line and then act as if sh/hi mode was off,\r
// but leave lo pri op sprite markers alone\r
int c = 320/4, *zb = (int *)(HighCol+8);\r
- rendstatus |= PDRAW_SHHI_DONE;\r
+ Pico.est.rendstatus |= PDRAW_SHHI_DONE;\r
while (c--)\r
{\r
*zb++ &= 0xbfbfbfbf;\r
}\r
}\r
\r
-static void DrawTilesFromCache(int *hc, int sh, int rlim)\r
+static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est)\r
{\r
int code, addr, dx;\r
int pal;\r
\r
// *ts->hc++ = code | (dx<<16) | (ty<<25); // cache it\r
\r
- if (sh && (rendstatus & (PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO)))\r
+ if (sh && (est->rendstatus & (PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO)))\r
{\r
- if (!(rendstatus & PDRAW_SHHI_DONE))\r
+ if (!(est->rendstatus & PDRAW_SHHI_DONE))\r
DrawTilesFromCacheShPrep();\r
sh = 0;\r
}\r
height=(sy>>24)&7; // Width and height in tiles\r
sy=(sy<<16)>>16; // Y\r
\r
- row=DrawScanline-sy; // Row of the sprite we are on\r
+ row=Pico.est.DrawScanline-sy; // Row of the sprite we are on\r
\r
if (code&0x1000) row=(height<<3)-1-row; // Flip Y\r
\r
width=(height>>2)&3; height&=3;\r
width++; height++; // Width and height in tiles\r
\r
- row=(DrawScanline<<1)-sy; // Row of the sprite we are on\r
+ row=(Pico.est.DrawScanline<<1)-sy; // Row of the sprite we are on\r
\r
code=sprite[1];\r
sx=((code>>16)&0x1ff)-0x78; // X\r
static void DrawAllSpritesInterlace(int pri, int sh)\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
- int i,u,table,link=0,sline=DrawScanline<<1;\r
+ int i,u,table,link=0,sline=Pico.est.DrawScanline<<1;\r
unsigned int *sprites[80]; // Sprite index\r
\r
table=pvid->reg[5]&0x7f;\r
* Index + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: vert./horiz. size\r
* Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8\r
*/\r
-static void DrawSpritesSHi(unsigned char *sprited)\r
+static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)\r
{\r
int (*fTileFunc)(int sx,int addr,int pal);\r
unsigned char *p;\r
height=(sy>>24)&7; // Width and height in tiles\r
sy=(sy<<16)>>16; // Y\r
\r
- row=DrawScanline-sy; // Row of the sprite we are on\r
+ row=est->DrawScanline-sy; // Row of the sprite we are on\r
\r
if (code&0x1000) row=(height<<3)-1-row; // Flip Y\r
\r
cnt = sprited[0] & 0x7f;\r
if (cnt == 0) return;\r
\r
- rendstatus |= PDRAW_SPR_LO_ON_HI;\r
+ Pico.est.rendstatus |= PDRAW_SPR_LO_ON_HI;\r
\r
p = &sprited[3];\r
\r
height=(sy>>24)&7; // Width and height in tiles\r
sy=(sy<<16)>>16; // Y\r
\r
- row=DrawScanline-sy; // Row of the sprite we are on\r
+ row=Pico.est.DrawScanline-sy; // Row of the sprite we are on\r
\r
if (code&0x1000) row=(height<<3)-1-row; // Flip Y\r
\r
\r
/* nasty 2: sh operator pass */\r
sprited[0] = sh_cnt;\r
- DrawSpritesSHi(sprited);\r
+ DrawSpritesSHi(sprited, &Pico.est);\r
}\r
\r
\r
\r
void PrepareSprites(int full)\r
{\r
- struct PicoVideo *pvid=&Pico.video;\r
+ const struct PicoVideo *pvid=&Pico.video;\r
+ const struct PicoEState *est=&Pico.est;\r
int u,link=0,sh;\r
int table=0;\r
int *pd = HighPreSpr;\r
sy = (pack << 16) >> 16;\r
height = (pack >> 24) & 0xf;\r
\r
- if (sy < max_lines && sy + (height<<3) > DrawScanline && // sprite onscreen (y)?\r
+ if (sy < max_lines &&\r
+ sy + (height<<3) > est->DrawScanline && // sprite onscreen (y)?\r
(sx > -24 || sx < max_width)) // onscreen x\r
{\r
- int y = (sy >= DrawScanline) ? sy : DrawScanline;\r
+ int y = (sy >= est->DrawScanline) ? sy : est->DrawScanline;\r
int entry = ((pd - HighPreSpr) / 2) | ((code2>>8)&0x80);\r
for (; y < sy + (height<<3) && y < max_lines; y++)\r
{\r
sx = (code2>>16)&0x1ff;\r
sx -= 0x78; // Get X coordinate + 8\r
\r
- if (sy < max_lines && sy + (height<<3) > DrawScanline) // sprite onscreen (y)?\r
+ if (sy < max_lines && sy + (height<<3) > est->DrawScanline) // sprite onscreen (y)?\r
{\r
int entry, y, sx_min, onscr_x, maybe_op = 0;\r
\r
maybe_op = SPRL_MAY_HAVE_OP;\r
\r
entry = ((pd - HighPreSpr) / 2) | ((code2>>8)&0x80);\r
- y = (sy >= DrawScanline) ? sy : DrawScanline;\r
+ y = (sy >= est->DrawScanline) ? sy : est->DrawScanline;\r
for (; y < sy + (height<<3) && y < max_lines; y++)\r
{\r
unsigned char *p = &HighLnSpr[y][0];\r
}\r
\r
#ifndef _ASM_DRAW_C\r
-static void DrawAllSprites(unsigned char *sprited, int prio, int sh)\r
+static void DrawAllSprites(unsigned char *sprited, int prio, int sh,\r
+ struct PicoEState *est)\r
{\r
- int rs = rendstatus;\r
+ int rs = est->rendstatus;\r
unsigned char *p;\r
int cnt;\r
\r
if (rs & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {\r
//elprintf(EL_STATUS, "PrepareSprites(%i)", (rs>>4)&1);\r
PrepareSprites(rs & PDRAW_DIRTY_SPRITES);\r
- rendstatus = rs & ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES);\r
+ est->rendstatus = rs & ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES);\r
}\r
\r
cnt = sprited[0] & 0x7f;\r
unsigned short HighPal[0x100];\r
\r
#ifndef _ASM_DRAW_C\r
-void PicoDoHighPal555(int sh)\r
+void PicoDoHighPal555(int sh, int line, struct PicoEState *est)\r
{\r
unsigned int *spal, *dpal;\r
unsigned int t, i;\r
int len;\r
\r
if (Pico.m.dirtyPal)\r
- PicoDoHighPal555(sh);\r
+ PicoDoHighPal555(sh, line, est);\r
\r
if (Pico.video.reg[12]&1) {\r
len = 320;\r
{\r
#ifndef PSP\r
int i, mask=0xff;\r
- if (!sh && (rendstatus & PDRAW_SPR_LO_ON_HI))\r
+ if (!sh && (est->rendstatus & PDRAW_SPR_LO_ON_HI))\r
mask=0x3f; // accurate sprites, upper bits are priority stuff\r
\r
for (i = 0; i < len; i++)\r
#else\r
extern void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);\r
extern void amips_clut_6bit(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);\r
- if (!sh && (rendstatus & PDRAW_SPR_LO_ON_HI))\r
+ if (!sh && (est->rendstatus & PDRAW_SPR_LO_ON_HI))\r
amips_clut_6bit(pd, ps, pal, len);\r
else amips_clut(pd, ps, pal, len);\r
#endif\r
}\r
#endif\r
\r
-static void FinalizeLine8bit(int sh, int line)\r
+static void FinalizeLine8bit(int sh, int line, struct PicoEState *est)\r
{\r
unsigned char *pd = DrawLineDest;\r
- int len, rs = rendstatus;\r
+ int len, rs = est->rendstatus;\r
static int dirty_count;\r
\r
if (!sh && Pico.m.dirtyPal == 1)\r
dirty_count = 1;\r
else dirty_count++;\r
rs |= PDRAW_SONIC_MODE;\r
- rendstatus = rs;\r
+ est->rendstatus = rs;\r
if (dirty_count == 3) {\r
blockcpy(HighPal, Pico.cram, 0x40*2);\r
} else if (dirty_count == 11) {\r
}\r
}\r
\r
-static void (*FinalizeLine)(int sh, int line);\r
+static void (*FinalizeLine)(int sh, int line, struct PicoEState *est);\r
\r
// --------------------------------------------\r
\r
static int DrawDisplay(int sh)\r
{\r
- unsigned char *sprited = &HighLnSpr[DrawScanline][0];\r
+ struct PicoEState *est=&Pico.est;\r
+ unsigned char *sprited = &HighLnSpr[est->DrawScanline][0];\r
struct PicoVideo *pvid=&Pico.video;\r
int win=0,edge=0,hvwind=0;\r
int maxw,maxcells;\r
\r
- rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO);\r
+ est->rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO);\r
\r
if (pvid->reg[12]&1) {\r
maxw = 328; maxcells = 40;\r
win=pvid->reg[0x12];\r
edge=(win&0x1f)<<3;\r
\r
- if (win&0x80) { if (DrawScanline>=edge) hvwind=1; }\r
- else { if (DrawScanline< edge) hvwind=1; }\r
+ if (win&0x80) { if (est->DrawScanline>=edge) hvwind=1; }\r
+ else { if (est->DrawScanline< edge) hvwind=1; }\r
\r
if (!hvwind) // we might have a vertical window here\r
{\r
\r
/* - layer B low - */\r
if (PicoDrawMask & PDRAW_LAYERB_ON)\r
- DrawLayer(1|(sh<<1), HighCacheB, 0, maxcells);\r
+ DrawLayer(1|(sh<<1), HighCacheB, 0, maxcells, est);\r
/* - layer A low - */\r
if (!(PicoDrawMask & PDRAW_LAYERA_ON));\r
else if (hvwind == 1)\r
- DrawWindow(0, maxcells>>1, 0, sh);\r
+ DrawWindow(0, maxcells>>1, 0, sh, est);\r
else if (hvwind == 2) {\r
- DrawLayer(0|(sh<<1), HighCacheA, (win&0x80) ? 0 : edge<<1, (win&0x80) ? edge<<1 : maxcells);\r
- DrawWindow( (win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh);\r
+ DrawLayer(0|(sh<<1), HighCacheA, (win&0x80) ? 0 : edge<<1, (win&0x80) ? edge<<1 : maxcells, est);\r
+ DrawWindow( (win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh, est);\r
} else\r
- DrawLayer(0|(sh<<1), HighCacheA, 0, maxcells);\r
+ DrawLayer(0|(sh<<1), HighCacheA, 0, maxcells, est);\r
/* - sprites low - */\r
if (!(PicoDrawMask & PDRAW_SPRITES_LOW_ON));\r
- else if (rendstatus & PDRAW_INTERLACE)\r
+ else if (Pico.est.rendstatus & PDRAW_INTERLACE)\r
DrawAllSpritesInterlace(0, sh);\r
else if (sprited[1] & SPRL_HAVE_LO)\r
- DrawAllSprites(sprited, 0, sh);\r
+ DrawAllSprites(sprited, 0, sh, est);\r
\r
/* - layer B hi - */\r
if ((PicoDrawMask & PDRAW_LAYERB_ON) && HighCacheB[0])\r
- DrawTilesFromCache(HighCacheB, sh, maxw);\r
+ DrawTilesFromCache(HighCacheB, sh, maxw, est);\r
/* - layer A hi - */\r
if (!(PicoDrawMask & PDRAW_LAYERA_ON));\r
else if (hvwind == 1)\r
- DrawWindow(0, maxcells>>1, 1, sh);\r
+ DrawWindow(0, maxcells>>1, 1, sh, est);\r
else if (hvwind == 2) {\r
- if (HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh, (win&0x80) ? edge<<4 : maxw);\r
- DrawWindow((win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 1, sh);\r
+ if (HighCacheA[0])\r
+ DrawTilesFromCache(HighCacheA, sh, (win&0x80) ? edge<<4 : maxw, est);\r
+ DrawWindow((win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 1, sh, est);\r
} else\r
- if (HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh, maxw);\r
+ if (HighCacheA[0])\r
+ DrawTilesFromCache(HighCacheA, sh, maxw, est);\r
/* - sprites hi - */\r
if (!(PicoDrawMask & PDRAW_SPRITES_HI_ON));\r
- else if (rendstatus & PDRAW_INTERLACE)\r
+ else if (Pico.est.rendstatus & PDRAW_INTERLACE)\r
DrawAllSpritesInterlace(1, sh);\r
// have sprites without layer pri bit ontop of sprites with that bit\r
else if ((sprited[1] & 0xd0) == 0xd0 && (PicoOpt & POPT_ACC_SPRITES))\r
DrawSpritesHiAS(sprited, sh);\r
else if (sh && (sprited[1] & SPRL_MAY_HAVE_OP))\r
- DrawSpritesSHi(sprited);\r
+ DrawSpritesSHi(sprited, est);\r
else if (sprited[1] & SPRL_HAVE_HI)\r
- DrawAllSprites(sprited, 1, 0);\r
+ DrawAllSprites(sprited, 1, 0, est);\r
\r
#if 0\r
{\r
int *c, a, b;\r
for (a = 0, c = HighCacheA; *c; c++, a++);\r
for (b = 0, c = HighCacheB; *c; c++, b++);\r
- printf("%i:%03i: a=%i, b=%i\n", Pico.m.frame_count, DrawScanline, a, b);\r
+ printf("%i:%03i: a=%i, b=%i\n", Pico.m.frame_count,\r
+ Pico.est.DrawScanline, a, b);\r
}\r
#endif\r
\r
int offs = 8, lines = 224;\r
\r
// prepare to do this frame\r
- rendstatus = 0;\r
+ Pico.est.rendstatus = 0;\r
if ((Pico.video.reg[12] & 6) == 6)\r
- rendstatus |= PDRAW_INTERLACE; // interlace mode\r
+ Pico.est.rendstatus |= PDRAW_INTERLACE; // interlace mode\r
if (!(Pico.video.reg[12] & 1))\r
- rendstatus |= PDRAW_32_COLS;\r
+ Pico.est.rendstatus |= PDRAW_32_COLS;\r
if (Pico.video.reg[1] & 8) {\r
offs = 0;\r
lines = 240;\r
}\r
\r
- if (rendstatus != rendstatus_old || lines != rendlines) {\r
+ if (Pico.est.rendstatus != rendstatus_old || lines != rendlines) {\r
rendlines = lines;\r
// mode_change() might reset rendstatus_old by calling SetColorFormat\r
emu_video_mode_change((lines == 240) ? 0 : 8,\r
lines, (Pico.video.reg[12] & 1) ? 0 : 1);\r
- rendstatus_old = rendstatus;\r
+ rendstatus_old = Pico.est.rendstatus;\r
}\r
\r
HighCol = HighColBase + offs * HighColIncrement;\r
DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement;\r
- DrawScanline = 0;\r
+ Pico.est.DrawScanline = 0;\r
skip_next_line = 0;\r
\r
if (PicoOpt & POPT_ALT_RENDERER)\r
BackFill(bgc, sh);\r
\r
if (FinalizeLine != NULL)\r
- FinalizeLine(sh, line);\r
+ FinalizeLine(sh, line, &Pico.est);\r
\r
if (PicoScanEnd != NULL)\r
PicoScanEnd(line + offs);\r
return;\r
}\r
\r
- DrawScanline = line;\r
+ Pico.est.DrawScanline = line;\r
if (PicoScanBegin != NULL)\r
skip = PicoScanBegin(line + offs);\r
\r
DrawDisplay(sh);\r
\r
if (FinalizeLine != NULL)\r
- FinalizeLine(sh, line);\r
+ FinalizeLine(sh, line, &Pico.est);\r
\r
if (PicoScanEnd != NULL)\r
skip_next_line = PicoScanEnd(line + offs);\r
if (rendlines != 240)\r
offs = 8;\r
\r
- for (line = DrawScanline; line < to; line++)\r
+ for (line = Pico.est.DrawScanline; line < to; line++)\r
{\r
PicoLine(line, offs, sh, bgc);\r
}\r
else PicoLine(line, offs, sh, bgc);\r
line++;\r
}\r
- DrawScanline = line;\r
+ Pico.est.DrawScanline = line;\r
\r
pprof_end(draw);\r
}\r
if (PicoOpt & POPT_ALT_RENDERER)\r
sh = 0; // no s/h support\r
\r
- PicoDoHighPal555(sh);\r
- if (rendstatus & PDRAW_SONIC_MODE) {\r
+ PicoDoHighPal555(sh, 0, &Pico.est);\r
+ if (Pico.est.rendstatus & PDRAW_SONIC_MODE) {\r
// FIXME?\r
memcpy(HighPal + 0x40, HighPal, 0x40*2);\r
memcpy(HighPal + 0x80, HighPal, 0x40*2);\r
{\r
DrawLineDestBase = dest;\r
DrawLineDestIncrement = increment;\r
- DrawLineDest = DrawLineDestBase + DrawScanline * increment;\r
+ DrawLineDest = DrawLineDestBase + Pico.est.DrawScanline * increment;\r
}\r
\r
void PicoDrawSetInternalBuf(void *dest, int increment)\r
if (dest != NULL) {\r
HighColBase = dest;\r
HighColIncrement = increment;\r
- HighCol = HighColBase + DrawScanline * increment;\r
+ HighCol = HighColBase + Pico.est.DrawScanline * increment;\r
}\r
else {\r
HighColBase = DefHighCol;\r
PicoScanEnd = end;\r
}\r
}\r
+\r
+// vim:ts=4:sw=4:expandtab\r
/*\r
* assembly optimized versions of most funtions from draw.c\r
- * (C) notaz, 2006-2010\r
+ * (C) notaz, 2006-2010,2017\r
*\r
* This work is licensed under the terms of MAME license.\r
* See COPYING file in the top-level directory.\r
* this is highly specialized, be careful if changing related C code!\r
*/\r
\r
-.extern Pico\r
+#include "pico_int_o32.h"\r
+\r
.extern PicoOpt\r
.extern HighCol\r
-.extern DrawScanline\r
.extern HighSprZ\r
-.extern rendstatus\r
.extern HighPreSpr\r
.extern DrawLineDest\r
.extern DrawStripInterlace\r
@ int cells; // 0x14\r
@ };\r
\r
-@ void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);\r
+@ void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,\r
+@ struct PicoEState *est)\r
\r
.global DrawLayer\r
\r
DrawLayer:\r
+ ldr r12, [sp] @ est\r
stmfd sp!, {r4-r11,lr}\r
\r
- ldr r11, =(Pico+0x22228) @ Pico.video\r
+ ldr r11, [r12, #OFS_Pico_video]\r
mov r8, #1\r
\r
ldrb r7, [r11, #16] @ ??vv??hh\r
cmp r10, #7\r
subge r10, r10, #1 @ r10=shift[width] (5,6,6,7)\r
\r
- @ calculate xmask:\r
- mov r5, r8, lsl r10\r
- sub r5, r5, #1 @ r5=xmask\r
+ ldr r2, [r12, #OFS_DrawScanline]\r
+ ldr lr, [r12, #OFS_Pico_vram]\r
\r
@ Find name table:\r
ands r0, r0, #1\r
ldreqb r12, [r11, #2]\r
ldrneb r12, [r11, #4]\r
\r
- ldr r2, =DrawScanline @ trying to make good use of pipeline here\r
- ldr lr, =(Pico+0x10000) @ lr=Pico.vram\r
+ @ calculate xmask:\r
+ mov r5, r8, lsl r10\r
+ sub r5, r5, #1 @ r5=xmask\r
\r
moveq r12, r12, lsl #10\r
movne r12, r12, lsl #13\r
\r
ldrh r8, [r11, #12]\r
ldrb r7, [r11, #11]\r
- ldr r2, [r2]\r
\r
mov r4, r8, lsr #8 @ pvid->reg[13]\r
mov r4, r4, lsl #10 @ htab=pvid->reg[13]<<9; (halfwords)\r
\r
.dsloop_exit:\r
tst r10, #1<<21 @ seen non hi-prio tile\r
- ldreq r1, =rendstatus\r
+ ldr r1, [sp, #9*4] @ est\r
mov r0, #0\r
- ldreq r2, [r1]\r
+ ldreq r2, [r1, #OFS_rendstatus]\r
str r0, [r6] @ terminate the cache list\r
orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles\r
- streq r2, [r1]\r
+ streq r2, [r1, #OFS_rendstatus]\r
\r
ldmfd sp!, {r4-r11,lr}\r
bx lr\r
bic r8, r8, #0x3fc00000\r
orr r8, r8, r5, lsl #25 @ r8=(xmask[31:25]|had_output[24]|tilex[21:0])\r
\r
- ldr r4, =DrawScanline\r
+ ldr r11, [sp, #9*4] @ est\r
orr r5, r1, r10, lsl #24\r
- ldr r4, [r4]\r
+ ldr r4, [r11, #OFS_DrawScanline]\r
sub r1, r3, #1\r
orr r5, r5, r4, lsl #16 @ r5=(shift_width[31:24]|scanline[23:16]|ymask[15:0])\r
and r1, r1, #7\r
\r
.dsloop_vs_exit:\r
tst r8, #(1<<24) @ seen non hi-prio tile\r
- ldreq r1, =rendstatus\r
+ ldr r1, [sp, #9*4] @ est\r
mov r0, #0\r
- ldreq r2, [r1]\r
+ ldreq r2, [r1, #OFS_rendstatus]\r
str r0, [r6] @ terminate the cache list\r
orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles\r
- streq r2, [r1]\r
+ streq r2, [r1, #OFS_rendstatus]\r
\r
ldmfd sp!, {r4-r11,lr}\r
bx lr\r
\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
+@ void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est)\r
\r
-.global DrawTilesFromCache @ int *hc, int sh, int rlim\r
+.global DrawTilesFromCache\r
\r
DrawTilesFromCache:\r
- stmfd sp!, {r4-r8,r11,lr}\r
+ stmfd sp!, {r4-r9,r11,lr}\r
\r
@ cache some stuff to avoid mem access\r
.if OVERRIDE_HIGHCOL\r
ldr r11,=HighCol\r
mov r12,#0xf\r
.endif\r
- ldr lr, =(Pico+0x10000) @ lr=Pico.vram\r
+ ldr lr, [r3, #OFS_Pico_vram]\r
+ mov r9, r3 @ est\r
\r
mvn r5, #0 @ r5=prevcode=-1\r
ands r8, r1, #1\r
.dtfc_loop:\r
ldr r6, [r0], #4 @ read code\r
movs r1, r6, lsr #16 @ r1=dx;\r
- ldmeqfd sp!, {r4-r8,r11,pc} @ dx is never zero, this must be a terminator, return\r
+ ldmeqfd sp!, {r4-r9,r11,pc} @ dx is never zero, this must be a terminator, return\r
bic r4, r1, #0xfe00\r
add r1, r11, r4 @ r1=pdest\r
\r
\r
@ check if we have detected layer covered with hi-prio tiles:\r
.dtfc_check_rendflags:\r
- ldr r1, =rendstatus\r
- ldr r2, [r1]\r
+ ldr r2, [r9, #OFS_rendstatus]\r
tst r2, #(PDRAW_PLANE_HI_PRIO|PDRAW_SHHI_DONE)\r
beq .dtfc_loop\r
bic r8, r8, #1 @ sh/hi mode off\r
tst r2, #PDRAW_SHHI_DONE\r
bne .dtfc_loop @ already processed\r
orr r2, r2, #PDRAW_SHHI_DONE\r
- str r2, [r1]\r
+ str r2, [r9, #OFS_rendstatus]\r
\r
add r1, r11,#8\r
mov r3, #320/4/4\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
\r
-.global DrawSpritesSHi @ unsigned char *sprited\r
+@ void DrawSpritesSHi(unsigned char *sprited, struct PicoEState *est)\r
+\r
+.global DrawSpritesSHi\r
\r
DrawSpritesSHi:\r
ldr r3, [r0]\r
ands r3, r3, #0x7f\r
bxeq lr\r
\r
- stmfd sp!, {r4-r11,lr}\r
+ stmfd sp!, {r1,r4-r11,lr} @ +est\r
strb r12,[r0,#2] @ set end marker\r
add r10,r0, #3 @ r10=HighLnSpr end\r
add r10,r10,r3 @ r10=HighLnSpr end\r
ldr r11,=HighCol\r
mov r12,#0xf\r
.endif\r
- ldr lr, =(Pico+0x10000) @ lr=Pico.vram\r
+ ldr lr, [r1, #OFS_Pico_vram]\r
\r
\r
DrawSpriteSHi:\r
@ draw next sprite\r
ldrb r0, [r10,#-1]!\r
+ ldr r7, [sp] @ est\r
ldr r1, =HighPreSpr\r
-@ ldr r8, [sp, #-4]\r
cmp r0, #0xff\r
- ldmeqfd sp!, {r4-r11,pc} @ end of list\r
+ ldmeqfd sp!, {r1,r4-r11,pc} @ end of list\r
and r0, r0, #0x7f\r
add r0, r1, r0, lsl #3\r
\r
bne DrawSpriteSHi @ non-operator low sprite, already drawn\r
\r
ldr r3, [r0] @ sprite[0]\r
- ldr r7, =DrawScanline\r
mov r6, r3, lsr #28\r
sub r6, r6, #1 @ r6=width-1 (inc later)\r
mov r5, r3, lsr #24\r
and r5, r5, #7 @ r5=height\r
\r
+ ldr r7, [r7, #OFS_DrawScanline]\r
mov r0, r3, lsl #16 @ r4=sy<<16 (tmp)\r
\r
- ldr r7, [r7]\r
sub r7, r7, r0, asr #16 @ r7=row=DrawScanline-sy\r
\r
tst r9, #0x1000\r
\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
-.global DrawAllSprites @ unsigned char *sprited, int prio, int sh\r
+@ void DrawAllSprites(unsigned char *sprited, int prio, int sh,\r
+@ struct PicoEState *est)\r
+\r
+.global DrawAllSprites\r
\r
DrawAllSprites:\r
- ldr r3, =rendstatus\r
orr r1, r2, r1, lsl #1\r
- ldr r12,[r3]\r
+ ldr r12,[r3, #OFS_rendstatus]\r
tst r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)\r
beq das_no_prep\r
- stmfd sp!, {r0,r1,lr}\r
+ stmfd sp!, {r0,r1,r3,lr}\r
and r0, r12,#PDRAW_DIRTY_SPRITES\r
bic r12,r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)\r
- str r12,[r3]\r
+ str r12,[r3, #OFS_rendstatus]\r
bl PrepareSprites\r
- ldmfd sp!, {r0,r1,lr}\r
+ ldmfd sp!, {r0,r1,r3,lr}\r
\r
das_no_prep:\r
- ldr r3, [r0]\r
- ands r3, r3, #0x7f\r
+ ldr r2, [r0]\r
+ ands r2, r2, #0x7f\r
bxeq lr\r
\r
@ time to do some real work\r
- stmfd sp!, {r4-r11,lr}\r
+ stmfd sp!, {r1,r3-r11,lr} @ +sh|prio<<1 +est\r
mov r12,#0xff\r
strb r12,[r0,#2] @ set end marker\r
add r10,r0, #3\r
- add r10,r10,r3 @ r10=HighLnSpr end\r
-\r
- str r1, [sp, #-4] @ no calls after this point\r
+ add r10,r10,r2 @ r10=HighLnSpr end\r
\r
.if OVERRIDE_HIGHCOL\r
ldr r11,=HighCol\r
ldr r11,=HighCol\r
mov r12,#0xf\r
.endif\r
- ldr lr, =(Pico+0x10000) @ lr=Pico.vram\r
+ ldr lr, [r3, #OFS_Pico_vram]\r
\r
@ + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size\r
@ + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8\r
\r
-DrawSprite: @ was: unsigned int *sprite, int sh, int acc_sprites\r
+DrawSprite:\r
@ draw next sprite\r
ldrb r0, [r10,#-1]!\r
- ldr r1, =HighPreSpr\r
- ldr r8, [sp, #-4]\r
+ ldr r8, [sp] @ sh|prio<<1\r
+ ldr r7, [sp, #4] @ est\r
mov r2, r0, lsr #7\r
cmp r0, #0xff\r
- ldmeqfd sp!, {r4-r11,pc} @ end of list\r
+ ldmeqfd sp!, {r1,r3-r11,pc} @ end of list\r
cmp r2, r8, lsr #1\r
bne DrawSprite @ wrong priority\r
+ ldr r1, =HighPreSpr\r
and r0, r0, #0x7f\r
add r0, r1, r0, lsl #3\r
\r
-@ stmfd sp!, {r4-r9,r11,lr}\r
-@ orr r8, r2, r1, lsl #4\r
-\r
ldr r3, [r0] @ sprite[0]\r
- ldr r7, =DrawScanline\r
+ ldr r7, [r7, #OFS_DrawScanline]\r
mov r6, r3, lsr #28\r
sub r6, r6, #1 @ r6=width-1 (inc later)\r
mov r5, r3, lsr #24\r
\r
mov r4, r3, lsl #16 @ r4=sy<<16 (tmp)\r
\r
- ldr r7, [r7]\r
ldr r9, [r0, #4]\r
sub r7, r7, r4, asr #16 @ r7=row=DrawScanline-sy\r
\r
\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
-.global DrawWindow @ int tstart, int tend, int prio, int sh // int *hcache\r
+@ void DrawWindow(int tstart, int tend, int prio, int sh\r
+@ struct PicoEState *est)\r
+\r
+.global DrawWindow\r
\r
DrawWindow:\r
+ ldr r12, [sp] @ est\r
stmfd sp!, {r4-r11,lr}\r
\r
- ldr r11, =(Pico+0x22228) @ Pico.video\r
- ldr r10, =DrawScanline\r
- ldrb r12, [r11, #3] @ pvid->reg[3]\r
+ ldr r6, [r12, #OFS_Pico_video]\r
+ ldr r10, [r12, #OFS_DrawScanline]\r
+ mov r11, r12 @ est\r
+ ldrb r12, [r6, #3] @ pvid->reg[3]\r
\r
- ldr r10, [r10]\r
- ldr r4, [r11, #12]\r
+ ldr r4, [r6, #12]\r
mov r5, r10, lsr #3\r
and r10, r10, #7\r
mov r10, r10, lsl #1 @ r10=ty\r
addeq r12, r12, r5, lsl #6 @ nametab\r
add r12, r12, r0, lsl #2 @ +starttile\r
\r
- ldr r6, =rendstatus\r
- ldr lr, =(Pico+0x10000) @ lr=Pico.vram\r
- ldr r6, [r6]\r
+ ldr lr, [r11, #OFS_Pico_vram]\r
+ ldr r6, [r11, #OFS_rendstatus]\r
\r
@ fetch the first code now\r
ldrh r7, [lr, r12]\r
b .dw_shadow_done\r
\r
.dwloop_end:\r
- ldr r0, =rendstatus\r
- ldr r1, [r0]\r
- and r6, r6, #PDRAW_WND_DIFF_PRIO\r
- orr r1, r1, r6\r
- str r1, [r0]\r
+ and r2, r6, #PDRAW_WND_DIFF_PRIO\r
+ ldmfd sp!, {r4-r11,lr}\r
+ ldr r0, [sp]\r
+ ldr r1, [r0, #OFS_rendstatus]\r
+ orr r1, r1, r2\r
+ str r1, [r0, #OFS_rendstatus]\r
\r
- ldmfd sp!, {r4-r11,r12}\r
- bx r12\r
+ bx lr\r
\r
\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
bx lr\r
\r
\r
-.global PicoDoHighPal555 @ int sh\r
+@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est)\r
+\r
+.global PicoDoHighPal555\r
\r
PicoDoHighPal555:\r
- stmfd sp!, {r4-r9,lr}\r
+ stmfd sp!, {r4-r10,lr}\r
+ mov r10,r2 @ est\r
mov r1, #0\r
- ldr r8, =(Pico+0x22228) @ Pico.video\r
+ ldr r8, [r10, #OFS_Pico_video]\r
\r
PicoDoHighPal555_nopush:\r
orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h\r
\r
PicoDoHighPal555_end:\r
tst r9, #1\r
- ldmeqfd sp!, {r4-r9,pc}\r
+ ldmeqfd sp!, {r4-r10,pc}\r
\r
- ldr r8, =(Pico+0x22228) @ Pico.video\r
+ ldr r8, [r10, #OFS_Pico_video]\r
b FinalizeLineRGB555_pal_done\r
\r
\r
-.global FinalizeLine555 @ int sh\r
+@ void FinalizeLine555(int sh, int line, struct PicoEState *est)\r
+\r
+.global FinalizeLine555\r
\r
FinalizeLine555:\r
- stmfd sp!, {r4-r9,lr}\r
- ldr r8, =(Pico+0x22228) @ Pico.video\r
+ stmfd sp!, {r4-r10,lr}\r
+ mov r10,r2 @ est\r
+ ldr r8, [r10, #OFS_Pico_video]\r
\r
ldrb r2, [r8, #-0x1a] @ 0x2220e ~ dirtyPal\r
mov r1, #1\r
FinalizeLineRGB555_pal_done:\r
ldr r3, =HighPal\r
\r
- ldr r12,=rendstatus\r
+ ldr r12, [r10, #OFS_rendstatus]\r
eors r0, r0, #1 @ sh is 0\r
- ldr r12,[r12]\r
mov lr, #0xff\r
tstne r12,#PDRAW_ACC_SPRITES\r
movne lr, #0x3f\r
stmia r0!, {r4,r5,r8,r12}\r
bne .fl_loopRGB555\r
\r
- ldmfd sp!, {r4-r9,lr}\r
+ ldmfd sp!, {r4-r10,lr}\r
bx lr\r
\r
\r
.fl_32scale_RGB555:\r
- stmfd sp!, {r10}\r
mov r9, #0x3900 @ f800 07e0 001f | e000 0780 001c | 3800 01e0 0007\r
orr r9, r9, #0x00e7\r
\r
stmia r0!, {r4,r5,r6,r8,r10}\r
bne .fl_loop32scale_RGB555\r
\r
- ldmfd sp!, {r10}\r
- ldmfd sp!, {r4-r9,lr}\r
+ ldmfd sp!, {r4-r10,lr}\r
bx lr\r
\r
#ifdef UNALIGNED_DRAWLINEDEST\r
\r
strh r8, [r0], #2\r
\r
- ldmfd sp!, {r4-r9,lr}\r
+ ldmfd sp!, {r4-r10,lr}\r
bx lr\r
\r
\r
\r
strh r4, [r0], #2\r
\r
- ldmfd sp!, {r10}\r
- ldmfd sp!, {r4-r9,lr}\r
+ ldmfd sp!, {r4-r10,lr}\r
bx lr\r
\r
#endif /* UNALIGNED_DRAWLINEDEST */\r
int lines = 192;
skip_next_line = 0;
screen_offset = 24;
- rendstatus = PDRAW_32_COLS;
+ Pico.est.rendstatus = PDRAW_32_COLS;
if ((Pico.video.reg[0] & 6) == 6 && (Pico.video.reg[1] & 0x18)) {
if (Pico.video.reg[1] & 0x08) {
}
}
- if (rendstatus != rendstatus_old || lines != rendlines) {
+ if (Pico.est.rendstatus != rendstatus_old || lines != rendlines) {
emu_video_mode_change(screen_offset, lines, 1);
- rendstatus_old = rendstatus;
+ rendstatus_old = Pico.est.rendstatus;
rendlines = lines;
}
// standard FinalizeLine can finish it for us,
// with features like scaling and such
- FinalizeLine555(0, line);
+ FinalizeLine555(0, line, &Pico.est);
}
static void FinalizeLine8bitM4(int line)
memset(&PicoPad,0,sizeof(PicoPad));\r
memset(&PicoPadInt,0,sizeof(PicoPadInt));\r
\r
+ Pico.est.Pico_video = &Pico.video;\r
+ Pico.est.Pico_vram = Pico.vram;\r
+\r
// Init CPUs:\r
SekInit();\r
z80_init(); // init even if we aren't going to use it\r
typedef union { int vint; void *vptr; } pint_ret_t;\r
void PicoGetInternal(pint_t which, pint_ret_t *ret);\r
\r
+struct PicoEState;\r
+\r
// cd/mcd.c\r
extern void (*PicoMCDopenTray)(void);\r
extern void (*PicoMCDcloseTray)(void);\r
#ifdef _ASM_DRAW_C\r
void vidConvCpyRGB565(void *to, void *from, int pixels);\r
#endif\r
-void PicoDoHighPal555(int sh);\r
+void PicoDoHighPal555(int sh, int line, struct PicoEState *est);\r
extern int PicoDrawMask;\r
#define PDRAW_LAYERB_ON (1<<2)\r
#define PDRAW_LAYERA_ON (1<<3)\r
#define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)\r
#define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed\r
#define PDRAW_32_COLS (1<<8) // 32 column mode\r
-extern int rendstatus, rendstatus_old;\r
+extern int rendstatus_old;\r
extern int rendlines;\r
extern unsigned short HighPal[0x100];\r
\r
if (!skip)
{
- if (DrawScanline < y)
+ if (Pico.est.DrawScanline < y)
PicoDrawSync(y - 1, 0);
#ifdef DRAW_FINISH_FUNC
DRAW_FINISH_FUNC();
unsigned char pad[0x4e];\r
};\r
\r
+// emu state and data for the asm code\r
+struct PicoEState\r
+{\r
+ int DrawScanline;\r
+ int rendstatus;\r
+ void *Pico_video;\r
+ void *Pico_vram;\r
+};\r
+\r
// some assembly stuff depend on these, do not touch!\r
struct Pico\r
{\r
struct PicoMisc m;\r
struct PicoVideo video;\r
struct PicoMS ms;\r
+ struct PicoEState est;\r
};\r
\r
// sram\r
PICO_INTERNAL void PicoFrameStart(void);\r
void PicoDrawSync(int to, int blank_last_line);\r
void BackFill(int reg7, int sh);\r
-void FinalizeLine555(int sh, int line);\r
+void FinalizeLine555(int sh, int line, struct PicoEState *est);\r
extern int (*PicoScanBegin)(unsigned int num);\r
extern int (*PicoScanEnd)(unsigned int num);\r
-extern int DrawScanline;\r
#define MAX_LINE_SPRITES 29\r
extern unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES];\r
extern void *DrawLineDestBase;\r
\r
// 32x/draw.c\r
void PicoDrawSetOutFormat32x(pdso_t which, int use_32x_line_mode);\r
-void FinalizeLine32xRGB555(int sh, int line);\r
+void FinalizeLine32xRGB555(int sh, int line, struct PicoEState *est);\r
void PicoDraw32xLayer(int offs, int lines, int mdbg);\r
void PicoDraw32xLayerMdOnly(int offs, int lines);\r
extern int (*PicoScan32xBegin)(unsigned int num);\r
--- /dev/null
+/* 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
case 1: if(a&1) d=(u16)((d<<8)|(d>>8)); // If address is odd, bytes are swapped (which game needs this?)\r
Pico.vram [(a>>1)&0x7fff]=d;\r
if (a - ((unsigned)(Pico.video.reg[5]&0x7f) << 9) < 0x400)\r
- rendstatus |= PDRAW_DIRTY_SPRITES;\r
+ Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;\r
break;\r
case 3: Pico.m.dirtyPal = 1;\r
Pico.cram [(a>>1)&0x003f]=d; break; // wraps (Desert Strike)\r
//if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM\r
}\r
}\r
- rendstatus |= PDRAW_DIRTY_SPRITES;\r
+ Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;\r
break;\r
\r
case 3: // cram\r
}\r
// remember addr\r
Pico.video.addr=a;\r
- rendstatus |= PDRAW_DIRTY_SPRITES;\r
+ Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;\r
}\r
\r
// check: Contra, Megaman\r
// update length\r
Pico.video.reg[0x13] = Pico.video.reg[0x14] = 0; // Dino Dini's Soccer (E) (by Haze)\r
\r
- rendstatus |= PDRAW_DIRTY_SPRITES;\r
+ Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;\r
}\r
\r
static void CommandDma(void)\r
static void DrawSync(int blank_on)\r
{\r
if (Pico.m.scanline < 224 && !(PicoOpt & POPT_ALT_RENDERER) &&\r
- !PicoSkipFrame && DrawScanline <= Pico.m.scanline) {\r
+ !PicoSkipFrame && Pico.est.DrawScanline <= Pico.m.scanline) {\r
//elprintf(EL_ANOMALY, "sync");\r
PicoDrawSync(Pico.m.scanline, blank_on);\r
}\r
goto update_irq;\r
case 0x05:\r
//elprintf(EL_STATUS, "spritep moved to %04x", (unsigned)(Pico.video.reg[5]&0x7f) << 9);\r
- if (d^dold) rendstatus |= PDRAW_SPRITES_MOVED;\r
+ if (d^dold) Pico.est.rendstatus |= PDRAW_SPRITES_MOVED;\r
break;\r
case 0x0c:\r
// renderers should update their palettes if sh/hi mode is changed\r
localPal[0xf0] = 0x00ffffff;\r
pallen = 0x100;\r
}\r
- else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes\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
}\r
localPal[0xe0] = 0;
localPal[0xf0] = 0x001f;
}
- else if (allow_as && (rendstatus & PDRAW_SPR_LO_ON_HI))
+ else if (allow_as && (Pico.est.rendstatus & PDRAW_SPR_LO_ON_HI))
{
memcpy32((int *)dpal+0x80/2, (void *)localPal, 0x40*2/4);
}
if (Pico.m.dirtyPal)
do_pal_update(1, 1);
- if ((rendstatus & PDRAW_SPR_LO_ON_HI) && !(Pico.video.reg[0xC]&8))
+ if ((Pico.est.rendstatus & PDRAW_SPR_LO_ON_HI) && !(Pico.video.reg[0xC]&8))
amips_clut_f = amips_clut_6bit;
else amips_clut_f = amips_clut;
}
CFLAGS = -Wall -ggdb
-TARGETS = amalgamate textfilter
+TARGETS = amalgamate textfilter mkoffsets
OBJS = $(addsuffix .o,$(TARGETS))
all: $(TARGETS)
clean:
$(RM) $(TARGETS) $(OBJS)
+mkoffsets: CFLAGS += -m32 -I..
+
+.PHONY: clean all
--- /dev/null
+#include <stdio.h>
+#include <stddef.h>
+
+#include "../pico/pico_int.h"
+
+#define DUMP(f, field) \
+ fprintf(f, "#define %-20s 0x%02x\n", \
+ "OFS_" #field, \
+ (int)offsetof(struct PicoEState, field))
+
+int main(int argc, char *argv[])
+{
+ char buf[128];
+ FILE *f;
+
+ snprintf(buf, sizeof(buf), "pico/pico_int_o%d.h", sizeof(void *) * 8);
+ f = fopen(buf, "w");
+ if (!f) {
+ perror("fopen");
+ return 1;
+ }
+
+ fprintf(f, "/* autogenerated by %s, do not edit */\n", argv[0]);
+ DUMP(f, DrawScanline);
+ DUMP(f, rendstatus);
+ DUMP(f, Pico_video);
+ DUMP(f, Pico_vram);
+ fclose(f);
+
+ return 0;
+}