1
0
Fork 0
forked from AbleOS/ableos

Adds a very broken (literally doesn't work) sound driver.

This commit is contained in:
peony 2024-10-16 00:32:32 +02:00
parent 15c978f90f
commit fbdf737306
8 changed files with 45 additions and 74 deletions

View file

@ -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",
]);

View file

@ -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!

View file

@ -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
}

View file

@ -0,0 +1 @@
Simple sound driver.

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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"