continued Elan (Plug & Play) refactoring (#5882)

* elan code refactoring (nw)

* save the obvious (nw)

* continued refactoring (nw)

* elan refactoring (nw)

* continued refactor (nw)

* continued elan refactoring (nw)
This commit is contained in:
David Haywood 2019-11-10 22:00:09 +00:00 committed by Robert
parent 072b6b4e63
commit 74155c31bf
8 changed files with 361 additions and 307 deletions

View File

@ -19,12 +19,38 @@ DEFINE_DEVICE_TYPE(ELAN_EU3A05_SOUND, elan_eu3a05_sound_device, "elan_eu3a05soun
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),
device_memory_interface(mconfig, *this),
m_space_config("regs", ENDIANNESS_NATIVE, 8, 6, 0, address_map_constructor(FUNC(elan_eu3a05_sound_device::map), this)),
m_stream(nullptr),
m_space_read_cb(*this),
m_sound_end_cb{ { *this }, { *this }, { *this }, { *this }, { *this }, { *this } }
{
}
device_memory_interface::space_config_vector elan_eu3a05_sound_device::memory_space_config() const
{
return space_config_vector {
std::make_pair(0, &m_space_config)
};
}
void elan_eu3a05_sound_device::map(address_map &map)
{
map(0x00, 0x3f).rw(FUNC(elan_eu3a05_sound_device::read_unmapped), FUNC(elan_eu3a05_sound_device::write_unmapped));
map(0x00, 0x11).rw(FUNC(elan_eu3a05_sound_device::elan_eu3a05_sound_addr_r), FUNC(elan_eu3a05_sound_device::elan_eu3a05_sound_addr_w)); // 6 * 24-bit (3 byte) channel addresses
map(0x12, 0x23).rw(FUNC(elan_eu3a05_sound_device::elan_eu3a05_sound_size_r), FUNC(elan_eu3a05_sound_device::elan_eu3a05_sound_size_w)); // 6 * 24-bit (3 byte) channel lengths
map(0x24, 0x24).rw(FUNC(elan_eu3a05_sound_device::reg50a4_r), FUNC(elan_eu3a05_sound_device::reg50a4_w)); // unknown TODO
map(0x25, 0x25).rw(FUNC(elan_eu3a05_sound_device::elan_eu3a05_sound_trigger_r), FUNC(elan_eu3a05_sound_device::elan_eu3a05_sound_trigger_w));
map(0x26, 0x27).rw(FUNC(elan_eu3a05_sound_device::elan_eu3a05_sound_volume_r), FUNC(elan_eu3a05_sound_device::elan_eu3a05_sound_volume_w)); // 0x26 = volume channels 0,1,2,3 0x27 = volume channels 5,6 (lunar rescue sets 0x03 0x00 and just uses a single channel)
map(0x28, 0x28).r(FUNC(elan_eu3a05_sound_device::elan_eu3a05_50a8_r)); // stopped status? (read only?)
map(0x29, 0x29).rw(FUNC(elan_eu3a05_sound_device::reg50a9_r), FUNC(elan_eu3a05_sound_device::reg50a9_w)); // IRQ mask?
// no other reads/writes seen?
}
void elan_eu3a05_sound_device::device_start()
{
m_space_read_cb.resolve_safe(0);
@ -40,7 +66,7 @@ void elan_eu3a05_sound_device::device_start()
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_50a4));
save_item(NAME(m_50a9));
}
@ -61,7 +87,7 @@ void elan_eu3a05_sound_device::device_reset()
m_volumes[0] = 0xff;
m_volumes[1] = 0x0f;
m_5024 = 0x00;
m_50a4 = 0x00;
m_50a9 = 0x00;
}
@ -104,7 +130,9 @@ void elan_eu3a05_sound_device::sound_stream_update(sound_stream &stream, stream_
m_sound_current_nib_pos[channel] = 0;
m_isstopped |= (1 << channel);
m_sound_end_cb[channel](1); // generate interrupt based on which channel just stopped?
// maybe, seems to match the system IRQ mask when the sound interrupts are enabled?
if (m_50a9 & (1 << channel))
m_sound_end_cb[channel](1); // generate interrupt based on which channel just stopped?
}
}
else
@ -310,96 +338,13 @@ WRITE8_MEMBER(elan_eu3a05_sound_device::elan_eu3a05_sound_volume_w)
m_volumes[offset] = data;
}
WRITE8_MEMBER(elan_eu3a05_sound_device::write)
READ8_MEMBER(elan_eu3a05_sound_device::read_unmapped)
{
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;
}
logerror("%s: elan_eu3a05_sound_device::read_unmapped (offset %02x)\n", machine().describe_context(), offset);
return 0x00;
}
READ8_MEMBER(elan_eu3a05_sound_device::read)
WRITE8_MEMBER(elan_eu3a05_sound_device::write_unmapped)
{
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;
}
logerror("%s: elan_eu3a05_sound_device::write_unmapped (offset %02x) (data %02x)\n", machine().describe_context(), offset, data);
}

