simplify starting emulator and UI
This commit is contained in:
parent
ebf8ded567
commit
1c89a1083b
6 changed files with 43 additions and 46 deletions
|
@ -1016,4 +1016,11 @@ int init_emulator( void )
|
|||
return 0;
|
||||
}
|
||||
|
||||
void start_emulator( void )
|
||||
{
|
||||
init_emulator();
|
||||
init_serial();
|
||||
init_display();
|
||||
}
|
||||
|
||||
void exit_emulator( void ) { write_files(); }
|
||||
|
|
|
@ -322,9 +322,8 @@ extern int annunciators_bits[ NB_ANNUNCIATORS ];
|
|||
/**************/
|
||||
/* emu_init.c */
|
||||
/**************/
|
||||
extern void init_display( void ); /* used in main.c */
|
||||
extern int init_emulator( void ); /* used in main.c */
|
||||
extern void exit_emulator( void ); /* used in debugger.c; main.c; ui_*.c */
|
||||
extern void start_emulator( void ); /* used in main.c */
|
||||
extern void exit_emulator( void ); /* used in debugger.c; ui_*.c */
|
||||
|
||||
/********************/
|
||||
/* emu_memory.c */
|
||||
|
@ -338,11 +337,6 @@ extern void press_key( int hpkey ); /* used in ui_*.c */
|
|||
extern void release_key( int hpkey ); /* used in ui_*.c */
|
||||
extern void release_all_keys( void ); /* used in ui_*.c */
|
||||
|
||||
/****************/
|
||||
/* emu_serial.c */
|
||||
/****************/
|
||||
extern int init_serial( void ); /* used in main.c */
|
||||
|
||||
/*****************/
|
||||
/* emu_emulate.c */
|
||||
/*****************/
|
||||
|
|
|
@ -77,5 +77,6 @@ extern int is_greater_or_equal_register( unsigned char* r1, unsigned char* r2, i
|
|||
extern void serial_baud( int baud );
|
||||
extern void transmit_char( void );
|
||||
extern void receive_char( void );
|
||||
extern int init_serial( void ); /* used in main.c */
|
||||
|
||||
#endif /* _EMULATOR_INNER_H */
|
||||
|
|
|
@ -100,13 +100,10 @@ int main( int argc, char** argv )
|
|||
parse_args( argc, argv );
|
||||
|
||||
/* Emulator */
|
||||
init_emulator();
|
||||
init_serial();
|
||||
init_display();
|
||||
start_emulator();
|
||||
|
||||
/* (G)UI */
|
||||
setup_frontend(); /* points init_ui to the correct function */
|
||||
init_ui( argc, argv );
|
||||
start_UI( argc, argv );
|
||||
|
||||
/************************/
|
||||
/* Start emulation loop */
|
||||
|
|
61
src/ui.c
61
src/ui.c
|
@ -148,40 +148,9 @@ void ( *ui_update_LCD )( void );
|
|||
void ( *ui_refresh_LCD )( void );
|
||||
void ( *ui_adjust_contrast )( void );
|
||||
void ( *ui_draw_annunc )( void );
|
||||
void ( *init_ui )( int argc, char** argv );
|
||||
|
||||
void ui_init_LCD( void ) { memset( lcd_nibbles_buffer, 0xf0, sizeof( lcd_nibbles_buffer ) ); }
|
||||
|
||||
void setup_frontend( void )
|
||||
{
|
||||
switch ( frontend_type ) {
|
||||
#if ( defined( HAS_X11 ) )
|
||||
case FRONTEND_X11:
|
||||
default:
|
||||
init_ui = init_x11_ui;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if ( defined( HAS_SDL ) )
|
||||
case FRONTEND_SDL:
|
||||
# if ( !defined( HAS_X11 ) )
|
||||
default:
|
||||
# endif
|
||||
init_ui = init_sdl_ui;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case FRONTEND_TEXT:
|
||||
#if ( !defined( HAS_X11 ) && !defined( HAS_SDL ) )
|
||||
default:
|
||||
#endif
|
||||
init_ui = init_text_ui;
|
||||
break;
|
||||
}
|
||||
|
||||
ui_init_LCD();
|
||||
}
|
||||
|
||||
int SmallTextWidth( const char* string, unsigned int length )
|
||||
{
|
||||
unsigned int i;
|
||||
|
@ -200,3 +169,33 @@ int SmallTextWidth( const char* string, unsigned int length )
|
|||
|
||||
return w;
|
||||
}
|
||||
|
||||
void start_UI( int argc, char** argv )
|
||||
{
|
||||
ui_init_LCD();
|
||||
|
||||
switch ( frontend_type ) {
|
||||
#if ( defined( HAS_X11 ) )
|
||||
case FRONTEND_X11:
|
||||
default:
|
||||
init_x11_ui( argc, argv );
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if ( defined( HAS_SDL ) )
|
||||
case FRONTEND_SDL:
|
||||
# if ( !defined( HAS_X11 ) )
|
||||
default:
|
||||
# endif
|
||||
init_sdl_ui( argc, argv );
|
||||
break;
|
||||
#endif
|
||||
|
||||
case FRONTEND_TEXT:
|
||||
#if ( !defined( HAS_X11 ) && !defined( HAS_SDL ) )
|
||||
default:
|
||||
#endif
|
||||
init_text_ui( argc, argv );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
3
src/ui.h
3
src/ui.h
|
@ -65,7 +65,6 @@ extern void ( *ui_draw_annunc )( void );
|
|||
/*******************/
|
||||
/* used in: main.c */
|
||||
/*******************/
|
||||
extern void ( *init_ui )( int argc, char** argv );
|
||||
extern void start_UI( int argc, char** argv );
|
||||
|
||||
extern void setup_frontend( void );
|
||||
#endif /* !_UI_H */
|
||||
|
|
Loading…
Reference in a new issue