summaryrefslogblamecommitdiffstatshomepage
path: root/src/mame/drivers/vlc.c
blob: 71030cc16a9bc50234ec59287f6d76e539a11cb8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                 


 




















                                                                                               
                                  


















































                                                                                      
                                             











                                                                                                            
                                     







                                                                        
                                                                                                                                                                             




                                                                                                                                                                             
 


  
                                  





























                                                                                      

                                                 





                                             
 


                                                        
                                            
                                             
 
                            
 

                                    
 


                                
 








                                                                                  
                                                                        
 
                                                         



                                                                                          















                                                                                               






                                                                             
                                      
 


                                                                               







                                                            



                                    
                                     
 












                                                                             
                        
 


                                                                       




                                                                             

                                                             





                                                                             

                                                              
 



                                                                 
 
                                        






                                                                             
       
  


                                                                                                     




                                                                             
               



                                                                       
                 




                                                                             
                       















                                                                             
                 


                                                                                                                                            
                 




                                                                            
                                                   




                                                                            
 





                                                                                                   

                                                                        

                           
                                          
         


















                                                                             
 





                                                                                                   

                                                                        

                           
                                  
         

            
                                                          

         




















                                                                             
                             





                                                                                                   
                             
                                                                                            

                           
                                                                         

            


                                            



                                                                             
                                     



















                                                                             
                                                                                                                            














                                                                             

                                             

                                                            





                                                                             
 

                                                 



                                                                             
                                                         



                                                                             
                                                           



                                                                             


                                                                          





                                                                                                              
 



                                                                             

                                                                          
                                                                              
                                                                                                        
                                                   










                                                                             
 
















                                                                             
                                                                      




















                                                                    
                                                                                                    



                                                                    
                                                                    




                                                                    
            








                                                                                           
                               







                                                                                           
  



                                                                             
                                                                                              



                                                                                              

                                                                                               

                                                                                                    

                                                                                                                           













                                                                                                                                     
                                                                      

































                                                                                             
                                                        


































                                                                                  
                                                                  
 


                                                                   











                                                                             
 
                                  
                                                                                                           


                                  



                                         
                                                       




                                                                                                                                  
                                                

                                 
 
                                                                  
 




                                                    
 





                                                                                                                                      
 



                                                                             
                                                                

                                                                                                                                                         
 
                                                                                                                                                      

                                                                                                                              
                                                                          



                                                                                                                                                                              
                                                                                                                                                
 



                          







                                                                             
                                                             
 
                                                       
 


                                                 


                             
                            



                                        


                                    








                                                                                                      
                                                                                                                                           