View File

@ -11,7 +11,7 @@
// ======================> elan_eu3a05_sound_device
class elan_eu3a05_sound_device : public device_t, public device_sound_interface
class elan_eu3a05_sound_device : public device_t, public device_sound_interface, public device_memory_interface
{
public:
elan_eu3a05_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
@ -20,8 +20,8 @@ public:
template <unsigned N> auto sound_end_cb() { return m_sound_end_cb[N].bind(); }
DECLARE_WRITE8_MEMBER(write);
DECLARE_READ8_MEMBER(read);
void map(address_map& map);
protected:
// device-level overrides
@ -30,6 +30,8 @@ protected:
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
virtual space_config_vector memory_space_config() const override;
const address_space_config m_space_config;
private:
sound_stream *m_stream;
@ -45,7 +47,7 @@ private:
uint8_t m_isstopped;
uint8_t m_volumes[2];
uint8_t m_5024;
uint8_t m_50a4;
uint8_t m_50a9;
void handle_sound_trigger(int which);
@ -66,9 +68,17 @@ private:
DECLARE_READ8_MEMBER(elan_eu3a05_50a8_r);
DECLARE_READ8_MEMBER(reg50a4_r) { return m_50a4; }
DECLARE_WRITE8_MEMBER(reg50a4_w) { m_50a4 = data; }
DECLARE_READ8_MEMBER(reg50a9_r) { return m_50a9; }
DECLARE_WRITE8_MEMBER(reg50a9_w) { m_50a9 = data; }
DECLARE_READ8_MEMBER(elan_eu3a05_sound_volume_r);
DECLARE_WRITE8_MEMBER(elan_eu3a05_sound_volume_w);
DECLARE_WRITE8_MEMBER(write_unmapped);
DECLARE_READ8_MEMBER(read_unmapped);
devcb_write_line m_sound_end_cb[6];
};

View File

@ -223,17 +223,7 @@ void elan_eu3a05_state::elan_eu3a05_map(address_map &map)
map(0x5016, 0x5016).rw(m_sys, FUNC(elan_eu3a05sys_device::elan_eu3a05_dmatrg_r), FUNC(elan_eu3a05sys_device::elan_eu3a05_dmatrg_w));
// 502x - 503x video regs area?
map(0x5020, 0x5026).ram(); // unknown, space invaders sets these to fixed values, tetris has them as 00
map(0x5027, 0x5027).rw(m_vid, FUNC(elan_eu3a05vid_device::elan_eu3a05_vidctrl_r), FUNC(elan_eu3a05vid_device::elan_eu3a05_vidctrl_w));
map(0x5028, 0x5028).ram();
map(0x5029, 0x5029).rw(m_vid, FUNC(elan_eu3a05vid_device::tile_gfxbase_lo_r), FUNC(elan_eu3a05vid_device::tile_gfxbase_lo_w)); // tilebase
map(0x502a, 0x502a).rw(m_vid, FUNC(elan_eu3a05vid_device::tile_gfxbase_hi_r), FUNC(elan_eu3a05vid_device::tile_gfxbase_hi_w)); // tilebase
map(0x502b, 0x502b).rw(m_vid, FUNC(elan_eu3a05vid_device::sprite_gfxbase_lo_r), FUNC(elan_eu3a05vid_device::sprite_gfxbase_lo_w)); // tilebase (spr?)
map(0x502c, 0x502c).rw(m_vid, FUNC(elan_eu3a05vid_device::sprite_gfxbase_hi_r), FUNC(elan_eu3a05vid_device::sprite_gfxbase_hi_w)); // tilebase (spr?)
map(0x502d, 0x502e).rw(m_vid, FUNC(elan_eu3a05vid_device::splitpos_r), FUNC(elan_eu3a05vid_device::splitpos_w)); // split position
map(0x502f, 0x5036).rw(m_vid, FUNC(elan_eu3a05vid_device::tile_scroll_r), FUNC(elan_eu3a05vid_device::tile_scroll_w)); // there are 4 scroll values in here, x scroll, y scroll, xscroll1 for split, xscroll2 for split (eu3a14 can do split too)
// 5037
map(0x5038, 0x5038).ram();
map(0x5020, 0x503f).m(m_vid, FUNC(elan_eu3a05vid_device::map));
// 504x GPIO area?
map(0x5040, 0x5046).rw(m_gpio, FUNC(elan_eu3a05gpio_device::gpio_r), FUNC(elan_eu3a05gpio_device::gpio_w));
@ -244,7 +234,7 @@ void elan_eu3a05_state::elan_eu3a05_map(address_map &map)
map(0x5060, 0x506d).ram(); // read/written by tetris (ADC?)
// 508x sound
map(0x5080, 0x50a9).rw(m_sound, FUNC(elan_eu3a05_sound_device::read), FUNC(elan_eu3a05_sound_device::write));
map(0x5080, 0x50bf).m(m_sound, FUNC(elan_eu3a05_sound_device::map));
//map(0x5000, 0x50ff).ram();
map(0x6000, 0xdfff).m(m_bank, FUNC(address_map_bank_device::amap8));

