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

« back to all changes in this revision

Viewing changes to src/emu/driver.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:
2
2
 
3
3
    driver.c
4
4
 
5
 
    Driver enumeration helpers.
 
5
    Core driver device base class.
6
6
 
7
7
****************************************************************************
8
8
 
38
38
***************************************************************************/
39
39
 
40
40
#include "emu.h"
41
 
#include <ctype.h>
42
 
 
43
 
 
44
 
 
45
 
//**************************************************************************
46
 
//  DRIVER LIST
47
 
//**************************************************************************
48
 
 
49
 
//-------------------------------------------------
50
 
//  driver_list - constructor
51
 
//-------------------------------------------------
52
 
 
53
 
driver_list::driver_list()
54
 
{
55
 
}
56
 
 
57
 
 
58
 
//-------------------------------------------------
59
 
//  find - find a driver by name
60
 
//-------------------------------------------------
61
 
 
62
 
int driver_list::find(const char *name)
63
 
{
64
 
        // if no name, bail
65
 
        if (name == NULL)
66
 
                return -1;
67
 
 
68
 
        // create a dummy item for comparison purposes
69
 
        game_driver driver;
70
 
        driver.name = name;
71
 
        game_driver *driverptr = &driver;
72
 
 
73
 
        // binary search to find it
74
 
        const game_driver **result = reinterpret_cast<const game_driver **>(bsearch(&driverptr, s_drivers_sorted, s_driver_count, sizeof(*s_drivers_sorted), driver_sort_callback));
75
 
        return (result == NULL) ? -1 : result - s_drivers_sorted;
76
 
}
77
 
 
78
 
 
79
 
//-------------------------------------------------
80
 
//  matches - true if we match, taking into
81
 
//  account wildcards in the wildstring
82
 
//-------------------------------------------------
83
 
 
84
 
bool driver_list::matches(const char *wildstring, const char *string)
85
 
{
86
 
        // can only match internal drivers if the wildstring starts with an underscore
87
 
        if (string[0] == '_' && (wildstring == NULL || wildstring[0] != '_'))
88
 
                return false;
89
 
 
90
 
        // match everything else normally
91
 
        return (wildstring == NULL || mame_strwildcmp(wildstring, string) == 0);
92
 
}
93
 
 
94
 
 
95
 
//-------------------------------------------------
96
 
//  driver_sort_callback - compare two items in
97
 
//  an array of game_driver pointers
98
 
//-------------------------------------------------
99
 
 
100
 
int driver_list::driver_sort_callback(const void *elem1, const void *elem2)
101
 
{
102
 
        const game_driver * const *item1 = reinterpret_cast<const game_driver * const *>(elem1);
103
 
        const game_driver * const *item2 = reinterpret_cast<const game_driver * const *>(elem2);
104
 
        return mame_stricmp((*item1)->name, (*item2)->name);
105
 
}
106
 
 
107
 
 
108
 
//-------------------------------------------------
109
 
//  penalty_compare - compare two strings for
110
 
//  closeness and assign a score.
111
 
//-------------------------------------------------
112
 
 
113
 
int driver_list::penalty_compare(const char *source, const char *target)
114
 
{
115
 
        int gaps = 1;
116
 
        bool last = true;
117
 
 
118
 
        // scan the strings
119
 
        for ( ; *source && *target; target++)
120
 
        {
121
 
                // do a case insensitive match
122
 
                bool match = (tolower((UINT8)*source) == tolower((UINT8)*target));
123
 
 
124
 
                // if we matched, advance the source
125
 
                if (match)
126
 
                        source++;
127
 
 
128
 
                // if the match state changed, count gaps
129
 
                if (match != last)
130
 
                {
131
 
                        last = match;
132
 
                        if (!match)
133
 
                                gaps++;
134
 
                }
135
 
        }
136
 
 
137
 
        // penalty if short string does not completely fit in
138
 
        for ( ; *source; source++)
139
 
                gaps++;
140
 
 
141
 
        // if we matched perfectly, gaps == 0
142
 
        if (gaps == 1 && *source == 0 && *target == 0)
143
 
                gaps = 0;
144
 
 
145
 
        return gaps;
146
 
}
147
 
 
148
 
 
149
 
 
150
 
//**************************************************************************
151
 
//  DRIVER ENUMERATOR
152
 
//**************************************************************************
153
 
 
154
 
//-------------------------------------------------
155
 
//  driver_enumerator - constructor
156
 
//-------------------------------------------------
157
 
 
158
 
driver_enumerator::driver_enumerator(emu_options &options)
159
 
        : m_current(-1),
160
 
          m_filtered_count(0),
161
 
          m_options(options),
162
 
          m_included(global_alloc_array(UINT8, s_driver_count)),
163
 
          m_config(global_alloc_array_clear(machine_config *, s_driver_count))
164
 
{
165
 
        include_all();
166
 
}
167
 
 
168
 
 
169
 
driver_enumerator::driver_enumerator(emu_options &options, const char *string)
170
 
        : m_current(-1),
171
 
          m_filtered_count(0),
172
 
          m_options(options),
173
 
          m_included(global_alloc_array(UINT8, s_driver_count)),
174
 
          m_config(global_alloc_array_clear(machine_config *, s_driver_count))
175
 
{
176
 
        filter(string);
177
 
}
178
 
 
179
 
 
180
 
driver_enumerator::driver_enumerator(emu_options &options, const game_driver &driver)
181
 
        : m_current(-1),
182
 
          m_filtered_count(0),
183
 
          m_options(options),
184
 
          m_included(global_alloc_array(UINT8, s_driver_count)),
185
 
          m_config(global_alloc_array_clear(machine_config *, s_driver_count))
186
 
{
187
 
        filter(driver);
188
 
}
189
 
 
190
 
 
191
 
//-------------------------------------------------
192
 
//  ~driver_enumerator - destructor
193
 
//-------------------------------------------------
194
 
 
195
 
driver_enumerator::~driver_enumerator()
196
 
{
197
 
        // free any configs
198
 
        for (int index = 0; index < s_driver_count; index++)
199
 
                global_free(m_config[index]);
200
 
 
201
 
        // free the arrays
202
 
        global_free(m_included);
203
 
        global_free(m_config);
204
 
}
205
 
 
206
 
 
207
 
//-------------------------------------------------
208
 
//  config - return a machine_config for the given
209
 
//  driver, allocating on demand if needed
210
 
//-------------------------------------------------
211
 
 
212
 
machine_config &driver_enumerator::config(int index, emu_options &options) const
213
 
