forked from AbleOS/ableos
Compare commits
45 commits
Author | SHA1 | Date | |
---|---|---|---|
peony | 2d2bec803f | ||
peony | 388d8c8c20 | ||
peony | 5c131eae13 | ||
peony | 7f920e2f65 | ||
peony | 97f7aa49f7 | ||
peony | 52b6272439 | ||
peony | d764dc9dd6 | ||
peony | d0f078cf10 | ||
peony | daced693fa | ||
peony | 2b13242f7f | ||
peony | d154c9fab1 | ||
peony | f31d35703d | ||
peony | e670a0ef53 | ||
peony | 376a5213ac | ||
peony | 552b613151 | ||
peony | 5a44a707eb | ||
peony | f52e3979a2 | ||
peony | e3ec34684f | ||
peony | d19f15aa5c | ||
peony | 9e0a508a6f | ||
peony | 20bb741bf1 | ||
peony | a95f1b5a4b | ||
peony | e6b972a7f3 | ||
peony | 4a0f65753e | ||
peony | d143acb8b6 | ||
peony | f65f04460b | ||
peony | 223a1c15ad | ||
peony | fe85a91548 | ||
peony | f5ffed5662 | ||
peony | 382a4f5510 | ||
peony | f023773b2e | ||
peony | b7d668c83a | ||
peony | 92bf9207b3 | ||
peony | 0da9467a0f | ||
peony | f6dd752b77 | ||
peony | 851e0bd94a | ||
peony | 38c6f6cf47 | ||
peony | 1c9ca8962e | ||
peony | 8d36083729 | ||
peony | ad351155da | ||
peony | 1039db1247 | ||
peony | fbdf737306 | ||
peony | 15c978f90f | ||
peony | 39ebaa03ba | ||
peony | de8000f596 |
|
@ -428,6 +428,11 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> {
|
|||
"-monitor", "none",
|
||||
"-machine", accel,
|
||||
"-cpu", "max",
|
||||
//"-serial", "stdio",
|
||||
//"-d", "trace:ps2_mouse_send_packet",
|
||||
//"-d", "trace:ps2_mouse_event_disabled",
|
||||
"-audiodev", "pa,id=speaker",
|
||||
"-machine", "pcspk-audiodev=speaker",
|
||||
"-device", "isa-debug-exit,iobase=0xf4,iosize=0x04",
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
- Invert
|
||||
- Surface Operations:
|
||||
- FlipH
|
||||
- Resize
|
||||
- Wrap the colour operations
|
||||
- Tile
|
||||
- Gradient overlay
|
||||
|
|
|
@ -38,9 +38,13 @@ $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_circle := mode.put_circle
|
||||
put_filled_circle := mode.put_filled_circle
|
||||
put_textured_circle := mode.put_textured_circle
|
||||
put_line := mode.put_line
|
||||
clear := mode.clear
|
||||
put_surface := mode.put_surface
|
||||
put_scaled := mode.put_scaled
|
||||
put_text := mode.put_text
|
||||
// thanks peony for these three!
|
||||
put_trirect := mode.put_trirect
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
.{math, memory, dt} := @use("../../stn/src/lib.hb");
|
||||
.{math, memory, dt, log} := @use("../../stn/src/lib.hb");
|
||||
.{Color, text} := @use("lib.hb");
|
||||
.{get_glyph, get_glyph_unicode, Font, UNC_TABLE_SIZE} := text;
|
||||
.{Vec2} := math
|
||||
|
||||
// safety: don't use before init() or you will get a memory access violation
|
||||
framebuffer := memory.dangling(Color)
|
||||
//framebuffer := memory.dangling(Color)
|
||||
|
||||
Surface := struct {
|
||||
buf: ^Color,
|
||||
|
@ -26,14 +26,38 @@ clone_surface := fn(surface: ^Surface): Surface {
|
|||
return new
|
||||
}
|
||||
|
||||
init := fn(doublebuffer: bool): Surface {
|
||||
// ! is broken, check memory.free function
|
||||
free_surface := fn(surface: Surface): void {
|
||||
return @inline(memory.free, Color, surface.buf, @intcast(surface.width * surface.height), false)
|
||||
}
|
||||
|
||||
framebuffer := @as(?^Color, null)
|
||||
|
||||
init := fn(doublebuffer: bool): ?Surface {
|
||||
framebuffer = dt.get(^Color, "framebuffer/fb0/ptr\0")
|
||||
width := dt.get(uint, "framebuffer/fb0/width\0")
|
||||
height := dt.get(uint, "framebuffer/fb0/height\0")
|
||||
|
||||
errlevel := 0
|
||||
if framebuffer == null {
|
||||
log.error("'framebuffer/fb0/ptr' is null\0")
|
||||
errlevel = 1
|
||||
}
|
||||
if width == null {
|
||||
log.error("'framebuffer/fb0/width' is null\0")
|
||||
errlevel = 1
|
||||
}
|
||||
if height == null {
|
||||
log.error("'framebuffer/fb0/height' is null\0")
|
||||
errlevel = 1
|
||||
}
|
||||
|
||||
if errlevel > 0 return null
|
||||
|
||||
if doublebuffer {
|
||||
return new_surface(width, height)
|
||||
return new_surface(@unwrap(width), @unwrap(height))
|
||||
} else {
|
||||
return .(framebuffer, width, height)
|
||||
return .(@unwrap(framebuffer), @unwrap(width), @unwrap(height))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +66,10 @@ clear := fn(surface: Surface, color: Color): void {
|
|||
}
|
||||
|
||||
sync := fn(surface: Surface): void {
|
||||
// vague safety
|
||||
if framebuffer == null {
|
||||
return
|
||||
}
|
||||
if surface.buf == framebuffer {
|
||||
return
|
||||
}
|
||||
|
@ -149,7 +177,7 @@ put_line_high := fn(surface: Surface, p0: Vec2(uint), p1: Vec2(uint), color: Col
|
|||
}
|
||||
|
||||
put_line := fn(surface: Surface, p0: Vec2(uint), p1: Vec2(uint), color: Color): void {
|
||||
if math.abs(uint, p1.y - p0.y) < math.abs(uint, p1.x - p0.x) {
|
||||
if math.abs(uint, @intcast(@as(int, @intcast(p1.y)) - @as(int, @intcast(p0.y)))) < math.abs(uint, @intcast(@as(int, @intcast(p1.x)) - @as(int, @intcast(p0.x)))) {
|
||||
if p0.x > p1.x {
|
||||
@inline(put_line_low, surface, p1, p0, color)
|
||||
} else {
|
||||
|
@ -195,7 +223,78 @@ put_surface := fn(surface: Surface, top: Surface, pos: Vec2(uint), flip_v: bool)
|
|||
}
|
||||
|
||||
if rows_to_copy == 1 {
|
||||
@inline(memory.copy, Color, src_top_cursor, dst_top_idx, top.width)
|
||||
@inline(memory.copy, Color, top_cursor, top_start_idx, @bitcast(top.width))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
put_scaled := fn(surface: Surface, source: Surface, pos: Vec2(int), size: Vec2(int)): void {
|
||||
step := Vec2(int).(1, 1)
|
||||
if size.x < 0 {
|
||||
pos.x += source.width - 1
|
||||
size.x = -size.x
|
||||
step.x = -1
|
||||
}
|
||||
if size.y < 0 {
|
||||
pos.y += source.height - 1
|
||||
size.y = -size.y
|
||||
step.y = -1
|
||||
}
|
||||
surface_idx := @inline(index, surface, pos.x, pos.y)
|
||||
|
||||
source_pos := Vec2(int).(0, 0)
|
||||
subpixel_pos := Vec2(int).(0, 0)
|
||||
step_size := size / .(source.width, source.height)
|
||||
if size.x < source.width {
|
||||
step_size.x = source.width / size.x
|
||||
}
|
||||
if size.y < source.height {
|
||||
step_size.y = source.height / size.y
|
||||
}
|
||||
one_up_step := size / (size - step_size * .(source.width, source.height))
|
||||
|
||||
pos = .(0, 0)
|
||||
loop if pos.y >= size.y break else {
|
||||
loop if pos.x >= size.x break else {
|
||||
*surface_idx = *@inline(index, source, source_pos.x, source_pos.y)
|
||||
surface_idx += step.x
|
||||
|
||||
if size.x < source.width {
|
||||
if source_pos.x % one_up_step.x == 0 {
|
||||
source_pos.x += 1
|
||||
}
|
||||
source_pos.x += step_size.x
|
||||
} else {
|
||||
subpixel_pos.x += 1
|
||||
if subpixel_pos.x > step_size.x | source_pos.x % one_up_step.x == 0 & subpixel_pos.x >= step_size.x {
|
||||
source_pos.x += 1
|
||||
subpixel_pos.x = 0
|
||||
}
|
||||
}
|
||||
|
||||
pos.x += 1
|
||||
}
|
||||
|
||||
if size.y < source.height {
|
||||
if source_pos.y % one_up_step.y == 0 {
|
||||
source_pos.y += 1
|
||||
}
|
||||
source_pos.y += step_size.y
|
||||
} else {
|
||||
subpixel_pos.y += 1
|
||||
if subpixel_pos.y > step_size.y | source_pos.y % one_up_step.y == 0 & subpixel_pos.y >= step_size.y {
|
||||
source_pos.y += 1
|
||||
subpixel_pos.y = 0
|
||||
}
|
||||
}
|
||||
|
||||
surface_idx += surface.width * step.y - size.x * step.x
|
||||
|
||||
source_pos.x = 0
|
||||
pos.x = 0
|
||||
|
||||
pos.y += 1
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -251,7 +350,89 @@ put_hline := fn(surface: Surface, y: uint, x0: uint, x1: uint, color: Color): vo
|
|||
|
||||
return
|
||||
}
|
||||
utf8_len_table := [u8].(0, 0, 2, 3)
|
||||
|
||||
put_circle := fn(surface: Surface, pos: Vec2(uint), radius: uint, color: Color): void {
|
||||
x := 0
|
||||
y := radius
|
||||
error := @as(int, 3) - @as(int, @intcast(2 * radius));
|
||||
*@inline(indexptr, surface, pos.x + radius, pos.y) = color;
|
||||
*@inline(indexptr, surface, pos.x - radius, pos.y) = color;
|
||||
*@inline(indexptr, surface, pos.x, pos.y + radius) = color;
|
||||
*@inline(indexptr, surface, pos.x, pos.y - radius) = color
|
||||
|
||||
loop if y < x break else {
|
||||
x += 1
|
||||
|
||||
if error > 0 {
|
||||
y -= 1
|
||||
error += 4 * (@as(int, @intcast(x)) - @as(int, @intcast(y))) + 10
|
||||
} else {
|
||||
error += 4 * @intcast(x) + 6
|
||||
};
|
||||
*@inline(indexptr, surface, pos.x + x, pos.y + y) = color;
|
||||
*@inline(indexptr, surface, pos.x + y, pos.y + x) = color;
|
||||
*@inline(indexptr, surface, pos.x - x, pos.y + y) = color;
|
||||
*@inline(indexptr, surface, pos.x - y, pos.y + x) = color;
|
||||
*@inline(indexptr, surface, pos.x + x, pos.y - y) = color;
|
||||
*@inline(indexptr, surface, pos.x + y, pos.y - x) = color;
|
||||
*@inline(indexptr, surface, pos.x - x, pos.y - y) = color;
|
||||
*@inline(indexptr, surface, pos.x - y, pos.y - x) = color
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
put_filled_circle := fn(surface: Surface, pos: Vec2(uint), radius: uint, color: Color): void {
|
||||
x := 0
|
||||
y := radius
|
||||
error := @as(int, 3) - @as(int, @intcast(2 * radius))
|
||||
@inline(put_hline, surface, pos.y - x, pos.x - radius, pos.x + radius, color);
|
||||
*@inline(indexptr, surface, pos.x, pos.y + radius) = color;
|
||||
*@inline(indexptr, surface, pos.x, pos.y - radius) = color
|
||||
|
||||
loop if y < x break else {
|
||||
x += 1
|
||||
|
||||
if error > 0 {
|
||||
@inline(put_hline, surface, pos.y + y, pos.x - x, pos.x + x, color)
|
||||
@inline(put_hline, surface, pos.y - y, pos.x - x, pos.x + x, color)
|
||||
y -= 1
|
||||
error += 4 * (@as(int, @intcast(x)) - @as(int, @intcast(y))) + 10
|
||||
} else {
|
||||
error += 4 * @intcast(x) + 6
|
||||
}
|
||||
@inline(put_hline, surface, pos.y + x, pos.x - y, pos.x + y, color)
|
||||
@inline(put_hline, surface, pos.y - x, pos.x - y, pos.x + y, color)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
put_textured_circle := fn(surface: Surface, source: Surface, source_pos: Vec2(uint), pos: Vec2(uint), radius: uint): void {
|
||||
x := 0
|
||||
y := radius
|
||||
error := @as(int, 3) - @as(int, @intcast(2 * radius))
|
||||
@inline(memory.copy, Color, @inline(indexptr, source, source_pos.x - y, source_pos.y), @inline(indexptr, surface, pos.x - y, pos.y), 2 * y);
|
||||
*@inline(indexptr, surface, pos.x, pos.y + y) = *@inline(indexptr, source, source_pos.x, source_pos.y + y);
|
||||
*@inline(indexptr, surface, pos.x, pos.y - y) = *@inline(indexptr, source, source_pos.x, source_pos.y - y)
|
||||
|
||||
loop if y < x break else {
|
||||
x += 1
|
||||
|
||||
if error > 0 {
|
||||
@inline(memory.copy, Color, @inline(indexptr, source, source_pos.x - x, source_pos.y + y), @inline(indexptr, surface, pos.x - x, pos.y + y), 2 * x)
|
||||
@inline(memory.copy, Color, @inline(indexptr, source, source_pos.x - x, source_pos.y - y), @inline(indexptr, surface, pos.x - x, pos.y - y), 2 * x)
|
||||
y -= 1
|
||||
error += 4 * (@as(int, @intcast(x)) - @as(int, @intcast(y))) + 10
|
||||
} else {
|
||||
error += 4 * @intcast(x) + 6
|
||||
}
|
||||
@inline(memory.copy, Color, @inline(indexptr, source, source_pos.x - y, source_pos.y + x), @inline(indexptr, surface, pos.x - y, pos.y + x), 2 * y)
|
||||
@inline(memory.copy, Color, @inline(indexptr, source, source_pos.x - y, source_pos.y - x), @inline(indexptr, surface, pos.x - y, pos.y - x), 2 * y)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
put_text := fn(surface: Surface, font: Font, pos: Vec2(uint), color: Color, str: ^u8): void {
|
||||
cursor := Vec2(uint).(pos.x, pos.y)
|
||||
|
|
1
sysdata/libraries/sound/README.md
Normal file
1
sysdata/libraries/sound/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
Simple sound driver.
|
23
sysdata/libraries/sound/src/lib.hb
Normal file
23
sysdata/libraries/sound/src/lib.hb
Normal 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
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
.{string} := @use("../../stn/src/lib.hb")
|
||||
|
||||
get := fn($Expr: type, query: ^u8): Expr {
|
||||
get := fn($Expr: type, query: ^u8): ?Expr {
|
||||
return @eca(3, 5, query, @inline(string.length, query))
|
||||
}
|
|
@ -28,6 +28,10 @@ main := fn(): int {
|
|||
win_buff := buffer.create("XHorizon\0")
|
||||
|
||||
screen := render.init(true)
|
||||
if screen == null {
|
||||
log.error("Screen could not be initialized!\0")
|
||||
return 1
|
||||
}
|
||||
|
||||
// Clear the screen to black.
|
||||
render.clear(screen, render.black)
|
||||
|
@ -72,6 +76,26 @@ main := fn(): int {
|
|||
// get input events from drivers via intouch
|
||||
// key_event := intouch.recieve_key_event();
|
||||
// log.info("before mouse event check\0");
|
||||
{
|
||||
// Note: MLokis, this inline halts the compiler forever
|
||||
// mouse_event := @inline(intouch.recieve_mouse_event)
|
||||
// Note: MLokis, this function returns null unless the mouse is moving
|
||||
mouse_event := intouch.recieve_mouse_event()
|
||||
//
|
||||
|
||||
if mouse_event != null {
|
||||
log.warn("Mouse event recieved\0")
|
||||
|
||||
mouse_x += mouse_event.x_change
|
||||
mouse_y += mouse_event.y_change
|
||||
set_label_text(text_label, "Mouse Moved\0")
|
||||
}
|
||||
// render mouse
|
||||
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
|
||||
// Send events to focused window
|
||||
}
|
||||
|
||||
// TODO: Get windows out of a collection and iter through
|
||||
|
||||
if false {
|
||||
// Scroll bar :ThumbsUp:
|
||||
|
|
12
sysdata/programs/ps2_driver/README.md
Normal file
12
sysdata/programs/ps2_driver/README.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Unified PS/2 Driver
|
||||
|
||||
Te entire thing is heavily documented with comments because I'm not sure how else to make this understandable.
|
||||
|
||||
## !!Assumptions!!
|
||||
Anyone who works on this should work to keep this list as small as possible/remove as many of these as possible.
|
||||
- Bit 5 of the response form 0x64 indicates which port the data is coming from. (Not true on all systems)
|
||||
- A parity or timeout error never occurs.
|
||||
- PS/2 controller exists.
|
||||
- Both PS/2 ports being broken doesn't need handling.
|
||||
- One PS/2 port being broken doesn't need special attention.
|
||||
- PS/2 controller doesn't need to perform a self-check.
|
11
sysdata/programs/ps2_driver/meta.toml
Normal file
11
sysdata/programs/ps2_driver/meta.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "ps2_driver"
|
||||
authors = ["Peony"]
|
||||
|
||||
[dependants.libraries]
|
||||
|
||||
[dependants.binaries]
|
||||
hblang.version = "1.0.0"
|
||||
|
||||
[build]
|
||||
command = "hblang src/main.hb"
|
108
sysdata/programs/ps2_driver/src/main.hb
Normal file
108
sysdata/programs/ps2_driver/src/main.hb
Normal file
|
@ -0,0 +1,108 @@
|
|||
.{memory, log} := @use("../../../libraries/stn/src/lib.hb")
|
||||
|
||||
DeviceID := struct {value: u16}
|
||||
|
||||
Mouse3Button := DeviceID.(0x0)
|
||||
MouseScrollwheel := DeviceID.(0x3)
|
||||
Mouse5Button := DeviceID.(0x4)
|
||||
Spacesaver := DeviceID.(0xAB84)
|
||||
Keyboard122Key := DeviceID.(0xAB86)
|
||||
KeyboardJapaneseG := DeviceID.(0xAB90)
|
||||
KeyboardJapanesep := DeviceID.(0xAB91)
|
||||
KeyboardJapaneseA := DeviceID.(0xAB92)
|
||||
KeyboardNCDSun := DeviceID.(0xACA1)
|
||||
NoDevice := DeviceID.(0xFFFF)
|
||||
|
||||
Port := struct {exists: bool, device: DeviceID, command_queued: bool, command_queue: u8}
|
||||
|
||||
check_bit := fn(value: u8, bit: u8, state: u8): bool {
|
||||
return value >> bit & 1 == state
|
||||
}
|
||||
|
||||
ports := [Port].(.(true, NoDevice, false, 0xFF), .(true, NoDevice, false, 0xFF))
|
||||
|
||||
initialize_controller := fn(): void {
|
||||
memory.outb(0x64, 0xAD)
|
||||
memory.outb(0x64, 0xA7)
|
||||
//Disables ports to make sure that they won't interfere with the setup process.
|
||||
|
||||
loop if (memory.inb(0x64) & 1) == 0 break else memory.inb(0x60)
|
||||
//Flushes any output because apperantly that might interfere with stuff.
|
||||
|
||||
memory.outb(0x64, 0xA8)
|
||||
//Enables port 2.
|
||||
memory.outb(0x64, 0x20)
|
||||
//Gimme configuration byte.
|
||||
loop if (memory.inb(0x64) & 1) == 1 break
|
||||
ports[1].exists = @inline(check_bit, memory.inb(0x60), 5, 0)
|
||||
if ports[1].exists {
|
||||
memory.outb(0x64, 0xA7)
|
||||
}
|
||||
|
||||
loop if (memory.inb(0x64) & 1) == 0 break else memory.inb(0x60)
|
||||
//Flushes any output because apperantly that might interfere with stuff.
|
||||
|
||||
memory.outb(0x64, 0xAB)
|
||||
loop if (memory.inb(0x64) & 1) == 1 break
|
||||
ports[0].exists = memory.inb(0x60) == 0x0
|
||||
//Test port 1.
|
||||
|
||||
if ports[1].exists {
|
||||
memory.outb(0x64, 0xA9)
|
||||
loop if (memory.inb(0x64) & 1) == 1 break
|
||||
ports[1].exists = memory.inb(0x60) == 0x0
|
||||
}
|
||||
//Test port 2.
|
||||
|
||||
if (ports[0].exists | ports[1].exists) == false {
|
||||
log.error("No ports detected! No input will be processed! Cannot handle this!\0")
|
||||
}
|
||||
|
||||
if ports[0].exists {
|
||||
memory.outb(0x64, 0xAE)
|
||||
//Enables port 1.
|
||||
ports[0].command_queued = true
|
||||
}
|
||||
if ports[1].exists {
|
||||
memory.outb(0x64, 0xA8)
|
||||
//Enables port 2.
|
||||
ports[1].command_queued = true
|
||||
}
|
||||
}
|
||||
|
||||
handle_input := fn(port: uint, input: u8): void {
|
||||
}
|
||||
|
||||
main := fn(): void {
|
||||
loop {
|
||||
port_info := memory.inb(0x64)
|
||||
//Enables port 1.
|
||||
if (port_info & 0x40) > 0 {
|
||||
log.error("Timeout error! Cannot handle these!\0")
|
||||
}
|
||||
if (port_info & 0x80) > 0 {
|
||||
log.error("Parity error! Cannot handle these!\0")
|
||||
}
|
||||
|
||||
if (port_info & 1) == 0 {
|
||||
if ports[0].exists & ports[0].command_queued {
|
||||
memory.outb(0x60, ports[0].command_queue)
|
||||
ports[0].command_queued = false
|
||||
}
|
||||
if ports[1].exists & ports[1].command_queued {
|
||||
memory.outb(0x64, 0xD4)
|
||||
memory.outb(0x60, ports[1].command_queue)
|
||||
ports[1].command_queued = false
|
||||
}
|
||||
}
|
||||
|
||||
port := 0
|
||||
if ports[1].exists {
|
||||
port = port_info >> 5 & 1
|
||||
}
|
||||
|
||||
if ports[port].exists {
|
||||
@inline(handle_input, port, memory.inb(0x60))
|
||||
}
|
||||
}
|
||||
}
|
72
sysdata/programs/render_example/src/examples/cube.hb
Normal file
72
sysdata/programs/render_example/src/examples/cube.hb
Normal file
|
@ -0,0 +1,72 @@
|
|||
.{Vec2} := @use("../../../../libraries/stn/src/lib.hb").math;
|
||||
.{log, string, memory} := @use("../../../../libraries/stn/src/lib.hb");
|
||||
.{Color, Surface} := @use("../../../../libraries/render/src/lib.hb")
|
||||
render := @use("../../../../libraries/render/src/lib.hb")
|
||||
|
||||
Face := struct {a: uint, b: uint, c: uint, mode: u8, color: Color, texture: ^Surface}
|
||||
WIREFRAME := @as(u8, 0)
|
||||
FILLED := @as(u8, 1)
|
||||
TEXTURED := @as(u8, 2)
|
||||
|
||||
Vec3 := struct {x: int, y: int, z: int}
|
||||
|
||||
vertecies := [Vec3].(.(-1, -1, -1), .(1, -1, -1), .(1, 1, -1), .(-1, 1, -1), .(-1, -1, 1), .(1, -1, 1), .(1, 1, 1), .(-1, 1, 1))
|
||||
projected := @as([Vec3; 8], idk)
|
||||
|
||||
faces := [Face].(Face.(0, 1, 2, WIREFRAME, .(255, 0, 0, 255), null))
|
||||
|
||||
d := @as(int, 1)
|
||||
|
||||
example := fn(): void {
|
||||
screen := render.init(true)
|
||||
|
||||
unit := @as(int, 0)
|
||||
half_width := @as(int, @intcast(screen.width / 2))
|
||||
half_height := @as(int, @intcast(screen.height / 2))
|
||||
if screen.width < screen.height {
|
||||
unit = @intcast(half_width / 2)
|
||||
} else {
|
||||
unit = @intcast(half_height / 2)
|
||||
}
|
||||
|
||||
format_page := @as([u8; 1024], idk)
|
||||
loop {
|
||||
index := 0
|
||||
loop if index == 8 break else {
|
||||
vertex := vertecies[index]
|
||||
vertex = .(vertex.x * unit, vertex.y * unit, vertex.z * unit + unit)
|
||||
|
||||
vertex = .(vertex.x * d / (vertex.z / unit + d) + half_width, vertex.y * d / (vertex.z / unit + d) + half_height, vertex.z)
|
||||
projected[index] = vertex
|
||||
|
||||
log.info(string.display_int(vertex.x, @bitcast(&format_page), 10))
|
||||
log.info(string.display_int(vertex.y, @bitcast(&format_page), 10))
|
||||
|
||||
index += 1
|
||||
}
|
||||
|
||||
index = 0
|
||||
render.clear(screen, render.black)
|
||||
loop if index == 1 break else {
|
||||
face := faces[index]
|
||||
|
||||
a := projected[face.a]
|
||||
b := projected[face.b]
|
||||
c := projected[face.c]
|
||||
|
||||
if face.mode == WIREFRAME {
|
||||
//render.put_tri(screen, .(@intcast(0), @intcast(0)), .(@intcast(512), @intcast(128)), .(@intcast(256), @intcast(256)), .(255, 0, 0, 255))
|
||||
//face.color)
|
||||
}
|
||||
|
||||
index += 1
|
||||
}
|
||||
//render.put_line(screen, .(1, 1), .(512, 128), .(255, 0, 0, 255))
|
||||
//render.put_line(screen, .(256, 256), .(512, 128), .(255, 0, 0, 255))
|
||||
render.put_tri(screen, .(1, 1), .(512, 128), .(256, 256), .(255, 0, 0, 255))
|
||||
|
||||
//render.put_filled_tri(screen, .(128, 256), .(512, 512), .(10, 10), .(255, 255, 255, 255))
|
||||
render.sync(screen)
|
||||
}
|
||||
return
|
||||
}
|
26
sysdata/programs/render_example/src/examples/gravity.hb
Normal file
26
sysdata/programs/render_example/src/examples/gravity.hb
Normal file
|
@ -0,0 +1,26 @@
|
|||
.{Vec2, sin_i, cos_i} := @use("../../../../libraries/stn/src/lib.hb").math
|
||||
render := @use("../../../../libraries/render/src/lib.hb")
|
||||
|
||||
able_bmp := @embed("./assets/able.bmp")
|
||||
mini_bmp := @embed("./assets/mini.bmp")
|
||||
|
||||
example := fn(): void {
|
||||
able := render.image.surface_from_bmp(@bitcast(&able_bmp))
|
||||
mini := render.image.surface_from_bmp(@bitcast(&mini_bmp))
|
||||
|
||||
angle := @as(int, 0)
|
||||
|
||||
screen := render.init(true)
|
||||
|
||||
loop {
|
||||
render.clear(screen, render.black)
|
||||
render.put_filled_circle(screen, .(screen.width / 2, screen.height / 2), 128, render.light_yellow)
|
||||
render.put_circle(screen, .(screen.width / 2, screen.height / 2), 256, render.light_blue)
|
||||
render.put_textured_circle(screen, able, .(able.width / 2, able.height / 2), .(screen.width / 2 + @intcast(sin_i(angle, @as(int, 256))), screen.height / 2 + @intcast(cos_i(angle, @as(int, 256)))), able.width / 2 - 1)
|
||||
render.put_textured_circle(screen, mini, .(mini.width / 2, mini.height / 2), .(screen.width / 2 + @intcast(sin_i(angle + 180, @as(int, 256))), screen.height / 2 + @intcast(cos_i(angle + 180, @as(int, 256)))), mini.width / 2 - 1)
|
||||
render.sync(screen)
|
||||
|
||||
angle += 1
|
||||
}
|
||||
return
|
||||
}
|
17
sysdata/programs/render_example/src/examples/scale.hb
Normal file
17
sysdata/programs/render_example/src/examples/scale.hb
Normal file
|
@ -0,0 +1,17 @@
|
|||
.{Vec2} := @use("../../../../libraries/stn/src/lib.hb").math
|
||||
render := @use("../../../../libraries/render/src/lib.hb")
|
||||
|
||||
bmp_1 := @embed("./assets/able.bmp")
|
||||
bmp_2 := @embed("./assets/mini.bmp")
|
||||
|
||||
example := fn(): void {
|
||||
screen := render.init(true)
|
||||
|
||||
image := render.image.surface_from_bmp(@bitcast(&bmp_2))
|
||||
|
||||
loop {
|
||||
render.clear(screen, render.black)
|
||||
render.put_scaled(screen, image, .(100, 100), .(image.width / 2 + image.width / 4, image.height * 3))
|
||||
render.sync(screen)
|
||||
}
|
||||
}
|
30
sysdata/programs/tests/src/main.hb
Normal file
30
sysdata/programs/tests/src/main.hb
Normal file
|
@ -0,0 +1,30 @@
|
|||
.{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()
|
||||
buf := "\0\0\0\0"
|
||||
x := @as(int, 0)
|
||||
loop if x > 255 break else {
|
||||
log.info(string.display_int(x, buf, 2))
|
||||
x += 1
|
||||
}
|
||||
return 0
|
||||
}
|
|
@ -3,9 +3,8 @@
|
|||
default_entry = 1
|
||||
timeout = 0
|
||||
verbose = false
|
||||
# interface_resolution = "1920x1080x24"
|
||||
interface_resolution = "1024x768x24"
|
||||
# interface_resolution = "640x480x24"
|
||||
interface_resolution = "1600x900x24"
|
||||
# interface_resolution = "640x480x32"
|
||||
# Terminal related settings
|
||||
# term_wallpaper = "boot:///background.bmp"
|
||||
term_wallpaper = "boot:///empty-background.bmp"
|
||||
|
@ -16,20 +15,53 @@ comment = "Default AbleOS boot entry."
|
|||
protocol = "limine"
|
||||
kernel_path = "boot:///kernel_${ARCH}"
|
||||
kernel_cmdline = ""
|
||||
# resolution = "1920x1080x24"
|
||||
resolution = "1024x768x24"
|
||||
# resolution = "640x480x24"
|
||||
# resolution = "640x480x32"
|
||||
resolution = "1600x900x24"
|
||||
|
||||
[boot.limine.ableos.modules]
|
||||
|
||||
# [boot.limine.ableos.modules.render_example]
|
||||
# path = "boot:///render_example.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.mouse_driver]
|
||||
# path = "boot:///mouse_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.serial_driver]
|
||||
# path = "boot:///serial_driver.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_testing_program]
|
||||
# path = "boot:///horizon_testing_program.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.dt_buffer_test]
|
||||
# path = "boot:///dt_buffer_test.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.svga_driver]
|
||||
# path = "boot:///svga_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
||||
# path = "boot:///ps2_keyboard_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.filesystem_fat32]
|
||||
# [boot.limine.ableos.modules.ps2_keyboard_driv
|
||||
# path = "boot:///filesystem_fat32.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.pumpkin_print]
|
||||
# path = "boot:///pumpkin_print.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.ps2_mouse_driver]
|
||||
path = "boot:///ps2_mouse_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
||||
# path = "boot:///ps2_keyboard_driver.hbf"
|
||||
# [boot.limine.ableos.modules.ps2_driver]
|
||||
# path = "boot:///ps2_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.app_bar]
|
||||
# path = "boot:///app_bar.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.test_abc]
|
||||
# path = "boot:///test_abc.hbf"
|
||||
|
|
Loading…
Reference in a new issue