Skip to content

Commit

Permalink
README: updated UI and control information
Browse files Browse the repository at this point in the history
  • Loading branch information
Amjad50 committed Aug 11, 2020
1 parent baf4b2b commit 03c2807
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ This is a personal project for fun and to experience emulating hardware and conn
- [x] Mapper 2
- [x] Mapper 3
- [x] Mapper 4
- [ ] Mapper 5 (Milestone)
- [ ] Mapper 6
- [x] Mapper 7
- [ ] Mapper 8
- [x] Mapper 9
- [ ] Audio Processing Unit:
- [x] 2 Pulse wave(square)
Expand All @@ -28,6 +31,92 @@ This is a personal project for fun and to experience emulating hardware and conn
- [x] Controller:
controllable using the keyboard and controller (tested with PS4 controller)

### Interfaces
One advantage of this emulator is the great abstraction, for example, adding UI
handlers for the emulator is very easy and straight forward. All you have to do
is to write a [`UiProvider`](./nes_ui_base/src/lib.rs), and simply
use it with [`NES`](./nes_ui_base/src/nes.rs) like so:
```rust
use nes_ui_base::nes::NES;

// Provider implement trait `UiProvider`
let mut nes = NES::new("path/to/rom.nes", Provider {})?;

nes.run();
```

Using this design, I have implemented some providers which have
different purposes:

#### SFML
![screenshot SFML](images/SFML_UI.png)

[SFML][SFML] is a game development UI library, it has a good and
easy to use API and is the most performing UI in the list.

#### Advantages
1. Designed for Canvas and raw drawing, which makes it faster.
2. Has support for gamepad (only tested with PS4).

#### GTK
![screenshot SFML](images/GTK_UI.png)

[GTK][GTK] is a casual GUI library that is used to make all kinds
of applications and not designed for games.

The reason I chose to go with it is for future plans to add a
debugger, which would be a lot easier to add in this UI compared
to [SFML](#sfml)

#### Advantages
1. Ability to add buttons and menus which enable easier integration
for debuggers and anything similar.
#### Disadvantages
1. Does not offer gamepad support, but it can be added through
other external libraries.

#### TUI
[![TUI demo](https://img.youtube.com/vi/cMO89-Xljr8/0.jpg)](https://www.youtube.com/watch?v=cMO89-Xljr8)

This is just for fun, but it is actually working way better than
I expected. Check the demo.

I used [gilrs][gilrs] for gamepad support and its working very
nicely, keyboard on the other hand is not very responsive, so it
is advised to use gamepad. Also since this uses one character for
each pixel, it is advised to use the smallest font size your
terminal emulator supports. Have fun.

### Controls
In all the UI providers I followed the same controlling scheme:

#### Keyboard
| keyboard | nes controller |
| -------- | -------------- |
| J | B |
| K | A |
| U | Select |
| I | Start |
| W | Up |
| S | Down |
| A | Left |
| D | Right |

#### Gamepad
| gamepad (PS4) | nes controller |
| -------- | -------------- |
| X | B |
| O | A |
| Select | Select |
| Start | Start |
| Button Up | Up |
| Button Down | Down |
| Button Left | Left |
| Button Right | Right |

For now its static, and there is no way to change it except for
doing it in the code, TODO later.

### References
Most of the documentation for NES components can be found in the [NES dev wiki](http://wiki.nesdev.com/w/index.php/Nesdev_Wiki)

Expand All @@ -38,3 +127,6 @@ For the CPU(6502), [this](https://www.masswerk.at/6502/6502_instruction_set.html

[NES-wiki]: https://en.wikipedia.org/wiki/Nintendo_Entertainment_System
[Rust]: https://www.rust-lang.org/
[SFML]: https://www.sfml-dev.org/
[GTK]: https://www.gtk.org/
[gilrs]: https://gitlab.com/gilrs-project/gilrs
Binary file added images/GTK_UI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/SFML_UI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 03c2807

Please sign in to comment.