{
214
 
        assert(index >= 0 && index < s_driver_count);
215
 
 
216
 
        // if we don't have it cached, add it
217
 
        if (m_config[index] == NULL)
218
 
        {
219
 
                // if our cache is full, release the head entry
220
 
                if (m_config_cache.count() == CONFIG_CACHE_COUNT)
221
 
                {
222
 
                        config_entry *first = m_config_cache.first();
223
 
                        m_config[first->index()] = NULL;
224
 
                        m_config_cache.remove(*first);
225
 
                }
226
 
 
227
 
                // allocate the config and add it to the end of the list
228
 
                machine_config *config = m_config[index] = global_alloc(machine_config(*s_drivers_sorted[index], options));
229
 
                m_config_cache.append(*global_alloc(config_entry(*config, index)));
230
 
        }
231
 
        return *m_config[index];
232
 
}
233
 
 
234
 
 
235
 
//-------------------------------------------------
236
 
//  filter - filter the driver list against the
237
 
//  given string
238
 
//-------------------------------------------------
239
 
 
240
 
int driver_enumerator::filter(const char *filterstring)
241
 
{
242
 
        // reset the count
243
 
        exclude_all();
244
 
 
245
 
        // match name against each driver in the list
246
 
        for (int index = 0; index < s_driver_count; index++)
247
 
                if (matches(filterstring, s_drivers_sorted[index]->name))
248
 
                        include(index);
249
 
 
250
 
        return m_filtered_count;
251
 
}
252
 
 
253
 
 
254
 
//-------------------------------------------------
255
 
//  filter - filter the driver list against the
256
 
//  given driver
257
 
//-------------------------------------------------
258
 
 
259
 
int driver_enumerator::filter(const game_driver &driver)
260
 
{
261
 
        // reset the count
262
 
        exclude_all();
263
 
 
264
 
        // match name against each driver in the list
265
 
        for (int index = 0; index < s_driver_count; index++)
266
 
                if (s_drivers_sorted[index] == &driver)
267
 
                        include(index);
268
 
 
269
 
        return m_filtered_count;
270
 
}
271
 
 
272
 
 
273
 
//-------------------------------------------------
274
 
//  include_all - include all non-internal drivers
275
 
//-------------------------------------------------
276
 
 
277
 
void driver_enumerator::include_all()
278
 
{
279
 
        memset(m_included, 1, sizeof(m_included[0]) * s_driver_count); m_filtered_count = s_driver_count;
280
 
        int empty = find("___empty");
281
 
        assert(empty != -1);
282
 
        m_included[empty] = 0;
283
 
}
284
 
 
285
 
 
286
 
//-------------------------------------------------
287
 
//  next - get the next driver matching the given
288
 
//  filter
289
 
//-------------------------------------------------
290
 
 
291
 
bool driver_enumerator::next()
292
 
{
293
 
        // always advance one
294
 
        m_current++;
295
 
 
296
 
        // if we have a filter, scan forward to the next match
297
 
        while (m_current < s_driver_count)
298
 
        {
299
 
                if (m_included[m_current])
300
 
                        break;
301
 
                m_current++;
302
 
        }
303
 
 
304
 
        // return true if we end up in range
305
 
        return (m_current >= 0 && m_current < s_driver_count);
306
 
}
307
 
 
308
 
 
309
 
//-------------------------------------------------
310
 
//  next_excluded - get the next driver that is
311
 
//  not currently included in the list
312
 
//-------------------------------------------------
313
 
 
314
 
bool driver_enumerator::next_excluded()
315
 
{
316
 
        // always advance one
317
 
        m_current++;
318
 
 
319
 
        // if we have a filter, scan forward to the next match
320
 
        while (m_current < s_driver_count)
321
 
        {
322
 
                if (!m_included[m_current])
323
 
                        break;
324
 
                m_current++;
325
 
        }
326
 
 
327
 
        // return true if we end up in range
328
 
        return (m_current >= 0 && m_current < s_driver_count);
329
 
}
330
 
 
331
 
 
332
 
//-------------------------------------------------
333
 
//  driver_sort_callback - compare two items in
334
 
//  an array of game_driver pointers
335
 
//-------------------------------------------------
336
 
 
337
 
void driver_enumerator::find_approximate_matches(const char *string, int count, int *results)
338
 
{
339
 
#undef rand
340
 
 
341
 
        // if no name, pick random entries
342
 
        if (string == NULL || string[0] == 0)
343
 
        {
344
 
                // seed the RNG first
345
 
                srand(osd_ticks());
346
 
 
347
 
                // allocate a temporary list
348
 
                int *templist = global_alloc_array(int, m_filtered_count);
349
 
                int arrayindex = 0;
350
 
                for (int index = 0; index < s_driver_count; index++)
351
 
                        if (m_included[index])
352
 
                                templist[arrayindex++] = index;
353
 
                assert(arrayindex == m_filtered_count);
354
 
 
355
 
                // shuffle
356
 
                for (int shufnum = 0; shufnum < 4 * s_driver_count; shufnum++)
357
 
                {
358
 
                        int item1 = rand() % m_filtered_count;
359
 
                        int item2 = rand() % m_filtered_count;
360
 
                        int temp = templist[item1];
361
 
                        templist[item1] = templist[item2];
362
 
                        templist[item2] = temp;
363
 
                }
364
 
 
365
 
                // copy out the first few entries
366
 
                for (int matchnum = 0; matchnum < count; matchnum++)
367
 
                        results[matchnum] = templist[matchnum % m_filtered_count];
368
 
 
369
 
                global_free(templist);
370
 
                return;
371
 
        }
372
 
 
373
 
        // allocate memory to track the penalty value
374
 
        int *penalty = global_alloc_array(int, count);
375
 
 
376
 
        // initialize everyone's states
377
 
        for (int matchnum = 0; matchnum < count; matchnum++)
378
 
        {
379
 
                penalty[matchnum] = 9999;
380
 
                results[matchnum] = -1;
381
 
        }
382
 
 
383
 
        // scan the entire drivers array
384
 
        for (int index = 0; index < s_driver_count; index++)
385
 
                if (m_included[index])
386
 
                {
387
 
                        // skip things that can't run
388
 
                        if ((s_drivers_sorted[index]->flags & GAME_NO_STANDALONE) != 0)
389
 
                                continue;
390
 
 
391
 
                        // pick the best match between driver name and description
392
 
                        int curpenalty = penalty_compare(string, s_drivers_sorted[index]->description);
393
 
                        int tmp = penalty_compare(string, s_drivers_sorted[index]->name);
394
 
                        curpenalty = MIN(curpenalty, tmp);
395
 
 
396
 
                        // insert into the sorted table of matches
397
 
                        for (int matchnum = count - 1; matchnum >= 0; matchnum--)
398
 
                        {
399
 
                                // stop if we're worse than the current entry
400
 
                                if (curpenalty >= penalty[matchnum])
401
 
                                        break;
402
 
 
403
 
                                // as long as this isn't the last entry, bump this one down
404
 
                                if (matchnum < count - 1)
405
 
                                {
406
 
                                        penalty[matchnum + 1] = penalty[matchnum];
407
 
                                        results[matchnum + 1] = results[matchnum];
408
 
                                }
409
 
                                results[matchnum] = index;
410
 
                                penalty[matchnum] = curpenalty;
411
 
                        }
412
 
                }
413
 
 
414
 
        // free our temp memory
415
 
        global_free(penalty);
416
 
}
417
 
 
418
 
 
419
 
