]> 4ch.mooo.com Git - 16.git/blob - src/zcroll.c
trying to figure out the issue with player sprite with pcx i have no idea wwww
[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/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 //bitmap_t p;\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         player[0].data = malloc(72*128); //TODO use exmm\r
80         *player[0].data = bitmapLoadPcx("data/chikyuu.pcx", &gvar); // load sprite\r
81 \r
82         //      input!\r
83         IN_Default(0, &player,ctrl_Keyboard1);\r
84 \r
85         // save the palette\r
86 #ifdef FADE\r
87         dpal = modexNewPal();\r
88         modexPalSave(dpal);\r
89         modexFadeOff(4, dpal);\r
90 #endif\r
91         textInit();\r
92         VGAmodeX(bakapee, 1, &gvar);\r
93 #ifdef MODEXZ\r
94 #ifdef FADE\r
95         modexPalBlack();        //reset the palette~\r
96 #endif\r
97         CA_LoadFile("data/spri/chikyuu.pal", &pal, &gvar);\r
98         modexPalUpdate1(pal);\r
99 #ifdef FADE\r
100         gpal = modexNewPal();\r
101         modexPalSave(gpal);\r
102         modexSavePalFile("data/g.pal", gpal);\r
103         modexPalBlack();        //so player will not see loadings~\r
104 #endif\r
105 \r
106         // setup camera and screen~\r
107         modexHiganbanaPageSetup(&gvar.video);\r
108         for(i=0;i<gvar.video.num_of_pages;i++)\r
109         {\r
110                 mv[i].page = &gvar.video.page[i];\r
111                 mv[i].map = &map;\r
112                 mv[i].video = &gvar.video;\r
113                 mv[i].pan       = &pan;\r
114         }\r
115         player[0].ent->spri->x = player[0].ent->spri->y = 20;\r
116 \r
117         // set up paging\r
118         //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen\r
119         mapGoTo(mv, 0, 0);\r
120 #endif\r
121 \r
122         //TODO: put player in starting position of spot\r
123         //default player position on the viewable map\r
124         player[0].tx = mv[0].tx + mv[0].page->tilemidposscreenx;\r
125         player[0].ty = mv[0].ty + mv[0].page->tilemidposscreeny;\r
126         IN_initplayer(&player, 0);\r
127 \r
128         i = set_anim_by_id(player[0].ent->spri, 11);\r
129         print_anim_ids(player[0].ent->spri);\r
130         if (i == -1)\r
131         {\r
132 #ifdef FADE\r
133                 modexFadeOff(4, gpal);\r
134 #endif\r
135                 Quit(&gvar, "Wrong");\r
136 #ifdef FADE\r
137                 modexFadeOn(4, dpal);\r
138 #endif\r
139         exit(-4);\r
140         }\r
141         //++++animate_spri(&(player[0].ent->spri));\r
142 \r
143         modexShowPage(mv[0].page);//!(gvar.video.p)\r
144         shinku_fps_indicator_page = 0; // we're on page 1 now, shinku(). follow along please or it will not be visible.\r
145 #ifdef FADE\r
146         modexFadeOn(4, gpal);\r
147 #endif\r
148         /*strcpy(global_temp_status_text, "press enter for the loop of zcroll\nescape to quit");\r
149         modexprint(&gvar.video.page[0], 144, 72, 1, 7, 0, global_temp_status_text);\r
150         while(!IN_KeyDown(sc_Enter)){ if(IN_KeyDown(sc_Escape)) goto quit; } IN_UserInput(1,1);*///wwww\r
151         while(!IN_KeyDown(sc_Escape))// && player[0].hp>0)\r
152         {\r
153                 shinku(&gvar);\r
154                 //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square\r
155                 //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction\r
156                 //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
157 \r
158                 //player movement\r
159                 IN_ReadControl(0, &player);\r
160                 if(!panswitch){\r
161                         //ZC_walk(player[0].ent, mv);\r
162                         walk(mv, &player, 0);\r
163                 }\r
164 \r
165                 //the scripting stuff....\r
166 /*              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
167                 {\r
168                         short i;\r
169                         for(i=800; i>=400; i--)\r
170                         {\r
171                                 sound(i);\r
172                         }\r
173                         nosound();\r
174                 }\r
175                 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
176 */              //debugging binds!\r
177                 if(IN_KeyDown(2)){ modexShowPage(mv[0].page); pan.pn=0; }\r
178                 if(IN_KeyDown(25)){ modexpdump(mv[0].page);\r
179                          IN_UserInput(1,1);\r
180                 }       //p\r
181 #ifdef FADE\r
182                 if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; modexpdump(mv[0].page); IN_UserInput(1,1); } //p\r
183                 if(IN_KeyDown(22)){\r
184                         printf("2paloffset      =       %d\n", paloffset/3);\r
185                         IN_UserInput(1,1);\r
186                 }\r
187 #endif\r
188 \r
189                 //pan switch\r
190                 if(IN_KeyDown(88)){panswitch=!panswitch; IN_UserInput(1,1);}    //f12\r
191                 if(IN_KeyDown(87))      //f11\r
192                 {\r
193                         pageflipflop=!pageflipflop;\r
194                         IN_UserInput(1,1);\r
195                 }\r
196                 if(IN_KeyDown(68))      //f10\r
197                 {\r
198                         gvar.kurokku.fpscap=!gvar.kurokku.fpscap;\r
199                         IN_UserInput(1,1);\r
200                 }\r
201                 if(IN_KeyDown(67))      //f9\r
202                 {\r
203                         modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 2);\r
204                 }\r
205                 if(IN_KeyDown(66))      //f8\r
206                 {\r
207 //                      modexDrawSprite(mv[0].page, 16, 16, &p);\r
208                         modexDrawSprite(mv[0].page, 32+72, 16, (player[0].data));\r
209                 }\r
210                 //TODO fmemtest into page\r
211                 /*if(IN_KeyDown(4+1))   //4\r
212                 {\r
213                         pg=1;\r
214                         SELECT_ALL_PLANES();\r
215                         _fmemset(((mv[pg].page->data+4)+(16*(mv[pg].page->width/4))), 15, 4);\r
216                 }*/\r
217 \r
218                 //9\r
219 #ifdef FADE\r
220                 if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(dpal); IN_UserInput(1,1); }\r
221                 //if(IN_KeyDown(11)){ modexPalOverscan(15); }\r
222 #endif\r
223                 if((player[0].q==1) && !(player[0].x%TILEWH==0 && player[0].y%TILEWH==0)) break;        //incase things go out of sync!\r
224                 player[0].hp = 0;\r
225         }\r
226 \r
227         /* fade back to text mode */\r
228         /* but 1st lets save the game palette~ */\r
229         //quit:\r
230 #ifdef FADE\r
231         modexPalSave(gpal);\r
232         modexSavePalFile("data/g.pal", gpal);\r
233         modexFadeOff(4, gpal);\r
234 #endif\r
235         VGAmodeX(0, 1, &gvar);\r
236         Shutdown16(&gvar);\r
237         printf("\nProject 16 zcroll.exe. This is just a test file!\n");\r
238         printf("version %s\n", VERSION);\r
239         SCROLLEXITMESG;\r
240         switch(detectcpu())\r
241         {\r
242                 case 0: cpus = "8086/8088 or 186/88"; break;\r
243                 case 1: cpus = "286"; break;\r
244                 case 2: cpus = "386 or newer"; break;\r
245                 default: cpus = "internal error"; break;\r
246         }\r
247         printf("detected CPU type: %s\n", cpus);\r
248 #ifdef FADE\r
249         modexFadeOn(4, dpal);\r
250 #endif\r
251 }\r