X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fmodex16.c;h=90005d7ecb0d125fcb96b7627a82c7707bb14483;hb=60d62fcab6d8310dc1ab11b40906e9a59e4c9c6a;hp=2defd97d4210f39e0b362a8591857079040646ee;hpb=5cf6961096efa8f4ecf5171ff46f4bb0e8c9fa41;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c index 2defd97d..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 - modex__320x240_256__Enter(gv); + 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,61 +69,79 @@ 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 -modex__320x240_256__Enter(global_game_variables_t *gv) +modexEnter(sword vq, global_game_variables_t *gv) { word i; dword far*ptr=(dword far*)VGA; /* used for faster screen clearing */ - word CRTParms[] = { -// 0xe300, /* horizontal total */ -// 0x4f01, /* horizontal display enable end */ - 0x5002, /* */ - 0x5404, /* */ - 0x8005, /* */ - 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 */ - 0x2813, /* 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]); - /* width and height */ - //TODO WWWW - - /* disable chain4 mode */ - outpw(SC_INDEX, 0x0604); - - /* synchronous reset while setting Misc Output */ - outpw(SC_INDEX, 0x0100); + int CRTParmCount; + /* common mode X initiation stuff~ */ + modexsetBaseXMode(gv->video.page); - /* select 25 MHz dot clock & 60 Hz scanning rate */ - outp(MISC_OUTPUT, 0xe3); + 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