public Byte GetColorCode(Byte x, Byte y) { if (x > 7) { throw new ArgumentOutOfRangeException(nameof(x), "x must be between 0 and 7"); } if (y > 7) { throw new ArgumentOutOfRangeException(nameof(y), "y must be between 0 and 7"); } Byte result = 0; Byte rowIndex = y * 2; if (data[rowIndex + 1].Read()[7 - x]) { result |= 2; } if (data[rowIndex].Read()[7 - x]) { result |= 1; } return(result); }
private void SetRomBankNr(Byte value) { var bankNr = value & 0x0F; if (bankNr == 0) { bankNr = 1; } romBanks.Switch(bankNr % romBankCount); }
protected override void OnBank0Write(Address address, Byte value) { Byte highByte = GetHighByte(address); if (highByte[0]) { SetRomBankNr(value); } else { ToggleRam(value); } }
public void Initialize() { initialVolume = data >> 4; isIncrease = data[3]; Byte stepLengthData = data & 7; if (stepLengthData == 0 || (isIncrease && initialVolume == 0xF) || (!isIncrease && initialVolume == 0)) { isActive = false; } else { var secondsPerStep = stepLengthData / 64d; cyclesPerStep = (int)(secondsPerStep * Statics.Frequencies.cpuSpeed); isActive = true; } }
public Address GetVolume(int elapsedCycles) { Byte currentVolume = initialVolume; if (isActive) { int steps = elapsedCycles / cyclesPerStep; if (isIncrease) { currentVolume = Math.Min(0x0F, initialVolume + steps); } else { currentVolume = Math.Max(0, initialVolume - steps); } } return(ScaleVolume(currentVolume)); }
public void Write(Address address, Byte value, bool isCpu = false) { }
public override void Write(Address address, Byte value, bool isCpu = false) { base.Write(address % RAMSize, value, isCpu); }
protected override void OnBank1Write(Address address, Byte value) { }
private void ToggleRam(Byte value) { var lowNibble = GetLowNibble(value); ((MbcRam)ramBanks).isEnabled = lowNibble == 0b1010; }
public void Write(Address address, Byte value, bool isCpu = false) => data[address].Write(value);