X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16.c;h=02fc24062c5d8760fe21a995a2b2c89a68f31b0d;hb=ffd855e814f3aa4f300915ffca12be6f5763e608;hp=a0ffccb4b9f29e8acc25208507311f059bea6cc7;hpb=6b585194480dbbfb1ca8ae9d4564418b24e79d48;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c index a0ffccb4..02fc2406 100644 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -28,37 +28,37 @@ 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; - -///////////////////////////////////////////////////////////////////////////// -// // -// setvideo() - This function Manages the video modes // -// // -///////////////////////////////////////////////////////////////////////////// -void VGAmodeX(sword vq) -{ - union REGS in, out; - - if(!vq) - { // 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 = old_mode; - //int86(0x10, &in, &out); - - } - else if(vq==1) - { // init the video - // get old video mode - //in.h.ah = 0xf; - //int86(0x10, &in, &out); - //old_mode = out.h.al; - // enter mode - modexEnter(); - } -} +static byte tmppal[PAL_SIZE]; +//int old_mode; + +///////////////////////////////////////////////////////////////////////////// +// // +// setvideo() - This function Manages the video modes // +// // +///////////////////////////////////////////////////////////////////////////// +void VGAmodeX(sword vq, global_game_variables_t *gv) +{ + union REGS in, out; + + if(!vq) + { // 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->old_mode; + int86(0x10, &in, &out); + + } + else if(vq==1) + { // init the video + // get old video mode + in.h.ah = 0xf; + int86(0x10, &in, &out); + gv->old_mode = out.h.al; + // enter mode + modexEnter(); + } +} static void vgaSetMode(byte mode) @@ -677,7 +677,7 @@ modexPalWhite() { } -/* utility */ +/* utility */ void modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset) { @@ -970,90 +970,90 @@ no... wait.... no wwww } void modexputPixel(page_t *page, int x, int y, byte color) -{ +{ word pageOff = (word) page->data; /* Each address accesses four neighboring pixels, so set Write Plane Enable according to which pixel we want to modify. The plane is determined by the two least - significant bits of the x-coordinate: */ - //modexSelectPlane(PLANE(x)); - outp(SC_INDEX, 0x02); - outp(SC_DATA, 0x01 << (x & 3)); + significant bits of the x-coordinate: */ + modexSelectPlane(PLANE(x)); + //outp(SC_INDEX, 0x02); + //outp(SC_DATA, 0x01 << (x & 3)); /* The offset of the pixel into the video segment is offset = (width * y + x) / 4, and write the given color to the plane we selected above. Heed the active page start selection. */ - VGA[(unsigned)((SCREEN_WIDTH/4) * y) + (x / 4) + pageOff] = color; + VGA[(unsigned)((page->width/4) * y) + (x / 4) + pageOff] = color; } byte modexgetPixel(page_t *page, int x, int y) -{ +{ word pageOff = (word) page->data; /* Select the plane from which we must read the pixel color: */ outpw(GC_INDEX, 0x04); outpw(GC_INDEX+1, x & 3); - return VGA[(unsigned)((SCREEN_WIDTH/4) * y) + (x / 4) + pageOff]; - -} - -void modexhlin(page_t *page, word xl, word xh, word y, word color) -{ - word x; - word yy=0; - - for(x=0;x=SCREEN_WIDTH-1){ x=0; yy+=4; } - modexClearRegion(page, x+xl, y+yy, 4, 4, color); - } - //modexputPixel(page, x+xl, y, color); + return VGA[(unsigned)((page->width/4) * y) + (x / 4) + pageOff]; + +} + +void modexhlin(page_t *page, word xl, word xh, word y, word color) +{ + word x; + word yy=0; + + for(x=0;x=SCREEN_WIDTH-1){ x=0; yy+=4; } + modexClearRegion(page, x+xl, y+yy, 4, 4, color); + } + //modexputPixel(page, x+xl, y, color); } void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str) -{ - word i, s, o, w, j, xp; +{ + word i, s, o, w, j, xp; byte l[1024]; - word addr = (word) l; - word chw=0; - byte c; - + word addr = (word) l; + word chw=0; + byte c; + switch(t) { - case 0: + case 0: w=14; break; - case 1: + case 1: w=8; break; - case 2: + case 2: w=8; break; - case 3: + case 3: w=16; break; - default: + default: t=3; w=16; break; - } + } s=romFonts[t].seg; - o=romFonts[t].off; + o=romFonts[t].off; for(; *str != '\0'; str++) - { - c = (*str); - if((c=='\n'/* || c=="\ -"*/) || chw ->=page->width) - { - chw=0; - y+=w; - continue; - } + { + c = (*str); + if((c=='\n'/* || c=="\ +"*/) || chw +>=page->width) + { + chw=0; + y+=w; + continue; + } //load the letter 'A' __asm { MOV DI, addr @@ -1070,64 +1070,64 @@ void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, cons INC DI DEC CX JNZ L1 - } + } - for(i=0; i>=1; - } + while(j) + { + modexputPixel(page, x+xp+chw, y+i, l[i] & j ? col:bgcol); + xp++; + j>>=1; + } } chw += xp; } -} - +} + void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str) -{ - word i, s, o, w, j, xp; +{ + word i, s, o, w, j, xp; byte l[1024]; - word addr = (word) l; - word chw=0; - byte c; - + word addr = (word) l; + word chw=0; + byte c; + switch(t) { - case 0: + case 0: w=14; break; - case 1: + case 1: w=8; break; - case 2: + case 2: w=8; break; - case 3: + case 3: w=16; break; - default: + default: t=3; w=16; break; - } + } s=romFonts[t].seg; - o=romFonts[t].off; + o=romFonts[t].off; for(; *str != '\0'; str++) - { - c = (*str); - if((c=='\n'/* || c=="\ -"*/)/* || chw>=page->width*/) - { - chw=0; - y+=w; - continue; - } + { + c = (*str); + if((c=='\n'/* || c=="\ +"*/)/* || chw>=page->width*/) + { + chw=0; + y+=w; + continue; + } //load the letter 'A' __asm { MOV DI, addr @@ -1144,19 +1144,19 @@ void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, c INC DI DEC CX JNZ L1 - } + } - for(i=0; i>=1; - } + while(j) + { + //modexputPixel(page, x+xp+chw, y+i, l[i] & j ? col:bgcol); + modexClearRegion(page, (x+xp+chw)*8, (y+i)*8, 8, 8, l[i] & j ? col:bgcol); + xp++; + j>>=1; + } } chw += xp; }