11use crate :: commands;
22use crate :: serial;
3- use reedline_repl_rs:: clap:: { ArgMatches , Command } ;
3+ use reedline_repl_rs:: clap:: { Arg , ArgMatches , Command } ;
44use reedline_repl_rs:: { Repl , Result } ;
55use serialport:: SerialPort ;
66
@@ -19,13 +19,35 @@ pub fn start_repl(port: &mut Box<dyn SerialPort>) -> Result<()> {
1919 . with_banner ( "Welcome to matrix65!" )
2020 . with_command ( Command :: new ( "reset" ) . about ( "Reset MEGA65" ) , reset)
2121 . with_command ( Command :: new ( "go64" ) . about ( "Go to C64 mode" ) , go64)
22+ . with_command ( Command :: new ( "stop" ) . about ( "Halt CPU" ) , stop)
23+ . with_command ( Command :: new ( "start" ) . about ( "Resume CPU" ) , start)
24+ . with_command (
25+ Command :: new ( "dasm" )
26+ . about ( "Disassemble memory (prefix hex values w. 0x....)" )
27+ . arg ( Arg :: new ( "address" ) . required ( true ) )
28+ . arg ( Arg :: new ( "length" ) . required ( true ) ) ,
29+ peek,
30+ )
2231 . with_command (
2332 Command :: new ( "filehost" ) . about ( "Start the filehost" ) ,
2433 filehost,
2534 ) ;
2635 repl. run ( )
2736}
2837
38+ /// Wrap peek command
39+ fn peek ( _args : ArgMatches , context : & mut Context ) -> Result < Option < String > > {
40+ let address = _args. value_of ( "address" ) . unwrap ( ) . to_string ( ) ;
41+ let length = _args. value_of ( "length" ) . unwrap_or ( "1" ) . to_string ( ) . parse :: < usize > ( ) ?;
42+ match commands:: peek ( context. port , address, length, None , true ) {
43+ Err ( err) => Err ( reedline_repl_rs:: Error :: IllegalDefaultError (
44+ err. to_string ( ) ,
45+ ) ) ,
46+ Ok ( ( ) ) => Ok ( None ) ,
47+ }
48+ }
49+
50+
2951/// Wrap reset command
3052fn reset ( _args : ArgMatches , context : & mut Context ) -> Result < Option < String > > {
3153 match commands:: reset ( context. port , false ) {
@@ -46,6 +68,26 @@ fn go64(_args: ArgMatches, context: &mut Context) -> Result<Option<String>> {
4668 }
4769}
4870
71+ /// Wrap stop cpu command
72+ fn stop ( _args : ArgMatches , context : & mut Context ) -> Result < Option < String > > {
73+ match serial:: stop_cpu ( context. port ) {
74+ Err ( err) => Err ( reedline_repl_rs:: Error :: IllegalDefaultError (
75+ err. to_string ( ) ,
76+ ) ) ,
77+ Ok ( ( ) ) => Ok ( None ) ,
78+ }
79+ }
80+
81+ /// Wrap start cpu command
82+ fn start ( _args : ArgMatches , context : & mut Context ) -> Result < Option < String > > {
83+ match serial:: start_cpu ( context. port ) {
84+ Err ( err) => Err ( reedline_repl_rs:: Error :: IllegalDefaultError (
85+ err. to_string ( ) ,
86+ ) ) ,
87+ Ok ( ( ) ) => Ok ( None ) ,
88+ }
89+ }
90+
4991/// Wrap filehost command
5092fn filehost ( _args : ArgMatches , context : & mut Context ) -> Result < Option < String > > {
5193 match commands:: filehost ( context. port ) {
0 commit comments