int86(0x10, &in, &out);\r
gv->old_mode = out.h.al;\r
// enter mode\r
- modexEnter();\r
+ modex__320x240_256__Enter(gv);\r
}\r
}\r
\r
int86(VIDEO_INT, ®s, ®s);\r
}\r
\r
-\r
/* -========================= Entry Points ==========================- */\r
void\r
-modexEnter() {\r
- word i;\r
- dword far*ptr=(dword far*)VGA; /* used for faster screen clearing */\r
- word CRTParms[] = {\r
- 0x0d06, /* vertical total */\r
- 0x3e07, /* overflow (bit 8 of vertical counts) */\r
- 0x4109, /* cell height (2 to double-scan */\r
- 0xea10, /* v sync start */\r
- 0xac11, /* v sync end and protect cr0-cr7 */\r
- 0xdf12, /* vertical displayed */\r
- 0x0014, /* turn off dword mode */\r
- 0xe715, /* v blank start */\r
- 0x0616, /* v blank end */\r
- 0xe317 /* turn on byte mode */\r
- };\r
- int CRTParmCount = sizeof(CRTParms) / sizeof(CRTParms[0]);\r
-\r
- /* TODO save current video mode and palette */\r
- vgaSetMode(VGA_256_COLOR_MODE);\r
-\r
- /* disable chain4 mode */\r
- outpw(SC_INDEX, 0x0604);\r
-\r
- /* synchronous reset while setting Misc Output */\r
- outpw(SC_INDEX, 0x0100);\r
-\r
- /* select 25 MHz dot clock & 60 Hz scanning rate */\r
- outp(MISC_OUTPUT, 0xe3);\r
-\r
- /* undo reset (restart sequencer) */\r
- outpw(SC_INDEX, 0x0300);\r
-\r
- /* reprogram the CRT controller */\r
- outp(CRTC_INDEX, 0x11); /* VSync End reg contains register write prot */\r
- outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */\r
-\r
- /* send the CRTParms */\r
- for(i=0; i<CRTParmCount; i++) {\r
- outpw(CRTC_INDEX, CRTParms[i]);\r
- }\r
+modex__320x240_256__Enter(global_game_variables_t *gv)\r
+{\r
+ word i;\r
+ dword far*ptr=(dword far*)VGA; /* used for faster screen clearing */\r
+ word CRTParms[] = {\r
+// 0xe300, /* horizontal total */\r
+ 0x4f01, /* horizontal display enable end */\r
+ 0x5002, /* */\r
+ 0x5404, /* */\r
+ 0x8005, /* */\r
+ 0x0d06, /* vertical total */\r
+ 0x3e07, /* overflow (bit 8 of vertical counts) */\r
+ 0x4109, /* cell height (2 to double-scan */\r
+ 0xea10, /* v sync start */\r
+ 0xac11, /* v sync end and protect cr0-cr7 */\r
+ 0xdf12, /* vertical displayed */\r
+ 0x2813, /* offset/logical width */\r
+ 0x0014, /* turn off dword mode */\r
+ 0xe715, /* v blank start */\r
+ 0x0616, /* v blank end */\r
+ 0xe317 /* turn on byte mode */\r
+ };\r
+\r
+ int CRTParmCount = sizeof(CRTParms) / sizeof(CRTParms[0]);\r
+ /* width and height */\r
+ //TODO WWWW\r
+\r
+ /* disable chain4 mode */\r
+ outpw(SC_INDEX, 0x0604);\r
+\r
+ /* synchronous reset while setting Misc Output */\r
+ outpw(SC_INDEX, 0x0100);\r
+\r
+ /* select 25 MHz dot clock & 60 Hz scanning rate */\r
+ outp(MISC_OUTPUT, 0xe3);\r
+\r
+ /* undo reset (restart sequencer) */\r
+ outpw(SC_INDEX, 0x0300);\r
+\r
+ /* reprogram the CRT controller */\r
+ outp(CRTC_INDEX, 0x11); /* VSync End reg contains register write prot */\r
+ outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */\r
+\r
+ /* send the CRTParms */\r
+ for(i=0; i<CRTParmCount; i++) {\r
+ outpw(CRTC_INDEX, CRTParms[i]);\r
+ }\r
\r
- /* clear video memory */\r
- outpw(SC_INDEX, 0x0f02);\r
- for(i=0; i<0x8000; i++) {\r
- ptr[i] = 0x0000;\r
- }\r
+ /* clear video memory */\r
+ outpw(SC_INDEX, 0x0f02);\r
+ for(i=0; i<0x8000; i++) {\r
+ ptr[i] = 0x0000;\r
+ }\r
}\r
\r
+// setBaseXMode() does the initialization to make the VGA ready to\r
+// accept any combination of configuration register settings. This\r
+// involves enabling writes to index 0 to 7 of the CRT controller (port\r
+// 0x3D4), by clearing the most significant bit (bit 7) of index 0x11.\r
+void\r
+modexsetBaseXMode(void)\r
+{\r
+ int temp;\r
+\r
+ /* TODO save current video mode and palette */\r
+ vgaSetMode(VGA_256_COLOR_MODE);\r
+\r
+ outp(CRTC_INDEX, 0x11);\r
+ temp = inp(CRTC_DATA) & 0x7F;\r
+ outp(CRTC_INDEX, 0x11);\r
+ outp(CRTC_DATA, temp);\r
+}\r
\r
void\r
modexLeave() {\r
page.dy = 0;\r
page.width = SCREEN_WIDTH;\r
page.height = SCREEN_HEIGHT;\r
- page.id = 0;\r
+ page.tw = page.width/TILEWH;\r
+ page.th = page.height/TILEWH;\r
+ page.id = 0;\r
\r
return page;\r
}\r
result.dy = 0;\r
result.width = p->width;\r
result.height = p->height;\r
- result.id = p->id+1;\r
- //result = modexNextPageFlexibleSize(&p, p->width, p->height);\r
- return result;\r
+ result.tw = p->width/TILEWH;\r
+ result.th = p->height/TILEWH;\r
+ result.id = p->id+1;\r
+\r
+ return result;\r
+// return modexNextPageFlexibleSize(&p, p->width, p->height);\r
}\r
\r
//next page with defined dimentions~\r
page_t\r
modexNextPageFlexibleSize(page_t *p, word x, word y)\r
{\r
- page_t result;\r
-\r
- result.data = p->data + (p->width/4)*p->height; /* compute the offset */\r
- result.dx = 0;\r
- result.dy = 0;\r
- result.width = x;\r
- result.height = y;\r
- result.id = p->id+1;\r
-\r
- return result;\r
+ page_t result;\r
+\r
+ result.data = p->data + (p->width/4)*p->height; /* compute the offset */\r
+ result.dx = 0;\r
+ result.dy = 0;\r
+ result.width = x;\r
+ result.height = y;\r
+ result.tw = p->width/TILEWH;\r
+ result.th = p->height/TILEWH;\r
+ result.id = p->id+1;\r
+\r
+ return result;\r
}\r
\r
\r
}\r
}\r
\r
+void\r
+modex_sparky4_DrawBmpRegion(page_t *page, int x, int y,\r
+ int rx, int ry, int rw, int rh, bitmap_t *bmp) {\r
+ word poffset = (word) page->data + y*(page->width/4) + x/4;\r
+ byte far *data = bmp->data;//+bmp->offset;\r
+ word bmpOffset = (word) data + ry * bmp->width + rx;\r
+ word width = rw;\r
+ word height = rh;\r
+ byte plane = 1 << ((byte) x & 0x03);\r
+ word scanCount = width/4 + (width%4 ? 1 :0);\r
+ word nextPageRow = page->width/4 - scanCount;\r
+ word nextBmpRow = (word) bmp->width - width;\r
+ word rowCounter;\r
+ byte planeCounter = 4;\r
+\r
+/* printf("bmp->data=%Fp\n",bmp->data);\r
+ printf("*bmp->data=%Fp\n",*(bmp->data));\r
+ printf("&bmp->data=%Fp\n",&(bmp->data));*/\r
+\r
+ //code is a bit slow here\r
+ __asm {\r
+ MOV AX, SCREEN_SEG ; go to the VGA memory\r
+ MOV ES, AX\r
+\r
+ MOV DX, SC_INDEX ; point at the map mask register\r
+ MOV AL, MAP_MASK ;\r
+ OUT DX, AL ;\r
+\r
+ PLANE_LOOP:\r
+ MOV DX, SC_DATA ; select the current plane\r
+ MOV AL, plane ;\r
+ OUT DX, AL ;\r
+\r
+ ;-- begin plane painting\r
+ MOV AX, height ; start the row counter\r
+ MOV rowCounter, AX ;\r
+ MOV DI, poffset ; go to the first pixel\r
+ MOV SI, bmpOffset ; go to the bmp pixel\r
+ ROW_LOOP:\r
+ MOV CX, width ; count the columns\r
+ SCAN_LOOP:\r
+ MOVSB ; copy the pixel\r
+ SUB CX, 3 ; we skip the next 3\r
+ ADD SI, 3 ; skip the bmp pixels\r
+ LOOP SCAN_LOOP ; finish the scan\r
+\r
+ MOV AX, nextPageRow\r
+ ADD DI, AX ; go to the next row on screen\r
+ MOV AX, nextBmpRow\r
+ ADD SI, AX ; go to the next row on bmp\r
+\r
+ DEC rowCounter\r
+ JNZ ROW_LOOP ; do all the rows\r
+ ;-- end plane painting\r
+\r
+ MOV AL, plane ; advance to the next plane\r
+ SHL AL, 1 ;\r
+ AND AL, 0x0f ; mask the plane properly\r
+ MOV plane, AL ; store the plane\r
+\r
+ INC bmpOffset ; start bmp at the right spot\r
+\r
+ DEC planeCounter\r
+ JNZ PLANE_LOOP ; do all 4 planes\r
+ }\r
+}\r
\r
void\r
modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp) {\r