ScummVM API documentation
u6_misc.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_MISC_U6_MISC_H
23#define NUVIE_MISC_U6_MISC_H
24
25/*
26 * ultima/nuvie/misc/u6_misc.h
27 * Nuvie
28 *
29 * Created by Eric Fry on Sat Jun 14 2003.
30 * Copyright (c) 2003. All rights reserved.
31 *
32 */
33#include "common/str.h"
34#include "ultima/nuvie/core/nuvie_defs.h"
35#include "common/rect.h"
36#include "graphics/managed_surface.h"
37
38namespace Ultima {
39namespace Nuvie {
40
41class Configuration;
42
43typedef enum {
44 BLOCKED,
45 CAN_MOVE,
46 FORCE_MOVE
47} MovementStatus;
48
49Common::String config_get_game_key(const Configuration *config);
50const char *get_game_tag(int game_type);
51void config_get_path(const Configuration *config, const Common::String &filename, Common::Path &path);
52uint8 get_game_type(const char *string);
53nuvie_game_t get_game_type(const Configuration *config);
54void build_path(const Common::Path &path, const Common::String &filename, Common::Path &full_path);
55bool directory_exists(const Common::Path &directory);
56bool file_exists(const Common::Path &path);
57void print_b(DebugLevelType level, uint8 num);
58void print_b16(DebugLevelType level, uint16 num);
59void print_indent(DebugLevelType level, uint8 indent);
60void print_bool(DebugLevelType level, bool state, const char *yes = "true", const char *no = "false");
61void print_flags(DebugLevelType level, uint8 num, const char *f[8]);
62bool subtract_rect(const Common::Rect *rect1, const Common::Rect *rect2, Common::Rect *sub_rect);
63NuvieDir get_nuvie_dir_code(uint8 original_dir_code);
64sint8 get_original_dir_code(NuvieDir nuvie_dir_code);
65NuvieDir get_direction_code(sint16 rel_x, sint16 rel_y);
66NuvieDir get_reverse_direction(NuvieDir dir);
67void get_relative_dir(NuvieDir dir, sint16 *rel_x, sint16 *rel_y);
68const char *get_direction_name(NuvieDir dir);
69const char *get_direction_name(sint16 rel_x, sint16 rel_y);
70int str_bsearch(const char *const str[], int max, const char *value);
71
72/* Does line xy->x2y2 cross rect, to any extent?
73 */
74inline bool line_in_rect(uint16 x1, uint16 y1, uint16 x2, uint16 y2, const Common::Rect *rect) {
75 uint16 rx2 = rect->right, ry2 = rect->bottom;
76 return (((y1 >= rect->top && y1 <= ry2 && x1 <= rx2 && x2 >= rect->left)
77 || (x1 >= rect->left && x1 <= rx2 && y1 <= ry2 && y2 >= rect->top)));
78}
79
80
81/* Measure a timeslice for a single function-call. (last_time must be static)
82 * Returns fraction of a second between this_time and last_time.
83 */
84inline uint32 divide_time(uint32 this_time, uint32 &last_time, uint32 *passed_time = nullptr) {
85 uint32 ms_passed = (this_time - last_time) > 0 ? (this_time - last_time) : 1;
86 uint32 fraction = 1000 / ms_passed; // % of second
87 last_time = this_time;
88 if (passed_time)
89 *passed_time = ms_passed;
90 return (fraction);
91}
92
93int mkdir_recursive(const Common::Path &path, int mode);
94
95void draw_line_8bit(int sx, int sy, int ex, int ey, uint8 col, uint8 *pixels, uint16 w, uint16 h);
96
97bool string_i_compare(const Common::String &s1, const Common::String &s2);
98
99void *nuvie_realloc(void *ptr, size_t size);
100
101uint32 sdl_getpixel(const Graphics::ManagedSurface *surface, int x, int y);
102
103void scale_rect_8bit(const unsigned char *Source, unsigned char *Target, int SrcWidth, int SrcHeight, int TgtWidth, int TgtHeight);
104
105bool has_file_extension(const char *filename, const char *extension);
106
107bool has_fmtowns_support(const Configuration *config);
108
109uint16 wrap_signed_coord(sint16 coord, uint8 level);
110sint8 get_wrapped_rel_dir(sint16 p1, sint16 p2, uint8 level);
111
112Common::String encode_xml_entity(const Common::String &s);
113
114} // End of namespace Nuvie
115} // End of namespace Ultima
116
117#endif
Definition: path.h:52
Definition: str.h:59
Definition: managed_surface.h:51
Definition: rect.h:536