X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_vl.c;h=a9d4b66805ba28432b976a3cfc2d4395ae4ec00b;hb=eda37da84ccb4fc381507f04832d0358799ed67c;hp=77c5fad2e4839df1202869b259ab7041e97cff33;hpb=818c6c740d03393778fbabc2d790ca99c56b60bd;p=16.git diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 77c5fad2..a9d4b668 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -28,7 +28,7 @@ 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]; +/*static */byte tmppal[PAL_SIZE]; //=========================================================================== @@ -45,7 +45,8 @@ void VL_Startup (global_game_variables_t *gvar) __asm cld; VGAmodeX(1/*TODO other modes*/, 1, gvar); - VL_LoadPalFileCore(gvar->video.palette, gvar); +//-- VL_LoadPalFileCore(gvar->video.palette, gvar); + VL_SetCorePal(gvar); //Quit ("Improper video card! If you really have a VGA card that I am not\ndetecting it!", gvar); } @@ -545,6 +546,9 @@ void modexHiganbanaPageSetup(global_game_variables_t *gvar) gvar->video.page[1].dx=gvar->video.page[1].dy=TILEWH; // 1 tile size buffer gvar->video.page[2].dx=gvar->video.page[2].dy= gvar->video.page[3].dx=gvar->video.page[3].dy=0; // cache pages are buffer wwww + + gvar->video.page[0].tlx=gvar->mv[0].tx*TILEWH; + gvar->video.page[0].tly=gvar->mv[0].ty*TILEWH; } // @@ -567,14 +571,14 @@ modexShowPage(page_t *page) { low_address = LOW_ADDRESS | (offset << 8); /* wait for appropriate timing and then program CRTC */ -//+=+= while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE)); +//+=+= while ((inp(STATUS_REGISTER_1) & DISPLAY_ENABLE)); outpw(CRTC_INDEX, high_address); outpw(CRTC_INDEX, low_address); outp(CRTC_INDEX, 0x13); outp(CRTC_DATA, crtcOffset); /* wait for one retrace */ -//+=+= while (!(inp(INPUT_STATUS_1) & VRETRACE)); +//+=+= while (!(inp(STATUS_REGISTER_1) & VRETRACE)); /* do PEL panning here */ outp(AC_INDEX, 0x33); @@ -609,14 +613,14 @@ VL_ShowPage(page_t *page, boolean vsync, boolean sr) low_address = LOW_ADDRESS | (offset << 8); // wait for appropriate timing and then program CRTC - if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE)); + if(vsync) while ((inp(STATUS_REGISTER_1) & DISPLAY_ENABLE)); outpw(CRTC_INDEX, high_address); outpw(CRTC_INDEX, low_address); outp(CRTC_INDEX, 0x13); outp(CRTC_DATA, crtcOffset); // wait for one retrace - if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE)); + if(vsync) while (!(inp(STATUS_REGISTER_1) & VRETRACE)); // do PEL panning here outp(AC_INDEX, 0x33); @@ -879,11 +883,11 @@ void modexPalSave(byte *palette) /*byte * modexNewPal() { byte *ptr; - ptr = m a l l o c(PAL_SIZE); + ptr = mAlloc(PAL_SIZE); // handle errors if(!ptr) { - printf("Could not allocate palette.\n"); + printf("Could not Allocate palette.\n"); } return ptr; @@ -916,38 +920,60 @@ modexLoadPalFile(byte *filename, byte *palette) { fclose(file); } -void VL_LoadPalFile(const char *filename, byte *palette, global_game_variables_t *gvar) -{ - VL_LoadPalFilewithoffset(filename, palette, - 0, gvar); - //9, gvar); -// VL_LoadPalFileCore(palette); -} - -void VL_LoadPalFileCore(byte *palette, global_game_variables_t *gvar) -{ - VL_LoadPalFilewithoffset("data/16.pal", palette, 0, gvar); -} +#define COREPALSIZE 9//27 //3*9 -void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o, global_game_variables_t *gvar) +void VLL_LoadPalFilewithoffset(const char *filename, byte *palette, word o, word palsize, global_game_variables_t *gvar) { int fd; + byte *newpalette; fd = open(filename,O_RDONLY|O_BINARY); if (fd >= 0) { - read(fd,palette, PAL_SIZE); + read(fd,palette, palsize*3); close(fd); - VL_UpdatePaletteWrite(palette, o, gvar); + if(palsize==COREPALSIZE) newpalette = palette; else{ //if core then load it + newpalette = &palette[3]; //skip overscan color + if(!o) o++; + } + VL_UpdatePaletteWrite(newpalette, o, palsize, gvar); } } -void VL_UpdatePaletteWrite(byte *palette, word o, global_game_variables_t *gvar) +//++++// +void VL_SetCorePal(global_game_variables_t *gvar) +{ + byte *palette = &corepal; + word i; + + vga_palette_lseek(0); + for (i=0;i < COREPALSIZE;i++) + vga_palette_write(palette[(i*3)+0]>>2, + palette[(i*3)+1]>>2, + palette[(i*3)+2]>>2); + + VL_PaletteSync(gvar); +} + +void VL_LoadPalFile(const char *filename, byte *palette, global_game_variables_t *gvar) +{ + VLL_LoadPalFilewithoffset(filename, palette, + 0, //overwrite core/system palette +// COREPALSIZE, //preserved core/system palette + PAL_SIZE/3, gvar); +} + +void VL_LoadPalFileCore(byte *palette, global_game_variables_t *gvar) +{ + VLL_LoadPalFilewithoffset("data/16.pal", palette, 0, COREPALSIZE, gvar); +} + +void VL_UpdatePaletteWrite(byte *palette, word o, word p, global_game_variables_t *gvar) { word i; - vga_palette_lseek(/*1+*/o); - //for (i=o;i < 256-o;i++) - for (i=0;i < 256-o;i++) + + vga_palette_lseek(o); + for (i=0;i < p-o;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); VL_PaletteSync(gvar); @@ -1031,12 +1057,17 @@ VL_modexPalScramble(byte *p) } word -modexPalOverscan(word col) +VL_modexPalOverscan(byte *p, word col) { + int i; //modexWaitBorder(); vga_wait_for_vsync(); outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */ - outp(PAL_DATA_REG, col); + for(i=col; i<(3+col); i++) + { + outp(PAL_DATA_REG, p[i]); + } +// modexPalSave(p); return col; } @@ -1125,7 +1156,7 @@ void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word color break; case 1: if(tlsw){ x-=page->tlx; y-=page->tly; } - x_draw = x/4; + x_draw = x>>2; addrq = (page->stridew) * y + (word)(x_draw) + ((word)page->data); addrr = addrq; @@ -1253,8 +1284,14 @@ void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, c } } +// short hand of modexprint +void VL_print(const byte *str, nibble pagenum, global_game_variables_t *gvar) +{ + modexprint(&(gvar->video.page[pagenum]), gvar->video.print.x, gvar->video.print.y, gvar->video.print.t, gvar->video.print.tlsw, gvar->video.print.color, gvar->video.print.bgcolor, gvar->video.VL_Started, str); +} + /* palette dump on display! */ -void modexpdump(page_t *pee) +void modexpdump(nibble pagenum, global_game_variables_t *gvar) { int mult=(QUADWH); int palq=(mult)*TILEWH; @@ -1262,10 +1299,11 @@ void modexpdump(page_t *pee) int palx, paly; for(paly=TILEWH*8; palyvideo.page[pagenum], palx+TILEWH, paly+TILEWH, mult, mult, palcol); palcol++; } } + modexPalSave(gvar->video.palette); } #if 0 ///////////////////////////////////////////////////////////////////////////// @@ -1335,11 +1373,11 @@ void VL_PatternDraw(video_t *video, word pn, boolean sw, boolean allsw) void modexWaitBorder() { - while(inp(INPUT_STATUS_1) & 8) { + while(inp(STATUS_REGISTER_1) & 8) { // spin } - while(!(inp(INPUT_STATUS_1) & 8)) { + while(!(inp(STATUS_REGISTER_1) & 8)) { //spin } } @@ -1347,7 +1385,7 @@ modexWaitBorder() { void modexWaitBorder_start() { - while(inp(INPUT_STATUS_1) & 8) { + while(inp(STATUS_REGISTER_1) & 8) { // spin } @@ -1356,7 +1394,7 @@ modexWaitBorder_start() void modexWaitBorder_end() { - while(!(inp(INPUT_STATUS_1) & 8)) { + while(!(inp(STATUS_REGISTER_1) & 8)) { // spin } @@ -1376,7 +1414,8 @@ void VL_PrintmodexmemInfo(video_t *v) // printf("========================================\n"); printf(" Virtual Screen: %dx", v->page[0].width); printf("%d ", v->page[0].height); printf("Tile: %dx", v->page[0].ti.tilesw); printf("%d", v->page[0].ti.tilesh); printf("=((Virtual Screen)/16)\n"); printf(" Screen: %dx", v->page[0].sw); printf("%d ", v->page[0].sh); printf("Tile: %dx", v->page[0].ti.tw); printf("%d", v->page[0].ti.th); printf("=((Screen)/16)\n"); - printf(" stride: %u ", vga_state.vga_stride); + printf(" vga_stride: %u ", vga_state.vga_stride); + printf("pagestride: %u ", v->page[0].stridew); printf("draw_stride: %u ", vga_state.vga_draw_stride); printf("draw_stride_limit: %u\n", vga_state.vga_draw_stride_limit);