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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Emmanuel Kasper, Félix Arreola Rodríguez, Jordi Mallach
  • Date: 2011-05-11 21:06:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110511210650-jizvh8a6x117y9hr
Tags: 0.142-1
[ Emmanuel Kasper ]
* New upstream release
* Set NOWERROR=1 to allow compiling with gcc-4.6
* Remove fix_powerpc_build.patch, as upstream has taken it in this release
* Add gnome-video-arcade front end as a suggested package

[ Félix Arreola Rodríguez ]
* Add kfreebsd-build.patch to quilt series, to fix build on kfreebsd

[ Jordi Mallach ]
* Remove unneeded and bogus addition of --with-quilt to the dh invocation.
* Add Cesare Falco (long time Ubuntu maintainer) to Uploaders, and wrap
  them into multiple lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
static WRITE8_HANDLER( rom_bank_select_w )
46
46
{
47
 
        memory_set_bank(space->machine, "bank1", data & 15);
 
47
        memory_set_bank(space->machine(), "bank1", data & 15);
48
48
}
49
49
 
50
50
 
51
51
static MACHINE_START( crgolf )
52
52
{
53
 
        crgolf_state *state = machine->driver_data<crgolf_state>();
 
53
        crgolf_state *state = machine.driver_data<crgolf_state>();
54
54
 
55
 
        state->maincpu = machine->device("maincpu");
56
 
        state->audiocpu = machine->device("audiocpu");
 
55
        state->m_maincpu = machine.device("maincpu");
 
56
        state->m_audiocpu = machine.device("audiocpu");
57
57
 
58
58
        /* configure the banking */
59
 
        memory_configure_bank(machine, "bank1", 0, 16, machine->region("maincpu")->base() + 0x10000, 0x2000);
 
59
        memory_configure_bank(machine, "bank1", 0, 16, machine.region("maincpu")->base() + 0x10000, 0x2000);
60
60
        memory_set_bank(machine, "bank1", 0);
61
61
 
62
62
        /* register for save states */
63
 
        state_save_register_global(machine, state->port_select);
64
 
        state_save_register_global(machine, state->main_to_sound_data);
65
 
        state_save_register_global(machine, state->sound_to_main_data);
66
 
        state_save_register_global(machine, state->sample_offset);
67
 
        state_save_register_global(machine, state->sample_count);
 
63
        state->save_item(NAME(state->m_port_select));
 
64
        state->save_item(NAME(state->m_main_to_sound_data));
 
65
        state->save_item(NAME(state->m_sound_to_main_data));
 
66
        state->save_item(NAME(state->m_sample_offset));
 
67
        state->save_item(NAME(state->m_sample_count));
68
68
}
69
69
 
70
70
 
71
71
static MACHINE_RESET( crgolf )
72
72
{
73
 
        crgolf_state *state = machine->driver_data<crgolf_state>();
 
73
        crgolf_state *state = machine.driver_data<crgolf_state>();
74
74
 
75
 
        state->port_select = 0;
76
 
        state->main_to_sound_data = 0;
77
 
        state->sound_to_main_data = 0;
78
 
        state->sample_offset = 0;
79
 
        state->sample_count = 0;
 
75
        state->m_port_select = 0;
 
76
        state->m_main_to_sound_data = 0;
 
77
        state->m_sound_to_main_data = 0;
 
78
        state->m_sample_offset = 0;
 
79
        state->m_sample_count = 0;
80
80
}
81
81
 
82
82
 
89
89
static READ8_HANDLER( switch_input_r )
90
90
{
91
91
        static const char *const portnames[] = { "IN0", "IN1", "P1", "P2", "DSW", "UNUSED0", "UNUSED1" };
92
 
        crgolf_state *state = space->machine->driver_data<crgolf_state>();
 
92
        crgolf_state *state = space->machine().driver_data<crgolf_state>();
93
93
 
94
 
        return input_port_read(space->machine, portnames[state->port_select]);
 
94
        return input_port_read(space->machine(), portnames[state->m_port_select]);
95
95
}
96
96
 
97
97
 
98
98
static READ8_HANDLER( analog_input_r )
99
99
{
100
 
        return ((input_port_read(space->machine, "STICK0") >> 4) | (input_port_read(space->machine, "STICK1") & 0xf0)) ^ 0x88;
 
100
        return ((input_port_read(space->machine(), "STICK0") >> 4) | (input_port_read(space->machine(), "STICK1") & 0xf0)) ^ 0x88;
101
101
}
102
102
 
103
103
 
