@@ -65,31 +65,77 @@ fn print_modes() {
6565 let api = crate :: API . get ( ) ;
6666 let current_mode = ( api. video_get_mode ) ( ) ;
6767 let mut any_mode = false ;
68- for mode_no in 0 ..255 {
69- // Note (unsafe): we'll test if it's right before we try and use it
70- let Some ( m) = Mode :: try_from_u8 ( mode_no) else {
71- continue ;
72- } ;
73- let is_supported = ( api. video_is_valid_mode ) ( m) ;
74- if is_supported {
75- any_mode = true ;
76- let is_current = if current_mode == m { "*" } else { " " } ;
77- let text_rows = m. text_height ( ) ;
78- let text_cols = m. text_width ( ) ;
79- let f = m. format ( ) ;
80- let width = m. horizontal_pixels ( ) ;
81- let height = m. vertical_lines ( ) ;
82- let hz = m. frame_rate_hz ( ) ;
83- if let ( Some ( text_rows) , Some ( text_cols) ) = ( text_rows, text_cols) {
84- // It's a text mode
85- osprintln ! ( "{mode_no:3}{is_current}: {width} x {height} @ {hz} Hz {f} ({text_cols} x {text_rows})" ) ;
86- } else {
87- // It's a framebuffer mode
88- let f = m. format ( ) ;
89- osprintln ! ( "{mode_no:3}{is_current}: {width} x {height} @ {hz} Hz {f}" ) ;
68+
69+ let formats = [
70+ ( "T16 " , neotron_common_bios:: video:: Format :: Text8x16 ) ,
71+ ( "T8 " , neotron_common_bios:: video:: Format :: Text8x8 ) ,
72+ ( "C32 " , neotron_common_bios:: video:: Format :: Chunky32 ) ,
73+ ( "C16 " , neotron_common_bios:: video:: Format :: Chunky16 ) ,
74+ ( "C8 " , neotron_common_bios:: video:: Format :: Chunky8 ) ,
75+ ( "C4 " , neotron_common_bios:: video:: Format :: Chunky4 ) ,
76+ ( "C2 " , neotron_common_bios:: video:: Format :: Chunky2 ) ,
77+ ( "C1 " , neotron_common_bios:: video:: Format :: Chunky1 ) ,
78+ ] ;
79+
80+ osprint ! ( " " ) ;
81+ for ( name, _) in formats {
82+ osprint ! ( "{}" , name) ;
83+ }
84+ osprintln ! ( ) ;
85+
86+ for scaling in [
87+ neotron_common_bios:: video:: Scaling :: None ,
88+ neotron_common_bios:: video:: Scaling :: DoubleHeight ,
89+ neotron_common_bios:: video:: Scaling :: DoubleWidth ,
90+ neotron_common_bios:: video:: Scaling :: DoubleWidthAndHeight ,
91+ ] {
92+ for timing in [
93+ neotron_common_bios:: video:: Timing :: T640x480 ,
94+ neotron_common_bios:: video:: Timing :: T640x400 ,
95+ neotron_common_bios:: video:: Timing :: T800x600 ,
96+ ] {
97+ // check if any formats work for this timing mode
98+ let mut any_format = false ;
99+ for ( _, format) in formats {
100+ let m = neotron_common_bios:: video:: Mode :: new_with_scaling ( timing, format, scaling) ;
101+ let is_supported = ( api. video_is_valid_mode ) ( m) ;
102+ if is_supported {
103+ any_format = true ;
104+ break ;
105+ }
106+ }
107+ // if there's a valid format, print the line (otherwise skip it for brevity)
108+ if any_format {
109+ let basic_mode = neotron_common_bios:: video:: Mode :: new_with_scaling (
110+ timing,
111+ neotron_common_bios:: video:: Format :: Chunky1 ,
112+ scaling,
113+ ) ;
114+ osprint ! (
115+ "{:03}x{:03}:" ,
116+ basic_mode. horizontal_pixels( ) ,
117+ basic_mode. vertical_lines( )
118+ ) ;
119+ for ( _, format) in formats {
120+ let m =
121+ neotron_common_bios:: video:: Mode :: new_with_scaling ( timing, format, scaling) ;
122+ let is_supported = ( api. video_is_valid_mode ) ( m) ;
123+ if is_supported {
124+ osprint ! (
125+ "{:03}{}" ,
126+ m. as_u8( ) ,
127+ if current_mode == m { "<" } else { " " }
128+ ) ;
129+ any_mode = true ;
130+ } else {
131+ osprint ! ( "--- " ) ;
132+ }
133+ }
134+ osprintln ! ( ) ;
90135 }
91136 }
92137 }
138+
93139 if !any_mode {
94140 osprintln ! ( "No valid modes found" ) ;
95141 }
0 commit comments