s/files/persistence/g; code formatting

This commit is contained in:
Gwenhael Le Moine 2024-04-15 19:43:28 +02:00
parent 8137109c17
commit f8fe206626
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
7 changed files with 99 additions and 130 deletions

View file

@ -18,7 +18,7 @@ dist/hpemung: src/bus.o \
src/keyboard.o \ src/keyboard.o \
src/main.o \ src/main.o \
src/opcodes.o \ src/opcodes.o \
src/files.o \ src/persistence.o \
src/ports.o \ src/ports.o \
src/rpl.o \ src/rpl.o \
src/config.o \ src/config.o \

151
src/bus.c
View file

@ -66,36 +66,33 @@ void bus_read( byte* buf, address adr, address len )
while ( true ) { while ( true ) {
if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) { if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
n = MIN( len, 0x40 - ( adr & 0x3F ) ); n = MIN( len, 0x40 - ( adr & 0x3F ) );
for ( i = 0; i < n; i++ ) { for ( i = 0; i < n; i++ )
buf[ i ] = hdw_read_nibble( ( adr & 0x3F ) + i ); buf[ i ] = hdw_read_nibble( ( adr & 0x3F ) + i );
}
if ( ( ( adr & 0x3F ) + n ) == 0x40 ) { if ( ( ( adr & 0x3F ) + n ) == 0x40 )
update_crc( buf[ n - 1 ] ); update_crc( buf[ n - 1 ] );
}
} else { } else {
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) { if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 )
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr ); n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
} else { else
n = MIN( len, 0x1000 - OFFSET_OF( adr ) ); n = MIN( len, 0x1000 - OFFSET_OF( adr ) );
}
if ( CAN_READ( adr ) ) { if ( CAN_READ( adr ) )
memcpy( buf, MAP_READ( adr ), n ); memcpy( buf, MAP_READ( adr ), n );
} else { else {
for ( i = 0; i < n; i++ ) { for ( i = 0; i < n; i++ )
buf[ i ] = ( ( i + adr ) & 1 ) ? 0xE : 0xD; buf[ i ] = ( ( i + adr ) & 1 ) ? 0xE : 0xD;
}
if ( bus_info.ce1_bs && bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) ) { if ( bus_info.ce1_bs && bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) )
ports_switch_bank( OFFSET_OF( adr + n ) ); ports_switch_bank( OFFSET_OF( adr + n ) );
} }
} for ( i = 0; i < n; i++ )
for ( i = 0; i < n; i++ ) {
update_crc( buf[ i ] ); update_crc( buf[ i ] );
} }
}
len -= n; len -= n;
if ( !len ) { if ( !len )
break; break;
}
buf += n; buf += n;
adr += n; adr += n;
adr &= 0xFFFFF; adr &= 0xFFFFF;
@ -109,33 +106,31 @@ void bus_write( byte* buf, address adr, address len )
while ( true ) { while ( true ) {
if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) { if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
n = MIN( len, 0x40 - ( adr & 0x3F ) ); n = MIN( len, 0x40 - ( adr & 0x3F ) );
for ( i = 0; i < n; i++ ) { for ( i = 0; i < n; i++ )
hdw_write_nibble( buf[ i ], ( adr & 0x3F ) + i ); hdw_write_nibble( buf[ i ], ( adr & 0x3F ) + i );
}
} else { } else {
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) { if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 )
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr ); n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
} else { else
n = MIN( len, 0x1000 - OFFSET_OF( adr ) ); n = MIN( len, 0x1000 - OFFSET_OF( adr ) );
}
if ( CAN_WRITE( adr ) ) { if ( CAN_WRITE( adr ) )
memcpy( MAP_WRITE( adr ), buf, n ); memcpy( MAP_WRITE( adr ), buf, n );
} else if ( bus_info.ce1_bs ) { else if ( bus_info.ce1_bs ) {
if ( bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) ) { if ( bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) ) {
if ( !bus_info.nce3_r_o ) { if ( !bus_info.nce3_r_o )
ports_switch_bank( OFFSET_OF( adr + n - 1 ) ); ports_switch_bank( OFFSET_OF( adr + n - 1 ) );
} else if ( ( adr + n ) & 1 ) { else if ( ( adr + n ) & 1 )
ports_switch_bank( OFFSET_OF( adr + n - 1 ) ); ports_switch_bank( OFFSET_OF( adr + n - 1 ) );
} else if ( adr & 0x1 ) { else if ( adr & 0x1 )
ports_switch_bank( OFFSET_OF( adr ) ); ports_switch_bank( OFFSET_OF( adr ) );
} }
} }
} }
}
len -= n; len -= n;
if ( !len ) { if ( !len )
break; break;
}
buf += n; buf += n;
adr += n; adr += n;
adr &= 0xFFFFF; adr &= 0xFFFFF;
@ -149,27 +144,25 @@ static void bus_peek( byte* buf, address adr, address len )
while ( true ) { while ( true ) {
if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) { if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
n = MIN( len, 0x40 - ( adr & 0x3F ) ); n = MIN( len, 0x40 - ( adr & 0x3F ) );
for ( i = 0; i < n; i++ ) { for ( i = 0; i < n; i++ )
buf[ i ] = hdw_read_nibble( ( adr & 0x3F ) + i ); buf[ i ] = hdw_read_nibble( ( adr & 0x3F ) + i );
}
} else { } else {
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) { if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 )
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr ); n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
} else { else
n = MIN( len, 0x1000 - OFFSET_OF( adr ) ); n = MIN( len, 0x1000 - OFFSET_OF( adr ) );
}
if ( CAN_READ( adr ) ) { if ( CAN_READ( adr ) )
memcpy( buf, MAP_READ( adr ), n ); memcpy( buf, MAP_READ( adr ), n );
} else { else
for ( i = 0; i < n; i++ ) { for ( i = 0; i < n; i++ )
buf[ i ] = ( ( i + adr ) & 1 ) ? 0xE : 0xD; buf[ i ] = ( ( i + adr ) & 1 ) ? 0xE : 0xD;
} }
}
}
len -= n; len -= n;
if ( !len ) { if ( !len )
break; break;
}
buf += n; buf += n;
adr += n; adr += n;
adr &= 0xFFFFF; adr &= 0xFFFFF;
@ -183,17 +176,16 @@ static void bus_peek_no_hdw( byte* buf, address adr, address len )
while ( true ) { while ( true ) {
n = MIN( len, 0x1000 - OFFSET_OF( adr ) ); n = MIN( len, 0x1000 - OFFSET_OF( adr ) );
if ( CAN_READ( adr ) ) { if ( CAN_READ( adr ) )
memcpy( buf, MAP_READ( adr ), n ); memcpy( buf, MAP_READ( adr ), n );
} else { else
for ( i = 0; i < n; i++ ) { for ( i = 0; i < n; i++ )
buf[ i ] = ( ( i + adr ) & 1 ) ? 0xE : 0xD; buf[ i ] = ( ( i + adr ) & 1 ) ? 0xE : 0xD;
}
}
len -= n; len -= n;
if ( !len ) { if ( !len )
break; break;
}
buf += n; buf += n;
adr += n; adr += n;
adr &= 0xFFFFF; adr &= 0xFFFFF;
@ -216,62 +208,60 @@ byte* bus_fast_peek( byte* buf, address adr, int* len )
static int tmp_len; static int tmp_len;
address adr2; address adr2;
if ( !buf ) { if ( !buf )
buf = tmp_buf; buf = tmp_buf;
}
if ( !len ) { if ( !len ) {
tmp_len = FAST_PEEK_MAX; tmp_len = FAST_PEEK_MAX;
len = &tmp_len; len = &tmp_len;
} }
if ( *len > FAST_PEEK_MAX ) { if ( *len > FAST_PEEK_MAX )
*len = FAST_PEEK_MAX; *len = FAST_PEEK_MAX;
}
adr2 = adr + *len - 1; adr2 = adr + *len - 1;
if ( ( SEG_OF( adr ) == hdw_seg || SEG_OF( adr2 ) == hdw_seg ) && if ( ( SEG_OF( adr ) == hdw_seg || SEG_OF( adr2 ) == hdw_seg ) &&
( ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 || ( ( bus_info.hdw_base ^ adr2 ) & 0xFFFC0 ) == 0 ) ) { ( ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 || ( ( bus_info.hdw_base ^ adr2 ) & 0xFFFC0 ) == 0 ) ) {
bus_peek( buf, adr, *len ); bus_peek( buf, adr, *len );
return buf; return buf;
} else if ( !CAN_READ( adr ) ) { } else if ( !CAN_READ( adr ) ) {
bus_peek_no_hdw( buf, adr, *len ); bus_peek_no_hdw( buf, adr, *len );
return buf; return buf;
} else if ( SEG_OF( adr ) == SEG_OF( adr2 ) ) { } else if ( SEG_OF( adr ) == SEG_OF( adr2 ) ) {
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) { if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 )
*len = ( bus_info.hdw_base & 0xFFFC0 ) - adr; *len = ( bus_info.hdw_base & 0xFFFC0 ) - adr;
} else { else
*len = 0x1000 - OFFSET_OF( adr ); *len = 0x1000 - OFFSET_OF( adr );
}
return MAP_READ( adr ); return MAP_READ( adr );
} else if ( CAN_READ( adr2 ) && MAP_READ( adr ) + *len - 1 == MAP_READ( adr2 ) ) { } else if ( CAN_READ( adr2 ) && MAP_READ( adr ) + *len - 1 == MAP_READ( adr2 ) ) {
if ( hdw_seg == SEG_OF( adr2 ) ) { if ( hdw_seg == SEG_OF( adr2 ) )
*len = ( bus_info.hdw_base & 0xFFFC0 ) - adr; *len = ( bus_info.hdw_base & 0xFFFC0 ) - adr;
} else { else
*len = 0x2000 - OFFSET_OF( adr ); *len = 0x2000 - OFFSET_OF( adr );
}
return MAP_READ( adr ); return MAP_READ( adr );
} else { } else {
bus_peek_no_hdw( buf, adr, *len ); bus_peek_no_hdw( buf, adr, *len );
return buf; return buf;
} }
} }
void bus_remap( void ) void bus_remap( void )
{ {
int adr; for ( int adr = 0; adr < 0x100000; adr += 0x01000 ) {
for ( adr = 0; adr < 0x100000; adr += 0x01000 ) {
if ( bus_info.ram_cfg && ( ( bus_info.ram_base ^ adr ) & bus_info.ram_size ) == 0 ) { if ( bus_info.ram_cfg && ( ( bus_info.ram_base ^ adr ) & bus_info.ram_size ) == 0 ) {
read_map[ SEG_OF( adr ) ] = bus_info.ram_data + ( adr & bus_info.ram_mask ); read_map[ SEG_OF( adr ) ] = bus_info.ram_data + ( adr & bus_info.ram_mask );
write_map[ SEG_OF( adr ) ] = bus_info.ram_data + ( adr & bus_info.ram_mask ); write_map[ SEG_OF( adr ) ] = bus_info.ram_data + ( adr & bus_info.ram_mask );
} else if ( bus_info.ce2_cfg && ( ( bus_info.ce2_base ^ adr ) & bus_info.ce2_size ) == 0 ) { } else if ( bus_info.ce2_cfg && ( ( bus_info.ce2_base ^ adr ) & bus_info.ce2_size ) == 0 ) {
if ( bus_info.ce2_data ) { if ( bus_info.ce2_data ) {
read_map[ SEG_OF( adr ) ] = bus_info.ce2_data + ( adr & bus_info.ce2_mask ); read_map[ SEG_OF( adr ) ] = bus_info.ce2_data + ( adr & bus_info.ce2_mask );
if ( !bus_info.ce2_r_o ) { if ( !bus_info.ce2_r_o )
write_map[ SEG_OF( adr ) ] = bus_info.ce2_data + ( adr & bus_info.ce2_mask ); write_map[ SEG_OF( adr ) ] = bus_info.ce2_data + ( adr & bus_info.ce2_mask );
} else { else
write_map[ SEG_OF( adr ) ] = NULL; write_map[ SEG_OF( adr ) ] = NULL;
}
} else { } else {
read_map[ SEG_OF( adr ) ] = NULL; read_map[ SEG_OF( adr ) ] = NULL;
write_map[ SEG_OF( adr ) ] = NULL; write_map[ SEG_OF( adr ) ] = NULL;
@ -279,11 +269,10 @@ void bus_remap( void )
} else if ( bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) == 0 ) { } else if ( bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) == 0 ) {
if ( bus_info.ce1_data ) { if ( bus_info.ce1_data ) {
read_map[ SEG_OF( adr ) ] = bus_info.ce1_data + ( adr & bus_info.ce1_mask ); read_map[ SEG_OF( adr ) ] = bus_info.ce1_data + ( adr & bus_info.ce1_mask );
if ( !bus_info.ce1_r_o ) { if ( !bus_info.ce1_r_o )
write_map[ SEG_OF( adr ) ] = bus_info.ce1_data + ( adr & bus_info.ce1_mask ); write_map[ SEG_OF( adr ) ] = bus_info.ce1_data + ( adr & bus_info.ce1_mask );
} else { else
write_map[ SEG_OF( adr ) ] = NULL; write_map[ SEG_OF( adr ) ] = NULL;
}
} else { } else {
read_map[ SEG_OF( adr ) ] = NULL; read_map[ SEG_OF( adr ) ] = NULL;
write_map[ SEG_OF( adr ) ] = NULL; write_map[ SEG_OF( adr ) ] = NULL;
@ -291,11 +280,10 @@ void bus_remap( void )
} else if ( bus_info.nce3_cfg && ( ( bus_info.nce3_base ^ adr ) & bus_info.nce3_size ) == 0 ) { } else if ( bus_info.nce3_cfg && ( ( bus_info.nce3_base ^ adr ) & bus_info.nce3_size ) == 0 ) {
if ( bus_info.nce3_data && bus_info.ben && !bus_info.da19 ) { if ( bus_info.nce3_data && bus_info.ben && !bus_info.da19 ) {
read_map[ SEG_OF( adr ) ] = bus_info.nce3_data + ( adr & bus_info.nce3_mask ); read_map[ SEG_OF( adr ) ] = bus_info.nce3_data + ( adr & bus_info.nce3_mask );
if ( !bus_info.nce3_r_o ) { if ( !bus_info.nce3_r_o )
write_map[ SEG_OF( adr ) ] = bus_info.nce3_data + ( adr & bus_info.nce3_mask ); write_map[ SEG_OF( adr ) ] = bus_info.nce3_data + ( adr & bus_info.nce3_mask );
} else { else
write_map[ SEG_OF( adr ) ] = NULL; write_map[ SEG_OF( adr ) ] = NULL;
}
} else { } else {
read_map[ SEG_OF( adr ) ] = NULL; read_map[ SEG_OF( adr ) ] = NULL;
write_map[ SEG_OF( adr ) ] = NULL; write_map[ SEG_OF( adr ) ] = NULL;
@ -401,25 +389,24 @@ void bus_reset( void )
address bus_get_id( void ) address bus_get_id( void )
{ {
if ( !bus_info.hdw_cfg ) { if ( !bus_info.hdw_cfg )
return bus_info.hdw_base | 0x00019; return bus_info.hdw_base | 0x00019;
} else if ( !bus_info.ram_sz_cfg ) { else if ( !bus_info.ram_sz_cfg )
return bus_info.ram_size | 0x00003; return bus_info.ram_size | 0x00003;
} else if ( !bus_info.ram_cfg ) { else if ( !bus_info.ram_cfg )
return bus_info.ram_base | 0x000F4; return bus_info.ram_base | 0x000F4;
} else if ( !bus_info.ce1_sz_cfg ) { else if ( !bus_info.ce1_sz_cfg )
return bus_info.ce1_size | 0x00005; return bus_info.ce1_size | 0x00005;
} else if ( !bus_info.ce1_cfg ) { else if ( !bus_info.ce1_cfg )
return bus_info.ce1_base | 0x000F6; return bus_info.ce1_base | 0x000F6;
} else if ( !bus_info.ce2_sz_cfg ) { else if ( !bus_info.ce2_sz_cfg )
return bus_info.ce2_size | 0x00007; return bus_info.ce2_size | 0x00007;
} else if ( !bus_info.ce2_cfg ) { else if ( !bus_info.ce2_cfg )
return bus_info.ce2_base | 0x000F8; return bus_info.ce2_base | 0x000F8;
} else if ( !bus_info.nce3_sz_cfg ) { else if ( !bus_info.nce3_sz_cfg )
return bus_info.nce3_size | 0x00001; return bus_info.nce3_size | 0x00001;
} else if ( !bus_info.nce3_cfg ) { else if ( !bus_info.nce3_cfg )
return bus_info.nce3_base | 0x000F2; return bus_info.nce3_base | 0x000F2;
} else { else
return 0x00000; return 0x00000;
}
} }

View file

@ -50,9 +50,6 @@ extern word crc;
// FAST_PEEK_MAX must not be greater than the size of the hdw registers (64) // FAST_PEEK_MAX must not be greater than the size of the hdw registers (64)
#define FAST_PEEK_MAX 64 #define FAST_PEEK_MAX 64
/* extern void bus_init( void ); */
/* extern void bus_exit( void ); */
extern void bus_read( byte* buf, address adr, address len ); extern void bus_read( byte* buf, address adr, address len );
extern void bus_write( byte* buf, address adr, address len ); extern void bus_write( byte* buf, address adr, address len );
extern byte* bus_fast_peek( byte* buf, address adr, address* len ); extern byte* bus_fast_peek( byte* buf, address adr, address* len );

View file

@ -10,7 +10,7 @@
#include "timers.h" #include "timers.h"
#include "display.h" #include "display.h"
#include "emulator.h" #include "emulator.h"
#include "files.h" #include "persistence.h"
#include "ports.h" #include "ports.h"
#include "config.h" #include "config.h"

View file

@ -1,6 +1,6 @@
#include "types.h" #include "types.h"
#include "cpu.h" #include "cpu.h"
#include "files.h" #include "persistence.h"
bool kbd_on; bool kbd_on;

View file

@ -337,36 +337,36 @@ void load_file_on_stack( char* filename )
void bus_init( char* filename ) void bus_init( char* filename )
{ {
bus_reset();
char fullpath[ MAX_LENGTH_FILENAME ]; char fullpath[ MAX_LENGTH_FILENAME ];
get_absolute_working_dir_path(); get_absolute_working_dir_path();
sprintf( fullpath, "%s%s", absolute_working_dir_path, filename ); sprintf( fullpath, "%s%s", absolute_working_dir_path, filename );
if ( config.verbose )
fprintf( stderr, "fullpath = %s\n", fullpath );
int filesize = file_size( fullpath ); int filesize = file_size( fullpath );
/* if ( filesize ) { */ if ( filesize ) {
/* FILE* fp; */ FILE* fp;
/* BusInfo tmp_bus_info; */
/* if ( NULL == ( fp = fopen( fullpath, "w" ) ) ) { */ if ( NULL == ( fp = fopen( fullpath, "w" ) ) ) {
/* if ( config.verbose ) */ if ( config.verbose )
/* fprintf( stderr, "can\'t open %s\n", fullpath ); */ fprintf( stderr, "can\'t open %s\n", fullpath );
/* return; */ return;
/* } */ }
if ( config.verbose )
fprintf( stderr, "Loading bus_info from %s\n", fullpath );
/* fwrite( &bus_info, sizeof( BusInfo ), 1, fp ); */ fread( &bus_info, sizeof( BusInfo ), 1, fp );
/* fclose( fp ); */ fclose( fp );
/* } else */ }
bus_reset();
} }
void bus_exit( char* filename ) void bus_exit( char* filename )
{ {
char fullpath[ MAX_LENGTH_FILENAME ]; char fullpath[ MAX_LENGTH_FILENAME ];
get_absolute_working_dir_path(); get_absolute_working_dir_path();
sprintf( fullpath, "%s%s", absolute_working_dir_path, filename ); sprintf( fullpath, "%s%s", absolute_working_dir_path, filename );
if ( config.verbose )
fprintf( stderr, "fullpath = %s\n", fullpath );
FILE* fp; FILE* fp;
@ -386,23 +386,23 @@ void cpu_init( char* filename )
char fullpath[ MAX_LENGTH_FILENAME ]; char fullpath[ MAX_LENGTH_FILENAME ];
get_absolute_working_dir_path(); get_absolute_working_dir_path();
sprintf( fullpath, "%s%s", absolute_working_dir_path, filename ); sprintf( fullpath, "%s%s", absolute_working_dir_path, filename );
if ( config.verbose )
fprintf( stderr, "fullpath = %s\n", fullpath );
int filesize = file_size( fullpath ); int filesize = file_size( fullpath );
if ( filesize ) { if ( filesize ) {
/* FILE* fp; */ FILE* fp;
/* if ( NULL == ( fp = fopen( fullpath, "w" ) ) ) { */ if ( NULL == ( fp = fopen( fullpath, "w" ) ) ) {
/* if ( config.verbose ) */ if ( config.verbose )
/* fprintf( stderr, "can\'t open %s\n", fullpath ); */ fprintf( stderr, "can\'t open %s\n", fullpath );
/* return; */ return;
/* } */ }
if ( config.verbose )
fprintf( stderr, "Loading cpu from %s\n", fullpath );
/* fwrite( &cpu, sizeof( Cpu ), 1, fp ); */ fread( &cpu, sizeof( Cpu ), 1, fp );
/* fclose( fp ); */ fclose( fp );
} }
} }
void cpu_exit( char* filename ) void cpu_exit( char* filename )
@ -410,8 +410,6 @@ void cpu_exit( char* filename )
char fullpath[ MAX_LENGTH_FILENAME ]; char fullpath[ MAX_LENGTH_FILENAME ];
get_absolute_working_dir_path(); get_absolute_working_dir_path();
sprintf( fullpath, "%s%s", absolute_working_dir_path, filename ); sprintf( fullpath, "%s%s", absolute_working_dir_path, filename );
if ( config.verbose )
fprintf( stderr, "fullpath = %s\n", fullpath );
FILE* fp; FILE* fp;
@ -435,8 +433,6 @@ void rom_init( char* filename )
char fullpath[ MAX_LENGTH_FILENAME ]; char fullpath[ MAX_LENGTH_FILENAME ];
get_absolute_working_dir_path(); get_absolute_working_dir_path();
sprintf( fullpath, "%s%s", absolute_working_dir_path, filename ); sprintf( fullpath, "%s%s", absolute_working_dir_path, filename );
if ( config.verbose )
fprintf( stderr, "fullpath = %s\n", fullpath );
size = file_size( fullpath ); size = file_size( fullpath );
if ( !size ) { if ( !size ) {
@ -501,8 +497,6 @@ void ram_init( char* filename )
char fullpath[ MAX_LENGTH_FILENAME ]; char fullpath[ MAX_LENGTH_FILENAME ];
get_absolute_working_dir_path(); get_absolute_working_dir_path();
sprintf( fullpath, "%s%s", absolute_working_dir_path, filename ); sprintf( fullpath, "%s%s", absolute_working_dir_path, filename );
if ( config.verbose )
fprintf( stderr, "fullpath = %s\n", fullpath );
int filesize = file_size( fullpath ) * 2; int filesize = file_size( fullpath ) * 2;
if ( config.verbose ) if ( config.verbose )
@ -531,10 +525,9 @@ void ram_exit( char* filename )
char fullpath[ MAX_LENGTH_FILENAME ]; char fullpath[ MAX_LENGTH_FILENAME ];
get_absolute_working_dir_path(); get_absolute_working_dir_path();
sprintf( fullpath, "%s%s", absolute_working_dir_path, filename ); sprintf( fullpath, "%s%s", absolute_working_dir_path, filename );
if ( config.verbose ) { if ( config.verbose )
fprintf( stderr, "fullpath = %s\n", fullpath );
fprintf( stderr, "Saving RAM to %s\n", fullpath ); fprintf( stderr, "Saving RAM to %s\n", fullpath );
}
write_mem_file( fullpath, bus_info.ram_data, ram_size ); write_mem_file( fullpath, bus_info.ram_data, ram_size );
free( bus_info.ram_data ); free( bus_info.ram_data );
@ -556,8 +549,6 @@ void ports_init( char* filename1, char* filename2 )
char fullpath1[ MAX_LENGTH_FILENAME ]; char fullpath1[ MAX_LENGTH_FILENAME ];
get_absolute_working_dir_path(); get_absolute_working_dir_path();
sprintf( fullpath1, "%s%s", absolute_working_dir_path, filename1 ); sprintf( fullpath1, "%s%s", absolute_working_dir_path, filename1 );
if ( config.verbose )
fprintf( stderr, "fullpath = %s\n", fullpath1 );
int filesize = file_size( fullpath1 ) * 2; int filesize = file_size( fullpath1 ) * 2;
if ( filesize == port1_size ) if ( filesize == port1_size )
@ -572,8 +563,6 @@ void ports_init( char* filename1, char* filename2 )
char fullpath2[ MAX_LENGTH_FILENAME ]; char fullpath2[ MAX_LENGTH_FILENAME ];
get_absolute_working_dir_path(); get_absolute_working_dir_path();
sprintf( fullpath2, "%s%s", absolute_working_dir_path, filename2 ); sprintf( fullpath2, "%s%s", absolute_working_dir_path, filename2 );
if ( config.verbose )
fprintf( stderr, "fullpath = %s\n", fullpath1 );
filesize = file_size( fullpath2 ) * 2; filesize = file_size( fullpath2 ) * 2;
if ( filesize == port2_size ) if ( filesize == port2_size )
@ -591,14 +580,10 @@ void ports_exit( char* filename1, char* filename2 )
char fullpath1[ MAX_LENGTH_FILENAME ]; char fullpath1[ MAX_LENGTH_FILENAME ];
get_absolute_working_dir_path(); get_absolute_working_dir_path();
sprintf( fullpath1, "%s%s", absolute_working_dir_path, filename1 ); sprintf( fullpath1, "%s%s", absolute_working_dir_path, filename1 );
if ( config.verbose )
fprintf( stderr, "fullpath = %s\n", fullpath1 );
char fullpath2[ MAX_LENGTH_FILENAME ]; char fullpath2[ MAX_LENGTH_FILENAME ];
get_absolute_working_dir_path(); get_absolute_working_dir_path();
sprintf( fullpath2, "%s%s", absolute_working_dir_path, filename2 ); sprintf( fullpath2, "%s%s", absolute_working_dir_path, filename2 );
if ( config.verbose )
fprintf( stderr, "fullpath = %s\n", fullpath1 );
write_mem_file( fullpath1, bus_info.ce2_data, port1_size ); write_mem_file( fullpath1, bus_info.ce2_data, port1_size );
write_mem_file( fullpath2, port2, port2_size ); write_mem_file( fullpath2, port2, port2_size );