X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fscroll16.c;h=d4a34e5ccc4879134b3a9242d10d54700c96efff;hb=06a59aa7546448c4e6f6e816f2e01219d4f3c041;hp=f1ec4cfeebbc32e0b9cdf7f28e7f520bf760ba41;hpb=a6dac9aacc0353763dc564afda8b57848afc3e0b;p=16.git diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index f1ec4cfe..d4a34e5c 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -24,11 +24,13 @@ */ #include "src/lib/scroll16.h" -void walk(map_view_t *pip, player_t *player, word pn) +#define ANIMATESPRIFUN ZC_animatePlayer + +void oldwalk(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; - //printf("player[%d].d=%d\n", pn, player[pn].d); - switch(player[pn].d) + #define INC_PER_FRAME if(player[pn].enti.q&1) player[pn].enti.persist_aniframe++; if(player[pn].enti.persist_aniframe>4) player[pn].enti.persist_aniframe = 1; + //printf("player[%d].d=%d\n", pn, player[pn].enti.d); + switch(player[pn].enti.d) { //no direction case 2: @@ -37,272 +39,489 @@ void walk(map_view_t *pip, player_t *player, word pn) //right movement case 3: //printf("pip[0].page->tilesw=%d ", pip[0].page->tilesw); printf("pip[0].page->tw=%d\n", pip[0].page->tw); - if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].map->width && player[pn].tx == pip[0].tx+pip[0].page->tilemidposscreenx && - !(pip[0].map->data[(player[pn].tx)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx+1 == TRIGGX && player[pn].ty == TRIGGY)) //collision detection! + if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx && + !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection! { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { INC_PER_FRAME; - animatePlayer(pip, player, pn, 1); + ANIMATESPRIFUN(pip, player, pn, 1); ScrollRight(pip, player, 3, pn); ScrollRight(pip, player, 2, pn); //mapScrollRight(pip, player, !(pip[0].video->p), pn); mapScrollRight(pip, player, (pip[0].video->p), pn); if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; + player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; - } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } } - else if(player[pn].tx < pip[0].map->width && !(pip[0].map->data[(player[pn].tx)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx+1 == TRIGGX && player[pn].ty == TRIGGY)) + else if(player[pn].enti.tx < pip[0].map->width && !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { INC_PER_FRAME; - player[pn].x+=(player[pn].speed); - animatePlayer(pip, player, pn, 0); + player[pn].enti.x+=(player[pn].enti.speed); + ANIMATESPRIFUN(pip, player, pn, 0); if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; - } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx++; } + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } } else { - if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 24, 32); + if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32); #ifdef SPRITE - PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATA); + modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR); #else - modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 24, 32, 14); + modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14); #endif if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].d = 2; + player[pn].enti.d = 2; } - player[pn].triggerx = player[pn].tx+1; - player[pn].triggery = player[pn].ty; + player[pn].enti.triggerx = player[pn].enti.tx+1; + player[pn].enti.triggery = player[pn].enti.ty; break; //left movement case 1: - if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].map->width && player[pn].tx == pip[0].tx+pip[0].page->tilemidposscreenx && - !(pip[0].map->data[(player[pn].tx-2)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx-1 == TRIGGX && player[pn].ty == TRIGGY)) //collision detection! + if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx && + !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection! { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { INC_PER_FRAME; - animatePlayer(pip, player, pn, 1); + ANIMATESPRIFUN(pip, player, pn, 1); ScrollLeft(pip, player, 3, pn); ScrollLeft(pip, player, 2, pn); //mapScrollLeft(pip, player, !(pip[0].video->p), pn); mapScrollLeft(pip, player, (pip[0].video->p), pn); if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; + player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; - } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } } - else if(player[pn].tx > 1 && !(pip[0].map->data[(player[pn].tx-2)+(pip[0].map->width*(player[pn].ty-1))] == 0))//!(player[pn].tx-1 == TRIGGX && player[pn].ty == TRIGGY)) + else if(player[pn].enti.tx > 1 && !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { INC_PER_FRAME; - player[pn].x-=(player[pn].speed); - animatePlayer(pip, player, pn, 0); + player[pn].enti.x-=(player[pn].enti.speed); + ANIMATESPRIFUN(pip, player, pn, 0); if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; - } else { player[pn].q = 1; player[pn].d = 2; player[pn].tx--; } + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } } else { - if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 24, 32); + if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32); #ifdef SPRITE - PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATA); + modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR); #else - modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 24, 32, 10); + modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10); #endif if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].d = 2; + player[pn].enti.d = 2; } - player[pn].triggerx = player[pn].tx-1; - player[pn].triggery = player[pn].ty; + player[pn].enti.triggerx = player[pn].enti.tx-1; + player[pn].enti.triggery = player[pn].enti.ty; break; //down movement case 4: - if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].map->height && player[pn].ty == pip[0].ty+pip[0].page->tilemidposscreeny && - !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty+1 == TRIGGY)) //collision detection! + if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny && + !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection! { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { INC_PER_FRAME; - animatePlayer(pip, player, pn, 1); + ANIMATESPRIFUN(pip, player, pn, 1); ScrollDown(pip, player, 3, pn); ScrollDown(pip, player, 2, pn); //mapScrollDown(pip, player, !(pip[0].video->p), pn); mapScrollDown(pip, player, (pip[0].video->p), pn); if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; + player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; - } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } } - else if(player[pn].ty < pip[0].map->height && !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty+1 == TRIGGY)) + else if(player[pn].enti.ty < pip[0].map->height && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { INC_PER_FRAME; - player[pn].y+=(player[pn].speed); - animatePlayer(pip, player, pn, 0); + player[pn].enti.y+=(player[pn].enti.speed); + ANIMATESPRIFUN(pip, player, pn, 0); if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; - } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty++; } + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } } else { - if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 24, 32); + if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32); #ifdef SPRITE - PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATA); + modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR); #else - modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 24, 32, 9); + modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9); #endif if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].d = 2; + player[pn].enti.d = 2; } - player[pn].triggerx = player[pn].tx; - player[pn].triggery = player[pn].ty+1; + player[pn].enti.triggerx = player[pn].enti.tx; + player[pn].enti.triggery = player[pn].enti.ty+1; break; //up movement case 0: - if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].map->height && player[pn].ty == pip[0].ty+pip[0].page->tilemidposscreeny && - !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty-2))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty-1 == TRIGGY)) //collision detection! + if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny && + !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection! { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { INC_PER_FRAME; - animatePlayer(pip, player, pn, 1); + ANIMATESPRIFUN(pip, player, pn, 1); ScrollUp(pip, player, 3, pn); ScrollUp(pip, player, 2, pn); //mapScrollUp(pip, player, !(pip[0].video->p), pn); mapScrollUp(pip, player, (pip[0].video->p), pn); if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; + player[pn].enti.q++; //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; - } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; } + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } } - else if(player[pn].ty > 1 && !(pip[0].map->data[(player[pn].tx-1)+(pip[0].map->width*(player[pn].ty-2))] == 0))//!(player[pn].tx == TRIGGX && player[pn].ty-1 == TRIGGY)) + else if(player[pn].enti.ty > 1 && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { INC_PER_FRAME; - player[pn].y-=(player[pn].speed); - animatePlayer(pip, player, 0, pn); + player[pn].enti.y-=(player[pn].enti.speed); + ANIMATESPRIFUN(pip, player, 0, pn); if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].q++; - } else { player[pn].q = 1; player[pn].d = 2; player[pn].ty--; } + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } } else { - if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x, player[pn].y-TILEWH, player[pn].x, player[pn].y-TILEWH, 24, 32); + if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32); #ifdef SPRITE - PBUFSFUN(pip[0].page, player[pn].x, player[pn].y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATA); + modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR); #else - modexClearRegion(pip[1].page, player[pn].x, player[pn].y-TILEWH, 24, 32, 12); + modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12); #endif if(!pageflipflop) modexShowPage(pip[1].page); - player[pn].d = 2; + player[pn].enti.d = 2; + } + player[pn].enti.triggerx = player[pn].enti.tx; + player[pn].enti.triggery = player[pn].enti.ty-1; + break; + } +} + + +/* +src/lib/scroll16.c: mv[0].video->r=1; +src/lib/scroll16.c: mv[0].video->r=1; +src/lib/scroll16.c: mv[0].video->r=1; +src/lib/scroll16.c: mv[0].video->r=1; +src/lib/scroll16.c: pip->video->r=1; +src/lib/scroll16.c: mv->video->r=1; + */ + +void ZC_walk(map_view_t *pip, player_t *player, word pn) +{ + #define INC_PER_FRAME if(player[pn].enti.q&1) player[pn].enti.persist_aniframe++; if(player[pn].enti.persist_aniframe>4) player[pn].enti.persist_aniframe = 1; + switch(player[pn].enti.d) + { + //no direction + case 2: + //0000pip[0].video->startclk = (*clockw); + break; + //right movement + case 3: + if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx && + !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection! + { + if(player[pn].enti.q<=player[pn].enti.spt) + { + INC_PER_FRAME; + ANIMATESPRIFUN(pip, player, pn, 1); + ScrollRight(pip, player, 3, pn); + ScrollRight(pip, player, 2, pn); + mapScrollRight(pip, player, (pip[0].video->p), pn); + player[pn].enti.q++; + //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } + } + else if(player[pn].enti.tx < pip[0].map->width && !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) + { + if(player[pn].enti.q<=player[pn].enti.spt) + { + INC_PER_FRAME; + player[pn].enti.x+=(player[pn].enti.speed); + ANIMATESPRIFUN(pip, player, pn, 0); + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx++; } + } + else + { +#ifdef SPRITE + modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATAPTR); +#else + modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 14); +#endif + player[pn].enti.d = 2; + } + player[pn].enti.triggerx = player[pn].enti.tx+1; + player[pn].enti.triggery = player[pn].enti.ty; + break; + //left movement + case 1: + if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx && + !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection! + { + if(player[pn].enti.q<=player[pn].enti.spt) + { + INC_PER_FRAME; + ANIMATESPRIFUN(pip, player, pn, 1); + ScrollLeft(pip, player, 3, pn); + ScrollLeft(pip, player, 2, pn); + mapScrollLeft(pip, player, (pip[0].video->p), pn); + player[pn].enti.q++; + //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } + } + else if(player[pn].enti.tx > 1 && !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) + { + if(player[pn].enti.q<=player[pn].enti.spt) + { + INC_PER_FRAME; + player[pn].enti.x-=(player[pn].enti.speed); + ANIMATESPRIFUN(pip, player, pn, 0); + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.tx--; } + } + else + { +#ifdef SPRITE + modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATAPTR); +#else + modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 10); +#endif + player[pn].enti.d = 2; + } + player[pn].enti.triggerx = player[pn].enti.tx-1; + player[pn].enti.triggery = player[pn].enti.ty; + break; + //down movement + case 4: + if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny && + !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection! + { + if(player[pn].enti.q<=player[pn].enti.spt) + { + INC_PER_FRAME; + ANIMATESPRIFUN(pip, player, pn, 1); + ScrollDown(pip, player, 3, pn); + ScrollDown(pip, player, 2, pn); + mapScrollDown(pip, player, (pip[0].video->p), pn); + player[pn].enti.q++; + //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } + } + else if(player[pn].enti.ty < pip[0].map->height && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) + { + if(player[pn].enti.q<=player[pn].enti.spt) + { + INC_PER_FRAME; + player[pn].enti.y+=(player[pn].enti.speed); + ANIMATESPRIFUN(pip, player, pn, 0); + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty++; } + } + else + { +#ifdef SPRITE + modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATAPTR); +#else + modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 9); +#endif + player[pn].enti.d = 2; } - player[pn].triggerx = player[pn].tx; - player[pn].triggery = player[pn].ty-1; + player[pn].enti.triggerx = player[pn].enti.tx; + player[pn].enti.triggery = player[pn].enti.ty+1; + break; + //up movement + case 0: + if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny && + !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection! + { + if(player[pn].enti.q<=player[pn].enti.spt) + { + INC_PER_FRAME; + ANIMATESPRIFUN(pip, player, pn, 1); + ScrollUp(pip, player, 3, pn); + ScrollUp(pip, player, 2, pn); + mapScrollUp(pip, player, (pip[0].video->p), pn); + player[pn].enti.q++; + //0000pip[0].video->clk = ((*clockw)-pip[0].video->startclk)/18.2; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } + } + else if(player[pn].enti.ty > 1 && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) + { + if(player[pn].enti.q<=player[pn].enti.spt) + { + INC_PER_FRAME; + player[pn].enti.y-=(player[pn].enti.speed); + ANIMATESPRIFUN(pip, player, 0, pn); + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; player[pn].enti.ty--; } + } + else + { +#ifdef SPRITE + modexDrawSpriteRegion(pip[0].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATAPTR); +#else + modexClearRegion(pip[1].page, player[pn].enti.x, player[pn].enti.y-TILEWH, 24, 32, 12); +#endif + player[pn].enti.d = 2; + } + player[pn].enti.triggerx = player[pn].enti.tx; + player[pn].enti.triggery = player[pn].enti.ty-1; break; } } //panning page -void panPageManual(map_view_t *pip, player_t *player, word pn) +void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) { - switch(player[pn].d) +#define SHOWMVFUN_ ZC_ShowMV(pip, 0, 0); + switch(player[pn].enti.d) { //right movement case 3: - if(pip[pip[0].pan->pn].tx >= 0 && pip[pip[0].pan->pn].tx+pip[pip[0].pan->pn].page->tw < pip[pip[0].pan->pn].page->tilesw) + if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].page->tilesw) { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { - pip[pip[0].pan->pn].page[0].dx+=4; - modexShowPage(pip[pip[0].pan->pn].page); - player[pn].q++; - } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx++; } + pip[0].page->dx+=4; + SHOWMVFUN_; + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx++; } } break; //left movement case 1: - if(pip[pip[0].pan->pn].tx > 0 && pip[pip[0].pan->pn].tx+pip[pip[0].pan->pn].page->tw <= pip[pip[0].pan->pn].page->tilesw) + if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].page->tilesw) { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { - pip[pip[0].pan->pn].page[0].dx-=4; - modexShowPage(pip[pip[0].pan->pn].page); - player[pn].q++; - } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].tx--; } + pip[0].page->dx-=4; + SHOWMVFUN_; + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].tx--; } } break; //down movement case 4: - if(pip[pip[0].pan->pn].ty >= 0 && pip[pip[0].pan->pn].ty+pip[pip[0].pan->pn].page->th < pip[pip[0].pan->pn].page->tilesh) + if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].page->tilesh) { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { - pip[pip[0].pan->pn].page[0].dy+=4; - modexShowPage(pip[pip[0].pan->pn].page); - player[pn].q++; - } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty++; } + pip[0].page->dy+=4; + SHOWMVFUN_; + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty++; } } break; //up movement case 0: - if(pip[pip[0].pan->pn].ty > 0 && pip[pip[0].pan->pn].ty+pip[pip[0].pan->pn].page->th <= pip[pip[0].pan->pn].page->tilesh) + if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].page->tilesh) { - if(player[pn].q<=player[pn].spt) + if(player[pn].enti.q<=player[pn].enti.spt) { - pip[pip[0].pan->pn].page[0].dy-=4; - modexShowPage(pip[pip[0].pan->pn].page); - player[pn].q++; - } else { player[pn].q = 1; player[pn].d = 2; pip[pip[0].pan->pn].ty--; } + pip[0].page->dy-=4; + SHOWMVFUN_; + player[pn].enti.q++; + } else { player[pn].enti.q = 1; player[pn].enti.d = 2; pip[0].ty--; } } - break; + break; } - //if (player[pn].d!=2) printf("player[%u].d=%u player[%u].q=%u\n", pn, player[pn].d, pn, player[pn].q); } /* * modex mv setup */ -void modexMVSetup(map_view_t *pip, map_t *map, pan_t *pan, global_game_variables_t *gv) +void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv) { +#define ZC_MVI 1 nibble i; // 1st page pip[0].page = &gv->video.page[0]; pip[0].map = map; pip[0].video = &gv->video; - pip[0].pan = pan; - modexMVInit(pip, 1, 1); + pip[0].panp = &gv->video.panp; + ZC_MVInit(pip, 1, 1); - for(i=1;ivideo.num_of_pages;i++) + for(i=ZC_MVI;ivideo.num_of_pages;i++) { pip[i].page = &gv->video.page[i]; pip[i].map = pip[0].map; pip[i].video = pip[0].video; - pip[i].pan = pip[0].pan; - //pip[i].tx = 1; - //pip[i].ty = 1; + pip[i].panp = pip[0].panp; +// if(i>ZC_MVI) { + pip[i].tx = 1; + pip[i].ty = 1; +// } } } -void modexMVInit(map_view_t *mv, int tx, int ty) +void ZC_MVInit(map_view_t *pip, int tx, int ty) { - //mv[0].tx = tx; - //mv[0].ty = ty; - mv[0].tx = mv[1].tx = tx; - mv[0].ty = mv[1].ty = ty; + pip[0].tx = tx; + pip[0].ty = ty; + //pip[0].tx = pip[1].tx = tx; + //pip[0].ty = pip[1].ty = ty; +} + +void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr) +{ + word high_address, low_address, offset; + byte crtcOffset; + + /* calculate offset */ + offset = (word) moo[moo[0].video->panp].page->data; + offset += moo[0].page->dy * (moo[0].page->width >> 2 ); + offset += moo[0].page->dx >> 2; + + /* calculate crtcOffset according to virtual width */ + switch(sr) + { + case 1: + crtcOffset = moo[0].page->sw >> 3; + break; + default: + case 0: + crtcOffset = moo[0].page->width >> 3; + break; + } + + high_address = HIGH_ADDRESS | (offset & 0xff00); + low_address = LOW_ADDRESS | (offset << 8); + + /* wait for appropriate timing and then program CRTC */ + if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE)); + outpw(CRTC_INDEX, high_address); + outpw(CRTC_INDEX, low_address); + outp(CRTC_INDEX, 0x13); + outp(CRTC_DATA, crtcOffset); + + /* wait for one retrace */ + if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE)); + + /* do PEL panning here */ + outp(AC_INDEX, 0x33); + outp(AC_INDEX, (moo[0].page->dx & 0x03) << 1); } /*map_t @@ -397,7 +616,7 @@ void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid) word x;//, y; /* coordinate for drawing */ /* increment the pixel position and update the page */ - mv[id].page[0].dx += player[plid].speed; + mv[id].page[0].dx += player[plid].enti.speed; /* check to see if this changes the tile */ if(mv[id].page[0].dx >= mv[id].dxThresh ) @@ -412,7 +631,7 @@ void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid) /* draw the next column */ x= mv[0].page->sw + mv[id].map->tiles->tileWidth; - if(player[plid].q%4) + if(player[plid].enti.q%4) if(id==0) mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, mv->page[0].dx); else @@ -427,7 +646,7 @@ void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid) word x;//,y; /* coordinate for drawing */ /* decrement the pixel position and update the page */ - mv[id].page[0].dx -= player[plid].speed; + mv[id].page[0].dx -= player[plid].enti.speed; /* check to see if this changes the tile */ if(mv[id].page[0].dx == 0) @@ -442,7 +661,7 @@ void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid) /* draw the next column */ x= 0; - if(player[plid].q%4) + if(player[plid].enti.q%4) if(id==0) mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, mv->page[0].dx); else @@ -457,7 +676,7 @@ void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid) word y;//x, /* coordinate for drawing */ /* decrement the pixel position and update the page */ - mv[id].page[0].dy -= player[plid].speed; + mv[id].page[0].dy -= player[plid].enti.speed; /* check to see if this changes the tile */ if(mv[id].page[0].dy == 0 ) @@ -472,7 +691,7 @@ void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid) /* draw the next row */ y= 0; - if(player[plid].q%3) + if(player[plid].enti.q%3) if(id==0) mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, mv->page[0].dy); else @@ -486,7 +705,7 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid) word y;//x, /* coordinate for drawing */ /* increment the pixel position and update the page */ - mv[id].page[0].dy += player[plid].speed; + mv[id].page[0].dy += player[plid].enti.speed; /* check to see if this changes the tile */ if(mv[id].page[0].dy >= mv[id].dyThresh ) @@ -501,7 +720,7 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid) /* draw the next row */ y= mv[0].page->sh + mv[id].map->tiles->tileHeight; - if(player[plid].q%3) + if(player[plid].enti.q%3) if(id==0) mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, mv->page[0].dy); else @@ -515,7 +734,7 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid) void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid) { /* increment the pixel position and update the page */ - mv[id].page->dx += player[plid].speed; + mv[id].page->dx += player[plid].enti.speed; /* check to see if this changes the tile */ if(mv[id].page->dx >= mv[0].dxThresh ) @@ -532,7 +751,7 @@ void near ScrollRight(map_view_t *mv, player_t *player, word id, word plid) void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid) { /* decrement the pixel position and update the page */ - mv[id].page->dx -= player[plid].speed; + mv[id].page->dx -= player[plid].enti.speed; /* check to see if this changes the tile */ if(mv[id].page->dx == 0) @@ -549,7 +768,7 @@ void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid) void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid) { /* decrement the pixel position and update the page */ - mv[id].page->dy -= player[plid].speed; + mv[id].page->dy -= player[plid].enti.speed; /* check to see if this changes the tile */ if(mv[id].page->dy == 0) @@ -566,7 +785,7 @@ void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid) void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid) { /* increment the pixel position and update the page */ - mv[id].page->dy += player[plid].speed; + mv[id].page->dy += player[plid].enti.speed; /* check to see if this changes the tile */ if(mv[id].page->dy >= mv[0].dxThresh ) @@ -585,8 +804,8 @@ void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid) //default player position on the viewable map void playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn) { - player[pn].tx = x + pip[0].tx + pip[0].page->tilemidposscreenx; - player[pn].ty = y + pip[0].ty + pip[0].page->tilemidposscreeny; + player[pn].enti.tx = x + pip[0].tx + pip[0].page->tilemidposscreenx; + player[pn].enti.ty = y + pip[0].ty + pip[0].page->tilemidposscreeny; } //=========================================================================== @@ -708,7 +927,7 @@ mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((dbg_mapdata[i])+1)); //modexprint(page, x, y, 1, 15, 0, (char const *)(t->debug_data[i])); #else - PBUFBFUN (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data)); + modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data)); /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */ //draw_vrl1_vgax_modex(x-rx,y-ry,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); //modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data)); @@ -731,11 +950,11 @@ mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) } } -void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *p, word poopoffset) +void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset) { word x; int i; - poopoffset%=p[0].speed; + poopoffset%=player[0].enti.speed; //printf("y: %d\n", poopoffset); /* the position within the map array */ i=ty * mv->map->width + tx; @@ -748,11 +967,11 @@ void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *p, word p } } -void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *p, word poopoffset) +void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset) { int y; int i; - poopoffset%=p[0].speed; + poopoffset%=player[0].enti.speed; //printf("x: %d\n", poopoffset); /* location in the map array */ i=ty * mv->map->width + tx; @@ -808,7 +1027,6 @@ void mapDrawWCol(map_view_t *mv, int tx, int ty, word x) //setkb(0); }*/ -unsigned char shinku_fps_indicator_page = 2; boolean pageflipflop = 1; boolean pageploop = 1; @@ -822,9 +1040,9 @@ void shinku(global_game_variables_t *gv) //modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4); /* block copy to visible RAM from offscreen */ // vga_setup_wm1_block_copy(); -// modexCopyPageRegion(&(gv->video.page[shinku_fps_indicator_page]), &(gv->video.page[!shinku_fps_indicator_page]), x, y, x+w, 0, w, h); +// modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x+w, 0, w, h); // o = *(gv->video.page[2].data); // source offscreen -// o2 = *(gv->video.page[shinku_fps_indicator_page].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride) +// o2 = *(gv->video.page[gv->video->sfip].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride) // for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) vga_wm1_mem_block_copy(o2,o,w >> 2); /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */ // vga_restore_rm0wm0(); @@ -838,15 +1056,15 @@ void shinku(global_game_variables_t *gv) // // This fixes *** Null pointer assignment detected error message in ZCROLL.EXE on exit. sprintf(global_temp_status_text, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv)); - //modexClearRegion(&(gv->video.page[shinku_fps_indicator_page]), x, y, w, h, 45); + //modexClearRegion(&(gv->video.page[gv->video->sfip]), x, y, w, h, 45); modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, global_temp_status_text); gv->kurokku.tiku=0; /* block copy to visible RAM from offscreen */ // vga_setup_wm1_block_copy(); -// o = *(gv->video.page[shinku_fps_indicator_page].data); // source offscreen +// o = *(gv->video.page[gv->video->sfip].data); // source offscreen // o2 = *(gv->video.page[2].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride) // for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) vga_wm1_mem_block_copy(o2,o,w >> 2); -// modexCopyPageRegion(&(gv->video.page[shinku_fps_indicator_page]), &(gv->video.page[!shinku_fps_indicator_page]), x, y, x, 0, w, h); +// modexCopyPageRegion(&(gv->video.page[gv->video->sfip]), &(gv->video.page[!gv->video->sfip]), x, y, x, 0, w, h); /* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */ // vga_restore_rm0wm0(); }else //copy dat sheet @@ -855,7 +1073,7 @@ void shinku(global_game_variables_t *gv) switch(gv->kurokku.fpscap) { case 0: - //modexprint(&(gv->video.page[shinku_fps_indicator_page]), x, y+8, type, col, bgcol, "sanic!"); + //modexprint(&(gv->video.page[gv->video->sfip]), x, y+8, type, col, bgcol, "sanic!"); gv->kurokku.frames_per_second=1; break; case 1: @@ -879,15 +1097,27 @@ void shinku(global_game_variables_t *gv) } } +#ifdef SPRITE +#define FRAME1 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 48, dire, 24, 32, PLAYERBMPDATAPTR); +#define FRAME2 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATAPTR); +#define FRAME3 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 0, dire, 24, 32, PLAYERBMPDATAPTR); +#define FRAME4 modexDrawSpriteRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATAPTR); +#else +#define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 2+dire); +#define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire); +#define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, dire); +#define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire); +#endif + void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch) { - sword x = player[pn].x; - sword y = player[pn].y; + sword x = player[pn].enti.x; + sword y = player[pn].enti.y; sword bx = x+16; //buffer's x sword by = y+16; //buffer's y word dire=32; //direction sword qq; //scroll offset - word ls = player[pn].persist_aniframe; + word ls = player[pn].enti.persist_aniframe; switch(scrollswitch) { @@ -895,22 +1125,22 @@ void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scroll qq = 0; break; default: - qq = ((player[pn].q)*(player[pn].speed)); + qq = ((player[pn].enti.q)*(player[pn].enti.speed)); break; } //x-=4; y-=pip[0].map->tiles->tileHeight; - switch (player[pn].d) + switch (player[pn].enti.d) { case 0: //up - dire*=player[pn].d; + dire*=player[pn].enti.d; y-=qq; by-=4; break; case 3: // right - dire*=(player[pn].d-2); + dire*=(player[pn].enti.d-2); x+=qq; bx+=4; break; @@ -918,29 +1148,18 @@ void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scroll break; case 4: //down - dire*=(player[pn].d-2); + dire*=(player[pn].enti.d-2); y+=qq; by+=4; break; case 1: //left - dire*=(player[pn].d+2); + dire*=(player[pn].enti.d+2); x-=qq; bx-=4; break; } -#ifdef SPRITE -#define FRAME1 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 48, dire, 24, 32, PLAYERBMPDATA); -#define FRAME2 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA); -#define FRAME3 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 0, dire, 24, 32, PLAYERBMPDATA); -#define FRAME4 PBUFSFUN(pip[/*!*/(pip->video->p)].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA); -#else -#define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 2+dire); -#define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire); -#define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, dire); -#define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire); -#endif if(!pageflipflop) modexCopyPageRegion(pip[1].page, pip[0].page, x-4, y-4, x-4, y-4, 28, 36); else{ @@ -978,6 +1197,183 @@ void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scroll pip->video->r=1; } +/* +void animate_spri(struct sprite *spri, global_game_variables_t *gv) +{ +#define GVARVIDEO gv->video +#define VMEMPAGESIZE2 GVARVIDEO.page[0].pagesize+GVARVIDEO.page[1].pagesize +#define VMEMPAGEDATA2 GVARVIDEO.page[2].data + unsigned int i,o,o2; int j; + int x,y,rx,ry,w,h; + int overdraw = 1; // how many pixels to "overdraw" so that moving sprites with edge pixels don't leave streaks. + // if the sprite's edge pixels are clear anyway, you can set this to 0. + VGA_RAM_PTR omemptr; + + // Events go here + + + omemptr = vga_state.vga_graphics_ram; // save original mem ptr + x=spri->x-4; + y=spri->y; + + // Draw sprite + j = get_vrl_by_id(spri->spritesheet, spri->curr_spri_id, spri->sprite_vrl_cont); + if(j < 0) + { + Quit (gv, "Error retriving required sprite"); + } + + // render box bounds. y does not need modification, but x and width must be multiple of 4 + if (x >= overdraw) rx = (x - overdraw) & (~3); + else rx = -(GVARVIDEO.page[0].dx); + if (y >= overdraw) ry = (y - overdraw); + else ry = -(GVARVIDEO.page[0].dy); + h = spri->sprite_vrl_cont->vrl_header->height + overdraw + y - ry; + w = (x + spri->sprite_vrl_cont->vrl_header->width + (overdraw*2) + 3 - rx) & (~3);//round up + if ((rx+w) > GVARVIDEO.page[0].width) w = GVARVIDEO.page[0].width-rx; + if ((ry+h) > GVARVIDEO.page[0].height) h = GVARVIDEO.page[0].height-ry; + + // block copy pattern to where we will draw the sprite + vga_setup_wm1_block_copy(); + o2 = VMEMPAGESIZE2; + o = (0x10000UL - (uint16_t)VMEMPAGEDATA2) + (ry * GVARVIDEO.page[0].stridew) + (rx >> 2); // source offscreen + for (i=0;i < h;i++,o += GVARVIDEO.page[0].stridew,o2 += (w >> 2)) vga_wm1_mem_block_copy(o2,o,w >> 2); + + // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally + vga_restore_rm0wm0(); + + // replace VGA stride with our own and mem ptr. then sprite rendering at this stage is just (0,0) + vga_state.vga_draw_stride_limit = (GVARVIDEO.page[0].width + 3 - x) >> 2;//round up + vga_state.vga_draw_stride = w >> 2; + vga_state.vga_graphics_ram = omemptr + VMEMPAGESIZE2; + + // then the sprite. note modding ram ptr means we just draw to (x&3,0) + draw_vrl1_vgax_modex( + x-rx, + y-ry, + spri->sprite_vrl_cont->vrl_header, + spri->sprite_vrl_cont->line_offsets, + spri->sprite_vrl_cont->buffer + sizeof(struct vrl1_vgax_header), + spri->sprite_vrl_cont->data_size + ); + + // restore ptr + vga_state.vga_graphics_ram = omemptr; + + // block copy to visible RAM from offscreen + vga_setup_wm1_block_copy(); + o = VMEMPAGESIZE2; // source offscreen + o2 = (ry * GVARVIDEO.page[0].stridew) + (rx >> 2); // dest visible (original stride) + for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += GVARVIDEO.page[0].stridew) vga_wm1_mem_block_copy(o2,o,w >> 2); + // must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally + vga_restore_rm0wm0(); + + // restore stride + vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = GVARVIDEO.page[0].stridew; + + // Depending on delay, update indices + switch(spri->delay){ + // Delay = 0 means that sprite should loop. Nothing to change here + case 0: + break; + + // Delay = 1 means that on next time unit sprite should be changed + case 1: + spri->curr_anim_spri++; + + // If we hit the end of an animation sequence, restart it + if(!(spri->curr_spri_id = spri->curr_anim_list[spri->curr_anim_spri].sprite_id)){ + spri->curr_anim_spri = 0; + spri->curr_spri_id = spri->curr_anim_list[spri->curr_anim_spri].sprite_id; + } + spri->delay = spri->curr_anim_list[spri->curr_anim_spri].delay; + + // Delay > 1 means that we should not change sprite yet. Decrease delay + default: + spri->delay--; + break; + } +} +*/ +//void animate_spri(struct sprite *spri, global_game_variables_t *gv) +void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch) +{ + sword x = player[pn].enti.x; + sword y = player[pn].enti.y; + word dire=10; //direction + sword i; + sword qq; //scroll offset + word ls = player[pn].enti.persist_aniframe; + + switch(scrollswitch) + { + case 0: + qq = 0; + break; + default: + qq = ((player[pn].enti.q)*(player[pn].enti.speed)); + break; + } + //x-=4; + y-=pip[0].map->tiles->tileHeight; + switch (player[pn].enti.d) + { + case 0: + //up + dire*=(player[pn].enti.d+1);// dire++; + y-=qq; + break; + case 3: + // right + dire*=(player[pn].enti.d-1);// dire++; + x+=qq; + break; + case 2: + break; + case 4: + //down + dire*=(player[pn].enti.d-1);// dire++; + y+=qq; + break; + case 1: + //left + dire*=(player[pn].enti.d+3);// dire++; + x-=qq; + break; + } + + //setting xy position + player[pn].ent->spri->x = x; + player[pn].ent->spri->y = y; + +//#define FRAME1 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 2+dire); +//#define FRAME2 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire); +//#define FRAME3 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, dire); +//#define FRAME4 modexClearRegion(pip[/*!*/(pip->video->p)].page, x, y, 24, 32, 1+dire); +#define DRAWFRAME if (i == -1) return; animate_spri(player[pn].ent->spri, pip->video) +#define NFRAME1 i = set_anim_by_id(player[pn].ent->spri, 2+dire); DRAWFRAME; +#define NFRAME2 i = set_anim_by_id(player[pn].ent->spri, 1+dire); DRAWFRAME; +#define NFRAME3 i = set_anim_by_id(player[pn].ent->spri, dire); DRAWFRAME; +#define NFRAME4 i = set_anim_by_id(player[pn].ent->spri, 2+dire); DRAWFRAME; + + switch(ls) + { + case 1: + NFRAME1 + break; + case 2: + NFRAME2; + break; + case 3: + NFRAME3 + break; + case 4: + NFRAME4 + break; + } + pip->video->r=1; +} + /* * from zcroll16.c */ @@ -993,7 +1389,7 @@ boolean coll_check(int x, int y, int dx, int dy, map_view_t *map_v) return dx && 1;//crossable_tile(x + dx, map_v) || dy && crossable_tile(y + dy, map_v); } -boolean ZC_walk(entity_t *ent, map_view_t *map_v) +boolean ZC_walk2(entity_t *ent, map_view_t *map_v) { //return 1; int dx = 1; @@ -1027,7 +1423,7 @@ boolean ZC_walk(entity_t *ent, map_view_t *map_v) void player_walk(player_t *player, map_view_t *map_v){ int dx=16, dy=16; - if(ZC_walk(player->ent, map_v) && boundary_check(map_v->tx, map_v->ty, dx, dy, map_v->map->width - 2*map_v->page->tilesw, map_v->map->height - 2*map_v->page->tilesh)) + if(ZC_walk2(&(player->enti), map_v) && boundary_check(map_v->tx, map_v->ty, dx, dy, map_v->map->width - 2*map_v->page->tilesw, map_v->map->height - 2*map_v->page->tilesh)) { mapScroll(map_v, player); // (Un)load stuff?