driver_enumerator::config_entry::config_entry(machine_config &config, int index)
420
 
        : m_next(NULL),
421
 
          m_config(&config),
422
 
          m_index(index)
423
 
{
424
 
}
425
 
 
426
 
 
427
 
driver_enumerator::config_entry::~config_entry()
428
 
{
429
 
        global_free(m_config);
430
 
}
 
41
#include "drivenum.h"
 
42
 
 
43
 
 
44
//**************************************************************************
 
45
//  DRIVER DEVICE
 
46
//**************************************************************************
 
47
 
 
48
//-------------------------------------------------
 
49
//  driver_device - constructor
 
50
//-------------------------------------------------
 
51
 
 
52
driver_device::driver_device(const machine_config &mconfig, device_type type, const char *tag)
 
53
        : device_t(mconfig, type, "Driver Device", tag, NULL, 0),
 
54
          m_generic_paletteram_8(*this, "paletteram"),
 
55
          m_generic_paletteram2_8(*this, "paletteram2"),
 
56
          m_generic_paletteram_16(*this, "paletteram"),
 
57
          m_generic_paletteram2_16(*this, "paletteram2"),
 
58
          m_generic_paletteram_32(*this, "paletteram"),
 
59
          m_generic_paletteram2_32(*this, "paletteram2"),
 
60
          m_system(NULL),
 
61
          m_latch_clear_value(0),
 
62
          m_flip_screen_x(0),
 
63
          m_flip_screen_y(0)
 
64
{
 
65
        memset(m_legacy_callbacks, 0, sizeof(m_legacy_callbacks));
 
66
        memset(m_latched_value, 0, sizeof(m_latched_value));
 
67
        memset(m_latch_read, 0, sizeof(m_latch_read));
 
68
}
 
69
 
 
70
 
 
71
//-------------------------------------------------
 
72
//  driver_device - destructor
 
73
//-------------------------------------------------
 
74
 
 
75
driver_device::~driver_device()
 
76
{
 
77
}
 
78
 
 
79
 
 
80
//-------------------------------------------------
 
81
//  static_set_game - set the game in the device
 
82
//  configuration
 
83
//-------------------------------------------------
 
84
 
 
85
void driver_device::static_set_game(device_t &device, const game_driver &game)
 
86
{
 
87
        driver_device &driver = downcast<driver_device &>(device);
 
88
 
 
89
        // set the system
 
90
        driver.m_system = &game;
 
91
 
 
92
        // set the short name to the game's name
 
93
        driver.m_shortname = game.name;
 
94
 
 
95
        // set the full name to the game's description
 
96
        driver.m_name = game.description;
 
97
 
 
98
        // and set the search path to include all parents
 
99
        driver.m_searchpath = game.name;
 
100
        for (int parent = driver_list::clone(game); parent != -1; parent = driver_list::clone(parent))
 
101
                driver.m_searchpath.cat(";").cat(driver_list::driver(parent).name);
 
102
}
 
103
 
 
104
 
 
105
//-------------------------------------------------
 
106
//  static_set_callback - set the a callback in
 
107
//  the device configuration
 
108
//-------------------------------------------------
 
109
 
 
110
void driver_device::static_set_callback(device_t &device, callback_type type, legacy_callback_func callback)
 
111
{
 
112
        downcast<driver_device &>(device).m_legacy_callbacks[type] = callback;
 
113
}
 
114
 
 
115
void driver_device::static_set_callback(device_t &device, callback_type type, driver_callback_delegate callback)
 
116
{
 
117
        downcast<driver_device &>(device).m_callbacks[type] = callback;
 
118
}
 
119
 
 
120
 
 
121
//-------------------------------------------------
 
122
//  driver_start - default implementation which
 
123
//  does nothing
 
124
//-------------------------------------------------
 
125
 
 
126
void driver_device::driver_start()
 
127
{
 
128
}
 
129
 
 
130
 
 
131
//-------------------------------------------------
 
132
//  machine_start - default implementation which
 
133
//  calls to the legacy machine_start function
 
134
//-------------------------------------------------
 
135
 
 
136
void driver_device::machine_start()
 
137
{
 
138
}
 
139
 
 
140
 
 
141
//-------------------------------------------------
 
142
//  sound_start - default implementation which
 
143
//  calls to the legacy sound_start function
 
144
//-------------------------------------------------
 
145
 
 
146
void driver_device::sound_start()
 
147
{
 
148
}
 
149
 
 
150
 
 
151
//-------------------------------------------------
 
152
//  palette_init - default implementation which
 
153
//  does nothing
 
154
//-------------------------------------------------
 
155
 
 
156
void driver_device::palette_init()
 
157
{
 
158
}
 
159
 
 
160
 
 
161
//-------------------------------------------------
 
162
//  video_start - default implementation which
 
163
//  calls to the legacy video_start function
 
164
//-------------------------------------------------
 
165
 
 
166
void driver_device::video_start()
 
167
{
 
168
}
 
169
 
 
170
 
 
171
//-------------------------------------------------
 
172
//  driver_reset - default implementation which
 
173
//  does nothing
 
174
//-------------------------------------------------
 
175
 
 
176
void driver_device::driver_reset()
 
177
{
 
178
}
 
179
 
 
180
 
 
181
//-------------------------------------------------
 
182
//  machine_reset - default implementation which
 
183
//  calls to the legacy machine_reset function
 
184
//-------------------------------------------------
 
185
 
 
186
void driver_device::machine_reset()
 
187
{
 
188
}
 
189
 
 
190
 
 
191
//-------------------------------------------------
 
192
//  sound_reset - default implementation which
 
193
//  calls to the legacy sound_reset function
 
194
//-------------------------------------------------
 
195
 
 
196
void driver_device::sound_reset()
 
197
{
 
198
}
 
199
 
 
200
 
 
201
//-------------------------------------------------
 
202
//  video_reset - default implementation which
 
203
//  calls to the legacy video_reset function
 
204
//-------------------------------------------------
 
205
 
 
206
void driver_device::video_reset()
 
207
{
 
208
}
 
209
 
 
210
 
 
211
//-------------------------------------------------
 
212
//  device_rom_region - return a pointer to the
 
213
//  game's ROMs
 
214
//-------------------------------------------------
 
215
 
 
216
const rom_entry *driver_device::device_rom_region() const
 
217
{
 
218
        return m_system->rom;
 
219
}
 
220
 
 
221
 
 
222
//-------------------------------------------------
 
223
//  device_input_ports - return a pointer to the
 
224
//  game's input ports
 
225
//-------------------------------------------------
 
226
 
 
227
ioport_constructor driver_device::device_input_ports() const
 
228
{
 
229
        return m_system->ipt;
 
230
}
 
231
 
 
232
 
 
233
//-------------------------------------------------
 
234
//  device_start - device override which calls
 
235
//  the various helpers
 
