]> 4ch.mooo.com Git - 16.git/blob - src/zcroll.c
==== PRE SHOWPAGE TO SHOWMV CONVERSION ==== i am going to work on a really big area...
[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/scroll16.h"\r
24 #include "src/lib/16_timer.h"\r
25 #include "src/lib/16render.h"\r
26 #include "src/lib/16_dbg.h"\r
27 \r
28 //bitmap_t p;\r
29 static map_t map;\r
30 map_view_t mv[4];\r
31 float t;\r
32 sword bakapee;\r
33 //debugswitches\r
34 boolean panswitch=0,baka=0;\r
35 //extern boolean pageflipflop=1;\r
36 unsigned int i;\r
37 \r
38 #ifdef FADE\r
39 static word paloffset=0;\r
40 byte *dpal;\r
41 #endif\r
42 byte *gpal;\r
43 byte *ptr;\r
44 memptr pal;\r
45 \r
46 void main(int argc, char *argv[])\r
47 {\r
48         static global_game_variables_t gvar;\r
49         static player_t player[MaxPlayers];\r
50         if(argv[1]) bakapee = atoi(argv[1]);\r
51         else bakapee = 1;\r
52 \r
53         Startup16(&gvar);\r
54 \r
55         gvar.video.panp=0;\r
56 \r
57         // OK, this one takes hellova time and needs to be done in farmalloc or MM_...\r
58         //IN CA i think you use CAL_SetupGrFile but i do think we should work together on this part --sparky4\r
59         player[0].ent = malloc(sizeof(entity_t));\r
60         player[0].ent->spri = malloc(sizeof(struct sprite));\r
61         player[0].ent->spri->spritesheet = malloc(sizeof(struct vrs_container));\r
62 \r
63         // create the map\r
64 //      fprintf(stderr, "testing map load~      ");\r
65         loadmap("data/test.map", &map);\r
66         chkmap(&map, 0);\r
67 //      printf("chkmap ok       ");\r
68 //      fprintf(stderr, "yay map loaded~~\n");\r
69 \r
70         // data\r
71         read_vrs(&gvar, "data/spri/chikyuu.vrs", player[0].ent->spri->spritesheet);\r
72         PCXBMP = bitmapLoadPcx("data/chikyuu.pcx", &gvar); // load sprite\r
73 \r
74         // input!\r
75         IN_Default(0, &player,ctrl_Keyboard1);\r
76 \r
77         // save the palette\r
78 #ifdef FADE\r
79         dpal = modexNewPal();\r
80         modexPalSave(dpal);\r
81         modexFadeOff(4, dpal);\r
82 #endif\r
83 \r
84         VGAmodeX(bakapee, 1, &gvar);\r
85 \r
86         /* fix up the palette and everything */\r
87 #ifdef FADE\r
88         modexPalBlack();        //reset the palette~\r
89 #endif\r
90         modexPalUpdate1(&PCXBMP->palette);\r
91 //      CA_LoadFile("data/spri/chikyuu.pal", &pal, &gvar);\r
92 //      modexPalUpdate1(pal);\r
93 #ifdef FADE\r
94         gpal = modexNewPal();\r
95         modexPalSave(gpal);\r
96         modexSavePalFile("data/g.pal", gpal);\r
97         modexPalBlack();        //so player will not see loadings~\r
98 #endif\r
99 \r
100         // setup camera and screen~\r
101         modexHiganbanaPageSetup(&gvar.video);\r
102         ZC_MVSetup(&mv, &map, &gvar);\r
103         player[0].ent->spri->x = player[0].ent->spri->y = TILEWH;\r
104 \r
105         // set up paging\r
106         //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen\r
107         mapGoTo(&mv, 0, 0);\r
108 \r
109         playerXYpos(0, 0, &player, &mv, 0);\r
110         IN_initplayer(&player, 0);\r
111 \r
112         i = set_anim_by_id(player[0].ent->spri, 11);\r
113         print_anim_ids(player[0].ent->spri);\r
114         if (i == -1)\r
115         {\r
116 #ifdef FADE\r
117                 modexFadeOff(4, gpal);\r
118 #endif\r
119                 Quit(&gvar, "Wrong");\r
120 #ifdef FADE\r
121                 modexFadeOn(4, dpal);\r
122 #endif\r
123         }\r
124         animate_spri((player[0].ent->spri), &gvar);\r
125 \r
126         VL_ShowPage(mv[0].page, 0, 0);//modexShowPage(mv[0].page);//!(gvar.video.p)\r
127 #ifdef FADE\r
128         modexFadeOn(4, gpal);\r
129 #endif\r
130         /*strcpy(global_temp_status_text, "press enter for the loop of zcroll\nescape to quit");\r
131         modexprint(&gvar.video.page[0], 144, 72, 1, 7, 0, global_temp_status_text);\r
132         while(!IN_KeyDown(sc_Enter)){ if(IN_KeyDown(sc_Escape)) goto quit; } IN_UserInput(1,1);*///wwww\r
133         while(!IN_KeyDown(sc_Escape))// && player[0].hp>0)\r
134         {\r
135                 shinku(&gvar);\r
136                 //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square\r
137                 //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction\r
138                 //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
139 \r
140                 //player movement\r
141                 IN_ReadControl(0, &player);\r
142                 if(!panswitch){\r
143                         //ZC_walk2(player[0].ent, mv);\r
144                         ZC_walk(&mv, &player, 0);\r
145                 }\r
146 \r
147                 //the scripting stuff....\r
148 /*              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
149                 {\r
150                         short i;\r
151                         for(i=800; i>=400; i--)\r
152                         {\r
153                                 sound(i);\r
154                         }\r
155                         nosound();\r
156                 }\r
157                 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
158 */              //debugging binds!\r
159                 if(IN_KeyDown(2)){ modexShowPage(mv[0].page); gvar.video.panp=0; }\r
160                 if(IN_KeyDown(25)){ modexpdump(mv[0].page);\r
161                          IN_UserInput(1,1);\r
162                 }       //p\r
163 \r
164                 if(IN_KeyDown(24)){ modexPalUpdate0(gpal); /*paloffset=0;*/ modexpdump(mv[0].page); IN_UserInput(1,1); } //o\r
165                 if(IN_KeyDown(22)){ modexPalUpdate0(gpal); } //u\r
166 \r
167                 //pan switch\r
168                 //if(IN_KeyDown(88)){panswitch=!panswitch; IN_UserInput(1,1);}  //f12\r
169                 if(IN_KeyDown(87))      //f11\r
170                 {\r
171                         pageflipflop=!pageflipflop;\r
172                         IN_UserInput(1,1);\r
173                 }\r
174                 if(IN_KeyDown(68))      //f10\r
175                 {\r
176                         gvar.kurokku.fpscap=!gvar.kurokku.fpscap;\r
177                         IN_UserInput(1,1);\r
178                 }\r
179                 if(IN_KeyDown(67))      //f9\r
180                 {\r
181                         modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 2);\r
182                 }\r
183                 if(IN_KeyDown(66))      //f8\r
184                 {\r
185 //                      modexDrawSprite(mv[0].page, 16, 16, &p);\r
186 //                      modexDrawSprite(mv[0].page, 32+72, 16, (player[0].data));\r
187                         switch(i)\r
188                         {\r
189                                 case 11:\r
190                                         i=0;\r
191                                         player[0].ent->spri->x = 0;\r
192                                 default:\r
193                                         i++;\r
194                                         player[0].ent->spri->delay = 1; animate_spri((player[0].ent->spri), &gvar); player[0].ent->spri->x += 20;\r
195                                 break;\r
196                         }\r
197                 }\r
198                 FUNCTIONKEYFUNCTIONS;\r
199 \r
200                 //9\r
201 #ifdef FADE\r
202                 if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(dpal); IN_UserInput(1,1); }\r
203 #endif\r
204                 if(IN_KeyDown(sc_R)){ modexPalOverscan(rand()%56); } //r\r
205 \r
206                 if((player[0].q==1) && !(player[0].x%TILEWH==0 && player[0].y%TILEWH==0)) break;        //incase things go out of sync!\r
207                 player[0].hp = 0;\r
208         }\r
209 \r
210         /* fade back to text mode */\r
211         /* but 1st lets save the game palette~ */\r
212 #ifdef FADE\r
213         modexPalSave(gpal);\r
214         modexSavePalFile("data/g.pal", gpal);\r
215         modexFadeOff(4, gpal);\r
216 #endif\r
217         VGAmodeX(0, 1, &gvar);\r
218         Shutdown16(&gvar);\r
219         printf("\nProject 16 zcroll.exe. This is just a test file!\n");\r
220         printf("version %s\n", VERSION);\r
221         SCROLLEXITMESG;\r
222         WCPU_cpufpumesg();\r
223 #ifdef FADE\r
224         modexFadeOn(4, dpal);\r
225 #endif\r
226 }\r