コード例 #1
0
ファイル: NECUPD765.cs プロジェクト: xy2iii/BizHawk
 /// <summary>
 /// Initialization routine
 /// </summary>
 public void Init(SpectrumBase machine)
 {
     _machine = machine;
     FDD_Init();
     TimingInit();
     Reset();
 }
コード例 #2
0
ファイル: ZXSpectrum.cs プロジェクト: Asnivor/BizHawk
        private void Init(MachineType machineType, BorderType borderType, TapeLoadSpeed tapeLoadSpeed, List <byte[]> files, List <JoystickType> joys)
        {
            _machineType = machineType;

            // setup the emulated model based on the MachineType
            switch (machineType)
            {
            case MachineType.ZXSpectrum16:
                _machine = new ZX16(this, _cpu, borderType, files, joys);
                var _systemRom16 = GetFirmware(0x4000, "48ROM");
                var romData16    = RomData.InitROM(machineType, _systemRom16);
                _machine.InitROM(romData16);
                break;

            case MachineType.ZXSpectrum48:
                _machine = new ZX48(this, _cpu, borderType, files, joys);
                var _systemRom = GetFirmware(0x4000, "48ROM");
                var romData    = RomData.InitROM(machineType, _systemRom);
                _machine.InitROM(romData);
                break;

            case MachineType.ZXSpectrum128:
                _machine = new ZX128(this, _cpu, borderType, files, joys);
                var _systemRom128 = GetFirmware(0x8000, "128ROM");
                var romData128    = RomData.InitROM(machineType, _systemRom128);
                _machine.InitROM(romData128);
                break;

            case MachineType.ZXSpectrum128Plus2:
                _machine = new ZX128Plus2(this, _cpu, borderType, files, joys);
                var _systemRomP2 = GetFirmware(0x8000, "PLUS2ROM");
                var romDataP2    = RomData.InitROM(machineType, _systemRomP2);
                _machine.InitROM(romDataP2);
                break;

            case MachineType.ZXSpectrum128Plus2a:
                _machine = new ZX128Plus2a(this, _cpu, borderType, files, joys);
                var _systemRomP4 = GetFirmware(0x10000, "PLUS2AROM");
                var romDataP4    = RomData.InitROM(machineType, _systemRomP4);
                _machine.InitROM(romDataP4);
                break;

            case MachineType.ZXSpectrum128Plus3:
                _machine = new ZX128Plus3(this, _cpu, borderType, files, joys);
                var _systemRomP3 = GetFirmware(0x10000, "PLUS3ROM");
                var romDataP3    = RomData.InitROM(machineType, _systemRomP3);
                _machine.InitROM(romDataP3);
                //System.Windows.Forms.MessageBox.Show("+3 is not working at all yet :/");
                break;

            case MachineType.Pentagon128:
                _machine = new Pentagon128(this, _cpu, borderType, files, joys);
                var _systemRomPen128 = GetFirmware(0x8000, "PentagonROM");
                var _systemRomTrdos  = GetFirmware(0x4000, "TRDOSROM");
                var conc             = _systemRomPen128.Concat(_systemRomTrdos).ToArray();
                var romDataPen128    = RomData.InitROM(machineType, conc);
                _machine.InitROM(romDataPen128);
                break;
            }
        }
コード例 #3
0
ファイル: NullJoystick.cs プロジェクト: mfloresn90/BizHawk
        public NullJoystick(SpectrumBase machine, int playerNumber)
        {
            _machine      = machine;
            _joyLine      = 0;
            _playerNumber = playerNumber;

            ButtonCollection = new List <string>
            {
            }.ToArray();
        }
コード例 #4
0
        public SinclairJoystick1(SpectrumBase machine, int playerNumber)
        {
            _machine = machine;
            //_joyLine = 0;
            _playerNumber = playerNumber;

            ButtonCollection = new List <string>
            {
                "P" + _playerNumber + " Left",
                "P" + _playerNumber + " Right",
                "P" + _playerNumber + " Down",
                "P" + _playerNumber + " Up",
                "P" + _playerNumber + " Button",
            }.ToArray();
        }
