]> 4ch.mooo.com Git - 16.git/blob - src/bakapi.c
28faa99d7c53c9663811565cf58873b06fd7e277
[16.git] / src / bakapi.c
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123
3  *
4  * This file is part of Project 16.
5  *
6  * Project 16 is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Project 16 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You screen.heightould have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,
19  * Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22
23 #include "src/bakapi.h"
24
25 /*
26  * BAKAPEE!
27  */
28 global_game_variables_t gvar;
29 static bakapee_t bakapee;
30 word key,d,xpos,ypos,xdir,ydir;
31 int ch=0x0;
32
33 void
34 main(int argc, char *argvar[])
35 {
36         // main variables values
37         d=4; // switch variable
38         key=2; // default screensaver number
39         xpos=TILEWH*2;
40         ypos=TILEWH*2;
41         xdir=1;
42         ydir=1;
43
44 #ifdef MXLIB
45         VGAmodeX(1, &gvar);
46 #else
47                 probe_dos();
48         if (!probe_vga()) {
49                 printf("VGA probe failed\n");
50                 return 1;
51         }
52         int10_setmode(19);
53         update_state_from_vga();
54         vga_enable_256color_modex(); // VGA mode X
55         vga_state.vga_width = 320; // VGA lib currently does not update this
56         vga_state.vga_height = 240; // VGA lib currently does not update this
57
58 //#if 1 // 320x240 test mode: this is how Project 16 is using our code, enable for test case
59         {
60                 struct vga_mode_params cm;
61
62                 vga_read_crtc_mode(&cm);
63
64                 // 320x240 mode 60Hz
65                 cm.vertical_total = 525;
66                 cm.vertical_start_retrace = 0x1EA;
67                 cm.vertical_end_retrace = 0x1EC;
68                 cm.vertical_display_end = 480;
69                 cm.vertical_blank_start = 489;
70                 cm.vertical_blank_end = 517;
71
72                 vga_write_crtc_mode(&cm,0);
73         }
74         vga_state.vga_height = 240; // VGA lib currently does not update this
75 //#endif
76 #endif
77         bakapee.xx = rand()&0%gvar.video.page[0].width;
78         bakapee.yy = rand()&0%gvar.video.page[0].height;
79         bakapee.gq = 0;
80         bakapee.sx=0;
81         bakapee.sy=0;
82         bakapee.bakax=0;
83         bakapee.bakay=0;
84         bakapee.coor=0;
85         bakapee.tile=0;
86
87         /* setup camera and screen~ */
88         gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
89         gvar.video.page[0].width += (TILEWH*2);
90         gvar.video.page[0].height += (TILEWH*2);
91         textInit();
92
93         //modexPalUpdate(bmp.palette); //____
94         //modexDrawBmp(VGA, 0, 0, &bmp, 0); //____
95         //getch(); //____
96
97         modexShowPage(&gvar.video.page[0]);
98
99 // screen savers
100 #ifdef BOINK
101         while(d>0)      // on!
102         {
103                 if(!kbhit())
104                 { // conditions of screen saver
105                         ding(&gvar.video.page[0], &bakapee, key);
106                 }
107                 else
108                 {
109 #ifndef MXLIB
110                         int10_setmode(3);
111 #else
112                         VGAmodeX(0, &gvar);
113 #endif
114                         // user imput switch
115                         fprintf(stderr, "xx=%d  yy=%d   tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile);
116                         printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n", getch());  // prompt the user
117                         //scanf("%d", &key);
118                         if(scanf("%d", &key) != 1)
119                         {
120                                 printf("%d\n", key);
121                         }
122                         getch();
123                         //if(key==3){xx=yy=0;} // crazy screen saver wwww
124                         switch (key)
125                         {
126                                 case 0:
127                                         d=0;
128                                 break;
129                                 case 65536:
130                                         switch (bakapee.tile)
131                                         {
132                                                 case 0:
133                                                         bakapee.tile=1;
134                                                 break;
135                                                 case 1:
136                                                         bakapee.tile=0;
137                                                 break;
138                                         }
139                                         d=2;
140                                 default:
141 #ifdef MXLIB
142                                         gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
143                                         gvar.video.page[0].width += (TILEWH*2);
144                                         gvar.video.page[0].height += (TILEWH*2);
145                                         VGAmodeX(1, &gvar);
146 #else
147                                                 probe_dos();
148         if (!probe_vga()) {
149                 printf("VGA probe failed\n");
150                 return 1;
151         }
152         int10_setmode(19);
153         update_state_from_vga();
154         vga_enable_256color_modex(); // VGA mode X
155         vga_state.vga_width = 320; // VGA lib currently does not update this
156         vga_state.vga_height = 240; // VGA lib currently does not update this
157
158 //#if 1 // 320x240 test mode: this is how Project 16 is using our code, enable for test case
159         {
160                 struct vga_mode_params cm;
161
162                 vga_read_crtc_mode(&cm);
163
164                 // 320x240 mode 60Hz
165                 cm.vertical_total = 525;
166                 cm.vertical_start_retrace = 0x1EA;
167                 cm.vertical_end_retrace = 0x1EC;
168                 cm.vertical_display_end = 480;
169                 cm.vertical_blank_start = 489;
170                 cm.vertical_blank_end = 517;
171
172                 vga_write_crtc_mode(&cm,0);
173         }
174         vga_state.vga_height = 240; // VGA lib currently does not update this
175 //#endif
176 #endif
177                                         modexShowPage(&gvar.video.page[0]);
178                                 break;
179                         }
180                 }
181         }
182 #else
183         while(1)
184         { // conditions of screen saver
185                 while(!kbhit())
186                 {
187                         ding(&gvar.video.page[0], &bakapee, key);
188                 }
189                 //end of screen savers
190                 /*for(int x = 0; x < gvar.video.page[0].width; ++x)
191                 {
192                         modexputPixel(&page, x, 0, 15);
193                         mxPutPixel(x, gvar.video.page[0].height-1, 15);
194                         }
195                 for (int y = 0; y < VH; ++y)
196                         {
197                                 mxPutPixel(0, y, 15);
198                                 mxPutPixel(gvar.video.page[0].width-1, y, 15);
199                         }
200                 for (int x = 0; x < VW; ++x)
201                         {
202                                 mxPutPixel(x, 0, 15);
203                                 mxPutPixel(x, VH-1, 15);
204                         }
205                 for (int y = 240; y < VH; ++y)
206                         {
207                                 mxPutPixel(0, y, 15);
208                                 mxPutPixel(VW-1, y, 15);
209                         }*/
210                 pdump(&gvar.video.page[0]);
211                 getch();
212                 //text box
213                 /*++++mxBitBlt(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, BS); //copy background
214                 mxFillBox(xpos, ypos+(TILEWH*12), gvar.video.page[0].width, TILEWH*BUFFMX, 0, OP_SET); // background for text box
215                 //+(QUADWH*6)
216                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-48, "========================================");
217                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-40, "|    |Chikyuu:$line1");
218                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-32, "|    |$line2");
219                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-24, "|    |$line3");
220                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-16, "|    |$line4");
221                 mxOutText(xpos+1, ypos+gvar.video.page[0].height-8,  "========================================");
222                 mxFillBox(xpos+QUADWH, ypos+QUADWH+(TILEWH*12), TILEWH*2, TILEWH*2, 9, OP_SET); //portriat~
223                 getch();
224                 mxBitBlt(0, BS, gvar.video.page[0].width, TILEWH*BUFFMX, xpos, ypos+(TILEWH*12)); //copy background
225                 getch();++++*/
226                 while(!kbhit())
227                 {
228                         //for(int i=0;i<TILEWH;i++){
229                                 ding(&gvar.video.page[0], &bakapee, key);
230                                 modexPanPage(&gvar.video.page[0], xpos, ypos);
231 //++++mxFillBox(384, 304, 384, 304, 10, OP_SET);
232 //mxBitBlt(xpos, ypos, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
233 //++++mxBitBlt(TILEWH*2, TILEWH*2, gvar.video.page[0].width, gvar.video.page[0].height, 32, (gvar.video.page[0].height+64+32));
234                                 //for(word o = 0; o<TILEWH; o++){
235                                         xpos+=xdir;
236                                         ypos+=ydir;
237                                         //if(ypos==1 || (ypos==(BH-gvar.video.page[0].height-1)))delay(500);
238                                         //if((xpos>(VW-gvar.video.page[0].width-1)) || (xpos<1))delay(500);
239                                         //mxWaitRetrace();
240 //mxBitBlt(32, (gvar.video.page[0].height+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
241 //++++mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
242 //xpos=ypos=TILEWH*2;
243                                         //????modexPanPage(&gvar.video.page[0], 32, 32);
244                                 //}
245                                 if( (xpos>(VW-gvar.video.page[0].width-1))  || (xpos<1)){xdir=-xdir;}
246                                 if( (ypos>(BH-gvar.video.page[0].height-1)) || (ypos<1)){ydir=-ydir;} // { Hit a boundry, change
247                         //}//    direction!
248 //mxBitBlt(32, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, xpos, ypos);
249 //mxBitBlt(TILEWH*2, (gvar.video.page[0].height+64+32), gvar.video.page[0].width, gvar.video.page[0].height, TILEWH*2, TILEWH*2);
250                 }
251         ch=getch();
252         if(ch==0x71)break; // 'q'
253         if(ch==0x1b)break; // 'ESC'
254         }
255 //      VGAmodeX(0, &gvar);
256 #endif
257         printf("bakapi ver. 1.04.13.04\nis made by sparky4\81i\81\86\83Ö\81\85\81j feel free to use it ^^\nLicence: GPL v3\n");
258 }
259 //pee!