Skip to content

Commit

Permalink
start trying to identify more sound related features on the elan hw (…
Browse files Browse the repository at this point in the history
…nw) + Senario Poker SunPlus (not working) (#5874)

* elan sound stuff (nw)

* move more audio bits into audio  file (nw)

* new NOT WORKING machines
-----
Texas Hold'em TV Poker - 6 Player Edition (UK) [David Haywood,  Morten Kirkegaard, Peter Wilhelmsen]

need to emulate the controllers etc. (currently requires debug hack to boot past initial logo)

* start moving some more elan stuff around (nw)
  • Loading branch information
David Haywood authored and rb6502 committed Nov 8, 2019
1 parent 56a4a69 commit ab39e40
Show file tree
Hide file tree
Showing 11 changed files with 1,343 additions and 851 deletions.
2 changes: 2 additions & 0 deletions scripts/target/mame/mess.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3711,6 +3711,8 @@ files {
MAME_DIR .. "src/mame/video/elan_eu3a05commonvid.h",
MAME_DIR .. "src/mame/video/elan_eu3a05vid.cpp",
MAME_DIR .. "src/mame/video/elan_eu3a05vid.h",
MAME_DIR .. "src/mame/video/elan_eu3a14vid.cpp",
MAME_DIR .. "src/mame/video/elan_eu3a14vid.h",
MAME_DIR .. "src/mame/drivers/trkfldch.cpp",
MAME_DIR .. "src/mame/drivers/tvgame.cpp",
MAME_DIR .. "src/mame/drivers/spg110.cpp",
Expand Down
52 changes: 52 additions & 0 deletions src/devices/machine/spg2xx_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,51 @@ void spg2xx_video_device::draw(const rectangle &cliprect, uint32_t line, uint32_
}
}

void spg2xx_video_device::draw_bitmap(const rectangle& cliprect, uint32_t scanline, int priority, uint32_t bitmap_addr, uint16_t* regs)
{
if ((scanline < 0) || (scanline >= 240))
return;

address_space& space = m_cpu->space(AS_PROGRAM);
const int linewidth = 320 / 2;
int sourcebase = 0x3f0000; // this is correct for Texas Hold'em - TODO: get from a register?

sourcebase++; // why is this needed?
int bitmapline = scanline - 20; // should be from scrolly?

// at least for Texas Hold'em there is only enough memory for this size bitmap, and other reads would be outside of memory and generate excessive logging
// maybe we just need to silence logging instead tho?
if ((bitmapline < 0) || (bitmapline >= 200))
return;

sourcebase += bitmapline * linewidth;

uint32_t* dest = &m_screenbuf[320 * scanline];

for (int i = 0; i < 320 / 2; i++)
{
uint8_t palette_entry;
uint16_t color;
const uint16_t data = space.read_word(sourcebase + i);

palette_entry = (data & 0x00ff);
color = m_paletteram[palette_entry];

if (!(color & 0x8000))
{
dest[(i * 2)+0] = m_rgb555_to_rgb888[color & 0x7fff];
}

palette_entry = (data & 0xff00) >> 8;
color = m_paletteram[palette_entry];

if (!(color & 0x8000))
{
dest[(i * 2)+1] = m_rgb555_to_rgb888[color & 0x7fff];
}
}
}

void spg2xx_video_device::draw_page(const rectangle &cliprect, uint32_t scanline, int priority, uint32_t bitmap_addr, uint16_t *regs)
{
uint32_t xscroll = regs[0];
Expand All @@ -229,6 +274,13 @@ void spg2xx_video_device::draw_page(const rectangle &cliprect, uint32_t scanline
return;
}

if (ctrl & 0x0001) // Bitmap mode!
{
draw_bitmap(cliprect, scanline, priority, bitmap_addr, regs);
return;
}


uint32_t tile_h = 8 << ((attr & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT);
uint32_t tile_w = 8 << ((attr & PAGE_TILE_WIDTH_MASK) >> PAGE_TILE_WIDTH_SHIFT);

Expand Down
1 change: 1 addition & 0 deletions src/devices/machine/spg2xx_video.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class spg2xx_video_device : public device_t

template<blend_enable_t Blend, rowscroll_enable_t RowScroll, flipx_t FlipX>
void draw(const rectangle &cliprect, uint32_t line, uint32_t xoff, uint32_t yoff, uint32_t bitmap_addr, uint16_t tile, int32_t h, int32_t w, uint8_t bpp, uint32_t yflipmask, uint32_t palette_offset);
void draw_bitmap(const rectangle& cliprect, uint32_t scanline, int priority, uint32_t bitmap_addr, uint16_t* regs);
void draw_page(const rectangle &cliprect, uint32_t scanline, int priority, uint32_t bitmap_addr, uint16_t *regs);
void draw_sprite(const rectangle &cliprect, uint32_t scanline, int priority, uint32_t base_addr);
void draw_sprites(const rectangle &cliprect, uint32_t scanline, int priority);
Expand Down
149 changes: 140 additions & 9 deletions src/mame/audio/elan_eu3a05.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,32 @@ DEFINE_DEVICE_TYPE(ELAN_EU3A05_SOUND, elan_eu3a05_sound_device, "elan_eu3a05soun
#include "logmacro.h"


elan_eu3a05_sound_device::elan_eu3a05_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, ELAN_EU3A05_SOUND, tag, owner, clock)
, device_sound_interface(mconfig, *this)
, m_stream(nullptr)
, m_space_read_cb(*this)
elan_eu3a05_sound_device::elan_eu3a05_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, ELAN_EU3A05_SOUND, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_stream(nullptr),
m_space_read_cb(*this),
m_sound_end_cb{ { *this }, { *this }, { *this }, { *this }, { *this }, { *this } }
{
}

void elan_eu3a05_sound_device::device_start()
{
m_space_read_cb.resolve_safe(0);
m_stream = stream_alloc(0, 1, 8000);

for (devcb_write_line &cb : m_sound_end_cb)
cb.resolve_safe();

save_item(NAME(m_sound_byte_address));
save_item(NAME(m_sound_byte_len));
save_item(NAME(m_sound_current_nib_pos));
save_item(NAME(m_isstopped));
save_item(NAME(m_sound_trigger));
save_item(NAME(m_sound_unk));
save_item(NAME(m_volumes));
save_item(NAME(m_5024));
save_item(NAME(m_50a9));
}

void elan_eu3a05_sound_device::device_reset()
Expand All @@ -40,6 +54,15 @@ void elan_eu3a05_sound_device::device_reset()
}

m_isstopped = 0x3f;

m_sound_trigger = 0x00;
m_sound_unk = 0x00;

m_volumes[0] = 0xff;
m_volumes[1] = 0x0f;

m_5024 = 0x00;
m_50a9 = 0x00;
}

//-------------------------------------------------
Expand Down Expand Up @@ -81,8 +104,7 @@ void elan_eu3a05_sound_device::sound_stream_update(sound_stream &stream, stream_
m_sound_current_nib_pos[channel] = 0;
m_isstopped |= (1 << channel);

// maybe should generate an interrupt with vector
// ffb8, ffbc, ffc0, ffc4, ffc8, or ffcc depending on which channel finished??
m_sound_end_cb[channel](1); // generate interrupt based on which channel just stopped?
}
}
else
Expand All @@ -95,6 +117,8 @@ void elan_eu3a05_sound_device::sound_stream_update(sound_stream &stream, stream_
}