コード例 #5
0
        public StandardKeyboard(SpectrumBase machine)
        {
            _machine = machine;

            KeyboardMatrix = new string[]
            {
                // 0xfefe	-	0 - 4
                "Key Caps Shift", "Key Z", "Key X", "Key C", "Key V",
                // 0xfdfe	-	5 - 9
                "Key A", "Key S", "Key D", "Key F", "Key G",
                // 0xfbfe	-	10 - 14
                "Key Q", "Key W", "Key E", "Key R", "Key T",
                // 0xf7fe	-	15 - 19
                "Key 1", "Key 2", "Key 3", "Key 4", "Key 5",
                // 0xeffe	-	20 - 24
                "Key 0", "Key 9", "Key 8", "Key 7", "Key 6",
                // 0xdffe	-	25 - 29
                "Key P", "Key O", "Key I", "Key U", "Key Y",
                // 0xbffe	-	30 - 34
                "Key Return", "Key L", "Key K", "Key J", "Key H",
                // 0x7ffe	-	35 - 39
                "Key Space", "Key Symbol Shift", "Key M", "Key N", "Key B"
            };

            var nonMatrix = new List <string>();

            foreach (var key in _machine.Spectrum.ZXSpectrumControllerDefinition.BoolButtons)
            {
                if (!KeyboardMatrix.Any(s => s == key))
                {
                    nonMatrix.Add(key);
                }
            }

            NonMatrixKeys = nonMatrix.ToArray();

            LineStatus       = new byte[8];
            _keyLine         = new int[] { 255, 255, 255, 255, 255, 255, 255, 255 };
            IsIssue2Keyboard = true;
        }
コード例 #6
0
 public ULA(SpectrumBase machine)
 {
     _machine   = machine;
     CPUMon     = _machine.CPUMon;
     borderType = _machine.Spectrum.SyncSettings.BorderType;
 }