104
104
static WRITE8_HANDLER( switch_input_select_w )
105
105
{
106
 
        crgolf_state *state = space->machine->driver_data<crgolf_state>();
 
106
        crgolf_state *state = space->machine().driver_data<crgolf_state>();
107
107
 
108
 
        if (!(data & 0x40)) state->port_select = 6;
109
 
        if (!(data & 0x20)) state->port_select = 5;
110
 
        if (!(data & 0x10)) state->port_select = 4;
111
 
        if (!(data & 0x08)) state->port_select = 3;
112
 
        if (!(data & 0x04)) state->port_select = 2;
113
 
        if (!(data & 0x02)) state->port_select = 1;
114
 
        if (!(data & 0x01)) state->port_select = 0;
 
108
        if (!(data & 0x40)) state->m_port_select = 6;
 
109
        if (!(data & 0x20)) state->m_port_select = 5;
 
110
        if (!(data & 0x10)) state->m_port_select = 4;
 
111
        if (!(data & 0x08)) state->m_port_select = 3;
 
112
        if (!(data & 0x04)) state->m_port_select = 2;
 
113
        if (!(data & 0x02)) state->m_port_select = 1;
 
114
        if (!(data & 0x01)) state->m_port_select = 0;
115
115
}
116
116
 
117
117
 
118
118
static WRITE8_HANDLER( unknown_w )
119
119
{
120
 
        logerror("%04X:unknown_w = %02X\n", cpu_get_pc(space->cpu), data);
 
120
        logerror("%04X:unknown_w = %02X\n", cpu_get_pc(&space->device()), data);
121
121
}
122
122
 
123
123
 
130
130
 
131
131
static TIMER_CALLBACK( main_to_sound_callback )
132
132
{
133
 
        crgolf_state *state = machine->driver_data<crgolf_state>();
 
133
        crgolf_state *state = machine.driver_data<crgolf_state>();
134
134
 
135
 
        cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, ASSERT_LINE);
136
 
        state->main_to_sound_data = param;
 
135
        device_set_input_line(state->m_audiocpu, INPUT_LINE_NMI, ASSERT_LINE);
 
136
        state->m_main_to_sound_data = param;
137
137
}
138
138
 
139
139
 
140
140
static WRITE8_HANDLER( main_to_sound_w )
141
141
{
142
 
        timer_call_after_resynch(space->machine, NULL, data, main_to_sound_callback);
 
142
        space->machine().scheduler().synchronize(FUNC(main_to_sound_callback), data);
143
143
}
144
144
 
145
145
 
146
146
static READ8_HANDLER( main_to_sound_r )
147
147
{
148
 
        crgolf_state *state = space->machine->driver_data<crgolf_state>();
 
148
        crgolf_state *state = space->machine().driver_data<crgolf_state>();
149
149
 
150
 
        cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE);
151
 
        return state->main_to_sound_data;
 
150
        device_set_input_line(state->m_audiocpu, INPUT_LINE_NMI, CLEAR_LINE);
 
151
        return state->m_main_to_sound_data;
152
152
}
153
153
 
154
154
 
161
161
 
162
162
static TIMER_CALLBACK( sound_to_main_callback )
163
163
{
164
 
        crgolf_state *state = machine->driver_data<crgolf_state>();
 
164
        crgolf_state *state = machine.driver_data<crgolf_state>();
165
165
 
166
 
        cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, ASSERT_LINE);
167
 
        state->sound_to_main_data = param;
 
166
        device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, ASSERT_LINE);
 
167
        state->m_sound_to_main_data = param;
168
168
}
169
169
 
170
170
 
171
171
static WRITE8_HANDLER( sound_to_main_w )
172
172
{
173
 
        timer_call_after_resynch(space->machine, NULL, data, sound_to_main_callback);
 
173
        space->machine().scheduler().synchronize(FUNC(sound_to_main_callback), data);
174
174
}
175
175
 
176
176
 
177
177
static READ8_HANDLER( sound_to_main_r )
178
178
{
179
 
        crgolf_state *state = space->machine->driver_data<crgolf_state>();
 
179
        crgolf_state *state = space->machine().driver_data<crgolf_state>();
180
180
 
181
 
        cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, CLEAR_LINE);
182
 
        return state->sound_to_main_data;
 
181
        device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, CLEAR_LINE);
 
182
        return state->m_sound_to_main_data;
183
183
}
184
184
 
185
185
 
192
192
 
193
193
static void vck_callback( device_t *device )
194
194
{
195
 
        crgolf_state *state = device->machine->driver_data<crgolf_state>();
 
195
        crgolf_state *state = device->machine().driver_data<crgolf_state>();
196
196
 
197
197
        /* only play back if we have data remaining */
198
 
        if (state->sample_count != 0xff)
 
198
        if (state->m_sample_count != 0xff)
199
199
        {
200
 
                UINT8 data = device->machine->region("adpcm")->base()[state->sample_offset >> 1];
 
200
                UINT8 data = device->machine().region("adpcm")->base()[state->m_sample_offset >> 1];
201
201
 
202
202
                /* write the next nibble and advance */
203
 
                msm5205_data_w(device, (data >> (4 * (~state->sample_offset & 1))) & 0x0f);
204
 
                state->sample_offset++;
 
203
                msm5205_data_w(device, (data >> (4 * (~state->m_sample_offset & 1))) & 0x0f);
 
204
                state->m_sample_offset++;
205
205
 
206
206
                /* every 256 clocks, we decrement the length */
207
 
                if (!(state->sample_offset & 0xff))
 
207
                if (!(state->m_sample_offset & 0xff))
208
208
                {
209
 
                        state->sample_count--;
 
209
                        state->m_sample_count--;
210
210
 
211
211
                        /* if we hit 0xff, automatically turn off playback */
212
 
                        if (state->sample_count == 0xff)
 
212
                        if (state->m_sample_count == 0xff)
213
213
                                msm5205_reset_w(device, 1);
214
214
                }
215
215
        }
218
218
 
219
219
static WRITE8_DEVICE_HANDLER( crgolfhi_sample_w )
220
220
{
221
 
        crgolf_state *state = device->machine->driver_data<crgolf_state>();
 
221
        crgolf_state *state = device->machine().driver_data<crgolf_state>();
222
222
 
223
223
        switch (offset)
224
224
        {
229
229
 
230
230
                /* offset 1 is the length/256 nibbles */
231
231
                case 1:
232
 
                        state->sample_count = data;
 
232
                        state->m_sample_count = data;
233
233
                        break;
234
234
 
235
235
                /* offset 2 is the offset/256 nibbles */
236
236
                case 2:
237
 
                        state->sample_offset = data << 8;
 
237
                        state->m_sample_offset = data << 8;
238
238
                        break;
239
239
 
240
240
                /* offset 3 turns on playback */
252
252
 *
253
253
 *************************************/
254
254
 
255
 
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
 
255
static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8 )
256
256
        AM_RANGE(0x0000, 0x3fff) AM_ROM
257
257
        AM_RANGE(0x4000, 0x5fff) AM_RAM
258
258
        AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1")
259
 
        AM_RANGE(0x8003, 0x8003) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, color_select)
260
 
        AM_RANGE(0x8004, 0x8004) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, screen_flip)
261
 
        AM_RANGE(0x8005, 0x8005) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, screen_select)
262
 
        AM_RANGE(0x8006, 0x8006) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, screenb_enable)
263
 
        AM_RANGE(0x8007, 0x8007) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, screena_enable)
 
259
        AM_RANGE(0x8003, 0x8003) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, m_color_select)
 
260
        AM_RANGE(0x8004, 0x8004) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, m_screen_flip)
 
261
        AM_RANGE(0x8005, 0x8005) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, m_screen_select)
 
262
        AM_RANGE(0x8006, 0x8006) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, m_screenb_enable)
 
263
        AM_RANGE(0x8007, 0x8007) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, m_screena_enable)
264
264
        AM_RANGE(0x8800, 0x8800) AM_READWRITE(sound_to_main_r, main_to_sound_w)
265
265
        AM_RANGE(0x9000, 0x9000) AM_WRITE(rom_bank_select_w)
266
266
        AM_RANGE(0xa000, 0xffff) AM_READWRITE(crgolf_videoram_r, crgolf_videoram_w)
274
274
 *
275
275
 *************************************/
276
276
 
277
 
static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
 
277
static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8 )
278
278
        AM_RANGE(0x0000, 0x7fff) AM_ROM
279
279
        AM_RANGE(0x8000, 0x87ff) AM_RAM
280
280
        AM_RANGE(0xc000, 0xc001) AM_DEVWRITE("aysnd", ay8910_address_data_w)
395
395
 
396
396
        MCFG_MACHINE_START(crgolf)
397
397
        MCFG_MACHINE_RESET(crgolf)
398
 
        MCFG_QUANTUM_TIME(HZ(6000))
 
398
        MCFG_QUANTUM_TIME(attotime::from_hz(6000))
399
399
 
400
400
        /* video hardware */
401
401
        MCFG_FRAGMENT_ADD(crgolf_video)
599
599
 
600
600
static DRIVER_INIT( crgolfhi )
601
601
{
602
 
        device_t *msm = machine->device("msm");
603
 
        memory_install_write8_device_handler(cputag_get_address_space(machine, "audiocpu", ADDRESS_SPACE_PROGRAM), msm, 0xa000, 0xa003, 0, 0, crgolfhi_sample_w);
 
602
        device_t *msm = machine.device("msm");
 
603
        machine.device("audiocpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(*msm, 0xa000, 0xa003, FUNC(crgolfhi_sample_w));
604
604
}
605
605
 
606
606