stn := @use("../../../libraries/stn/src/lib.hb"); .{memory, buffer, log, string, math} := stn; .{inb, outb} := memory $PIT_CLOCK := 1193180 play_sound := fn(frequency: u32): void { div := 0 div = PIT_CLOCK / frequency memory.outb(0x43, 0xB6) memory.outb(0x42, @intcast(div)) memory.outb(0x42, @intcast(div >> 8)) tmp := inb(0x61) if tmp != (tmp | 3) { outb(0x61, tmp | 3) } } no_sound := fn(): void { tmp := memory.inb(0x61) & 0xFC memory.outb(0x61, tmp) } beep := fn(): void { play_sound(1000) idx := 0 loop { if idx >= 1000000 { idx += 1 } else { break } } no_sound() } main := fn(): int { no_sound() beep() return 0 }