mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
thomson.cpp: Improve floppy device encapsulation (nw)
- Eliminate all global-level static variables and functions in thomflop.cpp - Simplify read/write handlers for floppy interfaces mc6843: Simplify read/write handlers (nw)
This commit is contained in:
parent
3e0e72a937
commit
c67f75fdd7
@ -141,7 +141,7 @@ void bml3bus_mp1805_device::device_start()
|
||||
|
||||
// install into memory
|
||||
address_space &space_prg = space();
|
||||
space_prg.install_readwrite_handler(0xff18, 0xff1f, read8_delegate(*m_mc6843, FUNC(mc6843_device::read)), write8_delegate(*m_mc6843, FUNC(mc6843_device::write)));
|
||||
space_prg.install_readwrite_handler(0xff18, 0xff1f, read8sm_delegate(*m_mc6843, FUNC(mc6843_device::read)), write8sm_delegate(*m_mc6843, FUNC(mc6843_device::write)));
|
||||
space_prg.install_readwrite_handler(0xff20, 0xff20, read8_delegate(*this, FUNC(bml3bus_mp1805_device::bml3_mp1805_r)), write8_delegate(*this, FUNC(bml3bus_mp1805_device::bml3_mp1805_w)));
|
||||
// overwriting the main ROM (rather than using e.g. install_rom) should mean that bank switches for RAM expansion still work...
|
||||
uint8_t *mainrom = device().machine().root_device().memregion("maincpu")->base();
|
||||
|
@ -451,7 +451,7 @@ void mc6843_device::device_timer(emu_timer &timer, device_timer_id id, int param
|
||||
|
||||
|
||||
|
||||
READ8_MEMBER( mc6843_device::read )
|
||||
uint8_t mc6843_device::read(offs_t offset)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
|
||||
@ -590,7 +590,7 @@ READ8_MEMBER( mc6843_device::read )
|
||||
return data;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER( mc6843_device::write )
|
||||
void mc6843_device::write(offs_t offset, uint8_t data)
|
||||
{
|
||||
switch ( offset ) {
|
||||
case 0: /* Data Output Register (DOR) */
|
||||
|
@ -32,8 +32,8 @@ public:
|
||||
|
||||
auto irq() { return m_write_irq.bind(); }
|
||||
|
||||
DECLARE_READ8_MEMBER(read);
|
||||
DECLARE_WRITE8_MEMBER(write);
|
||||
uint8_t read(offs_t offset);
|
||||
void write(offs_t offset, uint8_t data);
|
||||
|
||||
void set_drive(int drive);
|
||||
void set_side(int side);
|
||||
|
@ -676,6 +676,8 @@ void thomson_state::to7_base(machine_config &config)
|
||||
m_cassette->set_interface("to_cass");
|
||||
|
||||
/* floppy */
|
||||
CQ90_028(config, m_to7qdd, 0);
|
||||
|
||||
THMFC1(config, m_thmfc, 16_MHz_XTAL);
|
||||
m_thmfc->floppy_active_cb().set(FUNC(thomson_state::thom_floppy_active));
|
||||
|
||||
|
@ -147,6 +147,7 @@ public:
|
||||
m_cartlobank(*this, MO6_CART_LO),
|
||||
m_carthibank(*this, MO6_CART_HI),
|
||||
m_cart_rom(*this, "cartridge"),
|
||||
m_to7qdd(*this, "to7qdd"),
|
||||
m_thmfc(*this, "thmfc"),
|
||||
m_floppy_led(*this, "floppy"),
|
||||
m_floppy_image(*this, "floppy%u", 0U)
|
||||
@ -345,22 +346,20 @@ private:
|
||||
DECLARE_WRITE_LINE_MEMBER(thom_vblank);
|
||||
DECLARE_VIDEO_START( thom );
|
||||
|
||||
DECLARE_READ8_MEMBER( to7_5p14_r );
|
||||
DECLARE_WRITE8_MEMBER( to7_5p14_w );
|
||||
DECLARE_READ8_MEMBER( to7_5p14sd_r );
|
||||
DECLARE_WRITE8_MEMBER( to7_5p14sd_w );
|
||||
DECLARE_READ8_MEMBER( to7_qdd_r );
|
||||
DECLARE_WRITE8_MEMBER( to7_qdd_w );
|
||||
uint8_t to7_5p14_r(offs_t offset);
|
||||
void to7_5p14_w(offs_t offset, uint8_t data);
|
||||
uint8_t to7_5p14sd_r(offs_t offset);
|
||||
void to7_5p14sd_w(offs_t offset, uint8_t data);
|
||||
TIMER_CALLBACK_MEMBER( ans4 );
|
||||
TIMER_CALLBACK_MEMBER( ans3 );
|
||||
TIMER_CALLBACK_MEMBER( ans2 );
|
||||
TIMER_CALLBACK_MEMBER( ans );
|
||||
DECLARE_READ8_MEMBER( to7_network_r );
|
||||
DECLARE_WRITE8_MEMBER( to7_network_w );
|
||||
DECLARE_READ8_MEMBER( to7_floppy_r );
|
||||
DECLARE_WRITE8_MEMBER( to7_floppy_w );
|
||||
DECLARE_READ8_MEMBER( to9_floppy_r );
|
||||
DECLARE_WRITE8_MEMBER( to9_floppy_w );
|
||||
uint8_t to7_network_r(offs_t offset);
|
||||
void to7_network_w(offs_t offset, uint8_t data);
|
||||
uint8_t to7_floppy_r(offs_t offset);
|
||||
void to7_floppy_w(offs_t offset, uint8_t data);
|
||||
uint8_t to9_floppy_r(offs_t offset);
|
||||
void to9_floppy_w(offs_t offset, uint8_t data);
|
||||
WRITE_LINE_MEMBER( fdc_index_0_w );
|
||||
WRITE_LINE_MEMBER( fdc_index_1_w );
|
||||
WRITE_LINE_MEMBER( fdc_index_2_w );
|
||||
@ -430,6 +429,7 @@ private:
|
||||
optional_memory_bank m_carthibank;
|
||||
required_region_ptr<uint8_t> m_cart_rom;
|
||||
|
||||
required_device<cq90_028_device> m_to7qdd;
|
||||
required_device<thmfc1_device> m_thmfc;
|
||||
output_finder<> m_floppy_led;
|
||||
required_device_array<legacy_floppy_image_device, 4> m_floppy_image;
|
||||
@ -546,6 +546,11 @@ private:
|
||||
emu_timer *m_thom_init_timer;
|
||||
void (thomson_state::*m_thom_init_cb)( int init );
|
||||
|
||||
uint8_t m_to7_controller_type;
|
||||
uint8_t m_to7_floppy_bank;
|
||||
uint8_t m_to7_5p14_select;
|
||||
uint8_t m_to7_5p14sd_select;
|
||||
|
||||
int to7_get_cassette();
|
||||
int mo5_get_cassette();
|
||||
void mo5_set_cassette( int data );
|
||||
@ -615,13 +620,6 @@ private:
|
||||
void to7_5p14_index_pulse_callback( int state );
|
||||
void to7_5p14sd_reset();
|
||||
void to7_5p14sd_init();
|
||||
void to7_qdd_index_pulse_cb( int state );
|
||||
legacy_floppy_image_device * to7_qdd_image();
|
||||
void to7_qdd_stat_update();
|
||||
uint8_t to7_qdd_read_byte();
|
||||
void to7_qdd_write_byte( uint8_t data );
|
||||
void to7_qdd_reset();
|
||||
void to7_qdd_init();
|
||||
void to7_network_init();
|
||||
void to7_network_reset();
|
||||
void to7_floppy_init();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,37 +16,40 @@
|
||||
#include "machine/mc6843.h"
|
||||
#include "machine/mc6854.h"
|
||||
|
||||
extern uint8_t to7_controller_type; /* set during init */
|
||||
extern uint8_t to7_floppy_bank;
|
||||
|
||||
/* number of external floppy controller ROM banks */
|
||||
#define TO7_NB_FLOP_BANK 9
|
||||
|
||||
/* external floppy / network controller active */
|
||||
#define THOM_FLOPPY_EXT (to7_controller_type >= 1)
|
||||
#define THOM_FLOPPY_EXT (m_to7_controller_type >= 1)
|
||||
|
||||
/* internal floppy controller active (no or network extension) */
|
||||
#define THOM_FLOPPY_INT (to7_controller_type == 0 || to7_controller_type > 4)
|
||||
#define THOM_FLOPPY_INT (m_to7_controller_type == 0 || m_to7_controller_type > 4)
|
||||
|
||||
|
||||
/* external controllers */
|
||||
/* TO9 internal (WD2793) & external controllers */
|
||||
/* TO8 internal (THMFC1) controller */
|
||||
|
||||
class thmfc1_device : public device_t
|
||||
class thomson_legacy_floppy_interface : public device_interface
|
||||
{
|
||||
protected:
|
||||
thomson_legacy_floppy_interface(const machine_config &mconfig, device_t &device)
|
||||
: device_interface(device, "thom_flop")
|
||||
{
|
||||
}
|
||||
|
||||
static int floppy_make_addr(chrn_id id, uint8_t *dst, int sector_size);
|
||||
static int floppy_make_sector(legacy_floppy_image_device *img, chrn_id id, uint8_t *dst, int sector_size);
|
||||
static int floppy_make_track(legacy_floppy_image_device *img, uint8_t *dst, int sector_size, int side);
|
||||
|
||||
static int qdd_make_addr(int sector, uint8_t *dst);
|
||||
static int qdd_make_sector(legacy_floppy_image_device *img, int sector, uint8_t *dst);
|
||||
static int qdd_make_disk(legacy_floppy_image_device *img, uint8_t *dst);
|
||||
};
|
||||
|
||||
class thmfc1_device : public device_t, public thomson_legacy_floppy_interface
|
||||
{
|
||||
public:
|
||||
// STAT0 flags
|
||||
enum : uint8_t
|
||||
{
|
||||
STAT0_SYNCHRO = 0x01, // bit clock synchronized
|
||||
STAT0_BYTE_READY_OP = 0x02, // byte ready (high-level operation)
|
||||
STAT0_CRC_ERROR = 0x04,
|
||||
STAT0_FINISHED = 0x08,
|
||||
STAT0_FINISHING = 0x10, // (unemulated)
|
||||
STAT0_BYTE_READY_POL = 0x80 // polling mode
|
||||
};
|
||||
|
||||
thmfc1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
auto floppy_active_cb() { return m_floppy_active_cb.bind(); }
|
||||
@ -111,6 +114,46 @@ private:
|
||||
emu_timer *m_floppy_cmd;
|
||||
};
|
||||
|
||||
class cq90_028_device : public device_t, public thomson_legacy_floppy_interface
|
||||
{
|
||||
public:
|
||||
cq90_028_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
uint8_t qdd_r(offs_t offset);
|
||||
void qdd_w(offs_t offset, uint8_t data);
|
||||
|
||||
void index_pulse_cb(int state);
|
||||
void qdd_reset();
|
||||
|
||||
protected:
|
||||
virtual void device_start() override;
|
||||
|
||||
private:
|
||||
void stat_update();
|
||||
uint8_t qdd_read_byte();
|
||||
void qdd_write_byte(uint8_t data);
|
||||
|
||||
required_device<legacy_floppy_image_device> m_qdd_image;
|
||||
|
||||
// MC6852 registers
|
||||
uint8_t m_status;
|
||||
uint8_t m_ctrl1;
|
||||
uint8_t m_ctrl2;
|
||||
uint8_t m_ctrl3;
|
||||
|
||||
// extra registers
|
||||
uint8_t m_drive;
|
||||
|
||||
// internal state
|
||||
std::unique_ptr<uint8_t[]> m_data; // enough for a whole track
|
||||
uint32_t m_data_idx; // byte position in track
|
||||
uint32_t m_start_idx; // start of write position
|
||||
uint32_t m_data_size; // track length
|
||||
uint8_t m_data_crc; // checksum when writing
|
||||
uint8_t m_index_pulse; // one pulse per track
|
||||
};
|
||||
|
||||
DECLARE_DEVICE_TYPE(THMFC1, thmfc1_device)
|
||||
DECLARE_DEVICE_TYPE(CQ90_028, cq90_028_device)
|
||||
|
||||
#endif /* THOMFLOP_H_ */
|
||||
|
@ -2891,7 +2891,7 @@ void thomson_state::to8_kbd_init()
|
||||
|
||||
void thomson_state::to8_update_floppy_bank()
|
||||
{
|
||||
int bank = (m_to8_reg_sys1 & 0x80) ? to7_floppy_bank : (m_to8_bios_bank + TO7_NB_FLOP_BANK);
|
||||
int bank = (m_to8_reg_sys1 & 0x80) ? m_to7_floppy_bank : (m_to8_bios_bank + TO7_NB_FLOP_BANK);
|
||||
|
||||
if ( bank != m_old_floppy_bank )
|
||||
{
|
||||
@ -3178,7 +3178,7 @@ READ8_MEMBER( thomson_state::to8_floppy_r )
|
||||
|
||||
if ( (m_to8_reg_sys1 & 0x80) && THOM_FLOPPY_EXT )
|
||||
/* external controller */
|
||||
return to7_floppy_r( space, offset );
|
||||
return to7_floppy_r( offset );
|
||||
else if ( ! (m_to8_reg_sys1 & 0x80) && THOM_FLOPPY_INT )
|
||||
/* internal controller */
|
||||
return m_thmfc->floppy_r( offset );
|
||||
@ -3193,7 +3193,7 @@ WRITE8_MEMBER( thomson_state::to8_floppy_w )
|
||||
{
|
||||
if ( (m_to8_reg_sys1 & 0x80) && THOM_FLOPPY_EXT )
|
||||
/* external controller */
|
||||
to7_floppy_w( space, offset, data );
|
||||
to7_floppy_w( offset, data );
|
||||
else if ( ! (m_to8_reg_sys1 & 0x80) && THOM_FLOPPY_INT )
|
||||
/* internal controller */
|
||||
m_thmfc->floppy_w( offset, data );
|
||||
@ -3321,7 +3321,7 @@ READ8_MEMBER( thomson_state::to8_vreg_r )
|
||||
return 0;
|
||||
|
||||
if ( THOM_FLOPPY_EXT )
|
||||
return to7_floppy_r( space, 0xc );
|
||||
return to7_floppy_r( 0xc );
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@ -3386,7 +3386,7 @@ WRITE8_MEMBER( thomson_state::to8_vreg_w )
|
||||
if ( ( offset == 3 ) && ( m_to8_reg_ram & 0x80 ) && ( m_to8_reg_sys1 & 0x80 ) )
|
||||
{
|
||||
if ( THOM_FLOPPY_EXT )
|
||||
to7_floppy_w( space, 0xc, data );
|
||||
to7_floppy_w( 0xc, data );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4269,7 +4269,7 @@ READ8_MEMBER( thomson_state::mo6_vreg_r )
|
||||
if ( ( offset == 3 ) && ( m_to8_reg_ram & 0x80 ) )
|
||||
{
|
||||
if ( !machine().side_effects_disabled() )
|
||||
return to7_floppy_r( space, 0xc );
|
||||
return to7_floppy_r( 0xc );
|
||||
}
|
||||
|
||||
switch ( offset )
|
||||
@ -4305,7 +4305,7 @@ WRITE8_MEMBER( thomson_state::mo6_vreg_w )
|
||||
|
||||
case 2: /* display / external floppy register */
|
||||
if ( ( m_to8_reg_sys1 & 0x80 ) && ( m_to8_reg_ram & 0x80 ) )
|
||||
to7_floppy_w( space, 0xc, data );
|
||||
to7_floppy_w( 0xc, data );
|
||||
else
|
||||
to9_set_video_mode( data, 2 );
|
||||
break;
|
||||
@ -4313,7 +4313,7 @@ WRITE8_MEMBER( thomson_state::mo6_vreg_w )
|
||||
case 3: /* system register 2 */
|
||||
/* 0xa7dc from external floppy drive aliases the video gate-array */
|
||||
if ( ( offset == 3 ) && ( m_to8_reg_ram & 0x80 ) )
|
||||
to7_floppy_w( space, 0xc, data );
|
||||
to7_floppy_w( 0xc, data );
|
||||
else
|
||||
{
|
||||
m_to8_reg_sys2 = data;
|
||||
@ -4452,8 +4452,8 @@ READ8_MEMBER( thomson_state::mo5nr_net_r )
|
||||
if ( machine().side_effects_disabled() )
|
||||
return 0;
|
||||
|
||||
if ( to7_controller_type )
|
||||
return to7_floppy_r ( space, offset );
|
||||
if ( m_to7_controller_type )
|
||||
return to7_floppy_r ( offset );
|
||||
|
||||
logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", m_maincpu->pc(), machine().time().as_double(), offset );
|
||||
|
||||
@ -4464,8 +4464,8 @@ READ8_MEMBER( thomson_state::mo5nr_net_r )
|
||||
|
||||
WRITE8_MEMBER( thomson_state::mo5nr_net_w )
|
||||
{
|
||||
if ( to7_controller_type )
|
||||
to7_floppy_w ( space, offset, data );
|
||||
if ( m_to7_controller_type )
|
||||
to7_floppy_w ( offset, data );
|
||||
else
|
||||
logerror( "$%04x %f mo5nr_net_w: write $%02X to reg %i\n",
|
||||
m_maincpu->pc(), machine().time().as_double(), data, offset );
|
||||
|
Loading…
Reference in New Issue
Block a user