X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fscroll16.h;h=fc187954663f4a3fbfdf0d8fe805146f437dfde7;hb=d26e0714368d1cfbe4caee5d6309cf97e0af55db;hp=a32874346daaa4f91347cfe04ac21f4b157d6c88;hpb=786882743258ea46b79ece3cb64b7be1e5156a46;p=16.git diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index a3287434..fc187954 100755 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -1,5 +1,5 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover + * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover * * This file is part of Project 16. * @@ -34,7 +34,7 @@ //#include "src/lib/16_map.h" //new map stuff #include "src/lib/16_timer.h" #include "src/lib/wcpu/16_wcpu.h" -#include "src/lib/16_sprit.h" +#include "src/lib/16_spri.h" #include #include @@ -44,8 +44,6 @@ #define SPRITE //#define TILERENDER -#define ANIMATESPRIFUN ZC_animatePlayer - #define PLAYERBMPDATAVAR player[pn].data #define PLAYERBMPDATA *PLAYERBMPDATAVAR #define PLAYERBMPDATAPTR PLAYERBMPDATAVAR @@ -55,83 +53,53 @@ #define PCXBMPPTR PCXBMPVAR //row and colum drawing routines -//#define FULLRCREND -//#define DRAWCOLNUM mv->page[0].dx -//#define DRAWROLNUM mv->page[0].dy -#define DRAWCOLNUM player[plid].enti.q -#define DRAWROLNUM player[plid].enti.q - -typedef struct { - map_t *map; - page_t *page; - int tx; //appears to be the top left tile position on the viewable screen map - int ty; //appears to be the top left tile position on the viewable screen map - word dxThresh; //Threshold for physical tile switch - word dyThresh; //Threshold for physical tile switch - video_t *video; //pointer to game variables of the video - nibble *panp; // pointer to video's pan page num - int drawx, drawy; // draw row and col var -//newer vars! - int dx, dy, delta, d; -} map_view_t; -/* Map is presumed to: - * 1. Have all the required layers and tilesets within itself - * 2. Have a 'fence' around accessible blocks to simplify boundary logic - * 3. Have a persistent map and tile size among the layers - * Map view is presumed to: - * 1. Calculate, store and update a panning info, which includes, but not limited to: - * combined layer information, actual map representation (reflecting real state of the game), - * pixel shift for smooth tile scrolling. - * 2. Provide ways to draw a visible part of map. For simplicity with smooth scrolling, - * additional row/column is always drawn at the each side of the map. This implies that 'fence' - * should have a sprite too. Map is drawn left-to-right, top-to-bottom. - */ +#define FULLRCREND +#define DRAWCOLNUM mv->page[id].dx +#define DRAWROWNUM mv->page[id].dy +//#define DRAWCOLNUM player[plid].enti.q +//#define DRAWROLNUM player[plid].enti.q //for null map! #define MAPW 40 #define MAPH 30 +//===========================================================================// + //if(player[0].enti.hp==0) printf("%d wwww\n", player[0].enti.y+8); //else printf("\nplayer[0].enti.y: %d\n", player[0].enti.y); -// printf("palette offset: %d\n", paloffset/3); -//++++ printf("Total used: %zu\n", oldfreemem-GetFreeSize()); -//++++ printf("Total free: %zu\n", GetFreeSize()); +//printf("gvar.video.p=%u ", gvar.video.p); //not used now printf("temporary player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n"); //not used now printf("temporary player sprite 1: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=44606385\n"); //printf("mv[%u].tx: %d", gvar.video.panp, mv[gvar.video.panp].tx); printf(" mv[%u].ty: %d ", gvar.video.panp, mv[gvar.video.panp].ty); //printf("gvar.kurokku: "); printf("%.0f ", clock()); printf("tiku=%lu ", gvar.kurokku.tiku); printf("t=%.0f ", gvar.kurokku.t); printf("ticktock()=%f ", ticktock(&gvar)); printf("%.0f fps", (double)gvar.kurokku.tiku/ticktock(&gvar)); -//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]); +//printf("map.width=%d map.height=%d map.data[0]=%d\n", mv[1].map->width, mv[1].map->height, mv[1].map->layerdata[0][0]); +//printf("pageflipflop=%u", pageflipflop); //printf("&global_temp_status_text = %Fp\n", &global_temp_status_text); //printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx); printf("%d\n", gvar.video.page[0].tilemidposscreeny); -//printf("Virtual Screen: %dx", gvar.video.page[0].width); printf("%d ", gvar.video.page[0].height); printf("Tile: %dx", gvar.video.page[0].tilesw); printf("%d", gvar.video.page[0].tilesh); printf("=((Virtual Screen)/16)\n"); -//printf(" Screen: %dx", gvar.video.page[0].sw); printf("%d ", gvar.video.page[0].sh); printf("Tile: %dx", gvar.video.page[0].tw); printf("%d", gvar.video.page[0].th); printf("=((Screen)/16)\n"); -//print_anim_ids(player[0].ent->spri); //printf(" aniframe=%u", player[0].enti.persist_aniframe); -#define SCROLLEXITMESG printf("tx: %d ", mv[0].tx);\ - printf("ty: %d\n", mv[0].ty);\ - printf("\n");\ +//printf("mv[0]txy: %dx%d ", mv[0].tx, mv[0].ty); printf("mv[1]txy: %dx%d", mv[1].tx, mv[1].ty); +#define SCROLLEXITMESG printf("page[0]dxy: %dx%d", gvar.video.page[0].dx, gvar.video.page[0].dy);\ + printf("\n\n");\ printf("player vars:\n");\ - printf(" x: %d", player[0].enti.x); printf(" y: %d\n", player[0].enti.y);\ - \ - printf(" tx: %d", player[0].enti.tx); printf(" ty: %d\n", player[0].enti.ty);\ - printf(" triggx: %d", player[0].enti.triggerx); printf(" triggy: %d", player[0].enti.triggery); printf(" value: %d\n", mv[0].map->data[(player[0].enti.triggerx-1)+(map.width*(player[0].enti.triggery-1))]);\ - printf(" hp: %d", (player[0].enti.hp)); printf(" q: %d", player[0].enti.q); printf(" player.info.dir: %d", player[0].info.dir); printf(" player.d: %d ", player[0].enti.d);\ - printf(" pdir=%d\n", player[0].pdir); printf(" delay=%u", player[0].enti.spri->delay);\ + printf(" xy: %dx%d", player[0].enti.x, player[0].enti.y); printf(" txy: %dx%d", player[0].enti.tx, player[0].enti.ty); printf(" triggxy: %dx%d", player[0].enti.triggerx, player[0].enti.triggery); printf(" value: %d\n", mv[1].map->MAPDATAPTR[(player[0].enti.triggerx-1)+(map.width*(player[0].enti.triggery-1))]);\ + printf(" hp: %d", (player[0].enti.hp)); printf(" q: %u", player[0].enti.q); printf(" info.dir: %u", player[0].info.dir); printf(" d: %u", player[0].enti.d); printf(" dire: %u", player[0].enti.dire);\ + printf(" pdir: %u\n", player[0].pdir); printf(" delay=%u", player[0].enti.spri->delay);\ printf("\n\n");\ VL_PrintmodexmemInfo(&gvar.video);\ \ - printf("gvar.video.p=%u ", gvar.video.p); printf("gvar.video.r=%u ", gvar.video.r);\ - printf("pageflipflop=%u\n", pageflipflop);\ - printf("\n"); + printf("gvar.video:\n");\ + printf(" r=%u ", gvar.video.dorender);\ + printf("bgps=%u ", gvar.video.bgps);\ +printf("\n\n"); -extern boolean pageflipflop, pageploop, pagenorendermap, pagedelayrendermap; +extern boolean pagenorendermap, pagedelayrendermap; extern char global_temp_status_text[512]; +extern char global_temp_status_text2[512]; //map_t allocMap(int w, int h); -//void initMap(map_t *map); +void initMap(map_t *map); void ZC_walk(map_view_t *pip, player_t *player, word pn); -//void oldwalk(map_view_t *pip, player_t *player, word pn); void ZC_panPageManual(map_view_t *pip, player_t *player, word pn); void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv); void ZC_MVInit(map_view_t *pip, int tx, int ty); @@ -140,24 +108,90 @@ 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); 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); -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); -void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid); -void playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn); +void ZC_mapScroll(map_view_t *mv, player_t *player, word pn); +void ZC_playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn, boolean defaultsw); sword chkmap(map_t *map, word q); void mapGoTo(map_view_t *mv, int tx, int ty); -void mapinitmapview(map_view_t *mv, int tx, int ty); +void ZC_mapinitMV(map_view_t *mv, int tx, int ty); +void ZC_mapredraw(map_view_t *mv, int tx, int ty); void near 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 *player, word poopoffset); void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset); void mapDrawWRow(map_view_t *mv, int tx, int ty, word y); void mapDrawWCol(map_view_t *mv, int tx, int ty, word x); +inline 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].enti.speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dx >= mv[id].dxThresh ) + { + /* go forward one tile */ + if(id==0) mv[id].tx++; + /* Snap the origin forward */ + mv[id].page->data += 4; + + mv[id].page->dx = mv[id].map->MAPTILESPTR->tileWidth; + } +} + +inline 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].enti.speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dx == 0) + { + /* go backward one tile */ + if(id==0) mv[id].tx--; + /* Snap the origin backward */ + mv[id].page->data -= 4; + + mv[id].page->dx = mv[id].map->MAPTILESPTR->tileWidth; + } +} + +inline 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].enti.speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dy == 0 ) + { + /* go up one tile */ + if(id==0) mv[id].ty--; + /* Snap the origin upward */ + mv[id].page->data -= mv[id].page->pi; + + mv[id].page->dy = mv[id].map->MAPTILESPTR->tileHeight; + } +} + +inline 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].enti.speed; + + /* check to see if this changes the tile */ + if(mv[id].page->dy >= mv[id].dyThresh ) + { + /* go down one tile */ + if(id==0) mv[id].ty++; + /* Snap the origin downward */ + mv[id].page->data += mv[id].page->pi; + + mv[id].page->dy = mv[id].map->MAPTILESPTR->tileHeight; + } +} + //void qclean(); +//sync void shinku(global_game_variables_t *gv); -void near ZC_drawframe(map_view_t *pip, entity_t *enti, sword x, sword y); -void animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch); -void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch); +//animate the sprite +void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn); // Move an entity around. Should actually be in 16_entity boolean ZC_walk2(entity_t *ent, map_view_t *map_v);