initialize emulator display and lcd_nibbles_buffer in one place only

This commit is contained in:
Gwenhael Le Moine 2023-12-21 13:48:40 +01:00
parent 52464c29c6
commit b4dddbd542
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
6 changed files with 51 additions and 78 deletions

View file

@ -99,6 +99,8 @@ int main( int argc, char** argv )
/********************/
init_emulator();
init_serial();
init_display();
ui_init_LCD();
init_ui( argc, argv );
/************************/

View file

@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "runtime_options.h"
#include "ui.h"
@ -147,9 +148,9 @@ 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 );
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 ) {

View file

@ -62,15 +62,15 @@ extern void ( *ui_refresh_LCD )( void );
extern void ( *ui_adjust_contrast )( void );
extern void ( *ui_draw_annunc )( void );
/*********************************/
/* used in: debugger.c, ui_sdl.c */
/*********************************/
extern void ( *ui_init_LCD )( void );
/*******************/
/* used in: main.c */
/*******************/
extern void ( *init_ui )( int argc, char** argv );
/*********************************/
/* used in: debugger.c, ui_sdl.c */
/*********************************/
extern void ui_init_LCD( void );
extern void setup_frontend( void );
#endif /* !_X48_GUI_H */

View file

@ -1950,13 +1950,6 @@ void sdl_adjust_contrast()
sdl_draw_annunc();
}
void sdl_init_LCD( void )
{
init_display();
memset( lcd_nibbles_buffer, 0xf0, sizeof( lcd_nibbles_buffer ) );
}
void sdl_update_LCD( void )
{
if ( display.on ) {
@ -2061,9 +2054,7 @@ void init_sdl_ui( int argc, char** argv )
ui_refresh_LCD = sdl_refresh_LCD;
ui_adjust_contrast = sdl_adjust_contrast;
ui_draw_annunc = sdl_draw_annunc;
ui_init_LCD = sdl_init_LCD;
SDLInit();
SDLCreateHP();
sdl_init_LCD();
}

View file

@ -528,14 +528,6 @@ int text_get_event( void ) { return ncurses_get_event(); }
void text_adjust_contrast() { text_update_LCD(); }
/* TODO: not specific to tui */
void text_init_LCD( void )
{
init_display();
memset( lcd_nibbles_buffer, 0xf0, sizeof( lcd_nibbles_buffer ) );
}
/* TODO: not specific to tui */
void text_update_LCD( void )
{
@ -637,9 +629,6 @@ void init_text_ui( int argc, char** argv )
ui_refresh_LCD = text_refresh_LCD;
ui_adjust_contrast = text_adjust_contrast;
ui_draw_annunc = text_draw_annunc;
ui_init_LCD = text_init_LCD;
text_init_LCD();
ncurses_init_ui();
}

View file

@ -3548,56 +3548,6 @@ void x11_adjust_contrast( void )
}
}
void x11_init_LCD( void )
{
init_display();
memset( lcd_nibbles_buffer, 0xf0, sizeof( lcd_nibbles_buffer ) );
/* init nibble_maps */
for ( int i = 0; i < 16; i++ )
nibble_maps[ i ] = XCreateBitmapFromData( dpy, lcd.win, ( char* )nibbles[ i ], 8, 2 );
if ( !shm_flag )
return;
if ( lcd.disp_image->bitmap_bit_order == MSBFirst ) {
nibble_bitmap[ 0x0 ] = 0x00; /* ---- */
nibble_bitmap[ 0x1 ] = 0xc0; /* *--- */
nibble_bitmap[ 0x2 ] = 0x30; /* -*-- */
nibble_bitmap[ 0x3 ] = 0xf0; /* **-- */
nibble_bitmap[ 0x4 ] = 0x0c; /* --*- */
nibble_bitmap[ 0x5 ] = 0xcc; /* *-*- */
nibble_bitmap[ 0x6 ] = 0x3c; /* -**- */
nibble_bitmap[ 0x7 ] = 0xfc; /* ***- */
nibble_bitmap[ 0x8 ] = 0x03; /* ---* */
nibble_bitmap[ 0x9 ] = 0xc3; /* *--* */
nibble_bitmap[ 0xa ] = 0x33; /* -*-* */
nibble_bitmap[ 0xb ] = 0xf3; /* **-* */
nibble_bitmap[ 0xc ] = 0x0f; /* --** */
nibble_bitmap[ 0xd ] = 0xcf; /* *-** */
nibble_bitmap[ 0xe ] = 0x3f; /* -*** */
nibble_bitmap[ 0xf ] = 0xff; /* **** */
} else {
nibble_bitmap[ 0x0 ] = 0x00; /* ---- */
nibble_bitmap[ 0x1 ] = 0x03; /* *--- */
nibble_bitmap[ 0x2 ] = 0x0c; /* -*-- */
nibble_bitmap[ 0x3 ] = 0x0f; /* **-- */
nibble_bitmap[ 0x4 ] = 0x30; /* --*- */
nibble_bitmap[ 0x5 ] = 0x33; /* *-*- */
nibble_bitmap[ 0x6 ] = 0x3c; /* -**- */
nibble_bitmap[ 0x7 ] = 0x3f; /* ***- */
nibble_bitmap[ 0x8 ] = 0xc0; /* ---* */
nibble_bitmap[ 0x9 ] = 0xc3; /* *--* */
nibble_bitmap[ 0xa ] = 0xcc; /* -*-* */
nibble_bitmap[ 0xb ] = 0xcf; /* **-* */
nibble_bitmap[ 0xc ] = 0xf0; /* --** */
nibble_bitmap[ 0xd ] = 0xf3; /* *-** */
nibble_bitmap[ 0xe ] = 0xfc; /* -*** */
nibble_bitmap[ 0xf ] = 0xff; /* **** */
}
}
void x11_update_LCD( void )
{
int i, j;
@ -3795,7 +3745,6 @@ void init_x11_ui( int argc, char** argv )
ui_refresh_LCD = x11_refresh_LCD;
ui_adjust_contrast = x11_adjust_contrast;
ui_draw_annunc = x11_draw_annunc;
ui_init_LCD = x11_init_LCD;
save_options( argc, argv );
@ -3809,5 +3758,46 @@ void init_x11_ui( int argc, char** argv )
init_annunc_pixmaps();
x11_init_LCD();
/* init nibble_maps */
for ( int i = 0; i < 16; i++ )
nibble_maps[ i ] = XCreateBitmapFromData( dpy, lcd.win, ( char* )nibbles[ i ], 8, 2 );
if ( !shm_flag )
return;
if ( lcd.disp_image->bitmap_bit_order == MSBFirst ) {
nibble_bitmap[ 0x0 ] = 0x00; /* ---- */
nibble_bitmap[ 0x1 ] = 0xc0; /* *--- */
nibble_bitmap[ 0x2 ] = 0x30; /* -*-- */
nibble_bitmap[ 0x3 ] = 0xf0; /* **-- */
nibble_bitmap[ 0x4 ] = 0x0c; /* --*- */
nibble_bitmap[ 0x5 ] = 0xcc; /* *-*- */
nibble_bitmap[ 0x6 ] = 0x3c; /* -**- */
nibble_bitmap[ 0x7 ] = 0xfc; /* ***- */
nibble_bitmap[ 0x8 ] = 0x03; /* ---* */
nibble_bitmap[ 0x9 ] = 0xc3; /* *--* */
nibble_bitmap[ 0xa ] = 0x33; /* -*-* */
nibble_bitmap[ 0xb ] = 0xf3; /* **-* */
nibble_bitmap[ 0xc ] = 0x0f; /* --** */
nibble_bitmap[ 0xd ] = 0xcf; /* *-** */
nibble_bitmap[ 0xe ] = 0x3f; /* -*** */
nibble_bitmap[ 0xf ] = 0xff; /* **** */
} else {
nibble_bitmap[ 0x0 ] = 0x00; /* ---- */
nibble_bitmap[ 0x1 ] = 0x03; /* *--- */
nibble_bitmap[ 0x2 ] = 0x0c; /* -*-- */
nibble_bitmap[ 0x3 ] = 0x0f; /* **-- */
nibble_bitmap[ 0x4 ] = 0x30; /* --*- */
nibble_bitmap[ 0x5 ] = 0x33; /* *-*- */
nibble_bitmap[ 0x6 ] = 0x3c; /* -**- */
nibble_bitmap[ 0x7 ] = 0x3f; /* ***- */
nibble_bitmap[ 0x8 ] = 0xc0; /* ---* */
nibble_bitmap[ 0x9 ] = 0xc3; /* *--* */
nibble_bitmap[ 0xa ] = 0xcc; /* -*-* */
nibble_bitmap[ 0xb ] = 0xcf; /* **-* */
nibble_bitmap[ 0xc ] = 0xf0; /* --** */
nibble_bitmap[ 0xd ] = 0xf3; /* *-** */
nibble_bitmap[ 0xe ] = 0xfc; /* -*** */
nibble_bitmap[ 0xf ] = 0xff; /* **** */
}
}