#define GRAC_ADDR 0x3ce /* Base port of the Graphics Controller */\r
#define STATUS_ADDR 0x3DA\r
\r
-unsigned char *RowsX[600];\r
-unsigned char write_plane, read_plane;\r
-unsigned short text_mask[16] = { 0x0002, 0x0102, 0x0202, 0x0302,\r
- 0x0402, 0x0502, 0x0602, 0x0702,\r
- 0x0802, 0x0902, 0x0A02, 0x0B02,\r
- 0x0C02, 0x0D02, 0x0E02, 0x0F02 };\r
-\r
\r
/*\r
* Make a far pointer to the VGA graphics buffer segment. Your compiler\r
to be based at offset 0 in the video segment. */\r
actStart = visStart = 0;\r
\r
- /*\r
---------------------\r
-HORIZONTAL SCROLLING\r
---------------------\r
-Horizontal scrolling is essentially the same as vertical scrolling, all\r
-you do is increment or decrement the VGA offset register by 1 instead of\r
-80 as with vertical scrolling.\r
-\r
-However, horizontal scrolling is complicated by two things\r
-\r
- 1. Incrementing the offset register by one actually scrolls by FOUR\r
- pixels (and there are FOUR planes on the VGA, what a coincidence)\r
-\r
- 2. You can't draw the image off the screen and then scroll it on\r
- because of the way the VGA wraps to the next row every 80 bytes\r
- (80 bytes * 4 planes = 320 pixels), if you tried it, you would\r
- actually be drawing to the other side of the screen (which is\r
- entirely visible)\r
-\r
-I'll solve these problems one at a time.\r
-\r
-Firstly, to get the VGA to scroll by only one pixel you use the horizontal\r
-pixel panning (HPP) register. This register resides at\r
-\r
- PORT: 3C0H\r
- INDEX: 13h\r
-\r
-and in real life, you use it like this\r
-\r
------------------ Pixel Panning ---------------\r
-IN PORT 3DAH (this clears an internal\r
- flip-flop of the VGA)\r
-OUT 13H TO PORT 3C0H\r
-OUT value TO PORT 3C0H (where "value" is the\r
- number of pixels to offset)\r
------------------------------------------------\r
-*/\r
-\r
-//mxSetVirtualScreen(480,360);\r
}\r
\r
/*\r
\r
if(!vq){ // deinit the video\r
// change to the video mode we were in before we switched to mode 13h\r
- mxSetMode( MX_TEXT );\r
- //in.h.ah = 0x00;\r
- //in.h.al = old_mode;\r
- //int86(0x10, &in, &out);
+ //mxSetMode( MX_TEXT );\r
mxTerm();\r
+ in.h.ah = 0x00;\r
+ in.h.al = old_mode;\r
+ int86(0x10, &in, &out);\r
\r
}else if(vq == 1){ // init the video\r
// get old video mode\r
- //in.h.ah = 0xf;\r
- //int86(0x10, &in, &out);\r
- //old_mode = out.h.al;\r
+ in.h.ah = 0xf;\r
+ int86(0x10, &in, &out);\r
+ old_mode = out.h.al;\r
\r
// enter mode\r
mxInit();\r
mxSetMode( MX_320x240 );\r
- mxSetVirtualScreen( 480, 360 );\r
+ width=320;\r
+ height=240;\r
+// mxSetVirtualScreen(width+(width/4), height+(height/4));\r
+// mxSetVirtualScreen(width*2, height*2);\r
//set320x240x256_X();\r
- //mxSetMode(MX_320x240);\r
- //mxSetVirtualScreen(560,420);\r
- //mxSetVirtualScreen((640-TILEWH),(480-TILEWH));\r
- //mxSetClip( TRUE );\r
+ mxSetVirtualScreen(560,420);\r
+// mxSetVirtualScreen((640-(TILEWH*2)),(480-(TILEWH*2)));\r
+ mxSetClip(0);\r
+ //mxSetClipRegion(0, 0, width, height);\r
}\r
}\r
\r
}\r
// fixer\r
// if(q!=16){\r
-//if(q!=16)\r
-// if(xx<0) xx=(width-TILEWH);\r
-// if(yy<0) yy=(height-TILEWH);\r
-// if(xx>(width-TILEWH)) xx=0;\r
-// if(yy>(height-TILEWH)) yy=0;\r
+ if(xx<0) xx=(560/*-TILEWH*/);\r
+ if(yy<0) yy=(420/*-TILEWH*/);\r
+ if(xx>(560/*-TILEWH*/)) xx=0;\r
+ if(yy>(420/*-TILEWH*/)) yy=0;\r
// }\r
\r
//interesting effects\r
int tx=0,ty=0;\r
tx+=xx+16;\r
ty+=yy+16;\r
- putPixel_X(tx, ty, coor);\r
+ mxPutPixel(tx, ty, coor);\r
//drawrect(tx, ty, tx+TILEWH, ty+TILEWH, coor);\r
//printf("%d %d %d %d %d %d\n", xx, yy, tx, ty, TILEWH);\r
\r
// plot the pixel\r
//---- ppf(xx, yy, coor, vga);\r
}else /*if(xx>=0 && xx<width && yy>=0 && yy<(height*3))*/{\r
-// putColorBox_X(xx, yy, TILEWH, TILEWH, coor);\r
+// mxFillBox(xx, yy, TILEWH, TILEWH, coor, 0);\r
//++++0000\r
-// putPixel_X(xx, yy, coor);
+// putPixel_X(xx, yy, coor);\r
mxPutPixel(xx, yy, coor);\r
} \r
\r
//---- if(q==2) ppf(rand()%, rand()%height, 0, vga);\r
// if(q==2) putColorBox_X(rand()%width, rand()%(height*3), TILEWH, TILEWH, 0);\r
//++++0000\r
- if(q==2) putPixel_X(rand()%width, rand()%(height*3), 0);\r
- if(q==16) putPixel_X(rand()%width, rand()%(height*3), 0);\r
+ if(q==2) mxPutPixel(rand()%width, rand()%(height*3), 0);\r
+ if(q==16) mxPutPixel(rand()%width, rand()%(height*3), 0);\r
if(q==2||q==4||q==16){ bakax = rand()%3; bakay = rand()%3; }\r
gq++;\r
//if(xx<0||xx>320||yy<0||yy>(height*3))\r
// printf("%d %d %d %d %d %d\n", xx, yy, coor, bakax, bakay, getPixel_X(xx,yy));\r
// printf("%d\n", getPixel_X(xx,yy));\r
-//0000\r
-// drawText(0, 0, 15, getPixel_X(xx,yy));\r
}else gq = LGQ;\r
return gq;\r
}\r
//{\r
for (x = 0; x <= width; ++x)\r
{\r
- putPixel_X(x, 0, p+1);\r
- if(p!=pages) putPixel_X(x, height-1, p+1);\r
- else if(height==240) putPixel_X(x, 99-1, p+1);\r
+// putPixel_X(x, 0, p+1);\r
+ mxPutPixel(x, 0, p+1);\r
+ if(p!=pages) mxPutPixel(x, height-1, p+1);\r
+ else if(height==240) mxPutPixel(x, 99-1, p+1);\r
}\r
\r
for (y = 0; y <= height; ++y)\r
{\r
- putPixel_X(0, y, p+1);\r
- if(p!=pages) putPixel_X(width-1, y, p+1);\r
- else if(height==240) putPixel_X(width-1, y, p+1);\r
+ mxPutPixel(0, y, p+1);\r
+ if(p!=pages) mxPutPixel(width-1, y, p+1);\r
+ else if(height==240) mxPutPixel(width-1, y, p+1);\r
}\r
\r
for (x = 0; x < TILEWH; ++x)\r
for (y = 0; y < TILEWH; ++y)\r
- putPixel_X(x+(p+2)*16, y+(p+2)*TILEWH, x + y*TILEWH);\r
+ mxPutPixel(x+(p+2)*16, y+(p+2)*TILEWH, x + y*TILEWH);\r
//}\r
\r
}\r
\r
int main(void)\r
{\r
- int key,d,x,y;\r
+ int key,d,xpos,ypos,xdir,ydir;\r
//short int temp;\r
// main variables\r
d=1; // switch variable\r
key=4; // default screensaver number\r
- x=0;\r
- y=0;\r
+ xpos=0;\r
+ ypos=0;
+ xdir=1;\r
+ ydir=1;\r
// puts("First, have a look at the 320x200 mode. I will draw some rubbish");\r
// puts("on all of the four pages, then let you cycle through them by");\r
// puts("hitting a key on each page.");\r
\r
//++++0000\r
setvideo(1);\r
- /*temp = loadfontX("vga8x8.fnt");\r
-\r
- if (temp) {\r
- putstringX(0, 0, "bakapi!", 2);\r
- }\r
- getch();*/\r
// screen savers\r
\r
/*while(d!=0){ // on!\r
}\r
}*/ // else off\r
while(!kbhit()){ // conditions of screen saver\r
- ding(4);\r
+ ding(key);\r
}\r
//end of screen savers\r
//doTest();\r
+ for (int x = 0; x < width; ++x)\r
+ {\r
+ mxPutPixel(x, 0, 15);\r
+ mxPutPixel(x, height-1, 15);\r
+ }\r
+ for (int y = 0; y < height; ++y)\r
+ {\r
+ mxPutPixel(0, y, 15);\r
+ mxPutPixel(width-1, y, 15);\r
+ }\r
getch();\r
-\r
- while(!kbhit()){ // conditions of screen saver\r
+ while(!kbhit()){\r
// hScroll(1);\r
// scrolly(1);\r
// vScroll(1);\r
-// delay(100);
- for(int i=0;i<TILEWH;i++){\r
- mxPan(x,y);\r
+// delay(100);\r
+ //for(int i=0;i<TILEWH;i++){\r
+ ding(key);\r
+ mxPan(xpos,ypos);\r
mxWaitRetrace();\r
- x++;
- y++;\r
- }
- //delay(100);\r
+ xpos=xpos+xdir;\r
+ ypos=ypos+ydir;\r
+ if( (xpos>239) || (xpos<1))xdir=-xdir;\r
+ if( (ypos>179) || (ypos<1))ydir=-ydir; // { Hit a boundry, change\r
+ // direction! }\r
+ //}\r
}\r
setvideo(0);\r
printf("wwww\n%dx%d\n", width,height);\r