-/* Project 16 Source Code~\r
- * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
- *\r
- * This file is part of Project 16.\r
- *\r
- * Project 16 is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * Project 16 is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>, or\r
- * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
- * Fifth Floor, Boston, MA 02110-1301 USA.\r
- *\r
- */\r
-\r
-#include "src/lib/scroll16.h"\r
-#include "src/lib/16_timer.h"\r
-#include "src/lib/16render.h"\r
-#include "src/lib/16_dbg.h"\r
-\r
-#define FADE\r
-\r
-static map_t map;\r
-map_view_t mv[4];\r
-float t;\r
-\r
-//debugswitches\r
-boolean panswitch=0,baka=0;\r
-//extern boolean pageflipflop=1;\r
-extern boolean pagenorendermap; //default: 0\r
-unsigned int i;\r
-\r
-#ifdef FADE\r
-//static word paloffset=0;\r
-byte *dpal;\r
-#endif\r
-byte *gpal;\r
-byte *ptr;\r
-memptr pal;\r
-\r
-#define FILENAME_1 "data/spri/chikyuu.vrs"\r
-#define FILENAME_1P "data/spri/chikyuu.pal"\r
-#define FILENAME_2 "data/spri/ptmp.vrs"\r
-#define FILENAME_2P "data/spri/ptmp.pal"\r
-\r
-void main(int argc, char *argv[])\r
-{\r
- static global_game_variables_t gvar;\r
- static player_t player[MaxPlayers];\r
- char *bakapee1,*bakapee1p;\r
-// sword bakapee;\r
-// if(argv[1]) bakapee = atoi(argv[1]);\r
-// else bakapee = 1;\r
-\r
- Startup16(&gvar);\r
-\r
- bakapee1=malloc(64);\r
- bakapee1p=malloc(64);\r
-\r
- if (argc < 2) {\r
- //fprintf(stderr,"drawvrl <VRL file> <palette file>\n palette file optional\n");\r
- bakapee1 = FILENAME_1;\r
- bakapee1p = FILENAME_1P;\r
-\r
- }else{\r
- if(argv[1]) bakapee1 = argv[1];\r
- if(argv[2]) bakapee1p = argv[2];\r
- }\r
-\r
- // OK, this one takes hellova time and needs to be done in farmalloc or MM_...\r
- //IN CA i think you use CAL_SetupGrFile but i do think we should work together on this part --sparky4\r
- //player[0].ent = malloc(sizeof(entity_t));\r
- player[0].enti.spri = malloc(sizeof(struct sprite));\r
- player[0].enti.spri->spritesheet = malloc(sizeof(struct vrs_container));\r
-\r
- // create the map\r
-// fprintf(stderr, "testing map load~ ");\r
- loadmap("data/test.map", &map);\r
- chkmap(&map, 0);\r
-// initMap(&map);\r
-// printf("chkmap ok ");\r
-// fprintf(stderr, "yay map loaded~~\n");\r
-\r
- // data\r
- VRS_LoadVRS(bakapee1, &player[0].enti, &gvar);\r
-\r
- // input!\r
- IN_Default(0, &player,ctrl_Keyboard1);\r
-\r
- // save the palette\r
-#ifdef FADE\r
- dpal = modexNewPal();\r
- modexPalSave(dpal);\r
- modexFadeOff(4, dpal);\r
-#endif\r
-\r
- VGAmodeX(1/*bakapee*/, 1, &gvar);\r
-\r
- /* load color palette */\r
- VL_LoadPalFile(bakapee1p, &gvar.video.palette);\r
-\r
-#ifdef FADE\r
- gpal = modexNewPal();\r
- modexPalSave(gpal);\r
- modexSavePalFile("data/g.pal", gpal);\r
- modexPalBlack(); //so player will not see loadings~\r
-#endif\r
-\r
- // setup camera and screen~\r
- modexHiganbanaPageSetup(&gvar.video);\r
- ZC_MVSetup(&mv, &map, &gvar);\r
-\r
- // set up paging\r
- //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen\r
- mapGoTo(&mv, 0, 0);\r
-\r
- ZC_playerXYpos(0, 0, &player, &mv, 0, 1);\r
- EN_initplayer(&player, 0, &gvar.video);\r
- //print_anim_ids(player[0].enti.spri);\r
- if (gvar.video.sprifilei == -1)\r
- {\r
-#ifdef FADE\r
- modexFadeOff(4, gpal);\r
-#endif\r
- Quit(&gvar, "Wrong ID for sprite");\r
-#ifdef FADE\r
- modexFadeOn(4, dpal);\r
-#endif\r
- }\r
-\r
-// while(!IN_KeyDown(sc_Escape) && !IN_KeyDown(sc_Space) && !IN_KeyDown(sc_Enter)){ FUNCTIONKEYSHOWMV }\r
- gvar.video.page[0].tlx=mv[0].tx*TILEWH;\r
- gvar.video.page[0].tly=mv[0].ty*TILEWH;\r
- shinku(&gvar);\r
-#ifdef FADE\r
- modexFadeOn(4, gpal);\r
-#endif\r
- while(!IN_KeyDown(sc_Escape) && player[0].enti.hp>0)\r
- {\r
- gvar.video.page[0].tlx=mv[0].tx*TILEWH;\r
- gvar.video.page[0].tly=mv[0].ty*TILEWH;\r
- shinku(&gvar);\r
- //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square\r
- //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction\r
- //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
-\r
- //player movement\r
- IN_ReadControl(0, &player);\r
- if(!panswitch){\r
- //ZC_walk2(player[0].ent, mv);\r
- ZC_walk(&mv, &player, 0);\r
- }else{\r
- PANKEYFUNZC;\r
- //printf(" player[0].enti.q: %d", player[0].enti.q); printf(" player[0].d: %d\n", player[0].d);\r
- }\r
-\r
- //the scripting stuff....\r
- //if(((player[0].enti.triggerx == TRIGGX && player[0].enti.triggery == TRIGGY) && IN_KeyDown(0x1C))||(player[0].enti.tx == 5 && player[0].enti.ty == 5))\r
- if(((mv[0].map->data[(player[0].enti.triggerx-1)+(map.width*(player[0].enti.triggery-1))] == 0) && IN_KeyDown(0x1C))||(player[0].enti.tx == 5 && player[0].enti.ty == 5))\r
- {\r
- short i;\r
- for(i=800; i>=400; i--)\r
- {\r
- sound(i);\r
- }\r
- nosound();\r
- }\r
- if(player[0].enti.q == (TILEWH/(player[0].enti.speed))+1 && player[0].info.dir != 2 && (player[0].enti.triggerx == 5 && player[0].enti.triggery == 5)){ player[0].enti.hp--; }\r
- //debugging binds!\r
-\r
- if(IN_KeyDown(24)){ modexPalUpdate0(gpal); /*paloffset=0;*/ modexpdump(mv[0].page); IN_UserInput(1,1); } //o\r
- if(IN_KeyDown(22)){ modexPalUpdate0(gpal); } //u\r
-\r
- FUNCTIONKEYFUNCTIONS\r
- FUNCTIONKEYDRAWJUNK\r
- if(IN_KeyDown(sc_L)){ modexClearRegion(&gvar.video.page[0], player[0].enti.x, player[0].enti.y, 16, 16, 1); }\r
- if(IN_KeyDown(sc_J) || IN_KeyDown(sc_K))\r
- {\r
- if(IN_KeyDown(sc_J))\r
- {\r
- bakapee1=FILENAME_1;\r
- bakapee1p=FILENAME_1P;\r
- player[0].enti.overdraww=0;\r
- }\r
- if(IN_KeyDown(sc_K))\r
- {\r
- bakapee1=FILENAME_2;\r
- bakapee1p=FILENAME_2P;\r
- player[0].enti.overdraww=2;\r
- }\r
- //read_vrs(&gvar, bakapee1, player[0].enti.spri->spritesheet);\r
- VRS_ReadVRS(bakapee1, &player[0].enti, &gvar);\r
- VL_LoadPalFile(bakapee1p, &gvar.video.palette);\r
- }//JK\r
-#ifdef FADE\r
- if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate(dpal); IN_UserInput(1,1); }\r
-#endif\r
- if(IN_KeyDown(sc_R)){ modexPalOverscan(rand()%56); } //r\r
-\r
- if((player[0].enti.q==1) && !(player[0].enti.x%TILEWH==0 && player[0].enti.y%TILEWH==0)) Quit(&gvar, "PLAYER OFF THE RAILS!");//break; //incase things go out of sync!\r
- }\r
-\r
- /* fade back to text mode */\r
- /* but 1st lets save the game palette~ */\r
-#ifdef FADE\r
- modexPalSave(gpal);\r
- modexSavePalFile("data/g.pal", gpal);\r
- modexFadeOff(4, gpal);\r
-#endif\r
- Shutdown16(&gvar);\r
- printf("\nProject 16 zcroll.exe. This is just a test file!\n");\r
- printf("version %s\n", VERSION);\r
- SCROLLEXITMESG;\r
- WCPU_cpufpumesg();\r
-#ifdef FADE\r
- modexFadeOn(4, dpal);\r
-#endif\r
-}\r