Ejemplo n.º 1
0
        /// <summary>
        /// Main constructor
        /// </summary>
        public ZX128(ZXSpectrum spectrum, Z80A cpu, ZXSpectrum.BorderType borderType, List <byte[]> files, List <JoystickType> joysticks)
        {
            Spectrum = spectrum;
            CPU      = cpu;

            CPUMon = new CPUMonitor(this)
            {
                machineType = MachineType.ZXSpectrum128
            };

            ROMPaged       = 0;
            SHADOWPaged    = false;
            RAMPaged       = 0;
            PagingDisabled = false;

            ULADevice = new Screen128(this);

            BuzzerDevice = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "SystemBuzzer");

            TapeBuzzer = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "TapeBuzzer");

            AYDevice = new AY38912(this);
            AYDevice.Init(44100, ULADevice.FrameLength);

            KeyboardDevice = new StandardKeyboard(this);

            InitJoysticks(joysticks);

            TapeDevice = new DatacorderDevice(spectrum.SyncSettings.AutoLoadTape);
            TapeDevice.Init(this);

            InitializeMedia(files);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Main constructor
        /// </summary>
        /// <param name="spectrum"></param>
        /// <param name="cpu"></param>
        public ZX48(ZXSpectrum spectrum, Z80A cpu, ZXSpectrum.BorderType borderType, List <byte[]> files, List <JoystickType> joysticks)
        {
            Spectrum = spectrum;
            CPU      = cpu;

            CPUMon = new CPUMonitor(this);

            //ULADevice = new ULA48(this);
            ULADevice = new Screen48(this);

            BuzzerDevice = new Beeper(this);
            BuzzerDevice.Init(44100, ULADevice.FrameLength);

            TapeBuzzer = new Beeper(this);
            TapeBuzzer.Init(44100, ULADevice.FrameLength);

            KeyboardDevice = new StandardKeyboard(this);

            InitJoysticks(joysticks);

            TapeDevice = new DatacorderDevice(spectrum.SyncSettings.AutoLoadTape);
            TapeDevice.Init(this);

            InitializeMedia(files);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Main constructor
        /// </summary>
        /// <param name="spectrum"></param>
        /// <param name="cpu"></param>
        public ZX128(ZXSpectrum spectrum, Z80A cpu, ZXSpectrum.BorderType borderType, List <byte[]> files, List <JoystickType> joysticks)
        {
            Spectrum = spectrum;
            CPU      = cpu;

            ROMPaged       = 0;
            SHADOWPaged    = false;
            RAMPaged       = 0;
            PagingDisabled = false;

            ULADevice = new ULA128(this);

            BuzzerDevice = new Buzzer(this);
            BuzzerDevice.Init(44100, ULADevice.FrameLength);

            TapeBuzzer = new Buzzer(this);
            TapeBuzzer.Init(44100, ULADevice.FrameLength);

            AYDevice = new AYChip(this);
            AYDevice.Init(44100, ULADevice.FrameLength);

            KeyboardDevice = new StandardKeyboard(this);

            InitJoysticks(joysticks);

            TapeDevice = new DatacorderDevice(spectrum.SyncSettings.AutoLoadTape);
            TapeDevice.Init(this);

            InitializeMedia(files);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Writes a byte of data to a specified port address
        /// </summary>
        /// <param name="port"></param>
        /// <param name="value"></param>
        public override void WritePort(ushort port, byte value)
        {
            // process IO contention
            ContendPortAddress(port);

            // get a BitArray of the port
            BitArray portBits = new BitArray(BitConverter.GetBytes(port));
            // get a BitArray of the value byte
            BitArray bits = new BitArray(new byte[] { value });

            // Check whether the low bit is reset
            bool lowBitReset = !portBits[0]; // (port & 0x01) == 0;

            AYDevice.WritePort(port, value);

            UPDDiskDevice.WritePort(port, value);

            // port 0x7ffd - hardware should only respond when bits 1 & 15 are reset and bit 14 is set
            if (port == 0x7ffd)
            {
                if (!PagingDisabled)
                {
                    // bits 0, 1, 2 select the RAM page
                    var rp = value & 0x07;
                    if (rp < 8)
                    {
                        RAMPaged = rp;
                    }

                    // bit 3 controls shadow screen
                    SHADOWPaged = bits[3];

                    // Bit 5 set signifies that paging is disabled until next reboot
                    PagingDisabled = bits[5];

                    // portbit 4 is the LOW BIT of the ROM selection
                    ROMlow = bits[4];
                }
            }
            // port 0x1ffd - hardware should only respond when bits 1, 13, 14 & 15 are reset and bit 12 is set
            if (port == 0x1ffd)
            {
                if (!PagingDisabled)
                {
                    if (!bits[0])
                    {
                        // special paging is not enabled - get the ROMpage high byte
                        ROMhigh = bits[2];

                        // set the special paging mode flag
                        SpecialPagingMode = false;
                    }
                    else
                    {
                        // special paging is enabled
                        // this is decided based on combinations of bits 1 & 2
                        // Config 0 = Bit1-0 Bit2-0
                        // Config 1 = Bit1-1 Bit2-0
                        // Config 2 = Bit1-0 Bit2-1
                        // Config 3 = Bit1-1 Bit2-1
                        BitArray confHalfNibble = new BitArray(2);
                        confHalfNibble[0] = bits[1];
                        confHalfNibble[1] = bits[2];

                        // set special paging configuration
                        PagingConfiguration = ZXSpectrum.GetIntFromBitArray(confHalfNibble);

                        // set the special paging mode flag
                        SpecialPagingMode = true;
                    }
                }

                // bit 4 is the printer port strobe
                PrinterPortStrobe = bits[4];
            }

            // Only even addresses address the ULA
            if (lowBitReset)
            {
                // store the last OUT byte
                LastULAOutByte = value;

                /*
                 *  Bit   7   6   5   4   3   2   1   0
                 +-------------------------------+
                 |   |   |   | E | M |   Border  |
                 +-------------------------------+
                 */

                // Border - LSB 3 bits hold the border colour
                if (ULADevice.borderColour != (value & BORDER_BIT))
                {
                    ULADevice.UpdateScreenBuffer(CurrentFrameCycle);
                }

                ULADevice.borderColour = value & BORDER_BIT;

                // Buzzer
                BuzzerDevice.ProcessPulseValue((value & EAR_BIT) != 0);

                // Tape
                TapeDevice.WritePort(port, value);

                // Tape
                //TapeDevice.ProcessMicBit((value & MIC_BIT) != 0);
            }


            LastULAOutByte = value;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Main constructor
 /// </summary>
 /// <param name="spectrum"></param>
 /// <param name="cpu"></param>
 public ZX128Plus2(ZXSpectrum spectrum, Z80A cpu, ZXSpectrum.BorderType borderType, List <byte[]> files, List <JoystickType> joysticks)
     : base(spectrum, cpu, borderType, files, joysticks)
 {
 }
        /// <summary>
        /// Detailed info to be displayed within the settings UIs
        /// </summary>
        public static ZXMachineMetaData GetMetaObject(MachineType type)
        {
            ZXMachineMetaData m = new ZXMachineMetaData {
                MachineType = type
            };

            switch (type)
            {
            case MachineType.ZXSpectrum16:
                m.Name         = "Sinclair ZX Spectrum 16K";
                m.Description  = "The original ZX Spectrum 16K RAM version. Aside from available RAM this machine is technically identical to the 48K machine that was released at the same time. ";
                m.Description += "Due to the small amount of RAM, very few games were actually made to run on this model.";
                m.Released     = "1982";
                m.CPU          = "Zilog Z80A @ 3.5MHz";
                m.Memory       = "16KB ROM / 16KB RAM";
                m.Video        = "ULA @ 7MHz - PAL (50.08Hz Interrupt)";
                m.Audio        = "Beeper (HW 1ch. / 10oct.) - Internal Speaker";
                m.Media        = "Cassette Tape (via 3rd party external tape player)";
                break;

            case MachineType.ZXSpectrum48:
                m.Name         = "Sinclair ZX Spectrum 48K / 48K+";
                m.Description  = "The original ZX Spectrum 48K RAM version. 2 years later a 'plus' version was released that had a better keyboard. ";
                m.Description += "Electronically both the 48K and + are identical, so ZXHawk treats them as the same emulated machine. ";
                m.Description += "These machines dominated the UK 8-bit home computer market throughout the 1980's so most non-128k only games are compatible.";
                m.Released     = "1982 (48K) / 1984 (48K+)";
                m.CPU          = "Zilog Z80A @ 3.5MHz";
                m.Memory       = "16KB ROM / 48KB RAM";
                m.Video        = "ULA @ 7MHz - PAL (50.08Hz Interrupt)";
                m.Audio        = "Beeper (HW 1ch. / 10oct.) - Internal Speaker";
                m.Media        = "Cassette Tape (via 3rd party external tape player)";
                break;

            case MachineType.ZXSpectrum128:
                m.Name         = "Sinclair ZX Spectrum 128";
                m.Description  = "The first Spectrum 128K machine released in Spain in 1985 and later UK in 1986. ";
                m.Description += "With an updated ROM and new memory paging system to work around the Z80's 16-bit address bus. ";
                m.Description += "The 128 shipped with a copy of the 48k ROM (that is paged in when required) and a new startup menu with the option of dropping into a '48k mode'. ";
                m.Description += "Even so, there were some compatibility issues with older Spectrum games that were written to utilise some of the previous model's intricacies. ";
                m.Description += "Many games released after 1985 supported the new AY-3-8912 PSG chip making for far superior audio. The extra memory also enabled many games to be loaded in all at once (rather than loading each level from tape when needed).";
                m.Released     = "1985 / 1986";
                m.CPU          = "Zilog Z80A @ 3.5469 MHz";
                m.Memory       = "32KB ROM / 128KB RAM";
                m.Video        = "ULA @ 7.0938MHz - PAL (50.01Hz Interrupt)";
                m.Audio        = "Beeper (HW 1ch. / 10oct.) & General Instruments AY-3-8912 PSG (3ch) - RF Output";
                m.Media        = "Cassette Tape (via 3rd party external tape player)";
                break;

            case MachineType.ZXSpectrum128Plus2:
                m.Name         = "Sinclair ZX Spectrum +2";
                m.Description  = "The first Sinclair Spectrum 128K machine that was released after Amstrad purchased Sinclair in 1986. ";
                m.Description += "Electronically it was almost identical to the 128, but with the addition of a built-in tape deck and 2 Sinclair Joystick ports.";
                m.Released     = "1986";
                m.CPU          = "Zilog Z80A @ 3.5469 MHz";
                m.Memory       = "32KB ROM / 128KB RAM";
                m.Video        = "ULA @ 7.0938MHz - PAL (50.01Hz Interrupt)";
                m.Audio        = "Beeper (HW 1ch. / 10oct.) & General Instruments AY-3-8912 PSG (3ch) - RF Output";
                m.Media        = "Cassette Tape (via built-in Datacorder)";
                break;

            case MachineType.ZXSpectrum128Plus2a:
                m.Name         = "Sinclair ZX Spectrum +2a";
                m.Description  = "The +2a looks almost identical to the +2 but is a variant of the +3 machine that was released the same year (except with the same built-in datacorder that the +2 had rather than a floppy drive). ";
                m.Description += "Memory paging again changed significantly and this (along with memory contention timing changes) caused more compatibility issues with some older games. ";
                m.Description += "Although functionally identical to the +3, it does not contain floppy disk controller.";
                m.Released     = "1987";
                m.CPU          = "Zilog Z80A @ 3.5469 MHz";
                m.Memory       = "64KB ROM / 128KB RAM";
                m.Video        = "ULA @ 7.0938MHz - PAL (50.01Hz Interrupt)";
                m.Audio        = "Beeper (HW 1ch. / 10oct.) & General Instruments AY-3-8912 PSG (3ch) - RF Output";
                m.Media        = "Cassette Tape (via built-in Datacorder)";
                break;

            case MachineType.ZXSpectrum128Plus3:
                m.Name         = "Sinclair ZX Spectrum +3";
                m.Description  = "Amstrad released the +3 the same year as the +2a, but it featured a built-in floppy drive rather than a datacorder. An external cassette player could still be connected though as in the older 48k models. ";
                m.Description += "Memory paging again changed significantly and this (along with memory contention timing changes) caused more compatibility issues with some older games. ";
                m.Released     = "1987";
                m.CPU          = "Zilog Z80A @ 3.5469 MHz";
                m.Memory       = "64KB ROM / 128KB RAM";
                m.Video        = "ULA @ 7.0938MHz - PAL (50.01Hz Interrupt)";
                m.Audio        = "Beeper (HW 1ch. / 10oct.) & General Instruments AY-3-8912 PSG (3ch) - RF Output";
                m.Media        = "3\" Floppy Disk (via built-in Floppy Drive)";
                break;

            case MachineType.Pentagon128:
                m.Name         = "(NOT WORKING YET) Pentagon 128 Clone";
                m.Description  = " ";
                m.Description += " ";
                m.Released     = " ";
                m.CPU          = " ";
                m.Memory       = " ";
                m.Video        = " ";
                m.Audio        = " ";
                m.Media        = " ";
                break;
            }

            m.Data.Add(ZXSpectrum.GetMemberName((ZXMachineMetaData c) => c.Name), m.Name.Trim());
            m.Data.Add(ZXSpectrum.GetMemberName((ZXMachineMetaData c) => c.Description), m.Description.Trim());
            m.Data.Add(ZXSpectrum.GetMemberName((ZXMachineMetaData c) => c.Released), m.Released.Trim());
            m.Data.Add(ZXSpectrum.GetMemberName((ZXMachineMetaData c) => c.CPU), m.CPU.Trim());
            m.Data.Add(ZXSpectrum.GetMemberName((ZXMachineMetaData c) => c.Memory), m.Memory.Trim());
            m.Data.Add(ZXSpectrum.GetMemberName((ZXMachineMetaData c) => c.Video), m.Video.Trim());
            m.Data.Add(ZXSpectrum.GetMemberName((ZXMachineMetaData c) => c.Audio), m.Audio.Trim());
            m.Data.Add(ZXSpectrum.GetMemberName((ZXMachineMetaData c) => c.Media), m.Media.Trim());

            return(m);
        }