Example #1
0
File: SMS.cs Project: m35/BizHawk
        private byte ReadPort(ushort port)
        {
            port &= 0xFF;
            if (port < 0x40)             // General IO ports
            {
                switch (port)
                {
                case 0x00: if (stand_alone)
                    {
                        return(ReadPort0());
                    }
                    else
                    {
                        _lagged = false; return(cntr_rd_0);
                    }

                case 0x01: return(Port01);

                case 0x02: return(Port02);

                case 0x03: return(Port03);

                case 0x04: p4_read = true; return(Port04);

                case 0x05: return(Port05);

                case 0x06: return(0xFF);

                case 0x3E: return(Port3E);

                default: return(0xFF);
                }
            }
            if (port < 0x80)              // VDP Vcounter/HCounter
            {
                if ((port & 1) == 0)
                {
                    return(Vdp.ReadVLineCounter());
                }
                else
                {
                    return(Vdp.ReadHLineCounter());
                }
            }
            if (port < 0xC0)             // VDP data/control ports
            {
                if ((port & 1) == 0)
                {
                    return(Vdp.ReadData());
                }
                else
                {
                    return(Vdp.ReadVdpStatus());
                }
            }
            switch (port)
            {
            case 0xC0:
            case 0xDC: if (stand_alone)
                {
                    return(ReadControls1());
                }
                else
                {
                    _lagged = false; return(cntr_rd_1);
                }

            case 0xC1:
            case 0xDD: if (stand_alone)
                {
                    return(ReadControls2());
                }
                else
                {
                    _lagged = false; return(cntr_rd_2);
                }

            case 0xDE: return(PortDEEnabled ? PortDE : (byte)0xFF);

            case 0xF2: return(HasYM2413 ? YM2413.DetectionValue : (byte)0xFF);

            default: return(0xFF);
            }
        }
Example #2
0
        private byte ReadPort(ushort port)
        {
            port &= 0xFF;
            if (port < 0x40)             // General IO ports
            {
                switch (port)
                {
                case 0x00: return(ReadPort0());

                case 0x01: return(Port01);

                case 0x02: return(Port02);

                case 0x03: return(0x00);

                case 0x04: return(0xFF);

                case 0x05: return(0x00);

                case 0x06: return(0xFF);

                case 0x3E: return(Port3E);

                default: return(0xFF);
                }
            }
            if (port < 0x80)              // VDP Vcounter/HCounter
            {
                if ((port & 1) == 0)
                {
                    return(Vdp.ReadVLineCounter());
                }
                else
                {
                    return(0x50);                    // TODO Vdp.ReadHLineCounter();
                }
            }
            if (port < 0xC0)             // VDP data/control ports
            {
                if ((port & 1) == 0)
                {
                    return(Vdp.ReadData());
                }
                else
                {
                    return(Vdp.ReadVdpStatus());
                }
            }
            switch (port)
            {
            case 0xC0:
            case 0xDC: return(ReadControls1());

            case 0xC1:
            case 0xDD: return(ReadControls2());

            case 0xF2: return(HasYM2413 ? YM2413.DetectionValue : (byte)0xFF);

            default: return(0xFF);
            }
        }