mirror of
https://github.com/holub/mame
synced 2025-07-01 08:18:59 +03:00
Add register usage tracking to Zeus 2.
Added artifical Z offset of -2 to make the full screen show in crusnexo. Really fixed TMS3203x interrupt handling. Added hack to catch invalid SP values during 32031 execution (debug mode only).
This commit is contained in:
parent
3228b1b341
commit
b482fd8c82
@ -317,6 +317,12 @@ static void check_irqs(void)
|
||||
UINT16 validints;
|
||||
int i;
|
||||
|
||||
/* external interrupts are level-sensitive on the '31 and can be
|
||||
configured as such on the '32; in that case, if the external
|
||||
signal is high, we need to update the value in IF accordingly */
|
||||
if (!tms32031.is_32032 || (IREG(TMR_ST) & 0x4000) == 0)
|
||||
IREG(TMR_IF) |= tms32031.irq_state & 0x0f;
|
||||
|
||||
/* determine if we have any live interrupts */
|
||||
validints = IREG(TMR_IF) & IREG(TMR_IE) & 0x0fff;
|
||||
if (validints == 0 || (IREG(TMR_ST) & GIEFLAG) == 0)
|
||||
@ -340,11 +346,10 @@ static void check_irqs(void)
|
||||
IREG(TMR_IF) &= ~intmask;
|
||||
trap(whichtrap);
|
||||
|
||||
/* external interrupts are level-sensitive on the '31 and can be
|
||||
configured as such on the '32; in that case, if the external
|
||||
signal is still high, we need to retrigger the interrupt */
|
||||
if (whichtrap < 4 && (!tms32031.is_32032 || (IREG(TMR_ST) & 0x4000) == 0))
|
||||
IREG(TMR_IF) |= tms32031.irq_state & intmask;
|
||||
/* after auto-clearing the interrupt bit, we need to re-trigger
|
||||
level-sensitive interrupts */
|
||||
if (!tms32031.is_32032 || (IREG(TMR_ST) & 0x4000) == 0)
|
||||
IREG(TMR_IF) |= tms32031.irq_state & 0x0f;
|
||||
}
|
||||
else
|
||||
tms32031.irq_pending = TRUE;
|
||||
@ -514,6 +519,10 @@ static int tms32031_execute(int cycles)
|
||||
|
||||
while (tms32031_icount > 0)
|
||||
{
|
||||
#ifdef MAME_DEBUG
|
||||
if (IREG(TMR_SP) & 0xff000000)
|
||||
DEBUGGER_BREAK;
|
||||
#endif
|
||||
if ((IREG(TMR_ST) & RMFLAG) && tms32031.pc == IREG(TMR_RE) + 1)
|
||||
{
|
||||
if ((INT32)--IREG(TMR_RC) >= 0)
|
||||
|
@ -453,7 +453,7 @@ static WRITE16_HANDLER( tms_irq_w )
|
||||
/* done after uploading, and after modifying the comm area */
|
||||
logerror("%06X:tms_irq_w(%02X) = %08X & %08X\n", activecpu_get_pc(), offset, data, ~mem_mask);
|
||||
if (!(mem_mask & 0xff))
|
||||
cpunum_set_input_line(1, 0, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE);
|
||||
cpunum_set_input_line(1, 0, (data & 0x01) ? CLEAR_LINE : ASSERT_LINE);
|
||||
}
|
||||
static WRITE32_HANDLER( tms_irq_020_w ) { if ((mem_mask & 0xffff) != 0xffff) tms_irq_w(offset, data, mem_mask); }
|
||||
|
||||
|
@ -87,6 +87,25 @@ static MACHINE_RESET( midzeus )
|
||||
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* Display interrupt generation
|
||||
*
|
||||
*************************************/
|
||||
|
||||
static TIMER_CALLBACK( display_irq_off )
|
||||
{
|
||||
cpunum_set_input_line(0, 0, CLEAR_LINE);
|
||||
}
|
||||
|
||||
static INTERRUPT_GEN( display_irq )
|
||||
{
|
||||
cpunum_set_input_line(0, 0, ASSERT_LINE);
|
||||
timer_set(ATTOTIME_IN_HZ(30000000), NULL, 0, display_irq_off);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* CMOS access (Zeus only)
|
||||
@ -417,7 +436,7 @@ static ADDRESS_MAP_START( zeus2_map, ADDRESS_SPACE_PROGRAM, 32 )
|
||||
AM_RANGE(0x000000, 0x03ffff) AM_RAM AM_BASE(&ram_base)
|
||||
AM_RANGE(0x400000, 0x43ffff) AM_RAM
|
||||
AM_RANGE(0x808000, 0x80807f) AM_READWRITE(tms32031_control_r, tms32031_control_w) AM_BASE(&tms32031_control)
|
||||
AM_RANGE(0x880000, 0x8801ff) AM_READWRITE(zeus2_r, zeus2_w) AM_BASE(&zeusbase)
|
||||
AM_RANGE(0x880000, 0x88007f) AM_READWRITE(zeus2_r, zeus2_w) AM_BASE(&zeusbase)
|
||||
AM_RANGE(0x8a0000, 0x8a0027) AM_READWRITE(unknown_8a0000_r, unknown_8a0000_w) AM_BASE(&unknown_8a0000)
|
||||
AM_RANGE(0x8d0000, 0x8d0003) AM_READWRITE(unknown_8d0000_r, unknown_8d0000_w) AM_BASE(&unknown_8d0000)
|
||||
AM_RANGE(0x8d0005, 0x8d0005) AM_WRITE(rombank_select_w)
|
||||
@ -884,7 +903,7 @@ static MACHINE_DRIVER_START( midzeus )
|
||||
/* basic machine hardware */
|
||||
MDRV_CPU_ADD_TAG("main", TMS32032, CPU_CLOCK)
|
||||
MDRV_CPU_PROGRAM_MAP(zeus_map,0)
|
||||
MDRV_CPU_VBLANK_INT(irq0_line_assert,1)
|
||||
MDRV_CPU_VBLANK_INT(display_irq,1)
|
||||
|
||||
MDRV_MACHINE_START(midzeus)
|
||||
MDRV_MACHINE_RESET(midzeus)
|
||||
@ -911,7 +930,7 @@ static MACHINE_DRIVER_START( midzeus2 )
|
||||
/* basic machine hardware */
|
||||
MDRV_CPU_ADD_TAG("main", TMS32032, CPU_CLOCK)
|
||||
MDRV_CPU_PROGRAM_MAP(zeus2_map,0)
|
||||
MDRV_CPU_VBLANK_INT(irq0_line_assert,1)
|
||||
MDRV_CPU_VBLANK_INT(display_irq,1)
|
||||
|
||||
MDRV_MACHINE_START(midzeus2)
|
||||
MDRV_MACHINE_RESET(midzeus)
|
||||
@ -1081,7 +1100,6 @@ static DRIVER_INIT( crusnexo )
|
||||
|
||||
static DRIVER_INIT( thegrid )
|
||||
{
|
||||
cpunum_set_input_line(0, INPUT_LINE_HALT, ASSERT_LINE);
|
||||
dcs2_init(0, 0);
|
||||
midway_ioasic_init(MIDWAY_IOASIC_STANDARD, 474/* or 491 */, 99, NULL);
|
||||
memory_configure_bank(1, 0, 3, memory_region(REGION_USER2), 0x400000*4);
|
||||
|
@ -61,7 +61,7 @@ static TIMER_CALLBACK( scanline_timer_cb )
|
||||
{
|
||||
cpunum_set_input_line(0, 0, ASSERT_LINE);
|
||||
timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline + 1, 0), scanline, attotime_zero);
|
||||
timer_set(video_screen_get_time_until_pos(0, video_screen_get_vpos(0) + 1, video_screen_get_hpos(0)), NULL, -1, scanline_timer_cb);
|
||||
timer_set(ATTOTIME_IN_HZ(25000000), NULL, -1, scanline_timer_cb);
|
||||
}
|
||||
else
|
||||
cpunum_set_input_line(0, 0, CLEAR_LINE);
|
||||
|
@ -20,6 +20,7 @@
|
||||
*************************************/
|
||||
|
||||
#define DUMP_WAVE_RAM 0
|
||||
#define TRACK_REG_USAGE 0
|
||||
|
||||
#define WAVERAM0_WIDTH 1024
|
||||
#define WAVERAM0_HEIGHT 2048
|
||||
@ -76,6 +77,23 @@ static int zeus_quad_size;
|
||||
static UINT32 *waveram[2];
|
||||
static emu_timer *int_timer;
|
||||
|
||||
#if TRACK_REG_USAGE
|
||||
typedef struct reg_info
|
||||
{
|
||||
struct reg_info *next;
|
||||
UINT32 value;
|
||||
} reg_info;
|
||||
|
||||
static reg_info *regdata[0x80];
|
||||
static int regdata_count[0x80];
|
||||
static int regread_count[0x80];
|
||||
static int regwrite_count[0x80];
|
||||
static reg_info *subregdata[0x100];
|
||||
static int subregdata_count[0x80];
|
||||
static int subregwrite_count[0x100];
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*************************************
|
||||
@ -286,6 +304,39 @@ static void exit_handler(running_machine *machine)
|
||||
fclose(f);
|
||||
#endif
|
||||
|
||||
#if TRACK_REG_USAGE
|
||||
{
|
||||
reg_info *info;
|
||||
int regnum;
|
||||
|
||||
for (regnum = 0; regnum < 0x80; regnum++)
|
||||
{
|
||||
printf("Register %02X\n", regnum);
|
||||
if (regread_count[regnum] == 0)
|
||||
printf("\tNever read\n");
|
||||
else
|
||||
printf("\tRead %d times\n", regread_count[regnum]);
|
||||
|
||||
if (regwrite_count[regnum] == 0)
|
||||
printf("\tNever written\n");
|
||||
else
|
||||
{
|
||||
printf("\tWritten %d times\n", regwrite_count[regnum]);
|
||||
for (info = regdata[regnum]; info != NULL; info = info->next)
|
||||
printf("\t%08X\n", info->value);
|
||||
}
|
||||
}
|
||||
|
||||
for (regnum = 0; regnum < 0x100; regnum++)
|
||||
if (subregwrite_count[regnum] != 0)
|
||||
{
|
||||
printf("Sub-Register %02X (%d writes)\n", regnum, subregwrite_count[regnum]);
|
||||
for (info = subregdata[regnum]; info != NULL; info = info->next)
|
||||
printf("\t%08X\n", info->value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
poly_free(poly);
|
||||
}
|
||||
|
||||
@ -297,12 +348,17 @@ static void exit_handler(running_machine *machine)
|
||||
*
|
||||
*************************************/
|
||||
|
||||
static float zbase = 2.0f;
|
||||
|
||||
VIDEO_UPDATE( midzeus2 )
|
||||
{
|
||||
int x, y;
|
||||
|
||||
poly_wait(poly, "VIDEO_UPDATE");
|
||||
|
||||
if (input_code_pressed(KEYCODE_UP)) { zbase += 1.0f; popmessage("Zbase = %f", zbase); }
|
||||
if (input_code_pressed(KEYCODE_DOWN)) { zbase -= 1.0f; popmessage("Zbase = %f", zbase); }
|
||||
|
||||
/* normal update case */
|
||||
if (!input_code_pressed(KEYCODE_W))
|
||||
{
|
||||
@ -359,6 +415,10 @@ READ32_HANDLER( zeus2_r )
|
||||
int logit = (offset != 0x00 && offset != 0x01 && offset != 0x54 && offset != 0x48 && offset != 0x49 && offset != 0x58 && offset != 0x59 && offset != 0x5a);
|
||||
UINT32 result = zeusbase[offset];
|
||||
|
||||
#if TRACK_REG_USAGE
|
||||
regread_count[offset]++;
|
||||
#endif
|
||||
|
||||
if (logit)
|
||||
logerror("%06X:zeus2_r(%02X)\n", activecpu_get_pc(), offset);
|
||||
|
||||
@ -422,6 +482,25 @@ static void zeus_register32_w(offs_t offset, UINT32 data, int logit)
|
||||
{
|
||||
UINT32 oldval = zeusbase[offset];
|
||||
|
||||
#if TRACK_REG_USAGE
|
||||
regwrite_count[offset]++;
|
||||
if (regdata_count[offset] < 256)
|
||||
{
|
||||
reg_info **tailptr;
|
||||
|
||||
for (tailptr = ®data[offset]; *tailptr != NULL; tailptr = &(*tailptr)->next)
|
||||
if ((*tailptr)->value == data)
|
||||
break;
|
||||
if (*tailptr == NULL)
|
||||
{
|
||||
*tailptr = malloc_or_die(sizeof(reg_info));
|
||||
(*tailptr)->next = NULL;
|
||||
(*tailptr)->value = data;
|
||||
regdata_count[offset]++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* writes to register $CC need to force a partial update */
|
||||
// if ((offset & ~1) == 0xcc)
|
||||
// video_screen_update_partial(0, video_screen_get_vpos(0));
|
||||
@ -647,6 +726,25 @@ static void zeus_register_update(offs_t offset, UINT32 oldval, int logit)
|
||||
|
||||
static void zeus_pointer_write(UINT8 which, UINT32 value)
|
||||
{
|
||||
#if TRACK_REG_USAGE
|
||||
subregwrite_count[which]++;
|
||||
if (subregdata_count[which] < 256)
|
||||
{
|
||||
reg_info **tailptr;
|
||||
|
||||
for (tailptr = &subregdata[which]; *tailptr != NULL; tailptr = &(*tailptr)->next)
|
||||
if ((*tailptr)->value == value)
|
||||
break;
|
||||
if (*tailptr == NULL)
|
||||
{
|
||||
*tailptr = malloc_or_die(sizeof(reg_info));
|
||||
(*tailptr)->next = NULL;
|
||||
(*tailptr)->value = value;
|
||||
subregdata_count[which]++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case 0x04:
|
||||
@ -842,6 +940,9 @@ static void zeus_draw_model(UINT32 baseaddr, UINT16 count, int logit)
|
||||
if (logit)
|
||||
logerror(" -- model @ %08X, len %04X\n", baseaddr, count);
|
||||
|
||||
if (count > 0x1000)
|
||||
fatalerror("Extreme count\n");
|
||||
|
||||
while (baseaddr != 0 && !model_done)
|
||||
{
|
||||
const void *base = waveram0_ptr_from_expanded_addr(baseaddr);
|
||||
@ -1063,6 +1164,7 @@ In memory:
|
||||
vert[i].x = x * zeus_matrix[0][0] + y * zeus_matrix[0][1] + z * zeus_matrix[0][2] + zeus_point[0];
|
||||
vert[i].y = x * zeus_matrix[1][0] + y * zeus_matrix[1][1] + z * zeus_matrix[1][2] + zeus_point[1];
|
||||
vert[i].p[0] = x * zeus_matrix[2][0] + y * zeus_matrix[2][1] + z * zeus_matrix[2][2] + zeus_point[2];
|
||||
vert[i].p[0] += zbase;
|
||||
vert[i].p[2] += texoffs >> 16;
|
||||
vert[i].p[1] *= 256.0f;
|
||||
vert[i].p[2] *= 256.0f;
|
||||
@ -1082,6 +1184,7 @@ In memory:
|
||||
maxx = maxy = -1000.0f;
|
||||
for (i = 0; i < numverts; i++)
|
||||
{
|
||||
// 412.0f here works for crusnexo
|
||||
float ooz = 512.0f / clipvert[i].p[0];
|
||||
|
||||
// ooz *= 1.0f / (512.0f * 512.0f);
|
||||
|
Loading…
Reference in New Issue
Block a user