diff options
Diffstat (limited to 'src/devices/machine/vrender0.cpp')
-rw-r--r-- | src/devices/machine/vrender0.cpp | 176 |
1 files changed, 79 insertions, 97 deletions
diff --git a/src/devices/machine/vrender0.cpp b/src/devices/machine/vrender0.cpp index c60a8908207..34ba7fb31bb 100644 --- a/src/devices/machine/vrender0.cpp +++ b/src/devices/machine/vrender0.cpp @@ -35,18 +35,17 @@ DEFINE_DEVICE_TYPE(VRENDER0_SOC, vrender0soc_device, "vrender0", "MagicEyes VRen // vrender0soc_device - constructor //------------------------------------------------- -vrender0soc_device::vrender0soc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, VRENDER0_SOC, tag, owner, clock), +vrender0soc_device::vrender0soc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, VRENDER0_SOC, tag, owner, clock), m_host_cpu(*this, finder_base::DUMMY_TAG), m_screen(*this, "screen"), m_palette(*this, "palette"), m_vr0vid(*this, "vr0vid"), m_vr0snd(*this, "vr0snd"), - m_lspeaker(*this, "lspeaker"), - m_rspeaker(*this, "rspeaker"), + m_speaker(*this, "speaker"), m_uart(*this, "uart%u", 0), m_crtcregs(*this, "crtcregs"), - write_tx{ { *this }, { *this } } + write_tx(*this) { } @@ -98,9 +97,19 @@ void vrender0soc_device::regs_map(address_map &map) void vrender0soc_device::audiovideo_map(address_map &map) { map(0x00000000, 0x0000ffff).m(m_vr0vid, FUNC(vr0video_device::regs_map)); - map(0x00800000, 0x00ffffff).rw(FUNC(vrender0soc_device::textureram_r), FUNC(vrender0soc_device::textureram_w)); - map(0x01000000, 0x017fffff).rw(FUNC(vrender0soc_device::frameram_r), FUNC(vrender0soc_device::frameram_w)); - map(0x01800000, 0x01800fff).rw(m_vr0snd, FUNC(vr0sound_device::vr0_snd_read), FUNC(vr0sound_device::vr0_snd_write)); + map(0x00800000, 0x00ffffff).m(FUNC(vrender0soc_device::texture_map)); + map(0x01000000, 0x017fffff).m(FUNC(vrender0soc_device::frame_map)); + map(0x01800000, 0x01800fff).m(m_vr0snd, FUNC(vr0sound_device::sound_map)); +} + +void vrender0soc_device::texture_map(address_map &map) +{ + map(0x000000, 0x7fffff).rw(FUNC(vrender0soc_device::textureram_r), FUNC(vrender0soc_device::textureram_w)); +} + +void vrender0soc_device::frame_map(address_map &map) +{ + map(0x000000, 0x7fffff).rw(FUNC(vrender0soc_device::frameram_r), FUNC(vrender0soc_device::frameram_w)); } //------------------------------------------------- @@ -115,24 +124,24 @@ void vrender0soc_device::device_add_mconfig(machine_config &config) SCREEN(config, m_screen, SCREEN_TYPE_RASTER); // evolution soccer defaults - m_screen->set_raw((XTAL(14'318'180)*2)/4, 455, 0, 320, 262, 0, 240); + m_screen->set_raw((XTAL(14'318'181)*2)/4, 455, 0, 320, 262, 0, 240); m_screen->set_screen_update(FUNC(vrender0soc_device::screen_update)); m_screen->screen_vblank().set(FUNC(vrender0soc_device::screen_vblank)); m_screen->set_palette(m_palette); - VIDEO_VRENDER0(config, m_vr0vid, 14318180); - #ifdef IDLE_LOOP_SPEEDUP - m_vr0vid->idleskip_cb().set(FUNC(vrender0soc_device::idle_skip_speedup_w)); - #endif + // runs at double speed wrt of the CPU clock + VIDEO_VRENDER0(config, m_vr0vid, DERIVED_CLOCK(2, 1)); PALETTE(config, m_palette, palette_device::RGB_565); - SPEAKER(config, m_lspeaker).front_left(); - SPEAKER(config, m_rspeaker).front_right(); + SPEAKER(config, m_speaker, 2).front(); - SOUND_VRENDER0(config, m_vr0snd, 0); - m_vr0snd->add_route(0, m_lspeaker, 1.0); - m_vr0snd->add_route(1, m_rspeaker, 1.0); + SOUND_VRENDER0(config, m_vr0snd, DERIVED_CLOCK(1,1)); // Correct? + m_vr0snd->set_addrmap(vr0sound_device::AS_TEXTURE, &vrender0soc_device::texture_map); + m_vr0snd->set_addrmap(vr0sound_device::AS_FRAME, &vrender0soc_device::frame_map); + m_vr0snd->irq_callback().set(FUNC(vrender0soc_device::soundirq_cb)); + m_vr0snd->add_route(0, m_speaker, 1.0, 0); + m_vr0snd->add_route(1, m_speaker, 1.0, 1); } @@ -142,24 +151,21 @@ void vrender0soc_device::device_add_mconfig(machine_config &config) void vrender0soc_device::device_start() { - int i; - m_textureram = auto_alloc_array_clear(machine(), uint16_t, 0x00800000/2); - m_frameram = auto_alloc_array_clear(machine(), uint16_t, 0x00800000/2); + m_textureram = make_unique_clear<uint16_t []>(0x00800000/2); + m_frameram = make_unique_clear<uint16_t []>(0x00800000/2); - m_vr0vid->set_areas(m_textureram, m_frameram); - m_vr0snd->set_areas(m_textureram, m_frameram); + m_vr0vid->set_areas(m_textureram.get(), m_frameram.get()); m_host_space = &m_host_cpu->space(AS_PROGRAM); if (this->clock() == 0) fatalerror("%s: bus clock not setup properly",this->tag()); - for (i = 0; i < 4; i++) - m_Timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vrender0soc_device::Timercb),this), (void*)(uintptr_t)i); + m_Timer[0] = timer_alloc(FUNC(vrender0soc_device::Timercb<0>), this); + m_Timer[1] = timer_alloc(FUNC(vrender0soc_device::Timercb<1>), this); + m_Timer[2] = timer_alloc(FUNC(vrender0soc_device::Timercb<2>), this); + m_Timer[3] = timer_alloc(FUNC(vrender0soc_device::Timercb<3>), this); - for (auto &cb : write_tx) - cb.resolve_safe(); - - for (i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) { m_uart[i]->set_channel_num(i); m_uart[i]->set_parent(this); @@ -180,10 +186,6 @@ void vrender0soc_device::device_start() save_item(NAME(m_dma[1].src)); save_item(NAME(m_dma[1].dst)); save_item(NAME(m_dma[1].size)); - -#ifdef IDLE_LOOP_SPEEDUP - save_item(NAME(m_FlipCntRead)); -#endif } void vrender0soc_device::write_line_tx(int port, uint8_t value) @@ -214,10 +216,6 @@ void vrender0soc_device::device_reset() m_timer_control[i] = 0xff << 8; m_Timer[i]->adjust(attotime::never); } - -#ifdef IDLE_LOOP_SPEEDUP - m_FlipCntRead = 0; -#endif } @@ -231,22 +229,22 @@ void vrender0soc_device::device_reset() * */ -READ16_MEMBER(vrender0soc_device::textureram_r) +uint16_t vrender0soc_device::textureram_r(offs_t offset) { return m_textureram[offset]; } -WRITE16_MEMBER(vrender0soc_device::textureram_w) +void vrender0soc_device::textureram_w(offs_t offset, uint16_t data, uint16_t mem_mask) { COMBINE_DATA(&m_textureram[offset]); } -READ16_MEMBER(vrender0soc_device::frameram_r) +uint16_t vrender0soc_device::frameram_r(offs_t offset) { return m_frameram[offset]; } -WRITE16_MEMBER(vrender0soc_device::frameram_w) +void vrender0soc_device::frameram_w(offs_t offset, uint16_t data, uint16_t mem_mask) { COMBINE_DATA(&m_frameram[offset]); } @@ -257,12 +255,12 @@ WRITE16_MEMBER(vrender0soc_device::frameram_w) * */ -READ32_MEMBER(vrender0soc_device::intvec_r) +uint32_t vrender0soc_device::intvec_r() { return (m_IntHigh & 7) << 8; } -WRITE32_MEMBER(vrender0soc_device::intvec_w) +void vrender0soc_device::intvec_w(offs_t offset, uint32_t data, uint32_t mem_mask) { if (ACCESSING_BITS_0_7) { @@ -274,12 +272,12 @@ WRITE32_MEMBER(vrender0soc_device::intvec_w) m_IntHigh = (data >> 8) & 7; } -READ32_MEMBER( vrender0soc_device::inten_r ) +uint32_t vrender0soc_device::inten_r() { return m_inten; } -WRITE32_MEMBER( vrender0soc_device::inten_w ) +void vrender0soc_device::inten_w(offs_t offset, uint32_t data, uint32_t mem_mask) { COMBINE_DATA(&m_inten); // P'S Attack has a timer 0 irq service with no call to intvec_w but just this @@ -288,12 +286,12 @@ WRITE32_MEMBER( vrender0soc_device::inten_w ) m_host_cpu->set_input_line(SE3208_INT, CLEAR_LINE); } -READ32_MEMBER( vrender0soc_device::intst_r ) +uint32_t vrender0soc_device::intst_r() { return m_intst; } -WRITE32_MEMBER( vrender0soc_device::intst_w ) +void vrender0soc_device::intst_w(uint32_t data) { // TODO: contradicts with documentation, games writes to this? // ... @@ -306,14 +304,10 @@ void vrender0soc_device::IntReq( int num ) m_intst |= (1 << num); m_host_cpu->set_input_line(SE3208_INT, ASSERT_LINE); } - -#ifdef IDLE_LOOP_SPEEDUP - idle_skip_resume_w(ASSERT_LINE); -#endif } -int vrender0soc_device::irq_callback() +uint8_t vrender0soc_device::irq_callback() { for (int i = 0; i < 32; ++i) { @@ -326,6 +320,14 @@ int vrender0soc_device::irq_callback() } +void vrender0soc_device::soundirq_cb(int state) +{ + if (state) + { + IntReq(2); + } +} + /* * * Timer @@ -344,27 +346,27 @@ void vrender0soc_device::TimerStart(int which) // printf("timer %d start, PD = %x TCV = %x period = %s\n", which, PD, TCV, period.as_string()); } +template<int Which> TIMER_CALLBACK_MEMBER(vrender0soc_device::Timercb) { - int which = (int)(uintptr_t)ptr; static const int num[] = { 0, 1, 9, 10 }; - if (m_timer_control[which] & 2) - TimerStart(which); + if (m_timer_control[Which] & 2) + TimerStart(Which); else - m_timer_control[which] &= ~1; + m_timer_control[Which] &= ~1; - IntReq(num[which]); + IntReq(num[Which]); } template<int Which> -READ32_MEMBER(vrender0soc_device::tmcon_r) +uint32_t vrender0soc_device::tmcon_r() { return m_timer_control[Which]; } template<int Which> -WRITE32_MEMBER(vrender0soc_device::tmcon_w) +void vrender0soc_device::tmcon_w(offs_t offset, uint32_t data, uint32_t mem_mask) { uint32_t old = m_timer_control[Which]; data = COMBINE_DATA(&m_timer_control[Which]); @@ -385,13 +387,13 @@ WRITE32_MEMBER(vrender0soc_device::tmcon_w) } template<int Which> -READ16_MEMBER(vrender0soc_device::tmcnt_r) +uint16_t vrender0soc_device::tmcnt_r() { return m_timer_count[Which] & 0xffff; } template<int Which> -WRITE16_MEMBER(vrender0soc_device::tmcnt_w) +void vrender0soc_device::tmcnt_w(offs_t offset, uint16_t data, uint16_t mem_mask) { COMBINE_DATA(&m_timer_count[Which]); } @@ -411,15 +413,15 @@ inline int vrender0soc_device::dma_setup_hold(uint8_t setting, uint8_t bitmask) return setting & bitmask ? 0 : (setting & 2) ? 4 : (1 << (setting & 1)); } -template<int Which> READ32_MEMBER(vrender0soc_device::dmasa_r) { return m_dma[Which].src; } -template<int Which> WRITE32_MEMBER(vrender0soc_device::dmasa_w) { COMBINE_DATA(&m_dma[Which].src); } -template<int Which> READ32_MEMBER(vrender0soc_device::dmada_r) { return m_dma[Which].dst; } -template<int Which> WRITE32_MEMBER(vrender0soc_device::dmada_w) { COMBINE_DATA(&m_dma[Which].dst); } -template<int Which> READ32_MEMBER(vrender0soc_device::dmatc_r) { return m_dma[Which].size; } -template<int Which> WRITE32_MEMBER(vrender0soc_device::dmatc_w) { COMBINE_DATA(&m_dma[Which].size); } -template<int Which> READ32_MEMBER(vrender0soc_device::dmac_r) { return m_dma[Which].ctrl; } +template<int Which> uint32_t vrender0soc_device::dmasa_r() { return m_dma[Which].src; } +template<int Which> void vrender0soc_device::dmasa_w(offs_t offset, uint32_t data, uint32_t mem_mask) { COMBINE_DATA(&m_dma[Which].src); } +template<int Which> uint32_t vrender0soc_device::dmada_r() { return m_dma[Which].dst; } +template<int Which> void vrender0soc_device::dmada_w(offs_t offset, uint32_t data, uint32_t mem_mask) { COMBINE_DATA(&m_dma[Which].dst); } +template<int Which> uint32_t vrender0soc_device::dmatc_r() { return m_dma[Which].size; } +template<int Which> void vrender0soc_device::dmatc_w(offs_t offset, uint32_t data, uint32_t mem_mask) { COMBINE_DATA(&m_dma[Which].size); } +template<int Which> uint32_t vrender0soc_device::dmac_r() { return m_dma[Which].ctrl; } template<int Which> -WRITE32_MEMBER(vrender0soc_device::dmac_w) +void vrender0soc_device::dmac_w(offs_t offset, uint32_t data, uint32_t mem_mask) { if (((data ^ m_dma[Which].ctrl) & (1 << 10)) && (data & (1 << 10))) //DMAOn { @@ -471,7 +473,7 @@ WRITE32_MEMBER(vrender0soc_device::dmac_w) * */ -READ32_MEMBER(vrender0soc_device::crtc_r) +uint32_t vrender0soc_device::crtc_r(offs_t offset) { uint32_t res = m_crtcregs[offset]; uint32_t hdisp = (m_crtcregs[0x0c / 4] + 1); @@ -497,7 +499,7 @@ READ32_MEMBER(vrender0soc_device::crtc_r) return res; } -WRITE32_MEMBER(vrender0soc_device::crtc_w) +void vrender0soc_device::crtc_w(offs_t offset, uint32_t data, uint32_t mem_mask) { if (((m_crtcregs[0] & 0x0100) == 0x0100) && (offset > 0) && (offset < 0x28/4)) // Write protect return; @@ -663,7 +665,7 @@ void vrender0soc_device::crtc_update() } // accessed by cross puzzle -READ32_MEMBER(vrender0soc_device::sysid_r) +uint32_t vrender0soc_device::sysid_r() { // Device ID: VRender0+ -> 0x0a // Revision Number -> 0x00 @@ -671,7 +673,7 @@ READ32_MEMBER(vrender0soc_device::sysid_r) return 0x00000a00; } -READ32_MEMBER(vrender0soc_device::cfgr_r) +uint32_t vrender0soc_device::cfgr_r() { // TODO: this truly needs real HW verification, // only Cross Puzzle reads this so far so leaving a logerror @@ -702,35 +704,15 @@ uint32_t vrender0soc_device::screen_update(screen_device &screen, bitmap_ind16 & return 0; } -WRITE_LINE_MEMBER(vrender0soc_device::screen_vblank) +void vrender0soc_device::screen_vblank(int state) { // rising edge if (state) { if (crt_active_vblank_irq() == true) + { IntReq(24); //VRender0 VBlank - - m_vr0vid->execute_flipping(); + m_vr0vid->execute_flipping(); + } } } - -/* - * - * Hacks - * - */ - -#ifdef IDLE_LOOP_SPEEDUP -WRITE_LINE_MEMBER(vrender0soc_device::idle_skip_resume_w) -{ - m_FlipCntRead = 0; - m_host_cpu->resume(SUSPEND_REASON_SPIN); -} - -WRITE_LINE_MEMBER(vrender0soc_device::idle_skip_speedup_w) -{ - m_FlipCntRead++; - if (m_FlipCntRead >= 16 && irq_pending() == false && state == ASSERT_LINE) - m_host_cpu->suspend(SUSPEND_REASON_SPIN, 1); -} -#endif |