Пример #1
0
        public GusboyVisualWaveProvider(WaveFormat waveFormat, Gameboy gb, WaveformPainter painter, int bufferLength)
        {
            this.waveFormat = waveFormat;
            this.gb         = gb;
            this.painter    = painter;

            // We can assume stereo (since the emulator doesn't support mono)
            this.bufferSkip  = waveFormat.SampleRate * 2 / 60;
            this.queueLength = bufferLength / 500 * waveFormat.SampleRate / this.bufferSkip;
        }
Пример #2
0
        public MBC3(byte[] romFile, byte[] sram, string ramPath, Gameboy gb)
            : base(romFile, sram, ramPath)
        {
            this.gb = gb;
            this.gb.Cpu.RtcSupported = this.gb.Cpu.RtcTimerActive = true;

            // TODO: Test ROM/RAM banking

            // If there's an RTC footer in the sram file, the base constructor will have ignored it.

            // TODO: Support the 44-byte legacy format (32-bit unix timestamp)
            if (File.Exists(ramPath) && new FileInfo(ramPath).Length == this.Sram.Length + 48)
            {
                // TODO: Test this more fully
                byte[] file = File.ReadAllBytes(ramPath);
                Array.Copy(file, this.Sram, this.Sram.Length - 48);

                this.ProcessState(file[^ 48..]);
Пример #3
0
        public GPU(Gameboy gameBoy, Func <bool> drawFramebuffer, int[] framebuffer)
        {
            this.gb = gameBoy;

            // Select palette
            this.palObj = this.palObjMGB;
            this.palBg  = this.palBgMGB;

            // Initialize sprite array
            for (int i = 0; i < this.spriteCache.Length; i++)
            {
                this.spriteCache[i] = new Sprite((byte)i, this.gb, this.palObj);
            }

            // Initialize background tile array
            for (int i = 0; i < this.tileCache.Length; i++)
            {
                this.tileCache[i] = default;
                this.tileCache[i].MappedPalette = new int[] { 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF };
            }

            this.drawFramebuffer = drawFramebuffer;

            // We might be loaded by a GBS player that cares not for the video output
            if (framebuffer == null)
            {
                framebuffer = new int[160 * 144];
            }

            this.framebuffer = framebuffer;

            // Pre-set palette alpha
            for (int i = 0; i < 4; i++)
            {
                this.palBg[i]  |= 0xFF << 24;
                this.palObj[i] |= 0xFF << 24;
            }

            // Init object palette maps so they're at least not undefined
            this.PalObjMap[0] = new int[4];
            this.PalObjMap[1] = new int[4];

            this.BuildColourCache(this.gb.UseFilter);
        }
Пример #4
0
        private void InitGameboy(string filePath)
        {
            if (File.Exists(filePath))
            {
                if (this.outputDevice != null)
                {
                    this.outputDevice.Stop();
                    this.outputDevice.Dispose();
                }

                this.gb = new Gameboy(this.AddMessage, this.DrawFramebuffer, this.framebuffer, SAMPLE_RATE, filePath);

                this.audioSource  = new GusboyWaveProvider(WaveFormat.CreateIeeeFloatWaveFormat(SAMPLE_RATE, 2), this.gb);
                this.outputDevice = new WaveOutEvent()
                {
                    DesiredLatency = 100, NumberOfBuffers = 50
                };                                                                                     // 2ms buffers
                this.outputDevice.Init(this.audioSource);
                this.outputDevice.Play();
            }
        }
Пример #5
0
 public APU(Gameboy gameBoy, int sampleRate)
 {
     this.gb          = gameBoy;
     this.sampleClock = (int)Math.Round(CPU_CLOCK / (double)sampleRate);
 }
Пример #6
0
 public GusboyWaveProvider(WaveFormat waveFormat, Gameboy gb)
 {
     this.waveFormat = waveFormat;
     this.gb         = gb;
 }
Пример #7
0
 public RAM(Gameboy gameBoy)
 {
     this.gb = gameBoy;
 }