Misc cleanup, nw

This commit is contained in:
mooglyguy 2018-06-08 05:01:23 +02:00
parent a279ee3773
commit 1dd98cd6ff
4 changed files with 48 additions and 44 deletions

View File

@ -579,22 +579,22 @@ INPUT_PORTS_END
WRITE_LINE_MEMBER( thomson_state::fdc_index_0_w ) WRITE_LINE_MEMBER( thomson_state::fdc_index_0_w )
{ {
thomson_index_callback(machine().device<legacy_floppy_image_device>(FLOPPY_0), state); thomson_index_callback(0, state);
} }
WRITE_LINE_MEMBER( thomson_state::fdc_index_1_w ) WRITE_LINE_MEMBER( thomson_state::fdc_index_1_w )
{ {
thomson_index_callback(machine().device<legacy_floppy_image_device>(FLOPPY_1), state); thomson_index_callback(1, state);
} }
WRITE_LINE_MEMBER( thomson_state::fdc_index_2_w ) WRITE_LINE_MEMBER( thomson_state::fdc_index_2_w )
{ {
thomson_index_callback(machine().device<legacy_floppy_image_device>(FLOPPY_2), state); thomson_index_callback(2, state);
} }
WRITE_LINE_MEMBER( thomson_state::fdc_index_3_w ) WRITE_LINE_MEMBER( thomson_state::fdc_index_3_w )
{ {
thomson_index_callback(machine().device<legacy_floppy_image_device>(FLOPPY_3), state); thomson_index_callback(3, state);
} }
static const floppy_interface thomson_floppy_interface = static const floppy_interface thomson_floppy_interface =
@ -677,16 +677,16 @@ MACHINE_CONFIG_START(thomson_state::to7)
/* floppy */ /* floppy */
MCFG_DEVICE_ADD("mc6843", MC6843, 0) MCFG_DEVICE_ADD("mc6843", MC6843, 0)
MCFG_DEVICE_ADD(FLOPPY_0, LEGACY_FLOPPY, 0) MCFG_DEVICE_ADD(m_floppy_image[0], LEGACY_FLOPPY, 0)
MCFG_LEGACY_FLOPPY_CONFIG(thomson_floppy_interface) MCFG_LEGACY_FLOPPY_CONFIG(thomson_floppy_interface)
MCFG_LEGACY_FLOPPY_IDX_CB(WRITELINE(*this, thomson_state, fdc_index_0_w)) MCFG_LEGACY_FLOPPY_IDX_CB(WRITELINE(*this, thomson_state, fdc_index_0_w))
MCFG_DEVICE_ADD(FLOPPY_1, LEGACY_FLOPPY, 0) MCFG_DEVICE_ADD(m_floppy_image[1], LEGACY_FLOPPY, 0)
MCFG_LEGACY_FLOPPY_CONFIG(thomson_floppy_interface) MCFG_LEGACY_FLOPPY_CONFIG(thomson_floppy_interface)
MCFG_LEGACY_FLOPPY_IDX_CB(WRITELINE(*this, thomson_state, fdc_index_1_w)) MCFG_LEGACY_FLOPPY_IDX_CB(WRITELINE(*this, thomson_state, fdc_index_1_w))
MCFG_DEVICE_ADD(FLOPPY_2, LEGACY_FLOPPY, 0) MCFG_DEVICE_ADD(m_floppy_image[2], LEGACY_FLOPPY, 0)
MCFG_LEGACY_FLOPPY_CONFIG(thomson_floppy_interface) MCFG_LEGACY_FLOPPY_CONFIG(thomson_floppy_interface)
MCFG_LEGACY_FLOPPY_IDX_CB(WRITELINE(*this, thomson_state, fdc_index_2_w)) MCFG_LEGACY_FLOPPY_IDX_CB(WRITELINE(*this, thomson_state, fdc_index_2_w))
MCFG_DEVICE_ADD(FLOPPY_3, LEGACY_FLOPPY, 0) MCFG_DEVICE_ADD(m_floppy_image[3], LEGACY_FLOPPY, 0)
MCFG_LEGACY_FLOPPY_CONFIG(thomson_floppy_interface) MCFG_LEGACY_FLOPPY_CONFIG(thomson_floppy_interface)
MCFG_LEGACY_FLOPPY_IDX_CB(WRITELINE(*this, thomson_state, fdc_index_3_w)) MCFG_LEGACY_FLOPPY_IDX_CB(WRITELINE(*this, thomson_state, fdc_index_3_w))

View File

