File: OVGA.h

package info (click to toggle)
7kaa 2.15.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 134,980 kB
  • sloc: cpp: 137,722; ansic: 3,599; asm: 3,523; perl: 1,665; makefile: 1,185; sh: 185; pascal: 27
file content (137 lines) | stat: -rw-r--r-- 3,192 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
 * Seven Kingdoms: Ancient Adversaries
 *
 * Copyright 1997,1998 Enlight Software Ltd.
 * Copyright 2010,2015 Jesse Allen
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

//Filename    : OVGA.H
//Description : VGA management class (SDL version)

#ifndef __OVGA_H
#define __OVGA_H

#include <OVGABUF.h>
#include <COLOR.h>
#include <SDL.h>

//----------- define constants ----------//

#define VGA_WIDTH             800
#define VGA_HEIGHT            600
#define VGA_BPP                 8
#define VGA_PALETTE_SIZE      256

#define MAX_BRIGHTNESS_ADJUST_DEGREE 10

#define IF_LIGHT_BORDER_COLOR     V_WHITE
#define IF_DARK_BORDER_COLOR      V_BLACK
#define IF_UP_BRIGHTNESS_ADJUST   5
#define IF_DOWN_BRIGHTNESS_ADJUST 6

//-------- Define macro functions ---------//

#define get_bitmap_width(bitmapPtr)  (*(short*)bitmapPtr)
#define get_bitmap_height(bitmapPtr) (*((short*)bitmapPtr+1))

//-------- Define modes --------//

enum MouseInputMode
{
	MOUSE_INPUT_ABS,
	MOUSE_INPUT_REL,
	MOUSE_INPUT_REL_WARP,
};

enum WinGrab
{
	WINGRAB_OFF,
	WINGRAB_ON,
	WINGRAB_TOGGLE,
	WINGRAB_FORCE,
	WINGRAB_RESTORE,
};

//-------- Define class Vga ----------------//

class ColorTable;

class Vga
{
private:
	SDL_Window*    window;
	SDL_Renderer*  renderer;
	SDL_Texture*   texture;
	SDL_Surface*   target;
	SDL_Color      game_pal[VGA_PALETTE_SIZE];
	SDL_Color*     custom_pal;

	int win_grab_forced;
	int win_grab_user_mode;
	int bound_x1, bound_y1, bound_x2, bound_y2;
	int boundary_set;

public:
	ColorTable*    vga_color_table;
	unsigned char  gray_remap_table[VGA_PALETTE_SIZE];

	static VgaBuf* active_buf;
	static char    use_back_buf;
	static char    opaque_flag;

	MouseInputMode mouse_mode;

public:
	Vga();
	~Vga();

	int    init();
	void   deinit();

	char   is_inited()  { return window != NULL; }

	int    load_pal(const char* fileName);
	void   activate_pal(VgaBuf*);

	int    set_custom_palette(char*);
	void   free_custom_palette();
	void   adjust_brightness(int changeValue);

	void use_front() { use_back_buf=0; active_buf = &vga_front; }
	void use_back()  { use_back_buf=1; active_buf = &vga_back;  }

	void   handle_messages();
	void   flag_redraw();
	int    is_full_screen();
	int    is_input_grabbed();
	void   update_boundary();
	void   update_mouse_pos();
	void   set_full_screen_mode(int mode);
	void   set_mouse_mode(MouseInputMode mode);
	void   set_window_grab(WinGrab mode);
	void   flip();
	void   save_status_report();

private:
	void   get_window_scale(float *xscale, float *yscale);
};

extern Vga vga;

//--------------------------------------------//

#endif