summaryrefslogtreecommitdiffstatshomepage
path: root/trunk/src/emu/machine/ds2401.h
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/src/emu/machine/ds2401.h')
-rw-r--r--trunk/src/emu/machine/ds2401.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/trunk/src/emu/machine/ds2401.h b/trunk/src/emu/machine/ds2401.h
new file mode 100644
index 00000000000..353735899f7
--- /dev/null
+++ b/trunk/src/emu/machine/ds2401.h
@@ -0,0 +1,69 @@
+/*
+ * DS2401
+ *
+ * Dallas Semiconductor
+ * Silicon Serial Number
+ *
+ */
+
+#ifndef __DS2401_H__
+#define __DS2401_H__
+
+#define MCFG_DS2401_ADD(_tag) \
+ MCFG_DEVICE_ADD(_tag, DS2401, 0)
+
+#include "emu.h"
+
+class ds2401_device : public device_t
+{
+public:
+ // construction/destruction
+ ds2401_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ void write(bool line);
+ bool read();
+ UINT8 direct_read(int index);
+
+protected:
+ enum {
+ SIZE_DATA = 8,
+
+ COMMAND_READROM = 0x33
+ };
+
+ enum {
+ STATE_IDLE,
+ STATE_RESET,
+ STATE_RESET1,
+ STATE_RESET2,
+ STATE_COMMAND,
+ STATE_READROM
+ };
+
+ enum {
+ TIMER_MAIN,
+ TIMER_RESET
+ };
+
+ // device-level overrides
+ virtual void device_start();
+ virtual void device_reset();
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
+
+ // internal state
+ int state, bit, shift;
+ UINT8 byte;
+ bool rx, tx;
+ UINT8 data[SIZE_DATA];
+ emu_timer *timer_main, *timer_reset;
+ attotime t_samp, t_rdv, t_rstl, t_pdh, t_pdl;
+
+private:
+ inline void ATTR_PRINTF(3,4) verboselog(int n_level, const char *s_fmt, ...);
+};
+
+
+// device type definition
+extern const device_type DS2401;
+
+#endif
iltin */ .highlight .nc { color: #000000 } /* Name.Class */ .highlight .no { color: #000000 } /* Name.Constant */ .highlight .nd { color: #5c35cc; font-weight: bold } /* Name.Decorator */ .highlight .ni { color: #ce5c00 } /* Name.Entity */ .highlight .ne { color: #cc0000; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #000000 } /* Name.Function */ .highlight .nl { color: #f57900 } /* Name.Label */ .highlight .nn { color: #000000 } /* Name.Namespace */ .highlight .nx { color: #000000 } /* Name.Other */ .highlight .py { color: #000000 } /* Name.Property */ .highlight .nt { color: #204a87; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #000000 } /* Name.Variable */ .highlight .ow { color: #204a87; font-weight: bold } /* Operator.Word */ .highlight .pm { color: #000000; font-weight: bold } /* Punctuation.Marker */ .highlight .w { color: #f8f8f8 } /* Text.Whitespace */ .highlight .mb { color: #0000cf; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000cf; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000cf; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000cf; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000cf; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #4e9a06 } /* Literal.String.Affix */ .highlight .sb { color: #4e9a06 } /* Literal.String.Backtick */ .highlight .sc { color: #4e9a06 } /* Literal.String.Char */ .highlight .dl { color: #4e9a06 } /* Literal.String.Delimiter */ .highlight .sd { color: #8f5902; font-style: italic } /* Literal.String.Doc */ .highlight .s2 { color: #4e9a06 } /* Literal.String.Double */ .highlight .se { color: #4e9a06 } /* Literal.String.Escape */ .highlight .sh { color: #4e9a06 } /* Literal.String.Heredoc */ .highlight .si { color: #4e9a06 } /* Literal.String.Interpol */ .highlight .sx { color: #4e9a06 } /* Literal.String.Other */ .highlight .sr { color: #4e9a06 } /* Literal.String.Regex */ .highlight .s1 { color: #4e9a06 } /* Literal.String.Single */ .highlight .ss { color: #4e9a06 } /* Literal.String.Symbol */ .highlight .bp { color: #3465a4 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #000000 } /* Name.Function.Magic */ .highlight .vc { color: #000000 } /* Name.Variable.Class */ .highlight .vg { color: #000000 } /* Name.Variable.Global */ .highlight .vi { color: #000000 } /* Name.Variable.Instance */ .highlight .vm { color: #000000 } /* Name.Variable.Magic */ .highlight .il { color: #0000cf; font-weight: bold } /* Literal.Number.Integer.Long */
// license:BSD-3-Clause
// copyright-holders:AJR
/****************************************************************************

    Skeleton driver for Lee Data 1214 terminal (IBM 3278-compatible).

****************************************************************************/

#include "emu.h"
#include "cpu/i86/i186.h"
#include "machine/eeprompar.h"
#include "machine/z80sio.h"
//#include "video/mc6845.h"
//#include "screen.h"

class lee1214_state : public driver_device
{
public:
	lee1214_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_maincpu(*this, "maincpu")
	{
	}

	void lee1214(machine_config &config);

protected:
	virtual void machine_start() override;

private:
	void mem_map(address_map &map);
	void io_map(address_map &map);

	u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);

	required_device<cpu_device> m_maincpu;
};

void lee1214_state::mem_map(address_map &map)
{
	map(0x00000, 0x007ff).ram();
	map(0x80000, 0x80fff).ram();
	map(0xa0000, 0xa1fff).ram();
	map(0xf8000, 0xfffff).rom().region("maincpu", 0);
}

void lee1214_state::io_map(address_map &map)
{
	map(0x0000, 0x0003).rw("mpsc", FUNC(i8274_device::cd_ba_r), FUNC(i8274_device::cd_ba_w));
	//map(0x0100, 0x0100).w("crtc", FUNC(mc6845_device::address_w));
	//map(0x0101, 0x0101).rw("crtc", FUNC(mc6845_device::register_r), FUNC(mc6845_device::register_w));
}

void lee1214_state::machine_start()
{
}

u32 lee1214_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
	return 0;
}

static INPUT_PORTS_START(lee1214)
INPUT_PORTS_END

void lee1214_state::lee1214(machine_config &config)
{
	I80188(config, m_maincpu, 12_MHz_XTAL);
	m_maincpu->set_addrmap(AS_PROGRAM, &lee1214_state::mem_map);
	m_maincpu->set_addrmap(AS_IO, &lee1214_state::io_map);

	i8274_device &mpsc(I8274(config, "mpsc", 4'000'000));
	mpsc.out_int_callback().set("maincpu", FUNC(i80188_cpu_device::int0_w));

	EEPROM_2816(config, "eeprom");
}

ROM_START(lee1214d) // X1 = 12 MHz, X2 = 41.028 MHz, X3 = 24.823 MHz, X5 = 5.9335 MHz
	ROM_REGION(0x8000, "maincpu", 0)
	ROM_LOAD("13311502_u41_27256.bin", 0x0000, 0x8000, CRC(6f469221) SHA1(deef1d83c41fdbe09b830dc45698988cf89003e0))

	ROM_REGION(0x0800, "eeprom", 0)
	ROM_LOAD("13300001_u19_2816.bin", 0x0000, 0x0800, CRC(30411ecd) SHA1(8755a1e0a36fe96d438bf2ee35cb0917fbc97e52))
ROM_END

