From: Jonathan Campbell Date: Sun, 17 Apr 2016 05:29:15 +0000 (-0700) Subject: let's show Sparky4 what I mean by vertical column font rendering. X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=c1d3221afb5fe541d8c886ff66198329c153e48e;p=16.git let's show Sparky4 what I mean by vertical column font rendering. this code should demonstrate what I mean about minimizing our writes to the map mask register and using arithmetic to step from byte to byte. at least in DOSBox-X, the characters appear much faster now. --- diff --git a/pcx2vrl b/pcx2vrl index 3d9ac6e6..06179c75 100755 Binary files a/pcx2vrl and b/pcx2vrl differ diff --git a/pcxsscut b/pcxsscut index d743ac3b..2ce56d28 100755 Binary files a/pcxsscut and b/pcxsscut differ diff --git a/src/lib/modex16.c b/src/lib/modex16.c index 4e7004e1..bada2e67 100755 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -914,7 +914,8 @@ void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, cons JNZ L1 } //TODO: OPTIMIZE THIS!!!! - modexDrawCharPBuf(page, x, y, t, col, bgcol, addrq); + modexDrawCharPBuf(page, x/*for mode X planar use*/, y/*redunant, remove*/, t, col, bgcol, addrq); + addrq += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */ //if(!q) getch(); } diff --git a/src/lib/modex16.h b/src/lib/modex16.h index c1c45252..f85eb055 100755 --- a/src/lib/modex16.h +++ b/src/lib/modex16.h @@ -71,7 +71,7 @@ static struct pcxHeader { /* -========================== 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 @@ -149,6 +149,8 @@ void modexPalOverscan(byte *p, word col); 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 @@ -172,6 +174,8 @@ static inline byte modexreadPixel(page_t *page, int x, int y, word addr) 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); diff --git a/src/lib/modex16/16render.c b/src/lib/modex16/16render.c index fe78022d..8e6fa436 100755 --- a/src/lib/modex16/16render.c +++ b/src/lib/modex16/16render.c @@ -435,34 +435,38 @@ modexDrawSpritePBufRegion(page_t *page, int x, int y, } } -void modexDrawCharPBuf(page_t *page, int x, int y, word t, word col, word bgcol, word addr) +void modexDrawCharPBuf(page_t *page, int x/*for planar selection only*/, int y/*redundant, remove*/, word t, word col, word bgcol, word addr) { - word i, j, k; - for(i=0; idata + (((page->width/4) * (y+i)) + ((x+romFontsData.chw+k) / 4)), romFontsData.l[i] & j ? col:bgcol, 2); - modexwritepixel(page, x+k+romFontsData.chw, y+i, addr, romFontsData.l[i] & j ? col:bgcol); -// else - //printf("l[i]=%c j=%02u l[i] & j=%02u %c\n", l[i] , j, l[i] & j, l[i] & j ? '*':' '); - //printf("%c", l[i] & j ? '*':' '); -// romFontsData.z[k]=romFontsData.l[i] & j ? '*':' '; - j>>=1; - k++; + /* vertical drawing routine by joncampbell123. + * + * optimize for VGA mode X planar memory to minimize the number of times we do I/O write to map mask register. + * so, we enumerate over columns (not rows!) to draw every 4th pixel. bit masks are used because of the font bitmap. + * + * 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. */ + word drawaddr; + word colm, row; + byte fontbyte; + byte plane; + byte m1,m2; + + plane = x & 3; + m1 = 0x80; // left half + m2 = 0x08; // right half + for (colm=0;colm < 4;colm++) { + drawaddr = addr; + modexSelectPlane(PLANE(plane)); + for (row=0;row < 8;row++) { + fontbyte = romFontsData.l[row]; + vga_state.vga_graphics_ram[drawaddr ] = (fontbyte & m1) ? col : bgcol; + vga_state.vga_graphics_ram[drawaddr+1] = (fontbyte & m2) ? col : bgcol; + drawaddr += page->width >> 2; + } + + m1 >>= 1; + m2 >>= 1; + if ((++plane) == 4) { + addr++; + plane = 0; } -// if(!q) -// { -// for(k=0;k<9;k++) -// { -// printf("%c", romFontsData.z[k]); -// } -// printf("\n"); -// } } - romFontsData.chw += k; } diff --git a/vrl2vrs b/vrl2vrs index acdd4bda..cee2d1d5 100755 Binary files a/vrl2vrs and b/vrl2vrs differ diff --git a/vrsdump b/vrsdump index 8ba0497d..a75a903a 100755 Binary files a/vrsdump and b/vrsdump differ