diff options
Diffstat (limited to 'src/mame/machine/xavix.cpp')
-rw-r--r-- | src/mame/machine/xavix.cpp | 193 |
1 files changed, 117 insertions, 76 deletions
diff --git a/src/mame/machine/xavix.cpp b/src/mame/machine/xavix.cpp index 5ad392d7c2c..698ae5c7e62 100644 --- a/src/mame/machine/xavix.cpp +++ b/src/mame/machine/xavix.cpp @@ -4,46 +4,36 @@ #include "emu.h" #include "includes/xavix.h" +// #define VERBOSE 1 +#include "logmacro.h" + // general DMA to/from entire main map (not dedicated sprite DMA) WRITE8_MEMBER(xavix_state::rom_dmatrg_w) { if (data & 0x01) // namcons2 writes 0x81, most of the time things write 0x01 { - logerror("%s: rom_dmatrg_w (do DMA?) %02x\n", machine().describe_context(), data); + LOG("%s: rom_dmatrg_w (do DMA?) %02x\n", machine().describe_context(), data); uint32_t source = (m_rom_dma_src[2] << 16) | (m_rom_dma_src[1] << 8) | m_rom_dma_src[0]; uint16_t dest = (m_rom_dma_dst[1] << 8) | m_rom_dma_dst[0]; uint16_t len = (m_rom_dma_len[1] << 8) | m_rom_dma_len[0]; - logerror(" (possible DMA op SRC %08x DST %04x LEN %04x)\n", source, dest, len); - - address_space& destspace = m_maincpu->space(AS_PROGRAM); + LOG(" (possible DMA op SRC %08x DST %04x LEN %04x)\n", source, dest, len); for (int i = 0; i < len; i++) { - uint32_t m_tmpaddress = source+i; + uint32_t m_tmpaddress = source + i; // many games explicitly want to access with the high bank bit set, so probably the same logic as when grabbing tile data // we have to be careful here or we get the zero page memory read, hence not just using read8 on the whole space // this again probably indicates there is 'data space' where those don't appear - uint8_t dat = 0; - // if bank is > 0x80, or address is >0x8000 it's a plain ROM read - if ((m_tmpaddress >= 0x80000) || (m_tmpaddress & 0x8000)) - { - dat= m_rgn[m_tmpaddress & (m_rgnlen - 1)]; - } - else - { - address_space& mainspace = m_maincpu->space(AS_PROGRAM); - dat = m_lowbus->read8(mainspace, m_tmpaddress & 0x7fff); - } - - destspace.write_byte(dest + i, dat); + uint8_t dat = m_maincpu->read_full_special(m_tmpaddress); + m_maincpu->write_full_data(dest+i, dat); } } else // the interrupt routine writes 0x80 to the trigger, maybe 'clear IRQ?' { - logerror("%s: rom_dmatrg_w (unknown) %02x\n", machine().describe_context(), data); + LOG("%s: rom_dmatrg_w (unknown) %02x\n", machine().describe_context(), data); } } @@ -51,26 +41,26 @@ WRITE8_MEMBER(xavix_state::rom_dmatrg_w) WRITE8_MEMBER(xavix_state::rom_dmasrc_w) { // has_wamg expects to be able to read back the source to modify it (need to check if it expects it to change after an operation) - logerror("%s: rom_dmasrc_w (%02x) %02x\n", machine().describe_context(), offset, data); + LOG("%s: rom_dmasrc_w (%02x) %02x\n", machine().describe_context(), offset, data); m_rom_dma_src[offset] = data; } WRITE8_MEMBER(xavix_state::rom_dmadst_w) { - logerror("%s: rom_dmadst_w (%02x) %02x\n", machine().describe_context(), offset, data); + LOG("%s: rom_dmadst_w (%02x) %02x\n", machine().describe_context(), offset, data); m_rom_dma_dst[offset] = data; } WRITE8_MEMBER(xavix_state::rom_dmalen_w) { - logerror("%s: rom_dmalen_w (%02x) %02x\n", machine().describe_context(), offset, data); + LOG("%s: rom_dmalen_w (%02x) %02x\n", machine().describe_context(), offset, data); m_rom_dma_len[offset] = data; } READ8_MEMBER(xavix_state::rom_dmastat_r) { - logerror("%s: rom_dmastat_r (operation status?)\n", machine().describe_context()); + LOG("%s: rom_dmastat_r (operation status?)\n", machine().describe_context()); return 0x00; } @@ -78,87 +68,87 @@ READ8_MEMBER(xavix_state::rom_dmastat_r) WRITE8_MEMBER(xavix_state::vector_enable_w) { - logerror("%s: vector_enable_w %02x\n", machine().describe_context(), data); + LOG("%s: vector_enable_w %02x\n", machine().describe_context(), data); m_vectorenable = data; } WRITE8_MEMBER(xavix_state::nmi_vector_lo_w) { - logerror("%s: nmi_vector_lo_w %02x\n", machine().describe_context(), data); + LOG("%s: nmi_vector_lo_w %02x\n", machine().describe_context(), data); m_nmi_vector_lo_data = data; } WRITE8_MEMBER(xavix_state::nmi_vector_hi_w) { - logerror("%s: nmi_vector_hi_w %02x\n", machine().describe_context(), data); + LOG("%s: nmi_vector_hi_w %02x\n", machine().describe_context(), data); m_nmi_vector_hi_data = data; } WRITE8_MEMBER(xavix_state::irq_vector_lo_w) { - logerror("%s: irq_vector_lo_w %02x\n", machine().describe_context(), data); + LOG("%s: irq_vector_lo_w %02x\n", machine().describe_context(), data); m_irq_vector_lo_data = data; } WRITE8_MEMBER(xavix_state::irq_vector_hi_w) { - logerror("%s: irq_vector_hi_w %02x\n", machine().describe_context(), data); + LOG("%s: irq_vector_hi_w %02x\n", machine().describe_context(), data); m_irq_vector_hi_data = data; } WRITE8_MEMBER(xavix_state::extintrf_7900_w) { - logerror("%s: extintrf_7900_w %02x (---FIRST WRITE ON STARTUP---)\n", machine().describe_context(), data); + LOG("%s: extintrf_7900_w %02x (---FIRST WRITE ON STARTUP---)\n", machine().describe_context(), data); } WRITE8_MEMBER(xavix_state::extintrf_7901_w) { - logerror("%s: extintrf_7901_w %02x\n", machine().describe_context(), data); + LOG("%s: extintrf_7901_w %02x\n", machine().describe_context(), data); } WRITE8_MEMBER(xavix_state::extintrf_7902_w) { - logerror("%s: extintrf_7902_w %02x\n", machine().describe_context(), data); + LOG("%s: extintrf_7902_w %02x\n", machine().describe_context(), data); } WRITE8_MEMBER(xavix_state::xavix_7a80_w) { - logerror("%s: xavix_7a80_w %02x\n", machine().describe_context(), data); + LOG("%s: xavix_7a80_w %02x\n", machine().describe_context(), data); } WRITE8_MEMBER(xavix_state::adc_7b00_w) { - logerror("%s: adc_7b00_w %02x\n", machine().describe_context(), data); + LOG("%s: adc_7b00_w %02x\n", machine().describe_context(), data); } READ8_MEMBER(xavix_state::adc_7b80_r) { - logerror("%s: adc_7b80_r\n", machine().describe_context()); + LOG("%s: adc_7b80_r\n", machine().describe_context()); return 0x00;//0xff; } WRITE8_MEMBER(xavix_state::adc_7b80_w) { - logerror("%s: adc_7b80_w %02x\n", machine().describe_context(), data); + LOG("%s: adc_7b80_w %02x\n", machine().describe_context(), data); } WRITE8_MEMBER(xavix_state::adc_7b81_w) { - logerror("%s: adc_7b81_w %02x\n", machine().describe_context(), data); + LOG("%s: adc_7b81_w %02x\n", machine().describe_context(), data); } READ8_MEMBER(xavix_state::adc_7b81_r) { - return 0x00; -// return machine().rand(); +// has_wamg polls this if interrupt is enabled + return machine().rand(); } WRITE8_MEMBER(xavix_state::slotreg_7810_w) { - logerror("%s: slotreg_7810_w %02x\n", machine().describe_context(), data); + LOG("%s: slotreg_7810_w %02x\n", machine().describe_context(), data); } @@ -169,8 +159,11 @@ TIMER_DEVICE_CALLBACK_MEMBER(xavix_state::scanline_cb) INTERRUPT_GEN_MEMBER(xavix_state::interrupt) { - if (m_6ff8 & 0x20) - m_maincpu->pulse_input_line(INPUT_LINE_NMI, attotime::zero); + if (m_video_ctrl & 0x20) + { + m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); + m_video_ctrl |= 0x80; + } } @@ -178,31 +171,71 @@ INTERRUPT_GEN_MEMBER(xavix_state::interrupt) WRITE8_MEMBER(xavix_state::colmix_6ff2_w) { - logerror("%s: colmix_6ff2_w %02x\n", machine().describe_context(), data); + LOG("%s: colmix_6ff2_w %02x\n", machine().describe_context(), data); + m_colmix_ctrl[0] = data; } READ8_MEMBER(xavix_state::dispctrl_6ff8_r) { - //logerror("%s: dispctrl_6ff8_r\n", machine().describe_context()); - return m_6ff8; + // 0x80 = main IRQ asserted flag + // 0x40 = raster IRQ asserted flag + // 0x20 = main IRQ enable + // 0x10 = raster IRQ enable? + + //LOG("%s: dispctrl_6ff8_r\n", machine().describe_context()); + return m_video_ctrl; } WRITE8_MEMBER(xavix_state::dispctrl_6ff8_w) { // I think this is something to do with IRQ ack / enable - m_6ff8 = data; - logerror("%s: dispctrl_6ff8_w %02x\n", machine().describe_context(), data); + + // 0x80 = main IRQ ack? + // 0x40 = raster IRQ ack? + // 0x20 = main IRQ enable + // 0x10 = raster IRQ enable? + + if (data & 0x40) + { + m_maincpu->set_input_line(0, CLEAR_LINE); + } + + if (data & 0x80) + { + m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); + } + + m_video_ctrl = data & 0x3f; + // printf("%s: dispctrl_6ff8_w %02x\n", machine().describe_context(), data); +} + + +TIMER_CALLBACK_MEMBER(xavix_state::interrupt_gen) +{ + if (m_video_ctrl & 0x10) + { + //printf("callback on scanline %d %d with IRQ enabled\n", m_screen->vpos(), m_screen->hpos()); + m_maincpu->set_input_line(0, ASSERT_LINE); + m_video_ctrl |= 0x40; + m_screen->update_partial(m_screen->vpos()); + } + m_interrupt_timer->adjust(attotime::never, 0); } + WRITE8_MEMBER(xavix_state::dispctrl_posirq_x_w) { - logerror("%s: dispctrl_posirq_x_w %02x\n", machine().describe_context(), data); + LOG("%s: dispctrl_posirq_x_w %02x\n", machine().describe_context(), data); + m_posirq_x[0] = data; } WRITE8_MEMBER(xavix_state::dispctrl_posirq_y_w) { - logerror("%s: dispctrl_posirq_y_w %02x\n", machine().describe_context(), data); + LOG("%s: dispctrl_posirq_y_w %02x\n", machine().describe_context(), data); + m_posirq_y[0] = data; + + m_interrupt_timer->adjust(m_screen->time_until_pos(m_posirq_y[0], m_posirq_x[0]), 0); } READ8_MEMBER(xavix_state::io0_data_r) @@ -245,13 +278,13 @@ READ8_MEMBER(xavix_state::io1_direction_r) WRITE8_MEMBER(xavix_state::io0_data_w) { m_io0_data = data; - logerror("%s: io0_data_w %02x\n", machine().describe_context(), data); + LOG("%s: io0_data_w %02x\n", machine().describe_context(), data); } WRITE8_MEMBER(xavix_state::io1_data_w) { m_io1_data = data; - logerror("%s: io1_data_w %02x\n", machine().describe_context(), data); + LOG("%s: io1_data_w %02x\n", machine().describe_context(), data); if (m_i2cmem) { @@ -270,76 +303,81 @@ WRITE8_MEMBER(xavix_state::io1_data_w) WRITE8_MEMBER(xavix_state::io0_direction_w) { m_io0_direction = data; - logerror("%s: io0_direction_w %02x\n", machine().describe_context(), data); - io0_data_w(space,0,m_io0_data); + LOG("%s: io0_direction_w %02x\n", machine().describe_context(), data); + io0_data_w(space, 0, m_io0_data); } WRITE8_MEMBER(xavix_state::io1_direction_w) { m_io1_direction = data; - logerror("%s: io1_direction_w %02x\n", machine().describe_context(), data); - io1_data_w(space,0,m_io1_data); // requires this for i2cmem to work, is it correct tho? + LOG("%s: io1_direction_w %02x\n", machine().describe_context(), data); + io1_data_w(space, 0, m_io1_data); // requires this for i2cmem to work, is it correct tho? } READ8_MEMBER(xavix_state::arena_start_r) { - //logerror("%s: arena_start_r\n", machine().describe_context()); + //LOG("%s: arena_start_r\n", machine().describe_context()); return m_arena_start; } WRITE8_MEMBER(xavix_state::arena_start_w) { - logerror("%s: arena_start_w %02x\n", machine().describe_context(), data); + LOG("%s: arena_start_w %02x\n", machine().describe_context(), data); m_arena_start = data; // expected to return data written } READ8_MEMBER(xavix_state::arena_end_r) { - logerror("%s: arena_end_r\n", machine().describe_context()); + LOG("%s: arena_end_r\n", machine().describe_context()); return m_arena_end; } WRITE8_MEMBER(xavix_state::arena_end_w) { - logerror("%s: arena_end_w %02x\n", machine().describe_context(), data); + LOG("%s: arena_end_w %02x\n", machine().describe_context(), data); m_arena_end = data; // expected to return data written } READ8_MEMBER(xavix_state::arena_control_r) { - m_arena_control ^= 0x40; // unknown, xavtenni expects this to become high, also seems to be running in some kind of interlace mode, so could be a field flag? + // xavtenni expects 0x40 to go high (interlace related?) + m_arena_control ^= 0x40; return m_arena_control; } WRITE8_MEMBER(xavix_state::arena_control_w) { - logerror("%s: arena_control_w %02x\n", machine().describe_context(), data); + LOG("%s: arena_control_w %02x\n", machine().describe_context(), data); m_arena_control = data; + + // rad_bb2 waits on this in the IRQ (what does it want?) is this hblank related? + if (data & 0x80) + m_arena_control &= ~0x80; } READ8_MEMBER(xavix_state::timer_baseval_r) { - logerror("%s: timer_baseval_r\n", machine().describe_context()); + LOG("%s: timer_baseval_r\n", machine().describe_context()); return m_timer_baseval; } WRITE8_MEMBER(xavix_state::timer_control_w) { - logerror("%s: timer_control_w %02x\n", machine().describe_context(), data); + LOG("%s: timer_control_w %02x\n", machine().describe_context(), data); } WRITE8_MEMBER(xavix_state::timer_baseval_w) { // expected to return data written m_timer_baseval = data; - logerror("%s: timer_baseval_w %02x\n", machine().describe_context(), data); + LOG("%s: timer_baseval_w %02x\n", machine().describe_context(), data); } WRITE8_MEMBER(xavix_state::timer_freq_w) { // 4-bit prescale - logerror("%s: timer_freq_w %02x\n", machine().describe_context(), data); + LOG("%s: timer_freq_w %02x\n", machine().describe_context(), data); } @@ -378,8 +416,8 @@ WRITE8_MEMBER(xavix_state::mult_param_w) int param2 = m_multparams[2]; #if 0 - int signparam1 = (m_multparams[0] & 0x02)>>1; - int signparam2 = (m_multparams[0] & 0x01)>>0; + int signparam1 = (m_multparams[0] & 0x02) >> 1; + int signparam2 = (m_multparams[0] & 0x01) >> 0; if (signparam1) param1 = -param1; if (signparam2) param2 = -param2; @@ -403,8 +441,8 @@ WRITE8_MEMBER(xavix_state::mult_param_w) popmessage("unknown multiplier mode %02n", m_multparams[0] & 0xc0); } - m_multresults[1] = (result>>8)&0xff; - m_multresults[0] = result&0xff; + m_multresults[1] = (result >> 8) & 0xff; + m_multresults[0] = result & 0xff; } } @@ -414,22 +452,23 @@ READ8_MEMBER(xavix_state::irq_source_r) /* the 2nd IRQ routine (regular IRQ) reads here before deciding what to do the following bits have been seen to be checked (active low?) + monster truck does most extensive checking 0x80 - Sound Irq 0x40 - Picture / Arena Irq? - 0x20 - DMA Irq + 0x20 - DMA Irq (most routines check this as first priority, and ignore other requests if it is set?) 0x10 - Timer / Counter IRQ 0x08 - IO Irq (ADC? - used for analog control on Monster Truck) (uses 7a80 top bit to determine direction, and 7a81 0x08 as an output, presumably to clock) 0x04 - ADC IRQ - loads/stores 7b81 */ - logerror("%s: irq_source_r\n", machine().describe_context()); - return 0xff; + LOG("%s: irq_source_r\n", machine().describe_context()); + return 0x40; } WRITE8_MEMBER(xavix_state::irq_source_w) { - logerror("%s: irq_source_w %02x\n", machine().describe_context(), data); + LOG("%s: irq_source_w %02x\n", machine().describe_context(), data); // cleared on startup in monster truck, no purpose? } @@ -439,6 +478,8 @@ void xavix_state::machine_start() // card night expects RAM to be initialized to 0xff or it will show the pause menu over the startup graphics?! // don't do this every reset or it breaks the baseball 2 secret mode toggle which flips a bit in RAM std::fill_n(&m_mainram[0], 0x4000, 0xff); + + m_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(xavix_state::interrupt_gen), this)); } void xavix_state::machine_reset() @@ -459,7 +500,7 @@ void xavix_state::machine_reset() m_irq_vector_lo_data = 0; m_irq_vector_hi_data = 0; - m_6ff8 = 0; + m_video_ctrl = 0; m_arena_control = 0; m_arena_start = 0; @@ -485,7 +526,7 @@ void xavix_state::machine_reset() std::fill(std::begin(m_txarray), std::end(m_txarray), 0x00); std::fill_n(&m_fragment_sprite[0], 0x800, 0x00); // taito nostalgia 1 never initializes the ram at 0x6400 but there's no condition on using it at present? - m_lowbus->set_bank(0); + //m_lowbus->set_bank(0); m_io0_data = 0x00; m_io1_data = 0x00; @@ -495,11 +536,11 @@ void xavix_state::machine_reset() } -typedef device_delegate<uint8_t (int which, int half)> xavix_interrupt_vector_delegate; +typedef device_delegate<uint8_t(int which, int half)> xavix_interrupt_vector_delegate; int16_t xavix_state::get_vectors(int which, int half) { -// logerror("get_vectors %d %d\n", which, half); + // LOG("get_vectors %d %d\n", which, half); if (m_vectorenable == 0) return -1; |