merge ui.c & ui_sdl2.c; ui communicate with emulator through functions defined in emulator.h
This commit is contained in:
parent
ce5bec821d
commit
ed0cd5cfa5
8 changed files with 1133 additions and 1275 deletions
1
Makefile
1
Makefile
|
@ -7,7 +7,6 @@ PKG_CONFIG ?= pkg-config
|
||||||
MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES)
|
MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES)
|
||||||
|
|
||||||
DOTOS = src/ui.o \
|
DOTOS = src/ui.o \
|
||||||
src/ui_sdl2.o \
|
|
||||||
src/config.o \
|
src/config.o \
|
||||||
src/emulator.o \
|
src/emulator.o \
|
||||||
src/main.o
|
src/main.o
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
|
|
||||||
hpkey_t keyboard[ 49 ] = {
|
typedef struct hpkey_t {
|
||||||
|
int code;
|
||||||
|
bool pressed;
|
||||||
|
} hpkey_t;
|
||||||
|
|
||||||
|
static hpkey_t keyboard[ 49 ] = {
|
||||||
/* From top left to bottom right */
|
/* From top left to bottom right */
|
||||||
{0x14, 0},
|
{0x14, 0},
|
||||||
{0x84, 0},
|
{0x84, 0},
|
||||||
|
@ -61,7 +66,46 @@ hpkey_t keyboard[ 49 ] = {
|
||||||
{0x00, 0},
|
{0x00, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
saturn_t saturn;
|
static int contrast = 10;
|
||||||
display_t display;
|
|
||||||
|
|
||||||
int annunciators_bits[ NB_ANNUNCIATORS ] = { ANN_LEFT, ANN_RIGHT, ANN_ALPHA, ANN_BATTERY, ANN_BUSY, ANN_IO };
|
void press_key( int hpkey )
|
||||||
|
{
|
||||||
|
// Check not already pressed (may be important: avoids a useless do_kbd_int)
|
||||||
|
if ( keyboard[ hpkey ].pressed )
|
||||||
|
return;
|
||||||
|
|
||||||
|
keyboard[ hpkey ].pressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void release_key( int hpkey )
|
||||||
|
{
|
||||||
|
// Check not already released (not critical)
|
||||||
|
if ( !keyboard[ hpkey ].pressed )
|
||||||
|
return;
|
||||||
|
|
||||||
|
keyboard[ hpkey ].pressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_key_pressed( int hpkey ) { return keyboard[ hpkey ].pressed; }
|
||||||
|
|
||||||
|
unsigned char get_annunciators( void ) { return 255; }
|
||||||
|
|
||||||
|
bool get_display_state( void ) { return true; }
|
||||||
|
|
||||||
|
void get_lcd_buffer( int* target )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < ( LCD_WIDTH * LCD_HEIGHT ); ++i )
|
||||||
|
target[ i ] = i % 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_contrast( void ) { return contrast; }
|
||||||
|
|
||||||
|
void init_emulator( void )
|
||||||
|
{
|
||||||
|
// nop;
|
||||||
|
}
|
||||||
|
|
||||||
|
void exit_emulator( void )
|
||||||
|
{
|
||||||
|
// nop;
|
||||||
|
}
|
||||||
|
|
|
@ -78,41 +78,20 @@
|
||||||
#define ANN_BUSY 0x90
|
#define ANN_BUSY 0x90
|
||||||
#define ANN_IO 0xa0
|
#define ANN_IO 0xa0
|
||||||
|
|
||||||
|
// LCD
|
||||||
#define NIBBLES_PER_ROW 34
|
#define NIBBLES_PER_ROW 34
|
||||||
|
#define LCD_WIDTH 131
|
||||||
|
#define LCD_HEIGHT 64
|
||||||
|
|
||||||
typedef unsigned char word_4;
|
void press_key( int hpkey );
|
||||||
typedef unsigned char word_8;
|
void release_key( int hpkey );
|
||||||
typedef long word_20;
|
bool is_key_pressed( int hpkey );
|
||||||
|
|
||||||
typedef struct hpkey_t {
|
void init_emulator( void );
|
||||||
int code;
|
void exit_emulator( void );
|
||||||
bool pressed;
|
|
||||||
} hpkey_t;
|
|
||||||
|
|
||||||
typedef struct display_t {
|
|
||||||
int on;
|
|
||||||
|
|
||||||
long disp_start;
|
|
||||||
long disp_end;
|
|
||||||
|
|
||||||
int offset;
|
|
||||||
int lines;
|
|
||||||
int nibs_per_line;
|
|
||||||
|
|
||||||
int contrast;
|
|
||||||
|
|
||||||
long menu_start;
|
|
||||||
long menu_end;
|
|
||||||
} display_t;
|
|
||||||
|
|
||||||
typedef struct saturn_t {
|
|
||||||
word_8 annunc;
|
|
||||||
} saturn_t;
|
|
||||||
|
|
||||||
extern hpkey_t keyboard[ 49 ];
|
|
||||||
extern saturn_t saturn;
|
|
||||||
extern display_t display;
|
|
||||||
|
|
||||||
extern int annunciators_bits[ NB_ANNUNCIATORS ];
|
|
||||||
|
|
||||||
|
unsigned char get_annunciators( void );
|
||||||
|
bool get_display_state( void );
|
||||||
|
void get_lcd_buffer( int* target );
|
||||||
|
int get_contrast( void );
|
||||||
#endif /* !_EMULATOR_H */
|
#endif /* !_EMULATOR_H */
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "emulator.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
// start_emulator();
|
init_emulator();
|
||||||
|
|
||||||
/* (G)UI */
|
/* (G)UI */
|
||||||
start_UI( config_init( argc, argv ) );
|
ui_start( config_init( argc, argv ) );
|
||||||
|
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
ui_update_LCD();
|
ui_update_LCD();
|
||||||
|
|
38
src/ui.h
38
src/ui.h
|
@ -4,49 +4,19 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
|
|
||||||
#define DISP_ROWS 64
|
|
||||||
#define NIBS_PER_BUFFER_ROW ( NIBBLES_PER_ROW + 2 )
|
|
||||||
|
|
||||||
/*************/
|
|
||||||
/* variables */
|
|
||||||
/*************/
|
|
||||||
extern int last_annunc_state;
|
|
||||||
|
|
||||||
extern unsigned char lcd_nibbles_buffer[ DISP_ROWS ][ NIBS_PER_BUFFER_ROW ];
|
|
||||||
|
|
||||||
/*************/
|
|
||||||
/* functions */
|
|
||||||
/*************/
|
|
||||||
extern void init_sdl2_ui( config_t* config );
|
|
||||||
extern void sdl2_ui_stop( void );
|
|
||||||
|
|
||||||
/*************************************************/
|
/*************************************************/
|
||||||
/* public API: if it's there it's used elsewhere */
|
/* public API: if it's there it's used elsewhere */
|
||||||
/*************************************************/
|
/*************************************************/
|
||||||
/*************************/
|
extern void ui_get_event( void );
|
||||||
/* used in: emu_memory.c */
|
extern void ui_adjust_contrast( void );
|
||||||
/*************************/
|
|
||||||
extern void ( *ui_disp_draw_nibble )( word_20 addr, word_4 val );
|
|
||||||
extern void ( *ui_menu_draw_nibble )( word_20 addr, word_4 val );
|
|
||||||
|
|
||||||
/*****************************************/
|
extern void ui_update_LCD( void );
|
||||||
/* used in: emu_emulate.c */
|
|
||||||
/*****************************************/
|
|
||||||
extern void ( *ui_get_event )( void );
|
|
||||||
extern void ( *ui_adjust_contrast )( void );
|
|
||||||
extern void ( *ui_draw_annunc )( void );
|
|
||||||
|
|
||||||
/*****************************************************/
|
|
||||||
/* used in: emu_emulate.c, debugger.c */
|
|
||||||
/*****************************************************/
|
|
||||||
extern void ( *ui_update_LCD )( void );
|
|
||||||
extern void ( *ui_refresh_LCD )( void );
|
|
||||||
|
|
||||||
/*******************/
|
/*******************/
|
||||||
/* used in: main.c */
|
/* used in: main.c */
|
||||||
/*******************/
|
/*******************/
|
||||||
extern void ui_stop( void );
|
extern void ui_stop( void );
|
||||||
extern void start_UI( config_t* config );
|
extern void ui_start( config_t* config );
|
||||||
|
|
||||||
extern void close_and_exit( void );
|
extern void close_and_exit( void );
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,5 @@ extern ann_struct_t ann_tbl[ NB_ANNUNCIATORS ];
|
||||||
/*************/
|
/*************/
|
||||||
extern int SmallTextWidth( const char* string, unsigned int length );
|
extern int SmallTextWidth( const char* string, unsigned int length );
|
||||||
extern int BigTextWidth( const char* string, unsigned int length );
|
extern int BigTextWidth( const char* string, unsigned int length );
|
||||||
extern void ui_init_LCD( void );
|
|
||||||
|
|
||||||
#endif /* _UI_INNER_H */
|
#endif /* _UI_INNER_H */
|
||||||
|
|
1184
src/ui_sdl2.c
1184
src/ui_sdl2.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue