예제 #1
0
파일: PPU.cs 프로젝트: dgrigoriou1/NES-Emu
 public static void WriteToOAMRegister(int Val)
 {
     if (((TOTALCYCLES - 1) & 1) != 0)
     {
         OddCycle = true;
     }
     if (OddCycle)
     {
         CPU.AddCycles(1);
         RunPPU(1);
         APU.RunAPU(1);
     }
     else
     {
         CPU.AddCycles(2);
         RunPPU(2);
         APU.RunAPU(2);
     }
     for (int k = (Val * 0x100); k < ((Val * 0x100) + 0x100); k++)
     {
         OAMMEM[((k - (Val * 0x100)) + OAMADDR2003) & 0xFF] = CPU.CPUMemory[k];
         PPUSTATUS2002 = (PPUSTATUS2002 & 0xE0) | (CPU.CPUMemory[k] & 0x1F);
         CPU.AddCycles(2);
         RunPPU(2);
         APU.RunAPU(2);
     }
 }
예제 #2
0
 private void RunNESBackGroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     while (PlayLoop && !e.Cancel)
     {
         bitmapData = NESBMP.LockBits(new Rectangle(0, 0, 256, 240), ImageLockMode.WriteOnly, NESBMP.PixelFormat);
         Iptr       = bitmapData.Scan0;
         Marshal.Copy(Iptr, PPU.Pixels, 0, 245760);
         while (!DrawFrame && PlayLoop)
         {
             if (Trace && (CPU.CycleNumber == 0))
             {
                 Debugger.GetTracedata();
             }
             CPU.RunCPU();
             APU.RunAPU(1);
             PPU.RunPPU(1);
         }
         Marshal.Copy(PPU.Pixels, 0, Iptr, 245760);
         try
         {
             if (bitmapData != null)
             {
                 NESBMP.UnlockBits(bitmapData);
                 RunNESBackGroundWorker.ReportProgress(0);
             }
         }
         finally
         {
             DrawFrame = false;
         }
     }
 }
예제 #3
0
 internal MemoryHandler(GameBoy gameboy)
 {
     this.gameboy   = gameboy;
     this.memory    = (Memory)gameboy.Memory;
     this.cartridge = (Cartridge.Cartridge)gameboy.Cartridge;
     this.cpu       = (CPU)gameboy.CPU;
     this.display   = (Display)gameboy.Display;
     this.apu       = (APU)gameboy.APU;
 }
예제 #4
0
        private void CatchUpApu()
        {
            long catchUpCycles = (long)_apuCatchCycles & 0xffffffff;

            for (var i = 0; i < catchUpCycles; i++)
            {
                APU.Cycle();
            }
            _apuCatchCycles -= catchUpCycles;
        }
예제 #5
0
파일: DSP.cs 프로젝트: fattard/xFF
                    public void PlayAudio(APU aAPU)
                    {
                        aAPU.UserChannel1Enabled = channel1Enabled;
                        aAPU.UserChannel2Enabled = channel2Enabled;
                        aAPU.UserChannel3Enabled = channel3Enabled;
                        aAPU.UserChannel4Enabled = channel4Enabled;

                        aAPU.UpdateOutputWave();
                        m_stream.Write(aAPU.OutputWave, 0, aAPU.OutputWave.Length);
                    }
예제 #6
0
 public void LoadROM(string fileName)
 {
     FileName = fileName;
     byte[] data = File.ReadAllBytes(FileName);
     LoadRom(data);
     GameName = ROM.Header.Name;
     Reset1();
     CPU.Reset();
     PPU.Reset();
     APU.Reset();
     Reset2();
     Run();
 }
예제 #7
0
파일: Gameboy.cs 프로젝트: honased/GBSharp
        public Gameboy(ConstructAudioEmitter constructor)
        {
            ConstructEmitter = constructor;
            Mmu   = new MMU(this);
            Ppu   = new PPU(this);
            Apu   = new APU(this);
            Input = new Input(this);
            Timer = new Timer(this);

            Cpu       = new CPU(this);
            Dma       = new DMA(this);
            LinkCable = new LinkCable(this);

            Reset();
        }
