Skip to content

Commit

Permalink
Add chess game (#230)
Browse files Browse the repository at this point in the history
* Add chess game

* Add missing file

* Add moves parsing

* Add autocompletion

* Add perft command to chess

* Update Cargo.lock

* Add undo and time commands

* Improve output of commands

* Add endgame support

* Split main into multiple methods of a Chess struct

* Update littlewing

* Use chess prelude

* Add show board command

* Add help

* Update docs

* Fix url syntax in doc

* Add commands to doc index

* Update doc/index.md

* Fix typos
  • Loading branch information
vinc authored Aug 12, 2021
1 parent 54b52ee commit e5a7b63
Show file tree
Hide file tree
Showing 11 changed files with 444 additions and 19 deletions.
73 changes: 68 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ time = { version = "0.2.27", default-features = false }
uart_16550 = "0.2.15"
vte = "0.10.1"
x86_64 = "0.14.4"
littlewing = { git = "https://github.com/vinc/littlewing", branch = "feature/add-no-std-support", default-features = false }
#littlewing = { path = "../littlewing", default-features = false }

[package.metadata.bootimage]
test-success-exit-code = 33 # (0x10 << 1) | 1
Binary file added doc/chess.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 79 additions & 6 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,100 @@

MOROS is a hobby operating system written in Rust for the x86 architecture.

It targets 64 bits processors with a legacy BIOS, so roughly computers from the
2010 era, but it also run well on most hypervisors.

![screenshot](moros.png)

Everything in MOROS is done from a command line interface and most tools are
The first task when running the OS is to install the
[filesystem](filesystem.md) on a disk (or in RAM) using the `install` program,
although it's possible to skip the installation and stay in read only mode.

Everything in MOROS is done from a command line interface and most programs are
rather minimalist.

It has a shell:
It has a [shell](shell.md):

![screenshot](shell.png)

With a few tools like `find` that use a regex engine to find files or lines:
With a few programs like `find` that use a [regex engine](regex.md) to find
files or lines:

![screenshot](find.png)

It also has a lisp interpreter:
It also has a [lisp](lisp.md) interpreter:

![screenshot](lisp.png)

And a text editor:
And a [text editor](editor.md):

![screenshot](edit.png)

It has a network stack with two drivers for RTL81339 and PCNET cards:
It has a [network stack](network.md) with two drivers for RTL81339 and PCNET cards:

![screenshot](network.png)

It even has a chess game:

![chess](chess.png)

Finally here are a few commands to try it out:

> date
2021-08-12T20:16:48

> memory
Size: 16777216
Used: 15400
Free: 16761816

> disk
Size: 8388608
Used: 445440
Free: 7943168

> list /tmp
5083 2021-08-07 15:10:09 alice.txt
118 2021-08-07 15:10:09 fibonacci.lisp

> goto /tmp

> read fibonacci.lisp
(label fib
(lambda (n)
(cond
((< n 2) n)
(true (+ (fib (- n 1)) (fib (- n 2)))))))

(print (fib 6))

> lisp fibonacci.lisp
8

> find /tmp --line "p.*nt"
/tmp/alice.txt
9: bank, and of having nothing to do: once or twice she had peeped into the
36: dipped suddenly down, so suddenly that Alice had not a moment to think
41: plenty of time as she went down to look about her and to wonder what was
48: disappointment it was empty: she did not like to drop the jar for fear
49: of killing somebody, so managed to put it into one of the cupboards as
85: began to get rather sleepy, and went on saying to herself, in a dreamy

/tmp/fibonacci.lisp
7: (print (fib 6))

> dhcp
DHCP Discover transmitted
DHCP Offer received
Leased: 10.0.2.15/24
Router: 10.0.2.2
DNS: 10.0.2.3

> tcp time.nist.gov 13
Connecting to 132.163.97.4:13

59438 21-08-12 20:18:27 50 0 0 358.8 UTC(NIST) *

> halt
MOROS has reached its fate, the system is now halting.
[782.191890] ACPI Shutdown
2 changes: 1 addition & 1 deletion doc/lisp.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A minimalist Lisp interpreter is available in MOROS to extend the capabilities
of the Shell.

It started from [Risp][https://github.com/stopachka/risp] and was extended to
It started from [Risp](https://github.com/stopachka/risp) and was extended to
include the seven primitive operators and the two special forms of John
McCarthy's paper "Recursive Functions of Symbolic Expressions and Their
Computation by Machine" (1960) and "The Roots of Lisp" (2002) by Paul Graham.
Expand Down
2 changes: 1 addition & 1 deletion src/sys/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use x86_64::structures::paging::{FrameAllocator, Mapper, Page, PageTableFlags, S
use x86_64::VirtAddr;

pub const HEAP_START: usize = 0x_4444_4444_0000;
pub const HEAP_SIZE: usize = 8 << 20; // MB
pub const HEAP_SIZE: usize = 16 << 20; // MB

#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();
Expand Down
6 changes: 1 addition & 5 deletions src/sys/fs/block_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ impl BlockDeviceIO for MemBlockDevice {
}

pub fn mount_mem() {
let len = sys::allocator::HEAP_SIZE / 2 / 512;
// FIXME: `len` should be equal to `super::DISK_SIZE` which is set during
// compilation for now. But that's not the case because the allocator is
// too slow to allocate more than a few megabytes of memory. So we take
// half of the heap and will panic when this get full.
let len = super::DISK_SIZE / 2;
let dev = MemBlockDevice::new(len);
*BLOCK_DEVICE.lock() = Some(BlockDevice::Mem(dev));
}
Expand Down
Loading

0 comments on commit e5a7b63

Please sign in to comment.