X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_vl.c;h=91776466836ea7cb0bd26297e9b02aaa5967d5af;hb=946dfbe9b29be3a3b180c37e0b414a938e867dc6;hp=2e5fa42e184eb9d6ed18da64adc0fc4a1abe8503;hpb=0fafba3a1ca84e8bb74c995cc42e397131f2bcd6;p=16.git diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 2e5fa42e..91776466 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -43,12 +43,20 @@ void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv) { case 0: // deinit the video // change to the video mode we were in before we switched to mode 13h - modexLeave(); - in.h.ah = 0x00; - in.h.al = gv->video.old_mode; - int86(0x10, &in, &out); + if(gv->video.VL_Started) + { + modexLeave(); + in.h.ah = 0x00; + in.h.al = gv->video.old_mode; + int86(0x10, &in, &out); + } + gv->video.VL_Started=0; break; default: // init the video + if(gv->video.VL_Started) + return; + if(!gv->video.VL_Initiated) + TL_VidInit(gv); // get old video mode //in.h.ah = 0xf; //int86(0x10, &in, &out); @@ -163,6 +171,8 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) } break; } +// VL_SetLineWidth (cm.offset, &gv->video.ofs); + gv->video.VL_Started=1; } void @@ -274,7 +284,7 @@ void modexCalcVmemRemain(video_t *video) void VL_Initofs(video_t *video) { - if(!video->bgps) + if(!video->vga_state.bgps) { video->ofs.offscreen_ofs = video->page[0].pagesize+video->page[1].pagesize;//(vga_state.vga_stride * vga_state.vga_height); video->ofs.pattern_ofs = (uint16_t)video->page[2].data; @@ -304,12 +314,12 @@ void modexHiganbanaPageSetup(video_t *video) VL_Initofs(video); //doslib origi var - video->omemptr= vga_state.vga_graphics_ram; - video->vga_draw_stride= vga_state.vga_draw_stride; - video->vga_draw_stride_limit= vga_state.vga_draw_stride_limit; + video->vga_state.omemptr= vga_state.vga_graphics_ram; + video->vga_state.vga_draw_stride= vga_state.vga_draw_stride; + video->vga_state.vga_draw_stride_limit= vga_state.vga_draw_stride_limit; //sprite render switch and bgpreservation switch - video->rss= 1; - video->bgps= 1; + video->vga_state.rss= 1; + video->vga_state.bgps= 1; //setup the buffersize video->page[0].dx=video->page[0].dy= @@ -404,25 +414,25 @@ modexPanPage(page_t *page, int dx, int dy) { void modexSelectPlane(byte plane) { - outp(SC_INDEX, MAP_MASK); /* select plane */ + outp(SC_INDEX, SC_MAPMASK); /* select plane */ outp(SC_DATA, 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 */ - byte rclip[] = {0x00, 0x01, 0x03, 0x07}; + 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 + LRCLIPDEF 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); @@ -440,7 +450,7 @@ modexClearRegion(page_t *page, int x, int y, int w, int h, byte color) { MOV ES, AX MOV DI, poffset ; go to the first pixel MOV DX, SC_INDEX ; point to the map mask - MOV AL, MAP_MASK + MOV AL, SC_MAPMASK OUT DX, AL INC DX MOV AL, color ; get ready to write colors @@ -492,17 +502,16 @@ 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 rclip[] = {0x00, 0x01, 0x03, 0x07}; + LRCLIPDEF 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; } @@ -530,7 +539,7 @@ modexCopyPageRegion(page_t *dest, page_t *src, MOV AX, SC_INDEX ; point to the mask register MOV DX, AX ; - MOV AL, MAP_MASK ; + MOV AL, SC_MAPMASK ; OUT DX, AL ; INC DX ; @@ -579,6 +588,7 @@ modexCopyPageRegion(page_t *dest, page_t *src, } } +//check 16_vl_1.c /* fade and flash */ void @@ -763,7 +773,8 @@ modexPalUpdate(byte *p) } void -modexPalUpdate0(byte *p) +//modexPalUpdate0(byte *p) +VL_modexPalScramble(byte *p) { int i; //modexWaitBorder(); @@ -781,14 +792,16 @@ modexPalUpdate0(byte *p) } } -void +word modexPalOverscan(word col) { //modexWaitBorder(); vga_wait_for_vsync(); outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */ outp(PAL_DATA_REG, col); + return col; } +//check 16_vl_1.c void modexputPixel(page_t *page, int x, int y, byte color) { @@ -857,7 +870,7 @@ 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, boolean tlsw, word col, word bgcol, const byte *str) +void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col, word bgcol, boolean sw, const byte *str) { word s, o, w; word x_draw; @@ -866,38 +879,46 @@ void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col, word addrr; byte c; - if(tlsw){ x-=page->tlx; y-=page->tly; } - x_draw = x/4; - addrq = (page->stridew) * y + (word)(x_draw) + - ((word)page->data); - addrr = addrq; - s=romFonts[t].seg; - o=romFonts[t].off; - w=romFonts[t].charSize; - romFontsData.chw=0; - - for(; *str != '\0'; str++) + switch(sw) { - c = (*str); - if(c=='\n') - { - x = x_draw; - romFontsData.chw = 0; - addrq += (page->stridew) * 8; + case 0: + printf("%s\n", str); + break; + case 1: + if(tlsw){ x-=page->tlx; y-=page->tly; } + x_draw = x/4; + addrq = (page->stridew) * y + (word)(x_draw) + + ((word)page->data); addrr = addrq; - y += 8; - continue; - } + s=romFonts[t].seg; + o=romFonts[t].off; + w=romFonts[t].charSize; + romFontsData.chw=0; - // load the character into romFontsData.l - // no need for inline assembly! - // NTS: It might even be faster to just let the modexDrawChar point directly at ROM font than to copy per char! --J.C. - _fmemcpy(romFontsData.l,MK_FP(s,o+(w*c))/*ROM font location*/,w/*char size*/); - modexDrawChar(page, x_draw/*for mode X planar use*/, t, col, bgcol, addrr); - x_draw += 8; /* track X for edge of screen */ - addrr += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */ + for(; *str != '\0'; str++) + { + c = (*str); + if(c=='\n') + { + x = x_draw; + romFontsData.chw = 0; + addrq += (page->stridew) * 8; + addrr = addrq; + y += 8; + continue; + } + + // load the character into romFontsData.l + // no need for inline assembly! + // NTS: It might even be faster to just let the modexDrawChar point directly at ROM font than to copy per char! --J.C. + _fmemcpy(romFontsData.l,MK_FP(s,o+(w*c))/*ROM font location*/,w/*char size*/); + modexDrawChar(page, x_draw/*for mode X planar use*/, t, col, bgcol, addrr); + 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); + break; } - //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) @@ -1102,6 +1123,8 @@ modexWaitBorder_end() } +//=========================================================================== + // // printings of video memory information //