Struct tms9918a_emu::TMS9918A [−][src]
Fields
frame: Vec<u32>
VDP framebuffer
frame_width: usize
VDP framebuffer width
frame_height: usize
VDP framebuffer height
vdp_ram: Vec<u8>
TMS9918A video memory, 16KB: contains name table, color table, and pattern table
Initialized with random values to simulate real memory behavior.
Implementations
impl TMS9918A
[src]
pub fn new() -> Self
[src]
pub fn update(&mut self)
[src]
Update the framebuffer from the TMS9918A video memory contents
Examples
let mut vdp = TMS9918A::new(); while vdp.window.is_open() { vdp.update(); }
pub fn enable_video(&mut self, enable: bool)
[src]
Enable or disable the video display by setting or clearing the blanking bit in register 1
The video display is disabled by default due to registers 0 and 1 being cleared on reset, resulting in a black screen similar to the behavior of a real TMS9918A.
pub fn warm_reset(&mut self)
[src]
Reset VDP to initial state without modifying video memory
pub fn cold_reset(&mut self)
[src]
Reset VDP to initial state and randomize video memory contents
pub fn set_video_mode(&mut self, mode: VideoMode)
[src]
Set TMS9918A video mode
Valid video modes are Text, Graphics I, Graphics II, and Multicolor.
Graphics II and Multicolor modes are not currently implemented, and sprites are not currently implemented in any mode.
Undocumented modes (combining video modes by setting the bitmap enable bit in register 0) are not supported.
Examples
// use text mode vdp.set_video_mode(VideoMode::Text);
pub fn write_register(&mut self, register: u8, data: u8)
[src]
Write register value
pub fn write_ram(&mut self, address: usize, data: u8)
[src]
Write memory contents
pub fn read_ram(&mut self, address: usize) -> u8
[src]
Read memory contents
pub fn set_name_table_multiplier(&mut self, mut multiplier: u8)
[src]
Set the name table address multiplier in register 2
Name table base address is equal to multiplier * 0x0400.
This function is equivalent to setting register 2 directly.
Examples
// set name table base address to 0x0400 vdp.set_name_table_multiplier(1);
pub fn fill_name_table(&mut self, array: &[u8], offset: usize, length: usize)
[src]
Fill name table contents from an array
Name table offset register must be set first.
Examples
// fill the first 5 name table entries let name_table: [u8; 5] = [1, 2, 3, 4, 5]; vdp.fill_name_table(&name_table, 0, name_table.len());
pub fn clear_name_table(&mut self)
[src]
Clear the screen by zeroing the name table
Name table offset register must be set first.
pub fn write_name_table(&mut self, offset: usize, data: u8)
[src]
Write name table contents
Name table offset register must be set first.
pub fn read_name_table(&self, offset: usize) -> u8
[src]
Read name table contents
Name table offset register must be set first.
pub fn set_color_table_multiplier(&mut self, multiplier: u8)
[src]
Set the color table address multiplier in register 3
Color table base address is equal to multiplier * 0x0040.
This function is equivalent to setting register 3 directly.
Examples
// set color table base address to 0x0040 vdp.set_color_table_multiplier(1);
pub fn fill_color_table(&mut self, array: &[u8], offset: usize, length: usize)
[src]
Fill color table contents from an array
Color table offset register must be set first.
Examples
// fill the first 5 color table entries // black on white, white on black, light blue on dark blue, light red on cyan, black on gray let color_table: [u8; 5] = [0x1F, 0xF1, 0x54, 0x97, 0x1E]; vdp.fill_color_table(&color_table, 0, color_table.len());
pub fn write_color_table(&mut self, offset: usize, data: u8)
[src]
Write color table contents
Color table offset register must be set first.
pub fn read_color_table(&self, offset: usize) -> u8
[src]
Read color table contents
Color table offset register must be set first.
pub fn set_pattern_table_multiplier(&mut self, mut multiplier: u8)
[src]
Set the pattern table address multiplier in register 4
Pattern table base address is equal to multiplier * 0x0800.
This function is equivalent to setting register 4 directly.
Examples
// set pattern table base address to 0x0800 vdp.set_pattern_table_multiplier(1);
pub fn fill_pattern_table(&mut self, array: &[u8], offset: usize, length: usize)
[src]
Fill pattern table contents from an array
Pattern table offset register must be set first.
Examples
// fill 8 pattern table entries starting at offset 8 // 8 pattern table entries make one tile // this makes tile 1 a nice smiley face :) let pattern_table: [u8; 8] = [0b00000000, 0b00100100, 0b00100100, 0b00100100, 0b00000000, 0b01000010, 0b01111110, 0b00000000]; vdp.fill_pattern_table(&pattern_table, 8, pattern_table.len());
pub fn write_pattern_table(&mut self, offset: usize, data: u8)
[src]
Write pattern table contents
Pattern table offset register must be set first.
pub fn read_pattern_table(&self, offset: usize) -> u8
[src]
Read pattern table contents
Pattern table offset register must be set first.
pub fn write_control_port(&mut self, data: u8)
[src]
Write to the TMS9918A control port
This expects standard TMS9918A commands, see the TMS9918A Data Manual for details.
pub fn write_data_port(&mut self, data: u8)
[src]
Write to the TMS9918A data port
This follows the standard TMS9918A behavior of incrementing the addr. pointer after each write, see the TMS9918A Data Manual for details.
pub fn read_data_port(&mut self) -> u8
[src]
Read from the TMS9918A data port
This follows the standard TMS9918A behavior of incrementing the addr. pointer after each read, see the TMS9918A Data Manual for details.
Auto Trait Implementations
impl RefUnwindSafe for TMS9918A
[src]
impl Send for TMS9918A
[src]
impl Sync for TMS9918A
[src]
impl Unpin for TMS9918A
[src]
impl UnwindSafe for TMS9918A
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,