@@ -30,6 +30,7 @@ const SdkLibs = struct {
3030 atari5200 : ? sdk_mod.Libs = null ,
3131 a8megacart : ? sdk_mod.Libs = null ,
3232 a8xegs : ? sdk_mod.Libs = null ,
33+ eater : ? sdk_mod.Libs = null ,
3334};
3435
3536pub fn build (b : * std.Build ) void {
@@ -78,6 +79,7 @@ pub fn build(b: *std.Build) void {
7879 .{ .name = "atari5200-supercart" , .query = .{ .cpu_arch = .mos , .os_tag = .atari5200 } },
7980 .{ .name = "atari8-cart-megacart" , .query = .{ .cpu_arch = .mos , .os_tag = .atari8 } },
8081 .{ .name = "atari8-cart-xegs" , .query = .{ .cpu_arch = .mos , .os_tag = .atari8 } },
82+ .{ .name = "eater" , .query = .{ .cpu_arch = .mos , .os_tag = .eater } },
8183 }) | pd | {
8284 const libs = sdk_mod .buildPlatform (b , sdk_src_raw , pd , optimize );
8385 const dest = b .fmt ("mos-platform/{s}/lib" , .{pd .name });
@@ -114,6 +116,7 @@ pub fn build(b: *std.Build) void {
114116 if (std .mem .eql (u8 , pd .name , "atari5200-supercart" )) sdk_libs .atari5200 = libs ;
115117 if (std .mem .eql (u8 , pd .name , "atari8-cart-megacart" )) sdk_libs .a8megacart = libs ;
116118 if (std .mem .eql (u8 , pd .name , "atari8-cart-xegs" )) sdk_libs .a8xegs = libs ;
119+ if (std .mem .eql (u8 , pd .name , "eater" )) sdk_libs .eater = libs ;
117120 }
118121
119122 // Translate neslib.h and nesdoug.h from the MOS SDK into Zig modules.
@@ -620,6 +623,16 @@ pub fn build(b: *std.Build) void {
620623 run_bininfo .addFileArg (exe .getEmittedBin ());
621624 }
622625
626+ // ---- Ben Eater 6502 hello-lcd ----
627+ {
628+ const step = b .step ("eater-hello-lcd" , "Build Ben Eater 6502 LCD hello example" );
629+ const exe = addEaterExe (b , sdk_dep , sdk_src , sdk_libs .eater orelse @panic ("eater libs not built" ), optimize , "eater-hello-lcd" , "eater/hello-lcd/hello-lcd.zig" );
630+ const install = b .addInstallArtifact (exe , .{ .dest_sub_path = "eater-hello-lcd.rom" });
631+ step .dependOn (& install .step );
632+ b .getInstallStep ().dependOn (& install .step );
633+ run_bininfo .addFileArg (exe .getEmittedBin ());
634+ }
635+
623636 // ---- PC Engine color-cycle ----
624637 {
625638 const step = b .step ("pce-color-cycle" , "Build PC Engine color-cycle example" );
@@ -1854,6 +1867,49 @@ fn addLynxBllExe(
18541867 return exe ;
18551868}
18561869
1870+ fn addEaterExe (
1871+ b : * std.Build ,
1872+ sdk_dep : * std.Build.Dependency ,
1873+ sdk_src : []const u8 ,
1874+ libs : sdk_mod.Libs ,
1875+ opt : std.builtin.OptimizeMode ,
1876+ name : []const u8 ,
1877+ root_src : []const u8 ,
1878+ ) * std.Build.Step.Compile {
1879+ const target = b .resolveTargetQuery (.{ .cpu_arch = .mos , .os_tag = .eater });
1880+
1881+ const wf = b .addWriteFiles ();
1882+ const wrapper_ld = wf .add ("eater-wrapper.ld" , b .fmt (
1883+ \\SEARCH_DIR("{s}/mos-platform/eater");
1884+ \\SEARCH_DIR("{s}/mos-platform/common/ldscripts");
1885+ \\INCLUDE "{s}/mos-platform/eater/link.ld"
1886+ , .{ sdk_src , sdk_src , sdk_src }));
1887+
1888+ const exe = b .addExecutable (.{
1889+ .name = name ,
1890+ .root_module = b .createModule (.{
1891+ .root_source_file = b .path (root_src ),
1892+ .target = target ,
1893+ .optimize = opt ,
1894+ .sanitize_c = .off ,
1895+ }),
1896+ });
1897+ exe .bundle_compiler_rt = false ;
1898+ exe .lto = .full ;
1899+ exe .root_module .addIncludePath (sdk_dep .path ("mos-platform/eater" ));
1900+ exe .root_module .addIncludePath (sdk_dep .path ("mos-platform/common/include" ));
1901+ exe .root_module .linkLibrary (libs .crt );
1902+ exe .root_module .linkLibrary (libs .crt0 );
1903+ exe .root_module .linkLibrary (libs .c );
1904+ if (libs .crt0_obj ) | obj | exe .root_module .addObject (obj );
1905+ exe .forceUndefinedSymbol ("__zig_call_main_section" );
1906+ exe .forceUndefinedSymbol ("main" );
1907+ exe .setLinkerScript (wrapper_ld );
1908+ addMosPanicImport (b , exe , target , opt );
1909+
1910+ return exe ;
1911+ }
1912+
18571913fn addPceExe (
18581914 b : * std.Build ,
18591915 sdk_dep : * std.Build.Dependency ,
0 commit comments