misc
This commit is contained in:
parent
eea23d967b
commit
68d3236cc0
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -228,12 +228,12 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbbytecode"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#42a713aeaef11ca86d96083915191fbe456c47e5"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#7865d692a156c1d31f63b8f04b5d51472d1ff30a"
|
||||
|
||||
[[package]]
|
||||
name = "hblang"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#42a713aeaef11ca86d96083915191fbe456c47e5"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#7865d692a156c1d31f63b8f04b5d51472d1ff30a"
|
||||
dependencies = [
|
||||
"hashbrown 0.15.1",
|
||||
"hbbytecode",
|
||||
|
@ -245,7 +245,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbvm"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#42a713aeaef11ca86d96083915191fbe456c47e5"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#7865d692a156c1d31f63b8f04b5d51472d1ff30a"
|
||||
dependencies = [
|
||||
"hbbytecode",
|
||||
]
|
||||
|
|
|
@ -2,26 +2,23 @@
|
|||
.{Surface} := @use("../lib.hb")
|
||||
bmp := @use("bmp.hb")
|
||||
qoi := @use("qoi.hb")
|
||||
$BMP := 0x4D42
|
||||
$QOI := 0x66696F71
|
||||
|
||||
BMP := 0x4D42
|
||||
QOI := 0x66696F71
|
||||
// stand-in for null until bugfix
|
||||
DOES_NOT_EXIST := 1 << 32
|
||||
|
||||
get_format := fn(file: ^u8): uint {
|
||||
get_format := fn(file: ^u8): ?uint {
|
||||
if *@as(^u16, @bitcast(file)) == BMP {
|
||||
return BMP
|
||||
} else if *@as(^u32, @bitcast(file)) == QOI {
|
||||
return QOI
|
||||
} else {
|
||||
return DOES_NOT_EXIST
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
from := fn(file: ^u8): ?Surface {
|
||||
format := get_format(file)
|
||||
|
||||
if format == DOES_NOT_EXIST {
|
||||
if format == null {
|
||||
log.error("Could not detect image format.\0")
|
||||
return null
|
||||
} else if format == BMP {
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -1,29 +1,26 @@
|
|||
.{log} := @use("../../../../libraries/stn/src/lib.hb")
|
||||
.{log, math, string} := @use("../../../../libraries/stn/src/lib.hb")
|
||||
render := @use("../../../../libraries/render/src/lib.hb")
|
||||
|
||||
/* expected result:
|
||||
a cute qoi image and a cute bmp image */
|
||||
|
||||
qoi := @embed("./assets/mini.qoi")
|
||||
bmp := @embed("./assets/mini.bmp")
|
||||
|
||||
example := fn(): void {
|
||||
screen := render.init(true)
|
||||
image_qoi := render.image.from(@bitcast(&qoi))
|
||||
image_bmp := render.image.from(@bitcast(&bmp))
|
||||
image_qoi := render.image.from(@bitcast(&@embed("./assets/mini.qoi")))
|
||||
image_bmp := render.image.from(@bitcast(&@embed("./assets/mini.bmp")))
|
||||
|
||||
if image_qoi == null {
|
||||
log.error("failed to load qoi image for whatever reason\0")
|
||||
return
|
||||
}
|
||||
if image_bmp == null {
|
||||
log.error("failed to load bmp image for whatever reason\0")
|
||||
if image_qoi == null | image_bmp == null {
|
||||
log.error("failed to load images for whatever reason\0")
|
||||
return
|
||||
}
|
||||
|
||||
t := 0.0
|
||||
loop {
|
||||
render.clear(screen, render.black)
|
||||
render.put_surface(screen, image_bmp, .((screen.width - image_bmp.width * 3) / 2, (screen.height - image_bmp.height) / 2), false)
|
||||
render.put_surface(screen, image_qoi, .((screen.width + image_qoi.width) / 2, (screen.height - image_qoi.height) / 2), false)
|
||||
render.put_surface(screen, image_bmp, .(@bitcast(@fti(math.cos(t) * 100.0)) + (screen.width - image_bmp.width * 3) / 2, (screen.height - image_bmp.height) / 2), false)
|
||||
render.put_surface(screen, image_qoi, .((screen.width + image_qoi.width) / 2, @bitcast(@fti(math.sin(t) * 100.0)) + (screen.height - image_qoi.height) / 2), false)
|
||||
render.sync(screen)
|
||||
t += 0.02
|
||||
}
|
||||
return
|
||||
}
|
|
@ -14,6 +14,7 @@ render := @use("../../../../libraries/render/src/lib.hb")
|
|||
*/
|
||||
|
||||
psf := @embed("../../../../consolefonts/tamsyn/10x20r.psf")
|
||||
img := @embed("./assets/wallpaper.qoi")
|
||||
|
||||
is_shift_pressed := false
|
||||
is_ctrl_pressed := false
|
||||
|
@ -29,10 +30,14 @@ example := fn(): void {
|
|||
screen := render.init(true)
|
||||
window := render.new_surface(600, 300)
|
||||
font := render.text.font_from_psf2(@bitcast(&psf), false)
|
||||
wallpaper := render.image.from(@bitcast(&img))
|
||||
|
||||
if font == null {
|
||||
return
|
||||
}
|
||||
if wallpaper == null {
|
||||
return
|
||||
}
|
||||
|
||||
msg := "sticky note:\n\0"
|
||||
msg_len := string.length(msg)
|
||||
|
@ -45,7 +50,7 @@ example := fn(): void {
|
|||
cursor := bottom
|
||||
|
||||
draw_window(window, font, buf, cursor)
|
||||
draw_screen(screen, window)
|
||||
draw_screen(screen, window, wallpaper)
|
||||
|
||||
memory.outb(96, 238)
|
||||
memory.outb(96, 238)
|
||||
|
@ -105,7 +110,7 @@ example := fn(): void {
|
|||
}
|
||||
}
|
||||
draw_window(window, font, buf, cursor)
|
||||
draw_screen(screen, window)
|
||||
draw_screen(screen, window, wallpaper)
|
||||
|
||||
if holding_timer > 0 & current_key != 0 {
|
||||
if (memory.inb(96) & 0x80) != 0 {
|
||||
|
@ -132,7 +137,7 @@ handle_extended_key := fn(scancode: u8, cursor: ^u8, bottom: ^u8, font: render.t
|
|||
padding := 3 * @sizeof(render.Color)
|
||||
|
||||
draw_window := fn(window: render.Surface, font: render.text.Font, buf: ^u8, cursor: ^u8): void {
|
||||
render.clear(window, render.light_yellow)
|
||||
render.clear(window, .(0x88, 0xF4, 0xFC, 0x0))
|
||||
line := font.height + padding - 1
|
||||
render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.black)
|
||||
|
||||
|
@ -166,8 +171,8 @@ draw_window := fn(window: render.Surface, font: render.text.Font, buf: ^u8, curs
|
|||
render.put_rect(window, .(x_pos, y_pos), .(1, font.height - 1), render.black)
|
||||
}
|
||||
|
||||
draw_screen := fn(screen: render.Surface, window: render.Surface): void {
|
||||
render.clear(screen, render.light_blue)
|
||||
draw_screen := fn(screen: render.Surface, window: render.Surface, wallpaper: render.Surface): void {
|
||||
render.put_surface(screen, wallpaper, .(0, 0), false)
|
||||
render.put_surface(screen, window, .(100, 100), false)
|
||||
render.sync(screen)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue