Exemplo n.º 1
0
        private RoomType GetRoomTypeFromRomType(RomType roomType)
        {
            switch (roomType)
            {
            case RomType.SuperDeluxeSuite:
                return(RoomType.SuperDeluxeSuite);

            case RomType.Suite:
                return(RoomType.Suite);

            case RomType.JuniorSuite:
                return(RoomType.JuniorSuite);

            case RomType.Dobbel:
                return(RoomType.Double);

            case RomType.Twin:
                return(RoomType.Twin);

            case RomType.Enkel:
                return(RoomType.Single);

            case RomType.Delt:
                return(RoomType.Shared);
            }

            throw new InvalidEnumArgumentException("Missing mapping for RomType");
        }
Exemplo n.º 2
0
        public static Task HandleCoop(RomType romType, Dictionary <string, byte[]> data, CoopSetting previousSetting, CoopSetting newSetting, byte[] rawFile)
        {
            // Only do this once
            if (romType != RomType.NorthAmerica)
            {
                return(Task.FromResult(0));
            }

            lock (WebFileHandler.Lock)
            {
                // Get the WebConfig
                JelonzoBotWebConfig webConfig = ((JelonzoBotConfiguration)Configuration.LoadedConfiguration).WebConfig;

                // Connect to the remote server if needed
                WebFileHandler.Connect(webConfig);

                // Deserialize the CoopSetting dynamically
                dynamic settingDynamic = ByamlLoader.GetByamlDynamic(rawFile);

                // Upload to the server
                WebFileHandler.WriteSerializedJson(webConfig.CoopSettingPath, settingDynamic);

                // Disconnect
                WebFileHandler.Disconnect();
            }

            return(Task.FromResult(0));
        }
Exemplo n.º 3
0
        public Roms(RomType romType)
        {
            switch (romType)
            {
            case RomType.MAME:
                Directory    = P_romsDirectory_MAME.ToLower().Trim();
                P_extensions = P_extensions_MAME.Trim();
                break;

            default:
                break;
            }

            //FileExtensions
            if (P_extensions.Contains(";"))
            {
                FileExtensions = P_extensions.Split(';').Select(a => a != null ? a.Trim() : null).ToList();
            }
            else
            {
                FileExtensions.Add(P_extensions);
            }
            FileExtensions.Remove(string.Empty);
            P_extensions = null;
        }
Exemplo n.º 4
0
        public static void Initialize()
        {
            if (!Configuration.LoadedConfiguration.FirstRunCompleted)
            {
                throw new Exception("Cannot initialize FileCache if the first run is not complete");
            }

            // Create a ByamlSerializer
            ByamlSerializer byamlSerializer = new ByamlSerializer(new ByamlSerializerSettings()
            {
                ByteOrder    = Syroot.BinaryData.ByteOrder.LittleEndian,
                SupportPaths = false,
                Version      = ByamlVersion.Version1
            });

            // Create the FestivalSettings dictionary
            FestivalSettings = new Dictionary <RomType, List <FestivalSetting> >();

            // Populate the FestivalSettings dictionary with RomTypes and lists
            foreach (RomType romType in Program.BcatPairs.Keys)
            {
                // Create a list for this RomType
                FestivalSettings[romType] = new List <FestivalSetting>();

                // Get all FestivalSetting byamls for this RomType
                string[] festPaths = Directory.GetFiles(Path.Combine(LOCAL_DIRECTORY, "Festival", romType.ToString()), "*.byaml");

                // Loop over every path
                foreach (string festPath in festPaths)
                {
                    // Deserialize the byaml
                    FestivalSetting festivalSetting = byamlSerializer.Deserialize <FestivalSetting>(festPath);

                    // Add this to the list
                    FestivalSettings[romType].Add(festivalSetting);
                }

                // Sort in ascending order
                FestivalSettings[romType].Sort((x, y) => x.Times.Start.CompareTo(y.Times.Start));
            }

            // Create the VersusSettings dictionary
            VersusSettings = new Dictionary <RomType, VersusSetting>();

            // Get all VersusSetting byamls
            string[] versusPaths = Directory.GetFiles(Path.Combine(LOCAL_DIRECTORY, "VSSetting"));

            // Loop over every path
            foreach (string versusPath in versusPaths)
            {
                // Get the RomType
                RomType romType = (RomType)EnumUtil.GetEnumValueFromString(typeof(RomType), Path.GetFileNameWithoutExtension(versusPath));

                // Deserialize the byaml
                VersusSettings[romType] = byamlSerializer.Deserialize <VersusSetting>(versusPath);
            }

            // Deserialize the CoopSetting byaml
            CoopSetting = byamlSerializer.Deserialize <CoopSetting>(COOP_SETTING_PATH);
        }
