1 /* 2 BStone: A Source port of 3 Blake Stone: Aliens of Gold and Blake Stone: Planet Strike 4 5 Copyright (c) 1992-2013 Apogee Entertainment, LLC 6 Copyright (c) 2013-2015 Boris I. Bendovsky (bibendovsky@hotmail.com) 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the 20 Free Software Foundation, Inc., 21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 */ 23 24 25 #ifndef BSTONE_JM_TP_INCLUDED 26 #define BSTONE_JM_TP_INCLUDED 27 28 29 #include <cstdint> 30 31 32 // ------------------------------------------------------------------------- 33 // defines 34 // ------------------------------------------------------------------------- 35 36 #define PI_MAX_NUM_DISP_STRS 1 // Num display str ptrs allocated for text presenter 37 38 #define TP_CASE_SENSITIVE // ctrl codes are case sensitive 39 40 #define TP_640x200 0 // is presenter in 640 x 200 mode? 41 42 #define TP_RETURN_CHAR '\r' 43 #define TP_CONTROL_CHAR '^' 44 45 #define TP_CURSOR_SAVES 8 // MAX different points to save 46 47 #define TP_CNVT_CODE(c1, c2) ((c1) | (c2 << 8)) 48 49 #define TP_MAX_ANIMS 10 50 #define TP_MAX_PAGES 41 51 52 #define TP_MARGIN 1 // distance between xl/xh/yl/yh points and text 53 54 #define is_shadowed ((flags & fl_shadowtext) == fl_shadowtext) 55 #define ch_width(ch) (font->width[static_cast<int>(ch)]) // +((flags & fl_shadowtext) == fl_shadowtext)) 56 #define font_height (font->height) // +((flags & fl_shadowtext) == fl_shadowtext)) 57 #define TP_INIT_DISPLAY_STR(num, str_ptr) { if ((num) < PI_MAX_NUM_DISP_STRS) { \ 58 piStringTable[(num)] = (str_ptr); } \ 59 else { \ 60 TP_ERROR(TP_DISPLAY_STR_NUM_BAD); } } 61 62 63 // 64 // global static flags 65 // 66 67 #define fl_center 0x0001 68 #define fl_uncachefont 0x0002 69 #define fl_boxshape 0x0004 70 #define fl_shadowtext 0x0008 71 #define fl_presenting 0x0010 72 #define fl_startofline 0x0020 73 #define fl_upreleased 0x0040 74 #define fl_dnreleased 0x0080 75 #define fl_pagemanager 0x0100 76 #define fl_hidecursor 0x0200 77 #define fl_shadowpic 0x0400 78 #define fl_clearscback 0x0800 79 80 81 // 82 // PresenterInfo structure flags 83 // 84 85 #define TPF_CACHED_SCRIPT 0x0001 86 #define TPF_CACHE_NO_GFX 0x0002 87 #define TPF_CONTINUE 0x0004 88 #define TPF_USE_CURRENT 0x0008 89 #define TPF_SHOW_CURSOR 0x0010 90 #define TPF_SCROLL_REGION 0x0020 91 #define TPF_SHOW_PAGES 0x0040 92 #define TPF_TERM_SOUND 0x0080 93 #define TPF_ABORTABLE 0x0100 94 95 96 // ------------------------------------------------------------------------- 97 // typedefs 98 // ------------------------------------------------------------------------- 99 struct PresenterInfo { 100 uint16_t flags; 101 uint16_t gflags; 102 const char* script[TP_MAX_PAGES]; 103 void* scriptstart; 104 int8_t numpages; 105 int8_t pagenum; 106 uint16_t xl; 107 uint16_t yl; 108 uint16_t xh; 109 uint16_t yh; 110 int8_t fontnumber; 111 uint8_t bgcolor; 112 uint8_t ltcolor; 113 uint8_t dkcolor; 114 uint8_t shcolor; 115 uint16_t cur_x; 116 uint16_t cur_y; 117 int8_t print_delay; 118 uint8_t highlight_color; 119 uint8_t fontcolor; 120 int16_t id_cache; 121 char* infoline; 122 int custom_line_height; 123 }; // PresenterInfo; 124 125 enum tpCacheType { 126 ct_scaled, 127 ct_chunk, 128 ct_marks, 129 ct_music 130 }; // tpCacheType 131 132 enum pisType { 133 pis_pic, 134 pis_sprite, 135 pis_scaled, 136 pis_scwall, 137 pis_latchpic 138 139 #if TP_640x200 140 , 141 pis_pic2x, 142 pis_sprite2x 143 #endif 144 }; // pisType; 145 146 struct piShapeInfo { 147 int16_t shapenum; 148 pisType shapetype; 149 }; // piShapeInfo 150 151 enum piaType { 152 pia_grabscript, 153 pia_shapetable 154 }; // piaType; 155 156 enum pidType { 157 pid_cycle, 158 pid_rebound 159 }; // pidType 160 161 struct piAnimInfo { 162 int16_t baseshape; 163 int8_t frame; 164 int8_t maxframes; 165 int16_t delay; 166 int16_t maxdelay; 167 piaType animtype; 168 pidType dirtype; 169 int16_t x, y; 170 int8_t diradd; 171 }; // piAnimInfo 172 173 // ------------------------------------------------------------------------- 174 // variable externs 175 // ------------------------------------------------------------------------- 176 using PiShapeInfos = std::vector<piShapeInfo>; 177 using PiAnimationInfos = std::vector<piAnimInfo>; 178 179 extern PiShapeInfos piShapeTable; 180 extern PiAnimationInfos piAnimTable; 181 extern piAnimInfo piAnimList[TP_MAX_ANIMS]; 182 extern char* piStringTable[PI_MAX_NUM_DISP_STRS]; 183 extern ScanCode TPscan; 184 185 // ------------------------------------------------------------------------- 186 // Function prototypes 187 // ------------------------------------------------------------------------- 188 void TP_Presenter( 189 PresenterInfo* pi); 190 void TP_WrapText(); 191 void TP_HandleCodes(); 192 int16_t TP_DrawShape( 193 int16_t x, 194 int16_t y, 195 int16_t shapenum, 196 pisType type); 197 uint16_t TP_VALUE( 198 const char* ptr, 199 int8_t num_nybbles); 200 int32_t TP_LoadScript( 201 const char* filename, 202 PresenterInfo* pi, 203 uint16_t id_cache); 204 void TP_FreeScript( 205 PresenterInfo* pi, 206 uint16_t id_cache); 207 void TP_InitScript( 208 PresenterInfo* pi); 209 void TP_AnimatePage( 210 int16_t numanims); 211 int16_t TP_BoxAroundShape( 212 int16_t x1, 213 int16_t y1, 214 uint16_t shapenum, 215 pisType shapetype); 216 void TP_JumpCursor(); 217 void TP_Print( 218 const char* str, 219 bool single_char); 220 bool TP_SlowPrint( 221 const char* str, 222 int8_t delay); 223 void TP_PurgeAllGfx(); 224 void TP_CachePage( 225 const char* script); 226 void TP_CacheIn( 227 tpCacheType type, 228 int16_t chunk); 229 void TP_ResetPagePointers(); 230 int16_t TP_LineCommented( 231 const char* s); 232 void TP_PrintPageNumber(); 233 234 235 #endif // BSTONE_JM_TP_INCLUDED 236