From 12c63404238dfe6077110f211921a7e6b5031515 Mon Sep 17 00:00:00 2001 From: sparky4 Date: Fri, 29 Apr 2016 15:58:56 -0500 Subject: [PATCH] panning needs to be finished i am about to CRASH wwwwwwwwwwwwwwwwwww --- SCROLL.16L | 35 ++++++++++ src/lib/16_in.c | 2 + src/lib/modex16.c | 4 +- src/lib/scroll16.c | 67 +++++++++++++++++++ src/lib/scroll16.h | 4 +- src/lib/typdefst.h | 7 +- src/scroll.c | 157 ++++++++------------------------------------- 7 files changed, 141 insertions(+), 135 deletions(-) diff --git a/SCROLL.16L b/SCROLL.16L index e69de29b..671f9c4b 100755 --- a/SCROLL.16L +++ b/SCROLL.16L @@ -0,0 +1,35 @@ +starting timer ok +index=4096 +chkmap ok + + 1st vmem_remain=262144 + [0], video->page[i].pagesize=95744 + [0], vmem_remain=166400 + [1], video->page[i].pagesize=95744 + [1], vmem_remain=70656 + [2], video->page[i].pagesize=70400 + [2], vmem_remain=256 + [3], video->page[i].pagesize=256 + [3], vmem_remain=0 +Project 16 scroll.exe. This is just a test file! +version Apr 29 2016 15:57:39 +tx: -1 +ty: 14 +player[0].x: 160 player[0].y: 128 +player[0].tx: 10 player[0].ty: 8 +player[0].triggx: 10 player[0].triggy: 9 +player[0].hp: 4 player[0].q: 1 player[0].info.dir: 0 player[0].d: 2 pdir=0 +tile data value at player trigger position: 0 +Virtual Screen: 352x272 +Screen: 320x240 +tile resolution: 15x15 middle tile position: 10x8 +video memory remaining: 0 +page [0]=(a000:0000) + [1]=(a000:5d80) + [2]=(a000:bb00) + [3]=(a000:ffc0) +mv[0].tx: -1 mv[0].ty: 14 +player[1].q: 1 player[1].d: 2 + + +detected CPU type: 386 or newer diff --git a/src/lib/16_in.c b/src/lib/16_in.c index 5bccecaf..f4a66213 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -1297,4 +1297,6 @@ void IN_initplayer(player_t *player, word pn) player[pn].q=1; player[pn].d=2; player[pn].hp=4; + player[pn].speed=4; + player[pn].persist_aniframe=0; } diff --git a/src/lib/modex16.c b/src/lib/modex16.c index 8b7bf8c4..c6bb04fd 100755 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -193,7 +193,7 @@ page_t modexNextPage(page_t *p) { page_t result; - result.data = p->data + (p->width/4)*p->height; + result.data = p->data + (byte)(p->width/4)*p->height; result.dx = 0; result.dy = 0; result.width = p->width; @@ -212,7 +212,7 @@ modexNextPageFlexibleSize(page_t *p, word x, word y) { page_t result; - result.data = p->data + (p->width/4)*p->height; /* compute the offset */ + result.data = p->data + (byte)(p->width/4)*p->height; /* compute the offset */ result.dx = 0; result.dy = 0; result.width = x; diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index 509f9743..a56de644 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -204,6 +204,73 @@ void walk(map_view_t *pip, player_t *player, word pn) } } +void panpagemanual(map_view_t *pip, player_t *player, word pn) +{ + #define INC_PER_FRAME if(player[pn].q&1) player[pn].persist_aniframe++; if(player[pn].persist_aniframe>4) player[pn].persist_aniframe = 1; + switch(player[pn].d) + { + //right movement + case 3: + if(pip[pip[0].pan->pagenum].tx >= -1 && pip[pip[0].pan->pagenum].tx+pip[pip[0].pan->pagenum].page->tilesw < pip[pip[0].pan->pagenum].map->width+1) + //!(pip[0].map->data[(pip[0].pan->tx)+(pip[0].map->width*(pip[0].pan->ty-1))] == 0)) + { + if(player[pn].q<=(TILEWH/(player[pn].speed))) + { + INC_PER_FRAME; + pip[pip[0].pan->pagenum].page->dx++; + modexShowPage(pip[pip[0].pan->pagenum].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pagenum].tx++; } + } + break; + + //left movement + case 1: + if(pip[pip[0].pan->pagenum].tx > -1 && pip[pip[0].pan->pagenum].tx+pip[pip[0].pan->pagenum].page->tilesw <= pip[pip[0].pan->pagenum].map->width+1) + //!(pip[0].map->data[(pip[0].pan->tx-2)+(pip[0].map->width*(pip[0].pan->ty-1))] == 0)) + { + if(player[pn].q<=(TILEWH/(player[pn].speed))) + { + INC_PER_FRAME; + pip[pip[0].pan->pagenum].page->dx--; + modexShowPage(pip[pip[0].pan->pagenum].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pagenum].tx--; } + } + break; + + //down movement + case 4: + if(pip[pip[0].pan->pagenum].ty >= -1 && pip[pip[0].pan->pagenum].ty+pip[pip[0].pan->pagenum].page->tilesh < pip[pip[0].pan->pagenum].map->height+1) + //!(pip[0].map->data[(pip[0].pan->tx-1)+(pip[0].map->width*(pip[0].pan->ty))] == 0)) + { + if(player[pn].q<=(TILEWH/(player[pn].speed))) + { + INC_PER_FRAME; + pip[pip[0].pan->pagenum].page->dy++; + modexShowPage(pip[pip[0].pan->pagenum].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pagenum].ty++; } + } + break; + + //up movement + case 0: + if(pip[pip[0].pan->pagenum].ty > -1 && pip[pip[0].pan->pagenum].ty+pip[pip[0].pan->pagenum].page->tilesh <= pip[pip[0].pan->pagenum].map->height+1) + //!(pip[0].map->data[(pip[0].pan->tx-1)+(pip[0].map->width*(pip[0].pan->ty-2))] == 0)) + { + if(player[pn].q<=(TILEWH/(player[pn].speed))) + { + INC_PER_FRAME; + pip[pip[0].pan->pagenum].page->dy--; + modexShowPage(pip[pip[0].pan->pagenum].page); + player[pn].q++; + } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pagenum].ty--; } + } + break; + } +} + /*map_t allocMap(int w, int h) { map_t result; diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index 67e09455..669237b4 100755 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -52,7 +52,8 @@ typedef struct { int ty; //appears to be the top left tile position on the viewable screen map word dxThresh; //???? word dyThresh; //???? - video_t *video; + video_t *video; //pointer to game variables of the video + pan_t *pan; //pointer the the page panning debug system } map_view_t; typedef struct @@ -69,6 +70,7 @@ extern boolean pageflipflop; //map_t allocMap(int w, int h); //void initMap(map_t *map); void walk(map_view_t *pip, player_t *player, word pn); +void panpagemanual(map_view_t *pip, player_t *player, word pn); void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid); void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid); void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid); diff --git a/src/lib/typdefst.h b/src/lib/typdefst.h index 8eff787f..bd6dfd6f 100755 --- a/src/lib/typdefst.h +++ b/src/lib/typdefst.h @@ -36,6 +36,8 @@ #define AAMAGENTA "\x1b[45;35m" #define AARESET "\x1b[0m" +#define MAXPAGE 4 + /* * typedefs of the game variables! */ @@ -100,7 +102,10 @@ typedef struct boolean fpscap; //cap the fps var } kurokku_t; -#define MAXPAGE 4 +typedef struct +{ + word pagenum; +} pan_t; typedef struct { diff --git a/src/scroll.c b/src/scroll.c index 30433ef7..982f4b51 100755 --- a/src/scroll.c +++ b/src/scroll.c @@ -39,9 +39,8 @@ word pn=0; static planar_buf_t huge *pp; float t; sword bakapee; - -// word panswitch=0, panq=1, pand=0; - word panpagenum=0; //for panning! +pan_t pan; +boolean panswitch=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 */ @@ -84,8 +83,7 @@ void main(int argc, char *argv[]) return; } - player[0].persist_aniframe=0; - player[0].speed=4; + pan.pagenum=0; //player[0].data = &pp; printf("starting timer "); @@ -120,6 +118,7 @@ void main(int argc, char *argv[]) /* input! */ IN_Startup(); IN_Default(0,&player,ctrl_Joystick); + IN_Default(1,&player,ctrl_Joystick); /* save the palette */ #ifdef MODEX @@ -166,6 +165,7 @@ void main(int argc, char *argv[]) mv[i].page = &gvar.video.page[i]; mv[i].map = ↦ mv[i].video = &gvar.video; + mv[i].pan = &pan; } /* set up paging */ @@ -177,6 +177,7 @@ void main(int argc, char *argv[]) player[0].tx = mv[0].tx + mv[0].page->tilemidposscreenx; player[0].ty = mv[0].ty + mv[0].page->tilemidposscreeny; IN_initplayer(&player, 0); + IN_initplayer(&player, 1); modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height); #ifndef SPRITE @@ -197,129 +198,22 @@ void main(int argc, char *argv[]) while(!IN_KeyDown(sc_Escape) && player[0].hp>0) { shinku(&gvar); - IN_ReadControl(0,&player); //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[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 //player movement - //if(!panswitch){ + if(!panswitch){ + IN_ReadControl(0,&player); walk(mv, player, 0); - /*}else{ -//88 switch! - //right movement - if((IN_KeyDown(77) && !IN_KeyDown(75) && pand == 0) || pand == 2) - { - if(pand == 0){ pand = 2; } - if(panq<=(TILEWH/(player[0].speed))) - { - switch(panpagenum) - { - case 0: - //bg - mv[0].page->dx++; - modexShowPage(mv[0].page); - break; - case 1: - //spri - mv[1].page->dx++; - modexShowPage(mv[1].page); - break; - case 2: - //fg - mv[2].page->dx++; - modexShowPage(mv[2].page); - break; - } - panq++; - } else { panq = 1; pand = 0; } - } - //left movement - if((IN_KeyDown(75) && !IN_KeyDown(77) && pand == 0) || pand == 4) - { - if(pand == 0){ pand = 4; } - if(panq<=(TILEWH/(player[0].speed))) - { - switch(panpagenum) - { - case 0: - //bg - mv[0].page->dx--; - modexShowPage(mv[0].page); - break; - case 1: - //spri - mv[1].page->dx--; - modexShowPage(mv[1].page); - break; - case 2: - //fg - mv[2].page->dx--; - modexShowPage(mv[2].page); - break; - } - panq++; - } else { panq = 1; pand = 0; } + }else{ + IN_ReadControl(1,&player); + panpagemanual(mv, player, 1); + //printf(" player[1].q: %d", player[1].q); printf(" player[1].d: %d\n", player[1].d); } - //down movement - if((IN_KeyDown(72) && !IN_KeyDown(80) && pand == 0) || pand == 3) - { - if(pand == 0){ pand = 3; } - if(panq<=(TILEWH/(player[0].speed))) - { - switch(panpagenum) - { - case 0: - //bg - mv[0].page->dy--; - modexShowPage(mv[0].page); - break; - case 1: - //spri - mv[1].page->dy--; - modexShowPage(mv[1].page); - break; - case 2: - //fg - mv[2].page->dy--; - modexShowPage(mv[2].page); - break; - } - panq++; - } else { panq = 1; pand = 0; } - } - //up movement - if((IN_KeyDown(80) && !IN_KeyDown(72) && pand == 0) || pand == 1) - { - if(pand == 0){ pand = 1; } - if(panq<=(TILEWH/(player[0].speed))) - { - switch(panpagenum) - { - case 0: - //bg - mv[0].page->dy++; - modexShowPage(mv[0].page); - break; - case 1: - //spri - mv[1].page->dy++; - modexShowPage(mv[1].page); - break; - case 2: - //fg - mv[2].page->dy++; - modexShowPage(mv[2].page); - break; - } - panq++; - } else { panq = 1; pand = 0; } - } -}*/ - - //the scripting stuf.... + //the scripting stuff.... //if(((player[0].triggerx == TRIGGX && player[0].triggery == TRIGGY) && IN_KeyDown(0x1C))||(player[0].tx == 5 && player[0].ty == 5)) 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)) { @@ -333,9 +227,10 @@ void main(int argc, char *argv[]) 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--; } //debugging binds! //if(IN_KeyDown(0x0E)) while(1){ if(xmsmalloc(24)) break; } - if(IN_KeyDown(2)){ modexShowPage(mv[0].page); panpagenum=0; } - if(IN_KeyDown(3)){ modexShowPage(mv[1].page); panpagenum=1; } - if(IN_KeyDown(4)){ modexShowPage(mv[2].page); panpagenum=2; } + if(IN_KeyDown(2)){ modexShowPage(mv[0].page); pan.pagenum=0; } + if(IN_KeyDown(3)){ modexShowPage(mv[1].page); pan.pagenum=1; } + //if(IN_KeyDown(4)){ modexShowPage(mv[2].page); pan.pagenum=2; } + //if(IN_KeyDown(4+1)){ modexShowPage(mv[3].page); pan.pagenum=3; } if(IN_KeyDown(25)){ modexpdump(mv[0].page); modexpdump(mv[1].page); //IN_Ack(); } //p @@ -351,7 +246,7 @@ void main(int argc, char *argv[]) #endif #endif //pan switch - //if(IN_KeyDown(88)){if(!panswitch) panswitch++; else panswitch--; } //f12 + if(IN_KeyDown(88)){panswitch=!panswitch;} //f12 //TSR if(IN_KeyDown(87)) //f11 { @@ -365,18 +260,18 @@ void main(int argc, char *argv[]) // int 21h // } } - if(IN_KeyDown(88)) //s + if(IN_KeyDown(68)) //s { gvar.kurokku.fpscap=!gvar.kurokku.fpscap; //IN_Ack(); } //TODO fmemtest into page - if(IN_KeyDown(4+1)) //4 + /*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 if(IN_KeyDown(10)){ modexPalOverscan(default_pal, rand()%56); modexPalUpdate1(default_pal); } @@ -404,7 +299,7 @@ void main(int argc, char *argv[]) //else printf("\nplayer[0].y: %d\n", player[0].y); printf("player[0].tx: %d", player[0].tx); printf(" player[0].ty: %d\n", player[0].ty); printf("player[0].triggx: %d", player[0].triggerx); printf(" player[0].triggy: %d\n", player[0].triggery); - printf("player[0].hp: %d", (player[0].hp)); printf(" player[0].q: %d", player[0].q); printf(" player[0].info.dir: %d", player[0].info.dir); printf(" player[0].d: %d\n", player[0].d); + printf("player[0].hp: %d", (player[0].hp)); printf(" player[0].q: %d", player[0].q); printf(" player[0].info.dir: %d", player[0].info.dir); printf(" player[0].d: %d ", player[0].d); printf("pdir=%d\n", player[0].pdir); printf("tile data value at player trigger position: %d\n", mv[0].map->data[(player[0].triggerx-1)+(map.width*(player[0].triggery-1))]); // printf("palette offset: %d\n", paloffset/3); @@ -417,14 +312,14 @@ void main(int argc, char *argv[]) printf("tile resolution: %dx", gvar.video.page[0].tilesh); printf("%d ", gvar.video.page[0].tilesh); printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx); printf("%d\n", gvar.video.page[0].tilemidposscreeny); printf("video memory remaining: %ld\n", gvar.video.vmem_remain); - printf("\npage "); + printf("page "); for(i=0; i