\r
//unsigned short ppt[] = { 0x0f11, 0x0ff1, 0x01f1, 0x011f, 0x01ff, 0x0f1f, 0x0f0e, 0x0e7c };\r
\r
\r
//unsigned short ppt[] = { 0x0f11, 0x0ff1, 0x01f1, 0x011f, 0x01ff, 0x0f1f, 0x0f0e, 0x0e7c };\r
\r
-static void (*DrawAllSpritesLoPri)(int *hcache, int maxwidth, int prio, int sh) = NULL;\r
-static void (*DrawAllSpritesHiPri)(int *hcache, int maxwidth, int prio, int sh) = NULL;\r
+static void (*DrawAllSpritesLoPri)(int *hcache, int prio, int sh) = NULL;\r
+static void (*DrawAllSpritesHiPri)(int *hcache, int prio, int sh) = NULL;\r
\r
struct TileStrip\r
{\r
\r
struct TileStrip\r
{\r
void BackFill(int reg7, int sh);\r
void DrawSprite(int *sprite, int sh, int as);\r
void DrawTilesFromCache(int *hc, int sh, int rlim);\r
void BackFill(int reg7, int sh);\r
void DrawSprite(int *sprite, int sh, int as);\r
void DrawTilesFromCache(int *hc, int sh, int rlim);\r
-void DrawSpritesFromCache(int *hc, int maxwidth, int prio, int sh);\r
+void DrawSpritesFromCache(int *hc, int prio, int sh);\r
void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);\r
void FinalizeLineBGR444(int sh);\r
void FinalizeLineRGB555(int sh);\r
void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);\r
void FinalizeLineBGR444(int sh);\r
void FinalizeLineRGB555(int sh);\r
switch (rlim-dx+8)\r
{\r
case 7: t=pack&0x00f00000; if (t) pd[6]=(unsigned char)(pal|(t>>20));\r
switch (rlim-dx+8)\r
{\r
case 7: t=pack&0x00f00000; if (t) pd[6]=(unsigned char)(pal|(t>>20));\r
- case 6: t=pack&0x0f000000; if (t) pd[5]=(unsigned char)(pal|(t>>24));\r
- case 5: t=pack&0xf0000000; if (t) pd[4]=(unsigned char)(pal|(t>>28));\r
- case 4: t=pack&0x0000000f; if (t) pd[3]=(unsigned char)(pal|(t ));\r
- case 3: t=pack&0x000000f0; if (t) pd[2]=(unsigned char)(pal|(t>> 4));\r
- case 2: t=pack&0x00000f00; if (t) pd[1]=(unsigned char)(pal|(t>> 8));\r
- case 1: t=pack&0x0000f000; if (t) pd[0]=(unsigned char)(pal|(t>>12));\r
- default: break;\r
+ case 6: t=pack&0x0f000000; if (t) pd[5]=(unsigned char)(pal|(t>>24));\r
+ case 5: t=pack&0xf0000000; if (t) pd[4]=(unsigned char)(pal|(t>>28));\r
+ case 4: t=pack&0x0000000f; if (t) pd[3]=(unsigned char)(pal|(t ));\r
+ case 3: t=pack&0x000000f0; if (t) pd[2]=(unsigned char)(pal|(t>> 4));\r
+ case 2: t=pack&0x00000f00; if (t) pd[1]=(unsigned char)(pal|(t>> 8));\r
+ case 1: t=pack&0x0000f000; if (t) pd[0]=(unsigned char)(pal|(t>>12));\r
+ default: break;\r
-static void DrawAllSpritesInterlace(int *hcache, int maxwidth, int pri, int sh)\r
+static void DrawAllSpritesInterlace(int *hcache, int pri, int sh)\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
int i,u,table,link=0,sline=DrawScanline<<1;\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
int i,u,table,link=0,sline=DrawScanline<<1;\r
// check if sprite is not hidden offscreen\r
sx = (sx>>16)&0x1ff;\r
sx -= 0x78; // Get X coordinate + 8\r
// check if sprite is not hidden offscreen\r
sx = (sx>>16)&0x1ff;\r
sx -= 0x78; // Get X coordinate + 8\r
- if(sx <= -8*3 || sx >= maxwidth) goto nextsprite;\r
+ if(sx <= -8*3 || sx >= 328) goto nextsprite;\r
\r
// sprite is good, save it's pointer\r
sprites[i++]=sprite;\r
\r
// sprite is good, save it's pointer\r
sprites[i++]=sprite;\r
\r
\r
#ifndef _ASM_DRAW_C\r
\r
\r
#ifndef _ASM_DRAW_C\r
-static void DrawSpritesFromCache(int *hc, int maxwidth, int prio, int sh)\r
+static void DrawSpritesFromCache(int *hc, int prio, int sh)\r
{\r
int code, tile, sx, delta, width;\r
int pal;\r
{\r
int code, tile, sx, delta, width;\r
int pal;\r
-static void DrawSpritesFromCacheAS(int *hc, int maxwidth, int prio, int sh)\r
+static void DrawSpritesFromCacheAS(int *hc, int prio, int sh)\r
{\r
int code, tile, sx, delta, width;\r
int pal, *hce, *hco;\r
{\r
int code, tile, sx, delta, width;\r
int pal, *hce, *hco;\r
int u,link=0;\r
int table=0;\r
int *pd = HighPreSpr;\r
int u,link=0;\r
int table=0;\r
int *pd = HighPreSpr;\r
- int max_lines = 224, max_sprites = 80;\r
+ int max_lines = 224, max_sprites = 80, max_width = 328;\r
int max_line_sprites = 20; // 20 sprites, 40 tiles\r
\r
if (!(Pico.video.reg[12]&1))\r
int max_line_sprites = 20; // 20 sprites, 40 tiles\r
\r
if (!(Pico.video.reg[12]&1))\r
- max_sprites = 64, max_line_sprites = 16;\r
+ max_sprites = 64, max_line_sprites = 16, max_width = 264;\r
if (PicoOpt & POPT_DIS_SPRITE_LIM)\r
max_line_sprites = MAX_LINE_SPRITES;\r
\r
if (PicoOpt & POPT_DIS_SPRITE_LIM)\r
max_line_sprites = MAX_LINE_SPRITES;\r
\r
sx = (code2>>16)&0x1ff;\r
sx -= 0x78; // Get X coordinate + 8\r
sy = (pack << 16) >> 16;\r
sx = (code2>>16)&0x1ff;\r
sx -= 0x78; // Get X coordinate + 8\r
sy = (pack << 16) >> 16;\r
+ height = (pack >> 24) & 0xf;\r
\r
if (sy < max_lines && sy + (height<<3) > DrawScanline && // sprite onscreen (y)?\r
\r
if (sy < max_lines && sy + (height<<3) > DrawScanline && // sprite onscreen (y)?\r
- (sx > -24 || sx < 328)) // onscreen x\r
+ (sx > -24 || sx < max_width)) // onscreen x\r
{\r
int y = (sy >= DrawScanline) ? sy : DrawScanline;\r
{\r
int y = (sy >= DrawScanline) ? sy : DrawScanline;\r
+ int offs = (pd - HighPreSpr) / 2;\r
for (; y < sy + (height<<3) && y < max_lines; y++)\r
{\r
for (; y < sy + (height<<3) && y < max_lines; y++)\r
{\r
cnt = HighLnSpr[y][0] & 0x7f;\r
if (cnt >= max_line_sprites) continue; // sprite limit?\r
cnt = HighLnSpr[y][0] & 0x7f;\r
if (cnt >= max_line_sprites) continue; // sprite limit?\r
- offs = (pd - HighPreSpr) / 2;\r
\r
for (i = 0; i < cnt; i++)\r
if (HighLnSpr[y][2+i] == offs) goto found;\r
\r
for (i = 0; i < cnt; i++)\r
if (HighLnSpr[y][2+i] == offs) goto found;\r
{\r
unsigned int *sprite;\r
int code, code2, sx, sy, hv, height, width;\r
{\r
unsigned int *sprite;\r
int code, code2, sx, sy, hv, height, width;\r
- int sx_min, offscr_x;\r
\r
sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
\r
\r
sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
\r
sx -= 0x78; // Get X coordinate + 8\r
sx_min = 8-(width<<3);\r
\r
sx -= 0x78; // Get X coordinate + 8\r
sx_min = 8-(width<<3);\r
\r
- offscr_x = (sx <= sx_min) || sx >= 328;\r
-\r
if (sy < max_lines && sy + (height<<3) > DrawScanline) // sprite onscreen (y)?\r
{\r
int y = (sy >= DrawScanline) ? sy : DrawScanline;\r
if (sy < max_lines && sy + (height<<3) > DrawScanline) // sprite onscreen (y)?\r
{\r
int y = (sy >= DrawScanline) ? sy : DrawScanline;\r
int cnt = HighLnSpr[y][0];\r
if (cnt >= max_line_sprites) continue; // sprite limit?\r
\r
int cnt = HighLnSpr[y][0];\r
if (cnt >= max_line_sprites) continue; // sprite limit?\r
\r
- if (HighLnSpr[y][1] >= max_line_sprites*2) { // tile limit?\r
+ if (HighLnSpr[y][1] >= max_line_sprites*2) { // tile limit?\r
HighLnSpr[y][0] |= 0x80;\r
HighLnSpr[y][0] |= 0x80;\r
}\r
HighLnSpr[y][1] += width;\r
\r
if (sx == -0x78) {\r
if (cnt > 0)\r
HighLnSpr[y][0] |= 0x80; // masked, no more sprites for this line\r
}\r
HighLnSpr[y][1] += width;\r
\r
if (sx == -0x78) {\r
if (cnt > 0)\r
HighLnSpr[y][0] |= 0x80; // masked, no more sprites for this line\r
}\r
// must keep the first sprite even if it's offscreen, for masking\r
}\r
// must keep the first sprite even if it's offscreen, for masking\r
- if (cnt > 0 && (sx <= sx_min || sx >= 328)) continue; // offscreen x\r
+ if (cnt > 0 && (sx <= sx_min || sx >= max_width)) continue; // offscreen x\r
\r
HighLnSpr[y][2+cnt] = ((pd - HighPreSpr) / 2); // | prio;\r
HighLnSpr[y][0] = cnt + 1;\r
\r
HighLnSpr[y][2+cnt] = ((pd - HighPreSpr) / 2); // | prio;\r
HighLnSpr[y][0] = cnt + 1;\r
-static void DrawAllSprites(int *hcache, int maxwidth, int prio, int sh)\r
+static void DrawAllSprites(int *hcache, int prio, int sh)\r
{\r
int rs = rendstatus, scan = DrawScanline;\r
unsigned char *p;\r
{\r
int rs = rendstatus, scan = DrawScanline;\r
unsigned char *p;\r
DrawWindow( (win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh|as);\r
} else\r
DrawLayer(0|((sh|as)<<1), HighCacheA, 0, maxcells);\r
DrawWindow( (win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh|as);\r
} else\r
DrawLayer(0|((sh|as)<<1), HighCacheA, 0, maxcells);\r
- DrawAllSpritesLoPri(HighCacheS, maxw, 0, sh);\r
+ DrawAllSpritesLoPri(HighCacheS, 0, sh);\r
- if (HighCacheB[0]) DrawTilesFromCache(HighCacheB, sh, 328);\r
+ if (HighCacheB[0]) DrawTilesFromCache(HighCacheB, sh, maxw);\r
if (hvwind == 1)\r
DrawWindow(0, maxcells>>1, 1, sh);\r
else if (hvwind == 2) {\r
if (hvwind == 1)\r
DrawWindow(0, maxcells>>1, 1, sh);\r
else if (hvwind == 2) {\r
- if(HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh, (win&0x80) ? edge<<4 : 328);\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
} else\r
DrawWindow((win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 1, sh);\r
} else\r
- if (HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh, 328);\r
- if (HighCacheS[0]) DrawAllSpritesHiPri(HighCacheS, maxw, 1, sh);\r
+ if (HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh, maxw);\r
+ if (HighCacheS[0]) DrawAllSpritesHiPri(HighCacheS, 1, sh);\r
+// TODO: rm from asm too\r
int idle_hit_counter = 0;\r
\r
void PicoFrame(void)\r
int idle_hit_counter = 0;\r
\r
void PicoFrame(void)\r
void vidConvCpyRGB565(void *to, void *from, int pixels);\r
#endif\r
// internals\r
void vidConvCpyRGB565(void *to, void *from, int pixels);\r
#endif\r
// internals\r
-#define PDRAW_SPRITES_MOVED (1<<0)\r
+#define PDRAW_SPRITES_MOVED (1<<0) // (asm)\r
#define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority\r
#define PDRAW_ACC_SPRITES (1<<2) // accurate sprites (copied from PicoOpt)\r
#define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority\r
#define PDRAW_ACC_SPRITES (1<<2) // accurate sprites (copied from PicoOpt)\r
-#define PDRAW_INTERLACE (1<<3) //\r
-#define PDRAW_DIRTY_SPRITES (1<<4)\r
+#define PDRAW_INTERLACE (1<<3)\r
+#define PDRAW_DIRTY_SPRITES (1<<4) // (asm)\r
#define PDRAW_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer\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_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer\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
- // V-int line (224 or 240)
- Pico.m.scanline = y;
- pv->v_counter = 0xe0; // bad for 240 mode
- if ((pv->reg[12]&6) == 6) pv->v_counter = 0xc1;
-
if (!skip)
{
if (DrawScanline < y)
if (!skip)
{
if (DrawScanline < y)
+ // V-int line (224 or 240)
+ Pico.m.scanline = y;
+ pv->v_counter = 0xe0; // bad for 240 mode
+ if ((pv->reg[12]&6) == 6) pv->v_counter = 0xc1;
+
// VDP FIFO
pv->lwrite_cnt=0;
Pico.video.status|=0x200;
// VDP FIFO
pv->lwrite_cnt=0;
Pico.video.status|=0x200;
{\r
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
{\r
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
- rendstatus |= PDRAW_DIRTY_SPRITES; break;\r
+ if (a - ((unsigned)(Pico.video.reg[5]&0x7f) << 9) < 0x400)\r
+ 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
case 5: Pico.vsram[(a>>1)&0x003f]=d; break;\r
case 3: Pico.m.dirtyPal = 1;\r
Pico.cram [(a>>1)&0x003f]=d; break; // wraps (Desert Strike)\r
case 5: Pico.vsram[(a>>1)&0x003f]=d; break;\r
{\r
unsigned int d;\r
int lineCycles;\r
{\r
unsigned int d;\r
int lineCycles;\r
lineCycles = (488-SekCyclesLeft)&0x1ff;\r
if (Pico.video.reg[12]&1)\r
d = hcounts_40[lineCycles];\r
lineCycles = (488-SekCyclesLeft)&0x1ff;\r
if (Pico.video.reg[12]&1)\r
d = hcounts_40[lineCycles];\r