[AD] Windows-port naming conventions |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
A lot of code in the Windows port doesn't follow the naming convention for
internal or platform specific functions, claiming global symbols like
thread_init() and thread_exit().
I would think this is quite evil, so attached is a patch that renames a lot
of things to what I hope is a more proper naming. Mostly, I've adopted
either a _win_ prefix, or the gfx_directx_ prefix that was already in use
here and there. I'm not sure I've been consistent though.
Comments?
Evert
diff -ur ./include/allegro/platform/aintwin.h /windows/d/Program/allegro_cvs/include/allegro/platform/aintwin.h
--- ./include/allegro/platform/aintwin.h 2004-09-25 10:24:51.000000000 +0200
+++ /windows/d/Program/allegro_cvs/include/allegro/platform/aintwin.h 2005-05-04 01:07:04.000000000 +0200
@@ -69,7 +69,6 @@
/* main window */
#define WND_TITLE_SIZE 128
-AL_VAR(HWND, allegro_wnd);
AL_ARRAY(char, wnd_title);
AL_VAR(int, wnd_x);
AL_VAR(int, wnd_y);
@@ -92,17 +91,17 @@
/* switch routines */
-AL_VAR(int, app_foreground);
+AL_VAR(int, _win_app_foreground);
AL_FUNC(void, sys_directx_display_switch_init, (void));
AL_FUNC(void, sys_directx_display_switch_exit, (void));
AL_FUNC(int, sys_directx_set_display_switch_mode, (int mode));
-AL_FUNC(void, sys_switch_in, (void));
-AL_FUNC(void, sys_switch_out, (void));
-AL_FUNC(void, sys_reset_switch_mode, (void));
+AL_FUNC(void, _win_switch_in, (void));
+AL_FUNC(void, _win_switch_out, (void));
+AL_FUNC(void, _win_reset_switch_mode, (void));
-AL_FUNC(int, thread_switch_out, (void));
+AL_FUNC(int, _win_thread_switch_out, (void));
/* main window routines */
@@ -111,14 +110,14 @@
/* input routines */
-AL_VAR(int, input_events);
-AL_ARRAY(HANDLE, input_event_id);
-AL_FUNCPTRARRAY(void, input_event_handler, (void));
-
-AL_FUNC(void, input_init, (int need_thread));
-AL_FUNC(void, input_exit, (void));
-AL_FUNC(int, input_register_event, (HANDLE event_id, void (*event_handler)(void)));
-AL_FUNC(void, input_unregister_event, (HANDLE event_id));
+AL_VAR(int, _win_input_events);
+AL_ARRAY(HANDLE, _win_input_event_id);
+AL_FUNCPTRARRAY(void, _win_input_event_handler, (void));
+
+AL_FUNC(void, _win_input_init, (int need_thread));
+AL_FUNC(void, _win_input_exit, (void));
+AL_FUNC(int, _win_input_register_event, (HANDLE event_id, void (*event_handler)(void)));
+AL_FUNC(void, _win_input_unregister_event, (HANDLE event_id));
/* keyboard routines */
@@ -162,8 +161,8 @@
/* thread routines */
-AL_FUNC(void, thread_init, (void));
-AL_FUNC(void, thread_exit, (void));
+AL_FUNC(void, _win_thread_init, (void));
+AL_FUNC(void, _win_thread_exit, (void));
/* synchronization routines */
diff -ur ./src/win/asmlock.s /windows/d/Program/allegro_cvs/src/win/asmlock.s
--- ./src/win/asmlock.s 2003-04-10 13:48:45.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/asmlock.s 2005-05-04 01:14:38.000000000 +0200
@@ -143,7 +143,7 @@
/* update dirty lines: this is safe because autolocking
* is guaranteed to be the only level of locking.
*/
- movl GLOBL(forefront_bitmap), %edx
+ movl GLOBL(gfx_directx_forefront_bitmap), %edx
call update_dirty_lines
popl %eax
@@ -167,7 +167,7 @@
popl %edx
/* forefront_bitmap may still be locked in case of nested locking */
- movl GLOBL(forefront_bitmap), %edx
+ movl GLOBL(gfx_directx_forefront_bitmap), %edx
testl $BMP_ID_LOCKED, BMP_ID(%edx)
jnz No_update_win
diff -ur ./src/win/wddaccel.c /windows/d/Program/allegro_cvs/src/win/wddaccel.c
--- ./src/win/wddaccel.c 2003-06-11 20:13:20.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wddaccel.c 2005-05-04 00:42:48.000000000 +0200
@@ -68,7 +68,7 @@
_exit_gfx_critical();
/* only for windowed mode */
- if ((gfx_driver->id == GFX_DIRECTX_WIN) && (dest_parent == forefront_bitmap)) {
+ if ((gfx_driver->id == GFX_DIRECTX_WIN) && (dest_parent == gfx_directx_forefront_bitmap)) {
src_rect.left = dest_parent_x;
src_rect.top = dest_parent_y;
src_rect.right = dest_parent_x + width;
@@ -129,7 +129,7 @@
_TRACE("Blt failed (%x)\n", hr);
/* only for windowed mode */
- if ((gfx_driver->id == GFX_DIRECTX_WIN) && (dest_parent == forefront_bitmap))
+ if ((gfx_driver->id == GFX_DIRECTX_WIN) && (dest_parent == gfx_directx_forefront_bitmap))
win_gfx_driver->paint(&dest_rect);
}
else {
@@ -225,7 +225,7 @@
_TRACE("Blt failed (%x)\n", hr);
/* only for windowed mode */
- if ((gfx_driver->id == GFX_DIRECTX_WIN) && (parent == forefront_bitmap))
+ if ((gfx_driver->id == GFX_DIRECTX_WIN) && (parent == gfx_directx_forefront_bitmap))
win_gfx_driver->paint(&dest_rect);
}
@@ -304,7 +304,7 @@
_TRACE("Blt failed (%x)\n", hr);
/* only for windowed mode */
- if ((gfx_driver->id == GFX_DIRECTX_WIN) && (parent == forefront_bitmap))
+ if ((gfx_driver->id == GFX_DIRECTX_WIN) && (parent == gfx_directx_forefront_bitmap))
win_gfx_driver->paint(&dest_rect);
}
@@ -371,7 +371,7 @@
_TRACE("Blt failed (%x)\n", hr);
/* only for windowed mode */
- if ((gfx_driver->id == GFX_DIRECTX_WIN) && (parent == forefront_bitmap))
+ if ((gfx_driver->id == GFX_DIRECTX_WIN) && (parent == gfx_directx_forefront_bitmap))
win_gfx_driver->paint(&dest_rect);
}
@@ -437,16 +437,16 @@
_TRACE("Blt failed (%x)\n", hr);
/* only for windowed mode */
- if ((gfx_driver->id == GFX_DIRECTX_WIN) && (parent == forefront_bitmap))
+ if ((gfx_driver->id == GFX_DIRECTX_WIN) && (parent == gfx_directx_forefront_bitmap))
win_gfx_driver->paint(&dest_rect);
}
-/* enable_acceleration:
+/* gfx_directx_enable_acceleration:
* Checks graphic driver for capabilities to accelerate Allegro.
*/
-void enable_acceleration(GFX_DRIVER * drv)
+void gfx_directx_enable_acceleration(GFX_DRIVER * drv)
{
/* safe pointer to software versions */
_orig_hline = _screen_vtable.hline;
@@ -491,14 +491,14 @@
-/* enable_triple_buffering:
+/* gfx_directx_enable_triple_buffering:
* Checks graphic driver for triple buffering capability.
*/
-void enable_triple_buffering(GFX_DRIVER *drv)
+void gfx_directx_enable_triple_buffering(GFX_DRIVER *drv)
{
HRESULT hr;
- hr = IDirectDrawSurface2_GetFlipStatus(DDRAW_SURFACE_OF(forefront_bitmap)->id, DDGFS_ISFLIPDONE);
+ hr = IDirectDrawSurface2_GetFlipStatus(DDRAW_SURFACE_OF(gfx_directx_forefront_bitmap)->id, DDGFS_ISFLIPDONE);
if ((hr == DD_OK) || (hr == DDERR_WASSTILLDRAWING)) {
drv->poll_scroll = gfx_directx_poll_scroll;
gfx_capabilities |= GFX_CAN_TRIPLE_BUFFER;
diff -ur ./src/win/wddbmp.c /windows/d/Program/allegro_cvs/src/win/wddbmp.c
--- ./src/win/wddbmp.c 2005-01-19 23:41:30.000000000 +0100
+++ /windows/d/Program/allegro_cvs/src/win/wddbmp.c 2005-05-04 00:49:24.000000000 +0200
@@ -299,10 +299,10 @@
-/* make_bitmap_from_surface:
+/* gfx_directx_make_bitmap_from_surface:
* Connects a DirectDraw surface with an Allegro bitmap.
*/
-BITMAP *make_bitmap_from_surface(DDRAW_SURFACE *surf, int w, int h, int id)
+BITMAP *gfx_directx_make_bitmap_from_surface(DDRAW_SURFACE *surf, int w, int h, int id)
{
BITMAP *bmp;
int i;
@@ -358,8 +358,8 @@
ASSERT(n_pages > 0);
/* set flipping chain characteristics */
- w = forefront_bitmap->w;
- h = forefront_bitmap->h;
+ w = gfx_directx_forefront_bitmap->w;
+ h = gfx_directx_forefront_bitmap->h;
type = flipping_page[0]->flags & DDRAW_SURFACE_TYPE_MASK;
n_backbuffers = n_pages - 1;
@@ -428,14 +428,14 @@
BITMAP *bmp;
/* try to detect page flipping and triple buffering patterns */
- if ((width == forefront_bitmap->w) && (height == forefront_bitmap->h)) {
+ if ((width == gfx_directx_forefront_bitmap->w) && (height == gfx_directx_forefront_bitmap->h)) {
switch (n_flipping_pages) {
case 0:
/* recycle the forefront surface as the first flipping page */
- flipping_page[0] = DDRAW_SURFACE_OF(forefront_bitmap);
- bmp = make_bitmap_from_surface(flipping_page[0], width, height, BMP_ID_VIDEO);
+ flipping_page[0] = DDRAW_SURFACE_OF(gfx_directx_forefront_bitmap);
+ bmp = gfx_directx_make_bitmap_from_surface(flipping_page[0], width, height, BMP_ID_VIDEO);
if (bmp) {
flipping_page[0]->parent_bmp = bmp;
n_flipping_pages++;
@@ -451,7 +451,7 @@
/* try to attach an additional page to the flipping chain */
flipping_page[n_flipping_pages] = malloc(sizeof(DDRAW_SURFACE));
if (recreate_flipping_chain(n_flipping_pages+1) == 0) {
- bmp = make_bitmap_from_surface(flipping_page[n_flipping_pages], width, height, BMP_ID_VIDEO);
+ bmp = gfx_directx_make_bitmap_from_surface(flipping_page[n_flipping_pages], width, height, BMP_ID_VIDEO);
if (bmp) {
flipping_page[n_flipping_pages]->parent_bmp = bmp;
n_flipping_pages++;
@@ -476,7 +476,7 @@
return NULL;
/* create the bitmap that wraps up the surface */
- bmp = make_bitmap_from_surface(surf, width, height, BMP_ID_VIDEO);
+ bmp = gfx_directx_make_bitmap_from_surface(surf, width, height, BMP_ID_VIDEO);
if (!bmp) {
gfx_directx_destroy_surface(surf);
return NULL;
@@ -534,8 +534,8 @@
HRESULT hr;
/* flip only in the foreground */
- if (!app_foreground) {
- thread_switch_out();
+ if (!_win_app_foreground) {
+ _win_thread_switch_out();
return 0;
}
@@ -578,7 +578,7 @@
int gfx_directx_show_video_bitmap(BITMAP *bmp)
{
/* guard against show_video_bitmap(screen); */
- if (bmp == forefront_bitmap)
+ if (bmp == gfx_directx_forefront_bitmap)
return 0;
return flip_with_forefront_bitmap(bmp, _wait_for_vsync);
@@ -591,7 +591,7 @@
int gfx_directx_request_video_bitmap(BITMAP *bmp)
{
/* guard against request_video_bitmap(screen); */
- if (bmp == forefront_bitmap)
+ if (bmp == gfx_directx_forefront_bitmap)
return 0;
return flip_with_forefront_bitmap(bmp, FALSE);
@@ -636,7 +636,7 @@
return NULL;
/* create the bitmap that wraps up the surface */
- bmp = make_bitmap_from_surface(surf, width, height, BMP_ID_SYSTEM);
+ bmp = gfx_directx_make_bitmap_from_surface(surf, width, height, BMP_ID_SYSTEM);
if (!bmp) {
gfx_directx_destroy_surface(surf);
return NULL;
diff -ur ./src/win/wddfull.c /windows/d/Program/allegro_cvs/src/win/wddfull.c
--- ./src/win/wddfull.c 2005-01-22 14:42:11.000000000 +0100
+++ /windows/d/Program/allegro_cvs/src/win/wddfull.c 2005-05-04 00:27:58.000000000 +0200
@@ -164,8 +164,8 @@
bmp = gfx_directx_init(&gfx_directx_accel, w, h, v_w, v_h, color_depth);
if (bmp) {
- enable_acceleration(&gfx_directx_accel);
- enable_triple_buffering(&gfx_directx_accel);
+ gfx_directx_enable_acceleration(&gfx_directx_accel);
+ gfx_directx_enable_triple_buffering(&gfx_directx_accel);
finalize_fullscreen_init();
}
@@ -188,7 +188,7 @@
bmp = gfx_directx_init(&gfx_directx_soft, w, h, v_w, v_h, color_depth);
if (bmp) {
- enable_triple_buffering(&gfx_directx_soft);
+ gfx_directx_enable_triple_buffering(&gfx_directx_soft);
finalize_fullscreen_init();
}
diff -ur ./src/win/wddlock.c /windows/d/Program/allegro_cvs/src/win/wddlock.c
--- ./src/win/wddlock.c 2002-09-07 21:53:42.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wddlock.c 2005-05-04 00:41:58.000000000 +0200
@@ -32,7 +32,7 @@
_exit_gfx_critical();
if (GFX_CRITICAL_RELEASED)
- thread_switch_out();
+ _win_thread_switch_out();
_enter_gfx_critical();
}
@@ -76,7 +76,7 @@
_enter_gfx_critical();
/* handle display switch */
- if (!app_foreground)
+ if (!_win_app_foreground)
gfx_directx_switch_out();
/* this is a real bitmap, so can be locked directly */
@@ -249,7 +249,7 @@
HRESULT hr;
/* handle display switch */
- if (!app_foreground)
+ if (!_win_app_foreground)
gfx_directx_switch_out();
/* find parent */
diff -ur ./src/win/wddmode.c /windows/d/Program/allegro_cvs/src/win/wddmode.c
--- ./src/win/wddmode.c 2002-11-15 11:39:39.000000000 +0100
+++ /windows/d/Program/allegro_cvs/src/win/wddmode.c 2005-05-04 00:24:24.000000000 +0200
@@ -23,8 +23,8 @@
#include "wddraw.h"
-int desktop_depth;
-RGB_MAP desktop_rgb_map; /* for 8-bit desktops */
+int _win_desktop_depth;
+RGB_MAP _win_desktop_rgb_map; /* for 8-bit desktops */
int mode_supported;
@@ -66,6 +66,7 @@
static int wnd_set_video_mode(void)
{
HRESULT hr;
+ HWND allegro_wnd = win_get_window();
/* set the cooperative level to allow fullscreen access */
hr = IDirectDraw2_SetCooperativeLevel(directdraw, allegro_wnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
@@ -123,10 +124,10 @@
pal[i].b = shift_gamma(system_palette[i].peBlue);
}
- create_rgb_table(&desktop_rgb_map, pal, NULL);
+ create_rgb_table(&_win_desktop_rgb_map, pal, NULL);
/* create_rgb_table() never maps RGB triplets to index 0 */
- desktop_rgb_map.data[pal[0].r>>1][pal[0].g>>1][pal[0].b>>1] = 0;
+ _win_desktop_rgb_map.data[pal[0].r>>1][pal[0].g>>1][pal[0].b>>1] = 0;
}
@@ -184,13 +185,13 @@
}
/* get the *real* color depth of the desktop */
- desktop_depth = surf_desc.ddpfPixelFormat.dwRGBBitCount;
- if (desktop_depth == 16) /* sure? */
- desktop_depth = get_color_bits(surf_desc.ddpfPixelFormat.dwRBitMask) +
+ _win_desktop_depth = surf_desc.ddpfPixelFormat.dwRGBBitCount;
+ if (_win_desktop_depth == 16) /* sure? */
+ _win_desktop_depth = get_color_bits(surf_desc.ddpfPixelFormat.dwRBitMask) +
get_color_bits(surf_desc.ddpfPixelFormat.dwGBitMask) +
get_color_bits(surf_desc.ddpfPixelFormat.dwBBitMask);
- if (color_depth == desktop_depth) {
+ if (color_depth == _win_desktop_depth) {
ddpixel_format = NULL;
return 0;
}
@@ -200,7 +201,7 @@
if ((pixel_realdepth[i] == color_depth) &&
((surf_desc.ddpfPixelFormat.dwRBitMask & pixel_format[i].dwRBitMask) ||
(surf_desc.ddpfPixelFormat.dwBBitMask & pixel_format[i].dwBBitMask) ||
- (desktop_depth == 8) || (color_depth == 8))) {
+ (_win_desktop_depth == 8) || (color_depth == 8))) {
ddpixel_format = &pixel_format[i];
break;
}
@@ -363,6 +364,7 @@
*/
int set_video_mode(int w, int h, int v_w, int v_h, int color_depth)
{
+ HWND allegro_wnd = win_get_window();
_wnd_width = w;
_wnd_height = h;
_wnd_depth = (color_depth == 15 ? 16 : color_depth);
diff -ur ./src/win/wddovl.c /windows/d/Program/allegro_cvs/src/win/wddovl.c
--- ./src/win/wddovl.c 2005-01-22 19:44:48.000000000 +0100
+++ /windows/d/Program/allegro_cvs/src/win/wddovl.c 2005-05-04 01:13:04.000000000 +0200
@@ -118,12 +118,12 @@
/* show the overlay surface */
hr = IDirectDrawSurface2_UpdateOverlay(overlay_surface->id, NULL,
- primary_surface->id, &dest_rect,
+ gfx_directx_primary_surface->id, &dest_rect,
DDOVER_SHOW | DDOVER_KEYDEST, NULL);
if (FAILED(hr)) {
_TRACE("Can't display overlay (%x)\n", hr);
IDirectDrawSurface2_UpdateOverlay(overlay_surface->id, NULL,
- primary_surface->id, NULL,
+ gfx_directx_primary_surface->id, NULL,
DDOVER_HIDE, NULL);
return -1;
}
@@ -152,6 +152,7 @@
static void move_overlay(int x, int y, int w, int h)
{
RECT window_rect;
+ HWND allegro_wnd = win_get_window();
int xmod;
/* handle hardware limitations */
@@ -175,7 +176,7 @@
overlay_visible = FALSE;
IDirectDrawSurface2_UpdateOverlay(overlay_surface->id, NULL,
- primary_surface->id, NULL,
+ gfx_directx_primary_surface->id, NULL,
DDOVER_HIDE, NULL);
}
}
@@ -190,7 +191,7 @@
/* We may have lost the DirectDraw surfaces, for example
* after the monitor has gone to low power.
*/
- if (IDirectDrawSurface2_IsLost(primary_surface->id))
+ if (IDirectDrawSurface2_IsLost(gfx_directx_primary_surface->id))
switch_in_overlay();
}
@@ -202,6 +203,7 @@
static int wnd_set_windowed_coop(void)
{
HRESULT hr;
+ HWND allegro_wnd = win_get_window();
hr = IDirectDraw2_SetCooperativeLevel(directdraw, allegro_wnd, DDSCL_NORMAL);
if (FAILED(hr)) {
@@ -214,16 +216,16 @@
-/* setup_driver_desc:
+/* gfx_directx_setup_driver_desc:
* Sets up the driver description string.
*/
-static void setup_driver_desc(void)
+static void gfx_directx_setup_driver_desc(void)
{
char tmp[256];
uszprintf(gfx_driver_desc, sizeof(gfx_driver_desc),
uconvert_ascii("DirectDraw, in matching, %d bpp overlay", tmp),
- desktop_depth);
+ _win_desktop_depth);
gfx_directx_ovl.desc = gfx_driver_desc;
}
@@ -286,6 +288,7 @@
{
HRESULT hr;
DDCOLORKEY key;
+ HWND allegro_wnd = win_get_window();
/* overlay would allow scrolling on some cards, but it isn't implemented yet */
if ((v_w != w && v_w != 0) || (v_h != h && v_h != 0)) {
@@ -322,7 +325,7 @@
}
/* create surfaces */
- if (create_primary() != 0)
+ if (gfx_directx_create_primary() != 0)
goto Error;
if (create_overlay(w, h, color_depth) != 0)
@@ -356,7 +359,7 @@
/* set color format */
if (color_depth == 8) {
- if (create_palette(overlay_surface) != 0)
+ if (gfx_directx_create_palette(overlay_surface) != 0)
goto Error;
}
else {
@@ -365,18 +368,18 @@
}
/* set up Allegro gfx driver */
- setup_driver_desc();
+ gfx_directx_setup_driver_desc();
- if (setup_driver(&gfx_directx_ovl, w, h, color_depth) != 0)
+ if (gfx_directx_setup_driver(&gfx_directx_ovl, w, h, color_depth) != 0)
goto Error;
- forefront_bitmap = make_bitmap_from_surface(overlay_surface, w, h, BMP_ID_VIDEO);
+ gfx_directx_forefront_bitmap = gfx_directx_make_bitmap_from_surface(overlay_surface, w, h, BMP_ID_VIDEO);
/* set the overlay color key */
- key.dwColorSpaceLowValue = forefront_bitmap->vtable->mask_color;
- key.dwColorSpaceHighValue = forefront_bitmap->vtable->mask_color;
+ key.dwColorSpaceLowValue = gfx_directx_forefront_bitmap->vtable->mask_color;
+ key.dwColorSpaceHighValue = gfx_directx_forefront_bitmap->vtable->mask_color;
- hr = IDirectDrawSurface2_SetColorKey(primary_surface->id, DDCKEY_DESTOVERLAY, &key);
+ hr = IDirectDrawSurface2_SetColorKey(gfx_directx_primary_surface->id, DDCKEY_DESTOVERLAY, &key);
if (FAILED(hr)) {
_TRACE("Can't set overlay dest color key\n");
goto Error;
@@ -386,10 +389,10 @@
show_overlay();
/* use hardware accelerated primitives */
- enable_acceleration(&gfx_directx_ovl);
+ gfx_directx_enable_acceleration(&gfx_directx_ovl);
/* use triple buffering */
- enable_triple_buffering(&gfx_directx_ovl);
+ gfx_directx_enable_triple_buffering(&gfx_directx_ovl);
/* connect to the system driver */
win_gfx_driver = &win_gfx_driver_overlay;
@@ -402,7 +405,7 @@
_exit_critical();
- return forefront_bitmap;
+ return gfx_directx_forefront_bitmap;
Error:
_exit_critical();
@@ -420,6 +423,7 @@
*/
static void gfx_directx_ovl_exit(struct BITMAP *bmp)
{
+ HWND allegro_wnd = win_get_window();
_enter_gfx_critical();
if (bmp) {
@@ -437,7 +441,7 @@
DeleteObject(overlay_brush);
gfx_directx_destroy_surface(overlay_surface);
overlay_surface = NULL;
- forefront_bitmap = NULL;
+ gfx_directx_forefront_bitmap = NULL;
}
gfx_directx_exit(NULL);
diff -ur ./src/win/wddraw.c /windows/d/Program/allegro_cvs/src/win/wddraw.c
--- ./src/win/wddraw.c 2005-04-25 19:39:42.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wddraw.c 2005-05-04 01:10:06.000000000 +0200
@@ -26,8 +26,8 @@
LPDDPIXELFORMAT ddpixel_format = NULL;
DDCAPS ddcaps;
-DDRAW_SURFACE *primary_surface = NULL;
-BITMAP *forefront_bitmap = NULL;
+DDRAW_SURFACE *gfx_directx_primary_surface = NULL;
+BITMAP *gfx_directx_forefront_bitmap = NULL;
char *pseudo_surf_mem;
/* DirectDraw internals */
@@ -43,6 +43,7 @@
LPDIRECTDRAW directdraw1;
HRESULT hr;
LPVOID temp;
+ HWND allegro_wnd = win_get_window();
/* first we have to set up the DirectDraw1 interface... */
hr = DirectDrawCreate(NULL, &directdraw1, NULL);
@@ -75,14 +76,14 @@
-/* create_primary:
+/* gfx_directx_create_primary:
* Low-level DirectDraw screen creation routine.
*/
-int create_primary(void)
+int gfx_directx_create_primary(void)
{
/* create primary surface */
- primary_surface = gfx_directx_create_surface(0, 0, NULL, DDRAW_SURFACE_PRIMARY);
- if (!primary_surface) {
+ gfx_directx_primary_surface = gfx_directx_create_surface(0, 0, NULL, DDRAW_SURFACE_PRIMARY);
+ if (!gfx_directx_primary_surface) {
_TRACE("Can't create primary surface.\n");
return -1;
}
@@ -92,10 +93,10 @@
-/* create_clipper:
+/* gfx_directx_create_clipper:
* Low-level DirectDraw clipper creation routine.
*/
-int create_clipper(HWND hwnd)
+int gfx_directx_create_clipper(HWND hwnd)
{
HRESULT hr;
@@ -116,10 +117,10 @@
-/* create_palette:
+/* gfx_directx_create_palette:
* Low-level DirectDraw palette creation routine.
*/
-int create_palette(DDRAW_SURFACE *surf)
+int gfx_directx_create_palette(DDRAW_SURFACE *surf)
{
HRESULT hr;
int n;
@@ -148,10 +149,10 @@
-/* setup_driver:
+/* gfx_directx_setup_driver:
* Helper function for initializing the gfx driver.
*/
-int setup_driver(GFX_DRIVER *drv, int w, int h, int color_depth)
+int gfx_directx_setup_driver(GFX_DRIVER *drv, int w, int h, int color_depth)
{
DDSCAPS ddsCaps;
@@ -204,9 +205,9 @@
*/
int exit_directx(void)
{
- if (directdraw) {
+ if (directdraw) {
/* set cooperative level back to normal */
- IDirectDraw2_SetCooperativeLevel(directdraw, allegro_wnd, DDSCL_NORMAL);
+ IDirectDraw2_SetCooperativeLevel(directdraw, win_get_window(), DDSCL_NORMAL);
/* release DirectDraw interface */
IDirectDraw2_Release(directdraw);
@@ -242,27 +243,27 @@
goto Error;
/* create screen */
- if (create_primary() != 0)
+ if (gfx_directx_create_primary() != 0)
goto Error;
/* set color format */
if (color_depth == 8) {
- if (create_palette(primary_surface) != 0)
+ if (gfx_directx_create_palette(gfx_directx_primary_surface) != 0)
goto Error;
}
else {
- if (gfx_directx_update_color_format(primary_surface, color_depth) != 0)
+ if (gfx_directx_update_color_format(gfx_directx_primary_surface, color_depth) != 0)
goto Error;
}
/* set gfx driver interface */
- if (setup_driver(drv, w, h, color_depth) != 0)
+ if (gfx_directx_setup_driver(drv, w, h, color_depth) != 0)
goto Error;
/* create forefront bitmap */
- forefront_bitmap = make_bitmap_from_surface(primary_surface, w, h, BMP_ID_VIDEO);
+ gfx_directx_forefront_bitmap = gfx_directx_make_bitmap_from_surface(gfx_directx_primary_surface, w, h, BMP_ID_VIDEO);
- return forefront_bitmap;
+ return gfx_directx_forefront_bitmap;
Error:
gfx_directx_exit(NULL);
@@ -320,10 +321,10 @@
win_gfx_driver = NULL;
/* destroy primary surface */
- if (primary_surface) {
- gfx_directx_destroy_surface(primary_surface);
- primary_surface = NULL;
- forefront_bitmap = NULL;
+ if (gfx_directx_primary_surface) {
+ gfx_directx_destroy_surface(gfx_directx_primary_surface);
+ gfx_directx_primary_surface = NULL;
+ gfx_directx_forefront_bitmap = NULL;
}
/* normally this list must be empty */
@@ -380,6 +381,7 @@
ICONINFO iconinfo;
HBITMAP hOldAndMaskBitmap;
HBITMAP hOldXorMaskBitmap;
+ HWND allegro_wnd = win_get_window();
if (hcursor) {
if (_win_hcursor == hcursor)
diff -ur ./src/win/wddraw.h /windows/d/Program/allegro_cvs/src/win/wddraw.h
--- ./src/win/wddraw.h 2004-09-25 10:24:51.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wddraw.h 2005-05-04 00:14:18.000000000 +0200
@@ -66,8 +66,8 @@
AL_VAR(LPDDPIXELFORMAT, ddpixel_format);
AL_VAR(DDCAPS, ddcaps);
-AL_VAR(DDRAW_SURFACE *, primary_surface);
-AL_VAR(BITMAP *, forefront_bitmap);
+AL_VAR(DDRAW_SURFACE *, gfx_directx_primary_surface);
+AL_VAR(BITMAP *, gfx_directx_forefront_bitmap);
AL_VAR(char *, pseudo_surf_mem);
@@ -93,22 +93,22 @@
/* driver initialisation and shutdown (from wddraw.c) */
AL_FUNC(int, init_directx, (void));
-AL_FUNC(int, create_primary, (void));
-AL_FUNC(int, create_clipper, (HWND hwnd));
-AL_FUNC(int, create_palette, (DDRAW_SURFACE *surf));
-AL_FUNC(int, setup_driver, (GFX_DRIVER * drv, int w, int h, int color_depth));
+AL_FUNC(int, gfx_directx_create_primary, (void));
+AL_FUNC(int, gfx_directx_create_clipper, (HWND hwnd));
+AL_FUNC(int, gfx_directx_create_palette, (DDRAW_SURFACE *surf));
+AL_FUNC(int, gfx_directx_setup_driver, (GFX_DRIVER * drv, int w, int h, int color_depth));
AL_FUNC(int, finalize_directx_init, (void));
AL_FUNC(int, exit_directx, (void));
/* driver initialisation and shutdown (from wddaccel.c) */
-AL_FUNC(void, enable_acceleration, (GFX_DRIVER *drv));
-AL_FUNC(void, enable_triple_buffering, (GFX_DRIVER *drv));
+AL_FUNC(void, gfx_directx_enable_acceleration, (GFX_DRIVER *drv));
+AL_FUNC(void, gfx_directx_enable_triple_buffering, (GFX_DRIVER *drv));
/* video mode setting (from wddmode.c) */
-AL_VAR(int, desktop_depth);
-AL_VAR(RGB_MAP, desktop_rgb_map);
+AL_VAR(int, _win_desktop_depth);
+AL_VAR(RGB_MAP, _win_desktop_rgb_map);
AL_FUNC(void, build_desktop_rgb_map, (void));
AL_FUNC(int, gfx_directx_compare_color_depth, (int color_depth));
@@ -133,7 +133,7 @@
/* bitmap creation (from wddbmp.c) */
AL_FUNC(DDRAW_SURFACE *, gfx_directx_create_surface, (int w, int h, LPDDPIXELFORMAT pixel_format, int type));
AL_FUNC(void, gfx_directx_destroy_surface, (DDRAW_SURFACE *surf));
-AL_FUNC(BITMAP *, make_bitmap_from_surface, (DDRAW_SURFACE *surf, int w, int h, int id));
+AL_FUNC(BITMAP *, gfx_directx_make_bitmap_from_surface, (DDRAW_SURFACE *surf, int w, int h, int id));
/* video bitmap list (from wddbmpl.c) */
diff -ur ./src/win/wddwin.c /windows/d/Program/allegro_cvs/src/win/wddwin.c
--- ./src/win/wddwin.c 2005-01-22 19:44:48.000000000 +0100
+++ /windows/d/Program/allegro_cvs/src/win/wddwin.c 2005-05-04 01:18:00.000000000 +0200
@@ -166,11 +166,12 @@
{
int xmod;
RECT window_rect;
+ HWND allegro_wnd = win_get_window();
if (colorconv_blit) {
- if (((BYTES_PER_PIXEL(desktop_depth) == 1) && (xmod=ABS(x)%4)) ||
- ((BYTES_PER_PIXEL(desktop_depth) == 2) && (xmod=ABS(x)%2)) ||
- ((BYTES_PER_PIXEL(desktop_depth) == 3) && (xmod=ABS(x)%4))) {
+ if (((BYTES_PER_PIXEL(_win_desktop_depth) == 1) && (xmod=ABS(x)%4)) ||
+ ((BYTES_PER_PIXEL(_win_desktop_depth) == 2) && (xmod=ABS(x)%2)) ||
+ ((BYTES_PER_PIXEL(_win_desktop_depth) == 3) && (xmod=ABS(x)%4))) {
GetWindowRect(allegro_wnd, &window_rect);
SetWindowPos(allegro_wnd, 0, window_rect.left + (x > 0 ? -xmod : xmod),
window_rect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
@@ -194,7 +195,7 @@
/* we may have lost the DirectDraw surfaces
* (e.g after the monitor has gone to low power)
*/
- if (IDirectDrawSurface2_IsLost(primary_surface->id))
+ if (IDirectDrawSurface2_IsLost(gfx_directx_primary_surface->id))
switch_in_win();
/* clip the rectangle */
@@ -211,6 +212,7 @@
*/
static void update_matching_window(RECT *rect)
{
+ HWND allegro_wnd = win_get_window();
union {
POINT p;
RECT r;
@@ -218,7 +220,7 @@
_enter_gfx_critical();
- if (!forefront_bitmap) {
+ if (!gfx_directx_forefront_bitmap) {
_exit_gfx_critical();
return;
}
@@ -236,7 +238,7 @@
ClientToScreen(allegro_wnd, &dest_rect.p + 1);
/* blit offscreen backbuffer to the window */
- IDirectDrawSurface2_Blt(primary_surface->id, &dest_rect.r,
+ IDirectDrawSurface2_Blt(gfx_directx_primary_surface->id, &dest_rect.r,
offscreen_surface->id, rect, 0, NULL);
_exit_gfx_critical();
@@ -321,10 +323,11 @@
HDC src_dc, dest_dc;
HRESULT hr;
int direct;
+ HWND allegro_wnd = win_get_window();
_enter_gfx_critical();
- if (!forefront_bitmap) {
+ if (!gfx_directx_forefront_bitmap) {
_exit_gfx_critical();
return;
}
@@ -357,7 +360,7 @@
if (direct) {
/* blit directly to the primary surface without clipping */
- ddsurf_blit_ex(primary_surface->id, &dest_rect.r,
+ ddsurf_blit_ex(gfx_directx_primary_surface->id, &dest_rect.r,
offscreen_surface->id, &src_rect);
}
else {
@@ -400,9 +403,9 @@
BITMAP *bmp;
/* try to detect page flipping and triple buffering patterns */
- if ((width == forefront_bitmap->w) && (height == forefront_bitmap->h) && (!reused_offscreen_surface)) {
+ if ((width == gfx_directx_forefront_bitmap->w) && (height == gfx_directx_forefront_bitmap->h) && (!reused_offscreen_surface)) {
/* recycle the offscreen surface as a video bitmap */
- bmp = make_bitmap_from_surface(offscreen_surface, width, height, BMP_ID_VIDEO);
+ bmp = gfx_directx_make_bitmap_from_surface(offscreen_surface, width, height, BMP_ID_VIDEO);
if (bmp) {
bmp->vtable = &_special_vtable;
bmp->write_bank = gfx_directx_write_bank_win;
@@ -426,7 +429,7 @@
return NULL;
/* create the bitmap that wraps up the surface */
- bmp = make_bitmap_from_surface(surf, width, height, BMP_ID_VIDEO);
+ bmp = gfx_directx_make_bitmap_from_surface(surf, width, height, BMP_ID_VIDEO);
if (!bmp) {
gfx_directx_destroy_surface(surf);
return NULL;
@@ -476,7 +479,7 @@
former_visible_bmp = offscreen_surface->parent_bmp;
/* manually flip the offscreen surface */
- forefront_bitmap->extra = surf;
+ gfx_directx_forefront_bitmap->extra = surf;
offscreen_surface = surf;
/* restore regular methods for video bitmaps */
@@ -510,7 +513,7 @@
cmap = _get_colorconv_map();
for (n = from; n <= to; n++)
- cmap[n] = desktop_rgb_map.data[p[n].r>>1][p[n].g>>1][p[n].b>>1];
+ cmap[n] = _win_desktop_rgb_map.data[p[n].r>>1][p[n].g>>1][p[n].b>>1];
update_window(NULL);
}
@@ -539,7 +542,8 @@
static int wnd_set_windowed_coop(void)
{
HRESULT hr;
-
+ HWND allegro_wnd = win_get_window();
+
hr = IDirectDraw2_SetCooperativeLevel(directdraw, allegro_wnd, DDSCL_NORMAL);
if (FAILED(hr)) {
_TRACE("SetCooperative level = %s (%x), hwnd = %x\n", win_err_str(hr), hr, allegro_wnd);
@@ -566,11 +570,11 @@
}
else {
/* disallow cross-conversion between 15-bit and 16-bit colors */
- if ((BYTES_PER_PIXEL(color_depth) == 2) && (BYTES_PER_PIXEL(desktop_depth) == 2))
+ if ((BYTES_PER_PIXEL(color_depth) == 2) && (BYTES_PER_PIXEL(_win_desktop_depth) == 2))
return -1;
/* the color depths don't match, need color conversion */
- colorconv_blit = _get_colorconv_blitter(color_depth, desktop_depth);
+ colorconv_blit = _get_colorconv_blitter(color_depth, _win_desktop_depth);
if (!colorconv_blit)
return -1;
@@ -625,17 +629,17 @@
}
-/* setup_driver_desc:
+/* gfx_directx_setup_driver_desc:
* Sets the driver description string.
*/
-static void setup_driver_desc(void)
+static void gfx_directx_setup_driver_desc(void)
{
char tmp1[128], tmp2[128];
uszprintf(gfx_driver_desc, sizeof(gfx_driver_desc),
uconvert_ascii("DirectDraw, in %s, %d bpp window", tmp1),
uconvert_ascii((colorconv_blit ? "color conversion" : "matching"), tmp2),
- desktop_depth);
+ _win_desktop_depth);
gfx_directx_win.desc = gfx_driver_desc;
}
@@ -650,6 +654,7 @@
unsigned char *cmap;
HRESULT hr;
int i;
+ HWND allegro_wnd = win_get_window();
/* flipping is impossible in windowed mode */
if ((v_w != w && v_w != 0) || (v_h != h && v_h != 0)) {
@@ -686,14 +691,14 @@
get_working_area(&working_area);
/* create primary surface */
- if (create_primary() != 0)
+ if (gfx_directx_create_primary() != 0)
goto Error;
/* create clipper */
- if (create_clipper(allegro_wnd) != 0)
+ if (gfx_directx_create_clipper(allegro_wnd) != 0)
goto Error;
- hr = IDirectDrawSurface_SetClipper(primary_surface->id, ddclipper);
+ hr = IDirectDrawSurface_SetClipper(gfx_directx_primary_surface->id, ddclipper);
if (FAILED(hr))
goto Error;
@@ -704,7 +709,7 @@
}
/* setup color management */
- if (desktop_depth == 8) {
+ if (_win_desktop_depth == 8) {
build_desktop_rgb_map();
if (color_depth == 8) {
@@ -714,7 +719,7 @@
cmap = _get_colorconv_map();
for (i=0; i<4096; i++)
- cmap[i] = desktop_rgb_map.data[((i&0xF00)>>7) | ((i&0x800)>>11)]
+ cmap[i] = _win_desktop_rgb_map.data[((i&0xF00)>>7) | ((i&0x800)>>11)]
[((i&0x0F0)>>3) | ((i&0x080)>>7)]
[((i&0x00F)<<1) | ((i&0x008)>>3)];
@@ -726,11 +731,11 @@
if (color_depth == 8) {
gfx_directx_win.set_palette = gfx_directx_set_palette_win;
- if (create_palette(offscreen_surface) != 0)
+ if (gfx_directx_create_palette(offscreen_surface) != 0)
goto Error;
/* init the core library color conversion functions */
- if (gfx_directx_update_color_format(primary_surface, desktop_depth) != 0)
+ if (gfx_directx_update_color_format(gfx_directx_primary_surface, _win_desktop_depth) != 0)
goto Error;
}
else {
@@ -740,18 +745,18 @@
}
/* setup Allegro gfx driver */
- setup_driver_desc();
- if (setup_driver(&gfx_directx_win, w, h, color_depth) != 0)
+ gfx_directx_setup_driver_desc();
+ if (gfx_directx_setup_driver(&gfx_directx_win, w, h, color_depth) != 0)
goto Error;
- forefront_bitmap = make_bitmap_from_surface(offscreen_surface, w, h, BMP_ID_VIDEO);
+ gfx_directx_forefront_bitmap = gfx_directx_make_bitmap_from_surface(offscreen_surface, w, h, BMP_ID_VIDEO);
- enable_acceleration(&gfx_directx_win);
+ gfx_directx_enable_acceleration(&gfx_directx_win);
memcpy(&_special_vtable, &_screen_vtable, sizeof (GFX_VTABLE));
_special_vtable.release = gfx_directx_unlock_win;
_special_vtable.unwrite_bank = gfx_directx_unwrite_bank_win;
- forefront_bitmap->vtable = &_special_vtable;
- forefront_bitmap->write_bank = gfx_directx_write_bank_win;
+ gfx_directx_forefront_bitmap->vtable = &_special_vtable;
+ gfx_directx_forefront_bitmap->write_bank = gfx_directx_write_bank_win;
/* the last flag serves as end of loop delimiter */
wd_dirty_lines = calloc(h+1, sizeof(char));
@@ -768,7 +773,7 @@
_exit_critical();
- return forefront_bitmap;
+ return gfx_directx_forefront_bitmap;
Error:
_exit_critical();
@@ -807,7 +812,7 @@
gfx_directx_destroy_surface(offscreen_surface);
offscreen_surface = NULL;
reused_offscreen_surface = FALSE;
- forefront_bitmap = NULL;
+ gfx_directx_forefront_bitmap = NULL;
}
/* release the color conversion blitter */
diff -ur ./src/win/wdispsw.c /windows/d/Program/allegro_cvs/src/win/wdispsw.c
--- ./src/win/wdispsw.c 2003-10-25 15:31:56.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wdispsw.c 2005-05-04 00:38:50.000000000 +0200
@@ -26,17 +26,17 @@
#endif
-int app_foreground = TRUE;
+int _win_app_foreground = TRUE;
static HANDLE foreground_event = NULL;
static int allegro_thread_priority = THREAD_PRIORITY_NORMAL;
-/* sys_reset_switch_mode:
+/* _win_reset_switch_mode:
* Resets the switch mode to its default state.
*/
-void sys_reset_switch_mode(void)
+void _win_reset_switch_mode(void)
{
/* The default state must be SWITCH_BACKGROUND so that the
threads don't get blocked when the focus moves forth and
@@ -44,7 +44,7 @@
to be particularly relevant to WinXP. */
set_display_switch_mode(SWITCH_BACKGROUND);
- app_foreground = TRUE;
+ _win_app_foreground = TRUE;
/* This has a nice side-effect: releasing the blocked threads. */
SetEvent(foreground_event);
@@ -57,7 +57,7 @@
void sys_directx_display_switch_init(void)
{
foreground_event = CreateEvent(NULL, TRUE, TRUE, NULL);
- sys_reset_switch_mode();
+ _win_reset_switch_mode();
}
@@ -98,16 +98,16 @@
-/* sys_switch_in:
+/* _win_switch_in:
* Puts the library in the foreground.
*/
-void sys_switch_in(void)
+void _win_switch_in(void)
{
int mode;
_TRACE("switch in\n");
- app_foreground = TRUE;
+ _win_app_foreground = TRUE;
key_dinput_acquire();
mouse_dinput_acquire();
@@ -132,16 +132,16 @@
-/* sys_switch_out:
+/* _win_switch_out:
* Puts the library in the background.
*/
-void sys_switch_out(void)
+void _win_switch_out(void)
{
int mode;
_TRACE("switch out\n");
- app_foreground = FALSE;
+ _win_app_foreground = FALSE;
key_dinput_unacquire();
mouse_dinput_unacquire();
@@ -170,11 +170,11 @@
-/* thread_switch_out:
+/* _win_thread_switch_out:
* Handles a switch out event for the calling thread.
* Returns TRUE if the thread was blocked, FALSE otherwise.
*/
-int thread_switch_out(void)
+int _win_thread_switch_out(void)
{
int mode = get_display_switch_mode();
diff -ur ./src/win/wdsndmix.c /windows/d/Program/allegro_cvs/src/win/wdsndmix.c
--- ./src/win/wdsndmix.c 2004-07-04 15:37:13.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wdsndmix.c 2005-05-04 00:54:44.000000000 +0200
@@ -186,7 +186,7 @@
switch_mode = get_display_switch_mode();
if (prim_buf_paused) {
- if (app_foreground ||
+ if (_win_app_foreground ||
(switch_mode == SWITCH_BACKGROUND) || (switch_mode == SWITCH_BACKAMNESIA)) {
prim_buf_paused = FALSE;
IDirectSoundBuffer_Play(prim_buf, 0, 0, DSBPLAY_LOOPING);
@@ -195,7 +195,7 @@
return;
}
else {
- if (!app_foreground &&
+ if (!_win_app_foreground &&
((switch_mode == SWITCH_PAUSE) || (switch_mode == SWITCH_AMNESIA))) {
prim_buf_paused = TRUE;
IDirectSoundBuffer_Stop(prim_buf);
@@ -355,6 +355,7 @@
DSCAPS dscaps;
DSBUFFERDESC desc;
WAVEFORMATEX format;
+ HWND allegro_wnd = win_get_window();
int v, id;
/* deduce our device number from the driver ID code */
diff -ur ./src/win/wdsound.c /windows/d/Program/allegro_cvs/src/win/wdsound.c
--- ./src/win/wdsound.c 2005-03-27 23:08:07.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wdsound.c 2005-05-04 01:18:00.000000000 +0200
@@ -372,7 +372,8 @@
DSBUFFERDESC desc;
WAVEFORMATEX format;
int v, id;
-
+ HWND allegro_wnd = win_get_window();
+
/* deduce our device number from the driver ID code */
id = ((digi_driver->id >> 8) & 0xFF) - 'A';
diff -ur ./src/win/wgdi.c /windows/d/Program/allegro_cvs/src/win/wgdi.c
--- ./src/win/wgdi.c 2005-01-22 19:44:48.000000000 +0100
+++ /windows/d/Program/allegro_cvs/src/win/wgdi.c 2005-05-04 00:41:58.000000000 +0200
@@ -157,6 +157,7 @@
static void update_mouse_pointer(int x, int y, int retrace)
{
HDC hdc;
+ HWND allegro_wnd = win_get_window();
/* put the screen contents located at the new position into the frontbuffer */
blit(gdi_screen, mouse_frontbuffer, x, y, 0, 0, mouse_frontbuffer->w, mouse_frontbuffer->h);
@@ -214,6 +215,7 @@
static void gfx_gdi_hide_mouse(void)
{
HDC hdc;
+ HWND allegro_wnd = win_get_window();
if (!mouse_on)
return;
@@ -258,6 +260,7 @@
{
int top_line, bottom_line;
HDC hdc = NULL;
+ HWND allegro_wnd = win_get_window();
/* to prevent reentrant calls */
if (render_semaphore)
@@ -363,6 +366,7 @@
static void gdi_update_window(RECT *rect)
{
HDC hdc;
+ HWND allegro_wnd = win_get_window();
_enter_gfx_critical();
@@ -396,14 +400,14 @@
_enter_gfx_critical();
/* arrange for drawing requests to pause when we are in the background */
- if (!app_foreground) {
+ if (!_win_app_foreground) {
/* stop timer */
remove_int(render_proc);
_exit_gfx_critical();
if (GFX_CRITICAL_RELEASED)
- thread_switch_out();
+ _win_thread_switch_out();
_enter_gfx_critical();
diff -ur ./src/win/winput.c /windows/d/Program/allegro_cvs/src/win/winput.c
--- ./src/win/winput.c 2002-09-08 18:42:48.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/winput.c 2005-05-04 00:55:32.000000000 +0200
@@ -32,9 +32,9 @@
#define MAX_EVENTS 8
/* input thread event queue */
-int input_events;
-HANDLE input_event_id[MAX_EVENTS];
-void (*input_event_handler[MAX_EVENTS])(void);
+int _win_input_events;
+HANDLE _win_input_event_id[MAX_EVENTS];
+void (*_win_input_event_handler[MAX_EVENTS])(void);
/* pending event waiting for being processed */
static HANDLE pending_event_id;
@@ -57,20 +57,20 @@
{
int result;
- thread_init();
+ _win_thread_init();
_TRACE("input thread starts\n");
/* event loop */
while (TRUE) {
- result = WaitForMultipleObjects(input_events, input_event_id, FALSE, INFINITE);
+ result = WaitForMultipleObjects(_win_input_events, _win_input_event_id, FALSE, INFINITE);
if (result == WAIT_OBJECT_0 + 2)
break; /* thread suicide */
- else if ((result >= WAIT_OBJECT_0) && (result < WAIT_OBJECT_0 + input_events))
- (*input_event_handler[result - WAIT_OBJECT_0])();
+ else if ((result >= WAIT_OBJECT_0) && (result < WAIT_OBJECT_0 + _win_input_events))
+ (*_win_input_event_handler[result - WAIT_OBJECT_0])();
}
_TRACE("input thread exits\n");
- thread_exit();
+ _win_thread_exit();
}
@@ -81,11 +81,11 @@
static void register_pending_event(void)
{
/* add the pending event to the queue */
- input_event_id[input_events] = pending_event_id;
- input_event_handler[input_events] = pending_event_handler;
+ _win_input_event_id[_win_input_events] = pending_event_id;
+ _win_input_event_handler[_win_input_events] = pending_event_handler;
/* adjust the size of the queue */
- input_events++;
+ _win_input_events++;
/* acknowledge the registration */
SetEvent(ack_event);
@@ -101,8 +101,8 @@
int i, found = -1;
/* look for the pending event in the event queue */
- for (i=reserved_events; i<input_events; i++) {
- if (input_event_id[i] == pending_event_id) {
+ for (i=reserved_events; i<_win_input_events; i++) {
+ if (_win_input_event_id[i] == pending_event_id) {
found = i;
break;
}
@@ -110,13 +110,13 @@
if (found >= 0) {
/* shift the queue to the left */
- for (i=found; i<input_events-1; i++) {
- input_event_id[i] = input_event_id[i+1];
- input_event_handler[i] = input_event_handler[i+1];
+ for (i=found; i<_win_input_events-1; i++) {
+ _win_input_event_id[i] = _win_input_event_id[i+1];
+ _win_input_event_handler[i] = _win_input_event_handler[i+1];
}
/* adjust the size of the queue */
- input_events--;
+ _win_input_events--;
}
/* acknowledge the unregistration */
@@ -125,12 +125,12 @@
-/* input_register_event: [primary thread]
+/* _win_input_register_event: [primary thread]
* Adds an event to the input thread event queue.
*/
-int input_register_event(HANDLE event_id, void (*event_handler)(void))
+int _win_input_register_event(HANDLE event_id, void (*event_handler)(void))
{
- if (input_events == MAX_EVENTS)
+ if (_win_input_events == MAX_EVENTS)
return -1;
/* record the event */
@@ -142,55 +142,55 @@
input_thread = (HANDLE) _beginthread(input_thread_proc, 0, NULL);
/* ask the input thread to register the pending event */
- SetEvent(input_event_id[0]);
+ SetEvent(_win_input_event_id[0]);
/* wait for the input thread to acknowledge */
WaitForSingleObject(ack_event, INFINITE);
- _TRACE("1 input event registered (total = %d)\n", input_events-reserved_events);
+ _TRACE("1 input event registered (total = %d)\n", _win_input_events-reserved_events);
return 0;
}
-/* input_unregister_event: [primary thread]
+/* _win_input_unregister_event: [primary thread]
* Removes an event from the input thread event queue.
*/
-void input_unregister_event(HANDLE event_id)
+void _win_input_unregister_event(HANDLE event_id)
{
/* record the event */
pending_event_id = event_id;
/* ask the input thread to unregister the pending event */
- SetEvent(input_event_id[1]);
+ SetEvent(_win_input_event_id[1]);
/* wait for the input thread to acknowledge */
WaitForSingleObject(ack_event, INFINITE);
/* kill the input thread if no more event */
- if (input_need_thread && (input_events == reserved_events)) {
- SetEvent(input_event_id[2]); /* thread suicide */
+ if (input_need_thread && (_win_input_events == reserved_events)) {
+ SetEvent(_win_input_event_id[2]); /* thread suicide */
input_thread = NULL;
}
- _TRACE("1 input event unregistered (total = %d)\n", input_events-reserved_events);
+ _TRACE("1 input event unregistered (total = %d)\n", _win_input_events-reserved_events);
}
-/* input_init: [primary thread]
+/* _win_input_init: [primary thread]
* Initializes the module.
*/
-void input_init(int need_thread)
+void _win_input_init(int need_thread)
{
- input_event_id[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
- input_event_handler[0] = register_pending_event;
- input_event_id[1] = CreateEvent(NULL, FALSE, FALSE, NULL);
- input_event_handler[1] = unregister_pending_event;
+ _win_input_event_id[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
+ _win_input_event_handler[0] = register_pending_event;
+ _win_input_event_id[1] = CreateEvent(NULL, FALSE, FALSE, NULL);
+ _win_input_event_handler[1] = unregister_pending_event;
if (need_thread) {
input_need_thread = TRUE;
- input_event_id[2] = CreateEvent(NULL, FALSE, FALSE, NULL);
+ _win_input_event_id[2] = CreateEvent(NULL, FALSE, FALSE, NULL);
reserved_events = 3;
}
else {
@@ -198,24 +198,24 @@
reserved_events = 2;
}
- input_events = reserved_events;
+ _win_input_events = reserved_events;
ack_event = CreateEvent(NULL, FALSE, FALSE, NULL);
}
-/* input_exit: [primary thread]
+/* _win_input_exit: [primary thread]
* Shuts down the module.
*/
-void input_exit(void)
+void _win_input_exit(void)
{
int i;
for (i=0; i<reserved_events; i++)
- CloseHandle(input_event_id[i]);
+ CloseHandle(_win_input_event_id[i]);
- input_events = 0;
+ _win_input_events = 0;
CloseHandle(ack_event);
}
diff -ur ./src/win/wjoydx.c /windows/d/Program/allegro_cvs/src/win/wjoydx.c
--- ./src/win/wjoydx.c 2004-07-04 15:37:13.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wjoydx.c 2005-05-04 01:18:00.000000000 +0200
@@ -328,7 +328,8 @@
LPDIRECTINPUTDEVICE2 dinput_device = NULL;
HRESULT hr;
LPVOID temp;
-
+ HWND allegro_wnd = win_get_window();
+
DIPROPRANGE property_range =
{
/* the header */
diff -ur ./src/win/wkeybd.c /windows/d/Program/allegro_cvs/src/win/wkeybd.c
--- ./src/win/wkeybd.c 2005-05-01 23:25:18.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wkeybd.c 2005-05-04 01:18:00.000000000 +0200
@@ -311,6 +311,7 @@
*/
static void key_dinput_handle_scancode(unsigned char scancode, int pressed)
{
+ HWND allegro_wnd = win_get_window();
/* ignore special Windows keys (alt+tab, alt+space, (ctrl|alt)+esc) */
if (((scancode == DIK_TAB) && (_key_shifts & KB_ALT_FLAG))
|| ((scancode == DIK_SPACE) && (_key_shifts & KB_ALT_FLAG))
@@ -473,7 +474,7 @@
{
if (key_dinput_device) {
/* unregister event handler first */
- input_unregister_event(key_input_event);
+ _win_input_unregister_event(key_input_event);
/* unacquire device */
wnd_call_proc(key_dinput_unacquire);
@@ -524,6 +525,7 @@
static int key_dinput_init(void)
{
HRESULT hr;
+ HWND allegro_wnd = win_get_window();
DIPROPDWORD property_buf_size =
{
/* the header */
@@ -570,7 +572,7 @@
goto Error;
/* Register event handler */
- if (input_register_event(key_input_event, key_dinput_handle) != 0)
+ if (_win_input_register_event(key_input_event, key_dinput_handle) != 0)
goto Error;
get_reverse_mapping();
diff -ur ./src/win/wmidi.c /windows/d/Program/allegro_cvs/src/win/wmidi.c
--- ./src/win/wmidi.c 2004-08-20 09:47:51.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wmidi.c 2005-05-04 01:01:04.000000000 +0200
@@ -48,7 +48,7 @@
int midi_win32_in_detect(int input);
int midi_win32_in_init(int input, int voices);
void midi_win32_in_exit(int input);
-void CALLBACK midi_in_proc(HMIDIIN, UINT, DWORD, DWORD, DWORD);
+static void CALLBACK midi_in_proc(HMIDIIN, UINT, DWORD, DWORD, DWORD);
/* driver globals */
@@ -61,8 +61,8 @@
/* MIDI recording callback */
-void CALLBACK midi_in_proc(HMIDIIN hMidiIn, UINT wMsg, DWORD dwInstance,
- DWORD dwParam1, DWORD dwParam2)
+static void CALLBACK midi_in_proc(HMIDIIN hMidiIn, UINT wMsg, DWORD dwInstance,
+ DWORD dwParam1, DWORD dwParam2)
{
if ((midi_in_device == NULL) || (midi_recorder == NULL)) return;
midi_recorder((unsigned char)(dwParam1 & 0xff)); /* status byte */
@@ -324,7 +324,7 @@
switch (get_display_switch_mode()) {
case SWITCH_AMNESIA:
case SWITCH_PAUSE:
- if (app_foreground)
+ if (_win_app_foreground)
midiOutShortMsg(midi_device, midi_msg);
else
midiOutReset(midi_device);
diff -ur ./src/win/wmouse.c /windows/d/Program/allegro_cvs/src/win/wmouse.c
--- ./src/win/wmouse.c 2005-04-25 19:39:42.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wmouse.c 2005-05-04 01:01:50.000000000 +0200
@@ -445,6 +445,7 @@
{
HRESULT hr;
DWORD level;
+ HWND allegro_wnd = win_get_window();
if (mouse_dinput_device) {
/* necessary in order to set the cooperative level */
@@ -488,6 +489,7 @@
*/
int mouse_set_syscursor(void)
{
+ HWND allegro_wnd = win_get_window();
if ((mouse_dinput_device && _mouse_on) || (gfx_driver && !gfx_driver->windowed)) {
SetCursor(_win_hcursor);
/* Make sure the cursor is removed by the system. */
@@ -534,7 +536,7 @@
{
if (mouse_dinput_device) {
/* unregister event handler first */
- input_unregister_event(mouse_input_event);
+ _win_input_unregister_event(mouse_input_event);
/* unacquire device */
wnd_call_proc(mouse_dinput_unacquire);
@@ -637,7 +639,7 @@
goto Error;
/* Register event handler */
- if (input_register_event(mouse_input_event, mouse_dinput_handle) != 0)
+ if (_win_input_register_event(mouse_input_event, mouse_dinput_handle) != 0)
goto Error;
/* Grab the device */
@@ -797,6 +799,7 @@
static int mouse_directx_select_system_cursor (AL_CONST int cursor)
{
HCURSOR wc;
+ HWND allegro_wnd = win_get_window();
wc = NULL;
switch(cursor) {
diff -ur ./src/win/wsndwo.c /windows/d/Program/allegro_cvs/src/win/wsndwo.c
--- ./src/win/wsndwo.c 2003-06-11 19:38:12.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wsndwo.c 2005-05-04 00:40:04.000000000 +0200
@@ -168,7 +168,7 @@
switch_mode = get_display_switch_mode();
if (waveout_paused) {
- if (app_foreground ||
+ if (_win_app_foreground ||
(switch_mode == SWITCH_BACKGROUND) || (switch_mode == SWITCH_BACKAMNESIA)) {
waveout_paused = FALSE;
waveOutRestart(hWaveOut);
@@ -177,7 +177,7 @@
return;
}
else {
- if (!app_foreground &&
+ if (!_win_app_foreground &&
((switch_mode == SWITCH_PAUSE) || (switch_mode == SWITCH_AMNESIA))) {
waveout_paused = TRUE;
waveOutPause(hWaveOut);
diff -ur ./src/win/wsystem.c /windows/d/Program/allegro_cvs/src/win/wsystem.c
--- ./src/win/wsystem.c 2004-07-28 02:15:47.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wsystem.c 2005-05-04 01:08:04.000000000 +0200
@@ -124,7 +124,7 @@
HANDLE current_process;
/* init thread */
- thread_init();
+ _win_thread_init();
allegro_inst = GetModuleHandle(NULL);
@@ -210,7 +210,7 @@
DeleteCriticalSection(&allegro_critical_section);
/* shutdown thread */
- thread_exit();
+ _win_thread_exit();
allegro_inst = NULL;
}
@@ -239,6 +239,8 @@
*/
static void sys_directx_set_window_title(AL_CONST char *name)
{
+ HWND allegro_wnd = win_get_window();
+
do_uconvert(name, U_CURRENT, wnd_title, U_ASCII, WND_TITLE_SIZE);
SetWindowText(allegro_wnd, wnd_title);
}
@@ -252,6 +254,7 @@
{
DWORD class_style;
HMENU sys_menu;
+ HWND allegro_wnd = win_get_window();
user_close_proc = proc;
@@ -291,6 +294,7 @@
{
char *tmp1 = malloc(ALLEGRO_MESSAGE_SIZE);
char tmp2[WND_TITLE_SIZE*2];
+ HWND allegro_wnd = win_get_window();
while ((ugetc(msg) == '\r') || (ugetc(msg) == '\n'))
msg += uwidth(msg);
@@ -320,6 +324,7 @@
*/
static void sys_directx_save_console_state(void)
{
+ HWND allegro_wnd = win_get_window();
GetWindowRect(allegro_wnd, &wnd_rect);
}
@@ -330,13 +335,14 @@
*/
static void sys_directx_restore_console_state(void)
{
+ HWND allegro_wnd = win_get_window();
/* unacquire input devices */
wnd_schedule_proc(key_dinput_unacquire);
wnd_schedule_proc(mouse_dinput_unacquire);
wnd_schedule_proc(joystick_dinput_unacquire);
/* reset switch mode */
- sys_reset_switch_mode();
+ _win_reset_switch_mode();
/* re-size and hide window */
SetWindowPos(allegro_wnd, HWND_TOP, wnd_rect.left, wnd_rect.top,
diff -ur ./src/win/wthread.c /windows/d/Program/allegro_cvs/src/win/wthread.c
--- ./src/win/wthread.c 2003-09-26 09:45:49.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wthread.c 2005-05-04 01:05:36.000000000 +0200
@@ -40,14 +40,15 @@
-/* thread_init:
+/* _win_thread_init:
* Initializes COM interface for the calling thread.
* Attempts to use Distributed COM if available (installed by default
* on every 32-bit Windows starting with Win98 and Win NT4).
*/
-void thread_init(void)
+void _win_thread_init(void)
{
HMODULE ole32 = NULL;
+ HWND allegro_wnd = win_get_window();
if (first_call) {
first_call = 0;
@@ -78,10 +79,10 @@
-/* thread_exit:
+/* _win_thread_exit:
* Shuts down COM interface for the calling thread.
*/
-void thread_exit(void)
+void _win_thread_exit(void)
{
CoUninitialize();
}
diff -ur ./src/win/wtimer.c /windows/d/Program/allegro_cvs/src/win/wtimer.c
--- ./src/win/wtimer.c 2005-05-01 15:47:33.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wtimer.c 2005-05-04 01:08:04.000000000 +0200
@@ -108,15 +108,15 @@
LARGE_INTEGER diff_counter;
/* init thread */
- thread_init();
+ _win_thread_init();
/* get initial counter */
QueryPerformanceCounter(&prev_tick);
while (TRUE) {
- if (!app_foreground) {
+ if (!_win_app_foreground) {
/* restart counter if the thread was blocked */
- if (thread_switch_out())
+ if (_win_thread_switch_out())
QueryPerformanceCounter(&prev_tick);
}
@@ -135,7 +135,7 @@
/* wait calculated time */
result = WaitForSingleObject(timer_stop_event, TIMER_TO_MSEC(delay));
if (result != WAIT_TIMEOUT) {
- thread_exit();
+ _win_thread_exit();
return;
}
}
@@ -155,15 +155,15 @@
DWORD diff_time;
/* init thread */
- thread_init();
+ _win_thread_init();
/* get initial time */
prev_time = timeGetTime();
while (TRUE) {
- if (!app_foreground) {
+ if (!_win_app_foreground) {
/* restart time if the thread was blocked */
- if (thread_switch_out())
+ if (_win_thread_switch_out())
prev_time = timeGetTime();
}
@@ -182,7 +182,7 @@
/* wait calculated time */
result = WaitForSingleObject(timer_stop_event, TIMER_TO_MSEC(delay));
if (result != WAIT_TIMEOUT) {
- thread_exit();
+ _win_thread_exit();
return;
}
}
diff -ur ./src/win/wwnd.c /windows/d/Program/allegro_cvs/src/win/wwnd.c
--- ./src/win/wwnd.c 2005-03-29 23:12:32.000000000 +0200
+++ /windows/d/Program/allegro_cvs/src/win/wwnd.c 2005-05-04 01:08:04.000000000 +0200
@@ -32,7 +32,7 @@
/* general */
-HWND allegro_wnd = NULL;
+static HWND allegro_wnd = NULL;
char wnd_title[WND_TITLE_SIZE]; /* ASCII string */
int wnd_x = 0;
int wnd_y = 0;
@@ -224,7 +224,7 @@
case WM_DESTROY:
if (user_wnd_proc) {
exit_window_modules(NULL);
- sys_reset_switch_mode();
+ _win_reset_switch_mode();
}
else {
PostQuitMessage(0);
@@ -242,7 +242,7 @@
case WM_ACTIVATE:
if (LOWORD(wparam) == WA_INACTIVE) {
- sys_switch_out();
+ _win_switch_out();
}
else {
if (gfx_driver && !gfx_driver->windowed) {
@@ -251,7 +251,7 @@
}
else {
/* no delay in windowed mode */
- sys_switch_in();
+ _win_switch_in();
}
}
break;
@@ -259,7 +259,7 @@
case WM_TIMER:
if (wparam == SWITCH_TIMER) {
KillTimer(allegro_wnd, SWITCH_TIMER);
- sys_switch_in();
+ _win_switch_in();
return 0;
}
break;
@@ -430,7 +430,7 @@
int result;
MSG msg;
- thread_init();
+ _win_thread_init();
_TRACE("window thread starts\n");
/* setup window */
@@ -447,12 +447,12 @@
/* message loop */
while (TRUE) {
- result = MsgWaitForMultipleObjects(input_events, input_event_id, FALSE, INFINITE, QS_ALLINPUT);
- if ((result >= WAIT_OBJECT_0) && (result < WAIT_OBJECT_0 + input_events)) {
+ result = MsgWaitForMultipleObjects(_win_input_events, _win_input_event_id, FALSE, INFINITE, QS_ALLINPUT);
+ if ((result >= WAIT_OBJECT_0) && (result < WAIT_OBJECT_0 + _win_input_events)) {
/* one of the registered events is in signaled state */
- (*input_event_handler[result - WAIT_OBJECT_0])();
+ (*_win_input_event_handler[result - WAIT_OBJECT_0])();
}
- else if (result == WAIT_OBJECT_0 + input_events) {
+ else if (result == WAIT_OBJECT_0 + _win_input_events) {
/* messages are waiting in the queue */
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
if (GetMessage(&msg, NULL, 0, 0)) {
@@ -467,7 +467,7 @@
End:
_TRACE("window thread exits\n");
- thread_exit();
+ _win_thread_exit();
}
@@ -491,7 +491,7 @@
if (user_wnd) {
/* initializes input module and requests dedicated thread */
- input_init(TRUE);
+ _win_input_init(TRUE);
/* hook the user window */
user_wnd_proc = (WNDPROC) SetWindowLong(user_wnd, GWL_WNDPROC, (long)directx_wnd_proc);
@@ -511,7 +511,7 @@
}
else {
/* initializes input module without dedicated thread */
- input_init(FALSE);
+ _win_input_init(FALSE);
/* create window thread */
events[0] = CreateEvent(NULL, FALSE, FALSE, NULL); /* acknowledges that thread is up */
@@ -568,7 +568,7 @@
DeleteCriticalSection(&gfx_crit_sect);
- input_exit();
+ _win_input_exit();
window_is_initialized = FALSE;
}