all parameters are handled through getopt_long, no more X resources

This commit is contained in:
Gwenhael Le Moine 2023-09-19 14:01:12 +02:00
parent eed26cded9
commit 7595b39c13
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
11 changed files with 381 additions and 801 deletions

View file

@ -105,6 +105,3 @@ install: all
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/applications
sed "s|@PREFIX@|$(PREFIX)|g" dist/x48ng.desktop > $(DESTDIR)$(PREFIX)/share/applications/x48ng.desktop
install -m 755 -d -- $(DESTDIR)/etc/X11/app-defaults
install -c -m 644 dist/X48NG.ad $(DESTDIR)/etc/X11/app-defaults/X48NG

39
dist/X48NG.ad vendored
View file

@ -1,39 +0,0 @@
!
! X11 related stuff
!
*iconic: False
*visual: Default
*mono: False
*gray: False
*monoIcon: False
*useXShm: True
*smallLabelFont: -*-fixed-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
*mediumLabelFont: -*-fixed-bold-r-normal-*-15-*-*-*-*-*-iso8859-1
*largeLabelFont: -*-fixed-medium-r-normal-*-20-*-*-*-*-*-iso8859-1
*connectionFont: -*-fixed-medium-r-normal-*-12-*-*-*-*-*-iso8859-1
!
! informative stuff
!
*verbose: False
*printVersion: False
*printCopyright: False
*printWarranty: False
!
! resources controlling the connections
!
*useTerminal: True
*useSerial: False
*serialLine: /dev/ttyS0
!
! stuff controlling initialization
!
*completeInitialize: False
*resetOnStartup: False
*romFileName: rom.dump
*homeDirectory: .x48ng

25
dist/x48ng.man.1 vendored
View file

@ -72,12 +72,6 @@ where options include:
\-V \-\-verbose be verbose (default: false)
.br
\-u \-\-front-end specify a front-end (available: x11, sdl; default: x11)
.br
\-\-no\-chrome [SDL only] only display the LCD (default: false)
.br
\-\-fullscreen [SDL only] make the UI fullscreen (default: false)
.br
\-\-netbook [X11 only] make the UI horizontal (default: false)
.br
\-t \-\-use\-terminal activate pseudo terminal interface (default: true)
.br
@ -90,7 +84,24 @@ where options include:
\-r \-\-reset perform a reset on startup
.br
\-T \-\-throttle try to emulate real speed (default: false)
.br
\-\-sdl\-no\-chrome [SDL] only display the LCD (default: false)
.br
\-\-sdl\-fullscreen [SDL] make the UI fullscreen (default: false)
.br
\-\-x11\-netbook [X11] make the UI horizontal (default: false)
.br
\-\-x11\-mono [X11] make the UI monochrome (default: false)
.br
\-\-x11\-gray [X11] make the UI grayscale (default: false)
.br
\-\-x11\-small\-font=<fontname> [X11] use <fontname> as small font
.br
\-\-x11\-medium\-font=<fontname> [X11] use <fontname> as medium font
.br
\-\-x11\-large\-font=<fontname> [X11] use <fontname> as large font
.br
\-\-x11\-connection\-font=<fontname> [X11] use <fontname> as connection font
.SH DESCRIPTION
.I x48ng

View file