236
//-------------------------------------------------
 
237
 
 
238
void driver_device::device_start()
 
239
{
 
240
        // bind our legacy callbacks
 
241
        for (int index = 0; index < ARRAY_LENGTH(m_legacy_callbacks); index++)
 
242
                if (m_legacy_callbacks[index] != NULL)
 
243
                        m_callbacks[index] = driver_callback_delegate(m_legacy_callbacks[index], "legacy_callback", &machine());
 
244
 
 
245
        // reschedule ourselves to be last
 
246
        device_iterator iter(*this);
 
247
        for (device_t *test = iter.first(); test != NULL; test = iter.next())
 
248
                if (test != this && !test->started())
 
249
                        throw device_missing_dependencies();
 
250
 
 
251
        // call the game-specific init
 
252
        if (m_system->driver_init != NULL)
 
253
                (*m_system->driver_init)(machine());
 
254
 
 
255
        // finish image devices init process
 
256
        image_postdevice_init(machine());
 
257
 
 
258
        // call palette_init if present
 
259
        if (!m_callbacks[CB_PALETTE_INIT].isnull())
 
260
                m_callbacks[CB_PALETTE_INIT]();
 
261
        else
 
262
                palette_init();
 
263
 
 
264
        // start the various pieces
 
265
        driver_start();
 
266
 
 
267
        if (!m_callbacks[CB_MACHINE_START].isnull())
 
268
                m_callbacks[CB_MACHINE_START]();
 
269
        else
 
270
                machine_start();
 
271
 
 
272
        if (!m_callbacks[CB_SOUND_START].isnull())
 
273
                m_callbacks[CB_SOUND_START]();
 
274
        else
 
275
                sound_start();
 
276
 
 
277
        if (!m_callbacks[CB_VIDEO_START].isnull())
 
278
                m_callbacks[CB_VIDEO_START]();
 
279
        else
 
280
                video_start();
 
281
 
 
282
        // save generic states
 
283
        save_item(NAME(m_flip_screen_x));
 
284
        save_item(NAME(m_flip_screen_y));
 
285
}
 
286
 
 
287
 
 
288
//-------------------------------------------------
 
289
//  device_reset_after_children - device override
 
290
//  which calls the various helpers; must happen
 
291
//  after all child devices are reset
 
292
//-------------------------------------------------
 
293
 
 
294
void driver_device::device_reset_after_children()
 
295
{
 
296
        // reset each piece
 
297
        driver_reset();
 
298
 
 
299
        if (!m_callbacks[CB_MACHINE_RESET].isnull())
 
300
                m_callbacks[CB_MACHINE_RESET]();
 
301
        else
 
302
                machine_reset();
 
303
 
 
304
        if (!m_callbacks[CB_SOUND_RESET].isnull())
 
305
                m_callbacks[CB_SOUND_RESET]();
 
306
        else
 
307
                sound_reset();
 
308
 
 
309
        if (!m_callbacks[CB_VIDEO_RESET].isnull())
 
310
                m_callbacks[CB_VIDEO_RESET]();
 
311
        else
 
312
                video_reset();
 
313
}
 
314
 
 
315
 
 
316
 
 
317
//**************************************************************************
 
318
//  INTERRUPT ENABLE AND VECTOR HELPERS
 
319
//**************************************************************************
 
320
 
 
321
//-------------------------------------------------
 
322
//  irq_pulse_clear - clear a "pulsed" IRQ line
 
323
//-------------------------------------------------
 
324
 
 
325
void driver_device::irq_pulse_clear(void *ptr, INT32 param)
 
326
{
 
327
        device_execute_interface *exec = reinterpret_cast<device_execute_interface *>(ptr);
 
328
        int irqline = param;
 
329
        exec->set_input_line(irqline, CLEAR_LINE);
 
330
}
 
331
 
 
332
 
 
333
//-------------------------------------------------
 
334
//  generic_pulse_irq_line - "pulse" an IRQ line by
 
335
//  asserting it and then clearing it x cycle(s)
 
336
//  later
 
337
//-------------------------------------------------
 
338
 
 
339
void driver_device::generic_pulse_irq_line(device_execute_interface &exec, int irqline, int cycles)
 
340
{
 
341
        assert(irqline != INPUT_LINE_NMI && irqline != INPUT_LINE_RESET && cycles > 0);
 
342
        exec.set_input_line(irqline, ASSERT_LINE);
 
343
 
 
344
        attotime target_time = exec.local_time() + exec.cycles_to_attotime(cycles * exec.min_cycles());
 
345
        machine().scheduler().timer_set(target_time - machine().time(), timer_expired_delegate(FUNC(driver_device::irq_pulse_clear), this), irqline, (void *)&exec);
 
346
}
 
347
 
 
348
 
 
349
//-------------------------------------------------
 
350
//  generic_pulse_irq_line_and_vector - "pulse" an
 
351
//  IRQ line by asserting it and then clearing it
 
352
//  x cycle(s) later, specifying a vector
 
353
//-------------------------------------------------
 
354
 
 
355
void driver_device::generic_pulse_irq_line_and_vector(device_execute_interface &exec, int irqline, int vector, int cycles)
 
356
{
 
357
        assert(irqline != INPUT_LINE_NMI && irqline != INPUT_LINE_RESET && cycles > 0);
 
358
        exec.set_input_line_and_vector(irqline, ASSERT_LINE, vector);
 
359
 
 
360
        attotime target_time = exec.local_time() + exec.cycles_to_attotime(cycles * exec.min_cycles());
 
361
        machine().scheduler().timer_set(target_time - machine().time(), timer_expired_delegate(FUNC(driver_device::irq_pulse_clear), this), irqline, (void *)&exec);
 
362
}
 
363
 
 
364
 
 
365
 
 
366
//**************************************************************************
 
367
//  INTERRUPT GENERATION CALLBACK HELPERS
 
368
//**************************************************************************
 
369
 
 
370
//-------------------------------------------------
 
371
//  NMI callbacks
 
372
//-------------------------------------------------
 
373
 
 
374
INTERRUPT_GEN_MEMBER( driver_device::nmi_line_pulse )   { device.execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE); }
 
375
INTERRUPT_GEN_MEMBER( driver_device::nmi_line_assert )  { device.execute().set_input_line(INPUT_LINE_NMI, ASSERT_LINE); }
 
376
 
 
377
 
 
378
//-------------------------------------------------
 
379
//  IRQn callbacks
 
380
//-------------------------------------------------
 
381
 
 
382
INTERRUPT_GEN_MEMBER( driver_device::irq0_line_hold )   { device.execute().set_input_line(0, HOLD_LINE); }
 
383
INTERRUPT_GEN_MEMBER( driver_device::irq0_line_pulse )  { generic_pulse_irq_line(device.execute(), 0, 1); }
 
384
INTERRUPT_GEN_MEMBER( driver_device::irq0_line_assert ) { device.execute().set_input_line(0, ASSERT_LINE); }
 
