Skip to content

Commit

Permalink
Allow custom key mapping with keyconf.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
yne committed Aug 27, 2022
1 parent f1561f8 commit 9eb7da6
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 199 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ It's around 70-80kLOC of C99 code, and reimplements all parts of the original ga
You need a copy of the ROM to extract game resources (levels, images). Then once that's done, the ROM is no longer needed.

It uses the PPU and DSP implementation from [LakeSnes](https://github.com/elzo-d/LakeSnes).
Additionally, it can be configured to also run the original machine code side by side. Then the RAM state is compared after each frame, to verify that the C++ implementation is correct.
Additionally, it can be configured to also run the original machine code side by side. Then the RAM state is compared after each frame, to verify that the C implementation is correct.

I got much assistance from spannierism's Zelda 3 JP disassembly and the other ones that documented loads of function names and variables.

## Dependencies

- the `libsdl2-dev` library (ubuntu: `apt install libsdl2-dev`, macOS: `brew install sdl2`)
- a `tables/zelda3.sfc` ROM file (for asset extraction step only)
- a `tables/zelda3.sfc` USA ROM file (for asset extraction step only)
- The `pillow` and `pyyaml` python dependencies used by assets extractor

```
Expand Down Expand Up @@ -49,7 +49,7 @@ CFLAGS=-m32 LDFLAGS=-m32 make # compile and link as x86 executable

The game supports snapshots. The joypad input history is also saved in the snapshot. It's thus possible to replay a playthrough in turbo mode to verify that the game behaves correctly.

The game is run with `./zelda3` and takes an optional path to the ROM-file, which will verify for each frame that the C++ code matches the original behavior.
The game is run with `./zelda3` and takes an optional path to the ROM-file, which will verify for each frame that the C code matches the original behavior.

| Button | Key |
| ------ | ----------- |
Expand All @@ -66,20 +66,21 @@ The game is run with `./zelda3` and takes an optional path to the ROM-file, whic
| L | D |
| R | C |

This mapping can be configured using the [keyconf.yaml](keyconf.yaml) file

Additionally, the following commands are available:

| Key | Action |
| --- | --------------------- |
| W | Fill health/magic |
| E | Hard reset |
| P | Pause |
| T | Toggle replay turbo |
| K | Clear all input history from current snapshot |
| F1-F10 | Load snapshot |
| F11 | Toggle Fullscreen |
| Shift+F1-F10 | Save snapshot |
| Ctrl+F1-F10 | Replay the snapshot |
| Key | Action |
| ------- | --------------------- |
| Ctrl+R | Hard reset |
| Ctrl+P | Pause |
| Ctrl+T | Toggle replay turbo |
| Ctrl+W | Fill health/magic |
| Ctrl+K | Clear all input history from current snapshot |
| F1-F10 | Load snapshot |
| F11 | Toggle Fullscreen |
| Shift+F1-F10 | Save snapshot |
| Ctrl+F1-F10 | Replay snapshot |

Additionally, there are a bunch of included playthrough snapshots that play all dungeons of the game. You access them with the digit keys. If you want to replay the stage in turbo mode, press Ctrl+Digit (eg Ctrl-5).

Expand Down
33 changes: 33 additions & 0 deletions keyconf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SNES to Key config file
# SDL list at https://github.com/libsdl-org/SDL/blob/main/include/SDL_keycode.h
# Symbols need a 0x40000000 mask over they value

# AZERTY example
#A: 120 # 'x'
#B: 119 # 'w'
#X: 115 # 's'
#Y: 113 # 'q'
#Up: 0x40000052
#Down: 0x40000051
#Left: 0x40000050
#Right: 0x4000004F
#Select: 0x400000e5
#Start: 13 # ENTER
#L: 100 # 'd'
#R: 99 # 'c'


# default (same as removing this file)
A: 120 # 'x'
B: 122 # 'z'
X: 115 # 's'
Y: 97 # 'a'
Up: 0x40000052 # UP
Down: 0x40000051 # DOWN
Left: 0x40000050 # LEFT
Right: 0x4000004F # RIGHT
Select: 0x400000e5 # RSHIFT
Start: 13 # ENTER
L: 100 # 'd'
R: 99 # 'c'

Loading

0 comments on commit 9eb7da6

Please sign in to comment.