mirror of
https://github.com/holub/mame
synced 2025-05-30 17:41:47 +03:00
Converted turbo.c to use i8279 device [Sandro Ronco]
This commit is contained in:
parent
46a014a281
commit
995513cb74
@ -173,13 +173,22 @@ void i8279_device::device_reset()
|
||||
void i8279_device::timer_adjust()
|
||||
{
|
||||
// Real device runs at about 100kHz internally, clock divider is chosen so that
|
||||
// this is the case. We do not need such speed, 200Hz is enough.
|
||||
// this is the case. We do not need such speed, 2000Hz is enough.
|
||||
// If this is too long, the sensor mode doesn't work correctly.
|
||||
|
||||
//UINT8 divider = (m_cmd[1]) ? m_cmd[1] : 1;
|
||||
//m_clock = clock() / divider;
|
||||
#if 0
|
||||
UINT8 divider = (m_cmd[1]) ? m_cmd[1] : 1;
|
||||
UINT32 new_clock = clock() / divider;
|
||||
#else
|
||||
UINT32 new_clock = 2000;
|
||||
#endif
|
||||
|
||||
m_clock = 200;
|
||||
m_timer->adjust(attotime::from_hz(m_clock), 0, attotime::from_hz(m_clock));
|
||||
if (m_clock != new_clock)
|
||||
{
|
||||
m_timer->adjust(attotime::from_hz(new_clock), 0, attotime::from_hz(new_clock));
|
||||
|
||||
m_clock = new_clock;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -148,6 +148,7 @@
|
||||
#include "cpu/z80/z80.h"
|
||||
#include "machine/8255ppi.h"
|
||||
#include "includes/turbo.h"
|
||||
#include "machine/i8279.h"
|
||||
#include "machine/segacrpt.h"
|
||||
#include "sound/samples.h"
|
||||
|
||||
@ -452,165 +453,31 @@ static const ppi8255_interface buckrog_8255_intf[2] =
|
||||
*
|
||||
*************************************/
|
||||
|
||||
static void update_outputs(i8279_state *chip, UINT16 which)
|
||||
WRITE8_MEMBER( turbo_state::scanlines_w )
|
||||
{
|
||||
m_i8279_scanlines = data;
|
||||
}
|
||||
|
||||
WRITE8_MEMBER( turbo_state::digit_w )
|
||||
{
|
||||
static const UINT8 ls48_map[16] =
|
||||
{ 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67,0x58,0x4c,0x62,0x69,0x78,0x00 };
|
||||
int i;
|
||||
|
||||
/* update the items in the bitmask */
|
||||
for (i = 0; i < 16; i++)
|
||||
if (which & (1 << i))
|
||||
{
|
||||
int val;
|
||||
|
||||
val = chip->ram[i] & 0x0f;
|
||||
if (chip->inhibit & 0x01)
|
||||
val = chip->clear & 0x0f;
|
||||
output_set_digit_value(i * 2 + 0, ls48_map[val]);
|
||||
|
||||
val = chip->ram[i] >> 4;
|
||||
if (chip->inhibit & 0x02)
|
||||
val = chip->clear >> 4;
|
||||
output_set_digit_value(i * 2 + 1, ls48_map[val]);
|
||||
}
|
||||
output_set_digit_value(m_i8279_scanlines * 2 + 0, ls48_map[data & 0x0f]);
|
||||
output_set_digit_value(m_i8279_scanlines * 2 + 1, ls48_map[(data>>4) & 0x0f]);
|
||||
}
|
||||
|
||||
|
||||
READ8_MEMBER(turbo_state::turbo_8279_r)
|
||||
static I8279_INTERFACE( turbo_i8279_intf )
|
||||
{
|
||||
i8279_state *chip = &m_i8279;
|
||||
UINT8 result = 0xff;
|
||||
UINT8 addr;
|
||||
|
||||
/* read data */
|
||||
if ((offset & 1) == 0)
|
||||
{
|
||||
switch (chip->command & 0xe0)
|
||||
{
|
||||
/* read sensor RAM */
|
||||
case 0x40:
|
||||
result = ~input_port_read(machine(), "DSW1"); /* DSW 1 - inverted! */
|
||||
break;
|
||||
|
||||
/* read display RAM */
|
||||
case 0x60:
|
||||
|
||||
/* set the value of the corresponding outputs */
|
||||
addr = chip->command & 0x0f;
|
||||
result = chip->ram[addr];
|
||||
|
||||
/* handle autoincrement */
|
||||
if (chip->command & 0x10)
|
||||
chip->command = (chip->command & 0xf0) | ((addr + 1) & 0x0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* read status word */
|
||||
else
|
||||
{
|
||||
logerror("read 0xfc%02x\n", offset);
|
||||
result = 0x10;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
WRITE8_MEMBER(turbo_state::turbo_8279_w)
|
||||
{
|
||||
i8279_state *chip = &m_i8279;
|
||||
UINT8 addr;
|
||||
|
||||
/* write data */
|
||||
if ((offset & 1) == 0)
|
||||
{
|
||||
switch (chip->command & 0xe0)
|
||||
{
|
||||
/* write display RAM */
|
||||
case 0x80:
|
||||
|
||||
/* set the value of the corresponding outputs */
|
||||
addr = chip->command & 0x0f;
|
||||
if (!(chip->inhibit & 0x04))
|
||||
chip->ram[addr] = (chip->ram[addr] & 0xf0) | (data & 0x0f);
|
||||
if (!(chip->inhibit & 0x08))
|
||||
chip->ram[addr] = (chip->ram[addr] & 0x0f) | (data & 0xf0);
|
||||
update_outputs(chip, 1 << addr);
|
||||
|
||||
/* handle autoincrement */
|
||||
if (chip->command & 0x10)
|
||||
chip->command = (chip->command & 0xf0) | ((addr + 1) & 0x0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* write command */
|
||||
else
|
||||
{
|
||||
chip->command = data;
|
||||
|
||||
switch (data & 0xe0)
|
||||
{
|
||||
/* command 0: set mode */
|
||||
/*
|
||||
Display modes:
|
||||
|
||||
00 = 8 x 8-bit character display -- left entry
|
||||
01 = 16 x 8-bit character display -- left entry
|
||||
10 = 8 x 8-bit character display -- right entry
|
||||
11 = 16 x 8-bit character display -- right entry
|
||||
|
||||
Keyboard modes:
|
||||
|
||||
000 = Encoded scan keyboard -- 2 key lockout
|
||||
001 = Decoded scan keyboard -- 2 key lockout
|
||||
010 = Encoded scan keyboard -- N-key rollover
|
||||
011 = Decoded scan keyboard -- N-key rollover
|
||||
100 = Encoded scan sensor matrix
|
||||
101 = Decoded scan sensor matrix
|
||||
110 = Strobed input, encoded display scan
|
||||
111 = Strobed input, decoded display scan
|
||||
*/
|
||||
case 0x00:
|
||||
logerror("turbo_8279: display mode = %d, keyboard mode = %d\n", (data >> 3) & 3, data & 7);
|
||||
chip->mode = data & 0x1f;
|
||||
break;
|
||||
|
||||
/* command 1: program clock */
|
||||
case 0x20:
|
||||
logerror("turbo_8279: clock prescaler set to %02X\n", data & 0x1f);
|
||||
chip->prescale = data & 0x1f;
|
||||
break;
|
||||
|
||||
/* command 2: read FIFO/sensor RAM */
|
||||
/* command 3: read display RAM */
|
||||
/* command 4: write display RAM */
|
||||
case 0x40:
|
||||
case 0x60:
|
||||
case 0x80:
|
||||
break;
|
||||
|
||||
/* command 5: display write inhibit/blanking */
|
||||
case 0xa0:
|
||||
chip->inhibit = data & 0x0f;
|
||||
update_outputs(chip, ~0);
|
||||
logerror("turbo_8279: clock prescaler set to %02X\n", data & 0x1f);
|
||||
break;
|
||||
|
||||
/* command 6: clear */
|
||||
case 0xc0:
|
||||
chip->clear = (data & 0x08) ? ((data & 0x04) ? 0xff : 0x20) : 0x00;
|
||||
if (data & 0x11)
|
||||
memset(chip->ram, chip->clear, sizeof(chip->ram));
|
||||
break;
|
||||
|
||||
/* command 7: end interrupt/error mode set */
|
||||
case 0xe0:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
DEVCB_NULL, // irq
|
||||
DEVCB_DRIVER_MEMBER(turbo_state, scanlines_w), // scan SL lines
|
||||
DEVCB_DRIVER_MEMBER(turbo_state, digit_w), // display A&B
|
||||
DEVCB_NULL, // BD
|
||||
DEVCB_INPUT_PORT("DSW1"), // kbd RL lines
|
||||
DEVCB_NULL, // Shift key
|
||||
DEVCB_NULL // Ctrl-Strobe line
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -745,7 +612,8 @@ static ADDRESS_MAP_START( turbo_map, AS_PROGRAM, 8, turbo_state )
|
||||
AM_RANGE(0xf900, 0xf903) AM_MIRROR(0x00fc) AM_DEVREADWRITE_LEGACY("ppi8255_1", ppi8255_r, ppi8255_w)
|
||||
AM_RANGE(0xfa00, 0xfa03) AM_MIRROR(0x00fc) AM_DEVREADWRITE_LEGACY("ppi8255_2", ppi8255_r, ppi8255_w)
|
||||
AM_RANGE(0xfb00, 0xfb03) AM_MIRROR(0x00fc) AM_DEVREADWRITE_LEGACY("ppi8255_3", ppi8255_r, ppi8255_w)
|
||||
AM_RANGE(0xfc00, 0xfc01) AM_MIRROR(0x00fe) AM_READWRITE(turbo_8279_r, turbo_8279_w)
|
||||
AM_RANGE(0xfc00, 0xfc00) AM_MIRROR(0x00fe) AM_DEVREADWRITE("i8279", i8279_device, data_r, data_w )
|
||||
AM_RANGE(0xfc01, 0xfc01) AM_MIRROR(0x00fe) AM_DEVREADWRITE("i8279", i8279_device, status_r, cmd_w)
|
||||
AM_RANGE(0xfd00, 0xfdff) AM_READ_PORT("INPUT")
|
||||
AM_RANGE(0xfe00, 0xfeff) AM_READ(turbo_collision_r)
|
||||
ADDRESS_MAP_END
|
||||
@ -771,7 +639,8 @@ static ADDRESS_MAP_START( subroc3d_map, AS_PROGRAM, 8, turbo_state )
|
||||
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(turbo_videoram_w) AM_SHARE("videoram") // FIX PAGE
|
||||
AM_RANGE(0xe800, 0xe803) AM_MIRROR(0x07fc) AM_DEVREADWRITE_LEGACY("ppi8255_0", ppi8255_r, ppi8255_w)
|
||||
AM_RANGE(0xf000, 0xf003) AM_MIRROR(0x07fc) AM_DEVREADWRITE_LEGACY("ppi8255_1", ppi8255_r, ppi8255_w)
|
||||
AM_RANGE(0xf800, 0xf801) AM_MIRROR(0x07fe) AM_READWRITE(turbo_8279_r, turbo_8279_w)
|
||||
AM_RANGE(0xf800, 0xf800) AM_MIRROR(0x07fe) AM_DEVREADWRITE("i8279", i8279_device, data_r, data_w )
|
||||
AM_RANGE(0xf801, 0xf801) AM_MIRROR(0x07fe) AM_DEVREADWRITE("i8279", i8279_device, status_r, cmd_w)
|
||||
ADDRESS_MAP_END
|
||||
|
||||
|
||||
@ -788,7 +657,8 @@ static ADDRESS_MAP_START( buckrog_map, AS_PROGRAM, 8, turbo_state )
|
||||
AM_RANGE(0xc000, 0xc7ff) AM_RAM_WRITE(turbo_videoram_w) AM_SHARE("videoram") // FIX PAGE
|
||||
AM_RANGE(0xc800, 0xc803) AM_MIRROR(0x07fc) AM_DEVREADWRITE_LEGACY("ppi8255_0", ppi8255_r, buckrog_ppi8255_0_w) // 8255
|
||||
AM_RANGE(0xd000, 0xd003) AM_MIRROR(0x07fc) AM_DEVREADWRITE_LEGACY("ppi8255_1", ppi8255_r, ppi8255_w) // 8255
|
||||
AM_RANGE(0xd800, 0xd801) AM_MIRROR(0x07fe) AM_READWRITE(turbo_8279_r, turbo_8279_w) // 8279
|
||||
AM_RANGE(0xd800, 0xd800) AM_MIRROR(0x07fe) AM_DEVREADWRITE("i8279", i8279_device, data_r, data_w )
|
||||
AM_RANGE(0xd801, 0xd801) AM_MIRROR(0x07fe) AM_DEVREADWRITE("i8279", i8279_device, status_r, cmd_w)
|
||||
AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_SHARE("sprite_position") // CONT RAM
|
||||
AM_RANGE(0xe400, 0xe7ff) AM_RAM AM_SHARE("spriteram") // CONT RAM
|
||||
AM_RANGE(0xe800, 0xe800) AM_MIRROR(0x07fc) AM_READ_PORT("IN0") // INPUT
|
||||
@ -1080,6 +950,8 @@ static MACHINE_CONFIG_START( turbo, turbo_state )
|
||||
MCFG_PPI8255_ADD( "ppi8255_2", turbo_8255_intf[2] )
|
||||
MCFG_PPI8255_ADD( "ppi8255_3", turbo_8255_intf[3] )
|
||||
|
||||
MCFG_I8279_ADD("i8279", MASTER_CLOCK/4, turbo_i8279_intf) // unknown clock
|
||||
|
||||
/* video hardware */
|
||||
MCFG_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
|
||||
MCFG_GFXDECODE(turbo)
|
||||
@ -1107,6 +979,8 @@ static MACHINE_CONFIG_START( subroc3d, turbo_state )
|
||||
MCFG_PPI8255_ADD( "ppi8255_0", subroc3d_8255_intf[0] )
|
||||
MCFG_PPI8255_ADD( "ppi8255_1", subroc3d_8255_intf[1] )
|
||||
|
||||
MCFG_I8279_ADD("i8279", MASTER_CLOCK/4, turbo_i8279_intf) // unknown clock
|
||||
|
||||
/* video hardware */
|
||||
MCFG_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
|
||||
MCFG_GFXDECODE(turbo)
|
||||
@ -1141,6 +1015,8 @@ static MACHINE_CONFIG_START( buckrog, turbo_state )
|
||||
MCFG_PPI8255_ADD( "ppi8255_0", buckrog_8255_intf[0] )
|
||||
MCFG_PPI8255_ADD( "ppi8255_1", buckrog_8255_intf[1] )
|
||||
|
||||
MCFG_I8279_ADD("i8279", MASTER_CLOCK/4, turbo_i8279_intf) // unknown clock
|
||||
|
||||
/* video hardware */
|
||||
MCFG_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
|
||||
MCFG_GFXDECODE(turbo)
|
||||
|
@ -11,16 +11,6 @@
|
||||
#define TURBO_X_SCALE 2
|
||||
|
||||
|
||||
struct i8279_state
|
||||
{
|
||||
UINT8 command;
|
||||
UINT8 mode;
|
||||
UINT8 prescale;
|
||||
UINT8 inhibit;
|
||||
UINT8 clear;
|
||||
UINT8 ram[16];
|
||||
};
|
||||
|
||||
|
||||
class turbo_state : public driver_device
|
||||
{
|
||||
@ -38,7 +28,7 @@ public:
|
||||
UINT8 * m_buckrog_bitmap_ram;
|
||||
|
||||
/* machine states */
|
||||
i8279_state m_i8279;
|
||||
UINT8 m_i8279_scanlines;
|
||||
|
||||
/* sound state */
|
||||
UINT8 m_turbo_osel;
|
||||
@ -82,8 +72,9 @@ public:
|
||||
UINT8 m_buckrog_command;
|
||||
UINT8 m_buckrog_myship;
|
||||
int m_last_sound_a;
|
||||
DECLARE_READ8_MEMBER(turbo_8279_r);
|
||||
DECLARE_WRITE8_MEMBER(turbo_8279_w);
|
||||
|
||||
DECLARE_WRITE8_MEMBER(scanlines_w);
|
||||
DECLARE_WRITE8_MEMBER(digit_w);
|
||||
DECLARE_READ8_MEMBER(turbo_collision_r);
|
||||
DECLARE_WRITE8_MEMBER(turbo_collision_clear_w);
|
||||
DECLARE_WRITE8_MEMBER(turbo_analog_reset_w);
|
||||
|
Loading…
Reference in New Issue
Block a user