diff -c -r --new-file xmame-0.95.orig/src/config.c xmame-0.95/src/config.c
*** xmame-0.95.orig/src/config.c	Mon Mar 28 20:20:13 2005
--- xmame-0.95/src/config.c	Fri Apr 22 20:22:22 2005
***************
*** 9,15 ****
  #include "driver.h"
  #include "config.h"
  #include "common.h"
! #include "expat.h"
  
  
  #define DEBUG_CONFIG		0
--- 9,15 ----
  #include "driver.h"
  #include "config.h"
  #include "common.h"
! #include "expat/expat.h"
  
  
  #define DEBUG_CONFIG		0
diff -c -r --new-file xmame-0.95.orig/src/core.mak xmame-0.95/src/core.mak
*** xmame-0.95.orig/src/core.mak	Mon Mar 28 20:20:12 2005
--- xmame-0.95/src/core.mak	Fri Apr 22 20:22:22 2005
***************
*** 5,11 ****
  	$(OBJ)/cpuintrf.o $(OBJ)/cpuexec.o $(OBJ)/cpuint.o $(OBJ)/memory.o $(OBJ)/timer.o \
  	$(OBJ)/palette.o $(OBJ)/input.o $(OBJ)/inptport.o $(OBJ)/config.o $(OBJ)/unzip.o \
  	$(OBJ)/audit.o $(OBJ)/info.o $(OBJ)/png.o $(OBJ)/artwork.o \
! 	$(OBJ)/tilemap.o $(OBJ)/fileio.o \
  	$(OBJ)/state.o $(OBJ)/datafile.o $(OBJ)/hiscore.o \
  	$(sort $(CPUOBJS)) \
  	$(OBJ)/sndintrf.o \
--- 5,11 ----
  	$(OBJ)/cpuintrf.o $(OBJ)/cpuexec.o $(OBJ)/cpuint.o $(OBJ)/memory.o $(OBJ)/timer.o \
  	$(OBJ)/palette.o $(OBJ)/input.o $(OBJ)/inptport.o $(OBJ)/config.o $(OBJ)/unzip.o \
  	$(OBJ)/audit.o $(OBJ)/info.o $(OBJ)/png.o $(OBJ)/artwork.o \
! 	$(OBJ)/tilemap.o $(OBJ)/fileio.o $(OBJ)/infofile.o \
  	$(OBJ)/state.o $(OBJ)/datafile.o $(OBJ)/hiscore.o \
  	$(sort $(CPUOBJS)) \
  	$(OBJ)/sndintrf.o \
diff -c -r --new-file xmame-0.95.orig/src/cpu/i960/i960.c xmame-0.95/src/cpu/i960/i960.c
*** xmame-0.95.orig/src/cpu/i960/i960.c	Mon Mar 28 20:20:12 2005
--- xmame-0.95/src/cpu/i960/i960.c	Fri Apr 22 20:22:22 2005
***************
*** 9,14 ****
--- 9,15 ----
  #include <stdio.h>
  #include <stdarg.h>
  #include <math.h>
+ #include <float.h>
  
  
  /* Warning, IP = Instruction Pointer, called PC outside of Intel */
diff -c -r --new-file xmame-0.95.orig/src/drivers/cps2.c xmame-0.95/src/drivers/cps2.c
*** xmame-0.95.orig/src/drivers/cps2.c	Mon Mar 28 20:20:13 2005
--- xmame-0.95/src/drivers/cps2.c	Fri Apr 22 20:22:22 2005
***************
*** 4604,4611 ****
  	ROM_CONTINUE(         0x10000, 0x18000 )
  
  	ROM_REGION( 0x400000, REGION_SOUND1, 0 ) /* QSound samples */
! 	ROM_LOAD16_WORD_SWAP( "pl2-simm.05a",   0x000000, 0x200000, CRC(85d8fbe8) SHA1(c19d5e9084d07e610379b6e1b6be7bdf0b9b7f7f) ) /* ROM on a simm */
! 	ROM_LOAD16_WORD_SWAP( "pl2-simm.05b",   0x200000, 0x200000, CRC(1ed62584) SHA1(28411f610f48cca6424a2d53e2a4ac691e826317) ) /* ROM on a simm */
  ROM_END
  
  ROM_START( qndream )
--- 4604,4611 ----
  	ROM_CONTINUE(         0x10000, 0x18000 )
  
  	ROM_REGION( 0x400000, REGION_SOUND1, 0 ) /* QSound samples */
! 	ROM_LOAD( "pl2-simm.05a",   0x000000, 0x200000, CRC(85d8fbe8) SHA1(c19d5e9084d07e610379b6e1b6be7bdf0b9b7f7f) ) /* ROM on a simm */
! 	ROM_LOAD( "pl2-simm.05b",   0x200000, 0x200000, CRC(1ed62584) SHA1(28411f610f48cca6424a2d53e2a4ac691e826317) ) /* ROM on a simm */
  ROM_END
  
  ROM_START( qndream )
diff -c -r --new-file xmame-0.95.orig/src/drivers/ddenlovr.c xmame-0.95/src/drivers/ddenlovr.c
*** xmame-0.95.orig/src/drivers/ddenlovr.c	Mon Mar 28 20:20:12 2005
--- xmame-0.95/src/drivers/ddenlovr.c	Fri Apr 22 20:22:22 2005
***************
*** 87,92 ****
--- 87,95 ----
  static struct mame_bitmap *framebuffer;
  static int extra_layers;
  
+ extern void *record;
+ extern void *playback;
+ 
  VIDEO_START(ddenlovr)
  {
  	int i;
***************
*** 886,894 ****
--- 889,902 ----
  {
  	time_t ltime;
  	struct tm *today;
+ 
  	time(&ltime);
  	today = localtime(&ltime);
  
+ 	if (record || playback)
+ 			  return 0; // keeps the time static. This is to make sure INPs
+ 						// will playback correctly in case they use it for random seed
+ 
  	switch (offset)
  	{
  		case 0x0: return today->tm_sec%10;
diff -c -r --new-file xmame-0.95.orig/src/drivers/namcos12.c xmame-0.95/src/drivers/namcos12.c
*** xmame-0.95.orig/src/drivers/namcos12.c	Mon Mar 28 20:20:12 2005
--- xmame-0.95/src/drivers/namcos12.c	Fri Apr 22 20:22:22 2005
***************
*** 666,671 ****
--- 666,674 ----
  
  #define VERBOSE_LEVEL ( 0 )
  
+ extern void *record;
+ extern void *playback;
+ 
  INLINE void verboselog( int n_level, const char *s_fmt, ... )
  {
  	if( VERBOSE_LEVEL >= n_level )
***************
*** 937,942 ****
--- 940,948 ----
  	struct tm *exptime;
  	static int weekday[7] = { 7, 1, 2, 3, 4, 5, 6 };
  
+ 	if (record || playback)
+ 			  return 0; // keep time seeds static when recording/playingback;
+ 
  	time(&curtime);
  	exptime = localtime(&curtime);
  
diff -c -r --new-file xmame-0.95.orig/src/drivers/othldrby.c xmame-0.95/src/drivers/othldrby.c
*** xmame-0.95.orig/src/drivers/othldrby.c	Mon Mar 28 20:20:13 2005
--- xmame-0.95/src/drivers/othldrby.c	Fri Apr 22 20:22:22 2005
***************
*** 30,35 ****
--- 30,37 ----
  VIDEO_UPDATE( othldrby );
  
  
+ extern void *playback;
+ extern void *record;
  
  static READ16_HANDLER( pip )
  {
***************
*** 69,74 ****
--- 71,78 ----
  	time_t ltime;
  	struct tm *today;
  
+ 	if (record || playback)
+ 			  return 0; // Keep time static when recording or playing back
  
  	time(&ltime);
  	today = localtime(&ltime);
diff -c -r --new-file xmame-0.95.orig/src/drivers/pgm.c xmame-0.95/src/drivers/pgm.c
*** xmame-0.95.orig/src/drivers/pgm.c	Mon Mar 28 20:20:12 2005
--- xmame-0.95/src/drivers/pgm.c	Fri Apr 22 20:22:22 2005
***************
*** 282,287 ****
--- 282,289 ----
  
  READ16_HANDLER (dw2_d80000_r );
  
+ extern void *record;
+ extern void *playback;
  
  static READ16_HANDLER ( z80_ram_r )
  {
***************
*** 427,432 ****
--- 429,436 ----
  				today = localtime(&ltime);
  				break;
  		}
+ 		if (record || playback)
+ 			CalVal = 1;
  	}
  }
  
diff -c -r --new-file xmame-0.95.orig/src/drivers/psikyo.c xmame-0.95/src/drivers/psikyo.c
*** xmame-0.95.orig/src/drivers/psikyo.c	Mon Mar 28 20:20:13 2005
--- xmame-0.95/src/drivers/psikyo.c	Fri Apr 22 20:22:22 2005
***************
*** 1590,1596 ****
  	/* basic machine hardware */
  	MDRV_CPU_ADD(M68EC020, 16000000)
  	MDRV_CPU_PROGRAM_MAP(psikyo_readmem,psikyo_writemem)
! 	MDRV_CPU_VBLANK_INT(irq1_line_hold,1)
  
  	MDRV_CPU_ADD(Z80, 4000000)	/* ! LZ8420M (Z80 core) ! */
  	MDRV_CPU_FLAGS(CPU_AUDIO_CPU)
--- 1590,1596 ----
  	/* basic machine hardware */
  	MDRV_CPU_ADD(M68EC020, 16000000)
  	MDRV_CPU_PROGRAM_MAP(psikyo_readmem,psikyo_writemem)
! 	MDRV_CPU_VBLANK_INT(irq1_line_hold,2)
  
  	MDRV_CPU_ADD(Z80, 4000000)	/* ! LZ8420M (Z80 core) ! */
  	MDRV_CPU_FLAGS(CPU_AUDIO_CPU)
diff -c -r --new-file xmame-0.95.orig/src/drivers/rohga.c xmame-0.95/src/drivers/rohga.c
*** xmame-0.95.orig/src/drivers/rohga.c	Mon Mar 28 20:20:12 2005
--- xmame-0.95/src/drivers/rohga.c	Fri Apr 22 20:22:22 2005
***************
*** 347,353 ****
  	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 )
  	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 )
  	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 )
