X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16.c;h=90005d7ecb0d125fcb96b7627a82c7707bb14483;hb=60d62fcab6d8310dc1ab11b40906e9a59e4c9c6a;hp=9d130a3b79ae6e807d02d541a106fddfba9e2da8;hpb=d280f25c9633d068fd3e106f2418e59ace6da2f1;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c index 9d130a3b..90005d7e 100755 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -29,7 +29,6 @@ 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; ///////////////////////////////////////////////////////////////////////////// // // @@ -40,23 +39,23 @@ 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(); + switch (vq) + { + 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); + break; + default: // init the video + // get old video mode + //in.h.ah = 0xf; + //int86(0x10, &in, &out); + gv->video.old_mode = vgaGetMode();//out.h.al; + // enter mode + modexEnter(vq, gv); + break; } } @@ -70,58 +69,74 @@ vgaSetMode(byte mode) int86(VIDEO_INT, ®s, ®s); } +//--------------------------------------------------- +// +// Use the bios to get the current video mode +// + +long +vgaGetMode() +{ + union REGS rg; + + rg.h.ah = 0x0f; + int86(VIDEO_INT, &rg, &rg); + + return rg.h.al; +} /* -========================= Entry Points ==========================- */ void -modexEnter() { - word i; - dword far*ptr=(dword far*)VGA; /* used for faster screen clearing */ - word CRTParms[] = { - 0x0d06, /* vertical total */ - 0x3e07, /* overflow (bit 8 of vertical counts) */ - 0x4109, /* cell height (2 to double-scan */ - 0xea10, /* v sync start */ - 0xac11, /* v sync end and protect cr0-cr7 */ - 0xdf12, /* vertical displayed */ - 0x2013, /* offset/logical width */ - 0x0014, /* turn off dword mode */ - 0xe715, /* v blank start */ - 0x0616, /* v blank end */ - 0xe317 /* turn on byte mode */ - }; - int CRTParmCount = sizeof(CRTParms) / sizeof(CRTParms[0]); - - /* TODO save current video mode and palette */ - vgaSetMode(VGA_256_COLOR_MODE); - - /* disable chain4 mode */ - outpw(SC_INDEX, 0x0604); - - /* synchronous reset while setting Misc Output */ - outpw(SC_INDEX, 0x0100); - - /* select 25 MHz dot clock & 60 Hz scanning rate */ - outp(MISC_OUTPUT, 0xe3); - - /* undo reset (restart sequencer) */ - outpw(SC_INDEX, 0x0300); - - /* reprogram the CRT controller */ - outp(CRTC_INDEX, 0x11); /* VSync End reg contains register write prot */ - outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */ - - /* send the CRTParms */ - for(i=0; ivideo.page); - /* clear video memory */ - outpw(SC_INDEX, 0x0f02); - for(i=0; i<0x8000; i++) { - ptr[i] = 0x0000; - } -} + switch(vq) + { + case 0: + CRTParmCount = sizeof(ModeX_320x240regs) / sizeof(ModeX_320x240regs[0]); + /* width and height */ + gv->video.page->sw=320; + gv->video.page->sh=240; + gv->video.page->tilesw = gv->video.page->sw/TILEWH; + gv->video.page->tilesh = gv->video.page->sh/TILEWH; + //TODO MAKE FLEXIBLE~ + gv->video.page->tilemidposscreenx = 10; + gv->video.page->tilemidposscreeny = 8; + + /* send the CRTParms */ + for(i=0; i