cinemat: move watchdog trigger to fake vblank handler

This commit is contained in:
hap 2024-12-07 01:11:33 +01:00
parent 2a34189190
commit c7cccef618
5 changed files with 56 additions and 57 deletions

View File

@ -22,18 +22,18 @@ DEFINE_DEVICE_TYPE(CCPU, ccpu_cpu_device, "ccpu", "Cinematronics CPU")
MACROS
***************************************************************************/
#define READOP(a) (m_cache.read_byte(a))
#define READOP(a) (m_cache.read_byte(a))
#define RDMEM(a) (m_data.read_word((a) & 0xfff))
#define WRMEM(a,v) (m_data.write_word((a), (v)))
#define RDMEM(a) (m_data.read_word((a) & 0xfff))
#define WRMEM(a,v) (m_data.write_word((a), (v)))
#define READPORT(a) (m_io.read_byte(a))
#define WRITEPORT(a,v) (m_io.write_byte((a), (v)))
#define READPORT(a) (m_io.read_byte(a))
#define WRITEPORT(a,v) (m_io.write_byte((a), (v)))
#define SET_A0 do { m_a0flag = m_A; } while (0)
#define SET_CMP_VAL(x) do { m_cmpacc = *m_acc; m_cmpval = (x) & 0xfff; } while (0)
#define SET_NC(a) do { m_ncflag = ~(a); } while (0)
#define SET_MI(a) do { m_nextnextmiflag = (a); } while (0)
#define SET_CMP_VAL(x) do { m_cmpacc = *m_acc; m_cmpval = (x) & 0xfff; } while (0)
#define SET_NC(a) do { m_ncflag = ~(a); } while (0)
#define SET_MI(a) do { m_nextnextmiflag = (a); } while (0)
#define TEST_A0 (m_a0flag & 1)
#define TEST_NC ((m_ncflag >> 12) & 1)
@ -52,10 +52,10 @@ DEFINE_DEVICE_TYPE(CCPU, ccpu_cpu_device, "ccpu", "Cinematronics CPU")
#define STANDARD_ACC_OP(resexp,cmpval) \
do { \
uint16_t result = resexp; \
SET_A0; /* set the A0 bit based on the previous 'A' value */ \
SET_CMP_VAL(cmpval); /* set the compare values to the previous accumulator and the cmpval */ \
SET_NC(result); /* set the NC flag based on the unmasked result */ \
*m_acc = result & 0xfff; /* store the low 12 bits of the new value */ \
SET_A0; /* set the A0 bit based on the previous 'A' value */ \
SET_CMP_VAL(cmpval); /* set the compare values to the previous accumulator and the cmpval */ \
SET_NC(result); /* set the NC flag based on the unmasked result */ \
*m_acc = result & 0xfff; /* store the low 12 bits of the new value */ \
} while (0)
@ -92,12 +92,15 @@ uint8_t ccpu_cpu_device::read_jmi()
}
void ccpu_cpu_device::wdt_timer_trigger()
void ccpu_cpu_device::wdt_trigger(int state)
{
if (!state)
return;
m_waiting = false;
m_watchdog++;
if (m_watchdog >= 3)
m_PC = 0;
device_reset();
}

View File