Exemplo n.º 5
0
 private void CreateCacheController(RomType romTypeEnum)
 {
     _cacheController = new CacheController(romTypeEnum);
     _cacheController.OnProgressChanged       += _cacheController_OnProgressChanged;
     _cacheController.OnCacheLoadingStarted   += _cacheController_OnCacheLoadingStarted;
     _cacheController.OnCacheLoadingAborted   += _cacheController_OnCacheLoadingAborted;
     _cacheController.OnCacheLoadingCompleted += _cacheController_OnCacheCompleted;
 }
Exemplo n.º 6
0
		private string GetDescription(RomType romType)
		{
			string description;

			if (descriptionCache.TryGetValue(romType, out description))
				return description;
			else
				return romType.ToString();
		}
Exemplo n.º 7
0
        public static void SetVersusSettingForRomType(RomType romType, VersusSetting versusSetting, byte[] rawSetting)
        {
            VersusSettings[romType] = versusSetting;

            // Construct the local path
            string localPath = string.Format(VERSUS_SETTING_PATH, romType.ToString());

            // Write out the file
            File.WriteAllBytes(localPath, rawSetting);
        }
Exemplo n.º 8
0
        public static int GetPos(RomType romType)
        {
            int pos = RomChecksumming.GetTablePos(romType);

            if (pos >= 0)
            {
                pos += RomChecksumming.ChecksumTableRecordCount * RomChecksumming.SizeOfNativeStruct;
            }
            return(pos);
        }
Exemplo n.º 9
0
        public RoomBookingInfo FindBookingBy(RomType romType, DateTime fromDate, int duration)
        {
            RoomBookingInfo[] roomBookingInfos = _client.Get("api/booking", true).ToObject <RoomBookingInfo[]>();

            var firstMatchingBooking =
                roomBookingInfos.First(roomBookingInfo => roomBookingInfo.RoomType == GetRoomTypeFromRomType(romType) &&
                                       roomBookingInfo.FromDate.Date == fromDate.Date &&
                                       roomBookingInfo.Duration == duration);

            return(firstMatchingBooking);
        }
Exemplo n.º 10
0
 public MBC2(byte[] fileData, byte[] savedData, RomType romType, int romSize, int romBanks) : this(fileData, romType, romSize, romBanks)
 {
     // Load RAM data
     if (savedData != null)
     {
         for (int i = 0; i < RAM_SIZE; ++i)
         {
             ram [i] = fileData [i];
         }
     }
 }
Exemplo n.º 11
0
        public static ErrorCode CheckInput(string file, out RomType type)
        {
            type = RomType.Invalid; // In case of previous invalid validations

            ErrorCode code = CheckPath(file);

            code = code.IsValid() ? CheckFileExists(file) : code;
            code = code.IsValid() ? CheckRomSize(file, RomLength) : code;
            code = code.IsValid() ? IsMd5Valid(file, out type) : code;
            return(code);
        }
Exemplo n.º 12
0
        public void MakeBooking(RomType romType, DateTime fraDato, int lengdePåOpphold)
        {
            var page = _webDriver.Navigate <NewBookingPage>();

            page.WaitUntilLoaded();

            page.RoomType.SelectFirstOptionThatContainsText(romType.ToString());
            page.FromDate.TypeDate(fraDato);
            page.Duration.TypeText(lengdePåOpphold);

            page.SaveButton.Click();
        }
Exemplo n.º 13
0
        private static string GetDescription(RomType romType)
        {
            string description;

            if (_descriptionCache.TryGetValue(romType, out description))
            {
                return(description);
            }
            else
            {
                return(romType.ToString());
            }
        }
