1 //DOS Graphics thingy by sparky4 licence GPL v2
\r
2 //a special thanks to everyone to release source code for mode X
\r
11 short bakax = 0, bakay = 0;
\r
12 syte xx = rand()&0%SW, yy = rand()&0%SH, sx = 0, sy = 0;
\r
15 byte *vga = (byte *) MK_FP(0xA000, 0);
\r
18 * Comment out the following #define if you don't want the testing main()
\r
24 /////////////////////////////////////////////////////////////////////////////
\r
26 // setvideo() - This function Manages the video modes //
\r
28 /////////////////////////////////////////////////////////////////////////////
\r
29 void setvideo(/*byte mode, */short vq){
\r
32 if(!vq){ // deinit the video
\r
33 // change to the video mode we were in before we switched to mode 13h
\r
34 //mxSetMode( MX_TEXT );
\r
38 int86(0x10, &in, &out);
\r
40 }else if(vq==1){ // init the video
\r
41 // get old video mode
\r
43 int86(0x10, &in, &out);
\r
44 old_mode = out.h.al;
\r
48 mxSetMode( MX_320x240 );
\r
49 // mxSetVirtualScreen(SW+(SW/4), SH+(SH/4));
\r
50 // mxSetVirtualScreen(SW*2, SH*2);
\r
51 mxSetVirtualScreen(VW,BH);
\r
52 // mxSetVirtualScreen((640-(TILEWH*4)),(480-(TILEWH*4)));
\r
54 mxSetClipRegion(0, 0, VW, BH);
\r
55 mxPan(TILEWH*2,TILEWH*2);
\r
56 //mxSetClipRegion(0, VH+1, VW, (TILEWH*BUFFMX));
\r
64 for(int paly=0; paly<palq; paly++){
65 for(int palx=0; palx<palq; palx++){
66 mxFillBox((SW-palq)+palx+32, paly+32, TILEWH, TILEWH, palcol, OP_SET);
67 for(int i=1; i<mult; i++) palx++;
70 for(int i=1; i<mult; i++) paly++;
74 /////////////////////////////////////////////////////////////////////////////
\r
76 // cls() - This clears the screen to the specified color, on the VGA or on //
\r
77 // the Virtual screen. //
\r
79 /////////////////////////////////////////////////////////////////////////////
\r
80 void cls(byte color, byte *Where){
\r
81 _fmemset(Where, color, VW*(VH*2));
\r
84 //color
\82Ä
\82·
\82Æ
\r
86 if(gq < NUM_COLORS){
\r
93 //color
\82Ä
\82·
\82Æ
\r
96 //---- cls(gq, vaddr);
\r
103 //slow spectrum down
\r
104 void ssd(short svq){
\r
107 //plotpixel(xx, yy, coor, vga);
\r
108 //ppf(sx, sy, coor, vga);
\r
109 mxPutPixel(sx, sy, coor);
\r
110 //printf("%d %d %d %d\n", sx, sy, svq, coor);
\r
115 if(svq == 7) coor++;
\r
116 if(sy == SH && svq == 8) coor = rand()%NUM_COLORS;
\r
121 /*-----------ding-------------*/
\r
126 //++++ if(q <= 4 && q!=2 && gq == BONK-1) coor = rand()%HGQ;
\r
131 if(coor < HGQ && coor < LGQ) coor = LGQ;
\r
135 bakax = rand()%3; bakay = rand()%3;
\r
139 if(q==8){ colorz(); return gq; mxOutText(SW/2, SH/2, "bakapi"); }else
\r
140 if(q==10){ ssd(q); /*printf("%d\n", coor);*/ }else
\r
141 if(q==5){ colortest(); return gq; }else
\r
142 if(q==11){ colorz(); delay(100); return gq; }
\r
144 coor = rand()%NUM_COLORS;
\r
152 if(q == 9){ ssd(q); coor++; }
\r
156 if((q<5 && gq<BONK) || (q==16 && gq<BONK)){ // the number variable make the colors more noticable
\r
158 if(xx==VW){bakax=0;}
\r
159 if(xx==0){bakax=1;}
\r
160 if(yy==VH){bakay=0;}
\r
161 if(yy==0){bakay=1;}
\r
163 if(xx!=VW||yy!=VH){
\r
164 if(xx==0){bakax=1;bakay=-1;d3y=1;}
\r
165 if(yy==0){bakax=1;bakay=0;d3y=1;}
\r
166 if(xx==VW){bakax=-1;bakay=-1;d3y=1;}
\r
167 if(yy==VH){bakax=1;bakay=0;d3y=1;}
\r
168 }else if(xx==VW&&yy==VH) xx=yy=0;
\r
232 if(xx<0) xx=(VW-TILEWH);
\r
233 if(yy<0) yy=(VH-TILEWH);
\r
234 if(xx>(VW-TILEWH)) xx=0;
\r
235 if(yy>(VH-TILEWH)/*+(TILEWH*BUFFMX)*/) yy=0;
\r
244 //interesting effects
\r
250 mxPutPixel(tx, ty, coor);
\r
251 //printf("%d %d %d %d %d %d\n", xx, yy, tx, ty, TILEWH);
\r
256 mxFillBox(xx, yy, TILEWH, TILEWH, coor, OP_SET);
\r
258 mxPutPixel(xx, yy, coor);
\r
264 mxFillBox((rand()*TILEWH)%VW, (rand()*TILEWH)%(VH), TILEWH, TILEWH, 0, OP_SET);
\r
266 mxPutPixel(rand()%VW, rand()%(VH), 0);
\r
268 if(q==16) mxPutPixel(rand()%VW, rand()%(VH), 0);
\r
269 if(q==2||q==4||q==16){ bakax = rand()%3; bakay = rand()%3; } //random 3 switch
\r
271 //if(xx<0||xx>320||yy<0||yy>(SH*3))
\r
272 // printf("%d %d %d %d %d\n", xx, yy, coor, bakax, bakay);
\r
279 * The library testing routines follows below.
\r
285 * Library test (program) entry point.
\r
290 short key,d,xpos,ypos,xdir,ydir;
\r
293 d=4; // switch variable
\r
294 key=2; // default screensaver number
\r
302 /*while(d!=0){ // on!
\r
303 if(!kbhit()){ // conditions of screen saver
\r
307 // user imput switch
\r
308 printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 5 to quit.\n", getch()); // prompt the user
\r
310 //if(key==3){xx=yy=0;} // crazy screen saver wwww
\r
315 mxFillBox(0, 0, VW, BH, 10, OP_SET);
\r
316 while(1){ // conditions of screen saver
\r
320 //end of screen savers
\r
322 /* for (int x = 0; x < VW; ++x)
\r
324 mxPutPixel(x, 0, 15);
\r
325 mxPutPixel(x, SH-1, 15);
\r
327 for (int y = 0; y < VH; ++y)
\r
329 mxPutPixel(0, y, 15);
\r
330 mxPutPixel(SW-1, y, 15);
\r
332 for (int x = 0; x < VW; ++x)
\r
334 mxPutPixel(x, 0, 15);
\r
335 mxPutPixel(x, VH-1, 15);
\r
337 for (int y = 240; y < VH; ++y)
\r
339 mxPutPixel(0, y, 15);
\r
340 mxPutPixel(VW-1, y, 15);
\r
346 mxSetTextColor(10, OP_TRANS); //set font
\r
347 mxBitBlt(xpos, ypos+(TILEWH*12), SW, TILEWH*BUFFMX, 0, BS); //copy background
\r
348 mxFillBox(xpos, ypos+(TILEWH*12), SW, TILEWH*BUFFMX, 0, OP_SET); // background for text box
\r
350 mxOutText(xpos+1, ypos+SH-48, "========================================");
\r
351 mxOutText(xpos+1, ypos+SH-40, "| |Chikyuu:$line1");
\r
352 mxOutText(xpos+1, ypos+SH-32, "| |$line2");
\r
353 mxOutText(xpos+1, ypos+SH-24, "| |$line3");
\r
354 mxOutText(xpos+1, ypos+SH-16, "| |$line4");
\r
355 mxOutText(xpos+1, ypos+SH-8, "========================================");
\r
356 mxFillBox(xpos+QUADWH, ypos+QUADWH+(TILEWH*12), TILEWH*2, TILEWH*2, 9, OP_SET); //portriat~
\r
358 mxBitBlt(0, BS, SW, TILEWH*BUFFMX, xpos, ypos+(TILEWH*12)); //copy background
\r
361 //for(int i=0;i<TILEWH;i++){
\r
365 mxFillBox(384, 304, 384, 304, 10, OP_SET);
\r
366 //mxBitBlt(xpos, ypos, SW, SH, 32, (SH+64+32));
\r
367 mxBitBlt(TILEWH*2, TILEWH*2, SW, SH, 32, (SH+64+32));
\r
368 //for(short o = 0; o<TILEWH; o++){
\r
371 //if(ypos==1 || (ypos==(BH-SH-1)))delay(500);
\r
372 //if((xpos>(VW-SW-1)) || (xpos<1))delay(500);
\r
374 //mxBitBlt(32, (SH+32), SW, SH, xpos, ypos);
375 mxBitBlt(TILEWH*2, (SH+64+32), SW, SH, TILEWH*2, TILEWH*2);
\r
376 //xpos=ypos=TILEWH*2;
\r
379 if( (xpos>(VW-SW-1)) || (xpos<1)){xdir=-xdir;}
\r
380 if( (ypos>(BH-SH-1)) || (ypos<1)){ydir=-ydir;} // { Hit a boundry, change
\r
382 //mxBitBlt(32, (SH+64+32), SW, SH, xpos, ypos);
383 //mxBitBlt(TILEWH*2, (SH+64+32), SW, SH, TILEWH*2, TILEWH*2);
\r
386 if(ch==0x71)break; // 'q'
\r
387 if(ch==0x1b)break; // 'ESC'
\r
390 printf("wwww\nFull Buffer Virtual Resolution: %dx%d\n", VW,BH);
\r
391 printf("Virtual Resolution: %dx%d\n", VW,VH);
\r
392 printf("Resolution: %dx%d\n", SW,SH);
\r
393 printf("Mode X Library Version: %d\n", mxGetVersion());
\r
394 printf("bakapi ver. 1.04.09.04\nis made by sparky4
\81i
\81\86\83Ö
\81\85\81j feel free to use it ^^\nLicence: GPL v2\n");
\r