Skip to content

Commit a171559

Browse files
committed
describe how to use the Lua and asm stuff
1 parent 43315e1 commit a171559

File tree

4 files changed

+122
-22
lines changed

4 files changed

+122
-22
lines changed

Lua/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
These are written for
44
[the latest revision of Bizhawk.][biz]
55

6-
[biz]: https://github.com/TASVideos/bizhawk/
6+
[biz]: //github.com/TASVideos/bizhawk/
77

88
Note that some scripts lack full support for Ocarina of Time.
99

@@ -63,7 +63,7 @@ TODO
6363
#### monitor epona.lua
6464
used to investigate [this glitch with unloading Epona.][eponaglitch]
6565

66-
[eponaglitch]: https://www.youtube.com/watch?v=kX0ZcIS8P84
66+
[eponaglitch]: //www.youtube.com/watch?v=kX0ZcIS8P84
6767

6868
#### monitor event flags.lua
6969
Monitors event flags,
@@ -78,7 +78,7 @@ using human-readable English names.
7878
Provides the function `dump_all_exits(fn)`
7979
which produces [a large csv file.][csv]
8080

81-
[csv]: https://eaguru.guru/t/_exits.csv
81+
[csv]: //eaguru.guru/t/_exits.csv
8282

8383
#### monitor misc.lua
8484
Monitors unknown regions of memory.

Lua/lib/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ where:
9999
* [two digits]: version number of a release build for the N64
100100
* GC: Gamecube
101101
* DE: Demo (includes Debug features)
102-
* DE: Debug
102+
* DB: Debug
103103
* MQ: Master Quest
104104

105105
### menus/\*

README.md

+118-18
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,112 @@
22

33
i like to muck around in the memory of these games.
44

5-
those who are more interested in the ROM will find [the binary template repo][bt]
5+
those who are more interested in the ROM may find [the binary template repo][bt]
66
more resourceful.
77

8-
[bt]: https://github.com/EntranceJew/zelda-binary-templates
8+
[bt]: //github.com/EntranceJew/zelda-binary-templates
99

