mirror of
https://github.com/holub/mame
synced 2025-04-23 08:49:55 +03:00
cp1610: More cleanups (nw)
- Add IAB callback and use it to vector everything (including reset) - Eliminate set_input_line_vector and register hackery from CP1610-based drivers - Eliminate CP1610_RESET
This commit is contained in:
parent
06919f1b8e
commit
e0e91464db
@ -1951,7 +1951,7 @@ void cp1610_cpu_device::cp1610_jsre(int r, uint16_t addr)
|
||||
{
|
||||
m_r[r] = m_r[7];
|
||||
m_r[7] = addr;
|
||||
m_intr_enabled = 1;
|
||||
m_intr_enabled = true;
|
||||
}
|
||||
|
||||
/***************************************************
|
||||
@ -1962,7 +1962,7 @@ void cp1610_cpu_device::cp1610_jsrd(int r, uint16_t addr)
|
||||
{
|
||||
m_r[r] = m_r[7];
|
||||
m_r[7] = addr;
|
||||
m_intr_enabled = 0;
|
||||
m_intr_enabled = false;
|
||||
}
|
||||
|
||||
/***************************************************
|
||||
@ -1981,7 +1981,7 @@ void cp1610_cpu_device::cp1610_j(uint16_t addr)
|
||||
void cp1610_cpu_device::cp1610_je(uint16_t addr)
|
||||
{
|
||||
m_r[7] = addr;
|
||||
m_intr_enabled = 1;
|
||||
m_intr_enabled = true;
|
||||
}
|
||||
|
||||
/***************************************************
|
||||
@ -1991,7 +1991,7 @@ void cp1610_cpu_device::cp1610_je(uint16_t addr)
|
||||
void cp1610_cpu_device::cp1610_jd(uint16_t addr)
|
||||
{
|
||||
m_r[7] = addr;
|
||||
m_intr_enabled = 0;
|
||||
m_intr_enabled = false;
|
||||
}
|
||||
|
||||
void cp1610_cpu_device::cp1610_do_sdbd()
|
||||
@ -2120,6 +2120,12 @@ void cp1610_cpu_device::execute_run()
|
||||
{
|
||||
uint16_t opcode;
|
||||
|
||||
if (m_reset_pending)
|
||||
{
|
||||
m_reset_pending = false;
|
||||
m_r[7] = m_read_iab();
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
debugger_instruction_hook(m_r[7]);
|
||||
@ -3297,28 +3303,30 @@ void cp1610_cpu_device::execute_run()
|
||||
|
||||
if (!m_mask_interrupts)
|
||||
{
|
||||
if (m_intr_pending)
|
||||
if (m_reset_pending)
|
||||
{
|
||||
m_reset_pending = false;
|
||||
m_r[7] = m_read_iab();
|
||||
}
|
||||
else if (m_intr_pending)
|
||||
{
|
||||
/* PSHR R7 */
|
||||
standard_irq_callback(CP1610_INT_INTR);
|
||||
cp1610_writemem16(m_r[6],m_r[7]);
|
||||
m_r[6]++;
|
||||
m_icount -= 9;
|
||||
m_intr_pending = false;
|
||||
m_r[7] = standard_irq_callback(CP1610_INT_INTR);
|
||||
m_r[7] = m_read_iab();
|
||||
}
|
||||
if (m_intrm_pending && m_intr_enabled)
|
||||
else if (m_intrm_pending && m_intr_enabled)
|
||||
{
|
||||
/* PSHR R7 */
|
||||
standard_irq_callback(CP1610_INT_INTRM);
|
||||
cp1610_writemem16(m_r[6],m_r[7]);
|
||||
m_r[6]++;
|
||||
m_icount -= 9;
|
||||
m_intrm_pending = false;
|
||||
m_r[7] = standard_irq_callback(CP1610_INT_INTRM);
|
||||
}
|
||||
if (m_reset_pending)
|
||||
{
|
||||
m_reset_pending = false;
|
||||
m_r[7] = standard_irq_callback(CP1610_RESET);
|
||||
m_r[7] = m_read_iab();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3329,20 +3337,19 @@ void cp1610_cpu_device::execute_run()
|
||||
void cp1610_cpu_device::device_start()
|
||||
{
|
||||
m_read_bext.resolve_safe(0);
|
||||
m_read_iab.resolve_safe(0);
|
||||
m_intr_enabled = false;
|
||||
m_reset_pending = false;
|
||||
m_intr_pending = false;
|
||||
m_intrm_pending = false;
|
||||
m_flags = 0;
|
||||
memset(m_r, 0x00, sizeof(m_r));
|
||||
std::fill(std::begin(m_r), std::end(m_r), 0x0000);
|
||||
|
||||
m_program = &space(AS_PROGRAM);
|
||||
|
||||
save_item(NAME(m_r));
|
||||
save_item(NAME(m_flags));
|
||||
save_item(NAME(m_intr_enabled));
|
||||
save_item(NAME(m_intr_vector));
|
||||
save_item(NAME(m_reset_state));
|
||||
save_item(NAME(m_intr_state));
|
||||
save_item(NAME(m_intrm_state));
|
||||
save_item(NAME(m_reset_pending));
|
||||
@ -3380,11 +3387,6 @@ void cp1610_cpu_device::execute_set_input(int irqline, int state)
|
||||
m_intrm_pending = (state == ASSERT_LINE);
|
||||
m_intrm_state = state;
|
||||
break;
|
||||
case CP1610_RESET:
|
||||
if (state == ASSERT_LINE)
|
||||
m_reset_pending = true;
|
||||
m_reset_state = state;
|
||||
break;
|
||||
case CP1610_INT_INTR:
|
||||
if (state == ASSERT_LINE)
|
||||
m_intr_pending = true;
|
||||
@ -3398,6 +3400,9 @@ cp1610_cpu_device::cp1610_cpu_device(const machine_config &mconfig, const char *
|
||||
: cpu_device(mconfig, CP1610, tag, owner, clock)
|
||||
, m_program_config("program", ENDIANNESS_BIG, 16, 16, -1)
|
||||
, m_read_bext(*this)
|
||||
, m_read_iab(*this)
|
||||
, m_intr_state(0)
|
||||
, m_intrm_state(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CP1610_INT_NONE 0
|
||||
#define CP1610_INT_INTRM 1 /* Maskable */
|
||||
#define CP1610_RESET INPUT_LINE_RESET /* Non-Maskable */
|
||||
#define CP1610_INT_INTR INPUT_LINE_NMI /* Non-Maskable */
|
||||
|
||||
class cp1610_cpu_device : public cpu_device
|
||||
@ -33,6 +31,7 @@ public:
|
||||
cp1610_cpu_device(const machine_config &mconfig, const char *_tag, device_t *_owner, uint32_t _clock);
|
||||
|
||||
auto bext() { return m_read_bext.bind(); }
|
||||
auto iab() { return m_read_iab.bind(); }
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
@ -43,7 +42,7 @@ protected:
|
||||
virtual uint32_t execute_min_cycles() const noexcept override { return 1; }
|
||||
virtual uint32_t execute_max_cycles() const noexcept override { return 7; }
|
||||
virtual uint32_t execute_input_lines() const noexcept override { return 2; }
|
||||
virtual bool execute_input_edge_triggered(int inputnum) const noexcept override { return inputnum == CP1610_RESET || inputnum == CP1610_INT_INTR; }
|
||||
virtual bool execute_input_edge_triggered(int inputnum) const noexcept override { return inputnum == CP1610_INT_INTR; }
|
||||
virtual void execute_run() override;
|
||||
virtual void execute_set_input(int inputnum, int state) override;
|
||||
|
||||
@ -61,19 +60,18 @@ private:
|
||||
|
||||
uint16_t m_r[8]; /* registers */
|
||||
uint8_t m_flags; /* flags */
|
||||
int m_intr_enabled;
|
||||
uint16_t m_intr_vector;
|
||||
int m_reset_state;
|
||||
bool m_intr_enabled;
|
||||
int m_intr_state;
|
||||
int m_intrm_state;
|
||||
int m_reset_pending;
|
||||
int m_intr_pending;
|
||||
int m_intrm_pending;
|
||||
int m_mask_interrupts;
|
||||
bool m_reset_pending;
|
||||
bool m_intr_pending;
|
||||
bool m_intrm_pending;
|
||||
bool m_mask_interrupts;
|
||||
address_space *m_program;
|
||||
int m_icount;
|
||||
|
||||
devcb_read8 m_read_bext;
|
||||
devcb_read16 m_read_iab;
|
||||
|
||||
void cp1610_illegal();
|
||||
void cp1610_hlt();
|
||||
|
@ -460,9 +460,10 @@ INTERRUPT_GEN_MEMBER(intv_state::intv_interrupt2)
|
||||
void intv_state::intv(machine_config &config)
|
||||
{
|
||||
/* basic machine hardware */
|
||||
CP1610(config, m_maincpu, XTAL(3'579'545)/4); /* Colorburst/4 */
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, &intv_state::intv_mem);
|
||||
m_maincpu->set_vblank_int("screen", FUNC(intv_state::intv_interrupt));
|
||||
cp1610_cpu_device &maincpu(CP1610(config, m_maincpu, XTAL(3'579'545)/4)); /* Colorburst/4 */
|
||||
maincpu.set_addrmap(AS_PROGRAM, &intv_state::intv_mem);
|
||||
maincpu.set_vblank_int("screen", FUNC(intv_state::intv_interrupt));
|
||||
maincpu.iab().set(FUNC(intv_state::iab_r));
|
||||
config.set_maximum_quantum(attotime::from_hz(60));
|
||||
|
||||
/* video hardware */
|
||||
|
@ -67,7 +67,6 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void machine_start() override;
|
||||
virtual void machine_reset() override;
|
||||
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
|
||||
|
||||
@ -82,15 +81,17 @@ private:
|
||||
|
||||
void unichamp_palette(palette_device &palette) const;
|
||||
|
||||
DECLARE_READ8_MEMBER(bext_r);
|
||||
uint8_t bext_r(offs_t offset);
|
||||
|
||||
DECLARE_READ8_MEMBER(unichamp_gicram_r);
|
||||
DECLARE_WRITE8_MEMBER(unichamp_gicram_w);
|
||||
uint8_t gicram_r(offs_t offset);
|
||||
void gicram_w(offs_t offset, uint8_t data);
|
||||
|
||||
DECLARE_READ16_MEMBER(unichamp_trapl_r);
|
||||
DECLARE_WRITE16_MEMBER(unichamp_trapl_w);
|
||||
uint16_t trapl_r(offs_t offset);
|
||||
void trapl_w(offs_t offset, uint16_t data);
|
||||
|
||||
DECLARE_READ16_MEMBER(read_ff);
|
||||
uint16_t read_ff();
|
||||
|
||||
uint16_t iab_r();
|
||||
|
||||
uint32_t screen_update_unichamp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
|
||||
@ -118,8 +119,8 @@ void unichamp_state::unichamp_palette(palette_device &palette) const
|
||||
void unichamp_state::unichamp_mem(address_map &map)
|
||||
{
|
||||
map.global_mask(0x1FFF); //B13/B14/B15 are grounded!
|
||||
map(0x0000, 0x00FF).rw(FUNC(unichamp_state::unichamp_gicram_r), FUNC(unichamp_state::unichamp_gicram_w)).umask16(0x00ff);
|
||||
map(0x0100, 0x07FF).rw(FUNC(unichamp_state::unichamp_trapl_r), FUNC(unichamp_state::unichamp_trapl_w));
|
||||
map(0x0000, 0x00FF).rw(FUNC(unichamp_state::gicram_r), FUNC(unichamp_state::gicram_w)).umask16(0x00ff);
|
||||
map(0x0100, 0x07FF).rw(FUNC(unichamp_state::trapl_r), FUNC(unichamp_state::trapl_w));
|
||||
map(0x0800, 0x0FFF).rom().region("maincpu", 0); // Carts and EXE ROM, 10-bits wide
|
||||
}
|
||||
|
||||
@ -143,7 +144,7 @@ void unichamp_state::device_timer(emu_timer &timer, device_timer_id id, int para
|
||||
}
|
||||
|
||||
|
||||
READ8_MEMBER(unichamp_state::bext_r)
|
||||
uint8_t unichamp_state::bext_r(offs_t offset)
|
||||
{
|
||||
//The BEXT instruction pushes a user-defined nibble out on the four EBCA pins (EBCA0 to EBCA3)
|
||||
//and reads the ECBI input pin for HIGH or LOW signal to know whether or not to branch
|
||||
@ -168,7 +169,7 @@ void unichamp_state::init_unichamp()
|
||||
{
|
||||
}
|
||||
|
||||
READ16_MEMBER(unichamp_state::read_ff)
|
||||
uint16_t unichamp_state::read_ff()
|
||||
{
|
||||
return 0xffff;
|
||||
}
|
||||
@ -189,11 +190,13 @@ void unichamp_state::machine_start()
|
||||
read16s_delegate(*m_cart, FUNC(generic_slot_device::read16_rom)));
|
||||
} else
|
||||
m_maincpu->space(AS_PROGRAM).install_read_handler(0x1000, 0x17ff,
|
||||
read16_delegate(*this, FUNC(unichamp_state::read_ff)));
|
||||
read16smo_delegate(*this, FUNC(unichamp_state::read_ff)));
|
||||
|
||||
memset(m_ram, 0, sizeof(m_ram));
|
||||
}
|
||||
|
||||
/* Set Reset and INTR/INTRM Vector */
|
||||
void unichamp_state::machine_reset()
|
||||
uint16_t unichamp_state::iab_r()
|
||||
{
|
||||
/*
|
||||
the intv driver did not explain this but from the CP1600 manual:
|
||||
@ -207,14 +210,8 @@ void unichamp_state::machine_reset()
|
||||
//The cart ROMS are self mapped to 0x1000
|
||||
//upon boot the EXEC ROM puts 0x0800 on the bus for the CPU to use as first INT vector
|
||||
|
||||
m_maincpu->set_input_line_vector(CP1610_RESET, 0x0800); // CP1610
|
||||
m_maincpu->set_input_line_vector(CP1610_INT_INTRM, 0x0804); // CP1610 - not used anyway
|
||||
m_maincpu->set_input_line_vector(CP1610_INT_INTR, 0x0804); // CP1610 - not used anyway
|
||||
|
||||
/* Set initial PC */
|
||||
m_maincpu->set_state_int(cp1610_cpu_device::CP1610_R7, 0x0800);
|
||||
|
||||
memset(m_ram, 0, sizeof(m_ram));
|
||||
return 0x0800;
|
||||
}
|
||||
|
||||
uint32_t unichamp_state::screen_update_unichamp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
|
||||
@ -222,23 +219,23 @@ uint32_t unichamp_state::screen_update_unichamp(screen_device &screen, bitmap_in
|
||||
return m_gic->screen_update(screen, bitmap, cliprect);
|
||||
}
|
||||
|
||||
READ8_MEMBER( unichamp_state::unichamp_gicram_r )
|
||||
uint8_t unichamp_state::gicram_r(offs_t offset)
|
||||
{
|
||||
return m_ram[offset];
|
||||
}
|
||||
|
||||
WRITE8_MEMBER( unichamp_state::unichamp_gicram_w )
|
||||
void unichamp_state::gicram_w(offs_t offset, uint8_t data)
|
||||
{
|
||||
m_ram[offset] = data;
|
||||
}
|
||||
|
||||
READ16_MEMBER( unichamp_state::unichamp_trapl_r )
|
||||
uint16_t unichamp_state::trapl_r(offs_t offset)
|
||||
{
|
||||
logerror("trapl_r(%x)\n",offset);
|
||||
return (int)0;
|
||||
}
|
||||
|
||||
WRITE16_MEMBER( unichamp_state::unichamp_trapl_w )
|
||||
void unichamp_state::trapl_w(offs_t offset, uint16_t data)
|
||||
{
|
||||
logerror("trapl_w(%x) = %x\n",offset,data);
|
||||
}
|
||||
@ -254,6 +251,7 @@ void unichamp_state::unichamp(machine_config &config)
|
||||
CP1610(config, m_maincpu, (7752.0/29868.0)*XTAL(3'579'545)/4);
|
||||
m_maincpu->set_addrmap(AS_PROGRAM, &unichamp_state::unichamp_mem);
|
||||
m_maincpu->bext().set(FUNC(unichamp_state::bext_r));
|
||||
m_maincpu->iab().set(FUNC(unichamp_state::iab_r));
|
||||
|
||||
config.set_maximum_quantum(attotime::from_hz(60));
|
||||
|
||||
@ -271,7 +269,7 @@ void unichamp_state::unichamp(machine_config &config)
|
||||
SPEAKER(config, "mono").front_center();
|
||||
GIC(config, m_gic, XTAL(3'579'545));
|
||||
m_gic->set_screen("screen");
|
||||
m_gic->ram_callback().set(FUNC(unichamp_state::unichamp_gicram_r));
|
||||
m_gic->ram_callback().set(FUNC(unichamp_state::gicram_r));
|
||||
m_gic->add_route(ALL_OUTPUTS, "mono", 0.40);
|
||||
|
||||
/* cartridge */
|
||||
|
@ -94,6 +94,7 @@ private:
|
||||
uint16_t m_ram16[0x160];
|
||||
int m_sr1_int_pending;
|
||||
uint8_t m_ram8[256];
|
||||
bool m_maincpu_reset;
|
||||
|
||||
// Keyboard Component
|
||||
DECLARE_WRITE16_MEMBER(intvkbd_dualport16_w);
|
||||
@ -106,6 +107,8 @@ private:
|
||||
DECLARE_READ8_MEMBER(intvkbd_periph_r);
|
||||
DECLARE_WRITE8_MEMBER(intvkbd_periph_w);
|
||||
|
||||
uint16_t iab_r();
|
||||
|
||||
bool m_printer_not_busy; // printer state
|
||||
bool m_printer_no_paper; // printer state
|
||||
bool m_printer_not_busy_enable; // printer interface state
|
||||
|
@ -546,18 +546,24 @@ READ8_MEMBER( intv_state::intvkb_iocart_r )
|
||||
return m_region_keyboard->as_u8(offset + 0xe000);
|
||||
}
|
||||
|
||||
uint16_t intv_state::iab_r()
|
||||
{
|
||||
if (m_maincpu_reset)
|
||||
{
|
||||
// Reset vector
|
||||
m_maincpu_reset = false;
|
||||
return 0x1000;
|
||||
}
|
||||
|
||||
// INTR/INTRM vector
|
||||
return 0x1004;
|
||||
}
|
||||
|
||||
|
||||
/* Set Reset and INTR/INTRM Vector */
|
||||
void intv_state::machine_reset()
|
||||
{
|
||||
m_maincpu->set_input_line_vector(CP1610_RESET, 0x1000); // CP1610
|
||||
|
||||
/* These are actually the same vector, and INTR is unused */
|
||||
m_maincpu->set_input_line_vector(CP1610_INT_INTRM, 0x1004); // CP1610
|
||||
m_maincpu->set_input_line_vector(CP1610_INT_INTR, 0x1004); // CP1610
|
||||
|
||||
/* Set initial PC */
|
||||
m_maincpu->set_state_int(cp1610_cpu_device::CP1610_R7, 0x1000);
|
||||
m_maincpu_reset = true;
|
||||
|
||||
if (m_is_keybd)
|
||||
{
|
||||
@ -574,6 +580,7 @@ void intv_state::machine_start()
|
||||
save_item(NAME(m_ram16));
|
||||
save_item(NAME(m_sr1_int_pending));
|
||||
save_item(NAME(m_ram8));
|
||||
save_item(NAME(m_maincpu_reset));
|
||||
|
||||
// intvkbd
|
||||
if (m_is_keybd)
|
||||
|
Loading…
Reference in New Issue
Block a user