385
 
 
386
INTERRUPT_GEN_MEMBER( driver_device::irq1_line_hold )   { device.execute().set_input_line(1, HOLD_LINE); }
 
387
INTERRUPT_GEN_MEMBER( driver_device::irq1_line_pulse )  { generic_pulse_irq_line(device.execute(), 1, 1); }
 
388
INTERRUPT_GEN_MEMBER( driver_device::irq1_line_assert ) { device.execute().set_input_line(1, ASSERT_LINE); }
 
389
 
 
390
INTERRUPT_GEN_MEMBER( driver_device::irq2_line_hold )   { device.execute().set_input_line(2, HOLD_LINE); }
 
391
INTERRUPT_GEN_MEMBER( driver_device::irq2_line_pulse )  { generic_pulse_irq_line(device.execute(), 2, 1); }
 
392
INTERRUPT_GEN_MEMBER( driver_device::irq2_line_assert ) { device.execute().set_input_line(2, ASSERT_LINE); }
 
393
 
 
394
INTERRUPT_GEN_MEMBER( driver_device::irq3_line_hold )   { device.execute().set_input_line(3, HOLD_LINE); }
 
395
INTERRUPT_GEN_MEMBER( driver_device::irq3_line_pulse )  { generic_pulse_irq_line(device.execute(), 3, 1); }
 
396
INTERRUPT_GEN_MEMBER( driver_device::irq3_line_assert ) { device.execute().set_input_line(3, ASSERT_LINE); }
 
397
 
 
398
INTERRUPT_GEN_MEMBER( driver_device::irq4_line_hold )   { device.execute().set_input_line(4, HOLD_LINE); }
 
399
INTERRUPT_GEN_MEMBER( driver_device::irq4_line_pulse )  { generic_pulse_irq_line(device.execute(), 4, 1); }
 
400
INTERRUPT_GEN_MEMBER( driver_device::irq4_line_assert ) { device.execute().set_input_line(4, ASSERT_LINE); }
 
401
 
 
402
INTERRUPT_GEN_MEMBER( driver_device::irq5_line_hold )   { device.execute().set_input_line(5, HOLD_LINE); }
 
403
INTERRUPT_GEN_MEMBER( driver_device::irq5_line_pulse )  { generic_pulse_irq_line(device.execute(), 5, 1); }
 
404
INTERRUPT_GEN_MEMBER( driver_device::irq5_line_assert ) { device.execute().set_input_line(5, ASSERT_LINE); }
 
405
 
 
406
INTERRUPT_GEN_MEMBER( driver_device::irq6_line_hold )   { device.execute().set_input_line(6, HOLD_LINE); }
 
407
INTERRUPT_GEN_MEMBER( driver_device::irq6_line_pulse )  { generic_pulse_irq_line(device.execute(), 6, 1); }
 
408
INTERRUPT_GEN_MEMBER( driver_device::irq6_line_assert ) { device.execute().set_input_line(6, ASSERT_LINE); }
 
409
 
 
410
INTERRUPT_GEN_MEMBER( driver_device::irq7_line_hold )   { device.execute().set_input_line(7, HOLD_LINE); }
 
411
INTERRUPT_GEN_MEMBER( driver_device::irq7_line_pulse )  { generic_pulse_irq_line(device.execute(), 7, 1); }
 
412
INTERRUPT_GEN_MEMBER( driver_device::irq7_line_assert ) { device.execute().set_input_line(7, ASSERT_LINE); }
 
413
 
 
414
 
 
415
 
 
416
//**************************************************************************
 
417
//  WATCHDOG READ/WRITE HELPERS
 
418
//**************************************************************************
 
419
 
 
420
//-------------------------------------------------
 
421
//  8-bit reset read/write handlers
 
422
//-------------------------------------------------
 
423
 
 
424
WRITE8_MEMBER( driver_device::watchdog_reset_w ) { machine().watchdog_reset(); }
 
425
READ8_MEMBER( driver_device::watchdog_reset_r ) { machine().watchdog_reset(); return space.unmap(); }
 
426
 
 
427
 
 
428
//-------------------------------------------------
 
429
//  16-bit reset read/write handlers
 
430
//-------------------------------------------------
 
431
 
 
432
WRITE16_MEMBER( driver_device::watchdog_reset16_w ) { machine().watchdog_reset(); }
 
433
READ16_MEMBER( driver_device::watchdog_reset16_r ) { machine().watchdog_reset(); return space.unmap(); }
 
434
 
 
435
 
 
436
//-------------------------------------------------
 
437
//  32-bit reset read/write handlers
 
438
//-------------------------------------------------
 
439
 
 
440
WRITE32_MEMBER( driver_device::watchdog_reset32_w ) { machine().watchdog_reset(); }
 
441
READ32_MEMBER( driver_device::watchdog_reset32_r ) { machine().watchdog_reset(); return space.unmap(); }
 
442
 
 
443
 
 
444
 
 
445
//**************************************************************************
 
446
//  GENERIC SOUND COMMAND LATCHING
 
447
//**************************************************************************
 
448
 
 
449
//-------------------------------------------------
 
450
//  soundlatch_sync_callback - time-delayed
 
451
//  callback to set a latch value
 
452
//-------------------------------------------------
 
453
 
 
454
void driver_device::soundlatch_sync_callback(void *ptr, INT32 param)
 
455
{
 
456
        UINT16 value = param >> 8;
 
457
        int which = param & 0xff;
 
458
 
 
459
        // if the latch hasn't been read and the value is changed, log a warning
 
460
        if (!m_latch_read[which] && m_latched_value[which] != value)
 
461
                logerror("Warning: sound latch %d written before being read. Previous: %02x, new: %02x\n", which, m_latched_value[which], value);
 
462
 
 
463
        // store the new value and mark it not read
 
464
        m_latched_value[which] = value;
 
465
        m_latch_read[which] = 0;
 
466
}
 
467
 
 
468
 
 
469
//-------------------------------------------------
 
470
//  soundlatch_byte_w - global write handlers for
 
471
//  writing to sound latches
 
472
//-------------------------------------------------
 
473
 
 
474
WRITE8_MEMBER( driver_device::soundlatch_byte_w )               { machine().scheduler().synchronize(timer_expired_delegate(FUNC(driver_device::soundlatch_sync_callback), this), 0 | (data << 8)); }
 
475
WRITE16_MEMBER( driver_device::soundlatch_word_w )  { machine().scheduler().synchronize(timer_expired_delegate(FUNC(driver_device::soundlatch_sync_callback), this), 0 | (data << 8)); }
 
476
WRITE8_MEMBER( driver_device::soundlatch2_byte_w )              { machine().scheduler().synchronize(timer_expired_delegate(FUNC(driver_device::soundlatch_sync_callback), this), 1 | (data << 8)); }
 
477
WRITE16_MEMBER( driver_device::soundlatch2_word_w ) { machine().scheduler().synchronize(timer_expired_delegate(FUNC(driver_device::soundlatch_sync_callback), this), 1 | (data << 8)); }
 
