X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16.c;h=bada2e67972d951ea48fdacbe96bbda4b969b5b8;hb=c1d3221afb5fe541d8c886ff66198329c153e48e;hp=5c0cab2c0031bc35accfac37ab355a60a6c1b114;hpb=6340f73596b16d6b718e3ddca2b09f13ce521f6d;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c index 5c0cab2c..bada2e67 100755 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -62,11 +62,7 @@ void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv) static void vgaSetMode(byte mode) { - union REGS regs; - - regs.h.ah = SET_MODE; - regs.h.al = mode; - int86(VIDEO_INT, ®s, ®s); + int10_setmode(mode); } //--------------------------------------------------- @@ -74,22 +70,17 @@ vgaSetMode(byte mode) // Use the bios to get the current video mode // -long +byte/*FIXME: why long? "long" is 32-bit datatype, VGA modes are 8-bit numbers. */ vgaGetMode() { - union REGS rg; - - rg.h.ah = 0x0f; - int86(VIDEO_INT, &rg, &rg); - - return rg.h.al; + return int10_getmode(); } /* -========================= Entry Points ==========================- */ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) { word i; - dword far*ptr=(dword far*)VGA; /* used for faster screen clearing */ + dword far*ptr=(dword far*)vga_state.vga_graphics_ram;//VGA; /* used for faster screen clearing */ struct vga_mode_params cm; int CRTParmCount; @@ -124,6 +115,8 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) cm.clock_select = 0; /* misc register = 0xE3 25MHz */ cm.vsync_neg = 1; cm.hsync_neg = 1; + vga_state.vga_stride=0x58; + cm.offset=0x2c; break; case 2: // TODO: 160x120 according to ModeX_160x120regs return; @@ -168,7 +161,7 @@ modexDefaultPage(page_t *p) page_t page; /* default page values */ - page.data = VGA; + page.data = vga_state.vga_graphics_ram;//VGA; page.dx = 0; page.dy = 0; page.sw = p->sw; @@ -554,7 +547,8 @@ modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset) static word a[PAL_SIZE]; //palette array of change values! word z=0, aq=0, aa=0, pp=0; - modexWaitBorder(); + //modexWaitBorder(); + vga_wait_for_vsync(); if((*i)==0) { memset(a, -1, sizeof(a)); @@ -604,7 +598,8 @@ modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset) //if(qp>0) printf("qp=%d\n", qp); //if(qp>0) printf(" (*i)=%d\n", (*i)/3); } - modexWaitBorder(); /* waits one retrace -- less flicker */ + //modexWaitBorder(); /* waits one retrace -- less flicker */ + vga_wait_for_vsync(); if((*i)>=PAL_SIZE/2 && w==0) { for(; (*i)=page[0].sw-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, boolean q) +void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str) { word s, o, w; word addr = (word) romFontsData.l; + word addrq = (page->width/4) * y + (x / 4) + ((word)page->data); byte c; s=romFonts[t].seg; @@ -926,7 +914,8 @@ void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, cons JNZ L1 } //TODO: OPTIMIZE THIS!!!! - modexDrawCharPBuf(page, x, y, t, col, bgcol, q); + modexDrawCharPBuf(page, x/*for mode X planar use*/, y/*redunant, remove*/, t, col, bgcol, addrq); + addrq += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */ //if(!q) getch(); } @@ -1008,7 +997,7 @@ void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, c } /* palette dump on display! */ -void pdump(page_t *pee) +void modexpdump(page_t *pee) { int mult=(QUADWH); int palq=(mult)*TILEWH; @@ -1028,7 +1017,7 @@ void pdump(page_t *pee) // the Virtual screen. // // // ///////////////////////////////////////////////////////////////////////////// -void cls(page_t *page, byte color, byte *Where) +void modexcls(page_t *page, byte color, byte *Where) { //modexClearRegion(page, 0, 0, page->width, page->height, color); /* set map mask to all 4 planes */ @@ -1037,13 +1026,40 @@ void cls(page_t *page, byte color, byte *Where) _fmemset(Where, color, page->width*(page->height)/4); } -void +/*void modexWaitBorder() { while(inp(INPUT_STATUS_1) & 8) { - /* spin */ + // spin } while(!(inp(INPUT_STATUS_1) & 8)) { - /* spin */ + // spin } +}*/ + +void bios_cls() { + VGA_ALPHA_PTR ap; + VGA_RAM_PTR rp; + unsigned char m; + + m = int10_getmode(); + if ((rp=vga_state.vga_graphics_ram) != NULL && !(m <= 3 || m == 7)) { + unsigned int i,im; + + im = (FP_SEG(vga_state.vga_graphics_ram_fence) - FP_SEG(vga_state.vga_graphics_ram)); + if (im > 0xFFE) im = 0xFFE; + im <<= 4; + for (i=0;i < im;i++) vga_state.vga_graphics_ram[i] = 0; + } + else if ((ap=vga_state.vga_alpha_ram) != NULL) { + unsigned int i,im; + + im = (FP_SEG(vga_state.vga_alpha_ram_fence) - FP_SEG(vga_state.vga_alpha_ram)); + if (im > 0x7FE) im = 0x7FE; + im <<= 4 - 1; /* because ptr is type uint16_t */ + for (i=0;i < im;i++) vga_state.vga_alpha_ram[i] = 0x0720; + } + else { + printf("WARNING: bios cls no ptr\n"); + } }