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 for(i=0;i<gvar.video.num_of_pages;i++)
\r
112 mv[i].page = &gvar.video.page[i];
\r
114 mv[i].video = &gvar.video;
\r
117 player[0].ent->spri->x = player[0].ent->spri->y = 20;
\r
120 //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen
\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
130 i = set_anim_by_id(player[0].ent->spri, 11);
\r
131 print_anim_ids(player[0].ent->spri);
\r
135 modexFadeOff(4, gpal);
\r
137 Quit(&gvar, "Wrong");
\r
139 modexFadeOn(4, dpal);
\r
142 //animate_spri((player[0].ent->spri), &gvar);
\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
147 modexFadeOn(4, gpal);
\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
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
160 IN_ReadControl(0, &player);
\r
162 //ZC_walk(player[0].ent, mv);
\r
163 walk(mv, &player, 0);
\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
170 for(i=800; i>=400; i--)
\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
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
187 if(IN_KeyDown(88)){panswitch=!panswitch; IN_UserInput(1,1);} //f12
\r
188 if(IN_KeyDown(87)) //f11
\r
190 pageflipflop=!pageflipflop;
\r
193 if(IN_KeyDown(68)) //f10
\r
195 gvar.kurokku.fpscap=!gvar.kurokku.fpscap;
\r
198 if(IN_KeyDown(67)) //f9
\r
200 modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 2);
\r
202 if(IN_KeyDown(66)) //f8
\r
204 // modexDrawSprite(mv[0].page, 16, 16, &p);
\r
205 // modexDrawSprite(mv[0].page, 32+72, 16, (player[0].data));
\r
210 player[0].ent->spri->x = 0;
\r
213 player[0].ent->spri->delay = 1; animate_spri((player[0].ent->spri), &gvar); player[0].ent->spri->x += 20;
\r
217 //TODO fmemtest into page
\r
218 /*if(IN_KeyDown(4+1)) //4
\r
221 SELECT_ALL_PLANES();
\r
222 _fmemset(((mv[pg].page->data+4)+(16*(mv[pg].page->width/4))), 15, 4);
\r
227 if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(dpal); IN_UserInput(1,1); }
\r
228 //if(IN_KeyDown(11)){ modexPalOverscan(15); }
\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
234 /* fade back to text mode */
\r
235 /* but 1st lets save the game palette~ */
\r
237 modexPalSave(gpal);
\r
238 modexSavePalFile("data/g.pal", gpal);
\r
239 modexFadeOff(4, gpal);
\r
241 VGAmodeX(0, 1, &gvar);
\r
243 printf("\nProject 16 zcroll.exe. This is just a test file!\n");
\r
244 printf("version %s\n", VERSION);
\r
248 modexFadeOn(4, dpal);
\r