mirror of
https://github.com/holub/mame
synced 2025-04-23 08:49:55 +03:00
From: JEA Wallace [mailto:jeaw100@york.ac.uk]
Subject: AGEMAME upstream patches for u8/0.123 I thought I'd push a few minor coding improvements in now, while I still have something resembling free time. Firstly, I've made a few changes to the 6840 interrupt handling, to be more like that in the 6821 driver, and to hopefully reduce the IRQ swamping that could occur using the old setup. In the process, I've added the 6840 IRQ handler to the wire-OR in the MPU4 driver, as that's what the schematic shows (there's just one track for each interrupt class, all the way down the PCB to the cartridge loading point). Since I was looking at that, I made MPU4 games that didn't use a CRT as screenless as they can get at present, and altered the logging options to avoid a redefinition issue if you wanted the core and driver portions to log at different levels. Scorpion 2 has also been altered to match the MPU4 coding style, where proper handlers re now included for the stepper motor data, which can then be expanded on in AGEMAME.
This commit is contained in:
parent
839029d302
commit
381fe1f9b8
@ -6,7 +6,7 @@
|
||||
This function is a simple emulation of up to 4 MC6840
|
||||
Programmable Timer Modules
|
||||
|
||||
Written By El Condor based on previous work by Aaron Giles,
|
||||
Written By J.Wallace based on previous work by Aaron Giles,
|
||||
'Re-Animator' and Mathis Rosenhauer.
|
||||
|
||||
Todo:
|
||||
@ -117,6 +117,18 @@ int ptm6840_get_status(int which, int clock)
|
||||
return p->enabled[clock-1];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// ptm6840_get_irq: get IRQ state //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int ptm6840_get_irq(int which)
|
||||
{
|
||||
ptm6840 *p = ptm + which;
|
||||
return p->IRQ;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Subtract from Counter //
|
||||
@ -197,18 +209,24 @@ static void subtract_from_counter(int counter, int count, int which)
|
||||
|
||||
INLINE void update_interrupts(int which)
|
||||
{
|
||||
int new_state;
|
||||
ptm6840 *currptr = ptm + which;
|
||||
currptr->status_reg &= ~0x80;
|
||||
|
||||
if ((currptr->status_reg & 0x01) && (currptr->control_reg[0] & 0x40)) currptr->status_reg |= 0x80;
|
||||
if ((currptr->status_reg & 0x02) && (currptr->control_reg[1] & 0x40)) currptr->status_reg |= 0x80;
|
||||
if ((currptr->status_reg & 0x04) && (currptr->control_reg[2] & 0x40)) currptr->status_reg |= 0x80;
|
||||
new_state = (((currptr->status_reg & 0x01) && (currptr->control_reg[0] & 0x40)) || ((currptr->status_reg & 0x02) && (currptr->control_reg[1] & 0x40))
|
||||
||((currptr->status_reg & 0x04) && (currptr->control_reg[2] & 0x80)));
|
||||
|
||||
currptr->IRQ = currptr->status_reg >> 7;
|
||||
|
||||
if ( currptr->intf->irq_func )
|
||||
if (new_state != currptr->IRQ)
|
||||
{
|
||||
currptr->intf->irq_func(currptr->IRQ);
|
||||
currptr->IRQ = new_state;
|
||||
if (currptr->IRQ)
|
||||
{
|
||||
currptr->status_reg |= 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
currptr->status_reg &= ~0x80;
|
||||
}
|
||||
if (currptr->intf->irq_func) (currptr->intf->irq_func)(currptr->IRQ);
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +310,7 @@ static void reload_count(int idx, int which)
|
||||
|
||||
currptr->fired[idx]=0;
|
||||
|
||||
if ((currptr->mode[idx] == 4)|(currptr->mode[idx] == 6))
|
||||
if ((currptr->mode[idx] == 4)||(currptr->mode[idx] == 6))
|
||||
{
|
||||
currptr->output[idx] = 1;
|
||||
if ( currptr->intf->out_func[idx] ) currptr->intf->out_func[idx](0, currptr->output[idx]);
|
||||
@ -645,7 +663,7 @@ void ptm6840_set_g3(int which, int state) { ptm6840_set_gate(which, state, 2); }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// ptm6840_set_clock: set clock status (0 or 1) //
|
||||
// ptm6840_set_clock: set clock status (0 or 1) //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -665,7 +683,7 @@ void ptm6840_set_c1(int which, int state) { ptm6840_set_clock(which, state, 0);
|
||||
void ptm6840_set_c2(int which, int state) { ptm6840_set_clock(which, state, 1); }
|
||||
void ptm6840_set_c3(int which, int state) { ptm6840_set_clock(which, state, 2); }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
READ8_HANDLER( ptm6840_0_r ) { return ptm6840_read(0, offset); }
|
||||
READ8_HANDLER( ptm6840_1_r ) { return ptm6840_read(1, offset); }
|
||||
|
@ -31,6 +31,7 @@ int ptm6840_read( int which, int offset);
|
||||
void ptm6840_write( int which, int offset, int data);
|
||||
|
||||
int ptm6840_get_status(int which, int clock); // get whether timer is enabled
|
||||
int ptm6840_get_irq(int which); // get IRQ state
|
||||
void ptm6840_set_g1(int which, int state); // set gate1 state
|
||||
void ptm6840_set_c1(int which, int state); // set clock1 state
|
||||
|
||||
|
@ -172,6 +172,12 @@ Adder hardware:
|
||||
#define UART_LOG(x) do { if (VERBOSE) logerror x; } while (0)
|
||||
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
|
||||
|
||||
#ifndef AWP_VIDEO //Defined for fruit machines with mechanical reels
|
||||
#define draw_reel(x)
|
||||
#else
|
||||
#define draw_reel(x) awp_draw_reel x
|
||||
#endif
|
||||
|
||||
#define MASTER_CLOCK (XTAL_8MHz)
|
||||
|
||||
// local prototypes ///////////////////////////////////////////////////////
|
||||
@ -523,23 +529,6 @@ static INTERRUPT_GEN( timer_irq )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef UNUSED_FUNCTION
|
||||
static WRITE8_HANDLER( reel12_w )
|
||||
{
|
||||
reel12_latch = data;
|
||||
|
||||
if ( Stepper_update(0, data ) ) reel_changed |= 0x01;
|
||||
if ( Stepper_update(1, data>>4) ) reel_changed |= 0x02;
|
||||
|
||||
if ( Stepper_optic_state(0) ) optic_pattern |= 0x01;
|
||||
else optic_pattern &= ~0x01;
|
||||
if ( Stepper_optic_state(1) ) optic_pattern |= 0x02;
|
||||
else optic_pattern &= ~0x02;
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static WRITE8_HANDLER( reel12_vid_w ) // in a video cabinet this is used to drive a hopper
|
||||
{
|
||||
reel12_latch = data;
|
||||
@ -586,6 +575,9 @@ static WRITE8_HANDLER( reel34_w )
|
||||
else optic_pattern &= ~0x04;
|
||||
if ( Stepper_optic_state(3) ) optic_pattern |= 0x08;
|
||||
else optic_pattern &= ~0x08;
|
||||
|
||||
draw_reel((2));
|
||||
draw_reel((3));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -601,6 +593,9 @@ static WRITE8_HANDLER( reel56_w )
|
||||
else optic_pattern &= ~0x10;
|
||||
if ( Stepper_optic_state(5) ) optic_pattern |= 0x20;
|
||||
else optic_pattern &= ~0x20;
|
||||
|
||||
draw_reel((4));
|
||||
draw_reel((5));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -609,76 +604,22 @@ static WRITE8_HANDLER( reel56_w )
|
||||
|
||||
static WRITE8_HANDLER( mmtr_w )
|
||||
{
|
||||
int i;
|
||||
int changed = mmtr_latch ^ data;
|
||||
long cycles = ATTOTIME_TO_CYCLES(0, timer_get_time() );
|
||||
|
||||
mmtr_latch = data;
|
||||
|
||||
if ( changed & 0x01 )
|
||||
{
|
||||
if ( Mechmtr_update(0, cycles, data & 0x01 ) )
|
||||
{
|
||||
sc2gui_update_mmtr |= 0x01;
|
||||
}
|
||||
}
|
||||
|
||||
if ( changed & 0x02 )
|
||||
{
|
||||
if ( Mechmtr_update(1, cycles, data & 0x02 ) )
|
||||
{
|
||||
sc2gui_update_mmtr |= 0x02;
|
||||
}
|
||||
}
|
||||
|
||||
if ( changed & 0x04 )
|
||||
{
|
||||
if ( Mechmtr_update(2, cycles, data & 0x04 ) )
|
||||
{
|
||||
sc2gui_update_mmtr |= 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
if ( changed & 0x08 )
|
||||
{
|
||||
if ( Mechmtr_update(3, cycles, data & 0x08 ) )
|
||||
{
|
||||
sc2gui_update_mmtr |= 0x08;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( changed & 0x10 )
|
||||
{
|
||||
if ( Mechmtr_update(4, cycles, data & 0x10 ) )
|
||||
{
|
||||
sc2gui_update_mmtr |= 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
if ( changed & 0x20 )
|
||||
{
|
||||
if ( Mechmtr_update(5, cycles, data & 0x20 ) )
|
||||
{
|
||||
sc2gui_update_mmtr |= 0x20;
|
||||
}
|
||||
}
|
||||
|
||||
if ( changed & 0x40 )
|
||||
{
|
||||
if ( Mechmtr_update(6, cycles, data & 0x40 ) )
|
||||
{
|
||||
sc2gui_update_mmtr |= 0x40;
|
||||
}
|
||||
}
|
||||
|
||||
if ( changed & 0x80 )
|
||||
{
|
||||
if ( Mechmtr_update(7, cycles, data & 0x80 ) )
|
||||
{
|
||||
sc2gui_update_mmtr |= 0x80;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i<8; i++)
|
||||
{
|
||||
if ( changed & (1 << i) )
|
||||
{
|
||||
if ( Mechmtr_update(i, cycles, data & (1 << i) ) )
|
||||
{
|
||||
sc2gui_update_mmtr |= (1 << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( data & 0x1F ) cpunum_set_input_line(Machine, 0, M6809_FIRQ_LINE, ASSERT_LINE );
|
||||
}
|
||||
|
||||
@ -951,15 +892,6 @@ static WRITE8_HANDLER( coininhib_w )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef UNUSED_FUNCTION
|
||||
static READ8_HANDLER( direct_input_r )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static READ8_HANDLER( coin_input_r )
|
||||
{
|
||||
return input_port_0_r(0);
|
||||
|
@ -255,16 +255,16 @@ TODO: - Fix lamp timing, MAME doesn't update fast enough to see everything
|
||||
#include "machine/meters.h"
|
||||
|
||||
#ifdef MAME_DEBUG
|
||||
#define VERBOSE 1
|
||||
#define MPU4VERBOSE 1
|
||||
#else
|
||||
#define VERBOSE 0
|
||||
#define MPU4VERBOSE 0
|
||||
#endif
|
||||
|
||||
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
|
||||
#define LOG_CHR(x) do { if (VERBOSE) logerror x; } while (0)
|
||||
#define LOG_CHR_FULL(x) do { if (VERBOSE) logerror x; } while (0)
|
||||
#define LOG_IC3(x) do { if (VERBOSE) logerror x; } while (0)
|
||||
#define LOG_IC8(x) do { if (VERBOSE) logerror x; } while (0)
|
||||
#define LOG(x) do { if (MPU4VERBOSE) logerror x; } while (0)
|
||||
#define LOG_CHR(x) do { if (MPU4VERBOSE) logerror x; } while (0)
|
||||
#define LOG_CHR_FULL(x) do { if (MPU4VERBOSE) logerror x; } while (0)
|
||||
#define LOG_IC3(x) do { if (MPU4VERBOSE) logerror x; } while (0)
|
||||
#define LOG_IC8(x) do { if (MPU4VERBOSE) logerror x; } while (0)
|
||||
|
||||
#ifndef AWP_VIDEO //Defined for fruit machines with mechanical reels
|
||||
#define draw_reel(x)
|
||||
@ -376,23 +376,6 @@ static void update_lamps(void)
|
||||
|
||||
}
|
||||
|
||||
// palette initialisation /////////////////////////////////////////////////
|
||||
|
||||
static PALETTE_INIT( mpu4 )
|
||||
{
|
||||
int i;
|
||||
static const rgb_t color[16] =
|
||||
{
|
||||
MAKE_RGB(0x00,0x00,0x00), MAKE_RGB(0x00,0x00,0xFF), MAKE_RGB(0x00,0xFF,0x00), MAKE_RGB(0x00,0xFF,0xFF),
|
||||
MAKE_RGB(0xFF,0x00,0x00), MAKE_RGB(0xFF,0x00,0xFF), MAKE_RGB(0xFF,0xFF,0x00), MAKE_RGB(0xFF,0xFF,0xFF),
|
||||
MAKE_RGB(0x80,0x80,0x80), MAKE_RGB(0x00,0x00,0x80), MAKE_RGB(0x00,0x80,0x00), MAKE_RGB(0x00,0x80,0x80),
|
||||
MAKE_RGB(0x80,0x00,0x00), MAKE_RGB(0x80,0x00,0x80), MAKE_RGB(0x80,0x80,0x00), MAKE_RGB(0x80,0x80,0x80)
|
||||
};
|
||||
|
||||
for (i=0; i<16; i++)
|
||||
palette_set_color(machine, i, color[i]);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// called if board is reset ///////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -441,14 +424,17 @@ static MACHINE_RESET( mpu4 )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void pia_cpu0_irq(int state)
|
||||
static void cpu0_irq(int state)
|
||||
{
|
||||
// The PIA and PTM IRQ lines are all connected to a common PCB track,
|
||||
// leading directly to the 6809 IRQ line.
|
||||
int combined_state = pia_get_irq_a(0) | pia_get_irq_b(0) |
|
||||
pia_get_irq_a(1) | pia_get_irq_b(1) |
|
||||
pia_get_irq_a(2) | pia_get_irq_b(2) |
|
||||
pia_get_irq_a(3) | pia_get_irq_b(3) |
|
||||
pia_get_irq_a(4) | pia_get_irq_b(4) |
|
||||
pia_get_irq_a(5) | pia_get_irq_b(5);
|
||||
pia_get_irq_a(5) | pia_get_irq_b(5) |
|
||||
ptm6840_get_irq(0);
|
||||
|
||||
if (!serial_card_connected)
|
||||
{
|
||||
@ -462,22 +448,6 @@ static void pia_cpu0_irq(int state)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void ptm_cpu0_irq(int state)
|
||||
{
|
||||
if (!serial_card_connected)
|
||||
{
|
||||
cpunum_set_input_line(Machine, 0, M6809_IRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
|
||||
LOG(("6809 int%d \n", state));
|
||||
}
|
||||
else
|
||||
{
|
||||
cpunum_set_input_line(Machine, 0, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
|
||||
LOG(("6809 fint%d \n", state));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
static WRITE8_HANDLER( bankswitch_w )
|
||||
{
|
||||
@ -513,7 +483,7 @@ static const ptm6840_interface ptm_ic2_intf =
|
||||
MPU4_MASTER_CLOCK/4,
|
||||
{ 0,0,0 },
|
||||
{ ic2_o1_callback, ic2_o2_callback, ic2_o3_callback },
|
||||
ptm_cpu0_irq
|
||||
cpu0_irq
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
@ -565,7 +535,7 @@ static const pia6821_interface pia_ic3_intf =
|
||||
{
|
||||
/*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
|
||||
/*outputs: A/B,CA/B2 */ pia_ic3_porta_w, pia_ic3_portb_w, pia_ic3_ca2_w, pia_ic3_cb2_w,
|
||||
/*irqs : A/B */ pia_cpu0_irq, pia_cpu0_irq
|
||||
/*irqs : A/B */ cpu0_irq, cpu0_irq
|
||||
};
|
||||
|
||||
/*---------------------------------------
|
||||
@ -695,7 +665,7 @@ static const pia6821_interface pia_ic4_intf =
|
||||
{
|
||||
/*inputs : A/B,CA/B1,CA/B2 */ 0, pia_ic4_portb_r, 0, 0, 0, 0,
|
||||
/*outputs: A/B,CA/B2 */ pia_ic4_porta_w, 0, pia_ic4_ca2_w, 0,
|
||||
/*irqs : A/B */ pia_cpu0_irq, pia_cpu0_irq
|
||||
/*irqs : A/B */ cpu0_irq, cpu0_irq
|
||||
};
|
||||
|
||||
//IC5
|
||||
@ -791,7 +761,7 @@ static const pia6821_interface pia_ic5_intf =
|
||||
{
|
||||
/*inputs : A/B,CA/B1,CA/B2 */ pia_ic5_porta_r, pia_ic5_portb_r, 0, 0, 0, 0,
|
||||
/*outputs: A/B,CA/B2 */ 0, 0, pia_ic5_ca2_w, pia_ic5_cb2_w,
|
||||
/*irqs : A/B */ pia_cpu0_irq, pia_cpu0_irq
|
||||
/*irqs : A/B */ cpu0_irq, cpu0_irq
|
||||
};
|
||||
|
||||
//IC6
|
||||
@ -849,7 +819,7 @@ static const pia6821_interface pia_ic6_intf =
|
||||
{
|
||||
/*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
|
||||
/*outputs: A/B,CA/B2 */ pia_ic6_porta_w, pia_ic6_portb_w, pia_ic6_ca2_w, pia_ic6_cb2_w,
|
||||
/*irqs : A/B */ pia_cpu0_irq, pia_cpu0_irq
|
||||
/*irqs : A/B */ cpu0_irq, cpu0_irq
|
||||
};
|
||||
|
||||
//IC7
|
||||
@ -925,7 +895,7 @@ static const pia6821_interface pia_ic7_intf =
|
||||
{
|
||||
/*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
|
||||
/*outputs: A/B,CA/B2 */ pia_ic7_porta_w, pia_ic7_portb_w, pia_ic7_ca2_w, pia_ic7_cb2_w,
|
||||
/*irqs : A/B */ pia_cpu0_irq, pia_cpu0_irq
|
||||
/*irqs : A/B */ cpu0_irq, cpu0_irq
|
||||
};
|
||||
|
||||
static READ8_HANDLER( pia_ic8_porta_r )
|
||||
@ -973,7 +943,7 @@ static const pia6821_interface pia_ic8_intf =
|
||||
{
|
||||
/*inputs : A/B,CA/B1,CA/B2 */ pia_ic8_porta_r, 0, 0, 0, 0, 0,
|
||||
/*outputs: A/B,CA/B2 */ 0, pia_ic8_portb_w, pia_ic8_ca2_w, pia_ic8_cb2_w,
|
||||
/*irqs : A/B */ pia_cpu0_irq, pia_cpu0_irq
|
||||
/*irqs : A/B */ cpu0_irq, cpu0_irq
|
||||
};
|
||||
|
||||
|
||||
@ -1400,18 +1370,13 @@ static MACHINE_DRIVER_START( mpu4mod2 )
|
||||
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
|
||||
|
||||
MDRV_NVRAM_HANDLER(generic_0fill) // load/save nv RAM
|
||||
MDRV_DEFAULT_LAYOUT(layout_mpu4)
|
||||
|
||||
/* video hardware */
|
||||
MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
|
||||
MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
|
||||
|
||||
MDRV_SCREEN_SIZE(288, 34)
|
||||
MDRV_SCREEN_VISIBLE_AREA(0, 288-1, 0, 34-1)
|
||||
MDRV_SCREEN_REFRESH_RATE(50)
|
||||
|
||||
MDRV_PALETTE_LENGTH(16)
|
||||
MDRV_COLORTABLE_LENGTH(16)
|
||||
MDRV_PALETTE_INIT(mpu4)
|
||||
MDRV_DEFAULT_LAYOUT(layout_mpu4)
|
||||
MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_NONE)
|
||||
/* dummy values */
|
||||
MDRV_SCREEN_REFRESH_RATE(60)
|
||||
MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION)
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
const UINT8 MPU4_chr_lut[72]= { 0x00,0x1A,0x04,0x10,0x18,0x0F,0x13,0x1B,
|
||||
|
@ -182,12 +182,12 @@ TODO: - Confirm that MC6850 emulation is sufficient.
|
||||
#include "video/crtc6845.h"
|
||||
|
||||
#ifdef MAME_DEBUG
|
||||
#define VERBOSE 1
|
||||
#define MPU4VIDVERBOSE 1
|
||||
#else
|
||||
#define VERBOSE 0
|
||||
#define MPU4VIDVERBOSE 0
|
||||
#endif
|
||||
|
||||
#define LOGSTUFF(x) do { if (VERBOSE) logerror x; } while (0)
|
||||
#define LOGSTUFF(x) do { if (MPU4VIDVERBOSE) logerror x; } while (0)
|
||||
|
||||
#define VIDEO_MASTER_CLOCK (10000000)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user