#![no_std]
#![feature(start)]
extern crate mos_alloc;
use core::panic::PanicInfo;
use mos_hardware::mega65::*;
use mos_hardware::screen_codes_null;
use rand::{seq::SliceRandom, SeedableRng};
use ufmt_stdio::*;
#[start]
fn _main(_argc: isize, _argv: *const *const u8) -> isize {
conio_init();
set_border_color(libc::COLOUR_BROWN as u8);
clear_screen();
set_upper_case();
go_home();
set_text_color(libc::COLOUR_BLACK as u8);
cputs([8, 5, 12, 12, 15, 0].as_slice());
cputs_xy(4, 4, screen_codes_null!("hello from rust!").as_slice());
let resolution = get_screen_size();
println!("SCREEN SIZE = {} x {}", resolution.width, resolution.height);
print!("RANDUM BYTES FROM LIBC: ");
for _ in 0..10 {
print!("{} ", random::rand8(u8::MAX));
}
print!("\nRANDOM SHUFFLE USING RNGCORE TRAIT: ");
let mut rng = random::LibcRng::seed_from_u64(1);
let mut seq = [0, 1, 2, 3, 4, 5, 6, 7, 9];
seq.shuffle(&mut rng);
println!("{:?}", &seq);
print!("\nRANDUM BYTES FROM SID: ");
sid0().start_random_generator();
for _ in 0..10 {
print!("{} ", sid0().rand8(u8::MAX));
}
println!();
let rtc = get_real_time_clock();
println!("TIME = {}:{}:{}", rtc.tm_hour, rtc.tm_min, rtc.tm_sec);
let (mul, whole, fraction) = math_accelerator().multiply_divide(0xa, 3);
println!("10 MUL 3 = {}", mul);
println!("10 DIV 3 = {} W FRACTION {}", whole, fraction);
println!("OK TO CONTINUE?");
flush_keyboard_buffer();
let pressed_key = cgetc().to_char().to_ascii_lowercase();
let message = match pressed_key {
'y' => "LET US CONTINUE",
_ => "LET US STOP",
};
println!("{}", message);
0
}
#[panic_handler]
fn panic(_: &PanicInfo) -> ! {
print!("PANIC!");
loop {}
}