Exemplo n.º 1
0
void main()
{
	OpenWindow(); /* Open a window (if needed) */

	Level = (STARTLEV-1);
	SetupLevel(); /* Display the first level */

	/* Loop keyhandler till you finished the game */
	while (CheckNotFinished())
	  Gamekeys();

	MyExit();     /* Close the window (if needed) */
}
Exemplo n.º 2
0
void ShowErrorQuick(const char *msg, ...)
{
  va_list args;
  char header[256];
  char message[256];

  snprintf(header, sizeof(header), MSG_ERR_ERROR_QUICK, ScanFile);
  va_start(args, msg);
  vsnprintf(message, sizeof(message), msg, args);
  va_end(args);
  fprintf(stderr, "%s %s\n", header, message);

#ifdef AMIGA
  NumberOfWarnings++;
#endif

  MyExit ( 10 );
}
Exemplo n.º 3
0
void Gamekeys(void)
{
	char *charptr;

    /* Set up a pointer to the variable we want to change
     * (either the box or the ball) */
	charptr = PieceIsBall ? &BoxOffset : &BallOffset;

	switch(getk())
	{
		case K_DOWN:
		  MovePiece(charptr,0,+1);
		  break;
		case K_UP:
		  MovePiece(charptr,0,-1);
		  break;
		case K_RIGHT:
		  MovePiece(charptr,+1,0);
		  break;
		case K_LEFT:
		  MovePiece(charptr,-1,0);
		  break;
		case K_SWITCH:
		  PieceIsBall^=1;   /* Toggle ball/box */
		  break;
		case K_EXIT:
		  MyExit();
		case K_NEXTLEV:    /* Okay this IS cheating... */
		  if(++Level==MAXLEVEL)
		  { --Level; break; }
		  SetupLevel();
		  break;
		case K_PREVLEV:
		  if(--Level==-1)
		  { ++Level; break; }
		  /* fall thrue */
		case K_CLEAR:
		  SetupLevel();
	}
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
  char *cdfile = NULL;
  char *ctfile = NULL;
  char *pofile = NULL;
  char *newctfile = NULL;
  char *catalog = NULL;
  char *source;
  char *template;
  int makenewct = FALSE;
  int makecatalog = FALSE;
  int i;

  if(argc == 0)      /* Aztec's entry point for workbench programs */
  {
    fprintf(stderr, "FlexCat can't be run from Workbench!\n" \
            "\n"
            "Open a Shell session and type FlexCat ?\n" \
            "for more information\n");
    exit(5);
  }

  if(OpenLibs() == FALSE)
    exit(20);

  OpenFlexCatCatalog();

  /* Big Endian vs. Little Endian (both supported ;-) */

  if(!SwapChoose())
  {
    fprintf(stderr, "FlexCat is unable to determine\n" \
            "the byte order used by your system.\n" \
            "It's neither Little nor Big Endian?!.\n");
    exit(5);
  }
#ifdef AMIGA
  ReadPrefs();
#endif
  if(argc == 1)
  {
    Usage();
  }

  for(i = 1; i < argc; i++)
  {
    if(Strnicmp(argv[i], "catalog=", 8) == 0)
    {
      catalog = argv[i] + 8;
      makecatalog = TRUE;
    }
    else if(Stricmp(argv[i], "catalog") == 0)
    {
      if(i == argc - 1)
      {
        catalog = NULL;
        makecatalog = TRUE;
      }
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          catalog = argv[i + 1];
          i++;
          makecatalog = TRUE;
        }
        else
        {
          catalog = NULL;
          makecatalog = TRUE;
        }
      }
    }
    else if(Strnicmp(argv[i], "pofile=", 7) == 0)
    {
      pofile = argv[i] + 7;
    }
    else if(Stricmp(argv[i], "pofile") == 0)
    {
      if(i == argc - 1)
        pofile = NULL;
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          pofile = argv[i + 1];
          i++;
        }
        else
          pofile = NULL;
      }
    }
    else if(Strnicmp(argv[i], "codeset=", 8) == 0)
    {
      strcpy(DestCodeset, argv[i] + 8);
    }
    else if(Stricmp(argv[i], "codeset") == 0)
    {
      if(i == argc - 1)
        DestCodeset[0] = '\0';
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          strcpy(DestCodeset, argv[i + 1]);
          i++;
        }
        else
          DestCodeset[0] = '\0';
      }
    }
    else if(Strnicmp(argv[i], "version=", 8) == 0)
    {
      CatVersion = strtol(argv[i]+8, NULL, 10);
    }
    else if(Stricmp(argv[i], "version") == 0)
    {
      if(i == argc - 1)
        CatVersion = -1;
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          CatVersion = strtol(argv[i + 1], NULL, 10);
          i++;
        }
        else
          CatVersion = -1;
      }
    }
    else if(Strnicmp(argv[i], "revision=", 9) == 0)
    {
      CatRevision = strtol(argv[i]+9, NULL, 10);
    }
    else if(Stricmp(argv[i], "revision") == 0)
    {
      if(i == argc - 1)
        CatRevision = -1;
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          CatRevision = strtol(argv[i + 1], NULL, 10);
          i++;
        }
        else
          CatRevision = -1;
      }
    }
    else if(Stricmp(argv[i], "nooptim") == 0)
    {
      NoOptim = TRUE;
    }
    else if(Stricmp(argv[i], "fill") == 0)
    {
      Fill = TRUE;
    }
    else if(Stricmp(argv[i], "quiet") == 0)
    {
      Quiet = TRUE;
    }
    else if(Stricmp(argv[i], "flush") == 0)
    {
      DoExpunge = TRUE;
    }
    else if(Stricmp(argv[i], "nobeep") == 0)
    {
      NoBeep = TRUE;
    }
    else if(Stricmp(argv[i], "nobufferedio") == 0)
    {
      NoBufferedIO = TRUE;
    }
    else if(Strnicmp(argv[i], "newctfile=", 10) == 0)
    {
      newctfile = argv[i] + 10;
      makenewct = TRUE;
    }
    else if(Stricmp(argv[i], "newctfile") == 0)
    {
      if(i == argc - 1)
      {
        newctfile = NULL;
        makenewct = TRUE;
      }
      else if(i < argc - 1)
      {
        if(isParam(argv[i + 1]) != TRUE)
        {
          newctfile = argv[i + 1];
          i++;
          makenewct = TRUE;
        }
        else
        {
          newctfile = NULL;
          makenewct = TRUE;
        }
      }
    }
    else if(Stricmp(argv[i], "nolangtolower") == 0)
    {
      LANGToLower = FALSE;
    }
    else if(Stricmp(argv[i], "modified") == 0)
    {
      Modified = TRUE;
    }
    else if(Stricmp(argv[i], "warnctgaps") == 0)
    {
      WarnCTGaps = TRUE;
    }
    else if(Stricmp(argv[i], "copymsgnew") == 0)
    {
      CopyNEWs = TRUE;
    }
    else if(Stricmp(argv[i], "oldmsgnew") == 0)
    {
      snprintf(Old_Msg_New, sizeof(Old_Msg_New), "; %s", argv[++i]);
    }
    else if(Stricmp(argv[i], "noautodate") == 0 || Stricmp(argv[i], "nospaces") == 0)
    {
      // just swallow some no longer supported options to
      // keep old scripts alive and happy
    }
    else if(cdfile == NULL)
    {
      if(Stricmp(argv[i], "?") == 0 ||
         Stricmp(argv[i], "-h") == 0 ||
         Stricmp(argv[i], "help") == 0 ||
         Stricmp(argv[i], "--help") == 0)
      {
        Usage();
      }

      cdfile = argv[i];

      // find out file extension and depending on it
      // we eiterh scan a CD file or the supplied pot file
      if(strstr(cdfile, ".pot") != NULL)
      {
        if(!ScanPOFile(cdfile, FALSE))
          MyExit(10);
      }
      else
      {
        if(!ScanCDFile(cdfile))
          MyExit(10);
      }
    }
    else if(strchr(argv[i], '=') != NULL)
    {
      /* Determine basename. */
      if(BaseName == NULL && cdfile != NULL)
      {
        char *lslash = strrchr(cdfile, '/');
        char  *ldot = strrchr(cdfile, '.');

        if(lslash == NULL)
          lslash = cdfile;
        else
          lslash++;

        if(ldot == NULL)
          ldot = cdfile + strlen(cdfile);

        if(ldot - lslash > 0)
        {
          BaseName = calloc(ldot - lslash + 3, 1);
          strncpy(BaseName, lslash, ldot - lslash);
        }
      }

      source =AllocString(argv[i]);
      template = strchr(source, '=');
      *template++ = '\0';
Exemplo n.º 5
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_SEND_MESH_FILE_NAME:
		{
			ReadFromMapFile(g_szMeshFileName, sizeof(g_szMeshFileName) * sizeof(char));
		
	
			SIZE ssss;
			ssss.cx = 96;
			ssss.cy = 96;
			BOOL bCreateBmpOK = g_pEngineProxy->CreateThumbnail(ssss, g_szMeshFileName);
			LRESULT lRet = S_FALSE;
			if (bCreateBmpOK)
			{
				lRet = S_OK;
			}
			else
			{
				lRet = S_FALSE;
			}
			return lRet;
		}
	case WM_SEND_ANI_FILE_NAME:
		{
			if (g_bAnimationReady && strcmp((char*)g_lpMapAddr, g_szAniFileName) != 0)
			{
				ReadFromMapFile(g_szAniFileName, sizeof(g_szAniFileName) * sizeof(char));
				return S_OK;
			}
			else 
			{
				return S_FALSE;
			}
		}
	case WM_ANIMATION_FILE:
		{
			ReadFromMapFile(g_szMeshFileName, sizeof(g_szMeshFileName) * sizeof(char));

			SIZE ssss;
			ssss.cx = 300;
			ssss.cy = 300;
			BOOL bCreateBmpOK = g_pEngineProxy->CreateAnimationFile(ssss, g_szMeshFileName, g_szAniFileName);
			LRESULT lRet = S_FALSE;
			if (bCreateBmpOK)
			{
				lRet = S_OK;
			}
			else
			{
				lRet = S_FALSE;
			}
			return lRet;
		}
	case WM_DESTROY:
		MyExit();
		PostQuitMessage (0) ;
		return 0 ;
	case WM_REINIT_ENGINE:
		if (g_pEngineProxy)
		{
			g_pEngineProxy->Stop();
			BOOL bInitProxy = FALSE;
			bInitProxy = g_pEngineProxy->Start(g_hWnd_3dEngine);
			if (!bInitProxy)
			{
				MessageBox(g_hWnd_3dEngine, "Init EngineProxy failed", "quit", MB_ICONERROR);
				MyExit();

				return 1;
			}
		}
		
		return 0;

	}
	return DefWindowProc (hwnd, message, wParam, lParam) ;
}
Exemplo n.º 6
0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
					PSTR szCmdLine, int iCmdShow)
{
	static TCHAR szAppName[] = TEXT ("3d_engine") ;
	MSG          msg ;
	WNDCLASS     wndclass ;

	wndclass.style         = CS_VREDRAW | CS_HREDRAW ;
	wndclass.lpfnWndProc   = WndProc ;
	wndclass.cbClsExtra    = 0 ;
	wndclass.cbWndExtra    = 0 ;
	wndclass.hInstance     = hInstance ;
	wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
	wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
	wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
	wndclass.lpszMenuName  = NULL ;
	wndclass.lpszClassName = szAppName ;

	if (!RegisterClass (&wndclass))
	{
		MessageBox (NULL, TEXT ("This program requires Windows NT!"), 
			szAppName, MB_ICONERROR) ;
		return 0 ;
	}

	g_hWnd_3dEngine = CreateWindow (szAppName,                  // window class name
		TEXT (""), // window caption
		WS_OVERLAPPEDWINDOW,        // window style
		CW_USEDEFAULT,              // initial x position
		CW_USEDEFAULT,              // initial y position
		220,                         // initial x size
		220,                         // initial y size
		NULL,                       // parent window handle
		NULL,                       // window menu handle
		hInstance,                  // program instance handle
		NULL) ;                     // creation parameters

	
	ShowWindow (g_hWnd_3dEngine, iCmdShow) ;
	UpdateWindow (g_hWnd_3dEngine) ;

	

	g_pEngineProxy = new EngineProxy();
	BOOL bInitProxy = FALSE;
	bInitProxy = g_pEngineProxy->Start(g_hWnd_3dEngine);
	if (!bInitProxy)
	{
#ifdef DEBUG
		MessageBox(g_hWnd_3dEngine, "Init EngineProxy failed", "quit", MB_ICONERROR);
#endif		
		MyExit();

		return 1;
	}

	if (!InitShareMemory())
	{
		MyExit();
		return 1;
	}
	
	::SetWindowText(g_hWnd_3dEngine, _T(EngineWindowName));

	BOOL bRet = false;
	while (bRet = GetMessage (&msg, NULL, 0, 0))
	{
		if (bRet == -1)
		{


		}
		else
		{
			TranslateMessage (&msg) ;
			DispatchMessage (&msg) ;
		}
		
	}
	return msg.wParam ;
}