@ -253,7 +253,7 @@ int get_identification( void ) {
void do_shutdown( void ) {
if ( device.display_touched ) {
device.display_touched = 0;
ui_update_LCD();
ui_refresh_LCD();
}
stop_timer( RUN_TIMER );
@ -273,7 +273,7 @@ void do_shutdown( void ) {
if ( got_alarm ) {
got_alarm = 0;
ui_update_LCD();
ui_refresh_LCD();
ticks = get_t1_t2();
if ( saturn.t2_ctrl & 0x01 )

View file

@ -2446,7 +2446,7 @@ inline void schedule( void ) {
if ( got_alarm ) {
got_alarm = 0;
ui_update_LCD();
ui_refresh_LCD();
ui_get_event();
}

View file

@ -9,16 +9,12 @@
char* progname = "x48ng";
int verbose = 0;
int show_ui_chrome = 1;
int show_ui_fullscreen = 0;
int netbook = 0;
int useTerminal = 1;
int useSerial = 0;
int useDebugger = 1;
int throttle = 0;
int initialize = 0;
int resetOnStartup = 0;
int frontend_type = FRONTEND_X11;
char* serialLine = "/dev/ttyS0";
char* homeDirectory = ".x48ng";
@ -29,6 +25,33 @@ char* stateFileName = "hp48";
char* port1FileName = "port1";
char* port2FileName = "port2";
int frontend_type = FRONTEND_X11;
/* sdl */
int show_ui_chrome = 1;
int show_ui_fullscreen = 0;
/* x11 */
int netbook = 0;
char* name = "x48ng";
char* title = "x48ng";
char* geometry;
/* char* iconGeom; */
/* char* iconName; */
/* int x11_visual = -1; */
int mono = 0;
int gray = 0;
int monoIcon = 0;
int iconic = 0;
int xrm = 1;
char* smallFont = "-*-fixed-bold-r-normal-*-14-*-*-*-*-*-iso8859-1";
char* mediumFont = "-*-fixed-bold-r-normal-*-15-*-*-*-*-*-iso8859-1";
char* largeFont = "-*-fixed-medium-r-normal-*-20-*-*-*-*-*-iso8859-1";
char* connFont = "-*-fixed-medium-r-normal-*-12-*-*-*-*-*-iso8859-1";
int parse_args( int argc, char* argv[] ) {
int option_index;
int c = '?';
@ -50,9 +73,6 @@ int parse_args( int argc, char* argv[] ) {
{ "version", no_argument, NULL, 'v' },
{ "verbose", no_argument, &verbose, 1 },
{ "no-chrome", no_argument, &show_ui_chrome, 0 },
{ "fullscreen", no_argument, &show_ui_fullscreen, 1 },
{ "netbook", no_argument, &netbook, 1 },
{ "use-terminal", no_argument, &useTerminal, 1 },
{ "use-serial", no_argument, &useSerial, 1 },
@ -62,6 +82,17 @@ int parse_args( int argc, char* argv[] ) {
{ "no-debug", no_argument, &useDebugger, 0 },
{ "sdl-no-chrome", no_argument, &show_ui_chrome, 0 },
{ "sdl-fullscreen", no_argument, &show_ui_fullscreen, 1 },
{ "x11-netbook", no_argument, &netbook, 1 },
{ "x11-mono", no_argument, &mono, 1 },
{ "x11-gray", no_argument, &gray, 1 },
{ "x11-small-font", required_argument, NULL, 8111 },
{ "x11-medium-font", required_argument, NULL, 8112 },
{ "x11-large-font", required_argument, NULL, 8113 },
{ "x11-connection-font", required_argument, NULL, 8114 },
{ 0, 0, 0, 0 } };
char* help_text =
@ -84,12 +115,6 @@ int parse_args( int argc, char* argv[] ) {
"\t --serial-line=<path>\t\tuse <path> as serial device default: "
"%s)\n"
"\t-V --verbose\t\t\tbe verbose (default: false)\n"
"\t --no-chrome\t\t\t[SDL only] only display the LCD (default: "
"false)\n"
"\t --fullscreen\t\t\t[SDL only] make the UI fullscreen (default: "
"false)\n"
"\t --netbook\t\t\t[X11 only] make the UI horizontal (default: "
"false)\n"
"\t-u --front-end\t\t\tspecify a front-end (available: x11, sdl; "
"default: x11)\n"
"\t-t --use-terminal\t\tactivate pseudo terminal interface (default: "
@ -98,14 +123,33 @@ int parse_args( int argc, char* argv[] ) {
"\t --no-debug\t\t\tdisable the debugger\n"
"\t-i --initialize\t\t\tinitialize the content of <config-dir>\n"
"\t-r --reset\t\t\tperform a reset on startup\n"
"\t-T --throttle\t\t\ttry to emulate real speed (default: false)\n";
"\t-T --throttle\t\t\ttry to emulate real speed (default: false)\n"
"\t --sdl-no-chrome\t\t[SDL only] only display the LCD (default: "
"false)\n"
"\t --sdl-fullscreen\t\t[SDL only] make the UI fullscreen "
"(default: "
"false)\n"
"\t --x11-netbook\t\t[X11 only] make the UI horizontal (default: "
"false)\n"
"\t --x11-mono\t\t\t[X11 only] make the UI monochrome (default: "
"false)\n"
"\t --x11-gray\t\t\t[X11 only] make the UI grayscale (default: "
"false)\n"
"\t --x11-small-font=<X font name>\tuse <X font name> as small "
"font (default: %s)\n"
"\t --x11-medium-font=<X font name>\tuse <X font name> as medium "
"font (default: %s)\n"
"\t --x11-large-font=<X font name>\tuse <X font name> as large "
"font (default: %s)\n"
"\t --x11-connection-font=<X font name>\tuse <X font name> as "
"connection font (default: %s)\n";
while ( c != EOF ) {
c = getopt_long( argc, argv, optstring, long_options, &option_index );
switch ( c ) {
case 'h':
fprintf( stdout, help_text, progname, serialLine );
fprintf( stdout, help_text, progname, serialLine, smallFont,
mediumFont, largeFont, connFont );
exit( 0 );
break;
case 'v':
@ -134,6 +178,18 @@ int parse_args( int argc, char* argv[] ) {
case 1015:
serialLine = optarg;
break;
case 8111:
smallFont = optarg;
break;
case 8112:
mediumFont = optarg;
break;
case 8113:
largeFont = optarg;
break;
case 8114:
connFont = optarg;
break;
case 'u':
if ( strcmp( optarg, "sdl" ) == 0 )
frontend_type = FRONTEND_SDL;

View file

@ -7,9 +7,6 @@
extern char* progname;
extern int verbose;
extern int show_ui_chrome;
extern int show_ui_fullscreen;
extern int netbook;
extern int useTerminal;
extern int useSerial;
extern int useDebugger;
@ -27,6 +24,34 @@ extern char* stateFileName;
extern char* port1FileName;
extern char* port2FileName;
/* sdl */
extern int show_ui_chrome;
extern int show_ui_fullscreen;
/* x11 */
extern int netbook;
extern char* name;
extern char* title;
extern char* geometry;
/* extern char* iconGeom; */
/* extern char* iconName; */
/* extern int x11_visual; */
extern int mono;
extern int gray;
extern int monoIcon;
extern int iconic;
extern int xrm;
extern char* smallFont;
extern char* mediumFont;
extern char* largeFont;
extern char* connFont;
/*************/
/* functions */
/*************/
extern int parse_args( int argc, char* argv[] );
#endif /* !_OPTIONS_H */

View file

@ -143,6 +143,7 @@ void ( *ui_disp_draw_nibble )( word_20 addr, word_4 val );
void ( *ui_menu_draw_nibble )( word_20 addr, word_4 val );
int ( *ui_get_event )( void );
void ( *ui_update_LCD )( void );
void ( *ui_refresh_LCD )( void );
void ( *ui_adjust_contrast )( void );
void ( *ui_draw_annunc )( void );
void ( *ui_init_LCD )( void );
@ -155,6 +156,7 @@ void setup_frontend( void ) {
ui_menu_draw_nibble = sdl_menu_draw_nibble;
ui_get_event = sdl_get_event;
ui_update_LCD = sdl_update_LCD;
ui_refresh_LCD = sdl_refresh_LCD;
ui_adjust_contrast = sdl_adjust_contrast;
ui_draw_annunc = sdl_draw_annunc;
ui_init_LCD = sdl_init_LCD;
@ -167,6 +169,7 @@ void setup_frontend( void ) {
ui_menu_draw_nibble = x11_menu_draw_nibble;
ui_get_event = x11_get_event;
ui_update_LCD = x11_update_LCD;
ui_refresh_LCD = x11_refresh_LCD;
ui_adjust_contrast = x11_adjust_contrast;
ui_draw_annunc = x11_draw_annunc;
ui_init_LCD = x11_init_LCD;

View file

@ -39,6 +39,9 @@ extern int x11_get_event( void );
extern void sdl_update_LCD( void );
extern void x11_update_LCD( void );
extern void sdl_refresh_LCD( void );
extern void x11_refresh_LCD( void );
extern void sdl_adjust_contrast( void );
extern void x11_adjust_contrast( void );
@ -69,6 +72,7 @@ extern int ( *ui_get_event )( void );
/* used in: emu_actions.c, emu_emulate.c, debugger.c */
/*****************************************************/
extern void ( *ui_update_LCD )( void );
extern void ( *ui_refresh_LCD )( void );
/**************************/
/* used in: emu_emulate.c */

View file

@ -2705,6 +2705,54 @@ int sdl_get_event( void ) {
return 1;
}
void sdl_adjust_contrast() {
SDLCreateColors();
SDLCreateAnnunc();
// redraw LCD
memset( disp_buf, 0, sizeof( disp_buf ) );
memset( lcd_buffer, 0, sizeof( lcd_buffer ) );
sdl_update_LCD();
// redraw annunc
last_annunc_state = -1;
sdl_draw_annunc();
}
void sdl_init_LCD( void ) {
display.on = ( int )( saturn.disp_io & 0x8 ) >> 3;
display.disp_start = ( saturn.disp_addr & 0xffffe );
display.offset = ( saturn.disp_io & 0x7 );
display.lines = ( saturn.line_count & 0x3f );
if ( display.lines == 0 )
display.lines = 63;
if ( display.offset > 3 )
display.nibs_per_line =
( NIBBLES_PER_ROW + saturn.line_offset + 2 ) & 0xfff;
else
display.nibs_per_line =
( NIBBLES_PER_ROW + saturn.line_offset ) & 0xfff;
display.disp_end =
display.disp_start + ( display.nibs_per_line * ( display.lines + 1 ) );
display.menu_start = saturn.menu_addr;
display.menu_end = saturn.menu_addr + 0x110;
display.contrast = saturn.contrast_ctrl;
display.contrast |= ( ( saturn.disp_test & 0x1 ) << 4 );
display.annunc = saturn.annunc;
memset( disp_buf, 0xf0, sizeof( disp_buf ) );
memset( lcd_buffer, 0xf0, sizeof( lcd_buffer ) );
}
void sdl_update_LCD( void ) {
int i, j;
long addr;
@ -2748,6 +2796,8 @@ void sdl_update_LCD( void ) {
}
}
void sdl_refresh_LCD( void ) {}
void sdl_disp_draw_nibble( word_20 addr, word_4 val ) {
long offset;
int x, y;
@ -2805,54 +2855,6 @@ void sdl_draw_annunc( void ) {
SDLDrawAnnunc( sdl_annuncstate );
}
void sdl_adjust_contrast() {
SDLCreateColors();
SDLCreateAnnunc();
// redraw LCD
memset( disp_buf, 0, sizeof( disp_buf ) );
memset( lcd_buffer, 0, sizeof( lcd_buffer ) );
sdl_update_LCD();
// redraw annunc
last_annunc_state = -1;
sdl_draw_annunc();
}
void sdl_init_LCD( void ) {
display.on = ( int )( saturn.disp_io & 0x8 ) >> 3;
display.disp_start = ( saturn.disp_addr & 0xffffe );
display.offset = ( saturn.disp_io & 0x7 );
display.lines = ( saturn.line_count & 0x3f );
if ( display.lines == 0 )
display.lines = 63;
if ( display.offset > 3 )
display.nibs_per_line =
( NIBBLES_PER_ROW + saturn.line_offset + 2 ) & 0xfff;
else
display.nibs_per_line =
( NIBBLES_PER_ROW + saturn.line_offset ) & 0xfff;
display.disp_end =
display.disp_start + ( display.nibs_per_line * ( display.lines + 1 ) );
display.menu_start = saturn.menu_addr;
display.menu_end = saturn.menu_addr + 0x110;
display.contrast = saturn.contrast_ctrl;
display.contrast |= ( ( saturn.disp_test & 0x1 ) << 4 );
display.annunc = saturn.annunc;
memset( disp_buf, 0xf0, sizeof( disp_buf ) );
memset( lcd_buffer, 0xf0, sizeof( lcd_buffer ) );
}
void init_sdl_ui( int argc, char** argv ) {
SDLInit();
SDLCreateHP();

File diff suppressed because it is too large Load diff