misc
This commit is contained in:
parent
3333b1706f
commit
2439722c88
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
|
@ -1,5 +1,13 @@
|
|||
// Image := struct {
|
||||
// magic: uint,
|
||||
// is_dirty: bool,
|
||||
// surface: Surface,
|
||||
// }
|
||||
render := @use("../../../../libraries/render/src/lib.hb");
|
||||
.{Surface} := render
|
||||
|
||||
Image := struct {
|
||||
magic: uint,
|
||||
is_dirty: bool,
|
||||
surface: Surface,
|
||||
}
|
||||
|
||||
image_from_surface := fn(surface: Surface): Image {
|
||||
img := Image.(4, true, surface)
|
||||
return img
|
||||
}
|
|
@ -4,20 +4,20 @@
|
|||
/* source:
|
||||
https://github.com/phoboslab/qoi/blob/master/qoi.h */
|
||||
|
||||
QOI_SRGB := 0
|
||||
QOI_LINEAR := 1
|
||||
QOI_OP_INDEX := 0x0
|
||||
QOI_OP_DIFF := 0x40
|
||||
QOI_OP_LUMA := 0x80
|
||||
QOI_OP_RUN := 0xC0
|
||||
QOI_OP_RGB := 0xFE
|
||||
QOI_OP_RGBA := 0xFF
|
||||
QOI_MASK_2 := 0xC0
|
||||
$QOI_SRGB := 0
|
||||
$QOI_LINEAR := 1
|
||||
$QOI_OP_INDEX := 0x0
|
||||
$QOI_OP_DIFF := 0x40
|
||||
$QOI_OP_LUMA := 0x80
|
||||
$QOI_OP_RUN := 0xC0
|
||||
$QOI_OP_RGB := 0xFE
|
||||
$QOI_OP_RGBA := 0xFF
|
||||
$QOI_MASK_2 := 0xC0
|
||||
QOI_COLOR_HASH := fn(c: Color): u8 {
|
||||
return (c.r * 3 + c.g * 5 + c.b * 7 + c.a * 11) % 64
|
||||
}
|
||||
QOI_MAGIC := 0x716F6966
|
||||
QOI_PIXELS_MAX := 400000000
|
||||
$QOI_MAGIC := 0x716F6966
|
||||
$QOI_PIXELS_MAX := 400000000
|
||||
|
||||
QuiteOkayHeader := packed struct {
|
||||
magic: u32,
|
||||
|
|
|
@ -17,22 +17,22 @@ indexptr := mode.indexptr
|
|||
|
||||
// Colours
|
||||
Color := packed struct {b: u8, g: u8, r: u8, a: u8}
|
||||
white := Color.(255, 255, 255, 255)
|
||||
black := Color.(0, 0, 0, 255)
|
||||
gray := Color.(127, 127, 127, 255)
|
||||
red := Color.(0, 0, 205, 255)
|
||||
green := Color.(0, 205, 0, 255)
|
||||
yellow := Color.(0, 205, 205, 255)
|
||||
blue := Color.(205, 0, 0, 255)
|
||||
magenta := Color.(205, 0, 205, 255)
|
||||
cyan := Color.(205, 205, 0, 255)
|
||||
light_gray := Color.(229, 229, 229, 255)
|
||||
light_red := Color.(0, 0, 255, 255)
|
||||
light_green := Color.(0, 255, 0, 255)
|
||||
light_yellow := Color.(0, 255, 255, 255)
|
||||
light_blue := Color.(255, 0, 0, 255)
|
||||
light_magenta := Color.(255, 0, 255, 255)
|
||||
light_cyan := Color.(255, 255, 0, 255)
|
||||
$white := Color.(255, 255, 255, 255)
|
||||
$black := Color.(0, 0, 0, 255)
|
||||
$gray := Color.(127, 127, 127, 255)
|
||||
$red := Color.(0, 0, 205, 255)
|
||||
$green := Color.(0, 205, 0, 255)
|
||||
$yellow := Color.(0, 205, 205, 255)
|
||||
$blue := Color.(205, 0, 0, 255)
|
||||
$magenta := Color.(205, 0, 205, 255)
|
||||
$cyan := Color.(205, 205, 0, 255)
|
||||
$light_gray := Color.(229, 229, 229, 255)
|
||||
$light_red := Color.(0, 0, 255, 255)
|
||||
$light_green := Color.(0, 255, 0, 255)
|
||||
$light_yellow := Color.(0, 255, 255, 255)
|
||||
$light_blue := Color.(255, 0, 0, 255)
|
||||
$light_magenta := Color.(255, 0, 255, 255)
|
||||
$light_cyan := Color.(255, 255, 0, 255)
|
||||
|
||||
// Drawing
|
||||
put_pixel := mode.put_pixel
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
# app bar
|
||||
The app bar is a mini-bar meant to launch applications.
|
|
@ -1,11 +0,0 @@
|
|||
[package]
|
||||
name = "app_bar"
|
||||
authors = ["able"]
|
||||
|
||||
[dependants.libraries]
|
||||
|
||||
[dependants.binaries]
|
||||
hblang.version = "1.0.0"
|
||||
|
||||
[build]
|
||||
command = "hblang src/main.hb"
|
|
@ -1,35 +0,0 @@
|
|||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{string, memory, buffer, random, log} := stn;
|
||||
.{Vec2} := stn.math
|
||||
|
||||
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb")
|
||||
|
||||
render := @use("../../../libraries/render/src/lib.hb")
|
||||
|
||||
psf := @embed("../../../consolefonts/tamsyn/10x20r.psf")
|
||||
|
||||
main := fn(): int {
|
||||
screen := render.init(true)
|
||||
|
||||
// Clear the screen to black.
|
||||
render.clear(screen, render.black)
|
||||
|
||||
x := 0
|
||||
|
||||
mem_buf := memory.request_page(1)
|
||||
color := random.any(render.Color)
|
||||
|
||||
str := "Window Title Bar\0"
|
||||
font := render.text.font_from_psf2(@bitcast(&psf))
|
||||
|
||||
loop {
|
||||
// Clear the screen
|
||||
render.clear(screen, render.black)
|
||||
|
||||
render.put_rect(screen, .(0, 0), .(screen.width - 1, 26), render.white)
|
||||
// Sync the screen
|
||||
render.sync(screen)
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
|
@ -21,7 +21,8 @@ Window := struct {
|
|||
y: int,
|
||||
}
|
||||
|
||||
psf := @embed("../../../consolefonts/tamsyn/10x20r.psf")
|
||||
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
||||
img := @embed("../../../assets/wallpaper.qoi")
|
||||
|
||||
main := fn(): int {
|
||||
win_buff := buffer.create("XHorizon\0")
|
||||
|
@ -31,6 +32,11 @@ main := fn(): int {
|
|||
// Clear the screen to black.
|
||||
render.clear(screen, render.black)
|
||||
|
||||
wallpaper := render.image.from(@bitcast(&img))
|
||||
if wallpaper == null {
|
||||
return 1
|
||||
}
|
||||
|
||||
window := render.new_surface(screen.width / 3, screen.height / 3)
|
||||
|
||||
mem_buf := memory.request_page(1)
|
||||
|
@ -43,12 +49,14 @@ main := fn(): int {
|
|||
mouse_x := @as(i16, 0)
|
||||
mouse_y := @as(i16, 0)
|
||||
text_label := new_label("Hi\0")
|
||||
|
||||
// widgets := "()\0"
|
||||
// ui := sexpr_parser(widgets)
|
||||
|
||||
loop {
|
||||
// Clear the screen
|
||||
render.clear(screen, render.black)
|
||||
render.put_surface(screen, wallpaper, .(0, 0), false)
|
||||
|
||||
// TODO: Read the window buffer here
|
||||
{
|
||||
|
@ -77,7 +85,7 @@ main := fn(): int {
|
|||
{
|
||||
pos := Vec2(uint).(1, screen.height - 21)
|
||||
render_label_to_surface(screen, text_label, font, pos)
|
||||
render.put_rect(screen, .(0, screen.height - 21), .(screen.width - 1, screen.height - 1), render.white)
|
||||
render.put_rect(screen, .(0, screen.height - 21), .(screen.width - 1, 20), render.white)
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -113,9 +121,11 @@ main := fn(): int {
|
|||
|
||||
if mouse_event.left {
|
||||
set_label_text(text_label, "LEFT CLICK\0")
|
||||
} else if mouse_event.middle {
|
||||
}
|
||||
if mouse_event.middle {
|
||||
set_label_text(text_label, "MIDDLE CLICK\0")
|
||||
} else if mouse_event.right {
|
||||
}
|
||||
if mouse_event.right {
|
||||
set_label_text(text_label, "RIGHT CLICK\0")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,22 +6,11 @@ intouch := @use("../../../libraries/intouch/src/lib.hb");
|
|||
|
||||
i9 := packed struct {sign: bool, value: u8}
|
||||
Button := struct {id: u8}
|
||||
LeftButton := Button.(1)
|
||||
RightButton := Button.(2)
|
||||
MiddleButton := Button.(4)
|
||||
Button4 := Button.(8)
|
||||
Button5 := Button.(16)
|
||||
|
||||
mouse_moved := fn(delta: Vec2(i9)): void {
|
||||
// log.info("Mouse movement.\0")
|
||||
}
|
||||
button_event := fn(button: Button, pressed: bool): void {
|
||||
if pressed {
|
||||
// log.info("Mouse-button pressed.\0")
|
||||
} else {
|
||||
// log.info("Mouse-button released.\0")
|
||||
}
|
||||
}
|
||||
$LeftButton := Button.(1)
|
||||
$RightButton := Button.(2)
|
||||
$MiddleButton := Button.(4)
|
||||
$Button4 := Button.(8)
|
||||
$Button5 := Button.(16)
|
||||
|
||||
send_byte := fn(target: u8, data: u8): void {
|
||||
loop if (memory.inb(0x64) & 2) == 0 break
|
||||
|
@ -41,7 +30,6 @@ send_command_byte := fn(byte: u8): void {
|
|||
@inline(send_byte, 0x64, 0xD4)
|
||||
@inline(send_byte, 0x60, byte)
|
||||
loop if memory.inb(0x60) == 0xFA {
|
||||
log.info("ACK\0")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -61,13 +49,13 @@ set_linear_scaling := fn(): void @inline(send_command_byte, 0xE6)
|
|||
resend_packet := fn(): void @inline(send_command_byte, 0xFE)
|
||||
|
||||
SampleRate := struct {value: u8}
|
||||
sr10 := SampleRate.(10)
|
||||
sr20 := SampleRate.(20)
|
||||
sr40 := SampleRate.(40)
|
||||
sr60 := SampleRate.(60)
|
||||
sr80 := SampleRate.(80)
|
||||
sr100 := SampleRate.(100)
|
||||
sr200 := SampleRate.(200)
|
||||
$sr10 := SampleRate.(10)
|
||||
$sr20 := SampleRate.(20)
|
||||
$sr40 := SampleRate.(40)
|
||||
$sr60 := SampleRate.(60)
|
||||
$sr80 := SampleRate.(80)
|
||||
$sr100 := SampleRate.(100)
|
||||
$sr200 := SampleRate.(200)
|
||||
|
||||
set_sample_rate := fn(sample_rate: SampleRate): void {
|
||||
@inline(send_command_byte, 0xE6)
|
||||
|
@ -75,10 +63,10 @@ set_sample_rate := fn(sample_rate: SampleRate): void {
|
|||
}
|
||||
|
||||
Resolution := struct {value: u8}
|
||||
res_1count_per_mm := Resolution.(0)
|
||||
res_2count_per_mm := Resolution.(1)
|
||||
res_4count_per_mm := Resolution.(2)
|
||||
res_8count_per_mm := Resolution.(3)
|
||||
$res_1count_per_mm := Resolution.(0)
|
||||
$res_2count_per_mm := Resolution.(1)
|
||||
$res_4count_per_mm := Resolution.(2)
|
||||
$res_8count_per_mm := Resolution.(3)
|
||||
|
||||
set_resolution := fn(resolution: Resolution): void {
|
||||
@inline(send_command_byte, 0xE6)
|
||||
|
@ -122,28 +110,22 @@ main := fn(): int {
|
|||
|
||||
changes := button_states ^ status & 7
|
||||
|
||||
if (changes & LeftButton.id) != 0 {
|
||||
if (status & LeftButton.id) != 0 {
|
||||
event.left = true
|
||||
} else {
|
||||
event.left = false
|
||||
}
|
||||
if (changes & LeftButton.id) != 0 | (status & LeftButton.id) != 0 {
|
||||
event.left = true
|
||||
} else {
|
||||
event.left = false
|
||||
}
|
||||
|
||||
if (changes & MiddleButton.id) != 0 {
|
||||
if (status & MiddleButton.id) != 0 {
|
||||
event.middle = true
|
||||
} else {
|
||||
event.middle = false
|
||||
}
|
||||
if (changes & MiddleButton.id) != 0 | (status & MiddleButton.id) != 0 {
|
||||
event.middle = true
|
||||
} else {
|
||||
event.middle = false
|
||||
}
|
||||
|
||||
if (changes & RightButton.id) != 0 {
|
||||
if (status & RightButton.id) != 0 {
|
||||
event.right = true
|
||||
} else {
|
||||
event.right = false
|
||||
}
|
||||
if (changes & RightButton.id) != 0 | (status & RightButton.id) != 0 {
|
||||
event.right = true
|
||||
} else {
|
||||
event.right = false
|
||||
}
|
||||
|
||||
button_states ^= changes
|
||||
|
|
|
@ -6,8 +6,8 @@ render := @use("../../../../libraries/render/src/lib.hb")
|
|||
|
||||
example := fn(): void {
|
||||
screen := render.init(true)
|
||||
image_qoi := render.image.from(@bitcast(&@embed("./assets/mini.qoi")))
|
||||
image_bmp := render.image.from(@bitcast(&@embed("./assets/mini.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 | image_bmp == null {
|
||||
log.error("failed to load images for whatever reason\0")
|
||||
|
|
|
@ -13,8 +13,8 @@ render := @use("../../../../libraries/render/src/lib.hb")
|
|||
- shift key support
|
||||
*/
|
||||
|
||||
psf := @embed("../../../../consolefonts/tamsyn/10x20r.psf")
|
||||
img := @embed("./assets/wallpaper.qoi")
|
||||
psf := @embed("../../../../assets/consolefonts/tamsyn/10x20r.psf")
|
||||
img := @embed("../../../../assets/wallpaper.qoi")
|
||||
|
||||
is_shift_pressed := false
|
||||
is_ctrl_pressed := false
|
||||
|
|
Loading…
Reference in a new issue