ScummVM API documentation
screen.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 NUVIE_SCREEN_SCREEN_H
23#define NUVIE_SCREEN_SCREEN_H
24
25#include "common/str.h"
26#include "ultima/nuvie/core/game.h"
27#include "ultima/nuvie/screen/surface.h"
28#include "graphics/screen.h"
29
30namespace Ultima {
31namespace Nuvie {
32
33class Configuration;
34
35enum LightingStyle {
36 LightingNone,
37 LightingSmooth,
38 LightingOriginal
39};
40
41class Screen {
42private:
43 const Configuration *config;
44 Graphics::Screen *_rawSurface;
45 RenderSurface *_renderSurface;
46
47 bool is_no_darkness;
48 bool non_square_pixels;
49
50 uint16 width;
51 uint16 height;
52
53 Common::Rect shading_rect;
54 uint8 *shading_data;
55 uint8 *shading_globe[6];
56 uint8 shading_ambient;
57 uint8 *shading_tile[4];
58
59public:
60 Screen(const Configuration *cfg);
61 ~Screen();
62
63 bool init();
64
65 bool is_fullscreen() const;
66 bool is_non_square_pixels() const {
67 return non_square_pixels;
68 }
69 bool toggle_darkness_cheat();
70 bool toggle_fullscreen();
71 bool set_fullscreen(bool value);
72 bool set_palette(const uint8 *palette);
73 bool set_palette_entry(uint8 idx, uint8 r, uint8 g, uint8 b);
74 bool rotate_palette(uint8 pos, uint8 length);
75 bool clear(sint16 x, sint16 y, sint16 w, sint16 h, Common::Rect *clip_rect = nullptr);
76 Graphics::ManagedSurface *create_sdl_surface_from(const byte *src_buf, uint16 src_bpp, uint16 src_w, uint16 src_h, uint16 src_pitch);
77 Graphics::ManagedSurface *create_sdl_surface_8(const byte *src_buf, uint16 src_w, uint16 src_h);
78 Graphics::ManagedSurface *get_sdl_surface();
79 uint16 get_width() const {
80 return width;
81 }
82 uint16 get_height() const {
83 return height;
84 }
85
86 bool fill(uint8 colour_num, uint16 x, uint16 y, sint16 w, sint16 h);
87 void fade(uint16 dest_x, uint16 dest_y, uint16 src_w, uint16 src_h, uint8 opacity, uint8 fade_bg_color = 0);
88 void stipple_8bit(uint8 color_num);
89 void stipple_8bit(uint8 color_num, uint16 x, uint16 y, uint16 w, uint16 h);
90 void put_pixel(uint8 colour_num, uint16 x, uint16 y);
91
92 bool blit(int32 dest_x, int32 dest_y, const byte *src_buf, uint16 src_bpp, uint16 src_w, uint16 src_h, uint16 src_pitch, bool trans = false, const Common::Rect *clip_rect = nullptr, uint8 opacity = 255);
93 void blitbitmap(uint16 dest_x, uint16 dest_y, const byte *src_buf, uint16 src_w, uint16 src_h, uint8 fg_color, uint8 bg_color);
94
95 void buildalphamap8();
96 void clearalphamap8(uint16 x, uint16 y, uint16 w, uint16 h, uint8 opacity, bool party_light_source);
97 void drawalphamap8globe(sint16 x, sint16 y, uint16 radius);
98 void blitalphamap8(sint16 x, sint16 y, Common::Rect *clip_rect);
99
100 LightingStyle get_lighting_style() const {
101 return lighting_style;
102 }
103 LightingStyle get_old_lighting_style() const {
104 return old_lighting_style; // return the lighting_style before cheats applied
105 }
106
107 uint8 get_ambient() const {
108 return shading_ambient;
109 }
110 void set_ambient(uint8 ambient) {
111 shading_ambient = ambient;
112 }
113
114 void update();
115 void update(int x, int y, uint16 w, uint16 h);
116 void performUpdate();
117
118 byte *copy_area(const Common::Rect *area = nullptr, byte *buf = nullptr);
119 byte *copy_area(const Common::Rect *area, uint16 down_scale);
120
121 void restore_area(byte *pixels, const Common::Rect *area = nullptr, byte *target = nullptr, const Common::Rect *target_area = nullptr, bool free_src = true);
122
123 void draw_line(int sx, int sy, int ex, int ey, uint8 color);
124
125 void get_mouse_location(int *x, int *y) const;
126
127 void set_non_square_pixels(bool value);
128
129protected:
130 LightingStyle lighting_style, old_lighting_style;
131 bool fill16(uint8 colour_num, uint16 x, uint16 y, sint16 w, sint16 h);
132
133 bool fill32(uint8 colour_num, uint16 x, uint16 y, sint16 w, sint16 h);
134
135 void fade16(uint16 dest_x, uint16 dest_y, uint16 src_w, uint16 src_h, uint8 opacity, uint8 fade_bg_color);
136 void fade32(uint16 dest_x, uint16 dest_y, uint16 src_w, uint16 src_h, uint8 opacity, uint8 fade_bg_color);
137
138 inline uint16 blendpixel16(uint16 p, uint16 p1, uint8 opacity);
139 inline uint32 blendpixel32(uint32 p, uint32 p1, uint8 opacity);
140
141 inline bool blit16(uint16 dest_x, uint16 dest_y, const byte *src_buf, uint16 src_bpp, uint16 src_w, uint16 src_h, uint16 src_pitch, bool trans);
142 inline bool blit16WithOpacity(uint16 dest_x, uint16 dest_y, const byte *src_buf, uint16 src_bpp, uint16 src_w, uint16 src_h, uint16 src_pitch, bool trans, uint8 opacity);
143
144 inline bool blit32(uint16 dest_x, uint16 dest_y, const byte *src_buf, uint16 src_bpp, uint16 src_w, uint16 src_h, uint16 src_pitch, bool trans);
145 inline bool blit32WithOpacity(uint16 dest_x, uint16 dest_y, const byte *src_buf, uint16 src_bpp, uint16 src_w, uint16 src_h, uint16 src_pitch, bool trans, uint8 opacity);
146
147 inline void blitbitmap16(uint16 dest_x, uint16 dest_y, const byte *src_buf, uint16 src_w, uint16 src_h, uint8 fg_color, uint8 bg_color);
148
149 inline void blitbitmap32(uint16 dest_x, uint16 dest_y, const byte *src_buf, uint16 src_w, uint16 src_h, uint8 fg_color, uint8 bg_color);
150
151 byte *copy_area16(const Common::Rect *area, uint16 down_scale);
152 byte *copy_area32(const Common::Rect *area, uint16 down_scale);
153
154 byte *copy_area16(const Common::Rect *area, byte *buf);
155 byte *copy_area32(const Common::Rect *area, byte *buf);
156 void restore_area16(byte *pixels, const Common::Rect *area, byte *target = nullptr, const Common::Rect *target_area = nullptr, bool free_src = true);
157 void restore_area32(byte *pixels, const Common::Rect *area, byte *target = nullptr, const Common::Rect *target_area = nullptr, bool free_src = true);
158
159 void set_screen_mode();
160};
161
162} // End of namespace Nuvie
163} // End of namespace Ultima
164
165#endif
Definition: managed_surface.h:51
Definition: screen.h:47
Definition: configuration.h:60
Definition: surface.h:32
Definition: screen.h:41
Definition: rect.h:536