Skip to content

Commit 80141eb

Browse files
Print memory and serial on startup. Then print HID events.
1 parent 94e35a4 commit 80141eb

File tree

3 files changed

+42
-27
lines changed

3 files changed

+42
-27
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ panic = "abort"
3737
panic = "abort"
3838

3939
[dependencies]
40-
neotron-common-bios = "0.6.1"
40+
neotron-common-bios = "0.7"
4141
r0 = "1.0"
4242
postcard = "0.5"
4343
serde = { version = "1.0", default-features = false }

build.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use std::env;
22
fn main() {
3-
43
match env::var("CARGO_CFG_TARGET_OS").as_deref() {
54
Ok("none") => {
65
println!("cargo:rustc-link-arg-bin=flash1002=-Tneotron-flash-1002.ld");
76
println!("cargo:rustc-link-arg-bin=flash0802=-Tneotron-flash-0802.ld");
8-
println!("cargo:rustc-link-arg-bin=flash0002=-Tneotron-flash-0002.ld");
7+
println!("cargo:rustc-link-arg-bin=flash0002=-Tneotron-flash-0002.ld");
98
}
109
_ => {
1110
// No args
@@ -29,6 +28,6 @@ fn main() {
2928
println!("cargo:rustc-env=OS_VERSION={}", env!("CARGO_PKG_VERSION"));
3029
}
3130

32-
#[cfg(target_os="macos")]
31+
#[cfg(target_os = "macos")]
3332
println!("cargo:rustc-link-lib=c");
3433
}

src/lib.rs

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,10 @@ pub extern "C" fn main(api: &'static bios::Api) -> ! {
430430
let config = Config::load().unwrap_or_else(|_| Config::default());
431431

432432
if config.has_vga_console() {
433-
// Try and set 80x50 mode for that authentic Windows NT bootloader feel
433+
// Try and set 80x30 mode for maximum compatibility
434434
(api.video_set_mode)(bios::video::Mode::new(
435-
bios::video::Timing::T640x400,
436-
bios::video::Format::Text8x8,
435+
bios::video::Timing::T640x480,
436+
bios::video::Format::Text8x16,
437437
));
438438
// Work with whatever we get
439439
let mode = (api.video_get_mode)();
@@ -465,28 +465,47 @@ pub extern "C" fn main(api: &'static bios::Api) -> ! {
465465
println!("Welcome to {}!", OS_VERSION);
466466
println!("Copyright © Jonathan 'theJPster' Pallant and the Neotron Developers, 2022");
467467

468+
let mut found;
469+
470+
println!("Memory Regions:");
471+
found = false;
468472
for region_idx in 0..=255 {
469-
match (api.memory_get_region)(region_idx) {
470-
bios::Result::Ok(region) => {
471-
println!("Region {}: {}", region_idx, region);
472-
}
473-
_ => {
474-
// Ran out of regions (we assume they are consecutive)
475-
break;
476-
}
473+
if let bios::Option::Some(region) = (api.memory_get_region)(region_idx) {
474+
println!("Region {}: {}", region_idx, region);
475+
found = true;
476+
} else {
477+
// Ran out of regions (we assume they are consecutive)
478+
break;
477479
}
478480
}
481+
if !found {
482+
println!("None.");
483+
}
479484

480-
// Some text, to force the console to scroll.
481-
for i in 0..50 {
482-
for _x in 0..50 - i {
483-
print!(".");
485+
println!("Serial Ports:");
486+
found = false;
487+
for device_idx in 0..=255 {
488+
if let bios::Option::Some(serial) = (api.serial_get_info)(device_idx) {
489+
println!("Serial Device {}: {:?}", device_idx, serial);
490+
found = true;
491+
} else {
492+
// Ran out of serial devices (we assume they are consecutive)
493+
break;
484494
}
485-
println!("{}", i);
486-
(api.delay)(neotron_common_bios::Timeout::new_ms(250));
495+
}
496+
if !found {
497+
println!("None.");
487498
}
488499

489-
panic!("Testing a panic...");
500+
loop {
501+
if let neotron_common_bios::Result::Ok(neotron_common_bios::Option::Some(ev)) =
502+
(api.hid_get_event)()
503+
{
504+
let ticks = (api.time_ticks_get)();
505+
println!("HID Ev: {:?} @ {}", ev, ticks.0);
506+
}
507+
(api.power_idle)();
508+
}
490509
}
491510

492511
/// Called when we have a panic.
@@ -495,11 +514,8 @@ pub extern "C" fn main(api: &'static bios::Api) -> ! {
495514
fn panic(info: &core::panic::PanicInfo) -> ! {
496515
println!("PANIC!\n{:#?}", info);
497516
loop {
498-
for ch in "|/-\\".chars() {
499-
print!("\r{}", ch);
500-
if let Some(api) = unsafe { API } {
501-
(api.delay)(neotron_common_bios::Timeout::new_ms(100));
502-
}
517+
if let Some(api) = unsafe { API } {
518+
(api.power_idle)();
503519
}
504520
}
505521
}

0 commit comments

Comments
 (0)