From e49ac92835d2ea5749b926be6b9483fc6265aff5 Mon Sep 17 00:00:00 2001 From: Isabelle L Date: Sat, 13 Jun 2020 17:22:42 -0500 Subject: [PATCH] added some comments --- Cargo.toml | 2 +- README.md | 10 ++++++---- ceres-sys/src/lib.rs | 5 +++++ ceres-sys/src/memory.rs | 1 + ceres-sys/src/video.rs | 2 ++ 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2ae79e5..6613c21 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ ceres-sys = { path = "ceres-sys" } [workspace] members = [ - "ceres-sys" + "ceres-sys", ] \ No newline at end of file diff --git a/README.md b/README.md index ada91ab..ac05551 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ -# Ceres -a shitty fantasy console written in rust using a proprietary MIPS based asm instruction set. a bit of inspiration from PICO-8 +# CERES-16 +a shitty fantasy console written in rust using a proprietary MIPS based asm instruction set. a lot of inspiration from PICO-8. ceres is structured of these crates: -### GRAPHICS +- ceres-sys: the core system structure of ceres-16 -uhhhhh funny 256x144 screen +### Graphics + +ceres uses a 256x144 screen with a separate video buffer from the standard memory. colors are 16-bit structured like `0b0000_rrrr_gggg_bbbb` where the first four bits are ignored. the video buffer is structured row major where each u16 is an individual pixel ### Register layout and info diff --git a/ceres-sys/src/lib.rs b/ceres-sys/src/lib.rs index b1a96c6..0131b18 100644 --- a/ceres-sys/src/lib.rs +++ b/ceres-sys/src/lib.rs @@ -6,10 +6,14 @@ pub use memory::Memory; pub use registers::Registers; pub use video::VideoMemory; +/// ceres screen width pub const SCREEN_WIDTH: usize = 256; +/// ceres screen height pub const SCREEN_HEIGHT: usize = 144; +/// ceres video memory buffer length pub const VIDEO_MEMORY_LEN: usize = SCREEN_HEIGHT * SCREEN_WIDTH; +/// the core system structure of ceres pub struct System { pub registers: Registers, pub memory: Memory, @@ -17,6 +21,7 @@ pub struct System { } impl System { + /// initialize a new system and all of it's component parts pub fn init() -> System { System { registers: Registers::init(), diff --git a/ceres-sys/src/memory.rs b/ceres-sys/src/memory.rs index 5867eb4..61ec4ed 100644 --- a/ceres-sys/src/memory.rs +++ b/ceres-sys/src/memory.rs @@ -4,6 +4,7 @@ pub struct Memory { } impl Memory { + /// initialize the main memory buffer pub fn init() -> Memory { Memory { data: [0x00; std::u16::MAX as usize] } } diff --git a/ceres-sys/src/video.rs b/ceres-sys/src/video.rs index 3724dc6..a833e90 100644 --- a/ceres-sys/src/video.rs +++ b/ceres-sys/src/video.rs @@ -1,8 +1,10 @@ +/// video memory pub struct VideoMemory { data: [u16; crate::VIDEO_MEMORY_LEN], } impl VideoMemory { + /// initialize the video memory pub fn init() -> VideoMemory { VideoMemory { data: [0x0000; crate::VIDEO_MEMORY_LEN] } }