]> 4ch.mooo.com Git - 16.git/blob - src/zcroll.c
no idea why bcexmm.exe is broke w tweaked zcroll.exe a bit also Quit is refined now...
[16.git] / src / zcroll.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2016 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/16_scr.h"\r
24 #include "src/lib/16_timer.h"\r
25 #include "src/lib/wcpu/wcpu.h"\r
26 #include "src/lib/16render.h"\r
27 #include "src/lib/16_dbg.h"\r
28 \r
29 #define MODEXZ\r
30 \r
31 //TODO: known issues the array dependent mv stuff and player arrays\r
32 static map_t map;\r
33 player_t player[MaxPlayers];\r
34 map_view_t mv[4];\r
35 float t;\r
36 sword bakapee;\r
37 pan_t pan;\r
38 //debugswitches\r
39 boolean panswitch=0,baka=0;\r
40 //extern boolean pageflipflop=1;\r
41 unsigned int i;\r
42 const char *cpus;\r
43 //static int persist_aniframe = 0;    /* gonna be increased to 1 before being used, so 0 is ok for default */\r
44 \r
45 //map_view_db_t pgid[4];\r
46 word pg;\r
47 #ifdef FADE\r
48 static word paloffset=0;\r
49 byte *dpal;\r
50 #endif\r
51 byte *gpal;\r
52 byte *ptr;\r
53 memptr pal;\r
54 \r
55 void main(int argc, char *argv[])\r
56 {\r
57         static global_game_variables_t gvar;\r
58         if(argv[1]) bakapee = atoi(argv[1]);\r
59         else bakapee = 1;\r
60 \r
61         Startup16(&gvar);\r
62 \r
63         pan.pn=0;\r
64         // OK, this one takes hellova time and needs to be done in farmalloc or MM_...\r
65         //IN CA i think you use CAL_SetupGrFile but i do think we should work together on this part --sparky4\r
66         player[0].ent = malloc(sizeof(entity_t));\r
67         player[0].ent->spri = malloc(sizeof(struct sprite));\r
68         player[0].ent->spri->spritesheet = malloc(sizeof(struct vrs_container));\r
69 \r
70         // create the map\r
71         fprintf(stderr, "testing map load~      ");\r
72         loadmap("data/test.map", &map);\r
73         chkmap(&map, 0);\r
74         printf("chkmap ok       ");\r
75         fprintf(stderr, "yay map loaded~~\n");\r
76 \r
77         // data\r
78         read_vrs(&gvar, "data/spri/chikyuu.vrs", player[0].ent->spri->spritesheet);\r
79 \r
80         //      input!\r
81         IN_Default(0, &player,ctrl_Keyboard1);\r
82 \r
83         // save the palette\r
84 #ifdef FADE\r
85         dpal = modexNewPal();\r
86         modexPalSave(dpal);\r
87         modexFadeOff(4, dpal);\r
88 #endif\r
89         textInit();\r
90         VGAmodeX(bakapee, 1, &gvar);\r
91 #ifdef MODEXZ\r
92 #ifdef FADE\r
93         modexPalBlack();        //reset the palette~\r
94         CA_LoadFile("data/spri/chikyuu.pal", &pal, &gvar);\r
95         modexPalUpdate1(pal);\r
96         gpal = modexNewPal();\r
97         modexPalSave(gpal);\r
98         modexSavePalFile("data/g.pal", gpal);\r
99         modexPalBlack();        //so player will not see loadings~\r
100 #endif\r
101 \r
102         // setup camera and screen~\r
103         modexHiganbanaPageSetup(&gvar.video);\r
104         for(i=0;i<gvar.video.num_of_pages;i++)\r
105         {\r
106                 mv[i].page = &gvar.video.page[i];\r
107                 mv[i].map = &map;\r
108                 mv[i].video = &gvar.video;\r
109                 mv[i].pan       = &pan;\r
110         }\r
111         player[0].ent->spri->x = player[0].ent->spri->y = 20;\r
112 \r
113         // set up paging\r
114         //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen\r
115         mapGoTo(mv, 0, 0);\r
116 #endif\r
117 \r
118         //TODO: put player in starting position of spot\r
119         //default player position on the viewable map\r
120         player[0].tx = mv[0].tx + mv[0].page->tilemidposscreenx;\r
121         player[0].ty = mv[0].ty + mv[0].page->tilemidposscreeny;\r
122         IN_initplayer(&player, 0);\r
123 \r
124         i = set_anim_by_id(player[0].ent->spri, 11);\r
125         print_anim_ids(player[0].ent->spri);\r
126         if (i == -1)\r
127         {\r
128 #ifdef FADE\r
129                 modexFadeOff(4, gpal);\r
130 #endif\r
131                 Quit(&gvar, "Wrong");\r
132 #ifdef FADE\r
133                 modexFadeOn(4, dpal);\r
134 #endif\r
135         exit(-4);\r
136         }\r
137         //++++animate_spri(&(player[0].ent->spri));\r
138 \r
139         modexShowPage(mv[0].page);//!(gvar.video.p)\r
140         shinku_fps_indicator_page = 0; // we're on page 1 now, shinku(). follow along please or it will not be visible.\r
141 #ifdef FADE\r
142         modexFadeOn(4, gpal);\r
143 #endif\r
144         strcpy(global_temp_status_text, "press enter for the loop of zcroll\nescape to quit");\r
145         modexprint(&gvar.video.page[0], 144, 72, 1, 7, 0, global_temp_status_text);\r
146         while(!IN_KeyDown(sc_Enter)){ if(IN_KeyDown(sc_Escape)) goto quit; } IN_UserInput(1,1); //wwww\r
147         while(!IN_KeyDown(sc_Escape))// && player[0].hp>0)\r
148         {\r
149                 shinku(&gvar);\r
150                 //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square\r
151                 //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction\r
152                 //when player[0].tx or player[0].ty == 0 or player[0].tx == 20 or player[0].ty == 15 then stop because that is edge of map and you do not want to walk of the map\r
153 \r
154                 //player movement\r
155                 IN_ReadControl(0, &player);\r
156                 if(!panswitch){\r
157                         ZC_walk(player[0].ent, mv);\r
158                         //walk(mv, &player, 0);\r
159                 }\r
160 \r
161                 //the scripting stuff....\r
162 /*              if(((mv[0].map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))] == 0) && IN_KeyDown(0x1C))||(player[0].tx == 5 && player[0].ty == 5))\r
163                 {\r
164                         short i;\r
165                         for(i=800; i>=400; i--)\r
166                         {\r
167                                 sound(i);\r
168                         }\r
169                         nosound();\r
170                 }\r
171                 if(player[0].q == (TILEWH/(player[0].speed))+1 && player[0].info.dir != 2 && (player[0].triggerx == 5 && player[0].triggery == 5)){ player[0].hp--; }\r
172 */              //debugging binds!\r
173                 if(IN_KeyDown(2)){ modexShowPage(mv[0].page); pan.pn=0; }\r
174                 if(IN_KeyDown(25)){ modexpdump(mv[0].page);\r
175                          IN_UserInput(1,1);\r
176                 }       //p\r
177 #ifdef FADE\r
178                 if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; modexpdump(mv[0].page); IN_UserInput(1,1); }\r
179                 if(IN_KeyDown(22)){\r
180                         printf("2paloffset      =       %d\n", paloffset/3);\r
181                         IN_UserInput(1,1);\r
182                 }\r
183 #endif\r
184 \r
185                 //pan switch\r
186                 if(IN_KeyDown(88)){panswitch=!panswitch; IN_UserInput(1,1);}    //f12\r
187                 if(IN_KeyDown(87))      //f11\r
188                 {\r
189                         pageflipflop=!pageflipflop;\r
190                         IN_UserInput(1,1);\r
191                 }\r
192                 if(IN_KeyDown(68))      //f10\r
193                 {\r
194                         gvar.kurokku.fpscap=!gvar.kurokku.fpscap;\r
195                         IN_UserInput(1,1);\r
196                 }\r
197                 if(IN_KeyDown(67))      //f9\r
198                 {\r
199                         modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 2);\r
200                 }\r
201                 if(IN_KeyDown(66))      //f8\r
202                 {\r
203         //              modexDrawSprite(mv[0].page, 16, 16, p);\r
204                         modexDrawSprite(mv[0].page, 32+48, 16, (player[0].data));\r
205                 }\r
206                 //TODO fmemtest into page\r
207                 /*if(IN_KeyDown(4+1))   //4\r
208                 {\r
209                         pg=1;\r
210                         SELECT_ALL_PLANES();\r
211                         _fmemset(((mv[pg].page->data+4)+(16*(mv[pg].page->width/4))), 15, 4);\r
212                 }*/\r
213 \r
214                 //9\r
215 #ifdef FADE\r
216                 if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(dpal); IN_UserInput(1,1); }\r
217                 //if(IN_KeyDown(11)){ modexPalOverscan(15); }\r
218 #endif\r
219                 if((player[0].q==1) && !(player[0].x%TILEWH==0 && player[0].y%TILEWH==0)) break;        //incase things go out of sync!\r
220                 player[0].hp = 0;\r
221         }\r
222 \r
223         /* fade back to text mode */\r
224         /* but 1st lets save the game palette~ */\r
225         quit:\r
226 #ifdef FADE\r
227         modexPalSave(gpal);\r
228         modexSavePalFile("data/g.pal", gpal);\r
229         modexFadeOff(4, gpal);\r
230 #endif\r
231         VGAmodeX(0, 1, &gvar);\r
232         Shutdown16(&gvar);\r
233         printf("\nProject 16 zcroll.exe. This is just a test file!\n");\r
234         printf("version %s\n", VERSION);\r
235         SCROLLEXITMESG;\r
236         switch(detectcpu())\r
237         {\r
238                 case 0: cpus = "8086/8088 or 186/88"; break;\r
239                 case 1: cpus = "286"; break;\r
240                 case 2: cpus = "386 or newer"; break;\r
241                 default: cpus = "internal error"; break;\r
242         }\r
243         printf("detected CPU type: %s\n", cpus);\r
244 #ifdef FADE\r
245         modexFadeOn(4, dpal);\r
246 #endif\r
247 }\r