~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/mame/drivers/ettrivia.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Emmanuel Kasper, Jordi Mallach
  • Date: 2012-06-05 20:02:23 UTC
  • mfrom: (0.3.1) (0.1.4)
  • Revision ID: package-import@ubuntu.com-20120605200223-gnlpogjrg6oqe9md
Tags: 0.146-1
[ Emmanuel Kasper ]
* New upstream release
* Drop patch to fix man pages section and patches to link with flac 
  and jpeg system lib: all this has been pushed upstream by Cesare Falco
* Add DM-Upload-Allowed: yes field.

[ Jordi Mallach ]
* Create a "gnu" TARGETOS stanza that defines NO_AFFINITY_NP.
* Stop setting TARGETOS to "unix" in d/rules. It should be autodetected,
  and set to the appropriate value.
* mame_manpage_section.patch: Change mame's manpage section to 6 (games),
  in the TH declaration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
{
36
36
public:
37
37
        ettrivia_state(const machine_config &mconfig, device_type type, const char *tag)
38
 
                : driver_device(mconfig, type, tag) { }
 
38
                : driver_device(mconfig, type, tag) ,
 
39
                m_fg_videoram(*this, "fg_videoram"),
 
40
                m_bg_videoram(*this, "bg_videoram"){ }
39
41
 
40
42
        int m_palreg;
41
43
        int m_gfx_bank;
43
45
        int m_b000_val;
44
46
        int m_b000_ret;
45
47
        int m_b800_prev;
46
 
        UINT8 *m_bg_videoram;
47
 
        UINT8 *m_fg_videoram;
 
48
        required_shared_ptr<UINT8> m_fg_videoram;
 
49
        required_shared_ptr<UINT8> m_bg_videoram;
48
50
        tilemap_t *m_bg_tilemap;
49
51
        tilemap_t *m_fg_tilemap;
 
52
        DECLARE_WRITE8_MEMBER(ettrivia_fg_w);
 
53
        DECLARE_WRITE8_MEMBER(ettrivia_bg_w);
 
54
        DECLARE_WRITE8_MEMBER(ettrivia_control_w);
 
55
        DECLARE_READ8_MEMBER(ettrivia_question_r);
 
56
        DECLARE_WRITE8_MEMBER(b000_w);
 
57
        DECLARE_READ8_MEMBER(b000_r);
 
58
        DECLARE_WRITE8_MEMBER(b800_w);
50
59
};
51
60
 
52
61
 
53
 
static WRITE8_HANDLER( ettrivia_fg_w )
54
 
{
55
 
        ettrivia_state *state = space->machine().driver_data<ettrivia_state>();
56
 
        state->m_fg_videoram[offset] = data;
57
 
        state->m_fg_tilemap->mark_tile_dirty(offset);
58
 
}
59
 
 
60
 
static WRITE8_HANDLER( ettrivia_bg_w )
61
 
{
62
 
        ettrivia_state *state = space->machine().driver_data<ettrivia_state>();
63
 
        state->m_bg_videoram[offset] = data;
64
 
        state->m_bg_tilemap->mark_tile_dirty(offset);
65
 
}
66
 
 
67
 
static WRITE8_HANDLER( ettrivia_control_w )
68
 
{
69
 
        ettrivia_state *state = space->machine().driver_data<ettrivia_state>();
70
 
        space->machine().tilemap().mark_all_dirty();
71
 
 
72
 
        state->m_palreg  = (data >> 1) & 3;
73
 
        state->m_gfx_bank = (data >> 2) & 1;
74
 
 
75
 
        state->m_question_bank = (data >> 3) & 3;
76
 
 
77
 
        coin_counter_w(space->machine(), 0, data & 0x80);
78
 
 
79
 
        flip_screen_set(space->machine(), data & 1);
80
 
}
81
 
 
82
 
static READ8_HANDLER( ettrivia_question_r )
83
 
