1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\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
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
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
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
37 boolean panswitch=0,baka=0;
\r
38 //extern boolean pageflipflop=1;
\r
40 //static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */
\r
42 //map_view_db_t pgid[4];
\r
45 static word paloffset=0;
\r
52 void main(int argc, char *argv[])
\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
59 player[0].data = _fmalloc(72*128); //TODO use exmm
\r
60 *player[0].data = bitmapLoadPcx("data/chikyuu.pcx", &gvar); // load sprite
\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
73 // fprintf(stderr, "testing map load~ ");
\r
74 loadmap("data/test.map", &map);
\r
76 // printf("chkmap ok ");
\r
77 // fprintf(stderr, "yay map loaded~~\n");
\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
85 IN_Default(0, &player,ctrl_Keyboard1);
\r
89 dpal = modexNewPal();
\r
91 modexFadeOff(4, dpal);
\r
94 VGAmodeX(bakapee, 1, &gvar);
\r
97 modexPalBlack(); //reset the palette~
\r
99 CA_LoadFile("data/spri/chikyuu.pal", &pal, &gvar);
\r
100 modexPalUpdate1(pal);
\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
108 // setup camera and screen~
\r
109 modexHiganbanaPageSetup(&gvar.video);
\r
110 modexMVSetup(&mv, &map, &pan, &gvar);
\r
111 player[0].ent->spri->x = player[0].ent->spri->y = TILEWH;
\r
114 //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen
\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
124 i = set_anim_by_id(player[0].ent->spri, 11);
\r
125 print_anim_ids(player[0].ent->spri);
\r
129 modexFadeOff(4, gpal);
\r
131 Quit(&gvar, "Wrong");
\r
133 modexFadeOn(4, dpal);
\r
136 animate_spri((player[0].ent->spri), &gvar);
\r
138 modexShowPage(mv[0].page);//!(gvar.video.p)
\r
139 shinku_fps_indicator_page = 0; // we're on page 1 now, shinku(). follow along please or it will not be visible.
\r
141 modexFadeOn(4, gpal);
\r
143 /*strcpy(global_temp_status_text, "press enter for the loop of zcroll\nescape to quit");
\r
144 modexprint(&gvar.video.page[0], 144, 72, 1, 7, 0, global_temp_status_text);
\r
145 while(!IN_KeyDown(sc_Enter)){ if(IN_KeyDown(sc_Escape)) goto quit; } IN_UserInput(1,1);*///wwww
\r
146 while(!IN_KeyDown(sc_Escape))// && player[0].hp>0)
\r
149 //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square
\r
150 //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction
\r
151 //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
154 IN_ReadControl(0, &player);
\r
156 //ZC_walk(player[0].ent, mv);
\r
157 walk(mv, &player, 0);
\r
160 //the scripting stuff....
\r
161 /* 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
164 for(i=800; i>=400; i--)
\r
170 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
171 */ //debugging binds!
\r
172 if(IN_KeyDown(2)){ modexShowPage(mv[0].page); pan.pn=0; }
\r
173 if(IN_KeyDown(25)){ modexpdump(mv[0].page);
\r
177 if(IN_KeyDown(24)){ modexPalUpdate0(gpal); /*paloffset=0;*/ modexpdump(mv[0].page); IN_UserInput(1,1); } //o
\r
178 if(IN_KeyDown(22)){ modexPalUpdate0(gpal); } //u
\r
181 if(IN_KeyDown(88)){panswitch=!panswitch; IN_UserInput(1,1);} //f12
\r
182 if(IN_KeyDown(87)) //f11
\r
184 pageflipflop=!pageflipflop;
\r
187 if(IN_KeyDown(68)) //f10
\r
189 gvar.kurokku.fpscap=!gvar.kurokku.fpscap;
\r
192 if(IN_KeyDown(67)) //f9
\r
194 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 2);
\r
196 if(IN_KeyDown(66)) //f8
\r
198 // modexDrawSprite(mv[0].page, 16, 16, &p);
\r
199 // modexDrawSprite(mv[0].page, 32+72, 16, (player[0].data));
\r
204 player[0].ent->spri->x = 0;
\r
207 player[0].ent->spri->delay = 1; animate_spri((player[0].ent->spri), &gvar); player[0].ent->spri->x += 20;
\r
211 FUNCTIONKEYFUNCTIONS;
\r
212 // fmemtest into page
\r
213 /*if(IN_KeyDown(4+1)) //4
\r
216 SELECT_ALL_PLANES();
\r
217 _fmemset(((mv[pg].page->data+4)+(16*(mv[pg].page->width/4))), 15, 4);
\r
222 if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(dpal); IN_UserInput(1,1); }
\r
224 if(IN_KeyDown(sc_R)){ modexPalOverscan(rand()%56); } //r
\r
226 if((player[0].q==1) && !(player[0].x%TILEWH==0 && player[0].y%TILEWH==0)) break; //incase things go out of sync!
\r
230 /* fade back to text mode */
\r
231 /* but 1st lets save the game palette~ */
\r
233 modexPalSave(gpal);
\r
234 modexSavePalFile("data/g.pal", gpal);
\r
235 modexFadeOff(4, gpal);
\r
237 VGAmodeX(0, 1, &gvar);
\r
239 printf("\nProject 16 zcroll.exe. This is just a test file!\n");
\r
240 printf("version %s\n", VERSION);
\r
244 modexFadeOn(4, dpal);
\r