OSDN Git Service

i did some minor things including commenting out some joy stick timing stuff and...
[proj16/16.git] / src / lib / scroll16.h
index a3402a0..2b5ca92 100755 (executable)
-/* 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 <http://www.gnu.org/licenses/>, or
- * write to the Free Software Foundation, Inc., 51 Franklin Street,
- * Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-#ifndef __SCROLL16_H_
-#define __SCROLL16_H_
-
-#include "src/lib/16_head.h"
-#include "src/lib/bakapee.h"
-#include "src/lib/modex16.h"
-#include "src/lib/16_in.h"
-#include "src/lib/bitmap.h"
-#include "src/lib/mapread.h" //map is loaded here www
-#include "src/lib/16_timer.h"
-#include "src/lib/wcpu/wcpu.h"
-
-#include <hw/cpu/cpu.h>
-#include <hw/dos/dos.h>
-#include <hw/vga/vga.h>
-#include <hw/vga/vrl.h>
-
-#define SPRITE
-//#define TILERENDER
-
-//modexDrawSpritePBufRegion
-//modexDrawBmpPBufRegion
-#define PBUFSFUN               modexDrawSpriteRegion
-#define PBUFBFUN               modexDrawBmpRegion
-#define PLAYERBMPDATA  player[pn].data
-
-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; //????
-       word dyThresh; //????
-       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
-{
-       map_view_t *mv;
-} map_view_db_t;
-
-//for null map!
-#define MAPW   40
-#define MAPH   30
-
-extern boolean pageflipflop, pageploop;
-extern unsigned char shinku_fps_indicator_page;
-
-//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);
-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);
-sword chkmap(map_t *map, word q);
-void mapGoTo(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 *p, word poopoffset);
-void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *p, 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);
-//void qclean();
-void shinku(global_game_variables_t *gv);
-void near animatePlayer(map_view_t *pip, player_t *player, word playnum, sword scrollswitch);
-
-#endif /*__SCROLL16_H_*/
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2017 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
+#ifndef __SCROLL16_H_\r
+#define __SCROLL16_H_\r
+\r
+#include "src/lib/16_head.h"\r
+#include "src/lib/16_tail.h"\r
+#include "src/lib/bakapee.h"\r
+#include "src/lib/16_vl.h"\r
+#include "src/lib/16_in.h"\r
+#include "src/lib/16_map.h" //map is loaded here www\r
+//#include "src/lib/16render.h"\r
+#include "src/lib/16_timer.h"\r
+#include "src/lib/wcpu/16_wcpu.h"\r
+#include "src/lib/16_spri.h"\r
+\r
+#include <hw/cpu/cpu.h>\r
+#include <hw/dos/dos.h>\r
+#include <hw/vga/vga.h>\r
+#include <hw/vga/vrl.h>\r
+\r
+#define SPRITE\r
+//#define TILERENDER\r
+\r
+//0000#define SHOWFPS\r
+//#define OLDWALKSHOWPAGESTUFF\r
+\r
+\r
+#define PLAYERBMPDATAVAR       gvar.player[pn].data\r
+#define PLAYERBMPDATA          *PLAYERBMPDATAVAR\r
+#define PLAYERBMPDATAPTR       PLAYERBMPDATAVAR\r
+\r
+#define PCXBMPVAR      gvar.player[0].data\r
+#define PCXBMP         *PCXBMPVAR\r
+#define PCXBMPPTR      PCXBMPVAR\r
+\r
+//row and colum drawing routines\r
+//#define FULLRCREND\r
+#define DRAWCOLNUM mv->page[id].dx\r
+#define DRAWROWNUM mv->page[id].dy\r
+//#define DRAWCOLNUM pl[plid].enti.q\r
+//#define DRAWROLNUM pl[plid].enti.q\r
+\r
+//for null map!\r
+#define MAPW   40\r
+#define MAPH   30\r
+\r
+extern struct glob_game_vars   *ggvv;\r
+#ifdef __DEBUG_RF__\r
+#define DBG_RFDELAYMETHOD delay(250);\r
+#endif\r
+\r
+//===========================================================================//\r
+\r
+       //if(gvar.player[0].enti.hp==0) printf("%d wwww\n", gvar.player[0].enti.y+8);\r
+       //else printf("\ngvar.player[0].enti.y: %d\n", gvar.player[0].enti.y);\r
+//printf("gvar.video.p=%u ", gvar.video.p);\r
+//not used now printf("temporary gvar.player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n");\r
+//not used now printf("temporary gvar.player sprite 1: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=44606385\n");\r
+//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);\r
+//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));\r
+//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]);\r
+//printf("pageflipflop=%u", pageflipflop);\r
+//printf("&global_temp_status_text = %Fp\n", &global_temp_status_text);\r
+//printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx);   printf("%d\n", gvar.video.page[0].tilemidposscreeny);\r
+//printf("     aniframe=%u", gvar.player[0].enti.persist_aniframe);\r
+//printf("mv[0]txy: %dx%d      ", mv[0].tx, mv[0].ty); printf("mv[1]txy: %dx%d", mv[1].tx, mv[1].ty);\r
+//     printf("page[0]dxy: %dx%d", gvar.video.page[0].dx, gvar.video.page[0].dy);\r
+#define SCROLLEXITMESG \\r
+       printf("size of mmblocktype: %u ", sizeof(mmblocktype));\\r
+       printf("\n\n");\\r
+       printf("player vars:\n");\\r
+       printf("        xy: %dx%d", gvar.player[0].enti.x, gvar.player[0].enti.y); printf("     txy: %dx%d", gvar.player[0].enti.tx, gvar.player[0].enti.ty); printf("  triggxy: %dx%d", gvar.player[0].enti.triggerx, gvar.player[0].enti.triggery); printf("  value: %d\n", gvar.mv[1].map->layerdata[0].data[(gvar.player[0].enti.triggerx-1)+(gvar.map.width*(gvar.player[0].enti.triggery-1))]);\\r
+       printf("        hp: %d", (gvar.player[0].enti.hp));     printf("        q: %u", gvar.player[0].enti.q); printf("        info.dir: %u", gvar.player[0].info.dir);        printf("        d: %u", gvar.player[0].enti.d); printf("        dire: %u", gvar.player[0].enti.dire);\\r
+               printf("        pdir: %u\n", gvar.player[0].pdir); printf("     delay=%u", gvar.player[0].enti.spri.delay);\\r
+printf("\n\n");\\r
+       VL_PrintmodexmemInfo(&gvar.video);\\r
+\\r
+       printf("gvar.video:\n");\\r
+       printf(" r=%u ", gvar.video.dorender);\\r
+       printf("bgps=%u ", gvar.video.vga_state.bgps);\\r
+printf("\n\n");\r
+\r
+//     printf("dbg_delayanimation=%u ", dbg_delayanimation);\r
+/*\r
+       if(IN_KeyDown(sc_F11)){ pagedelayrendermap=!pagedelayrendermap;         IN_UserInput(1, &gvar); }\r
+       if(IN_KeyDown(sc_F10)){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap;               IN_UserInput(1, &gvar); }\r
+       if(IN_KeyDown(sc_F9)){ pagenorendermap=!pagenorendermap;                                IN_UserInput(1, &gvar); }\r
+       if(IN_KeyDown(sc_F8)){ gvar.video.vga_state.bgps=!gvar.video.vga_state.bgps;                                    IN_UserInput(1, &gvar); }\r
+       if(IN_KeyDown(sc_T)){ gvar.video.vga_state.rss=!gvar.video.vga_state.rss;                                               IN_UserInput(1, &gvar); }\r
+*/\r
+\r
+extern char global_temp_status_text[512];\r
+extern char global_temp_status_text2[512];\r
+\r
+void initMap(map_t *map);\r
+void ZC_walk(global_game_variables_t *gvar, word pn);\r
+void ZC_panPageManual(map_view_t *pip, player_t *player, word pn);\r
+void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv);\r
+void ZC_MVInit(map_view_t *pip, int tx, int ty);\r
+//void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr);\r
+void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid);\r
+void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid);\r
+void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid);\r
+void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid);\r
+void ZC_mapScroll(map_view_t *mv, player_t *player, word pn);\r
+void ZC_PlayerXYpos(int x, int y, player_t *player, map_view_t *pip, boolean defaultsw);\r
+sword chkmap(map_t *map, word q);\r
+void mapGoTo(map_view_t *mv, int tx, int ty);\r
+void ZC_mapinitMV(map_view_t *mv, int tx, int ty);\r
+void ZC_mapredraw(map_view_t *mv, int tx, int ty);\r
+void near mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y);\r
+void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset);\r
+void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset);\r
+void mapDrawWRow(map_view_t *mv, int tx, int ty, word y);\r
+void mapDrawWCol(map_view_t *mv, int tx, int ty, word x);\r
+inline void near ScrollRight(map_view_t *mv, player_t *pl, word id, word plid)\r
+{\r
+       /* increment the pixel position and update the page */\r
+       mv[id].page->dx += pl[plid].enti.spt;\r
+\r
+       /* check to see if this changes the tile */\r
+       if(mv[id].page->dx >= mv[id].dxThresh )\r
+       {\r
+               /* go forward one tile */\r
+               if(id==0) mv[id].tx++;\r
+               /* Snap the origin forward */\r
+               mv[id].page->data += 4;\r
+\r
+               mv[id].page->dx = mv[id].map->tiles->tileWidth;\r
+       }\r
+}\r
+\r
+inline void near ScrollLeft(map_view_t *mv, player_t *pl, word id, word plid)\r
+{\r
+       /* decrement the pixel position and update the page */\r
+       mv[id].page->dx -= pl[plid].enti.spt;\r
+\r
+       /* check to see if this changes the tile */\r
+       if(mv[id].page->dx == 0)\r
+       {\r
+               /* go backward one tile */\r
+               if(id==0) mv[id].tx--;\r
+               /* Snap the origin backward */\r
+               mv[id].page->data -= 4;\r
+\r
+               mv[id].page->dx = mv[id].map->tiles->tileWidth;\r
+       }\r
+}\r
+\r
+inline void near ScrollUp(map_view_t *mv, player_t *pl, word id, word plid)\r
+{\r
+       /* decrement the pixel position and update the page */\r
+       mv[id].page->dy -= pl[plid].enti.spt;\r
+\r
+       /* check to see if this changes the tile */\r
+       if(mv[id].page->dy == 0 )\r
+       {\r
+               /* go up one tile */\r
+               if(id==0) mv[id].ty--;\r
+               /* Snap the origin upward */\r
+               mv[id].page->data -= mv[id].page->pi;\r
+\r
+               mv[id].page->dy = mv[id].map->tiles->tileHeight;\r
+       }\r
+}\r
+\r
+inline void near ScrollDown(map_view_t *mv, player_t *pl, word id, word plid)\r
+{\r
+       /* increment the pixel position and update the page */\r
+       mv[id].page->dy += pl[plid].enti.spt;\r
+\r
+       /* check to see if this changes the tile */\r
+       if(mv[id].page->dy >= mv[id].dyThresh )\r
+       {\r
+               /* go down one tile */\r
+               if(id==0) mv[id].ty++;\r
+               /* Snap the origin downward */\r
+               mv[id].page->data += mv[id].page->pi;\r
+\r
+               mv[id].page->dy = mv[id].map->tiles->tileHeight;\r
+       }\r
+}\r
+\r
+//void qclean();\r
+//sync\r
+void shinku(global_game_variables_t *gv);\r
+//animate the sprite\r
+void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn);\r
+\r
+// Move an entity around. Should actually be in 16_entity\r
+boolean ZC_walk2(entity_t *ent, map_view_t *map_v);\r
+\r
+// Move gvar.player around and call map scrolling if required/possible\r
+void walk_player(player_t *player, map_view_t *map_v);\r
+\r
+// Scroll map in one direction (assumed from gvar.player's movement)\r
+void mapScroll(map_view_t *mv, player_t *player);\r
+\r
+void ZC_GirdChk (global_game_variables_t *gvar, player_t *player);\r
+\r
+#endif /*__SCROLL16_H_*/\r