@ -28,6 +28,7 @@
#include "machine/mos6551.h" #include "machine/mos6551.h"
#include "machine/ram.h" #include "machine/ram.h"
#include "machine/thomflop.h" #include "machine/thomflop.h"
#include "machine/wd_fdc.h"
#include "sound/dac.h" #include "sound/dac.h"
#include "sound/mea8000.h" #include "sound/mea8000.h"
@ -115,6 +116,7 @@ public:
m_ram(*this, RAM_TAG), m_ram(*this, RAM_TAG),
m_mc6846(*this, "mc6846"), m_mc6846(*this, "mc6846"),
m_mc6843(*this, "mc6843"), m_mc6843(*this, "mc6843"),
m_wd2793_fdc(*this, "wd2793"),
m_screen(*this, "screen"), m_screen(*this, "screen"),
m_mainirq(*this, "mainirq"), m_mainirq(*this, "mainirq"),
m_mainfirq(*this, "mainfirq"), m_mainfirq(*this, "mainfirq"),
@ -143,7 +145,8 @@ public:
m_biosbank(*this, TO8_BIOS_BANK), m_biosbank(*this, TO8_BIOS_BANK),
m_cartlobank(*this, MO6_CART_LO), m_cartlobank(*this, MO6_CART_LO),
m_carthibank(*this, MO6_CART_HI), m_carthibank(*this, MO6_CART_HI),
m_floppy(*this, "floppy") m_floppy_led(*this, "floppy"),
m_floppy_image(*this, "floppy%u", 0U)
{ {
} }
@ -342,7 +345,7 @@ public:
WRITE_LINE_MEMBER( fdc_index_1_w ); WRITE_LINE_MEMBER( fdc_index_1_w );
WRITE_LINE_MEMBER( fdc_index_2_w ); WRITE_LINE_MEMBER( fdc_index_2_w );
WRITE_LINE_MEMBER( fdc_index_3_w ); WRITE_LINE_MEMBER( fdc_index_3_w );
void thomson_index_callback(legacy_floppy_image_device *device, int state); void thomson_index_callback(int index, int state);
DECLARE_PALETTE_INIT(thom); DECLARE_PALETTE_INIT(thom);
DECLARE_PALETTE_INIT(mo5); DECLARE_PALETTE_INIT(mo5);
@ -389,6 +392,7 @@ protected:
required_device<ram_device> m_ram; required_device<ram_device> m_ram;
optional_device<mc6846_device> m_mc6846; optional_device<mc6846_device> m_mc6846;
optional_device<mc6843_device> m_mc6843; optional_device<mc6843_device> m_mc6843;
required_device<wd2793_device> m_wd2793_fdc;
required_device<screen_device> m_screen; required_device<screen_device> m_screen;
required_device<input_merger_device> m_mainirq; required_device<input_merger_device> m_mainirq;
required_device<input_merger_device> m_mainfirq; required_device<input_merger_device> m_mainfirq;
@ -418,7 +422,8 @@ protected:
optional_memory_bank m_cartlobank; optional_memory_bank m_cartlobank;
optional_memory_bank m_carthibank; optional_memory_bank m_carthibank;
output_finder<> m_floppy; output_finder<> m_floppy_led;
required_device_array<legacy_floppy_image_device, 4> m_floppy_image;
/* bank logging and optimisations */ /* bank logging and optimisations */
int m_old_cart_bank; int m_old_cart_bank;
@ -604,10 +609,10 @@ protected:
int thom_qdd_make_disk ( legacy_floppy_image_device* img, uint8_t* dst ); int thom_qdd_make_disk ( legacy_floppy_image_device* img, uint8_t* dst );
void to7_5p14_reset(); void to7_5p14_reset();
void to7_5p14_init(); void to7_5p14_init();
void to7_5p14_index_pulse_callback( device_t *controller,legacy_floppy_image_device *image, int state ); void to7_5p14_index_pulse_callback( int state );
void to7_5p14sd_reset(); void to7_5p14sd_reset();
void to7_5p14sd_init(); void to7_5p14sd_init();
void to7_qdd_index_pulse_cb( device_t *controller,legacy_floppy_image_device *image, int state ); void to7_qdd_index_pulse_cb( int state );
legacy_floppy_image_device * to7_qdd_image(); legacy_floppy_image_device * to7_qdd_image();
void to7_qdd_stat_update(); void to7_qdd_stat_update();
uint8_t to7_qdd_read_byte(); uint8_t to7_qdd_read_byte();
@ -616,7 +621,7 @@ protected:
void to7_qdd_init(); void to7_qdd_init();
legacy_floppy_image_device * thmfc_floppy_image(); legacy_floppy_image_device * thmfc_floppy_image();
int thmfc_floppy_is_qdd( legacy_floppy_image_device *image ); int thmfc_floppy_is_qdd( legacy_floppy_image_device *image );
void thmfc_floppy_index_pulse_cb( device_t *controller,legacy_floppy_image_device *image, int state ); void thmfc_floppy_index_pulse_cb( int index, int state );
int thmfc_floppy_find_sector( chrn_id* dst ); int thmfc_floppy_find_sector( chrn_id* dst );
void thmfc_floppy_cmd_complete(); void thmfc_floppy_cmd_complete();
uint8_t thmfc_floppy_read_byte(); uint8_t thmfc_floppy_read_byte();

