1 /*
2 
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 #ifndef __AMAP_H
20 #define __AMAP_H
21 
22 // header for the real infernal automap
23 
24 // defines
25 #define AMAP_PURE_MODE 0x0000
26 #define AMAP_INT_WALLS 0x0001
27 #define AMAP_SHOW_CRIT 0x0002
28 #define AMAP_SHOW_ROB  0x0004
29 #define AMAP_SHOW_HAZ  0x0008
30 #define AMAP_SHOW_FLR  0x0010
31 #define AMAP_SHOW_MSG  0x0020
32 #define AMAP_SHOW_HGT  0x0040
33 #define AMAP_TRACK_OBJ 0x0080
34 #define AMAP_SHOW_SEC  0x0100
35 #define AMAP_FULL_MSG  0x0200
36 #define AMAP_SHOW_ALL  0x0400
37 #define AMAP_SHOW_SENS 0x0800
38 
39 #define AMAP_AVAIL_ALWAYS (AMAP_SHOW_SENS | AMAP_SHOW_FLR | AMAP_FULL_MSG)
40 
41 #define AMAP_SET       1
42 #define AMAP_UNSET     0
43 #define AMAP_TOGGLE   -1
44 
45 #define AMAP_PAN_N     1
46 #define AMAP_PAN_E     2
47 #define AMAP_PAN_S     3
48 #define AMAP_PAN_W     4
49 #define AMAP_DEF_DST   0x40000
50 
51 #define AMAP_MAX_ZOOM  6
52 #define AMAP_MIN_ZOOM  1
53 
54 #define AMAP_OFF_MAP   0
55 #define AMAP_HAVE_NOTE 1
56 #define AMAP_NO_NOTE   2
57 
58 // really should live in the player structure....
59 typedef struct {
60     uchar init;
61     uchar zoom;
62     int xf, yf;
63     ushort lw, lh;
64     ushort obj_to_follow, sensor_obj;
65     ushort note_obj;
66     ushort flags;
67     ushort avail_flags;
68     uchar version_id;
69     ushort sensor_rad; // in obj coords
70 } curAMap;
71 
72 // prototypes
73 uchar amap_kb_callback(curAMap *amptr, int code);
74 void amap_draw(curAMap *amptr, int expose);
75 void amap_version_set(int id, int new_ver);
76 void automap_init(int version, int id);
77 void amap_invalidate(int id);
78 uchar amap_flags(curAMap *amptr, int flags, int set);                  // set -1 to toggle
79 uchar amap_zoom(curAMap *amptr, uchar set, int zoom_delta);
80 void amap_pan(curAMap *amptr, int dir, int *dist);
81 uchar amap_get_note(curAMap *amptr, char *buf);
82 void amap_settings_copy(curAMap *from, curAMap *to);
83 
84 // this is a mess
85 // it modifies x and y to be map location of click
86 // returns null if off map, (void*)mapelemptr if within map
87 // sets amptr->note_obj to the note if found, else OBJ_NULL
88 void *amap_deal_with_map_click(curAMap *amptr, int *x, int *y);
89 
90 // strings
91 void amap_str_init(void);
92 char *amap_str_next(void);
93 void amap_str_grab(char *str);
94 int amap_str_deref(char *str);
95 char *amap_str_reref(int offs);
96 void amap_str_delete(char *toast_str);
97 void amap_str_startup(int magic_num);
98 
99 #define MFD_FULLSCR_MAP 2
100 #define NUM_O_AMAP MFD_FULLSCR_MAP + 1
101 
102 // globals
103 // for now
104 
105 #define oAMap(mid) (&(level_gamedata.auto_maps[mid]))
106 //#define oAMap(mid) (auto_maps[mid])
107 
108 #define amap_reset()                     \
109     do {                                 \
110         int i;                           \
111         for (i = 0; i < NUM_O_AMAP; i++) \
112             amap_invalidate(i);          \
113     } while (0)
114 
115 #define amap_note_value(objid)  (objTraps[objs[objid].specID].p4)
116 #define amap_note_string(objid) (amap_str_reref(amap_note_value(objid)))
117 
118 #define AMAP_STRING_SIZE 2048
119 
120 #endif
121