Compare commits

...

45 commits

Author SHA1 Message Date
peony 2d2bec803f Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-11-10 13:00:45 +01:00
peony 388d8c8c20 Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-11-10 12:54:02 +01:00
peony 5c131eae13 misc 2024-11-10 12:51:51 +01:00
peony 7f920e2f65 Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-11-10 11:02:04 +01:00
peony 97f7aa49f7 PS/2 work 2024-11-10 10:59:30 +01:00
peony 52b6272439 PS/2 work 2024-11-10 10:59:01 +01:00
peony d764dc9dd6 Don't ask. 2024-11-08 20:41:30 +01:00
peony d0f078cf10 Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-11-04 02:58:58 +01:00
peony daced693fa Attempt at enabling the scrollwheel. 2024-11-04 02:47:09 +01:00
peony 2b13242f7f Mouse driver is good now! 2024-11-04 00:43:29 +01:00
peony d154c9fab1 Fixed mouse driver I think 2024-11-04 00:33:37 +01:00
peony f31d35703d Mouse driver finished for 3 button mice. 2024-11-03 23:04:10 +01:00
peony e670a0ef53 Simple mouse driver commands 2024-11-02 14:20:44 +01:00
peony 376a5213ac Removed triangle drawing stuff 2024-11-01 21:53:59 +01:00
peony 552b613151 Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-11-01 21:17:14 +01:00
peony 5a44a707eb Nothin, null even 2024-11-01 20:42:18 +01:00
peony f52e3979a2 render.init safety checks 2024-11-01 20:26:31 +01:00
peony e3ec34684f framebuffer is ?^Color now. 2024-11-01 18:56:15 +01:00
peony d19f15aa5c I am good at this/s 2024-11-01 18:35:30 +01:00
peony 9e0a508a6f Very informative commit message 2024-11-01 18:34:10 +01:00
peony 20bb741bf1 Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-10-27 16:59:03 +01:00
peony a95f1b5a4b Cube work 2024-10-27 16:54:59 +01:00
peony e6b972a7f3 Circle drawing, slightly bugged 2024-10-26 16:02:47 +02:00
peony 4a0f65753e Tri work 2024-10-25 17:58:19 +02:00
peony d143acb8b6 Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-10-25 17:43:23 +02:00
peony f65f04460b more stubs 2024-10-25 17:39:00 +02:00
peony 223a1c15ad Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-10-25 16:28:45 +02:00
peony fe85a91548 Triangle rendering stubs. 2024-10-25 16:27:57 +02:00
peony f5ffed5662 Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-10-25 16:01:02 +02:00
peony 382a4f5510 Literally 0 mouse driver work 2024-10-25 15:57:53 +02:00
peony f023773b2e Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-10-20 14:47:40 +02:00
peony b7d668c83a More mouse work 2024-10-20 14:46:25 +02:00
peony 92bf9207b3 Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-10-20 14:21:48 +02:00
peony 0da9467a0f Bncha mouse driver stubs 2024-10-20 14:18:16 +02:00
peony f6dd752b77 Removed resize from the render TODO 2024-10-19 18:00:03 +02:00
peony 851e0bd94a Uuugh 2024-10-19 17:58:55 +02:00
peony 38c6f6cf47 Merge 2024-10-19 17:56:40 +02:00
peony 1c9ca8962e Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-10-19 17:56:20 +02:00
peony 8d36083729 Fixed scaling bug 2024-10-19 17:40:42 +02:00
peony ad351155da Added put_scaled. 2024-10-19 17:35:20 +02:00
peony 1039db1247 Merge branch 'master' of https://git.ablecorp.us/AbleOS/ableos 2024-10-16 00:39:27 +02:00
peony fbdf737306 Adds a very broken (literally doesn't work) sound driver. 2024-10-16 00:32:32 +02:00
peony 15c978f90f Merge remote-tracking branch 'ableos/master' 2024-10-14 22:06:05 +02:00
peony 39ebaa03ba Uuuugh 2024-10-14 14:35:41 +02:00
peony de8000f596 Fixed software renderer; added vline,hline,trirect 2024-10-13 23:15:10 +02:00
16 changed files with 563 additions and 18 deletions

View file

@ -428,6 +428,11 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> {
"-monitor", "none", "-monitor", "none",
"-machine", accel, "-machine", accel,
"-cpu", "max", "-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", "-device", "isa-debug-exit,iobase=0xf4,iosize=0x04",
]); ]);
} }

View file

@ -10,7 +10,6 @@
- Invert - Invert
- Surface Operations: - Surface Operations:
- FlipH - FlipH
- Resize
- Wrap the colour operations - Wrap the colour operations
- Tile - Tile
- Gradient overlay - Gradient overlay

View file

@ -38,9 +38,13 @@ $light_cyan := Color.(255, 255, 0, 255)
put_pixel := mode.put_pixel put_pixel := mode.put_pixel
put_rect := mode.put_rect put_rect := mode.put_rect
put_filled_rect := mode.put_filled_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 put_line := mode.put_line
clear := mode.clear clear := mode.clear
put_surface := mode.put_surface put_surface := mode.put_surface
put_scaled := mode.put_scaled
put_text := mode.put_text put_text := mode.put_text
// thanks peony for these three! // thanks peony for these three!
put_trirect := mode.put_trirect put_trirect := mode.put_trirect