View File

@ -10,7 +10,6 @@
#include "emu.h" #include "emu.h"
#include "includes/thomson.h" #include "includes/thomson.h"
#include "machine/wd_fdc.h"
#define VERBOSE 0 /* 0, 1 or 2 */ #define VERBOSE 0 /* 0, 1 or 2 */
@ -276,14 +275,12 @@ static uint8_t to7_5p14_select;
READ8_MEMBER( thomson_state::to7_5p14_r ) READ8_MEMBER( thomson_state::to7_5p14_r )
{ {
wd2793_device *fdc = machine().device<wd2793_device>("wd2793");
if ( offset < 4 ) if ( offset < 4 )
return fdc->read(space, offset ); return m_wd2793_fdc->read(space, offset );
else if ( offset == 8 ) else if ( offset == 8 )
return to7_5p14_select; return to7_5p14_select;
else else
logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", machine().time().as_double(), m_maincpu->pc(), offset ); logerror ( "%s: to7_5p14_r: invalid read offset %i\n", machine().describe_context(), offset );
return 0; return 0;
} }
@ -291,18 +288,17 @@ READ8_MEMBER( thomson_state::to7_5p14_r )
WRITE8_MEMBER( thomson_state::to7_5p14_w ) WRITE8_MEMBER( thomson_state::to7_5p14_w )
{ {
wd2793_device *fdc = machine().device<wd2793_device>("wd2793");
if ( offset < 4 ) if ( offset < 4 )
fdc->write(space, offset, data ); m_wd2793_fdc->write(space, offset, data );
else if ( offset == 8 ) else if ( offset == 8 )
{ {
/* drive select */ /* drive select */
floppy_image_device *floppy = nullptr; floppy_image_device *floppy = nullptr;
if (BIT(data, 1)) floppy = fdc->subdevice<floppy_connector>("0")->get_device(); if (BIT(data, 1)) floppy = m_wd2793_fdc->subdevice<floppy_connector>("0")->get_device();
if (BIT(data, 2)) floppy = fdc->subdevice<floppy_connector>("1")->get_device(); if (BIT(data, 2)) floppy = m_wd2793_fdc->subdevice<floppy_connector>("1")->get_device();
fdc->set_floppy(floppy); m_wd2793_fdc->set_floppy(floppy);
if (floppy) if (floppy)
{ {
@ -312,24 +308,25 @@ WRITE8_MEMBER( thomson_state::to7_5p14_w )
} }
} }
else else
logerror ( "%f $%04x to7_5p14_w: invalid write offset %i (data=$%02X)\n", {
machine().time().as_double(), m_maincpu->pc(), offset, data ); logerror("%s: to7_5p14_w: invalid write offset %i (data=$%02X)\n",
machine().describe_context(), offset, data );
}
} }
void thomson_state::to7_5p14_reset() void thomson_state::to7_5p14_reset()
{ {
wd2793_device *fdc = machine().device<wd2793_device>("wd2793"); logerror("%s: to7_5p14_reset: CD 90-640 controller\n", machine().describe_context());
LOG(( "to7_5p14_reset: CD 90-640 controller\n" )); m_wd2793_fdc->reset();
fdc->reset();
} }
void thomson_state::to7_5p14_init() void thomson_state::to7_5p14_init()
{ {
LOG(( "to7_5p14_init: CD 90-640 controller\n" )); logerror("%s: to7_5p14_init: CD 90-640 controller\n", machine().describe_context());
save_item(NAME(to7_5p14_select)); save_item(NAME(to7_5p14_select));
} }
@ -408,7 +405,7 @@ WRITE8_MEMBER( thomson_state::to7_5p14sd_w )
machine().time().as_double(), m_maincpu->pc(), offset, data ); machine().time().as_double(), m_maincpu->pc(), offset, data );
} }
void thomson_state::to7_5p14_index_pulse_callback( device_t *controller,legacy_floppy_image_device *image, int state ) void thomson_state::to7_5p14_index_pulse_callback( int state )
{ {
m_mc6843->set_index_pulse( state ); m_mc6843->set_index_pulse( state );
} }
@ -505,7 +502,7 @@ static to7qdd_t * to7qdd;
void thomson_state::to7_qdd_index_pulse_cb( device_t *controller,legacy_floppy_image_device *image, int state ) void thomson_state::to7_qdd_index_pulse_cb( int state )
{ {
to7qdd->index_pulse = state; to7qdd->index_pulse = state;
@ -889,7 +886,7 @@ struct thmfc1_t
{ {
uint8_t op; uint8_t op;
uint8_t sector; /* target sector, in [1,16] */ uint8_t sector; /* target sector, in [1,16] */
uint32_t sector_id; uint32_t sector_id;
uint8_t track; /* current track, in [0,79] */ uint8_t track; /* current track, in [0,79] */
uint8_t side; /* current side, 0 or 1 */ uint8_t side; /* current side, 0 or 1 */
uint8_t drive; /* 0 to 3 */ uint8_t drive; /* 0 to 3 */
@ -926,19 +923,21 @@ legacy_floppy_image_device * thomson_state::thmfc_floppy_image()
int thomson_state::thmfc_floppy_is_qdd ( legacy_floppy_image_device *image ) int thomson_state::thmfc_floppy_is_qdd ( legacy_floppy_image_device *image )
{ {
if (image==nullptr) return 0; if (!image) return 0;
if (!image->exists()) return 0; if (!image->exists()) return 0;
return image->length()==51200; // idf QDD return image->length() == 51200; // idf QDD
} }
void thomson_state::thmfc_floppy_index_pulse_cb ( device_t *controller,legacy_floppy_image_device *image, int state ) void thomson_state::thmfc_floppy_index_pulse_cb( int index, int state )
{ {
legacy_floppy_image_device *image = m_floppy_image[index];
if ( image != thmfc_floppy_image()) if ( image != thmfc_floppy_image())
return; return;
if ( thmfc_floppy_is_qdd(image)) if ( thmfc_floppy_is_qdd(m_floppy_image[index]))
{ {
/* pulse each time the whole-disk spiraling track ends */ /* pulse each time the whole-disk spiraling track ends */
image->floppy_drive_set_rpm( 16.92f /* 423/25 */ ); image->floppy_drive_set_rpm( 16.92f /* 423/25 */ );
@ -1890,23 +1889,23 @@ WRITE8_MEMBER( thomson_state::to9_floppy_w )
to7_5p14_w( space, offset, data, mem_mask ); to7_5p14_w( space, offset, data, mem_mask );
} }
void thomson_state::thomson_index_callback(legacy_floppy_image_device *device, int state) void thomson_state::thomson_index_callback(int index, int state)
{ {
switch ( to7_controller_type ) switch ( to7_controller_type )
{ {
case 1: case 1:
to7_5p14_index_pulse_callback(nullptr, device, state); to7_5p14_index_pulse_callback(state);
break; break;
case 2: case 2:
break; break;
case 3: case 3:
thmfc_floppy_index_pulse_cb(nullptr, device, state); thmfc_floppy_index_pulse_cb(index, state);
break; break;
case 4: case 4:
to7_qdd_index_pulse_cb(nullptr, device, state); to7_qdd_index_pulse_cb(state);
break; break;
default: default:

View File

@ -890,7 +890,7 @@ void thomson_state::thom_floppy_active( int write )
/* update icon */ /* update icon */
fnew = FLOP_STATE; fnew = FLOP_STATE;
if ( fold != fnew ) if ( fold != fnew )
m_floppy = fnew; m_floppy_led = fnew;
} }
@ -1041,7 +1041,7 @@ WRITE_LINE_MEMBER(thomson_state::thom_vblank)
m_thom_floppy_rcount--; m_thom_floppy_rcount--;
fnew = FLOP_STATE; fnew = FLOP_STATE;
if ( fnew != fold ) if ( fnew != fold )
m_floppy = fnew; m_floppy_led = fnew;
/* prepare state for next frame */ /* prepare state for next frame */
for ( i = 0; i <= THOM_TOTAL_HEIGHT; i++ ) for ( i = 0; i <= THOM_TOTAL_HEIGHT; i++ )
@ -1160,7 +1160,7 @@ VIDEO_START_MEMBER( thomson_state, thom )
m_thom_floppy_wcount = 0; m_thom_floppy_wcount = 0;
save_item(NAME(m_thom_floppy_wcount)); save_item(NAME(m_thom_floppy_wcount));
save_item(NAME(m_thom_floppy_rcount)); save_item(NAME(m_thom_floppy_rcount));
m_floppy.resolve(); m_floppy_led.resolve();
m_thom_video_timer = machine().scheduler().timer_alloc(timer_expired_delegate()); m_thom_video_timer = machine().scheduler().timer_alloc(timer_expired_delegate());