1 /*         ______   ___    ___
2  *        /\  _  \ /\_ \  /\_ \
3  *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
4  *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
5  *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
6  *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
7  *            \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
8  *                                           /\____/
9  *                                           \_/__/
10  *
11  *      The Be Allegro Header File.
12  *
13  *      Aren't you glad you used the BeOS header file?
14  *      Don't you wish everybody did?
15  *
16  *      By Jason Wilkins.
17  *
18  *      See readme.txt for copyright information.
19  */
20 
21 #ifndef BE_ALLEGRO_H
22 #define BE_ALLEGRO_H
23 
24 /* There is namespace cross-talk between the Be API and
25    Allegro, lets use my favorite namespace detergent.
26    "Kludge!" Now with 25% more hack. */
27 
28 #ifdef __cplusplus
29 # define color_map    al_color_map
30 # define drawing_mode al_drawing_mode
31 #endif
32 
33 #include "allegro.h"
34 #include "allegro/internal/aintern.h"
35 
36 #ifdef __cplusplus
37 # undef color_map
38 # undef drawing_mode
39 # undef MIN
40 # undef MAX
41 # undef TRACE
42 # undef ASSERT
43 
44 #ifdef DEBUGMODE
45 # define AL_ASSERT(condition)  { if (!(condition)) al_assert(__FILE__, __LINE__); }
46 #else
47 # define AL_ASSERT(condition)
48 #endif
49 
50 #ifndef SCAN_DEPEND
51    #include <Be.h>
52 #endif
53 
54 #define BE_ALLEGRO_VIEW_DIRECT    1
55 #define BE_ALLEGRO_VIEW_OVERLAY   2
56 
57 #define LINE8_HOOK_NUM    3
58 #define LINE16_HOOK_NUM  12
59 #define LINE32_HOOK_NUM   4
60 #define ARRAY8_HOOK_NUM   8
61 #define ARRAY32_HOOK_NUM  9
62 #define RECT8_HOOK_NUM    5
63 #define RECT16_HOOK_NUM  16
64 #define RECT32_HOOK_NUM   6
65 #define INVERT_HOOK_NUM  11
66 #define BLIT_HOOK_NUM     7
67 #define SYNC_HOOK_NUM    10
68 
69 
70 
71 typedef int32 (*LINE8_HOOK)(int32 startX, int32 endX, int32 startY,
72    int32 endY, uint8 colorIndex, bool clipToRect, int16 clipLeft,
73    int16 clipTop, int16 clipRight, int16 clipBottom);
74 
75 typedef int32 (*ARRAY8_HOOK)(indexed_color_line *array,
76    int32 numItems, bool clipToRect, int16 top, int16 right,
77    int16 bottom, int16 left);
78 
79 typedef int32 (*LINE16_HOOK)(int32 startX, int32 endX, int32 startY,
80    int32 endY, uint16 color, bool clipToRect, int16 clipLeft,
81    int16 clipTop, int16 clipRight, int16 clipBottom);
82 
83 typedef int32 (*LINE32_HOOK)(int32 startX, int32 endX, int32 startY,
84    int32 endY, uint32 color, bool clipToRect, int16 clipLeft,
85    int16 clipTop, int16 clipRight, int16 clipBottom);
86 
87 typedef int32 (*ARRAY32_HOOK)(rgb_color_line *array,
88    int32 numItems, bool clipToRect, int16 top, int16 right,
89    int16 bottom, int16 left);
90 
91 typedef int32 (*RECT8_HOOK)(int32 left, int32 top, int32 right,
92    int32 bottom, uint8 colorIndex);
93 
94 typedef int32 (*RECT16_HOOK)(int32 left, int32 top, int32 right,
95    int32 bottom, uint16 color);
96 
97 typedef int32 (*RECT32_HOOK)(int32 left, int32 top, int32 right,
98    int32 bottom, uint32 color);
99 
100 typedef int32 (*INVERT_HOOK)(int32 left, int32 top, int32 right,
101    int32 bottom);
102 
103 typedef int32 (*BLIT_HOOK)(int32 sourceX, int32 sourceY,
104    int32 destinationX, int32 destinationY, int32 width,
105    int32 height);
106 
107 typedef int32 (*SYNC_HOOK)(void);
108 
109 
110 
111 typedef struct HOOKS {
112    LINE8_HOOK   draw_line_8;
113    LINE16_HOOK  draw_line_16;
114    LINE32_HOOK  draw_line_32;
115    ARRAY8_HOOK  draw_array_8;
116    ARRAY32_HOOK draw_array_32;
117    RECT8_HOOK   draw_rect_8;
118    RECT16_HOOK  draw_rect_16;
119    RECT32_HOOK  draw_rect_32;
120    INVERT_HOOK  invert_rect;
121    BLIT_HOOK    blit;
122    SYNC_HOOK    sync;
123 } HOOKS;
124 
125 
126 
127 typedef struct {
128    int    d, w, h;
129    uint32 mode;
130    uint32 space;
131 } BE_MODE_TABLE;
132 
133 
134 
135 class BeAllegroView
136    : public BView
137 {
138    public:
139       BeAllegroView(BRect, const char *, uint32, uint32, int);
140 
141       void MessageReceived(BMessage *);
142       void Draw(BRect);
143 
144    private:
145       int flags;
146 };
147 
148 
149 
150 class BeAllegroWindow
151    : public BWindow
152 {
153    public:
154       BeAllegroWindow(BRect, const char *, window_look, window_feel, uint32, uint32, uint32, uint32, uint32);
155      ~BeAllegroWindow();
156 
157       void MessageReceived(BMessage *);
158       bool QuitRequested(void);
159       void WindowActivated(bool);
160 
161       int screen_depth;
162       int screen_width;
163       int screen_height;
164       BBitmap *buffer;
165       BBitmap *aux_buffer;
166       bool dying;
167       thread_id	drawing_thread_id;
168 };
169 
170 
171 
172 class BeAllegroDirectWindow
173    : public BDirectWindow
174 {
175    public:
176       BeAllegroDirectWindow(BRect, const char *, window_look, window_feel, uint32, uint32, uint32, uint32, uint32);
177      ~BeAllegroDirectWindow();
178 
179       void DirectConnected(direct_buffer_info *);
180       void MessageReceived(BMessage *);
181       bool QuitRequested(void);
182       void WindowActivated(bool);
183 
184       void *screen_data;
185       uint32 screen_pitch;
186       uint32 screen_height;
187       uint32 screen_depth;
188 
189       void *display_data;
190       uint32 display_pitch;
191       uint32 display_depth;
192 
193       uint32 num_rects;
194       clipping_rect *rects;
195       clipping_rect window;
196       COLORCONV_BLITTER_FUNC *blitter;
197 
198       bool connected;
199       bool dying;
200       BLocker *locker;
201       thread_id	drawing_thread_id;
202 };
203 
204 
205 
206 class BeAllegroScreen
207    : public BWindowScreen
208 {
209    public:
210       BeAllegroScreen(const char *title, uint32 space, status_t *error, bool debugging = false);
211 
212       void MessageReceived(BMessage *);
213       bool QuitRequested(void);
214       void ScreenConnected(bool connected);
215 };
216 
217 
218 
219 class BeAllegroOverlay
220    : public BWindow
221 {
222    public:
223       BeAllegroOverlay(BRect, const char *, window_look, window_feel, uint32, uint32, uint32, uint32, uint32);
224      ~BeAllegroOverlay();
225 
226       void MessageReceived(BMessage *);
227       bool QuitRequested(void);
228       void WindowActivated(bool);
229 
230       BBitmap *buffer;
231       rgb_color color_key;
232 };
233 
234 
235 
236 class BeAllegroApp
237    : public BApplication
238 {
239    public:
240       BeAllegroApp(const char *signature);
241 
242       bool QuitRequested(void);
243       void ReadyToRun(void);
244 };
245 
246 
247 
248 AL_VAR(BeAllegroApp, *_be_allegro_app);
249 AL_VAR(BeAllegroWindow, *_be_allegro_window);
250 AL_VAR(BeAllegroDirectWindow, *_be_allegro_direct_window);
251 AL_VAR(BeAllegroView, *_be_allegro_view);
252 AL_VAR(BeAllegroScreen, *_be_allegro_screen);
253 AL_VAR(BeAllegroOverlay, *_be_allegro_overlay);
254 AL_VAR(BWindow, *_be_window);
255 AL_VAR(BMidiSynth, *_be_midisynth);
256 AL_VAR(sem_id, _be_sound_stream_lock);
257 AL_VAR(sem_id, _be_fullscreen_lock);
258 AL_VAR(sem_id, _be_window_lock);
259 AL_VAR(sem_id, _be_mouse_view_attached);
260 AL_VAR(BWindow, *_be_mouse_window);
261 AL_VAR(BView, *_be_mouse_view);
262 AL_VAR(int, _be_mouse_z);
263 AL_VAR(bool, _be_mouse_window_mode);
264 AL_VAR(HOOKS, _be_hooks);
265 AL_VAR(int, _be_switch_mode);
266 AL_VAR(volatile int, _be_lock_count);
267 AL_VAR(volatile int, _be_focus_count);
268 AL_VAR(volatile bool, _be_gfx_initialized);
269 AL_VAR(int, *_be_dirty_lines);
270 
271 AL_ARRAY(AL_CONST BE_MODE_TABLE, _be_mode_table);
272 
273 
274 extern int32 (*_be_sync_func)();
275 extern void (*_be_window_close_hook)();
276 
277 void _be_terminate(thread_id caller, bool exit_caller);
278 void _be_gfx_set_truecolor_shifts();
279 void _be_change_focus(bool active);
280 bool _be_handle_window_close(const char *title);
281 
282 
283 
284 #endif /* ifdef C++ */
285 
286 
287 
288 #endif /* ifndef BE_ALLEGRO_H */
289