Skip to content

Commit c7a7fc2

Browse files
committed
Better Windows instructions.
1 parent e1176f2 commit c7a7fc2

2 files changed

Lines changed: 37 additions & 12 deletions

File tree

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $ export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib"
2121

2222
You will need to re-run the `export` command before you re-build the application.
2323

24-
## Building
24+
## Building on Linux
2525

2626
Build and run this BIOS (and use it to boot Neotron OS) with...
2727

@@ -44,6 +44,23 @@ The file `libneotron_os.so` is not supplied. You can build it with:
4444
~/neotron-os $ cp ./target/release/libneotron_os.so ~/Neotron-Desktop-BIOS
4545
```
4646

47+
## Building on Windows
48+
49+
1. Install and bootstrap [vcpkg](https://github.com/microsoft/vcpkg)
50+
2. Install the SDL2 libraries with vcpkg:
51+
52+
```console
53+
C:\Users\user\Documents\vcpkg> ./vcpkg.exe install sdl2-ttf:x64-windows sdl2:x64-windows sdl2-mixer:x64-windows sdl2-gfx:x64-windows sdl2-ttf:x64-windows sdl2-image:x64-windows
54+
```
55+
56+
3. Set your PATH, INCLUDE and LIB to include the directories in your vcpkg install folder:
57+
58+
```console
59+
C:\Users\user\Documents> set PATH=%PATH%;C:\Users\user\Documents\vcpkg\installed\x64-windows\bin
60+
C:\Users\user\Documents> set INCLUDE=%INCLUDE%;C:\Users\user\Documents\vcpkg\installed\x64-windows\include
61+
C:\Users\user\Documents> set LIB=%LIB%;C:\Users\user\Documents\vcpkg\installed\x64-windows\lib
62+
```
63+
4764
## Features
4865

4966
* GUI window with pixel-perfect video rendering

src/main.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,15 @@ fn main() {
720720
}
721721

722722
// Process args
723-
info!("Loading OS from {}", args.os.display());
724-
let lib = unsafe { libloading::Library::new(args.os).expect("library to load") };
725-
println!("Loaded!");
723+
let mut lib = None;
724+
for arg in std::env::args() {
725+
if let Some(os_path) = arg.strip_prefix("--os=") {
726+
info!("Loading OS from {:?}", os_path);
727+
lib = unsafe { Some(libloading::Library::new(os_path).expect("library to load")) };
728+
println!("Loaded!");
729+
}
730+
}
731+
let lib = lib.expect("Fetching --os=filename from args");
726732

727733
// Make a window
728734
let mut engine = PixEngine::builder()
@@ -751,7 +757,7 @@ fn main() {
751757
drop(queue);
752758
info!("Video init complete. OS starting...");
753759
let main_func: libloading::Symbol<unsafe extern "C" fn(api: &'static common::Api) -> !> =
754-
lib.get(b"main").expect("main() found");
760+
lib.get(b"os_main").expect("os_main() not found");
755761
main_func(&BIOS_API);
756762
});
757763

@@ -798,7 +804,7 @@ extern "C" fn serial_get_info(_device: u8) -> common::Option<common::serial::Dev
798804
/// options are invalid for that serial device.
799805
extern "C" fn serial_configure(_device: u8, _config: common::serial::Config) -> common::Result<()> {
800806
debug!("serial_configure()");
801-
common::Result::Err(common::Error::Unimplemented)
807+
Err(common::Error::Unimplemented).into()
802808
}
803809

804810
/// Write bytes to a serial port. There is no sense of 'opening' or
@@ -812,7 +818,7 @@ extern "C" fn serial_write(
812818
_timeout: common::Option<common::Timeout>,
813819
) -> common::Result<usize> {
814820
debug!("serial_write()");
815-
common::Result::Err(common::Error::Unimplemented)
821+
Err(common::Error::Unimplemented).into()
816822
}
817823

818824
/// Read bytes from a serial port. There is no sense of 'opening' or
@@ -826,7 +832,7 @@ extern "C" fn serial_read(
826832
_timeout: common::Option<common::Timeout>,
827833
) -> common::Result<usize> {
828834
debug!("serial_read()");
829-
common::Result::Err(common::Error::Unimplemented)
835+
Err(common::Error::Unimplemented).into()
830836
}
831837

832838
/// Get the current wall time.
@@ -874,15 +880,15 @@ extern "C" fn time_clock_set(time: common::Time) {
874880
/// battery-backed SRAM.
875881
extern "C" fn configuration_get(_buffer: common::ApiBuffer) -> common::Result<usize> {
876882
debug!("configuration_get()");
877-
common::Result::Err(common::Error::Unimplemented)
883+
Err(common::Error::Unimplemented).into()
878884
}
879885

880886
/// Set the configuration data block.
881887
///
882888
/// See `configuration_get`.
883889
extern "C" fn configuration_set(_buffer: common::ApiByteSlice) -> common::Result<()> {
884890
debug!("configuration_set()");
885-
common::Result::Err(common::Error::Unimplemented)
891+
Err(common::Error::Unimplemented).into()
886892
}
887893

888894
/// Does this Neotron BIOS support this video mode?
@@ -981,7 +987,7 @@ extern "C" fn video_get_framebuffer() -> *mut u8 {
981987
/// The pointer must point to enough video memory to handle the current video
982988
/// mode, and any future video mode you set.
983989
unsafe extern "C" fn video_set_framebuffer(_buffer: *const u8) -> common::Result<()> {
984-
common::Result::Err(common::Error::Unimplemented)
990+
Err(common::Error::Unimplemented).into()
985991
}
986992

987993
/// Find out whether the given video mode needs more VRAM than we currently have.
@@ -1185,7 +1191,7 @@ fn convert_keycode(key: Key) -> common::hid::KeyCode {
11851191
/// Control the keyboard LEDs.
11861192
extern "C" fn hid_set_leds(_leds: common::hid::KeyboardLeds) -> common::Result<()> {
11871193
debug!("hid_set_leds()");
1188-
common::Result::Err(common::Error::Unimplemented)
1194+
Err(common::Error::Unimplemented).into()
11891195
}
11901196

11911197
/// Wait for the next occurence of the specified video scan-line.
@@ -1523,6 +1529,7 @@ impl MyApp {
15231529
for glyph in 0..=255 {
15241530
for palette_entry in PALETTE.iter().take(Self::NUM_FG) {
15251531
let fg = RGBColour::from_packed(palette_entry.load(Ordering::Relaxed));
1532+
info!("Drawing {glyph} in {:06x}", fg.as_packed());
15261533
let texture_id = if texture_buffer.len() > slot {
15271534
texture_buffer[slot]
15281535
} else {
@@ -1631,6 +1638,7 @@ impl AppState for MyApp {
16311638
let num_rows = self.mode.text_height().unwrap();
16321639
// FRAMEBUFFER is an num_cols x num_rows size array of (u8_glyph, u8_attr).
16331640
for row in 0..num_rows {
1641+
let y = row * font_height;
16341642
for col in 0..num_cols {
16351643
let cell_no = (row * num_cols) + col;
16361644
let byte_offset = usize::from(cell_no) * 2;

0 commit comments

Comments
 (0)