/*     vlc.c
Multi-games from VLC Nevada 1995
CGA monitor 15Khz 60hz
// CPU    CLOCK use Crystal 16.000MHZ
// VIDEO  CLOCK use Crystal 33.000MHZ

    - 1x MC68000  (CPU)  8mhz
    - 1x MC68B45P (CRTC)
    - 1x AY3-8912 (sound)
    - 1x M4262B oki (RTC CLOCK)
    - 3x MC68681  (2 x UART)
    - 4x 27C512
    - 2x 62256 NVRAM  + batt  (connect in 16bits)
    - 2x 6264  BACKUP + batt  (connect in  8bits)
    - 1x MODEM XE1214 from XECOM (300/1200 Baud)



on MAME 0.145u4
Yves
Todo :
Video Section
Security PAL U35 decoding
In/Out interface Board communication (included mechanical METER + some switch Door open ,etc..)
JCM Bill acceptor communication (probably ID-003 protocol)
PRINTER communication (Star Printer )

******************************************************
******************************************************
SECURITY SYSTEM

ADRESS A40000..A40001
U35 PAL16R8  SECURITY
PAL is connect on the BUS D15..D8
Write Clock 8 bits in D15..D8
Read  OE    8 bit  on D15..D8

U50 4Bit D Flop Register is connect on D3..D0
this one seem to have 2 use.
1. keep track of the PAL16R8 state
2. DOOR SWITCH is connect on U50 Clear pin (D3..D0 LOW = Door Open)
Write Clock 4 bits in D-Flop Register
Read  OE    4 bits on D3..D0


Boot Section is locate in NVRAM. Interrupts Pointers are changed on the fly.
seem to check hardware WDT ,Power Failure , interrupt system,etc..  before game start.

INT7 seem to control POWER FAILURE ,WDT.
INT7 initialisation is needed to boot the game.

******************************************************
******************************************************
VIDEO REGISTER of 6845

BOOT:FE1A82 00A5 0000           CRTC_TYPE1:     dc.l unk_A50000
BOOT:FE1A86 0000                                dc.b   0
BOOT:FE1A87 0000                                dc.b   0
BOOT:FE1A88 0000                                dc.b   0
BOOT:FE1A89 0000                                dc.b   0
BOOT:FE1A8A 0000                                dc.b   0
BOOT:FE1A8B 0007                                dc.b   7
BOOT:FE1A8C 0000                                dc.b   0
BOOT:FE1A8D 001F                                dc.b $1F
BOOT:FE1A8E 001F                                dc.b $1F
BOOT:FE1A8F 0002                                dc.b   2
BOOT:FE1A90 0020                                dc.b $20
BOOT:FE1A91 0003                                dc.b   3
BOOT:FE1A92 0023                                dc.b $23 * #
BOOT:FE1A93 001F                                dc.b $1F
BOOT:FE1A94 002A                                dc.b $2A * *
BOOT:FE1A95 0000                                dc.b   0
BOOT:FE1A96 00A5 8000           CRTC_TYPE2:     dc.l unk_A58000
BOOT:FE1A9A 00FF                                dc.b $FF
BOOT:FE1A9B 0000                                dc.b   0
BOOT:FE1A9C 0000                                dc.b   0
BOOT:FE1A9D 0000                                dc.b   0
BOOT:FE1A9E 0000                                dc.b   0
BOOT:FE1A9F 0007                                dc.b   7
BOOT:FE1AA0 0000                                dc.b   0
BOOT:FE1AA1 001F                                dc.b $1F
BOOT:FE1AA2 001F                                dc.b $1F
BOOT:FE1AA3 0002                                dc.b   2
BOOT:FE1AA4 0020                                dc.b $20
BOOT:FE1AA5 0006                                dc.b   6
BOOT:FE1AA6 0033                                dc.b $33 * 3
BOOT:FE1AA7 002D                                dc.b $2D * -
BOOT:FE1AA8 0040                                dc.b $40 * @
BOOT:FE1AA9 0000                                dc.b   0


BOOT:FE19F0                     INI_CRTC6845:
BOOT:FE19F0 48E7 8140                           movem.l d0/d7/a1,-(sp)
BOOT:FE19F4 2258                                movea.l (a0)+,a1        * type1 = 0xA50000, type2 = 0xA80000
BOOT:FE19F6 50D1                                st      (a1)
BOOT:FE19F8 11D8 0435                           move.b  (a0)+,(ScreenMode)
BOOT:FE19FC 4278 0412                           clr.w   (word_412)
BOOT:FE1A00 2248                                movea.l a0,a1
BOOT:FE1A02 3E3C 0FFF                           move.w  #$FFF,d7
BOOT:FE1A06 307C 0000                           movea.w #0,a0
BOOT:FE1A0A 6100 0108                           bsr     set_vid_D0_A0   * D0 = 0x800020
BOOT:FE1A0A                                                             * A0 = 0xB00000
BOOT:FE1A0E 7E0D                                moveq   #$D,d7
BOOT:FE1A10
BOOT:FE1A10                     LOOP:
BOOT:FE1A10 13C7 0090 0001                      move.b  d7,(CRTC_ADR)
BOOT:FE1A16 13D9 0090 8001                      move.b  (a1)+,(CRTC_DAT)
BOOT:FE1A1C 51CF FFF2                           dbf     d7,LOOP
BOOT:FE1A20 4CDF 0281                           movem.l (sp)+,d0/d7/a1
BOOT:FE1A24 4E75                                rts


    *** MC6845 Initialization ***
                Htotal   Hdisp   HsyncPos HsyncW   Vtotal  VtotalAdj Vdisp  VsyncPos InterMode MaxScanAdr CurStart CurEnd StartAdrH StartAdrL CurH  CurL  LightPenH LightPenL
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    register:   00       01      02       03       04      05        06     07       08        09         10       11     12        13        14    15    16        17
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
nevada TYPE1 :  42       31      35       03       32      02        31     31       00        07         00       00     00        00        00    00    00        00
nevada TYPE2 :  64       45      51       06       32      02        31     31       00        07         00       00     00        00        00    00    00        00

*/


#define MASTER_CLOCK    XTAL_16MHz
#define MASTER_CPU            ((MASTER_CLOCK)/2)    // 8mhz
#define SOUND_CLOCK           ((MASTER_CLOCK) /8)   // 2mhz

#define VIDEO_CLOCK           XTAL_33MHz
#define MC6845_CLOCK          ((VIDEO_CLOCK)/4/16)  // 0.515625 MHZ


#include "emu.h"
#include "cpu/m68000/m68000.h"
#include "machine/68681.h"
#include "video/mc6845.h"
#include "sound/ay8910.h"
#include "machine/msm6242.h"
#include "machine/microtch.h"


/***************************************************************************

                                 General

***************************************************************************/


class nevada_state : public driver_device
{
public:
	nevada_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag),
		m_maincpu(*this,"maincpu"),
		m_microtouch(*this,"microtouch"),
			m_nvram(*this, "nvram"),
			m_backup(*this, "backup")
		{ }

	DECLARE_WRITE8_MEMBER(microtouch_tx);
	device_t *m_duart18_68681;
	device_t *m_duart39_68681;
	device_t *m_duart40_68681;

	required_device<cpu_device> m_maincpu;
	optional_device<microtouch_device> m_microtouch;

	required_shared_ptr<UINT16> m_nvram;
	required_shared_ptr<UINT16> m_backup;

	UINT16  m_datA40000;

		//UINT8* m_videoram;
		//UINT8* m_colorram;

	UINT16* m_videoram;
	tilemap_t *m_bg_tilemap;


	DECLARE_DRIVER_INIT(nevada);
};