View File

@ -219,7 +219,7 @@ void elan_eu3a14_state::bank_map(address_map &map)
map(0x000000, 0x3fffff).rom().region("maincpu", 0);
}
void elan_eu3a14_state::radica_eu3a14_map(address_map &map)
void elan_eu3a14_state::radica_eu3a14_map(address_map& map)
{
map(0x0000, 0x01ff).ram();
map(0x0200, 0x3fff).ram().share("mainram"); // 200-9ff is sprites? a00 - ??? is tilemap?
@ -243,7 +243,6 @@ void elan_eu3a14_state::radica_eu3a14_map(address_map &map)
// 5019 - 46 on startup (hnt3) 22 (bb3, foot) na (gtg) 09 (rsg)
// 501a - 01 on startup (hnt3) 03 (bb3, foot) na (gtg) 02,01 (rsg)
// probably GPIO like eu3a05, although it access 47/48 as unknown instead of 48/49/4a
map(0x5040, 0x5040).w(FUNC(elan_eu3a14_state::porta_dir_w));
map(0x5041, 0x5041).portr("IN0").w(FUNC(elan_eu3a14_state::porta_dat_w));
@ -256,60 +255,13 @@ void elan_eu3a14_state::radica_eu3a14_map(address_map &map)
map(0x5047, 0x5047).nopw();
map(0x5048, 0x5048).nopw();
// 5060 - 506e r/w during startup on foot
// 5060 - 506e r/w during startup on foot (adc?)
// sound appears to be the same as eu3a05
map(0x5080, 0x50a9).rw(m_sound, FUNC(elan_eu3a05_sound_device::read), FUNC(elan_eu3a05_sound_device::write));
// 0x5080 - 50bf = SOUND AREA (same as eu5a03?)
map(0x5080, 0x50bf).m(m_sound, FUNC(elan_eu3a05_sound_device::map));
// video regs are in the 51xx range
// huntin'3 seems to use some registers for a windowing / highlight effect on the trophy room names and "Target Range" mode timer??
// 5100 - 0x0f when effect is enabled, 0x00 otherwise?
// 5101 - 0x0e in both modes
// 5102 - 0x86 in both modes
// 5103 - 0x0e in tropy room (left?) / 0x2a in "Target Range" mode (left position?)
// 5104 - trophy room window / highlight top, move with cursor / 0xbf in "Target Range" mode (top?)
// 5105 - 0x52 in trophy room (right?) / counts from 0xa1 to 0x2a in "Target Range" mode (right position?)
// 5106 - trophy room window / highlight bottom, move with cursor / 0xcb in "Target Range" mode (bottom?)
// 5107 - 0x00
// 5108 - 0x04 in both modes
// 5109 - 0xc2 in both modes
map(0x5100, 0x5100).ram();
map(0x5101, 0x5101).ram();
map(0x5102, 0x5102).ram();
map(0x5103, 0x5106).ram();
map(0x5107, 0x5107).ram(); // on transitions, maybe layer disables?
map(0x5108, 0x5109).ram(); // hnt3, frequently rewrites same values, maybe something to do with raster irq?
// layer specific regs?
map(0x5110, 0x5115).rw(m_vid, FUNC(elan_eu3a14vid_device::tilecfg_r), FUNC(elan_eu3a14vid_device::tilecfg_w));
map(0x5116, 0x5117).rw(m_vid, FUNC(elan_eu3a14vid_device::rowscrollcfg_r), FUNC(elan_eu3a14vid_device::rowscrollcfg_w)); // 00 01 in hnt3 (could just be extra tile config bits, purpose guessed) set to 00 05 in rad_gtg overhead part (no rowscroll)
// 0x5118, 0x5119 not used
map(0x511a, 0x511e).rw(m_vid, FUNC(elan_eu3a14vid_device::rowscrollsplit_r), FUNC(elan_eu3a14vid_device::rowscrollsplit_w)); // hnt3 (60 68 78 90 b8 - rowscroll position list see note below
// register value notes for 511a-511e and how they relate to screen
// 00-6f normal scroll reg
// 60-67 is where the first extra scroll reg (rowscrollregs) is onscreen
// 68-77 is the 2nd
// 78-8f is the 3rd
// 90-b7 is the 4th
// b8-ff no scroll?
map(0x5121, 0x5124).rw(m_vid, FUNC(elan_eu3a14vid_device::scrollregs_r), FUNC(elan_eu3a14vid_device::scrollregs_w));
map(0x5125, 0x512c).rw(m_vid, FUNC(elan_eu3a14vid_device::rowscrollregs_r), FUNC(elan_eu3a14vid_device::rowscrollregs_w)); // 4 extra x scroll regs
// layer specific regs?
map(0x5140, 0x5145).rw(m_vid, FUNC(elan_eu3a14vid_device::ramtilecfg_r), FUNC(elan_eu3a14vid_device::ramtilecfg_w)); // hnt3
map(0x5148, 0x514b).ram(); // hnt3 (always 0 tho?)
// sprite specific regs?
map(0x5150, 0x5150).rw(m_vid, FUNC(elan_eu3a14vid_device::spriteaddr_r), FUNC(elan_eu3a14vid_device::spriteaddr_w)); // startup 01 bb3,gtg,rsg, (na) foot 0c hnt3
map(0x5151, 0x5152).rw(m_vid, FUNC(elan_eu3a14vid_device::spritebase_r), FUNC(elan_eu3a14vid_device::spritebase_w));
map(0x5153, 0x5153).ram(); // startup
// 0x5100 - 517f = VIDEO AREA
map(0x5100, 0x517f).m(m_vid, FUNC(elan_eu3a14vid_device::map));
map(0x6000, 0xdfff).m(m_bank, FUNC(address_map_bank_device::amap8));

View File

@ -6,16 +6,42 @@
DEFINE_DEVICE_TYPE(ELAN_EU3A05_VID, elan_eu3a05vid_device, "elan_eu3a05vid", "Elan EU3A05 Video")
// map(0x0600, 0x3dff).ram().share("vram");
// map(0x3e00, 0x3fff).ram().share("spriteram");
// tilemaps start at 0x0600 in mainram, sprites at 0x3e00, unlike eu3a14 these could be fixed addresses
elan_eu3a05vid_device::elan_eu3a05vid_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: elan_eu3a05commonvid_device(mconfig, ELAN_EU3A05_VID, tag, owner, clock),
device_memory_interface(mconfig, *this),
m_cpu(*this, finder_base::DUMMY_TAG),
m_bank(*this, finder_base::DUMMY_TAG)
m_bank(*this, finder_base::DUMMY_TAG),
m_space_config("regs", ENDIANNESS_NATIVE, 8, 5, 0, address_map_constructor(FUNC(elan_eu3a05vid_device::map), this))
{
}
device_memory_interface::space_config_vector elan_eu3a05vid_device::memory_space_config() const
{
return space_config_vector {
std::make_pair(0, &m_space_config)
};
}
void elan_eu3a05vid_device::map(address_map &map)
{
map(0x00, 0x1f).rw(FUNC(elan_eu3a05vid_device::read_unmapped), FUNC(elan_eu3a05vid_device::write_unmapped));
map(0x00, 0x06).ram(); // unknown, space invaders sets these to fixed values, tetris has them as 00
map(0x07, 0x07).rw(FUNC(elan_eu3a05vid_device::elan_eu3a05_vidctrl_r), FUNC(elan_eu3a05vid_device::elan_eu3a05_vidctrl_w));
map(0x08, 0x08).ram(); // unknown
map(0x09, 0x09).rw(FUNC(elan_eu3a05vid_device::tile_gfxbase_lo_r), FUNC(elan_eu3a05vid_device::tile_gfxbase_lo_w));
map(0x0a, 0x0a).rw(FUNC(elan_eu3a05vid_device::tile_gfxbase_hi_r), FUNC(elan_eu3a05vid_device::tile_gfxbase_hi_w));
map(0x0b, 0x0b).rw(FUNC(elan_eu3a05vid_device::sprite_gfxbase_lo_r), FUNC(elan_eu3a05vid_device::sprite_gfxbase_lo_w));
map(0x0c, 0x0c).rw(FUNC(elan_eu3a05vid_device::sprite_gfxbase_hi_r), FUNC(elan_eu3a05vid_device::sprite_gfxbase_hi_w));
map(0x0d, 0x0e).rw(FUNC(elan_eu3a05vid_device::splitpos_r), FUNC(elan_eu3a05vid_device::splitpos_w));
map(0x0f, 0x16).rw(FUNC(elan_eu3a05vid_device::tile_scroll_r), FUNC(elan_eu3a05vid_device::tile_scroll_w));
map(0x17, 0x17).ram(); // unknown
map(0x18, 0x18).ram(); // unknown
// no other writes seen
}
void elan_eu3a05vid_device::device_start()
{
elan_eu3a05commonvid_device::device_start();
@ -565,4 +591,15 @@ WRITE8_MEMBER(elan_eu3a05vid_device::elan_eu3a05_vidctrl_w)
*/
m_vidctrl = data;
}
}
READ8_MEMBER(elan_eu3a05vid_device::read_unmapped)
{
logerror("%s: elan_eu3a05vid_device::read_unmapped (offset %02x)\n", machine().describe_context(), offset);
return 0x00;
}
WRITE8_MEMBER(elan_eu3a05vid_device::write_unmapped)
{
logerror("%s: elan_eu3a05vid_device::write_unmapped (offset %02x) (data %02x)\n", machine().describe_context(), offset, data);
}