! 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
  	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
--- 347,353 ----
  	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 )
  	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 )
  	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 )
! 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 ) PORT_IMPULSE(1)
  	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
***************
*** 355,361 ****
  	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
  	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
  	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
! 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
  
  	PORT_START
  	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
--- 355,361 ----
  	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
  	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
  	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
! 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 ) PORT_IMPULSE(1)
  
  	PORT_START
  	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
***************
*** 447,453 ****
  	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 )
  	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 )
  	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
! 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
  	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
--- 447,453 ----
  	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 )
  	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 )
  	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
! 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 ) PORT_IMPULSE(1)
  	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
***************
*** 455,461 ****
  	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
  	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
  	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
! 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
  
  	PORT_START
  	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
--- 455,461 ----
  	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
  	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
  	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
! 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 ) PORT_IMPULSE(1)
  
  	PORT_START
  	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
***************
*** 520,526 ****
  	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 )
  	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 )
  	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
! 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
  	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
--- 520,526 ----
  	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 )
  	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 )
  	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
! 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 ) PORT_IMPULSE(1)
  	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
***************
*** 528,534 ****
  	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
  	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
  	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
! 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
  
  	PORT_START
  	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
--- 528,534 ----
  	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
  	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
  	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
! 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 ) PORT_IMPULSE(1)
  
  	PORT_START
  	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
***************
*** 604,610 ****
  	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 )
  	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 )
  	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 )
! 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
  	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
--- 604,610 ----
  	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 )
  	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 )
  	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 )
! 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 ) PORT_IMPULSE(1)
  	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
  	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
***************
*** 612,618 ****
  	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
  	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
  	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
! 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
  
  	PORT_START
  	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
--- 612,618 ----
  	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
  	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
  	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
! 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 ) PORT_IMPULSE(1)
  
  	PORT_START
  	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
diff -c -r --new-file xmame-0.95.orig/src/drivers/stv.c xmame-0.95/src/drivers/stv.c
*** xmame-0.95.orig/src/drivers/stv.c	Mon Mar 28 20:20:12 2005
--- xmame-0.95/src/drivers/stv.c	Fri Apr 22 20:22:22 2005
***************
*** 169,174 ****
--- 169,177 ----
  extern data32_t* stv_vdp2_cram;
  extern data32_t* stv_vdp1_vram;
  
+ extern void *record;
+ extern void *playback;
+ 
  #define USE_SLAVE 1
  
  #define LOG_CDB  0
***************
*** 301,306 ****
--- 304,311 ----
  {
  	int i, cnt = 0, tmp, res = 0;
  
+ 	if (playback || record)
+ 		return 0;
  	while (num > 0) {
  		tmp = num;
  		while (tmp >= 10) tmp %= 10;
***************
*** 2117,2123 ****
  				smpc_ram[0x21]=0x80;
  			  	smpc_ram[0x23] = DectoBCD((today->tm_year + 1900)/100);
  		    	smpc_ram[0x25] = DectoBCD((today->tm_year + 1900)%100);
! 	    		smpc_ram[0x27] = (today->tm_wday << 4) | (today->tm_mon+1);
  		    	smpc_ram[0x29] = DectoBCD(today->tm_mday);
  		    	smpc_ram[0x2b] = DectoBCD(today->tm_hour);
  		    	smpc_ram[0x2d] = DectoBCD(today->tm_min);
--- 2122,2131 ----
  				smpc_ram[0x21]=0x80;
  			  	smpc_ram[0x23] = DectoBCD((today->tm_year + 1900)/100);
  		    	smpc_ram[0x25] = DectoBCD((today->tm_year + 1900)%100);
! 				if (playback || record)
! 		    		smpc_ram[0x27] = 0;
! 				else
! 		    		smpc_ram[0x27] = (today->tm_wday << 4) | (today->tm_mon+1);
  		    	smpc_ram[0x29] = DectoBCD(today->tm_mday);
  		    	smpc_ram[0x2b] = DectoBCD(today->tm_hour);
  		    	smpc_ram[0x2d] = DectoBCD(today->tm_min);
***************
*** 3996,4002 ****
  
    	smpc_ram[0x23] = DectoBCD((today->tm_year + 1900)/100);
      smpc_ram[0x25] = DectoBCD((today->tm_year + 1900)%100);
!     smpc_ram[0x27] = (today->tm_wday << 4) | (today->tm_mon+1);
      smpc_ram[0x29] = DectoBCD(today->tm_mday);
      smpc_ram[0x2b] = DectoBCD(today->tm_hour);
      smpc_ram[0x2d] = DectoBCD(today->tm_min);
--- 4004,4013 ----
  
    	smpc_ram[0x23] = DectoBCD((today->tm_year + 1900)/100);
      smpc_ram[0x25] = DectoBCD((today->tm_year + 1900)%100);
! 	 if (playback || record)
! 	    smpc_ram[0x27] = 0;
! 	 else
! 	    smpc_ram[0x27] = (today->tm_wday << 4) | (today->tm_mon+1);
      smpc_ram[0x29] = DectoBCD(today->tm_mday);
      smpc_ram[0x2b] = DectoBCD(today->tm_hour);
      smpc_ram[0x2d] = DectoBCD(today->tm_min);
diff -c -r --new-file xmame-0.95.orig/src/drivers/suprnova.c xmame-0.95/src/drivers/suprnova.c
*** xmame-0.95.orig/src/drivers/suprnova.c	Mon Mar 28 20:20:12 2005
--- xmame-0.95/src/drivers/suprnova.c	Fri Apr 22 20:22:22 2005
***************
*** 742,748 ****
  	long value;
  
  	if(record != 0 || playback != 0)
! 		return 0;
  
  	time(&tms);
  	tm = localtime(&tms);
--- 742,748 ----
  	long value;
  
  	if(record != 0 || playback != 0)
! 		return 0x00010001;
  
  	time(&tms);
  	tm = localtime(&tms);
diff -c -r --new-file xmame-0.95.orig/src/fileio.c xmame-0.95/src/fileio.c
*** xmame-0.95.orig/src/fileio.c	Mon Mar 28 20:20:13 2005
--- xmame-0.95/src/fileio.c	Fri Apr 22 20:22:22 2005
***************
*** 211,216 ****
--- 211,219 ----
  		case FILETYPE_INPUTLOG:
  			return generic_fopen(filetype, NULL, gamename, 0, openforwrite ? FILEFLAG_OPENWRITE : FILEFLAG_OPENREAD);
  
+ 		case FILETYPE_WLF:
+ 			return generic_fopen(filetype, NULL, gamename, 0, openforwrite ? FILEFLAG_OPENWRITE : FILEFLAG_OPENREAD);
+ 
  		/* save state files */
  		case FILETYPE_STATE:
  #ifndef MESS
***************
*** 841,846 ****
--- 844,853 ----
  			extension = "inp";
  			break;
  
+ 		case FILETYPE_WLF:
+ 			extension = "wlf";
+ 			break;
+ 
  		case FILETYPE_STATE:		/* save state files */
  			extension = "sta";
  			break;
***************
*** 887,893 ****
  	}
  #endif /* MESS */
  
! 	LOG(("generic_fopen(%d, %s, %s, %s, %X)\n", pathc, gamename, filename, extension, flags));
  
  	/* reset the file handle */
  	memset(&file, 0, sizeof(file));
--- 894,900 ----
  	}
  #endif /* MESS */
  
! 	LOG(("generic_fopen(%s, %s, %s, %X)\n", gamename, filename, extension, flags));
  
  	/* reset the file handle */
  	memset(&file, 0, sizeof(file));
diff -c -r --new-file xmame-0.95.orig/src/fileio.h xmame-0.95/src/fileio.h
*** xmame-0.95.orig/src/fileio.h	Mon Mar 28 20:20:13 2005
--- xmame-0.95/src/fileio.h	Fri Apr 22 20:22:22 2005
***************
*** 43,48 ****
--- 43,49 ----
  #ifdef MESS
  	FILETYPE_HASH,
  #endif
+ 	FILETYPE_WLF,
  	FILETYPE_end /* dummy last entry */
  };
  
