Struct Api

Source
#[repr(C)]
pub struct Api {
Show 24 fields 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),
}
Expand description

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 Freeze for Api

§

impl RefUnwindSafe for Api

§

impl Send for Api

§

impl Sync for Api

§

impl Unpin for Api

§

impl UnwindSafe for Api

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.