special header file for debugger: emulator_for_debugger.h
This commit is contained in:
parent
84328c19ae
commit
d4a3bae009
7 changed files with 163 additions and 141 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "runtime_options.h"
|
||||
#include "emulator.h"
|
||||
#include "emulator_for_debugger.h"
|
||||
#include "romio.h"
|
||||
#include "ui.h" /* ui_update_LCD(); */
|
||||
#include "debugger.h"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _DEBUGGER_H 1
|
||||
|
||||
#include "emulator.h"
|
||||
#include "emulator_for_debugger.h"
|
||||
|
||||
#define USER_INTERRUPT 1
|
||||
#define ILLEGAL_INSTRUCTION 2
|
||||
|
|
168
src/emu_init.c
168
src/emu_init.c
|
@ -90,43 +90,6 @@ hpkey_t keyboard[ 49 ] = {
|
|||
|
||||
int annunciators_bits[ NB_ANNUNCIATORS ] = { ANN_LEFT, ANN_RIGHT, ANN_ALPHA, ANN_BATTERY, ANN_BUSY, ANN_IO };
|
||||
|
||||
int read_rom( const char* fname )
|
||||
{
|
||||
int ram_size;
|
||||
|
||||
if ( !read_rom_file( fname, &saturn.rom, &rom_size ) )
|
||||
return 0;
|
||||
|
||||
if ( verbose )
|
||||
printf( "read %s\n", fname );
|
||||
|
||||
dev_memory_init();
|
||||
|
||||
ram_size = opt_gx ? RAM_SIZE_GX : RAM_SIZE_SX;
|
||||
|
||||
if ( NULL == ( saturn.ram = ( word_4* )malloc( ram_size ) ) ) {
|
||||
if ( verbose )
|
||||
fprintf( stderr, "can\'t malloc RAM\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset( saturn.ram, 0, ram_size );
|
||||
|
||||
port1_size = 0;
|
||||
port1_mask = 0;
|
||||
port1_is_ram = false;
|
||||
saturn.port1 = ( unsigned char* )0;
|
||||
|
||||
port2_size = 0;
|
||||
port2_mask = 0;
|
||||
port2_is_ram = false;
|
||||
saturn.port2 = ( unsigned char* )0;
|
||||
|
||||
saturn.card_status = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void saturn_config_init( void )
|
||||
{
|
||||
saturn.version[ 0 ] = VERSION_MAJOR;
|
||||
|
@ -174,53 +137,6 @@ void init_saturn( void )
|
|||
dev_memory_init();
|
||||
}
|
||||
|
||||
void init_display( void )
|
||||
{
|
||||
display.on = ( int )( saturn.disp_io & 0x8 ) >> 3;
|
||||
|
||||
display.disp_start = ( saturn.disp_addr & 0xffffe );
|
||||
display.offset = ( saturn.disp_io & 0x7 );
|
||||
|
||||
display.lines = ( saturn.line_count & 0x3f );
|
||||
if ( display.lines == 0 )
|
||||
display.lines = 63;
|
||||
|
||||
if ( display.offset > 3 )
|
||||
display.nibs_per_line = ( NIBBLES_PER_ROW + saturn.line_offset + 2 ) & 0xfff;
|
||||
else
|
||||
display.nibs_per_line = ( NIBBLES_PER_ROW + saturn.line_offset ) & 0xfff;
|
||||
|
||||
display.disp_end = display.disp_start + ( display.nibs_per_line * ( display.lines + 1 ) );
|
||||
|
||||
display.menu_start = saturn.menu_addr;
|
||||
display.menu_end = saturn.menu_addr + 0x110;
|
||||
|
||||
display.contrast = saturn.contrast_ctrl;
|
||||
display.contrast |= ( ( saturn.disp_test & 0x1 ) << 4 );
|
||||
}
|
||||
|
||||
int init_emulator( void )
|
||||
{
|
||||
/* If files are successfully read => return and let's go */
|
||||
if ( read_files() ) {
|
||||
if ( resetOnStartup )
|
||||
saturn.PC = 0x00000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if files were not readble => initialize */
|
||||
if ( verbose )
|
||||
fprintf( stderr, "initialization of %s\n", normalized_config_path );
|
||||
|
||||
init_saturn();
|
||||
if ( !read_rom( normalized_rom_path ) )
|
||||
exit( 1 ); /* can't read ROM */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void exit_emulator( void ) { write_files(); }
|
||||
|
||||
/***********************************************/
|
||||
/* READING ~/.config/x48ng/{rom,ram,state,port1,port2} */
|
||||
/***********************************************/
|
||||
|
@ -1017,3 +933,87 @@ int write_files( void )
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int read_rom( const char* fname )
|
||||
{
|
||||
int ram_size;
|
||||
|
||||
if ( !read_rom_file( fname, &saturn.rom, &rom_size ) )
|
||||
return 0;
|
||||
|
||||
if ( verbose )
|
||||
printf( "read %s\n", fname );
|
||||
|
||||
dev_memory_init();
|
||||
|
||||
ram_size = opt_gx ? RAM_SIZE_GX : RAM_SIZE_SX;
|
||||
|
||||
if ( NULL == ( saturn.ram = ( word_4* )malloc( ram_size ) ) ) {
|
||||
if ( verbose )
|
||||
fprintf( stderr, "can\'t malloc RAM\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset( saturn.ram, 0, ram_size );
|
||||
|
||||
port1_size = 0;
|
||||
port1_mask = 0;
|
||||
port1_is_ram = false;
|
||||
saturn.port1 = ( unsigned char* )0;
|
||||
|
||||
port2_size = 0;
|
||||
port2_mask = 0;
|
||||
port2_is_ram = false;
|
||||
saturn.port2 = ( unsigned char* )0;
|
||||
|
||||
saturn.card_status = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void init_display( void )
|
||||
{
|
||||
display.on = ( int )( saturn.disp_io & 0x8 ) >> 3;
|
||||
|
||||
display.disp_start = ( saturn.disp_addr & 0xffffe );
|
||||
display.offset = ( saturn.disp_io & 0x7 );
|
||||
|
||||
display.lines = ( saturn.line_count & 0x3f );
|
||||
if ( display.lines == 0 )
|
||||
display.lines = 63;
|
||||
|
||||
if ( display.offset > 3 )
|
||||
display.nibs_per_line = ( NIBBLES_PER_ROW + saturn.line_offset + 2 ) & 0xfff;
|
||||
else
|
||||
display.nibs_per_line = ( NIBBLES_PER_ROW + saturn.line_offset ) & 0xfff;
|
||||
|
||||
display.disp_end = display.disp_start + ( display.nibs_per_line * ( display.lines + 1 ) );
|
||||
|
||||
display.menu_start = saturn.menu_addr;
|
||||
display.menu_end = saturn.menu_addr + 0x110;
|
||||
|
||||
display.contrast = saturn.contrast_ctrl;
|
||||
display.contrast |= ( ( saturn.disp_test & 0x1 ) << 4 );
|
||||
}
|
||||
|
||||
int init_emulator( void )
|
||||
{
|
||||
/* If files are successfully read => return and let's go */
|
||||
if ( read_files() ) {
|
||||
if ( resetOnStartup )
|
||||
saturn.PC = 0x00000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if files were not readble => initialize */
|
||||
if ( verbose )
|
||||
fprintf( stderr, "initialization of %s\n", normalized_config_path );
|
||||
|
||||
init_saturn();
|
||||
if ( !read_rom( normalized_rom_path ) )
|
||||
exit( 1 ); /* can't read ROM */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void exit_emulator( void ) { write_files(); }
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "emulator.h"
|
||||
#include "emulator_inner.h"
|
||||
|
||||
void press_key( int hpkey )
|
||||
{
|
||||
|
|
|
@ -324,48 +324,28 @@ extern int annunciators_bits[ NB_ANNUNCIATORS ];
|
|||
/**************/
|
||||
extern void init_display( void ); /* used in main.c */
|
||||
extern int init_emulator( void ); /* used in main.c */
|
||||
extern void exit_emulator( void ); /* debugger.c; main.c; ui_*.c */
|
||||
extern int read_files( void ); /* debugger.c */
|
||||
extern int write_files( void ); /* used in debugger.c */
|
||||
|
||||
/***************/
|
||||
/* emu_timer.c */
|
||||
/***************/
|
||||
extern void start_timer( int timer );
|
||||
extern void stop_timer( int timer );
|
||||
|
||||
extern t1_t2_ticks get_t1_t2( void );
|
||||
extern void set_accesstime( void );
|
||||
extern void exit_emulator( void ); /* used in debugger.c; main.c; ui_*.c */
|
||||
|
||||
/********************/
|
||||
/* emu_memory.c */
|
||||
/********************/
|
||||
extern int ( *read_nibble )( long addr );
|
||||
|
||||
/****************/
|
||||
/* emu_memory.c */
|
||||
/****************/
|
||||
extern long read_nibbles( long addr, int len );
|
||||
extern int ( *read_nibble )( long addr ); /* used in debugger.c; ui_*.c */
|
||||
|
||||
/******************/
|
||||
/* emu_keyboard.c */
|
||||
/******************/
|
||||
extern void press_key( int hpkey );
|
||||
extern void release_key( int hpkey );
|
||||
extern void release_all_keys( void );
|
||||
extern void press_key( int hpkey ); /* used in ui_*.c */
|
||||
extern void release_key( int hpkey ); /* used in ui_*.c */
|
||||
extern void release_all_keys( void ); /* used in ui_*.c */
|
||||
|
||||
/****************/
|
||||
/* emu_serial.c */
|
||||
/****************/
|
||||
extern int init_serial( void );
|
||||
extern int init_serial( void ); /* used in main.c */
|
||||
|
||||
/*****************/
|
||||
/* emu_emulate.c */
|
||||
/*****************/
|
||||
extern void load_addr( word_20* dat, long addr, int n );
|
||||
extern void do_kbd_int( void );
|
||||
extern int step_instruction( void );
|
||||
extern void schedule( void );
|
||||
extern void emulate( void );
|
||||
extern void emulate( void ); /* used in main.c */
|
||||
|
||||
#endif /* !_EMULATOR_H */
|
||||
|
|
38
src/emulator_for_debugger.h
Normal file
38
src/emulator_for_debugger.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#ifndef _EMULATOR_FOR_DEBUGGER_H
|
||||
#define _EMULATOR_FOR_DEBUGGER_H 1
|
||||
|
||||
#include "emulator.h"
|
||||
|
||||
/**************/
|
||||
/* emu_init.c */
|
||||
/**************/
|
||||
extern void exit_emulator( void ); /* used in debugger.c; main.c; ui_*.c */
|
||||
extern int read_files( void ); /* used in debugger.c */
|
||||
extern int write_files( void ); /* used in debugger.c */
|
||||
|
||||
/***************/
|
||||
/* emu_timer.c */
|
||||
/***************/
|
||||
extern void start_timer( int timer ); /* used in debugger.c */
|
||||
extern void stop_timer( int timer ); /* used in debugger.c */
|
||||
extern t1_t2_ticks get_t1_t2( void ); /* used in debugger.c */
|
||||
extern void set_accesstime( void ); /* used in debugger.c */
|
||||
|
||||
/********************/
|
||||
/* emu_memory.c */
|
||||
/********************/
|
||||
extern int ( *read_nibble )( long addr ); /* used in debugger.c; ui_*.c */
|
||||
|
||||
/****************/
|
||||
/* emu_memory.c */
|
||||
/****************/
|
||||
extern long read_nibbles( long addr, int len ); /* used in debugger.c */
|
||||
|
||||
/*****************/
|
||||
/* emu_emulate.c */
|
||||
/*****************/
|
||||
extern void load_addr( word_20* dat, long addr, int n ); /* used in debugger.c */
|
||||
extern int step_instruction( void ); /* used in debugger.c */
|
||||
extern void schedule( void ); /* used in debugger.c */
|
||||
|
||||
#endif /* !_EMULATOR_FOR_DEBUGGER_H */
|
|
@ -24,6 +24,7 @@ extern word_64 get_timer( int timer );
|
|||
/* emu_emulate.c */
|
||||
/*****************/
|
||||
extern void do_interupt( void );
|
||||
extern void do_kbd_int( void );
|
||||
|
||||
/********************/
|
||||
/* emu_memory.c */
|
||||
|
@ -39,36 +40,36 @@ extern void dev_memory_init( void ); /* */
|
|||
/******************/
|
||||
/* emu_register.c */
|
||||
/******************/
|
||||
int get_start( int code );
|
||||
int get_end( int code );
|
||||
void add_p_plus_one( unsigned char* r );
|
||||
void add_register_constant( unsigned char* res, int code, int val );
|
||||
void sub_register_constant( unsigned char* res, int code, int val );
|
||||
void add_register( unsigned char* res, unsigned char* r1, unsigned char* r2, int code );
|
||||
void sub_register( unsigned char* res, unsigned char* r1, unsigned char* r2, int code );
|
||||
void complement_2_register( unsigned char* r, int code );
|
||||
void complement_1_register( unsigned char* r, int code );
|
||||
void inc_register( unsigned char* r, int code );
|
||||
void dec_register( unsigned char* r, int code );
|
||||
void zero_register( unsigned char* r, int code );
|
||||
void or_register( unsigned char* res, unsigned char* r1, unsigned char* r2, int code );
|
||||
void and_register( unsigned char* res, unsigned char* r1, unsigned char* r2, int code );
|
||||
void copy_register( unsigned char* to, unsigned char* from, int code );
|
||||
void exchange_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
void exchange_reg( unsigned char* r, word_20* d, int code );
|
||||
void shift_left_register( unsigned char* r, int code );
|
||||
void shift_left_circ_register( unsigned char* r, int code );
|
||||
void shift_right_register( unsigned char* r, int code );
|
||||
void shift_right_circ_register( unsigned char* r, int code );
|
||||
void shift_right_bit_register( unsigned char* r, int code );
|
||||
int is_zero_register( unsigned char* r, int code );
|
||||
int is_not_zero_register( unsigned char* r, int code );
|
||||
int is_equal_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
int is_not_equal_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
int is_less_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
int is_less_or_equal_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
int is_greater_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
int is_greater_or_equal_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
extern int get_start( int code );
|
||||
extern int get_end( int code );
|
||||
extern void add_p_plus_one( unsigned char* r );
|
||||
extern void add_register_constant( unsigned char* res, int code, int val );
|
||||
extern void sub_register_constant( unsigned char* res, int code, int val );
|
||||
extern void add_register( unsigned char* res, unsigned char* r1, unsigned char* r2, int code );
|
||||
extern void sub_register( unsigned char* res, unsigned char* r1, unsigned char* r2, int code );
|
||||
extern void complement_2_register( unsigned char* r, int code );
|
||||
extern void complement_1_register( unsigned char* r, int code );
|
||||
extern void inc_register( unsigned char* r, int code );
|
||||
extern void dec_register( unsigned char* r, int code );
|
||||
extern void zero_register( unsigned char* r, int code );
|
||||
extern void or_register( unsigned char* res, unsigned char* r1, unsigned char* r2, int code );
|
||||
extern void and_register( unsigned char* res, unsigned char* r1, unsigned char* r2, int code );
|
||||
extern void copy_register( unsigned char* to, unsigned char* from, int code );
|
||||
extern void exchange_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
extern void exchange_reg( unsigned char* r, word_20* d, int code );
|
||||
extern void shift_left_register( unsigned char* r, int code );
|
||||
extern void shift_left_circ_register( unsigned char* r, int code );
|
||||
extern void shift_right_register( unsigned char* r, int code );
|
||||
extern void shift_right_circ_register( unsigned char* r, int code );
|
||||
extern void shift_right_bit_register( unsigned char* r, int code );
|
||||
extern int is_zero_register( unsigned char* r, int code );
|
||||
extern int is_not_zero_register( unsigned char* r, int code );
|
||||
extern int is_equal_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
extern int is_not_equal_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
extern int is_less_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
extern int is_less_or_equal_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
extern int is_greater_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
extern int is_greater_or_equal_register( unsigned char* r1, unsigned char* r2, int code );
|
||||
|
||||
/****************/
|
||||
/* emu_serial.c */
|
||||
|
|
Loading…
Reference in a new issue