void elan_eu3a05_sound_device::handle_sound_addr_w(int which, int offset, uint8_t data)
{
switch (offset)
Expand Down Expand Up @@ -260,8 +284,11 @@ void elan_eu3a05_sound_device::handle_sound_trigger(int which)
{
LOGMASKED( LOG_AUDIO, "Triggering operation on channel (%d) with params %08x %08x\n", which, m_sound_byte_address[which], m_sound_byte_len[which]);

m_sound_current_nib_pos[which] = 0;
m_isstopped &= ~(1 << which);
if (m_isstopped & (1 << which)) // golden tee will repeatedly try to start the music on the title screen (although could depend on a status read first?)
{
m_sound_current_nib_pos[which] = 0;
m_isstopped &= ~(1 << which);
}
}


Expand All @@ -272,3 +299,107 @@ READ8_MEMBER(elan_eu3a05_sound_device::elan_eu3a05_50a8_r)
LOGMASKED( LOG_AUDIO, "%s: elan_eu3a05_50a8_r\n", machine().describe_context());
return m_isstopped;
}

READ8_MEMBER(elan_eu3a05_sound_device::elan_eu3a05_sound_volume_r)
{
return m_volumes[offset];
}

WRITE8_MEMBER(elan_eu3a05_sound_device::elan_eu3a05_sound_volume_w)
{
m_volumes[offset] = data;
}

WRITE8_MEMBER(elan_eu3a05_sound_device::write)
{
switch (offset)
{
case 0x00: case 0x01: case 0x02: // channel 0 address
case 0x03: case 0x04: case 0x05: // channel 1 address
case 0x06: case 0x07: case 0x08: // channel 2 address
case 0x09: case 0x0a: case 0x0b: // channel 3 address
case 0x0c: case 0x0d: case 0x0e: // channel 4 address
case 0x0f: case 0x10: case 0x11: // channel 5 address
elan_eu3a05_sound_addr_w(space, offset, data);
break;

case 0x12: case 0x13: case 0x14: // channel 0 length
case 0x15: case 0x16: case 0x17: // channel 1 length
case 0x18: case 0x19: case 0x1a: // channel 2 length
case 0x1b: case 0x1c: case 0x1d: // channel 3 length
case 0x1e: case 0x1f: case 0x20: // channel 4 length
case 0x21: case 0x22: case 0x23: // channel 5 length
elan_eu3a05_sound_size_w(space, offset - 0x12, data);
break;

case 0x24: // unk
m_5024 = data;
break;

case 0x25: // trigger
elan_eu3a05_sound_trigger_w(space, offset - 0x25, data);
break;

case 0x26: // volume channels 0,1,2,3 ? (lunar rescue sets 0x03 here and 0x00 below and just uses a single channel)
case 0x27: // volume channels 5,6 ?
elan_eu3a05_sound_volume_w(space, offset - 0x26, data);
break;

case 0x28: // stopped status?
LOGMASKED( LOG_AUDIO, "%s: write to stop state register? %02x\n", machine().describe_context(), data);
break;

case 0x29: // interrupt enable? or looping?
m_50a9 = data;
break;
}
}

