]> 4ch.mooo.com Git - 16.git/blob - src/lib/scroll16.h
i did some minor things including commenting out some joy stick timing stuff and...
[16.git] / src / lib / scroll16.h
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 \r
23 #ifndef __SCROLL16_H_\r
24 #define __SCROLL16_H_\r
25 \r
26 #include "src/lib/16_head.h"\r
27 #include "src/lib/16_tail.h"\r
28 #include "src/lib/bakapee.h"\r
29 #include "src/lib/16_vl.h"\r
30 #include "src/lib/16_in.h"\r
31 #include "src/lib/16_map.h" //map is loaded here www\r
32 //#include "src/lib/16render.h"\r
33 #include "src/lib/16_timer.h"\r
34 #include "src/lib/wcpu/16_wcpu.h"\r
35 #include "src/lib/16_spri.h"\r
36 \r
37 #include <hw/cpu/cpu.h>\r
38 #include <hw/dos/dos.h>\r
39 #include <hw/vga/vga.h>\r
40 #include <hw/vga/vrl.h>\r
41 \r
42 #define SPRITE\r
43 //#define TILERENDER\r
44 \r
45 //0000#define SHOWFPS\r
46 //#define OLDWALKSHOWPAGESTUFF\r
47 \r
48 \r
49 #define PLAYERBMPDATAVAR        gvar.player[pn].data\r
50 #define PLAYERBMPDATA           *PLAYERBMPDATAVAR\r
51 #define PLAYERBMPDATAPTR        PLAYERBMPDATAVAR\r
52 \r
53 #define PCXBMPVAR       gvar.player[0].data\r
54 #define PCXBMP          *PCXBMPVAR\r
55 #define PCXBMPPTR       PCXBMPVAR\r
56 \r
57 //row and colum drawing routines\r
58 //#define FULLRCREND\r
59 #define DRAWCOLNUM mv->page[id].dx\r
60 #define DRAWROWNUM mv->page[id].dy\r
61 //#define DRAWCOLNUM pl[plid].enti.q\r
62 //#define DRAWROLNUM pl[plid].enti.q\r
63 \r
64 //for null map!\r
65 #define MAPW    40\r
66 #define MAPH    30\r
67 \r
68 extern struct glob_game_vars    *ggvv;\r
69 #ifdef __DEBUG_RF__\r
70 #define DBG_RFDELAYMETHOD delay(250);\r
71 #endif\r
72 \r
73 //===========================================================================//\r
74 \r
75         //if(gvar.player[0].enti.hp==0) printf("%d wwww\n", gvar.player[0].enti.y+8);\r
76         //else printf("\ngvar.player[0].enti.y: %d\n", gvar.player[0].enti.y);\r
77 //printf("gvar.video.p=%u ", gvar.video.p);\r
78 //not used now  printf("temporary gvar.player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n");\r
79 //not used now  printf("temporary gvar.player sprite 1: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=44606385\n");\r
80 //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
81 //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
82 //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
83 //printf("pageflipflop=%u", pageflipflop);\r
84 //printf("&global_temp_status_text = %Fp\n", &global_temp_status_text);\r
85 //printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx);    printf("%d\n", gvar.video.page[0].tilemidposscreeny);\r
86 //printf("      aniframe=%u", gvar.player[0].enti.persist_aniframe);\r
87 //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
88 //      printf("page[0]dxy: %dx%d", gvar.video.page[0].dx, gvar.video.page[0].dy);\r
89 #define SCROLLEXITMESG \\r
90         printf("size of mmblocktype: %u ", sizeof(mmblocktype));\\r
91         printf("\n\n");\\r
92         printf("player vars:\n");\\r
93         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
94         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
95                 printf("        pdir: %u\n", gvar.player[0].pdir); printf("     delay=%u", gvar.player[0].enti.spri.delay);\\r
96 printf("\n\n");\\r
97         VL_PrintmodexmemInfo(&gvar.video);\\r
98 \\r
99         printf("gvar.video:\n");\\r
100         printf(" r=%u ", gvar.video.dorender);\\r
101         printf("bgps=%u ", gvar.video.vga_state.bgps);\\r
102 printf("\n\n");\r
103 \r
104 //      printf("dbg_delayanimation=%u ", dbg_delayanimation);\r
105 /*\r
106         if(IN_KeyDown(sc_F11)){ pagedelayrendermap=!pagedelayrendermap;         IN_UserInput(1, &gvar); }\r
107         if(IN_KeyDown(sc_F10)){ gvar.kurokku.fpscap=!gvar.kurokku.fpscap;               IN_UserInput(1, &gvar); }\r
108         if(IN_KeyDown(sc_F9)){ pagenorendermap=!pagenorendermap;                                IN_UserInput(1, &gvar); }\r
109         if(IN_KeyDown(sc_F8)){ gvar.video.vga_state.bgps=!gvar.video.vga_state.bgps;                                    IN_UserInput(1, &gvar); }\r
110         if(IN_KeyDown(sc_T)){ gvar.video.vga_state.rss=!gvar.video.vga_state.rss;                                               IN_UserInput(1, &gvar); }\r
111 */\r
112 \r
113 extern char global_temp_status_text[512];\r
114 extern char global_temp_status_text2[512];\r
115 \r
116 void initMap(map_t *map);\r
117 void ZC_walk(global_game_variables_t *gvar, word pn);\r
118 void ZC_panPageManual(map_view_t *pip, player_t *player, word pn);\r
119 void ZC_MVSetup(map_view_t *pip, map_t *map, global_game_variables_t *gv);\r
120 void ZC_MVInit(map_view_t *pip, int tx, int ty);\r
121 //void ZC_ShowMV(map_view_t *moo, boolean vsync, boolean sr);\r
122 void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid);\r
123 void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid);\r
124 void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid);\r
125 void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid);\r
126 void ZC_mapScroll(map_view_t *mv, player_t *player, word pn);\r
127 void ZC_PlayerXYpos(int x, int y, player_t *player, map_view_t *pip, boolean defaultsw);\r
128 sword chkmap(map_t *map, word q);\r
129 void mapGoTo(map_view_t *mv, int tx, int ty);\r
130 void ZC_mapinitMV(map_view_t *mv, int tx, int ty);\r
131 void ZC_mapredraw(map_view_t *mv, int tx, int ty);\r
132 void near mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y);\r
133 void near mapDrawRow(map_view_t *mv, int tx, int ty, word y, player_t *player, word poopoffset);\r
134 void near mapDrawCol(map_view_t *mv, int tx, int ty, word x, player_t *player, word poopoffset);\r
135 void mapDrawWRow(map_view_t *mv, int tx, int ty, word y);\r
136 void mapDrawWCol(map_view_t *mv, int tx, int ty, word x);\r
137 inline void near ScrollRight(map_view_t *mv, player_t *pl, word id, word plid)\r
138 {\r
139         /* increment the pixel position and update the page */\r
140         mv[id].page->dx += pl[plid].enti.spt;\r
141 \r
142         /* check to see if this changes the tile */\r
143         if(mv[id].page->dx >= mv[id].dxThresh )\r
144         {\r
145                 /* go forward one tile */\r
146                 if(id==0) mv[id].tx++;\r
147                 /* Snap the origin forward */\r
148                 mv[id].page->data += 4;\r
149 \r
150                 mv[id].page->dx = mv[id].map->tiles->tileWidth;\r
151         }\r
152 }\r
153 \r
154 inline void near ScrollLeft(map_view_t *mv, player_t *pl, word id, word plid)\r
155 {\r
156         /* decrement the pixel position and update the page */\r
157         mv[id].page->dx -= pl[plid].enti.spt;\r
158 \r
159         /* check to see if this changes the tile */\r
160         if(mv[id].page->dx == 0)\r
161         {\r
162                 /* go backward one tile */\r
163                 if(id==0) mv[id].tx--;\r
164                 /* Snap the origin backward */\r
165                 mv[id].page->data -= 4;\r
166 \r
167                 mv[id].page->dx = mv[id].map->tiles->tileWidth;\r
168         }\r
169 }\r
170 \r
171 inline void near ScrollUp(map_view_t *mv, player_t *pl, word id, word plid)\r
172 {\r
173         /* decrement the pixel position and update the page */\r
174         mv[id].page->dy -= pl[plid].enti.spt;\r
175 \r
176         /* check to see if this changes the tile */\r
177         if(mv[id].page->dy == 0 )\r
178         {\r
179                 /* go up one tile */\r
180                 if(id==0) mv[id].ty--;\r
181                 /* Snap the origin upward */\r
182                 mv[id].page->data -= mv[id].page->pi;\r
183 \r
184                 mv[id].page->dy = mv[id].map->tiles->tileHeight;\r
185         }\r
186 }\r
187 \r
188 inline void near ScrollDown(map_view_t *mv, player_t *pl, word id, word plid)\r
189 {\r
190         /* increment the pixel position and update the page */\r
191         mv[id].page->dy += pl[plid].enti.spt;\r
192 \r
193         /* check to see if this changes the tile */\r
194         if(mv[id].page->dy >= mv[id].dyThresh )\r
195         {\r
196                 /* go down one tile */\r
197                 if(id==0) mv[id].ty++;\r
198                 /* Snap the origin downward */\r
199                 mv[id].page->data += mv[id].page->pi;\r
200 \r
201                 mv[id].page->dy = mv[id].map->tiles->tileHeight;\r
202         }\r
203 }\r
204 \r
205 //void qclean();\r
206 //sync\r
207 void shinku(global_game_variables_t *gv);\r
208 //animate the sprite\r
209 void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn);\r
210 \r
211 // Move an entity around. Should actually be in 16_entity\r
212 boolean ZC_walk2(entity_t *ent, map_view_t *map_v);\r
213 \r
214 // Move gvar.player around and call map scrolling if required/possible\r
215 void walk_player(player_t *player, map_view_t *map_v);\r
216 \r
217 // Scroll map in one direction (assumed from gvar.player's movement)\r
218 void mapScroll(map_view_t *mv, player_t *player);\r
219 \r
220 void ZC_GirdChk (global_game_variables_t *gvar, player_t *player);\r
221 \r
222 #endif /*__SCROLL16_H_*/\r