Exemple #1
0
        private unsafe void DrawBitmap(int *p, bool gammaCorrection, int layer, bool bkgrnd, int bgndColor, int borderXSize, int borderYSize, int line, int width, int height)
        {
            // Bitmap Controller is located at $AF:0100 and $AF:0108
            int  regAddr = MemoryMap.BITMAP_CONTROL_REGISTER_ADDR - MemoryMap.VICKY_BASE_ADDR + layer * 8;
            byte reg     = VICKY.ReadByte(regAddr);

            if ((reg & 0x01) == 00)
            {
                return;
            }
            byte lutIndex = (byte)((reg >> 1) & 7);  // 8 possible LUTs

            int bitmapAddress = VICKY.ReadLong(regAddr + 1);
            int xOffset       = VICKY.ReadWord(regAddr + 4);
            int yOffset       = VICKY.ReadWord(regAddr + 6);

            int  colorVal      = 0;
            int  offsetAddress = bitmapAddress + line * width;
            int  pixelOffset   = line * STRIDE;
            int *ptr           = p + pixelOffset;
            int  col           = borderXSize;

            //byte pixVal = 0;

            byte[] pixVals = new byte[width];
            VRAM.CopyIntoBuffer(offsetAddress, pixVals, 0, width);
            while (col < width - borderXSize)
            {
                //pixVal = VRAM.ReadByte(offsetAddress + col);
                colorVal   = pixVals[col] == 0 ? bgndColor : GetLUTValue(lutIndex, pixVals[col], gammaCorrection);
                ptr[col++] = colorVal;
            }
        }
Exemple #2
0
        // Convert a Hex file to PGX
        // Header is PGX,1,4 byte jump address
        private void ConvertHexToPGXToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog
            {
                Filter          = "Hex Files|*.hex",
                Title           = "Select a Hex File",
                CheckFileExists = true
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                MemoryRAM temporaryRAM = new MemoryRAM(0, 4 * 1024 * 1024);
                HexFile.Load(temporaryRAM, dialog.FileName, 0, out int DataStartAddress, out int DataLength);
                // write the file
                string outputFileName = Path.ChangeExtension(dialog.FileName, "PGX");

                byte[] buffer = new byte[DataLength];
                temporaryRAM.CopyIntoBuffer(DataStartAddress, buffer, 0, DataLength);
                using (BinaryWriter writer = new BinaryWriter(File.Open(outputFileName, FileMode.Create)))
                {
                    // 8 byte header
                    writer.Write((byte)'P');
                    writer.Write((byte)'G');
                    writer.Write((byte)'X');
                    writer.Write((byte)1);
                    writer.Write(DataStartAddress);
                    writer.Write(buffer);
                }
            }
        }
Exemple #3
0
        public static byte[] LoadGammaCorrection(MemoryRAM VKY)
        {
            // Read the color lookup tables
            int gammaAddress = MemoryMap.GAMMA_BASE_ADDR - MemoryMap.VICKY_BASE_ADDR;

            //
            byte[] result = new byte[3 * 256];
            VKY.CopyIntoBuffer(gammaAddress, result, 0, 3 * 256);
            return(result);
        }
Exemple #4
0
 /**
  * Save the content of memory to a binary file.
  */
 private void SaveButton_Click(object sender, EventArgs e)
 {
     if (SaveDialog.ShowDialog() == DialogResult.OK)
     {
         FileStream outputFile = File.Create(SaveDialog.FileName);
         MemoryRAM  ram        = (MemoryRAM)Memory;
         byte[]     buffer     = new byte[ram.Length];
         ram.CopyIntoBuffer(0, buffer, 0, ram.Length);
         outputFile.Write(buffer, 0, buffer.Length);
         outputFile.Flush();
         outputFile.Close();
     }
 }