unkhorse: fix AM_MIRROR problem + small cleanup

This commit is contained in:
hap 2016-06-17 19:30:18 +02:00
parent 402f0c86ab
commit 150877cf4c

View File

@ -22,8 +22,7 @@ TODO:
#include "emu.h"
#include "cpu/i8085/i8085.h"
#include "machine/i8155.h"
#include "sound/dac.h"
#include "sound/speaker.h"
class horse_state : public driver_device
{
@ -31,35 +30,38 @@ public:
horse_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_dac(*this, "dac"),
m_speaker(*this, "speaker"),
m_inp_matrix(*this, "IN"),
m_video_ram(*this, "video_ram"),
m_color_ram(*this, "color_ram") { }
m_color_ram(*this, "color_ram")
{ }
required_device<cpu_device> m_maincpu;
required_device<dac_device> m_dac;
required_device<speaker_sound_device> m_speaker;
required_ioport_array<4> m_inp_matrix;
required_shared_ptr<UINT8> m_video_ram;
required_shared_ptr<UINT8> m_color_ram;
UINT8 m_output;
DECLARE_READ8_MEMBER(cram_trampoline_r) { return m_color_ram[offset & ~0x60]; }
DECLARE_WRITE8_MEMBER(cram_trampoline_w) { m_color_ram[offset & ~0x60] = data; }
DECLARE_READ8_MEMBER(input_r);
DECLARE_WRITE8_MEMBER(output_w);
DECLARE_WRITE_LINE_MEMBER(timer_out);
virtual void machine_start() override;
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(interrupt);
};
void horse_state::machine_start()
{
save_item(NAME(m_output));
}
/***************************************************************************
Video
@ -84,6 +86,7 @@ UINT32 horse_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, c
}
/***************************************************************************
I/O
@ -94,7 +97,7 @@ static ADDRESS_MAP_START( horse_map, AS_PROGRAM, 8, horse_state )
AM_RANGE(0x0000, 0x37ff) AM_ROM
AM_RANGE(0x4000, 0x40ff) AM_DEVREADWRITE("i8155", i8155_device, memory_r, memory_w)
AM_RANGE(0x6000, 0x7fff) AM_RAM AM_SHARE("video_ram")
AM_RANGE(0x8000, 0x879f) AM_RAM AM_SHARE("color_ram") AM_MIRROR(0x0860)
AM_RANGE(0x8000, 0x87ff) AM_READWRITE(cram_trampoline_r, cram_trampoline_w) AM_SHARE("color_ram") AM_MIRROR(0x0800)
ADDRESS_MAP_END
static ADDRESS_MAP_START( horse_io_map, AS_IO, 8, horse_state )
@ -104,15 +107,7 @@ ADDRESS_MAP_END
READ8_MEMBER(horse_state::input_r)
{
switch (m_output >> 6 & 3)
{
case 0: return ioport("IN0")->read();
case 1: return ioport("IN1")->read();
case 2: return ioport("IN2")->read();
default: break;
}
return 0xff;
return m_inp_matrix[m_output >> 6 & 3]->read();
}
WRITE8_MEMBER(horse_state::output_w)
@ -124,10 +119,7 @@ WRITE8_MEMBER(horse_state::output_w)
// other bits: ?
}
WRITE_LINE_MEMBER(horse_state::timer_out)
{
m_dac->write_signed8(state ? 0x7f : 0);
}
/***************************************************************************
@ -136,7 +128,7 @@ WRITE_LINE_MEMBER(horse_state::timer_out)
***************************************************************************/
static INPUT_PORTS_START( horse )
PORT_START("IN0")
PORT_START("IN.0")
PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:1,2,3")
PORT_DIPSETTING( 0x01, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) )
@ -158,7 +150,7 @@ static INPUT_PORTS_START( horse )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("IN1")
PORT_START("IN.1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
@ -168,7 +160,7 @@ static INPUT_PORTS_START( horse )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("IN2")
PORT_START("IN.2")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
@ -177,9 +169,13 @@ static INPUT_PORTS_START( horse )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_TILT )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_START("IN.3")
PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
INPUT_PORTS_END
/***************************************************************************
Machine Config
@ -200,11 +196,10 @@ static MACHINE_CONFIG_START( horse, horse_state )
MCFG_CPU_IO_MAP(horse_io_map)
MCFG_CPU_VBLANK_INT_DRIVER("screen", horse_state, interrupt)
MCFG_DEVICE_ADD("i8155", I8155, XTAL_12MHz / 2)
MCFG_DEVICE_ADD("i8155", I8155, XTAL_12MHz / 2) // port A input, B output, C output but unused
MCFG_I8155_IN_PORTA_CB(READ8(horse_state, input_r))
MCFG_I8155_OUT_PORTB_CB(WRITE8(horse_state, output_w))
//port C output (but unused)
MCFG_I8155_OUT_TIMEROUT_CB(WRITELINE(horse_state, timer_out))
MCFG_I8155_OUT_TIMEROUT_CB(DEVWRITELINE("speaker", speaker_sound_device, level_w))
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
@ -214,17 +209,16 @@ static MACHINE_CONFIG_START( horse, horse_state )
MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
MCFG_SCREEN_UPDATE_DRIVER(horse_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
MCFG_PALETTE_ADD_3BIT_BGR("palette")
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_DAC_ADD("dac")
MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
MACHINE_CONFIG_END
/***************************************************************************
Game drivers