summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/namcond1.c
blob: fea7a38cc6ff440fa2acbbc15611a25f815da496 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/***************************************************************************

  Namco ND-1

  machine.c

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

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

#include "driver.h"
#include "cpu/m6809/m6809.h"
#include "namcond1.h"

/* Perform basic machine initialisation */

UINT8 namcond1_h8_irq5_enabled;
UINT8 namcond1_gfxbank;

MACHINE_START( namcond1 )
{
	state_save_register_global(namcond1_h8_irq5_enabled);
	state_save_register_global(namcond1_gfxbank);
}

MACHINE_RESET( namcond1 )
{
#ifdef MAME_DEBUG
    /*UINT8   *ROM = memory_region(REGION_CPU1);*/
    /*UINT32 debug_trigger_addr;*/
    /*int             i;*/

#if 0
    // debug trigger patch
    // insert a "move.b $B0000000,D2" into the code
    debug_trigger_addr = 0x152d4; // after ygv_init
    ROM[debug_trigger_addr++] = 0x39;
    ROM[debug_trigger_addr++] = 0x14;
    ROM[debug_trigger_addr++] = 0xB0;
    ROM[debug_trigger_addr++] = 0x00;
    ROM[debug_trigger_addr++] = 0x00;
    ROM[debug_trigger_addr++] = 0x00;
#endif
#endif

    // initialise MCU states
    namcond1_h8_irq5_enabled = 0;

    // halt the MCU
    cpunum_set_input_line(1,INPUT_LINE_RESET,ASSERT_LINE);
}

// instance of the shared ram pointer
UINT16 *namcond1_shared_ram;

READ16_HANDLER( namcond1_shared_ram_r )
{
	return namcond1_shared_ram[offset];
}

// $c3ff00-$c3ffff
READ16_HANDLER( namcond1_cuskey_r )
{
    switch( offset )
    {
        // this address returns a jump vector inside ISR2
        // - if zero then the ISR returns without jumping
        case (0x2e>>1):
            return( 0x0000 );
        case (0x30>>1):
            return( 0x0000 );

        default :
            logerror( "offset $%X accessed from $%X\n",
                      offset<<1, activecpu_get_pc() );
            return( 0 );
    }
}

WRITE16_HANDLER( namcond1_shared_ram_w )
{

    switch( offset )
    {
        default :
            COMBINE_DATA( namcond1_shared_ram + offset );
            break;
    }
}

WRITE16_HANDLER( namcond1_cuskey_w )
{
    switch( offset )
    {
        case (0x0a>>1):
            // this is a kludge until we emulate the h8
	    if ((namcond1_h8_irq5_enabled == 0) && (data != 0x0000))
	    {
	    	cpunum_set_input_line(1, INPUT_LINE_RESET, CLEAR_LINE);
	    }
            namcond1_h8_irq5_enabled = ( data != 0x0000 );
            break;

		case (0x0c>>1):
			namcond1_gfxbank = (data & 0x0002) >>1; // i think
			// should mark tilemaps dirty but i think they already are
			break;

        default :
            break;
    }
}