add a --no-chrome option to only show the LCD

This commit is contained in:
Gwenhael Le Moine 2023-09-16 11:07:34 +02:00
parent c3e4ddc776
commit e4aef06805
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
6 changed files with 89 additions and 59 deletions

2
dist/x48ng.man.1 vendored
View file

@ -70,6 +70,8 @@ where options include:
\-\-serial\-line=<path> use <path> as serial device default: /dev/ttyS0)
.br
\-V \-\-verbose be verbose (default: false)
\" .br
\" \-\-no\-chrome only display the LCD (default: false)
.br
\-t \-\-use\-terminal activate pseudo terminal interface (default: true)
.br

View file

@ -515,7 +515,6 @@ static void cmd_load( int argc, char** argv ) {
}
}
static void cmd_mode( int argc, char** argv ) {
if ( argc < 2 ) {
printf( "Disassembler uses %s mnemonics.\n",

View file

@ -8,6 +8,7 @@
char* progname = "x48ng";
int verbose = 0;
int show_ui_chrome = 1;
int useTerminal = 1;
int useSerial = 0;
int useDebugger = 1;
@ -43,6 +44,7 @@ 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 },
{ "use-terminal", no_argument, &useTerminal, 1 },
{ "use-serial", no_argument, &useSerial, 1 },
@ -74,6 +76,7 @@ int parse_args( int argc, char* argv[] ) {
"\t --serial-line=<path>\t\t use <path> as serial device default: "
"%s)\n"
"\t-V --verbose\t\t\t be verbose (default: false)\n"
"\t --no-chrome\t\t\t only display the LCD (default: false)\n"
"\t-t --use-terminal\t\t activate pseudo terminal interface (default: "
"true)\n"
"\t-s --use-serial\t\t\t activate serial interface (default: false)\n"

View file

@ -4,6 +4,7 @@
extern char* progname;
extern int verbose;
extern int show_ui_chrome;
extern int useTerminal;
extern int useSerial;
extern int useDebugger;

View file

@ -6,7 +6,7 @@
/**************/
/* public API */
/**************/
/* used in: hp48emu_memory.c */
/* used in: emu_memory.c */
typedef struct disp_t {
unsigned int w, h;
short mapped;
@ -18,13 +18,13 @@ extern disp_t disp;
extern void ui__disp_draw_nibble( word_20 addr, word_4 val );
extern void ui__menu_draw_nibble( word_20 addr, word_4 val );
/* used in: hp48emu_actions.c, hp48_emulate.c */
/* used in: emu_actions.c, emu_emulate.c */
extern int ui__get_event( void );
/* used in: hp48emu_actions.c, hp48_emulate.c, debugger.c */
/* used in: emu_actions.c, emu_emulate.c, debugger.c */
extern void ui__update_LCD( void );
/* used in: hp48_emulate.c */
/* used in: emu_emulate.c */
extern void ui__adjust_contrast( void );
extern void ui__draw_annunc( void );

View file

@ -1183,6 +1183,7 @@ void SDLDrawMore( unsigned int cut, unsigned int offset_y, int keypad_width,
int keypad_height );
void SDLDrawLogo();
void SDLDrawBackground( int width, int height, int w_top, int h_top );
void SDLDrawBackgroundLCD();
void SDLUIShowKey( int hpkey );
void SDLUIHideKey( void );
void SDLUIFeedback( void );
@ -1205,6 +1206,8 @@ void SDLCreateHP( void );
/* functions implementation */
/****************************/
void SDLInit( void ) {
unsigned int width, height;
// Initialize SDL
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
printf( "Couldn't initialize SDL: %s\n", SDL_GetError() );
@ -1230,12 +1233,18 @@ void SDLInit( void ) {
KEYBOARD_OFFSET_Y = _KEYBOARD_OFFSET_Y;
KBD_UPLINE = _KBD_UPLINE;
unsigned width =
( buttons_gx[ LAST_BUTTON ].x + buttons_gx[ LAST_BUTTON ].w ) +
2 * SIDE_SKIP;
unsigned height = DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + DISP_KBD_SKIP +
buttons_gx[ LAST_BUTTON ].y +
buttons_gx[ LAST_BUTTON ].h + BOTTOM_SKIP;
if ( show_ui_chrome ) {
width = ( buttons_gx[ LAST_BUTTON ].x + buttons_gx[ LAST_BUTTON ].w ) +
2 * SIDE_SKIP;
height = DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + DISP_KBD_SKIP +
buttons_gx[ LAST_BUTTON ].y + buttons_gx[ LAST_BUTTON ].h +
BOTTOM_SKIP;
} else {
width = DISPLAY_WIDTH;
height = DISPLAY_HEIGHT;
DISPLAY_OFFSET_X = 0;
DISPLAY_OFFSET_Y = 0;
}
sdlwindow = SDL_SetVideoMode( width, height, 32, SDL_SWSURFACE );
@ -1328,51 +1337,6 @@ void ui__adjust_contrast() {
redraw_annunc();
}
void SDLCreateHP( void ) {
// we allocate memory for the buttons because we need to modify
// their coordinates, and we don't want to change the original buttons_gx or
// buttons_sx
if ( buttons ) {
free( buttons );
buttons = 0;
}
buttons = ( button_t* )malloc( sizeof( buttons_gx ) );
if ( opt_gx ) {
// buttons = buttons_gx;
memcpy( buttons, buttons_gx, sizeof( buttons_gx ) );
colors = colors_gx;
} else {
// buttons = buttons_sx;
memcpy( buttons, buttons_sx, sizeof( buttons_sx ) );
colors = colors_sx;
}
unsigned int width = KEYBOARD_WIDTH + 2 * SIDE_SKIP;
unsigned int height = DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + DISP_KBD_SKIP +
KEYBOARD_HEIGHT + BOTTOM_SKIP;
int cut = buttons[ BUTTON_MTH ].y + KEYBOARD_OFFSET_Y - 19;
SDLCreateColors();
disp.mapped = 1;
disp.w = DISPLAY_WIDTH;
disp.h = DISPLAY_HEIGHT;
keypad.width = width;
keypad.height = height;
SDLDrawBackground( width, cut, width, height );
SDLDrawMore( cut, KEYBOARD_OFFSET_Y, keypad.width, keypad.height );
SDLDrawLogo();
SDLDrawBezel();
SDLDrawKeypad();
SDLDrawSerialDevices();
SDL_UpdateRect( sdlwindow, 0, 0, 0, 0 );
}
// Find which key is pressed, if any.
// Returns -1 is no key is pressed
int SDLCoordinateToKey( unsigned int x, unsigned int y ) {
@ -2379,8 +2343,11 @@ void SDLDrawBackground( int width, int height, int w_top, int h_top ) {
rect.w = width;
rect.h = height;
SDL_FillRect( sdlwindow, &rect, ARGBColors[ DISP_PAD ] );
}
void SDLDrawBackgroundLCD() {
SDL_Rect rect;
// LCD
rect.x = DISPLAY_OFFSET_X;
rect.y = DISPLAY_OFFSET_Y;
rect.w = DISPLAY_WIDTH;
@ -3112,7 +3079,8 @@ int ui__get_event( void ) {
}
// Display button being pressed, if any
SDLUIShowKey( keyispressed );
if ( show_ui_chrome )
SDLUIShowKey( keyispressed );
// If we press long, then the button releases makes SDLUIShowKey restore
// the old key, but rv does not indicate that we need to update the
@ -3143,6 +3111,7 @@ int ui__get_event( void ) {
}
/* x48_lcd.c */
static inline void draw_nibble( int c, int r, int val ) {
int x, y;
@ -3162,6 +3131,8 @@ static inline void draw_nibble( int c, int r, int val ) {
SDLDrawNibble( x, y, val );
}
void ui__draw_nibble( int c, int r, int val ) { draw_nibble( c, r, val ); }
static inline void draw_row( long addr, int row ) {
int i, v;
int line_length;
@ -3329,8 +3300,62 @@ void ui__init_LCD( void ) {
}
/* \ x48_lcd.c */
void SDLCreateHP( void ) {
unsigned int width, height;
if ( show_ui_chrome ) {
width = KEYBOARD_WIDTH + 2 * SIDE_SKIP;
height = DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + DISP_KBD_SKIP +
KEYBOARD_HEIGHT + BOTTOM_SKIP;
} else {
width = KEYBOARD_WIDTH;
height = DISPLAY_HEIGHT;
}
disp.mapped = 1;
disp.w = DISPLAY_WIDTH;
disp.h = DISPLAY_HEIGHT;
keypad.width = width;
keypad.height = height;
colors = opt_gx ? colors_gx : colors_sx;
// we allocate memory for the buttons because we need to modify
// their coordinates, and we don't want to change the original buttons_gx or
// buttons_sx
if ( buttons ) {
free( buttons );
buttons = 0;
}
buttons = ( button_t* )malloc( sizeof( buttons_gx ) );
if ( opt_gx )
memcpy( buttons, buttons_gx, sizeof( buttons_gx ) );
else
memcpy( buttons, buttons_sx, sizeof( buttons_sx ) );
SDLCreateColors();
if ( show_ui_chrome ) {
int cut = buttons[ BUTTON_MTH ].y + KEYBOARD_OFFSET_Y - 19;
SDLDrawBackground( width, cut, width, height );
SDLDrawMore( cut, KEYBOARD_OFFSET_Y, keypad.width, keypad.height );
SDLDrawLogo();
SDLDrawBezel();
SDLDrawKeypad();
SDLDrawSerialDevices();
}
SDLDrawBackgroundLCD();
SDL_UpdateRect( sdlwindow, 0, 0, 0, 0 );
}
void ui__init( void ) {
// SDL Initialization
// SDL Initialization
SDLInit();
/*