ZoriaRPG

Allegro Hack Diff

Jul 23rd, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 8.01 KB | None | 0 0
  1. h src/win/wdispsw.c | 15 +++++++++++----
  2.  src/win/wwnd.c    | 54 ++++++++++++++++++++++++++++++++----------------------
  3.  2 files changed, 43 insertions(+), 26 deletions(-)
  4.  
  5. diff --git a/src/win/wdispsw.c b/src/win/wdispsw.c
  6. index 8707ea1a8..375a6789a 100644
  7. --- a/src/win/wdispsw.c
  8. +++ b/src/win/wdispsw.c
  9. @@ -111,6 +111,8 @@ void _win_switch_in(void)
  10.  
  11.     _TRACE(PREFIX_I "switch in\n");
  12.  
  13. +   _enter_gfx_critical();
  14. +
  15.     _win_app_foreground = TRUE;
  16.  
  17.     key_dinput_acquire();
  18. @@ -132,6 +134,7 @@ void _win_switch_in(void)
  19.     }
  20.  
  21.     _switch_in();
  22. +   _exit_gfx_critical();
  23.  }
  24.  
  25.  
  26. @@ -145,6 +148,10 @@ void _win_switch_out(void)
  27.  
  28.     _TRACE(PREFIX_I "switch out\n");
  29.  
  30. +   _enter_gfx_critical();
  31. +
  32. +   _switch_out();
  33. +
  34.     _win_app_foreground = FALSE;
  35.  
  36.     key_dinput_unacquire();
  37. @@ -165,11 +172,11 @@ void _win_switch_out(void)
  38.  
  39.        /* if the thread doesn't stop, lower its priority only if another window is active */
  40.        allegro_thread_priority = GetThreadPriority(allegro_thread);
  41. -      if ((HINSTANCE)GetWindowLongPtr(GetForegroundWindow(), GWLP_HINSTANCE) != allegro_inst)
  42. -         SetThreadPriority(allegro_thread, THREAD_PRIORITY_LOWEST);
  43. +      if ((HINSTANCE)GetWindowLong(GetForegroundWindow(), GWL_HINSTANCE) != allegro_inst)
  44. +    SetThreadPriority(allegro_thread, THREAD_PRIORITY_LOWEST);
  45.     }
  46. -
  47. -   _switch_out();
  48. +      
  49. +   _exit_gfx_critical();
  50.  }
  51.  
  52.  
  53. diff --git a/src/win/wwnd.c b/src/win/wwnd.c
  54. index f5eccaae1..6bb342d9e 100644
  55. --- a/src/win/wwnd.c
  56. +++ b/src/win/wwnd.c
  57. @@ -1,6 +1,6 @@
  58. -/*         ______   ___    ___
  59. - *        /\  _  \ /\_ \  /\_ \
  60. - *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
  61. +/*         ______   ___    ___
  62. + *        /\  _  \ /\_ \  /\_ \
  63. + *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
  64.   *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
  65.   *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
  66.   *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
  67. @@ -19,6 +19,7 @@
  68.  #include "allegro.h"
  69.  #include "allegro/internal/aintern.h"
  70.  #include "allegro/platform/aintwin.h"
  71. +#include "wddraw.h"
  72.  
  73.  #ifndef SCAN_DEPEND
  74.     #include <string.h>
  75. @@ -189,7 +190,7 @@ static void exit_window_modules(struct WINDOW_MODULES *wm)
  76.   */
  77.  int wnd_call_proc(int (*proc) (void))
  78.  {
  79. -   return SendMessage(allegro_wnd, msg_call_proc, (WPARAM)proc, (LPARAM)0);
  80. +   return SendMessage(allegro_wnd, msg_call_proc, (DWORD) proc, 0);
  81.  }
  82.  
  83.  
  84. @@ -200,7 +201,7 @@ int wnd_call_proc(int (*proc) (void))
  85.   */
  86.  void wnd_schedule_proc(int (*proc) (void))
  87.  {
  88. -   PostMessage(allegro_wnd, msg_call_proc, (WPARAM)proc, (LPARAM)0);
  89. +   PostMessage(allegro_wnd, msg_call_proc, (DWORD) proc, 0);
  90.  }
  91.  
  92.  
  93. @@ -213,7 +214,7 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
  94.     PAINTSTRUCT ps;
  95.  
  96.     if (message == msg_call_proc)
  97. -      return ( ( LRESULT(*)( void ) )wparam ) ( );
  98. +      return ((int (*)(void))wparam) ();
  99.  
  100.     if (message == msg_suicide) {
  101.        DestroyWindow(wnd);
  102. @@ -224,7 +225,7 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
  103.     if (wnd_msg_pre_proc){
  104.        int retval = 0;
  105.        if (wnd_msg_pre_proc(wnd, message, wparam, lparam, &retval) == 0)
  106. -         return (LRESULT)retval;
  107. +         return retval;
  108.     }
  109.  
  110.     /* See get_reverse_mapping() in wkeybd.c to see what this is for. */
  111. @@ -373,7 +374,7 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
  112.  
  113.        case WM_MENUCHAR :
  114.           return (MNC_CLOSE<<16)|(wparam&0xffff);
  115. -
  116. +        
  117.        case WM_CLOSE:
  118.           if (!user_wnd_proc) {
  119.              if (user_close_proc)
  120. @@ -381,6 +382,14 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
  121.              return 0;
  122.           }
  123.           break;
  124. +
  125. +      case WM_QUERYNEWPALETTE:
  126. +      case WM_PALETTECHANGED:
  127. +         if ((HWND)wparam != wnd && gfx_directx_primary_surface) {
  128. +            IDirectDrawSurface2_SetPalette(gfx_directx_primary_surface->id, ddpalette);
  129. +            InvalidateRect(wnd, NULL, 1);
  130. +         }
  131. +         return 1;
  132.     }
  133.  
  134.     /* pass message to default window proc */
  135. @@ -442,6 +451,7 @@ static HWND create_directx_window(void)
  136.        return NULL;
  137.     }
  138.  
  139. +   SetSystemPaletteUse(GetDC(wnd), SYSPAL_NOSTATIC256);
  140.     ShowWindow(wnd, SW_SHOWNORMAL);
  141.     SetForegroundWindow(wnd);
  142.     UpdateWindow(wnd);
  143. @@ -456,7 +466,7 @@ static HWND create_directx_window(void)
  144.   */
  145.  static void wnd_thread_proc(HANDLE setup_event)
  146.  {
  147. -   DWORD result;
  148. +   int result;
  149.     MSG msg;
  150.  
  151.     _win_thread_init();
  152. @@ -477,7 +487,7 @@ static void wnd_thread_proc(HANDLE setup_event)
  153.     /* message loop */
  154.     while (TRUE) {
  155.        result = MsgWaitForMultipleObjects(_win_input_events, _win_input_event_id, FALSE, INFINITE, QS_ALLINPUT);
  156. -      if ((result >= WAIT_OBJECT_0) && (result < (int)(WAIT_OBJECT_0 + _win_input_events))) {
  157. +      if ((result >= WAIT_OBJECT_0) && (result < WAIT_OBJECT_0 + _win_input_events)) {
  158.           /* one of the registered events is in signaled state */
  159.           (*_win_input_event_handler[result - WAIT_OBJECT_0])();
  160.        }
  161. @@ -518,12 +528,15 @@ int init_directx_window(void)
  162.     msg_call_proc = RegisterWindowMessage("Allegro call proc");
  163.     msg_suicide = RegisterWindowMessage("Allegro window suicide");
  164.  
  165. +   /* initialize gfx critical section */
  166. +   InitializeCriticalSection(&gfx_crit_sect);
  167. +
  168.     if (user_wnd) {
  169.        /* initializes input module and requests dedicated thread */
  170.        _win_input_init(TRUE);
  171.  
  172.        /* hook the user window */
  173. -      user_wnd_proc = (WNDPROC) SetWindowLongPtr(user_wnd, GWLP_WNDPROC, (LONG_PTR)directx_wnd_proc);
  174. +      user_wnd_proc = (WNDPROC) SetWindowLong(user_wnd, GWL_WNDPROC, (long)directx_wnd_proc);
  175.        if (!user_wnd_proc)
  176.           return -1;
  177.  
  178. @@ -557,12 +570,9 @@ int init_directx_window(void)
  179.  
  180.      default:               /* thread failed to create window */
  181.         return -1;
  182. -      }
  183. +      }
  184.     }
  185.  
  186. -   /* initialize gfx critical section */
  187. -   InitializeCriticalSection(&gfx_crit_sect);
  188. -
  189.     /* save window style */
  190.     old_style = GetWindowLong(allegro_wnd, GWL_STYLE);
  191.  
  192. @@ -579,7 +589,7 @@ void exit_directx_window(void)
  193.  {
  194.     if (user_wnd) {
  195.        /* restore old window proc */
  196. -      SetWindowLongPtr(user_wnd, GWLP_WNDPROC, (LONG_PTR)user_wnd_proc);
  197. +      SetWindowLong(user_wnd, GWL_WNDPROC, (long)user_wnd_proc);
  198.        user_wnd_proc = NULL;
  199.        user_wnd = NULL;
  200.        allegro_wnd = NULL;
  201. @@ -598,7 +608,7 @@ void exit_directx_window(void)
  202.     DeleteCriticalSection(&gfx_crit_sect);
  203.  
  204.     _win_input_exit();
  205. -
  206. +  
  207.     window_is_initialized = FALSE;
  208.  }
  209.  
  210. @@ -651,11 +661,11 @@ int adjust_window(int w, int h)
  211.           }
  212.           if (!user32_handle || !get_title_bar_info)
  213.              tb_height = GetSystemMetrics(SM_CYSIZE);
  214. -
  215. +        
  216.      /* try to center the window relative to its last position */
  217.      last_wnd_x += (last_w - w)/2;
  218.      last_wnd_y += (last_h - h)/2;
  219. -
  220. +    
  221.      if (last_wnd_x + w >= working_area.right)
  222.         last_wnd_x = working_area.right - w;
  223.      if (last_wnd_y + h >= working_area.bottom)
  224. @@ -680,7 +690,7 @@ int adjust_window(int w, int h)
  225.  
  226.        /* retrieve the size of the decorated window */
  227.        AdjustWindowRect(&win_size, GetWindowLong(allegro_wnd, GWL_STYLE), FALSE);
  228. -
  229. +  
  230.        /* display the window */
  231.        MoveWindow(allegro_wnd, win_size.left, win_size.top,
  232.                   win_size.right - win_size.left, win_size.bottom - win_size.top, TRUE);
  233. @@ -702,7 +712,7 @@ int adjust_window(int w, int h)
  234.  
  235.  
  236.  /* save_window_pos:
  237. - *  Stores the position of the current window before closing it so that
  238. + *  Stores the position of the current window before closing it so that
  239.   *  it can be used as the initial position for the next window.
  240.   */
  241.  void save_window_pos(void)
  242. @@ -746,7 +756,7 @@ void win_set_window(HWND wnd)
  243.        init_directx_window();
  244.        init_window_modules(&wm);
  245.     }
  246. -
  247. +  
  248.     window_is_initialized = TRUE;
  249.  }
Add Comment
Please, Sign In to add comment