Exemplo n.º 14
0
        private RezController(string offlineListCacheLocation, RomType fileType)
        {
            _datRezEntities = new List <DatRezEntity>();

            _backgroundWorker = new BackgroundWorker();
            _backgroundWorker.WorkerReportsProgress = true;
            _backgroundWorker.DoWork             += backgroundWorker_DoWork;
            _backgroundWorker.ProgressChanged    += backgroundWorker_ProgressChanged;
            _backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted;

            _offlineListCacheLocation = offlineListCacheLocation;
            _fileType = fileType;
        }
Exemplo n.º 15
0
 public static int GetTablePos(RomType romType)
 {
     switch (romType) {
     case RomType.SH7055:
         return 0x7FB80;
     case RomType.SH7058:
         return 0xFFB80;
     case RomType.SH7059:
         return 0x17FB80;
     default:
         return 0;
     }
 }
Exemplo n.º 16
0
        public static Task HandleCoop(RomType romType, Dictionary <string, byte[]> data, CoopSetting previousSetting, CoopSetting newSetting, byte[] rawFile)
        {
            // Only do this once
            if (romType != RomType.NorthAmerica)
            {
                return(Task.FromResult(0));
            }

            // Update CoopSetting
            FileCache.SetCoopSetting(newSetting, rawFile);

            return(Task.FromResult(0));
        }
Exemplo n.º 17
0
        public MBC2(byte[] fileData, RomType romType, int romSize, int romBanks)
        {
            this.romType = romType;
            int bankSize = romSize / romBanks;

            rom = new byte[romBanks, bankSize];
            for (int i = 0, k = 0; i < romBanks; ++i)
            {
                for (int j = 0; j < bankSize; ++j, ++k)
                {
                    rom [i, j] = fileData [k];
                }
            }
        }
Exemplo n.º 18
0
        public Mbc1(byte[] fileData, RomType romType, int romSize, int romBanks)
        {
            _romType = romType;
            int bankSize = romSize / romBanks;

            _rom = new byte[romBanks, bankSize];
            for (int i = 0, k = 0; i < romBanks; i++)
            {
                for (int j = 0; j < bankSize; j++, k++)
                {
                    _rom[i, j] = fileData[k];
                }
            }
        }
Exemplo n.º 19
0
 public MBC3(byte[] fileData, byte[] savedData, RomType romType, int romSize, int romBanks)
     : this(fileData, romType, romSize, romBanks)
 {
     // Load the RAM
     if (savedData != null)
     {
         for (int i = 0, k = 0; i < RAM_BANK; ++i)
         {
             for (int j = 0; j < RAM_BANK_SIZE; ++j, ++k)
             {
                 ram [i, j] = savedData [k];
             }
         }
     }
 }
Exemplo n.º 20
0
        private static Dictionary <RomType, string> BuildDescriptionChache()
        {
            Dictionary <RomType, string> descriptionCache = new Dictionary <RomType, string>();

            foreach (FieldInfo fieldInfo in typeof(RomType).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.GetField))
            {
                DescriptionAttribute[] descriptionAttributes = (DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
                RomType value       = (RomType)fieldInfo.GetRawConstantValue();
                string  description = string.Intern(descriptionAttributes.Length > 0 ? descriptionAttributes[0].Description : fieldInfo.Name);

                descriptionCache.Add(value, description);
            }

            return(descriptionCache);
        }
Exemplo n.º 21
0
 private static ErrorCode IsMd5Valid(string rom, out RomType type)
 {
     type = GetMd5Index(rom);
     if (type == RomType.Invalid)
     {
         return(ErrorCode.InvalidChecksum);
     }
     else if (type == RomType.TranslationApBanner)
     {
         return(ErrorCode.DoNothing);
     }
     else
     {
         return(ErrorCode.Valid);
     }
 }
Exemplo n.º 22
0
        public MBC3(byte[] fileData, RomType romType, int romSize, int romBanks)
        {
            this.romType = romType;
            int bankSize = romSize / romBanks;

            rom = new byte[romBanks, bankSize];

            // Load the ROM
            for (int i = 0, k = 0; i < romBanks; i++)
            {
                for (int j = 0; j < bankSize; j++, k++)
                {
                    rom [i, j] = fileData [k];
                }
            }
        }