478
WRITE8_MEMBER( driver_device::soundlatch3_byte_w )              { machine().scheduler().synchronize(timer_expired_delegate(FUNC(driver_device::soundlatch_sync_callback), this), 2 | (data << 8)); }
 
479
WRITE16_MEMBER( driver_device::soundlatch3_word_w ) { machine().scheduler().synchronize(timer_expired_delegate(FUNC(driver_device::soundlatch_sync_callback), this), 2 | (data << 8)); }
 
480
WRITE8_MEMBER( driver_device::soundlatch4_byte_w )      { machine().scheduler().synchronize(timer_expired_delegate(FUNC(driver_device::soundlatch_sync_callback), this), 3 | (data << 8)); }
 
481
WRITE16_MEMBER( driver_device::soundlatch4_word_w ) { machine().scheduler().synchronize(timer_expired_delegate(FUNC(driver_device::soundlatch_sync_callback), this), 3 | (data << 8)); }
 
482
 
 
483
 
 
484
//-------------------------------------------------
 
485
//  soundlatch_byte_r - global read handlers for
 
486
//  reading from sound latches
 
487
//-------------------------------------------------
 
488
 
 
489
READ8_MEMBER( driver_device::soundlatch_byte_r )                { return m_latched_value[0]; }
 
490
READ16_MEMBER( driver_device::soundlatch_word_r )   { return m_latched_value[0]; }
 
491
READ8_MEMBER( driver_device::soundlatch2_byte_r )               { return m_latched_value[1]; }
 
492
READ16_MEMBER( driver_device::soundlatch2_word_r )  { return m_latched_value[1]; }
 
493
READ8_MEMBER( driver_device::soundlatch3_byte_r )               { return m_latched_value[2]; }
 
494
READ16_MEMBER( driver_device::soundlatch3_word_r )  { return m_latched_value[2]; }
 
495
READ8_MEMBER( driver_device::soundlatch4_byte_r )               { return m_latched_value[3]; }
 
496
READ16_MEMBER( driver_device::soundlatch4_word_r )  { return m_latched_value[3]; }
 
497
 
 
498
 
 
499
//-------------------------------------------------
 
500
//  soundlatch_clear_byte_w - global write handlers
 
501
//  for clearing sound latches
 
502
//-------------------------------------------------
 
503
 
 
504
WRITE8_MEMBER( driver_device::soundlatch_clear_byte_w )  { m_latched_value[0] = m_latch_clear_value; }
 
505
WRITE8_MEMBER( driver_device::soundlatch2_clear_byte_w ) { m_latched_value[1] = m_latch_clear_value; }
 
506
WRITE8_MEMBER( driver_device::soundlatch3_clear_byte_w ) { m_latched_value[2] = m_latch_clear_value; }
 
507
WRITE8_MEMBER( driver_device::soundlatch4_clear_byte_w ) { m_latched_value[3] = m_latch_clear_value; }
 
508
 
 
509
 
 
510
 
 
511
//**************************************************************************
 
512
//  GENERIC FLIP SCREEN HANDLING
 
513
//**************************************************************************
 
514
 
 
515
//-------------------------------------------------
 
516
//  updateflip - handle global flipping
 
517
//-------------------------------------------------
 
518
 
 
519
void driver_device::updateflip()
 
520
{
 
521
        // push the flip state to all tilemaps
 
522
        machine().tilemap().set_flip_all((TILEMAP_FLIPX & m_flip_screen_x) | (TILEMAP_FLIPY & m_flip_screen_y));
 
523
 
 
524
        // flip the visible area within the screen width/height
 
525
        int width = machine().primary_screen->width();
 
526
        int height = machine().primary_screen->height();
 
527
        rectangle visarea = machine().primary_screen->visible_area();
 
528
        if (m_flip_screen_x)
 
529
        {
 
530
                int temp = width - visarea.min_x - 1;
 
531
                visarea.min_x = width - visarea.max_x - 1;
 
532
                visarea.max_x = temp;
 
533
        }
 
534
        if (m_flip_screen_y)
 
535
        {
 
536
                int temp = height - visarea.min_y - 1;
 
537
                visarea.min_y = height - visarea.max_y - 1;
 
538
                visarea.max_y = temp;
 
539
        }
 
540
 
 
541
        // reconfigure the screen with the new visible area
 
542
        attoseconds_t period = machine().primary_screen->frame_period().attoseconds;
 
543
        machine().primary_screen->configure(width, height, visarea, period);
 
544
}
 
545
 
 
546
 
 
547
//-------------------------------------------------
 
548
//  flip_screen_set - set global flip
 
549
//-------------------------------------------------
 
550
 
 
551
void driver_device::flip_screen_set(UINT32 on)
 
552
{
 
553
        // normalize to all 1
 
554
        if (on)
 
555
                on = ~0;
 
556
 
 
557
        // if something's changed, handle it
 
558
        if (m_flip_screen_x != on || m_flip_screen_y != on)
 
559
        {
 
560
                if (!on)
 
561
                        updateflip(); // flip visarea back
 
562
                m_flip_screen_x = m_flip_screen_y = on;
 
563
                updateflip();
 
564
        }
 
565
}
 
566
 
 
567
 
 
568
//-------------------------------------------------
 
569
//  flip_screen_set_no_update - set global flip
 
570
//  do not call update_flip.
 
571
//-------------------------------------------------
 
572
 
 
573
void driver_device::flip_screen_set_no_update(UINT32 on)
 
574
{
 
575
        // flip_screen_y is not updated on purpose
 
576
    // this function is for drivers which
 
577
    // where writing to flip_screen_x to
 
578
    // bypass update_flip
 
579
        if (on)
 
580
                on = ~0;
 
581
        m_flip_screen_x = on;
 
582
}
 
583
 
 
584
 
 
585
//-------------------------------------------------
 
586
//  flip_screen_x_set - set global horizontal flip
 
587
//-------------------------------------------------
 
588
 
 
589
void driver_device::flip_screen_x_set(UINT32 on)
 
590
{
 
591
        // normalize to all 1
 
592
        if (on)
 
593
                on = ~0;
 
594
 
 
595
        // if something's changed, handle it
 
596
        if (m_flip_screen_x != on)
 
597
        {
 
598
                m_flip_screen_x = on;
 
599
                updateflip();
 
600
        }
 
601
}
 
602
 
 
603
 
 
604
//-------------------------------------------------
 
605
//  flip_screen_y_set - set global vertical flip
 
606
//-------------------------------------------------
 
607
 
 
608
void driver_device::flip_screen_y_set(UINT32 on)
 
609
{
 
610
        // normalize to all 1
 
611
        if (on)
 
612
                on = ~0;
 
613
 
 
614
        // if something's changed, handle it
 
615
        if (m_flip_screen_y != on)
 
616
        {
 
617
                m_flip_screen_y = on;
 
618
                updateflip();
 
619
        }
 
620
}
 
