X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_vl.c;h=2c3fc766df37efe84f32ee076e86372e2cedf9b8;hb=a9fe632397649ac62b1d7febda9a62bc517c5c53;hp=12d8c4b6e125dacc4a6632d167a6623bb74915d7;hpb=243e22dc4fb6ae069348ac984f79ae7827747be1;p=16.git diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 12d8c4b6..2c3fc766 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -879,11 +879,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,36 +916,43 @@ modexLoadPalFile(byte *filename, byte *palette) { fclose(file); } -void VL_LoadPalFile(const char *filename, byte *palette, global_game_variables_t *gvar) -{ - VL_LoadPalFilewithoffset(filename, palette, 9, gvar); -// VL_LoadPalFileCore(palette); -} - -void VL_LoadPalFileCore(byte *palette, global_game_variables_t *gvar) -{ - VL_LoadPalFilewithoffset("data/16.pal", palette, 0, gvar); -} - -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); close(fd); - VL_UpdatePaletteWrite(palette, o, gvar); + if(palsize==27) newpalette = palette; else{ //if core then load it + newpalette = &palette[3]; //skip overscan color + if(!o) o++; + } + VL_UpdatePaletteWrite(newpalette, o, gvar); } } +void VL_LoadPalFile(const char *filename, byte *palette, global_game_variables_t *gvar) +{ + VLL_LoadPalFilewithoffset(filename, palette, + 0, //overwrite core/system palette +// 9, //preserved core/system palette + PAL_SIZE, gvar); +} + +void VL_LoadPalFileCore(byte *palette, global_game_variables_t *gvar) +{ + VLL_LoadPalFilewithoffset("data/16.pal", palette, 0, 27, gvar); +} + void VL_UpdatePaletteWrite(byte *palette, word o, 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 < 255-o;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); VL_PaletteSync(gvar); @@ -1029,12 +1036,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; } @@ -1107,7 +1119,7 @@ void modexDrawChar(page_t *page, int x/*for planar selection only*/, word t, wor } } -void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col, word bgcol, boolean sw, const byte *str) +void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word color, word bgcolor, boolean vidsw, const byte *str) { word s, o, w; word x_draw; @@ -1116,14 +1128,14 @@ void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col, word addrr; byte c; - switch(sw) + switch(vidsw) { case 0: printf("%s\n", str); 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; @@ -1149,7 +1161,7 @@ void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col, // no need for inline assembly! // NTS: It might even be faster to just let the modexDrawChar point directly at ROM font than to copy per char! --J.C. _fmemcpy(romFontsData.l,MK_FP(s,o+(w*c))/*ROM font location*/,w/*char size*/); - modexDrawChar(page, x_draw/*for mode X planar use*/, t, col, bgcol, addrr); + modexDrawChar(page, x_draw/*for mode X planar use*/, t, color, bgcolor, addrr); x_draw += 8; /* track X for edge of screen */ addrr += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */ } @@ -1252,7 +1264,7 @@ void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, c } /* 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; @@ -1260,10 +1272,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 /////////////////////////////////////////////////////////////////////////////