riscii

An emulator for the RISC II
Log | Files | Refs | LICENSE

commit 6519e8809739d0fa822efe5c975986e9a62b7302
parent e31915a5c2d014b57347b388de316ed9d8b5727a
Author: Ryan Jeffrey <ryan@ryanmj.xyz>
Date:   Mon, 13 Jun 2022 02:14:18 -0700

More docucomments

Diffstat:
Msrc/sdl.rs | 9++++++++-
Msrc/system.rs | 23+++++++++++++++++------
2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/sdl.rs b/src/sdl.rs @@ -1,4 +1,4 @@ -// RISC II emulator configuration. +// RISC II emulator window and I/O. // (C) Ryan Jeffrey <ryan@ryanmj.xyz>, 2022 // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -30,16 +30,23 @@ use sdl2::VideoSubsystem; // Struct definitions. +/// SDL context structs. pub struct Context { + /// SDL context. context: Sdl, + /// Video context. video_system: VideoSubsystem, + /// Window canvas. canvas: Canvas<Window>, + /// Event queue. event_pump: EventPump, } // Struct impls. impl Context { + /// Create a new SDL window/context. Return context on success and a + /// string on error. pub fn new(config: &Config) -> Result<Self, String> { let sdl_context = sdl2::init()?; let video_subsystem = sdl_context.video()?; diff --git a/src/system.rs b/src/system.rs @@ -19,6 +19,7 @@ use cpu::RegisterFile; use memory::Memory; use std::fmt; +/// RISC II emulated system. pub struct System { /// RISC II register file. regs: RegisterFile, @@ -41,6 +42,10 @@ pub struct System { // Impls. impl System { + /// Create a new emulated RISC II system. Return system on success and + /// a string on error. + /// # Arguments + /// * `config` - Emulator configuration. pub fn new(config: &Config) -> Result<Self, String> { Ok(Self { regs: RegisterFile::new(), @@ -79,18 +84,24 @@ CC Carry: {}", // Private functions. -fn privilege_string(s: bool) -> String { +/// Create a descriptive string for the system's privilege state bits. +/// # Arguments +/// * `s` - Privilege state bit. +fn privilege_string(s: bool) -> &str { if s { - "Privileged".to_string() + "Privileged" } else { - "Unprivileged".to_string() + "Unprivileged" } } -fn bool_hl_string(s: bool) -> String { +/// Stringify booleans with hardware terminology. +/// # Arguments +/// * `s` - Boolean. +fn bool_hl_string(s: bool) -> &str { if s { - "High".to_string() + "High" } else { - "Low".to_string() + "Low" } }