10-
# Majora's Mask
10+
## Lua Scripts
11+
12+
this repo contains a ton of Lua scripts
13+
written for [the latest version of Bizhawk.][bizhawk]
14+
all the scripts you'll want to use are in the root Lua directory,
15+
and their dependencies are in further subdirectories.
16+
that means, if you want to use a script,
17+
you **must** preserve the directory structure.
18+
you **cannot,** say, extract one file from [this repo's archive][arch]
19+
and expect it to work.
20+
[bizhawk]: //github.com/tasvideos/bizhawk
21+
[arch]: //github.com/notwa/mm/archive/master.zip
22+
23+
a summary of each script is available in [the Lua README.md file,][luarm]
24+
and another for [the library files][librm] that the scripts use.
25+
26+
[luarm]: /Lua/README.md
27+
[librm]: /Lua/lib/README.md
28+
29+
of these, you probably came for `cheat menu.lua`
30+
this script will bind your L button to open an on-screen menu
31+
allowing you to control many aspects of the game.
32+
33+
![cheat menu.lua in action](/img/M_US10.2016-10-02%2019.02.17.png)
34+
35+
of immediate interest are the classic levitation and run-fast cheats,
36+
but also the menu of warps to any area and any entrance in the game.
37+
you can also change your Z-Targeting method to Hold in the 2nd
38+
page of the Progress menu, in case you forgot to change it in-game.
39+
40+
## Assembly Hacks
41+
42+
i have written a handful of ROM and RAM hacks for Majora's Mask and Ocarina of Time.
43+
these have all been written in the custom assembler syntax of
44+
[_lips,_ a MIPS assembler written in Lua.][lips]
45+
_lips_ is included in this repository; you do not need to acquire it separately.
46+
[lips]: //github.com/notwa/lips
47+
48+
you only need to run `Lua/inject.lua` in Bizhawk
49+
to run the *RAM hacks* — that is, modifications that act
50+
directly on the game's RAM while it runs; not modifying the ROM.
51+
52+
for the *ROM hacks,* you will need to set up a lot more.
53+
you will need:
54+
55+
* **bash 4.3** to run the shell scripts responsible for
56+
automatically running all the following software.
57+
58+
* **Python 3.4** to run the scripts responsible for
59+
splitting the ROM into files, and merging those files into a single ROM again.
60+
61+
* **LuaJIT 2.0** to run the *lips* assembler responsible for
62+
turning the assembly files into executable binary code.
63+
you might manage to use the *Lua 5.1* interpreter,
64+
but this is not strictly supported.
65+
66+
* **gcc 4.9** *or* **clang 3.6** to compile the programs responsible for
67+
(de)compressing the *Yaz* archive files, and for computing checksums.
68+
69+
the versions listed above are rough estimates, and newer versions of software
70+
are likely to work fine.
71+
72+
if you're on Windows, and you're not afraid of the (\*nix) console,
73+
you can set up [cygwin](//cygwin.com)
74+
to install binaries of bash, python, and gcc.
75+
then all that's left is to compile LuaJIT yourself.
76+
77+
last, but not least, you will need the approriate ROM for the ROM hack.
78+
you will probably need to change the hard-coded paths to the ROMs.
79+
*(note to self: change scripts to take the required ROM as their first argument)*
80+
81+
finally, you just run the appropriate shell scripts
82+
for the ROM hacks you want to produce. for example:
83+
```
84+
$ cd asm
85+
$ ./mm-bq
86+
zelda@srd44
87+
00-07-31 17:04:16
88+
uncompressed 0031 V00B3C000
89+
ratio: 59%
90+
compressed 0031 V00B3C000
91+
ratio: 59%
92+
compressed 1552 V02EE7040
93+
ratio: 1%
94+
bootcode: 6105
95+
crcs: 5CF5359C A893E696
96+
```
97+
98+
### blah
99+
100+
to compile the C programs, you might need to pass `-std=gnu11`. basically:
101+
```
102+
gcc -std=gnu11 -Wall -Ofast z64yaz0.c -o z64yaz0
103+
gcc -std=gnu11 -Wall -Ofast z64crc.c -o z64crc
104+
```
105+
106+
in the future, it'd be nice to only depend on LuaJIT to build ROMs.
107+
108+
cygwin's newline mangling will be the death of me.
109+
110+
# Miscellaneous notes on Majora's Mask
11111

12112
for brevity, all addresses written here are given for the original US version.
13113
refer to the spreadsheets or Lua tables for their equivalent in other versions.
@@ -33,19 +133,19 @@ some sheets have been put together to dump data in. some of them can be used to
33133
*spoilers:* no desirable results besides light arrows, if it were even possible.
34134
_potential crashes are not taken account for._
35135

36-
[eventflags]: https://docs.google.com/spreadsheets/d/181V9dR5vBROdCVB4FkljG5oz2O4gGU5OTAkoPQX9X10/edit?usp=sharing
37-
[gs_addrs]: https://docs.google.com/spreadsheets/d/1HD8yZM1Jza3O8zO28n3k_Rjwdx58RSMA03915l51oDA/edit?usp=sharing
38-
[noice]: /Lua/addrs/M/common.lua
39-
[gim]: https://docs.google.com/spreadsheets/d/17LsLbF6aRePVRxisui8azPtDBfPmjugWIf91wPuXTsY
40-
[ed]: https://docs.google.com/spreadsheets/d/1e9kDyAW0gxXHFWS-GNEtVIo-rp39wQJJOtf3B0ehhqY
136+
[eventflags]: //docs.google.com/spreadsheets/d/181V9dR5vBROdCVB4FkljG5oz2O4gGU5OTAkoPQX9X10/edit?usp=sharing
137+
[gs_addrs]: //docs.google.com/spreadsheets/d/1HD8yZM1Jza3O8zO28n3k_Rjwdx58RSMA03915l51oDA/edit?usp=sharing
138+
[noice]: /Lua/lib/addrs/M/common.lua
139+
[gim]: //docs.google.com/spreadsheets/d/17LsLbF6aRePVRxisui8azPtDBfPmjugWIf91wPuXTsY
140+
[ed]: //docs.google.com/spreadsheets/d/1e9kDyAW0gxXHFWS-GNEtVIo-rp39wQJJOtf3B0ehhqY
41141
[calc]: /Lua/exit%20calculator.lua
42-
[csv]: https://eaguru.guru/t/_exits.csv
142+
[csv]: //eaguru.guru/t/_exits.csv
43143

44144
## save files
45145

46146
save contents are mostly documented by [the save file binary templates.][savebt]
47147

48-
[savebt]: https://github.com/EntranceJew/zelda-binary-templates/tree/master/filetypes/Save
148+
[savebt]: //github.com/EntranceJew/zelda-binary-templates/tree/master/filetypes/Save
49149

50150
in the versions of the game with owl saves,
51151
regular saves are 0x100C in size, and owl saves are 0x3CA0.
@@ -56,16 +156,16 @@ each slot has one backup copy of itself, though they don't seem to be used?
56156
if a slot is corrupted, it will show up as empty in the menu.
57157

58158
the checksum is a 16-bit sum of all bytes up to that point, allowing overflows.
59-
i've written [a checksum-fixing program][chksum] in python for bizhawk savefiles.
159+
i've written [a checksum-fixing program][chksum] in Python for Bizhawk savefiles.
60160
i've also written an [010][010] Editor [script][chksum2]
61161
and its [OoT variant][chksumOoT]
62162
for properly formed save files, such as those made by nemu64.
63163

64164
owl saves always have 0x24 added to their checksum for some reason.
65165

66166
[chksum]: /chksum.py
67-
[chksum2]: https://github.com/EntranceJew/zelda-binary-templates/blob/master/scripts/FixSaveMM.1sc
68-
[chksumOoT]: https://github.com/EntranceJew/zelda-binary-templates/blob/master/scripts/FixSaveOoT.1sc
167+
[chksum2]: //github.com/EntranceJew/zelda-binary-templates/blob/master/scripts/FixSaveMM.1sc
168+
[chksumOoT]: //github.com/EntranceJew/zelda-binary-templates/blob/master/scripts/FixSaveOoT.1sc
69169
[010]: http://www.sweetscape.com/010editor/
70170

71171
bizhawk save files, at the time of writing, have the first file offset to 0x20800.
@@ -84,14 +184,14 @@ xxd -r $x > "$s"
84184
revend "$s"
85185
```
86186

87-
## save files (for download)
187+
## MM Save Files
88188

89189
because no one likes first cycle.
90190

91191
sometime i'll bother checking what the bombers/lottery codes are for these.
92192

93-
* [Bizhawk US 1.0 race file](https://eaguru.guru/t/MM%20US%20Race%20File%20for%20Bizhawk.zip )
94-
* [mupen64plus US 1.0 race file](https://eaguru.guru/t/Legend%20of%20Zelda%2C%20The%20-%20Majora%27s%20Mask%20%28U%29%20%5B%21%5D.zip)
193+
* [Bizhawk US 1.0 race file](//eaguru.guru/t/MM%20US%20Race%20File%20for%20Bizhawk.zip )
194+
* [mupen64plus US 1.0 race file](//eaguru.guru/t/Legend%20of%20Zelda%2C%20The%20-%20Majora%27s%20Mask%20%28U%29%20%5B%21%5D.zip)
95195

96196
## bitfields
97197

@@ -114,8 +214,8 @@ they appear in a different order than in save files, however.
114214
803E898C corresponds to offset 0xC.
115215
803E8994 corresponds to offset 0x10.
116216

117-
### link's status
217+
### Link's status
118218

119-
here's [an incomplete document on some of link's bitfields][linkfields] for JP 1.0.
219+
here's [an incomplete document on some of Link's bitfields][linkfields] for JP 1.0.
120220

121221
[linkfields]: /mm-bitflags.txt

img/M_US10.2016-10-02 19.02.17.png

99.7 KB
Loading

0 commit comments

Comments
 (0)