// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! 

#include <r3/binders/auto.h>
#include <gh_global.h>

extern "C" {
undefined FUN_004013a0(void); // 004013a0 // FUN_004013a0
undefined FUN_00401320(void); // 00401320 // FUN_00401320

// 004025e0
long r3_windowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)

{
  long lVar1;
  
  if (uMsg < WM_SETCURSOR + 1) {
    if (uMsg == WM_SETCURSOR) {
      if (((g_engineShouldRun != 0) && (g_engineRunning != 0)) && (g_runMaximized != 0)) {
        FUN_00401320();
        return 1;
      }
    }
    else {
      if (uMsg == WM_CLOSE) {
        FUN_004013a0();
        DAT_0077d0b8 = 1;
        if (g_drawSemaphore != (HANDLE)0x0) {
          CloseHandle(g_drawSemaphore);
        }
        g_drawSemaphore = (HANDLE)0x0;
        PostQuitMessage(0);
        return 0;
      }
      if (uMsg == WM_ACTIVATEAPP) {
        g_engineShouldRun = wParam;
      }
    }
  }
  else {
    if (uMsg != WM_NCHITTEST) {
      if (uMsg != WM_SYSCOMMAND) goto LAB_004026ab;
                    /* handle SYSCOMMAND */
      if (wParam < SC_MAXIMIZE + 1) {
        if ((wParam != SC_MAXIMIZE) && ((wParam != SC_SIZE && (wParam != SC_MOVE))))
        goto LAB_004026ab;
      }
      else if ((wParam != SC_KEYMENU) && (wParam != SC_MONITORPOWER)) goto LAB_004026ab;
    }
                    /* WM_NCHITTEST
                        */
    if (g_runMaximized != 0) {
      return 1;
    }
  }
LAB_004026ab:
                    /* WARNING: Could not recover jumptable at 0x004026b3. Too many branches */
                    /* WARNING: Treating indirect jump as call */
  lVar1 = DefWindowProcA(hwnd,uMsg,wParam,lParam);
  return lVar1;
}

}

