tamamo/src/overhead.zig

77 lines
2.1 KiB
Zig

const palette = @import("./palette.zig");
const sh0rk = @import("./sh0rk.zig");
const sprites = @import("./sprites.zig");
const w4 = @import("./wasm4.zig");
pub fn title() !void {
w4.m.colors._0 = .p3;
w4.m.colors._1 = .p0;
w4.text("Mara 2:\nTamamo's Fury", 28, 8);
w4.text("Press z or x", 32, 136);
w4.text("From Within 2022", 16, 152);
w4.m.colors._0 = .p0;
w4.m.colors._1 = .p1;
w4.m.colors._2 = .p2;
w4.m.colors._3 = .p3;
w4.blit(&sprites.tamamotitle, 48, 60, sprites.tamamotitle_width, sprites.tamamotitle_height, w4.BlitFlags{ .two_bits = true });
const gamepad = w4.m.gamepads[0];
if (gamepad.a or gamepad.b) {
sh0rk.state = .StoryDump;
}
}
const story = "After defeating\nthe evil mage,\nMalto was at\npeace.\n\nOne day Mara was\nwalking along the\nbeach when she saw\nthe killing stone\nwas split in two.\nTamamo-no-Mae was\nfree to wreak havoc\nacross the land.\n\nHelp us again Mara!\nSave Malto from\nTamamo-no-Mae!\n\nPress x.";
var story_idx: u16 = 0;
var story_counter: u8 = 4;
pub fn storydump() !void {
w4.m.colors._0 = .p3;
w4.m.colors._1 = .p0;
w4.text(story[0..story_idx], 4, 4);
const gamepad = w4.m.gamepads[0];
if (gamepad.b) {
sh0rk.state = .Gameplay;
palette.mist();
}
if (story_idx < story.len) {
story_counter -= 1;
if (gamepad.a) {
story_counter = 0;
}
if (story_counter == 0) {
story_idx += 1;
story_counter = 4;
w4.tone(
w4.Tone.Frequency{ .start = 280, .end = 310 },
w4.Tone.Duration{
.attack = 0,
.decay = 0,
.sustain = 2,
.release = 0,
},
w4.Tone.Volume{
.sustain = 100,
.attack = 100,
},
w4.Tone.Flags{
.channel = .triangle,
.pulse_duty = .@"1/4",
},
);
}
} else {
if (gamepad.a) {
sh0rk.state = .Gameplay;
palette.mist();
}
}
}