From b4dddbd542bd92f89df940bc2134b67e8001f358 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 21 Dec 2023 13:48:40 +0100 Subject: [PATCH 1/3] initialize emulator display and lcd_nibbles_buffer in one place only --- src/main.c | 2 ++ src/ui.c | 3 +- src/ui.h | 10 +++--- src/ui_sdl.c | 9 ----- src/ui_text.c | 11 ------ src/ui_x11.c | 94 +++++++++++++++++++++++---------------------------- 6 files changed, 51 insertions(+), 78 deletions(-) diff --git a/src/main.c b/src/main.c index 0b6be35..7dc145d 100644 --- a/src/main.c +++ b/src/main.c @@ -99,6 +99,8 @@ int main( int argc, char** argv ) /********************/ init_emulator(); init_serial(); + init_display(); + ui_init_LCD(); init_ui( argc, argv ); /************************/ diff --git a/src/ui.c b/src/ui.c index 54004e9..acbd799 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1,5 +1,6 @@ #include #include +#include #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 ) { diff --git a/src/ui.h b/src/ui.h index 6b679de..950e0c4 100644 --- a/src/ui.h +++ b/src/ui.h @@ -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 */ diff --git a/src/ui_sdl.c b/src/ui_sdl.c index be0fcd2..57e2679 100644 --- a/src/ui_sdl.c +++ b/src/ui_sdl.c @@ -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(); } diff --git a/src/ui_text.c b/src/ui_text.c index e02dd39..0560b21 100644 --- a/src/ui_text.c +++ b/src/ui_text.c @@ -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(); } diff --git a/src/ui_x11.c b/src/ui_x11.c index 394dbdd..e3ab3ff 100644 --- a/src/ui_x11.c +++ b/src/ui_x11.c @@ -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; /* **** */ + } } From 194b8d6ab9b459d5d3ecaf45b515ab60b9e78a57 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 21 Dec 2023 14:28:59 +0100 Subject: [PATCH 2/3] unify naming in ui_* --- src/ui_sdl.c | 10 +++++----- src/ui_text.c | 2 +- src/ui_x11.c | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ui_sdl.c b/src/ui_sdl.c index 57e2679..a8c6db6 100644 --- a/src/ui_sdl.c +++ b/src/ui_sdl.c @@ -1683,19 +1683,19 @@ static inline void draw_nibble( int col, int row, int val ) static inline void draw_row( long addr, int row ) { - int v; + int nibble; int line_length = NIBBLES_PER_ROW; if ( ( display.offset > 3 ) && ( row <= display.lines ) ) line_length += 2; for ( int i = 0; i < line_length; i++ ) { - v = read_nibble( addr + i ); - if ( v == lcd_nibbles_buffer[ row ][ i ] ) + nibble = read_nibble( addr + i ); + if ( nibble == lcd_nibbles_buffer[ row ][ i ] ) continue; - lcd_nibbles_buffer[ row ][ i ] = v; - draw_nibble( i, row, v ); + lcd_nibbles_buffer[ row ][ i ] = nibble; + draw_nibble( i, row, nibble ); } } diff --git a/src/ui_text.c b/src/ui_text.c index 0560b21..1a213cb 100644 --- a/src/ui_text.c +++ b/src/ui_text.c @@ -528,7 +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_update_LCD( void ) { if ( display.on ) { @@ -562,6 +561,7 @@ void text_update_LCD( void ) } else memset( lcd_nibbles_buffer, 0xf0, sizeof( lcd_nibbles_buffer ) ); + /* text UI specific from here */ if ( small ) ncurses_draw_lcd_small(); else if ( tiny ) diff --git a/src/ui_x11.c b/src/ui_x11.c index e3ab3ff..94bfe78 100644 --- a/src/ui_x11.c +++ b/src/ui_x11.c @@ -2911,19 +2911,19 @@ static inline void draw_nibble( int c, int r, int val ) static inline void draw_row( long addr, int row ) { - int i, v; - int line_length; + int nibble; + int line_length = NIBBLES_PER_ROW; - line_length = NIBBLES_PER_ROW; if ( ( display.offset > 3 ) && ( row <= display.lines ) ) line_length += 2; - for ( i = 0; i < line_length; i++ ) { - v = read_nibble( addr + i ); - if ( v == lcd_nibbles_buffer[ row ][ i ] ) + + for ( int i = 0; i < line_length; i++ ) { + nibble = read_nibble( addr + i ); + if ( nibble == lcd_nibbles_buffer[ row ][ i ] ) continue; - lcd_nibbles_buffer[ row ][ i ] = v; - draw_nibble( i, row, v ); + lcd_nibbles_buffer[ row ][ i ] = nibble; + draw_nibble( i, row, nibble ); } } From ff07e630958fe1f9c85eb4ead00b74a7ea0b568e Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 21 Dec 2023 16:18:04 +0100 Subject: [PATCH 3/3] bit of rationalizing UI codebases --- src/ui_sdl.c | 43 +++---- src/ui_text.c | 316 +++++++++++++++++++++++++------------------------- src/ui_x11.c | 3 +- 3 files changed, 179 insertions(+), 183 deletions(-) diff --git a/src/ui_sdl.c b/src/ui_sdl.c index a8c6db6..0ae5c45 100644 --- a/src/ui_sdl.c +++ b/src/ui_sdl.c @@ -12,8 +12,7 @@ #include #include /* lineColor(); pixelColor(); rectangleColor();stringColor(); */ -#include "emulator.h" -#include "romio.h" +#include "romio.h" /* opt_gx */ #include "runtime_options.h" #include "ui.h" #include "ui_inner.h" @@ -292,12 +291,6 @@ static int showkeylastx, showkeylasty, showkeylastkey; static SDL_Surface* sdlwindow; -/************************/ -/* functions prototypes */ -/************************/ -void sdl_draw_annunc( void ); -void sdl_update_LCD( void ); - /****************************/ /* functions implementation */ /****************************/ @@ -1934,22 +1927,6 @@ int sdl_get_event( void ) return 1; } -void sdl_adjust_contrast() -{ - SDLCreateColors(); - SDLCreateAnnunc(); - - // redraw LCD - memset( lcd_nibbles_buffer, 0, sizeof( lcd_nibbles_buffer ) ); - - sdl_update_LCD(); - - // redraw annunc - last_annunc_state = -1; - - sdl_draw_annunc(); -} - void sdl_update_LCD( void ) { if ( display.on ) { @@ -1997,8 +1974,10 @@ void sdl_disp_draw_nibble( word_20 addr, word_4 val ) y = offset / display.nibs_per_line; if ( y < 0 || y > 63 ) return; + if ( val == lcd_nibbles_buffer[ y ][ x ] ) return; + lcd_nibbles_buffer[ y ][ x ] = val; draw_nibble( x, y, val ); } else { @@ -2044,6 +2023,22 @@ void sdl_draw_annunc( void ) SDLDrawAnnunc( sdl_annuncstate ); } +void sdl_adjust_contrast() +{ + SDLCreateColors(); + SDLCreateAnnunc(); + + // redraw LCD + memset( lcd_nibbles_buffer, 0, sizeof( lcd_nibbles_buffer ) ); + + sdl_update_LCD(); + + // redraw annunc + last_annunc_state = -1; + + sdl_draw_annunc(); +} + void init_sdl_ui( int argc, char** argv ) { /* Set public API to this UI's functions */ diff --git a/src/ui_text.c b/src/ui_text.c index 1a213cb..31e55d9 100644 --- a/src/ui_text.c +++ b/src/ui_text.c @@ -13,11 +13,8 @@ #include -#include "emulator.h" -#include "romio.h" -#include "runtime_options.h" -#include "ui.h" -#include "ui_inner.h" +#include "runtime_options.h" /* mono, gray, small, tiny, progname */ +#include "ui.h" /* last_annunc_state, lcd_nibbles_buffer, DISP_ROWS */ #define LCD_WIDTH 131 #define LCD_HEIGHT 64 @@ -33,29 +30,10 @@ #define LCD_PIXEL_OFF 2 #define LCD_COLORS_PAIR 3 -/************************/ -/* functions prototypes */ -/************************/ -void text_update_LCD( void ); - /****************************/ /* functions implementation */ /****************************/ -static inline void ncurses_draw_annunciators( void ) -{ - wchar_t* annunciators_icons[ 6 ] = { L"↰", L"↱", L"α", L"🪫", L"⌛", L"⇄" }; - int val = display.annunc; - - if ( val == last_annunc_state ) - return; - - last_annunc_state = val; - - for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) - mvaddwstr( 0, 4 + ( i * 4 ), ( ( annunciators_bits[ i ] & val ) == annunciators_bits[ i ] ) ? annunciators_icons[ i ] : L" " ); -} - static inline wchar_t eight_bits_to_braille_char( bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7, bool b8 ) { /*********/ @@ -210,7 +188,7 @@ static inline void ncurses_draw_lcd_small( void ) wrefresh( stdscr ); } -static inline void ncurses_draw_lcd( void ) +static inline void ncurses_draw_lcd_fullsize( void ) { bool bit; int nibble; @@ -248,7 +226,152 @@ static inline void ncurses_draw_lcd( void ) wrefresh( stdscr ); } -static inline int ncurses_get_event( void ) +static inline void ncurses_draw_lcd( void ) +{ + if ( small ) + ncurses_draw_lcd_small(); + else if ( tiny ) + ncurses_draw_lcd_tiny(); + else + ncurses_draw_lcd_fullsize(); +} + +/* TODO: not specific to tui */ +static inline void draw_nibble( int col, int row, int val ) +{ + /* Dummy, NCurses version draws the whole LCD at once at the end of update_LCD() */ +} + +/* TODO: duplicate of ui_sdl.c:draw_row() */ +static inline void draw_row( long addr, int row ) +{ + int nibble; + int line_length = NIBBLES_PER_ROW; + + if ( ( display.offset > 3 ) && ( row <= display.lines ) ) + line_length += 2; + + for ( int i = 0; i < line_length; i++ ) { + nibble = read_nibble( addr + i ); + if ( nibble == lcd_nibbles_buffer[ row ][ i ] ) + continue; + + lcd_nibbles_buffer[ row ][ i ] = nibble; + draw_nibble( i, row, nibble ); + } +} + +/**********/ +/* public */ +/**********/ +/* TODO: quasi-duplicate of ui_sdl.c:sdl_update_LCD() */ +void text_update_LCD( void ) +{ + if ( display.on ) { + int i; + long addr; + static int old_offset = -1; + static int old_lines = -1; + + addr = display.disp_start; + if ( display.offset != old_offset ) { + memset( lcd_nibbles_buffer, 0xf0, ( size_t )( ( display.lines + 1 ) * NIBS_PER_BUFFER_ROW ) ); + + old_offset = display.offset; + } + if ( display.lines != old_lines ) { + memset( &lcd_nibbles_buffer[ 56 ][ 0 ], 0xf0, ( size_t )( 8 * NIBS_PER_BUFFER_ROW ) ); + + old_lines = display.lines; + } + for ( i = 0; i <= display.lines; i++ ) { + draw_row( addr, i ); + addr += display.nibs_per_line; + } + if ( i < DISP_ROWS ) { + addr = display.menu_start; + for ( ; i < DISP_ROWS; i++ ) { + draw_row( addr, i ); + addr += NIBBLES_PER_ROW; + } + } + } else + memset( lcd_nibbles_buffer, 0xf0, sizeof( lcd_nibbles_buffer ) ); + + /* text UI specific from here */ + ncurses_draw_lcd(); +} + +/* TODO: duplicate of ui_sdl.c:sdl_refresh_LCD() */ +void text_refresh_LCD( void ) {} + +/* TODO: duplicate of ui_sdl.c:sdl_disp_draw_nibble() */ +void text_disp_draw_nibble( word_20 addr, word_4 val ) +{ + long offset; + int x, y; + + offset = ( addr - display.disp_start ); + x = offset % display.nibs_per_line; + if ( x < 0 || x > 35 ) + return; + if ( display.nibs_per_line != 0 ) { + y = offset / display.nibs_per_line; + if ( y < 0 || y > 63 ) + return; + + if ( val == lcd_nibbles_buffer[ y ][ x ] ) + return; + + lcd_nibbles_buffer[ y ][ x ] = val; + draw_nibble( x, y, val ); + } else { + for ( y = 0; y < display.lines; y++ ) { + if ( val == lcd_nibbles_buffer[ y ][ x ] ) + break; + + lcd_nibbles_buffer[ y ][ x ] = val; + draw_nibble( x, y, val ); + } + } +} + +/* TODO: duplicate of ui_sdl.c:sdl_menu_draw_nibble() */ +void text_menu_draw_nibble( word_20 addr, word_4 val ) +{ + long offset; + int x, y; + + offset = ( addr - display.menu_start ); + x = offset % NIBBLES_PER_ROW; + y = display.lines + ( offset / NIBBLES_PER_ROW ) + 1; + + if ( val == lcd_nibbles_buffer[ y ][ x ] ) + return; + + lcd_nibbles_buffer[ y ][ x ] = val; + draw_nibble( x, y, val ); +} + +void text_draw_annunc( void ) +{ + wchar_t* annunciators_icons[ 6 ] = { L"↰", L"↱", L"α", L"🪫", L"⌛", L"⇄" }; + int val = display.annunc; + + if ( val == last_annunc_state ) + return; + + last_annunc_state = val; + + for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) + mvaddwstr( 0, 4 + ( i * 4 ), ( ( annunciators_bits[ i ] & val ) == annunciators_bits[ i ] ) ? annunciators_icons[ i ] : L" " ); +} + +void text_adjust_contrast( void ) +{ /* Dummy, NCurses version doesn't hand contrast (yet?) */ +} + +int text_get_event( void ) { int hpkey = -1; uint32_t k; @@ -459,8 +582,17 @@ static inline int ncurses_get_event( void ) return 1; } -static inline void ncurses_init_ui( void ) +void init_text_ui( int argc, char** argv ) { + /* Set public API to this UIs functions */ + ui_disp_draw_nibble = text_disp_draw_nibble; + ui_menu_draw_nibble = text_menu_draw_nibble; + ui_get_event = text_get_event; + ui_update_LCD = text_update_LCD; + ui_refresh_LCD = text_refresh_LCD; + ui_adjust_contrast = text_adjust_contrast; + ui_draw_annunc = text_draw_annunc; + setlocale( LC_ALL, "" ); initscr(); /* initialize the curses library */ keypad( stdscr, TRUE ); /* enable keyboard mapping */ @@ -502,133 +634,3 @@ static inline void ncurses_init_ui( void ) mvprintw( LCD_BOTTOM + 1, 0, "F1: Enter, F2: Left-Shift, F3: Right-Shift, F4: Alpha, F5: On, F7: Quit" ); } - -/* TODO: not specific to tui */ -static inline void draw_row( long addr, int row ) -{ - int nibble; - int line_length = NIBBLES_PER_ROW; - - if ( ( display.offset > 3 ) && ( row <= display.lines ) ) - line_length += 2; - - for ( int i = 0; i < line_length; i++ ) { - nibble = read_nibble( addr + i ); - if ( nibble == lcd_nibbles_buffer[ row ][ i ] ) - continue; - - lcd_nibbles_buffer[ row ][ i ] = nibble; - } -} - -/**********/ -/* public */ -/**********/ -int text_get_event( void ) { return ncurses_get_event(); } - -void text_adjust_contrast() { text_update_LCD(); } - -void text_update_LCD( void ) -{ - if ( display.on ) { - int i; - long addr; - static int old_offset = -1; - static int old_lines = -1; - - addr = display.disp_start; - if ( display.offset != old_offset ) { - memset( lcd_nibbles_buffer, 0xf0, ( size_t )( ( display.lines + 1 ) * NIBS_PER_BUFFER_ROW ) ); - - old_offset = display.offset; - } - if ( display.lines != old_lines ) { - memset( &lcd_nibbles_buffer[ 56 ][ 0 ], 0xf0, ( size_t )( 8 * NIBS_PER_BUFFER_ROW ) ); - - old_lines = display.lines; - } - for ( i = 0; i <= display.lines; i++ ) { - draw_row( addr, i ); - addr += display.nibs_per_line; - } - if ( i < DISP_ROWS ) { - addr = display.menu_start; - for ( ; i < DISP_ROWS; i++ ) { - draw_row( addr, i ); - addr += NIBBLES_PER_ROW; - } - } - } else - memset( lcd_nibbles_buffer, 0xf0, sizeof( lcd_nibbles_buffer ) ); - - /* text UI specific from here */ - if ( small ) - ncurses_draw_lcd_small(); - else if ( tiny ) - ncurses_draw_lcd_tiny(); - else - ncurses_draw_lcd(); -} - -void text_refresh_LCD( void ) {} - -/* TODO: not specific to tui */ -void text_disp_draw_nibble( word_20 addr, word_4 val ) -{ - long offset; - int x, y; - - offset = ( addr - display.disp_start ); - x = offset % display.nibs_per_line; - if ( x < 0 || x > 35 ) - return; - if ( display.nibs_per_line != 0 ) { - y = offset / display.nibs_per_line; - if ( y < 0 || y > 63 ) - return; - - if ( val == lcd_nibbles_buffer[ y ][ x ] ) - return; - - lcd_nibbles_buffer[ y ][ x ] = val; - } else { - for ( y = 0; y < display.lines; y++ ) { - if ( val == lcd_nibbles_buffer[ y ][ x ] ) - break; - - lcd_nibbles_buffer[ y ][ x ] = val; - } - } -} - -/* TODO: not specific to tui */ -void text_menu_draw_nibble( word_20 addr, word_4 val ) -{ - long offset; - int x, y; - - offset = ( addr - display.menu_start ); - x = offset % NIBBLES_PER_ROW; - y = display.lines + ( offset / NIBBLES_PER_ROW ) + 1; - - if ( val == lcd_nibbles_buffer[ y ][ x ] ) - return; - - lcd_nibbles_buffer[ y ][ x ] = val; -} - -void text_draw_annunc( void ) { ncurses_draw_annunciators(); } - -void init_text_ui( int argc, char** argv ) -{ - /* Set public API to this UIs functions */ - ui_disp_draw_nibble = text_disp_draw_nibble; - ui_menu_draw_nibble = text_menu_draw_nibble; - ui_get_event = text_get_event; - ui_update_LCD = text_update_LCD; - ui_refresh_LCD = text_refresh_LCD; - ui_adjust_contrast = text_adjust_contrast; - ui_draw_annunc = text_draw_annunc; - - ncurses_init_ui(); -} diff --git a/src/ui_x11.c b/src/ui_x11.c index 94bfe78..3bbc536 100644 --- a/src/ui_x11.c +++ b/src/ui_x11.c @@ -18,8 +18,7 @@ #include #include -#include "emulator.h" -#include "romio.h" +#include "romio.h" /* opt_gx */ #include "runtime_options.h" #include "ui.h" #include "ui_inner.h"