Initial commit. Add registers
This commit is contained in:
commit
fc710000a4
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "ferris-boi"
|
||||
version = "0.1.0"
|
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "ferris-boi"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
src/lib.rs
Normal file
3
src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
#![warn(clippy::all, clippy::pedantic)]
|
||||
|
||||
mod register;
|
3
src/main.rs
Normal file
3
src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
46
src/register.rs
Normal file
46
src/register.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
//! The register module Holds the basic [`Registers`] type and functions needed
|
||||
//! to access/manipulate them
|
||||
|
||||
const INITIAL_PROGRAM_COUNTER_VALUE: u16 = 0x100;
|
||||
|
||||
/// Registers holds all of the registers for the Gameboy
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Registers {
|
||||
pub a: u8,
|
||||
pub b: u8,
|
||||
pub c: u8,
|
||||
pub d: u8,
|
||||
pub e: u8,
|
||||
pub f: u8,
|
||||
pub h: u8,
|
||||
pub l: u8,
|
||||
pub stack_pointer: u16,
|
||||
pub program_counter: u16,
|
||||
flags: u8,
|
||||
}
|
||||
|
||||
impl Registers {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Registers {
|
||||
fn default() -> Self {
|
||||
// TODO: verify that these 0 values are correct. I feel like they must
|
||||
// be, but I haven't read enough of the manual
|
||||
Registers {
|
||||
a: 0,
|
||||
b: 0,
|
||||
c: 0,
|
||||
d: 0,
|
||||
e: 0,
|
||||
f: 0,
|
||||
h: 0,
|
||||
l: 0,
|
||||
stack_pointer: 0,
|
||||
program_counter: INITIAL_PROGRAM_COUNTER_VALUE,
|
||||
flags: 0,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue