-/* 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/wcpu/wcpu.h"\r
-#include "src/lib/16render.h"\r
-#include "src/lib/16_dbg.h"\r
-\r
-#define MODEXZ\r
-boolean dbg_noplayerinpu=0;\r
-\r
-//TODO: known issues the array dependent mv stuff and player arrays\r
-global_game_variables_t gvar;\r
-static map_t map;\r
-player_t player[MaxPlayers];\r
-map_view_t mv[4];\r
-float t;\r
-sword bakapee;\r
-pan_t pan;\r
-//debugswitches\r
-boolean panswitch=0,baka=0;\r
-//extern boolean pageflipflop=1;\r
-unsigned int i;\r
-const char *cpus;\r
-//static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */\r
-\r
-//map_view_db_t pgid[4];\r
-word pg;\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
- if(argv[1]) bakapee = atoi(argv[1]);\r
- else bakapee = 1;\r
-\r
- Startup16(&gvar);\r
-\r
- pan.pn=0;\r
- // OK, this one takes hellova time and needs to be done in farmalloc or MM_...\r
- //TODO: USE MM AND CA AND PM WWWWWWWW\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
-\r
- // input!\r
-if(!dbg_noplayerinpu)\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
- textInit();\r
- VGAmodeX(bakapee, 1, &gvar);\r
-#ifdef MODEXZ\r
-#ifdef FADE\r
- modexPalBlack(); //reset the palette~\r
- CA_LoadFile("data/spri/chikyuu.pal", &pal, &gvar);\r
- modexPalUpdate1(pal);\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
- strcpy(global_temp_status_text, "press a key for video setup");\r
- modexprint(mv[0].page, 0, 64, 1, 7, 0, global_temp_status_text);\r
-\r
- modexHiganbanaPageSetup(&gvar.video);\r
- mv[0].page = &gvar.video.page[0];\r
- mv[0].map = ↦\r
- mv[0].video = &gvar.video;\r
- mv[0].pan = &pan;\r
- player[0].ent->spri->x = player[0].ent->spri->y = 20;\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
-#endif\r
-\r
- //TODO: put player in starting position of spot\r
- //default player position on the viewable map\r
- player[0].tx = mv[0].tx + mv[0].page->tilemidposscreenx;\r
- player[0].ty = mv[0].ty + mv[0].page->tilemidposscreeny;\r
- IN_initplayer(&player, 0);\r
-\r
- i = set_anim_by_id(player[0].ent->spri, 11);\r
- print_anim_ids(player[0].ent->spri);\r
- if (i == -1)\r
- {\r
-#ifdef FADE\r
- modexFadeOff(4, gpal);\r
-#endif\r
- VGAmodeX(0, 1, &gvar);\r
- Shutdown16(&gvar);\r
- printf("Wrong");\r
-#ifdef FADE\r
- modexFadeOn(4, dpal);\r
-#endif\r
- exit(-4);\r
- }\r
- //animate_spri(&(player[0].ent->spri));\r
-\r
- modexShowPage(mv[0].page);//!(gvar.video.p)\r
- shinku_fps_indicator_page = 0; // we're on page 1 now, shinku(). follow along please or it will not be visible.\r
-#ifdef FADE\r
- modexFadeOn(4, gpal);\r
-#endif\r
- if(!dbg_noplayerinpu)\r
- while(!IN_KeyDown(sc_Escape))// && player[0].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_walk(player[0].ent, mv);\r
- //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].q == (TILEWH/(player[0].speed))+1 && player[0].info.dir != 2 && (player[0].triggerx == 5 && player[0].triggery == 5)){ player[0].hp--; }\r
-*/ //debugging binds!\r
- if(IN_KeyDown(2)){ modexShowPage(mv[0].page); pan.pn=0; }\r
- if(IN_KeyDown(25)){ modexpdump(mv[0].page);\r
- IN_UserInput(1,1);\r
- } //p\r
-#ifdef FADE\r
- if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; modexpdump(mv[0].page); IN_UserInput(1,1); }\r
- if(IN_KeyDown(22)){\r
- printf("2paloffset = %d\n", paloffset/3);\r
- IN_UserInput(1,1);\r
- }\r
-#endif\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+48, 16, (player[0].data));\r
- }\r
- //TODO fmemtest into page\r
- /*if(IN_KeyDown(4+1)) //4\r
- {\r
- pg=1;\r
- SELECT_ALL_PLANES();\r
- _fmemset(((mv[pg].page->data+4)+(16*(mv[pg].page->width/4))), 15, 4);\r
- }*/\r
-\r
- //9\r
-#ifdef FADE\r
- if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(dpal); IN_UserInput(1,1); }\r
- //if(IN_KeyDown(11)){ modexPalOverscan(15); }\r
-#endif\r
- if((player[0].q==1) && !(player[0].x%TILEWH==0 && player[0].y%TILEWH==0)) break; //incase things go out of sync!\r
- player[0].hp = 0;\r
- }\r
-\r
- else\r
- while(!kbhit())\r
- {\r
- shinku(&gvar);\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
- printf("tx: %d ", mv[0].tx);\r
- printf("ty: %d\n", mv[0].ty);\r
- printf("\n");\r
- printf("player vars:\n");\r
- printf(" x: %d", player[0].x); printf(" y: %d\n", player[0].y);\r
- //if(player[0].hp==0) printf("%d wwww\n", player[0].y+8);\r
- //else printf("\nplayer[0].y: %d\n", player[0].y);\r
- printf(" tx: %d", player[0].tx); printf(" ty: %d\n", player[0].ty);\r
- printf(" triggx: %d", player[0].triggerx); printf(" triggy: %d\n", player[0].triggery);\r
- printf(" hp: %d", (player[0].hp)); printf(" q: %d", player[0].q); printf(" player.info.dir: %d", player[0].info.dir); printf(" player.d: %d ", player[0].d);\r
- printf(" pdir=%d\n", player[0].pdir);\r
- printf(" tile data value at player trigger position: %d\n\n", mv[0].map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))]);\r
- printf("Virtual Screen: %dx", gvar.video.page[0].width); printf("%d ", gvar.video.page[0].height);\r
- printf("Screen: %dx", gvar.video.page[0].sw); printf("%d\n", gvar.video.page[0].sh);\r
- printf("virtual tile resolution: %dx", gvar.video.page[0].tilesw); printf("%d ", gvar.video.page[0].tilesh);\r
- printf("tile resolution: %dx", gvar.video.page[0].tw); printf("%d\n", gvar.video.page[0].th);\r
- printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx); printf("%d\n", gvar.video.page[0].tilemidposscreeny);\r
- modexprintmeminfo(&gvar.video);\r
- //printf("mv[%u].tx: %d", pan.pn, mv[pan.pn].tx); printf(" mv[%u].ty: %d ", pan.pn, mv[pan.pn].ty);\r
- printf("gvar.video.p=%u ", gvar.video.p); printf("gvar.video.r=%u ", gvar.video.r);\r
- printf("pageflipflop=%u\n", pageflipflop);\r
- printf("\n");\r
- //printf("map.width=%d map.height=%d map.data[0]=%d\n", mv[0].map->width, mv[0].map->height, mv[0].map->data[0]);\r
-\r
- printf("\n");\r
- switch(detectcpu())\r
- {\r
- case 0: cpus = "8086/8088 or 186/88"; break;\r
- case 1: cpus = "286"; break;\r
- case 2: cpus = "386 or newer"; break;\r
- default: cpus = "internal error"; break;\r
- }\r
- printf("detected CPU type: %s\n", cpus);\r
-#ifdef FADE\r
- modexFadeOn(4, dpal);\r
-#endif\r
-}\r
+[zcroll is now the pre menu game loop system with PROPER data usage with CAMMPM]