/*
need further test on PAL16R8 (FlipFlop Trick with other bits ?)
this DUMP is done writing 0 to 255 and reading output (probably not the good way.)

PAL is connected on the UPPER byte D15..D8
Adress A40000..A40001
2 Type of PAL (one for game, the other is to set game to fabric default)

there is a 74LS173 on the LOWER byte that used bit D3..D0
funny thing , the DOOR ACCESS Switch is connected on the CLEAR  PIN of this 4bits register
so when D3..D0 are LOW , DOOR is OPEN
*/
static const UINT8 pal35[256] = {
0x11, 0x42, 0x5B, 0xCA, 0x19, 0x42, 0x5B, 0xCA, 0x38, 0x63, 0x3A, 0x63, 0x3A, 0x63, 0x3A, 0x63,
0xD3, 0x08, 0x5B, 0xCA, 0x19, 0xCA, 0x19, 0xCA, 0x18, 0xEB, 0x18, 0xEB, 0x18, 0xEB, 0x18, 0xEB,
0xD3, 0xCA, 0x5B, 0xCC, 0x5B, 0xCC, 0x5B, 0xCC, 0xBA, 0x63, 0x38, 0x65, 0x38, 0x65, 0x38, 0x65,
0xD1, 0xCA, 0x5B, 0xC8, 0x5B, 0xC8, 0x5B, 0xC8, 0x9A, 0xEB, 0x1A, 0xED, 0x1A, 0xED, 0x1A, 0xED,
0x0C, 0x65, 0xF0, 0x00, 0x64, 0xF5, 0x04, 0x65, 0xB8, 0x25, 0x20, 0x20, 0x24, 0x24, 0x24, 0x24,
0xF0, 0x00, 0xF8, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xB8, 0x3D, 0xFC, 0x19, 0xFC, 0x19, 0xFC, 0x19,
0x44, 0xF9, 0xC4, 0xF9, 0xC4, 0xFD, 0xC4, 0xFD, 0xFC, 0xFD, 0xFC, 0xFD, 0xFC, 0xFD, 0xFC, 0xFD,
0xC0, 0xD9, 0xC8, 0xD9, 0xC8, 0xD9, 0xC8, 0xD9, 0xD8, 0xD9, 0xD8, 0xD9, 0xD8, 0xD9, 0xD8, 0xD9,
0x0C, 0x44, 0xFB, 0x04, 0x67, 0xD4, 0x0C, 0x44, 0xBA, 0x24, 0x22, 0x02, 0x26, 0x06, 0x26, 0x06,
0xFB, 0x00, 0xFB, 0x00, 0xEF, 0x10, 0xCE, 0x18, 0xEF, 0x18, 0xEF, 0x18, 0xFF, 0x18, 0xFF, 0x18,
0x44, 0xF8, 0xC6, 0xD8, 0xCE, 0xDC, 0xCE, 0xDC, 0xEF, 0x9E, 0x67, 0xB8, 0x67, 0xBC, 0x67, 0xBC,
0xC6, 0xD8, 0xCA, 0xD8, 0xCA, 0xD8, 0xCA, 0xD8, 0xCB, 0x9A, 0xEF, 0x9A, 0xFF, 0xD8, 0xDB, 0xD8,
0x66, 0xF4, 0x00, 0x64, 0xBA, 0x25, 0x22, 0x22, 0x26, 0x26, 0x26, 0x26, 0xF2, 0x00, 0xFA, 0x00,
0xFA, 0x00, 0xFA, 0x00, 0xBA, 0x3D, 0xFA, 0x19, 0xFA, 0x19, 0xFA, 0x19, 0x44, 0xF9, 0xC2, 0xF0,
0xC2, 0xF4, 0xC2, 0xF4, 0xFA, 0xF4, 0xFA, 0xF4, 0xFA, 0xF4, 0xFA, 0xF4, 0xC2, 0xD0, 0xCA, 0xD0,
0xCA, 0xD0, 0xCA, 0xD0, 0xDA, 0xD0, 0xDA, 0xD0, 0xDA, 0xD0, 0xDA, 0xD0, 0x08, 0x63, 0xD3, 0x08
};


/***************************************************************************/
/********************   VIDEO SECTION   ************************************/
/***************************************************************************/

static MC6845_INTERFACE( mc6845_intf )
{
	"screen",	/* screen we are acting on */
	false,		/* show border area */
	8,			/* number of pixels per video memory address */
	NULL,       /* before pixel update callback */
	NULL,       /* row update callback */
	NULL,       /* after pixel update callback */
	DEVCB_NULL, /* callback for display state changes */
	DEVCB_NULL, /* callback for cursor state changes */
	DEVCB_NULL, /* HSYNC callback */
	DEVCB_NULL, /* VSYNC callback */
	NULL        /* update address callback */
};

