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 // Generic fizzle effect.
27 //
28
29
30 #include "bstone_generic_fizzle_fx.h"
31 #include "3d_def.h"
32 #include "id_vl.h"
33
34
35 namespace bstone
36 {
37
38
39 class GenericFizzleFX::Impl
40 {
41 public:
42 uint8_t plot_color_;
43 bool is_transparent_;
44 int y_offset_;
45 int height_;
46 VgaBuffer old_ui_;
47 UiMaskBuffer old_ui_mask_;
48
Impl()49 Impl() :
50 plot_color_(),
51 is_transparent_(),
52 y_offset_(),
53 height_(),
54 old_ui_(),
55 old_ui_mask_()
56 {
57 }
58 }; // Impl
59
60
GenericFizzleFX(uint8_t plot_color,bool is_transparent)61 GenericFizzleFX::GenericFizzleFX(
62 uint8_t plot_color,
63 bool is_transparent) :
64 impl_(new Impl())
65 {
66 impl_->plot_color_ = plot_color;
67 impl_->is_transparent_ = is_transparent;
68 }
69
~GenericFizzleFX()70 GenericFizzleFX::~GenericFizzleFX()
71 {
72 uninitialize();
73 }
74
initialize()75 void GenericFizzleFX::initialize()
76 {
77 impl_->y_offset_ = ::ref_view_top;
78 impl_->height_ = ::ref_view_height;
79
80 if (!impl_->is_transparent_)
81 {
82 ::vid_export_ui(impl_->old_ui_);
83 ::vid_export_ui_mask(impl_->old_ui_mask_);
84
85 ::VL_Bar(
86 0,
87 impl_->y_offset_,
88 ::vga_ref_width,
89 impl_->height_,
90 impl_->plot_color_,
91 false);
92 }
93 }
94
uninitialize()95 void GenericFizzleFX::uninitialize()
96 {
97 }
98
is_abortable() const99 bool GenericFizzleFX::is_abortable() const
100 {
101 return false;
102 }
103
get_frame_count() const104 int GenericFizzleFX::get_frame_count() const
105 {
106 return 70;
107 }
108
get_y() const109 int GenericFizzleFX::get_y() const
110 {
111 return impl_->y_offset_;
112 }
113
get_height() const114 int GenericFizzleFX::get_height() const
115 {
116 return impl_->height_;
117 }
118
plot(int x,int y)119 void GenericFizzleFX::plot(
120 int x,
121 int y)
122 {
123 if (impl_->is_transparent_)
124 {
125 ::VL_Plot(
126 x,
127 y,
128 impl_->plot_color_,
129 !impl_->is_transparent_);
130 }
131 else
132 {
133 const auto index = (y * ::vga_ref_width) + x;
134
135 ::VL_Plot(
136 x,
137 y,
138 impl_->old_ui_[index],
139 !impl_->old_ui_mask_[index]);
140 }
141 }
142
skip_to_the_end()143 void GenericFizzleFX::skip_to_the_end()
144 {
145 if (impl_->is_transparent_)
146 {
147 ::VL_Bar(
148 0,
149 get_y(),
150 ::vga_ref_width,
151 get_height(),
152 impl_->plot_color_,
153 !impl_->is_transparent_);
154 }
155 else
156 {
157 ::vid_import_ui(impl_->old_ui_);
158 ::vid_import_ui_mask(impl_->old_ui_mask_);
159 }
160 }
161
162
163 } // bstone
164