### Example Search Queries Source: https://docs.rs/boytacean/latest/src/boytacean/licensee.rs.html?search= Demonstrates example search queries for different functionalities. ```text Example searches: * std::vec * u32 -> bool * Option, (T -> U) -> Option ``` -------------------------------- ### Example Search Queries Source: https://docs.rs/boytacean/latest/boytacean/data/constant.DMG_BOOT.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Examples of search queries that can be used on docs.rs to find specific Rust functionalities or patterns. ```text std::vec ``` ```text u32 -> bool ``` ```text Option, (T -> U) -> Option ``` -------------------------------- ### Example Search: u32 to bool Source: https://docs.rs/boytacean/latest/boytacean/data/constant.CGB_BOOT.html?search=std%3A%3Avec An example search query for converting a 'u32' to a 'bool', useful for type casting and conditional logic. ```rust u32 -> bool ``` -------------------------------- ### ObjectData Search Examples Source: https://docs.rs/boytacean/latest/boytacean/ppu/struct.ObjectData.html?search= Demonstrates example search queries for ObjectData, illustrating how to search for types, type conversions, and generic type transformations. ```APIDOC ## ObjectData Search Examples ### Description Provides examples of search queries that can be performed on ObjectData, including searching for standard library types, type conversions, and generic type mappings. ### Example Searches - `std::vec` - `u32 -> bool` - `Option, (T -> U) -> Option` ``` -------------------------------- ### BoscState Search Examples Source: https://docs.rs/boytacean/latest/boytacean/state/struct.BoscState.html?search= Provides examples of search queries that can be used with BoscState. ```APIDOC ## Search Examples ### Example 1: Searching for a standard library type ``` std::vec ``` ### Example 2: Searching for a type conversion ``` u32 -> bool ``` ### Example 3: Searching for a generic type conversion with Option ``` Option, (T -> U) -> Option ``` ``` -------------------------------- ### ClockFrame Search Examples Source: https://docs.rs/boytacean/latest/boytacean/gb/struct.ClockFrame.html?search= Demonstrates example search queries for ClockFrame, illustrating common patterns for searching types, type conversions, and generic type transformations. ```APIDOC ## Search Examples This section provides examples of how to search for specific types and patterns within the documentation. ### Example Searches * `std::vec` * `u32 -> bool` * `Option, (T -> U) -> Option` These examples showcase searching for standard library types, simple type conversions, and more complex generic transformations. ``` -------------------------------- ### DMA Value Accessors Source: https://docs.rs/boytacean/latest/src/boytacean/dma.rs.html?search= Provides methods to get and set the value associated with the OAM DMA transfer. This is typically the starting address for OAM DMA. ```APIDOC ## OAM DMA Value Management ### Description Allows retrieval and modification of the value used for OAM DMA transfers. This value usually corresponds to the source address for the OAM DMA operation. ### Methods #### Get DMA Value - **Method**: `value_dma()` - **Returns**: `u8` - The current OAM DMA value. #### Set DMA Value - **Method**: `set_value_dma(value: u8)` - **Parameters**: - **value** (u8) - Required - The new OAM DMA value to set. ``` -------------------------------- ### Boot and Loading Methods Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html?search=std%3A%3Avec Methods for initializing the emulator, including direct boot and unsafe loading strategies. ```APIDOC ## Boot and Loading Methods ### `boot()` Directly boots the machine to its post-boot state, skipping the boot ROM sequence and jumping to cartridge execution. ### `load_unsafe(boot: bool)` Loads the machine with an unsafe strategy that will panic if boot ROM loading fails. The `boot` parameter determines if the boot ROM should be loaded. ### `load_boot_state()` Loads the machine directly to the state after boot execution, setting the PC to 0x0100. This method is intended for DMG machines and allows direct cartridge execution. ``` -------------------------------- ### DMA Source Accessors Source: https://docs.rs/boytacean/latest/src/boytacean/dma.rs.html?search= Provides methods to get and set the DMA source address. This is used for configuring the starting address of data to be transferred during DMA operations. ```APIDOC ## DMA Source Management ### Description Allows retrieval and modification of the DMA source address. This is essential for defining where the DMA transfer will read data from. ### Methods #### Get Source Address - **Method**: `source()` - **Returns**: `u16` - The current DMA source address. #### Set Source Address - **Method**: `set_source(value: u16)` - **Parameters**: - **value** (u16) - Required - The new DMA source address to set. ``` -------------------------------- ### Bit Test (BIT) Operations Source: https://docs.rs/boytacean/latest/src/boytacean/inst.rs.html Tests a specific bit in a CPU register and sets the Z flag if the bit is 0. This example shows the setup for testing bit 0 of register B, C, and D. ```rust fn bit_0_b(cpu: &mut Cpu) { bit_b(cpu, 0); } fn bit_0_c(cpu: &mut Cpu) { bit_c(cpu, 0); } fn bit_0_d(cpu: &mut Cpu) { bit_d(cpu, 0); } ``` -------------------------------- ### Boot and Loading Methods Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html?search=u32+-%3E+bool Methods for initiating the boot sequence or loading the machine into a post-boot state, bypassing the normal boot ROM execution. ```APIDOC ## Boot Machine ### Description Directly boots the machine into the post-boot state, skipping the boot ROM sequence and jumping directly to cartridge execution. ### Method `boot()` ## Load Unsafe ### Description Loads the machine state with error handling that panics on boot ROM loading issues. This is an unsafe operation. ### Method `load_unsafe(boot: bool)` ### Parameters - `boot` (bool): Whether to load the boot ROM state. ## Load Boot State ### Description Loads the machine directly to the state after boot execution, setting the Program Counter (PC) to 0x0100. This method is intended for DMG machines and skips the boot sequence. ### Method `load_boot_state()` ``` -------------------------------- ### Boot and Loading Methods Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html Methods for controlling the emulator's boot sequence and loading states. ```APIDOC ## Boot and Loading Methods Provides methods for initiating the emulator's boot process and loading specific states. ### `boot()` Directly boots the machine to the post-boot state, skipping the boot ROM sequence and jumping to cartridge execution. ### `load_unsafe(boot: bool)` Loads the machine with an unsafe strategy that will panic on boot ROM loading issues. The `boot` parameter determines if the boot ROM is loaded. ### `load_boot_state()` Loads the machine directly to the state after boot execution, setting the PC to the post-boot address (0x0100). This method is intended for DMG machines and allows direct cartridge execution. ``` -------------------------------- ### Cpu Initialization and Boot Source: https://docs.rs/boytacean/latest/boytacean/cpu/struct.Cpu.html?search=u32+-%3E+bool Provides methods for creating a new Cpu instance and initializing its state to mimic the Game Boy boot ROM completion. Use `boot` to skip the initial boot sequence. ```rust pub fn new(mmu: Mmu, gbc: SharedThread) -> Self ``` ```rust pub fn boot(&mut self) Sets the CPU registers and some of the memory space to the expected state after a typical Game Boy boot ROM finishes. Using this strategy it’s possible to skip the “normal” boot loading process for the original DMG Game Boy. ``` -------------------------------- ### Load System Source: https://docs.rs/boytacean/latest/boytacean/gb/struct.GameBoy.html?search=std%3A%3Avec Loads the system with specified boot options. ```APIDOC ## pub fn load(&mut self, boot: bool) -> Result<(), Error> ### Description Loads the system, optionally with boot ROM. ### Method `&mut self` ### Parameters #### Query Parameters - **boot** (bool) - Required - Whether to boot the system. ``` ```APIDOC ## pub fn load_dmg( &mut self, boot: bool, boot_rom: Option, ) -> Result<(), Error> ### Description Loads the system in DMG mode, optionally with a boot ROM. ### Method `&mut self` ### Parameters #### Query Parameters - **boot** (bool) - Required - Whether to boot the system. - **boot_rom** (Option) - Optional - The boot ROM to use. ``` ```APIDOC ## pub fn load_cgb( &mut self, boot: bool, boot_rom: Option, ) -> Result<(), Error> ### Description Loads the system in CGB mode, optionally with a boot ROM. ### Method `&mut self` ### Parameters #### Query Parameters - **boot** (bool) - Required - Whether to boot the system. - **boot_rom** (Option) - Optional - The boot ROM to use. ``` -------------------------------- ### Boot and Loading Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods for controlling the emulator's boot sequence and loading states. ```APIDOC ## boot ### Description Directly boots the machine to its post-boot state, skipping the boot sequence and jumping to cartridge execution. ### Method `boot(&mut self)` ## load_unsafe ### Description Loads the machine with an unsafe strategy that panics on boot ROM loading issues. Optionally loads the boot ROM. ### Method `load_unsafe(&mut self, boot: bool)` ## load_boot_state ### Description Loads the machine directly to the state after boot execution, updating the PC to the post-boot address (0x0100). Currently supports only DMG machines. ### Method `load_boot_state(&mut self)` ``` -------------------------------- ### Example Search: std::vec Source: https://docs.rs/boytacean/latest/boytacean/data/constant.CGB_BOOT.html?search=std%3A%3Avec An example search query for 'std::vec', commonly used when looking for vector-related functionalities in Rust. ```rust std::vec ``` -------------------------------- ### FastPpu Initialization Source: https://docs.rs/boytacean/latest/src/boytacean/ppu_fast.rs.html?search=std%3A%3Avec Creates a new instance of `FastPpu` with default values. This is used to set up the PPU simulation. ```rust pub fn new() -> Self { Self { clock: 0, clock_target: 80, ly: 0, mode: FastMode::OamRead, frame_index: 0, render_pending: false, int_vblank: false, } } ``` -------------------------------- ### Get Title from BessState Source: https://docs.rs/boytacean/latest/src/boytacean/state.rs.html Delegates the call to get the title from the internal BessState. This assumes BessState also implements the necessary trait. ```rust fn title(&self) -> Result { self.bess.title() } ``` -------------------------------- ### Initialize APU with New Source: https://docs.rs/boytacean/latest/src/boytacean/apu.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Constructs a new Apu instance, setting up audio channels, buffer, and filter parameters based on the provided sampling rate, channel count, buffer size, and clock frequency. ```rust impl Apu { pub fn new(sampling_rate: u16, channels: u8, buffer_size: f32, clock_freq: u32) -> Self { Self { ch1_timer: 0, ch1_sequence: 0, ch1_envelope_sequence: 0, ch1_envelope_enabled: false, ch1_sweep_sequence: 0, ch1_output: 0, ch1_dac: false, ch1_sweep_slope: 0x0, ch1_sweep_increase: true, ch1_sweep_pace: 0x0, ch1_length_timer: 0x0, ch1_wave_duty: 0x0, ch1_pace: 0x0, ch1_direction: 0x0, ch1_volume: 0x0, ch1_wave_length: 0x0, ch1_length_enabled: false, ch1_enabled: false, ch2_timer: 0, ch2_sequence: 0, ch2_envelope_sequence: 0, ch2_envelope_enabled: false, ch2_output: 0, ch2_dac: false, ch2_length_timer: 0x0, ch2_wave_duty: 0x0, ch2_pace: 0x0, ch2_direction: 0x0, ch2_volume: 0x0, ch2_wave_length: 0x0, ch2_length_enabled: false, ch2_enabled: false, ch3_timer: 0, ch3_position: 0, ch3_output: 0, ch3_dac: false, ch3_length_timer: 0x0, ch3_output_level: 0x0, ch3_wave_length: 0x0, ch3_length_enabled: false, ch3_enabled: false, ch4_timer: 0, ch4_envelope_sequence: 0, ch4_envelope_enabled: false, ch4_output: 0, ch4_dac: false, ch4_length_timer: 0x0, ch4_pace: 0x0, ch4_direction: 0x0, ch4_volume: 0x0, ch4_divisor: 0x0, ch4_width_mode: false, ch4_clock_shift: 0x0, ch4_lfsr: 0x0, ch4_length_enabled: false, ch4_enabled: false, master: 0x0, glob_panning: 0x0, left_enabled: true, right_enabled: true, sound_enabled: true, ch1_out_enabled: true, ch2_out_enabled: true, ch3_out_enabled: true, ch4_out_enabled: true, wave_ram: [0u8; 16], sampling_rate, channels, sequencer: 0, sequencer_step: 0, output_timer: 0, output_timer_delta: (clock_freq as f32 / sampling_rate as f32) as i16, audio_buffer: VecDeque::with_capacity( (sampling_rate as f32 * buffer_size) as usize * channels as usize, ), audio_buffer_max: (sampling_rate as f32 * buffer_size) as usize * channels as usize, filter_mode: HighPassFilter::Accurate, filter_rate: FILTER_RATE_BASE.powf(clock_freq as f64 / sampling_rate as f64) as f32, filter_diff: [0.0; 2], clock_freq, } } } ``` -------------------------------- ### Apu::new Source: https://docs.rs/boytacean/latest/boytacean/apu/struct.Apu.html?search=std%3A%3Avec Constructs a new Apu instance with the specified audio parameters. ```APIDOC ## Apu::new ### Description Constructs a new Apu instance with the specified audio parameters. ### Signature `pub fn new(sampling_rate: u16, channels: u8, buffer_size: f32, clock_freq: u32) -> Self` ### Parameters * `sampling_rate` (u16) - The audio sampling rate. * `channels` (u8) - The number of audio channels. * `buffer_size` (f32) - The size of the audio buffer. * `clock_freq` (u32) - The clock frequency of the APU. ``` -------------------------------- ### Create and Boot GameBoy Instance Source: https://docs.rs/boytacean/latest/boytacean/gb/index.html Initializes a new GameBoy instance, loads the boot ROM, and clocks the CPU until it reaches the post-boot address (0x0100). This is useful for starting an emulation session. ```rust use boytacean::gb::{GameBoy, GameBoyMode}; let mut game_boy = GameBoy::new(Some(GameBoyMode::Dmg)); game_boy.load(true).unwrap(); game_boy.load_rom_empty().unwrap(); let cycles = game_boy.step_to(0x0100); println!("Ran {} cycles", cycles); ``` -------------------------------- ### Boot Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html?search= Directly boots the machine to the post-boot state, skipping the boot sequence and jumping to cartridge execution. ```APIDOC ## boot ### Description Directly boots the machine to the post-boot state, skipping the boot sequence and jumping to cartridge execution. ### Method `boot(&mut self)` ``` -------------------------------- ### Get Save State Format as String for WebAssembly Source: https://docs.rs/boytacean/latest/src/boytacean/state.rs.html?search=u32+-%3E+bool WebAssembly-compatible wrapper to get the save state format as a string. It takes raw byte data and returns the format name. ```rust pub fn format_str_wa(data: &[u8]) -> Result { Ok(Self::format(data)?.to_string()) } ``` -------------------------------- ### GameBoy Boot Methods Source: https://docs.rs/boytacean/latest/boytacean/gb/struct.GameBoy.html?search=std%3A%3Avec Methods related to booting and loading the GameBoy state. ```APIDOC ## `boot()` ### Description Direct boot method that immediately jumps the machine to the post boot state, effectively skipping the boot sequence and jumping to the cartridge execution. ### Method `pub fn boot(&mut self)` ### Endpoint N/A (Method Call) ### Parameters None ### Request Example N/A ### Response N/A (Modifies internal state) ## `load_unsafe(boot: bool)` ### Description Unsafe load strategy that will panic the current system in case there are boot ROM loading issues. ### Method `pub fn load_unsafe(&mut self, boot: bool)` ### Endpoint N/A (Method Call) ### Parameters - **boot** (bool) - Description not provided in source. ### Request Example N/A ### Response N/A (Modifies internal state, may panic) ## `load_boot_state()` ### Description Loads the machine directly to after the boot execution state, setting the state of the system accordingly and updating the Program Counter (PC) to the post boot address (0x0100). Should allow the machine to jump to the cartridge (ROM) execution directly, skipping the boot sequence. Currently supports only DMG machines. ### Method `pub fn load_boot_state(&mut self)` ### Endpoint N/A (Method Call) ### Parameters None ### Request Example N/A ### Response N/A (Modifies internal state) ``` -------------------------------- ### Any Trait Implementation for T Source: https://docs.rs/boytacean/latest/boytacean/state/struct.BosInfo.html?search= Gets the TypeId of self. ```rust fn type_id(&self) -> TypeId where T: 'static + ?Sized, ``` -------------------------------- ### boot_rom_s() Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html?search=u32+-%3E+bool Returns a string description of the current boot ROM. ```APIDOC ## boot_rom_s() ### Description Returns a string description of the current boot ROM by calling the `description()` method on the `BootRom`. ### Method `boot_rom_s()` ### Parameters None ### Response - `String` - A string describing the current boot ROM. ``` -------------------------------- ### Any::type_id Source: https://docs.rs/boytacean/latest/boytacean/apu/struct.Apu.html Gets the TypeId of the Apu instance. ```APIDOC ## Any::type_id ### Description Gets the `TypeId` of `self`. ### Signature ```rust fn type_id(&self) -> TypeId ``` ``` -------------------------------- ### Creating a New BosDeviceState Source: https://docs.rs/boytacean/latest/src/boytacean/state.rs.html Initializes a BosDeviceState with a specified GameBoyDevice, StateFormat, and the state data. Sets up the header with the correct block kind and size. ```rust impl BosDeviceState { pub fn new(device: GameBoyDevice, format: StateFormat, state: Vec) -> Self { Self { header: BosBlock::new( BosBlockKind::DeviceState, 1, (size_of::() + size_of::() + state.len()) as u32, ), device, format, state, } } } ``` -------------------------------- ### Get Background Palette Source: https://docs.rs/boytacean/latest/src/boytacean/ppu.rs.html?search=u32+-%3E+bool Retrieves the background palette. ```rust pub fn palette_bg(&self) -> Palette { self.palette_bg } ``` -------------------------------- ### Boot Source: https://docs.rs/boytacean/latest/boytacean/gb/struct.GameBoy.html Directly boots the machine, skipping the boot sequence and jumping to cartridge execution. ```APIDOC ## boot ### Description Direct boot method that immediately jumps the machine to the post boot state, this will effectively skip the boot sequence and jump to the cartridge execution. ### Method `self.boot()` ``` -------------------------------- ### Serial::device Source: https://docs.rs/boytacean/latest/boytacean/serial/struct.Serial.html?search=std%3A%3Avec Gets the current serial device. ```APIDOC ## Serial::device ### Description Gets the current serial device. ### Signature ```rust pub fn device(&self) -> &dyn SerialDevice ``` ### Returns * `&dyn SerialDevice` - A reference to the current serial device. ``` -------------------------------- ### audio_filter_mode Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html Gets the current high-pass filter mode for the audio. ```APIDOC ## audio_filter_mode ### Description Retrieves the current high-pass filter mode of the audio processing unit. ### Method `audio_filter_mode(&self) -> HighPassFilter` ### Response * **Return Value** (HighPassFilter) - The current high-pass filter mode. ``` -------------------------------- ### Cpu::new Source: https://docs.rs/boytacean/latest/boytacean/cpu/struct.Cpu.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Constructs a new Cpu instance with the provided MMU and Game Boy configuration. ```APIDOC ## Cpu::new ### Description Creates a new `Cpu` instance. ### Parameters * `mmu: Mmu` - The Memory Management Unit to be used by the CPU. * `gbc: SharedThread` - Configuration for the Game Boy. ### Returns A new `Cpu` instance. ``` -------------------------------- ### Apu::new Source: https://docs.rs/boytacean/latest/boytacean/apu/struct.Apu.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Initializes a new Apu instance with the specified sampling rate, number of channels, buffer size, and clock frequency. ```APIDOC ## Apu::new ### Description Initializes a new Apu instance with the specified sampling rate, number of channels, buffer size, and clock frequency. ### Signature `pub fn new(sampling_rate: u16, channels: u8, buffer_size: f32, clock_freq: u32) -> Self` ### Parameters * `sampling_rate` (u16) - The audio sampling rate. * `channels` (u8) - The number of audio channels. * `buffer_size` (f32) - The size of the audio buffer. * `clock_freq` (u32) - The clock frequency for the APU. ``` -------------------------------- ### mode() Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html?search=u32+-%3E+bool Gets the current operating mode of the Game Boy. ```APIDOC ## mode() ### Description Returns the current `GameBoyMode` of the Game Boy. ### Method `mode()` ### Parameters None ### Response - `GameBoyMode` - The current operating mode. ``` -------------------------------- ### Sampling Rate Source: https://docs.rs/boytacean/latest/src/boytacean/apu.rs.html?search=std%3A%3Avec Gets the current sampling rate of the APU. ```APIDOC ## sampling_rate ### Description Returns the current sampling rate of the APU. ### Method `sampling_rate()` ### Returns - `u16`: The sampling rate. ``` -------------------------------- ### Basic Ppu Usage Source: https://docs.rs/boytacean/latest/boytacean/ppu/struct.Ppu.html Demonstrates the basic usage of the Ppu struct by creating a default instance and clocking it. ```rust use boytacean::ppu::Ppu; let mut ppu = Ppu::default(); ppu.clock(8); ``` -------------------------------- ### Get Emulator Version Source: https://docs.rs/boytacean/latest/boytacean/info/struct.Info.html?search=u32+-%3E+bool Obtains the version of the emulator as a String. ```rust pub fn version() -> String ``` -------------------------------- ### PPU Initialization and Reset Source: https://docs.rs/boytacean/latest/boytacean/ppu/struct.Ppu.html?search=std%3A%3Avec Provides methods for initializing a new PPU instance and resetting its state. ```APIDOC ## PPU Methods ### `new(mode: GameBoyMode, gbc: SharedThread) -> Self` Initializes a new PPU instance with the specified Game Boy mode and configuration. ### `reset(&mut self)` Resets the PPU to its default state. ``` -------------------------------- ### Get Emulator Name Source: https://docs.rs/boytacean/latest/boytacean/info/struct.Info.html?search=u32+-%3E+bool Obtains the name of the emulator as a String. ```rust pub fn name() -> String ``` -------------------------------- ### GameBoy::new Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html?search= Constructs a new Game Boy instance. It initializes all internal components and the configuration structure. ```APIDOC ## GameBoy::new ### Description Constructs a new Game Boy instance with optional initial mode. Initializes all internal components and the configuration structure. ### Signature ```rust pub fn new(mode: Option) -> Self ``` ### Parameters - **mode** (Option) - Optional. Specifies the initial Game Boy mode (e.g., Dmg). Defaults to `GameBoyMode::Dmg` if `None`. ``` -------------------------------- ### Get Clock Frequency Source: https://docs.rs/boytacean/latest/boytacean/apu/struct.Apu.html Retrieves the clock frequency of the APU. ```rust pub fn clock_freq(&self) -> u32 ``` -------------------------------- ### FromGbOptions Source: https://docs.rs/boytacean/latest/src/boytacean/state.rs.html?search=std%3A%3Avec Options for creating a new emulator state from a Game Boy instance. ```APIDOC ## FromGbOptions ### Description Options for creating a new emulator state from a Game Boy instance. ### Fields - **thumbnail** (bool) - If true, the state will include a thumbnail of the current frame buffer. This will increase the size of the state, but will allow to have a preview of the state without having to load it into the emulator. - **state_format** (Option) - Defines the format to be used in the storage of the state data (controls size of the state). - **agent** (Option) - Name of the agent that is creating the state. If defined it's expected to have this value stored as part of the state. - **agent_version** (Option) - Version of the agent that is creating the state. If defined it's expected to have this value stored as part of the state. ### Methods - **new(thumbnail: bool, state_format: Option, agent: Option, agent_version: Option) -> Self** Creates a new instance of `FromGbOptions`. ``` -------------------------------- ### Get Object Palette 1 Source: https://docs.rs/boytacean/latest/src/boytacean/ppu.rs.html?search=u32+-%3E+bool Retrieves the second object palette. ```rust pub fn palette_obj_1(&self) -> Palette { self.palette_obj_1 } ``` -------------------------------- ### Tile::new Source: https://docs.rs/boytacean/latest/boytacean/ppu/struct.Tile.html?search=std%3A%3Avec Creates a new Tile instance. ```APIDOC ## Tile::new ### Description Creates a new Tile instance. ### Signature `pub fn new() -> Self` ``` -------------------------------- ### GameBoy::new Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html?search=u32+-%3E+bool Constructs a new GameBoy instance. It initializes the Game Boy configuration and all its core components (PPU, APU, DMA, Pad, Timer, Serial, MMU, CPU). ```APIDOC ## GameBoy::new ### Description Constructs a new GameBoy instance. It initializes the Game Boy configuration and all its core components (PPU, APU, DMA, Pad, Timer, Serial, MMU, CPU). ### Method `new(mode: Option) -> Self` ### Parameters * **mode** (Option) - Optional - Specifies the Game Boy mode (e.g., Dmg). Defaults to `GameBoyMode::Dmg` if `None`. ``` -------------------------------- ### Get Object Palette 0 Source: https://docs.rs/boytacean/latest/src/boytacean/ppu.rs.html?search=u32+-%3E+bool Retrieves the first object palette. ```rust pub fn palette_obj_0(&self) -> Palette { self.palette_obj_0 } ``` -------------------------------- ### Get HRAM Slice Source: https://docs.rs/boytacean/latest/src/boytacean/ppu.rs.html?search= Provides a slice of the High RAM (HRAM). ```rust pub fn hram(&self) -> &[u8; HRAM_SIZE] { &self.hram } ``` -------------------------------- ### boot_rom_s Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html Returns a string description of the currently set boot ROM. ```APIDOC ## boot_rom_s ### Description Returns a string description of the currently set boot ROM. ### Method `boot_rom_s()` ### Returns - `String`: A string describing the boot ROM. ``` -------------------------------- ### Number of Channels Source: https://docs.rs/boytacean/latest/src/boytacean/apu.rs.html?search=std%3A%3Avec Gets the number of audio channels the APU supports. ```APIDOC ## channels ### Description Returns the number of audio channels supported by the APU. ### Method `channels()` ### Returns - `u8`: The number of channels. ``` -------------------------------- ### FromGbOptions::new Source: https://docs.rs/boytacean/latest/boytacean/state/struct.FromGbOptions.html Constructs a new FromGbOptions instance with specified parameters for thumbnail generation, state format, and agent information. ```APIDOC ## `FromGbOptions::new` ### Description Constructs a new `FromGbOptions` instance. ### Signature ```rust pub fn new(thumbnail: bool, state_format: Option, agent: Option, agent_version: Option) -> Self ``` ### Parameters * **thumbnail** (`bool`) - Whether to generate a thumbnail. * **state_format** (`Option`) - The desired format for the state. * **agent** (`Option`) - The agent identifier. * **agent_version** (`Option`) - The version of the agent. ``` -------------------------------- ### Get Carry Flag Source: https://docs.rs/boytacean/latest/src/boytacean/cpu.rs.html?search= Returns the current state of the Carry flag. ```rust pub fn carry(&self) -> bool { self.carry } ``` -------------------------------- ### FromGbOptions Source: https://docs.rs/boytacean/latest/src/boytacean/state.rs.html Options for creating a new emulator state from a Game Boy instance. This includes settings for generating a thumbnail, specifying the state format, and providing agent information. ```APIDOC ## FromGbOptions ### Description Options for creating a new emulator state from a Game Boy instance. This includes settings for generating a thumbnail, specifying the state format, and providing agent information. ### Fields - **thumbnail** (bool) - If true, the state will include a thumbnail of the current frame buffer. This will increase the size of the state, but will allow to have a preview of the state without having to load it into the emulator. - **state_format** (Option) - Defines the format to be used in the storage of the state data (controls size of the state). - **agent** (Option) - Name of the agent that is creating the state. If defined it's expected to have this value stored as part of the state. - **agent_version** (Option) - Version of the agent that is creating the state. If defined it's expected to have this value stored as part of the state. ### Methods - **new(thumbnail: bool, state_format: Option, agent: Option, agent_version: Option) -> Self** Constructor for `FromGbOptions`. ### Default - **thumbnail**: true - **state_format**: None - **agent**: None - **agent_version**: None ``` -------------------------------- ### Get Subtract Flag Source: https://docs.rs/boytacean/latest/src/boytacean/cpu.rs.html?search= Returns the current state of the Subtract flag. ```rust pub fn sub(&self) -> bool { self.sub } ``` -------------------------------- ### Example Search: Option, (T -> U) -> Option Source: https://docs.rs/boytacean/latest/boytacean/consts/constant.NR33_ADDR.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Illustrates a common search pattern for function signatures involving Option types and transformations. ```rust Option, (T -> U) -> Option ``` -------------------------------- ### Get Zero Flag Source: https://docs.rs/boytacean/latest/src/boytacean/cpu.rs.html?search= Returns the current state of the Zero flag. ```rust pub fn zero(&self) -> bool { self.zero } ``` -------------------------------- ### BufferDevice::new Source: https://docs.rs/boytacean/latest/boytacean/devices/buffer/struct.BufferDevice.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new instance of BufferDevice. ```APIDOC ## BufferDevice::new ### Description Creates a new instance of `BufferDevice`. ### Method `new()` ### Returns - `Self`: A new `BufferDevice` instance. ``` -------------------------------- ### Get Cycles Source: https://docs.rs/boytacean/latest/src/boytacean/cpu.rs.html?search=u32+-%3E+bool Retrieves the number of cycles executed by the last instruction. ```APIDOC ## `cycles` ### Description Retrieves the number of cycles executed by the last instruction. ### Method `cycles(&self) -> u8` ``` -------------------------------- ### Create BosDeviceState Source: https://docs.rs/boytacean/latest/src/boytacean/state.rs.html?search= Initializes a BosDeviceState with a GameBoyDevice, StateFormat, and state data. ```rust impl BosDeviceState { pub fn new(device: GameBoyDevice, format: StateFormat, state: Vec) -> Self { Self { header: BosBlock::new( BosBlockKind::DeviceState, 1, (size_of::() + size_of::() + state.len()) as u32, ), device, format, state, } } pub fn from_data(reader: &mut R) -> Result { let mut instance = Self::default(); instance.read(reader)?; Ok(instance) } fn from_gb( gb: &mut GameBoy, device: GameBoyDevice, options: &FromGbOptions, ) -> Result { let format: StateFormat = options.state_format.unwrap_or(StateFormat::Partial); match device { GameBoyDevice::Cpu => Ok(Self::new(device, format, gb.cpu_i().state(Some(format))?)), GameBoyDevice::Ppu => Ok(Self::new(device, format, gb.ppu_i().state(Some(format))?)), GameBoyDevice::Apu => Ok(Self::new(device, format, gb.apu_i().state(Some(format))?)), GameBoyDevice::Dma => Ok(Self::new(device, format, gb.dma_i().state(Some(format))?)), ``` -------------------------------- ### Get ROM Size Source: https://docs.rs/boytacean/latest/boytacean/rom/struct.Cartridge.html?search=std%3A%3Avec Retrieves the total size of the ROM in the cartridge. ```rust pub fn rom_size(&self) -> RomSize ``` -------------------------------- ### Audio Filter Mode Source: https://docs.rs/boytacean/latest/boytacean/gb/struct.GameBoy.html?search=std%3A%3Avec Gets and sets the audio filter mode. ```APIDOC ## pub fn audio_filter_mode(&self) -> HighPassFilter ### Description Gets the current audio filter mode. ### Method `&self` ### Return Value `HighPassFilter` ``` ```APIDOC ## pub fn set_audio_filter_mode(&mut self, mode: HighPassFilter) ### Description Sets the audio filter mode. ### Method `&mut self` ### Parameters #### Query Parameters - **mode** (HighPassFilter) - Required - The audio filter mode to set. ``` -------------------------------- ### Initialize and Set APU State Source: https://docs.rs/boytacean/latest/src/boytacean/apu.rs.html Demonstrates initializing an APU with default settings, retrieving its current state, and then applying that state to a new APU instance. This is useful for saving and restoring APU configurations. ```rust let mut apu = Apu::default(); apu.ch1_timer = 1234; apu.ch1_sequence = 5; apu.ch1_envelope_sequence = 3; apu.ch1_envelope_enabled = true; apu.ch1_sweep_sequence = 2; apu.ch1_output = 10; apu.ch1_dac = true; apu.ch1_sweep_slope = 1; apu.ch1_sweep_increase = true; apu.ch1_sweep_pace = 4; apu.ch1_length_timer = 20; apu.ch1_wave_duty = 2; apu.ch1_pace = 3; apu.ch1_direction = 1; apu.ch1_volume = 15; apu.ch1_wave_length = 2048; apu.ch1_length_enabled = true; apu.ch1_enabled = true; apu.ch2_timer = 5678; apu.ch2_sequence = 6; apu.ch2_envelope_sequence = 4; apu.ch2_envelope_enabled = true; apu.ch2_output = 20; apu.ch2_dac = true; apu.ch2_length_timer = 30; apu.ch2_wave_duty = 3; apu.ch2_pace = 5; apu.ch2_direction = 0; apu.ch2_volume = 10; apu.ch2_wave_length = 1024; apu.ch2_length_enabled = true; apu.ch2_enabled = true; apu.ch3_timer = 9111; apu.ch3_position = 7; apu.ch3_output = 30; apu.ch3_dac = true; apu.ch3_length_timer = 40; apu.ch3_output_level = 2; apu.ch3_wave_length = 512; apu.ch3_length_enabled = true; apu.ch3_enabled = true; apu.ch4_timer = 121314; apu.ch4_envelope_sequence = 5; apu.ch4_envelope_enabled = true; apu.ch4_output = 40; apu.ch4_dac = true; apu.ch4_length_timer = 50; apu.ch4_pace = 6; apu.ch4_direction = 1; apu.ch4_volume = 5; apu.ch4_divisor = 2; apu.ch4_width_mode = true; apu.ch4_clock_shift = 3; apu.ch4_lfsr = 0x7ff1; apu.ch4_length_enabled = true; apu.ch4_enabled = true; apu.master = 0x77; apu.glob_panning = 0x88; apu.right_enabled = true; apu.left_enabled = true; apu.sound_enabled = true; apu.ch1_out_enabled = true; apu.ch2_out_enabled = true; apu.ch3_out_enabled = true; apu.ch4_out_enabled = true; let state = apu.state(None).unwrap(); assert_eq!(state.len(), 109); let mut new_apu = Apu::default(); new_apu.set_state(&state, None).unwrap(); assert_eq!(new_apu.ch1_timer, 1234); assert_eq!(new_apu.ch1_sequence, 5); assert_eq!(new_apu.ch1_envelope_sequence, 3); assert!(new_apu.ch1_envelope_enabled); assert_eq!(new_apu.ch1_sweep_sequence, 2); assert_eq!(new_apu.ch1_output, 10); assert!(new_apu.ch1_dac); assert_eq!(new_apu.ch1_sweep_slope, 1); assert!(new_apu.ch1_sweep_increase); assert_eq!(new_apu.ch1_sweep_pace, 4); assert_eq!(new_apu.ch1_length_timer, 20); assert_eq!(new_apu.ch1_wave_duty, 2); assert_eq!(new_apu.ch1_pace, 3); assert_eq!(new_apu.ch1_direction, 1); assert_eq!(new_apu.ch1_volume, 15); assert_eq!(new_apu.ch1_wave_length, 2048); assert!(new_apu.ch1_length_enabled); assert!(new_apu.ch1_enabled); assert_eq!(new_apu.ch2_timer, 5678); assert_eq!(new_apu.ch2_sequence, 6); assert_eq!(new_apu.ch2_envelope_sequence, 4); assert!(new_apu.ch2_envelope_enabled); assert_eq!(new_apu.ch2_output, 20); assert!(new_apu.ch2_dac); assert_eq!(new_apu.ch2_length_timer, 30); assert_eq!(new_apu.ch2_wave_duty, 3); assert_eq!(new_apu.ch2_pace, 5); assert_eq!(new_apu.ch2_direction, 0); assert_eq!(new_apu.ch2_volume, 10); assert_eq!(new_apu.ch2_wave_length, 1024); assert!(new_apu.ch2_length_enabled); assert!(new_apu.ch2_enabled); assert_eq!(new_apu.ch3_timer, 9111); assert_eq!(new_apu.ch3_position, 7); assert_eq!(new_apu.ch3_output, 30); assert!(new_apu.ch3_dac); assert_eq!(new_apu.ch3_length_timer, 40); assert_eq!(new_apu.ch3_output_level, 2); assert_eq!(new_apu.ch3_wave_length, 512); assert!(new_apu.ch3_length_enabled); assert!(new_apu.ch3_enabled); assert_eq!(new_apu.ch4_timer, 121314); assert_eq!(new_apu.ch4_envelope_sequence, 5); assert!(new_apu.ch4_envelope_enabled); assert_eq!(new_apu.ch4_output, 40); assert!(new_apu.ch4_dac); assert_eq!(new_apu.ch4_length_timer, 50); assert_eq!(new_apu.ch4_pace, 6); assert_eq!(new_apu.ch4_direction, 1); assert_eq!(new_apu.ch4_volume, 5); assert_eq!(new_apu.ch4_divisor, 2); assert!(new_apu.ch4_width_mode); assert_eq!(new_apu.ch4_clock_shift, 3); assert_eq!(new_apu.ch4_lfsr, 0x7ff1); assert!(new_apu.ch4_length_enabled); assert!(new_apu.ch4_enabled); assert_eq!(new_apu.master, 0x77); assert_eq!(new_apu.glob_panning, 0x88); assert!(new_apu.right_enabled); assert!(new_apu.left_enabled); assert!(new_apu.sound_enabled); assert!(new_apu.ch1_out_enabled); assert!(new_apu.ch2_out_enabled); assert!(new_apu.ch3_out_enabled); assert!(new_apu.ch4_out_enabled); ``` -------------------------------- ### FromGbOptions::new Source: https://docs.rs/boytacean/latest/boytacean/state/struct.FromGbOptions.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Constructs a new FromGbOptions instance with specified parameters for thumbnail generation and agent details. ```APIDOC ## pub fn new( thumbnail: bool, state_format: Option, agent: Option, agent_version: Option, ) -> Self ### Description Creates a new `FromGbOptions` instance. This is used to configure options for generating data from a Game Boy. ### Parameters * **thumbnail** (bool) - Required - Whether to generate a thumbnail. * **state_format** (Option) - Optional - The desired format for the state data. * **agent** (Option) - Optional - The name of the agent or tool being used. * **agent_version** (Option) - Optional - The version of the agent or tool. ``` -------------------------------- ### Get Compilation Time Source: https://docs.rs/boytacean/latest/boytacean/info/struct.Info.html?search=u32+-%3E+bool Retrieves the time when the Boytacean library was compiled. ```rust pub fn compilation_time() -> String ``` -------------------------------- ### Get Compilation Date Source: https://docs.rs/boytacean/latest/boytacean/info/struct.Info.html?search=u32+-%3E+bool Retrieves the date when the Boytacean library was compiled. ```rust pub fn compilation_date() -> String ``` -------------------------------- ### Cpu Initialization Source: https://docs.rs/boytacean/latest/boytacean/cpu/struct.Cpu.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new Cpu instance with a given MMU and Game Boy configuration. ```rust pub fn new(mmu: Mmu, gbc: SharedThread) -> Self ``` -------------------------------- ### Get Boot ROM Description Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html?search= Returns a string description of the currently configured boot ROM. ```rust pub fn boot_rom_s(&self) -> String { String::from(self.boot_rom().description()) } ``` -------------------------------- ### Get Emulated System Source: https://docs.rs/boytacean/latest/boytacean/info/struct.Info.html?search=u32+-%3E+bool Obtains the name of the system that the emulator is emulating. ```rust pub fn system() -> String ``` -------------------------------- ### Boot ROM Management Source: https://docs.rs/boytacean/latest/boytacean/gb/struct.GameBoy.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods for loading boot ROMs. ```APIDOC ## Load Boot ROM Data ### Description Loads boot ROM data from a byte slice. ### Method `load_boot(&mut self, data: &[u8])` ``` ```APIDOC ## Load Boot ROM Path ### Description Loads boot ROM from a file path. ### Method `load_boot_path(&mut self, path: &str) -> Result<(), Error>` ``` ```APIDOC ## Load Static Boot ROM ### Description Loads a static boot ROM. ### Method `load_boot_static(&mut self, boot_rom: BootRom)` ``` ```APIDOC ## Load Boot ROM File ### Description Loads a boot ROM from a file. ### Method `load_boot_file(&mut self, boot_rom: BootRom) -> Result<(), Error>` ``` ```APIDOC ## Load Default Boot ROM ### Description Loads the default boot ROM. ### Method `load_boot_default(&mut self, boot_rom: Option) -> Result<(), Error>` ``` ```APIDOC ## Load Smart Boot ROM ### Description Loads a smart boot ROM. ### Method `load_boot_smart(&mut self, boot_rom: Option) -> Result<(), Error>` ``` ```APIDOC ## Load DMG Boot ROM ### Description Loads the default boot ROM for DMG. ### Method `load_boot_dmg(&mut self, boot_rom: Option) -> Result<(), Error>` ``` ```APIDOC ## Load CGB Boot ROM ### Description Loads the default boot ROM for CGB. ### Method `load_boot_cgb(&mut self, boot_rom: Option) -> Result<(), Error>` ``` ```APIDOC ## Load Default Boot ROM (f) ### Description Loads the default boot ROM, with a specific flag 'f'. ### Method `load_boot_default_f(&mut self, boot_rom: Option) -> Result<(), Error>` ``` ```APIDOC ## Load Smart Boot ROM (f) ### Description Loads a smart boot ROM, with a specific flag 'f'. ### Method `load_boot_smart_f(&mut self, boot_rom: Option) -> Result<(), Error>` ``` ```APIDOC ## Load DMG Boot ROM (f) ### Description Loads the default boot ROM for DMG, with a specific flag 'f'. ### Method `load_boot_dmg_f(&mut self, boot_rom: Option) -> Result<(), Error>` ``` ```APIDOC ## Load CGB Boot ROM (f) ### Description Loads the default boot ROM for CGB, with a specific flag 'f'. ### Method `load_boot_cgb_f(&mut self, boot_rom: Option) -> Result<(), Error>` ``` -------------------------------- ### Get Tile Source: https://docs.rs/boytacean/latest/boytacean/gb/struct.GameBoy.html Obtains the tile structure for the tile at the given index. ```APIDOC ## get_tile ### Description Obtains the tile structure for the tile at the given index, no conversion in the pixel buffer is done so that the color reference is the GB one. ### Method `self.get_tile(index: usize)` ### Parameters - **index** (usize) - The index of the tile to retrieve. ### Returns Tile: The tile structure. ``` -------------------------------- ### Get Timer Reference Source: https://docs.rs/boytacean/latest/boytacean/cpu/struct.Cpu.html Provides mutable access to the system timer. ```rust pub fn timer(&mut self) -> &mut Timer ``` -------------------------------- ### load_boot_cgb Source: https://docs.rs/boytacean/latest/src/boytacean/gb.rs.html?search= Loads the CGB boot ROM. It verifies compatibility and loads the static boot ROM. An error is returned for incompatible boot ROMs. ```APIDOC ## load_boot_cgb ### Description Loads the CGB boot ROM. It verifies compatibility and loads the static boot ROM. An error is returned for incompatible boot ROMs. ### Method `pub fn load_boot_cgb(&mut self, boot_rom: Option) -> Result<(), Error>` ### Parameters - `boot_rom` (Option): The boot ROM to load. If `None`, defaults to `BootRom::CgbBoytacean`. ### Returns - `Result<(), Error>`: Ok(()) on success, or an Error if the boot ROM is incompatible. ``` -------------------------------- ### Get Sampling Rate Source: https://docs.rs/boytacean/latest/boytacean/apu/struct.Apu.html Retrieves the current sampling rate of the APU. ```rust pub fn sampling_rate(&self) -> u16 ``` -------------------------------- ### Rust Option Basic Usage Source: https://docs.rs/boytacean/latest/src/boytacean/data.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates the basic creation and usage of Option with Some and None variants. ```rust let some_value: Option = Some(5); let no_value: Option = None; ```