static const gfx_layout charlayout =
{
	/* Todo  , just for sample */

	8,8,
	RGN_FRAC(1,4),
	4,
	{ RGN_FRAC(0,4), RGN_FRAC(1,4), RGN_FRAC(2,4), RGN_FRAC(3,4) },
	{ 0, 1, 2, 3, 4, 5, 6, 7 },
	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
	8*8
};

/***************************************************************************/
/*
static WRITE16_HANDLER( nevada_videoram_w )
{
// Todo, Just for sample

    nevada_state *state = space->machine().driver_data<nevada_state>();
    state->m_videoram[offset] = data;
    state->m_bg_tilemap->mark_tile_dirty(offset);

}
*/
/***************************************************************************/
static GFXDECODE_START( nevada )
	/* Todo  , just for sample */
	GFXDECODE_ENTRY( "gfx1", 0x0000, charlayout,   0, 8 )
GFXDECODE_END

/***************************************************************************/
/*
static TILE_GET_INFO( get_bg_tile_info )
{
// Todo, Just for sample
    nevada_state *state = machine.driver_data<nevada_state>();

    int attr = state->m_colorram[tile_index];
    int code = ((attr & 1) << 8) | state->m_videoram[tile_index];
    int bank = (attr & 0x02) >> 1;
    int color = (attr & 0x3c) >> 2;

    SET_TILE_INFO(bank, code, color, 0);

}
*/

/***************************************************************************/
static VIDEO_START( nevada )
{
// todo
/*
    nevada_state *state = machine.driver_data<nevada_state>();
    state->m_bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
*/
}

/***************************************************************************/
static SCREEN_UPDATE_IND16( nevada )
{
	// Todo
/*
    nevada_state *state = screen.machine().driver_data<nevada_state>();
    state->m_bg_tilemap->draw(bitmap, cliprect, 0, 0);
*/
	return 0;
}

/***************************************************************************/
static PALETTE_INIT( nevada )
{
	// Palette init
}

/***************************************************************************/
/********************   NVRAM SECTION   ************************************/
/***************************************************************************/

static  NVRAM_HANDLER( nevada )
{
	nevada_state *state = machine.driver_data<nevada_state>();
	if (read_or_write)
		file->write(state->m_nvram,state->m_nvram.bytes());
	else
	{
		if (file)
			file->read(state->m_nvram,state->m_nvram.bytes());
		else
		{
			UINT16* defaultram = (UINT16 *) state->memregion("defaults")->base();
			memset(state->m_nvram,0x00,state->m_nvram.bytes());
			if (defaultram) memcpy(state->m_nvram, state->memregion("defaults")->base(), state->memregion("defaults")->bytes());
		}
	}
}

/***************************************************************************

    U18 MC68681 RS232 UART  SIDEA = MODEM 1200 Baud
    U18 MC68681 RS232 UART  SIDEB = not used
    Interrupt 4
***************************************************************************/

static void duart18_irq_handler(device_t *device, int state, UINT8 vector )
{
	device->machine().device("maincpu")->execute().set_input_line_and_vector(4, state, vector);
};

/***************************************************************************/
static void duart18_tx(device_t *device, int channel, UINT8 data)
{
//  nevada_state *state = device->machine().driver_data<nevada_state>();
/* Todo  , just for sample */
	if ( channel == 0 )
	{
			// Modem 1200 Baud
	}
};

/***************************************************************************/
static UINT8 duart18_input( device_t *device )
{
	return device->machine().root_device().ioport("DSW1")->read();
}

/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************

    U39 MC68681 RS232 UART SIDEA = Printer J3 (rs232)
    U39 MC68681 RS232 UART SIDEB = Player Tracking Interface J2 (not used)
    Interrupt 3
***************************************************************************/

static void duart39_irq_handler( device_t *device, int state, UINT8 vector )
{
	device->machine().device("maincpu")->execute().set_input_line_and_vector(3, state, vector);
};

/***************************************************************************/
static void duart39_tx(device_t *device, int channel, UINT8 data)
{
//  nevada_state *state = device->machine().driver_data<nevada_state>();
/* Todo  , just for sample */
	if ( channel == 0 )
	{
			// Printer
	}
	else
	{
		// Player Tracking Interface J2 (not used)
	}

};

/***************************************************************************/
static UINT8 duart39_input( device_t *device )
{
	return device->machine().root_device().ioport("DSW2")->read();
}

/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************

    68681 DUART <-> Microtouch touch screen controller communication
    U40 MC68681 RS232 UART  SIDEA = TouchScreen J1 (RS232)
    U40 MC68681 RS232 UART  SIDEB = JCM Bill Acceptor (RS422)
    Interrupt 5
***************************************************************************/

static void duart40_irq_handler( device_t *device, int state, UINT8 vector )
{
/* Todo  , just for sample */
	device->machine().device("maincpu")->execute().set_input_line_and_vector(5, state, vector);
};

