Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Windows.Forms;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.Windows.Threading;
- using System.Threading;
- namespace SpaceInvaders
- {
- class _8080
- {
- private CPU cpu = new CPU();
- private MainForm MainForm = new MainForm();
- public void StartEmulator()
- {
- cpu.initialiseEmulator(); // Reset
- LoadProgram("invaders.rom"); // Load ROM
- cpu.emulateCPU();
- }
- private bool LoadProgram(string filename)
- {
- Console.WriteLine("\nLoading: " + filename + "\n");
- //Initialize(); //reset
- //load file
- byte[] loadedProgramBytes = null;
- try
- {
- loadedProgramBytes = File.ReadAllBytes(filename);
- }
- catch (Exception Ex)
- {
- Debug.WriteLine(Ex.ToString());
- }
- //verify file is not empty
- if (loadedProgramBytes == null)
- {
- Debug.WriteLine("Error loading program. The byte array loaded is null.");
- return false;
- }
- int lSize = loadedProgramBytes.Count();
- for (int i = 0; i < lSize; ++i)
- {
- cpu.memory[i] = loadedProgramBytes[i]; // Store file into memory.
- }
- Debug.WriteLine("ROM loaded in successfully.\n");
- return true;
- }
- private void updateScreen(int addr, int val)
- {
- int x = addr >> 5;
- int y = 255 - ((addr & 0x1f) << 3);
- for (int bit = 1; bit <= 128; bit <<= 1)
- {
- //screenBuffer.SetPixel(x, y--, (bit & val) != 0 ? Color.White : Color.Black);
- }
- //Bitmap clone = (Bitmap)screenBuffer.Clone();
- //MainForm.pictureBox1.BackgroundImage = clone;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement