Moved example to example folder

This commit is contained in:
Gleb Zaharov 2023-06-20 22:03:39 +03:00
parent 5828b9bd81
commit e0bef3cc0a
3 changed files with 16 additions and 14 deletions

View File

@ -1,11 +1,15 @@
[package] [package]
name = "hw_kolibri" name = "kos"
version = "0.1.0" version = "0.1.0"
authors = ["Kitsu <mail@kitsu.me>"] authors = ["Kitsu <mail@kitsu.me>", "Sweetbread"]
edition = "2018" edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[example]]
name = "hwa"
path = "example/hwa.rs"
[profile.release] [profile.release]
opt-level = "z" opt-level = "z"
lto = "thin" lto = "thin"
@ -14,4 +18,3 @@ lto = "thin"
cstr_core = { version = "0.2.4", default-features = false, features = ["nightly"] } cstr_core = { version = "0.2.4", default-features = false, features = ["nightly"] }
[build-dependencies] [build-dependencies]
nasm-rs = "0.2.2"

View File

@ -3,5 +3,5 @@
Project uses [cargo-make](https://github.com/sagiegurari/cargo-make) for building steps. Project uses [cargo-make](https://github.com/sagiegurari/cargo-make) for building steps.
Also you need a working [FASM](https://flatassembler.net/download.php). Also you need a working [FASM](https://flatassembler.net/download.php).
Once installed building is trivial then: `cargo objcopy --release -- -O binary --binary-architecture=i386:x86 rust.kex` produces Once installed building is trivial then: `cargo objcopy --release --example hwa -- -O binary --binary-architecture=i386:x86 rust.kex` produces
a ready-to-use binary at root. a ready-to-use binary at root.

View File

@ -3,7 +3,7 @@
use cstr_core::{cstr, CStr}; use cstr_core::{cstr, CStr};
use hw_kolibri::{Color, Dot, Event, WindowKind, WindowParams, WindowTextParams}; use kos::{Color, Dot, Event, WindowKind, WindowParams, WindowTextParams};
const HEADER: &CStr = cstr!("Hey Kolibri"); const HEADER: &CStr = cstr!("Hey Kolibri");
const MSG: &str = "Hello from Rust!"; const MSG: &str = "Hello from Rust!";
@ -11,18 +11,17 @@ const MSG: &str = "Hello from Rust!";
#[inline(always)] // for some reason function removed otherwise #[inline(always)] // for some reason function removed otherwise
fn draw_window() { fn draw_window() {
unsafe { unsafe {
hw_kolibri::start_window_draw(); kos::start_window_draw();
hw_kolibri::define_window( kos::define_window(
Dot { x: 50, y: 50 }, Dot { x: 50, y: 50 },
300, 300, 400,
400,
WindowParams { WindowParams {
color: Color::rgb(0xff, 0xff, 0xff), color: Color::rgb(0xff, 0xff, 0xff),
kind: WindowKind::Themed, kind: WindowKind::Themed,
title: Some(HEADER), title: Some(HEADER),
}, },
); );
hw_kolibri::display_message( kos::display_message(
Dot { x: 0, y: 10 }, Dot { x: 0, y: 10 },
WindowTextParams { WindowTextParams {
color: Color::rgb(0x66, 0x22, 0x22), color: Color::rgb(0x66, 0x22, 0x22),
@ -30,7 +29,7 @@ fn draw_window() {
bg_color: None, bg_color: None,
}, },
); );
hw_kolibri::end_window_draw(); kos::end_window_draw();
} }
} }
@ -38,13 +37,13 @@ fn draw_window() {
fn kol_main() -> ! { fn kol_main() -> ! {
draw_window(); draw_window();
while let Some(ev) = hw_kolibri::fetch_event() { while let Some(ev) = kos::fetch_event() {
match ev { match ev {
Event::Redraw => draw_window(), Event::Redraw => draw_window(),
Event::KeyPress => drop(hw_kolibri::fetch_key()), Event::KeyPress => drop(kos::fetch_key()),
_ => break, _ => break,
} }
} }
hw_kolibri::exit(); kos::exit();
} }