コード例 #7
0
ファイル: SZX.Methods.cs プロジェクト: Asnivor/BizHawk
        /// <summary>
        /// Exports state information to a byte array in ZX-State format
        /// </summary>
        /// <param name="machine"></param>
        /// <returns></returns>
        public static byte[] ExportSZX(SpectrumBase machine)
        {
            var s = new SZX(machine);

            byte[] result = null;

            using (MemoryStream ms = new MemoryStream())
            {
                using (BinaryWriter r = new BinaryWriter(ms))
                {
                    // temp buffer
                    byte[] buff;
                    // working block
                    ZXSTBLOCK block = new ZXSTBLOCK();

                    // header
                    ZXSTHEADER header = new ZXSTHEADER();
                    header.dwMagic        = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("ZXST"), 0);
                    header.chMajorVersion = 1;
                    header.chMinorVersion = 4;
                    header.chFlags        = 0;
                    switch (s._machine.Spectrum.MachineType)
                    {
                    case MachineType.ZXSpectrum16: header.chMachineId = (int)MachineIdentifier.ZXSTMID_16K; break;

                    case MachineType.ZXSpectrum48: header.chMachineId = (int)MachineIdentifier.ZXSTMID_48K; break;

                    case MachineType.ZXSpectrum128: header.chMachineId = (int)MachineIdentifier.ZXSTMID_128K; break;

                    case MachineType.ZXSpectrum128Plus2: header.chMachineId = (int)MachineIdentifier.ZXSTMID_PLUS2; break;

                    case MachineType.ZXSpectrum128Plus2a: header.chMachineId = (int)MachineIdentifier.ZXSTMID_PLUS2A; break;

                    case MachineType.ZXSpectrum128Plus3: header.chMachineId = (int)MachineIdentifier.ZXSTMID_PLUS3; break;
                    }
                    buff = MediaConverter.SerializeRaw(header);
                    r.Write(buff);

                    // ZXSTCREATOR
                    var bStruct = s.GetZXSTCREATOR();
                    block.dwId   = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("CRTR"), 0);
                    block.dwSize = (uint)Marshal.SizeOf(bStruct);
                    buff         = MediaConverter.SerializeRaw(block);
                    r.Write(buff);
                    buff = MediaConverter.SerializeRaw(bStruct);
                    r.Write(buff);

                    // ZXSTZ80REGS
                    var cStruct = s.GetZXSTZ80REGS();
                    block.dwId   = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("Z80R"), 0);
                    block.dwSize = (uint)Marshal.SizeOf(cStruct);
                    buff         = MediaConverter.SerializeRaw(block);
                    r.Write(buff);
                    buff = MediaConverter.SerializeRaw(cStruct);
                    r.Write(buff);

                    // ZXSTSPECREGS
                    var dStruct = s.GetZXSTSPECREGS();
                    block.dwId   = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("SPCR"), 0);
                    block.dwSize = (uint)Marshal.SizeOf(dStruct);
                    buff         = MediaConverter.SerializeRaw(block);
                    r.Write(buff);
                    buff = MediaConverter.SerializeRaw(dStruct);
                    r.Write(buff);

                    // ZXSTKEYBOARD
                    var eStruct = s.GetZXSTKEYBOARD();
                    block.dwId   = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("KEYB"), 0);
                    block.dwSize = (uint)Marshal.SizeOf(eStruct);
                    buff         = MediaConverter.SerializeRaw(block);
                    r.Write(buff);
                    buff = MediaConverter.SerializeRaw(eStruct);
                    r.Write(buff);

                    // ZXSTJOYSTICK
                    var fStruct = s.GetZXSTJOYSTICK();
                    block.dwId   = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("JOY\0"), 0);
                    block.dwSize = (uint)Marshal.SizeOf(fStruct);
                    buff         = MediaConverter.SerializeRaw(block);
                    r.Write(buff);
                    buff = MediaConverter.SerializeRaw(fStruct);
                    r.Write(buff);


                    // ZXSTAYBLOCK
                    if (s._machine.Spectrum.MachineType != MachineType.ZXSpectrum16 && s._machine.Spectrum.MachineType != MachineType.ZXSpectrum48)
                    {
                        var gStruct = s.GetZXSTAYBLOCK();
                        block.dwId   = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("AY\0\0"), 0);
                        block.dwSize = (uint)Marshal.SizeOf(gStruct);
                        buff         = MediaConverter.SerializeRaw(block);
                        r.Write(buff);
                        buff = MediaConverter.SerializeRaw(gStruct);
                        r.Write(buff);
                    }

                    // ZXSTRAMPAGE
                    switch (s._machine.Spectrum.MachineType)
                    {
                    // For 16k Spectrums, only page 5 (0x4000 - 0x7fff) is saved.
                    case MachineType.ZXSpectrum16:
                        block.dwId = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("RAMP"), 0);
                        var rp16 = s.GetZXSTRAMPAGE(5, s._machine.RAM0);
                        block.dwSize = (uint)Marshal.SizeOf(rp16);
                        buff         = MediaConverter.SerializeRaw(block);
                        r.Write(buff);
                        buff = MediaConverter.SerializeRaw(rp16);
                        r.Write(buff);
                        break;

                    // For 48k Spectrums and Timex TS/TC models, pages 5, 2 (0x8000 - 0xbfff) and 0 (0xc000 - 0xffff) are saved.
                    case MachineType.ZXSpectrum48:
                        block.dwId = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("RAMP"), 0);
                        var rp48_0 = s.GetZXSTRAMPAGE(5, s._machine.RAM0);
                        block.dwSize = (uint)Marshal.SizeOf(rp48_0);
                        buff         = MediaConverter.SerializeRaw(block);
                        r.Write(buff);
                        buff = MediaConverter.SerializeRaw(rp48_0);
                        r.Write(buff);

                        block.dwId = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("RAMP"), 0);
                        var rp48_1 = s.GetZXSTRAMPAGE(5, s._machine.RAM1);
                        block.dwSize = (uint)Marshal.SizeOf(rp48_1);
                        buff         = MediaConverter.SerializeRaw(block);
                        r.Write(buff);
                        buff = MediaConverter.SerializeRaw(rp48_1);
                        r.Write(buff);

                        block.dwId = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("RAMP"), 0);
                        var rp48_2 = s.GetZXSTRAMPAGE(5, s._machine.RAM2);
                        block.dwSize = (uint)Marshal.SizeOf(rp48_2);
                        buff         = MediaConverter.SerializeRaw(block);
                        r.Write(buff);
                        buff = MediaConverter.SerializeRaw(rp48_2);
                        r.Write(buff);
                        break;

                    // For 128k Spectrums and the Pentagon 128, all pages (0-7) are saved.
                    case MachineType.ZXSpectrum128:
                    case MachineType.ZXSpectrum128Plus2:
                    case MachineType.ZXSpectrum128Plus2a:
                    case MachineType.ZXSpectrum128Plus3:
                        List <byte[]> rams = new List <byte[]>
                        {
                            s._machine.RAM0, s._machine.RAM1, s._machine.RAM2, s._machine.RAM3,
                            s._machine.RAM4, s._machine.RAM5, s._machine.RAM6, s._machine.RAM7
                        };
                        for (byte i = 0; i < 8; i++)
                        {
                            block.dwId = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("RAMP"), 0);
                            var rp = s.GetZXSTRAMPAGE(i, rams[i]);
                            block.dwSize = (uint)Marshal.SizeOf(rp);
                            buff         = MediaConverter.SerializeRaw(block);
                            r.Write(buff);
                            buff = MediaConverter.SerializeRaw(rp);
                            r.Write(buff);
                        }
                        break;
                    }

                    /*
                     * // ZXSTPLUS3
                     * if (s._machine.Spectrum.MachineType == MachineType.ZXSpectrum128Plus3)
                     * {
                     *  var iStruct = s.GetZXSTPLUS3();
                     *  block.dwId = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("+3\0\0"), 0);
                     *  block.dwSize = (uint)Marshal.SizeOf(iStruct);
                     *  buff = MediaConverter.SerializeRaw(block);
                     *  r.Write(buff);
                     *  buff = MediaConverter.SerializeRaw(iStruct);
                     *  r.Write(buff);
                     *
                     *  // ZXSTDSKFILE
                     *  if (s._machine.diskImages.Count() > 0)
                     *  {
                     *      var jStruct = s.GetZXSTDSKFILE();
                     *      block.dwId = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("DSK\0"), 0);
                     *      block.dwSize = (uint)Marshal.SizeOf(jStruct);
                     *      buff = MediaConverter.SerializeRaw(block);
                     *      r.Write(buff);
                     *      buff = MediaConverter.SerializeRaw(jStruct);
                     *      r.Write(buff);
                     *  }
                     * }
                     *
                     * // ZXSTTAPE
                     * if (s._machine.tapeImages.Count() > 0)
                     * {
                     *  var hStruct = s.GetZXSTTAPE();
                     *  var tapeData = s._machine.tapeImages[s._machine.TapeMediaIndex];
                     *  block.dwId = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("TAPE"), 0);
                     *  block.dwSize = (uint)Marshal.SizeOf(hStruct) + (uint)tapeData.Length;
                     *  buff = MediaConverter.SerializeRaw(block);
                     *  r.Write(buff);
                     *  buff = MediaConverter.SerializeRaw(hStruct);
                     *  r.Write(buff);
                     *  buff = MediaConverter.SerializeRaw(tapeData);
                     *  r.Write(buff);
                     *  char[] terminator = "\0".ToCharArray();
                     *  r.Write(terminator);
                     * }
                     */
                }

                result = ms.ToArray();
            }

            return(result);
        }
