55/// The corresponding value is the fill colour, which is taken modulo the number of on-screen colours.
66pub const COMMAND_CLEAR_SCREEN : u64 = 0 ;
77
8- /// Plot a chunky pixel
8+ /// Plot a chunky pixel (and move the cursor).
99///
1010/// The command contains [ x | y | mode | colour ].
1111///
@@ -29,16 +29,52 @@ pub const COMMAND_CHUNKY_PLOT: u64 = 1;
2929/// Use [`change_mode_value`] to construct a value.
3030pub const COMMAND_CHANGE_MODE : u64 = 2 ;
3131
32- /// Calculate a 64-bit value argument for a gfx ioctl
32+ /// Move the cursor
33+ ///
34+ /// The command contains [ x | y | <padding> ].
35+ ///
36+ /// The graphics handle maintains a virtual cursor position. This is used for
37+ /// plotting lines for example - you move the cursor to one end of the line, and
38+ /// then issue a LINE_DRAW ioctl containing the other end of the line. This saves
39+ /// having to try and pass two sets of co-ordinates within one ioctl.
40+ ///
41+ /// Use [`move_cursor_value`] to construct a value.
42+ pub const COMMAND_MOVE_CURSOR : u64 = 3 ;
43+
44+ /// Draw a line
45+ ///
46+ /// The command contains [ x | y | mode | colour ].
47+ ///
48+ /// * `x` is 16 bits and marks the final horizontal position (0 is left)
49+ /// * `y` is 16 bits and marks the final vertical position (0 is top)
50+ /// * `mode` is 8 bits and is currently ignored
51+ /// * `colour` is 24 bits, and is taken modulo the number of on-screen colours
52+ ///
53+ /// The start position is the cursor position. The cursor is updated to the final position.
54+ ///
55+ /// Use [`draw_line_value`] to construct a value.
56+ pub const COMMAND_DRAW_LINE : u64 = 4 ;
57+
58+ /// Calculate a 64-bit value argument for the [`COMMAND_CHUNKY_PLOT`] gfx ioctl
3359pub fn chunky_plot_value ( x : u16 , y : u16 , colour : u32 ) -> u64 {
3460 ( x as u64 ) << 48 | ( y as u64 ) << 32 | ( colour & 0xFFFFFF ) as u64
3561}
3662
37- /// Calculate a 64-bit value argument for a gfx ioctl
63+ /// Calculate a 64-bit value argument for the [`COMMAND_CHANGE_MODE`] gfx ioctl
3864pub fn change_mode_value ( mode : crate :: VideoMode , fb_ptr : * mut u32 ) -> u64 {
3965 let fb_ptr = fb_ptr as usize as u64 ;
4066 let mode = mode. as_u8 ( ) as u64 ;
4167 mode << 32 | fb_ptr
4268}
4369
70+ /// Calculate a 64-bit value argument for the [`COMMAND_MOVE_CURSOR`] gfx ioctl
71+ pub fn move_cursor_value ( x : u16 , y : u16 ) -> u64 {
72+ ( x as u64 ) << 48 | ( y as u64 ) << 32
73+ }
74+
75+ /// Calculate a 64-bit value argument for the [`COMMAND_DRAW_LINE`] gfx ioctl
76+ pub fn draw_line_value ( end_x : u16 , end_y : u16 , colour : u32 ) -> u64 {
77+ ( end_x as u64 ) << 48 | ( end_y as u64 ) << 32 | ( colour & 0xFFFFFF ) as u64
78+ }
79+
4480// End of file
0 commit comments