@ -27,7 +27,7 @@ public:
// public because the cinemat driver accesses A/P/X/Y through state interace - should there be a proper public interface to read registers?
enum
{
CCPU_PC=1,
CCPU_PC = 1,
CCPU_FLAGS,
CCPU_A,
CCPU_B,
@ -50,7 +50,7 @@ public:
template <typename... T> void set_vector_func(T &&... args) { m_vector_callback.set(std::forward<T>(args)...); }
uint8_t read_jmi();
void wdt_timer_trigger();
void wdt_trigger(int state);
protected:
// device-level overrides
@ -75,27 +75,27 @@ protected:
address_space_config m_data_config;
address_space_config m_io_config;
uint16_t m_PC;
uint16_t m_A;
uint16_t m_B;
uint8_t m_I;
uint16_t m_J;
uint8_t m_P;
uint16_t m_X;
uint16_t m_Y;
uint16_t m_T;
uint16_t * m_acc;
uint16_t m_PC;
uint16_t m_A;
uint16_t m_B;
uint8_t m_I;
uint16_t m_J;
uint8_t m_P;
uint16_t m_X;
uint16_t m_Y;
uint16_t m_T;
uint16_t * m_acc;
uint16_t m_a0flag, m_ncflag, m_cmpacc, m_cmpval;
uint16_t m_miflag, m_nextmiflag, m_nextnextmiflag;
uint16_t m_drflag;
uint16_t m_a0flag, m_ncflag, m_cmpacc, m_cmpval;
uint16_t m_miflag, m_nextmiflag, m_nextnextmiflag;
uint16_t m_drflag;
devcb_read8 m_external_input;
vector_delegate m_vector_callback;
devcb_read8 m_external_input;
vector_delegate m_vector_callback;
uint8_t m_waiting;
uint8_t m_watchdog;
uint8_t m_extinput;
uint8_t m_waiting;
uint8_t m_watchdog;
uint8_t m_extinput;
int m_icount;

View File

@ -44,8 +44,6 @@
#include "warrior.lh"
#include "wotw.lh"
#define MASTER_CLOCK XTAL(19'923'000)
/*************************************
*
@ -61,6 +59,7 @@ void cinemat_state::machine_start()
save_item(NAME(m_vector_color));
save_item(NAME(m_lastx));
save_item(NAME(m_lasty));
m_led.resolve();
m_pressed.resolve();
}
@ -1024,7 +1023,7 @@ INPUT_PORTS_END
void cinemat_state::cinemat_nojmi_4k(machine_config &config)
{
// basic machine hardware
CCPU(config, m_maincpu, MASTER_CLOCK/4);
CCPU(config, m_maincpu, 19.923_MHz_XTAL/4);
m_maincpu->set_vector_func(FUNC(cinemat_state::cinemat_vector_callback));
m_maincpu->external_func().set(FUNC(cinemat_state::joystick_read));
m_maincpu->set_addrmap(AS_PROGRAM, &cinemat_state::program_map_4k);
@ -1037,12 +1036,14 @@ void cinemat_state::cinemat_nojmi_4k(machine_config &config)
// video hardware
VECTOR(config, "vector", 0);
SCREEN(config, m_screen, SCREEN_TYPE_VECTOR);
m_screen->set_video_attributes(VIDEO_ALWAYS_UPDATE);
m_screen->set_refresh_hz(MASTER_CLOCK/4/16/16/16/16/2);
m_screen->set_refresh_hz(19.923_MHz_XTAL/4/16/16/16/16/2);
m_screen->set_size(1024, 768);
m_screen->set_visarea(0, 1023, 0, 767);
m_screen->set_visarea_full();
m_screen->set_screen_update(FUNC(cinemat_state::screen_update_cinemat));
m_screen->screen_vblank().set(m_maincpu, FUNC(ccpu_cpu_device::wdt_trigger));
}
void cinemat_state::cinemat_jmi_4k(machine_config &config)

View File

@ -5,6 +5,7 @@
Cinematronics vector hardware
*************************************************************************/
#ifndef MAME_CINEMATRONICS_CINEMAT_H
#define MAME_CINEMATRONICS_CINEMAT_H
@ -36,13 +37,7 @@ public:
, m_analog_y(*this, "ANALOGY")
, m_led(*this, "led")
, m_pressed(*this, "pressed%u", 0U)
, m_coin_detected(0)
, m_coin_last_reset(0)
, m_mux_select(0)
, m_gear(0)
, m_vector_color(255, 255, 255)
, m_lastx(0)
, m_lasty(0)
{ }
required_device<ccpu_cpu_device> m_maincpu;
@ -61,13 +56,15 @@ public:
output_finder<> m_led;
output_finder<10> m_pressed;
u8 m_coin_detected;
u8 m_coin_last_reset;
u8 m_mux_select;
u8 m_gear;
emu_timer *m_watchdog;
u8 m_coin_detected = 0;
u8 m_coin_last_reset = 0;
u8 m_mux_select = 0;
u8 m_gear = 0;
rgb_t m_vector_color;
s16 m_lastx;
s16 m_lasty;
s16 m_lastx = 0;
s16 m_lasty = 0;
u8 inputs_r(offs_t offset);
u8 switches_r(offs_t offset);
u8 coin_input_r();
@ -196,10 +193,10 @@ protected:
void demon_sound_ports(address_map &map) ATTR_COLD;
private:
u8 m_sound_fifo[16]{};
u8 m_sound_fifo_in = 0U;
u8 m_sound_fifo_out = 0U;
u8 m_last_portb_write = 0U;
u8 m_sound_fifo[16] = { };
u8 m_sound_fifo_in = 0;
u8 m_sound_fifo_out = 0;
u8 m_last_portb_write = 0;
};

View File

@ -147,8 +147,6 @@ uint32_t cinemat_state::screen_update_cinemat(screen_device &screen, bitmap_rgb3
m_vector->screen_update(screen, bitmap, cliprect);
m_vector->clear_list();
m_maincpu->wdt_timer_trigger();
return 0;
}