X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_vl.c;h=7e67b01293432e91b9166b430996522576c12711;hb=c99bda70e2b46d085d3ba7aa951117bcd737c208;hp=32b8fd8ff161f3c1d0f45a290013cae58e9cf9bf;hpb=16cb74317c1591986b9d856beb4c70ce875db179;p=16.git diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 32b8fd8f..7e67b012 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -409,20 +409,21 @@ modexSelectPlane(byte plane) { } void -modexClearRegion(page_t *page, int x, int y, int w, int h, byte color) { +modexClearRegion(page_t *page, int x, int y, int w, int h, byte color) +{ word pageOff = (word) page->data; - word xoff=x/4; /* xoffset that begins each row */ - word scanCount=w/4; /* number of iterations per row (excluding right clip)*/ - word poffset = pageOff + y*(page->stridew) + xoff; /* starting offset */ - word nextRow = page->stridew-scanCount-1; /* loc of next row */ - byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */ + word xoff=(x>>2); // xoffset that begins each row + word poffset = pageOff + y*(page->stridew) + xoff; // starting offset + word scanCount=w>>2; // number of iterations per row (excluding right clip) + word nextRow = page->stridew-scanCount-1; // loc of next row + byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; // clips for rectangles not on 4s byte rclip[] = {0x00, 0x01, 0x03, 0x07}; byte left = lclip[x&0x03]; byte right = rclip[(x+w)&0x03]; - /* handle the case which requires an extra group */ + // handle the case which requires an extra group if((x & 0x03) && !((x+w) & 0x03)) { - right=0x0f; + right=0x0f; } //printf("modexClearRegion(x=%u, y=%u, w=%u, h=%u, left=%u, right=%u)\n", x, y, w, h, left, right); @@ -492,17 +493,17 @@ modexCopyPageRegion(page_t *dest, page_t *src, word dx, word dy, word width, word height) { - word doffset = (word)dest->data + dy*(dest->stridew) + dx/4; - word soffset = (word)src->data + sy*(src->stridew) + sx/4; - word scans = vga_state.vga_stride; //++++0000 the quick and dirty fix of the major issue with p16 video display wwww + word doffset = (word)dest->data + dy*(dest->stridew) + (dx>>2); + word soffset = (word)src->data + sy*(src->stridew) + (sx>>2); + word scans = vga_state.vga_stride+8; //++++0000 the quick and dirty fix of the major issue with p16 video display wwww word nextSrcRow = src->stridew - scans - 1; word nextDestRow = dest->stridew - scans - 1; - byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; /* clips for rectangles not on 4s */ + byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08}; // clips for rectangles not on 4s byte rclip[] = {0x00, 0x01, 0x03, 0x07}; byte left = lclip[sx&0x03]; byte right = rclip[(sx+width)&0x03]; - /* handle the case which requires an extra group */ + // handle the case which requires an extra group if((sx & 0x03) && !((sx+width) & 0x03)) { right=0x0f; } @@ -644,41 +645,39 @@ modexPalSave(byte *palette) { } -byte * +/*byte * modexNewPal() { byte *ptr; - ptr = malloc(PAL_SIZE); + ptr = m a l l o c(PAL_SIZE); - /* handle errors */ + // handle errors if(!ptr) { printf("Could not allocate palette.\n"); } return ptr; -} +}*/ void -modexLoadPalFile(byte *filename, byte **palette) { +modexLoadPalFile(byte *filename, byte *palette) { FILE *file; byte *ptr; - /* free the palette if it exists */ - if(*palette) { - free(*palette); - } + // free the palette if it exists + //if(*palette) { free(*palette); } - /* allocate the new palette */ - *palette = modexNewPal(); + // allocate the new palette + //*palette = modexNewPal(); - /* open the file */ + // open the file file = fopen(filename, "rb"); if(!file) { - printf("Could not open palette file: %s\n", filename); + printf("Could not open palette file: %s\n", filename); } /* read the file */ - ptr = *palette; + ptr = palette; while(!feof(file)) { *ptr++ = fgetc(file); } @@ -689,18 +688,7 @@ modexLoadPalFile(byte *filename, byte **palette) { void VL_LoadPalFile(const char *filename, byte *palette) { - int fd; - - fd = open(filename,O_RDONLY|O_BINARY); - if (fd >= 0) { - word i; - - read(fd,palette, PAL_SIZE); - close(fd); - - vga_palette_lseek(0); - for (i=0;i < 256;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); - } + VL_LoadPalFilewithoffset(filename, palette, 0); } void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o) @@ -709,16 +697,19 @@ void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o) fd = open(filename,O_RDONLY|O_BINARY); if (fd >= 0) { - word i; - read(fd,palette, PAL_SIZE); close(fd); - vga_palette_lseek(o); - for (i=o;i < 256-o;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); + VL_UpdatePaletteWrite(palette, o); } } +void VL_UpdatePaletteWrite(byte *palette, word o) +{ + word i; + vga_palette_lseek(/*1+*/o); + for (i=o;i < 256-o;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); +} void modexSavePalFile(char *filename, byte *pal) { @@ -867,18 +858,18 @@ void modexDrawChar(page_t *page, int x/*for planar selection only*/, word t, wor } } -void modexprint(page_t *page, sword x, sword y, word t, word col, word bgcol, const byte *str) +void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col, word bgcol, const byte *str) { word s, o, w; - sword x_draw; + word x_draw; //word addr = (word) romFontsData.l; word addrq; word addrr; byte c; - x-=page->tlx; y-=page->tly; + if(tlsw){ x-=page->tlx; y-=page->tly; } x_draw = x/4; - addrq = (page->stridew) * y + (x_draw) + + addrq = (page->stridew) * y + (word)(x_draw) + ((word)page->data); addrr = addrq; s=romFonts[t].seg; @@ -907,7 +898,7 @@ void modexprint(page_t *page, sword x, sword y, word t, word col, word bgcol, co x_draw += 8; /* track X for edge of screen */ addrr += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */ } - printf("print xy:%dx%d tlxy:%dx%d\n", x, y, page->tlx, page->tly); + //printf("print xy:%dx%d tlxy:%dx%d\n", x, y, page->tlx, page->tly); } void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str) @@ -1010,8 +1001,8 @@ void modexpdump(page_t *pee) int palq=(mult)*TILEWH; int palcol=0; int palx, paly; - for(paly=0; paly