X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16.c;h=8ab175ed028d643a1a614203a419f24f36a9419b;hb=54e80274a159f2c8f12bbb284403927616c686c5;hp=d5e17a9862221debe792e7ec35a6c8cf6bd13004;hpb=6245ae3447f2f001412b05d37dc4482a5256656f;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c index d5e17a98..8ab175ed 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,25 +70,24 @@ 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; - /* common mode X initiation stuff~ */ - modexsetBaseXMode(); + + vgaSetMode(VGA_256_COLOR_MODE); + vga_enable_256color_modex(); + update_state_from_vga(); + vga_read_crtc_mode(&cm); switch(vq) { @@ -102,32 +97,6 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) gv->video.page[0].sw=vga_state.vga_width = 320; // VGA lib currently does not update this gv->video.page[0].sh=vga_state.vga_height = 240; // VGA lib currently does not update this - /* send the CRTParms */ - /*for(i=0; ivideo.page[0].sw=120; - gv->video.page[0].sh=160; - - /* send the CRTParms */ - for(i=0; ivideo.page[0].sw=320; - gv->video.page[0].sh=200; - - /* send the CRTParms */ - for(i=0; ivideo.page[0].sw=192; - gv->video.page[0].sh=144; - - /* send the CRTParms */ - for(i=0; ivideo.page[0].sw=256; - gv->video.page[0].sh=192; - - /* send the CRTParms */ - for(i=0; ivideo.page[0].tilesw = gv->video.page[0].sw/TILEWH; @@ -221,26 +155,13 @@ modexLeave() { vgaSetMode(TEXT_MODE); } -// setBaseXMode() does the initialization to make the VGA ready to -// accept any combination of configuration register settings. This -// involves enabling writes to index 0 to 7 of the CRT controller (port -// 0x3D4), by clearing the most significant bit (bit 7) of index 0x11. -void -modexsetBaseXMode() -{ - /* TODO save current video mode and palette */ - vgaSetMode(VGA_256_COLOR_MODE); - vga_enable_256color_modex(); - update_state_from_vga(); -} - page_t 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; @@ -626,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)); @@ -676,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)width, page->height, color); /* set map mask to all 4 planes */ @@ -1109,13 +1037,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"); + } }