From 0020f3fe0c51f2282d636631912198aba2fb019b Mon Sep 17 00:00:00 2001 From: Finn Coffey Date: Fri, 1 Jul 2022 10:03:19 +1000 Subject: [PATCH 1/3] Fix font WASM function signature --- src/api/wasm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/wasm.c b/src/api/wasm.c index 32a75f605..3c278e30b 100644 --- a/src/api/wasm.c +++ b/src/api/wasm.c @@ -972,12 +972,12 @@ M3Result linkTicAPI(IM3Module module) _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "exit", "v()", &wasmtic_exit))); _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "fget", "i(ii)", &wasmtic_fget))); _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "fset", "v(iii)", &wasmtic_fset))); - _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "font", "i(*iiiiiii)", &wasmtic_font))); + _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "font", "i(*iiiiiiiii)", &wasmtic_font))); _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "key", "i(i)", &wasmtic_key))); _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "keyp", "i(iii)", &wasmtic_keyp))); _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "line", "v(ffffi)", &wasmtic_line))); // TODO: needs a lot of help for all the optional arguments - _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "map", "v(iiiiiiiiii)", &wasmtic_map))); + _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "map", "v(iiiiiiiiii)", &wasmtic_map))); _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "memcpy", "v(iii)", &wasmtic_memcpy))); _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "memset", "v(iii)", &wasmtic_memset))); _ (SuppressLookupFailure (m3_LinkRawFunction (module, "env", "mget", "i(ii)", &wasmtic_mget))); From 5b419166a37c9afdd0719f42a826c62e35966aaa Mon Sep 17 00:00:00 2001 From: Finn Coffey Date: Fri, 1 Jul 2022 10:05:40 +1000 Subject: [PATCH 2/3] Fix D and Zig bindings to font --- templates/d/src/tic80.d | 2 +- templates/zig/src/tic80.zig | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/templates/d/src/tic80.d b/templates/d/src/tic80.d index 8db926a1e..07d2793b5 100644 --- a/templates/d/src/tic80.d +++ b/templates/d/src/tic80.d @@ -63,7 +63,7 @@ void exit(); void elli(int x, int y, int a, int b, int color); void ellib(int x, int y, int a, int b, int color); bool fget(int id, ubyte flag); -int font(char* text, int x, int y, ubyte transcolors, int colorcount, int width, int height, bool fixed, int scale); +int font(char* text, int x, int y, ubyte transcolors, int colorcount, int width, int height, bool fixed, int scale, bool alt); bool fset(int id, ubyte flag, bool value); bool key(int keycode); bool keyp(int keycode, int hold, int period); diff --git a/templates/zig/src/tic80.zig b/templates/zig/src/tic80.zig index 3dc74d906..e99f3c393 100644 --- a/templates/zig/src/tic80.zig +++ b/templates/zig/src/tic80.zig @@ -111,7 +111,7 @@ pub const raw = struct { pub extern fn elli(x: i32, y: i32, a: i32, b: i32, color: i32) void; pub extern fn ellib(x: i32, y: i32, a: i32, b: i32, color: i32) void; pub extern fn fget(id: i32, flag: u8) bool; - pub extern fn font(text: [*:0]u8, x: u32, y: i32, trans_colors: ?[*]const u8, color_count: i32, char_width: i32, char_height: i32, fixed: bool, scale: i32) i32; + pub extern fn font(text: [*:0]u8, x: u32, y: i32, trans_colors: ?[*]const u8, color_count: i32, char_width: i32, char_height: i32, fixed: bool, scale: i32, alt: bool) i32; pub extern fn fset(id: i32, flag: u8, value: bool) bool; pub extern fn key(keycode: i32) bool; pub extern fn keyp(keycode: i32, hold: i32, period: i32 ) bool; @@ -297,7 +297,8 @@ const FontArgs = struct { char_width: u8, char_height: u8, fixed: bool = false, - scale: u8 = 1 + scale: u8 = 1, + alt: bool = false }; fn sliceToZString(text: []const u8, buff: [*:0]u8, maxLen: u16) void { @@ -323,7 +324,7 @@ pub fn font(text: []const u8, x: u32, y: i32, args: FontArgs) i32 { const colors = args.transparent.ptr; var buff : [MAX_STRING_SIZE:0]u8 = undefined; sliceToZString(text, &buff, MAX_STRING_SIZE); - return raw.font(&buff, x, y, colors, color_count, args.char_width, args.char_height, args.fixed, args.scale); + return raw.font(&buff, x, y, colors, color_count, args.char_width, args.char_height, args.fixed, args.scale, args.alt); } From 6aecb380f03ba35d38f17e4fc447538a5998b5a9 Mon Sep 17 00:00:00 2001 From: Finn Coffey Date: Fri, 1 Jul 2022 14:24:56 +1000 Subject: [PATCH 3/3] Fix font (and map and ttri) D function signatures --- templates/d/src/tic80.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/d/src/tic80.d b/templates/d/src/tic80.d index 07d2793b5..796cbeea5 100644 --- a/templates/d/src/tic80.d +++ b/templates/d/src/tic80.d @@ -63,12 +63,12 @@ void exit(); void elli(int x, int y, int a, int b, int color); void ellib(int x, int y, int a, int b, int color); bool fget(int id, ubyte flag); -int font(char* text, int x, int y, ubyte transcolors, int colorcount, int width, int height, bool fixed, int scale, bool alt); +int font(const char* text, int x, int y, uint* transcolors, int colorcount, int width, int height, bool fixed, int scale, bool alt); bool fset(int id, ubyte flag, bool value); bool key(int keycode); bool keyp(int keycode, int hold, int period); void line(float x0, float y0, float x1, float y1, byte color); -void map(int x, int y, int w, int h, int sx, int sy, ubyte transcolors, int colorcount, int scale, int remap); +void map(int x, int y, int w, int h, int sx, int sy, uint* transcolors, int colorcount, int scale, int remap); void memcpy(uint copyto, uint copyfrom, uint length); void memset(uint addr, ubyte value, uint length); int mget(int x, int y); @@ -93,7 +93,7 @@ void sfx(int id, int note, int octave, int duration, int channel, int volumeLeft void spr(int id, int x, int y, uint* transcolors, uint colorcount, int scale, int flip, int rotate, int w, int h); void sync(int mask, int bank, bool tocart); void trace(const char* txt, int color); -void ttri(float x1, float y1, float x2, float y2, float x3, float y3, float u1, float v1, float u2, float v2, float u3, float v3, int texsrc, ubyte transcolors, int colorcount, float z1, float z2, float z3, bool persp); +void ttri(float x1, float y1, float x2, float y2, float x3, float y3, float u1, float v1, float u2, float v2, float u3, float v3, int texsrc, uint* transcolors, int colorcount, float z1, float z2, float z3, bool persp); void tri(float x1, float y1, float x2, float y2, float x3, float y3, int color); void trib(float x1, float y1, float x2, float y2, float x3, float y3, int color); float time();