READ8_MEMBER(elan_eu3a05_sound_device::read)
{
uint8_t ret = 0x00;

switch (offset)
{
case 0x00: case 0x01: case 0x02: // channel 0 address
case 0x03: case 0x04: case 0x05: // channel 1 address
case 0x06: case 0x07: case 0x08: // channel 2 address
case 0x09: case 0x0a: case 0x0b: // channel 3 address
case 0x0c: case 0x0d: case 0x0e: // channel 4 address
case 0x0f: case 0x10: case 0x11: // channel 5 address
ret = elan_eu3a05_sound_addr_r(space, offset);
break;

case 0x12: case 0x13: case 0x14: // channel 0 length
case 0x15: case 0x16: case 0x17: // channel 1 length
case 0x18: case 0x19: case 0x1a: // channel 2 length
case 0x1b: case 0x1c: case 0x1d: // channel 3 length
case 0x1e: case 0x1f: case 0x20: // channel 4 length
case 0x21: case 0x22: case 0x23: // channel 5 length
ret = elan_eu3a05_sound_size_r(space, offset - 0x12);
break;

case 0x24: // unk
ret = m_5024;
break;

case 0x25: // trigger
ret = elan_eu3a05_sound_trigger_r(space, offset - 0x25);
break;

case 0x26: // volume channels 0,1,2,3 ?
case 0x27: // volume channels 5,6 ?
ret = elan_eu3a05_sound_volume_r(space, offset - 0x26);
break;

case 0x28: // stopped status?
ret = elan_eu3a05_50a8_r(space, offset - 0x28);
break;

case 0x29: // interrupt enable? or looping?
ret = m_50a9;
break;
}

return ret;
}
33 changes: 24 additions & 9 deletions src/mame/audio/elan_eu3a05.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@ class elan_eu3a05_sound_device : public device_t, public device_sound_interface

auto space_read_callback() { return m_space_read_cb.bind(); }

DECLARE_WRITE8_MEMBER(elan_eu3a05_sound_addr_w);
DECLARE_READ8_MEMBER(elan_eu3a05_sound_addr_r);
DECLARE_WRITE8_MEMBER(elan_eu3a05_sound_size_w);
DECLARE_READ8_MEMBER(elan_eu3a05_sound_size_r);
DECLARE_READ8_MEMBER(elan_eu3a05_sound_trigger_r);
DECLARE_WRITE8_MEMBER(elan_eu3a05_sound_trigger_w);
DECLARE_READ8_MEMBER(elan_eu3a05_sound_unk_r);
DECLARE_WRITE8_MEMBER(elan_eu3a05_sound_unk_w);
template <unsigned N> auto sound_end_cb() { return m_sound_end_cb[N].bind(); }

DECLARE_WRITE8_MEMBER(write);
DECLARE_READ8_MEMBER(read);

DECLARE_READ8_MEMBER(elan_eu3a05_50a8_r);
protected:
// device-level overrides
virtual void device_start() override;
Expand All @@ -49,12 +44,32 @@ class elan_eu3a05_sound_device : public device_t, public device_sound_interface

uint8_t m_isstopped;

uint8_t m_volumes[2];
uint8_t m_5024;
uint8_t m_50a9;

void handle_sound_trigger(int which);

void handle_sound_addr_w(int which, int offset, uint8_t data);
uint8_t handle_sound_addr_r(int which, int offset);
void handle_sound_size_w(int which, int offset, uint8_t data);
uint8_t handle_sound_size_r(int which, int offset);

DECLARE_WRITE8_MEMBER(elan_eu3a05_sound_addr_w);
DECLARE_READ8_MEMBER(elan_eu3a05_sound_addr_r);
DECLARE_WRITE8_MEMBER(elan_eu3a05_sound_size_w);
DECLARE_READ8_MEMBER(elan_eu3a05_sound_size_r);
DECLARE_READ8_MEMBER(elan_eu3a05_sound_trigger_r);
DECLARE_WRITE8_MEMBER(elan_eu3a05_sound_trigger_w);
DECLARE_READ8_MEMBER(elan_eu3a05_sound_unk_r);
DECLARE_WRITE8_MEMBER(elan_eu3a05_sound_unk_w);

DECLARE_READ8_MEMBER(elan_eu3a05_50a8_r);

DECLARE_READ8_MEMBER(elan_eu3a05_sound_volume_r);
DECLARE_WRITE8_MEMBER(elan_eu3a05_sound_volume_w);

devcb_write_line m_sound_end_cb[6];
};

DECLARE_DEVICE_TYPE(ELAN_EU3A05_SOUND, elan_eu3a05_sound_device)
Expand Down
Loading

0 comments on commit ab39e40

Please sign in to comment.