COMP(1985, lee1214d, 0, 0, lee1214, lee1214, lee1214_state, empty_init, "Lee Data", "1214D Display Terminal", MACHINE_IS_SKELETON)
********************************************** void nb1412m2_device::nb1412m2_map(address_map &map) { // data decrypter map(0x32, 0x32).w(FUNC(nb1412m2_device::rom_op_w)); map(0x33, 0x34).w(FUNC(nb1412m2_device::rom_address_w)); map(0x35, 0x36).w(FUNC(nb1412m2_device::rom_adjust_w)); map(0x37, 0x37).r(FUNC(nb1412m2_device::rom_decrypt_r)); // timer map(0x40, 0x40).w(FUNC(nb1412m2_device::timer_w)); map(0x41, 0x41).rw(FUNC(nb1412m2_device::timer_r), FUNC(nb1412m2_device::timer_ack_w)); map(0x42, 0x43).nopw(); // always 0x03 // DAC control map(0x11, 0x11).nopw(); // - unknown (volume/channel control?) map(0x18, 0x18).w(FUNC(nb1412m2_device::dac_timer_w)); // timer frequency map(0x19, 0x19).nopw(); // 2 written at POST map(0x51, 0x52).w(FUNC(nb1412m2_device::dac_address_w)); // start address // latches? map(0x90, 0x90).rw(FUNC(nb1412m2_device::const90_r),FUNC(nb1412m2_device::const90_w)); //ram(); map(0x92, 0x92).ram(); map(0x94, 0x94).ram(); //rw(this,FUNC(nb1412m2_device::xor_r),FUNC(nb1412m2_device::xor_w)); // 16-bit registers (1=upper address), more latches? map(0xa0, 0xa1).ram(); map(0xa2, 0xa3).ram(); } //------------------------------------------------- // nb1412m2_device - constructor //------------------------------------------------- nb1412m2_device::nb1412m2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, NB1412M2, tag, owner, clock) , device_memory_interface(mconfig, *this) , m_space_config("regs", ENDIANNESS_LITTLE, 8, 8, 0, address_map_constructor(FUNC(nb1412m2_device::nb1412m2_map), this)) , m_data(*this, DEVICE_SELF) , m_dac_cb(*this) { } device_memory_interface::space_config_vector nb1412m2_device::memory_space_config() const { return space_config_vector { std::make_pair(0, &m_space_config) }; } //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- void nb1412m2_device::device_start() { save_item(NAME(m_command)); save_item(NAME(m_rom_address)); save_item(NAME(m_dac_start_address)); save_item(NAME(m_dac_current_address)); save_item(NAME(m_adj_address)); save_item(NAME(m_rom_op)); save_item(NAME(m_timer_reg)); save_item(NAME(m_dac_playback)); save_item(NAME(m_dac_frequency)); save_item(NAME(m_const90)); m_timer = timer_alloc(TIMER_MAIN); m_timer->adjust(attotime::never); m_dac_timer = timer_alloc(TIMER_DAC); m_dac_cb.resolve_safe(); } //------------------------------------------------- // device_reset - device-specific reset //------------------------------------------------- void nb1412m2_device::device_reset() { m_command = 0xff; m_rom_address = 0; m_adj_address = 0; m_rom_op = 0; m_const90 = 0x18; // fixes coin sample if inserted at first title screen m_dac_current_address = m_dac_start_address = 0; m_dac_frequency = 4000; m_timer_reg = false; m_dac_playback = false; m_dac_timer->adjust(attotime::never); } void nb1412m2_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch (id) { case TIMER_MAIN: m_timer_reg = true; m_timer->adjust(attotime::never); break; case TIMER_DAC: if(m_dac_playback == true) { uint8_t dac_value; dac_value = m_data[m_dac_current_address]; m_dac_cb(dac_value); m_dac_current_address++; m_dac_current_address&= m_data.mask(); if(dac_value == 0x80) m_dac_playback = false; } break; default: assert_always(false, "Unknown id in nb1412m2_device::device_timer"); } } //************************************************************************** // READ/WRITE HANDLERS //************************************************************************** WRITE8_MEMBER( nb1412m2_device::rom_op_w ) { // data == 2 starts DAC playback if(data == 2) { m_dac_current_address = m_dac_start_address; m_dac_timer->adjust(attotime::never); m_dac_timer->adjust(attotime::from_hz(m_dac_frequency), 0, attotime::from_hz(m_dac_frequency)); m_dac_playback = true; } // TODO: data == 5 probably loads the result into 0x37 // if(data != 5) // printf("%02x rom_op\n",data); m_rom_op = data; } WRITE8_MEMBER( nb1412m2_device::rom_address_w ) { if(offset == 0) // rom hi address { m_rom_address &= 0x00ff; m_rom_address |= data << 8; } else // rom lo address { m_rom_address &= 0xff00; m_rom_address |= data; } } WRITE8_MEMBER( nb1412m2_device::rom_adjust_w ) { if(offset == 0) // rom hi address { m_adj_address &= 0x00ff; m_adj_address |= data << 8; } else // rom lo address { m_adj_address &= 0xff00; m_adj_address |= data; } } // readback from ROM data READ8_MEMBER( nb1412m2_device::rom_decrypt_r ) { uint8_t prot_adj; // all games but Mighty Guy uses this form as protection: // 0xff: -> 0x44 // Mighty Guy variants // 0x86: SFXs -> 0xbd // 0x94: BGM -> 0xaf // 0x00: DAC -> 0x43 // summing adjust entry and actual value needed always make 0x143 therefore: prot_adj = (0x43 - m_data[m_adj_address]) & 0xff; // printf("%02x %04x %04x %02x\n",m_data[m_adj_address],m_rom_address,m_adj_address,m_rom_op); return m_data[m_rom_address & 0x1fff] - prot_adj; } // Mighty Guy specifics READ8_MEMBER( nb1412m2_device::timer_r ) { return m_timer_reg == true; } WRITE8_MEMBER( nb1412m2_device::timer_w ) { if(data != 1) logerror("nb1412m2: timer_w with data == %02x\n",data); // TODO: timing of this, related to m_const90? m_timer->adjust(attotime::from_hz(960)); } WRITE8_MEMBER( nb1412m2_device::timer_ack_w ) { m_timer_reg = false; m_timer->adjust(attotime::never); } WRITE8_MEMBER( nb1412m2_device::dac_address_w ) { if(offset == 0) // dac hi address { m_dac_start_address &= 0x00ff; m_dac_start_address |= data << 8; } else // dac lo address { m_dac_start_address &= 0xff00; m_dac_start_address |= data; } } // seems directly correlated to the DAC timer frequency // 0xd0 - 0xe0 - 0xf0 are the settings used WRITE8_MEMBER( nb1412m2_device::dac_timer_w ) { // popmessage("%02x",data); // TODO: unknown algo, 0xe0*18 gives 4032 Hz which seems close enough for sample 36 m_dac_frequency = data*18; } // controls music tempo READ8_MEMBER( nb1412m2_device::const90_r ) { // TODO: likely wrong return m_const90; } WRITE8_MEMBER( nb1412m2_device::const90_w ) { m_const90 = data; } // public accessors READ8_MEMBER( nb1412m2_device::data_r ) { return this->space().read_byte(m_command); } WRITE8_MEMBER( nb1412m2_device::data_w ) { this->space().write_byte(m_command, data); } WRITE8_MEMBER( nb1412m2_device::command_w ) { m_command = data; }