/* Project 16 Source Code~\r
- * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
+ * Copyright (C) 2012-2019 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
*\r
* This file is part of Project 16.\r
*\r
byte far* VGA=(byte far*) 0xA0000000; /* this points to video memory. */\r
\r
static void fadePalette(sbyte fade, sbyte start, word iter, byte *palette);\r
-static byte tmppal[PAL_SIZE];\r
+/*static */byte tmppal[PAL_SIZE];\r
\r
//===========================================================================\r
\r
__asm cld;\r
\r
VGAmodeX(1/*TODO other modes*/, 1, gvar);\r
- VL_LoadPalFileCore(gvar->video.palette, gvar);\r
+//-- VL_LoadPalFileCore(gvar->video.palette, gvar);\r
+ VL_SetCorePal(gvar);\r
//Quit ("Improper video card! If you really have a VGA card that I am not\ndetecting it!", gvar);\r
}\r
\r
gvar->video.page[1].dx=gvar->video.page[1].dy=TILEWH; // 1 tile size buffer\r
gvar->video.page[2].dx=gvar->video.page[2].dy=\r
gvar->video.page[3].dx=gvar->video.page[3].dy=0; // cache pages are buffer wwww\r
+\r
+ gvar->video.page[0].tlx=gvar->mv[0].tx*TILEWH;\r
+ gvar->video.page[0].tly=gvar->mv[0].ty*TILEWH;\r
}\r
\r
//\r
low_address = LOW_ADDRESS | (offset << 8);\r
\r
/* wait for appropriate timing and then program CRTC */\r
-//+=+= while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));\r
+//+=+= while ((inp(STATUS_REGISTER_1) & DISPLAY_ENABLE));\r
outpw(CRTC_INDEX, high_address);\r
outpw(CRTC_INDEX, low_address);\r
outp(CRTC_INDEX, 0x13);\r
outp(CRTC_DATA, crtcOffset);\r
\r
/* wait for one retrace */\r
-//+=+= while (!(inp(INPUT_STATUS_1) & VRETRACE));\r
+//+=+= while (!(inp(STATUS_REGISTER_1) & VRETRACE));\r
\r
/* do PEL panning here */\r
outp(AC_INDEX, 0x33);\r
low_address = LOW_ADDRESS | (offset << 8);\r
\r
// wait for appropriate timing and then program CRTC\r
- if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE));\r
+ if(vsync) while ((inp(STATUS_REGISTER_1) & DISPLAY_ENABLE));\r
outpw(CRTC_INDEX, high_address);\r
outpw(CRTC_INDEX, low_address);\r
outp(CRTC_INDEX, 0x13);\r
outp(CRTC_DATA, crtcOffset);\r
\r
// wait for one retrace\r
- if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE));\r
+ if(vsync) while (!(inp(STATUS_REGISTER_1) & VRETRACE));\r
\r
// do PEL panning here\r
outp(AC_INDEX, 0x33);\r
fclose(file);\r
}\r
\r
+#define COREPALSIZE 9//27 //3*9\r
+\r
void VLL_LoadPalFilewithoffset(const char *filename, byte *palette, word o, word palsize, global_game_variables_t *gvar)\r
{\r
int fd;\r
\r
fd = open(filename,O_RDONLY|O_BINARY);\r
if (fd >= 0) {\r
- read(fd,palette, palsize);\r
+ read(fd,palette, palsize*3);\r
close(fd);\r
\r
- if(palsize==27) newpalette = palette; else{ //if core then load it\r
+ if(palsize==COREPALSIZE) newpalette = palette; else{ //if core then load it\r
newpalette = &palette[3]; //skip overscan color\r
if(!o) o++;\r
}\r
- VL_UpdatePaletteWrite(newpalette, o, gvar);\r
+ VL_UpdatePaletteWrite(newpalette, o, palsize, gvar);\r
}\r
}\r
\r
+//++++//\r
+void VL_SetCorePal(global_game_variables_t *gvar)\r
+{\r
+ byte *palette = &corepal;\r
+ word i;\r
+\r
+ vga_palette_lseek(0);\r
+ for (i=0;i < COREPALSIZE;i++)\r
+ vga_palette_write(palette[(i*3)+0]>>2,\r
+ palette[(i*3)+1]>>2,\r
+ palette[(i*3)+2]>>2);\r
+\r
+ VL_PaletteSync(gvar);\r
+}\r
+\r
void VL_LoadPalFile(const char *filename, byte *palette, global_game_variables_t *gvar)\r
{\r
VLL_LoadPalFilewithoffset(filename, palette,\r
- 0, //overwrite core/system palette\r
-// 9, //preserved core/system palette\r
- PAL_SIZE, gvar);\r
+ 0, //overwrite core/system palette\r
+// COREPALSIZE, //preserved core/system palette\r
+ PAL_SIZE/3, gvar);\r
}\r
\r
void VL_LoadPalFileCore(byte *palette, global_game_variables_t *gvar)\r
{\r
- VLL_LoadPalFilewithoffset("data/16.pal", palette, 0, 27, gvar);\r
+ VLL_LoadPalFilewithoffset("data/16.pal", palette, 0, COREPALSIZE, gvar);\r
}\r
\r
-void VL_UpdatePaletteWrite(byte *palette, word o, global_game_variables_t *gvar)\r
+void VL_UpdatePaletteWrite(byte *palette, word o, word p, global_game_variables_t *gvar)\r
{\r
word i;\r
\r
vga_palette_lseek(o);\r
- for (i=0;i < 255-o;i++)\r
+ for (i=0;i < p-o;i++)\r
vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2);\r
\r
VL_PaletteSync(gvar);\r
}\r
}\r
\r
+// short hand of modexprint\r
+void VL_print(const byte *str, nibble pagenum, global_game_variables_t *gvar)\r
+{\r
+ 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);\r
+}\r
+\r
/* palette dump on display! */\r
void modexpdump(nibble pagenum, global_game_variables_t *gvar)\r
{\r
\r
void\r
modexWaitBorder() {\r
- while(inp(INPUT_STATUS_1) & 8) {\r
+ while(inp(STATUS_REGISTER_1) & 8) {\r
// spin\r
}\r
\r
- while(!(inp(INPUT_STATUS_1) & 8)) {\r
+ while(!(inp(STATUS_REGISTER_1) & 8)) {\r
//spin\r
}\r
}\r
void\r
modexWaitBorder_start()\r
{\r
- while(inp(INPUT_STATUS_1) & 8) {\r
+ while(inp(STATUS_REGISTER_1) & 8) {\r
// spin\r
}\r
\r
void\r
modexWaitBorder_end()\r
{\r
- while(!(inp(INPUT_STATUS_1) & 8)) {\r
+ while(!(inp(STATUS_REGISTER_1) & 8)) {\r
// spin\r
}\r
\r
// printf("========================================\n");\r
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");\r
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");\r
- printf(" stride: %u ", vga_state.vga_stride);\r
+ printf(" vga_stride: %u ", vga_state.vga_stride);\r
+ printf("pagestride: %u ", v->page[0].stridew);\r
printf("draw_stride: %u ", vga_state.vga_draw_stride);\r
printf("draw_stride_limit: %u\n", vga_state.vga_draw_stride_limit);\r
\r