View file

@ -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"); .{Color, text} := @use("lib.hb");
.{get_glyph, get_glyph_unicode, Font, UNC_TABLE_SIZE} := text; .{get_glyph, get_glyph_unicode, Font, UNC_TABLE_SIZE} := text;
.{Vec2} := math .{Vec2} := math
// safety: don't use before init() or you will get a memory access violation // safety: don't use before init() or you will get a memory access violation
framebuffer := memory.dangling(Color) //framebuffer := memory.dangling(Color)
Surface := struct { Surface := struct {
buf: ^Color, buf: ^Color,
@ -26,14 +26,38 @@ clone_surface := fn(surface: ^Surface): Surface {
return new 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") framebuffer = dt.get(^Color, "framebuffer/fb0/ptr\0")
width := dt.get(uint, "framebuffer/fb0/width\0") width := dt.get(uint, "framebuffer/fb0/width\0")
height := dt.get(uint, "framebuffer/fb0/height\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 { if doublebuffer {
return new_surface(width, height) return new_surface(@unwrap(width), @unwrap(height))
} else { } 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 { sync := fn(surface: Surface): void {
// vague safety
if framebuffer == null {
return
}
if surface.buf == framebuffer { if surface.buf == framebuffer {
return 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 { 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 { if p0.x > p1.x {
@inline(put_line_low, surface, p1, p0, color) @inline(put_line_low, surface, p1, p0, color)
} else { } else {
@ -195,7 +223,78 @@ put_surface := fn(surface: Surface, top: Surface, pos: Vec2(uint), flip_v: bool)
} }
if rows_to_copy == 1 { 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 return
@ -251,7 +350,89 @@ put_hline := fn(surface: Surface, y: uint, x0: uint, x1: uint, color: Color): vo
return 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 { put_text := fn(surface: Surface, font: Font, pos: Vec2(uint), color: Color, str: ^u8): void {
cursor := Vec2(uint).(pos.x, pos.y) cursor := Vec2(uint).(pos.x, pos.y)

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,5 +1,5 @@
.{string} := @use("../../stn/src/lib.hb") .{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)) return @eca(3, 5, query, @inline(string.length, query))
} }

View file

@ -28,6 +28,10 @@ main := fn(): int {
win_buff := buffer.create("XHorizon\0") win_buff := buffer.create("XHorizon\0")
screen := render.init(true) screen := render.init(true)
if screen == null {
log.error("Screen could not be initialized!\0")
return 1
}
// Clear the screen to black. // Clear the screen to black.
render.clear(screen, render.black) render.clear(screen, render.black)
@ -72,6 +76,26 @@ main := fn(): int {
// get input events from drivers via intouch // get input events from drivers via intouch
// key_event := intouch.recieve_key_event(); // key_event := intouch.recieve_key_event();
// log.info("before mouse event check\0"); // 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 { if false {
// Scroll bar :ThumbsUp: // Scroll bar :ThumbsUp:

View 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.

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

View 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))
}
}
}

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

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

View 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)
}
}

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

View file

@ -3,9 +3,8 @@
default_entry = 1 default_entry = 1
timeout = 0 timeout = 0
verbose = false verbose = false
# interface_resolution = "1920x1080x24" interface_resolution = "1600x900x24"
interface_resolution = "1024x768x24" # interface_resolution = "640x480x32"
# interface_resolution = "640x480x24"
# Terminal related settings # Terminal related settings
# term_wallpaper = "boot:///background.bmp" # term_wallpaper = "boot:///background.bmp"
term_wallpaper = "boot:///empty-background.bmp" term_wallpaper = "boot:///empty-background.bmp"
@ -16,20 +15,53 @@ comment = "Default AbleOS boot entry."
protocol = "limine" protocol = "limine"
kernel_path = "boot:///kernel_${ARCH}" kernel_path = "boot:///kernel_${ARCH}"
kernel_cmdline = "" kernel_cmdline = ""
# resolution = "1920x1080x24" # resolution = "640x480x32"
resolution = "1024x768x24" resolution = "1600x900x24"
# resolution = "640x480x24"
[boot.limine.ableos.modules] [boot.limine.ableos.modules]
# [boot.limine.ableos.modules.render_example] # [boot.limine.ableos.modules.render_example]
# path = "boot:///render_example.hbf" # 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] [boot.limine.ableos.modules.horizon]
path = "boot:///horizon.hbf" 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] [boot.limine.ableos.modules.ps2_mouse_driver]
path = "boot:///ps2_mouse_driver.hbf" path = "boot:///ps2_mouse_driver.hbf"
# [boot.limine.ableos.modules.ps2_keyboard_driver] # [boot.limine.ableos.modules.ps2_driver]
# path = "boot:///ps2_keyboard_driver.hbf" # 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"