{
84
 
        ettrivia_state *state = space->machine().driver_data<ettrivia_state>();
85
 
        UINT8 *QUESTIONS = space->machine().region("user1")->base();
86
 
        return QUESTIONS[offset + 0x10000 * state->m_question_bank];
87
 
}
88
 
 
89
 
static WRITE8_HANDLER( b000_w )
90
 
{
91
 
        ettrivia_state *state = space->machine().driver_data<ettrivia_state>();
92
 
        state->m_b000_val = data;
93
 
}
94
 
 
95
 
static READ8_HANDLER( b000_r )
96
 
{
97
 
        ettrivia_state *state = space->machine().driver_data<ettrivia_state>();
98
 
        if(state->m_b800_prev)
99
 
                return state->m_b000_ret;
 
62
WRITE8_MEMBER(ettrivia_state::ettrivia_fg_w)
 
63
{
 
64
        m_fg_videoram[offset] = data;
 
65
        m_fg_tilemap->mark_tile_dirty(offset);
 
66
}
 
67
 
 
68
WRITE8_MEMBER(ettrivia_state::ettrivia_bg_w)
 
69
{
 
70
        m_bg_videoram[offset] = data;
 
71
        m_bg_tilemap->mark_tile_dirty(offset);
 
72
}
 
73
 
 
74
WRITE8_MEMBER(ettrivia_state::ettrivia_control_w)
 
75
{
 
76
        machine().tilemap().mark_all_dirty();
 
77
 
 
78
        m_palreg  = (data >> 1) & 3;
 
79
        m_gfx_bank = (data >> 2) & 1;
 
80
 
 
81
        m_question_bank = (data >> 3) & 3;
 
82
 
 
83
        coin_counter_w(machine(), 0, data & 0x80);
 
84
 
 
85
        flip_screen_set(data & 1);
 
86
}
 
87
 
 
88
READ8_MEMBER(ettrivia_state::ettrivia_question_r)
 
89
{
 
90
        UINT8 *QUESTIONS = memregion("user1")->base();
 
91
        return QUESTIONS[offset + 0x10000 * m_question_bank];
 
92
}
 
93
 
 
94
WRITE8_MEMBER(ettrivia_state::b000_w)
 
95
{
 
96
        m_b000_val = data;
 
97
}
 
98
 
 
99
READ8_MEMBER(ettrivia_state::b000_r)
 
100
{
 
101
        if(m_b800_prev)
 
102
                return m_b000_ret;
100
103
        else
101
 
                return state->m_b000_val;
 
104
                return m_b000_val;
102
105
}
103
106
 
104
 
static WRITE8_HANDLER( b800_w )
 
107
WRITE8_MEMBER(ettrivia_state::b800_w)
105
108
{
106
 
        ettrivia_state *state = space->machine().driver_data<ettrivia_state>();
107
109
        switch(data)
108
110
        {
109
111
                /* special case to return the value written to 0xb000 */
110
112
                /* does it reset the chips too ? */
111
113
                case 0: break;
112
 
                case 0xc4: state->m_b000_ret = ay8910_r(space->machine().device("ay1"), 0);     break;
113
 
                case 0x94: state->m_b000_ret = ay8910_r(space->machine().device("ay2"), 0);     break;
114
 
                case 0x86: state->m_b000_ret = ay8910_r(space->machine().device("ay3"), 0);     break;
 
114
                case 0xc4: m_b000_ret = ay8910_r(machine().device("ay1"), 0);   break;
 
115
                case 0x94: m_b000_ret = ay8910_r(machine().device("ay2"), 0);   break;
 
116
                case 0x86: m_b000_ret = ay8910_r(machine().device("ay3"), 0);   break;
115
117
 
116
118
                case 0x80:
117
 
                        switch(state->m_b800_prev)
 
119
                        switch(m_b800_prev)
118
120
                        {
119
 
                                case 0xe0: ay8910_address_w(space->machine().device("ay1"),0,state->m_b000_val);        break;
120
 
                                case 0x98: ay8910_address_w(space->machine().device("ay2"),0,state->m_b000_val);        break;
121
 
                                case 0x83: ay8910_address_w(space->machine().device("ay3"),0,state->m_b000_val);        break;
 
121
                                case 0xe0: ay8910_address_w(machine().device("ay1"),0,m_b000_val);      break;
 
122
                                case 0x98: ay8910_address_w(machine().device("ay2"),0,m_b000_val);      break;
 
123
                                case 0x83: ay8910_address_w(machine().device("ay3"),0,m_b000_val);      break;
122
124
 
123
 
                                case 0xa0: ay8910_data_w(space->machine().device("ay1"),0,state->m_b000_val);   break;
124
 
                                case 0x88: ay8910_data_w(space->machine().device("ay2"),0,state->m_b000_val);   break;
125
 
                                case 0x81: ay8910_data_w(space->machine().device("ay3"),0,state->m_b000_val);   break;
 
125
                                case 0xa0: ay8910_data_w(machine().device("ay1"),0,m_b000_val); break;
 
126
                                case 0x88: ay8910_data_w(machine().device("ay2"),0,m_b000_val); break;
 
127
                                case 0x81: ay8910_data_w(machine().device("ay3"),0,m_b000_val); break;
126
128
 
127
129
                        }
128
130
                break;
129
131
        }
130
132
 
131
 
        state->m_b800_prev = data;
 
133
        m_b800_prev = data;
132
134
}
133
135
 
134
 
static ADDRESS_MAP_START( cpu_map, AS_PROGRAM, 8 )
 
136
static ADDRESS_MAP_START( cpu_map, AS_PROGRAM, 8, ettrivia_state )
135
137
        AM_RANGE(0x0000, 0x7fff) AM_ROM
136
138
        AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("nvram")
137
139
        AM_RANGE(0x9000, 0x9000) AM_WRITE(ettrivia_control_w)
139
141
        AM_RANGE(0xa000, 0xa000) AM_WRITENOP
140
142
        AM_RANGE(0xb000, 0xb000) AM_READ(b000_r) AM_WRITE(b000_w)
141
143
        AM_RANGE(0xb800, 0xb800) AM_WRITE(b800_w)
142
 
        AM_RANGE(0xc000, 0xc7ff) AM_RAM_WRITE(ettrivia_fg_w) AM_BASE_MEMBER(ettrivia_state, m_fg_videoram)
143
 
        AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(ettrivia_bg_w) AM_BASE_MEMBER(ettrivia_state, m_bg_videoram)
 
144
        AM_RANGE(0xc000, 0xc7ff) AM_RAM_WRITE(ettrivia_fg_w) AM_SHARE("fg_videoram")
 
145
        AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(ettrivia_bg_w) AM_SHARE("bg_videoram")
144
146
ADDRESS_MAP_END
145
147
 
146
 
static ADDRESS_MAP_START( io_map, AS_IO, 8 )
 
148
static ADDRESS_MAP_START( io_map, AS_IO, 8, ettrivia_state )
147
149
        AM_RANGE(0x0000, 0xffff) AM_READ(ettrivia_question_r)
148
150
ADDRESS_MAP_END
149
151
 
213
215
 
214
216
static PALETTE_INIT( ettrivia )
215
217
{
 
218
        const UINT8 *color_prom = machine.root_device().memregion("proms")->base();
216
219
        static const int resistances[2] = { 270, 130 };
217
220
        double weights[2];
218
221
        int i;
287
290
 
288
291
static INTERRUPT_GEN( ettrivia_interrupt )
289
292
{
290
 
        if( input_port_read(device->machine(), "COIN") & 0x01 )
 
293
        if( device->machine().root_device().ioport("COIN")->read() & 0x01 )
291
294
                device_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
292
295
        else
293
296
                device_set_input_line(device, 0, HOLD_LINE);