X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16.c;h=d5e17a9862221debe792e7ec35a6c8cf6bd13004;hb=6245ae3447f2f001412b05d37dc4482a5256656f;hp=1ddefc699670533b11d02b0a466808d710c20ea6;hpb=81a89657d4c71baad7e1a6c65c166fcca6af8bf8;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c index 1ddefc69..d5e17a98 100755 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -1,11 +1,11 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669 + * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 * * This file is part of Project 16. * * Project 16 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or + * the Free Software Foundation; either verson 3 of the License, or * (at your option) any later version. * * Project 16 is distributed in the hope that it will be useful, @@ -35,7 +35,7 @@ static byte tmppal[PAL_SIZE]; // setvideo() - This function Manages the video modes // // // ///////////////////////////////////////////////////////////////////////////// -void VGAmodeX(sword vq, global_game_variables_t *gv) +void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv) { union REGS in, out; @@ -54,7 +54,7 @@ void VGAmodeX(sword vq, global_game_variables_t *gv) //int86(0x10, &in, &out); gv->video.old_mode = vgaGetMode();//out.h.al; // enter mode - modexEnter(vq, gv); + modexEnter(vq, cmem, gv); break; } } @@ -86,32 +86,68 @@ vgaGetMode() } /* -========================= Entry Points ==========================- */ -void -modexEnter(sword vq, global_game_variables_t *gv) +void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) { word i; dword far*ptr=(dword far*)VGA; /* used for faster screen clearing */ int CRTParmCount; /* common mode X initiation stuff~ */ - modexsetBaseXMode(gv->video.page); + modexsetBaseXMode(); switch(vq) { case 1: - CRTParmCount = sizeof(ModeX_320x240regs) / sizeof(ModeX_320x240regs[0]); + //CRTParmCount = sizeof(ModeX_320x240regs) / sizeof(ModeX_320x240regs[0]); /* width and height */ - gv->video.page[0].sw=320; - gv->video.page[0].sh=240; + 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].tilesw = gv->video.page[0].sw/TILEWH; @@ -193,8 +217,8 @@ modexEnter(sword vq, global_game_variables_t *gv) void modexLeave() { - /* TODO restore original mode and palette */ - vgaSetMode(TEXT_MODE); + /* TODO restore original mode and palette */ + vgaSetMode(TEXT_MODE); } // setBaseXMode() does the initialization to make the VGA ready to @@ -202,30 +226,12 @@ modexLeave() { // 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(page_t *page) +modexsetBaseXMode() { - word temp; /* 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 */ -// temp = inp(CRTC_DATA) & 0x7F; -// outp(CRTC_INDEX, 0x11); - outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */ -// outp(CRTC_DATA, temp); /* get current write protect on varios regs */ + vga_enable_256color_modex(); + update_state_from_vga(); } page_t @@ -994,9 +1000,8 @@ void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, cons //TODO: OPTIMIZE THIS!!!! modexDrawCharPBuf(page, x, y, t, col, bgcol, q); - if(!q) getch(); + //if(!q) getch(); } - //_nfree(bakapee); } void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str) @@ -1101,7 +1106,7 @@ void cls(page_t *page, byte color, byte *Where) /* set map mask to all 4 planes */ outpw(SC_INDEX, 0xff02); //_fmemset(VGA, color, 16000); - _fmemset(Where, color, page->width*(page->height)); + _fmemset(Where, color, page->width*(page->height)/4); } void