+void InitCommandName(char *argv0)
+{
+ program.command_basename =
+ (strrchr(argv0, '/') ? strrchr(argv0, '/') + 1 : argv0);
+}
+
+void InitExitFunction(void (*exit_function)(int))
+{
+ program.exit_function = exit_function;
+
+ /* set signal handlers to custom exit function */
+ signal(SIGINT, exit_function);
+ signal(SIGTERM, exit_function);
+
+#if defined(TARGET_SDL)
+ /* set exit function to automatically cleanup SDL stuff after exit() */
+ atexit(SDL_Quit);
+#endif
+}
+
+void InitPlatformDependantStuff(void)
+{
+#if defined(PLATFORM_MSDOS)
+ _fmode = O_BINARY;
+#endif
+
+#if !defined(PLATFORM_UNIX)
+ program.userdata_directory = "userdata";
+ initErrorFile();
+#endif
+
+#if defined(TARGET_SDL)
+ if (SDL_Init(SDL_INIT_EVENTTHREAD | SDL_INIT_NOPARACHUTE) < 0)
+ Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
+#endif
+}
+
+void ClosePlatformDependantStuff(void)
+{
+#if !defined(PLATFORM_UNIX)
+ dumpErrorFile();
+#endif
+}
+
+void InitProgramInfo(char *unix_userdata_directory, char *program_title,
+ char *window_title, char *icon_title,
+ char *x11_icon_basename, char *x11_iconmask_basename,
+ char *msdos_pointer_basename)
+{
+ char *gfx_dir = getPath2(options.ro_base_directory, GRAPHICS_DIRECTORY);
+ char *x11_icon_filename = getPath2(gfx_dir, x11_icon_basename);
+ char *x11_iconmask_filename = getPath2(gfx_dir, x11_iconmask_basename);
+ char *msdos_pointer_filename = getPath2(gfx_dir, msdos_pointer_basename);
+
+ free(gfx_dir);
+
+#if defined(PLATFORM_UNIX)
+ program.userdata_directory = unix_userdata_directory;
+#else
+ program.userdata_directory = "userdata";
+#endif
+
+ program.program_title = program_title;
+ program.window_title = window_title;
+ program.icon_title = icon_title;
+ program.x11_icon_filename = x11_icon_filename;
+ program.x11_iconmask_filename = x11_iconmask_filename;
+ program.msdos_pointer_filename = msdos_pointer_filename;
+}
+
+void InitGfxFieldInfo(int sx, int sy, int sxsize, int sysize,
+ int real_sx, int real_sy,
+ int full_sxsize, int full_sysize)
+{
+ gfx.sx = sx;
+ gfx.sy = sy;
+ gfx.sxsize = sxsize;
+ gfx.sysize = sysize;
+ gfx.real_sx = real_sx;
+ gfx.real_sy = real_sy;
+ gfx.full_sxsize = full_sxsize;
+ gfx.full_sysize = full_sysize;
+}
+
+void InitGfxDoor1Info(int dx, int dy, int dxsize, int dysize)
+{
+ gfx.dx = dx;
+ gfx.dy = dy;
+ gfx.dxsize = dxsize;
+ gfx.dysize = dysize;
+}
+
+void InitGfxDoor2Info(int vx, int vy, int vxsize, int vysize)
+{
+ gfx.vx = vx;
+ gfx.vy = vy;
+ gfx.vxsize = vxsize;
+ gfx.vysize = vysize;
+}
+
+void InitGfxScrollbufferInfo(int scrollbuffer_width, int scrollbuffer_height)
+{
+ /* currently only used by MSDOS code to alloc VRAM buffer, if available */
+ gfx.scrollbuffer_width = scrollbuffer_width;
+ gfx.scrollbuffer_height = scrollbuffer_height;
+}