Example #1
0
 /// <summary>
 /// Responds to the changes of memory slot registers ($50-$57)
 /// </summary>
 private void OnMemSlotRegisterValueSet(object sender, RegisterSetEventArgs registerSetEventArgs)
 {
     if (sender is MemorySlotRegister slotRegister)
     {
         _memoryDevice.PageIn(slotRegister.Id - 0x50, slotRegister.LastValue, false);
     }
 }
Example #2
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 OnWritePort(ushort addr, byte data)
        {
            // --- Handle I/O contention
            base.OnWritePort(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;
                }
            }
        }
Example #3
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)
        {
            // --- When paging is disabled, it will be enabled next time
            // --- only after reset
            if (!PagingEnabled)
            {
                return;
            }

            // --- Choose the RAM bank for Slot 3 (0xc000-0xffff)
            _memoryDevice.PageIn(3, writeValue & 0x07);

            // --- Choose screen (Bank 5 or 7)
            _memoryDevice.UsesShadowScreen = ((writeValue >> 3) & 0x01) == 0x01;

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

            // --- Enable/disable paging
            PagingEnabled = (writeValue & 0x20) == 0x00;
        }