-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* start showcase setup * commit build.zig and zon * add blobs * add readme
- Loading branch information
Showing
38 changed files
with
295 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,7 @@ jobs: | |
|
||
- name: Build | ||
run: zig build | ||
|
||
- name: Build Showcase | ||
working-directory: showcase | ||
run: zig build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# SYCL Badge Cart Showcase | ||
|
||
Here is a number of carts people have made with the SYCL Badge. | ||
|
||
## Contributing | ||
|
||
If you'd like to share what you've made with the SYCL Badge you can PR your | ||
project. This helps the project because we can test changes to the base badge | ||
firmware against a large number of applications, and in the future we'd like to | ||
generate a website from all this info. To add your project you're going to add | ||
it as a Zig package: | ||
|
||
1. Put your code under `carts/<my_cart_name>/`. Add `sycl_badge` as a path | ||
dependency: | ||
|
||
```zig | ||
.{ | ||
.name = "blobs", | ||
.version = "0.0.0", | ||
.dependencies = .{ | ||
.sycl_badge = .{ .path = "../../.." }, | ||
}, | ||
.paths = .{ | ||
"build.zig", | ||
"build.zig.zon", | ||
"src", | ||
}, | ||
} | ||
``` | ||
|
||
2. Build your cart in the package `build.zig` and export some metadata | ||
(`author_handle` is optional): | ||
|
||
```zig | ||
const std = @import("std"); | ||
const sycl_badge = @import("sycl_badge"); | ||
pub const author_name = "Jonathan Marler"; | ||
pub const author_handle = "marler"; | ||
pub const cart_title = "blobs"; | ||
pub const description = "<TODO>: get Marler to give a description"; | ||
pub fn build(b: *std.Build) void { | ||
const optimize = b.standardOptimizeOption(.{}); | ||
const sycl_badge_dep = b.dependency("sycl_badge", .{}); | ||
const cart = sycl_badge.add_cart(sycl_badge_dep, b, .{ | ||
.name = "blobs", | ||
.optimize = optimize, | ||
.root_source_file = b.path("src/blobs.zig"), | ||
}); | ||
cart.install(b); | ||
} | ||
``` | ||
|
||
2. Add it as a path dependency of `showcase` in `build.zig.zon`: | ||
|
||
```zig | ||
.{ | ||
.name = "sycl-badge/showcase", | ||
.version = "0.0.0", | ||
.dependencies = .{ | ||
.sycl_badge = .{ | ||
.path = "..", | ||
}, | ||
//.zine = .{ | ||
// .path = "../../zine", | ||
//}, | ||
// Carts go here | ||
.zeroman = .{ .path = "carts/zeroman" }, | ||
.blobs = .{ .path = "carts/blobs" }, | ||
}, | ||
.paths = .{ | ||
"README.md", | ||
"build.zig.zon", | ||
"build.zig", | ||
"carts", | ||
}, | ||
} | ||
``` | ||
|
||
3. Fill in the table of cart dependencies in `build.zig`: | ||
|
||
```zig | ||
const carts = .{ | ||
.{ "zeroman", @import("zeroman") }, | ||
.{ "blobs", @import("blobs") }, | ||
// Right here | ||
}; | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const std = @import("std"); | ||
//const zine = @import("zine"); | ||
|
||
const root = @import("root"); | ||
// cart imports | ||
const carts = .{ | ||
.{ "zeroman", @import("zeroman") }, | ||
.{ "blobs", @import("blobs") }, | ||
}; | ||
|
||
pub fn build(b: *std.Build) void { | ||
const optimize = b.standardOptimizeOption(.{}); | ||
|
||
inline for (carts) |cart| { | ||
const cart_name = cart[0]; | ||
const cart_import = cart[1]; | ||
_ = cart_import.author_name; | ||
if (@hasDecl(cart_import, "author_handle")) | ||
_ = cart_import.author_handle; | ||
_ = cart_import.cart_title; | ||
_ = cart_import.description; | ||
const dep = b.dependency(cart_name, .{ .optimize = optimize }); | ||
b.getInstallStep().dependOn(dep.builder.getInstallStep()); | ||
} | ||
|
||
//zine.addWebsite(b, .{ | ||
// .title = "SYCL Badge Showcase", | ||
// .host_url = "https://sample.com", | ||
// .layouts_dir_path = "layouts", | ||
// .content_dir_path = "content", | ||
// .static_dir_path = "static", | ||
//}) catch unreachable; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.{ | ||
.name = "sycl-badge/showcase", | ||
.version = "0.0.0", | ||
.dependencies = .{ | ||
.sycl_badge = .{ | ||
.path = "..", | ||
}, | ||
//.zine = .{ | ||
// .path = "../../zine", | ||
//}, | ||
|
||
// Carts go here | ||
.zeroman = .{ .path = "carts/zeroman" }, | ||
.blobs = .{ .path = "carts/blobs" }, | ||
}, | ||
.paths = .{ | ||
"README.md", | ||
"build.zig.zon", | ||
"build.zig", | ||
"carts", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const std = @import("std"); | ||
const sycl_badge = @import("sycl_badge"); | ||
|
||
pub const author_name = "Jonathan Marler"; | ||
pub const author_handle = "marler"; | ||
pub const cart_title = "blobs"; | ||
pub const description = "<TODO>: get Marler to give a description"; | ||
|
||
pub fn build(b: *std.Build) void { | ||
const optimize = b.standardOptimizeOption(.{}); | ||
const sycl_badge_dep = b.dependency("sycl_badge", .{}); | ||
|
||
const cart = sycl_badge.add_cart(sycl_badge_dep, b, .{ | ||
.name = "blobs", | ||
.optimize = optimize, | ||
.root_source_file = b.path("src/blobs.zig"), | ||
}); | ||
cart.install(b); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.{ | ||
.name = "blobs", | ||
.version = "0.0.0", | ||
.dependencies = .{ | ||
.sycl_badge = .{ .path = "../../.." }, | ||
}, | ||
.paths = .{ | ||
"build.zig", | ||
"build.zig.zon", | ||
"src", | ||
}, | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const std = @import("std"); | ||
const Build = std.Build; | ||
|
||
const sycl_badge = @import("sycl_badge"); | ||
|
||
pub const author_name = "Fabio Arnold"; | ||
pub const author_handle = "CaptainHorst"; | ||
pub const cart_title = "Zeroman"; | ||
pub const description = "<TODO>: get Fabio to give a description"; | ||
|
||
pub fn build(b: *Build) void { | ||
const optimize = b.standardOptimizeOption(.{}); | ||
const sycl_badge_dep = b.dependency("sycl_badge", .{}); | ||
|
||
const cart = sycl_badge.add_cart(sycl_badge_dep, b, .{ | ||
.name = "zeroman", | ||
.optimize = optimize, | ||
.root_source_file = b.path("src/main.zig"), | ||
}); | ||
add_zeroman_assets_step(sycl_badge_dep, b, cart); | ||
cart.install(b); | ||
} | ||
|
||
fn add_zeroman_assets_step( | ||
sycl_badge_dep: *Build.Dependency, | ||
b: *Build, | ||
cart: *sycl_badge.Cart, | ||
) void { | ||
const convert = b.addExecutable(.{ | ||
.name = "convert_gfx", | ||
.root_source_file = b.path("build/convert_gfx.zig"), | ||
.target = b.host, | ||
.optimize = cart.options.optimize, | ||
.link_libc = true, | ||
}); | ||
convert.root_module.addImport("zigimg", b.dependency("zigimg", .{}).module("zigimg")); | ||
|
||
const gen_gfx = b.addRunArtifact(convert); | ||
inline for (zeroman_assets) |file| { | ||
gen_gfx.addArg("-i"); | ||
gen_gfx.addFileArg(b.path(file.path)); | ||
gen_gfx.addArg(std.fmt.comptimePrint("{}", .{file.bits})); | ||
gen_gfx.addArg(std.fmt.comptimePrint("{}", .{file.transparency})); | ||
} | ||
gen_gfx.addArg("-o"); | ||
const gfx_zig = gen_gfx.addOutputFileArg("gfx.zig"); | ||
|
||
const gfx_mod = b.addModule("gfx", .{ | ||
.root_source_file = gfx_zig, | ||
.optimize = cart.options.optimize, | ||
}); | ||
gfx_mod.addImport("cart-api", sycl_badge_dep.module("cart-api")); | ||
|
||
cart.wasm.step.dependOn(&gen_gfx.step); | ||
cart.wasm.root_module.addImport("gfx", gfx_mod); | ||
cart.cart_lib.root_module.addImport("gfx", gfx_mod); | ||
} | ||
|
||
const GfxAsset = struct { path: []const u8, bits: u4, transparency: bool }; | ||
|
||
const zeroman_assets = [_]GfxAsset{ | ||
.{ .path = "assets/door.png", .bits = 2, .transparency = false }, | ||
.{ .path = "assets/effects.png", .bits = 2, .transparency = true }, | ||
.{ .path = "assets/font.png", .bits = 2, .transparency = true }, | ||
.{ .path = "assets/gopher.png", .bits = 4, .transparency = true }, | ||
.{ .path = "assets/healthbar.png", .bits = 4, .transparency = true }, | ||
.{ .path = "assets/hurt.png", .bits = 1, .transparency = true }, | ||
.{ .path = "assets/needleman.png", .bits = 4, .transparency = false }, | ||
.{ .path = "assets/shot.png", .bits = 2, .transparency = true }, | ||
.{ .path = "assets/spike.png", .bits = 2, .transparency = true }, | ||
.{ .path = "assets/teleport.png", .bits = 2, .transparency = true }, | ||
.{ .path = "assets/title.png", .bits = 4, .transparency = false }, | ||
.{ .path = "assets/zero.png", .bits = 4, .transparency = true }, | ||
}; |
Oops, something went wrong.