diff options
Diffstat (limited to 'src/emu/machine/x76f041.c')
-rw-r--r-- | src/emu/machine/x76f041.c | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/src/emu/machine/x76f041.c b/src/emu/machine/x76f041.c index f36dc2e0fbe..407b0ecceec 100644 --- a/src/emu/machine/x76f041.c +++ b/src/emu/machine/x76f041.c @@ -17,7 +17,7 @@ #define VERBOSE_LEVEL ( 0 ) -INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... ) +INLINE void ATTR_PRINTF(3,4) verboselog( running_machine *machine, int n_level, const char *s_fmt, ... ) { if( VERBOSE_LEVEL >= n_level ) { @@ -26,7 +26,7 @@ INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... ) va_start( v, s_fmt ); vsprintf( buf, s_fmt, v ); va_end( v ); - logerror( "%s: %s", cpuexec_describe_context(Machine), buf ); + logerror( "%s: %s", cpuexec_describe_context(machine), buf ); } } @@ -108,7 +108,7 @@ void x76f041_init( running_machine *machine, int chip, UINT8 *data ) if( chip >= X76F041_MAXCHIP ) { - verboselog( 0, "x76f041_init( %d ) chip out of range\n", chip ); + verboselog( machine, 0, "x76f041_init( %d ) chip out of range\n", chip ); return; } @@ -168,11 +168,12 @@ void x76f041_init( running_machine *machine, int chip, UINT8 *data ) void x76f041_cs_write( int chip, int cs ) { + running_machine *machine = Machine; struct x76f041_chip *c; if( chip >= X76F041_MAXCHIP ) { - verboselog( 0, "x76f041_cs_write( %d ) chip out of range\n", chip ); + verboselog( machine, 0, "x76f041_cs_write( %d ) chip out of range\n", chip ); return; } @@ -180,7 +181,7 @@ void x76f041_cs_write( int chip, int cs ) if( c->cs != cs ) { - verboselog( 2, "x76f041(%d) cs=%d\n", chip, cs ); + verboselog( machine, 2, "x76f041(%d) cs=%d\n", chip, cs ); } if( c->cs != 0 && cs == 0 ) { @@ -199,11 +200,12 @@ void x76f041_cs_write( int chip, int cs ) void x76f041_rst_write( int chip, int rst ) { + running_machine *machine = Machine; struct x76f041_chip *c; if( chip >= X76F041_MAXCHIP ) { - verboselog( 0, "x76f041_rst_write( %d ) chip out of range\n", chip ); + verboselog( machine, 0, "x76f041_rst_write( %d ) chip out of range\n", chip ); return; } @@ -211,11 +213,11 @@ void x76f041_rst_write( int chip, int rst ) if( c->rst != rst ) { - verboselog( 2, "x76f041(%d) rst=%d\n", chip, rst ); + verboselog( machine, 2, "x76f041(%d) rst=%d\n", chip, rst ); } if( c->rst == 0 && rst != 0 && c->cs == 0 ) { - verboselog( 1, "x76f041(%d) goto response to reset\n", chip ); + verboselog( machine, 1, "x76f041(%d) goto response to reset\n", chip ); c->state = STATE_RESPONSE_TO_RESET; c->bit = 0; c->byte = 0; @@ -285,13 +287,14 @@ static void x76f041_password_ok( struct x76f041_chip *c ) static void x76f041_load_address( int chip ) { + running_machine *machine = Machine; /* todo: handle other bcr bits */ struct x76f041_chip *c = &x76f041[ chip ]; int bcr; c->address = c->shift; - verboselog( 1, "x76f041(%d) -> address: %02x\n", chip, c->address ); + verboselog( machine, 1, "x76f041(%d) -> address: %02x\n", chip, c->address ); if( ( c->command & 1 ) == 0 ) { @@ -310,19 +313,19 @@ static void x76f041_load_address( int chip ) ( ( c->command & 0xe0 ) == COMMAND_WRITE && ( bcr & BCR_Z ) != 0 ) ) { /* todo: find out when this is really checked. */ - verboselog( 1, "x76f041(%d) command not allowed\n", chip ); + verboselog( machine, 1, "x76f041(%d) command not allowed\n", chip ); c->state = STATE_STOP; c->sdar = 0; } else if( ( ( c->command & 0xe0 ) == COMMAND_WRITE && ( bcr & BCR_X ) == 0 ) || ( ( c->command & 0xe0 ) == COMMAND_READ && ( bcr & BCR_Y ) == 0 ) ) { - verboselog( 1, "x76f041(%d) password not required\n", chip ); + verboselog( machine, 1, "x76f041(%d) password not required\n", chip ); x76f041_password_ok( c ); } else { - verboselog( 1, "x76f041(%d) send password\n", chip ); + verboselog( machine, 1, "x76f041(%d) send password\n", chip ); c->state = STATE_LOAD_PASSWORD; c->byte = 0; } @@ -339,11 +342,12 @@ static int x76f041_data_offset( struct x76f041_chip *c ) void x76f041_scl_write( int chip, int scl ) { + running_machine *machine = Machine; struct x76f041_chip *c; if( chip >= X76F041_MAXCHIP ) { - verboselog( 0, "x76f041_scl_write( %d ) chip out of range\n", chip ); + verboselog( machine, 0, "x76f041_scl_write( %d ) chip out of range\n", chip ); return; } @@ -351,7 +355,7 @@ void x76f041_scl_write( int chip, int scl ) if( c->scl != scl ) { - verboselog( 2, "x76f041(%d) scl=%d\n", chip, scl ); + verboselog( machine, 2, "x76f041(%d) scl=%d\n", chip, scl ); } if( c->cs == 0 ) { @@ -363,7 +367,7 @@ void x76f041_scl_write( int chip, int scl ) if( c->scl != 0 && scl == 0 ) { c->sdar = ( c->response_to_reset[ c->byte ] >> c->bit ) & 1; - verboselog( 2, "x76f041(%d) in response to reset %d (%d/%d)\n", chip, c->sdar, c->byte, c->bit ); + verboselog( machine, 2, "x76f041(%d) in response to reset %d (%d/%d)\n", chip, c->sdar, c->byte, c->bit ); c->bit++; if( c->bit == 8 ) { @@ -386,7 +390,7 @@ void x76f041_scl_write( int chip, int scl ) { if( c->bit < 8 ) { - verboselog( 2, "x76f041(%d) clock\n", chip ); + verboselog( machine, 2, "x76f041(%d) clock\n", chip ); c->shift <<= 1; if( c->sdaw != 0 ) { @@ -402,7 +406,7 @@ void x76f041_scl_write( int chip, int scl ) { case STATE_LOAD_COMMAND: c->command = c->shift; - verboselog( 1, "x76f041(%d) -> command: %02x\n", chip, c->command ); + verboselog( machine, 1, "x76f041(%d) -> command: %02x\n", chip, c->command ); /* todo: verify command is valid? */ c->state = STATE_LOAD_ADDRESS; break; @@ -410,7 +414,7 @@ void x76f041_scl_write( int chip, int scl ) x76f041_load_address( chip ); break; case STATE_LOAD_PASSWORD: - verboselog( 1, "x76f041(%d) -> password: %02x\n", chip, c->shift ); + verboselog( machine, 1, "x76f041(%d) -> password: %02x\n", chip, c->shift ); c->write_buffer[ c->byte++ ] = c->shift; if( c->byte == SIZE_WRITE_BUFFER ) { @@ -418,7 +422,7 @@ void x76f041_scl_write( int chip, int scl ) } break; case STATE_VERIFY_PASSWORD: - verboselog( 1, "x76f041(%d) -> verify password: %02x\n", chip, c->shift ); + verboselog( machine, 1, "x76f041(%d) -> verify password: %02x\n", chip, c->shift ); /* todo: this should probably be handled as a command */ if( c->shift == 0xc0 ) { @@ -434,7 +438,7 @@ void x76f041_scl_write( int chip, int scl ) } break; case STATE_WRITE_DATA: - verboselog( 1, "x76f041(%d) -> data: %02x\n", chip, c->shift ); + verboselog( machine, 1, "x76f041(%d) -> data: %02x\n", chip, c->shift ); c->write_buffer[ c->byte++ ] = c->shift; if( c->byte == SIZE_WRITE_BUFFER ) { @@ -444,11 +448,11 @@ void x76f041_scl_write( int chip, int scl ) } c->byte = 0; - verboselog( 1, "x76f041(%d) data flushed\n", chip ); + verboselog( machine, 1, "x76f041(%d) data flushed\n", chip ); } break; case STATE_WRITE_CONFIGURATION_REGISTERS: - verboselog( 1, "x76f041(%d) -> configuration register: %02x\n", chip, c->shift ); + verboselog( machine, 1, "x76f041(%d) -> configuration register: %02x\n", chip, c->shift ); /* todo: write after all bytes received? */ c->configuration_registers[ c->byte++ ] = c->shift; if( c->byte == SIZE_CONFIGURATION_REGISTERS ) @@ -475,11 +479,11 @@ void x76f041_scl_write( int chip, int scl ) { case STATE_READ_DATA: c->shift = c->data[ x76f041_data_offset( c ) ]; - verboselog( 1, "x76f041(%d) <- data: %02x\n", chip, c->shift ); + verboselog( machine, 1, "x76f041(%d) <- data: %02x\n", chip, c->shift ); break; case STATE_READ_CONFIGURATION_REGISTERS: c->shift = c->configuration_registers[ c->byte & 7 ]; - verboselog( 1, "x76f041(%d) <- configuration register: %02x\n", chip, c->shift ); + verboselog( machine, 1, "x76f041(%d) <- configuration register: %02x\n", chip, c->shift ); break; } } @@ -493,12 +497,12 @@ void x76f041_scl_write( int chip, int scl ) c->sdar = 0; if( c->sdaw == 0 ) { - verboselog( 2, "x76f041(%d) ack <-\n", chip ); + verboselog( machine, 2, "x76f041(%d) ack <-\n", chip ); c->byte++; } else { - verboselog( 2, "x76f041(%d) nak <-\n", chip ); + verboselog( machine, 2, "x76f041(%d) nak <-\n", chip ); } } } @@ -510,11 +514,12 @@ void x76f041_scl_write( int chip, int scl ) void x76f041_sda_write( int chip, int sda ) { + running_machine *machine = Machine; struct x76f041_chip *c; if( chip >= X76F041_MAXCHIP ) { - verboselog( 0, "x76f041_sda_write( %d ) chip out of range\n", chip ); + verboselog( machine, 0, "x76f041_sda_write( %d ) chip out of range\n", chip ); return; } @@ -522,13 +527,13 @@ void x76f041_sda_write( int chip, int sda ) if( c->sdaw != sda ) { - verboselog( 2, "x76f041(%d) sdaw=%d\n", chip, sda ); + verboselog( machine, 2, "x76f041(%d) sdaw=%d\n", chip, sda ); } if( c->cs == 0 && c->scl != 0 ) { if( c->sdaw == 0 && sda != 0 ) { - verboselog( 1, "x76f041(%d) goto stop\n", chip ); + verboselog( machine, 1, "x76f041(%d) goto stop\n", chip ); c->state = STATE_STOP; c->sdar = 0; } @@ -537,19 +542,19 @@ void x76f041_sda_write( int chip, int sda ) switch( c->state ) { case STATE_STOP: - verboselog( 1, "x76f041(%d) goto start\n", chip ); + verboselog( machine, 1, "x76f041(%d) goto start\n", chip ); c->state = STATE_LOAD_COMMAND; break; case STATE_LOAD_PASSWORD: /* todo: this will be the 0xc0 command, but it's not handled as a command yet. */ - verboselog( 1, "x76f041(%d) goto start\n", chip ); + verboselog( machine, 1, "x76f041(%d) goto start\n", chip ); break; case STATE_READ_DATA: - verboselog( 1, "x76f041(%d) goto load address\n", chip ); + verboselog( machine, 1, "x76f041(%d) goto load address\n", chip ); c->state = STATE_LOAD_ADDRESS; break; default: - verboselog( 1, "x76f041(%d) skipped start (default)\n", chip ); + verboselog( machine, 1, "x76f041(%d) skipped start (default)\n", chip ); break; } @@ -564,11 +569,12 @@ void x76f041_sda_write( int chip, int sda ) int x76f041_sda_read( int chip ) { + running_machine *machine = Machine; struct x76f041_chip *c; if( chip >= X76F041_MAXCHIP ) { - verboselog( 0, "x76f041_sda_read( %d ) chip out of range\n", chip ); + verboselog( machine, 0, "x76f041_sda_read( %d ) chip out of range\n", chip ); return 1; } @@ -576,10 +582,10 @@ int x76f041_sda_read( int chip ) if( c->cs != 0 ) { - verboselog( 2, "x76f041(%d) not selected\n", chip ); + verboselog( machine, 2, "x76f041(%d) not selected\n", chip ); return 1; } - verboselog( 2, "x76f041(%d) sdar=%d\n", chip, c->sdar ); + verboselog( machine, 2, "x76f041(%d) sdar=%d\n", chip, c->sdar ); return c->sdar; } @@ -589,7 +595,7 @@ static void nvram_handler_x76f041( int chip, running_machine *machine, mame_file if( chip >= X76F041_MAXCHIP ) { - verboselog( 0, "nvram_handler_x76f041( %d ) chip out of range\n", chip ); + verboselog( machine, 0, "nvram_handler_x76f041( %d ) chip out of range\n", chip ); return; } |