split global and UI-specific options; inline X11's init_nibble_maps()
This commit is contained in:
parent
bd490f493a
commit
1f5924b73a
11 changed files with 698 additions and 674 deletions
1
Makefile
1
Makefile
|
@ -36,6 +36,7 @@ DOTOS = src/main.o \
|
|||
src/hp48emu_actions.o \
|
||||
src/hp48emu_memory.o \
|
||||
src/hp48emu_register.o \
|
||||
src/options.o \
|
||||
src/romio.o \
|
||||
src/timer.o \
|
||||
src/x48_errors.o \
|
||||
|
|
|
@ -180,53 +180,6 @@ unsigned char nibbles[ 16 ][ 2 ] = {
|
|||
};
|
||||
|
||||
static unsigned char nibble_bitmap[ 16 ];
|
||||
|
||||
void init_nibble_maps( void ) {
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < 16; i++ ) {
|
||||
nibble_maps[ i ] =
|
||||
XCreateBitmapFromData( dpy, disp.win, ( char* )nibbles[ i ], 8, 2 );
|
||||
}
|
||||
|
||||
if ( shm_flag ) {
|
||||
if ( disp.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; /* **** */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ann_struct_t ann_tbl[] = {
|
||||
|
@ -275,40 +228,93 @@ void init_display( void ) {
|
|||
memset( lcd_buffer, 0xf0, sizeof( lcd_buffer ) );
|
||||
|
||||
#if defined( GUI_IS_X11 )
|
||||
init_nibble_maps();
|
||||
/* init nibble_maps */
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < 16; i++ ) {
|
||||
nibble_maps[ i ] =
|
||||
XCreateBitmapFromData( dpy, disp.win, ( char* )nibbles[ i ], 8, 2 );
|
||||
}
|
||||
|
||||
if ( shm_flag ) {
|
||||
if ( disp.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; /* **** */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined( GUI_IS_X11 )
|
||||
static inline void draw_nibble( int c, int r, int val ) {
|
||||
int x, y;
|
||||
|
||||
#if defined( GUI_IS_X11 )
|
||||
x = ( c * 8 ) + 5;
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
x = ( c * 4 ); // x: start in pixels
|
||||
#endif
|
||||
|
||||
if ( r <= display.lines )
|
||||
x -= disp.offset;
|
||||
#if defined( GUI_IS_X11 )
|
||||
y = ( r * 2 ) + 20;
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
y = r; // y: start in pixels
|
||||
#endif
|
||||
|
||||
val &= 0x0f;
|
||||
if ( val != lcd_buffer[ r ][ c ] ) {
|
||||
#if defined( GUI_IS_X11 )
|
||||
XCopyPlane( dpy, nibble_maps[ val ], disp.win, disp.gc, 0, 0, 8, 2, x,
|
||||
y, 1 );
|
||||
#endif
|
||||
lcd_buffer[ r ][ c ] = val;
|
||||
}
|
||||
if ( val != lcd_buffer[ r ][ c ] )
|
||||
lcd_buffer[ r ][ c ] = val;
|
||||
}
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
static inline void draw_nibble( int c, int r, int val ) {
|
||||
int x, y;
|
||||
|
||||
x = ( c * 4 ); // x: start in pixels
|
||||
|
||||
if ( r <= display.lines )
|
||||
x -= disp.offset;
|
||||
y = r; // y: start in pixels
|
||||
|
||||
val &= 0x0f;
|
||||
if ( val != lcd_buffer[ r ][ c ] ) {
|
||||
lcd_buffer[ r ][ c ] = val;
|
||||
}
|
||||
if ( val != lcd_buffer[ r ][ c ] )
|
||||
lcd_buffer[ r ][ c ] = val;
|
||||
|
||||
#if defined( GUI_IS_SDL1 )
|
||||
SDLDrawNibble( x, y, val );
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void draw_row( long addr, int row ) {
|
||||
int i, v;
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "options.h"
|
||||
#include "hp48.h"
|
||||
#include "hp48emu.h"
|
||||
#include "romio.h"
|
||||
#include "x48_resources.h"
|
||||
|
||||
#define X48_MAGIC 0x48503438
|
||||
#define NR_CONFIG 8
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "options.h"
|
||||
#include "hp48.h"
|
||||
#include "hp48emu.h"
|
||||
#include "x48.h"
|
||||
#include "x48_resources.h"
|
||||
#include "x48.h" /* ShowConnections() */
|
||||
|
||||
static int wire_fd;
|
||||
static int ir_fd;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "hp48emu.h"
|
||||
#include "romio.h"
|
||||
#include "x48.h"
|
||||
#include "x48_resources.h"
|
||||
#include "options.h"
|
||||
|
||||
extern int device_check;
|
||||
extern short port1_is_ram;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <langinfo.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "options.h"
|
||||
#include "hp48.h"
|
||||
#include "x48.h"
|
||||
#include "x48_resources.h"
|
||||
|
|
12
src/options.c
Normal file
12
src/options.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "options.h"
|
||||
|
||||
int verbose;
|
||||
int useTerminal;
|
||||
int useSerial;
|
||||
int throttle;
|
||||
int initialize;
|
||||
int resetOnStartup;
|
||||
|
||||
char* serialLine;
|
||||
char* romFileName;
|
||||
char* homeDirectory;
|
15
src/options.h
Normal file
15
src/options.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef _OPTIONS_H
|
||||
#define _OPTIONS_H 1
|
||||
|
||||
extern int verbose;
|
||||
extern int useTerminal;
|
||||
extern int useSerial;
|
||||
extern int throttle;
|
||||
extern int initialize;
|
||||
extern int resetOnStartup;
|
||||
|
||||
extern char* serialLine;
|
||||
extern char* romFileName;
|
||||
extern char* homeDirectory;
|
||||
|
||||
#endif /* !_OPTIONS_H */
|
|
@ -4,34 +4,20 @@
|
|||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "options.h"
|
||||
#include "x48_errors.h"
|
||||
#include "x48_resources.h"
|
||||
|
||||
int verbose;
|
||||
int useTerminal;
|
||||
int useSerial;
|
||||
int useXShm;
|
||||
int netbook;
|
||||
int throttle;
|
||||
int initialize;
|
||||
int resetOnStartup;
|
||||
#if defined( GUI_IS_X11 )
|
||||
char* serialLine;
|
||||
char* romFileName;
|
||||
char* homeDirectory;
|
||||
char* res_name;
|
||||
char* res_class;
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
char serialLine[ 1024 ];
|
||||
char romFileName[ 1024 ];
|
||||
char homeDirectory[ 1024 ];
|
||||
#endif
|
||||
|
||||
#if defined( GUI_IS_X11 )
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
int useXShm;
|
||||
int netbook;
|
||||
char* res_name;
|
||||
char* res_class;
|
||||
|
||||
XrmDatabase rdb = ( XrmDatabase )0;
|
||||
|
||||
void usage( void ) {
|
||||
|
@ -330,7 +316,6 @@ XFontStruct* get_font_resource( Display* dpy, char* name, char* class ) {
|
|||
}
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
void get_resources( void ) {
|
||||
verbose = 0;
|
||||
|
@ -341,7 +326,6 @@ void get_resources( void ) {
|
|||
netbook = 0;
|
||||
throttle = 0;
|
||||
|
||||
#if defined( GUI_IS_X11 )
|
||||
if ( get_boolean_resource( "printVersion", "PrintVersion" ) )
|
||||
show_version();
|
||||
if ( get_boolean_resource( "printCopyright", "PrintCopyright" ) )
|
||||
|
@ -366,10 +350,21 @@ void get_resources( void ) {
|
|||
netbook = get_boolean_resource( "netbook", "Netbook" );
|
||||
|
||||
throttle = get_boolean_resource( "throttle", "Throttle" );
|
||||
}
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
strcpy( serialLine, "/dev/ttyS0" );
|
||||
void get_resources( void ) {
|
||||
verbose = 0;
|
||||
useTerminal = 1;
|
||||
useSerial = 0;
|
||||
initialize = 0;
|
||||
resetOnStartup = 0;
|
||||
throttle = 0;
|
||||
|
||||
serialLine = "/dev/ttyS0" ;
|
||||
|
||||
romFileName = "rom.dump";
|
||||
|
||||
// Have homeDirectory in the user's home
|
||||
strcpy( homeDirectory, ".x48ng" ); // live files are stored in ~/.x48ng
|
||||
#endif
|
||||
homeDirectory = ".x48ng"; // live files are stored in ~/.x48ng
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,27 +4,10 @@
|
|||
#if defined( GUI_IS_X11 )
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
#endif
|
||||
|
||||
extern int verbose;
|
||||
extern int useTerminal;
|
||||
extern int useSerial;
|
||||
extern int useXShm;
|
||||
extern int netbook;
|
||||
extern int throttle;
|
||||
extern int initialize;
|
||||
extern int resetOnStartup;
|
||||
#if defined( GUI_IS_X11 )
|
||||
extern char* serialLine;
|
||||
extern char* romFileName;
|
||||
extern char* homeDirectory;
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
extern char serialLine[];
|
||||
extern char romFileName[];
|
||||
extern char homeDirectory[];
|
||||
#endif
|
||||
|
||||
#if defined( GUI_IS_X11 )
|
||||
extern char* progname;
|
||||
extern char* res_name;
|
||||
extern char* res_class;
|
||||
|
|
Loading…
Reference in a new issue