621
 
 
622
 
 
623
 
 
624
//**************************************************************************
 
625
//  8-BIT PALETTE WRITE HANDLERS
 
626
//**************************************************************************
 
627
 
 
628
// 3-3-2 RGB palette write handlers
 
629
WRITE8_MEMBER( driver_device::paletteram_BBGGGRRR_byte_w ) { palette_8bit_byte_w<3,3,2, 0,3,6>(space, offset, data, mem_mask); }
 
630
WRITE8_MEMBER( driver_device::paletteram_RRRGGGBB_byte_w ) { palette_8bit_byte_w<3,3,2, 5,2,0>(space, offset, data, mem_mask); }
 
631
WRITE8_MEMBER( driver_device::paletteram_BBGGRRII_byte_w )
 
632
{
 
633
        m_generic_paletteram_8[offset] = data;
 
634
        int i = (data >> 0) & 3;
 
635
        palette_set_color_rgb(machine(), offset, pal4bit(((data >> 0) & 0x0c) | i),
 
636
                                           pal4bit(((data >> 2) & 0x0c) | i),
 
637
                                           pal4bit(((data >> 4) & 0x0c) | i));
 
638
}
 
639
 
 
640
 
 
641
 
 
642
//**************************************************************************
 
643
//  16-BIT PALETTE WRITE HANDLERS
 
644
//**************************************************************************
 
645
 
 
646
// 4-4-4 RGB palette write handlers
 
647
WRITE8_MEMBER( driver_device::paletteram_xxxxBBBBGGGGRRRR_byte_le_w ) { palette_16bit_byte_le_w<4,4,4, 0,4,8>(space, offset, data, mem_mask); }
 
648
WRITE8_MEMBER( driver_device::paletteram_xxxxBBBBGGGGRRRR_byte_be_w ) { palette_16bit_byte_be_w<4,4,4, 0,4,8>(space, offset, data, mem_mask); }
 
649
WRITE8_MEMBER( driver_device::paletteram_xxxxBBBBGGGGRRRR_byte_split_lo_w ) { palette_16bit_byte_split_lo_w<4,4,4, 0,4,8>(space, offset, data, mem_mask); }
 
650
WRITE8_MEMBER( driver_device::paletteram_xxxxBBBBGGGGRRRR_byte_split_hi_w ) { palette_16bit_byte_split_hi_w<4,4,4, 0,4,8>(space, offset, data, mem_mask); }
 
651
WRITE16_MEMBER( driver_device::paletteram_xxxxBBBBGGGGRRRR_word_w ) { palette_16bit_word_w<4,4,4, 0,4,8>(space, offset, data, mem_mask); }
 
652
 
 
653
WRITE8_MEMBER( driver_device::paletteram_xxxxBBBBRRRRGGGG_byte_le_w ) { palette_16bit_byte_le_w<4,4,4, 4,0,8>(space, offset, data, mem_mask); }
 
654
WRITE8_MEMBER( driver_device::paletteram_xxxxBBBBRRRRGGGG_byte_be_w ) { palette_16bit_byte_be_w<4,4,4, 4,0,8>(space, offset, data, mem_mask); }
 
655
WRITE8_MEMBER( driver_device::paletteram_xxxxBBBBRRRRGGGG_byte_split_lo_w ) { palette_16bit_byte_split_lo_w<4,4,4, 4,0,8>(space, offset, data, mem_mask); }
 
656
WRITE8_MEMBER( driver_device::paletteram_xxxxBBBBRRRRGGGG_byte_split_hi_w ) { palette_16bit_byte_split_hi_w<4,4,4, 4,0,8>(space, offset, data, mem_mask); }
 
657
WRITE16_MEMBER( driver_device::paletteram_xxxxBBBBRRRRGGGG_word_w ) { palette_16bit_word_w<4,4,4, 4,0,8>(space, offset, data, mem_mask); }
 
658
 
 
659
WRITE8_MEMBER( driver_device::paletteram_xxxxRRRRBBBBGGGG_byte_split_lo_w ) { palette_16bit_byte_split_lo_w<4,4,4, 8,0,4>(space, offset, data, mem_mask); }
 
660
WRITE8_MEMBER( driver_device::paletteram_xxxxRRRRBBBBGGGG_byte_split_hi_w ) { palette_16bit_byte_split_hi_w<4,4,4, 8,0,4>(space, offset, data, mem_mask); }
 
661
 
 
662
WRITE8_MEMBER( driver_device::paletteram_xxxxRRRRGGGGBBBB_byte_le_w ) { palette_16bit_byte_le_w<4,4,4, 8,4,0>(space, offset, data, mem_mask); }
 
663
WRITE8_MEMBER( driver_device::paletteram_xxxxRRRRGGGGBBBB_byte_be_w ) { palette_16bit_byte_be_w<4,4,4, 8,4,0>(space, offset, data, mem_mask); }
 
664
WRITE8_MEMBER( driver_device::paletteram_xxxxRRRRGGGGBBBB_byte_split_lo_w ) { palette_16bit_byte_split_lo_w<4,4,4, 8,4,0>(space, offset, data, mem_mask); }
 
665
WRITE8_MEMBER( driver_device::paletteram_xxxxRRRRGGGGBBBB_byte_split_hi_w ) { palette_16bit_byte_split_hi_w<4,4,4, 8,4,0>(space, offset, data, mem_mask); }
 
666
WRITE16_MEMBER( driver_device::paletteram_xxxxRRRRGGGGBBBB_word_w ) { palette_16bit_word_w<4,4,4, 8,4,0>(space, offset, data, mem_mask); }
 
667
 
 
668
WRITE8_MEMBER( driver_device::paletteram_RRRRGGGGBBBBxxxx_byte_be_w ) { palette_16bit_byte_be_w<4,4,4, 12,8,4>(space, offset, data, mem_mask); }
 
669
WRITE8_MEMBER( driver_device::paletteram_RRRRGGGGBBBBxxxx_byte_split_lo_w ) { palette_16bit_byte_split_lo_w<4,4,4, 12,8,4>(space, offset, data, mem_mask); }
 
670
WRITE8_MEMBER( driver_device::paletteram_RRRRGGGGBBBBxxxx_byte_split_hi_w ) { palette_16bit_byte_split_hi_w<4,4,4, 12,8,4>(space, offset, data, mem_mask); }
 
671
WRITE16_MEMBER( driver_device::paletteram_RRRRGGGGBBBBxxxx_word_w ) { palette_16bit_word_w<4,4,4, 12,8,4>(space, offset, data, mem_mask); }
 
672
 
 
673
// 4-4-4-4 IRGB palette write handlers
 
674
template<int _IShift, int _RShift, int _GShift, int _BShift>
 
675
inline void set_color_irgb(running_machine &machine, pen_t color, UINT16 data)
 