diff -c -r --new-file xmame-0.95.orig/src/infofile.c xmame-0.95/src/infofile.c
*** xmame-0.95.orig/src/infofile.c	Wed Dec 31 16:00:00 1969
--- xmame-0.95/src/infofile.c	Fri Apr 22 20:22:22 2005
***************
*** 0 ****
--- 1,283 ----
+ // infofile.c  -- stores various info about a MAME inp recording, the
+ //                settings used and the system it was recorded on.
+ // This source is to be kept private - DO NOT DISTRIBUTE!
+ 
+ // Last update: 8 Dec, 2004
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include "mame.h"  // for the GameOptions structure
+ #include "osdepend.h"  // for the inp header structure
+ #include "fileio.h"  // for INP file reading functions
+ #include "infofile.h"
+ 
+ mame_file* infofile;
+ static char filename[200];
+ extern char build_version[];
+ 
+ struct infodata
+ {
+ 	char header[3];  // 3 character ID - "WLF" for now
+ 	INT32 rev;  // File format revision
+ 	char shortname[9]; // MAME game's shortname (wow, that rhymes!)
+ 	char version[80]; // version string, copied from build_version[]
+ 	INT32 optsize; // size of the GameOptions struct
+ 	struct GameOptions opt;  // MAME GameOptions
+ 	INT32 cpuvendor;  // as in the INP header:
+ 	                //  1 = Intel, 2 = AMD, 3 = Transmeta,
+ 	                //  4 = Cyrix, 0 = Unknown.  
+ 	                // Other CPUs could be added here for other systems
+ 	                // ie: if Rick ever gets off his ass and does a Mac version ;)
+ 	UINT32 cputype;  // stores the CPU family/model info.  Just a copy of 
+ 	               // what is returned in EAX after CPUID function 1.
+                    // Determining the exact CPU type from here is beyond the
+ 	               // scope of this code.  External apps can do that for us.
+ 	INT64 cpuspeed;  // approximate CPU speed in Hz
+ 	INT32 ostype;  // 0 = Windows, 1 = Windows NT, 2 = Win32s (yeah, right)
+ 	INT32 osvermin; // OS version - NT4 = 4.0, Win95 = 4.0, Win98 = 4.10,
+ 	INT32 osvermaj; // WinMe = 4.90, Win2k = 5.0, WinXP = 5.1, Server 2003 = 5.2
+ 	char osstring[128];  // extra OS string: "C" for Win95OSR2, "A" for Win98se,
+ 	                                     //  "Service Pack X" for WinNT 
+ 	UINT32 starttime;  // recording start time/date
+ 	UINT32 endtime;  // recording end time/date
+ 	UINT32 framecount;  // number of frames in recording
+ 	double avgspeed;  // average recorded speed
+ 	char biosstr[20];  // BIOS string, from -bios switch
+ 	short headercheck1;
+ 	short headercheck2;
+ 	short infocheck;  // redundancy check for the infofile
+ } info;
+ 
+ void getcpuvendor(char* v)
+ {
+ 	char vendor[13];
+ 	long val1,val2,val3;
+ 	int i;
+ 	char* ptr;
+ 
+ #ifdef _MSC_VER
+ 	__asm
+ 	{
+ 		mov eax,0
+ 		cpuid
+ 		mov val1,ebx
+ 		mov val2,edx
+ 		mov val3,ecx
+ 	}
+ #else
+ 	// use CPUID
+ 	__asm__ __volatile__ (
+ 		"movl $0,%%eax\n\t" \
+ 		"cpuid"
+ 		: "=b" (val1), "=d" (val2), "=c" (val3)
+ 	);
+ #endif
+ 	
+ 	for(i=0;i<4;i++)
+ 	{
+ 		ptr = (char*)&val1;
+ 		vendor[i] = (char)*(ptr+i);
+ 		ptr = (char*)&val2;
+ 		vendor[i+4] = (char)*(ptr+i);
+ 		ptr = (char*)&val3;
+ 		vendor[i+8] = (char)*(ptr+i);
+ 	}
+ 	vendor[12] = '\0'; // Terminate string with NULL
+ 	strcpy(v,vendor);
+ }
+ 
+ long getcpufamily(void)
+ {
+ 	long cpuinfo;
+ 
+ #ifdef _MSC_VER
+ 	__asm
+ 	{
+ 		mov ecx,0x119  
+ 		rdmsr
+ 		and eax,0xffdfffff
+ 		wrmsr  // disable CPU serial number on P3 CPUs
+ 		mov eax,$1
+ 		cpuid
+ 		mov cpuinfo,eax
+ 	}
+ #else
+ /*	if(info.cpuvendor == 1) // Intel CPU
+ 	{
+ 		__asm__ __volatile__
+ 		(
+ 			"movl 0x119,%ecx\n\t"      \
+ 			"rdmsr\n\t"                \
+ 			"andl 0xffdfffff,%eax\n\t"  \
+ 			"wrmsr\n\t"
+ 		);
+ 	}*/
+ 
+ 	__asm__ __volatile__
+ 	(
+ 		"movl $1,%%eax\n\t"        \
+ 		"cpuid"
+ 		: "=a" (cpuinfo)
+ 	);
+ #endif
+ 
+ 	return cpuinfo;
+ }
+ 
+ int infoRead(struct GameOptions* o)
+ {
+ 	char fullname[250];
+ 
+ 	strcpy(fullname,filename);
+ //	strcat(fullname,".wlf");
+ 	infofile = mame_fopen(fullname,NULL,FILETYPE_WLF,0);
+ 	if(infofile == NULL)
+ 		return 0;
+ 
+ 	mame_fread(infofile,&info,sizeof(struct infodata));
+ 	mame_fclose(infofile);
+ 
+ 	o->cheat = info.opt.cheat;
+ 	o->gui_host = info.opt.gui_host;
+ 	o->skip_disclaimer = info.opt.skip_disclaimer;
+ 	o->skip_gameinfo = info.opt.skip_gameinfo;
+ 	o->skip_warnings = info.opt.skip_warnings;
+ 	o->samplerate = info.opt.samplerate;
+ 	o->use_samples = info.opt.use_samples;
+ 	o->use_filter = info.opt.use_filter;
+ 
+ 	/* not  possible with xmame, since 68 is not option
+ #if defined(A68K0)
+ 	o->m68k_core = 1;
+ #else
+ 	o->m68k_core = 0;
+ #endif
+ 	*/
+ 
+ 	o->allownvram = info.opt.allownvram;
+ 
+ 	return 1;
+ }
+ 
+ int infoWrite(void)
+ {
+ 	char fullname[250];
+ 	char vendor[13];
+ 	mame_file* inpfile;
+ 	INP_HEADER* hdr;
+ 	unsigned short chk;
+ 	short* ptr;
+ 	int a;
+ 
+ 	// Allocate RAM for header
+ 	hdr = malloc(sizeof(INP_HEADER));
+ 
+ 	strcpy(fullname,filename);
+ //	strcat(fullname,".wlf");
+ 	infofile = mame_fopen(fullname,NULL,FILETYPE_WLF,1);
+ 	if(infofile == NULL)
+ 		return 0;
+ 
+ 	// header
+ 	strcpy(info.header,"WLF");
+ 	info.rev = 2;
+ 
+ 	// MAME version string
+ 	strcpy(info.version,build_version);
+ 
+ 	// CPU info
+ 	getcpuvendor(vendor);
+ 	if(strcmp(vendor,"GenuineIntel") == 0)
+ 		info.cpuvendor = 1;  // Intel CPU
+ 	if(strcmp(vendor,"AuthenticAMD") == 0)
+ 		info.cpuvendor = 2;  // AMD CPU
+ 	if(strcmp(vendor,"GenuineTMx86") == 0)
+ 		info.cpuvendor = 3;  // Transmeta CPU
+ 	if(strcmp(vendor,"CyrixInstead") == 0)
+ 		info.cpuvendor = 4;  // Cyrix CPU
+ 
+ 	info.cputype = getcpufamily();
+ 
+ 	// OS info
+ 		info.ostype = -1;  // Unknown
+ 
+ 	info.osvermin = 0;
+ 	info.osvermaj = 0;
+ 	strcpy(info.osstring,"linux");
+ 
+ 	// INP and WLF file validity checks
+ 	sprintf(fullname,"%s.inp",filename);
+ 	inpfile = mame_fopen(filename,0,FILETYPE_INPUTLOG,0);
+ 	if(inpfile == NULL)
+ 		return 0;
+ 
+ 	mame_fread(inpfile,hdr,sizeof(INP_HEADER));
+ 	info.headercheck1 = hdr->check;
+ 
+ 	mame_fseek(inpfile,0,SEEK_SET);
+ 
+ 	while(mame_fread(inpfile,&chk,2) != 0)
+ 	{
+ 		info.headercheck2 += chk;
+ 	}
+ 
+ 	mame_fclose(inpfile);
+ 
+ 	chk = 0;
+ 	ptr = (struct infodata*)&info;
+ 	for(a=0;a<(sizeof(struct infodata)/2)-4;a++)
+ 		chk+=(short)*(ptr+a);
+ 	info.infocheck = chk;
+ 
+ 	// write file
+ 	mame_fwrite(infofile,&info,sizeof(struct infodata));
+ 	mame_fclose(infofile);
+ 
+ 	// Free allocated RAM for header
+ 	free(hdr);
+ 
+ 	return 1;
+ }
+ 
+ void infoSetFilename(char* name)
+ {
+ 	strcpy(filename,name);
+ }
+ 
+ void infoSetOptions(struct GameOptions* o)
+ {
+ 	memcpy(&(info.opt),o,sizeof(struct GameOptions));
+ 	info.optsize = sizeof(struct GameOptions);
+ }
+ 
+ void infoSetTimeStart(UINT32 t)
+ {
+ 	info.starttime = t;
+ }
+ 
+ void infoSetTimeEnd(UINT32 t)
+ {
+ 	info.endtime = t;
+ }
+ 
+ void infoSetShortName(const char* name)
+ {
+ 	strcpy(info.shortname,name);
+ }
+ 
+ void infoSetSpeed(INT64 spd)
+ {
+ 	info.cpuspeed = spd;
+ }
+ 
+ void infoSetFrameCount(UINT32 f, double spd)
+ {
+ 	info.framecount = f;
+ 	info.avgspeed = spd;
+ }
+ 
+ void infoSetBIOSString(char* str)
+ {
+ 	strcpy(info.biosstr,str);
+ }
diff -c -r --new-file xmame-0.95.orig/src/infofile.h xmame-0.95/src/infofile.h
*** xmame-0.95.orig/src/infofile.h	Wed Dec 31 16:00:00 1969
--- xmame-0.95/src/infofile.h	Fri Apr 22 20:22:22 2005
***************
*** 0 ****
--- 1,25 ----
+ // infofile header
+ 
+ #include "mame.h"
+ 
+ // Function prototypes
+ 
+ int infoRead(struct GameOptions*);
+ 
+ int infoWrite(void);
+ 
+ void infoSetFilename(char*);
+ 
+ void infoSetOptions(struct GameOptions*);
+ 
+ void infoSetTimeStart(UINT32);
+ 
+ void infoSetTimeEnd(UINT32);
+ 
+ void infoSetShortName(const char*);
+ 
+ void infoSetSpeed(INT64);
+ 
+ void infoSetFrameCount(UINT32,double);  // and speed too :)
+ 
+ void infoSetBIOSString(char* str);
diff -c -r --new-file xmame-0.95.orig/src/inptport.c xmame-0.95/src/inptport.c
*** xmame-0.95.orig/src/inptport.c	Mon Mar 28 20:20:14 2005
--- xmame-0.95/src/inptport.c	Fri Apr 22 20:22:22 2005
***************
*** 105,111 ****
--- 105,125 ----
  
  extern void *record;
  extern void *playback;
