|
const std = @import("std"); |
|
const math = std.math; |
|
const ct = @import("ct"); |
|
const gba = ct.gba; |
|
|
|
const square1_1 = struct { |
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .length = 0, .duty = gba.dut_2_4, .env_interval = 3, .env_dir = gba.env_dec, .env_start = 4 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub const id: [*:0]const u8 = "S1"; |
|
}; |
|
|
|
const square1_2 = struct { |
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .length = 0, .duty = gba.dut_2_4, .env_interval = 0, .env_dir = gba.env_dec, .env_start = 3 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub fn release(freq: u32, _: u8, _: u32) callconv(.C) void { |
|
(gba.EnvDutyLen{ .length = 0, .duty = gba.dut_2_4, .env_interval = 0, .env_dir = gba.env_dec, .env_start = 0 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub const id: [*:0]const u8 = "S2"; |
|
}; |
|
|
|
const square2_1 = struct { |
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .length = 0, .duty = gba.dut_2_4, .env_interval = 4, .env_dir = gba.env_dec, .env_start = 8 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
} |
|
pub const id: [*:0]const u8 = "T1"; |
|
}; |
|
|
|
const square2_2 = struct { |
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .length = 0, .duty = gba.dut_2_4, .env_interval = 0, .env_dir = gba.env_dec, .env_start = 5 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
} |
|
pub fn release(freq: u32, _: u8, _: u32) callconv(.C) void { |
|
(gba.EnvDutyLen{ .length = 0, .duty = gba.dut_2_4, .env_interval = 0, .env_dir = gba.env_dec, .env_start = 0 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
} |
|
pub const id: [*:0]const u8 = "T2"; |
|
}; |
|
|
|
const wave_1 = struct { |
|
const table = gba.wav(0x0123456789abcdeffedcba9876543210); |
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
gba.WaveRam.setTable(&table); |
|
(gba.WaveVolLen{ .length = 0, .volume = gba.vol_100 }).writeTo(gba.wave); |
|
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave); |
|
} |
|
pub fn release(freq: u32, _: u8, _: u32) callconv(.C) void { |
|
(gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave); |
|
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave); |
|
} |
|
pub const id: [*:0]const u8 = "W"; |
|
}; |
|
|
|
const noise_1 = struct { |
|
pub fn press(_: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .length = 6, .duty = gba.dut_2_4, .env_interval = 1, .env_dir = gba.env_dec, .env_start = 10 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 0, .length_enabled = 1, .trigger = 1 }).writeTo(gba.noise); |
|
} |
|
pub const id: [*:0]const u8 = "N"; |
|
}; |
|
|
|
pub fn main() void { |
|
ct.registerInstrument(square1_1, 0); |
|
ct.registerInstrument(square1_2, 0); |
|
ct.registerInstrument(square2_1, 1); |
|
ct.registerInstrument(square2_2, 1); |
|
ct.registerInstrument(wave_1, 2); |
|
ct.registerInstrument(noise_1, 3); |
|
} |