]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/scroll16.h
==== MAJOR CHANGES ARE BEING MADE!! WWWW ====
[16.git] / src / lib / scroll16.h
index 939361575e602a69993e4c3fd77680076b702cba..697018758d9eaa388ee316e88d6ee4a4171b3280 100755 (executable)
-/* Project 16 Source Code~
- * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
- *
- * 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/planar.h"
-#include "src/lib/mapread.h"
-#include "src/lib/timer.h"
-#include "src/lib/wcpu/wcpu.h"
-
-//#define SPRITE
-#define TILERENDER
-
-#define PBUFSFUN               modexDrawSpritePBufRegion
-#define PBUFBFUN               modexDrawBmpPBufRegion
-#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; //????
-} map_view_t;
-
-typedef struct
-{
-       map_view_t *mv;
-} map_view_db_t;
-
-//for null map!
-#define MAPW   40
-#define MAPH   30
-
-//map_t allocMap(int w, int h);
-//void initMap(map_t *map);
-void walk(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);
-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(map_view_t *pip, 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-2016 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/bitmap.h"\r
+#include "src/lib/16_map.h" //map is loaded here www\r
+#include "src/lib/16render.h"\r
+//#include "src/lib/16_map.h"  //new map stuff\r
+#include "src/lib/16_timer.h"\r
+#include "src/lib/wcpu/16_wcpu.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
+//extern void modexDrawSpriteRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);\r
+\r
+//modexDrawSpritePBufRegion\r
+//modexDrawBmpPBufRegion\r
+//#define PBUFSFUN             modexDrawSpriteRegion\r
+//#define PBUFBFUN             modexDrawBmpRegion\r
+\r
+#define PLAYERBMPDATAVAR       player[pn].data\r
+#define PLAYERBMPDATA          *PLAYERBMPDATAVAR\r
+#define PLAYERBMPDATAPTR       PLAYERBMPDATAVAR\r
+\r
+#define PCXBMPVAR      player[0].data\r
+#define PCXBMP         *PCXBMPVAR\r
+#define PCXBMPPTR      PCXBMPVAR\r
+\r
+typedef struct {\r
+       map_t *map;\r
+       page_t *page;\r
+       int tx; //appears to be the top left tile position on the viewable screen map\r
+       int ty; //appears to be the top left tile position on the viewable screen map\r
+       word dxThresh; //Threshold for physical tile switch\r
+       word dyThresh; //Threshold for physical tile switch\r
+       video_t *video; //pointer to game variables of the video\r
+       nibble *panp;   // pointer to video's pan page num\r
+//newer vars!\r
+       int dx, dy, delta, d;\r
+} map_view_t;\r
+/* Map is presumed to:\r
+ * 1. Have all the required layers and tilesets within itself\r
+ * 2. Have a 'fence' around accessible blocks to simplify boundary logic\r
+ * 3. Have a persistent map and tile size among the layers\r
+ * Map view is presumed to:\r
+ * 1. Calculate, store and update a panning info, which includes, but not limited to:\r
+ *     combined layer information, actual map representation (reflecting real state of the game),\r
+ *     pixel shift for smooth tile scrolling.\r
+ * 2. Provide ways to draw a visible part of map. For simplicity with smooth scrolling,\r
+ *     additional row/column is always drawn at the each side of the map. This implies that 'fence'\r
+ *     should have a sprite too. Map is drawn left-to-right, top-to-bottom.\r
+ */\r
+\r
+//for null map!\r
+#define MAPW   40\r
+#define MAPH   30\r
+\r
+       //if(player[0].enti.hp==0) printf("%d wwww\n", player[0].enti.y+8);\r
+       //else printf("\nplayer[0].enti.y: %d\n", player[0].enti.y);\r
+//     printf("palette offset: %d\n", paloffset/3);\r
+//++++ printf("Total used: %zu\n", oldfreemem-GetFreeSize());\r
+//++++ printf("Total free: %zu\n", GetFreeSize());\r
+//not used now printf("temporary player sprite 0: http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45556867\n");\r
+//not used now printf("temporary 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[0].map->width, mv[0].map->height, mv[0].map->data[0]);\r
+//printf("&global_temp_status_text = %Fp\n", &global_temp_status_text);\r
+#define SCROLLEXITMESG         printf("tx: %d  ", mv[0].tx);\\r
+       printf("ty: %d\n", mv[0].ty);\\r
+       printf("\n");\\r
+       printf("player vars:\n");\\r
+       printf("        x: %d", player[0].enti.x); printf("     y: %d\n", player[0].enti.y);\\r
+       \\r
+       printf("        tx: %d", player[0].enti.tx); printf("   ty: %d\n", player[0].enti.ty);\\r
+       printf("        triggx: %d", player[0].enti.triggerx); printf(" triggy: %d\n", player[0].enti.triggery);\\r
+       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);\\r
+               printf("        pdir=%d\n", player[0].pdir);\\r
+       printf("        tile data value at player trigger position: %d\n\n", mv[0].map->data[(player[0].enti.triggerx-1)+(map.width*(player[0].enti.triggery-1))]);\\r
+\\r
+       printf("Virtual Screen: %dx", gvar.video.page[0].width);        printf("%d      ", gvar.video.page[0].height);\\r
+       printf("Screen: %dx", gvar.video.page[0].sw);   printf("%d\n", gvar.video.page[0].sh);\\r
+       printf("virtual tile resolution: %dx", gvar.video.page[0].tilesw);      printf("%d      ", gvar.video.page[0].tilesh);\\r
+       printf("tile resolution: %dx", gvar.video.page[0].tw);  printf("%d\n", gvar.video.page[0].th);\\r
+       printf("middle tile position: %dx", gvar.video.page[0].tilemidposscreenx);      printf("%d\n", gvar.video.page[0].tilemidposscreeny);\\r
+       modexprintmeminfo(&gvar.video);\\r
+\\r
+       printf("gvar.video.p=%u ", gvar.video.p); printf("gvar.video.r=%u ", gvar.video.r);\\r
+       printf("pageflipflop=%u\n", pageflipflop);\\r
+       printf("\n");\r
+\r
+#define SHOWMVFUN ZC_ShowMV(&mv, 0, 0);\r
+#define PANKEYFUN \\r
+                       ZC_panPageManual(&mv, &player, 0); \\r
+                       if(IN_KeyDown(1+1) || IN_KeyDown(sc_Z)){ gvar.video.panp=0; SHOWMVFUN; } \\r
+                       if(IN_KeyDown(2+1) || IN_KeyDown(sc_X)){ gvar.video.panp=1; SHOWMVFUN; } \\r
+                       if(IN_KeyDown(3+1) || IN_KeyDown(sc_C)){ gvar.video.panp=2; SHOWMVFUN; if(IN_KeyDown(sc_C)) modexClearRegion(&gvar.video.page[2], 0, 0, gvar.video.page[2].sw, gvar.video.page[2].sh, 47); } \\r
+                       if(IN_KeyDown(4+1) || IN_KeyDown(sc_V)){ gvar.video.panp=3; SHOWMVFUN; if(IN_KeyDown(sc_V)) modexClearRegion(&gvar.video.page[3], 0, 0, gvar.video.page[3].sw, gvar.video.page[3].sh, 45); } \\r
+                       if(IN_KeyDown(25)){ modexpdump(mv[1].page); modexShowPage(&(gvar.video.page[1])); IN_UserInput(1,1); }\r
+\r
+extern boolean pageflipflop, pageploop;\r
+\r
+extern char global_temp_status_text[512];\r
+\r
+//map_t allocMap(int w, int h);\r
+//void initMap(map_t *map);\r
+void walk(map_view_t *pip, player_t *player, word pn);\r
+void ZC_walk(map_view_t *pip, player_t *player, 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 near ScrollRight(map_view_t *mv, player_t *player, word id, word plid);\r
+void near ScrollLeft(map_view_t *mv, player_t *player, word id, word plid);\r
+void near ScrollUp(map_view_t *mv, player_t *player, word id, word plid);\r
+void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid);\r
+void playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn);\r
+sword chkmap(map_t *map, word q);\r
+void mapGoTo(map_view_t *mv, int tx, int ty);\r
+void mapinitmapview(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
+//void qclean();\r
+void shinku(global_game_variables_t *gv);\r
+void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch);\r
+void near ZC_animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch);\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 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 player's movement)\r
+void near mapScroll(map_view_t *mv, player_t *player);\r
+\r
+#endif /*__SCROLL16_H_*/\r