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 //
26 // Fizzle effect (base class).
27 //
28
29
30 #include "bstone_fizzle_fx.h"
31 #include "3d_def.h"
32 #include "id_in.h"
33 #include "id_vl.h"
34
35
36 void IN_StartAck();
37 bool IN_CheckAck();
38
39
40 namespace bstone
41 {
42
43
FizzleFX()44 FizzleFX::FizzleFX()
45 {
46 }
47
~FizzleFX()48 FizzleFX::~FizzleFX()
49 {
50 }
51
present()52 bool FizzleFX::present()
53 {
54 const auto y_offset = get_y();
55 const auto width = ::vga_ref_width;
56 const auto height = get_height();
57 const auto frame_count = get_frame_count();
58 const auto area = width * height;
59
60 auto rndval = 1;
61 const auto pixels_per_frame = area / frame_count;
62 auto remain_pixels = area % frame_count;
63 auto frame = 0;
64
65 ::IN_StartAck();
66
67 ::TimeCount = 0;
68 ::LastScan = ScanCode::sc_none;
69
70 auto is_finished = false;
71 auto is_aborted = false;
72 auto do_full_copy = false;
73
74 while (!is_finished)
75 {
76 if (is_abortable() && ::IN_CheckAck())
77 {
78 is_aborted = true;
79 do_full_copy = true;
80 }
81
82 if (!do_full_copy)
83 {
84 const auto pixel_count = pixels_per_frame + remain_pixels;
85
86 remain_pixels = 0;
87
88 for (auto p = 0; p < pixel_count; ++p)
89 {
90 auto x = (rndval >> 8) & 0xFFFF;
91 auto y = ((rndval & 0xFF) - 1) & 0xFF;
92
93 auto carry = ((rndval & 1) != 0);
94
95 rndval >>= 1;
96
97 if (carry)
98 {
99 rndval ^= 0x00012000;
100 }
101
102 if (x >= width || y >= height)
103 {
104 continue;
105 }
106
107 plot(
108 x,
109 y_offset + y);
110
111 if (rndval == 1)
112 {
113 do_full_copy = true;
114 }
115 }
116 }
117 else
118 {
119 is_finished = true;
120
121 skip_to_the_end();
122 }
123
124 ::VL_RefreshScreen();
125
126 ++frame;
127
128 ::CalcTics();
129 }
130
131 return is_aborted;
132 }
133
is_abortable() const134 bool FizzleFX::is_abortable() const
135 {
136 throw "Not implemented.";
137 }
138
get_frame_count() const139 int FizzleFX::get_frame_count() const
140 {
141 throw "Not implemented.";
142 }
143
get_y() const144 int FizzleFX::get_y() const
145 {
146 throw "Not implemented.";
147 }
148
get_height() const149 int FizzleFX::get_height() const
150 {
151 throw "Not implemented.";
152 }
153
plot(int x,int y)154 void FizzleFX::plot(
155 int x,
156 int y)
157 {
158 throw "Not implemented.";
159 }
160
skip_to_the_end()161 void FizzleFX::skip_to_the_end()
162 {
163 throw "Not implemented.";
164 }
165
166
167 } // bstone
168