View File

@ -8,7 +8,7 @@
#include "cpu/m6502/m6502.h"
#include "machine/bankdev.h"
class elan_eu3a05vid_device : public elan_eu3a05commonvid_device
class elan_eu3a05vid_device : public elan_eu3a05commonvid_device, public device_memory_interface
{
public:
elan_eu3a05vid_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
@ -16,6 +16,42 @@ public:
template <typename T> void set_cpu(T &&tag) { m_cpu.set_tag(std::forward<T>(tag)); }
template <typename T> void set_addrbank(T &&tag) { m_bank.set_tag(std::forward<T>(tag)); }
void map(address_map& map);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual space_config_vector memory_space_config() const override;
private:
required_device<m6502_device> m_cpu;
required_device<address_map_bank_device> m_bank;
const address_space_config m_space_config;
uint8_t m_vidctrl;
uint8_t m_tile_gfxbase_lo_data;
uint8_t m_tile_gfxbase_hi_data;
uint8_t m_sprite_gfxbase_lo_data;
uint8_t m_sprite_gfxbase_hi_data;
uint8_t m_tile_scroll[4*2];
uint8_t m_splitpos[2];
uint16_t get_scroll(int which);
bool get_tile_data(int base, int drawpri, int& tile, int &attr, int &unk2);
void draw_tilemaps(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int drawpri);
void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint8_t read_spriteram(int offset);
uint8_t read_vram(int offset);
// VIDEO
// tile bases
DECLARE_WRITE8_MEMBER(tile_gfxbase_lo_w);
@ -37,38 +73,8 @@ public:
DECLARE_READ8_MEMBER(splitpos_r);
DECLARE_WRITE8_MEMBER(splitpos_w);
uint16_t get_scroll(int which);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
private:
required_device<m6502_device> m_cpu;
required_device<address_map_bank_device> m_bank;
uint8_t m_vidctrl;
uint8_t m_tile_gfxbase_lo_data;
uint8_t m_tile_gfxbase_hi_data;
uint8_t m_sprite_gfxbase_lo_data;
uint8_t m_sprite_gfxbase_hi_data;
uint8_t m_tile_scroll[4*2];
uint8_t m_splitpos[2];
bool get_tile_data(int base, int drawpri, int& tile, int &attr, int &unk2);
void draw_tilemaps(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int drawpri);
void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint8_t read_spriteram(int offset);
uint8_t read_vram(int offset);
DECLARE_READ8_MEMBER(read_unmapped);
DECLARE_WRITE8_MEMBER(write_unmapped);
};
DECLARE_DEVICE_TYPE(ELAN_EU3A05_VID, elan_eu3a05vid_device)