/***************************************************************************/
static void duart40_tx( device_t *device, int channel, UINT8 data )
{
/* Todo  , just for sample */
			nevada_state *state = device->machine().driver_data<nevada_state>();
	if ( channel == 0 )
	{
		state->m_microtouch->rx(state->generic_space(), 0, data);
	}
	else
			{
			// JCM Bill Acceptor
			}
};
/***************************************************************************/
WRITE8_MEMBER( nevada_state::microtouch_tx )
{
	/* Todo  , just for sample */
	duart68681_rx_data(m_duart40_68681, 0, data);
}

static const microtouch_interface nevada_microtouch_config =
{
	DEVCB_DRIVER_MEMBER(nevada_state, microtouch_tx),
	NULL
};
/***************************************************************************/
static UINT8 duart40_input( device_t *device )
{
	return device->machine().root_device().ioport("DSW3")->read();
}


/***************************************************************************/
/*********************    RTC SECTION       ********************************/
/***************************************************************************/
static WRITE_LINE_DEVICE_HANDLER(nevada_rtc_irq)
{
	device->machine().device("maincpu")->execute().set_input_line(INPUT_LINE_IRQ1, HOLD_LINE);  // rtc interrupt on INT1
}

/***************************************************************************/
static MSM6242_INTERFACE( nevada_rtc_intf )
{
	DEVCB_LINE(nevada_rtc_irq)
};

/***************************************************************************/
/*********************    SOUND SECTION     ********************************/
/***************************************************************************/
static const ay8910_interface ay8910_config =
{
	AY8910_LEGACY_OUTPUT,
	AY8910_DEFAULT_LOADS,
//  DEVCB_INPUT_PORT("DSW1"),  /* not used */
//  DEVCB_INPUT_PORT("DSW2"),  /* not used */
	DEVCB_NULL, /* callback for display state changes */
	DEVCB_NULL, /* callback for cursor state changes */
	DEVCB_NULL,
	DEVCB_NULL
};

/***************************************************************************/
static READ16_HANDLER(io_board_r)
{
	// IO board Serial communication 0xA00000
	return 1;
}
/***************************************************************************/
static WRITE16_HANDLER(io_board_w)
{
	// IO board Serial communication 0xA00000 on bit0
}
/***************************************************************************/
static WRITE16_HANDLER (io_board_x)
{
	// IO board Serial communication 0xA80000  on bit15
}

/***************************************************************************/
static READ16_HANDLER( nevada_sec_r )
{
	nevada_state *state = space.machine().driver_data<nevada_state>();
//  D3..D0 = DOOR OPEN or Track STATE of PAL35
	UINT16 res;
		/* UPPER byte is use for input in PAL35 */
			// 74LS173 $bits Register used LOWER bits D3..D0 for PAL35 state and DOOR LOGIC SWITCH
			res = pal35[state->m_datA40000 >> 8];
			res = res << 8;
			res = res | (state->m_datA40000 & 0x00FF);

	return res;
}
/***************************************************************************/
static WRITE16_HANDLER( nevada_sec_w )
{
	nevada_state *state = space.machine().driver_data<nevada_state>();
	// 74LS173 $bits Register used LOWER bits D3..D0 for DOOR LOGIC SWITCH
	state->m_datA40000 = data | 0x00f0;     // since D7..D4 are not used and are connected to PULLUP
//  popmessage("WRITE %04x %04x  ",datA40000,data);
}

/***************************************************************************/

