- int nametab; // Position in VRAM of name table (for this tile line)
- int line; // Line number in pixels 0x000-0x3ff within the virtual tilemap
- int hscroll; // Horizontal scroll value in pixels for the line
- int xmask; // X-Mask (0x1f - 0x7f) for horizontal wraparound in the tilemap
- int *hc; // cache for high tile codes and their positions
- int cells; // cells (tiles) to draw (32 col mode doesn't need to update whole 320)
-};
-
-static void DrawStrip(struct TileStrip *ts, int cellskip)
+ struct PicoVideo *pv = &Pico.video;
+ unsigned int sprites_addr[8];
+ unsigned int sprites_x[8];
+ unsigned char *sat;
+ int xoff = 8; // relative to HighCol, which is (screen - 8)
+ int sprite_base, addr_mask;
+ int i, s, h;
+
+ if (pv->reg[0] & 8)
+ xoff = 0;
+
+ sat = (unsigned char *)Pico.vram + ((pv->reg[5] & 0x7e) << 7);
+ if (pv->reg[1] & 2) {
+ addr_mask = 0xfe; h = 16;
+ } else {
+ addr_mask = 0xff; h = 8;
+ }
+ sprite_base = (pv->reg[6] & 4) << (13-2-1);
+
+ for (i = s = 0; i < 64 && s < 8; i++)
+ {
+ int y;
+ y = sat[i] + 1;
+ if (y == 0xd1)
+ break;
+ if (y + h <= scanline || scanline < y)
+ continue; // not on this line
+
+ sprites_x[s] = xoff + sat[0x80 + i*2];
+ sprites_addr[s] = sprite_base + ((sat[0x80 + i*2 + 1] & addr_mask) << (5-1)) +
+ ((scanline - y) << (2-1));
+ s++;
+ }
+
+ // now draw all sprites backwards
+ for (--s; s >= 0; s--)
+ TileNormM4(sprites_x[s], sprites_addr[s], 0x10);
+}
+
+// tilex_ty_prio merged to reduce register pressure
+static void draw_strip(const unsigned short *nametab, int dx, int cells, int tilex_ty_prio)