summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/videogames/video21.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/videogames/video21.cpp')
-rw-r--r--src/mame/videogames/video21.cpp165
1 files changed, 96 insertions, 69 deletions
diff --git a/src/mame/videogames/video21.cpp b/src/mame/videogames/video21.cpp
index 15b1720d7e1..d0cd292eec6 100644
--- a/src/mame/videogames/video21.cpp
+++ b/src/mame/videogames/video21.cpp
@@ -1,6 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:hap
-/****************************************************************************************
+/*******************************************************************************
Video 21 blackjack game
VIDEO-GAMES - LICH/GERMANY 1017a
@@ -11,15 +11,16 @@ The game has sound (there's a LM380N visible), looks like there's a bunch of TTL
involved, and a 555.
TODO:
-- improve sound, it's definitely beeper pitch control, but sounds offtune
+- improve sound, it's definitely beeper pitch control, but sounds off-tune
- identify all dips (7 total)
- confirm CPU clock
When booted, press Key out (mapped to W by default) to get it going.
-*******************************************************************************************/
+*******************************************************************************/
#include "emu.h"
+
#include "cpu/i8085/i8085.h"
#include "machine/nvram.h"
#include "sound/beep.h"
@@ -27,6 +28,7 @@ When booted, press Key out (mapped to W by default) to get it going.
#include "screen.h"
#include "emupal.h"
#include "speaker.h"
+#include "tilemap.h"
#include "video21.lh"
@@ -39,73 +41,96 @@ public:
video21_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_maincpu(*this,"maincpu")
- , m_p_videoram(*this, "videoram")
- , m_p_chargen(*this, "chargen")
, m_beeper(*this, "beeper")
+ , m_gfxdecode(*this, "gfxdecode")
+ , m_videoram(*this, "videoram")
, m_lamps(*this, "lamp%u", 0U)
{ }
void video21(machine_config &config);
- int hopper_coinout_r();
+ int hopper_coinout_r() { return m_hopper_coin; }
protected:
virtual void machine_start() override ATTR_COLD;
+ virtual void video_start() override ATTR_COLD;
private:
required_device<cpu_device> m_maincpu;
- required_shared_ptr<u8> m_p_videoram;
- required_region_ptr<u8> m_p_chargen;
required_device<beep_device> m_beeper;
+ required_device<gfxdecode_device> m_gfxdecode;
+ required_shared_ptr<u8> m_videoram;
output_finder<6> m_lamps;
+ tilemap_t *m_tilemap = nullptr;
+
int m_hopper_motor = 0;
int m_hopper_coin = 0;
emu_timer *m_hopper_timer = nullptr;
- void mem_map(address_map &map) ATTR_COLD;
- void io_map(address_map &map) ATTR_COLD;
+ TILE_GET_INFO_MEMBER(get_tile_info);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
+ void videoram_w(offs_t offset, uint8_t data);
+
+ TIMER_CALLBACK_MEMBER(hopper_coinout);
void sound_w(uint8_t data);
void lamp1_w(uint8_t data);
void lamp2_w(uint8_t data);
- TIMER_CALLBACK_MEMBER(hopper_coinout);
+ void mem_map(address_map &map) ATTR_COLD;
+ void io_map(address_map &map) ATTR_COLD;
};
+void video21_state::machine_start()
+{
+ m_hopper_timer = timer_alloc(FUNC(video21_state::hopper_coinout), this);
-uint32_t video21_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
+ m_lamps.resolve();
+
+ // register for savestates
+ save_item(NAME(m_hopper_motor));
+ save_item(NAME(m_hopper_coin));
+}
+
+
+
+/*******************************************************************************
+ Video
+*******************************************************************************/
+
+static GFXDECODE_START( gfx_video21 )
+ GFXDECODE_ENTRY( "tiles", 0, gfx_8x8x1, 0, 1 )
+GFXDECODE_END
+
+TILE_GET_INFO_MEMBER(video21_state::get_tile_info)
{
- uint16_t sy = 0, ma = 0;
-
- for (uint8_t y = 0; y < 28; y++)
- {
- for (uint8_t ra = 0; ra < 8; ra++)
- {
- uint16_t *p = &bitmap.pix(sy++);
-
- for (uint16_t x = 0; x < 32; x++)
- {
- uint8_t chr = m_p_videoram[x+ma] & 0x7f;
- uint8_t gfx = m_p_chargen[(chr<<3) | ra ];
-
- /* Display a scanline of a character */
- *p++ = BIT(gfx, 7);
- *p++ = BIT(gfx, 6);
- *p++ = BIT(gfx, 5);
- *p++ = BIT(gfx, 4);
- *p++ = BIT(gfx, 3);
- *p++ = BIT(gfx, 2);
- *p++ = BIT(gfx, 1);
- *p++ = BIT(gfx, 0);
- }
- }
- ma += 32;
- }
+ int code = m_videoram[tile_index];
+ tileinfo.set(0, code, 0, 0);
+}
+
+void video21_state::video_start()
+{
+ m_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(video21_state::get_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
+}
+uint32_t video21_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
+{
+ m_tilemap->draw(screen, bitmap, cliprect, 0, 0);
return 0;
}
+void video21_state::videoram_w(offs_t offset, uint8_t data)
+{
+ m_videoram[offset] = data & 0x7f;
+ m_tilemap->mark_tile_dirty(offset);
+}
+
+
+
+/*******************************************************************************
+ I/O
+*******************************************************************************/
+
TIMER_CALLBACK_MEMBER(video21_state::hopper_coinout)
{
m_hopper_coin = param;
@@ -124,9 +149,9 @@ void video21_state::sound_w(uint8_t data)
void video21_state::lamp1_w(uint8_t data)
{
// d1-d3: coincounters
- machine().bookkeeping().coin_counter_w(0, data & 0x04); // coin in
- machine().bookkeeping().coin_counter_w(1, data & 0x08); // keeper coin out
- machine().bookkeeping().coin_counter_w(2, data & 0x02); // hopper coin out
+ machine().bookkeeping().coin_counter_w(0, BIT(data, 2)); // coin in
+ machine().bookkeeping().coin_counter_w(1, BIT(data, 1)); // hopper coin out
+ machine().bookkeeping().coin_counter_w(2, BIT(data, 3)); // keeper coin out
// d4: hopper motor
if (!m_hopper_motor && BIT(data, 4))
@@ -152,10 +177,15 @@ void video21_state::lamp2_w(uint8_t data)
}
+
+/*******************************************************************************
+ Address Maps
+*******************************************************************************/
+
void video21_state::mem_map(address_map &map)
{
map(0x0000,0x0fff).rom().mirror(0x3000);
- map(0xe000,0xe3ff).ram().share("videoram");
+ map(0xe000,0xe3ff).ram().w(FUNC(video21_state::videoram_w)).share(m_videoram);
map(0xff00,0xffff).ram().share("nvram");
}
@@ -170,10 +200,10 @@ void video21_state::io_map(address_map &map)
}
-int video21_state::hopper_coinout_r()
-{
- return m_hopper_coin;
-}
+
+/*******************************************************************************
+ Input Ports
+*******************************************************************************/
static INPUT_PORTS_START( video21 )
PORT_START("IN41")
@@ -230,49 +260,40 @@ static INPUT_PORTS_START( video21 )
INPUT_PORTS_END
-static GFXDECODE_START( gfx_video21 )
- GFXDECODE_ENTRY( "chargen", 0x0000, gfx_8x8x1, 0, 1 )
-GFXDECODE_END
-void video21_state::machine_start()
-{
- m_hopper_timer = timer_alloc(FUNC(video21_state::hopper_coinout), this);
-
- m_lamps.resolve();
-
- // zerofill/register for savestates
- m_hopper_motor = 0;
- m_hopper_coin = 0;
-
- save_item(NAME(m_hopper_motor));
- save_item(NAME(m_hopper_coin));
-}
+/*******************************************************************************
+ Machine Configs
+*******************************************************************************/
void video21_state::video21(machine_config &config)
{
- /* basic machine hardware */
+ // basic machine hardware
I8080A(config, m_maincpu, 20.79_MHz_XTAL / 10); // crystal confirmed but divisor unknown (divider appears to be 74LS160)
m_maincpu->set_addrmap(AS_PROGRAM, &video21_state::mem_map);
m_maincpu->set_addrmap(AS_IO, &video21_state::io_map);
NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);
- /* video hardware */
+ // video hardware
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
- screen.set_color(rgb_t::white());
screen.set_raw(20.79_MHz_XTAL / 4, 330, 0, 32*8, 315, 0, 28*8); // parameters guessed
screen.set_screen_update(FUNC(video21_state::screen_update));
screen.set_palette("palette");
- GFXDECODE(config, "gfxdecode", "palette", gfx_video21);
+ GFXDECODE(config, m_gfxdecode, "palette", gfx_video21);
PALETTE(config, "palette", palette_device::MONOCHROME);
- /* sound hardware */
+ // sound hardware
SPEAKER(config, "mono").front_center();
BEEP(config, m_beeper, 0).add_route(ALL_OUTPUTS, "mono", 0.25);
}
+
+/*******************************************************************************
+ ROM Definitions
+*******************************************************************************/
+
ROM_START( video21 )
ROM_REGION( 0x1000, "maincpu", 0 )
ROM_LOAD_NIB_HIGH( "2", 0x0000, 0x0400, CRC(05585e39) SHA1(7eefb5d63b4499a303ecdcad6af5df9fe9c89205) )
@@ -284,7 +305,7 @@ ROM_START( video21 )
ROM_LOAD_NIB_HIGH( "77", 0x0c00, 0x0400, CRC(3a725b98) SHA1(efa3802025f1f99b45e56abd85dc3d1860d4734d) )
ROM_LOAD_NIB_LOW ( "79", 0x0c00, 0x0400, CRC(044d1bfd) SHA1(5a57c1ab7eb7dd7ed05852e128b704c3b37a87b8) )
- ROM_REGION( 0x0400, "chargen", 0 )
+ ROM_REGION( 0x0400, "tiles", 0 )
ROM_LOAD_NIB_HIGH( "29", 0x0000, 0x0400, CRC(2b70870d) SHA1(1f50a6976e1634020c78f10c1259e38f5e010a86) )
ROM_LOAD_NIB_LOW ( "43", 0x0000, 0x0400, CRC(0ecb0aab) SHA1(7f3f1b93a5d38828ae3e97e5f8ef1a6a96dc798b) )
ROM_END
@@ -292,4 +313,10 @@ ROM_END
} // anonymous namespace
-GAMEL(1980?, video21, 0, video21, video21, video21_state, empty_init, ROT0, "Video Games GmbH", "Video 21", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE, layout_video21)
+
+/*******************************************************************************
+ Drivers
+*******************************************************************************/
+
+// YEAR NAME PARENT MACHINE INPUT CLASS INIT SCREEN COMPANY FULLNAME FLAGS LAYOUT
+GAMEL( 1980?, video21, 0, video21, video21, video21_state, empty_init, ROT0, "Video Games GmbH", "Video 21", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE, layout_video21 )