예제 #8
0
 public static void Reset()
 {
     DrawFrame  = false;
     bitmapData = null;
     nes.OutputPictureBox.Image = null;
     NESBMP = new Bitmap(256, 240, PixelFormat.Format32bppPArgb);
     DebuggerForm.Reset();
     APU.Reset();
     CPU.Reset();
     GAME.Reset();
     PPU.Reset();
     FramesPerSecond = 0;
     Debugger.Initialize();
     GC.Collect();
 }
예제 #9
0
    public bool iskljuci(APU apu)
    {
        if (apu.Ukljucenje == true)
        {
            MessageBox.Show("APU je uključena, prekidač se ne može isključiti.");
            return(false);
        }

        //MessageBox.Show("Prekidač isključen.");

        komanda        = false;
        trenutnoStanje = stanje.isključen;

        return(true);
    }
예제 #10
0
        public Device(Cartridge.Cartridge cartridge, DeviceType type, IRenderer renderer, ISoundOutput soundOutput, byte[] bootRom)
        {
            Log = new LoggerConfiguration()
                  .MinimumLevel.Information()
                  .CreateLogger();

            // A bit of double checking that we're loading a valid cartridge for the device type
            if (cartridge.CGBSupportCode == CGBSupportCode.CGBExclusive && type == DeviceType.DMG)
            {
                Log.Error("Cartridge can't be loaded because it's CGB only and this device was created as DMG");
                throw new ApplicationException("Cartridge can't be loaded because it's CGB only and this device was created as DMG");
            }

            Type = type;
            Mode = cartridge.CGBSupportCode switch
            {
                CGBSupportCode.CGBExclusive => DeviceType.CGB,
                CGBSupportCode.CGBCompatible => type,
                CGBSupportCode.CGBIncompatible => DeviceType.DMG,
                _ => throw new ArgumentOutOfRangeException()
            };

            Renderer    = renderer;
            SoundOutput = soundOutput;

            InterruptRegisters = new InterruptRegisters();
            ControlRegisters   = new ControlRegisters();
            APU           = new APU(this);
            LCDRegisters  = new LCDRegisters(this);
            Cartridge     = cartridge;
            MMU           = new MMU(bootRom, this);
            CPU           = new CPU.CPU(this);
            _cpuGenerator = CPU.GetEnumerator();
            LCDDriver     = new LCDDriver(this);
            Timer         = new Timer(this);
            DMAController = new DMAController(this);
            JoypadHandler = new JoypadHandler(this);

            // Set default values if there was no passed in boot rom
            if (bootRom == null)
            {
                SkipBootRom();
            }
        }
예제 #11
0
파일: EmuGB.cs 프로젝트: fattard/xFF
                public EmuGB(ConfigsGB aConfigs)
                {
                    m_configs = aConfigs;

                    m_cpu = new CPU();
                    m_ppu = new PPU();
                    m_apu = new APU();

                    m_mem             = new MEM();
                    m_dmaController   = new DMAController();
                    m_timerController = new TimerController();

                    m_joypad = new Joypad();

                    m_serialIO = new SerialIO();

                    // Start paused
                    m_paused = true;

                    // Temp binding
                    DrawDisplay     = (aPPU) => { };
                    DrawDisplayLine = (aPPU, aScanline) => { };


                    m_mem.AttachCPU(m_cpu);
                    m_mem.AttachPPU(m_ppu);
                    m_mem.AttachAPU(m_apu);
                    m_mem.AttachDMAController(m_dmaController);
                    m_mem.AttachTimerController(m_timerController);
                    m_mem.AttachJoypad(m_joypad);
                    m_mem.AttachSerialIO(m_serialIO);
                    m_cpu.ProcessorState.BindCyclesStep(m_ppu.CyclesStep);
                    m_cpu.ProcessorState.BindCyclesStep(m_apu.CyclesStep);
                    m_cpu.ProcessorState.BindCyclesStep(m_dmaController.CyclesStep);
                    m_cpu.ProcessorState.BindCyclesStep(m_timerController.CyclesStep);
                    m_cpu.ProcessorState.BindCyclesStep(m_serialIO.CyclesStep);

                    m_ppu.BindRequestIRQ(m_cpu.RequestIRQ);
                    m_timerController.BindRequestIRQ(m_cpu.RequestIRQ);
                    m_joypad.BindRequestIRQ(m_cpu.RequestIRQ);
                    m_serialIO.BindRequestIRQ(m_cpu.RequestIRQ);
                    //m_ppu.BindDrawDisplayLine(DrawDisplayLine);
                }
