Merge pull request #4926 from cam900/asic65_args

asic65.cpp : Updates
This commit is contained in:
R. Belmont 2019-04-26 12:12:42 -04:00 committed by GitHub
commit 3991aba388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 138 additions and 120 deletions

View File

@ -4862,9 +4862,9 @@ void harddriv_state::init_dsk()
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x910000, 0x910fff, read8_delegate(FUNC(eeprom_parallel_28xx_device::read), m_dsk_30c.target()), write8_delegate(FUNC(eeprom_parallel_28xx_device::write), m_dsk_30c.target()), 0x00ff);
/* install ASIC65 */
m_maincpu->space(AS_PROGRAM).install_write_handler(0x914000, 0x917fff, write16_delegate(FUNC(asic65_device::data_w), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x914000, 0x917fff, read16_delegate(FUNC(asic65_device::read), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x918000, 0x91bfff, read16_delegate(FUNC(asic65_device::io_r), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_write_handler(0x914000, 0x917fff, write16sm_delegate(FUNC(asic65_device::data_w), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x914000, 0x917fff, read16smo_delegate(FUNC(asic65_device::read), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x918000, 0x91bfff, read16smo_delegate(FUNC(asic65_device::io_r), (asic65_device*)m_asic65));
/* install extra ROM */
m_maincpu->space(AS_PROGRAM).install_read_handler(0x940000, 0x9fffff, read16_delegate(FUNC(harddriv_state::hd68k_dsk_small_rom_r), this));
@ -4878,9 +4878,9 @@ void harddriv_state::init_dsk2()
uint8_t *usr3 = memregion("user3")->base();
/* install ASIC65 */
m_maincpu->space(AS_PROGRAM).install_write_handler(0x824000, 0x824003, write16_delegate(FUNC(asic65_device::data_w), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x824000, 0x824003, read16_delegate(FUNC(asic65_device::read), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x825000, 0x825001, read16_delegate(FUNC(asic65_device::io_r), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_write_handler(0x824000, 0x824003, write16sm_delegate(FUNC(asic65_device::data_w), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x824000, 0x824003, read16smo_delegate(FUNC(asic65_device::read), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x825000, 0x825001, read16smo_delegate(FUNC(asic65_device::io_r), (asic65_device*)m_asic65));
/* install ASIC61 */
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x827000, 0x8277ff, read16_delegate(FUNC(harddriv_state::hd68k_dsk_dsp32_r), this), write16_delegate(FUNC(harddriv_state::hd68k_dsk_dsp32_w), this));
@ -4902,9 +4902,9 @@ void harddriv_state::init_dsk2()
void harddriv_state::init_dspcom()
{
/* install ASIC65 */
m_maincpu->space(AS_PROGRAM).install_write_handler(0x900000, 0x900003, write16_delegate(FUNC(asic65_device::data_w), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x900000, 0x900003, read16_delegate(FUNC(asic65_device::read), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x901000, 0x910001, read16_delegate(FUNC(asic65_device::io_r), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_write_handler(0x900000, 0x900003, write16sm_delegate(FUNC(asic65_device::data_w), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x900000, 0x900003, read16smo_delegate(FUNC(asic65_device::read), (asic65_device*)m_asic65));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x901000, 0x910001, read16smo_delegate(FUNC(asic65_device::io_r), (asic65_device*)m_asic65));
/* install DSPCOM control */
m_maincpu->space(AS_PROGRAM).install_write_handler(0x904000, 0x90401f, write16_delegate(FUNC(harddriv_state::hddspcom_control_w), this));

View File

@ -9,6 +9,7 @@
#include "emu.h"
#include "asic65.h"
#include <algorithm>
#define LOG_ASIC 0
@ -36,7 +37,7 @@
#define MAX_COMMANDS 0x2b
static const uint8_t command_map[3][MAX_COMMANDS] =
static const u8 command_map[3][MAX_COMMANDS] =
{
{
/* standard version */
@ -84,28 +85,25 @@ static const uint8_t command_map[3][MAX_COMMANDS] =
DEFINE_DEVICE_TYPE(ASIC65, asic65_device, "asic65", "Atari ASIC65")
asic65_device::asic65_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, ASIC65, tag, owner, clock),
m_asic65_type(0),
m_command(0),
m_yorigin(0x1800),
m_param_index(0),
m_result_index(0),
m_reset_state(0),
m_last_bank(0),
m_ourcpu(*this, "asic65cpu"),
m_tfull(0),
m_68full(0),
m_cmd(0),
m_xflg(0),
m_68data(0),
m_tdata(0),
m_log(nullptr)
asic65_device::asic65_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, ASIC65, tag, owner, clock)
, m_asic65_type(0)
, m_command(0)
, m_yorigin(0x1800)
, m_param_index(0)
, m_result_index(0)
, m_reset_state(0)
, m_last_bank(0)
, m_ourcpu(*this, "asic65cpu")
, m_tfull(0)
, m_68full(0)
, m_cmd(0)
, m_xflg(0)
, m_68data(0)
, m_tdata(0)
, m_log(nullptr)
{
for (auto & elem : m_param)
{
elem = 0;
}
std::fill(std::begin(m_param), std::end(m_param), 0);
}
//-------------------------------------------------
@ -140,8 +138,6 @@ void asic65_device::device_reset()
void asic65_device::reset_line(int state)
{
address_space &space = subdevice("^maincpu")->memory().space(AS_PROGRAM);
/* rom-based means reset and clear states */
if (m_asic65_type == ASIC65_ROMBASED)
m_ourcpu->set_input_line(INPUT_LINE_RESET, state ? ASSERT_LINE : CLEAR_LINE);
@ -159,7 +155,7 @@ void asic65_device::reset_line(int state)
else if (!state && m_reset_state)
{
if (m_command != -1)
data_w(space, 1, m_command, 0xffff);
data_w(1, m_command);
}
/* update the state */
@ -190,7 +186,7 @@ void asic65_device::device_timer(emu_timer &timer, device_timer_id id, int param
}
WRITE16_MEMBER( asic65_device::data_w )
void asic65_device::data_w(offs_t offset, u16 data)
{
/* logging */
if (LOG_ASIC && !m_log) m_log = fopen("m_log", "w");
@ -227,16 +223,19 @@ WRITE16_MEMBER( asic65_device::data_w )
}
READ16_MEMBER( asic65_device::read )
u16 asic65_device::read()
{
int64_t element, result64 = 0;
uint16_t result = 0;
s64 element, result64 = 0;
u16 result = 0;
/* rom-based just returns latched data */
if (m_asic65_type == ASIC65_ROMBASED)
{
if (!machine().side_effects_disabled())
{
m_68full = 0;
machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(5));
}
return m_68data;
}
@ -246,6 +245,7 @@ READ16_MEMBER( asic65_device::read )
switch (command)
{
case OP_UNKNOWN: /* return bogus data */
if (!machine().side_effects_disabled())
popmessage("ASIC65: Unknown cmd %02X", m_command);
break;
@ -267,26 +267,27 @@ READ16_MEMBER( asic65_device::read )
break;
case OP_RESET: /* reset */
if (!machine().side_effects_disabled())
m_result_index = m_param_index = 0;
break;
case OP_SIN: /* sin */
if (m_param_index >= 1)
result = (int)(16384. * sin(M_PI * (double)(int16_t)m_param[0] / 32768.));
result = (int)(16384. * sin(M_PI * (double)(s16)m_param[0] / 32768.));
break;
case OP_COS: /* cos */
if (m_param_index >= 1)
result = (int)(16384. * cos(M_PI * (double)(int16_t)m_param[0] / 32768.));
result = (int)(16384. * cos(M_PI * (double)(s16)m_param[0] / 32768.));
break;
case OP_ATAN: /* vector angle */
if (m_param_index >= 4)
{
int32_t xint = (int32_t)((m_param[0] << 16) | m_param[1]);
int32_t yint = (int32_t)((m_param[2] << 16) | m_param[3]);
s32 xint = (s32)((m_param[0] << 16) | m_param[1]);
s32 yint = (s32)((m_param[2] << 16) | m_param[3]);
double a = atan2((double)yint, (double)xint);
result = (int16_t)(a * 32768. / M_PI);
result = (s16)(a * 32768. / M_PI);
}
break;
@ -295,35 +296,36 @@ READ16_MEMBER( asic65_device::read )
/* in Race Drivin' will be off */
if (m_param_index >= 9+6)
{
int32_t v0 = (int32_t)((m_param[9] << 16) | m_param[10]);
int32_t v1 = (int32_t)((m_param[11] << 16) | m_param[12]);
int32_t v2 = (int32_t)((m_param[13] << 16) | m_param[14]);
s32 v0 = (s32)((m_param[9] << 16) | m_param[10]);
s32 v1 = (s32)((m_param[11] << 16) | m_param[12]);
s32 v2 = (s32)((m_param[13] << 16) | m_param[14]);
/* 2 results per element */
switch (m_result_index / 2)
{
case 0:
result64 = (int64_t)v0 * (int16_t)m_param[0] +
(int64_t)v1 * (int16_t)m_param[3] +
(int64_t)v2 * (int16_t)m_param[6];
result64 = (s64)v0 * (s16)m_param[0] +
(s64)v1 * (s16)m_param[3] +
(s64)v2 * (s16)m_param[6];
break;
case 1:
result64 = (int64_t)v0 * (int16_t)m_param[1] +
(int64_t)v1 * (int16_t)m_param[4] +
(int64_t)v2 * (int16_t)m_param[7];
result64 = (s64)v0 * (s16)m_param[1] +
(s64)v1 * (s16)m_param[4] +
(s64)v2 * (s16)m_param[7];
break;
case 2:
result64 = (int64_t)v0 * (int16_t)m_param[2] +
(int64_t)v1 * (int16_t)m_param[5] +
(int64_t)v2 * (int16_t)m_param[8];
result64 = (s64)v0 * (s16)m_param[2] +
(s64)v1 * (s16)m_param[5] +
(s64)v2 * (s16)m_param[8];
break;
}
/* remove lower 14 bits and pass back either upper or lower words */
result64 >>= 14;
result = (m_result_index & 1) ? (result64 & 0xffff) : ((result64 >> 16) & 0xffff);
if (!machine().side_effects_disabled())
m_result_index++;
}
break;
@ -331,42 +333,46 @@ READ16_MEMBER( asic65_device::read )
case OP_MATRIXMULT: /* matrix multiply???? */
if (m_param_index >= 9+6)
{
int32_t v0 = (int32_t)((m_param[9] << 16) | m_param[10]);
int32_t v1 = (int32_t)((m_param[11] << 16) | m_param[12]);
int32_t v2 = (int32_t)((m_param[13] << 16) | m_param[14]);
s32 v0 = (s32)((m_param[9] << 16) | m_param[10]);
s32 v1 = (s32)((m_param[11] << 16) | m_param[12]);
s32 v2 = (s32)((m_param[13] << 16) | m_param[14]);
/* 2 results per element */
switch (m_result_index / 2)
{
case 0:
result64 = (int64_t)v0 * (int16_t)m_param[0] +
(int64_t)v1 * (int16_t)m_param[1] +
(int64_t)v2 * (int16_t)m_param[2];
result64 = (s64)v0 * (s16)m_param[0] +
(s64)v1 * (s16)m_param[1] +
(s64)v2 * (s16)m_param[2];
break;
case 1:
result64 = (int64_t)v0 * (int16_t)m_param[3] +
(int64_t)v1 * (int16_t)m_param[4] +
(int64_t)v2 * (int16_t)m_param[5];
result64 = (s64)v0 * (s16)m_param[3] +
(s64)v1 * (s16)m_param[4] +
(s64)v2 * (s16)m_param[5];
break;
case 2:
result64 = (int64_t)v0 * (int16_t)m_param[6] +
(int64_t)v1 * (int16_t)m_param[7] +
(int64_t)v2 * (int16_t)m_param[8];
result64 = (s64)v0 * (s16)m_param[6] +
(s64)v1 * (s16)m_param[7] +
(s64)v2 * (s16)m_param[8];
break;
}
/* remove lower 14 bits and pass back either upper or lower words */
result64 >>= 14;
result = (m_result_index & 1) ? (result64 & 0xffff) : ((result64 >> 16) & 0xffff);
if (!machine().side_effects_disabled())
m_result_index++;
}
break;
case OP_YORIGIN:
if (m_param_index >= 1)
{
if (!machine().side_effects_disabled())
m_yorigin = m_param[m_param_index - 1];
}
break;
case OP_TRANSFORM: /* 3d transform */
@ -379,40 +385,41 @@ READ16_MEMBER( asic65_device::read )
/* return 0 == scale factor for 1/z */
/* return 1 == transformed X */
/* return 2 == transformed Y, taking height into account */
element = (int16_t)m_param[0];
element = (s16)m_param[0];
if (m_param_index == 2)
{
result64 = (element * (int16_t)m_param[1]) >> 8;
result64 = (element * (s16)m_param[1]) >> 8;
result64 -= 1;
if (result64 > 0x3fff) result64 = 0;
}
else if (m_param_index == 3)
{
result64 = (element * (int16_t)m_param[2]) >> 15;
result64 = (element * (s16)m_param[2]) >> 15;
result64 += 0xa8;
}
else if (m_param_index == 4)
{
result64 = (int16_t)((element * (int16_t)m_param[3]) >> 10);
result64 = (int16_t)m_yorigin - result64 - (result64 << 1);
result64 = (s16)((element * (s16)m_param[3]) >> 10);
result64 = (s16)m_yorigin - result64 - (result64 << 1);
}
result = result64 & 0xffff;
}
break;
case OP_INITBANKS: /* initialize banking */
if (!machine().side_effects_disabled())
m_last_bank = 0;
break;
case OP_SETBANK: /* set a bank */
{
static const uint8_t banklist[] =
static const u8 banklist[] =
{
1,4,0,4,4,3,4,2, 4,4,4,4,4,4,4,4,
3,3,4,4,1,1,0,0, 4,4,4,4,2,2,4,4,
4,4
};
static const uint16_t bankaddr[][8] =
static const u16 bankaddr[][8] =
{
{ 0x77c0,0x77ce,0x77c2,0x77cc,0x77c4,0x77ca,0x77c6,0x77c8 },
{ 0x77d0,0x77de,0x77d2,0x77dc,0x77d4,0x77da,0x77d6,0x77d8 },
@ -423,8 +430,12 @@ READ16_MEMBER( asic65_device::read )
if (m_param_index >= 1)
{
if (m_param_index < sizeof(banklist) && banklist[m_param[0]] < 4)
{
if (!machine().side_effects_disabled())
m_last_bank = banklist[m_param[0]];
}
result = bankaddr[m_last_bank][(m_result_index < 8) ? m_result_index : 7];
if (!machine().side_effects_disabled())
m_result_index++;
}
break;
@ -432,7 +443,7 @@ READ16_MEMBER( asic65_device::read )
case OP_VERIFYBANK: /* verify a bank */
{
static const uint16_t bankverify[] =
static const u16 bankverify[] =
{
0x0eb2,0x1000,0x171b,0x3d28
};
@ -448,7 +459,7 @@ READ16_MEMBER( asic65_device::read )
}
READ16_MEMBER( asic65_device::io_r )
u16 asic65_device::io_r()
{
if (m_asic65_type == ASIC65_ROMBASED)
{
@ -456,6 +467,7 @@ READ16_MEMBER( asic65_device::io_r )
/* bit 14 = 68FULL */
/* bit 13 = XFLG */
/* bit 12 = controlled by jumper */
if (!machine().side_effects_disabled())
machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(5));
return (m_tfull << 15) | (m_68full << 14) | (m_xflg << 13) | 0x0000;
}
@ -474,29 +486,32 @@ READ16_MEMBER( asic65_device::io_r )
*
*************************************/
WRITE16_MEMBER( asic65_device::m68k_w )
void asic65_device::m68k_w(u16 data)
{
m_68full = 1;
m_68data = data;
}
READ16_MEMBER( asic65_device::m68k_r )
u16 asic65_device::m68k_r()
{
if (!machine().side_effects_disabled())
{
m_tfull = 0;
if (m_asic65_type == ASIC65_ROMBASED)
m_ourcpu->set_input_line(0, CLEAR_LINE);
}
return m_tdata;
}
WRITE16_MEMBER( asic65_device::stat_w )
void asic65_device::stat_w(u16 data)
{
m_xflg = data & 1;
}
READ16_MEMBER( asic65_device::stat_r )
u16 asic65_device::stat_r()
{
/* bit 15 = 68FULL */
/* bit 14 = TFULL */
@ -508,8 +523,11 @@ READ16_MEMBER( asic65_device::stat_r )
READ_LINE_MEMBER( asic65_device::get_bio )
{
if (!machine().side_effects_disabled())
{
if (!m_tfull)
m_ourcpu->spin_until_interrupt();
}
return m_tfull ? CLEAR_LINE : ASSERT_LINE;
}

View File

@ -22,26 +22,26 @@ enum {
class asic65_device : public device_t
{
public:
asic65_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint8_t type)
asic65_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock, u8 type)
: asic65_device(mconfig, tag, owner, clock)
{
set_type(type);
}
asic65_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
asic65_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
// configuration helpers
void set_type(uint8_t type) { m_asic65_type = type; }
void set_type(u8 type) { m_asic65_type = type; }
void reset_line(int state);
DECLARE_WRITE16_MEMBER( data_w );
DECLARE_READ16_MEMBER( read );
DECLARE_READ16_MEMBER( io_r );
void data_w(offs_t offset, u16 data);
u16 read();
u16 io_r();
DECLARE_WRITE16_MEMBER( m68k_w );
DECLARE_READ16_MEMBER( m68k_r );
DECLARE_WRITE16_MEMBER( stat_w );
DECLARE_READ16_MEMBER( stat_r );
void m68k_w(u16 data);
u16 m68k_r();
void stat_w(u16 data);
u16 stat_r();
enum
{
@ -58,23 +58,23 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
private:
uint8_t m_asic65_type;
u8 m_asic65_type;
int m_command;
uint16_t m_param[32];
uint16_t m_yorigin;
uint8_t m_param_index;
uint8_t m_result_index;
uint8_t m_reset_state;
uint8_t m_last_bank;
u16 m_param[32];
u16 m_yorigin;
u8 m_param_index;
u8 m_result_index;
u8 m_reset_state;
u8 m_last_bank;
/* ROM-based interface states */
required_device<tms32010_device> m_ourcpu;
uint8_t m_tfull;
uint8_t m_68full;
uint8_t m_cmd;
uint8_t m_xflg;
uint16_t m_68data;
uint16_t m_tdata;
u8 m_tfull;
u8 m_68full;
u8 m_cmd;
u8 m_xflg;
u16 m_68data;
u16 m_tdata;
FILE * m_log;