summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/functions.h2
-rw-r--r--src/gfx.cpp18
-rw-r--r--src/gfx.h178
-rw-r--r--src/hal.h166
-rw-r--r--src/openttd.cpp17
-rw-r--r--src/rail.h1
-rw-r--r--src/video/cocoa_v.h1
7 files changed, 200 insertions, 183 deletions
diff --git a/src/functions.h b/src/functions.h
index bba59f5ea..87e540a7b 100644
--- a/src/functions.h
+++ b/src/functions.h
@@ -3,6 +3,8 @@
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
+#include "gfx.h"
+
void DoClearSquare(TileIndex tile);
void RunTileLoop(void);
diff --git a/src/gfx.cpp b/src/gfx.cpp
index de90ca461..ba6de033a 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -21,6 +21,24 @@
bool _dbg_screen_rect;
#endif
+byte _dirkeys; // 1 = left, 2 = up, 4 = right, 8 = down
+bool _fullscreen;
+CursorVars _cursor;
+bool _ctrl_pressed; // Is Ctrl pressed?
+bool _shift_pressed; // Is Shift pressed?
+byte _fast_forward;
+bool _left_button_down;
+bool _left_button_clicked;
+bool _right_button_down;
+bool _right_button_clicked;
+DrawPixelInfo _screen;
+bool _exit_game;
+bool _networking; ///< are we in networking mode?
+byte _game_mode;
+byte _pause;
+int _pal_first_dirty;
+int _pal_last_dirty;
+
Colour _cur_palette[256];
byte _stringwidth_table[FS_END][224];
diff --git a/src/gfx.h b/src/gfx.h
index a19ceaa45..365387103 100644
--- a/src/gfx.h
+++ b/src/gfx.h
@@ -3,6 +3,181 @@
#ifndef GFX_H
#define GFX_H
+/* !!! Note that the first part of this file if enclosed in extern "C" due to cocoa/obj-C !!! */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+enum WindowKeyCodes {
+ WKC_SHIFT = 0x8000,
+ WKC_CTRL = 0x4000,
+ WKC_ALT = 0x2000,
+ WKC_META = 0x1000,
+
+ // Special ones
+ WKC_NONE = 0,
+ WKC_ESC = 1,
+ WKC_BACKSPACE = 2,
+ WKC_INSERT = 3,
+ WKC_DELETE = 4,
+
+ WKC_PAGEUP = 5,
+ WKC_PAGEDOWN = 6,
+ WKC_END = 7,
+ WKC_HOME = 8,
+
+ // Arrow keys
+ WKC_LEFT = 9,
+ WKC_UP = 10,
+ WKC_RIGHT = 11,
+ WKC_DOWN = 12,
+
+ // Return & tab
+ WKC_RETURN = 13,
+ WKC_TAB = 14,
+
+ // Numerical keyboard
+ WKC_NUM_0 = 16,
+ WKC_NUM_1 = 17,
+ WKC_NUM_2 = 18,
+ WKC_NUM_3 = 19,
+ WKC_NUM_4 = 20,
+ WKC_NUM_5 = 21,
+ WKC_NUM_6 = 22,
+ WKC_NUM_7 = 23,
+ WKC_NUM_8 = 24,
+ WKC_NUM_9 = 25,
+ WKC_NUM_DIV = 26,
+ WKC_NUM_MUL = 27,
+ WKC_NUM_MINUS = 28,
+ WKC_NUM_PLUS = 29,
+ WKC_NUM_ENTER = 30,
+ WKC_NUM_DECIMAL = 31,
+
+ // Space
+ WKC_SPACE = 32,
+
+ // Function keys
+ WKC_F1 = 33,
+ WKC_F2 = 34,
+ WKC_F3 = 35,
+ WKC_F4 = 36,
+ WKC_F5 = 37,
+ WKC_F6 = 38,
+ WKC_F7 = 39,
+ WKC_F8 = 40,
+ WKC_F9 = 41,
+ WKC_F10 = 42,
+ WKC_F11 = 43,
+ WKC_F12 = 44,
+
+ // backquote is the key left of "1"
+ // we only store this key here, no matter what character is really mapped to it
+ // on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °)
+ WKC_BACKQUOTE = 45,
+ WKC_PAUSE = 46,
+
+ // 0-9 are mapped to 48-57
+ // A-Z are mapped to 65-90
+ // a-z are mapped to 97-122
+};
+
+enum GameModes {
+ GM_MENU,
+ GM_NORMAL,
+ GM_EDITOR
+};
+
+void GameLoop(void);
+
+void CreateConsole(void);
+
+typedef int32 CursorID;
+typedef byte Pixel;
+
+typedef struct Point {
+ int x,y;
+} Point;
+
+typedef struct Rect {
+ int left,top,right,bottom;
+} Rect;
+
+
+typedef struct CursorVars {
+ Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement
+ Point draw_pos, draw_size; ///< position and size bounding-box for drawing
+ CursorID sprite; ///< current image of cursor
+
+ int wheel; ///< mouse wheel movement
+ const CursorID *animate_list, *animate_cur; ///< in case of animated cursor, list of frames
+ uint animate_timeout; ///< current frame in list of animated cursor
+
+ bool visible; ///< cursor is visible
+ bool dirty; ///< the rect occupied by the mouse is dirty (redraw)
+ bool fix_at; ///< mouse is moving, but cursor is not (used for scrolling)
+ bool in_window; ///< mouse inside this window, determines drawing logic
+} CursorVars;
+
+typedef struct DrawPixelInfo {
+ Pixel *dst_ptr;
+ int left, top, width, height;
+ int pitch;
+ uint16 zoom;
+} DrawPixelInfo;
+
+typedef struct Colour {
+ byte r;
+ byte g;
+ byte b;
+} Colour;
+
+
+
+extern byte _dirkeys; // 1 = left, 2 = up, 4 = right, 8 = down
+extern bool _fullscreen;
+extern CursorVars _cursor;
+extern bool _ctrl_pressed; // Is Ctrl pressed?
+extern bool _shift_pressed; // Is Shift pressed?
+extern byte _fast_forward;
+
+extern bool _left_button_down;
+extern bool _left_button_clicked;
+extern bool _right_button_down;
+extern bool _right_button_clicked;
+
+extern DrawPixelInfo _screen;
+extern bool _exit_game;
+extern bool _networking; ///< are we in networking mode?
+extern byte _game_mode;
+extern byte _pause;
+
+extern int _pal_first_dirty;
+extern int _pal_last_dirty;
+extern int _num_resolutions;
+extern uint16 _resolutions[32][2];
+extern uint16 _cur_resolution[2];
+extern Colour _cur_palette[256];
+
+void HandleKeypress(uint32 key);
+void HandleMouseEvents(void);
+void CSleep(int milliseconds);
+void UpdateWindows(void);
+
+uint32 InteractiveRandom(void); /* Used for random sequences that are not the same on the other end of the multiplayer link */
+uint InteractiveRandomRange(uint max);
+void DrawTextMessage(void);
+void DrawMouseCursor(void);
+void ScreenSizeChanged(void);
+void HandleExitGameRequest(void);
+void GameSizeChanged(void);
+void UndrawMouseCursor(void);
+
+#ifdef __cplusplus
+}; //extern "C"
+/* Following part is only for C++ */
+
#include "helpers.hpp"
typedef enum FontSizes {
@@ -119,8 +294,11 @@ typedef enum StringColorFlags {
IS_PALETTE_COLOR = 0x100, // color value is already a real palette color index, not an index of a StringColor
} StringColorFlags;
+
#ifdef _DEBUG
extern bool _dbg_screen_rect;
#endif
+#endif /* __cplusplus */
+
#endif /* GFX_H */
diff --git a/src/hal.h b/src/hal.h
index 020df5f14..e3d051c25 100644
--- a/src/hal.h
+++ b/src/hal.h
@@ -7,81 +7,6 @@
extern "C" {
#endif //__cplusplus
-enum WindowKeyCodes {
- WKC_SHIFT = 0x8000,
- WKC_CTRL = 0x4000,
- WKC_ALT = 0x2000,
- WKC_META = 0x1000,
-
- // Special ones
- WKC_NONE = 0,
- WKC_ESC = 1,
- WKC_BACKSPACE = 2,
- WKC_INSERT = 3,
- WKC_DELETE = 4,
-
- WKC_PAGEUP = 5,
- WKC_PAGEDOWN = 6,
- WKC_END = 7,
- WKC_HOME = 8,
-
- // Arrow keys
- WKC_LEFT = 9,
- WKC_UP = 10,
- WKC_RIGHT = 11,
- WKC_DOWN = 12,
-
- // Return & tab
- WKC_RETURN = 13,
- WKC_TAB = 14,
-
- // Numerical keyboard
- WKC_NUM_0 = 16,
- WKC_NUM_1 = 17,
- WKC_NUM_2 = 18,
- WKC_NUM_3 = 19,
- WKC_NUM_4 = 20,
- WKC_NUM_5 = 21,
- WKC_NUM_6 = 22,
- WKC_NUM_7 = 23,
- WKC_NUM_8 = 24,
- WKC_NUM_9 = 25,
- WKC_NUM_DIV = 26,
- WKC_NUM_MUL = 27,
- WKC_NUM_MINUS = 28,
- WKC_NUM_PLUS = 29,
- WKC_NUM_ENTER = 30,
- WKC_NUM_DECIMAL = 31,
-
- // Space
- WKC_SPACE = 32,
-
- // Function keys
- WKC_F1 = 33,
- WKC_F2 = 34,
- WKC_F3 = 35,
- WKC_F4 = 36,
- WKC_F5 = 37,
- WKC_F6 = 38,
- WKC_F7 = 39,
- WKC_F8 = 40,
- WKC_F9 = 41,
- WKC_F10 = 42,
- WKC_F11 = 43,
- WKC_F12 = 44,
-
- // backquote is the key left of "1"
- // we only store this key here, no matter what character is really mapped to it
- // on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °)
- WKC_BACKQUOTE = 45,
- WKC_PAUSE = 46,
-
- // 0-9 are mapped to 48-57
- // A-Z are mapped to 65-90
- // a-z are mapped to 97-122
-};
-
-
typedef struct {
const char *(*start)(const char * const *parm);
void (*stop)(void);
@@ -121,97 +46,6 @@ enum DriverType {
MUSIC_DRIVER = 2,
};
-enum GameModes {
- GM_MENU,
- GM_NORMAL,
- GM_EDITOR
-};
-
-void GameLoop(void);
-
-void CreateConsole(void);
-
-typedef int32 CursorID;
-typedef byte Pixel;
-
-typedef struct Point {
- int x,y;
-} Point;
-
-typedef struct Rect {
- int left,top,right,bottom;
-} Rect;
-
-
-typedef struct CursorVars {
- Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement
- Point draw_pos, draw_size; ///< position and size bounding-box for drawing
- CursorID sprite; ///< current image of cursor
-
- int wheel; ///< mouse wheel movement
- const CursorID *animate_list, *animate_cur; ///< in case of animated cursor, list of frames
- uint animate_timeout; ///< current frame in list of animated cursor
-
- bool visible; ///< cursor is visible
- bool dirty; ///< the rect occupied by the mouse is dirty (redraw)
- bool fix_at; ///< mouse is moving, but cursor is not (used for scrolling)
- bool in_window; ///< mouse inside this window, determines drawing logic
-} CursorVars;
-
-typedef struct DrawPixelInfo {
- Pixel *dst_ptr;
- int left, top, width, height;
- int pitch;
- uint16 zoom;
-} DrawPixelInfo;
-
-
-extern byte _dirkeys; // 1 = left, 2 = up, 4 = right, 8 = down
-extern bool _fullscreen;
-extern CursorVars _cursor;
-extern bool _ctrl_pressed; // Is Ctrl pressed?
-extern bool _shift_pressed; // Is Shift pressed?
-extern byte _fast_forward;
-
-extern bool _left_button_down;
-extern bool _left_button_clicked;
-extern bool _right_button_down;
-extern bool _right_button_clicked;
-
-extern DrawPixelInfo _screen;
-extern bool _exit_game;
-extern bool _networking; ///< are we in networking mode?
-extern byte _game_mode;
-extern byte _pause;
-
-
-void HandleKeypress(uint32 key);
-void HandleMouseEvents(void);
-void CSleep(int milliseconds);
-void UpdateWindows(void);
-
-uint32 InteractiveRandom(void); /* Used for random sequences that are not the same on the other end of the multiplayer link */
-uint InteractiveRandomRange(uint max);
-void DrawTextMessage(void);
-void DrawMouseCursor(void);
-void ScreenSizeChanged(void);
-void HandleExitGameRequest(void);
-void GameSizeChanged(void);
-void UndrawMouseCursor(void);
-
-extern int _pal_first_dirty;
-extern int _pal_last_dirty;
-extern int _num_resolutions;
-extern uint16 _resolutions[32][2];
-extern uint16 _cur_resolution[2];
-
-typedef struct Colour {
- byte r;
- byte g;
- byte b;
-} Colour;
-extern Colour _cur_palette[256];
-
#ifdef __cplusplus
} // extern "C"
#endif //__cplusplus
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 7db90a4a1..b07622bf3 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1708,20 +1708,3 @@ HalMusicDriver *_music_driver;
HalSoundDriver *_sound_driver;
HalVideoDriver *_video_driver;
-byte _dirkeys; // 1 = left, 2 = up, 4 = right, 8 = down
-bool _fullscreen;
-CursorVars _cursor;
-bool _ctrl_pressed; // Is Ctrl pressed?
-bool _shift_pressed; // Is Shift pressed?
-byte _fast_forward;
-bool _left_button_down;
-bool _left_button_clicked;
-bool _right_button_down;
-bool _right_button_clicked;
-DrawPixelInfo _screen;
-bool _exit_game;
-bool _networking; ///< are we in networking mode?
-byte _game_mode;
-byte _pause;
-int _pal_first_dirty;
-int _pal_last_dirty;
diff --git a/src/rail.h b/src/rail.h
index 0d2d850a1..be895a0f9 100644
--- a/src/rail.h
+++ b/src/rail.h
@@ -5,6 +5,7 @@
#ifndef RAIL_H
#define RAIL_H
+#include "gfx.h"
#include "direction.h"
#include "tile.h"
diff --git a/src/video/cocoa_v.h b/src/video/cocoa_v.h
index c3f533467..c9ec182fa 100644
--- a/src/video/cocoa_v.h
+++ b/src/video/cocoa_v.h
@@ -4,6 +4,7 @@
#define VIDEO_COCOA_H
#include "../hal.h"
+#include "../gfx.h"
#ifdef __cplusplus
extern "C" {