summaryrefslogblamecommitdiffstatshomepage
path: root/src/mame/machine/wrally.cpp
blob: 968fe7f8b4daac769c6f3163abe831dd17c10a33 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
                       
                                                                                    








                                                                              
                
                            
                              
                            
 





                                                                                        

                                                                            
                               


                                                                            











                                                                                      
                                    
 
                                                                 
                                          
 
                                                                                        

 


                                             
 
 
                                                   
 
                                
                                                           


         










                                                         
 
                                                          

 
                                                
 
                                                          
 
// license:BSD-3-Clause
// copyright-holders:Manuel Abadia, Mike Coates, Nicola Salmoria, Miguel Angel Horna
/***************************************************************************

    World Rally

    Functions to emulate general aspects of the machine (RAM, ROM, interrupts,
    I/O ports)

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

#include "emu.h"
#include "cpu/mcs51/mcs51.h"
#include "includes/gaelcrpt.h"
#include "includes/wrally.h"


void wrally_state::machine_start()
{
	membank("okibank")->configure_entries(0, 16, memregion("oki")->base(), 0x10000);
}

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

    World Rally memory handlers

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

WRITE8_MEMBER(wrally_state::shareram_w)
{
	// why isn't there an AM_SOMETHING macro for this?
	reinterpret_cast<u8 *>(m_shareram.target())[BYTE_XOR_BE(offset)] = data;
}

READ8_MEMBER(wrally_state::shareram_r)
{
	// why isn't there an AM_SOMETHING macro for this?
	return reinterpret_cast<u8 const *>(m_shareram.target())[BYTE_XOR_BE(offset)];
}

WRITE16_MEMBER(wrally_state::vram_w)
{
	data = gaelco_decrypt(space, offset, data, 0x1f, 0x522a);
	COMBINE_DATA(&m_videoram[offset]);

	m_pant[(offset & 0x1fff) >> 12]->mark_tile_dirty(((offset << 1) & 0x1fff) >> 2);
}

WRITE_LINE_MEMBER(wrally_state::flipscreen_w)
{
	flip_screen_set(state);
}

WRITE16_MEMBER(wrally_state::okim6295_bankswitch_w)
{
	if (ACCESSING_BITS_0_7){
		membank("okibank")->set_entry(data & 0x0f);
	}
}

WRITE_LINE_MEMBER(wrally_state::coin1_counter_w)
{
	machine().bookkeeping().coin_counter_w(0, state);
}

WRITE_LINE_MEMBER(wrally_state::coin2_counter_w)
{
	machine().bookkeeping().coin_counter_w(1, state);
}

WRITE_LINE_MEMBER(wrally_state::coin1_lockout_w)
{
	machine().bookkeeping().coin_lockout_w(0, !state);
}

WRITE_LINE_MEMBER(wrally_state::coin2_lockout_w)
{
	machine().bookkeeping().coin_lockout_w(1, !state);
}