676
{
 
677
        static const UINT8 ztable[16] = { 0x0, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11 };
 
678
        UINT8 i = ztable[(data >> _IShift) & 15];
 
679
        UINT8 r = ((data >> _RShift) & 15) * i;
 
680
        UINT8 g = ((data >> _GShift) & 15) * i;
 
681
        UINT8 b = ((data >> _BShift) & 15) * i;
 
682
        palette_set_color_rgb(machine, color, r, g, b);
 
683
}
 
684
 
 
685
WRITE16_MEMBER( driver_device::paletteram_IIIIRRRRGGGGBBBB_word_w )
 
686
{
 
687
        COMBINE_DATA(&m_generic_paletteram_16[offset]);
 
688
        set_color_irgb<12,8,4,0>(machine(), offset, m_generic_paletteram_16[offset]);
 
689
}
 
690
 
 
691
WRITE16_MEMBER( driver_device::paletteram_RRRRGGGGBBBBIIII_word_w )
 
692
{
 
693
        COMBINE_DATA(&m_generic_paletteram_16[offset]);
 
694
        set_color_irgb<0,12,8,4>(machine(), offset, m_generic_paletteram_16[offset]);
 
695
}
 
696
 
 
697
// 5-5-5 RGB palette write handlers
 
698
WRITE8_MEMBER( driver_device::paletteram_xBBBBBGGGGGRRRRR_byte_le_w ) { palette_16bit_byte_le_w<5,5,5, 0,5,10>(space, offset, data, mem_mask); }
 
699
WRITE8_MEMBER( driver_device::paletteram_xBBBBBGGGGGRRRRR_byte_be_w ) { palette_16bit_byte_be_w<5,5,5, 0,5,10>(space, offset, data, mem_mask); }
 
700
WRITE8_MEMBER( driver_device::paletteram_xBBBBBGGGGGRRRRR_byte_split_lo_w ) { palette_16bit_byte_split_lo_w<5,5,5, 0,5,10>(space, offset, data, mem_mask); }
 
701
WRITE8_MEMBER( driver_device::paletteram_xBBBBBGGGGGRRRRR_byte_split_hi_w ) { palette_16bit_byte_split_hi_w<5,5,5, 0,5,10>(space, offset, data, mem_mask); }
 
702
WRITE16_MEMBER( driver_device::paletteram_xBBBBBGGGGGRRRRR_word_w ) { palette_16bit_word_w<5,5,5, 0,5,10>(space, offset, data, mem_mask); }
 
703
 
 
704
WRITE8_MEMBER( driver_device::paletteram_xBBBBBRRRRRGGGGG_byte_split_lo_w ) { palette_16bit_byte_split_lo_w<5,5,5, 5,0,10>(space, offset, data, mem_mask); }
 
705
WRITE8_MEMBER( driver_device::paletteram_xBBBBBRRRRRGGGGG_byte_split_hi_w ) { palette_16bit_byte_split_hi_w<5,5,5, 5,0,10>(space, offset, data, mem_mask); }
 
706
 
 
707
WRITE8_MEMBER( driver_device::paletteram_xRRRRRGGGGGBBBBB_byte_le_w ) { palette_16bit_byte_le_w<5,5,5, 10,5,0>(space, offset, data, mem_mask); }
 
708
WRITE8_MEMBER( driver_device::paletteram_xRRRRRGGGGGBBBBB_byte_be_w ) { palette_16bit_byte_be_w<5,5,5, 10,5,0>(space, offset, data, mem_mask); }
 
709
WRITE8_MEMBER( driver_device::paletteram_xRRRRRGGGGGBBBBB_byte_split_lo_w ) { palette_16bit_byte_split_lo_w<5,5,5, 10,5,0>(space, offset, data, mem_mask); }
 
710
WRITE8_MEMBER( driver_device::paletteram_xRRRRRGGGGGBBBBB_byte_split_hi_w ) { palette_16bit_byte_split_hi_w<5,5,5, 10,5,0>(space, offset, data, mem_mask); }
 
711
WRITE16_MEMBER( driver_device::paletteram_xRRRRRGGGGGBBBBB_word_w ) { palette_16bit_word_w<5,5,5, 10,5,0>(space, offset, data, mem_mask); }
 
712
WRITE32_MEMBER( driver_device::paletteram_xRRRRRGGGGGBBBBB_dword_be_w ) { palette_16bit_dword_be_w<5,5,5, 10,5,0>(space, offset, data, mem_mask); }
 
713
WRITE32_MEMBER( driver_device::paletteram_xRRRRRGGGGGBBBBB_dword_le_w ) { palette_16bit_dword_le_w<5,5,5, 10,5,0>(space, offset, data, mem_mask); }
 
714
 
 
715
WRITE8_MEMBER( driver_device::paletteram_xGGGGGRRRRRBBBBB_byte_le_w ) { palette_16bit_byte_le_w<5,5,5, 5,10,0>(space, offset, data, mem_mask); }
 
716
 
 
717
WRITE16_MEMBER( driver_device::paletteram_xGGGGGRRRRRBBBBB_word_w ) { palette_16bit_word_w<5,5,5, 5,10,0>(space, offset, data, mem_mask); }
 
718
WRITE16_MEMBER( driver_device::paletteram_xGGGGGBBBBBRRRRR_word_w ) { palette_16bit_word_w<5,5,5, 0,10,5>(space, offset, data, mem_mask); }
 
719
WRITE16_MEMBER( driver_device::paletteram_RRRRRGGGGGBBBBBx_word_w ) { palette_16bit_word_w<5,5,5, 11,6,1>(space, offset, data, mem_mask); }
 
720
WRITE16_MEMBER( driver_device::paletteram_GGGGGRRRRRBBBBBx_word_w ) { palette_16bit_word_w<5,5,5, 6,11,1>(space, offset, data, mem_mask); }
 
721
WRITE16_MEMBER( driver_device::paletteram_RRRRGGGGBBBBRGBx_word_w )
 
722
{
 
723
        COMBINE_DATA(&m_generic_paletteram_16[offset]);
 
724
        data = m_generic_paletteram_16[offset];
 
725
        palette_set_color_rgb(machine(), offset, pal5bit(((data >> 11) & 0x1e) | ((data >> 3) & 0x01)),
 
726
                                                pal5bit(((data >>  7) & 0x1e) | ((data >> 2) & 0x01)),
 
727
                                                pal5bit(((data >>  3) & 0x1e) | ((data >> 1) & 0x01)));
 
728
}
 
729
 
 
730
 
 
731
//**************************************************************************
 
732
//  32-BIT PALETTE WRITE HANDLERS
 
733
//**************************************************************************
 
734
 
 
735
// 8-8-8 RGB palette write handlers
 
736
WRITE16_MEMBER( driver_device::paletteram_xrgb_word_be_w ) { palette_32bit_word_be_w<8,8,8, 16,8,0>(space, offset, data, mem_mask); }
 
737
WRITE16_MEMBER( driver_device::paletteram_xbgr_word_be_w ) { palette_32bit_word_be_w<8,8,8, 0,8,16>(space, offset, data, mem_mask); }