//Counter clock 00: 4096Hz (1/64 timer clock speed) //Counter clock 01: 262144Hz (1 timer clock speed) //Counter clock 10: 65536Hz (1/4 timer clock speed) //Counter clock 11: 16384Hz (1/16 timer clock speed) public Timer(MMU mmu) { this.mmu = mmu; clock = 0; clockTmp = 0; dividerClockTmp = 0; }
public Joypad(MMU mmu) { this.mmu = mmu; states = new Dictionary <Button, bool>(); foreach (Button btn in System.Enum.GetValues(typeof(Button))) { states[btn] = false; } }
void Init() { mmu = new MMU(); cpu = new CPU(mmu); gpu = new GPU(mmu); timer = new Timer(mmu); joypad = new Joypad(mmu); if (outputMaterial != null) { outputMaterial.SetTexture("_MainTex", gpu.screenTexture); } InitKeyMap(); }
public GPU(MMU mmu) { this.mmu = mmu; this.mmu.OnMemoryWritten += (MMU m, ushort addr) => { if (addr >= 0x8000 && addr <= 0x97FF) { UpdateTile(addr); } else if (addr == 0xFF46) { OAMTransfer(); } }; STAT_Mode = GPUMode.HBlank; LY = 0; clock = 0; buffer = new Color[SCREEN_PIXELS_WIDTH * SCREEN_PIXELS_HEIGHT]; screenTexture = new Texture2D(SCREEN_PIXELS_WIDTH, SCREEN_PIXELS_HEIGHT, TextureFormat.ARGB32, false); screenTexture.filterMode = FilterMode.Point; }