Exemplo n.º 23
0
        internal static string GetExtension(this RomType romTypeEnum)
        {
            switch (romTypeEnum)
            {
            case RomType.GBA:
                return("gba");

            case RomType.NDS:
                return("nds");

            case RomType.THREEDS:
                return("3ds");

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 24
0
        internal CacheController(RomType fileType)
        {
            _datCacheEntities = new ConcurrentBag <DatCacheEntity>();

            _backgroundWorker = new BackgroundWorker
            {
                WorkerReportsProgress      = true,
                WorkerSupportsCancellation = true
            };
            _backgroundWorker.DoWork             += BackgroundWorker_DoWork;
            _backgroundWorker.ProgressChanged    += BackgroundWorker_ProgressChanged;
            _backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted;

            _offlineListCacheLocation = ConfigReader.Instance.OfflineListCacheDirectory;
            _romLocation = ConfigReader.Instance.RomDirectory;
            _fileType    = fileType;
        }
Exemplo n.º 25
0
        internal static string GetRezFileName(RomType fileType)
        {
            switch (fileType)
            {
            case RomType.GBA:
                return(_gbaRezFileName);

            case RomType.NDS:
                return(_ndsRezFileName);

            case RomType.THREEDS:
                return(_3dsRezFileName);

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 26
0
        internal static string GetFileTypeValue(RomType fileType)
        {
            switch (fileType)
            {
            case RomType.GBA:
                return("GBA");

            case RomType.NDS:
                return("NDS");

            case RomType.THREEDS:
                return("3DS");

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 27
0
        public static int GetTablePos(RomType romType)
        {
            switch (romType)
            {
            case RomType.SH7055:
                return(0x7FB80);

            case RomType.SH7058:
                return(0xFFB80);

            case RomType.SH7059:
                return(0x17FB80);

            default:
                return(0);
            }
        }
Exemplo n.º 28
0
        internal static string GetUserFriendlyName(this RomType romTypeEnum)
        {
            switch (romTypeEnum)
            {
            case RomType.GBA:
                return("GBA");

            case RomType.NDS:
                return("NDS");

            case RomType.THREEDS:
                return("3DS");

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 29
0
        private void UpdateAvailablePatchs(RomType romType)
        {
            // If it's invalid do nothing
            if (romType == RomType.Invalid)
            {
                return;
            }

            // If it's clean everything is available
            if (romType == RomType.Clean)
            {
                return;
            }

            if (romType == RomType.CleanAp)
            {
                RemoveAntiPiracy = true;
                return;
            }

            // Other rom types has the translation patch already, so disable it
            Translation = false;

            // If it has already the AP patch (maybe the user wants the banner too)
            if (romType == RomType.TranslationAp)
            {
                AntiPiracy = false;
            }

            // If it has already the banner patch (maybe the user wants the AP too)
            if (romType == RomType.TranslationBanner)
            {
                Banner = false;
            }

            // If it has everything already (maybe the user is stupid)
            if (romType == RomType.TranslationApBanner)
            {
                AntiPiracy = false;
                Banner     = false;
            }
        }
Exemplo n.º 30
0
        public static Task HandleVersus(RomType romType, Dictionary <string, byte[]> data, VersusSetting previousSetting, VersusSetting newSetting, byte[] rawFile)
        {
            lock (WebFileHandler.Lock)
            {
                // Get the WebConfig
                JelonzoBotWebConfig webConfig = ((JelonzoBotConfiguration)Configuration.LoadedConfiguration).WebConfig;

                // Connect to the remote server if needed
                WebFileHandler.Connect(webConfig);

                // Deserialize the VersusSetting dynamically
                dynamic settingDynamic = ByamlLoader.GetByamlDynamic(rawFile);

                // Get the FestivalSetting JSON path
                string path = webConfig.VersusSettingPath;
                switch (romType)
                {
                case RomType.NorthAmerica:
                    path = string.Format(path, "na");
                    break;

                case RomType.Europe:
                    path = string.Format(path, "eu");
                    break;

                case RomType.Japan:
                    path = string.Format(path, "jp");
                    break;

                default:
                    throw new Exception("Invalid RomType");
                }

                // Upload to the server
                WebFileHandler.WriteSerializedJson(path, settingDynamic);

                // Disconnect
                WebFileHandler.Disconnect();
            }

            return(Task.FromResult(0));
        }
Exemplo n.º 31
0
 private bool ValidateRom(byte[] raw, Region region, RomType type)
 {
     // Castlevania 3 ROM has 256 kb of PRG rom and 128 kb of CHR Rom in both regions
     // Mapper MMC5 (5) in U, and mapper VRC6a (24) for J
     switch (type)
     {
     case RomType.Ines:
     {
         var expectedMapper = region == Region.Japan ? 24 : 5;
         var prgBanks       = raw[4];
         var chrBanks       = raw[5];
         var mapper         = (raw[7] & 0xF0) | (raw[6] >> 4);
         if (prgBanks != 16 || chrBanks != 16 || mapper != expectedMapper)
         {
             return(false);
         }
         return(true);
     }
     }
     return(false);
 }
Exemplo n.º 32
0
        void Open()
        {
            const int BufferSize = 16 * KiB;

            // Copy whole file into MemoryStream at once for best performance.
            // As Stream has .Position property, it makes sence to use this instead of byte[] + own pos variable.
            byte[] buffer;
            int    length;

            using (FileStream fstream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, BufferSize, FileOptions.SequentialScan)) {
                length = (int)fstream.Length;
                buffer = new byte[length];
                if (fstream.Read(buffer, 0, length) != length)
                {
                    throw new IOException("stream.Read length mismatch");
                }
            }
            this.stream = new MemoryStream(buffer, 0, length, false, true);

            this.romType = DetectRomType(stream);
        }
Exemplo n.º 33
0
		public MBC2( byte[] fileData, RomType romType, int romSize, int romBanks ) {
			this.romType = romType;
			int bankSize = romSize / romBanks;
			rom = new byte[ romBanks, bankSize ];
			for( int i = 0, k = 0; i < romBanks; i++ ) {
				for( int j = 0; j < bankSize; j++, k++ ) {
					rom[ i, j ] = fileData[ k ];
				}
			}
		}
Exemplo n.º 34
0
        void Open()
        {
            const int BufferSize = 16 * KiB;

            // Copy whole file into MemoryStream at once for best performance.
            // As Stream has .Position property, it makes sence to use this instead of byte[] + own pos variable.
            byte[] buffer;
            int length;
            using (FileStream fstream = new FileStream (path, FileMode.Open, FileAccess.Read, FileShare.Read, BufferSize, FileOptions.SequentialScan)) {
                length = (int)fstream.Length;
                buffer = new byte[length];
                if (fstream.Read (buffer, 0, length) != length)
                    throw new IOException ("stream.Read length mismatch");
            }
            this.stream = new MemoryStream (buffer, 0, length, false, true);

            this.romType = DetectRomType (stream);
        }
Exemplo n.º 35
0
Arquivo: ROM.cs Projeto: KermEd/Unity
		public MBC2(byte[] fileData, byte[] savedData, RomType romType, int romSize, int romBanks) : this (fileData, romType, romSize, romBanks)
		{
			// Load RAM data
			if (savedData != null)
			{
				for (int i = 0; i < RAM_SIZE; ++i)
				{
					ram [i] = fileData [i];
				}
			}
		}
Exemplo n.º 36
0
Arquivo: ROM.cs Projeto: KermEd/Unity
		public MBC3(byte[] fileData, byte[] savedData, RomType romType, int romSize, int romBanks)
					: this (fileData, romType, romSize, romBanks)
		{
			// Load the RAM
			if (savedData != null)
			{
				for (int i = 0, k = 0; i < RAM_BANK; ++i)
				{
					for (int j = 0; j < RAM_BANK_SIZE; ++j, ++k)
					{
						ram [i, j] = savedData [k];
					}
				}
			}
		}
Exemplo n.º 37
0
 void Open()
 {
     fs = new FileStream (path, FileMode.Open, FileAccess.Read);
     romType = DetectRomType (fs);
 }
Exemplo n.º 38
0
 public ReflashCounter(RomType romType, System.IO.Stream stream)
     : this(GetPos (romType), stream)
 {
 }
Exemplo n.º 39
0
		public Game( byte[] fileData ) {
			title = ExtractGameTitle( fileData );
			gameBoyColorGame = fileData[ 0x0143 ] == 0x80;
			licenseCode = ( ( (int)fileData[ 0x0144 ] ) << 4 ) | fileData[ 0x0145 ];
			gameBoy = fileData[ 0x0146 ] == 0x00;
			romType = (RomType)fileData[ 0x0147 ];

			switch( fileData[ 0x0148 ] ) {
				case 0x00:
					romSize = 32 * 1024;
					romBanks = 2;
					break;
				case 0x01:
					romSize = 64 * 1024;
					romBanks = 4;
					break;
				case 0x02:
					romSize = 128 * 1024;
					romBanks = 8;
					break;
				case 0x03:
					romSize = 256 * 1024;
					romBanks = 16;
					break;
				case 0x04:
					romSize = 512 * 1024;
					romBanks = 32;
					break;
				case 0x05:
					romSize = 1024 * 1024;
					romBanks = 64;
					break;
				case 0x06:
					romSize = 2 * 1024 * 1024;
					romBanks = 128;
					break;
				case 0x52:
					romSize = 1179648;
					romBanks = 72;
					break;
				case 0x53:
					romSize = 1310720;
					romBanks = 80;
					break;
				case 0x54:
					romSize = 1572864;
					romBanks = 96;
					break;
			}

			switch( fileData[ 0x0149 ] ) {
				case 0x00:
					ramSize = 0;
					ramBanks = 0;
					break;
				case 0x01:
					ramSize = 2 * 1024;
					ramBanks = 1;
					break;
				case 0x02:
					ramSize = 8 * 1024;
					ramBanks = 1;
					break;
				case 0x03:
					ramSize = 32 * 1024;
					ramBanks = 4;
					break;
				case 0x04:
					ramSize = 128 * 1024;
					ramBanks = 16;
					break;
			}

			japanese = fileData[ 0x014A ] == 0x00;
			oldLicenseCode = fileData[ 0x014B ];
			maskRomVersion = fileData[ 0x014C ];

			headerChecksum = fileData[ 0x014D ];
			for( int i = 0x0134; i <= 0x014C; i++ ) {
				actualHeaderChecksum = actualHeaderChecksum - fileData[ i ] - 1;
			}
			actualHeaderChecksum &= 0xFF;

			checksum = ( ( (int)fileData[ 0x014E ] ) << 8 ) | fileData[ 0x014F ];
			for( int i = 0; i < fileData.Length; i++ ) {
				if( i != 0x014E && i != 0x014F ) {
					actualChecksum += fileData[ i ];
				}
			}
			actualChecksum &= 0xFFFF;

			noVerticalBlankInterruptHandler = fileData[ 0x0040 ] == 0xD9;
			noLCDCStatusInterruptHandler = fileData[ 0x0048 ] == 0xD9;
			noTimerOverflowInterruptHandler = fileData[ 0x0050 ] == 0xD9;
			noSerialTransferCompletionInterruptHandler = fileData[ 0x0058 ] == 0xD9;
			noHighToLowOfP10ToP13InterruptHandler = fileData[ 0x0060 ] == 0xD9;

			switch( romType ) {
				case RomType.ROM:
					cartridge = new ROM( fileData );
					break;
				case RomType.ROM_MBC1:
				case RomType.ROM_MBC1_RAM:
				case RomType.ROM_MBC1_RAM_BATT:
					cartridge = new MBC1( fileData, romType, romSize, romBanks );
					break;
				case RomType.ROM_MBC2:
				case RomType.ROM_MBC2_BATTERY:
					cartridge = new MBC2( fileData, romType, romSize, romBanks );
					break;
				default:
					throw new Exception( string.Format( "Cannot emulate cartridge type {0}.", romType ) );
			}
		}
Exemplo n.º 40
0
 public RomChecksumming(RomType romType, System.IO.Stream stream)
     : this(GetTablePos (romType), stream)
 {
 }