X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16%2F16render.c;h=8e6fa43624cd41be40f3b0b7fbd4ffbdb7809f53;hb=c1d3221afb5fe541d8c886ff66198329c153e48e;hp=d5a31e931962144c81aa2fc4fe0c71a24e2a6dd5;hpb=58af36d3092222530057d4ae7e1ea160c30beb5c;p=16.git diff --git a/src/lib/modex16/16render.c b/src/lib/modex16/16render.c index d5a31e93..8e6fa436 100755 --- a/src/lib/modex16/16render.c +++ b/src/lib/modex16/16render.c @@ -1,5 +1,5 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669 + * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 * * This file is part of Project 16. * @@ -31,36 +31,35 @@ //modexDrawBmpRegion (page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp) void modexDrawPBufRegion (page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *p, boolean sprite) { - sword plane; + word plane; int i; - const int px=x;//-page->dx; - const int py=y;//-page->dy; - #define PEEE ((rw)/4)-rx - //-(rx/4) - #define PEEEE ((p->pwidth)*(ry)) - //y=py; - //x=px; + const int px=x+page->dx; + const int py=y+page->dy; + const int prw = rw/4; + int prh; + + //fine tuning + rx+=1; + ry+=1; + + //^^; + #define PEEE rx-prw + #define PE (p->pwidth) + if(rhheight) prh = (PE*(ry-4)); + else if(rh==p->height) prh = (PE*(ry)); + y=py; + x=px; //printf("%d,%d p(%d,%d) r(%d,%d) rwh(%d,%d)\n", x, y, px, py, rx, ry, rw, rh); for(plane=0; plane < 4; plane++) { - i=PEEE+PEEEE; - //printf("PEEE=%d ", PEEE); - //printf("PEEEE=%d ", PEEEE); - //printf("i=%d\n", i); - modexSelectPlane(PLANE(plane+x)); + i=PEEE+prh; + modexSelectPlane(PLANE(plane-1)); for(; y < py+rh; y++) { - //for(px=0; px < p->width; px++) { - //printf("%02X ", (int) p->plane[plane][i++]); -// _fmemcpy(buff, &(p->plane[plane][i+=p->pwidth]), p->pwidth); -// printf("buff %u==%s\n", y, *buff); - _fmemcpy(page->data + (((page->width/4) * y) + (x / 4)), &(p->plane[plane][i+=p->pwidth]), (rw/4)); - //} - //if(plane==3) IN_Ack(); + _fmemcpy(page->data + (((page->width/4) * (y)) + ((x) / 4)), &(p->plane[plane][i]), prw); + i+=PE; } - /*printf("y%d=%d ", plane, y); - if(plane==3) printf("y%d=%d\n", plane, y);*/ x=px; y=py; - } + } } @@ -68,7 +67,9 @@ void modexDrawPBufRegion (page_t *page, int x, int y, int rx, int ry, int rw, in void modexDrawPBuf(page_t *page, int x, int y, planar_buf_t *p, boolean sprite) { - int plane; + modexDrawPBufRegion (page, x, x, 0, 0, p->width, p->height, p, sprite); + /* + sword plane; int i; // byte near *buff; const int px=x+page->dx; @@ -93,20 +94,21 @@ modexDrawPBuf(page_t *page, int x, int y, planar_buf_t *p, boolean sprite) // } for(plane=0; plane < 4; plane++) { i=0; - modexSelectPlane(PLANE(plane+x)); + modexSelectPlane(PLANE(plane-1)); for(; y < py+p->height; y++) { //for(px=0; px < p->width; px++) { //printf("%02X ", (int) p->plane[plane][i++]); -// _fmemcpy(buff, &(p->plane[plane][i+=p->pwidth]), p->pwidth); -// printf("buff %u==%s\n", y, *buff); -// _fmemcpy(page->data + (((page->width/4) * (y+page->dy)) + ((x+page->dx) / 4)), buff, p->pwidth); +// _fmemcpy(buff, &(p->plane[plane][i+=p->pwidth]), p->pwidth); +// printf("buff %u==%s\n", y, *buff); +// _fmemcpy(page->data + (((page->width/4) * (y+page->dy)) + ((x+page->dx) / 4)), buff, p->pwidth); _fmemcpy(page->data + (((page->width/4) * y) + (x / 4)), &(p->plane[plane][i+=p->pwidth]), p->pwidth); //} } +//getch(); x=px; y=py; } -// _nfree(buff); +// _nfree(buff);*/ } void @@ -287,7 +289,7 @@ void modexDrawBmpPBufRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *bmp) { word poffset = (word) page->data + y*(page->width/4) + x/4; - byte *data = *bmp->plane[0];//+bmp->offset; + byte *data = bmp->plane[0]; word bmpOffset = (word) data + ry * bmp->width + rx; word width = rw; word height = rh; @@ -365,7 +367,7 @@ void modexDrawSpritePBufRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *bmp) { word poffset = (word)page->data + y*(page->width/4) + x/4; - byte *data = *bmp->plane[0];//+bmp->offset; + byte *data = bmp->plane[0]; word bmpOffset = (word) data + ry * bmp->width + rx; word width = rw; word height = rh; @@ -432,3 +434,39 @@ modexDrawSpritePBufRegion(page_t *page, int x, int y, JNZ PLANE_LOOP ; do all 4 planes } } + +void modexDrawCharPBuf(page_t *page, int x/*for planar selection only*/, int y/*redundant, remove*/, word t, word col, word bgcol, word addr) +{ + /* 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; + } + } +}