Exemplo n.º 1
0
		public static void Load(Chip90611401 pla, byte[] prgFile)
		{
			var length = prgFile.Length;
		    if (length <= 2)
		    {
		        return;
		    }

		    var addr = prgFile[0] | (prgFile[1] << 8);
		    var offset = 2;
		    unchecked
		    {
		        while (offset < length)
		        {
		            pla.Write(addr, prgFile[offset]);
		            offset++;
		            addr++;
		        }
		    }
		}
Exemplo n.º 2
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();
        }