X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_vl.c;h=1f5754d9c2edcca74ddca917b6900ccf7df8e781;hb=0df3c2d5e81ce6a2f1d498b3107e1fd223e7af80;hp=12d8c4b6e125dacc4a6632d167a6623bb74915d7;hpb=243e22dc4fb6ae069348ac984f79ae7827747be1;p=16.git diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 12d8c4b6..1f5754d9 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -545,6 +545,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 +570,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 +612,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 +882,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 +919,45 @@ 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); -} +#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_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); @@ -1029,12 +1041,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 +1124,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 +1133,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 +1166,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 +1269,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 +1277,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 ///////////////////////////////////////////////////////////////////////////// @@ -1333,11 +1351,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 } } @@ -1345,7 +1363,7 @@ modexWaitBorder() { void modexWaitBorder_start() { - while(inp(INPUT_STATUS_1) & 8) { + while(inp(STATUS_REGISTER_1) & 8) { // spin } @@ -1354,7 +1372,7 @@ modexWaitBorder_start() void modexWaitBorder_end() { - while(!(inp(INPUT_STATUS_1) & 8)) { + while(!(inp(STATUS_REGISTER_1) & 8)) { // spin }