]> 4ch.mooo.com Git - 16.git/blob - src/lib/zcroll16.h
16_pm is now in exmmtest.exe and major studying of how it behaves is needed to functi...
[16.git] / src / lib / zcroll16.h
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
3  *
4  * This file is part of Project 16.
5  *
6  * Project 16 is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Project 16 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,
19  * Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22
23 #ifndef __ZCROLL16_H_
24 #define __ZCROLL16_H_
25
26 #include "src/lib/16_head.h"
27 //#include "src/lib/bakapee.h"
28 #include "src/lib/modex16.h"
29 //#include "src/lib/16_in.h"
30 #include "src/lib/bitmap.h"
31 #include "src/lib/16_map.h" //map is loaded here www
32 #include "src/lib/16_timer.h"
33 #include "src/lib/wcpu/wcpu.h"
34
35 #include <hw/cpu/cpu.h>
36 #include <hw/dos/dos.h>
37 #include <hw/vga/vga.h>
38 #include <hw/vga/vrl.h>
39
40 #define SPRITE
41 //#define TILERENDER
42
43 //modexDrawSpritePBufRegion
44 //modexDrawBmpPBufRegion
45 #define PBUFSFUN                modexDrawSpriteRegion
46 #define PBUFBFUN                modexDrawBmpRegion
47 #define PLAYERBMPDATA   player->data
48
49 typedef struct {
50         map_t *map;
51         page_t *page;
52         int tx; //appears to be the top left tile position on the viewable screen map
53         int ty; //appears to be the top left tile position on the viewable screen map
54         word dxThresh; //Threshold for physical tile switch
55         word dyThresh; //Threshold for physical tile switch
56         video_t *video; //pointer to game variables of the video
57         pan_t *pan;             //pointer the the page panning debug system
58 } map_view_t;
59
60 #define MAPW    40
61 #define MAPH    30
62
63 enum direction {STOP, UP, DOWN, LEFT, RIGHT};
64 typedef struct {
65         word id;        /* the Identification number of the page~ For layering~ */
66         byte far* data; /* the data for the page */
67         word sw;                /* screen width */
68         word sh;                /* screen heigth */
69         word tw;                /* screen width in tiles */
70         word th;                /* screen height in tiles */
71         word width;             /* virtual width of the page */
72         word height;    /* virtual height of the page */
73         word tilesw;            /* virtual screen width in tiles */
74         word tilesh;            /* virtual screen height in tiles */
75         sword tilemidposscreenx;        /* middle tile position */
76         sword tilemidposscreeny;        /* middle tile position */
77         sword tileplayerposscreenx;     /* player position on screen */
78         sword tileplayerposscreeny;     /* player position on screen */
79         word stridew;                   /*width/4*/
80         word pagesize;                  /* page size */
81         word pi;                                /* incremention page by this much to preserve location */
82         word delta;                     // How much should we shift the page for smooth scrolling
83         direction d;                    // Direction we should shift the page
84 } page_t;
85 extern boolean pageflipflop, pageploop;
86 extern unsigned char shinku_fps_indicator_page;
87
88 /* Map is presumed to:
89  * 1. Have all the required layers and tilesets within itself
90  * 2. Have a 'fence' around accessible blocks to simplify boundary logic
91  * 3. Have a persistent map and tile size among the layers
92  * Map view is presumed to:
93  * 1. Calculate, store and update a panning info, which includes, but not limited to:
94  *      combined layer information, actual map representation (reflecting real state of the game),
95  *      pixel shift for smooth tile scrolling.
96  * 2. Provide ways to draw a visible part of map. For simplicity with smooth scrolling, 
97  *      additional row/column is always drawn at the each side of the map. This implies that 'fence'
98  *      should have a sprite too. Map is drawn left-to-right, top-to-bottom.
99  */
100
101 // Move an entity around. Should actually be in 16_entity
102 boolean walk(entity_t *ent, map_view_t *map_v);
103
104 // Move player around and call map scrolling if required/possible
105 void walk_player(player_t *player, map_view_t *map_v);
106
107 // Scroll map in one direction (assumed from player's movement)
108 void near mapScroll(map_view_t *mv, player_t *player);
109 sword chkmap(map_t *map, word q);
110 void mapGoTo(map_view_t *mv, int tx, int ty);
111 void near mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y);
112 //void qclean();
113 void shinku(global_game_variables_t *gv);
114 void near animatePlayer(map_view_t *pip, player_t *player, sword scrollswitch);
115
116 #endif /*__ZCROLL16_H_*/