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_ID_HEADS_INCLUDED
26 #define BSTONE_ID_HEADS_INCLUDED
27 
28 
29 #include <cassert>
30 #include <cctype>
31 #include <cstdint>
32 #include <cstdio>
33 #include <cstdlib>
34 #include <cstring>
35 
36 #include <algorithm>
37 #include <atomic>
38 #include <chrono>
39 #include <exception>
40 #include <functional>
41 #include <memory>
42 #include <type_traits>
43 #include <vector>
44 
45 #include "SDL.h"
46 
47 #include "bstone_binary_reader.h"
48 #include "bstone_binary_writer.h"
49 #include "bstone_crc32.h"
50 #include "bstone_endian.h"
51 #include "bstone_file_stream.h"
52 #include "bstone_format_string.h"
53 #include "bstone_log.h"
54 #include "bstone_memory_binary_reader.h"
55 #include "bstone_memory_stream.h"
56 #include "bstone_sha1.h"
57 #include "bstone_string_helper.h"
58 #include "bstone_cl_args.h"
59 
60 #include "audio.h"
61 #include "gfxv.h"
62 #include "id_pm.h"
63 #include "id_ca.h"
64 #include "id_vl.h"
65 #include "id_vh.h"
66 #include "id_in.h"
67 #include "id_sd.h"
68 #include "id_us.h"
69 #include "jm_tp.h"
70 #include "movie.h"
71 
72 
73 //
74 // replacing refresh manager with custom routines
75 //
76 
77 #define PORTTILESWIDE (20) // all drawing takes place inside a
78 #define PORTTILESHIGH (13) // non displayed port of this size
79 
80 #define UPDATEWIDE (PORTTILESWIDE)
81 #define UPDATEHIGH (PORTTILESHIGH)
82 
83 #define TickBase (70) // 70Hz per tick - used as a base for timer 0
84 #define MAXTICS (10)
85 
86 extern uint16_t mapwidth;
87 extern uint16_t mapheight;
88 extern uint16_t tics;
89 extern uint16_t realtics;
90 
91 extern uint8_t* updateptr;
92 extern uint16_t uwidthtable[UPDATEHIGH];
93 extern uint16_t blockstarts[UPDATEWIDE * UPDATEHIGH];
94 
95 extern uint8_t fontcolor;
96 extern uint8_t backcolor;
97 
SETFONTCOLOR(int foreground_color,int background_color)98 inline void SETFONTCOLOR(
99     int foreground_color,
100     int background_color)
101 {
102     ::fontcolor = static_cast<uint8_t>(foreground_color);
103     ::backcolor = static_cast<uint8_t>(background_color);
104 }
105 
106 
107 #include "3d_menu.h"
108 
109 
110 // BBi
111 using Clock = std::chrono::system_clock;
112 using TimePoint = Clock::time_point;
113 
114 
115 const int UPDATESIZE = UPDATEWIDE * UPDATEHIGH;
116 
117 extern uint8_t update[UPDATESIZE];
118 
119 
120 extern uint8_t* vga_memory;
121 extern bstone::ClArgs g_args;
122 extern uint8_t update[UPDATESIZE];
123 
124 
125 void pre_quit();
126 
127 void Quit();
128 
129 template<typename... TArgs>
Quit(const std::string & format,TArgs...args)130 void Quit(
131     const std::string& format,
132     TArgs... args)
133 {
134     ::pre_quit();
135 
136     if (!format.empty()) {
137         bstone::Log::write_critical(format, args...);
138     }
139 
140     ::exit(1);
141 }
142 
143 uint32_t sys_get_timer_ticks();
144 // BBi
145 
146 
147 #endif // BSTONE_ID_HEADS_INCLUDED
148