Ejemplo n.º 1
0
        /// <summary>
        /// Sends a byte to the port with the specified address
        /// </summary>
        /// <param name="addr">Port address</param>
        /// <param name="data">Data to write to the port</param>
        /// <returns>Byte read from the memory</returns>
        public override void WritePort(ushort addr, byte data)
        {
            HandleSpectrum48PortWrites(addr, data);

            // --- Carry out the I/O write operation (bit 15 and bit 1 reset)
            if ((addr & 0x8002) == 0)
            {
                // --- When paging is disabled, it will be enabled next time
                // --- only after reset
                if (PagingEnabled)
                {
                    // --- Choose the RAM bank for Slot 3 (0xc000-0xffff)
                    MemoryDevice.PageIn(3, data & 0x07);

                    // --- Choose screen (Bank 5 or 7)
                    MemoryDevice.UseShadowScreen = ((data >> 3) & 0x01) == 0x01;

                    // --- Choose ROM bank for Slot 0 (0x0000-0x3fff)
                    MemoryDevice.SelectRom((data >> 4) & 0x01);

                    // --- Enable/disable paging
                    PagingEnabled = (data & 0x20) == 0x00;
                }
            }
            else if (addr == 0xFFFD)
            {
                SoundDevice.SetRegisterIndex(data);
            }
            else if (addr == 0xBFFD || addr == 0xBEFD)
            {
                SoundDevice.SetRegisterValue(data);
            }
        }
 /// <summary>
 /// Writes the specified value to the port
 /// </summary>
 /// <param name="addr">Full port address</param>
 /// <param name="writeValue">Value to write to the port</param>
 public override void HandleWrite(ushort addr, byte writeValue)
 {
     _soundDevice.SetRegisterIndex(writeValue);
 }