mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Add agnes NES emulator (very slow).
Add -W <n> -H <n> width and height options to host-sdl
This commit is contained in:
parent
2e90bfa812
commit
035608b04a
14 changed files with 3491 additions and 3 deletions
74
apps/agnes/build.zig
Normal file
74
apps/agnes/build.zig
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
const std = @import("std");
|
||||
const CrossTarget = @import("std").zig.CrossTarget;
|
||||
const Target = @import("std").Target;
|
||||
const Feature = @import("std").Target.Cpu.Feature;
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
var options = b.addOptions();
|
||||
const heapsize = b.option(u32, "heapsize", "heap size in bytes") orelse 0; // -Dheapsize=u32
|
||||
options.addOption(u32, "heapsize", heapsize);
|
||||
|
||||
const features = Target.riscv.Feature;
|
||||
var disabled_features = Feature.Set.empty;
|
||||
var enabled_features = Feature.Set.empty;
|
||||
|
||||
// disable all CPU extensions
|
||||
disabled_features.addFeature(@intFromEnum(features.a));
|
||||
disabled_features.addFeature(@intFromEnum(features.c));
|
||||
disabled_features.addFeature(@intFromEnum(features.d));
|
||||
disabled_features.addFeature(@intFromEnum(features.e));
|
||||
disabled_features.addFeature(@intFromEnum(features.f));
|
||||
// except multiply
|
||||
enabled_features.addFeature(@intFromEnum(features.m));
|
||||
|
||||
const target = b.resolveTargetQuery(.{
|
||||
.cpu_arch = Target.Cpu.Arch.riscv32,
|
||||
.os_tag = Target.Os.Tag.freestanding,
|
||||
.abi = Target.Abi.none,
|
||||
.cpu_model = .{ .explicit = &std.Target.riscv.cpu.generic_rv32},
|
||||
.cpu_features_sub = disabled_features,
|
||||
.cpu_features_add = enabled_features
|
||||
});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "agnes",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = .ReleaseFast,
|
||||
}),
|
||||
});
|
||||
exe.root_module.addOptions("buildopts", options);
|
||||
|
||||
// add zeptolibc
|
||||
const zeptolibc_dep = b.dependency("zeptolibc", .{
|
||||
.target = target,
|
||||
.optimize = .ReleaseFast,
|
||||
});
|
||||
exe.root_module.addImport("zeptolibc", zeptolibc_dep.module("zeptolibc"));
|
||||
exe.root_module.addIncludePath(zeptolibc_dep.path("include"));
|
||||
exe.root_module.addIncludePath(zeptolibc_dep.path("include/zeptolibc"));
|
||||
|
||||
exe.addCSourceFiles(.{
|
||||
.files = &.{
|
||||
"src/agnes.c",
|
||||
},
|
||||
.flags = &.{ "-Wall", "-fno-sanitize=undefined" }
|
||||
});
|
||||
exe.addIncludePath(b.path("src/"));
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
exe.addAssemblyFile(b.path("../common/crt0.S"));
|
||||
exe.setLinkerScript(b.path("../common/linker.ld"));
|
||||
exe.addIncludePath(b.path("../../common"));
|
||||
exe.addIncludePath(b.path("../common"));
|
||||
|
||||
const bin = b.addObjCopy(exe.getEmittedBin(), .{
|
||||
.format = .bin,
|
||||
});
|
||||
bin.step.dependOn(&exe.step);
|
||||
|
||||
const copy_bin = b.addInstallBinFile(bin.getOutput(), "agnes.bin");
|
||||
b.default_step.dependOn(©_bin.step);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue