Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
Force pushed to reorder all functions
Lots of names taken from spannerism's diassembly
  • Loading branch information
snesrev committed Aug 14, 2022
0 parents commit 02add69
Show file tree
Hide file tree
Showing 110 changed files with 106,516 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/.vs/
.DS_Store
*.dSYM
/Debug
/Release
/x64
/tables/overworld/*.yaml
/tables/dungeon/*.yaml
/tables/img/
/tables/old/
/saves/*.sav
__pycache__
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 elzo_d

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Zelda3
A reimplementation of Zelda 3.

## About

This is a reverse engineered clone of Zelda 3 - A Link to the Past.

It's around 70-80kLOC of C/C++ code, and reimplements all parts of the original game. The game is playable from start to end.

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. 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.

## Compiling

Put the ROM in tables/zelda3.sfc

`cd tables`

Install python dependencies: `pip install pillow` and `pip install pyyaml`

Run `python extract_resources.py` to extract resources from the ROM into a more human readable format.

Run `python compile_resources.py` to produce .h files that gets included by the C++ code.

### Windows
Build the .sln file with Visual Studio

### Linux
`apt install libsdl2-dev`

Make sure you are in the root directory.

`clang++ -I/usr/include/SDL2 -lSDL2 -O2 -ozelda3 *.cpp snes/*.cpp`


## Usage and controls

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.

| Button | Key |
| ------ | ----------- |
| Up | Up arrow |
| Down | Down arrow |
| Left | Left arrow |
| Right | Right arrow |
| Start | Enter |
| Select | Right shift |
| A | X |
| B | Z |
| X | S |
| Y | A |
| L | D |
| R | C |


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 |
| Shift+F1-F10 | Save snapshot |
| Ctrl+F1-F10 | Replay the 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).


## License

This project is licensed under the MIT license. See 'LICENSE.txt' for details.
31 changes: 31 additions & 0 deletions Zelda3.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30717.126
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zelda3", "zelda3.vcxproj", "{CB07E01D-A194-481A-BEA1-DC13756AD150}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CB07E01D-A194-481A-BEA1-DC13756AD150}.Debug|x64.ActiveCfg = Debug|x64
{CB07E01D-A194-481A-BEA1-DC13756AD150}.Debug|x64.Build.0 = Debug|x64
{CB07E01D-A194-481A-BEA1-DC13756AD150}.Debug|x86.ActiveCfg = Debug|Win32
{CB07E01D-A194-481A-BEA1-DC13756AD150}.Debug|x86.Build.0 = Debug|Win32
{CB07E01D-A194-481A-BEA1-DC13756AD150}.Release|x64.ActiveCfg = Release|x64
{CB07E01D-A194-481A-BEA1-DC13756AD150}.Release|x64.Build.0 = Release|x64
{CB07E01D-A194-481A-BEA1-DC13756AD150}.Release|x86.ActiveCfg = Release|Win32
{CB07E01D-A194-481A-BEA1-DC13756AD150}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E47623E3-1B23-4ED7-8FC1-3E1F0AD82DD0}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 02add69

Please sign in to comment.