+ unsigned char *pmd = HighCol + 8;
+ unsigned short *dram, *p32x;
+ unsigned char mdbg;
+
+ FinalizeLine555(sh, line);
+
+ if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 0 || // 32x blanking
+ // XXX: how is 32col mode hadled by real hardware?
+ !(Pico.video.reg[12] & 1) || // 32col mode
+ !(PicoDrawMask & PDRAW_32X_ON))
+ {
+ return;
+ }
+
+ dram = (void *)Pico32xMem->dram[Pico32x.vdp_regs[0x0a/2] & P32XV_FS];
+ p32x = dram + dram[line];
+ mdbg = Pico.video.reg[7] & 0x3f;
+
+ if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 2) { // Direct Color Mode
+ int inv_bit = (Pico32x.vdp_regs[0] & P32XV_PRI) ? 0x8000 : 0;
+ do_line_dc(pd, p32x, pmd, inv_bit,);
+ return;
+ }
+
+ if (Pico32x.dirty_pal)
+ convert_pal555(Pico32x.vdp_regs[0] & P32XV_PRI);
+
+ if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 1) { // Packed Pixel Mode
+ unsigned char *p32xb = (void *)p32x;
+ if (Pico32x.vdp_regs[2 / 2] & P32XV_SFT)
+ p32xb++;
+ do_line_pp(pd, p32xb, pmd,);
+ }
+ else { // Run Length Mode
+ do_line_rl(pd, p32x, pmd,);
+ }
+}
+
+#define MD_LAYER_CODE \
+ *dst = palmd[*pmd]
+
+#define PICOSCAN_PRE \
+ PicoScan32xBegin(l + (lines_sft_offs & 0xff)); \
+ dst = DrawLineDest; \
+
+#define PICOSCAN_POST \
+ PicoScan32xEnd(l + (lines_sft_offs & 0xff)); \
+
+#define make_do_loop(name, pre_code, post_code, md_code) \
+/* Direct Color Mode */ \
+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 + \
+ 328 * (lines_sft_offs & 0xff) + 8; \
+ unsigned short *palmd = HighPal; \
+ unsigned short *p32x; \
+ int lines = lines_sft_offs >> 16; \
+ int l; \
+ (void)palmd; \
+ for (l = 0; l < lines; l++, pmd += 8) { \
+ pre_code; \
+ p32x = dram + dram[l]; \
+ do_line_dc(dst, p32x, pmd, inv_bit, md_code); \
+ post_code; \
+ } \
+} \
+ \
+/* Packed Pixel Mode */ \
+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 + \
+ 328 * (lines_sft_offs & 0xff) + 8; \
+ unsigned short *palmd = HighPal; \
+ unsigned char *p32x; \
+ int lines = lines_sft_offs >> 16; \
+ int l; \
+ (void)palmd; \
+ for (l = 0; l < lines; l++, pmd += 8) { \
+ pre_code; \
+ p32x = (void *)(dram + dram[l]); \
+ p32x += (lines_sft_offs >> 8) & 1; \
+ do_line_pp(dst, p32x, pmd, md_code); \
+ post_code; \
+ } \
+} \
+ \
+/* Run Length Mode */ \
+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 + \
+ 328 * (lines_sft_offs & 0xff) + 8; \
+ unsigned short *palmd = HighPal; \
+ unsigned short *p32x; \
+ int lines = lines_sft_offs >> 16; \
+ int l; \
+ (void)palmd; \
+ for (l = 0; l < lines; l++, pmd += 8) { \
+ pre_code; \
+ p32x = dram + dram[l]; \
+ do_line_rl(dst, p32x, pmd, md_code); \
+ post_code; \
+ } \
+}
+
+#ifdef _ASM_32X_DRAW
+#undef make_do_loop
+#define make_do_loop(name, pre_code, post_code, md_code) \
+extern void do_loop_dc##name(unsigned short *dst, \
+ unsigned short *dram, int lines_offs, int mdbg); \
+extern void do_loop_pp##name(unsigned short *dst, \
+ unsigned short *dram, int lines_offs, int mdbg); \
+extern void do_loop_rl##name(unsigned short *dst, \
+ unsigned short *dram, int lines_offs, int mdbg);
+#endif