├── .gitignore
├── .idea
└── .idea.GB.Net6
│ └── .idea
│ ├── .gitignore
│ ├── .name
│ ├── encodings.xml
│ ├── indexLayout.xml
│ └── vcs.xml
├── GB.Console
├── GB.Console.csproj
└── Program.cs
├── GB.Core
├── Controller
│ ├── Button.cs
│ ├── IButtonListener.cs
│ ├── IController.cs
│ ├── JoyPadButtonListener.cs
│ ├── Joypad.cs
│ └── NullController.cs
├── Cpu
│ ├── CpuRegisters.cs
│ ├── CpuState.cs
│ ├── Flags.cs
│ ├── InstructionSet
│ │ ├── AluFunctions.cs
│ │ ├── DataType.cs
│ │ ├── InstructionBuilder.cs
│ │ ├── OpCode.cs
│ │ ├── Operand.cs
│ │ └── Operation.cs
│ ├── InterruptManager.cs
│ ├── Processor.cs
│ └── SpeedMode.cs
├── GB.Core.csproj
├── Gameboy.cs
├── Graphics
│ ├── ColorPalette.cs
│ ├── ColorPixelFifo.cs
│ ├── CorruptionType.cs
│ ├── DmgPixelFifo.cs
│ ├── Fetcher.cs
│ ├── Gpu.cs
│ ├── GpuRegister.cs
│ ├── IDisplay.cs
│ ├── IPixelFifo.cs
│ ├── IntQueue.cs
│ ├── Lcdc.cs
│ ├── NullDisplay.cs
│ ├── Phase
│ │ ├── HBlankPhase.cs
│ │ ├── IGpuPhase.cs
│ │ ├── OamSearch.cs
│ │ ├── PixelTransfer.cs
│ │ └── VBlankPhase.cs
│ ├── SpriteBug.cs
│ └── TileAttributes.cs
├── Gui
│ ├── Emulator.cs
│ ├── GameBoyMode.cs
│ └── IRunnable.cs
├── IAddressSpace.cs
├── Memory
│ ├── BootRom.cs
│ ├── BootRomType.cs
│ ├── Cartridge
│ │ ├── Battery
│ │ │ ├── FileBattery.cs
│ │ │ ├── IBattery.cs
│ │ │ └── NullBattery.cs
│ │ ├── Cartridge.cs
│ │ ├── CartridgeType.cs
│ │ ├── CartridgeTypeExtensions.cs
│ │ ├── GameboyType.cs
│ │ ├── RTC
│ │ │ ├── Clock.cs
│ │ │ ├── IClock.cs
│ │ │ ├── RealTimeClock.cs
│ │ │ └── SystemClock.cs
│ │ └── Type
│ │ │ ├── Mbc1.cs
│ │ │ ├── Mbc2.cs
│ │ │ ├── Mbc3.cs
│ │ │ ├── Mbc5.cs
│ │ │ └── Rom.cs
│ ├── Dma.cs
│ ├── DmaAddressSpace.cs
│ ├── GameboyColorRam.cs
│ ├── Hdma.cs
│ ├── IRegister.cs
│ ├── MemoryRegisters.cs
│ ├── Mmu.cs
│ ├── Ram.cs
│ ├── RegisterType.cs
│ ├── ShadowAddressSpace.cs
│ ├── UndocumentedGbcRegisters.cs
│ └── VoidAddressSpace.cs
├── Serial
│ ├── ISerialEndpoint.cs
│ ├── NullSerialEndpoint.cs
│ └── SerialPort.cs
├── Sound
│ ├── FrequencySweep.cs
│ ├── ISoundOutput.cs
│ ├── LengthCounter.cs
│ ├── Lfsr.cs
│ ├── NullSoundOutput.cs
│ ├── PolynomialCounter.cs
│ ├── Sound.cs
│ ├── SoundMode1.cs
│ ├── SoundMode2.cs
│ ├── SoundMode3.cs
│ ├── SoundMode4.cs
│ ├── SoundModeBase.cs
│ └── VolumeEnvelope.cs
├── Timer.cs
└── Utilities.cs
├── GB.Net.sln
├── GB.WASM
├── GB.WASM.csproj
├── Interop.cs
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ └── launchSettings.json
├── Resources
│ ├── Super Mario Land (World).gb
│ └── Super Mario Land (World).sav
├── TestResources.Designer.cs
├── TestResources.resx
├── WebDisplay.cs
├── WebGame.cs
├── launch.bat
└── wwwroot
│ ├── .nojekyll
│ ├── coi-serviceworker.min.js
│ ├── index.html
│ └── main.js
├── GB.WinForms
├── GB.WinForms.csproj
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── OsSpecific
│ ├── BitmapDisplay.cs
│ └── SoundOutput.cs
└── Program.cs
├── LICENSE.md
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | [Bb]in/
3 | [Oo]bj/
4 | wwwroot/[Ll]ib/
5 |
6 | # Logs
7 | Logs/
8 |
9 | # Generated files
10 | project.lock.json
11 | .vs/
12 |
13 | # mstest test results
14 | TestResults
15 |
16 | ## Ignore Visual Studio temporary files, build results, and
17 | ## files generated by popular Visual Studio add-ons.
18 |
19 | # User-specific files
20 | *.suo
21 | *.user
22 | *.sln.docstates
23 |
24 | # Build results
25 | [Dd]ebug/
26 | [Rr]elease/
27 | x64/
28 | *_i.c
29 | *_p.c
30 | *.ilk
31 | *.meta
32 | *.obj
33 | *.pch
34 | *.pdb
35 | *.pgc
36 | *.pgd
37 | *.rsp
38 | *.sbr
39 | *.tlb
40 | *.tli
41 | *.tlh
42 | *.tmp
43 | *.log
44 | *.vspscc
45 | *.vssscc
46 | .builds
47 |
48 | # Visual C++ cache files
49 | ipch/
50 | *.aps
51 | *.ncb
52 | *.opensdf
53 | *.sdf
54 |
55 | # Visual Studio profiler
56 | *.psess
57 | *.vsp
58 | *.vspx
59 |
60 | # Guidance Automation Toolkit
61 | *.gpState
62 |
63 | # ReSharper is a .NET coding add-in
64 | _ReSharper*
65 |
66 | # NCrunch
67 | *.ncrunch*
68 | .*crunch*.local.xml
69 |
70 | # Installshield output folder
71 | [Ee]xpress
72 |
73 | # DocProject is a documentation generator add-in
74 | DocProject/buildhelp/
75 | DocProject/Help/*.HxT
76 | DocProject/Help/*.HxC
77 | DocProject/Help/*.hhc
78 | DocProject/Help/*.hhk
79 | DocProject/Help/*.hhp
80 | DocProject/Help/Html2
81 | DocProject/Help/html
82 |
83 | # Click-Once directory
84 | publish
85 |
86 | # Publish Web Output
87 | *.Publish.xml
88 |
89 | # NuGet Packages Directory
90 | packages
91 |
92 | # Windows Azure Build Output
93 | csx
94 | *.build.csdef
95 |
96 | # Windows Store app package directory
97 | AppPackages/
98 |
99 | # Others
100 | [Bb]in
101 | [Oo]bj
102 | sql
103 | TestResults
104 | [Tt]est[Rr]esult*
105 | *.Cache
106 | ClientBin
107 | [Ss]tyle[Cc]op.*
108 | ~$*
109 | *.dbmdl
110 | Generated_Code #added for RIA/Silverlight projects
111 |
112 | # Backup & report files from converting an old project file to a newer
113 | # Visual Studio version. Backup files are not needed, because we have git ;-)
114 | _UpgradeReport_Files/
115 | Backup*/
116 | UpgradeLog*.XML
117 | src/.vs/config/applicationhost.config
118 |
119 | src/OE_Tenant.Web.Host/wwwroot/Temp/Downloads
120 | src/OE_Tenant.Web.Mvc/wwwroot/Temp/Downloads
121 | src/OE_Tenant.Web.Mvc/Properties/PublishProfiles
122 | src/OE_Tenant.Web.Mvc/node_modules
123 | src/OE_Tenant.Web.Mvc/wwwroot/lib
124 | src/OE_Tenant.Web.Mvc/wwwroot/dist
125 | src/OE_Tenant.Web.Mvc/wwwroot/view-resources/Views/_Bundles
126 | src/OE_Tenant.Web.Mvc/wwwroot/view-resources/Areas/Admin/Views/_Bundles
127 | src/OE_Tenant.Web.Mvc/wwwroot/view-resources/**/*.min.*
128 | src/OE_Tenant.Web.Mvc/wwwroot/Common/**/*.min.*
129 | src/OE_Tenant.Web.Mvc/wwwroot/metronic/**/*.min.*
130 | src/OE_Tenant.Web.Mvc/package-lock.json
131 |
132 | src/OE_Tenant.Web.Public/wwwroot/lib
133 | src/OE_Tenant.Web.Public/wwwroot/dist
134 | src/OE_Tenant.Web.Public/wwwroot/Common/_Bundles
135 | src/OE_Tenant.Web.Public/wwwroot/view-resources/Views/_Bundles
136 | src/OE_Tenant.Web.Public/wwwroot/view-resources/**/*.min.*
137 | src/OE_Tenant.Web.Public/wwwroot/Common/**/*.min.*
138 | src/OE_Tenant.Web.Public/node_modules
139 | /.idea/.idea.Cbims.All
140 | /Cbims.App/Admin/wwwroot/lib
141 |
--------------------------------------------------------------------------------
/.idea/.idea.GB.Net6/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Rider ignored files
5 | /contentModel.xml
6 | /projectSettingsUpdater.xml
7 | /.idea.GB.Net6.iml
8 | /modules.xml
9 | # Editor-based HTTP Client requests
10 | /httpRequests/
11 | # Datasource local storage ignored files
12 | /dataSources/
13 | /dataSources.local.xml
14 |
--------------------------------------------------------------------------------
/.idea/.idea.GB.Net6/.idea/.name:
--------------------------------------------------------------------------------
1 | GB.Net6
--------------------------------------------------------------------------------
/.idea/.idea.GB.Net6/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/.idea.GB.Net6/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/.idea.GB.Net6/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/GB.Console/GB.Console.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net7.0-windows
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/GB.Console/Program.cs:
--------------------------------------------------------------------------------
1 | using GB.Core;
2 | using GB.Core.Controller;
3 | using GB.Core.Graphics;
4 | using GB.Core.Memory.Cartridge;
5 | using GB.Core.Serial;
6 | using GB.Core.Sound;
7 |
8 | var cartridge = Cartridge.FromFile(@"C:\temp\Super Mario Land (World).gb");
9 | if (cartridge == null)
10 | {
11 | return;
12 | }
13 |
14 | var gb = new Gameboy(cartridge, new NullDisplay(), new NullController(), new NullSoundOutput(), new NullSerialEndpoint());
15 | gb.Run(CancellationToken.None);
16 |
--------------------------------------------------------------------------------
/GB.Core/Controller/Button.cs:
--------------------------------------------------------------------------------
1 | namespace GB.Core.Controller
2 | {
3 | public sealed class Button
4 | {
5 | public static Button Right = new Button(0x01, 0x10);
6 | public static Button Left = new Button(0x02, 0x10);
7 | public static Button Up = new Button(0x04, 0x10);
8 | public static Button Down = new Button(0x08, 0x10);
9 | public static Button A = new Button(0x01, 0x20);
10 | public static Button B = new Button(0x02, 0x20);
11 | public static Button Select = new Button(0x04, 0x20);
12 | public static Button Start = new Button(0x08, 0x20);
13 |
14 | public int Mask { get; }
15 | public int Line { get; }
16 |
17 | public Button(int mask, int line)
18 | {
19 | Mask = mask;
20 | Line = line;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/GB.Core/Controller/IButtonListener.cs:
--------------------------------------------------------------------------------
1 | namespace GB.Core.Controller
2 | {
3 | public interface IButtonListener
4 | {
5 | void OnButtonPress(Button button);
6 | void OnButtonRelease(Button button);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/GB.Core/Controller/IController.cs:
--------------------------------------------------------------------------------
1 | namespace GB.Core.Controller
2 | {
3 | public interface IController
4 | {
5 | void SetButtonListener(IButtonListener listener);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/GB.Core/Controller/JoyPadButtonListener.cs:
--------------------------------------------------------------------------------
1 | using GB.Core.Cpu;
2 | using System.Collections.Concurrent;
3 |
4 | namespace GB.Core.Controller
5 | {
6 | internal sealed class JoyPadButtonListener : IButtonListener
7 | {
8 | private readonly InterruptManager _interruptManager;
9 | private readonly ConcurrentDictionary