Exemplo n.º 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);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the active palette whenever the value of ULA Next
        /// control register ($43) is written
        /// </summary>
        private void OnUlaNextControlRegisterValueSet(object sender, RegisterSetEventArgs e)
        {
            switch (e.Value >> 4)
            {
            case 1:
                ActivePalette = Layer2FirstPalette;
                break;

            case 2:
                ActivePalette = SpritesFirstPalette;
                break;

            case 4:
                ActivePalette = UlaNextSecondPalette;
                break;

            case 5:
                ActivePalette = Layer2SecondPalette;
                break;

            case 6:
                ActivePalette = SpritesSecondPalette;
                break;

            default:
                ActivePalette = UlaNextFirstPalette;
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets the palette value (8 bit) when Register $41 is set
        /// </summary>
        private void OnPaletteValueRegisterSet(object sender, RegisterSetEventArgs e)
        {
            // --- Set the first 8 bits of palette color: RRRGGGBBX,
            // --- where X is the bitwise or of the two B bits
            var newValue = e.Value << 1
                           | ((e.Value & 0x03) == 0 ? 0x00 : 0x01);

            ActivePalette[PaletteIndexRegister.LastValue] = newValue;

            // --- Palette index is automatically incremented
            PaletteIndexRegister.Set((byte)(PaletteIndexRegister.LastValue + 1));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sets the 8-bit + 1-bit extended palette value
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnUlaNextPaletteExtensionValueSet(object sender, RegisterSetEventArgs e)
        {
            if (UlaNextPaletteExtensionRegister.FirstByteSet)
            {
                // --- We receive the 9th bit of the palette value
                var index = PaletteIndexRegister.LastValue;
                ActivePalette[index] = (ActivePalette[index] & 0x1FE) | (e.Value & 0x01);

                // --- Palette index is automatically incremented
                PaletteIndexRegister.Set((byte)(PaletteIndexRegister.LastValue + 1));
                UlaNextPaletteExtensionRegister.FirstByteSet = false;
            }
            else
            {
                // --- Set the first 8 bits of palette color: RRRGGGBBX,
                // --- where X is the bitwise or of the two B bits
                var newValue = e.Value << 1
                               | ((e.Value & 0x03) == 0 ? 0x00 : 0x01);
                ActivePalette[PaletteIndexRegister.LastValue] = newValue;
                UlaNextPaletteExtensionRegister.FirstByteSet  = true;
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Signs the Register $44 will receive the first byte
 /// </summary>
 private void OnPaletteIndexRegisterSet(object sender, RegisterSetEventArgs e)
 {
     UlaNextPaletteExtensionRegister.FirstByteSet = false;
 }