8 #define DIE(format, ...) do { \
9 fprintf(stderr, "Died at %s:%d: ", __FILE__, __LINE__ ); \
10 fprintf(stderr, format "\n", ## __VA_ARGS__); \
17 static HgwContext *hgw;
21 // hildon-games-wrapper sets this env variable for itself.
22 char* service = getenv("HGW_EXEC_SERVICE");
25 // Not launched from hildon-games-wrapper
30 hgw = hgw_context_init();
33 fprintf(stderr, "Error opening hgw context\n");
38 printf("Loading in HGW mode\n");
43 if (!hgwLaunched) return;
45 hgw_context_destroy(hgw,
46 (Config.snapshotSave ? HGW_BYE_PAUSED : HGW_BYE_INACTIVE));
53 if (!hgwLaunched) return;
55 Config.fullscreen = true;
57 char romFile[PATH_MAX + 1];
58 if (hgw_conf_request_string(hgw, kGConfRomFile, romFile) == HGW_ERR_NONE) {
59 S9xSetRomFile(romFile);
61 hgw_context_destroy(hgw, HGW_BYE_INACTIVE);
62 DIE("No Rom in Gconf!");
65 char no_audio = FALSE;
66 if (hgw_conf_request_bool(hgw, kGConfDisableAudio, &no_audio) == HGW_ERR_NONE) {
67 Config.enableAudio = no_audio ? true : false;
71 if (hgw_conf_request_bool(hgw, kGConfTurboMode, &turbo) == HGW_ERR_NONE) {
72 Settings.TurboMode = turbo ? TRUE : FALSE;
76 if (hgw_conf_request_int(hgw, kGConfFrameskip, &frameskip) == HGW_ERR_NONE) {
77 Settings.SkipFrames = (frameskip > 0 ? frameskip : AUTO_FRAMERATE);
80 char transparency = FALSE;
81 if (hgw_conf_request_bool(hgw, kGConfTransparency, &transparency) == HGW_ERR_NONE) {
82 Settings.Transparency = transparency ? TRUE : FALSE;
86 if (hgw_conf_request_int(hgw, kGConfFrameskip, &speedhacks) == HGW_ERR_NONE) {
87 if (speedhacks <= 0) {
88 Settings.HacksEnabled = FALSE;
89 Settings.HacksFilter = FALSE;
90 } else if (speedhacks == 1) {
91 Settings.HacksEnabled = TRUE;
92 Settings.HacksFilter = TRUE;
94 Settings.HacksEnabled = TRUE;
95 Settings.HacksFilter = FALSE;
99 HgwStartCommand cmd = hgw_context_get_start_command(hgw);
102 case HGW_COMM_NONE: // called from libosso
104 Config.snapshotLoad = true;
105 Config.snapshotSave = true;
107 case HGW_COMM_RESTART:
108 Config.snapshotLoad = false;
109 Config.snapshotSave = true;
113 Config.snapshotLoad = false;
114 Config.snapshotSave = false;
115 Config.quitting = true;
122 if (!hgwLaunched) return;
125 HgwMessageFlags flags = HGW_MSG_FLAG_NONE;
127 if ( hgw_msg_check_incoming(hgw, &msg, flags) == HGW_ERR_COMMUNICATION ) {
128 // Message Incoming, process msg
131 case HGW_MSG_TYPE_CBREQ:
135 Config.quitting = true;
139 case HGW_MSG_TYPE_DEVSTATE:
141 case HGW_DEVICE_STATE_SHUTDOWN:
142 Config.quitting = true; // try to quit gracefully
151 hgw_msg_free_data(&msg);