예제 #12
0
        public GBA(ushort[] display)
        {
            this.cpu = new ARM7TDMI(this, this.EventQueue);
            this.IO  = this.cpu.IO;
            this.mem = this.cpu.mem;
            this.bus = this.cpu.bus;

            this.apu = new APU(this.cpu, this.EventQueue);
            this.ppu = new PPU(this, display, this.IO);

            this.mem.Init(this.ppu);
            this.IO.Init(this.ppu, this.bus);
            this.IO.Layout(this.cpu, this.apu);

            // this.mem.UseNormattsBIOS();

            this.display = display;
#if THREADED_RENDERING
            this.RenderThread = new Thread(() => ppu.Mainloop());
#endif
        }
예제 #13
0
 public void ResumeEmulation()
 {
     AudioHandler.Resume();
     if (!string.IsNullOrEmpty(FileName))
     {
         if (ROM?.Header == null)
         {
             byte[] data = File.ReadAllBytes(FileName);
             LoadRom(data);
         }
         ROM.LoadSRAM();
         _isExecuting = true;
         while (_isExecuting)
         {
             RunFrame(false);
             Renderer.RenderBuffer(PPU.GetPixels());
             APU.SetSamples(AudioHandler.SampleBufferL, AudioHandler.SampleBufferR);
             AudioHandler.NextBuffer();
             FrameRendered?.Invoke(this, null);
         }
     }
 }
예제 #14
0
    public void Power()
    {
        if (MAPPER == null)
        {
            throw new System.Exception("No rom loaded");
        }

        Running = !Running;

        if (Running)
        {
            Sleep = Debug ? 0 : 0;

            MMC = new Memory(this);
            CPU = new CPU(this);
            PPU = new PPU(this);
            APU = new APU(this);

            MMC.Power();
            CPU.Power();
            PPU.Power();
            APU.Power();
        }
    }
예제 #15
0
 public bool iskljuciPrekidac(Prekidac prekidac, APU apu)
 {
     apu.iskljuci();
     return(prekidac.iskljuci(apu));
 }
예제 #16
0
파일: CrispyEmu.cs 프로젝트: Monczak/Crispy
        protected override void Initialize()
        {
            MyraEnvironment.Game = this;

            LoadConfig();

            messages = new List <Message>();

            _graphics.PreferredBackBufferWidth  = 640;
            _graphics.PreferredBackBufferHeight = 320;

            _graphics.ApplyChanges();

            isPaused  = false;
            isRunning = false;

            InputHandler.SetBindings(new Dictionary <int, Keys>
            {
                { 0, Keys.X },
                { 1, Keys.D1 },
                { 2, Keys.D2 },
                { 3, Keys.D3 },
                { 4, Keys.Q },
                { 5, Keys.W },
                { 6, Keys.E },
                { 7, Keys.A },
                { 8, Keys.S },
                { 9, Keys.D },
                { 10, Keys.Z },
                { 11, Keys.C },
                { 12, Keys.D4 },
                { 13, Keys.R },
                { 14, Keys.F },
                { 15, Keys.V }
            });

            pixel = new Texture2D(_graphics.GraphicsDevice, 10, 10);
            Color[] data = new Color[10 * 10];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = Color.White;
            }
            pixel.SetData(data);

            TargetElapsedTime = TimeSpan.FromSeconds(1f / cyclesPerSecond);
            IsFixedTimeStep   = true;

            cpu           = new CPU();
            cpu.hiResMode = true;
            cpu.Reset();

            apu = new APU();
            apu.Initialize();

            SavestateManager.Initialize(savestateSlots);

            RewindManager.Initialize(rewindBufferSize);

            ShowMessage("Welcome to Crispy! Press F3 to load a game, or press F1 for help.", 9999);

            base.Initialize();
        }
