mirror of
https://github.com/holub/mame
synced 2025-05-29 09:03:08 +03:00
othunder: Use ADC0808 device
Also use MCFG_SCREEN_VBLANK_CALLBACK instead of MCFG_CPU_VBLANK_INT_DRIVER.
This commit is contained in:
parent
3f9d74d78e
commit
8bf1fb49a1
@ -282,6 +282,7 @@ TODO:
|
||||
|
||||
#include "cpu/m68000/m68000.h"
|
||||
#include "cpu/z80/z80.h"
|
||||
#include "machine/adc0808.h"
|
||||
#include "machine/eepromser.h"
|
||||
#include "sound/2610intf.h"
|
||||
#include "sound/flt_vol.h"
|
||||
@ -293,45 +294,30 @@ TODO:
|
||||
INTERRUPTS
|
||||
***********************************************************/
|
||||
|
||||
void othunder_state::update_irq()
|
||||
{
|
||||
m_maincpu->set_input_line(6, m_ad_irq ? ASSERT_LINE : CLEAR_LINE);
|
||||
m_maincpu->set_input_line(5, m_vblank_irq ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(othunder_state::irq_ack_w)
|
||||
WRITE16_MEMBER( othunder_state::irq_ack_w )
|
||||
{
|
||||
switch (offset)
|
||||
{
|
||||
case 0:
|
||||
m_vblank_irq = 0;
|
||||
m_maincpu->set_input_line(5, CLEAR_LINE);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
m_ad_irq = 0;
|
||||
m_maincpu->set_input_line(6, CLEAR_LINE);
|
||||
break;
|
||||
}
|
||||
|
||||
update_irq();
|
||||
}
|
||||
|
||||
INTERRUPT_GEN_MEMBER(othunder_state::vblank_interrupt)
|
||||
WRITE_LINE_MEMBER( othunder_state::vblank_w )
|
||||
{
|
||||
m_vblank_irq = 1;
|
||||
update_irq();
|
||||
if (state)
|
||||
m_maincpu->set_input_line(5, ASSERT_LINE);
|
||||
}
|
||||
|
||||
void othunder_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
WRITE_LINE_MEMBER( othunder_state::adc_eoc_w )
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case TIMER_AD_INTERRUPT:
|
||||
m_ad_irq = 1;
|
||||
update_irq();
|
||||
break;
|
||||
default:
|
||||
assert_always(false, "Unknown id in othunder_state::device_timer");
|
||||
}
|
||||
if (state)
|
||||
m_maincpu->set_input_line(6, ASSERT_LINE);
|
||||
}
|
||||
|
||||
|
||||
@ -376,33 +362,6 @@ WRITE8_MEMBER(othunder_state::coins_w)
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************
|
||||
GAME INPUTS
|
||||
**********************************************************/
|
||||
|
||||
#define P1X_PORT_TAG "P1X"
|
||||
#define P1Y_PORT_TAG "P1Y"
|
||||
#define P2X_PORT_TAG "P2X"
|
||||
#define P2Y_PORT_TAG "P2Y"
|
||||
#define ROTARY_PORT_TAG "ROTARY"
|
||||
|
||||
READ16_MEMBER(othunder_state::lightgun_r)
|
||||
{
|
||||
static const char *const portname[4] = { P1X_PORT_TAG, P1Y_PORT_TAG, P2X_PORT_TAG, P2Y_PORT_TAG };
|
||||
return ioport(portname[offset])->read();
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(othunder_state::lightgun_w)
|
||||
{
|
||||
/* A write starts the A/D conversion. An interrupt will be triggered when
|
||||
the conversion is complete.
|
||||
The ADC60808 clock is 512kHz. Conversion takes between 0 and 8 clock
|
||||
cycles, so would end in a maximum of 15.625us. We'll use 10. */
|
||||
|
||||
m_ad_interrupt_timer->adjust(attotime::from_usec(10));
|
||||
}
|
||||
|
||||
|
||||
/*****************************************
|
||||
SOUND
|
||||
*****************************************/
|
||||
@ -472,7 +431,7 @@ void othunder_state::othunder_map(address_map &map)
|
||||
map(0x220000, 0x22000f).rw(m_tc0100scn, FUNC(tc0100scn_device::ctrl_word_r), FUNC(tc0100scn_device::ctrl_word_w));
|
||||
map(0x300000, 0x300003).rw(this, FUNC(othunder_state::sound_r), FUNC(othunder_state::sound_w));
|
||||
map(0x400000, 0x4005ff).ram().share("spriteram");
|
||||
map(0x500000, 0x500007).rw(this, FUNC(othunder_state::lightgun_r), FUNC(othunder_state::lightgun_w));
|
||||
map(0x500000, 0x500007).rw("adc", FUNC(adc0808_device::data_r), FUNC(adc0808_device::address_offset_start_w)).umask16(0x00ff);
|
||||
map(0x600000, 0x600003).w(this, FUNC(othunder_state::irq_ack_w));
|
||||
}
|
||||
|
||||
@ -489,7 +448,7 @@ void othunder_state::z80_sound_map(address_map &map)
|
||||
map(0xe201, 0xe201).rw(m_tc0140syt, FUNC(tc0140syt_device::slave_comm_r), FUNC(tc0140syt_device::slave_comm_w));
|
||||
map(0xe400, 0xe403).w(this, FUNC(othunder_state::tc0310fam_w)); /* pan */
|
||||
map(0xe600, 0xe600).nopw(); /* ? */
|
||||
map(0xea00, 0xea00).portr(ROTARY_PORT_TAG); /* rotary input */
|
||||
map(0xea00, 0xea00).portr("ROTARY"); /* rotary input */
|
||||
map(0xee00, 0xee00).nopw(); /* ? */
|
||||
map(0xf000, 0xf000).nopw(); /* ? */
|
||||
map(0xf200, 0xf200).w(this, FUNC(othunder_state::sound_bankswitch_w));
|
||||
@ -560,20 +519,20 @@ static INPUT_PORTS_START( othunder )
|
||||
enough and being accurate enough not to miss targets. 20 is too
|
||||
inaccurate, and 10 is too slow. */
|
||||
|
||||
PORT_START(P1X_PORT_TAG)
|
||||
PORT_START("P1X")
|
||||
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(13) PORT_REVERSE PORT_PLAYER(1)
|
||||
|
||||
PORT_START(P1Y_PORT_TAG)
|
||||
PORT_START("P1Y")
|
||||
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_CROSSHAIR(Y, 1.0, -0.057, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(13) PORT_PLAYER(1)
|
||||
|
||||
PORT_START(P2X_PORT_TAG)
|
||||
PORT_START("P2X")
|
||||
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(13) PORT_REVERSE PORT_PLAYER(2)
|
||||
|
||||
PORT_START(P2Y_PORT_TAG)
|
||||
PORT_START("P2Y")
|
||||
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_CROSSHAIR(Y, 1.0, -0.057, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(13) PORT_PLAYER(2)
|
||||
|
||||
/* rotary volume control */
|
||||
PORT_START(ROTARY_PORT_TAG)
|
||||
PORT_START("ROTARY")
|
||||
PORT_CONFNAME( 0x07, 0x07, "Stereo Separation" )
|
||||
PORT_CONFSETTING( 0x07, "Maximum" )
|
||||
PORT_CONFSETTING( 0x03, DEF_STR( High ) )
|
||||
@ -642,31 +601,26 @@ void othunder_state::machine_start()
|
||||
{
|
||||
membank("z80bank")->configure_entries(0, 4, memregion("audiocpu")->base(), 0x4000);
|
||||
|
||||
m_ad_interrupt_timer = timer_alloc(TIMER_AD_INTERRUPT);
|
||||
|
||||
save_item(NAME(m_vblank_irq));
|
||||
save_item(NAME(m_ad_irq));
|
||||
save_item(NAME(m_pan));
|
||||
}
|
||||
|
||||
void othunder_state::machine_reset()
|
||||
{
|
||||
m_vblank_irq = 0;
|
||||
m_ad_irq = 0;
|
||||
}
|
||||
|
||||
MACHINE_CONFIG_START(othunder_state::othunder)
|
||||
|
||||
/* basic machine hardware */
|
||||
MCFG_CPU_ADD("maincpu", M68000, 24000000/2 ) /* 12 MHz */
|
||||
MCFG_CPU_ADD("maincpu", M68000, 24_MHz_XTAL/2)
|
||||
MCFG_CPU_PROGRAM_MAP(othunder_map)
|
||||
MCFG_CPU_VBLANK_INT_DRIVER("screen", othunder_state, vblank_interrupt)
|
||||
|
||||
MCFG_CPU_ADD("audiocpu", Z80,16000000/4 ) /* 4 MHz */
|
||||
MCFG_CPU_ADD("audiocpu", Z80, 16_MHz_XTAL/2/2)
|
||||
MCFG_CPU_PROGRAM_MAP(z80_sound_map)
|
||||
|
||||
MCFG_EEPROM_SERIAL_93C46_ADD("eeprom")
|
||||
|
||||
MCFG_DEVICE_ADD("adc", ADC0808, 16_MHz_XTAL/2/2/8)
|
||||
MCFG_ADC0808_EOC_CB(WRITELINE(othunder_state, adc_eoc_w))
|
||||
MCFG_ADC0808_IN0_CB(IOPORT("P1X"))
|
||||
MCFG_ADC0808_IN1_CB(IOPORT("P1Y"))
|
||||
MCFG_ADC0808_IN2_CB(IOPORT("P2X"))
|
||||
MCFG_ADC0808_IN3_CB(IOPORT("P2Y"))
|
||||
|
||||
MCFG_DEVICE_ADD("tc0220ioc", TC0220IOC, 0)
|
||||
MCFG_TC0220IOC_READ_0_CB(IOPORT("DSWA"))
|
||||
@ -685,6 +639,7 @@ MACHINE_CONFIG_START(othunder_state::othunder)
|
||||
MCFG_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 2*8, 32*8-1)
|
||||
MCFG_SCREEN_UPDATE_DRIVER(othunder_state, screen_update)
|
||||
MCFG_SCREEN_PALETTE("palette")
|
||||
MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(othunder_state, vblank_w))
|
||||
|
||||
MCFG_GFXDECODE_ADD("gfxdecode", "palette", othunder)
|
||||
MCFG_PALETTE_ADD("palette", 4096)
|
||||
|
@ -17,11 +17,6 @@
|
||||
class othunder_state : public driver_device
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
TIMER_AD_INTERRUPT
|
||||
};
|
||||
|
||||
othunder_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: driver_device(mconfig, type, tag),
|
||||
m_spriteram(*this,"spriteram"),
|
||||
@ -45,25 +40,21 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void machine_start() override;
|
||||
virtual void machine_reset() override;
|
||||
virtual void video_start() override;
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
|
||||
|
||||
private:
|
||||
void update_irq();
|
||||
void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, const int *primasks, int y_offs);
|
||||
|
||||
DECLARE_WRITE16_MEMBER(irq_ack_w);
|
||||
DECLARE_WRITE8_MEMBER(eeprom_w);
|
||||
DECLARE_WRITE8_MEMBER(coins_w);
|
||||
DECLARE_READ16_MEMBER(lightgun_r);
|
||||
DECLARE_WRITE16_MEMBER(lightgun_w);
|
||||
DECLARE_WRITE_LINE_MEMBER(adc_eoc_w);
|
||||
DECLARE_WRITE8_MEMBER(sound_bankswitch_w);
|
||||
DECLARE_WRITE16_MEMBER(sound_w);
|
||||
DECLARE_READ16_MEMBER(sound_r);
|
||||
DECLARE_WRITE8_MEMBER(tc0310fam_w);
|
||||
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
INTERRUPT_GEN_MEMBER(vblank_interrupt);
|
||||
DECLARE_WRITE_LINE_MEMBER(vblank_w);
|
||||
|
||||
void othunder_map(address_map &map);
|
||||
void z80_sound_map(address_map &map);
|
||||
@ -85,10 +76,7 @@ private:
|
||||
std::unique_ptr<tempsprite[]> m_spritelist;
|
||||
|
||||
/* misc */
|
||||
int m_vblank_irq;
|
||||
int m_ad_irq;
|
||||
int m_pan[4];
|
||||
emu_timer *m_ad_interrupt_timer;
|
||||
|
||||
/* devices */
|
||||
required_device<cpu_device> m_maincpu;
|
||||
|
Loading…
Reference in New Issue
Block a user