]> 4ch.mooo.com Git - 16.git/blob - src/lib/bakapee.c
inconsistancy with wmake on 1.9 and 2.0 on both linux and dos is giving me issues...
[16.git] / src / lib / bakapee.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2019 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 \r
23 #include "src/lib/bakapee.h"\r
24 \r
25 //static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
26 //char global_temp_status_text[512];\r
27 //char global_temp_status_text2[512];\r
28 \r
29 //==========================================================================\r
30 \r
31 /*\r
32 ===================\r
33 =\r
34 = FizzleFade\r
35 =\r
36 = returns true if aborted\r
37 =\r
38 ===================\r
39 */\r
40 \r
41 //extern        ControlInfo     c;\r
42 #define PIXPOSX                 gvar->video.page[0].sw/2\r
43 #define PIXPOSY                 gvar->video.page[0].sh/2\r
44 \r
45 /*\r
46 ===================\r
47 =\r
48 = FizzleFade\r
49 =\r
50 = returns true if aborted\r
51 =\r
52 ===================\r
53 */\r
54 \r
55 //extern        ControlInfo     c;\r
56 //#define PIXPOSX                       gvar->video.page[0].sw/2\r
57 //#define PIXPOSY                       gvar->video.page[0].sh/2\r
58 #ifdef BAKAFIZZUNSIGNED\r
59 boolean baka_FizzleFade (unsigned source, unsigned dest, unsigned width, unsigned height, unsigned frames, boolean abortable, global_game_variables_t *gvar)\r
60 {\r
61         word            p,pixperframe;\r
62         unsigned        drawofs,pagedelta;\r
63         byte            mask,maskb[8] = {1,2,4,8};\r
64         unsigned        x,y,frame;\r
65         long            rndval;\r
66         word            screenseg;\r
67 #ifdef __WATCOMC__\r
68         unsigned        esorig;//,q;\r
69 #endif\r
70 \r
71         pagedelta = dest-source;\r
72         rndval = 1;\r
73 #ifdef __WATCOMC__\r
74         esorig = 0;// q = 16;\r
75 #endif\r
76         x = y = 0;\r
77         pixperframe = (dword)(gvar->video.page[0].width*gvar->video.page[0].height)/frames;//64000/(dword)frames;\r
78         screenseg = SCREENSEG;\r
79 \r
80 //      IN_StartAck (gvar);\r
81 \r
82 //      modexClearRegion(&(gvar->video.page[0]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 0);\r
83 //      modexClearRegion(&(gvar->video.page[1]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 15);\r
84 \r
85 #ifdef __WATCOMC__\r
86         __asm {\r
87                 mov     [esorig],es\r
88         }\r
89 #endif\r
90 //      TimeCount=\r
91         frame=0;\r
92         do      // while (1)\r
93         {\r
94                 if (abortable && kbhit())//IN_CheckAck (gvar) )\r
95                         return true;\r
96 \r
97                 __asm {\r
98                         mov     es,[screenseg]\r
99                 }\r
100 \r
101                 for (p=0;p<pixperframe;p++)\r
102                 {\r
103                         __asm {\r
104                                 //\r
105                                 // seperate random value into x/y pair\r
106                                 //\r
107                                 mov     ax,[WORD PTR rndval]\r
108                                 mov     dx,[WORD PTR rndval+2]\r
109                                 mov     bx,ax\r
110                                 dec     bl\r
111                                 mov     [BYTE PTR y],bl                 // low 8 bits - 1 = y xoordinate\r
112                                 mov     bx,ax\r
113                                 mov     cx,dx\r
114                                 mov     [BYTE PTR x],ah                 // next 9 bits = x xoordinate\r
115                                 mov     [BYTE PTR x+1],dl\r
116                                 //\r
117                                 // advance to next random element\r
118                                 //\r
119                                 shr     dx,1\r
120                                 rcr     ax,1\r
121                                 jnc     noxor\r
122                                 xor     dx,0x0001\r
123                                 xor     ax,0x2000\r
124 #ifdef __BORLANDC__\r
125                         }\r
126 #endif\r
127 noxor:\r
128 #ifdef __BORLANDC__\r
129                         __asm {\r
130 #endif\r
131                                 mov     [WORD PTR rndval],ax\r
132                                 mov     [WORD PTR rndval+2],dx\r
133                         }\r
134 \r
135                         if (x>width || y>height)\r
136 //                      if ((x>width || y>height) && (x<width*2 && y<height*2))\r
137                                 continue;\r
138 //                      drawofs = source+(gvar->video.ofs.ylookup[y]) + (x>>2);\r
139                         drawofs = source+(y*gvar->video.page[0].stridew) + (x>>2);\r
140 /*\r
141 sprintf(global_temp_status_text, "draw - %Fp", drawofs);\r
142 modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
143 sprintf(global_temp_status_text, "pdet - %Fp", pagedelta);\r
144 modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
145 sprintf(global_temp_status_text, "srce - %Fp", source);\r
146 modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
147 sprintf(global_temp_status_text, "dest - %Fp", dest);\r
148 modexprint(&(gvar->video.page[0]), PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q=16;\r
149 */\r
150 \r
151                         //\r
152                         // copy one pixel\r
153                         //\r
154                         mask = x&3;\r
155                         VGAREADMAP(mask);\r
156                         mask = maskb[mask];\r
157                         VGAMAPMASK(mask);\r
158 \r
159                         __asm {\r
160                                 mov     di,[drawofs]\r
161                                 mov     al,[es:di]\r
162                                 add     di,[pagedelta]\r
163                                 mov     [es:di],al\r
164                         }\r
165 \r
166                         if (rndval == 1)                // entire sequence has been completed\r
167                                 return false;\r
168                 }\r
169                 frame++;\r
170 //--            while (TimeCount<frame){}//;            // don't go too fast\r
171                 delay(1);\r
172         } while (1);\r
173 #ifdef __WATCOMC__\r
174         __asm {\r
175                 mov     es,[esorig]\r
176         }\r
177         return false;\r
178 #endif\r
179 }\r
180 #endif\r
181 #if 0\r
182 boolean baka_FizzleFade (page_t *sourcepage, page_t *destpage, unsigned width, unsigned height, unsigned frames, boolean abortable, global_game_variables_t *gvar)\r
183 {\r
184         word            p,pixperframe;\r
185         unsigned        drawofs,pagedelta;\r
186 //      byte            mask,maskb[8] = {1,2,4,8};\r
187         unsigned        x,y,frame               ,esorig,q;\r
188         dword           rndval;\r
189         unsigned        source,dest;\r
190         word screenseg = SCREENSEG;\r
191         source = ((word)sourcepage->data); dest = ((word)destpage->data);\r
192 \r
193         pagedelta = dest-source;\r
194         rndval = 1;     esorig = 0; q = 16;\r
195         x = y = 0;//destpage->dx;\r
196         pixperframe = 76800/(dword)frames;\r
197 \r
198 //      IN_StartAck ();\r
199 \r
200 //      VL_ShowPage(&(gvar->video.page[0]), 1, 0);\r
201 //      VL_ShowPage(&(gvar->video.page[1]), 1, 0);\r
202 \r
203 //      modexClearRegion(&(gvar->video.page[0]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 0);\r
204 //      modexClearRegion(&(gvar->video.page[1]), 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 15);\r
205 //      VL_SetLineWidth(80, gvar);\r
206 \r
207         __asm {\r
208                 mov     [esorig],es\r
209         }\r
210 //      TimeCount=\r
211         frame=0;\r
212         do      // while (1)\r
213         {\r
214 sprintf(global_temp_status_text, "%u", frame);\r
215 modexprint(destpage, PIXPOSX, PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);\r
216                 if (abortable && kbhit())//IN_CheckAck () )\r
217                         return true;\r
218 \r
219                 __asm {\r
220                         mov     es,[screenseg]\r
221                 }\r
222 \r
223                 for (p=0;p<pixperframe;p++)\r
224                 {\r
225                         __asm {\r
226                                 //\r
227                                 // seperate random value into x/y pair\r
228                                 //\r
229                                 mov     ax,[WORD PTR rndval]\r
230                                 mov     dx,[WORD PTR rndval+2]\r
231                                 mov     bx,ax\r
232                                 dec     bl\r
233                                 mov     [BYTE PTR y],bl                 // low 8 bits - 1 = y xoordinate\r
234                                 mov     bx,ax\r
235                                 mov     cx,dx\r
236                                 mov     [BYTE PTR x],ah                 // next 9 bits = x xoordinate\r
237                                 mov     [BYTE PTR x+1],dl\r
238                                 //\r
239                                 // advance to next random element\r
240                                 //\r
241                                 shr     dx,1\r
242                                 rcr     ax,1\r
243                                 jnc     noxor\r
244                                 xor     dx,0x0001\r
245                                 xor     ax,0x2000\r
246 #ifdef __BORLANDC__\r
247                         }\r
248 #endif\r
249 noxor:\r
250 #ifdef __BORLANDC__\r
251                         __asm {\r
252 #endif\r
253                                 mov     [WORD PTR rndval],ax\r
254                                 mov     [WORD PTR rndval+2],dx\r
255                         }\r
256 \r
257 //                      if (x>destpage->width || y>destpage->height)\r
258 //                      if (x<destpage->sw || y<destpage->sh)\r
259                         if ((x>width || y>height) && (x<width*2 && y<height*2))\r
260                                 continue;\r
261                         drawofs = source+(gvar->video.ofs.ylookup[y]) + (x>>2);\r
262 sprintf(global_temp_status_text, "draw - %Fp", drawofs);\r
263 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
264 sprintf(global_temp_status_text, "pdet - %Fp", pagedelta);\r
265 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
266 sprintf(global_temp_status_text, "srcp - %Fp", sourcepage->data);\r
267 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
268 sprintf(global_temp_status_text, "desp - %Fp", destpage->data);\r
269 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
270 sprintf(global_temp_status_text, "srce - %Fp", source);\r
271 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
272 sprintf(global_temp_status_text, "dest - %Fp", dest);\r
273 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q=16;\r
274 \r
275                         //\r
276                         // copy one pixel\r
277                         //\r
278 /*\r
279                         mask = x&3;\r
280                         VGAREADMAP(mask);\r
281                         mask = maskb[mask];\r
282                         VGAMAPMASK(mask);\r
283 /*/\r
284 //                      modexputPixel(&(gvar->video.page[0]), x, y, rand());\r
285 //                      VL_Plot (x, y, 15, &(gvar->video.ofs));\r
286                         modexCopyPageRegion(destpage, sourcepage, x, y, x, y, 4, 4);\r
287 \r
288                         __asm {\r
289                                 mov     di,[drawofs]\r
290                                 mov     al,[es:di]\r
291                                 add     di,[pagedelta]\r
292                                 mov     [es:di],al\r
293                         }\r
294 \r
295                         if (rndval == 1)                // entire sequence has been completed\r
296                                 return false;\r
297                 }\r
298                 frame++;\r
299 //--            while (TimeCount<frame){}//;            // don't go too fast\r
300         } while (1);\r
301         __asm {\r
302                 mov     es,[esorig]\r
303         }\r
304         return false;\r
305 }\r
306 #endif\r
307 \r
308 #if 0\r
309 boolean baka_FizzleFade (page_t *sourcepage, page_t *destpage, unsigned width, unsigned height, unsigned frames, boolean abortable, global_game_variables_t *gvar)\r
310 {\r
311         word            p,pixperframe;\r
312         unsigned        drawofs,pagedelta;\r
313         byte            mask,maskb[8] = {1,2,4,8};\r
314         unsigned        x,y,frame               ,esorig,q;\r
315         dword           rndval;\r
316         unsigned        source,dest;\r
317 //      word TimeCount = *clockw;\r
318         word screenseg = SCREENSEG;\r
319         source = ((word)sourcepage->data); dest = ((word)destpage->data);\r
320 \r
321         pagedelta = dest-source;//(word)(source->data - dest->data);//(dest->data - source->data)\r
322         rndval = 1;     esorig = 0; q = 16;\r
323         x = y = destpage->dx;\r
324         pixperframe = /*76800*/64000/(dword)frames;\r
325 \r
326 //      IN_StartAck ();\r
327 \r
328 //      VL_ShowPage(destpage, 1, 0);\r
329 //      VL_ShowPage(sourcepage, 1, 0);\r
330 \r
331 //      modexClearRegion(destpage, 0, 0, (destpage->width), (destpage->height), 12);\r
332         modexClearRegion(sourcepage, 0, 0, (sourcepage->width), (sourcepage->height), 64);\r
333 \r
334         __asm {\r
335                 mov     [esorig],es\r
336         }\r
337 //      TimeCount=\r
338         frame=0;\r
339         do      // while (1)\r
340         {\r
341 sprintf(global_temp_status_text, "%u", frame);\r
342 modexprint(destpage, PIXPOSX, PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text);\r
343                 if (abortable && kbhit())//IN_CheckAck () )\r
344                         return true;\r
345 \r
346                 __asm {\r
347                         mov     es,[screenseg]\r
348                 }\r
349 \r
350                 for (p=0;p<pixperframe;p++)\r
351                 {\r
352                         __asm {\r
353                                 //\r
354                                 // seperate random value into x/y pair\r
355                                 //\r
356                                 mov     ax,[WORD PTR rndval]\r
357                                 mov     dx,[WORD PTR rndval+2]\r
358                                 mov     bx,ax\r
359                                 dec     bl\r
360                                 mov     [BYTE PTR y],bl                 // low 8 bits - 1 = y xoordinate\r
361                                 mov     bx,ax\r
362                                 mov     cx,dx\r
363                                 mov     [BYTE PTR x],ah                 // next 9 bits = x xoordinate\r
364                                 mov     [BYTE PTR x+1],dl\r
365                                 //\r
366                                 // advance to next random element\r
367                                 //\r
368                                 shr     dx,1\r
369                                 rcr     ax,1\r
370                                 jnc     noxor\r
371                                 xor     dx,0x0001\r
372                                 xor     ax,0x2000\r
373 #ifdef __BORLANDC__\r
374                         }\r
375 #endif\r
376 noxor:\r
377 #ifdef __BORLANDC__\r
378                         __asm {\r
379 #endif\r
380                                 mov     [WORD PTR rndval],ax\r
381                                 mov     [WORD PTR rndval+2],dx\r
382                         }\r
383 \r
384 //                      if (x>destpage->width || y>destpage->height)\r
385 //                      if (x<destpage->sw || y<destpage->sh)\r
386                         if (x>width || y>height)\r
387                                 continue;\r
388                         drawofs = source+(gvar->video.ofs.ylookup[y]) + (x>>2);\r
389 sprintf(global_temp_status_text, "draw - %Fp", drawofs);\r
390 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
391 sprintf(global_temp_status_text, "pdet - %Fp", pagedelta);\r
392 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
393 sprintf(global_temp_status_text, "srcp - %Fp", sourcepage->data);\r
394 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
395 sprintf(global_temp_status_text, "desp - %Fp", destpage->data);\r
396 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
397 sprintf(global_temp_status_text, "srce - %Fp", source);\r
398 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q+=8;\r
399 sprintf(global_temp_status_text, "dest - %Fp", dest);\r
400 modexprint(destpage, PIXPOSX, q+PIXPOSY, 1, 0, 47, 0, 1, global_temp_status_text); q=16;\r
401 \r
402                         //\r
403                         // copy one pixel\r
404                         //\r
405                         mask = x&3;\r
406                         VGAREADMAP(mask);\r
407                         mask = maskb[mask];\r
408                         VGAMAPMASK(mask);\r
409 \r
410                         __asm {\r
411                                 mov     di,[drawofs]\r
412                                 mov     al,[es:di]\r
413                                 add     di,[pagedelta]\r
414                                 mov     [es:di],al\r
415                         }\r
416 \r
417                         if (rndval == 1)                // entire sequence has been completed\r
418                                 return false;\r
419                 }\r
420                 frame++;\r
421 //--            while (TimeCount<frame){}//;            // don't go too fast\r
422         } while (1);\r
423         __asm {\r
424                 mov     es,[esorig]\r
425         }\r
426         return false;\r
427 }\r
428 #endif\r
429 // clrstdin() clear any leftover chars tha may be in stdin stream //\r
430 void clrstdin()\r
431 {\r
432    int ch = 0;\r
433    while( ( ch = getchar() ) != '\n' && ch != EOF );\r
434 }\r
435 \r
436 //===========================================================================\r
437 \r
438 /*\r
439 ====================\r
440 =\r
441 = TL_DosLibStartup\r
442 =\r
443 ====================\r
444 */\r
445 \r
446 void TL_DosLibStartup(global_game_variables_t *gvar)\r
447 {\r
448         if(gvar->DLStarted)\r
449                 return;\r
450 \r
451         // DOSLIB: check our environment\r
452         probe_dos();\r
453 \r
454         // DOSLIB: what CPU are we using?\r
455         // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.\r
456         //        So this code by itself shouldn't care too much what CPU it's running on. Except that other\r
457         //        parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for\r
458         //        the CPU to carry out tasks. --J.C.\r
459         cpu_probe();\r
460 \r
461         // DOSLIB: check for VGA\r
462         if (!probe_vga()) {\r
463                 printf("VGA probe failed\n");\r
464                 return;\r
465         }\r
466         // hardware must be VGA or higher!\r
467         if (!(vga_state.vga_flags & VGA_IS_VGA)) {\r
468                 printf("This program requires VGA or higher graphics hardware\n");\r
469                 return;\r
470         }\r
471 \r
472         textInit();\r
473         gvar->DLStarted = true;\r
474 }\r
475 \r
476 //color \82Ä\82·\82Æ\r
477 void colortest(page_t *page, bakapee_t *pee)\r
478 {\r
479         //if(pee->coor < 256)\r
480         //{\r
481 //              modexcls(page, pee->coor, VGA);\r
482                 VL_ClearVideo (pee->coor);\r
483                 pee->coor++;\r
484         //}else pee->coor = 0;\r
485 }\r
486 \r
487 //color \82Ä\82·\82Æ\r
488 void colorz(page_t *page, bakapee_t *pee)\r
489 {\r
490         if(pee->coor <= pee->hgq)\r
491         {\r
492 //              modexcls(page, pee->coor, VGA);\r
493                 VL_ClearVideo (pee->coor);\r
494                 pee->coor++;\r
495         }else pee->coor = pee->lgq;\r
496 }\r
497 \r
498 //slow spectrum down\r
499 void ssd(page_t *page, bakapee_t *pee, word svq)\r
500 {\r
501         if(pee->sy < page->sh+1)\r
502         {\r
503                 if(pee->sx < page->sw+1)\r
504                 {\r
505                         //mxPutPixel(sx, sy, coor);\r
506                         //printf("%d %d %d %d\n", pee->sx, pee->sy, svq, pee->coor);\r
507                         dingpp(page, pee);\r
508                         pee->sx++;\r
509                 }else pee->sx = 0;\r
510                 if(pee->sx == page->sw)\r
511                 {\r
512                         pee->sy++;\r
513                         if(svq == 7) pee->coor++;\r
514                         if(pee->sy == page->sh && svq == 8) pee->coor = rand()%256;\r
515                 }\r
516         }else pee->sy = 0;\r
517 }\r
518 \r
519 //plot pixel or plot tile\r
520 void dingpp(page_t *page, bakapee_t *pee)\r
521 {\r
522         if(pee->tile)\r
523         {\r
524                 modexClearRegion(page, pee->xx, pee->yy, TILEWH, TILEWH, pee->coor);\r
525         }\r
526         else\r
527                 modexputPixel(page, pee->xx, pee->yy, pee->coor);\r
528 }\r
529 \r
530 void dingo(page_t *page, bakapee_t *pee)\r
531 {\r
532         if(pee->tile)\r
533         {\r
534                 if(pee->xx<0) pee->xx=(page->sw-TILEWH);\r
535                 if(pee->yy<0) pee->yy=(page->sh-TILEWH);\r
536                 if(pee->xx>(page->sw-TILEWH)) pee->xx=0;\r
537                 if(pee->yy>(page->sh-TILEWH)/*+(TILEWH*BUFFMX)*/) pee->yy=0;\r
538         }\r
539                 else\r
540         {\r
541                 if(pee->xx<0) pee->xx=page->sw;\r
542                 if(pee->yy<0) pee->yy=page->sh;\r
543                 if(pee->xx>page->sw) pee->xx=0;\r
544                 if(pee->yy>page->sh) pee->yy=0;\r
545         }\r
546 }\r
547 \r
548 //assigning values from randomizer\r
549 void dingas(bakapee_t *pee)\r
550 {\r
551         if(pee->gq == pee->bonk) dingu(pee);\r
552         if(!pee->bakax)\r
553         {\r
554                 if(pee->tile)\r
555                 pee->xx-=TILEWH;\r
556                 else pee->xx--;\r
557         }\r
558         else if(pee->bakax>1)\r
559         {\r
560                 if(pee->tile)\r
561                 pee->xx+=TILEWH;\r
562                 else pee->xx++;\r
563         }\r
564         if(!pee->bakay)\r
565         {\r
566                 if(pee->tile)\r
567                 pee->yy-=TILEWH;\r
568                 else pee->yy--;\r
569         }\r
570         else if(pee->bakay>1)\r
571         {\r
572                 if(pee->tile)\r
573                 pee->yy+=TILEWH;\r
574                 else pee->yy++;\r
575         }\r
576 }\r
577 \r
578 void dingaso(bakapee_t *pee)\r
579 {\r
580         if(pee->gq == pee->bonk) dingu(pee);\r
581         if(!pee->bakax)\r
582         {\r
583                 if(pee->tile)\r
584                 pee->xx-=TILEWH;\r
585                 else pee->xx--;\r
586         }\r
587         else\r
588         {\r
589                 if(pee->tile)\r
590                 pee->xx+=TILEWH;\r
591                 else pee->xx++;\r
592         }\r
593         if(!pee->bakay)\r
594         {\r
595                 if(pee->tile)\r
596                 pee->yy-=TILEWH;\r
597                 else pee->yy--;\r
598         }\r
599         else\r
600         {\r
601                 if(pee->tile)\r
602                 pee->yy+=TILEWH;\r
603                 else pee->yy++;\r
604         }\r
605 }\r
606 \r
607 void dingu(bakapee_t *pee)\r
608 {\r
609         if(pee->coor < pee->hgq && pee->coor < pee->lgq) pee->coor = pee->lgq;\r
610         if(pee->coor < pee->hgq)\r
611         {\r
612                 pee->coor++;\r
613         }else{\r
614                 pee->coor = pee->lgq;\r
615         }\r
616 }\r
617 \r
618 //randomizer\r
619 void dingq(bakapee_t *pee)\r
620 {\r
621         if(pee->gq<pee->bonk)\r
622         {\r
623                 pee->gq++;\r
624         }\r
625         else\r
626         {\r
627                 dingu(pee);\r
628                 pee->gq = 0;\r
629         }\r
630         pee->bakax = rand()%3; pee->bakay = rand()%3;\r
631 }\r
632 \r
633 void dingqo(bakapee_t *pee)\r
634 {\r
635         if(pee->gq<pee->bonk)\r
636         {\r
637                 pee->gq++;\r
638                 pee->bakax = rand()%3; pee->bakay = rand()%3;\r
639         }\r
640         else\r
641         {\r
642                 dingu(pee);\r
643                 pee->gq = 0;\r
644         }\r
645         //either one will do wwww --4\r
646         pee->bakax = rand()&0x1; pee->bakay = rand()&0x1;\r
647         //pee->bakax = rand()%2; pee->bakay = rand()%2;\r
648 }\r
649 \r
650 /*-----------ding-------------*/\r
651 void ding(page_t *page, bakapee_t *pee, word q)\r
652 {\r
653         word tx=0,ty=0;//d3y,\r
654 \r
655 //++++  if(q <= 4 && q!=2 && gq == pee->bonk-1) coor = rand()%pee->hgq;\r
656         switch(q)\r
657         {\r
658                 case 1:/*\r
659                         dingq(pee);\r
660                         if(pee->xx==page->sw){pee->bakax=0;}\r
661                         if(pee->xx==0){pee->bakax=1;}\r
662                         if(pee->yy==page->sh){pee->bakay=0;}\r
663                         if(pee->yy==0){pee->bakay=1;}*/\r
664                         dingqo(pee);\r
665                         dingaso(pee);\r
666                         dingo(page, pee);\r
667                         dingpp(page, pee);      //plot the pixel/tile\r
668                         if(pee->tile)\r
669                         modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);\r
670                         else\r
671                         modexputPixel(page, rand()%page->width, rand()%page->height, 0);\r
672                 break;\r
673                 case 2:\r
674                         dingq(pee);\r
675                         dingas(pee);\r
676                         dingo(page, pee);\r
677                         dingpp(page, pee);      //plot the pixel/tile\r
678                         if(pee->tile)\r
679                         modexClearRegion(page, (rand()*TILEWH)%page->width, (rand()*TILEWH)%(page->height), TILEWH, TILEWH, 0);\r
680                         else\r
681                         modexputPixel(page, rand()%page->width, rand()%page->height, 0);\r
682                 break;\r
683                 case 3:\r
684                         /*dingq(pee);\r
685                         if(pee->xx!=page->sw||pee->yy!=page->sh)\r
686                         {\r
687                                 if(pee->xx==0){pee->bakax=1;pee->bakay=-1;d3y=1;}\r
688                                 if(pee->yy==0){pee->bakax=1;pee->bakay=0;d3y=1;}\r
689                                 if(pee->xx==page->sw){pee->bakax=-1;pee->bakay=-1;d3y=1;}\r
690                                 if(pee->yy==page->sh){pee->bakax=1;pee->bakay=0;d3y=1;}\r
691                         }else if(pee->xx==page->sw&&pee->yy==page->sh) pee->xx=pee->yy=0;\r
692                         if(d3y)\r
693                         {\r
694                                 if(pee->bakay<0)\r
695                                 {\r
696                                         pee->yy--;\r
697                                         d3y--;\r
698                                 }else\r
699                                 if(pee->bakay>0)\r
700                                 {\r
701                                         pee->yy++;\r
702                                         d3y--;\r
703                                 }\r
704                         }\r
705                         if(pee->bakax<0)\r
706                         {\r
707                                 pee->xx--;\r
708                         }else\r
709                         if(pee->bakax>0)\r
710                         {\r
711                                 pee->xx++;\r
712                         }\r
713                         dingpp(page, pee);      //plot the pixel/tile*/\r
714                         dingqo(pee);\r
715                         dingaso(pee);\r
716                         dingo(page, pee);\r
717                         dingpp(page, pee);      //plot the pixel/tile\r
718                 break;\r
719                 case 4:\r
720                         dingq(pee);\r
721                         dingas(pee);\r
722                         dingo(page, pee);\r
723                         dingpp(page, pee);      //plot the pixel/tile\r
724                 break;\r
725                 case 5:\r
726                         colortest(page, pee);\r
727                 break;\r
728                 case 6:\r
729 //                      pee->coor = rand()%256;\r
730 //                      modexcls(page, pee->coor, VGA);\r
731                         colorz(page, pee);\r
732                         modexprint(page, page->sw/2, page->sh/2, 1, 0, 47, 0, 1, "bakapi");\r
733                 break;\r
734                 case 7:\r
735                         if(pee->coor <= pee->hgq)\r
736                         {\r
737                                 ssd(page, pee, q);\r
738                                 pee->coor++;\r
739                         }else pee->coor = pee->lgq;\r
740                 break;\r
741                 case 8:\r
742                         colorz(page, pee);\r
743                         modexprint(page, page->sw/2, page->sh/2, 1, 0, 47, 0, 1, "bakapi");\r
744                 break;\r
745 /*              case 9:\r
746                         modexClearRegion(&(ggvv->video.page[0]), 0, 0, ggvv->video.page[0].width/2, ggvv->video.page[0].height/2, 15);\r
747 #ifdef BAKAFIZZUNSIGNED\r
748 //                      baka_FizzleFade (ggvv->video.ofs.bufferofs, ggvv->video.ofs.displayofs, vga_state.vga_width, vga_state.vga_height, 70, true, ggvv);\r
749                         baka_FizzleFade (ggvv->video.ofs.bufferofs, ggvv->video.ofs.displayofs, ggvv->video.page[0].width, ggvv->video.page[0].height, 70, true, ggvv);\r
750 #else\r
751                         baka_FizzleFade (&ggvv->video.page[1], &ggvv->video.page[0], vga_state.vga_width, vga_state.vga_height, 70, true, ggvv);\r
752 #endif\r
753                 break;*/\r
754                 case 10:\r
755                         ssd(page, pee, q); /*printf("%d\n", pee->coor);*/\r
756                 break;\r
757                 case 11:\r
758                         colorz(page, pee); delay(100);\r
759                 break;\r
760 \r
761                 case 16:        //interesting effects\r
762                         dingq(pee);\r
763                         if(!pee->bakax){ pee->xx--;}\r
764                         else if(pee->bakax>0){ pee->xx++; }\r
765                         if(!pee->bakay){ pee->yy--;}\r
766                         else if(pee->bakay>0){ pee->yy++; }\r
767                         dingas(pee);\r
768                         tx+=pee->xx+TILEWH+4;\r
769                         ty+=pee->yy+TILEWH+4;\r
770                         modexClearRegion(page, tx, ty, 4, 4, pee->coor);\r
771                         if(pee->tile)\r
772                         modexClearRegion(page, (rand()*4)%page->width, (rand()*4)%(page->height), 4, 4, 0);\r
773                         else\r
774                         modexputPixel(page, rand()%page->width, rand()%(page->height), 0);\r
775                         //printf("%d %d %d %d %d %d\n", pee->xx, pee->yy, tx, ty, TILEWH);\r
776                 break;\r
777                 default:\r
778                 break;\r
779         }\r
780         //printf("      %dx%d   %dx%d\n", pee->xx, pee->yy, tx, ty);\r
781         //pee->coor++;\r
782 }\r