diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 9963774..80ed61a 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -395,6 +395,8 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> { "-parallel", "none", "-monitor", "none", "-machine", accel, + "-audiodev", "pa,id=speaker", + "-machine", "pcspk-audiodev=speaker", "-cpu", "max", "-device", "isa-debug-exit,iobase=0xf4,iosize=0x04", ]); diff --git a/sysdata/libraries/render/src/lib.hb b/sysdata/libraries/render/src/lib.hb index 1162478..556387c 100644 --- a/sysdata/libraries/render/src/lib.hb +++ b/sysdata/libraries/render/src/lib.hb @@ -32,10 +32,7 @@ light_cyan := Color.(255, 255, 0, 255) put_pixel := mode.put_pixel put_rect := mode.put_rect put_filled_rect := mode.put_filled_rect -put_trirect := mode.put_trirect put_line := mode.put_line -put_vline := mode.put_vline -put_hline := mode.put_hline clear := mode.clear put_image := mode.put_image // thanks peony for these three! diff --git a/sysdata/libraries/render/src/software.hb b/sysdata/libraries/render/src/software.hb index 6d13efe..aa83562 100644 --- a/sysdata/libraries/render/src/software.hb +++ b/sysdata/libraries/render/src/software.hb @@ -58,9 +58,6 @@ height := fn(): int { } screenidx := fn(x: int, y: int): int { - /*if x < 0 || y < 0 || x >= ctx.width || y >= ctx.height { - return -1 - }*/ return x + ctx.width * y } @@ -164,38 +161,6 @@ put_line := fn(p0: Vec2(int), p1: Vec2(int), color: Color): void { return } -put_vline := fn(x: int, y0: int, y1: int, color: Color): void { - if y1 < y0 { - tmp := y0 - y0 = y1 - y1 = tmp - } - y := y0 - - loop if y == y1 break else { - *(ctx.buf + @inline(screenidx, x, y)) = color - y += 1 - } - - return -} - -put_hline := fn(y: int, x0: int, x1: int, color: Color): void { - if x1 < x0 { - tmp := x0 - x0 = x1 - x1 = tmp - } - x := x0 - - loop if x == x1 break else { - *(ctx.buf + @inline(screenidx, x, y)) = color - x += 1 - } - - return -} - set_height := fn(new: int): void { return } diff --git a/sysdata/libraries/sound/README.md b/sysdata/libraries/sound/README.md new file mode 100644 index 0000000..0fc1d68 --- /dev/null +++ b/sysdata/libraries/sound/README.md @@ -0,0 +1 @@ +Simple sound driver. \ No newline at end of file diff --git a/sysdata/libraries/sound/src/lib.hb b/sysdata/libraries/sound/src/lib.hb new file mode 100644 index 0000000..cf9e9c8 --- /dev/null +++ b/sysdata/libraries/sound/src/lib.hb @@ -0,0 +1,23 @@ +.{memory, log, string} := @use("../../stn/src/lib.hb") + +start := fn(): void { + memory.outb(0x61, memory.inb(0x61) | 3) + return +} + +stop := fn(): void { + memory.outb(0x61, memory.inb(0x61) & 0xFC) + return +} + +set_frequency := fn(frequency: u16): void { + dfreq := 0xFFFE & 1193180 / frequency + memory.outb(0x43, 0xB6) + fmtpage := memory.request_page(1) + log.info(string.display_int(@as(u8, @intcast(dfreq) & 0xFF), fmtpage)) + log.info(string.display_int(@as(u8, @intcast(dfreq >> 8) & 0xFF), fmtpage)) + memory.outb(0x42, @as(u8, @intcast(dfreq) & 0xFF)) + memory.outb(0x42, @as(u8, @intcast(dfreq >> 8) & 0xFF)) + //memory.outb(0x20, 0x20) + return +} \ No newline at end of file diff --git a/sysdata/programs/tests/src/main.hb b/sysdata/programs/tests/src/main.hb index be45842..1dee15a 100644 --- a/sysdata/programs/tests/src/main.hb +++ b/sysdata/programs/tests/src/main.hb @@ -1,13 +1,24 @@ .{log, string, memory, buffer} := @use("../../../libraries/stn/src/lib.hb") +sound := @use("../../../libraries/sound/src/lib.hb") service_search := fn(): void { a := "\{01}\0" @eca(3, 0, a, 2) + return +} +beep := fn(): void { + sound.set_frequency(1024) + sound.start() return } main := fn(): int { + //loop { + // memory.outb(0x61, memory.inb(0x61) & 0xFE | 1) + // memory.outb(0x61, memory.inb(0x61) & 0xFE) + //} + beep() //service_search() return 0 } \ No newline at end of file diff --git a/sysdata/programs/tetris/src/main.hb b/sysdata/programs/tetris/src/main.hb deleted file mode 100644 index f4eaa3b..0000000 --- a/sysdata/programs/tetris/src/main.hb +++ /dev/null @@ -1,28 +0,0 @@ -.{memory, log, string, buffer, math} := @use("../../../libraries/stn/src/lib.hb") -render := @use("../../../libraries/render/src/lib.hb") -Color := render.Color -Vec2 := math.Vec2 - -main := fn(): void { - input := @as(u8, 0) - output_buffer := memory.request_page(1) - input_buffer := buffer.search("XKeyboard\0") - - render.init() - - loop { - render.clear(render.black) - render.put_vline(100, 255, 128, Color.(255, 255, 255, 255)) - render.put_hline(64, 100 - 64, 164, Color.(255, 255, 255, 255)) - render.put_trirect(Vec2(int).(128, 128 + 256), Vec2(int).(256, -256), Color.(147, 147, 147, 255), Color.(107, 107, 107, 255)) - render.put_filled_rect(Vec2(int).(128 + 32, 128 + 32), Vec2(int).(256 - 64, 256 - 64), Color.(127, 127, 127, 127)) - render.sync() - - buffer.recv(input_buffer, &input, 1) - if input != 0 { - log.info(string.display_int(input, output_buffer)) - input = 0 - } - } - return -} diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index a3c2ecd..faea9a9 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -20,8 +20,8 @@ resolution = "1600x900x24" [boot.limine.ableos.modules] -# [boot.limine.ableos.modules.tests] -# path = "boot:///tests.hbf" +[boot.limine.ableos.modules.tests] +path = "boot:///tests.hbf" # [boot.limine.ableos.modules.serial_driver] # path = "boot:///serial_driver.hbf" @@ -29,17 +29,17 @@ resolution = "1600x900x24" # [boot.limine.ableos.modules.diskio_driver] # path = "boot:///diskio_driver.hbf" -[boot.limine.ableos.modules.render_example] -path = "boot:///render_example.hbf" +# [boot.limine.ableos.modules.render_example] +#path = "boot:///render_example.hbf" # [boot.limine.ableos.modules.serial_driver_test] # path = "boot:///serial_driver_test.hbf" -[boot.limine.ableos.modules.horizon] -path = "boot:///horizon.hbf" +# [boot.limine.ableos.modules.horizon] +# path = "boot:///horizon.hbf" -[boot.limine.ableos.modules.horizon_testing_program] -path = "boot:///horizon_testing_program.hbf" +# [boot.limine.ableos.modules.horizon_testing_program] +# path = "boot:///horizon_testing_program.hbf" # [boot.limine.ableos.modules.dt_buffer_test] # path = "boot:///dt_buffer_test.hbf"