X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16.c;h=45ad93c933325f16a4c2685543c330f0a0b1f799;hb=f552f51c74cb11b9e17c8a644ad1ed86528cae43;hp=b1e6d51f79ef370366d443ed08c7330a6a048226;hpb=2170cf972950dffecd075a65d1f8d9a49eb82ce9;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c old mode 100644 new mode 100755 index b1e6d51f..45ad93c9 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -29,14 +29,14 @@ byte far* VGA=(byte far*) 0xA0000000; /* this points to video memory. */ static void fadePalette(sbyte fade, sbyte start, word iter, byte *palette); static byte tmppal[PAL_SIZE]; -int old_mode; +//int old_mode; ///////////////////////////////////////////////////////////////////////////// // // // setvideo() - This function Manages the video modes // // // ///////////////////////////////////////////////////////////////////////////// -void VGAmodeX(sword vq) +void VGAmodeX(sword vq, global_game_variables_t *gv) { union REGS in, out; @@ -45,7 +45,7 @@ void VGAmodeX(sword vq) // change to the video mode we were in before we switched to mode 13h modexLeave(); in.h.ah = 0x00; - in.h.al = old_mode; + in.h.al = gv->old_mode; int86(0x10, &in, &out); } @@ -54,7 +54,7 @@ void VGAmodeX(sword vq) // get old video mode in.h.ah = 0xf; int86(0x10, &in, &out); - old_mode = out.h.al; + gv->old_mode = out.h.al; // enter mode modexEnter(); } @@ -151,19 +151,19 @@ page_t modexNextPage(page_t *p) { page_t result; - result.data = p->data + (p->width/4)*p->height; /* compute the offset */ + result.data = p->data + (p->width/4)*p->height; result.dx = 0; result.dy = 0; result.width = p->width; result.height = p->height; result.id = p->id+1; - + //result = modexNextPageFlexibleSize(&p, p->width, p->height); return result; } //next page with defined dimentions~ page_t -modexNextPage0(page_t *p, word x, word y) +modexNextPageFlexibleSize(page_t *p, word x, word y) { page_t result; @@ -284,24 +284,46 @@ modexClearRegion(page_t *page, int x, int y, int w, int h, byte color) { void oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite) { - byte plane; - word px, py; - word offset; - - /* TODO Make this fast. It's SLOOOOOOW */ - for(plane=0; plane < 4; plane++) { - modexSelectPlane(PLANE(plane+x)); - for(px = plane; px < bmp->width; px+=4) { - offset=px; - for(py=0; pyheight; py++) { - if(!sprite || bmp->data[offset]) - page[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset]; - offset+=bmp->width; - } - } - } + byte plane; + word px, py; + word offset; + + /* TODO Make this fast. It's SLOOOOOOW */ + for(plane=0; plane < 4; plane++) { + modexSelectPlane(PLANE(plane+x)); + for(px = plane; px < bmp->width; px+=4) { + offset=px; + for(py=0; pyheight; py++) { + if(!sprite || bmp->data[offset]) + page[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset]; + offset+=bmp->width; + } + } + } } +void +CDrawBmp(byte far* vgamem, page_t* page, int x, int y, bitmap_t *bmp, byte sprite) +{ + byte plane; + word px, py; + word offset=0; + + + /* TODO Make this fast. It's SLOOOOOOW */ + for(plane=0; plane < 4; plane++) { + modexSelectPlane(PLANE(plane+x)); + for(px = plane; px < bmp->width; px+=4) { + offset=px; + for(py=0; pyheight; py++) { + if(!sprite || bmp->data[offset]) + //modexputPixel(page, x+px, y+py, bmp->data[offset]); + vgamem[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset]; + offset+=bmp->width; + } + } + } +} void modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp) { @@ -314,7 +336,7 @@ void modexDrawBmpRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp) { word poffset = (word) page->data + y*(page->width/4) + x/4; - byte *data = bmp->data;//+bmp->offset; + byte far *data = bmp->data;//+bmp->offset; word bmpOffset = (word) data + ry * bmp->width + rx; word width = rw; word height = rh; @@ -325,6 +347,10 @@ modexDrawBmpRegion(page_t *page, int x, int y, word rowCounter; byte planeCounter = 4; +/* printf("bmp->data=%Fp\n",bmp->data); + printf("*bmp->data=%Fp\n",*(bmp->data)); + printf("&bmp->data=%Fp\n",&(bmp->data));*/ + //code is a bit slow here __asm { MOV AX, SCREEN_SEG ; go to the VGA memory @@ -1162,6 +1188,21 @@ void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, c } } +///////////////////////////////////////////////////////////////////////////// +// // +// cls() - This clears the screen to the specified color, on the VGA or on // +// the Virtual screen. // +// // +///////////////////////////////////////////////////////////////////////////// +void cls(page_t *page, byte color, byte *Where) +{ + //modexClearRegion(page, 0, 0, page->width, page->height, color); + /* set map mask to all 4 planes */ + outpw(SC_INDEX, 0xff02); + //_fmemset(VGA, color, 16000); + _fmemset(Where, color, page->width*(page->height)); +} + void modexWaitBorder() { while(inp(INPUT_STATUS_1) & 8) {