Skip to content

Commit d7c67e2

Browse files
committed
update README and add cross compilation support
1 parent 96c2981 commit d7c67e2

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

README.md

+28-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,34 @@ The project is meant to serve as an example to anyone wanting to write their ow
1010
<img src="./screens/donkey-kong.png" alt="donkey kong gameplay" width="300px"/>
1111
</div>
1212

13+
## Usage
14+
15+
Make sure you have a ROM file in the iNES format.
16+
And definitely do not download ROMs from websites such as [this one](https://www.emulatorgames.net/roms/nintendo/),
17+
because that would be illegal (I think).
18+
19+
To launch a ROM from the command line:
20+
21+
```
22+
nez path/to/rom.nes
23+
```
24+
25+
To see debug info while playing the games:
26+
27+
```
28+
nez --debug path/to/rom.nes
29+
```
30+
31+
Controls:
32+
33+
| Controller | Keyboard |
34+
|--------------------|------------|
35+
| A | Q |
36+
| B | E |
37+
| Start | Enter |
38+
| Select | X |
39+
| Up/Down/Left/Right | Arrow keys |
40+
1341
## Components
1442

1543
### The CPU: Ricoh-2A03
@@ -73,10 +101,6 @@ To play games, make sure you have a `.nes` file somewhere, and use:
73101
zig build run -- <path-to-rom>
74102
```
75103

76-
**NOTE:** Pirating ROMs is illegal, and I therefore highly recommend against going to websites like
77-
[this](https://www.emulatorgames.net/roms/nintendo/)
78-
to download ROM files and open them in nez.
79-
80104
Oh, and only NROM games are supported right now. So no contra, duck hunt, ninja gaiden, or darkwing duck, etc.
81105

82106
The CPU has about ~10k test cases for each instruction, coming from [this awesome test repository](https://github.com/TomHarte/ProcessorTests/tree/main/nes6502).

build.zig

+9-1
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@ pub fn build(b: *std.Build) !void {
2222
const optimize = b.standardOptimizeOption(.{});
2323

2424
const exe = b.addExecutable(.{
25-
.name = "raylib-test",
25+
.name = "nez",
2626
// In this case the main source file is merely a path, however, in more
2727
// complicated build scripts, this could be a generated file.
2828
.root_source_file = .{ .path = "src/main.zig" },
2929
.target = target,
3030
.optimize = optimize,
3131
});
3232

33+
if (target.isDarwin() and !target.isNative()) {
34+
if (b.sysroot == null) {
35+
@panic(" Pass --sysroot <path/to/macOS/SDK>");
36+
}
37+
exe.addSystemIncludePath(.{ .path = b.pathJoin(&.{ b.sysroot.?, "/usr/include" }) });
38+
exe.addLibraryPath(.{ .path = b.pathJoin(&.{ b.sysroot.?, "/usr/lib" }) });
39+
exe.addFrameworkPath(.{ .path = b.pathJoin(&.{ b.sysroot.?, "/System/Library/Frameworks" }) });
40+
}
3341
raylib.addTo(b, exe, target, optimize);
3442
raygui.addTo(b, exe, target, optimize);
3543

src/main.zig

+4-3
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ const DebugView = struct {
9191
const debugFlag = "--debug";
9292

9393
pub fn main() !void {
94-
var args = std.process.args();
95-
_ = args.skip();
96-
9794
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
9895
var allocator = gpa.allocator();
9996

97+
var args = try std.process.argsWithAllocator(allocator);
98+
defer args.deinit();
99+
_ = args.skip();
100+
100101
var isDebug = false;
101102
var flags: [2]?[:0]const u8 = undefined;
102103

0 commit comments

Comments
 (0)