]> 4ch.mooo.com Git - 16.git/blobdiff - src/zcroll.c
dang it./wbuild.sh vga_state.vga_graphics_ram = video->omemptr; causes it to not...
[16.git] / src / zcroll.c
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9e3c0b58192374c638cbcbf2117222a2c9a09342 100755 (executable)
@@ -0,0 +1,232 @@
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2016 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
+//bitmap_t p;\r
+static map_t map;\r
+map_view_t mv[4];\r
+float t;\r
+sword bakapee;\r
+//debugswitches\r
+boolean panswitch=0,baka=0;\r
+//extern boolean pageflipflop=1;\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
+void main(int argc, char *argv[])\r
+{\r
+       static global_game_variables_t gvar;\r
+       static player_t player[MaxPlayers];\r
+       if(argv[1]) bakapee = atoi(argv[1]);\r
+       else bakapee = 1;\r
+\r
+       Startup16(&gvar);\r
+\r
+       gvar.video.panp=0;\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].ent->spri = malloc(sizeof(struct sprite));\r
+       player[0].ent->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
+//     printf("chkmap ok       ");\r
+//     fprintf(stderr, "yay map loaded~~\n");\r
+\r
+       // data\r
+       read_vrs(&gvar, "data/spri/chikyuu.vrs", player[0].ent->spri->spritesheet);\r
+       PCXBMP = bitmapLoadPcx("data/chikyuu.pcx", &gvar); // load sprite\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(bakapee, 1, &gvar);\r
+\r
+       /* fix up the palette and everything */\r
+#ifdef FADE\r
+       modexPalBlack();        //reset the palette~\r
+#endif\r
+       modexPalUpdate1(&PCXBMP->palette);\r
+//     CA_LoadFile("data/spri/chikyuu.pal", &pal, &gvar);\r
+//     modexPalUpdate1(pal);\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
+       //renderswitch\r
+       gvar.video.rs=0;\r
+       //player[0].ent->spri->x = player[0].ent->spri->y = TILEWH;\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
+       playerXYpos(0, 0, &player, &mv, 0);\r
+       IN_initplayer(&player, 0);\r
+       player[0].ent->spri->x = player[0].enti.x-4;\r
+       player[0].ent->spri->y = player[0].enti.y-16;\r
+       player[0].ent->spri->delay = 0;\r
+\r
+       i = set_anim_by_id(player[0].ent->spri, 31);\r
+       print_anim_ids(player[0].ent->spri);\r
+       if (i == -1)\r
+       {\r
+#ifdef FADE\r
+               modexFadeOff(4, gpal);\r
+#endif\r
+               Quit(&gvar, "Wrong");\r
+#ifdef FADE\r
+               modexFadeOn(4, dpal);\r
+#endif\r
+       }\r
+       animate_spri((player[0].ent->spri), &gvar.video);\r
+\r
+       VL_ShowPage(mv[0].page, 0, 0);//modexShowPage(mv[0].page);//!(gvar.video.p)\r
+#ifdef FADE\r
+       modexFadeOn(4, gpal);\r
+#endif\r
+       /*strcpy(global_temp_status_text, "press enter for the loop of zcroll\nescape to quit");\r
+       modexprint(&gvar.video.page[0], 144, 72, 1, 7, 0, global_temp_status_text);\r
+       while(!IN_KeyDown(sc_Enter)){ if(IN_KeyDown(sc_Escape)) goto quit; } IN_UserInput(1,1);*///wwww\r
+       while(!IN_KeyDown(sc_Escape))// && player[0].enti.hp>0)\r
+       {\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
+               }\r
+\r
+               //the scripting stuff....\r
+/*             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
+               {\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].speed))+1 && player[0].info.dir != 2 && (player[0].triggerx == 5 && player[0].triggery == 5)){ player[0].enti.hp--; }\r
+*/             //debugging binds!\r
+               if(IN_KeyDown(2)){ modexShowPage(mv[0].page); gvar.video.panp=0; }\r
+               if(IN_KeyDown(25)){ modexpdump(mv[0].page);\r
+                        IN_UserInput(1,1);\r
+               }       //p\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
+               //pan switch\r
+               //if(IN_KeyDown(88)){panswitch=!panswitch; IN_UserInput(1,1);}  //f12\r
+               if(IN_KeyDown(87))      //f11\r
+               {\r
+                       pageflipflop=!pageflipflop;\r
+                       IN_UserInput(1,1);\r
+               }\r
+               if(IN_KeyDown(68))      //f10\r
+               {\r
+                       gvar.kurokku.fpscap=!gvar.kurokku.fpscap;\r
+                       IN_UserInput(1,1);\r
+               }\r
+               if(IN_KeyDown(67))      //f9\r
+               {\r
+                       modexClearRegion(mv[0].page, 0, 0, mv[0].page->width, mv[0].page->height, 2);\r
+               }\r
+               if(IN_KeyDown(66))      //f8\r
+               {\r
+//                     modexDrawSprite(mv[0].page, 16, 16, &p);\r
+//                     modexDrawSprite(mv[0].page, 32+72, 16, (player[0].data));\r
+                       switch(i)\r
+                       {\r
+                               case 11:\r
+                                       i=0;\r
+                                       player[0].ent->spri->x = TILEWH;\r
+                               default:\r
+                                       i++;\r
+                                       player[0].ent->spri->delay = 0; animate_spri((player[0].ent->spri), &gvar.video);// player[0].ent->spri->x += 16;\r
+                               break;\r
+                       }\r
+               }\r
+               FUNCTIONKEYFUNCTIONS;\r
+\r
+               //9\r
+#ifdef FADE\r
+               if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(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)) break; //incase things go out of sync!\r
+               player[0].enti.hp = 0;\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
+       VGAmodeX(0, 1, &gvar);\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