コード例 #8
0
ファイル: SZX.Methods.cs プロジェクト: Asnivor/BizHawk
 private SZX(SpectrumBase machine)
 {
     _machine = machine;
 }
コード例 #9
0
 public Beeper(SpectrumBase machine)
 {
     _machine = machine;
 }
コード例 #10
0
ファイル: DatacorderDevice.cs プロジェクト: sornerol/BizHawk
 /// <summary>
 /// Initializes the datacorder device
 /// </summary>
 public void Init(SpectrumBase machine)
 {
     _machine = machine;
     _cpu     = _machine.CPU;
     _buzzer  = machine.TapeBuzzer;
 }
コード例 #11
0
 public ULABase(SpectrumBase machine)
 {
     _machine   = machine;
     borderType = _machine.Spectrum.SyncSettings.BorderType;
 }
コード例 #12
0
 public CPUMonitor(SpectrumBase machine)
 {
     _machine = machine;
     _cpu     = _machine.CPU;
 }
コード例 #13
0
ファイル: AY38912.cs プロジェクト: radtek/BizHawk
 /// <summary>
 /// Main constructor
 /// </summary>
 public AY38912(SpectrumBase machine)
 {
     _machine = machine;
 }
コード例 #14
0
ファイル: AYChip.cs プロジェクト: Prillan/BizHawk
 /// <summary>
 /// Main constructor
 /// </summary>
 public AYChip(SpectrumBase machine)
 {
     _machine = machine;
 }
コード例 #15
0
ファイル: Buzzer.cs プロジェクト: Prillan/BizHawk
 public Buzzer(SpectrumBase machine)
 {
     _machine = machine;
 }