Exemplo n.º 1
0
static gboolean audio_changed(DBusConnection *conn,
				DBusMessage *msg, void *user_data)
{
	struct modem_data *modem = user_data;
	DBusMessageIter iter, value;
	const char *key;

	if (dbus_message_iter_init(msg, &iter) == FALSE)
		return TRUE;

	dbus_message_iter_get_basic(&iter, &key);

	dbus_message_iter_next(&iter);
	dbus_message_iter_recurse(&iter, &value);

	audio_set(modem, key, &value);

	return TRUE;
}
Exemplo n.º 2
0
int main(int argc, char** argv)
{
 auint   j;
 auint   t;
 auint   cdi = 0U;
 auint   auc = 0U;
 uint16* lpt;
 uint16* rpt;
 uint16  edt;          /* Event data (just one) */
 auint   mid;          /* Mouse device id */
 SDL_Event event;      /* The event got from the queue */
 rrpge_object_t* emu = NULL;



 /* Init message */
 printf("\n");
 printf("%s", main_appname);
 printf("\n\n");
 printf("%s", main_appauth);
 printf("%s", main_copyrig);
 printf("\n");



 /* Check arguments: need an application */
 if (argc <= 1){
  printf("Error: need an application to run as parameter!\n");
  exit(1);
 }else{
  printf("Opening %s...\n", argv[1]);
  main_app = fopen(argv[1], "rb");
  if (main_app == NULL){
   perror("Failed to open file");
   exit(1);
  }
 }



 /* Initialize emulator library */
 rrpge_init_lib(&main_malloc, &free);



 /* Attempt to initialize the emulator. Note that the app. binary load
 ** callback is blocking, so no need to implement any waiting here using
 ** rrpge_init_run(). */
 emu = rrpge_new_emu(&main_cbpack);
 if (emu == NULL){
  printf("Failed to allocate emulator state\n");
  goto loadfault;
 }
 t = rrpge_init_run(emu, RRPGE_INI_RESET);
 if (t != RRPGE_ERR_OK){
  printf("Failed to initialize emulator\n");
  main_printrerr(t);
  goto loadfault;
 }
 mid = rrpge_dev_add(emu, RRPGE_DEV_POINT); /* Add mouse (pointing device) */

 /* Initialize renderer */
 render_reset(emu);

 /* Initialize SDL */
 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)!=0) return -1;

 /* Try to set up the screen */
 if (screen_set()!=0) return -1;
 SDL_WM_SetCaption(main_appname, main_appicon);

 /* Set up audio */
 if (audio_set(2048U) != 0U) return -1;

 /* OK, let's go! */

 printf("Entering emulation\n");

 /* The main loop: It is more straightforward to exit from it with a suitable
 ** break at the proper place */
 while(1){

  /* Wait for some event... */
  if (SDL_WaitEvent(&event)==0) return -1; /*Error?*/

  /* An event is here: do something about it! */
  if (event.type==SDL_USEREVENT){
   if (event.user.code==AUDIO_EVENT){

    t = 0U;                      /* No halt */

    while (audio_needservice()){ /* Waiting for audio data from emulator */

     do{
      j = rrpge_run(emu, RRPGE_RUN_FREE);
      t = rrpge_gethaltcause(emu);
      if (t & RRPGE_HLT_AUDIO){ cdi++; }
      if (cdi >= 10){
       cdi = 0U;
       printf("Audio events: %08d\n", auc);
       printf("Cycles: %08d\n", j);
       main_printstats(emu);
       main_printhalt(t);
      }
      /* Need proper exit point... */
     }while ((t & (RRPGE_HLT_AUDIO |
                   RRPGE_HLT_EXIT |
                   RRPGE_HLT_STACK |
                   RRPGE_HLT_INVKCALL |
                   RRPGE_HLT_INVOP |
                   RRPGE_HLT_FAULT |
                   RRPGE_HLT_DETACHED |
                   RRPGE_HLT_WAIT)) == 0U);

     if ((t & RRPGE_HLT_AUDIO) != 0U){ /* Audio data produced by emulator */

      audio_getbufptrs(&lpt, &rpt);
      rrpge_getaudio(emu, lpt, rpt);
      auc++;

     }

     if ((t & (RRPGE_HLT_EXIT |
               RRPGE_HLT_STACK |
               RRPGE_HLT_INVKCALL |
               RRPGE_HLT_INVOP |
               RRPGE_HLT_FAULT |
               RRPGE_HLT_DETACHED |
               RRPGE_HLT_WAIT)) != 0U){ /* Errors & Exit */
      break;
     }

    }                                  /* End of audio wait loop */

    if ((t & RRPGE_HLT_EXIT) != 0U){ break; } /* Exit program */
    if ((t & (RRPGE_HLT_STACK |
              RRPGE_HLT_INVKCALL |
              RRPGE_HLT_INVOP |
              RRPGE_HLT_FAULT |
              RRPGE_HLT_DETACHED |
              RRPGE_HLT_WAIT)) != 0U){
     main_errexit(t, emu);
     break;                            /* Also exit, with error */
    }

   }
  }else if (event.type==SDL_KEYDOWN){
   /* Some key was pressed. Which? */
   if (event.key.keysym.sym==SDLK_ESCAPE) break; /* Exit program */

  }else if (event.type==SDL_KEYUP){

  }else if (event.type==SDL_QUIT){     /* Exit program */
   break;

  }else if (event.type==SDL_MOUSEBUTTONDOWN){

   edt = (uint16)(event.button.x);
   rrpge_dev_push(emu, mid, 2U, 1U, &edt);
   edt = (uint16)(event.button.y);
   rrpge_dev_push(emu, mid, 3U, 1U, &edt);
   if      (event.button.button == SDL_BUTTON_LEFT){   edt = 1U; rrpge_dev_push(emu, mid, 0U, 1U, &edt); }
   else if (event.button.button == SDL_BUTTON_RIGHT){  edt = 2U; rrpge_dev_push(emu, mid, 0U, 1U, &edt); }
   else if (event.button.button == SDL_BUTTON_MIDDLE){ edt = 3U; rrpge_dev_push(emu, mid, 0U, 1U, &edt); }
   else {}

  }else if (event.type==SDL_MOUSEBUTTONUP){

   edt = (uint16)(event.button.x);
   rrpge_dev_push(emu, mid, 2U, 1U, &edt);
   edt = (uint16)(event.button.y);
   rrpge_dev_push(emu, mid, 3U, 1U, &edt);
   if      (event.button.button == SDL_BUTTON_LEFT){   edt = 1U; rrpge_dev_push(emu, mid, 1U, 1U, &edt); }
   else if (event.button.button == SDL_BUTTON_RIGHT){  edt = 2U; rrpge_dev_push(emu, mid, 1U, 1U, &edt); }
   else if (event.button.button == SDL_BUTTON_MIDDLE){ edt = 3U; rrpge_dev_push(emu, mid, 1U, 1U, &edt); }
   else {}

  }else if (event.type==SDL_MOUSEMOTION){

   edt = (uint16)(event.motion.x);
   rrpge_dev_push(emu, mid, 2U, 1U, &edt);
   edt = (uint16)(event.motion.y);
   rrpge_dev_push(emu, mid, 3U, 1U, &edt);

  }

 }

 printf("Trying to exit\n");

 rrpge_delete(emu);
 audio_free();
 screen_free();

 SDL_Quit();

 fclose(main_app);

 exit(0);