+ int pback=0;
  
+ // W: game speed storage
+ UINT32 framer;
+ static UINT32 hold;
+ 
+ // W: Average speed calculation
+ double speed_total;
+ unsigned int speed_counter;
+ 
+ // W: For regular INP usage
+ int isnotwolf;
+ 
+ // W: For input view
+ char inputstr[80];
  
  
  /*************************************
***************
*** 159,165 ****
  	UINT8				shift;		/* left shift to apply to the final result */
  	UINT8				bits;		/* how many bits of resolution are expected? */
  	UINT8				absolute;	/* is this an absolute or relative input? */
! 	UINT8				pedal;		/* is this a pedal input? */
  	UINT8				autocenter;	/* autocenter this input? */
  	UINT8				interpolate;/* should we do linear interpolation for mid-frame reads? */
  	UINT8				lastdigital;/* was the last modification caused by a digital form? */
--- 173,179 ----
  	UINT8				shift;		/* left shift to apply to the final result */
  	UINT8				bits;		/* how many bits of resolution are expected? */
  	UINT8				absolute;	/* is this an absolute or relative input? */
! 	UINT8				reverse;		/* reverse the sense of this input? */
  	UINT8				autocenter;	/* autocenter this input? */
  	UINT8				interpolate;/* should we do linear interpolation for mid-frame reads? */
  	UINT8				lastdigital;/* was the last modification caused by a digital form? */
***************
*** 196,203 ****
  #define JOYSTICK_INFO_FOR_PORT(in)	(&joystick_info[(in)->player][((in)->type - __ipt_digital_joystick_start) / 4])
  #define JOYSTICK_DIR_FOR_PORT(in)	(((in)->type - __ipt_digital_joystick_start) % 4)
  
! #define APPLY_SENSITIVITY(x,s)		(((x) >= 0) ? (((INT64)(x) * (s) + 50) / 100) : ((-(INT64)(x) * (s) + 50) / -100))
! #define APPLY_INVERSE_SENSITIVITY(x,s) (((x) >= 0) ? (((INT64)(x) * 100 - 50) / (s)) : ((-(INT64)(x) * 100 - 50) / -(s)))
  
  
  
--- 210,218 ----
  #define JOYSTICK_INFO_FOR_PORT(in)	(&joystick_info[(in)->player][((in)->type - __ipt_digital_joystick_start) / 4])
  #define JOYSTICK_DIR_FOR_PORT(in)	(((in)->type - __ipt_digital_joystick_start) % 4)
  
! 
! #define APPLY_SENSITIVITY(x,s)    (((x) >= 0) ? (((x) * (s) + 50) / 100) : ((-(x) * (s) + 50) / -100))
! #define APPLY_INVERSE_SENSITIVITY(x,s) (((x) >= 0) ? (((x) * 100 - 50) / (s)) : ((-(x) * 100 - 50) / -(s)))
  
  
  
***************
*** 947,952 ****
--- 962,973 ----
  	/* now load the game-specific info */
  	loaded = config_load(Machine->input_ports_default, Machine->input_ports);
  
+ 	/* W: cause barry told me to */
+ 	if (playback)
+ 		pback = 1;
+ 	else
+ 		pback = 0;
+ 
  	/* initialize the various port states */
  	inputport_init();
  
***************
*** 1043,1049 ****
  					case IPT_PEDAL2:
  					case IPT_PEDAL3:
  						info->maximum = 0;
! 						info->pedal = 1;
  						/* fall through... */
  
  					/* pedals, paddles and analog joysticks are absolute and autocenter */
--- 1064,1070 ----
  					case IPT_PEDAL2:
  					case IPT_PEDAL3:
  						info->maximum = 0;
! 						info->reverse = 1;
  						/* fall through... */
  
  					/* pedals, paddles and analog joysticks are absolute and autocenter */
***************
*** 1064,1072 ****
  						break;
  
  					/* dials, mice and trackballs are relative devices */
- 					/* these have fixed "min" and "max" values based on how many bits are in the port */
- 					/* in addition, we set the wrap around min/max values to 512 * the min/max values */
- 					/* this takes into account the mapping that one mouse unit ~= 512 analog units */
  					case IPT_DIAL:
  					case IPT_DIAL_V:
  					case IPT_MOUSE_X:
--- 1085,1090 ----
***************
*** 1076,1083 ****
  						info->absolute = 0;
  						port->analog.min = 0;
  						port->analog.max = (1 << info->bits) - 1;
- 						info->minimum = 0;
- 						info->maximum = port->analog.max * 512;
  						break;
  
  					default:
--- 1094,1099 ----
***************
*** 1100,1110 ****
  					}
  				}
  
- 				/* relative controls all map directly with a 512x scale factor */
  				else
! 					info->scalepos = info->scaleneg = 1.0 / 512.0;
  
- 				/* compute scale for keypresses */
  				info->keyscale = 1.0 / (0.5 * (info->scalepos + info->scaleneg));
  
  				/* hook in the list */
--- 1116,1129 ----
  					}
  				}
  
  				else
! 				{
! 					if (port->analog.max > port->analog.min)
! 						info->scalepos = info->scaleneg = (double)(port->analog.max - port->analog.min) / (double)(ANALOG_VALUE_MAX - ANALOG_VALUE_MIN);
! 					else
! 						info->scalepos = info->scaleneg = (double)((INT32)((port->analog.max - port->analog.min) << (32 - info->bits)) >> (32 - info->bits)) / (double)(ANALOG_VALUE_MAX - ANALOG_VALUE_MIN);
! 				}
  
  				info->keyscale = 1.0 / (0.5 * (info->scalepos + info->scaleneg));
  
  				/* hook in the list */
***************
*** 1579,1592 ****
   *
   *************************************/
  
! static void read_port_value(mame_file *f, UINT32 *result)
  {
  	if (mame_fread(f, result, sizeof(*result)) == sizeof(*result))
  	{
  #ifdef LSB_FIRST
  		*result = (*result >> 24) | ((*result >> 8) & 0xff00) | ((*result & 0xff00) << 8) | (*result << 24);
  #endif
  	}
  }
  
  
--- 1598,1613 ----
   *
   *************************************/
  
! static int read_port_value(mame_file *f, UINT32 *result)
  {
  	if (mame_fread(f, result, sizeof(*result)) == sizeof(*result))
  	{
  #ifdef LSB_FIRST
  		*result = (*result >> 24) | ((*result >> 8) & 0xff00) | ((*result & 0xff00) << 8) | (*result << 24);
  #endif
+ 		return 1;
  	}
+ 	return 0;
  }
  
  
***************
*** 1710,1718 ****
  	}
  
  	/* handle playback */
! 	if (playback != NULL)
! 		for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++)
! 			read_port_value(playback, &input_port_value[portnum]);
  
  #ifdef MESS
  	/* less MESS to MESSy things */
--- 1731,1789 ----
  	}
  
  	/* handle playback */
! 	if (playback != NULL && pback)
! 	{
! 		struct InputPort *in;
! 		int buf,port;
! 		for (portnum = 0; portnum < MAX_INPUT_PORTS+(isnotwolf?0:1); portnum++)
! 		{
! 			if ((portnum==MAX_INPUT_PORTS)
! 				? mame_fread(playback, &framer, sizeof(framer))!=sizeof(framer)
! 				: !read_port_value(playback, &buf))
! 			{
! 				pback = 0;
! 				usrintf_showmessage("End of playback");
! #ifdef AUTO_PAUSE_PLAYBACK
! 				if (options.auto_pause_playback)
! 					ui_auto_pause();
! #endif
! 				break;
! 			}
! 			else if (portnum==MAX_INPUT_PORTS)
! 				break;
! 			else
! 			{
! 					input_port_value[portnum] = buf;
! 			}
! 
! 			// this may be obsolete!!!!!!!!!!!
! 			port = 0;
! 			in = Machine->input_ports;
! 			++in;
! 			while (in->type != IPT_END && port < MAX_INPUT_PORTS)
! 			{
! 				while (in->type != IPT_END && in->type != IPT_PORT)
! 				{
! 					if (in->type == IPT_DIPSWITCH_NAME)
! 					{
! 						in->default_value =
! 							(in->default_value & ~in->mask) | (input_port_value[port] & in->mask);
! 					}
! 					++in;
! 				}
! 				++port;
! 				if (in->type == IPT_PORT)
! 					++in;
! 			}
! 		}
! 
! 			// For average speed calculations
! 			if (!mame_feof(playback))
! 			{
! 				++speed_counter;
! 				speed_total += (framer - 0xe143823e);
! 			}
! 	}
  
  #ifdef MESS
  	/* less MESS to MESSy things */
