JNZ L1\r
}\r
//TODO: OPTIMIZE THIS!!!!\r
- modexDrawCharPBuf(page, x, y, t, col, bgcol, addrq);\r
+ modexDrawCharPBuf(page, x/*for mode X planar use*/, y/*redunant, remove*/, t, col, bgcol, addrq);\r
+ addrq += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */\r
\r
//if(!q) getch();\r
}\r
/* -========================== Types & Macros ==========================- */
#define PAGE_OFFSET(x,y) (((y)<<6)+((y)<<4)+((x)>>2))
-#define PLANE(x) (1<< (x&3))
+#define PLANE(x) (1 << ((x) & 3))
#define SELECT_ALL_PLANES() outpw(0x03c4, 0xff02)
#define PALSIZE 768
void modexchkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/);
void modexputPixel(page_t *page, int x, int y, byte color);
byte modexgetPixel(page_t *page, int x, int y);
+
+#if 0 // not needed anymore. maybe good for reference purposes though.
static inline void modexwritepixel(page_t *page, int x, int y, word addr, byte color)
{
/* Each address accesses four neighboring pixels, so set
outpw(GC_INDEX+1, x & 3);
return vga_state.vga_graphics_ram[addr];
}
+#endif
+
void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str);
void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str);
void modexpdump(page_t *pee);
}\r
}\r
\r
-void modexDrawCharPBuf(page_t *page, int x, int y, word t, word col, word bgcol, word addr)\r
+void modexDrawCharPBuf(page_t *page, int x/*for planar selection only*/, int y/*redundant, remove*/, word t, word col, word bgcol, word addr)\r
{\r
- word i, j, k;\r
- for(i=0; i<romFonts[t].charSize; i++)\r
- {\r
- j=1<<8;\r
- k=0;\r
- //every "pixel" row\r
- while(j)\r
- {\r
-// if(q)\r
- //_fmemcpy(page->data + (((page->width/4) * (y+i)) + ((x+romFontsData.chw+k) / 4)), romFontsData.l[i] & j ? col:bgcol, 2);\r
- modexwritepixel(page, x+k+romFontsData.chw, y+i, addr, romFontsData.l[i] & j ? col:bgcol);\r
-// else\r
- //printf("l[i]=%c j=%02u l[i] & j=%02u %c\n", l[i] , j, l[i] & j, l[i] & j ? '*':' ');\r
- //printf("%c", l[i] & j ? '*':' ');\r
-// romFontsData.z[k]=romFontsData.l[i] & j ? '*':' ';\r
- j>>=1;\r
- k++;\r
+ /* vertical drawing routine by joncampbell123.\r
+ *\r
+ * optimize for VGA mode X planar memory to minimize the number of times we do I/O write to map mask register.\r
+ * so, we enumerate over columns (not rows!) to draw every 4th pixel. bit masks are used because of the font bitmap.\r
+ * \r
+ * NTS: addr defines what VGA memory address we use, "x" is redundant except to specify which of the 4 pixels we select in the map mask register. */\r
+ word drawaddr;\r
+ word colm, row;\r
+ byte fontbyte;\r
+ byte plane;\r
+ byte m1,m2;\r
+\r
+ plane = x & 3;\r
+ m1 = 0x80; // left half\r
+ m2 = 0x08; // right half\r
+ for (colm=0;colm < 4;colm++) {\r
+ drawaddr = addr;\r
+ modexSelectPlane(PLANE(plane));\r
+ for (row=0;row < 8;row++) {\r
+ fontbyte = romFontsData.l[row];\r
+ vga_state.vga_graphics_ram[drawaddr ] = (fontbyte & m1) ? col : bgcol;\r
+ vga_state.vga_graphics_ram[drawaddr+1] = (fontbyte & m2) ? col : bgcol;\r
+ drawaddr += page->width >> 2;\r
+ }\r
+\r
+ m1 >>= 1;\r
+ m2 >>= 1;\r
+ if ((++plane) == 4) {\r
+ addr++;\r
+ plane = 0;\r
}\r
-// if(!q)\r
-// {\r
-// for(k=0;k<9;k++)\r
-// {\r
-// printf("%c", romFontsData.z[k]);\r
-// }\r
-// printf("\n");\r
-// }\r
}\r
- romFontsData.chw += k;\r
}\r