/*
DOOR Switch desc
1 x FRONT DOOR SW
1 x REAR DOOR SW
1 x COIN DOOR SW
1 x TOP DOOR SW
1 x COMPUTER DOOR SW

Interrupt Vector
INT1  RTC MSM6242
INT2  nc
INT3  UART U39
INT4  UART U18
INT5  UART U40
INT6  nc
INT7  Seem to be used for confirmation of Ds1232 WDT work (need futher check)

U40 MC68681 RS232 UART  SIDEA = TouchScreen J1 (RS232)
U40 MC68681 RS232 UART  SIDEB = JCM Bill Acceptor (RS422)

U39 MC68681 RS232 UART SIDEA = Printer J3 (rs232)
U39 MC68681 RS232 UART SIDEB = Player Tracking Interface J2 (not used)

U18 MC68681 RS232 UART SIDEA = MODEM LOW SPEED 1200 BAUD from XECOM

U18 MC68681 PIN4  IP1  from U16 (75HC189 pin6) from PIN2 J90 UNKNOWN !
U18 MC68681 PIN36 IP2  ACCESS DOOR SWITCH
U18 MC68681 PIN2  IP3  LOW Battery Detector for ACCESS DOOR SWITCH
U18 MC68681 PIN39 IP4  from U12 75174  UNKNOWN !
U18 MC68681 PIN38 IP5  from U8 smart Battery (not used)

U39 MC68681 PIN7  IP0  Printer Data Terminal Ready
U39 MC68681 PIN4  IP1  COIN INPUT
U39 MC68681 PIN2  IP3  COIN INPUT
U39 MC68681 Pin38 IP5  JCM Bill Acceptor (J4-1,J4-2)
U39 MC68681 PIN29 OP0  Printer Clear To Send

U40 MC68681 PIN4  IP1  COIN INPUT
U40 MC68681 PIN2  IP3  COIN INPUT
U40 MC68681 PIN38 IP5  from U51 DS1260 smart Battery POWER FAIL FLAG

U40 MC68681 Pin12 OP1  JCM Bill Acceptor  (Enable Comm. U34)
U40 MC68681 Pin27 OP4  JCM Bill Acceptor  (J4-6, J4-7 Control)

// missing adress for :
// external I/O board communication via PAL23

    A23 A22 A21 A20  | A19 A18 A17 A16 | A15 A14 A13 A12 | A11 A10 A9 A8 | A7 A6 A5 A4 | A3 A2 A1 xx
    Memory Map (generic)
    --------------------
    00000000 0000FFFF  NVRAM  (only 0..FFFF vector and jump)  16bits
    00010000 00011FFF  BACKUP1                                 8bits
    00020000 00021FFF  BACKUP2                                 8bits
    00B00000 00B01FFF  VIDEO RAM                               8bits
    00FA0000 00FBFFFF  Not used (Expension board  SRAM)
    00FC0000 00FDFFFF  PROGRAM                                16bits
    00FE0000 00FFFFFF  BOOTLOADER                             16bits

    00010001
    00014001
    00020001
    00024001
    00900001 6845  CS  CRTC U8  RS=LOW   ADRESS REGISTER    (A15 ON RS)  Data bus on D7..D0
    00980001 6845  CS  CRTC U8  RS=HIGH  DATA   REGISTER    (A15 ON RS)
    00A00001           I/O Board Communication
    00A08001           I/O Board Communication
    00A10000 WDT    STROBE DS1232 WatchDog Controller (this adress reset Strobe of Ds1232)
    00A20001 AY8912 BDIR  AUDIO  Data bus on D7..D0
    00A28001 AY8912 BC1   AUDIO
    00A300x1 6242  CS  RTC  U41 A0..A3   (A4..A7 ON A0..A3)  Data bus on D3..D0
    00A4000x PAL   CS  READ   U35 SECURITY PAL16R8           Data bus on D15..D8
    00A4000x PAL   CLK WRITE  U35 SECURITY PAL16R8
    00A4000x       CLK WRITE  U50 74LS173  for DOOR LOGIC SW on D3..D0
    00A70000 ???
    00B100x0 68681 CS  UART U40 RS1..RS4 REGISTER (A4..A7 ON RS1..RS4)  Data bus on D7..D0
    00B200x0 68681 CS  UART U39 RS1..RS4 REGISTER (A4..A7 ON RS1..RS4)  Data bus on D7..D0
    00E000x0 68681 CS  UART U18 RS1..RS4 REGISTER (A4..A7 ON RS1..RS4)  Data bus on D15..D8
*/
/***************************************************************************/
static ADDRESS_MAP_START( nevada_map, AS_PROGRAM, 16,nevada_state )
	AM_RANGE(0x00000000, 0x0000ffff) AM_RAM AM_SHARE("nvram")
	AM_RANGE(0x00010000, 0x00021fff) AM_RAM AM_SHARE("backup")
	AM_RANGE(0x00900000, 0x00900001) AM_DEVWRITE8("crtc",mc6845_device, address_w,0x00ff )
	AM_RANGE(0x00908000, 0x00908001) AM_DEVWRITE8("crtc",mc6845_device,register_w,0x00ff )
	AM_RANGE(0x00a00000, 0x00a00001) AM_READWRITE_LEGACY (io_board_r,io_board_w)
	AM_RANGE(0x00a08000, 0x00a08001) AM_WRITE_LEGACY(io_board_x)
	AM_RANGE(0x00a10000, 0x00a10001) AM_WRITE(watchdog_reset16_w )
	AM_RANGE(0x00a20000, 0x00a20001) AM_DEVWRITE8_LEGACY("aysnd", ay8910_address_w,0x00ff )
	AM_RANGE(0x00a28000, 0x00a28001) AM_DEVWRITE8_LEGACY("aysnd", ay8910_data_w   ,0x00ff )
	AM_RANGE(0x00a30000, 0x00A300ff) AM_DEVREADWRITE8("rtc",msm6242_device, read, write, 0x00ff)
	AM_RANGE(0x00a40000, 0x00A40001) AM_READWRITE_LEGACY( nevada_sec_r, nevada_sec_w)
		//AM_RANGE(0x00b00000, 0x00b01fff) AM_RAM_WRITE(nevada_videoram_w) AM_BASE_MEMBER(nevada_state, m_videoram)
			AM_RANGE(0x00b00000, 0x00b01fff) AM_RAM // Video
	AM_RANGE(0x00b10000, 0x00b100ff) AM_DEVREADWRITE8_LEGACY( "duart40_68681", duart68681_r, duart68681_w, 0x00ff ) // Lower byte
	AM_RANGE(0x00b20000, 0x00b200ff) AM_DEVREADWRITE8_LEGACY( "duart39_68681", duart68681_r, duart68681_w, 0x00ff ) // Lower byte
	AM_RANGE(0x00e00000, 0x00e000ff) AM_DEVREADWRITE8_LEGACY( "duart18_68681", duart68681_r, duart68681_w, 0xff00 ) // Upper byte
	AM_RANGE(0x00fa0000, 0x00fbffff) AM_RAM  // not used
	AM_RANGE(0x00fc0000, 0x00ffffff) AM_ROM  // ROM ext + ROM boot