***************
*** 1720,1728 ****
  #endif
  
  	/* handle recording */
! 	if (record != NULL)
  		for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++)
  			write_port_value(record, input_port_value[portnum]);
  
  profiler_mark(PROFILER_END);
  }
--- 1791,1900 ----
  #endif
  
  	/* handle recording */
! 	if (record != NULL && playback == NULL)
! 	{
  		for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++)
  			write_port_value(record, input_port_value[portnum]);
+ 		hold = 0xe143823e + framer;
+ 		// so average speed can be calcualted for .wlf file
+ 		++speed_counter;
+ 		speed_total += framer;
+ 		portnum = hold;
+ 		write_port_value(record, portnum);
+ 	}
+ 
+ 	memset(inputstr,32,79);
+ 	inputstr[79] = '\0';
+ 	for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++)
+ 	{
+ 		struct InputBitInfo *info;
+ 		for (bitnum = 0, info = &bit_info[portnum][0]; bitnum < MAX_BITS_PER_PORT && info->port; bitnum++, info++)
+ 		{
+ 			struct InputPort *port = info->port;
+ 			
+ 			if(port->player == options.inpview - 1)
+ 			{
+ 			  if(port->type == IPT_JOYSTICK_LEFT && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 			  {
+ 				inputstr[2] = '_';
+ 				inputstr[3] = '4';
+ 			  }
+ 			  if(port->type == IPT_JOYSTICK_UP && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 			  {
+ 				inputstr[4] = '_';
+ 				inputstr[5] = '8';
+ 			  }
+ 			  if(port->type == IPT_JOYSTICK_RIGHT && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 			  {
+ 				inputstr[6] = '_';
+ 				inputstr[7] = '6';
+ 			  }
+ 			  if(port->type == IPT_JOYSTICK_DOWN && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 			  {
+ 				inputstr[8] = '_';
+ 				inputstr[9] = '2';
+ 			  }
+ 			  if(port->type == IPT_BUTTON1 && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 				inputstr[12] = '1';
+ 			  if(port->type == IPT_BUTTON2 && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 				inputstr[13] = '2';
+ 			  if(port->type == IPT_BUTTON3 && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 				inputstr[14] = '3';
+ 			  if(port->type == IPT_BUTTON4 && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 				inputstr[15] = '4';
+ 			  if(port->type == IPT_BUTTON5 && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 				inputstr[16] = '5';
+ 			  if(port->type == IPT_BUTTON6 && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 				inputstr[17] = '6';
+ 			  if(port->type == IPT_BUTTON7 && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 				inputstr[18] = '7';
+ 			  if(port->type == IPT_BUTTON8 && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 				inputstr[19] = '8';
+ 			  if(port->type == IPT_BUTTON9 && (input_port_value[portnum]
+ 				& port->mask) != (port->default_value & port->mask))
+ 				inputstr[20] = '9';
+ 			  if(port->type == IPT_BUTTON10 && (input_port_value[portnum]
+ 			  	& port->mask) != (port->default_value & port->mask))
+ 				inputstr[21] = '0';
+ 			}
+ 			if(port->type == IPT_START1 && (input_port_value[portnum]
+ 				& port->mask) != (port->default_value & port->mask))
+ 			{
+ 				inputstr[24] = '1';
+ 				inputstr[25] = 'P';
+ 			}
+ 			if(port->type == IPT_START2 && (input_port_value[portnum]
+ 				& port->mask) != (port->default_value & port->mask))
+ 			{
+ 				inputstr[27] = '2';
+ 				inputstr[28] = 'P';
+ 			}
+ 			if(port->type == IPT_START3 && (input_port_value[portnum]
+ 			& port->mask) != (port->default_value & port->mask))
+ 			{
+ 				inputstr[30] = '3';
+ 				inputstr[31] = 'P';
+ 			}
+ 			if(port->type == IPT_START4 && (input_port_value[portnum]
+ 				& port->mask) != (port->default_value & port->mask))
+ 			{
+ 				inputstr[33] = '4';
+ 				inputstr[34] = 'P';
+ 			}
+ 		}
+ 	}
  
  profiler_mark(PROFILER_END);
  }
***************
*** 1997,2008 ****
  		current = apply_analog_min_max(info, current);
  		current = APPLY_SENSITIVITY(current, info->port->analog.sensitivity);
  
! 		/* apply special reversal rules for pedals */
! 		if (info->pedal)
! 			current = !info->port->analog.reverse ? (info->maximum - current) : (-info->minimum + current);
! 
! 		/* apply standard reversal rules for everything else */
! 		else if (info->port->analog.reverse)
  			current = -current;
  
  		/* map differently for positive and negative values */
--- 2169,2176 ----
  		current = apply_analog_min_max(info, current);
  		current = APPLY_SENSITIVITY(current, info->port->analog.sensitivity);
  
! 		/* apply reversal */
! 		if (~info->port->analog.reverse & !info->reverse)
  			current = -current;
  
  		/* map differently for positive and negative values */
***************
*** 2017,2024 ****
  
  		/* handle playback/record scenarios */
  		if (playback)
! 			read_port_value(playback, &input_port_value[port]);
! 		if (record)
  			write_port_value(record, input_port_value[port]);
  	}
  
--- 2185,2195 ----
  
  		/* handle playback/record scenarios */
  		if (playback)
! 		{
! 			if (pback)
! 				read_port_value(playback, &input_port_value[port]);
! 		}
! 		else if (record)
  			write_port_value(record, input_port_value[port]);
  	}
  
diff -c -r --new-file xmame-0.95.orig/src/machine/ds2404.c xmame-0.95/src/machine/ds2404.c
*** xmame-0.95.orig/src/machine/ds2404.c	Mon Mar 28 20:20:13 2005
--- xmame-0.95/src/machine/ds2404.c	Fri Apr 22 20:22:22 2005
***************
*** 3,8 ****
--- 3,11 ----
  #include "driver.h"
  #include <time.h>
  
+ extern void *record;
+ extern void *playback;
+ 
  typedef enum {
  	DS2404_STATE_IDLE = 1,				/* waiting for ROM command, in 1-wire mode */
  	DS2404_STATE_COMMAND,				/* waiting for memory command */
***************
*** 94,99 ****
--- 97,104 ----
  		
  		time( &current_time );
  		current_time -= ds2404.clock_adjust;
+ 		if (record || playback)
+ 				  return 0;
  
  		switch( ds2404.address )
  		{
diff -c -r --new-file xmame-0.95.orig/src/machine/midwayic.c xmame-0.95/src/machine/midwayic.c
*** xmame-0.95.orig/src/machine/midwayic.c	Mon Mar 28 20:20:13 2005
--- xmame-0.95/src/machine/midwayic.c	Fri Apr 22 20:22:22 2005
***************
*** 29,34 ****
--- 29,37 ----
  #define FIFO_SIZE			512
  
  
+ extern void *record;
+ extern void *playback;
+ 
  
  /*************************************
   *
***************
*** 363,375 ****
  					time(&curtime);
  					exptime = localtime(&curtime);
  
! 					pic.buffer[pic.total++] = make_bcd(exptime->tm_sec);
! 					pic.buffer[pic.total++] = make_bcd(exptime->tm_min);
! 					pic.buffer[pic.total++] = make_bcd(exptime->tm_hour);
! 					pic.buffer[pic.total++] = make_bcd(exptime->tm_wday + 1);
! 					pic.buffer[pic.total++] = make_bcd(exptime->tm_mday);
! 					pic.buffer[pic.total++] = make_bcd(exptime->tm_mon + 1);
! 					pic.buffer[pic.total++] = make_bcd(exptime->tm_year - pic.yearoffs);
  				}
  				
  				/* otherwise, just parrot back what was written to pass self tests */
--- 366,391 ----
  					time(&curtime);
  					exptime = localtime(&curtime);
  
! 					if (playback || record)
! 					{
! 						pic.buffer[pic.total++] = 0;
! 						pic.buffer[pic.total++] = 0;
! 						pic.buffer[pic.total++] = 0;
! 						pic.buffer[pic.total++] = 0;
! 						pic.buffer[pic.total++] = 0;
! 						pic.buffer[pic.total++] = 0;
! 						pic.buffer[pic.total++] = 0;
! 					}
! 					else
! 					{
! 						pic.buffer[pic.total++] = make_bcd(exptime->tm_sec);
! 						pic.buffer[pic.total++] = make_bcd(exptime->tm_min);
! 						pic.buffer[pic.total++] = make_bcd(exptime->tm_hour);
! 						pic.buffer[pic.total++] = make_bcd(exptime->tm_wday + 1);
! 						pic.buffer[pic.total++] = make_bcd(exptime->tm_mday);
! 						pic.buffer[pic.total++] = make_bcd(exptime->tm_mon + 1);
! 						pic.buffer[pic.total++] = make_bcd(exptime->tm_year - pic.yearoffs);
! 					}
  				}
  				
  				/* otherwise, just parrot back what was written to pass self tests */
diff -c -r --new-file xmame-0.95.orig/src/mame.c xmame-0.95/src/mame.c
*** xmame-0.95.orig/src/mame.c	Mon Mar 28 20:27:21 2005
--- xmame-0.95/src/mame.c	Fri Apr 22 20:22:22 2005
***************
*** 135,140 ****
--- 135,141 ----
  #include "driver.h"
  #include <ctype.h>
  #include <stdarg.h>
+ #include <time.h> // only needed in dos wolf source
  #include "ui_text.h"
  #include "mamedbg.h"
  #include "artwork.h"
***************
*** 144,149 ****
--- 145,151 ----
  #include "vidhrdw/vector.h"
  #include "palette.h"
  #include "harddisk.h"
+ #include "infofile.h"
  
  
  /***************************************************************************
***************
*** 558,563 ****
--- 560,567 ----
  	run_machine_core - core execution loop
  -------------------------------------------------*/
  
+ extern void writeInpStartTime(void);
+ 
  void run_machine_core(void)
  {
  	/* disable artwork for the start */
***************
*** 585,604 ****
  				if (options.cheat)
  					InitCheat();
  
  				/* load the NVRAM now */
  				if (Machine->drv->nvram_handler)
  				{
! 					mame_file *nvram_file = mame_fopen(Machine->gamedrv->name, 0, FILETYPE_NVRAM, 0);
! 					(*Machine->drv->nvram_handler)(nvram_file, 0);
! 					if (nvram_file)
! 						mame_fclose(nvram_file);
  				}
  
  				/* run the emulation! */
  				cpu_run();
  
  				/* save the NVRAM */
! 				if (Machine->drv->nvram_handler)
  				{
  					mame_file *nvram_file = mame_fopen(Machine->gamedrv->name, 0, FILETYPE_NVRAM, 1);
  					if (nvram_file != NULL)
--- 589,619 ----
  				if (options.cheat)
  					InitCheat();
  
+ 
  				/* load the NVRAM now */
  				if (Machine->drv->nvram_handler)
  				{
! 					if ((record || playback) && !options.allownvram)
! 						(*Machine->drv->nvram_handler)(0,0);
! 					else
! 					{
! 						mame_file *nvram_file = mame_fopen(Machine->gamedrv->name, 0, FILETYPE_NVRAM, 0);
! 						(*Machine->drv->nvram_handler)(nvram_file, 0);
! 						if (nvram_file)
! 							mame_fclose(nvram_file);
! 					}
  				}
  
+ 				// write the start time here!
+ 				if (!playback && record)
+ 					writeInpStartTime();
+ 
  				/* run the emulation! */
  				cpu_run();
  
  				/* save the NVRAM */
! 				if (Machine->drv->nvram_handler
! 					&& !((record || playback) && !options.allownvram))
  				{
  					mame_file *nvram_file = mame_fopen(Machine->gamedrv->name, 0, FILETYPE_NVRAM, 1);
  					if (nvram_file != NULL)
***************
*** 608,613 ****
--- 623,629 ----
  					}
  				}
  
+ 
  				/* stop the cheat engine */
  				if (options.cheat)
  					StopCheat();
diff -c -r --new-file xmame-0.95.orig/src/mame.h xmame-0.95/src/mame.h
*** xmame-0.95.orig/src/mame.h	Mon Mar 28 20:27:44 2005
--- xmame-0.95/src/mame.h	Fri Apr 22 20:22:22 2005
***************
*** 250,255 ****
--- 250,257 ----
  	int		min_width;		/* minimum width for the display */
  	int		min_height;		/* minimum height for the display */
  #endif /* MESS */
+ 	int		allownvram; /* allows NVRAM to be used when recording or playing INPs */
+ 	int		inpview; /* enables input viewing and determines which player's to show */
  };
  
  
***************
*** 302,307 ****
--- 304,310 ----
  
  	/* other misc information */
  	UINT8					led_state;				/* bitfield of current LED states */
+ 	int					allow_nvram; /* allows NVRAM to be used when recording or playing INPs */
  };
  
  
diff -c -r --new-file xmame-0.95.orig/src/osdepend.h xmame-0.95/src/osdepend.h
*** xmame-0.95.orig/src/osdepend.h	Mon Mar 28 20:20:14 2005
--- xmame-0.95/src/osdepend.h	Fri Apr 22 20:22:22 2005
***************
*** 240,249 ****
  {
  	char name[9];      /* 8 bytes for game->name + NUL */
  	char version[3];   /* byte[0] = 0, byte[1] = version byte[2] = beta_version */
! 	char reserved[20]; /* for future use, possible store game options? */
  } INP_HEADER;
  
  
  typedef struct _osd_file osd_file;
  
  
--- 240,257 ----
  {
  	char name[9];      /* 8 bytes for game->name + NUL */
  	char version[3];   /* byte[0] = 0, byte[1] = version byte[2] = beta_version */
! 	char options;  /* Store some options */
! 	char fskip;    /* Store fskip value */
! 	char options2; /* more gameoptions Bit 0: Sound Enabled */
! 	char cputype; /* Intel/AMD CPU type */
! 	INT64 spd;  /* recorded clock speed */
! 	UINT32 starttime; /* date/time INP was started */
! 	short endtime; /* date/time INP was started */
! 	unsigned short check;  /* checksum */
  } INP_HEADER;
  
  
+ 
  typedef struct _osd_file osd_file;
  
  
diff -c -r --new-file xmame-0.95.orig/src/sndintrf.c xmame-0.95/src/sndintrf.c
*** xmame-0.95.orig/src/sndintrf.c	Mon Mar 28 20:20:13 2005
--- xmame-0.95/src/sndintrf.c	Fri Apr 22 20:22:22 2005
***************
*** 523,529 ****
  static INT16 *finalmix;
  static INT32 *leftmix, *rightmix;
  static int samples_this_frame;
! static int global_sound_enabled;
  static int nosound_mode;
  
  static UINT16 latch_clear_value = 0x00;
--- 523,529 ----
  static INT16 *finalmix;
  static INT32 *leftmix, *rightmix;
  static int samples_this_frame;
! int global_sound_enabled;
  static int nosound_mode;
  
  static UINT16 latch_clear_value = 0x00;
diff -c -r --new-file xmame-0.95.orig/src/sound/pokey.c xmame-0.95/src/sound/pokey.c
*** xmame-0.95.orig/src/sound/pokey.c	Mon Mar 28 20:20:12 2005
--- xmame-0.95/src/sound/pokey.c	Fri Apr 22 20:22:22 2005
***************
*** 49,54 ****
--- 49,55 ----
  
  #include "driver.h"
  #include "pokey.h"
+ #include "machine/random.h"
  
  /*
   * Defining this produces much more (about twice as much)
***************
*** 903,909 ****
  		 ****************************************************************/
  		if( p->SKCTL & SK_RESET )
  		{
! 			adjust = (UINT32)(timer_timeelapsed(p->rtimer) * p->clock + 0.5);
  			p->r9 = (p->r9 + adjust) % 0x001ff;
  			p->r17 = (p->r17 + adjust) % 0x1ffff;
  		}
--- 904,910 ----
  		 ****************************************************************/
  		if( p->SKCTL & SK_RESET )
  		{
! 			adjust = mame_rand();
  			p->r9 = (p->r9 + adjust) % 0x001ff;
  			p->r17 = (p->r17 + adjust) % 0x1ffff;
  		}
diff -c -r --new-file xmame-0.95.orig/src/unix/config.c xmame-0.95/src/unix/config.c
*** xmame-0.95.orig/src/unix/config.c	Mon Mar 28 20:20:21 2005
--- xmame-0.95/src/unix/config.c	Fri Apr 22 20:22:22 2005
***************
*** 13,18 ****
--- 13,21 ----
  #include "sysdep/sysdep_dsp.h"
  #include "sysdep/sysdep_mixer.h"
  #include "sysdep/misc.h"
+ #include "infofile.h"
+ 
+ extern int global_sound_enabled;
  
  /* be sure that device names are nullified */
  extern void XInput_trackballs_reset();
***************
*** 26,31 ****
--- 29,40 ----
  extern char *playbackname;
  extern char *recordname;
  
+ #include <time.h>
+ extern int frameskip;
+ //W: for regular INP usage
+ extern int isnotwolf;
+ static int override;
+ 
  /* some local vars */
  static int showconfig = 0;
  static int showmanusage = 0;
***************
*** 113,118 ****
--- 122,130 ----
  #endif
  	{ NULL, NULL, rc_link, frontend_list_opts, NULL, 0, 0, NULL, NULL },
  	{ NULL, NULL, rc_link, frontend_ident_opts, NULL, 0, 0, NULL, NULL },
+ 	{ "allownvram", "allownv", rc_bool, &options.allownvram, "0", 0, 0, NULL, "Allow the use of NVRAM when recording or playing back INPs" },
+ 	{ "inpview", "iv", rc_int, &options.inpview, "0", 0, 0, NULL, "Shows a certain play's input on screen in real-time (default 0=disable)" },
+ 	{ "override", NULL, rc_bool, &override, "0", 0, 0, NULL, "Overrides the default action of forcing the use of certain options that were used when recording an INP" },
  	{ "General Options", NULL, rc_seperator, NULL, NULL, 0, 0, NULL, NULL },
  	{ "loadconfig", "lcf", rc_bool, &loadconfig, "1", 0, 0, NULL, "Load (don't load) configfiles" },
  	{ "showconfig", "sc", rc_set_int, &showconfig, NULL, 1, 0, NULL, "Display running parameters in rc style" },
***************
*** 226,231 ****
--- 238,260 ----
  }
  #endif /* MESS */
  
+ //
+ //// might also get it from fgrep "cpu MHz :" "/proc/cpuinfo"
+ ////
+ ////
+ ////
+ ///* ONLY WORKS FOR X86 cpus!!!!!!!!!!! */
+ //
+ 
+ __inline__ unsigned long long int rdtsc()
+ {
+    unsigned long long int x;
+    __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
+    return x;
+ }
+ 
+ 
+ static short first12inpshorts;
  /*
   * get configuration from configfile and env.
   */
***************
*** 393,400 ****
--- 422,490 ----
  	{
  		INP_HEADER inp_header;
  
+ 		int a,oldwolf=0;
+ 		unsigned short chk = 0;
+ 		short* ptr;
+ 
+ 		infoSetFilename(playbackname);
+ 
  		/* read playback header */
+ 		isnotwolf = 0;
  		mame_fread(options.playback, &inp_header, sizeof(INP_HEADER));
+ 		if (inp_header.version[0] != 'W' || inp_header.version[1] < 70)
+ 		{
+ 			fprintf(stderr,"Not an WolfMAME Plus 0.87u1 or later INP file\n");
+ 			isnotwolf = 1;
+ 		}
+ 		if (isnotwolf == 0)
+ 		{
+ 			if (inp_header.version[1] < 79)
+ 			{
+ 				if (inp_header.version[1] == 78 && inp_header.version[2] < 4)
+ 				{
+ 					fprintf(stderr,"Pre-0.78u4 format.  Resetting file pointer.  Check will fail, please don't panic.\n");
+ 					mame_fseek(options.playback,-16,SEEK_CUR);
+ 					oldwolf=1;
+ 				}
+ 			}
+ 			if (inp_header.version[2] != 0)
+ 				printf("Recorded in WolfMAME 0.%iu%i\n",inp_header.version[1],inp_header.version[2]);
+ 			else
+ 				printf("Recorded in WolfMAME 0.%i\n",inp_header.version[1]);
+ 
+ 			printf("Recorded system's speed = ~%dMHz\n",
+ 				(int)(inp_header.spd/1000000));
+ 			if (inp_header.options & 0x02)
+ 				printf("This recording was made with the C 68k core enabled\n");
+ 			else
+ 				printf("This recording was made with the ASM 68k core enabled\n");
+ 			if (inp_header.options & 0x01)
+ 				printf("This recording has cheats enabled\n");
+ 			time_t then=inp_header.starttime;printf("Start date of recording: %s", ctime(&then));
+ 			if (!oldwolf)
+ 			{
+ 				long endtime,k=0x00000;
+ 				do
+ 				{
+ 					endtime = ((inp_header.starttime+k)&0xffff0000)
+ 					  |(inp_header.endtime&0xffff);
+ 					k+=0x10000;
+ 				}
+ 				while (endtime<inp_header.starttime);
+ 				//printf("  DONT KEEP THIS IN WOLFMAME End date of recording: %s", ctime(&endtime));
+ 			}
+ 
+ 			ptr = (INP_HEADER*)&inp_header;
+ 			// dont include the 16th byte which is the end recording
+ 			for(a=0;a<12;a++) // 14
+ 				chk+=(short)*(ptr+a);
+ 			if(inp_header.check != chk)
+ 				printf("Check failed.  Expected %04x, found %04x\n",chk,inp_header.check);
+ 			else
+ 				printf("Checks out OK. [%04x]\n",chk);
+ 		}
+ 		if (!override)
+ 			infoRead(&options);
  
  		if (!isalnum(inp_header.name[0])) /* If first byte is not alpha-numeric */
  			mame_fseek(options.playback, 0, SEEK_SET); /* old .inp file - no header */
***************
*** 622,630 ****
--- 712,802 ----
  	if (options.record)
  	{
  		INP_HEADER inp_header;
+ 		int start,end,priority,a;  extern char build_version[];
+ 		unsigned short chk = 0;
+ 		short* ptr;
  
  		memset(&inp_header, '\0', sizeof(INP_HEADER));
  		strcpy(inp_header.name, drivers[game_index]->name);
+ 		infoSetShortName(drivers[game_index]->name);
+ 		infoSetFilename(recordname);
+ 		infoSetBIOSString(options.bios);
+       /* MAME32 stores the MAME version numbers at bytes 9 - 11
+ 		 * MAME DOS keeps this information in a string, the
+ 		 * Windows code defines them in the Makefile.
+ 		 *                      */
+       /*
+ 		 * inp_header.version[0] = 0;
+ 		 * inp_header.version[1] = VERSION;
+ 		 * inp_header.version[2] = BETA_VERSION;
+ 		 *                                   */
+ 		inp_header.version[0] = 'W';
+ 		inp_header.version[1] = (char)(100*atof(build_version)+.5);
+ 		inp_header.version[2] = 0; /* BETA # */
+ 
+ 		inp_header.options = 0;
+ 		inp_header.options += options.cheat;
+ 
+ 		/* C vs ASM core is not a command line option */
+ 		/* so we check the preporcessor ... options.m68k_c_core*2; */
+ #if defined(A68K0)
+ 		/* using ASM core */
+ 		inp_header.options |= 0*2;
+ #else
+ 		/* using C core */
+ 		inp_header.options |= 1*2;
+ #endif
+ 		inp_header.fskip = frameskip;
+ 
+ 		inp_header.options2 = 0;
+ 		inp_header.options2 += global_sound_enabled;
+ 
+ 		// do clock speed detection
+ 		{
+ 			struct timezone tz;
+ 			struct timeval tvstart, tvstop;
+ 
+ 			unsigned long long int cycles[2]; /* gotta be 64 bit */
+ 			unsigned long microseconds; /* total time taken */
+ 			double freq = 1.0f;
+ 
+ 			memset(&tz, 0, sizeof(tz));
+ 
+ 			/* get this function in cached memory */
+ 			gettimeofday(&tvstart, &tz);
+ 			cycles[0] = rdtsc();
+ 			gettimeofday(&tvstart, &tz);
+ 
+ 			/* we don't trust that this is any specific length of time */
+ 			usleep(125000);
+ 			//usleep(250000);
+ 
+ 			gettimeofday(&tvstop, &tz);
+ 			cycles[1] = rdtsc();
+ 			gettimeofday(&tvstop, &tz);
+ 
+ 			microseconds = ((tvstop.tv_sec-tvstart.tv_sec)*1000000) +
+ 			  (tvstop.tv_usec-tvstart.tv_usec);
+ 
+       	inp_header.spd = 1000000*(double)(cycles[1]-cycles[0])
+ 					  /(microseconds/freq);
+ 		}
+ 		infoSetSpeed(inp_header.spd);
+ 
+       inp_header.starttime = (long)time(NULL);
+       inp_header.endtime = inp_header.starttime&0xffff;
+ 
+ 		ptr = (INP_HEADER*)&inp_header;
+ 		// include the 16th byte which is the end recording
+ 		for(a=0;a<12;a++) // 14
+ 		{
+ 			if (a==12)
+ 				first12inpshorts=chk;
+ 			chk+=(short)*(ptr+a);
+ 		}
+ 		inp_header.check = chk;
+ 		infoSetOptions(&options);
+ 
  		mame_fwrite(options.record, &inp_header, sizeof(INP_HEADER));
  	}
  
***************
*** 648,653 ****
--- 820,842 ----
  	return 1234;
  }
  
+ void writeInpStartTime(void)
+ {
+ 	INT64 curpos=mame_ftell(options.record);
+ 	UINT32 starttime = (long)time(NULL);
+ 	INP_HEADER temp;
+ 	mame_fseek(options.record,(INT64)((char*)&temp.starttime-(char*)&temp),SEEK_SET);
+ 	mame_fwrite(options.record,&starttime,sizeof(UINT32));
+ 	//first12inpshorts += ((short*)&starttime)[0];
+ 	//first12inpshorts += ((short*)&starttime)[1];
+ 
+ 	//mame_fseek(options.record,(INT64)((char*)&temp.check-(char*)&temp),SEEK_SET);
+ 	//mame_fwrite(options.record,&first12inpshorts,sizeof(UINT32));
+ 
+ 	// return to the previous position
+ 	mame_fseek(options.record,curpos,SEEK_SET);
+ }
+ 
  void config_exit(void)
  {
  	gamename = NULL;
***************
*** 671,677 ****
--- 860,882 ----
  	}
  	if (options.record)
  	{
+ 		INP_HEADER temp;
+ 		UINT32 endtime = (UINT32)time(NULL);
+ 		temp.endtime = endtime&0xffff;
+ 		mame_fseek(options.record,(INT64)((char*)&temp.endtime-(char*)&temp),SEEK_SET);
+ 		mame_fwrite(options.record,&endtime,sizeof(short));
+ 		/*
+ 		first12inpshorts += ((short*)&endtime)[0];
+ 		first12inpshorts += ((short*)&endtime)[1];
+ 		mame_fwrite(options.record,&first12inpshorts,sizeof(UINT32));
+ 		*/
  		mame_fclose(options.record);
+ 	   endtime = infoWrite();
+ 		if (endtime)
+ 			printf("OK\n");
+ 		else
+ 			printf("Fail\n");
+ 
  		options.record = NULL;
  	}
  	if (options.language_file)
diff -c -r --new-file xmame-0.95.orig/src/unix/fileio.c xmame-0.95/src/unix/fileio.c
*** xmame-0.95.orig/src/unix/fileio.c	Mon Mar 28 20:20:21 2005
--- xmame-0.95/src/unix/fileio.c	Sat Apr 23 10:18:09 2005
***************
*** 349,356 ****
  
  	/* when finished, reset the path info, so that future INI parsing 
  	 * will cause us to get called again */
! 	free((void *)list->rawpath);
! 	list->rawpath = NULL;
  	return;
  
  out_of_memory:
--- 349,358 ----
  
  	/* when finished, reset the path info, so that future INI parsing 
  	 * will cause us to get called again */
! 	// This doesn't make sense, why would you care to change the ini file
! 	// DURRING mame play...
! 	// free((void *)list->rawpath);
! 	// list->rawpath = NULL;
  	return;
  
  out_of_memory:
***************
*** 406,411 ****
--- 408,416 ----
  			list = &pathlist[FILETYPE_ROM];
  			break;
  #endif
+ 		case FILETYPE_WLF:
+ 			list = &pathlist[FILETYPE_INPUTLOG];
+ 			break;
  
  		default:
  			list = &pathlist[filetype];
diff -c -r --new-file xmame-0.95.orig/src/unix/main.c xmame-0.95/src/unix/main.c
*** xmame-0.95.orig/src/unix/main.c	Mon Mar 28 20:20:21 2005
--- xmame-0.95/src/unix/main.c	Fri Apr 22 20:50:27 2005
***************
*** 10,15 ****
--- 10,17 ----
  #include <sys/mman.h>
  #endif
  
+ extern void *record;
+ 
  /* put here anything you need to do when the program is started. Return 0 if */
  /* initialization was successful, nonzero otherwise. */
  int osd_init(void)
***************
*** 28,33 ****
--- 30,40 ----
   */
  void osd_exit(void)
  {
+ 	if (record)
+ 	{
+ 		int ret;
+ 		//mame_fclose(record);
+ 	}
  #ifdef XMAME_NET
  	osd_net_close();
  #endif
diff -c -r --new-file xmame-0.95.orig/src/unix/video.c xmame-0.95/src/unix/video.c
*** xmame-0.95.orig/src/unix/video.c	Mon Mar 28 20:29:56 2005
--- xmame-0.95/src/unix/video.c	Fri Apr 22 20:22:22 2005
***************
*** 19,24 ****
--- 19,33 ----
  #include "devices.h"
  #include "sysdep/misc.h"
  #include "sysdep/sysdep_display.h"
+ #include "infofile.h"
+ 
+ /* W: From window.c */
+ extern UINT32 framer;
+ extern void* record;
+ extern void* playback;
+ extern double speed_total;
+ extern unsigned int speed_counter;
+ extern int isnotwolf;
  
  #define FRAMESKIP_DRIVER_COUNT 2
  static int frameskipper = 0;
***************
*** 603,608 ****
--- 612,622 ----
  	{
  		cycles_t cps = osd_cycles_per_second();
  		fprintf(stderr_file, "Average FPS: %f (%d frames)\n", (double)cps / (end_time - start_time) * frames_displayed, frames_displayed);
+ 		if (playback && !isnotwolf)
+ 			fprintf(stderr_file, "Average recorded speed: %f%% (%d frames)\n",
+ 				speed_total / speed_counter, speed_counter);
+ 		if (record)
+ 			infoSetFrameCount(speed_counter, speed_total/speed_counter);
  	}
  }
  
***************
*** 1250,1256 ****
  		/* reset the frame counter so we'll measure the average FPS on a consistent status */
  		frames_displayed = 0;
  	}
! 	if (input_ui_pressed(IPT_UI_THROTTLE))
  	{
  		if (!code_pressed(KEYCODE_LSHIFT) && !code_pressed(KEYCODE_RSHIFT))
  		{
--- 1264,1270 ----
  		/* reset the frame counter so we'll measure the average FPS on a consistent status */
  		frames_displayed = 0;
  	}
! 	if (input_ui_pressed(IPT_UI_THROTTLE) && !record)
  	{
  		if (!code_pressed(KEYCODE_LSHIFT) && !code_pressed(KEYCODE_RSHIFT))
  		{
***************
*** 1414,1419 ****
--- 1428,1437 ----
  	  snprintf(dest, bufsize, "\n %d vector updates", performance->vector_updates_last_second);
  	else if (performance->partial_updates_this_frame > 1)
  	  snprintf(dest, bufsize, "\n %d partial updates", performance->partial_updates_this_frame);
+ 	if (playback && !mame_feof(playback))
+ 	{
+ 		dest += sprintf(dest, "\n Recorded xspeed: %4u%%", framer - 0xe143823e);
+ 	}
  
  	/* return a pointer to the static buffer */
  	return buffer;
diff -c -r --new-file xmame-0.95.orig/src/usrintrf.c xmame-0.95/src/usrintrf.c
*** xmame-0.95.orig/src/usrintrf.c	Mon Mar 28 20:29:10 2005
--- xmame-0.95/src/usrintrf.c	Fri Apr 22 20:22:22 2005
***************
*** 4098,4103 ****
--- 4098,4109 ----
  }
  
  
+ /* W: for speed stor */
+ extern void* record;
+ extern UINT32 framer;
+ // W: for inp view
+ extern char inputstr[80];
+ 
  
  int handle_user_interface(struct mame_bitmap *bitmap)
  {
***************
*** 4149,4168 ****
  	if (input_ui_pressed(IPT_UI_RESET_MACHINE))
  		machine_reset();
  
! 	if (input_ui_pressed(IPT_UI_SAVE_STATE))
  		do_loadsave(bitmap, LOADSAVE_SAVE);
  
! 	if (input_ui_pressed(IPT_UI_LOAD_STATE))
  		do_loadsave(bitmap, LOADSAVE_LOAD);
  
  #ifndef MESS
! 	if (single_step || input_ui_pressed(IPT_UI_PAUSE)) /* pause the game */
  	{
  #else
  	if (setup_selected)
  		mess_pause_for_ui = 1;
  
! 	if (single_step || input_ui_pressed(IPT_UI_PAUSE) || mess_pause_for_ui) /* pause the game */
  	{
  #endif
  /*		osd_selected = 0;	   disable on screen display, since we are going   */
--- 4155,4174 ----
  	if (input_ui_pressed(IPT_UI_RESET_MACHINE))
  		machine_reset();
  
! 	if (input_ui_pressed(IPT_UI_SAVE_STATE) && !record)
  		do_loadsave(bitmap, LOADSAVE_SAVE);
  
! 	if (input_ui_pressed(IPT_UI_LOAD_STATE) && !record)
  		do_loadsave(bitmap, LOADSAVE_LOAD);
  
  #ifndef MESS
! 	if ((single_step || input_ui_pressed(IPT_UI_PAUSE)) && !record) /* pause the game */
  	{
  #else
  	if (setup_selected)
  		mess_pause_for_ui = 1;
  
! 	if ((single_step || input_ui_pressed(IPT_UI_PAUSE) || mess_pause_for_ui) && !record) /* pause the game */
  	{
  #endif
  /*		osd_selected = 0;	   disable on screen display, since we are going   */
***************
*** 4193,4199 ****
  				do_loadsave(bitmap, LOADSAVE_LOAD);
  
  			/* if the user pressed F4, show the character set */
! 			if (input_ui_pressed(IPT_UI_SHOW_GFX))
  				showcharset(bitmap);
  
  			if (setup_selected == 0 && input_ui_pressed(IPT_UI_CANCEL))
--- 4199,4205 ----
  				do_loadsave(bitmap, LOADSAVE_LOAD);
  
  			/* if the user pressed F4, show the character set */
! 			if (input_ui_pressed(IPT_UI_SHOW_GFX) && !record)
  				showcharset(bitmap);
  
  			if (setup_selected == 0 && input_ui_pressed(IPT_UI_CANCEL))
***************
*** 4279,4284 ****
--- 4285,4296 ----
  
  	if (show_profiler) profiler_show(bitmap);
  
+ 	/* W: Store speed */
+ 	if (record)
+ 	{
+ 		const struct performance_info *performance = mame_get_performance_info();
+ 		framer = (UINT32)(performance->game_speed_percent + 0.5);
+ 	}
  
  	/* show FPS display? */
  	if (input_ui_pressed(IPT_UI_SHOW_FPS))
***************
*** 4304,4309 ****
--- 4316,4328 ----
  		drawgfx_toggle_crosshair();
  	}
  
+ 	// W: show inp view
+ 	if (options.inpview)
+ 	{
+ 		//convert_command_move(inputstr);
+ 		ui_text(bitmap,inputstr,0,uirotheight - uirotcharheight);
+ 	}
+ 			  	
  	/* add the FPS counter */
  	ui_display_fps(bitmap);
  
diff -c -r --new-file xmame-0.95.orig/src/xml2info.c xmame-0.95/src/xml2info.c
*** xmame-0.95.orig/src/xml2info.c	Mon Mar 28 20:20:14 2005
--- xmame-0.95/src/xml2info.c	Fri Apr 22 20:22:22 2005
***************
*** 9,15 ****
  /* libexpat */
  
  /* Use the system libexpat library */
! #include "expat.h"
  
  #include <stdio.h>
  #include <stdlib.h>
--- 9,15 ----
  /* libexpat */
  
  /* Use the system libexpat library */
! #include "expat/expat.h"
  
  #include <stdio.h>
  #include <stdlib.h>

