X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Fzcroll.c;h=1d940e212d4ac6b97f0b61d848d6ac0e749ea65e;hb=d40ef7f62ff3e5bd49ffec3b06c881cfa8d02bdb;hp=10f87f6683df713bc9ea5052df767d8dfa53c356;hpb=2e3fb239b58cf341ceb5b4e7b39b6542f5581cae;p=16.git diff --git a/src/zcroll.c b/src/zcroll.c index 10f87f66..1d940e21 100755 --- a/src/zcroll.c +++ b/src/zcroll.c @@ -1,291 +1 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover - * - * This file is part of Project 16. - * - * Project 16 is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Project 16 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see , or - * write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include "src/lib/zcroll16.h" -#include "src/lib/16_timer.h" -#include "src/lib/wcpu/wcpu.h" -#include "src/lib/16render.h" -#include "src/lib/16_dbg.h" - -#define MODEXZ -boolean dbg_noplayerinpu=1; - -//TODO: known issues the array dependent mv stuff and player arrays -global_game_variables_t gvar; -static map_t map; -player_t *player; -map_view_t *mv; -float t; -sword bakapee; -pan_t pan; -//debugswitches -boolean panswitch=0,baka=0; -//extern boolean pageflipflop=1; -unsigned int i; -const char *cpus; -//static int persist_aniframe = 0; /* gonna be increased to 1 before being used, so 0 is ok for default */ - -//map_view_db_t pgid[4]; -word pg; -#ifdef FADE -static word paloffset=0; -byte *dpal; -#endif -byte *gpal; -byte *ptr; -memptr pal; - -void main(int argc, char *argv[]) -{ - if(argv[1]) bakapee = atoi(argv[1]); - else bakapee = 1; - - Startup16(&gvar); - - pan.pn=0; - // OK, this one takes hellova time and needs to be done in farmalloc or MM_... - //TODO: USE MM AND CA AND PM WWWWWWWW - player = malloc(sizeof(player_t)); - player->ent = malloc(sizeof(entity_t)); - player->ent->spri = malloc(sizeof(struct sprite)); - player->ent->spri->spritesheet = malloc(sizeof(struct vrs_container)); - - // create the map - fprintf(stderr, "testing map load~ "); - loadmap("data/test.map", &map); - chkmap(&map, 0); - printf("chkmap ok "); - fprintf(stderr, "yay map loaded~~\n"); - - // data - printf("loading sprite\n"); - read_vrs(&gvar, "data/spri/chikyuu.vrs", player->ent->spri->spritesheet); printf("sprite loaded\n"); - - // input! -if(!dbg_noplayerinpu) -{ - IN_Default(0, player,ctrl_Joystick); printf("IN_defaulted\n"); -} - - // save the palette -#ifdef FADE - dpal = modexNewPal(); - modexPalSave(dpal); - modexFadeOff(4, dpal); -#endif - textInit(); - VGAmodeX(bakapee, 1, &gvar); -#ifdef MODEXZ -#ifdef FADE - modexPalBlack(); //reset the palette~ - printf("VGA\n"); - CA_LoadFile("data/spri/chikyuu.pal", &pal, &gvar); - modexPalUpdate1(pal); - printf("pallette\n"); - gpal = modexNewPal(); - modexPalSave(gpal); - modexSavePalFile("data/g.pal", gpal); - modexPalBlack(); //so player will not see loadings~ -#endif - - // setup camera and screen~ -if(dbg_noplayerinpu) -{ - //sprintf(&gvar.pee, "press a key for video setup"); - strcpy(global_temp_status_text, "press a key for video setup"); - modexprint(mv->page, 0, 64, 1, 7, 0, global_temp_status_text); - getch(); -} - modexHiganbanaPageSetup(&gvar.video); - mv->page = &gvar.video.page[0]; - mv->map = ↦ - mv->video = &gvar.video; - mv->pan = &pan; - player->ent->spri->x = player->ent->spri->y = 20; - - // set up paging - //TODO: LOAD map data and position the map in the middle of the screen if smaller then screen - mapGoTo(mv, 0, 0); -#endif - - //TODO: put player in starting position of spot - //default player position on the viewable map - player->tx = mv->tx + mv->page->tilemidposscreenx; - player->ty = mv->ty + mv->page->tilemidposscreeny; - IN_initplayer(player); printf("player inited\n"); - - i = set_anim_by_id(player->ent->spri, 11); - print_anim_ids(player->ent->spri); - if (i == -1) - { -#ifdef FADE - modexFadeOff(4, gpal); -#endif - VGAmodeX(0, 1, &gvar); - Shutdown16(&gvar); - printf("Wrong"); -#ifdef FADE - modexFadeOn(4, dpal); -#endif - exit(-4); - } - //animate_spri(&(player->ent->spri)); - printf("spri ok\n"); - - modexShowPage(mv->page);//!(gvar.video.p) - shinku_fps_indicator_page = 0; // we're on page 1 now, shinku(). follow along please or it will not be visible. -#ifdef FADE - modexFadeOn(4, gpal); -#endif - printf("LOOP\n"); - if(!dbg_noplayerinpu) - while(!IN_KeyDown(sc_Escape) && player->hp>0) - { - shinku(&gvar); - //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square - //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction - //when player->tx or player->ty == 0 or player->tx == 20 or player->ty == 15 then stop because that is edge of map and you do not want to walk of the map - - //player movement - IN_ReadControl(player); - if(!panswitch){ - walk(player->ent, mv); - } - - //the scripting stuff.... -/* if(((mv->map->data[(player->triggerx-1)+(map.width*(player->triggery-1))] == 0) && IN_KeyDown(0x1C))||(player->tx == 5 && player->ty == 5)) - { - short i; - for(i=800; i>=400; i--) - { - sound(i); - } - nosound(); - } - if(player->q == (TILEWH/(player->speed))+1 && player->info.dir != 2 && (player->triggerx == 5 && player->triggery == 5)){ player->hp--; } -*/ //debugging binds! - if(IN_KeyDown(2)){ modexShowPage(mv->page); pan.pn=0; } - if(IN_KeyDown(25)){ modexpdump(mv->page); - IN_UserInput(1,1); - } //p -#ifdef FADE - if(IN_KeyDown(24)){ modexPalUpdate0(gpal); paloffset=0; modexpdump(mv->page); IN_UserInput(1,1); } - if(IN_KeyDown(22)){ - printf("2paloffset = %d\n", paloffset/3); - IN_UserInput(1,1); - } -#endif - - //pan switch - if(IN_KeyDown(88)){panswitch=!panswitch; IN_UserInput(1,1);} //f12 - if(IN_KeyDown(87)) //f11 - { - pageflipflop=!pageflipflop; - IN_UserInput(1,1); - } - if(IN_KeyDown(68)) //f10 - { - gvar.kurokku.fpscap=!gvar.kurokku.fpscap; - IN_UserInput(1,1); - } - if(IN_KeyDown(67)) //f9 - { - modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 2); - } - if(IN_KeyDown(66)) //f8 - { - // modexDrawSprite(mv->page, 16, 16, p); - modexDrawSprite(mv->page, 32+48, 16, (player->data)); - } - //TODO fmemtest into page - /*if(IN_KeyDown(4+1)) //4 - { - pg=1; - SELECT_ALL_PLANES(); - _fmemset(((mv[pg].page->data+4)+(16*(mv[pg].page->width/4))), 15, 4); - }*/ - - //9 -#ifdef FADE - if(IN_KeyDown(10)){ modexPalOverscan(rand()%56); modexPalUpdate1(dpal); IN_UserInput(1,1); } - //if(IN_KeyDown(11)){ modexPalOverscan(15); } -#endif - if((player->q==1) && !(player->x%TILEWH==0 && player->y%TILEWH==0)) break; //incase things go out of sync! - player->hp = 0; - } - - else - while(!kbhit()) - { - shinku(&gvar); - } - - /* fade back to text mode */ - /* but 1st lets save the game palette~ */ -#ifdef FADE - modexPalSave(gpal); - modexSavePalFile("data/g.pal", gpal); - modexFadeOff(4, gpal); -#endif - VGAmodeX(0, 1, &gvar); - Shutdown16(&gvar); - printf("\nProject 16 zcroll.exe. This is just a test file!\n"); - printf("version %s\n", VERSION); - printf("tx: %d ", mv->tx); - printf("ty: %d\n", mv->ty); - printf("\n"); - printf("player vars:\n"); - printf(" x: %d", player->x); printf(" y: %d\n", player->y); - //if(player->hp==0) printf("%d wwww\n", player->y+8); - //else printf("\nplayer->y: %d\n", player->y); - printf(" tx: %d", player->tx); printf(" ty: %d\n", player->ty); - printf(" triggx: %d", player->triggerx); printf(" triggy: %d\n", player->triggery); - printf(" hp: %d", (player->hp)); printf(" q: %d", player->q); printf(" player.info.dir: %d", player->info.dir); printf(" player.d: %d ", player->d); - printf(" pdir=%d\n", player->pdir); - printf(" tile data value at player trigger position: %d\n\n", mv->map->data[(player->triggerx-1)+(map.width*(player->triggery-1))]); - printf("Virtual Screen: %dx", gvar.video.page[0].width); printf("%d ", gvar.video.page[0].height); - printf("Screen: %dx", gvar.video.page[0].sw); printf("%d\n", gvar.video.page[0].sh); - printf("virtual tile resolution: %dx", gvar.video.page[0].tilesw); printf("%d ", gvar.video.page[0].tilesh); - printf("tile resolution: %dx", gvar.video.page[0].tw); printf("%d\n", gvar.video.page[0].th); - printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx); printf("%d\n", gvar.video.page[0].tilemidposscreeny); - modexprintmeminfo(&gvar.video); - //printf("mv[%u].tx: %d", pan.pn, mv[pan.pn].tx); printf(" mv[%u].ty: %d ", pan.pn, mv[pan.pn].ty); - printf("gvar.video.p=%u ", gvar.video.p); printf("gvar.video.r=%u ", gvar.video.r); - printf("pageflipflop=%u\n", pageflipflop); - //0000printf("\ngvar.video.tickclk=%f\n", gvar.video.tickclk); - //0000printf("gvar.video.clk=%f", gvar.video.clk); - printf("\n"); - //printf("map.width=%d map.height=%d map.data[0]=%d\n", mv->map->width, mv->map->height, mv->map->data[0]); - - printf("\n"); - switch(detectcpu()) - { - case 0: cpus = "8086/8088 or 186/88"; break; - case 1: cpus = "286"; break; - case 2: cpus = "386 or newer"; break; - default: cpus = "internal error"; break; - } - printf("detected CPU type: %s\n", cpus); -#ifdef FADE - modexFadeOn(4, dpal); -#endif -} +[zcroll is now the pre menu game loop system with PROPER data usage with CAMMPM]