Exemplo n.º 1
0
        public void PowerOn()
        {
            if (_isRunnning)
            {
                return;
            }

            Initialize();

            // Apply ROM patches
            if (Settings.Default.KernalWhiteTextColor)
            {
                PatchKernalRomTextColor(0x01);
            }

            Cpu.Reset();

            _isRunnning = true;
            _tcsStop    = new TaskCompletionSource <bool>();

            var swCpuClock = Stopwatch.StartNew();

            var t = new Thread(() => {
                while (_isRunnning)
                {
                    // CPU clock
                    if (swCpuClock.Elapsed.TotalMilliseconds >= CpuPeriodMilliseconds)
                    {
                        CpuPeriodMillisecondsReal = swCpuClock.Elapsed.TotalMilliseconds;
                        CpuClockSpeedRealHz       = 1 / (CpuPeriodMillisecondsReal / 1000.0f);

                        swCpuClock.Restart();

                        // Clock CIA 1
                        Cia.Clock();

                        // Cycle VIC-II
                        Vic.Cycle();

                        // Cycle the CPU
                        Cpu.Cycle();
                    }
                }

                _tcsStop.SetResult(true);
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
        }
Exemplo n.º 2
0
		public Motherboard(C64 c64, C64.VicType initRegion)
		{
			// note: roms need to be added on their own externally
			_c64 = c64;
			int clockNum, clockDen, mainsFrq;
			switch (initRegion)
			{
				case C64.VicType.PAL:
					clockNum = 17734475;
					clockDen = 18;
					mainsFrq = 50;
					break;
				case C64.VicType.NTSC:
				case C64.VicType.NTSC_OLD:
					clockNum = 11250000;
					clockDen = 11;
					mainsFrq = 60;
					break;
				case C64.VicType.DREAN:
					clockNum = 14328225;
					clockDen = 14;
					mainsFrq = 50;
					break;
				default:
					throw new System.Exception();
			}
			cartPort = new CartridgePort();
			cassPort = new CassettePortDevice();
			cia0 = new MOS6526(clockNum, clockDen*mainsFrq);
			cia1 = new MOS6526(clockNum, clockDen*mainsFrq);
			colorRam = new Chip2114();
			cpu = new MOS6510();
			pla = new MOSPLA();
			ram = new Chip4864();
			serPort = new SerialPort();
			sid = MOS6581.Create(44100, clockNum, clockDen);
			switch (initRegion)
			{
				case C64.VicType.NTSC: vic = MOS6567R8.Create(); break;
				case C64.VicType.PAL: vic = MOS6569.Create(); break;
				case C64.VicType.NTSC_OLD: vic = MOS6567R56A.Create(); break;
				case C64.VicType.DREAN: vic = MOS6572.Create(); break;
			}
			userPort = new UserPortDevice();
		}
Exemplo n.º 3
0
        public Motherboard(C64 c64, Region initRegion)
        {
            // note: roms need to be added on their own externally
            _c64 = c64;

            cartPort = new CartridgePort();
            cassPort = new CassettePortDevice();
            cia0 = new MOS6526(initRegion);
            cia1 = new MOS6526(initRegion);
            colorRam = new Chip2114();
            cpu = new MOS6510();
            pla = new MOSPLA();
            ram = new Chip4864();
            serPort = new SerialPort();
            sid = MOS6581.Create(44100, initRegion);
            switch (initRegion)
            {
                case Region.NTSC: vic = MOS6567.Create(); break;
                case Region.PAL: vic = MOS6569.Create(); break;
            }
            userPort = new UserPortDevice();
        }
Exemplo n.º 4
0
 private bool Glue_ReadIRQ()
 {
     return(Cia0.ReadIrq() && Vic.ReadIrq() && CartPort.ReadIrq());
 }
        public async override void OnStart(Ped player)
        {
            base.OnStart(player);
            driver = await SpawnPed(RandomUtils.GetRandomPed(), Location + 2);

            Vic = await SpawnPed(RandomUtils.GetRandomPed(), Location + 1);

            Random      random  = new Random();
            string      cartype = carList[random.Next(carList.Length)];
            VehicleHash Hash    = (VehicleHash)API.GetHashKey(cartype);

            car = await SpawnVehicle(Hash, Location);

            driver.SetIntoVehicle(car, VehicleSeat.Driver);
            Vic.SetIntoVehicle(car, VehicleSeat.Passenger);
            PlayerData  playerData  = Utilities.GetPlayerData();
            string      displayName = playerData.DisplayName;
            VehicleData datacar     = await Utilities.GetVehicleData(car.NetworkId);

            string vehicleName = datacar.Name;

            Notify("~r~[KidnappingCallouts] ~y~Officer ~b~" + displayName + ",~y~ the suspect is driving a " +
                   vehicleName + "!");

            //Driver Data
            PedData data = new PedData();

            data.BloodAlcoholLevel = 0.01;
            List <Item> items  = new List <Item>();
            Item        Pistol = new Item
            {
                Name      = "Pistol",
                IsIllegal = true
            };

            items.Add(Pistol);
            data.Items = items;
            Utilities.SetPedData(driver.NetworkId, data);

            Utilities.ExcludeVehicleFromTrafficStop(car.NetworkId, true);

            //Tasks
            driver.AlwaysKeepTask       = true;
            driver.BlockPermanentEvents = true;
            Vic.AlwaysKeepTask          = true;
            Vic.BlockPermanentEvents    = true;

            driver.Weapons.Give(WeaponHash.Pistol, 30, true, true);
            API.SetDriveTaskMaxCruiseSpeed(driver.GetHashCode(), 35f);
            API.SetDriveTaskDrivingStyle(driver.GetHashCode(), 524852);
            driver.Task.FleeFrom(player);
            Vic.Task.HandsUp(1000000);
            Notify("~o~Officer ~b~" + displayName + ",~o~ the driver is fleeing with the victim!");
            car.AttachBlip();
            driver.AttachBlip();
            Vic.AttachBlip();
            PedData data2 = await Utilities.GetPedData(Vic.NetworkId);

            PedData data1 = await Utilities.GetPedData(driver.NetworkId);

            string firstname2 = data2.FirstName;
            string firstname  = data1.FirstName;

            API.Wait(6000);
            DrawSubtitle("~r~[" + firstname2 + "] ~s~Help me please!", 5000);
            API.Wait(6000);
            DrawSubtitle("~r~[" + firstname + "] ~s~Do not speak!", 5000);
            API.Wait(6000);
            DrawSubtitle("~r~[" + firstname2 + "] ~s~PLEASE HELP!", 5000);
        }
Exemplo n.º 6
0
        public Motherboard(C64 c64, C64.VicType initRegion, C64.BorderType borderType, C64.SidType sidType, C64.TapeDriveType tapeDriveType, C64.DiskDriveType diskDriveType)
        {
            // note: roms need to be added on their own externally
            _c64 = c64;
            int clockNum, clockDen;
            switch (initRegion)
            {
                case C64.VicType.Pal:
                    clockNum = 17734475;
                    clockDen = 18;
                    break;
                case C64.VicType.Ntsc:
                    clockNum = 14318181;
                    clockDen = 14;
                    break;
                case C64.VicType.NtscOld:
                    clockNum = 11250000;
                    clockDen = 11;
                    break;
                case C64.VicType.Drean:
                    clockNum = 14328225;
                    clockDen = 14;
                    break;
                default:
                    throw new System.Exception();
            }
            CartPort = new CartridgePort();
            Cassette = new CassettePort();
            ColorRam = new Chip2114();
            Cpu = new Chip6510();
            Pla = new Chip90611401();
            Ram = new Chip4864();
            Serial = new SerialPort();

            switch (sidType)
            {
                case C64.SidType.OldR2:
                    Sid = Chip6581R2.Create(44100, clockNum, clockDen);
                    break;
                case C64.SidType.OldR3:
                    Sid = Chip6581R3.Create(44100, clockNum, clockDen);
                    break;
                case C64.SidType.OldR4AR:
                    Sid = Chip6581R4AR.Create(44100, clockNum, clockDen);
                    break;
                case C64.SidType.NewR5:
                    Sid = Chip8580R5.Create(44100, clockNum, clockDen);
                    break;
            }

            switch (initRegion)
            {
                case C64.VicType.Ntsc:
                    Vic = Chip6567R8.Create(borderType);
                    Cia0 = Chip6526.Create(C64.CiaType.Ntsc,  Input_ReadKeyboard, Input_ReadJoysticks);
                    Cia1 = Chip6526.Create(C64.CiaType.Ntsc, Cia1_ReadPortA);
                    break;
                case C64.VicType.Pal:
                    Vic = Chip6569.Create(borderType);
                    Cia0 = Chip6526.Create(C64.CiaType.Pal, Input_ReadKeyboard, Input_ReadJoysticks);
                    Cia1 = Chip6526.Create(C64.CiaType.Pal, Cia1_ReadPortA);
                    break;
                case C64.VicType.NtscOld:
                    Vic = Chip6567R56A.Create(borderType);
                    Cia0 = Chip6526.Create(C64.CiaType.NtscRevA, Input_ReadKeyboard, Input_ReadJoysticks);
                    Cia1 = Chip6526.Create(C64.CiaType.NtscRevA, Cia1_ReadPortA);
                    break;
                case C64.VicType.Drean:
                    Vic = Chip6572.Create(borderType);
                    Cia0 = Chip6526.Create(C64.CiaType.Pal, Input_ReadKeyboard, Input_ReadJoysticks);
                    Cia1 = Chip6526.Create(C64.CiaType.Pal, Cia1_ReadPortA);
                    break;
            }
            User = new UserPort();

            ClockNumerator = clockNum;
            ClockDenominator = clockDen;

            // Initialize disk drive
            switch (diskDriveType)
            {
                case C64.DiskDriveType.Commodore1541:
                case C64.DiskDriveType.Commodore1541II:
                    DiskDrive = new Drive1541(ClockNumerator, ClockDenominator);
                    Serial.Connect(DiskDrive);
                    break;
            }

            // Initialize tape drive
            switch (tapeDriveType)
            {
                case C64.TapeDriveType.Commodore1530:
                    TapeDrive = new TapeDrive();
                    Cassette.Connect(TapeDrive);
                    break;
            }

            BasicRom = new Chip23128();
            CharRom = new Chip23128();
            KernalRom = new Chip23128();
        }
Exemplo n.º 7
0
 public Task Configure()
 {
     return(Vic.Configure());
 }
Exemplo n.º 8
0
        public async Task LyricsAsync()
        {
            if (player.CurrentTrack is null)
            {
                await ReplyAsync("There is no track playing right now.");

                return;
            }

            var lyrics = await Vic.ScrapeGeniusLyricsAsync(player.CurrentTrack.Title);

            if (lyrics == null)
            {
                await ReplyAsync("Could not fetch lyrics.");

                return;
            }

            var thumb = await player.CurrentTrack.FetchThumbnailAsync();

            var pager = new ReactivePager();
            var pages = new List <ReactivePage>();

            string[] paragraphs = Regex.Split(lyrics, "(\n){2,}");
            foreach (var group in paragraphs)
            {
                //Ensure that we are not including un-necessary empty pages
                if (string.IsNullOrWhiteSpace(group))
                {
                    continue;
                }
                //Ensure that the length of the paragraph does not exceed the max embed length
                if (group.Length >= 2048)
                {
                    //Split the paragraph into sub-groups and add individually
                    var words = group.Split(" ");
                    var sb    = new StringBuilder();
                    //Add the words of each group individually to ensure that the response is still coherent
                    foreach (var word in words)
                    {
                        if (sb.Length + word.Length >= 2048)
                        {
                            pages.Add(new ReactivePage()
                            {
                                Description = sb.ToString()
                            });
                            sb.Clear();
                        }
                        sb.Append($"{word} ");
                    }

                    //Ensure that any remaining content is added to the pager.
                    var remaining = sb.ToString();
                    if (!string.IsNullOrWhiteSpace(remaining))
                    {
                        pages.Add(new ReactivePage()
                        {
                            Description = remaining
                        });
                    }
                }
                else
                {
                    pages.Add(new ReactivePage()
                    {
                        Description = group
                    });
                }
            }
            pager.Pages = pages;
            if (pager.Pages.Any())
            {
                pager.Pages.First().ImageUrl = thumb;
                pager.Pages.First().Author   = new EmbedAuthorBuilder()
                {
                    Name    = $"Lyrics For {player.CurrentTrack.Title}",
                    IconUrl = thumb
                };

                await PagedReplyAsync(pager.ToCallBack().WithDefaultPagerCallbacks());
            }
        }