minor jank auto resolution detection
This commit is contained in:
parent
63c3544012
commit
555bc49663
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -390,17 +390,17 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbbytecode"
|
name = "hbbytecode"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641d344d2dcdf9392f6506831f5ccc31ed5e2ab8"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbbytecode"
|
name = "hbbytecode"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/ableos/holey-bytes#641d344d2dcdf9392f6506831f5ccc31ed5e2ab8"
|
source = "git+https://git.ablecorp.us/ableos/holey-bytes#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hblang"
|
name = "hblang"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641d344d2dcdf9392f6506831f5ccc31ed5e2ab8"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
|
"hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
|
||||||
]
|
]
|
||||||
|
@ -408,7 +408,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbvm"
|
name = "hbvm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641d344d2dcdf9392f6506831f5ccc31ed5e2ab8"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
|
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
|
||||||
]
|
]
|
||||||
|
@ -416,7 +416,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbvm"
|
name = "hbvm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/ableos/holey-bytes#641d344d2dcdf9392f6506831f5ccc31ed5e2ab8"
|
source = "git+https://git.ablecorp.us/ableos/holey-bytes#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)",
|
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)",
|
||||||
]
|
]
|
||||||
|
|
|
@ -176,10 +176,21 @@ pub fn handler(vm: &mut Vm) {
|
||||||
};
|
};
|
||||||
let fb1: &NonNullPtr<Framebuffer> =
|
let fb1: &NonNullPtr<Framebuffer> =
|
||||||
&FB_REQ.get_response().get().unwrap().framebuffers()[0];
|
&FB_REQ.get_response().get().unwrap().framebuffers()[0];
|
||||||
let fb_front = fb1.address.as_ptr().unwrap() as *const u8;
|
let msg = block_read(mem_addr, length)[0];
|
||||||
log::info!("Graphics front ptr {:?}", fb_front);
|
if msg == b'p' {
|
||||||
|
// ptr
|
||||||
vm.registers[1] = hbvm::value::Value(fb_front as u64);
|
let fb_front = fb1.address.as_ptr().unwrap() as *const u8;
|
||||||
|
log::info!("Graphics front ptr {:?}", fb_front);
|
||||||
|
vm.registers[1] = hbvm::value::Value(fb_front as u64);
|
||||||
|
} else if msg == b'w' {
|
||||||
|
// width
|
||||||
|
log::info!("FB Width: {}", fb1.width);
|
||||||
|
vm.registers[1] = hbvm::value::Value(fb1.width);
|
||||||
|
} else if msg == b'h' {
|
||||||
|
// height
|
||||||
|
log::info!("FB Height: {}", fb1.height);
|
||||||
|
vm.registers[1] = hbvm::value::Value(fb1.height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
buffer_id => {
|
buffer_id => {
|
||||||
let mut buffs = IPC_BUFFERS.lock();
|
let mut buffs = IPC_BUFFERS.lock();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
//! Named akern.
|
//! Named akern.
|
||||||
//! Akern is woefully undersupported at the moment but we are looking to add support improve hardware discovery and make our lives as kernel and operating system developers easier and better
|
//! Akern is woefully undersupported at the moment but we are looking to add support improve hardware discovery and make our lives as kernel and operating system developers easier and better
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
#![feature(new_uninit)]
|
||||||
#![feature(
|
#![feature(
|
||||||
abi_x86_interrupt,
|
abi_x86_interrupt,
|
||||||
alloc_error_handler,
|
alloc_error_handler,
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2024-07-17"
|
channel = "nightly-2024-07-27"
|
||||||
components = ["rust-src", "llvm-tools"]
|
components = ["rust-src", "llvm-tools"]
|
||||||
|
|
|
@ -19,13 +19,13 @@ light_blue := Color.(255, 0, 0, 255)
|
||||||
light_magenta := Color.(255, 0, 255, 255)
|
light_magenta := Color.(255, 0, 255, 255)
|
||||||
light_cyan := Color.(255, 255, 0, 255)
|
light_cyan := Color.(255, 255, 0, 255)
|
||||||
|
|
||||||
fb_width := 1024
|
// fb_width := 1024
|
||||||
fb_height := 768
|
// fb_height := 768
|
||||||
fb_pixels := fb_width * fb_height
|
// fb_pixels := fb_width * fb_height
|
||||||
fb_bytes := fb_pixels << 2
|
// fb_bytes := fb_pixels << 2
|
||||||
copy_pixels := math.min(0xC000, fb_bytes) >> 2
|
copy_pixels := 0xC000 >> 2
|
||||||
partitions := fb_pixels / copy_pixels
|
// partitions := fb_pixels / copy_pixels
|
||||||
total_pages := 1 + fb_bytes >> 12
|
// total_pages := 1 + fb_bytes >> 12
|
||||||
|
|
||||||
ctx := @as(Context, idk)
|
ctx := @as(Context, idk)
|
||||||
|
|
||||||
|
@ -33,9 +33,38 @@ Context := struct {
|
||||||
fb: ^Color,
|
fb: ^Color,
|
||||||
bb: ^Color,
|
bb: ^Color,
|
||||||
buf: ^Color,
|
buf: ^Color,
|
||||||
|
width: int,
|
||||||
|
height: int,
|
||||||
|
partitions: int,
|
||||||
|
pixels: int,
|
||||||
|
bb_pages: int,
|
||||||
double_buffer: bool,
|
double_buffer: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init := fn(): void {
|
||||||
|
width := @eca(int, 3, 6, "w\0", 2)
|
||||||
|
height := @eca(int, 3, 6, "h\0", 2)
|
||||||
|
// width := 1024
|
||||||
|
// height := 768
|
||||||
|
pixels := width * height
|
||||||
|
bytes := pixels << 2
|
||||||
|
partitions := pixels / copy_pixels
|
||||||
|
pages := 1 + bytes >> 12
|
||||||
|
back_buffer := create_back_buffer(pages)
|
||||||
|
ctx = Context.{
|
||||||
|
fb: @eca(^Color, 3, 6, "p\0", 2),
|
||||||
|
bb: back_buffer,
|
||||||
|
buf: back_buffer,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
partitions,
|
||||||
|
pixels,
|
||||||
|
bb_pages: pages,
|
||||||
|
double_buffer: true,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
doublebuffer := fn(enable: bool): void {
|
doublebuffer := fn(enable: bool): void {
|
||||||
if enable {
|
if enable {
|
||||||
ctx.buf = ctx.bb
|
ctx.buf = ctx.bb
|
||||||
|
@ -46,12 +75,12 @@ doublebuffer := fn(enable: bool): void {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
create_back_buffer := fn(): ^Color {
|
create_back_buffer := fn(pages: int): ^Color {
|
||||||
if total_pages <= 0xFF {
|
if pages <= 0xFF {
|
||||||
return @bitcast(@inline(memory.request_page, total_pages))
|
return @bitcast(@inline(memory.request_page, pages))
|
||||||
}
|
}
|
||||||
ptr := @inline(memory.request_page, 255)
|
ptr := @inline(memory.request_page, 255)
|
||||||
remaining := total_pages - 0xFF
|
remaining := pages - 0xFF
|
||||||
loop if remaining <= 0 break else {
|
loop if remaining <= 0 break else {
|
||||||
if remaining < 0xFF {
|
if remaining < 0xFF {
|
||||||
memory.request_page(remaining)
|
memory.request_page(remaining)
|
||||||
|
@ -80,7 +109,7 @@ clear := fn(color: Color): void {
|
||||||
*@as(^[Color; 4096], @bitcast(cursor)) = *@as(^[Color; 4096], @bitcast(ctx.buf))
|
*@as(^[Color; 4096], @bitcast(cursor)) = *@as(^[Color; 4096], @bitcast(ctx.buf))
|
||||||
cursor += 4096
|
cursor += 4096
|
||||||
}
|
}
|
||||||
boundary += (partitions - 1) * copy_pixels
|
boundary += (ctx.partitions - 1) * copy_pixels
|
||||||
loop if cursor == boundary break else {
|
loop if cursor == boundary break else {
|
||||||
*@as(^[Color; copy_pixels], @bitcast(cursor)) = *@as(^[Color; copy_pixels], @bitcast(ctx.buf))
|
*@as(^[Color; copy_pixels], @bitcast(cursor)) = *@as(^[Color; copy_pixels], @bitcast(ctx.buf))
|
||||||
cursor += @sizeof([u8; copy_pixels])
|
cursor += @sizeof([u8; copy_pixels])
|
||||||
|
@ -92,26 +121,26 @@ sync := fn(): void {
|
||||||
if ctx.double_buffer {
|
if ctx.double_buffer {
|
||||||
bb := ctx.buf
|
bb := ctx.buf
|
||||||
fb := ctx.fb
|
fb := ctx.fb
|
||||||
boundary := bb + fb_pixels
|
boundary := bb + ctx.pixels
|
||||||
loop if bb == boundary break else {
|
loop if bb == boundary break else {
|
||||||
*@as(^[Color; copy_pixels], @bitcast(fb)) = *@as(^[Color; copy_pixels], @bitcast(bb))
|
*@as(^[Color; copy_pixels], @bitcast(fb)) = *@as(^[Color; copy_pixels], @bitcast(bb))
|
||||||
bb += @sizeof([u8; copy_pixels])
|
bb += copy_pixels
|
||||||
fb += @sizeof([u8; copy_pixels])
|
fb += copy_pixels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
width := fn(): int {
|
width := fn(): int {
|
||||||
return fb_width
|
return ctx.width
|
||||||
}
|
}
|
||||||
|
|
||||||
height := fn(): int {
|
height := fn(): int {
|
||||||
return fb_height
|
return ctx.height
|
||||||
}
|
}
|
||||||
|
|
||||||
screenidx := fn(x: int, y: int): int {
|
screenidx := fn(x: int, y: int): int {
|
||||||
return x + fb_width * y
|
return x + ctx.width * y
|
||||||
}
|
}
|
||||||
|
|
||||||
put_pixel := fn(pos: IVec2, color: Color): void {
|
put_pixel := fn(pos: IVec2, color: Color): void {
|
||||||
|
@ -226,20 +255,9 @@ set_width := fn(new: int): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
dimensions := fn(): IVec2 {
|
dimensions := fn(): IVec2 {
|
||||||
return .(fb_width, fb_height)
|
return .(ctx.width, ctx.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
set_dimensions := fn(new: IVec2): void {
|
set_dimensions := fn(new: IVec2): void {
|
||||||
return
|
return
|
||||||
}
|
|
||||||
|
|
||||||
init := fn(): void {
|
|
||||||
back_buffer := create_back_buffer()
|
|
||||||
ctx = Context.{
|
|
||||||
fb: @as(^Color, @bitcast(@eca(uint, 3, 6))),
|
|
||||||
bb: back_buffer,
|
|
||||||
buf: back_buffer,
|
|
||||||
double_buffer: true,
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue