Ejemplo n.º 1
0
        public Chip8Emu(IFontLoader fontLoader, IAudioDevice audioDevice, IPPU ppu, IInputDevice inputDevice, byte[] rom)
        {
            _audioDevice = audioDevice;
            _ppu         = ppu;
            _inputDevice = inputDevice;

            Array.Copy(rom, 0, _memory, ROM_INDEX, rom.Length);

            var font = fontLoader.GetFont();

            Array.Copy(font, 0, _memory, FONT_INDEX, font.Length);

            _opCodes = new Dictionary <byte, Action <OpCodeData> >
            {
                { 0x0, Misc0 },
                { 0x1, JumpToNNN },
                { 0x2, CallSubroutine },
                { 0x3, SkipXEqualsNN },
                { 0x4, SkipXNotEqualsNN },
                { 0x5, SkipXEqualsY },
                { 0x6, SetXToNN },
                { 0x7, AddXToNN },
                { 0x8, Arithmetic },
                { 0x9, SkipXNotEqualsY },
                { 0xA, SetIToNNN },
                { 0xB, JumpToNNNPlusV0 },
                { 0xC, SetRandomX },
                { 0xD, DrawSprite },
                { 0xE, KeyPressedOps },
                { 0xF, MiscF },
            };
            _misc0OpCodes = new Dictionary <byte, Action <OpCodeData> >
            {
                { 0xE0, ClearScreen },
                { 0xEE, ReturnSubroutine },
            };
            _miscFOpCodes = new Dictionary <byte, Action <OpCodeData> >
            {
                { 0x07, SetXToTimer },
                { 0x0A, AwaitAndStoreKeyPress },
                { 0x15, SetDelayTimer },
                { 0x18, SetSoundTimer },
                { 0x1E, AddXToI },
                { 0x29, SetIToFont },
                { 0x33, SetIToBCD },
                { 0x55, SetX },
                { 0x65, LoadX },
            };

            var timer = new Timer(1000 / DISPLAY_HZ);

            timer.Elapsed += On60HzTimerTick;
            timer.Start();
        }
Ejemplo n.º 2
0
 public SNESSystem(ICPU cpu, IRenderer renderer, IROM rom, IPPU ppu, IAPU apu, IAudioHandler audioHandler)
 {
     CPU          = cpu;
     Renderer     = renderer;
     AudioHandler = audioHandler;
     ROM          = rom;
     rom?.SetSystem(this);
     PPU = ppu;
     PPU?.SetSystem(this);
     APU = apu;
     CPU?.SetSystem(this);
 }