ADDRESS_MAP_END


/***************************************************************************/
static ADDRESS_MAP_START( nevada_iomap, AS_IO, 8, nevada_state )
// todo

ADDRESS_MAP_END
/*
U18 MC68681 PIN4  IP1  from U16 (75HC189 pin6) from PIN2 J90 UNKNOWN !
U18 MC68681 PIN36 IP2  ACCESS DOOR SWITCH
U18 MC68681 PIN2  IP3  LOW Battery Detector for ACCESS DOOR SWITCH
U18 MC68681 PIN39 IP4  from U12 75174  UNKNOWN !
U18 MC68681 PIN38 IP5  from U8 smart Battery (not used)

U39 MC68681 PIN7  IP0  Printer Data Terminal Ready
U39 MC68681 PIN4  IP1  COIN INPUT
U39 MC68681 PIN2  IP3  COIN INPUT
U39 MC68681 Pin38 IP5  JCM Bill Acceptor (J4-1,J4-2)
U39 MC68681 PIN29 OP0  Printer Clear To Send
U39 MC68681 PIN27 OP4  ROM CHAR A14

U40 MC68681 PIN4  IP1  COIN INPUT
U40 MC68681 PIN2  IP3  COIN INPUT
U40 MC68681 PIN38 IP5  from U51 DS1260 smart Battery POWER FAIL FLAG

U40 MC68681 Pin12 OP1  JCM Bill Acceptor  (Enable Comm. U34)
U40 MC68681 Pin27 OP4  JCM Bill Acceptor  (J4-6, J4-7 Control)

*/
/***************************************************************************/
static INPUT_PORTS_START( nevada )
	PORT_START("DSW1")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW,  IPT_BUTTON1  ) PORT_NAME("U16 pin6")
	PORT_BIT( 0x0002, IP_ACTIVE_LOW,  IPT_BUTTON2  ) PORT_NAME("DOOR SW1")
	PORT_BIT( 0x0004, IP_ACTIVE_LOW,  IPT_BUTTON3  ) PORT_NAME("LOW BATT on DOOR ACCESS")
	PORT_BIT( 0x0008, IP_ACTIVE_LOW,  IPT_BUTTON4  ) PORT_NAME("U12 ??")
	PORT_BIT( 0x0080, IP_ACTIVE_LOW,  IPT_BUTTON5  ) PORT_NAME("LOW BATT U8")
	PORT_START("DSW2")
	PORT_BIT( 0x0001, IP_ACTIVE_LOW,  IPT_BUTTON6  ) PORT_NAME("PRINTER READY")
	PORT_BIT( 0x0002, IP_ACTIVE_LOW,  IPT_COIN1    )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW,  IPT_COIN2    )
	PORT_START("DSW3")
	PORT_BIT( 0x0002, IP_ACTIVE_LOW,  IPT_COIN3    )
	PORT_BIT( 0x0008, IP_ACTIVE_LOW,  IPT_COIN4    )
	PORT_BIT( 0x0080, IP_ACTIVE_LOW,  IPT_BUTTON7  ) PORT_NAME("LOW BATT U51")
INPUT_PORTS_END

/***************************************************************************/
static const duart68681_config nevada_duart18_68681_config =
{
	duart18_irq_handler,
	duart18_tx,
	duart18_input,
	NULL
};
/***************************************************************************/
static const duart68681_config nevada_duart39_68681_config =
{
	duart39_irq_handler,
	duart39_tx,
	duart39_input,
	NULL
};
/***************************************************************************/
static const duart68681_config nevada_duart40_68681_config =
{
	duart40_irq_handler,
	duart40_tx,
	duart40_input,
	NULL
};

/***************************************************************************/
/*************************
*     Machine Reset      *
*************************/

static MACHINE_RESET( nevada )
{
	nevada_state *state = machine.driver_data<nevada_state>();

	state->m_duart18_68681 = machine.device( "duart18_68681" );
	state->m_duart39_68681 = machine.device( "duart39_68681" );
	state->m_duart40_68681 = machine.device( "duart40_68681" );
}
/***************************************************************************/

/*************************
*     Machine Driver     *
*************************/

