public void WriteByte(int address, int value) { switch (address) { case 0xFF01: lock (this) { data[0] = (byte)value; } break; case 0xFF02: lock (this) { bool oldTransfer = transferInProgress; transferInProgress = Bitwise.IsBitOn(value, 7); clockSpeed = Bitwise.IsBitOn(value, 1); shiftClock = Bitwise.IsBitOn(value, 0); if (!oldTransfer && transferInProgress && shiftClock && ENABLED && socket.IsAlive) { socket.Send(data); } } break; default: Console.WriteLine("Can't read from address " + address.ToString() + " in LinkCable"); break; } }
public void StartDMA(int srcHi, int srcLo, int destHi, int destLo, int lenModStrt) { if (!IsEnabled && _gameboy.IsCGB) { Source = (srcHi << 8) | (srcLo & 0xF0); Destination = ((destHi & 0x1F) << 8) | (destLo & 0xF0); Length = ((lenModStrt & 0x7F) + 1) * 16; IsHDMA = Bitwise.IsBitOn(lenModStrt, 7); Destination |= 0x8000; IsEnabled = true; _lastIndex = 0; } }
public void Tick() { if (!Bitwise.IsBitOn(_gameboy.Mmu.Joypad, 4)) // Direction Keys { _gameboy.Mmu.Joypad = (_gameboy.Mmu.Joypad & 0xF0) | (directionInput); if (setDirectionInterrupt) { _gameboy.Mmu.SetInterrupt(Interrupts.Joypad); } } if (!Bitwise.IsBitOn(_gameboy.Mmu.Joypad, 5)) // Button Keys { _gameboy.Mmu.Joypad = (_gameboy.Mmu.Joypad & 0xF0) | (buttonInput); if (setButtonInterrupt) { _gameboy.Mmu.SetInterrupt(Interrupts.Joypad); } } setButtonInterrupt = false; setDirectionInterrupt = false; }
public void SetInput(Button button, bool Pressed) { int buttonVal = (int)button; int bitIndex = buttonVal % 4; if (buttonVal > 3) { if (Pressed) { if (Bitwise.IsBitOn(buttonInput, bitIndex)) { setButtonInterrupt = true; } buttonInput = Bitwise.ClearBit(buttonInput, bitIndex); } else { buttonInput = Bitwise.SetBit(buttonInput, bitIndex); } } else { if (Pressed) { if (Bitwise.IsBitOn(directionInput, bitIndex)) { setDirectionInterrupt = true; } directionInput = Bitwise.ClearBit(directionInput, bitIndex); } else { directionInput = Bitwise.SetBit(directionInput, bitIndex); } } }
internal void DisableInterrupt(Interrupts interrupt) { IF = Bitwise.ClearBit(IF, (int)interrupt); }
internal void SetInterrupt(Interrupts interrupt) { IF = Bitwise.SetBit(IF, (int)interrupt); }