11//! Screen-related commands for Neotron OS
22
3- use neotron_common_bios:: video:: RGBColour ;
4- use pc_keyboard:: DecodedKey ;
5-
63use crate :: {
74 bios:: {
85 video:: { Format , Mode } ,
@@ -138,18 +135,34 @@ fn gfx_cmd(_menu: &menu::Menu<Ctx>, item: &menu::Item<Ctx>, args: &[&str], ctx:
138135 } ;
139136 let _ = file. read ( buffer) ;
140137 } else {
138+ let ( odd_pattern, even_pattern) = match mode. format ( ) {
139+ // This is alternating hearts and diamonds
140+ Format :: Text8x16 | Format :: Text8x8 => (
141+ u32:: from_le_bytes ( * b"\x03 \x0F \x04 \x70 " ) ,
142+ u32:: from_le_bytes ( * b"\x04 \x70 \x03 \x0F " ) ,
143+ ) ,
144+ // Can't do a checkerboard here - so stripes will do
145+ Format :: Chunky32 => ( 0x0000_0000 , 0x0000_0001 ) ,
146+ // These should produce black/white checkerboard, in the default
147+ // palette
148+ Format :: Chunky16 => ( 0x0000_FFFF , 0xFFFF_0000 ) ,
149+ Format :: Chunky8 => ( 0x000F_000F , 0x0F00_0F00 ) ,
150+ Format :: Chunky4 => ( 0x0F0F_0F0F , 0xF0F0_F0F0 ) ,
151+ Format :: Chunky2 => ( 0x3333_3333 , 0xCCCC_CCCC ) ,
152+ Format :: Chunky1 => ( 0x5555_5555 , 0xAAAA_AAAA ) ,
153+ _ => todo ! ( ) ,
154+ } ;
141155 // draw a dummy non-zero data. In Chunky1 this is a checkerboard.
142156 let line_size_words = mode. line_size_bytes ( ) / 4 ;
143157 for row in 0 ..mode. vertical_lines ( ) as usize {
144158 let word = if ( row % 2 ) == 0 {
145- 0x5555_5555
159+ even_pattern
146160 } else {
147- 0xAAAA_AAAA
161+ odd_pattern
148162 } ;
149163 for col in 0 ..line_size_words {
150164 let idx = ( row * line_size_words) + col;
151165 unsafe {
152- // Let's try stripes?
153166 buffer_ptr. add ( idx) . write_volatile ( word) ;
154167 }
155168 }
@@ -163,20 +176,8 @@ fn gfx_cmd(_menu: &menu::Menu<Ctx>, item: &menu::Item<Ctx>, args: &[&str], ctx:
163176 }
164177
165178 // Now wait for user input
166- let mut r = 0u8 ;
167- let mut g = 80u8 ;
168- let mut b = 160u8 ;
169- ' wait: loop {
170- ( api. video_wait_for_line ) ( 0 ) ;
171- ( ( api. video_set_palette ) ( 0 , RGBColour :: from_rgb ( r, g, b) ) ) ;
172- r = r. wrapping_add ( 1 ) ;
173- g = g. wrapping_add ( 1 ) ;
174- b = b. wrapping_add ( 1 ) ;
175-
176- let keyin = crate :: STD_INPUT . lock ( ) . get_raw ( ) ;
177- if let Some ( DecodedKey :: Unicode ( 'Q' ) | DecodedKey :: Unicode ( 'q' ) ) = keyin {
178- break ' wait;
179- }
179+ while crate :: STD_INPUT . lock ( ) . get_raw ( ) . is_none ( ) {
180+ // spin
180181 }
181182
182183 // Put it back as it was
0 commit comments