Пример #1
0
int AGOL_InitVideo(const string& drivers, const int width, const int height, const short depth)
{
	ostringstream spec;

	cout << "Initializing with resolution (" << width << "x" << height << ")..." << endl;

	/* Initialize Agar-GUI. */
	if(drivers.size())
		spec << drivers;
	else
		spec << "<OpenGL>";

	spec << "(width=" << width << ":height=" << height << ":depth=" << depth << ")";

	if (AG_InitGraphics(spec.str().c_str()) == -1) 
	{
		cerr << AG_GetError() << endl;
		return -1;
	}

#ifdef _XBOX
	// Software cursor only updates at the refresh rate so make it respectable
	if(agDriverSw)
		AG_SetRefreshRate(60);
#endif

	return 0;
}
Пример #2
0
int
main(int argc, char *argv[])
{
	char *driverSpec = NULL, *optArg;
	int c;

	while ((c = AG_Getopt(argc, argv, "?hd:", &optArg, NULL)) != -1) {
		switch (c) {
		case 'd':
			driverSpec = optArg;
			break;
		case '?':
		case 'h':
		default:
			printf("Usage: keyevents [-d agar-driver-spec]\n");
			return (1);
		}
	}
	if (AG_InitCore("agar-keyevents-demo", 0) == -1 ||
	    AG_InitGraphics(driverSpec) == -1) {
		fprintf(stderr, "%s\n", AG_GetError());
		return (1);
	}
	AG_BindGlobalKey(AG_KEY_ESCAPE, AG_KEYMOD_ANY, AG_QuitGUI);
	AG_BindGlobalKey(AG_KEY_F8, AG_KEYMOD_ANY, AG_ViewCapture);
	CreateWindow();
	AG_EventLoop();
	AG_Destroy();
	return (0);
}
Пример #3
0
void MainLoop(int argc, char *argv[])
{
   int c;
   char *drivers = NULL;
   char *optArg;
   char strbuf[2048];
   char homedir[2048];
   const SDL_VideoInfo *inf;
   BOOL flag;
   SDL_Surface *s;

//   mtrace();
   if(AG_GetVariable(agConfig, "font.size", NULL) == NULL) { 
	AG_SetInt(agConfig, "font.size", UI_PT);
   }
   while ((c = AG_Getopt(argc, argv, "?fWd:w:h:T:t:c:T:F:S:o:O:l:s:i:", &optArg, NULL))
          != -1) {
              switch (c) {
              case 'd':
                      drivers = optArg;
                      break;
              case 'f':
                      /* Force full screen */
                      AG_SetBool(agConfig, "view.full-screen", 1);
                      break;
              case 'W':
                      /* Force Window */
                      AG_SetBool(agConfig, "view.full-screen", 0);
                      break;
              case 'T':
                      /* Set an alternate font directory */
                      AG_SetString(agConfig, "font-path", optArg);
                      break;
              case 'F':
                      /* Set an alternate font face */
                      AG_SetString(agConfig, "font.face", optArg);
                      break;
              case 'S':
                  /* Set an alternate font face */
                  AG_SetInt(agConfig, "font.size", atoi(optArg));
                  break;
              case 'o':
                  /* Set an alternate font face */
                  AG_SetString(agConfig, "osdfont.face", optArg);
                  break;
              case 'O':
                  /* Set an alternate font face */
                  AG_SetInt(agConfig, "osdfont.size", atoi(optArg));
                  break;
              case 'l':
                  /* Set an alternate font face */
                  AG_SetString(agConfig, "load-path", optArg);
                  break;
              case 's':
                  /* Set an alternate font face */
                  AG_SetString(agConfig, "save-path", optArg);
                  break;
              case 'i':
                  /* Set an alternate font face */
                  AG_SetString(agConfig, "save-path", optArg);
                  AG_SetString(agConfig, "load-path", optArg);
                  break;
              case 't':
                  /* Change the default font */
                  AG_TextParseFontSpec(optArg);
                  break;
          case '?':
          default:
                  printf("%s [-v] [-f|-W] [-d driver] [-r fps] [-t fontspec] "
                         "[-w width] [-h height] "
                	 "[-F font.face] [-S font.size]"
			 "[-o osd-font.face] [-O osd-font.size]"
			 "[-s SavePath] [-l LoadPath] "
                         "[-T font-path]\n\n"
			 "Usage:\n"
			 "-f : FullScreen\n-W:Window Mode\n",
                         agProgName);
                  exit(0);
          }
    }
   
    if(SDL_getenv("HOME") != NULL) {
	strcpy(homedir, SDL_getenv("HOME"));
    } else {
        strcpy(homedir, ".");
    }
    XM7_DebugLog(XM7_LOG_DEBUG, "HOME = %s", homedir);

#ifdef _WINDOWS
	AG_PrtString(agConfig, "font-path", "%s:%s/xm7:%s:.",
		homedir, homedir, FONTPATH);
#else
    flag = FALSE;
    if(AG_GetString(agConfig, "font-path", strbuf, 2047) != NULL) {
       if((strlen(strbuf) <= 0) || (strncmp(strbuf, "_agFontVera", 11) == 0)){
	  flag = TRUE;
	 }
    } else {
       flag = TRUE;
    }
    if(flag) AG_PrtString(agConfig, "font-path", "%s/.fonts:%s:%s/.xm7:%s:.", 
		homedir, homedir, homedir, FONTPATH);
    flag = FALSE;
   
    XM7_DebugLog(XM7_LOG_DEBUG, "font-path = %s", strbuf);
#endif /* _WINDOWS */
    flag = FALSE;
    if(AG_GetString(agConfig, "font.face", strbuf, 511) != NULL) {
       if((strlen(strbuf) <= 0) || (strncmp(strbuf, "_agFontVera", 11) == 0)){
	  flag = TRUE;
       }
    } else {
	flag = TRUE;
    }
    if(flag) AG_SetString(agConfig, "font.face", UI_FONT);
    flag = FALSE;
    XM7_DebugLog(XM7_LOG_DEBUG, "font.face = %s", strbuf);
   
    stopreq_flag = FALSE;
    run_flag = TRUE;
    // Debug
#ifdef _XM7_FB_DEBUG // Force FB.
drivers = "sdlfb:width=1280:height=880:depth=32";
#endif
	/*
	 * Agar のメインループに入る
	 */

    if(drivers == NULL)  {
#ifdef USE_OPENGL
       if(AG_InitGraphics(NULL) == -1){
                fprintf(stderr, "%s\n", AG_GetError());
                return;
        }
#else
       if(AG_InitGraphics("cocoa,sdlfb") == -1){
                fprintf(stderr, "%s\n", AG_GetError());
                return;
        }
#endif
    } else {
        if (AG_InitGraphics(drivers) == -1) {
                fprintf(stderr, "%s\n", AG_GetError());
                return;
        }
    }
    OnCreate((AG_Widget *)NULL);
//    AG_AtExitFunc(OnDestroy);
    XM7_DebugLog(XM7_LOG_DEBUG, "Widget creation OK.");
   
   XM7_DebugLog(XM7_LOG_INFO, "Emulate version:%d", fm7_ver);
   SDL_InitSubSystem(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
   XM7_DebugLog(XM7_LOG_DEBUG, "Audio and JOYSTICK subsystem was initialised.");

   InitInstance();
   XM7_DebugLog(XM7_LOG_DEBUG, "InitInstance() OK.");
   if(agDriverSw && AG_UsingSDL(NULL)) {
      SDL_Init(SDL_INIT_VIDEO);
      XM7_DebugLog(XM7_LOG_INFO, "Start Single WM with SDL.");
      switch(fm7_ver) {
       case 1: // FM7/77
	 if(!(LoadGlobalIconPng(NULL, "tamori.png"))) {
	    LoadGlobalIconPng(NULL, "xm7.png");
	 }
	 break;
       case 2: // FM77AV
	 if(!(LoadGlobalIconPng(NULL, "fujitsu.png"))) {
	    LoadGlobalIconPng(NULL, "xm7.png");
	 }
	 break;
       case 3: // FM77AV20/40/EX/SX
	 if(!(LoadGlobalIconPng(NULL, "fujitsu2.png"))) {
	    LoadGlobalIconPng(NULL, "xm7.png");
	 }
	 break;
       default:
	 LoadGlobalIconPng(NULL, "xm7.png");
	 break;
      }
   } else { // WM function is managed by SDL, load and set icon for WM. 
      SDL_Init(SDL_INIT_VIDEO);
      XM7_DebugLog(XM7_LOG_INFO, "Start multi window mode.");
   }
       
   stopreq_flag = FALSE;
   run_flag = TRUE;
   AG_DrawInitsub();

   inf = SDL_GetVideoInfo();
   if(inf != NULL) {
      RootVideoWidth = inf->current_w;
      RootVideoHeight = inf->current_h;
   } else {
      RootVideoWidth = 640;
      RootVideoHeight = 400;
   }

   newResize = FALSE;
   nDrawTick1D = XM7_timeGetTime();
   nDrawTick1E = nDrawTick1D;

   ResizeWindow_Agar2(nDrawWidth, nDrawHeight);
   XM7_DebugLog(XM7_LOG_DEBUG, "Screen is %d x %d.", nDrawWidth, nDrawHeight);
    switch(nErrorCode) 
     {
      case 0:
	break;
      case 1:
	ErrorPopup(gettext("Error init VM.\nPlease check ROMS and system-memory.\n"));
	break;
      case 2:
	ErrorPopup(gettext("Error init Emulator.\nPlease check window system, display and more.\n"));
	break;
      default:
	ErrorPopup(gettext("Unknown error on setup.\nPlease email to author."));
	break;
     }
#if 0
   mtrace();
#endif
   if(DrawArea != NULL) {
      AG_RedrawOnTick(DrawArea, 1000 / nDrawFPS);
      XM7_DebugLog(XM7_LOG_INFO, "Direct draw mode.");
   } else if(GLDrawArea != NULL) {
      AG_RedrawOnTick(GLDrawArea, 1000 / nDrawFPS);
      XM7_DebugLog(XM7_LOG_INFO, "OpenGL mode.");
   }
   bEventRunFlag == TRUE;
   AGDrawTaskEvent(TRUE);
//   muntrace();
   XM7_DebugLog(XM7_LOG_INFO, "All End.");
}
Пример #4
0
int
main(int argc, char *argv[])
{
	char s[256];
	double v = 10.0;
	char *driverSpec = NULL, *optArg;
	int c;

	while ((c = AG_Getopt(argc, argv, "?hd:", &optArg, NULL)) != -1) {
		switch (c) {
		case 'd':
			driverSpec = optArg;
			break;
		case '?':
		case 'h':
		default:
			printf("Usage: textdlg [-d agar-driver-spec]\n");
			return (1);
		}
	}
	if (AG_InitCore("agar-textdlg-demo", 0) == -1 ||
	    AG_InitGraphics(driverSpec) == -1) {
		fprintf(stderr, "%s\n", AG_GetError());
		return (1);
	}
	AG_BindGlobalKey(AG_KEY_ESCAPE, AG_KEYMOD_ANY, AG_QuitGUI);
	AG_BindGlobalKey(AG_KEY_F8, AG_KEYMOD_ANY, AG_ViewCapture);
	
	/* Prompt for a series of options. */
	{
		AG_Button *btns[3];

		btns[0] = AG_ButtonNew(NULL, 0, NULL);
		btns[1] = AG_ButtonNew(NULL, 0, NULL);
		btns[2] = AG_ButtonNew(NULL, 0, NULL);
		AG_TextPromptOptions(btns, 3, "Multiple-choice selection: ");
		AG_ButtonText(btns[0], "Yes");
		AG_ButtonText(btns[1], "No");
		AG_ButtonText(btns[2], "Maybe");
	}
	
	/* Prompt for a string and invoke callback on return. */
	AG_TextPromptString("Prompt for a string: ", EnteredString, NULL);

	/* Various canned dialogs as described in AG_Text(3). */
	AG_TextWarning("my-warning-key", "This is a warning");
	AG_TextError("This is an error message");
	AG_TextTmsg(AG_MSG_INFO, 3000, "This is a timed message");
	AG_TextMsg(AG_MSG_INFO, "This is an informational message");
	AG_TextInfo("infomsg",
	    "This is an informational message. Multiline text is "
	    "always allowed. Text will be wrapped to multiple lines "
	    "if it cannot be displayed properly on a single line.");

	/* Edit an existing floating-point variable. */
	AG_TextEditFloat(&v, 0.0, 100.0, "cm", "Edit a float value: ");

	/* Edit an existing fixed-size string buffer. */
	AG_Strlcpy(s, "Test string", sizeof(s));
	AG_TextEditString(s, sizeof(s), "Edit a string: ");

	/* Use the standard Agar event loop. */
	AG_EventLoop();
	AG_Destroy();
	return (0);
}