Exemplo n.º 1
0
 private void updateTimer()
 {
     if (GameBoyCPU.getBit(6, RTCRegisters[4]) == 0)
     {
         DateTime curr     = System.DateTime.Now;
         TimeSpan currSpan = curr - start;
         RTCRegisters[0] = (byte)(currSpan.Seconds);
         RTCRegisters[1] = (byte)(currSpan.Minutes);
         RTCRegisters[2] = (byte)(currSpan.Hours);
         RTCRegisters[3] = (byte)(currSpan.Days);
         if (currSpan.Days > 255)
         {
             //Rollover
             RTCRegisters[4] = GameBoyCPU.setBit(0, RTCRegisters[4]);
         }
         if (currSpan.Days > 511)
         {
             //Set overflow bit.
             RTCRegisters[4] = GameBoyCPU.setBit(7, RTCRegisters[4]);
             //Unset rollover
             RTCRegisters[4] = GameBoyCPU.resetBit(0, RTCRegisters[4]);
             start           = start.AddDays(512);
         }
     }
 }
Exemplo n.º 2
0
    public bool ResetJoyPadBit(byte key)
    {
        bool isHighToLow = (GameBoyCPU.getBit(5, memory[0xFF00]) == 1) ? true : false;

        joypadState = GameBoyCPU.resetBit(key, GameBoyMemory.joypadState);
        return(isHighToLow);
    }
Exemplo n.º 3
0
    public void setSpeed()
    {
        byte speedBit = getSpeedBit();

        if (speedBit == 0)
        {
            setSpeedBit();
        }
        else
        {
            resetSpeedBit();
        }
        speed = (uint)((GameBoyCPU.getBit(7, memory[KEY1])) == 1 ? 2 : 1); // if 1 we switch to normal speed (1) and if 0 we switch to double speed (2)
    }
Exemplo n.º 4
0
    private void updateControl(byte data)
    {
        DateTime e      = System.DateTime.Now;
        TimeSpan diff   = e - start;
        byte     dayBit = GameBoyCPU.getBit(0, RTCRegisters[4]);

        if (dayBit == 1 && (data & 0x1) == 0)
        {
            start = start.AddDays(256);
        }
        else if (dayBit == 0 && (data & 0x1) == 1)
        {
            start = start.AddDays(-256);
        }
        LatchRegisters[4] = RTCRegisters[4] = data;
    }
Exemplo n.º 5
0
    private void updateDays(ushort dayReset)
    {
        DateTime e    = System.DateTime.Now;
        TimeSpan diff = e - start;

        if (GameBoyCPU.getBit(0, RTCRegisters[4]) == 1)
        {
            dayReset += 256;
        }
        if (dayReset < diff.Days)
        {
            ushort diffDays = (ushort)(diff.Days - dayReset);
            start = start.AddDays(diffDays);
        }
        else if (dayReset > diff.Days)
        {
            ushort diffDays = (ushort)(dayReset - diff.Days);
            start = start.AddDays(-diffDays);
        }
    }
Exemplo n.º 6
0
    private byte getJoyPadState()
    {
        byte res = memory[0xFF00];

        // flip all the bits
        res ^= 0xFF;

        // are we interested in the standard buttons?
        if (GameBoyCPU.getBit(4, res) == 0)
        {
            byte topJoypad = (byte)(joypadState >> 4);
            topJoypad |= 0xF0;                   // turn the top 4 bits on
            res       &= topJoypad;              // show what buttons are pressed
        }
        else if (GameBoyCPU.getBit(5, res) == 0) //directional buttons
        {
            byte bottomJoypad = (byte)(joypadState & 0xF);
            bottomJoypad |= 0xF0;
            res          &= bottomJoypad;
        }
        return(res);
    }
Exemplo n.º 7
0
 private byte getSpeedBit()
 {
     return(GameBoyCPU.getBit(7, memory[KEY1]));
 }