Exemplo n.º 1
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.º 2
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;
            }
        }