Skip to content

Commit

Permalink
forte2, unkhorse: small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
happppp committed Aug 9, 2023
1 parent d94d4b3 commit f70bc8e
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 160 deletions.
136 changes: 72 additions & 64 deletions src/mame/misc/unkhorse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// copyright-holders:hap, Tomasz Slanina
/*******************************************************************************
unknown Japanese horse gambling game
probably early 80s, manufacturer unknown
unknown Japanese horse gambling game
probably early 80s, manufacturer unknown
from a broken PCB, labeled EFI TG-007
8085A CPU + 8155 (for I/O and sound)
8KB RAM mainly for bitmap video, and 512x4 RAM for color map
from a broken PCB, labeled EFI TG-007
M5L8085AP CPU + M5L8155P (for I/O and sound)
8KB RAM mainly for bitmap video, and 512x4 RAM for color map
TODO:
- identify game!
Expand Down Expand Up @@ -38,37 +38,40 @@ class horse_state : public driver_device
horse_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_speaker(*this, "speaker"),
m_inputs(*this, "IN.%u", 0),
m_vram(*this, "vram")
m_i8155(*this, "i8155"),
m_screen(*this, "screen"),
m_vram(*this, "vram"),
m_colorram(*this, "colorram", 0x200, ENDIANNESS_LITTLE),
m_inputs(*this, "IN.%u", 0)
{ }

void horse(machine_config &config);

protected:
virtual void machine_start() override;

private:
required_device<cpu_device> m_maincpu;
required_device<speaker_sound_device> m_speaker;
required_device<i8155_device> m_i8155;
required_device<screen_device> m_screen;
required_shared_ptr<u8> m_vram;
memory_share_creator<u8> m_colorram;
required_ioport_array<4> m_inputs;
required_shared_ptr<uint8_t> m_vram;

std::unique_ptr<uint8_t[]> m_colorram;
uint8_t m_output = 0;
u8 m_output = 0;

uint8_t colorram_r(offs_t offset) { return m_colorram[(offset >> 2 & 0x1e0) | (offset & 0x1f)] | 0x0f; }
void colorram_w(offs_t offset, uint8_t data) { m_colorram[(offset >> 2 & 0x1e0) | (offset & 0x1f)] = data & 0xf0; }
uint8_t input_r();
void output_w(uint8_t data);
u8 colorram_r(offs_t offset) { return m_colorram[(offset >> 2 & 0x1e0) | (offset & 0x1f)] | 0x0f; }
void colorram_w(offs_t offset, u8 data) { m_colorram[(offset >> 2 & 0x1e0) | (offset & 0x1f)] = data & 0xf0; }
u8 input_r();
void output_w(u8 data);

virtual void machine_start() override;
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void horse_io_map(address_map &map);
void horse_map(address_map &map);
};

void horse_state::machine_start()
{
m_colorram = std::make_unique<uint8_t []>(0x200);
save_pointer(NAME(m_colorram), 0x200);
save_item(NAME(m_output));
}

Expand All @@ -78,14 +81,14 @@ void horse_state::machine_start()
Video
*******************************************************************************/

