Example #1
0
        private void WritePort(ushort port, byte value)
        {
            port &= 0xFF;

            if (port >= 0xA0 && port <= 0xBF)
            {
                if ((port & 1) == 0)
                {
                    _vdp.WriteVdpData(value);
                }
                else
                {
                    _vdp.WriteVdpControl(value);
                }

                return;
            }

            if (port >= 0x80 && port <= 0x9F)
            {
                _inputPortSelection = InputPortMode.Right;
                return;
            }

            if (port >= 0xC0 && port <= 0xDF)
            {
                _inputPortSelection = InputPortMode.Left;
                return;
            }

            if (port >= 0xE0)
            {
                PSG.WritePsgData(value, _cpu.TotalExecutedCycles);
            }
        }
Example #2
0
        private void WritePort(ushort port, byte value)
        {
            port &= 0xFF;

            if (port >= 0xA0 && port <= 0xBF)
            {
                if ((port & 1) == 0)
                {
                    _vdp.WriteVdpData(value);
                }
                else
                {
                    _vdp.WriteVdpControl(value);
                }

                return;
            }

            if (port >= 0x80 && port <= 0x9F)
            {
                _inputPortSelection = InputPortMode.Right;
                return;
            }

            if (port >= 0xC0 && port <= 0xDF)
            {
                _inputPortSelection = InputPortMode.Left;
                return;
            }

            if (port >= 0xE0)
            {
                PSG.WriteReg(value);
            }

            if (use_SGM)
            {
                if (port == 0x50)
                {
                    SGM_sound.port_sel = (byte)(value & 0xF);
                }

                if (port == 0x51)
                {
                    SGM_sound.WriteReg(value);
                }

                if (port == 0x53)
                {
                    if ((value & 1) > 0)
                    {
                        enable_SGM_high = true;
                    }
                    else
                    {
                        // NOTE: the documentation states that you shouldn't turn RAM back off once enabling it
                        // so we won't do anything here
                    }

                    port_0x53 = value;
                }

                if (port == 0x7F)
                {
                    if (value == 0xF)
                    {
                        enable_SGM_low = false;
                    }
                    else if (value == 0xD)
                    {
                        enable_SGM_low = true;
                    }

                    port_0x7F = value;
                }
            }
        }