[][src]Struct monotron_api::Api

#[repr(C)]
pub struct Api {
    pub putchar: extern "C" fn(ch: u8) -> i32,
    pub puts: extern "C" fn(string: *const u8) -> i32,
    pub readc: extern "C" fn() -> i32,
    pub kbhit: extern "C" fn() -> i32,
    pub move_cursor: extern "C" fn(row: u8, col: u8),
    pub play: extern "C" fn(frequency: u32, channel: u8, volume: u8, waveform: u8) -> i32,
    pub change_font: extern "C" fn(font_id: u32, font_data: *const u8),
    pub get_joystick: extern "C" fn() -> u8,
    pub set_cursor_visible: extern "C" fn(enabled: u8),
    pub read_char_at: extern "C" fn(row: u8, col: u8) -> u16,
    pub wfvbi: extern "C" fn(),
    pub open: extern "C" fn(filename: BorrowedString, mode: OpenMode) -> HandleResult,
    pub close: extern "C" fn(handle: Handle) -> EmptyResult,
    pub read: extern "C" fn(handle: Handle, buffer: *mut u8, buffer_len: usize) -> SizeResult,
    pub write: extern "C" fn(handle: Handle, buffer: *const u8, buffer_len: usize) -> SizeResult,
    pub write_then_read: extern "C" fn(handle: Handle, out_buffer: *const u8, out_buffer_len: usize, in_buffer: *mut u8, in_buffer_len: usize) -> SizeResult,
    pub seek: extern "C" fn(handle: Handle, offset: Offset) -> EmptyResult,
    pub opendir: extern "C" fn(filename: BorrowedString) -> HandleResult,
    pub readdir: extern "C" fn(handle: Handle, dir_entry: &mut DirEntry) -> EmptyResult,
    pub stat: extern "C" fn(filename: BorrowedString, stat_entry: &mut DirEntry) -> EmptyResult,
    pub gettime: extern "C" fn() -> Timestamp,
    pub puts_utf8: extern "C" fn(string: *const u8, length: usize),
    pub map_line: extern "C" fn(actual_scanline: u16, drawn_scanline: u16),
    pub get_cursor: extern "C" fn(row: *mut u8, col: *mut u8),
}

This structure contains all the function pointers the application can use to access OS functions.

Fields

putchar: extern "C" fn(ch: u8) -> i32

Old function for writing a single 8-bit character to the screen.

puts: extern "C" fn(string: *const u8) -> i32

Old function for writing a null-terminated 8-bit string to the screen.

readc: extern "C" fn() -> i32

Old function for reading one byte from stdin, blocking.

kbhit: extern "C" fn() -> i32

Old function for checking if readc() would block.

move_cursor: extern "C" fn(row: u8, col: u8)

Old function for moving the cursor on screen. To be replaced with ANSI escape codes.

play: extern "C" fn(frequency: u32, channel: u8, volume: u8, waveform: u8) -> i32

Old function for playing a note.

change_font: extern "C" fn(font_id: u32, font_data: *const u8)

Old function for changing the on-screen font.

get_joystick: extern "C" fn() -> u8

Old function for reading the Joystick status.

set_cursor_visible: extern "C" fn(enabled: u8)

Old function for turning the cursor on/off.

read_char_at: extern "C" fn(row: u8, col: u8) -> u16

Old function for reading the contents of the screen.

wfvbi: extern "C" fn()

Wait for next vertical blanking interval.

open: extern "C" fn(filename: BorrowedString, mode: OpenMode) -> HandleResult

Open/create a device/file. Returns a file handle, or an error.

close: extern "C" fn(handle: Handle) -> EmptyResult

Close a previously opened handle.

read: extern "C" fn(handle: Handle, buffer: *mut u8, buffer_len: usize) -> SizeResult

Read from a file handle into the given buffer. Returns an error, or the number of bytes read (which may be less than buffer_len).

write: extern "C" fn(handle: Handle, buffer: *const u8, buffer_len: usize) -> SizeResult

Write the contents of the given buffer to a file handle. Returns an error, or the number of bytes written (which may be less than buffer_len).

write_then_read: extern "C" fn(handle: Handle, out_buffer: *const u8, out_buffer_len: usize, in_buffer: *mut u8, in_buffer_len: usize) -> SizeResult

Write to the handle and the read from the handle. Useful when doing an I2C read of a specific address. It is an error if the complete out_buffer could not be written.

seek: extern "C" fn(handle: Handle, offset: Offset) -> EmptyResult

Move the read/write pointer in a file.

opendir: extern "C" fn(filename: BorrowedString) -> HandleResult

Open a directory. Returns a file handle, or an error.

readdir: extern "C" fn(handle: Handle, dir_entry: &mut DirEntry) -> EmptyResult

Read directory entry into given buffer.

stat: extern "C" fn(filename: BorrowedString, stat_entry: &mut DirEntry) -> EmptyResult

Get information about a file by path

gettime: extern "C" fn() -> Timestamp

Get the current time

puts_utf8: extern "C" fn(string: *const u8, length: usize)

Old function for writing a UTF-8 string to the screen.

map_line: extern "C" fn(actual_scanline: u16, drawn_scanline: u16)

Maps an actual line on the screen to be drawn as if it was somewhere else on the screen.

So if you ran this, the image would look completely normal:

for x in 0..576 {
    map_line(x, x);
}

But if you did this, the screen would be upside down.

for x in 0..576 {
    map_line(x, 576 - x);
}

And if you did this, the top 32 scanlines on the screen would repeat all the way down.

for x in 0..576 {
    map_line(x, x % 32);
}
get_cursor: extern "C" fn(row: *mut u8, col: *mut u8)

Get the current cursor position

Auto Trait Implementations

impl Unpin for Api

impl Send for Api

impl Sync for Api

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]