loadfault:

 if (emu != NULL) free(emu);
 fclose(main_app);

 exit(1);
}
Exemplo n.º 3
0
// Write out the config file for the whole application
int configAppSaveXml()
{
	if (bCmdOptUsed) {
		return 1;
	}

	char configName[MAX_PATH];
	createConfigName(configName);

	try {
		char tempStr[64] = "";

		// root
		ticpp::Document doc;
		ticpp::Declaration decl("1.0", "UTF-8", "");
		doc.LinkEndChild(&decl);

		ticpp::Element root("configuration");
		setAttr(root, "version", configVersion);
		ticpp::Comment comment("Don't edit this file manually unless you know what you're doing\n" \
					APP_TITLE " will restore default settings when this file is deleted");
		doc.LinkEndChild(&comment);
		doc.LinkEndChild(&root);

		// title
		sprintf(tempStr, "0x%06X", nBurnVer);
		addTextNode(root, "version", tempStr);

		// emulation
		ticpp::Element emulation("emulation");
		root.LinkEndChild(&emulation);
		setAttr(emulation, "asm-68k", bBurnUseASM68K);
		setAttr(emulation, "all-ram", bDrvSaveAll);

		// video
		ticpp::Element video("video");
		root.LinkEndChild(&video);

		ticpp::Element fullscreen("fullscreen");
		video.LinkEndChild(&fullscreen);
		setAttr(fullscreen, "width", nVidWidth);
		setAttr(fullscreen, "height", nVidHeight);
		setAttr(fullscreen, "depth", nVidDepth);
		setAttr(fullscreen, "refresh", nVidRefresh);

		ticpp::Element adjust("adjust");
		video.LinkEndChild(&adjust);
		setAttr(adjust, "rotate-vertical", nVidRotationAdjust);

		ticpp::Element screen_size("screen-size");
		video.LinkEndChild(&screen_size);
		setAttr(screen_size, "window", nWindowSize);

		ticpp::Element window_position("window-position");
		video.LinkEndChild(&window_position);
		setAttr(window_position, "x", nWindowPosX);
		setAttr(window_position, "y", nWindowPosY);

		ticpp::Element stretch("stretch");
		video.LinkEndChild(&stretch);
		setAttr(stretch, "full-stretch", bVidFullStretch);
		setAttr(stretch, "correct-aspect", bVidCorrectAspect);

		ticpp::Element color("color");
		video.LinkEndChild(&color);
		setAttr(color, "enable", bcolorAdjust);
		setAttr(color, "contrast", color_contrast);
		setAttr(color, "brightness", color_brightness);
		setAttr(color, "gamma", color_gamma);
		setAttr(color, "grayscale", color_grayscale);
		setAttr(color, "invert", color_invert);

		ticpp::Element vsync("vsync");
		video.LinkEndChild(&vsync);
		setAttr(vsync, "enable", bVidVSync);

		ticpp::Element triple_buffer("triple-buffer");
		video.LinkEndChild(&triple_buffer);
		setAttr(triple_buffer, "enable", bVidTripleBuffer);

		// video render
		ticpp::Element render("render");
		video.LinkEndChild(&render);

		ticpp::Element render_driver("render-driver");
		render.LinkEndChild(&render_driver);
		setAttr(render_driver, "driver", nVidSelect);
		setAttr(render_driver, "adapter", nVidAdapter);

		ticpp::Element filter("filter");
		render.LinkEndChild(&filter);
		setAttr(filter, "linear", vidFilterLinear);
		setAttr(filter, "use-pixelfilter", vidUseFilter);
		setAttr(filter, "pixel-filter", nVidFilter);

		ticpp::Element option("option");
		render.LinkEndChild(&option);
		setAttr(option, "force-16bit", bVidForce16bit);
		setAttr(option, "hardware-vertex", vidHardwareVertex);
		setAttr(option, "motion-blur", vidMotionBlur);
		setAttr(option, "projection", nVid3DProjection);
		setAttr(option, "angel", fVidScreenAngle);
		setAttr(option, "curvature", fVidScreenCurvature);
		setAttr(option, "dxmanager", nVidDXTextureManager);

		setAttr(option, "x-offset", nXOffset);
		setAttr(option, "y-offset", nYOffset);
		setAttr(option, "x-scale",  nXScale);
		setAttr(option, "y-scale",  nYScale);

		// video others
		ticpp::Element monitor("monitor");
		video.LinkEndChild(&monitor);
		setAttr(monitor, "auto-aspect", autoVidScrnAspect);
		setAttr(monitor, "aspect-x", nVidScrnAspectX);
		setAttr(monitor, "aspect-y", nVidScrnAspectY);

		ticpp::Element frame("frame");
		video.LinkEndChild(&frame);
		setAttr(frame, "auto-frameskip", autoFrameSkip);
		setAttr(frame, "force-60hz", bForce60Hz);

		// audio
		ticpp::Element audio("audio");
		root.LinkEndChild(&audio);
		addTextNode(audio, "sound", audSelect);

		ticpp::Element device("device");
		audio.LinkEndChild(&device);
		setAttr(device, "ds", dsDevice);
		setAttr(device, "xa2", xa2Device);
		setAttr(device, "oal", oalDevice);

		ticpp::Element audio_set("setting");
		audio.LinkEndChild(&audio_set);
		setAttr(audio_set, "rate", nAudSampleRate);
		setAttr(audio_set, "frame", nAudSegCount);
		setAttr(audio_set, "dsp", nAudDSPModule);
		setAttr(audio_set, "pcm-interp", nInterpolation);
		setAttr(audio_set, "fm-interp", nFMInterpolation);
		setAttr(audio_set, "stereo-upmix", audStereoUpmixing);

		// gui
		ticpp::Element gui("gui");
		root.LinkEndChild(&gui);
		addTextNode(gui, "language", szLanguage);
		//addTextNode(gui, "gamelist", szTransGamelistFile);

		ticpp::Element chat("chat-font");
		gui.LinkEndChild(&chat);
		setAttr(chat, "min-size", nMinChatFontSize);
		setAttr(chat, "max-size", nMaxChatFontSize);

		ticpp::Element menu("menu");
		gui.LinkEndChild(&menu);
		setAttr(menu, "modeless", bModelessMenu);
		setAttr(menu, "style", menuNewStyle);

		ticpp::Element gui_misc("gui-misc");
		gui.LinkEndChild(&gui_misc);
		setAttr(gui_misc, "on-top", bShowOnTop);
		setAttr(gui_misc, "auto-fullscreen", bFullscreenOnStart);
		setAttr(gui_misc, "lastRom", nLastRom);
		setAttr(gui_misc, "lastFilter", nLastFilter);

		setAttr(gui_misc, "hideChildren", HideChildren);
		setAttr(gui_misc, "showThreeFourPlayerOnly", ThreeOrFourPlayerOnly);
		setAttr(gui_misc, "arcadeJoyStickSettings", ArcadeJoystick);

		// gui load game dialog
		ticpp::Element gamelist("gamelist-dlg");
		gui.LinkEndChild(&gamelist);
		setAttr(gamelist, "options", nLoadMenuShowX);
		//setAttr(gamelist, "drivers", nLoadDriverShowX);
		//setAttr(gamelist, "sys-sel", nSystemSel);
		//setAttr(gamelist, "tab-sel", nTabSel);
		//addTextNode(gamelist, "user-filter", szUserFilterStr);

		// gui ips
		ticpp::Element ips("ips");
		gui.LinkEndChild(&ips);
		setAttr(ips, "language", nPatchLang);
		setAttr(ips, "dependancy", bEnforceDep);

		//ticpp::Element skin("skin");
		//gui.LinkEndChild(&skin);
		//setAttr(skin, "use-placeholder", bVidUsePlaceholder);
		//setAttr(skin, "random", nRandomSkin);
		//addTextNode(skin, NULL, szPlaceHolder);

		// preferences
		ticpp::Element preference("preferences");
		root.LinkEndChild(&preference);

		ticpp::Element settings("settings");
		preference.LinkEndChild(&settings);
		setAttr(settings, "always-processkey", bAlwaysProcessKey);
		setAttr(settings, "auto-pause", bAutoPause);
		//setAttr(settings, "avi-audio", nAviIntAudio);
		//setAttr(settings, "use-gdip", bUseGdip);
		ticpp::Element fastforward("fastforward");
		preference.LinkEndChild(&fastforward);
		setAttr(fastforward, "speed", nFastSpeed);
		ticpp::Element thread("thread");
		preference.LinkEndChild(&thread);
		setAttr(thread, "priority", nAppThreadPriority);
		ticpp::Element autofire("autofire");
		preference.LinkEndChild(&autofire);
		setAttr(autofire, "enable", nAutofireEnabled);
		setAttr(autofire, "default-delay", autofireDefaultDelay);
		ticpp::Element macro("macro");
		preference.LinkEndChild(&macro);
		setAttr(macro, "enable", nInputMacroEnabled);

		// pref misc
		ticpp::Element pref_misc("misc");
		preference.LinkEndChild(&pref_misc);
		setAttr(pref_misc, "effect", nShowEffect);

		ticpp::Element controls("controls");
		preference.LinkEndChild(&controls);
		for (int i = 0; i < 4; i++) {
			sprintf(tempStr, "default%d", i);
			addTextNode(controls, tempStr, szPlayerDefaultIni[i]);
		}

		// paths
		ticpp::Element paths("paths");
		root.LinkEndChild(&paths);

		ticpp::Element rom_path("rom");
		paths.LinkEndChild(&rom_path);
		for (int i = 0; i < DIRS_MAX; i++) {
			addTextNode(rom_path, "path", szAppRomPaths[i]);
		}

		ticpp::Element misc_path("misc");
		paths.LinkEndChild(&misc_path);
		for (int i = PATH_PREVIEW; i < PATH_SUM; i++) {
			sprintf(tempStr, "path%d", i);
			addTextNode(misc_path, tempStr, szMiscPaths[i]);
		}

		// hotkeys
		ticpp::Element hotkeys("hotkeys");
		root.LinkEndChild(&hotkeys);

		/*for (int i = 0; !lastCustomKey(customKeys[i]); i++) {
			CustomKey& customkey = customKeys[i];

			ticpp::Element key(customkey.config_code);
			hotkeys.LinkEndChild(&key);
			setAttr(key, "key", customkey.key);
			setAttr(key, "mod", customkey.keymod);
		}*/

		// save file
		doc.SaveFile(configName, TIXML_ENCODING_UTF8);
	}
	catch (ticpp::Exception& ex) {
		return 1;
	}

	return 0;
}