コード例 #1
0
    public void IncrementTIMACheck()
    {
        gbMemory.IncrementReg(TIMA);
        byte result = (byte)(gbMemory.ReadFromMemory(TIMA));

        if (result == 0)
        {
            //gbMemory.WriteToMemory(TIMA, 0);
            //TIMAReloadCounter = 4;
            //isReloading = true;
            gbMemory.WriteDirectly(TIMA, gbMemory.ReadFromMemory(TMA));
            gbInterrupts.RequestInterrupt(GameBoyInterrupts.TimerOverflowBit);
        }
    }
コード例 #2
0
    public void HandleKeyEvents()
    {
        bool highToLow = false; // High to low mean we went from 1(released) to 0(pressed)

        // Buttons down (b,a,select,start) 0 = pressed 1 = released
        if (Input.GetKeyDown(KeyCode.S))
        {
            highToLow = memory.ResetJoyPadBit(5);
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
            highToLow = memory.ResetJoyPadBit(4);
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            highToLow = memory.ResetJoyPadBit(6);
        }
        if (Input.GetKeyDown(KeyCode.Return))
        {
            highToLow = memory.ResetJoyPadBit(7);
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (UIPanel.activeSelf)
            {
                UIPanel.SetActive(false);
            }
            else
            {
                UIPanel.SetActive(true);
            }
        }

        // Buttons up (b,a,select,start)
        if (Input.GetKeyUp(KeyCode.S))
        {
            memory.SetJoyPadBit(5);
        }
        if (Input.GetKeyUp(KeyCode.A))
        {
            memory.SetJoyPadBit(4);
        }
        if (Input.GetKeyUp(KeyCode.Space))
        {
            memory.SetJoyPadBit(6);
        }
        if (Input.GetKeyUp(KeyCode.Return))
        {
            memory.SetJoyPadBit(7);
        }

        // Directional down (b,a,select,start)
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            highToLow = memory.ResetJoyPadBit(2);
        }
        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            highToLow = memory.ResetJoyPadBit(3);
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            highToLow = memory.ResetJoyPadBit(1);
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            highToLow = memory.ResetJoyPadBit(0);
        }

        // Directional up (b,a,select,start)
        if (Input.GetKeyUp(KeyCode.UpArrow))
        {
            memory.SetJoyPadBit(2);
        }
        if (Input.GetKeyUp(KeyCode.DownArrow))
        {
            memory.SetJoyPadBit(3);
        }
        if (Input.GetKeyUp(KeyCode.LeftArrow))
        {
            memory.SetJoyPadBit(1);
        }
        if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            memory.SetJoyPadBit(0);
        }

        if (highToLow)
        {
            interrupts.RequestInterrupt(4); // joypad interrupts
        }
    }