static MACHINE_CONFIG_START( nevada, nevada_state )
	// basic machine hardware
	MCFG_CPU_ADD("maincpu", M68000, MASTER_CPU)
	MCFG_CPU_PROGRAM_MAP(nevada_map)
	MCFG_CPU_IO_MAP(nevada_iomap)  //0x10000 0x20000

	MCFG_MACHINE_RESET(nevada)
			MCFG_WATCHDOG_TIME_INIT(attotime::from_msec(150))   /* 150ms Ds1232 TD to Ground */


	MCFG_NVRAM_HANDLER(nevada)

	// video hardware
	MCFG_SCREEN_ADD("screen", RASTER)
	MCFG_SCREEN_REFRESH_RATE(60)
	MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
	MCFG_SCREEN_SIZE((42+1)*8, (32+1)*8)                  /* From MC6845 init, registers 00 & 04 (programmed with value-1). */
	MCFG_SCREEN_VISIBLE_AREA(0*8, 31*8-1, 0*8, 31*8-1)    /* From MC6845 init, registers 01 & 06. */
	MCFG_SCREEN_UPDATE_STATIC(nevada)

	MCFG_GFXDECODE(nevada)
			MCFG_PALETTE_LENGTH(256)
	MCFG_PALETTE_INIT(nevada)
	MCFG_VIDEO_START(nevada)

	MCFG_MC6845_ADD("crtc", MC6845, MC6845_CLOCK, mc6845_intf)

	// sound hardware
	MCFG_SPEAKER_STANDARD_MONO("mono")

	MCFG_SOUND_ADD("aysnd", AY8912, SOUND_CLOCK)
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)

	MCFG_DUART68681_ADD( "duart18_68681", XTAL_3_6864MHz , nevada_duart18_68681_config )  // UARTA = Modem 1200Baud
	MCFG_DUART68681_ADD( "duart39_68681", XTAL_3_6864MHz , nevada_duart39_68681_config )  // UARTA = Printer
	MCFG_DUART68681_ADD( "duart40_68681", XTAL_3_6864MHz , nevada_duart40_68681_config )  // UARTA = Touch , UARTB = Bill Acceptor
	MCFG_MICROTOUCH_ADD( "microtouch", nevada_microtouch_config )
	/* devices */
	MCFG_MSM6242_ADD("rtc", nevada_rtc_intf)

MACHINE_CONFIG_END

/***************************************************************************/
ROM_START( nevada )
	ROM_REGION( 0x1000000, "maincpu", 0 )   /* 2 x 27C512 */
	ROM_LOAD16_BYTE( "u9even.bin" ,     0xfc0000, 0x010000, CRC(ADB207BD) SHA1(3E3509B78FDF32785F92CB21272694673D25C563) )  // program fc0000..fdffff
	ROM_LOAD16_BYTE( "u10odd.bin" ,     0xfc0001, 0x010000, CRC(A79778D7) SHA1(6FF969F09D9781479360BCA3403B927099AD6481) )

	ROM_LOAD16_BYTE( "u31even.bin",     0xfe0000, 0x010000, CRC(C9779F30) SHA1(5310B3D8B5E887313CE8059BD72D0730A295074F) )  // Boot fe0000..ffffff
	ROM_LOAD16_BYTE( "u32odd.bin" ,     0xfe0001, 0x010000, CRC(51035ED1) SHA1(66CBF582CDF34CF3DDE30CF8A99BBCED4AF1CE6F) )

	ROM_REGION16_BE( 0x0010000, "defaults", 0 ) /* 2 x 62256  NVRAM */
	ROM_LOAD16_BYTE( "u30nv_even.bin",  0x000000, 0x008000, CRC(11f5c663) SHA1(f447fd59010bc7fbbda321c5aaf13e23c2aebd40) )  // NVRAM even  (RESET + Vector table in NVRAM)
	ROM_LOAD16_BYTE( "u33nv_odd.bin" ,  0x000001, 0x008000, CRC(20623da2) SHA1(2dd31a96f0a3454855cd975e8ee95e43316344e0) )  // NVRAM odd

	ROM_REGION( 0x08000, "gfx1", 0 )
	ROM_LOAD( "u34char.bin",            0x00000  , 0x08000, CRC(6F1C6953) SHA1(E8DB3B1D3FC3EC1C3DCA155517553BD0000A2249) )  /* Characters */

		/*
		BACKUP RAM
		PAL DUMP
		*/
ROM_END

/***************************************************************************/
/*************************
*      Driver Init       *
*************************/
DRIVER_INIT_MEMBER(nevada_state,nevada)
{
	UINT16 *ROM = (UINT16 *)memregion("maincpu")->base();

	memset(m_backup,0x00,m_backup.bytes()); // temp

	/* Patch for WDT test with int Level7 */
	/* PATCH FE0086   4278 0414 Clrf $0414 */
	/* this skip the test for the WDT */
//  ROM[0xFE0086/2] = 0x4278;
//  ROM[0xFE0088/2] = 0x0414;

	// Skip PAL SECURITY
	ROM[0xFE0248/2] = 0x4E71; // nop
	ROM[0xFE05D0/2] = 0x4E71; // nop
	ROM[0xFE05D8/2] = 0x6014; // bra
	ROM[0xFE0606/2] = 0x600A; // bra
//  ROM[0xFE18B4/2] = 0x4E71; // nop


}
/***************************************************************************/

/*************************
*      Game Drivers      *
*************************/

/*    YEAR  NAME     PARENT MACHINE INPUT   INIT    ROT    COMPANY    FULLNAME             FLAGS... */

GAME( 1995, nevada,  0,     nevada, nevada, nevada_state, nevada, ROT0, "VLC Inc.", "VLC Nevada",        GAME_NO_SOUND | GAME_NOT_WORKING )