Skip to content

Commit 1c7150d

Browse files
committed
fix(zig): replace ** to @splat()
updated toolchains
1 parent 06f0a02 commit 1c7150d

18 files changed

Lines changed: 52 additions & 49 deletions

File tree

build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2850,7 +2850,7 @@ fn addSnesExe(
28502850

28512851
// Build ROM header title: pad/truncate to exactly 21 ASCII bytes.
28522852
const raw_title = cfg.title orelse if (cfg.hirom) "ZIG SNES HIROM" else "ZIG SNES HELLO";
2853-
var title_buf: [21]u8 = .{' '} ** 21;
2853+
var title_buf: [21]u8 = @splat(' ');
28542854
@memcpy(title_buf[0..@min(raw_title.len, 21)], raw_title[0..@min(raw_title.len, 21)]);
28552855
const map_mode: u8 = if (cfg.hirom) 0x21 else if (cfg.fastrom) 0x30 else 0x20;
28562856

nes/cnrom-hello/cnrom-hello.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub export fn main() callconv(.c) void {
1212
// Select CHR bank 0 (Alpha.chr) before enabling rendering.
1313
mapper.set_chr_bank(0);
1414
// Blue background: NES palette 0x11 (light blue), white text on colour 3.
15-
const bg_pal: [16]u8 = .{ 0x11, 0x00, 0x10, 0x30 } ++ .{0x00} ** 12;
15+
const bg_pal: [16]u8 = .{ 0x11, 0x00, 0x10, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
1616
neslib.pal_bright(4);
1717
neslib.pal_bg(&bg_pal);
1818
neslib.vram_adr(neslib.NTADR_A(4, 14));

nes/gtrom-color-cycle/gtrom-color-cycle.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ pub export fn main() callconv(.c) void {
1515
mapper.set_nt_bank(0);
1616
_ = mapper.set_mapper_green_led(true);
1717
_ = mapper.set_mapper_red_led(false);
18-
neslib.pal_bg(&(.{0x0f} ** 16));
18+
const pal: [16]u8 = @splat(0x0f);
19+
neslib.pal_bg(&pal);
1920
neslib.ppu_on_bg();
2021

2122
var color: u8 = 0;

nes/gtrom-hello/gtrom-hello.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub export fn main() callconv(.c) void {
1717
mapper.set_nt_bank(0);
1818
// Light the green LED on the cartridge PCB.
1919
_ = mapper.set_mapper_green_led(true);
20-
const bg_pal: [16]u8 = .{ 0x19, 0x19, 0x29, 0x39 } ++ .{0x00} ** 12;
20+
const bg_pal: [16]u8 = .{ 0x19, 0x19, 0x29, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
2121
neslib.pal_bright(4);
2222
neslib.pal_bg(&bg_pal);
2323
neslib.ppu_on_all();

nes/mmc1-hello/mmc1-hello.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub export fn main() callconv(.c) void {
1313
// Initialise MMC1: select PRG bank 0 and set vertical mirroring.
1414
mapper.set_prg_bank(0);
1515
mapper.set_mirroring(mapper.MIRROR_VERTICAL);
16-
const bg_pal: [16]u8 = .{ 0x1A, 0x1A, 0x2A, 0x3A } ++ .{0x00} ** 12;
16+
const bg_pal: [16]u8 = .{ 0x1A, 0x1A, 0x2A, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
1717
neslib.pal_bright(4);
1818
neslib.pal_bg(&bg_pal);
1919
neslib.ppu_on_all();

nes/mmc3-hello/mmc3-hello.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub export fn main() callconv(.c) void {
1414
mapper.set_prg_8000(0);
1515
mapper.set_prg_a000(1);
1616
mapper.set_mirroring(mapper.MIRROR_VERTICAL);
17-
const bg_pal: [16]u8 = .{ 0x1C, 0x1C, 0x2C, 0x3C } ++ .{0x00} ** 12;
17+
const bg_pal: [16]u8 = .{ 0x1C, 0x1C, 0x2C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
1818
neslib.pal_bright(4);
1919
neslib.pal_bg(&bg_pal);
2020
neslib.ppu_on_all();

nes/nesdoug/color-cycle/color-cycle.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const neslib = @import("neslib");
66

77
pub export fn main() callconv(.c) void {
88
neslib.ppu_off();
9-
neslib.pal_bg(&(.{0x0f} ** 16));
9+
const pal: [16]u8 = @splat(0x0f);
10+
neslib.pal_bg(&pal);
1011
neslib.ppu_on_bg();
1112

1213
var color: u8 = 0;

nes/nesdoug/full-game/full_game.zig

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -666,20 +666,20 @@ var death: u8 = 0;
666666
var map_loaded: u8 = 0;
667667
var enemy_frames: u8 = 0;
668668

669-
var coin_x: [MAX_COINS]u8 = [_]u8{0} ** MAX_COINS;
670-
var coin_y: [MAX_COINS]u8 = [_]u8{TURN_OFF} ** MAX_COINS;
671-
var coin_active: [MAX_COINS]u8 = [_]u8{0} ** MAX_COINS;
672-
var coin_room: [MAX_COINS]u8 = [_]u8{0} ** MAX_COINS;
673-
var coin_actual_x: [MAX_COINS]u8 = [_]u8{0} ** MAX_COINS;
674-
var coin_type: [MAX_COINS]u8 = [_]u8{0} ** MAX_COINS;
675-
676-
var enemy_x: [MAX_ENEMY]u8 = [_]u8{0} ** MAX_ENEMY;
677-
var enemy_y: [MAX_ENEMY]u8 = [_]u8{TURN_OFF} ** MAX_ENEMY;
678-
var enemy_active: [MAX_ENEMY]u8 = [_]u8{0} ** MAX_ENEMY;
679-
var enemy_room: [MAX_ENEMY]u8 = [_]u8{0} ** MAX_ENEMY;
680-
var enemy_actual_x: [MAX_ENEMY]u8 = [_]u8{0} ** MAX_ENEMY;
681-
var enemy_type: [MAX_ENEMY]u8 = [_]u8{0} ** MAX_ENEMY;
682-
var enemy_anim: [MAX_ENEMY]?*const anyopaque = [_]?*const anyopaque{null} ** MAX_ENEMY;
669+
var coin_x: [MAX_COINS]u8 = @splat(0);
670+
var coin_y: [MAX_COINS]u8 = @splat(TURN_OFF);
671+
var coin_active: [MAX_COINS]u8 = @splat(0);
672+
var coin_room: [MAX_COINS]u8 = @splat(0);
673+
var coin_actual_x: [MAX_COINS]u8 = @splat(0);
674+
var coin_type: [MAX_COINS]u8 = @splat(0);
675+
676+
var enemy_x: [MAX_ENEMY]u8 = @splat(0);
677+
var enemy_y: [MAX_ENEMY]u8 = @splat(TURN_OFF);
678+
var enemy_active: [MAX_ENEMY]u8 = @splat(0);
679+
var enemy_room: [MAX_ENEMY]u8 = @splat(0);
680+
var enemy_actual_x: [MAX_ENEMY]u8 = @splat(0);
681+
var enemy_type: [MAX_ENEMY]u8 = @splat(0);
682+
var enemy_anim: [MAX_ENEMY]?*const anyopaque = @splat(null);
683683

684684
// Persistent loop state
685685
var short_jump_count: u8 = 0;

nes/nesdoug/hello1/hello1.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const neslib = @import("neslib");
66

77
/// One full BG palette (4 sub-palettes × 4 colours = 16 bytes).
88
/// Sub-palette 0: black background, three greys.
9-
const bg_palette: [16]u8 = .{ 0x0f, 0x00, 0x10, 0x30 } ++ .{0x00} ** 12;
9+
const bg_palette: [16]u8 = .{ 0x0f, 0x00, 0x10, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
1010

1111
pub export fn main() callconv(.c) void {
1212
neslib.ppu_off();

nes/nesdoug/hello2/hello2.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pub const panic = @import("mos_panic");
55
const neslib = @import("neslib");
66

7-
const bg_palette: [16]u8 = .{ 0x0f, 0x00, 0x10, 0x30 } ++ .{0x00} ** 12;
7+
const bg_palette: [16]u8 = .{ 0x0f, 0x00, 0x10, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
88

99
pub export fn main() callconv(.c) void {
1010
// Sequential VRAM packet: writes "HELLO WORLD!" horizontally at tile (10, 14).

0 commit comments

Comments
 (0)