ScummVM API documentation
title.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef ULTIMA3_VIEWS_TITLE_H
23#define ULTIMA3_VIEWS_TITLE_H
24
25#include "common/array.h"
26#include "graphics/managed_surface.h"
27#include "graphics/views/view.h"
28
29namespace Ultima {
30namespace Ultima3 {
31namespace Views {
32
33using namespace Graphics::Views;
34
39struct TitleBox {
40 int srcY, dstY, x, width, height;
41};
42
57class Title : public View {
58private:
59 // Prefixed to avoid colliding with the file-scope TitleBox constants of
60 // the same names (BOX2/BOX3/BOX5/BOX6) in title.cpp -- an unscoped
61 // enum's values are injected into the class's own scope
62 enum Phase {
63 PH_BOX1_SPARKLE, PH_BOX1_WAIT,
64 PH_BOX4_SPARKLE, PH_BOX4_WAIT,
65 PH_BOX5, PH_BOX5_WAIT,
66 PH_PIXEL_PATH, PH_PIXEL_PATH_WAIT,
67 PH_BOX6, PH_BOX6_WAIT,
68 PH_FLAG_ANIM, PH_FLAG_ANIM_WAIT,
69 PH_BOX2,
70 PH_SOUND_BURST,
71 PH_BOX3, PH_BOX3_WAIT,
72 PH_DRAIN
73 };
74
75 Phase _phase = PH_BOX1_SPARKLE;
76 bool _keyPending = false;
77 uint16 _prngState = 0x9DE3;
78 int _waitCounter = 0;
79
80 // Sparkle-box sub-state: 0-63 selects threshold (pass*4), 64 = the
81 // unconditional final full-detail pass
82 int _sparklePass = 0;
83
84 // How many frames the last pass of a sparkle takes, which is how long its buzz lasts
85 int _sparkleFrames = 1;
86
87 // drawAnimatedPixelPath (NAME.DAT) sub-state: byte offset of the next
88 // (length, row) pair
89 uint _pixelPathPos = 0;
90
91 // runBootFlagAnimation (ANIMATE.DAT) sub-state, mirroring si/bl/al
92 int _flagSi = 2;
93 int _flagBl = 0x2A;
94 int _flagAl = 0;
95 bool _flagAlActive = false;
96
99 Common::Array<byte> _nameData;
100 Common::Array<byte> _animateData;
101
102 void loadPic(Graphics::ManagedSurface &surf, const Common::String &filename);
103 void loadRaw(Common::Array<byte> &data, const Common::String &filename);
104
105 // Returns true if the picture is being shown any way other than the original CGA, which
106 // has the upgrade's changes to the title screen
107 bool isUpgraded() const;
108
109 // Makes the buzz for a pass of a sparkle and works out how long it takes
110 void playSparkle(const Common::Array<bool> &revealed);
111
112 // Reveals one word-column (8 px) of `box` per PRNG roll when sparkle is
113 // true (drawSparkleBox's ah=0FFh mode); a plain full copy otherwise
114 void drawBox(const TitleBox &box, bool sparkle, int threshold);
115
116 // One 92x16px flag-flutter frame (drawAnimationFrameRow), plus its
117 // 4px erase margins on each side
118 void drawFlagFrame(int bxParam, int axParam);
119 void drawEnhancedFlagFrame(int bxParam, int axParam);
120
121 // One step of the NAME.DAT signature reveal; returns false once the
122 // terminator is hit
123 bool stepPixelPath();
124
125 // One step of the flag animation's nested si/bl/al loop; returns false
126 // once fully finished
127 bool stepFlagAnimation();
128
129 // Advances _waitCounter by one tick; returns true once the wait is over
130 // (naturally, or because a key is already pending)
131 bool tickWait();
132
133 void playSoundBurst();
134 void showLogoScreen();
135
136public:
137 Title();
138 ~Title() override {}
139
140 bool msgFocus(const FocusMessage &msg) override;
141 bool msgUnfocus(const UnfocusMessage &msg) override;
142 void draw() override;
143 void timeout() override;
144
145 bool msgKeypress(const KeypressMessage &msg) override;
146 bool msgMouseDown(const MouseDownMessage &msg) override;
147 bool msgAction(const ActionMessage &msg) override;
148};
149
150} // namespace Views
151} // namespace Ultima3
152} // namespace Ultima
153
154#endif
Definition: str.h:59
Definition: managed_surface.h:51
Definition: view.h:41
Definition: title.h:57
Definition: messages.h:118
Definition: messages.h:42
Definition: messages.h:54
Definition: messages.h:76
Definition: messages.h:50
Definition: title.h:39