uint32_t horse_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
u32 horse_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
{
for (int x = 0; x < 32; x++)
{
uint8_t data = m_vram[y << 5 | x];
uint8_t color = m_colorram[(y << 1 & 0x1e0) | x] >> 4;
u8 data = m_vram[y << 5 | x];
u8 color = m_colorram[(y << 1 & 0x1e0) | x] >> 4;

for (int i = 0; i < 8; i++)
bitmap.pix(y, x << 3 | i) = (data >> i & 1) ? color : 0;
Expand All @@ -101,32 +104,36 @@ uint32_t horse_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap,
I/O
*******************************************************************************/

void horse_state::horse_map(address_map &map)
u8 horse_state::input_r()
{
map(0x0000, 0x37ff).rom();
map(0x4000, 0x40ff).rw("i8155", FUNC(i8155_device::memory_r), FUNC(i8155_device::memory_w));
map(0x6000, 0x7fff).ram().share("vram");
map(0x8000, 0x87ff).mirror(0x0800).rw(FUNC(horse_state::colorram_r), FUNC(horse_state::colorram_w));
return m_inputs[m_output >> 6 & 3]->read();
}

void horse_state::horse_io_map(address_map &map)
void horse_state::output_w(u8 data)
{
map(0x40, 0x47).rw("i8155", FUNC(i8155_device::io_r), FUNC(i8155_device::io_w));
// d4: payout related
// d6-d7: input mux
// other bits: ?
m_output = data;
}


uint8_t horse_state::input_r()

/*******************************************************************************
Address Maps
*******************************************************************************/

void horse_state::horse_map(address_map &map)
{
return m_inputs[m_output >> 6 & 3]->read();
map(0x0000, 0x37ff).rom();
map(0x4000, 0x40ff).rw(m_i8155, FUNC(i8155_device::memory_r), FUNC(i8155_device::memory_w));
map(0x6000, 0x7fff).ram().share("vram");
map(0x8000, 0x87ff).mirror(0x0800).rw(FUNC(horse_state::colorram_r), FUNC(horse_state::colorram_w));
}

void horse_state::output_w(uint8_t data)
void horse_state::horse_io_map(address_map &map)
{
m_output = data;

// d4: payout related
// d6-d7: input mux
// other bits: ?
map(0x40, 0x47).rw(m_i8155, FUNC(i8155_device::io_r), FUNC(i8155_device::io_w));
}


Expand All @@ -138,14 +145,14 @@ void horse_state::output_w(uint8_t data)
static INPUT_PORTS_START( horse )
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 ) )
PORT_DIPSETTING( 0x03, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x04, DEF_STR( 1C_4C ) )
PORT_DIPSETTING( 0x05, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x06, DEF_STR( 1C_6C ) )
PORT_DIPSETTING( 0x07, DEF_STR( 1C_7C ) )
PORT_DIPSETTING( 0x00, "1 Coin/10 Credits" )
PORT_DIPSETTING( 0x01, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x03, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x04, DEF_STR( 1C_4C ) )
PORT_DIPSETTING( 0x05, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x06, DEF_STR( 1C_6C ) )
PORT_DIPSETTING( 0x07, DEF_STR( 1C_7C ) )
PORT_DIPSETTING( 0x00, "1 Coin/10 Credits" )
PORT_DIPNAME( 0x08, 0x08, "UNK04" ) PORT_DIPLOCATION("SW:4")
PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
Expand Down Expand Up @@ -190,30 +197,31 @@ INPUT_PORTS_END

void horse_state::horse(machine_config &config)
{
/* basic machine hardware */
I8085A(config, m_maincpu, XTAL(12'000'000) / 2);
// basic machine hardware
I8085A(config, m_maincpu, 12_MHz_XTAL / 2);
m_maincpu->set_addrmap(AS_PROGRAM, &horse_state::horse_map);
m_maincpu->set_addrmap(AS_IO, &horse_state::horse_io_map);

i8155_device &i8155(I8155(config, "i8155", XTAL(12'000'000) / 4)); // port A input, B output, C output but unused
i8155.in_pa_callback().set(FUNC(horse_state::input_r));
i8155.out_pb_callback().set(FUNC(horse_state::output_w));
i8155.out_to_callback().set("speaker", FUNC(speaker_sound_device::level_w));

/* video hardware */
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_refresh_hz(60);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
screen.set_size(32*8, 32*8);
screen.set_visarea(0*8, 32*8-1, 1*8, 31*8-1);
screen.set_screen_update(FUNC(horse_state::screen_update));
screen.screen_vblank().set_inputline(m_maincpu, I8085_RST75_LINE);
screen.set_palette("palette");
I8155(config, m_i8155, 12_MHz_XTAL / 4); // port A input, B output, C output but unused
m_i8155->in_pa_callback().set(FUNC(horse_state::input_r));
m_i8155->out_pb_callback().set(FUNC(horse_state::output_w));
m_i8155->out_to_callback().set("speaker", FUNC(speaker_sound_device::level_w));

// video hardware
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_refresh_hz(60);
m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0));
m_screen->set_size(32*8, 32*8);
m_screen->set_visarea(0*8, 32*8-1, 1*8, 31*8-1);
m_screen->set_screen_update(FUNC(horse_state::screen_update));
m_screen->screen_vblank().set_inputline(m_maincpu, I8085_RST75_LINE);
m_screen->set_palette("palette");

PALETTE(config, "palette", palette_device::BGR_3BIT);

/* sound hardware */
// sound hardware
SPEAKER(config, "mono").front_center();
SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "mono", 0.25);
SPEAKER_SOUND(config, "speaker").add_route(ALL_OUTPUTS, "mono", 0.25);
}


Expand Down
19 changes: 9 additions & 10 deletions src/mame/msx/big10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class big10_state : public driver_device
* Input Ports Demux & Common Routines *
****************************************/


void big10_state::mux_w(uint8_t data)
{
m_mux_data = ~data;
Expand Down Expand Up @@ -138,7 +137,7 @@ void big10_state::main_map(address_map &map)
void big10_state::main_io(address_map &map)
{
map.global_mask(0xff);
map(0x00, 0x00).r(FUNC(big10_state::mux_r)); // present in test mode
map(0x00, 0x00).r(FUNC(big10_state::mux_r)); // present in test mode
map(0x02, 0x02).portr("SYSTEM"); // coins and service
map(0x98, 0x9b).rw("v9938", FUNC(v9938_device::read), FUNC(v9938_device::write));
map(0xa0, 0xa1).w("aysnd", FUNC(ay8910_device::address_data_w));
Expand All @@ -157,8 +156,8 @@ static INPUT_PORTS_START( big10 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MEMORY_RESET )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) // in test mode, go to the game whilst keep pressed.
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) // in test mode, go to the game whilst keep pressed.
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) // in test mode, go to the game whilst keep pressed.
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) // "
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_IMPULSE(2)

Expand Down Expand Up @@ -188,7 +187,7 @@ static INPUT_PORTS_START( big10 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_GAMBLE_HIGH ) PORT_NAME("Big")
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_GAMBLE_LOW ) PORT_NAME("Small")
PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) // in test mode triggers a sound and screen turns black, hanging the game.
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) // in test mode triggers a sound and screen turns black, hanging the game.

PORT_START("IN4")
PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
Expand Down Expand Up @@ -234,12 +233,14 @@ INPUT_PORTS_END
void big10_state::big10(machine_config &config)
{
// basic machine hardware
Z80(config, m_maincpu, MASTER_CLOCK/6); // guess
Z80(config, m_maincpu, MASTER_CLOCK/6); // guess
m_maincpu->set_addrmap(AS_PROGRAM, &big10_state::main_map);
m_maincpu->set_addrmap(AS_IO, &big10_state::main_io);

NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);

TICKET_DISPENSER(config, m_hopper, attotime::from_msec(HOPPER_PULSE), TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_LOW);

// video hardware
v9938_device &v9938(V9938(config, "v9938", MASTER_CLOCK));
v9938.set_screen_ntsc("screen");
Expand All @@ -249,13 +250,11 @@ void big10_state::big10(machine_config &config)

// sound hardware
SPEAKER(config, "mono").front_center();
ym2149_device &aysnd(YM2149(config, "aysnd", MASTER_CLOCK/12)); // guess
ym2149_device &aysnd(YM2149(config, "aysnd", MASTER_CLOCK/12)); // guess
aysnd.port_a_read_callback().set_ioport("DSW2");
aysnd.port_b_read_callback().set_ioport("DSW1");
aysnd.port_a_write_callback().set(FUNC(big10_state::mux_w));
aysnd.add_route(ALL_OUTPUTS, "mono", 0.30);

TICKET_DISPENSER(config, m_hopper, attotime::from_msec(HOPPER_PULSE), TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_LOW);
}


Expand All @@ -277,5 +276,5 @@ ROM_END
* Game Driver(s) *
**************************************/

/* YEAR NAME PARENT MACHINE INPUT STATE INIT ROT COMPANY FULLNAME FLAGS */
// YEAR NAME PARENT MACHINE INPUT STATE INIT ROT COMPANY FULLNAME FLAGS
GAME( 1985, big10, 0, big10, big10, big10_state, empty_init, ROT0, "Success", "Big 10", MACHINE_SUPPORTS_SAVE )
Loading

0 comments on commit f70bc8e

Please sign in to comment.