1 /**
2  * @file handler_display.h
3  * @briefi Handle displaying and updating with SDL
4  * @created 2002-08-17
5  * @date 2007-11-18
6  * @copyright 1991-2014 TLK Games
7  * @author Bruno Ethvignot
8  * @version $Revision: 24 $
9  */
10 /*
11  * copyright (c) 1991-2014 TLK Games all rights reserved
12  * $Id: handler_display.h 24 2014-09-28 15:30:04Z bruno.ethvignot@gmail.com $
13  *
14  * TecnoballZ is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * TecnoballZ is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27  * MA  02110-1301, USA.
28  */
29 #ifndef __HANDLER_DISPLAY__
30 #define __HANDLER_DISPLAY__
31 #include "../include/tecnoballz.h"
32 #include "../include/offscreen_surface.h"
33 
34 class handler_display:public virtual tecnoballz
35   {
36   public:
37     static const Sint32 SHADOWOFFX = -4;
38     static const Sint32 SHADOWOFFY = 4;
39     static const unsigned char SHADOW_PIX = 0x80;
40     static const Uint32 SHADOWLONG = 0x80808080;
41     /** True if full screen mode */
42     static bool optionfull;
43     /** True if synchronisation */
44     static bool optionsync;
45 
46   private:
47     static const Uint32 bitspixels = 8;
48     static const Sint32 DELAY_CHANGE_MAX = 10;
49     Sint32 offsetplus;
50     /** The main surface of the game */
51     SDL_Surface *game_surface;
52     /** Pointer to pixels of the game offscreen */
53     char *game_screen_pixels;
54     /** Size of a line in bytes of the game and background offscreens */
55     Sint32 game_screen_pitch;
56     /** Pointer to pixels of the background offscreen */
57     char *background_pixels;
58     /** Main window surface */
59     SDL_Surface *sdl_screen;
60     /** The width of our main window in pixels */
61     Uint32 window_width;
62     /** The height of our main window in pixels */
63     Uint32 window_height;
64     /** The number of milliseconds since the SDL library initialization */
65     Uint32 previous_sdl_ticks;
66     /** Current frames per seconde or frames frequency */
67     Uint32 frames_per_second;
68     /** Amount of ticks for calculate the number of frames per second */
69     Uint32 sdl_ticks_amount;
70     /** Counter of frame modulo 100 */
71     Uint32 frames_counter_modulo;
72     /** Number of frame during the "delay_value" is used */
73     Sint32 delay_change_counter;
74     /** Delay value for SDL_delay() */
75     Sint32 delay_value;
76     /** game speed, the desired frames per second 20 <=> 50 fps */
77     Sint32 game_speed;
78     /** Amount of ticks for calculate "delay_value" */
79     Sint32 delay_ticks_amount;
80     /** The window tile and icon name */
81     static char window_title[25];
82     /** Current indexed color palette of the game */
83     SDL_Color sdl_palette[256];
84     /** Value of the vertical shift of the screen
85      * when the player tilts */
86     Uint32 tilt_offset;
87 
88   public:
89     handler_display ();
90     ~handler_display ();
91     void initialize ();
92     Uint32 get_width ();
93     Uint32 get_height ();
94     void lock_surfaces ();
95     void unlock_surfaces ();
96     Uint32 get_bits_per_pixel ();
97     void wait_frame ();
98     Uint32 get_frames_per_second ();
99 
100     Sint32 ecran_next (Sint32 zbase, Sint32 offsx, Sint32 offsy);
101 
102     // gestion des buffers & des tampons
103     void aff_buff32 (char *src, char *dest, Sint32 offs, Sint32 offd);
104     void buf_affx32 (char *srcPT, char *desPT, Sint32 width, Sint32 heigh = 32);
105     void buf_affx64 (char *srcPT, char *desPT, Sint32 width, Sint32 heigh = 64);
106     void buf_clr64 (char *desPT);
107     void enable_palette (unsigned char *adrPal);
108     void enable_palette (SDL_Color * adrPal);
109     void window_update ();
110     SDL_Color *get_palette ();
111     void clr_shadow (Sint32 offst, Sint32 large, Sint32 haute);
112     void clr_shadow (Sint32 _iPosX, Sint32 _iPosY, Sint32 _iLarg,
113                      Sint32 _iHaut);
114     void set_shadow (Sint32 offst, Sint32 large, Sint32 haute);
115     void tilt_screen ();
116     void set_color_gradation ();
117   private:
118     void get_info ();
119     void set_video_mode ();
120     void check_if_toggle_fullscreen ();
121 
122   };
123 #endif
124