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