\r
switch(vq)\r
{\r
- case 0:\r
+ case 1:\r
CRTParmCount = sizeof(ModeX_320x240regs) / sizeof(ModeX_320x240regs[0]);\r
/* width and height */\r
- gv->video.page->sw=320;\r
- gv->video.page->sh=240;\r
- gv->video.page->tilesw = gv->video.page->sw/TILEWH;\r
- gv->video.page->tilesh = gv->video.page->sh/TILEWH;\r
- //TODO MAKE FLEXIBLE~\r
- gv->video.page->tilemidposscreenx = 10;\r
- gv->video.page->tilemidposscreeny = 8;\r
+ gv->video.page[0].sw=320;\r
+ gv->video.page[0].sh=240;\r
\r
/* send the CRTParms */\r
for(i=0; i<CRTParmCount; i++) {\r
ptr[i] = 0x0000;\r
}\r
break;\r
- case 1:\r
+ case 2:\r
+ CRTParmCount = sizeof(ModeX_160x120regs) / sizeof(ModeX_160x120regs[0]);\r
+ /* width and height */\r
+ gv->video.page[0].sw=120;\r
+ gv->video.page[0].sh=160;\r
+\r
+ /* send the CRTParms */\r
+ for(i=0; i<CRTParmCount; i++) {\r
+ outpw(CRTC_INDEX, ModeX_160x120regs[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
+ break;\r
+ case 3:\r
+ CRTParmCount = sizeof(ModeX_320x200regs) / sizeof(ModeX_320x200regs[0]);\r
+ /* width and height */\r
+ gv->video.page[0].sw=320;\r
+ gv->video.page[0].sh=200;\r
+\r
+ /* send the CRTParms */\r
+ for(i=0; i<CRTParmCount; i++) {\r
+ outpw(CRTC_INDEX, ModeX_320x200regs[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
+ break;\r
+ case 4:\r
CRTParmCount = sizeof(ModeX_192x144regs) / sizeof(ModeX_192x144regs[0]);\r
/* width and height */\r
- //TODO add width and height of screen\r
+ gv->video.page[0].sw=192;\r
+ gv->video.page[0].sh=144;\r
\r
/* send the CRTParms */\r
for(i=0; i<CRTParmCount; i++) {\r
ptr[i] = 0x0000;\r
}\r
break;\r
+ case 5:\r
+ CRTParmCount = sizeof(ModeX_256x192regs) / sizeof(ModeX_256x192regs[0]);\r
+ /* width and height */\r
+ gv->video.page[0].sw=256;\r
+ gv->video.page[0].sh=192;\r
+\r
+ /* send the CRTParms */\r
+ for(i=0; i<CRTParmCount; i++) {\r
+ outpw(CRTC_INDEX, ModeX_256x192regs[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
+ break;\r
}\r
+ gv->video.page[0].tilesw = gv->video.page[0].sw/TILEWH;\r
+ gv->video.page[0].tilesh = gv->video.page[0].sh/TILEWH;\r
+ //TODO MAKE FLEXIBLE~\r
+ gv->video.page[0].tilemidposscreenx = gv->video.page[0].tilesw;\r
+ gv->video.page[0].tilemidposscreeny = (gv->video.page[0].tilesh/2)+1;\r
+ #define PAGE_SIZE (word)(gv->video.page[0].sw/4 * gv->video.page[0].sh)\r
}\r
\r
void\r
\r
/* reprogram the CRT controller */\r
outp(CRTC_INDEX, 0x11); /* VSync End reg contains register write prot */\r
- temp = inp(CRTC_DATA) & 0x7F;\r
- outp(CRTC_INDEX, 0x11);\r
-// outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */\r
- outp(CRTC_DATA, temp); /* get current write protect on varios regs */\r
+// temp = inp(CRTC_DATA) & 0x7F;\r
+// outp(CRTC_INDEX, 0x11);\r
+ outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */\r
+// outp(CRTC_DATA, temp); /* get current write protect on varios regs */\r
}\r
\r
page_t\r
-modexDefaultPage() {\r
+modexDefaultPage(page_t *p)\r
+{\r
page_t page;\r
\r
/* default page values */\r
page.data = VGA;\r
page.dx = 0;\r
page.dy = 0;\r
- page.width = SCREEN_WIDTH;\r
- page.height = SCREEN_HEIGHT;\r
- page.tw = page.width/TILEWH;\r
- page.th = page.height/TILEWH;\r
+ page.sw = p->sw;\r
+ page.sh = p->sh;\r
+ page.width = p->sw;\r
+ page.height = p->sh;\r
+ page.tw = page.sw/TILEWH;\r
+ page.th = page.sh/TILEWH;\r
+ page.tilemidposscreenx = page.tw/2;\r
+ page.tilemidposscreeny = (page.th/2)+1;\r
+ page.tilesw=p->tilesw;\r
+ page.tilesh=p->tilesh;\r
+ //pageSize = p->sw*p->sh;\r
page.id = 0;\r
\r
return page;\r
}\r
}\r
\r
+void\r
+DrawPBuf(page_t *page, int x, int y, planar_buf_t *p, byte sprite)\r
+{\r
+ int plane;\r
+ int px, py, i;\r
+// byte near *buff;\r
+\r
+ px=x;\r
+ py=y;\r
+// buff = _nmalloc(p->pwidth+1);\r
+ // TODO Make this fast. It's SLOOOOOOW\r
+// for(plane=0; plane < 4; plane++) {\r
+// i=0;\r
+// modexSelectPlane(PLANE(plane+x));\r
+// for(px = plane; px < p->width; px+=4) {\r
+// offset=px;\r
+// for(py=0; py<p->height/2; py++) {\r
+// //SELECT_ALL_PLANES();\r
+// if(!sprite || p->plane[offset])\r
+// page->data = &(p->plane[offset][i++]);\r
+// offset+=p->width;\r
+// offset++;\r
+// }\r
+// }\r
+// }\r
+ for(plane=0; plane < 4; plane++) {\r
+ i=0;\r
+ modexSelectPlane(PLANE(plane+x));\r
+ for(; y < py+p->height; y++) {\r
+ //for(px=0; px < p->width; px++) {\r
+ //printf("%02X ", (int) p->plane[plane][i++]);\r
+// _fmemcpy(buff, &(p->plane[plane][i+=p->pwidth]), p->pwidth);\r
+// printf("buff %u==%s\n", y, *buff);\r
+// _fmemcpy(page->data + (((page->width/4) * (y+page->dy)) + ((x+page->dx) / 4)), buff, p->pwidth);\r
+ _fmemcpy(page->data + (((page->width/4) * (y+page->dy)) + ((x+page->dx) / 4)), &(p->plane[plane][i+=p->pwidth]), p->pwidth);\r
+ //}\r
+ }\r
+ x=px;\r
+ y=py;\r
+ }\r
+// _nfree(buff);\r
+}\r
\r
void\r
oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite)\r
modexDrawBmpRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
}\r
\r
-\r
void\r
modexDrawBmpRegion(page_t *page, int x, int y,\r
int rx, int ry, int rw, int rh, bitmap_t *bmp) {\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
+modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp) {\r
+ /* TODO - adapt from test code */\r
+ int plane;\r
+ for(plane=0; plane < 4; plane++)\r
+ {\r
+ //fack\r
+ }\r
+}\r
+\r
+\r
+void\r
+modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {\r
+ /* draw the whole sprite */\r
+ modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
+}\r
+\r
+/*void\r
+modexDrawSpriteRegion(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 *data = bmp->data;//+bmp->offset;\r
word bmpOffset = (word) data + ry * bmp->width + rx;\r
word width = rw;\r
word height = rh;\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
ROW_LOOP:\r
MOV CX, width ; count the columns\r
SCAN_LOOP:\r
+ LODSB\r
+ DEC SI\r
+ CMP AL, 0\r
+ JNE DRAW_PIXEL ; draw non-zero pixels\r
+\r
+ INC DI ; skip the transparent pixel\r
+ ADD SI, 1\r
+ JMP NEXT_PIXEL\r
+ DRAW_PIXEL:\r
MOVSB ; copy the pixel\r
+ NEXT_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
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
- /* TODO - adapt from test code */\r
- int plane;\r
- for(plane=0; plane < 4; plane++)\r
- {\r
- //fack\r
- }\r
-}\r
-\r
-\r
-void\r
-modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {\r
- /* draw the whole sprite */\r
- modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
-}\r
+}//backup!*/\r
\r
void\r
modexDrawSpriteRegion(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 *data = bmp->data;//+bmp->offset;\r
+ byte huge *data = bmp->data;//+bmp->offset;\r
word bmpOffset = (word) data + ry * bmp->width + rx;\r
word width = rw;\r
word height = rh;\r
}\r
}\r
\r
-\r
/* copy a region of video memory from one page to another.\r
* It assumes that the left edge of the tile is the same on both\r
* regions and the memory areas do not overlap.\r
}\r
}\r
\r
+void\r
+modexPalOverscan(byte *p, word col)\r
+{\r
+ modexWaitBorder();\r
+ outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */\r
+ outp(PAL_DATA_REG, col);\r
+}\r
+\r
//color checker~\r
//i want to make another vesion that checks the palette when the palette is being appened~\r
void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/)\r
\r
for(x=0;x<xh*4;x+=4)\r
{\r
- if(x+4>=SCREEN_WIDTH-1){ x=0; yy+=4; }\r
+ if(x+4>=page[0].sw-1){ x=0; yy+=4; }\r
modexClearRegion(page, x+xl, y+yy, 4, 4, color);\r
}\r
//modexputPixel(page, x+xl, y, color);\r