/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. * Copyright (C) 2010-2012 - Hans-Kristian Arntzen * Copyright (C) 2011-2012 - Daniel De Matteis * * Some code herein may be based on code found in BSNES. * * SSNES is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. * * SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with SSNES. * If not, see . */ #include #include #include #include #include "menu.h" #include "xdk360_video.h" #include "../general.h" #include "shared.h" #define DEVICE_MEMORY_UNIT0 1 #define DEVICE_MEMORY_UNIT1 2 #define DEVICE_MEMORY_ONBOARD 3 #define DEVICE_CDROM0 4 #define DEVICE_HARDISK0_PART1 5 #define DEVICE_HARDISK0_SYSPART 6 #define DEVICE_USB0 7 #define DEVICE_USB1 8 #define DEVICE_USB2 9 #define DEVICE_TEST 10 #define DEVICE_CACHE 11 typedef struct _STRING { USHORT Length; USHORT MaximumLength; PCHAR Buffer; } STRING; extern "C" int __stdcall ObCreateSymbolicLink( STRING*, STRING*); uint32_t mode_switch = MODE_MENU; int Mounted[20]; int ssnes_main(int argc, char *argv[]); #undef main static int DriveMounted(std::string path) { WIN32_FIND_DATA findFileData; memset(&findFileData,0,sizeof(WIN32_FIND_DATA)); std::string searchcmd = path + "\\*.*"; HANDLE hFind = FindFirstFile(searchcmd.c_str(), &findFileData); if (hFind == INVALID_HANDLE_VALUE) return 0; FindClose(hFind); return 1; } static int Mount( int Device, char* MountPoint ) { char MountConv[260]; sprintf_s( MountConv,"\\??\\%s", MountPoint ); char * SysPath = NULL; switch( Device ) { case DEVICE_MEMORY_UNIT0: SysPath = "\\Device\\Mu0"; break; case DEVICE_MEMORY_UNIT1: SysPath = "\\Device\\Mu1"; break; case DEVICE_MEMORY_ONBOARD: SysPath = "\\Device\\BuiltInMuSfc"; break; case DEVICE_CDROM0: SysPath = "\\Device\\Cdrom0"; break; case DEVICE_HARDISK0_PART1: SysPath = "\\Device\\Harddisk0\\Partition1"; break; case DEVICE_HARDISK0_SYSPART: SysPath = "\\Device\\Harddisk0\\SystemPartition"; break; case DEVICE_USB0: SysPath = "\\Device\\Mass0"; break; case DEVICE_USB1: SysPath = "\\Device\\Mass1"; break; case DEVICE_USB2: SysPath = "\\Device\\Mass2"; break; case DEVICE_CACHE: SysPath = "\\Device\\Harddisk0\\Cache0"; break; } STRING sSysPath = { (USHORT)strlen( SysPath ), (USHORT)strlen( SysPath ) + 1, SysPath }; STRING sMountConv = { (USHORT)strlen( MountConv ), (USHORT)strlen( MountConv ) + 1, MountConv }; int res = ObCreateSymbolicLink( &sMountConv, &sSysPath ); if (res != 0) return res; return DriveMounted(MountPoint); } static void MountAll() { memset(&Mounted,0,20); Mounted[DEVICE_USB0] = Mount(DEVICE_USB0,"Usb0:"); Mounted[DEVICE_USB1] = Mount(DEVICE_USB1,"Usb1:"); Mounted[DEVICE_USB2] = Mount(DEVICE_USB2,"Usb2:"); Mounted[DEVICE_HARDISK0_PART1] = Mount(DEVICE_HARDISK0_PART1,"Hdd1:"); Mounted[DEVICE_HARDISK0_SYSPART] = Mount(DEVICE_HARDISK0_SYSPART,"HddX:"); Mounted[DEVICE_MEMORY_UNIT0] = Mount(DEVICE_MEMORY_UNIT0,"Memunit0:"); Mounted[DEVICE_MEMORY_UNIT1] = Mount(DEVICE_MEMORY_UNIT1,"Memunit1:"); Mounted[DEVICE_MEMORY_ONBOARD] = Mount(DEVICE_MEMORY_ONBOARD,"OnBoardMU:"); Mounted[DEVICE_CDROM0] = Mount(DEVICE_CDROM0,"Dvd:"); } int main(int argc, char *argv[]) { //for devkits only, we will need to mount all partitions for retail //in a different way //DmMapDevkitDrive(); MountAll(); ssnes_main_clear_state(); config_set_defaults(); xdk360_video_init(); menu_init(); menu_loop(); char arg1[] = "ssnes"; char arg2[] = "d:\\roms\\mario.sfc"; char arg3[] = "-v"; char arg4[] = "-c"; char arg5[] = "d:\\ssnes.cfg"; char *argv_[] = { arg1, arg2, arg3, arg4, arg5, NULL }; int argc_ = sizeof(argv_) / sizeof(argv_[0]) - 1; int init_ret = ssnes_main_init(argc_, argv_); while(ssnes_main_iterate()); ssnes_main_deinit(); xdk360_video_deinit(); }