View File

@ -8,26 +8,141 @@ DEFINE_DEVICE_TYPE(ELAN_EU3A14_VID, elan_eu3a14vid_device, "elan_eu3a14vid", "El
elan_eu3a14vid_device::elan_eu3a14vid_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: elan_eu3a05commonvid_device(mconfig, ELAN_EU3A14_VID, tag, owner, clock),
device_memory_interface(mconfig, *this),
m_cpu(*this, finder_base::DUMMY_TAG),
m_bank(*this, finder_base::DUMMY_TAG),
m_screen(*this, finder_base::DUMMY_TAG)
m_screen(*this, finder_base::DUMMY_TAG),
m_space_config("regs", ENDIANNESS_NATIVE, 8, 7, 0, address_map_constructor(FUNC(elan_eu3a14vid_device::map), this))
{
}
device_memory_interface::space_config_vector elan_eu3a14vid_device::memory_space_config() const
{
return space_config_vector {
std::make_pair(0, &m_space_config)
};
}
/* Windowing mode note
huntin'3 seems to use some registers for a windowing / highlight effect on the trophy room names and "Target Range" mode timer??
5100 - 0x0f when effect is enabled, 0x00 otherwise?
5101 - 0x0e in both modes
5102 - 0x86 in both modes
5103 - 0x0e in tropy room (left?) / 0x2a in "Target Range" mode (left position?)
5104 - trophy room window / highlight top, move with cursor / 0xbf in "Target Range" mode (top?)
5105 - 0x52 in trophy room (right?) / counts from 0xa1 to 0x2a in "Target Range" mode (right position?)
5106 - trophy room window / highlight bottom, move with cursor / 0xcb in "Target Range" mode (bottom?)
*/
void elan_eu3a14vid_device::map(address_map &map)
{
map(0x00, 0x7f).rw(FUNC(elan_eu3a14vid_device::read_unmapped), FUNC(elan_eu3a14vid_device::write_unmapped));
map(0x00, 0x06).ram(); // see Windowing note above
map(0x07, 0x07).rw(FUNC(elan_eu3a14vid_device::reg5107_r), FUNC(elan_eu3a14vid_device::reg5107_w)); // writes on transitions, maybe layer disables?
map(0x08, 0x08).rw(FUNC(elan_eu3a14vid_device::reg5108_r), FUNC(elan_eu3a14vid_device::reg5108_w)); // 0x04 in both modes // hnt3, frequently rewrites same values TODO
map(0x09, 0x09).rw(FUNC(elan_eu3a14vid_device::reg5109_r), FUNC(elan_eu3a14vid_device::reg5109_w)); // related to above?
// 0x0a
// 0x0b
// 0x0c
// 0x0d
// 0x0e
// 0x0f
map(0x10, 0x15).rw(FUNC(elan_eu3a14vid_device::tilecfg_r), FUNC(elan_eu3a14vid_device::tilecfg_w));
map(0x16, 0x17).rw(FUNC(elan_eu3a14vid_device::rowscrollcfg_r), FUNC(elan_eu3a14vid_device::rowscrollcfg_w));
// 0x18
// 0x19
map(0x1a, 0x1e).rw(FUNC(elan_eu3a14vid_device::rowscrollsplit_r), FUNC(elan_eu3a14vid_device::rowscrollsplit_w));
// 0x1f
// 0x20
map(0x21, 0x24).rw(FUNC(elan_eu3a14vid_device::scrollregs_r), FUNC(elan_eu3a14vid_device::scrollregs_w)); // 0x21,0x22 = scroll reg 1, 0x23,0x24 = scroll reg 2
map(0x25, 0x2c).rw(FUNC(elan_eu3a14vid_device::rowscrollregs_r), FUNC(elan_eu3a14vid_device::rowscrollregs_w)); // 0x25,0x26 = rowscroll reg 1, 0x27,0x28 = rowscroll reg 2, 0x29,0x2a = rowscroll reg 3, 0x2b,0x2c = rowscroll reg 3
// 0x2d
// 0x2e
// 0x2f
// 0x30
// 0x31
// 0x32
// 0x33
// 0x34
// 0x35
// 0x36
// 0x37
// 0x38
// 0x39
// 0x3a
// 0x3b
// 0x3c
// 0x3d
// 0x3e
// 0x3f
map(0x40, 0x45).rw(FUNC(elan_eu3a14vid_device::ramtilecfg_r), FUNC(elan_eu3a14vid_device::ramtilecfg_w));
// 0x46
// 0x47
map(0x48, 0x4b).ram(); // hnt3 (always 0 tho?)
// 0x4c
// 0x4d
// 0x4e
// 0x4f
map(0x50, 0x50).rw(FUNC(elan_eu3a14vid_device::spriteaddr_r), FUNC(elan_eu3a14vid_device::spriteaddr_w));
map(0x51, 0x52).rw(FUNC(elan_eu3a14vid_device::spritebase_r), FUNC(elan_eu3a14vid_device::spritebase_w));
map(0x53, 0x53).ram(); // startup
// nothing else used?
}
void elan_eu3a14vid_device::device_start()
{
elan_eu3a05commonvid_device::device_start();
save_item(NAME(m_scrollregs));
save_item(NAME(m_tilecfg));
save_item(NAME(m_rowscrollregs));
save_item(NAME(m_rowscrollsplit));
save_item(NAME(m_rowscrollcfg));
save_item(NAME(m_ramtilecfg));
save_item(NAME(m_spritebase));
save_item(NAME(m_5107));
save_item(NAME(m_5108));
save_item(NAME(m_5109));
save_item(NAME(m_spriteaddr));
}
void elan_eu3a14vid_device::device_reset()
{
elan_eu3a05commonvid_device::device_reset();
for (int i = 0; i < 4; i++)
m_scrollregs[i] = 0x00;
for (int i = 0; i < 6; i++)
m_tilecfg[i] = 0x00;
for (int i = 0; i < 8; i++)
m_rowscrollregs[i] = 0x00;
for (int i = 0; i < 5; i++)
m_rowscrollsplit[i] = 0x00;
for (int i = 0; i < 2; i++)
m_rowscrollcfg[i] = 0x00;
for (int i = 0; i < 6; i++)
m_ramtilecfg[i] = 0x00;
for (int i = 0; i < 2; i++)
m_spritebase[i] = 0x00;
m_5107 = 0x00;
m_5108 = 0x00;
m_5109 = 0x00;
m_spriteaddr = 0x14; // ?? rad_foot never writes, other games seem to use it to set sprite location
}
uint8_t elan_eu3a14vid_device::read_vram(int offset)
{
address_space& cpuspace = m_cpu->space(AS_PROGRAM);
@ -65,6 +180,22 @@ uint8_t elan_eu3a14vid_device::read_gfxdata(int offset, int x)
return fullbankspace.read_byte((offset+x) & 0x3fffff);
}
uint8_t elan_eu3a14vid_device::readpix(int baseaddr, int count, int drawfromram)
{
int pix;
if (drawfromram)
{
pix = read_vram((baseaddr + count) & 0x3fff);
}
else
{
address_space& fullbankspace = m_bank->space(AS_PROGRAM);
pix = fullbankspace.read_byte((baseaddr+count) & 0x3fffff);
}
return pix;
}
void elan_eu3a14vid_device::draw_background_tile(bitmap_ind16& bitmap, const rectangle& cliprect, int bpp, int tileno, int palette, int priority, int flipx, int flipy, int xpos, int ypos, int transpen, int size, int base, int drawfromram)
{
int baseaddr = base * 256;
@ -105,7 +236,6 @@ void elan_eu3a14vid_device::draw_background_tile(bitmap_ind16& bitmap, const rec
return;
}
int count = 0;
for (int y = 0; y < size; y++)
{
@ -127,18 +257,6 @@ void elan_eu3a14vid_device::draw_background_tile(bitmap_ind16& bitmap, const rec
for (int x = 0; x < xstride; x++)
{
int pix;
if (drawfromram)
{
pix = read_vram((baseaddr + count) & 0x3fff);
}
else
{
address_space& fullbankspace = m_bank->space(AS_PROGRAM);
pix = fullbankspace.read_byte((baseaddr+count) & 0x3fffff);
}
if (realy >= cliprect.min_y && realy <= cliprect.max_y)
{
if (bpp == 8) // 8bpp
@ -146,6 +264,8 @@ void elan_eu3a14vid_device::draw_background_tile(bitmap_ind16& bitmap, const rec
int realx = x + xposwithscroll;
if (realx >= cliprect.min_x && realx <= cliprect.max_x)
{
uint8_t pix = readpix(baseaddr, count, drawfromram);
if (pix)
{
if (pridst[realx] <= priority)
@ -172,29 +292,30 @@ void elan_eu3a14vid_device::draw_background_tile(bitmap_ind16& bitmap, const rec
else if (bpp == 4) // 4bpp
{
int realx = (x * 2) + xposwithscroll;
if (realx >= cliprect.min_x && realx <= cliprect.max_x)
{
if (pix & 0xf0)
{
if (pridst[realx] <= priority)
{
dst[realx] = ((pix & 0xf0) >> 4) | palette;
pridst[realx] = priority;
}
}
}
realx++;
if (realx >= cliprect.min_x && realx <= cliprect.max_x)
if (((realx + 1) >= cliprect.min_x) || (realx <= cliprect.max_x))
{
if (pix & 0x0f)
uint8_t pix = readpix(baseaddr, count, drawfromram);
int mask = 0xf0;
int shift = 4;
for (int i = 0; i < 4; i++)
{
if (pridst[realx] <= priority)
if (realx >= cliprect.min_x && realx <= cliprect.max_x)
{
dst[realx] = (pix & 0x0f) | palette;
pridst[realx] = priority;
if (pix & mask)
{
if (pridst[realx] <= priority)
{
dst[realx] = ((pix & mask) >> shift) | palette;
pridst[realx] = priority;
}
}
}
mask >>= 4;
shift -= 4;
realx++;
}
}
}
@ -205,57 +326,31 @@ void elan_eu3a14vid_device::draw_background_tile(bitmap_ind16& bitmap, const rec
else if (bpp == 2) // 2bpp (hnt3 ram text)
{
int realx = (x * 4) + xposwithscroll;
if (realx >= cliprect.min_x && realx <= cliprect.max_x)
if (((realx + 3) >= cliprect.min_x) || (realx <= cliprect.max_x))
{
if (pix & 0xc0)
uint8_t pix = readpix(baseaddr, count, drawfromram);
int mask = 0xc0;
int shift = 6;
for (int i = 0; i < 4; i++)
{
if (pridst[realx] <= priority)
if (realx >= cliprect.min_x && realx <= cliprect.max_x)
{
dst[realx] = ((pix & 0xc0) >> 6) | palette;
pridst[realx] = priority;
if (pix & 0xc0)
{
if (pridst[realx] <= priority)
{
dst[realx] = ((pix & mask) >> shift) | palette;
pridst[realx] = priority;
}
}
}
}
}
realx++;
if (realx >= cliprect.min_x && realx <= cliprect.max_x)
{
if (pix & 0x30)
{
if (pridst[realx] <= priority)
{
dst[realx] = ((pix & 0x30) >> 4) | palette;
pridst[realx] = priority;
}
}
}
realx++;
if (realx >= cliprect.min_x && realx <= cliprect.max_x)
{
if (pix & 0x0c)
{
if (pridst[realx] <= priority)
{
dst[realx] = ((pix & 0x0c) >> 2) | palette;
pridst[realx] = priority;
}
}
}
realx++;
if (realx >= cliprect.min_x && realx <= cliprect.max_x)
{
if (pix & 0x03)
{
if (pridst[realx] <= priority)
{
dst[realx] = ((pix & 0x03) >> 0) | palette;
pridst[realx] = priority;
}
realx++;
mask >>= 2;
shift -= 2;
}
}
}
@ -674,8 +769,6 @@ void elan_eu3a14vid_device::draw_sprite_line(screen_device &screen, bitmap_ind16
void elan_eu3a14vid_device::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
// first 4 sprite entries seem to be garbage sprites, so we start at 0x20
// likely we're just interpreting them wrong and they're used for blanking things or clipping?
for (int i = m_spriterambase; i < m_spriterambase + 0x800; i += 8)
{
/*
@ -763,4 +856,13 @@ void elan_eu3a14vid_device::draw_sprites(screen_device &screen, bitmap_ind16 &bi
}
}
}
READ8_MEMBER(elan_eu3a14vid_device::read_unmapped)
{
logerror("%s: elan_eu3a14vid_device::read_unmapped (offset %02x)\n", machine().describe_context(), offset);
return 0x00;
}
WRITE8_MEMBER(elan_eu3a14vid_device::write_unmapped)
{
logerror("%s: elan_eu3a14vid_device::write_unmapped (offset %02x) (data %02x)\n", machine().describe_context(), offset, data);
}

View File

@ -9,7 +9,7 @@
#include "machine/bankdev.h"
#include "screen.h"
class elan_eu3a14vid_device : public elan_eu3a05commonvid_device
class elan_eu3a14vid_device : public elan_eu3a05commonvid_device, public device_memory_interface
{
public:
elan_eu3a14vid_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
@ -18,11 +18,30 @@ public:
template <typename T> void set_addrbank(T &&tag) { m_bank.set_tag(std::forward<T>(tag)); }
template <typename T> void set_screen(T &&tag) { m_screen.set_tag(std::forward<T>(tag)); }
void map(address_map& map);
void set_tilerambase(int tilerambase) { m_tilerambase = tilerambase; }
void video_start();
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual space_config_vector memory_space_config() const override;
private:
required_device<m6502_device> m_cpu;
required_device<address_map_bank_device> m_bank;
required_device<screen_device> m_screen;
const address_space_config m_space_config;
inline uint8_t read_gfxdata(int offset, int x);
inline uint8_t read_vram(int offset);
inline uint8_t readpix(int baseaddr, int count, int drawfromram);
DECLARE_READ8_MEMBER(tilecfg_r) { return m_tilecfg[offset]; }
DECLARE_WRITE8_MEMBER(tilecfg_w) { m_tilecfg[offset] = data; }
DECLARE_READ8_MEMBER(ramtilecfg_r) { return m_ramtilecfg[offset]; }
@ -33,22 +52,22 @@ public:
DECLARE_WRITE8_MEMBER(scrollregs_w) { m_scrollregs[offset] = data; }
DECLARE_READ8_MEMBER(rowscrollregs_r) { return m_rowscrollregs[offset]; }
DECLARE_WRITE8_MEMBER(rowscrollregs_w) { m_rowscrollregs[offset] = data; }
DECLARE_READ8_MEMBER(spriteaddr_r) { return m_spriteaddr; }
DECLARE_WRITE8_MEMBER(spriteaddr_w) { m_spriteaddr = data; }
DECLARE_READ8_MEMBER(spritebase_r) { return m_spritebase[offset]; }
DECLARE_WRITE8_MEMBER(spritebase_w) { m_spritebase[offset] = data; }
DECLARE_READ8_MEMBER(rowscrollsplit_r) { return m_rowscrollsplit[offset]; }
DECLARE_WRITE8_MEMBER(rowscrollsplit_w) { m_rowscrollsplit[offset] = data; }
DECLARE_READ8_MEMBER(spriteaddr_r) { return m_spriteaddr; }
DECLARE_WRITE8_MEMBER(spriteaddr_w) { m_spriteaddr = data; }
DECLARE_READ8_MEMBER(reg5107_r) { return m_5107; }
DECLARE_WRITE8_MEMBER(reg5107_w) { m_5107 = data; }
DECLARE_READ8_MEMBER(reg5108_r) { return m_5108; }
DECLARE_WRITE8_MEMBER(reg5108_w) { m_5108 = data; }
DECLARE_READ8_MEMBER(reg5109_r) { return m_5109; }
DECLARE_WRITE8_MEMBER(reg5109_w) { m_5109 = data; }
int m_tilerambase;
int m_spriterambase;
bitmap_ind8 m_prioritybitmap;
DECLARE_READ8_MEMBER(read_unmapped);
DECLARE_WRITE8_MEMBER(write_unmapped);
void draw_background_ramlayer(screen_device& screen, bitmap_ind16& bitmap, const rectangle& cliprect);
int get_xscroll_for_screenypos(int line);
@ -59,21 +78,6 @@ public:
void draw_sprite_line(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int offset, int line, int pal, int flipx, int pri, int xpos, int ypos, int bpp);
void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
private:
required_device<m6502_device> m_cpu;
required_device<address_map_bank_device> m_bank;
required_device<screen_device> m_screen;
uint8_t read_gfxdata(int offset, int x);
uint8_t read_vram(int offset);
uint8_t m_scrollregs[4];
uint8_t m_tilecfg[6];
uint8_t m_rowscrollregs[8];
@ -83,6 +87,14 @@ private:
uint8_t m_spriteaddr;
uint8_t m_spritebase[2];
uint8_t m_5107;
uint8_t m_5108;
uint8_t m_5109;
int m_tilerambase;
int m_spriterambase;
bitmap_ind8 m_prioritybitmap;
};
DECLARE_DEVICE_TYPE(ELAN_EU3A14_VID, elan_eu3a14vid_device)