]> 4ch.mooo.com Git - 16.git/blob - 16/16/TEST.C
16_ca needs huge amounts of work and I should remember what needs to be done soon...
[16.git] / 16 / 16 / TEST.C
1 #include "lib\modex16.h"\r
2 #include <stdio.h>
3
4 #include <stdlib.h>\r
5 //#include <iostream.h>
6 \r
7 word far* clock= (word far*) 0x046C; /* 18.2hz clock */\r
8
9 //color てすと\r
10 short gq = LGQ;
11
12 page_t page, page2;
13
14 //てすと\r
15 short bakax = 0, bakay = 0;\r
16 sword xx = 0, yy = 0, sx = 0, sy = 0;\r
17 byte coor;\r
18
19 //byte *vga = (byte *) MK_FP(0xA000, 0);
20 \r
21 /*\r
22  * Comment out the following #define if you don't want the testing main()\r
23  * to be included.\r
24  */\r
25 //#define TILE
26
27 \r
28 /*void pdump(){\r
29         int mult=(QUADWH)/2;\r
30         int palq=(mult)*16;\r
31         int palcol=0;\r
32         for(int paly=0; paly<palq; paly+=mult){\r
33                 for(int palx=0; palx<palq; palx+=mult){\r
34                                 //mxFillBox((SCREEN_WIDTH-palq)+palx+32, paly+32, TILEWH, TILEWH, palcol, OP_SET);
35                                 modexClearRegion(page_t *page, (SCREEN_WIDTH-palq)+palx+32, paly+32, TILEWH, TILEWH, palcol);\r
36                         palcol++;\r
37                 }\r
38         }\r
39 }\r
40 \r
41 /////////////////////////////////////////////////////////////////////////////\r
42 //                                                                                                                                               //\r
43 // cls() - This clears the screen to the specified color, on the VGA or on //\r
44 //               the Virtual screen.                                                                                     //\r
45 //                                                                                                                                               //\r
46 /////////////////////////////////////////////////////////////////////////////\r
47 void cls(byte color, byte *Where){\r
48                 _fmemset(Where, color, VW*(VH*2));\r
49 }\r
50 \r
51 //color てすと\r
52 short colortest(){\r
53                 if(gq < NUM_COLORS){\r
54                                 cls(gq, vga);\r
55                                 gq++;\r
56                 }else gq = 0;\r
57                 return gq;\r
58 }\r
59 \r
60 //color てすと\r
61 short colorz(){\r
62                 if(gq <= HGQ){\r
63 //----            cls(gq, vaddr);\r
64                                 cls(gq, vga);\r
65                                 gq++;\r
66                 }else gq = LGQ;\r
67                 return gq;\r
68 }\r
69 \r
70 //slow spectrum down\r
71 void ssd(short svq){\r
72                 if(sy < SCREEN_HEIGHT+1){\r
73                                 if(sx < SCREEN_WIDTH+1){\r
74                                                 //plotpixel(xx, yy, coor, vga);\r
75                                                 //ppf(sx, sy, coor, vga);\r
76                                                 //mxPutPixel(sx, sy, coor);
77                                                 modexClearRegion(page_t *page, sx, sy, 1, 1, coor);
78                                                 //printf("%d %d %d %d¥n", sx, sy, svq, coor);\r
79                                                 sx++;\r
80                                 }else sx = 0;\r
81                                 if(sx == SCREEN_WIDTH){\r
82                                                 sy++;\r
83                                                 if(svq == 7) coor++;\r
84                                                 if(sy == SCREEN_HEIGHT && svq == 8) coor = rand()%NUM_COLORS;\r
85                                 }\r
86                 }else sy = 0;\r
87 }*/\r
88 \r
89 /*-----------ding-------------*/\r
90 short ding(int q){\r
91
92                 page=modexDefaultPage();\r
93                 page2 = modexNextPage(&page);\r
94                 page.width += 32;\r
95                 page.height += 32;
96                 short d3y;\r
97 \r
98 //++++  if(q <= 4 && q!=2 && gq == BONK-1) coor = rand()%HGQ;\r
99                 if((q == 2\r
100                 ||q==4\r
101                 ||q==16\r
102                 ) && gq == BONK){\r
103                                                 if(coor < HGQ && coor < LGQ) coor = LGQ;\r
104                                                 if(coor < HGQ){\r
105                                                                 coor++;\r
106                                 }else{ coor = LGQ;\r
107                                                 bakax = rand()%3; bakay = rand()%3;\r
108                                 }\r
109                 }\r
110 \r
111 //              if(q==8){ colorz(); return gq; /*mxOutText(SCREEN_WIDTH/2, SCREEN_HEIGHT/2, "bakapi");*/ }else\r
112 //              if(q==10){ ssd(q); /*printf("%d¥n", coor);*/ }else\r
113 //              if(q==5){ colortest(); return gq; }else\r
114 //              if(q==11){ colorz(); delay(100); return gq; }\r
115 /*              if(q==6){\r
116                                 coor = rand()%NUM_COLORS;\r
117                                 cls(coor, vga);\r
118                                 //updatevbuff();\r
119                 }\r
120 \r
121                 /f(q==7||q==9){\r
122                                 if(gq <= HGQ){\r
123                                                 if(q == 7) ssd(q);\r
124                                                 if(q == 9){ ssd(q); coor++; }\r
125                                                 gq++;\r
126                                 }else gq = LGQ;\r
127                 }*/\r
128                 if((q<5 && gq<BONK) || (q==16 && gq<BONK)){ // the number variable make the colors more noticable\r
129                                 if(q==1){\r
130                                                 if(xx==VW){bakax=0;}\r
131                                                 if(xx==0){bakax=1;}\r
132                                                 if(yy==VH){bakay=0;}\r
133                                                 if(yy==0){bakay=1;}\r
134                                 }else if(q==3){\r
135                                                 if(xx!=VW||yy!=VH){\r
136                                                                 if(xx==0){bakax=1;bakay=-1;d3y=1;}\r
137                                                                 if(yy==0){bakax=1;bakay=0;d3y=1;}\r
138                                                                 if(xx==VW){bakax=-1;bakay=-1;d3y=1;}\r
139                                                                 if(yy==VH){bakax=1;bakay=0;d3y=1;}\r
140                                                 }else if(xx==VW&&yy==VH) xx=yy=0;\r
141                                 }\r
142                                 if(q==3){\r
143                                                 if(d3y){\r
144                                                                 if(bakay<0){\r
145                                                                                 yy--;\r
146                                                                                 d3y--;\r
147                                                                 }else\r
148                                                                 if(bakay>0){\r
149                                                                                 yy++;\r
150                                                                                 d3y--;\r
151                                                                 }\r
152                                                 }\r
153                                                 if(bakax<0){\r
154                                                                 xx--;\r
155                                                 }else\r
156                                                 if(bakax>0){\r
157                                                                 xx++;\r
158                                                 }\r
159                                 }else{\r
160                                                 if(q==16)\r
161                                                 {\r
162                                                                 if(!bakax){\r
163                                                                         xx--;\r
164                                                                 }else if(bakax>0){\r
165                                                                         xx++;\r
166                                                                 }\r
167                                                                 if(!bakay){\r
168                                                                         yy--;\r
169                                                                 }else if(bakay>0){\r
170                                                                         yy++;\r
171                                                                 }\r
172                                                 }else{\r
173                                                                 if(!bakax){\r
174                                                                         #ifdef TILE\r
175                                                                         xx-=TILEWH;\r
176                                                                         #else\r
177                                                                         xx--;\r
178                                                                         #endif\r
179                                                                 }else if(bakax>1){\r
180                                                                         #ifdef TILE\r
181                                                                         xx+=TILEWH;\r
182                                                                         #else\r
183                                                                         xx++;\r
184                                                                         #endif\r
185                                                                 }\r
186                                                                 if(!bakay){\r
187                                                                         #ifdef TILE\r
188                                                                         yy-=TILEWH;\r
189                                                                         #else\r
190                                                                         yy--;\r
191                                                                         #endif\r
192                                                                 }else if(bakay>1){\r
193                                                                         #ifdef TILE\r
194                                                                         yy+=TILEWH;\r
195                                                                         #else\r
196                                                                         yy++;\r
197                                                                         #endif\r
198                                                                 }\r
199                                                 }\r
200                                 }\r
201                                 // fixer\r
202                                 if(q!=16){\r
203                                         #ifdef TILE\r
204                                                 if(xx<0) xx=(VW-TILEWH);\r
205                                                 if(yy<0) yy=(VH-TILEWH);\r
206                                                 if(xx>(VW-TILEWH)) xx=0;\r
207                                                 if(yy>(VH-TILEWH)/*+(TILEWH*BUFFMX)*/) yy=0;\r
208                                         #else\r
209                                                 if(xx<0) xx=VW;\r
210                                                 if(yy<0) yy=VH;\r
211                                                 if(xx>VW) xx=0;\r
212                                                 if(yy>VH) yy=0;\r
213                                         #endif\r
214                                 }\r
215 \r
216 //interesting effects\r
217                                 if(q==16)\r
218                                 {\r
219                                 short tx=0,ty=0;\r
220                                 tx+=xx+16;\r
221                                 ty+=yy+16;\r
222                                 //mxPutPixel(tx, ty, coor);
223                                 modexClearRegion(page_t *page, tx, ty, 1, 1, coor);
224                                 //printf("%d %d %d %d %d %d¥n", xx, yy, tx, ty, TILEWH);\r
225 \r
226                                 // plot the pixel\r
227                                 }else{\r
228                                         #ifdef TILE\r
229                                         //mxFillBox(xx, yy, TILEWH, TILEWH, coor, OP_SET);
230                                         modexClearRegion(page_t *page, xx, yy, TILEWH, TILEWH, coor);\r
231                                         #else\r
232                                         //mxPutPixel(xx, yy, coor);
233                                         modexClearRegion(page_t *page, xx, yy, 1, 1, coor);\r
234                                         #endif\r
235                                 } \r
236 \r
237                                 if(q==2)\r
238                                 #ifdef TILE\r
239                                         //mxFillBox((rand()*TILEWH)%VW, (rand()*TILEWH)%(VH), TILEWH, TILEWH, 0, OP_SET);
240                                         modexClearRegion(page_t *page, (rand()*TILEWH)%VW, (rand()*TILEWH)%(VH), TILEWH, TILEWH, 0);\r
241                                 #else\r
242                                         //mxPutPixel(rand()%VW, rand()%(VH), 0);
243                                         modexClearRegion(page_t *page, rand()%VW, rand()%(VH), 1, 1, 0);\r
244                                 #endif\r
245                                 if(q==16) //mxPutPixel(rand()%VW, rand()%(VH), 0);
246                                         modexClearRegion(page_t *page, rand()%VW, rand()%(VH), 1, 1, 0);\r
247                                 if(q==2||q==4||q==16){ bakax = rand()%3; bakay = rand()%3; }  //random 3 switch\r
248                                 gq++;\r
249 //if(xx<0||xx>320||yy<0||yy>(SCREEN_HEIGHT*3))\r
250 //        printf("%d %d %d %d %d¥n", xx, yy, coor, bakax, bakay);\r
251                 }else gq = LGQ;\r
252                 return gq;\r
253 }\r
254 \r
255 void main() {\r
256     int i, j;\r
257     bitmap_t bmp;\r
258     word start, end;
259         //page_t page, page2;\r
260     float elapsed;\r
261     byte *pal, *pal2=NULL;\r
262 \r
263         /* load pcx file */\r
264         bmp = modexLoadPcx("ed.pcx");\r
265 \r
266     /* load our palette */\r
267     modexLoadPalFile("gfx.pal", &pal2);\r
268 \r
269     /* save the palette */\r
270     pal  = modexNewPal();\r
271     modexPalSave(pal);\r
272     modexFadeOff(1, pal);\r
273     modexPalBlack();\r
274 \r
275     setvideo(1);\r
276     modexPalBlack();\r
277 \r
278     /* set up the page, but with 16 pixels on all borders in offscreen mem */\r
279     page=modexDefaultPage();\r
280     page2 = modexNextPage(&page);\r
281     page.width += 32;\r
282     page.height += 32;\r
283 \r
284 \r
285     /* fill the page with one color, but with a black border */\r
286     modexShowPage(&page2);\r
287     modexClearRegion(&page, 16, 16, SCREEN_WIDTH, SCREEN_HEIGHT, 128);\r
288     modexClearRegion(&page, 32, 32, SCREEN_WIDTH-32, SCREEN_HEIGHT-32, 42);\r
289     modexClearRegion(&page, 48, 48, SCREEN_WIDTH-64, SCREEN_HEIGHT-64, 128);\r
290     modexShowPage(&page);\r
291 \r
292     modexDrawSprite(&page, 20, 20, &bmp);\r
293     //modexDrawBmp(&page, xb, yb, &bmp);\r
294 \r
295     /* fade in */\r
296     modexFadeOn(1, pal2);\r
297 \r
298 \r
299     start = *clock;\r
300     //for(i=0; i<5; i++) {\r
301     while (!kbhit()){  /* Wait for a keystroke                         */\r
302         /* go right */\r
303         for(j=0; j<32; j++) {\r
304             page.dx++;\r
305             modexShowPage(&page);\r
306         }\r
307         /* go left */\r
308         for(j=0; j<32; j++) {\r
309             page.dx--;\r
310             modexShowPage(&page);\r
311         }\r
312         /* go up */\r
313         for(j=0; j<32; j++) {\r
314             page.dy++;\r
315             modexShowPage(&page);\r
316         }\r
317 \r
318         /* go down */\r
319         for(j=0; j<32; j++) {\r
320             page.dy--;\r
321             modexShowPage(&page);\r
322         }\r
323     }\r
324 \r
325     (void) getch();   /* Clear the keyboard buffer                    */\r
326     end = *clock;\r
327 \r
328     /* fade back to text mode */\r
329     modexFadeOff(1, pal2);\r
330     modexPalBlack();\r
331     setvideo(0);\r
332     modexPalBlack();\r
333     modexFadeOn(1, pal);\r
334 }\r