├── Emux ├── packages.config ├── DeviceEventArgs.cs ├── App.xaml ├── Expressions │ ├── Token.cs │ ├── Terminal.cs │ └── ExpressionLexer.cs ├── SettingsBinding.cs ├── App.xaml.cs ├── Gui │ ├── Converters │ │ ├── InverseConverter.cs │ │ └── HexadecimalConverter.cs │ ├── VideoWindow.xaml │ ├── InputDialog.xaml.cs │ ├── AboutDialog.xaml.cs │ ├── InputDialog.xaml │ ├── BreakpointDialog.xaml.cs │ ├── FlagsListBox.xaml │ ├── BreakpointInfo.cs │ ├── RegisterItem.cs │ ├── BreakpointDialog.xaml │ ├── KeypadWindow.xaml.cs │ ├── KeypadWindow.xaml │ ├── TitledOverlay.xaml.cs │ ├── TitledOverlay.xaml │ ├── FlagItem.cs │ ├── AboutDialog.xaml │ ├── CheatsWindow.xaml │ ├── InstructionItem.cs │ ├── AudioMixerWindow.xaml │ ├── VideoWindow.xaml.cs │ ├── AudioMixerWindow.xaml.cs │ ├── CheatsWindow.xaml.cs │ ├── FlagsListBox.xaml.cs │ └── OptionsDialog.xaml.cs ├── WinMmTimer.cs ├── EnumDescriptions.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Settings.settings │ └── Resources.resx ├── App.config └── DeviceManager.cs ├── Emux.GameBoy ├── IGameBoyComponent.cs ├── Cpu │ ├── IClock.cs │ ├── StepEventArgs.cs │ ├── RegisterFlags.cs │ ├── InterruptFlags.cs │ ├── InterruptVector.cs │ ├── Breakpoint.cs │ ├── Z80Disassembler.cs │ ├── Z80OpCode.cs │ ├── Z80Instruction.cs │ └── RegisterBank.cs ├── Audio │ ├── IAudioChannelOutput.cs │ ├── SpuOutputSelection.cs │ ├── ISoundChannel.cs │ ├── LfsRegister.cs │ ├── VolumeEnvelope.cs │ ├── SquareSweepChannel.cs │ ├── WaveSoundChannel.cs │ └── NoiseChannel.cs ├── Timer │ ├── TimerControlFlags.cs │ └── GameBoyTimer.cs ├── Cartridge │ ├── GameBoyColorFlag.cs │ ├── IMemoryBankController.cs │ ├── IExternalMemory.cs │ ├── RomOnlyBankController.cs │ ├── StreamedExternalMemory.cs │ ├── BufferedExternalMemory.cs │ ├── MemoryBankController2.cs │ ├── MemoryBankController5.cs │ ├── MemoryBankController3.cs │ ├── MemoryBankController1.cs │ ├── ICartridge.cs │ ├── EmulatedCartridge.cs │ └── CartridgeType.cs ├── Input │ ├── GameBoyPadButton.cs │ └── GameBoyPad.cs ├── Emux.GameBoy.csproj ├── Graphics │ ├── Color.cs │ ├── IVideoOutput.cs │ ├── SpriteData.cs │ ├── LcdStatusFlags.cs │ └── LcdControlFlags.cs ├── Cheating │ ├── GamesharkCode.cs │ └── GamesharkController.cs └── Memory │ └── DmaController.cs ├── Emux.GameBoy.Tests ├── packages.config ├── Properties │ └── AssemblyInfo.cs └── Emux.GameBoy.Tests.csproj ├── Emux.sln.DotSettings ├── Emux.MonoGame ├── Content │ ├── Content.mgcb │ └── Calibri.spritefont ├── Emux.MonoGame.csproj ├── Settings.cs └── Program.cs ├── Emux.NAudio ├── Emux.NAudio.csproj ├── NAudioChannelOutput.cs └── GameBoyNAudioMixer.cs ├── README.md └── Emux.sln /Emux/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Emux.GameBoy/IGameBoyComponent.cs: -------------------------------------------------------------------------------- 1 | namespace Emux.GameBoy 2 | { 3 | public interface IGameBoyComponent 4 | { 5 | void Initialize(); 6 | 7 | void Reset(); 8 | 9 | void Shutdown(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Emux.GameBoy/Cpu/IClock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux.GameBoy.Cpu 4 | { 5 | public interface IClock 6 | { 7 | event EventHandler Tick; 8 | 9 | void Start(); 10 | 11 | void Stop(); 12 | } 13 | } -------------------------------------------------------------------------------- /Emux.GameBoy.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Emux.GameBoy/Audio/IAudioChannelOutput.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux.GameBoy.Audio 4 | { 5 | public interface IAudioChannelOutput 6 | { 7 | int SampleRate 8 | { 9 | get; 10 | } 11 | 12 | void BufferSoundSamples(Span sampleData, int offset, int length); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Emux/DeviceEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux 4 | { 5 | public class DeviceEventArgs : EventArgs 6 | { 7 | public DeviceEventArgs(GameBoy.GameBoy device) 8 | { 9 | Device = device; 10 | } 11 | 12 | public GameBoy.GameBoy Device 13 | { 14 | get; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Emux.GameBoy/Timer/TimerControlFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux.GameBoy.Timer 4 | { 5 | [Flags] 6 | public enum TimerControlFlags : byte 7 | { 8 | Clock4096Hz = 0b00, 9 | Clock262144Hz = 0b01, 10 | Clock65536Hz = 0b10, 11 | Clock16384Hz = 0b11, 12 | 13 | ClockMask = 0b11, 14 | 15 | EnableTimer = (1 << 2), 16 | } 17 | } -------------------------------------------------------------------------------- /Emux.GameBoy/Cartridge/GameBoyColorFlag.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Emux.GameBoy.Cartridge 8 | { 9 | public enum GameBoyColorFlag : byte 10 | { 11 | OriginalGameBoy = 0, 12 | SupportsColor = 0x80, 13 | GameBoyColorOnly = 0xC0, 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Emux.GameBoy/Cpu/StepEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux.GameBoy.Cpu 4 | { 5 | public delegate void StepEventHandler(object sender, StepEventArgs args); 6 | 7 | public class StepEventArgs : EventArgs 8 | { 9 | public StepEventArgs(int cycles) 10 | { 11 | Cycles = cycles; 12 | } 13 | 14 | public int Cycles 15 | { 16 | get; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Emux.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True -------------------------------------------------------------------------------- /Emux.GameBoy/Cpu/RegisterFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux.GameBoy.Cpu 4 | { 5 | /// 6 | /// Provides members for representing all the register flags known by the GameBoy CPU. 7 | /// 8 | [Flags] 9 | public enum RegisterFlags : byte 10 | { 11 | None = 0, 12 | Z = 1 << 7, 13 | N = 1 << 6, 14 | H = 1 << 5, 15 | C = 1 << 4, 16 | All = Z | N | H | C 17 | } 18 | } -------------------------------------------------------------------------------- /Emux.GameBoy/Cpu/InterruptFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux.GameBoy.Cpu 4 | { 5 | /// 6 | /// Provides valid interrupt flags used by the interrupt registers IF and IE. 7 | /// 8 | [Flags] 9 | public enum InterruptFlags : byte 10 | { 11 | None = 0, 12 | VBlank = (1 << 0), 13 | LcdStat = (1 << 1), 14 | Timer = (1 << 2), 15 | Serial = (1 << 3), 16 | Joypad = (1 << 4) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Emux.GameBoy/Cartridge/IMemoryBankController.cs: -------------------------------------------------------------------------------- 1 | namespace Emux.GameBoy.Cartridge 2 | { 3 | /// 4 | /// Provides methods for emulation of a memory bank controller (MBC). 5 | /// 6 | public interface IMemoryBankController : IGameBoyComponent 7 | { 8 | byte ReadByte(ushort address); 9 | 10 | void ReadBytes(ushort address, byte[] buffer, int bufferOffset, int length); 11 | 12 | void WriteByte(ushort address, byte value); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Emux/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Emux.GameBoy/Audio/SpuOutputSelection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux.GameBoy.Audio 4 | { 5 | [Flags] 6 | public enum SpuOutputSelection : byte 7 | { 8 | OutputChannel1ToS01 = 1 << 0, 9 | OutputChannel2ToS01 = 1 << 1, 10 | OutputChannel3ToS01 = 1 << 2, 11 | OutputChannel4ToS01 = 1 << 3, 12 | OutputChannel1ToS02 = 1 << 4, 13 | OutputChannel2ToS02 = 1 << 5, 14 | OutputChannel3ToS02 = 1 << 6, 15 | OutputChannel4ToS02 = 1 << 7, 16 | } 17 | } -------------------------------------------------------------------------------- /Emux.GameBoy/Cartridge/IExternalMemory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux.GameBoy.Cartridge 4 | { 5 | public interface IExternalMemory : IDisposable { 6 | bool IsActive 7 | { 8 | get; 9 | } 10 | 11 | void Activate(); 12 | void Deactivate(); 13 | void SetBufferSize(int length); 14 | byte ReadByte(int address); 15 | void ReadBytes(int address, byte[] buffer, int offset, int length); 16 | void WriteByte(int address, byte value); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Emux.GameBoy/Input/GameBoyPadButton.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux.GameBoy.Input 4 | { 5 | /// 6 | /// Provides members that represent all the buttons on a GameBoy device. 7 | /// 8 | [Flags] 9 | public enum GameBoyPadButton : byte 10 | { 11 | None = 0, 12 | 13 | Right = 0x01, 14 | Left = 0x02, 15 | Up = 0x04, 16 | Down = 0x08, 17 | 18 | A = 0x10, 19 | B = 0x20, 20 | Select = 0x40, 21 | Start = 0x80, 22 | } 23 | } -------------------------------------------------------------------------------- /Emux/Expressions/Token.cs: -------------------------------------------------------------------------------- 1 | namespace Emux.Expressions 2 | { 3 | public class Token 4 | { 5 | public Token(Terminal terminal, string text) 6 | { 7 | Terminal = terminal; 8 | Text = text; 9 | } 10 | 11 | public Terminal Terminal 12 | { 13 | get; 14 | } 15 | 16 | public string Text 17 | { 18 | get; 19 | } 20 | 21 | public override string ToString() 22 | { 23 | return $"{Text} ({Terminal})"; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Emux/SettingsBinding.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Data; 2 | using Emux.Properties; 3 | 4 | namespace Emux 5 | { 6 | public class SettingBinding : Binding 7 | { 8 | public SettingBinding() 9 | { 10 | Initialize(); 11 | } 12 | 13 | public SettingBinding(string path) 14 | : base(path) 15 | { 16 | Initialize(); 17 | } 18 | 19 | private void Initialize() 20 | { 21 | Source = Settings.Default; 22 | Mode = BindingMode.TwoWay; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Emux.GameBoy/Emux.GameBoy.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netstandard2.0 4 | Emux.GameBoy 5 | 0.1.0.0 6 | GameBoy emulator engine 7 | true 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Emux.GameBoy/Graphics/Color.cs: -------------------------------------------------------------------------------- 1 | namespace Emux.GameBoy.Graphics 2 | { 3 | /// 4 | /// Represents a 24 bit color. 5 | /// 6 | public struct Color 7 | { 8 | public byte R; 9 | public byte G; 10 | public byte B; 11 | 12 | public Color(byte r, byte g, byte b) 13 | { 14 | R = r; 15 | G = g; 16 | B = b; 17 | } 18 | 19 | public override string ToString() 20 | { 21 | return $"{nameof(R)}: {R}, {nameof(G)}: {G}, {nameof(B)}: {B}"; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Emux/Expressions/Terminal.cs: -------------------------------------------------------------------------------- 1 | namespace Emux.Expressions 2 | { 3 | public enum Terminal 4 | { 5 | Not, 6 | 7 | Equals, 8 | NotEquals, 9 | LessThan, 10 | LessThanOrEqual, 11 | GreaterThan, 12 | GreaterThanOrEqual, 13 | 14 | Plus, 15 | Minus, 16 | 17 | BooleanAnd, 18 | BitwiseAnd, 19 | BooleanOr, 20 | BitwiseOr, 21 | 22 | Register, 23 | Flag, 24 | 25 | Decimal, 26 | Hexadecimal, 27 | RPar, 28 | LPar 29 | } 30 | } -------------------------------------------------------------------------------- /Emux.GameBoy/Cpu/InterruptVector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Emux.GameBoy.Cpu 6 | { 7 | public enum InterruptVector : ushort 8 | { 9 | Custom1= 0x08, 10 | Custom2 = 0x10, 11 | Custom3= 0x18, 12 | Custom4= 0x20, 13 | Custom5= 0x28, 14 | Custom6= 0x30, 15 | Custom7= 0x38, 16 | VBlank = GameBoyCpu.InterruptStartAddr, 17 | LcdStat = GameBoyCpu.InterruptStartAddr + 8, // 0x48 18 | Timer = GameBoyCpu.InterruptStartAddr + 16, // 0x50 19 | Serial = GameBoyCpu.InterruptStartAddr + 24, // 0x58 20 | Joypad = GameBoyCpu.InterruptStartAddr + 32 // 0x60 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Emux.MonoGame/Content/Content.mgcb: -------------------------------------------------------------------------------- 1 | 2 | #----------------------------- Global Properties ----------------------------# 3 | 4 | /outputDir:bin/$(Platform) 5 | /intermediateDir:obj/$(Platform) 6 | /platform:DesktopGL 7 | /config: 8 | /profile:Reach 9 | /compress:False 10 | 11 | #-------------------------------- References --------------------------------# 12 | 13 | 14 | #---------------------------------- Content ---------------------------------# 15 | 16 | #begin Calibri.spritefont 17 | /importer:FontDescriptionImporter 18 | /processor:FontDescriptionProcessor 19 | /processorParam:PremultiplyAlpha=True 20 | /processorParam:TextureFormat=Compressed 21 | /build:Calibri.spritefont 22 | 23 | -------------------------------------------------------------------------------- /Emux.GameBoy/Graphics/IVideoOutput.cs: -------------------------------------------------------------------------------- 1 | namespace Emux.GameBoy.Graphics 2 | { 3 | /// 4 | /// Represents a video output device. 5 | /// 6 | public interface IVideoOutput 7 | { 8 | /// 9 | /// Renders a frame to the output device. 10 | /// 11 | /// The 24bit RGB pixel data that represents the 160x144 bitmap to render. 12 | void RenderFrame(byte[] pixelData); 13 | } 14 | 15 | /// 16 | /// Represents a virtual video output device that does not output anything. 17 | /// 18 | public sealed class EmptyVideoOutput : IVideoOutput 19 | { 20 | public void RenderFrame(byte[] pixelData) 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Emux.GameBoy/Cpu/Breakpoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux.GameBoy.Cpu 4 | { 5 | public class Breakpoint 6 | { 7 | public static readonly Predicate BreakAlways = _ => true; 8 | 9 | public Breakpoint(ushort offset) 10 | : this(offset, BreakAlways) 11 | { 12 | } 13 | 14 | public Breakpoint(ushort offset, Predicate condition) 15 | { 16 | Offset = offset; 17 | Condition = condition; 18 | } 19 | 20 | public ushort Offset 21 | { 22 | get; 23 | } 24 | 25 | public Predicate Condition 26 | { 27 | get; 28 | set; 29 | } 30 | 31 | public override string ToString() 32 | { 33 | return Offset.ToString("X4"); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Emux.MonoGame/Emux.MonoGame.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | WinExe 4 | netcoreapp2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ..\packages\NAudio.1.9.0-preview1\lib\net35\NAudio.dll 20 | 21 | 22 | -------------------------------------------------------------------------------- /Emux/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using Emux.Expressions; 3 | using Emux.GameBoy.Cpu; 4 | using Emux.Properties; 5 | 6 | namespace Emux 7 | { 8 | /// 9 | /// Interaction logic for App.xaml 10 | /// 11 | public partial class App : Application 12 | { 13 | public App() 14 | { 15 | System.Windows.Forms.Application.EnableVisualStyles(); 16 | DeviceManager = new DeviceManager(); 17 | Settings.Default.Reload(); 18 | } 19 | 20 | public new static App Current 21 | { 22 | get { return (App) Application.Current; } 23 | } 24 | 25 | public DeviceManager DeviceManager 26 | { 27 | get; 28 | } 29 | 30 | protected override void OnExit(ExitEventArgs e) 31 | { 32 | Settings.Default.Save(); 33 | base.OnExit(e); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Emux.GameBoy/Graphics/SpriteData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Emux.GameBoy.Graphics 5 | { 6 | /// 7 | /// Represents the structure of a sprite located in the Object Attribute Memory (OAM). 8 | /// 9 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 10 | public struct SpriteData 11 | { 12 | public byte Y; 13 | public byte X; 14 | public byte TileDataIndex; 15 | public SpriteDataFlags Flags; 16 | } 17 | 18 | /// 19 | /// Provides members for representing all the valid sprite atrributes. 20 | /// 21 | [Flags] 22 | public enum SpriteDataFlags : byte 23 | { 24 | None = 0, 25 | PaletteNumberMask = 0b111, 26 | TileVramBank = (1 << 3), 27 | UsePalette1 = (1 << 4), 28 | XFlip = (1 << 5), 29 | YFlip = (1 << 6), 30 | BelowBackground = (1 << 7) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Emux/Gui/Converters/InverseConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Emux.Gui.Converters 6 | { 7 | public class InverseConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (targetType != typeof(bool)) 12 | throw new NotSupportedException(); 13 | if (value == null) 14 | throw new ArgumentNullException(nameof(value)); 15 | return !((bool) value); 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | if (targetType != typeof(bool)) 21 | throw new NotSupportedException(); 22 | if (value == null) 23 | throw new ArgumentNullException(nameof(value)); 24 | return !((bool)value); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Emux.NAudio/Emux.NAudio.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netstandard2.0 4 | 5 | 6 | true 7 | 8 | 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ..\packages\NAudio.1.9.0-preview1\lib\net35\NAudio.dll 23 | 24 | 25 | -------------------------------------------------------------------------------- /Emux.GameBoy/Cheating/GamesharkCode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Emux.GameBoy.Cheating 4 | { 5 | public class GamesharkCode 6 | { 7 | public GamesharkCode(byte[] code) 8 | { 9 | RawCode = new byte[4]; 10 | Buffer.BlockCopy(code, 0, RawCode, 0, RawCode.Length); 11 | Enabled = true; 12 | } 13 | 14 | public byte CodeType 15 | { 16 | get { return RawCode[0]; } 17 | } 18 | 19 | public byte Value 20 | { 21 | get { return RawCode[1]; } 22 | } 23 | 24 | public ushort Address 25 | { 26 | get { return (ushort) (RawCode[2] | (RawCode[3] << 8)); } 27 | } 28 | 29 | public bool Enabled 30 | { 31 | get; 32 | set; 33 | } 34 | 35 | public byte[] RawCode 36 | { 37 | get; 38 | } 39 | 40 | public string Description 41 | { 42 | get; 43 | set; 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Emux/Gui/VideoWindow.xaml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Emux/Gui/InputDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Emux.Gui 4 | { 5 | /// 6 | /// Interaction logic for InputDialog.xaml 7 | /// 8 | public partial class InputDialog : Window 9 | { 10 | public InputDialog() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | public string Text 16 | { 17 | get { return ContentsTextBox.Text; } 18 | set { ContentsTextBox.Text = value; } 19 | } 20 | 21 | private void CancelButtonOnClick(object sender, RoutedEventArgs e) 22 | { 23 | DialogResult = false; 24 | Close(); 25 | } 26 | 27 | private void OkButtonOnClick(object sender, RoutedEventArgs e) 28 | { 29 | DialogResult = true; 30 | Close(); 31 | } 32 | 33 | private void InputDialogOnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) 34 | { 35 | ContentsTextBox.SelectAll(); 36 | ContentsTextBox.Focus(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Emux/Gui/AboutDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Windows; 3 | 4 | namespace Emux.Gui 5 | { 6 | /// 7 | /// Interaction logic for AboutWindow.xaml 8 | /// 9 | public partial class AboutDialog : Window 10 | { 11 | public AboutDialog() 12 | { 13 | InitializeComponent(); 14 | VersionLabel.Content = typeof(AboutDialog).Assembly.GetName().Version.ToString(); 15 | } 16 | 17 | private void SourceCodeHyperlinkOnRequestNavigate(object sender, RoutedEventArgs routedEventArgs) 18 | { 19 | Process.Start(Properties.Settings.Default.Repository); 20 | } 21 | 22 | private void LicenseHyperlinkOnRequestNavigate(object sender, RoutedEventArgs routedEventArgs) 23 | { 24 | Process.Start(Properties.Settings.Default.Repository + "/blob/master/LICENSE"); 25 | } 26 | 27 | private void NAudioHyperlinkOnRequestNavigate(object sender, RoutedEventArgs e) 28 | { 29 | Process.Start("https://github.com/naudio/NAudio"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Emux/Gui/Converters/HexadecimalConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Emux.Gui.Converters 6 | { 7 | public class HexadecimalConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (value == null) 12 | throw new ArgumentNullException(nameof(value)); 13 | if (targetType != typeof(string)) 14 | throw new NotSupportedException(); 15 | 16 | if (value is byte) 17 | return ((byte)value).ToString("X2"); 18 | if (value is ushort) 19 | return ((ushort)value).ToString("X4"); 20 | if (value is byte[]) 21 | return BitConverter.ToString((byte[]) value).Replace("-", ""); 22 | 23 | throw new NotSupportedException(); 24 | } 25 | 26 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 27 | { 28 | throw new NotImplementedException(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Emux.GameBoy/Audio/ISoundChannel.cs: -------------------------------------------------------------------------------- 1 | namespace Emux.GameBoy.Audio 2 | { 3 | public interface ISoundChannel 4 | { 5 | GameBoySpu Spu 6 | { 7 | get; 8 | } 9 | 10 | int ChannelNumber 11 | { 12 | get; 13 | } 14 | 15 | byte NR0 16 | { 17 | get; 18 | set; 19 | } 20 | 21 | byte NR1 22 | { 23 | get; 24 | set; 25 | } 26 | 27 | byte NR2 28 | { 29 | get; 30 | set; 31 | } 32 | 33 | byte NR3 34 | { 35 | get; 36 | set; 37 | } 38 | 39 | byte NR4 40 | { 41 | get; 42 | set; 43 | } 44 | 45 | bool Active 46 | { 47 | get; 48 | set; 49 | } 50 | 51 | float ChannelVolume 52 | { 53 | get; 54 | set; 55 | } 56 | 57 | IAudioChannelOutput ChannelOutput 58 | { 59 | get; 60 | set; 61 | } 62 | 63 | void ChannelStep(int cycles); 64 | } 65 | } -------------------------------------------------------------------------------- /Emux/Gui/InputDialog.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |