looklook 0.6.0

Descriptive signal synthesiser.
// Creadright 2026 Gabriel Bjørnager Jensen.
//
// This file is part of LOOKLOOK.
//
// LOOKLOOK is free software: you can redistribute
// it and/or modify it under the terms of the GNU
// Affero General Public License as published by
// the Free Software Foundation, either version 3
// of the License, or (at your option) any later
// version.
//
// LOOKLOOK is distributed in the hope that it will
// be useful, but WITHOUT ANY WARRANTY; without
// even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Affero General Public License for more details.
//
// You should have received a copy of the GNU Af-
// fero General Public License along with LOOKLOOK.
// If not, see <https://www.gnu.org/licenses/>.

//! The [`Emu`] type.

mod exec;
mod read_image;

use crate::emu::{Mem, Stack};

/// A Motorola 68EC000 emulator
#[derive(Debug)]
pub struct Emu {
	/// The register stack.
	stack: Stack,

	/// The memory.
	mem: Mem,
}

impl Emu {
	/// The entry address.
	pub const ENTRY_ADDR: u32 = 0x100;

	/// Constructs a new emulator.
	#[expect(clippy::new_without_default)]
	#[inline]
	#[must_use]
	pub fn new() -> Self {
		let mem = Mem::with_capacity(Mem::DEFAULT_SIZE);
		Self { stack: Default::default(), mem }
	}

	/// Borrows the register stack.
	#[inline(always)]
	#[must_use]
	pub fn stack(&self) -> &Stack {
		&self.stack
	}

	/// Mutably borrows the register stack.
	#[inline(always)]
	#[must_use]
	pub fn stack_mut(&mut self) -> &mut Stack {
		&mut self.stack
	}

	/// Borrows memory.
	#[inline(always)]
	#[must_use]
	pub fn mem(&self) -> &Mem {
		&self.mem
	}

	/// Mutably borrows memory.
	#[inline(always)]
	#[must_use]
	pub fn mem_mut(&mut self) -> &mut Mem {
		&mut self.mem
	}

	/// Reboots the emulator.
	#[inline]
	pub fn reboot(&mut self) {
		self.stack.store_pc(Self::ENTRY_ADDR);
	}
}