예제 #17
0
 public void osvjeziVrijednosti(Prekidac prekidac, APU apu)
 {
     //potrebna implementacija
 }
예제 #18
0
파일: DSP.cs 프로젝트: fattard/xFF
 public void ConfigBuffers(APU aAPU)
 {
     aAPU.OutputWave = new byte[m_audioBuffer.Length];
     aAPU.SetSamplesAvailable(m_samplesBufferSize);
     aAPU.SetSampleRate(AudioSettings.outputSampleRate);
 }
예제 #19
0
파일: IO.Init.cs 프로젝트: DenSinH/GBAC-
        public void Layout(ARM7TDMI cpu, APU apu)
        {
            // ========================== LCD Registers ==========================
            this.Storage[0x00] = this.Storage[0x01] = this.DISPCNT;
            this.Storage[0x02] = this.Storage[0x03] = new DefaultRegister();  // green swap
            this.Storage[0x04] = this.Storage[0x05] = this.DISPSTAT;
            this.Storage[0x06] = this.Storage[0x07] = this.VCOUNT;

            this.Storage[0x08] = this.Storage[0x09] = this.BGCNT[0];
            this.Storage[0x0a] = this.Storage[0x0b] = this.BGCNT[1];
            this.Storage[0x0c] = this.Storage[0x0d] = this.BGCNT[2];
            this.Storage[0x0e] = this.Storage[0x0f] = this.BGCNT[3];

            this.Storage[0x10] = this.Storage[0x11] = this.BGHOFS[0];
            this.Storage[0x12] = this.Storage[0x13] = this.BGVOFS[0];
            this.Storage[0x14] = this.Storage[0x15] = this.BGHOFS[1];
            this.Storage[0x16] = this.Storage[0x17] = this.BGVOFS[1];
            this.Storage[0x18] = this.Storage[0x19] = this.BGHOFS[2];
            this.Storage[0x1a] = this.Storage[0x1b] = this.BGVOFS[2];
            this.Storage[0x1c] = this.Storage[0x1d] = this.BGHOFS[3];
            this.Storage[0x1e] = this.Storage[0x1f] = this.BGVOFS[3];

            this.Storage[0x20] = this.Storage[0x21] = this.BG2PA;
            this.Storage[0x22] = this.Storage[0x23] = this.BG2PB;
            this.Storage[0x24] = this.Storage[0x25] = this.BG2PC;
            this.Storage[0x26] = this.Storage[0x27] = this.BG2PD;

            this.Storage[0x28] = this.Storage[0x29] = this.BG2X.lower;
            this.Storage[0x2a] = this.Storage[0x2b] = this.BG2X.upper;
            this.Storage[0x2c] = this.Storage[0x2d] = this.BG2Y.lower;
            this.Storage[0x2e] = this.Storage[0x2f] = this.BG2Y.upper;

            this.Storage[0x30] = this.Storage[0x31] = this.BG3PA;
            this.Storage[0x32] = this.Storage[0x33] = this.BG3PB;
            this.Storage[0x34] = this.Storage[0x35] = this.BG3PC;
            this.Storage[0x36] = this.Storage[0x37] = this.BG3PD;

            this.Storage[0x38] = this.Storage[0x39] = this.BG3X.lower;
            this.Storage[0x3a] = this.Storage[0x3b] = this.BG3X.upper;
            this.Storage[0x3c] = this.Storage[0x3d] = this.BG3Y.lower;
            this.Storage[0x3e] = this.Storage[0x3f] = this.BG3Y.upper;

            this.Storage[0x40] = this.Storage[0x41] = this.WINH[0];
            this.Storage[0x42] = this.Storage[0x43] = this.WINH[1];

            this.Storage[0x44] = this.Storage[0x45] = this.WINV[0];
            this.Storage[0x46] = this.Storage[0x47] = this.WINV[1];

            this.Storage[0x48] = this.Storage[0x49] = this.WININ;
            this.Storage[0x4a] = this.Storage[0x4b] = this.WINOUT;

            this.Storage[0x4c] = this.Storage[0x4d] = this.MOSAIC;
            this.Storage[0x4e] = this.Storage[0x4f] = this.MasterZeroRegister;  // unused MOSAIC bits, lower half readable

            this.Storage[0x50] = this.Storage[0x51] = this.BLDCNT;
            this.Storage[0x52] = this.Storage[0x53] = this.BLDALPHA;
            this.Storage[0x54] = this.Storage[0x55] = this.BLDY;
            this.Storage[0x56] = this.Storage[0x57] = this.MasterZeroRegister;  // lower half readable

            for (int i = 0x58; i < 0x60; i += 4)
            {
                this.Storage[i]     = this.Storage[i + 1] = this.MasterUnusedRegister.lower;
                this.Storage[i + 2] = this.Storage[i + 3] = this.MasterUnusedRegister.upper;
            }

            // ========================== Sound Registers ==========================
            this.Storage[0x60] = this.Storage[0x61] = new SquareCNT_L(apu.sq1);
            this.Storage[0x62] = this.Storage[0x63] = new SquareCNT_H(apu.sq1);
            this.Storage[0x64] = this.Storage[0x65] = new SquareCNT_X(apu.sq1);
            this.Storage[0x66] = this.Storage[0x67] = this.MasterUnusedRegister.upper;

            this.Storage[0x68] = this.Storage[0x69] = new SquareCNT_H(apu.sq2);
            this.Storage[0x6a] = this.Storage[0x6b] = this.MasterUnusedRegister.upper;
            this.Storage[0x6c] = this.Storage[0x6d] = new SquareCNT_X(apu.sq2);
            this.Storage[0x6e] = this.Storage[0x6f] = this.MasterUnusedRegister.upper;

            this.Storage[0x70] = this.Storage[0x71] = new WaveCNT_L(apu.wave);
            this.Storage[0x72] = this.Storage[0x73] = new WaveCNT_H(apu.wave);
            this.Storage[0x74] = this.Storage[0x75] = new WaveCNT_X(apu.wave);
            this.Storage[0x76] = this.Storage[0x77] = this.MasterUnusedRegister.upper;

            this.Storage[0x78] = this.Storage[0x79] = new NoiseCNT_L(apu.noise);
            this.Storage[0x7a] = this.Storage[0x7b] = this.MasterUnusedRegister.upper;
            this.Storage[0x7c] = this.Storage[0x7d] = new NoiseCNT_H(apu.noise);
            this.Storage[0x7e] = this.Storage[0x7f] = this.MasterUnusedRegister.upper;

            this.Storage[0x80] = this.Storage[0x81] = new SOUNDCNT_L(apu);
            this.Storage[0x82] = this.Storage[0x83] = new SOUNDCNT_H(apu, cpu.Timers[0], cpu.Timers[1]);
            this.Storage[0x84] = this.Storage[0x85] = new SOUNDCNT_X(apu);
            this.Storage[0x86] = this.Storage[0x87] = this.MasterUnusedRegister.upper;
            this.Storage[0x88] = this.Storage[0x89] = new DefaultRegister();  // SOUNDBIAS (unnecessary?)

            this.Storage[0x8a] = this.Storage[0x8b] = this.MasterUnusedRegister.lower;
            this.Storage[0x8c] = this.Storage[0x8d] = this.MasterUnusedRegister.upper;
            this.Storage[0x8e] = this.Storage[0x8f] = this.MasterUnusedRegister.lower;

            for (int i = 0; i < 0x10; i += 2)
            {
                this.Storage[0x90 + i] = this.Storage[0x91 + i] = new WAVE_RAM(apu.wave, i);
            }

            this.Storage[0xa0] = this.Storage[0xa1] = new FIFO_Data(apu.FIFOA, cpu.bus, true);
            this.Storage[0xa2] = this.Storage[0xa3] = new FIFO_Data(apu.FIFOA, cpu.bus, false);
            this.Storage[0xa4] = this.Storage[0xa5] = new FIFO_Data(apu.FIFOB, cpu.bus, true);
            this.Storage[0xa6] = this.Storage[0xa7] = new FIFO_Data(apu.FIFOB, cpu.bus, false);

            for (int i = 0xa8; i < 0xb0; i += 4)
            {
                this.Storage[i]     = this.Storage[i + 1] = this.MasterUnusedRegister.lower;
                this.Storage[i + 2] = this.Storage[i + 3] = this.MasterUnusedRegister.upper;
            }

            // ======================= DMA Transfer Channels =======================
            this.Storage[0xb0] = this.Storage[0xb1] = cpu.DMAChannels[0].DMASAD.lower;
            this.Storage[0xb2] = this.Storage[0xb3] = cpu.DMAChannels[0].DMASAD.upper;
            this.Storage[0xb4] = this.Storage[0xb5] = cpu.DMAChannels[0].DMADAD.lower;
            this.Storage[0xb6] = this.Storage[0xb7] = cpu.DMAChannels[0].DMADAD.upper;
            this.Storage[0xb8] = this.Storage[0xb9] = cpu.DMAChannels[0].DMACNT_L;
            this.Storage[0xba] = this.Storage[0xbb] = cpu.DMAChannels[0].DMACNT_H;

            this.Storage[0xbc] = this.Storage[0xbd] = cpu.DMAChannels[1].DMASAD.lower;
            this.Storage[0xbe] = this.Storage[0xbf] = cpu.DMAChannels[1].DMASAD.upper;
            this.Storage[0xc0] = this.Storage[0xc1] = cpu.DMAChannels[1].DMADAD.lower;
            this.Storage[0xc2] = this.Storage[0xc3] = cpu.DMAChannels[1].DMADAD.upper;
            this.Storage[0xc4] = this.Storage[0xc5] = cpu.DMAChannels[1].DMACNT_L;
            this.Storage[0xc6] = this.Storage[0xc7] = cpu.DMAChannels[1].DMACNT_H;

            this.Storage[0xc8] = this.Storage[0xc9] = cpu.DMAChannels[2].DMASAD.lower;
            this.Storage[0xca] = this.Storage[0xcb] = cpu.DMAChannels[2].DMASAD.upper;
            this.Storage[0xcc] = this.Storage[0xcd] = cpu.DMAChannels[2].DMADAD.lower;
            this.Storage[0xce] = this.Storage[0xcf] = cpu.DMAChannels[2].DMADAD.upper;
            this.Storage[0xd0] = this.Storage[0xd1] = cpu.DMAChannels[2].DMACNT_L;
            this.Storage[0xd2] = this.Storage[0xd3] = cpu.DMAChannels[2].DMACNT_H;

            this.Storage[0xd4] = this.Storage[0xd5] = cpu.DMAChannels[3].DMASAD.lower;
            this.Storage[0xd6] = this.Storage[0xd7] = cpu.DMAChannels[3].DMASAD.upper;
            this.Storage[0xd8] = this.Storage[0xd9] = cpu.DMAChannels[3].DMADAD.lower;
            this.Storage[0xda] = this.Storage[0xdb] = cpu.DMAChannels[3].DMADAD.upper;
            this.Storage[0xdc] = this.Storage[0xdd] = cpu.DMAChannels[3].DMACNT_L;
            this.Storage[0xde] = this.Storage[0xdf] = cpu.DMAChannels[3].DMACNT_H;

            for (int i = 0xe0; i < 0x100; i += 4)
            {
                this.Storage[i]     = this.Storage[i + 1] = this.MasterUnusedRegister.lower;
                this.Storage[i + 2] = this.Storage[i + 3] = this.MasterUnusedRegister.upper;
            }

            // ========================== Timer Registers ==========================
            this.Storage[0x100] = this.Storage[0x101] = cpu.Timers[0].Data;
            this.Storage[0x102] = this.Storage[0x103] = cpu.Timers[0].Control;

            this.Storage[0x104] = this.Storage[0x105] = cpu.Timers[1].Data;
            this.Storage[0x106] = this.Storage[0x107] = cpu.Timers[1].Control;

            this.Storage[0x108] = this.Storage[0x109] = cpu.Timers[2].Data;
            this.Storage[0x10a] = this.Storage[0x10b] = cpu.Timers[2].Control;

            this.Storage[0x10c] = this.Storage[0x10d] = cpu.Timers[3].Data;
            this.Storage[0x10e] = this.Storage[0x10f] = cpu.Timers[3].Control;

            for (int i = 0x110; i < 0x120; i += 4)
            {
                this.Storage[i]     = this.Storage[i + 1] = this.MasterUnusedRegister.lower;
                this.Storage[i + 2] = this.Storage[i + 3] = this.MasterUnusedRegister.upper;
            }

            // ============================ SIO (1) ============================
            this.Storage[0x120] = this.Storage[0x121] = this.SIODATA32.lower;  // shared
            this.Storage[0x122] = this.Storage[0x123] = this.SIODATA32.upper;  // shared
            this.Storage[0x124] = this.Storage[0x125] = new DefaultRegister();
            this.Storage[0x126] = this.Storage[0x127] = new DefaultRegister();
            this.Storage[0x128] = this.Storage[0x129] = this.SIOCNT;
            this.Storage[0x12a] = this.Storage[0x12b] = this.SIODATA8;  // shared

            this.Storage[0x012c] = this.Storage[0x012d] = this.MasterUnusedRegister.lower;
            this.Storage[0x012e] = this.Storage[0x012f] = this.MasterUnusedRegister.upper;

            // =========================== Keypad Input ========================
            this.Storage[0x0130] = this.Storage[0x0131] = this.KEYINPUT;
            this.Storage[0x0132] = this.Storage[0x0133] = this.KEYCNT;

            // ============================ SIO (2) ============================
            this.Storage[0x134] = this.Storage[0x135] = this.RCNT;

            this.Storage[0x136] = this.Storage[0x137] = this.MasterUnusedRegister.upper;  // note offset!
            for (int i = 0x0138; i < 0x140; i += 4)
            {
                this.Storage[i]     = this.Storage[i + 1] = this.MasterUnusedRegister.lower;
                this.Storage[i + 2] = this.Storage[i + 3] = this.MasterUnusedRegister.upper;
            }

            this.Storage[0x140] = this.Storage[0x141] = new DefaultRegister();

            for (int i = 0x0142; i < 0x150; i += 4)
            {
                this.Storage[i]     = this.Storage[i + 1] = this.MasterUnusedRegister.lower;
                this.Storage[i + 2] = this.Storage[i + 3] = this.MasterUnusedRegister.upper;
            }

            this.Storage[0x150] = this.Storage[0x151] = new DefaultRegister();
            this.Storage[0x152] = this.Storage[0x153] = new DefaultRegister();
            this.Storage[0x154] = this.Storage[0x155] = new DefaultRegister();
            this.Storage[0x156] = this.Storage[0x157] = new DefaultRegister();
            this.Storage[0x158] = this.Storage[0x159] = new DefaultRegister();

            this.Storage[0x15a] = this.Storage[0x15b] = this.MasterZeroRegister;
            for (int i = 0x015c; i < 0x200; i += 4)
            {
                this.Storage[i]     = this.Storage[i + 1] = this.MasterUnusedRegister.lower;
                this.Storage[i + 2] = this.Storage[i + 3] = this.MasterUnusedRegister.upper;
            }

            // ========== Interrupt, Waitstate and Power-Down Control ===========
            this.Storage[0x0200] = this.Storage[0x0201] = this.IE;
            this.Storage[0x0202] = this.Storage[0x0203] = this.IF;
            this.Storage[0x0204] = this.Storage[0x0205] = this.WAITCNT;

            this.Storage[0x0206] = this.Storage[0x0207] = this.MasterZeroRegister;
            this.Storage[0x0208] = this.Storage[0x0209] = this.IME;
            this.Storage[0x020a] = this.Storage[0x020b] = this.MasterZeroRegister;

            for (int i = 0x20c; i < 0x300; i += 4)
            {
                this.Storage[i]     = this.Storage[i + 1] = this.MasterUnusedRegister.lower;
                this.Storage[i + 2] = this.Storage[i + 3] = this.MasterUnusedRegister.upper;
            }

            this.Storage[0x0300] = this.Storage[0x0301] = this.HALTCNT;
            this.Storage[0x0302] = this.Storage[0x0303] = this.MasterZeroRegister;

            for (int i = 0x304; i < 0x400; i += 4)
            {
                this.Storage[i]     = this.Storage[i + 1] = this.MasterUnusedRegister.lower;
                this.Storage[i + 2] = this.Storage[i + 3] = this.MasterUnusedRegister.upper;
            }

            for (int i = 0; i < 0x400; i++)
            {
                if (this.Storage[i] is null)
                {
                    this.Error(i.ToString("x4") + " in IORAM not initialized");
                    Console.ReadKey();
                }
            }

            this.InitLCD();
        }
 /// <summary>
 /// Создается элемент - отображение <see cref="BaseDetailControl"/>, управляемое Dispatcher ом
 /// </summary>
 /// <param name="apu">Отображаемый элемент</param>
 public DispatcheredAircraftBaseDetailInfoControl(APU apu) : base(apu)
 {
     InitializeControl();
 }
예제 #21
0
 public virtual void InitializeMemoryMap(APU apu)
 {
 }
예제 #22
0
        public Core(byte[] gameROM, byte[]?bootROM, Keypad Keypad, FrameSink frameSink)
        {
            if (gameROM.Length < 0x8000)
            {
                throw new Exception("Cartridge file has to be at least 8kb in size");
            }
            PC = new();

            InterruptRegisters        = new InterruptRegisters();
            Keypad.Input.KeyWentDown += InterruptRegisters.TriggerEvent;

            APU = new APU(32768);
            PPU = new PPU(InterruptRegisters.EnableVBlankInterrupt, InterruptRegisters.EnableLCDSTATInterrupt, frameSink);

            Timers = new Timers(InterruptRegisters.EnableTimerInterrupt);

            var ioRegisters = SetupControlRegisters(Keypad);

            CartHeader Header = new CartHeader(gameROM);

            MBC Card;

            if (Header.HasBattery())
            {
                var mmf = Header.MakeMemoryMappedFile();
                Card = Header.HasClock() ? Header.MakeMBC(gameROM, mmf, () => masterclock) : Header.MakeMBC(gameROM, mmf);
            }
            else
            {
                Card = Header.MakeMBC(gameROM);
            }

            //Writing out the RTC too often would be very heavy. This writes it out once per frame.
            //
            if (Header.Type == CartType.MBC3_TIMER_RAM_BATTERY)
            {
                var SaveRTC = ((MBC3)Card).SaveRTC();

                void h(object?x, EventArgs y) => SaveRTC();

                frameSink.FramePushed += h;
            }

            if (Card is MBC5WithRumble rumble)
            {
                rumble.RumbleStateChange += Keypad.ToggleRumble;
            }

            Memory = new MMU(
                bootROM,
                Card,
                PPU.VRAM,
                PPU.OAM,
                ioRegisters,
                (x => InterruptRegisters.InterruptControlRegister = x,
                 () => InterruptRegisters.InterruptControlRegister),
                PC
                );

            CPU = new CPU(Memory, InterruptRegisters, PC);
            ioRegisters[0x0f] = InterruptRegisters.HookUp();

            ioRegisters[0x50] = Memory.HookUpMemory();

            //We have to replicate the state of the system post boot without running the bootrom
            if (bootROM == null)
            {
                //registers
                CPU.SetStateWithoutBootrom();

                //timers
                Timers.SetStateWithoutBootrom();


                //sound
                APU.SetStateWithoutBootrom();

                //graphics TODO: we can't really set up the graphics environment correctly
                //because we will have to also initialize the internal renderer state correctly
                PPU.SetStateWithoutBootrom();


                InterruptRegisters.SetStateWithoutBootrom();
            }
        }
예제 #23
0
 public stanje provjeraAPU(APU apu)
 {
 }
예제 #24
0
 public void AttachAPU(APU aAPU)
 {
     m_apu = aAPU;
 }
예제 #25
0
파일: Napajanje.cs 프로젝트: ivancrg/MPIS
 public stanje provjeraAPU(APU apu)
 {
     return(stanje.prvo);
 }
예제 #26
0
 public SOUNDCNT_X(APU apu)
 {
     this.apu = apu;
 }
예제 #27
0
 public SOUNDCNT_H(APU apu, ARM7TDMI.cTimer Timer0, ARM7TDMI.cTimer Timer1)
 {
     this.apu       = apu;
     this.Timers[0] = Timer0;
     this.Timers[1] = Timer1;
 }