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

« back to all changes in this revision

Viewing changes to src/mame/drivers/jangou.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:
40
40
        jangou_state(running_machine &machine, const driver_device_config_base &config)
41
41
                : driver_device(machine, config) { }
42
42
 
43
 
        /* video-related */
44
 
        UINT8        *blit_buffer;
45
 
        UINT8        pen_data[0x10];
46
 
        UINT8        blit_data[6];
47
 
 
48
43
        /* sound-related */
49
44
        // Jangou CVSD Sound
50
 
        emu_timer    *cvsd_bit_timer;
51
 
        UINT8        cvsd_shiftreg;
52
 
        int          cvsd_shift_cnt;
 
45
        emu_timer    *m_cvsd_bit_timer;
 
46
        UINT8        m_cvsd_shiftreg;
 
47
        int          m_cvsd_shift_cnt;
53
48
        // Jangou Lady ADPCM Sound
54
 
        UINT8        adpcm_byte;
55
 
        int          msm5205_vclk_toggle;
 
49
        UINT8        m_adpcm_byte;
 
50
        int          m_msm5205_vclk_toggle;
56
51
 
57
52
        /* misc */
58
 
        UINT8        mux_data;
59
 
        UINT8        nsc_latch, z80_latch;
 
53
        UINT8        m_mux_data;
 
54
        UINT8        m_nsc_latch;
 
55
        UINT8            m_z80_latch;
60
56
 
61
57
        /* devices */
62
 
        device_t *cpu_0;
63
 
        device_t *cpu_1;
64
 
        device_t *cvsd;
65
 
        device_t *nsc;
 
58
        device_t *m_cpu_0;
 
59
        device_t *m_cpu_1;
 
60
        device_t *m_cvsd;
 
61
        device_t *m_nsc;
 
62
 
 
63
        /* video-related */
 
64
        UINT8        m_pen_data[0x10];
 
65
        UINT8        m_blit_data[6];
 
66
        UINT8        m_blit_buffer[256 * 256];
66
67
};
67
68
 
68
69
 
86
87
                        2, resistances_b,  weights_b,  0, 0,
87
88
                        0, 0, 0, 0, 0);
88
89
 
89
 
        for (i = 0;i < machine->total_colors(); i++)
 
90
        for (i = 0;i < machine.total_colors(); i++)
90
91
        {
91
92
                int bit0, bit1, bit2;
92
93
                int r, g, b;
114
115
 
115
116
static VIDEO_START( jangou )
116
117
{
117
 
        jangou_state *state = machine->driver_data<jangou_state>();
 
118
        jangou_state *state = machine.driver_data<jangou_state>();
118
119
 
119
 
        state->blit_buffer = auto_alloc_array(machine, UINT8, 256 * 256);
120
 
        state_save_register_global_pointer(machine, state->blit_buffer, 256 * 256);
 
120
        state->save_item(NAME(state->m_blit_buffer));
121
121
}
122
122
 
123
 
static VIDEO_UPDATE( jangou )
 
123
static SCREEN_UPDATE( jangou )
124
124
{
125
 
        jangou_state *state = screen->machine->driver_data<jangou_state>();
 
125
        jangou_state *state = screen->machine().driver_data<jangou_state>();
126
126
        int x, y;
127
127
 
128
128
        for (y = cliprect->min_y; y <= cliprect->max_y; ++y)
129
129
        {
130
 
                UINT8 *src = &state->blit_buffer[y * 512 / 2 + cliprect->min_x];
 
130
                UINT8 *src = &state->m_blit_buffer[y * 512 / 2 + cliprect->min_x];
131
131
                UINT16 *dst = BITMAP_ADDR16(bitmap, y, cliprect->min_x);
132
132
 
133
133
                for (x = cliprect->min_x; x <= cliprect->max_x; x += 2)
134
134
                {
135
135
                        UINT32 srcpix = *src++;
136
 
                        *dst++ = screen->machine->pens[srcpix & 0xf];
137
 
                        *dst++ = screen->machine->pens[(srcpix >> 4) & 0xf];
 
136
                        *dst++ = screen->machine().pens[srcpix & 0xf];
 
137
                        *dst++ = screen->machine().pens[(srcpix >> 4) & 0xf];
138
138
                }
139
139
        }
140
140
 
152
152
w [$17]
153
153
*/
154
154
 
155
 
static UINT8 jangou_gfx_nibble( running_machine *machine, UINT16 niboffset )
 
155
static UINT8 jangou_gfx_nibble( running_machine &machine, UINT16 niboffset )
156
156
{
157
 
        const UINT8 *const blit_rom = machine->region("gfx")->base();
 
157
        const UINT8 *const blit_rom = machine.region("gfx")->base();
158
158
 
159
159
        if (niboffset & 1)
160
160
                return (blit_rom[(niboffset >> 1) & 0xffff] & 0xf0) >> 4;
162
162
                return (blit_rom[(niboffset >> 1) & 0xffff] & 0x0f);
163
163
}
164
164
 
165
 
static void plot_jangou_gfx_pixel( running_machine *machine, UINT8 pix, int x, int y )
 
165
static void plot_jangou_gfx_pixel( running_machine &machine, UINT8 pix, int x, int y )
166
166
{
167
 
        jangou_state *state = machine->driver_data<jangou_state>();
 
167
        jangou_state *state = machine.driver_data<jangou_state>();
168
168
        if (y < 0 || y >= 512)
169
169
                return;
170
170
        if (x < 0 || x >= 512)
171
171
                return;
172
172
 
173
173
        if (x & 1)
174
 
                state->blit_buffer[(y * 256) + (x >> 1)] = (state->blit_buffer[(y * 256) + (x >> 1)] & 0x0f) | ((pix << 4) & 0xf0);
 
174
                state->m_blit_buffer[(y * 256) + (x >> 1)] = (state->m_blit_buffer[(y * 256) + (x >> 1)] & 0x0f) | ((pix << 4) & 0xf0);
175
175
        else
176
 
                state->blit_buffer[(y * 256) + (x >> 1)] = (state->blit_buffer[(y * 256) + (x >> 1)] & 0xf0) | (pix & 0x0f);
 
176
                state->m_blit_buffer[(y * 256) + (x >> 1)] = (state->m_blit_buffer[(y * 256) + (x >> 1)] & 0xf0) | (pix & 0x0f);
177
177
}
178
178
 
179
179
static WRITE8_HANDLER( blitter_process_w )
180
180
{
181
 
        jangou_state *state = space->machine->driver_data<jangou_state>();
 
181
        jangou_state *state = space->machine().driver_data<jangou_state>();
182
182
        int src, x, y, h, w, flipx;
183
 
        state->blit_data[offset] = data;
 
183
        state->m_blit_data[offset] = data;
184
184
 
185
185
        if (offset == 5)
186
186
        {
187
187
                int count = 0;
188
188
                int xcount, ycount;
189
189
 
190
 
                /* printf("%02x %02x %02x %02x %02x %02x\n", state->blit_data[0], state->blit_data[1], state->blit_data[2],
191
 
                    state->blit_data[3], state->blit_data[4], state->blit_data[5]); */
192
 
                w = (state->blit_data[4] & 0xff) + 1;
193
 
                h = (state->blit_data[5] & 0xff) + 1;
194
 
                src = ((state->blit_data[1] << 8)|(state->blit_data[0] << 0));
195
 
                x = (state->blit_data[2] & 0xff);
196
 
                y = (state->blit_data[3] & 0xff);
 
190
                /* printf("%02x %02x %02x %02x %02x %02x\n", state->m_blit_data[0], state->m_blit_data[1], state->m_blit_data[2],
 
191
                    state->m_blit_data[3], state->m_blit_data[4], state->m_blit_data[5]); */
 
192
                w = (state->m_blit_data[4] & 0xff) + 1;
 
193
                h = (state->m_blit_data[5] & 0xff) + 1;
 
194
                src = ((state->m_blit_data[1] << 8)|(state->m_blit_data[0] << 0));
 
195
                x = (state->m_blit_data[2] & 0xff);
 
196
                y = (state->m_blit_data[3] & 0xff);
197
197
 
198
198
                // lowest bit of src controls flipping / draw direction?
199
 
                flipx = (state->blit_data[0] & 1);
 
199
                flipx = (state->m_blit_data[0] & 1);
200
200
 
201
201
                if (!flipx)
202
202
                        src += (w * h) - 1;
209
209
                        {
210
210
                                int drawx = (x + xcount) & 0xff;
211
211
                                int drawy = (y + ycount) & 0xff;
212
 
                                UINT8 dat = jangou_gfx_nibble(space->machine, src + count);
213
 
                                UINT8 cur_pen_hi = state->pen_data[(dat & 0xf0) >> 4];
214
 
                                UINT8 cur_pen_lo = state->pen_data[(dat & 0x0f) >> 0];
 
212
                                UINT8 dat = jangou_gfx_nibble(space->machine(), src + count);
 
213
                                UINT8 cur_pen_hi = state->m_pen_data[(dat & 0xf0) >> 4];
 
214
                                UINT8 cur_pen_lo = state->m_pen_data[(dat & 0x0f) >> 0];
215
215
 
216
216
                                dat = cur_pen_lo | (cur_pen_hi << 4);
217
217
 
218
218
                                if ((dat & 0xff) != 0)
219
 
                                        plot_jangou_gfx_pixel(space->machine, dat, drawx, drawy);
 
219
                                        plot_jangou_gfx_pixel(space->machine(), dat, drawx, drawy);
220
220
 
221
221
                                if (!flipx)
222
222
                                        count--;
230
230
/* What is the bit 5 (0x20) for?*/
231
231
static WRITE8_HANDLER( blit_vregs_w )
232
232
{
233
 
        jangou_state *state = space->machine->driver_data<jangou_state>();
 
233
        jangou_state *state = space->machine().driver_data<jangou_state>();
234
234
 
235
235
        //  printf("%02x %02x\n", offset, data);
236
 
        state->pen_data[offset] = data & 0xf;
 
236
        state->m_pen_data[offset] = data & 0xf;
237
237
}
238
238
 
239
239
/*************************************
244
244
 
245
245
static WRITE8_HANDLER( mux_w )
246
246
{
247
 
        jangou_state *state = space->machine->driver_data<jangou_state>();
248
 
        state->mux_data = ~data;
 
247
        jangou_state *state = space->machine().driver_data<jangou_state>();
 
248
        state->m_mux_data = ~data;
249
249
}
250
250
 
251
251
static WRITE8_HANDLER( output_w )
256
256
    ---- ---x coin counter
257
257
    */
258
258
//  printf("%02x\n", data);
259
 
        coin_counter_w(space->machine, 0, data & 0x01);
 
259
        coin_counter_w(space->machine(), 0, data & 0x01);
260
260
//  flip_screen_set(data & 0x04);
261
 
//  coin_lockout_w(space->machine, 0, ~data & 0x20);
 
261
//  coin_lockout_w(space->machine(), 0, ~data & 0x20);
262
262
}
263
263
 
264
264
static READ8_DEVICE_HANDLER( input_mux_r )
265
265
{
266
 
        jangou_state *state = device->machine->driver_data<jangou_state>();
267
 
        switch(state->mux_data)
 
266
        jangou_state *state = device->machine().driver_data<jangou_state>();
 
267
        switch(state->m_mux_data)
268
268
        {
269
 
                case 0x01: return input_port_read(device->machine, "PL1_1");
270
 
                case 0x02: return input_port_read(device->machine, "PL1_2");
271
 
                case 0x04: return input_port_read(device->machine, "PL2_1");
272
 
                case 0x08: return input_port_read(device->machine, "PL2_2");
273
 
                case 0x10: return input_port_read(device->machine, "PL1_3");
274
 
                case 0x20: return input_port_read(device->machine, "PL2_3");
 
269
                case 0x01: return input_port_read(device->machine(), "PL1_1");
 
270
                case 0x02: return input_port_read(device->machine(), "PL1_2");
 
271
                case 0x04: return input_port_read(device->machine(), "PL2_1");
 
272
                case 0x08: return input_port_read(device->machine(), "PL2_2");
 
273
                case 0x10: return input_port_read(device->machine(), "PL1_3");
 
274
                case 0x20: return input_port_read(device->machine(), "PL2_3");
275
275
        }
276
276
 
277
 
        return input_port_read(device->machine, "IN_NOMUX");
 
277
        return input_port_read(device->machine(), "IN_NOMUX");
278
278
}
279
279
 
280
280
static READ8_DEVICE_HANDLER( input_system_r )
281
281
{
282
 
        return input_port_read(device->machine, "SYSTEM");
 
282
        return input_port_read(device->machine(), "SYSTEM");
283
283
}
284
284
 
285
285
 
291
291
 
292
292
static WRITE8_HANDLER( sound_latch_w )
293
293
{
294
 
        jangou_state *state = space->machine->driver_data<jangou_state>();
 
294
        jangou_state *state = space->machine().driver_data<jangou_state>();
295
295
        soundlatch_w(space, 0, data & 0xff);
296
 
        cpu_set_input_line(state->cpu_1, INPUT_LINE_NMI, ASSERT_LINE);
 
296
        device_set_input_line(state->m_cpu_1, INPUT_LINE_NMI, ASSERT_LINE);
297
297
}
298
298
 
299
299
static READ8_HANDLER( sound_latch_r )
300
300
{
301
 
        jangou_state *state = space->machine->driver_data<jangou_state>();
302
 
        cpu_set_input_line(state->cpu_1, INPUT_LINE_NMI, CLEAR_LINE);
 
301
        jangou_state *state = space->machine().driver_data<jangou_state>();
 
302
        device_set_input_line(state->m_cpu_1, INPUT_LINE_NMI, CLEAR_LINE);
303
303
        return soundlatch_r(space, 0);
304
304
}
305
305
 
306
306
/* Jangou HC-55516 CVSD */
307
307
static WRITE8_HANDLER( cvsd_w )
308
308
{
309
 
        jangou_state *state = space->machine->driver_data<jangou_state>();
310
 
        state->cvsd_shiftreg = data;
 
309
        jangou_state *state = space->machine().driver_data<jangou_state>();
 
310
        state->m_cvsd_shiftreg = data;
311
311
}
312
312
 
313
313
static TIMER_CALLBACK( cvsd_bit_timer_callback )
314
314
{
315
 
        jangou_state *state = machine->driver_data<jangou_state>();
 
315
        jangou_state *state = machine.driver_data<jangou_state>();
316
316
 
317
317
        /* Data is shifted out at the MSB */
318
 
        hc55516_digit_w(state->cvsd, (state->cvsd_shiftreg >> 7) & 1);
319
 
        state->cvsd_shiftreg <<= 1;
 
318
        hc55516_digit_w(state->m_cvsd, (state->m_cvsd_shiftreg >> 7) & 1);
 
319
        state->m_cvsd_shiftreg <<= 1;
320
320
 
321
321
        /* Trigger an IRQ for every 8 shifted bits */
322
 
        if ((++state->cvsd_shift_cnt & 7) == 0)
323
 
                cpu_set_input_line(state->cpu_1, 0, HOLD_LINE);
 
322
        if ((++state->m_cvsd_shift_cnt & 7) == 0)
 
323
                device_set_input_line(state->m_cpu_1, 0, HOLD_LINE);
324
324
}
325
325
 
326
326
 
327
327
/* Jangou Lady MSM5218 (MSM5205-compatible) ADPCM */
328
328
static WRITE8_HANDLER( adpcm_w )
329
329
{
330
 
        jangou_state *state = space->machine->driver_data<jangou_state>();
331
 
        state->adpcm_byte = data;
 
330
        jangou_state *state = space->machine().driver_data<jangou_state>();
 
331
        state->m_adpcm_byte = data;
332
332
}
333
333
 
334
334
static void jngolady_vclk_cb( device_t *device )
335
335
{
336
 
        jangou_state *state = device->machine->driver_data<jangou_state>();
 
336
        jangou_state *state = device->machine().driver_data<jangou_state>();
337
337
 
338
 
        if (state->msm5205_vclk_toggle == 0)
339
 
                msm5205_data_w(device, state->adpcm_byte >> 4);
 
338
        if (state->m_msm5205_vclk_toggle == 0)
 
339
                msm5205_data_w(device, state->m_adpcm_byte >> 4);
340
340
        else
341
341
        {
342
 
                msm5205_data_w(device, state->adpcm_byte & 0xf);
343
 
                cpu_set_input_line(state->cpu_1, 0, HOLD_LINE);
 
342
                msm5205_data_w(device, state->m_adpcm_byte & 0xf);
 
343
                device_set_input_line(state->m_cpu_1, 0, HOLD_LINE);
344
344
        }
345
345
 
346
 
        state->msm5205_vclk_toggle ^= 1;
 
346
        state->m_msm5205_vclk_toggle ^= 1;
347
347
}
348
348
 
349
349
 
355
355
 
356
356
static READ8_HANDLER( master_com_r )
357
357
{
358
 
        jangou_state *state = space->machine->driver_data<jangou_state>();
359
 
        return state->z80_latch;
 
358
        jangou_state *state = space->machine().driver_data<jangou_state>();
 
359
        return state->m_z80_latch;
360
360
}
361
361
 
362
362
static WRITE8_HANDLER( master_com_w )
363
363
{
364
 
        jangou_state *state = space->machine->driver_data<jangou_state>();
 
364
        jangou_state *state = space->machine().driver_data<jangou_state>();
365
365
 
366
 
        cpu_set_input_line(state->nsc, 0, HOLD_LINE);
367
 
        state->nsc_latch = data;
 
366
        device_set_input_line(state->m_nsc, 0, HOLD_LINE);
 
367
        state->m_nsc_latch = data;
368
368
}
369
369
 
370
370
static READ8_HANDLER( slave_com_r )
371
371
{
372
 
        jangou_state *state = space->machine->driver_data<jangou_state>();
373
 
        return state->nsc_latch;
 
372
        jangou_state *state = space->machine().driver_data<jangou_state>();
 
373
        return state->m_nsc_latch;
374
374
}
375
375
 
376
376
static WRITE8_HANDLER( slave_com_w )
377
377
{
378
 
        jangou_state *state = space->machine->driver_data<jangou_state>();
379
 
        state->z80_latch = data;
 
378
        jangou_state *state = space->machine().driver_data<jangou_state>();
 
379
        state->m_z80_latch = data;
380
380
}
381
381
 
382
382
/*************************************
385
385
 *
386
386
 *************************************/
387
387
 
388
 
static ADDRESS_MAP_START( cpu0_map, ADDRESS_SPACE_PROGRAM, 8 )
 
388
static ADDRESS_MAP_START( cpu0_map, AS_PROGRAM, 8 )
389
389
        AM_RANGE(0x0000, 0x9fff) AM_ROM
390
390
        AM_RANGE(0xc000, 0xc7ff) AM_RAM
391
391
ADDRESS_MAP_END
392
392
 
393
 
static ADDRESS_MAP_START( cpu0_io, ADDRESS_SPACE_IO, 8 )
 
393
static ADDRESS_MAP_START( cpu0_io, AS_IO, 8 )
394
394
        ADDRESS_MAP_GLOBAL_MASK(0xff)
395
395
        AM_RANGE(0x01,0x01) AM_DEVREAD("aysnd", ay8910_r)
396
396
        AM_RANGE(0x02,0x03) AM_DEVWRITE("aysnd", ay8910_data_address_w)
404
404
ADDRESS_MAP_END
405
405
 
406
406
 
407
 
static ADDRESS_MAP_START( cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
 
407
static ADDRESS_MAP_START( cpu1_map, AS_PROGRAM, 8 )
408
408
        AM_RANGE(0x0000, 0x7fff) AM_ROM AM_WRITENOP
409
409
ADDRESS_MAP_END
410
410
 
411
 
static ADDRESS_MAP_START( cpu1_io, ADDRESS_SPACE_IO, 8 )
 
411
static ADDRESS_MAP_START( cpu1_io, AS_IO, 8 )
412
412
        ADDRESS_MAP_GLOBAL_MASK(0xff)
413
413
        AM_RANGE(0x00,0x00) AM_READ(sound_latch_r)
414
414
        AM_RANGE(0x01,0x01) AM_WRITE(cvsd_w)
422
422
 *
423
423
 *************************************/
424
424
 
425
 
static ADDRESS_MAP_START( jngolady_cpu0_map, ADDRESS_SPACE_PROGRAM, 8 )
 
425
static ADDRESS_MAP_START( jngolady_cpu0_map, AS_PROGRAM, 8 )
426
426
        AM_RANGE(0x0000, 0x9fff) AM_ROM
427
427
        AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_SHARE("share1")
428
428
        AM_RANGE(0xe000, 0xe000) AM_READWRITE(master_com_r,master_com_w)
429
429
ADDRESS_MAP_END
430
430
 
431
431
 
432
 
static ADDRESS_MAP_START( jngolady_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
 
432
static ADDRESS_MAP_START( jngolady_cpu1_map, AS_PROGRAM, 8 )
433
433
        AM_RANGE(0x0000, 0x7fff) AM_ROM AM_WRITENOP
434
434
ADDRESS_MAP_END
435
435
 
436
 
static ADDRESS_MAP_START( jngolady_cpu1_io, ADDRESS_SPACE_IO, 8 )
 
436
static ADDRESS_MAP_START( jngolady_cpu1_io, AS_IO, 8 )
437
437
        ADDRESS_MAP_GLOBAL_MASK(0xff)
438
438
        AM_RANGE(0x00,0x00) AM_READ(sound_latch_r)
439
439
        AM_RANGE(0x01,0x01) AM_WRITE(adpcm_w)
441
441
ADDRESS_MAP_END
442
442
 
443
443
 
444
 
static ADDRESS_MAP_START( nsc_map, ADDRESS_SPACE_PROGRAM, 8 )
 
444
static ADDRESS_MAP_START( nsc_map, AS_PROGRAM, 8 )
445
445
        AM_RANGE(0x0000, 0x007f) AM_RAM //internal ram for irq etc.
446
446
        AM_RANGE(0x8000, 0x8000) AM_WRITENOP //write-only,irq related?
447
447
        AM_RANGE(0x9000, 0x9000) AM_READWRITE(slave_com_r,slave_com_w)
455
455
 *
456
456
 *************************************/
457
457
 
458
 
static ADDRESS_MAP_START( cntrygrl_cpu0_map, ADDRESS_SPACE_PROGRAM, 8 )
 
458
static ADDRESS_MAP_START( cntrygrl_cpu0_map, AS_PROGRAM, 8 )
459
459
        AM_RANGE(0x0000, 0x3fff) AM_ROM
460
460
//  AM_RANGE(0xc000, 0xc7ff) AM_RAM
461
461
        AM_RANGE(0xe000, 0xefff) AM_RAM
462
462
ADDRESS_MAP_END
463
463
 
464
 
static ADDRESS_MAP_START( cntrygrl_cpu0_io, ADDRESS_SPACE_IO, 8 )
 
464
static ADDRESS_MAP_START( cntrygrl_cpu0_io, AS_IO, 8 )
465
465
        ADDRESS_MAP_GLOBAL_MASK(0xff)
466
466
        AM_RANGE(0x01,0x01) AM_DEVREAD("aysnd", ay8910_r)
467
467
        AM_RANGE(0x02,0x03) AM_DEVWRITE("aysnd", ay8910_data_address_w)
480
480
 *
481
481
 *************************************/
482
482
 
483
 
static ADDRESS_MAP_START( roylcrdn_cpu0_map, ADDRESS_SPACE_PROGRAM, 8 )
 
483
static ADDRESS_MAP_START( roylcrdn_cpu0_map, AS_PROGRAM, 8 )
484
484
        AM_RANGE(0x0000, 0x2fff) AM_ROM
485
485
        AM_RANGE(0x7000, 0x77ff) AM_RAM AM_SHARE("nvram")       /* MK48Z02B-15 ZEROPOWER RAM */
486
486
ADDRESS_MAP_END
487
487
 
488
 
static ADDRESS_MAP_START( roylcrdn_cpu0_io, ADDRESS_SPACE_IO, 8 )
 
488
static ADDRESS_MAP_START( roylcrdn_cpu0_io, AS_IO, 8 )
489
489
        ADDRESS_MAP_GLOBAL_MASK(0xff)
490
490
        AM_RANGE(0x01,0x01) AM_DEVREAD("aysnd", ay8910_r)
491
491
        AM_RANGE(0x02,0x03) AM_DEVWRITE("aysnd", ay8910_data_address_w)
891
891
 
892
892
static SOUND_START( jangou )
893
893
{
894
 
        jangou_state *state = machine->driver_data<jangou_state>();
 
894
        jangou_state *state = machine.driver_data<jangou_state>();
895
895
 
896
896
        /* Create a timer to feed the CVSD DAC with sample bits */
897
 
        state->cvsd_bit_timer = timer_alloc(machine, cvsd_bit_timer_callback, NULL);
898
 
        timer_adjust_periodic(state->cvsd_bit_timer, ATTOTIME_IN_HZ(MASTER_CLOCK / 1024), 0, ATTOTIME_IN_HZ(MASTER_CLOCK / 1024));
 
897
        state->m_cvsd_bit_timer = machine.scheduler().timer_alloc(FUNC(cvsd_bit_timer_callback));
 
898
        state->m_cvsd_bit_timer->adjust(attotime::from_hz(MASTER_CLOCK / 1024), 0, attotime::from_hz(MASTER_CLOCK / 1024));
899
899
}
900
900
 
901
901
 
907
907
 
908
908
static MACHINE_START( common )
909
909
{
910
 
        jangou_state *state = machine->driver_data<jangou_state>();
911
 
 
912
 
        state->cpu_0 = machine->device("cpu0");
913
 
        state->cpu_1 = machine->device("cpu1");
914
 
        state->cvsd = machine->device("cvsd");
915
 
        state->nsc = machine->device("nsc");
916
 
 
917
 
        state_save_register_global_array(machine, state->pen_data);
918
 
        state_save_register_global_array(machine, state->blit_data);
919
 
        state_save_register_global(machine, state->mux_data);
 
910
        jangou_state *state = machine.driver_data<jangou_state>();
 
911
 
 
912
        state->m_cpu_0 = machine.device("cpu0");
 
913
        state->m_cpu_1 = machine.device("cpu1");
 
914
        state->m_cvsd = machine.device("cvsd");
 
915
        state->m_nsc = machine.device("nsc");
 
916
 
 
917
        state->save_item(NAME(state->m_pen_data));
 
918
        state->save_item(NAME(state->m_blit_data));
 
919
        state->save_item(NAME(state->m_mux_data));
920
920
}
921
921
 
922
922
static MACHINE_START( jangou )
923
923
{
924
 
        jangou_state *state = machine->driver_data<jangou_state>();
 
924
        jangou_state *state = machine.driver_data<jangou_state>();
925
925
 
926
926
        MACHINE_START_CALL(common);
927
927
 
928
 
        state_save_register_global(machine, state->cvsd_shiftreg);
929
 
        state_save_register_global(machine, state->cvsd_shift_cnt);
 
928
        state->save_item(NAME(state->m_cvsd_shiftreg));
 
929
        state->save_item(NAME(state->m_cvsd_shift_cnt));
930
930
}
931
931
 
932
932
static MACHINE_START( jngolady )
933
933
{
934
 
        jangou_state *state = machine->driver_data<jangou_state>();
 
934
        jangou_state *state = machine.driver_data<jangou_state>();
935
935
 
936
936
        MACHINE_START_CALL(common);
937
937
 
938
 
        state_save_register_global(machine, state->adpcm_byte);
939
 
        state_save_register_global(machine, state->msm5205_vclk_toggle);
940
 
        state_save_register_global(machine, state->nsc_latch);
941
 
        state_save_register_global(machine, state->z80_latch);
 
938
        state->save_item(NAME(state->m_adpcm_byte));
 
939
        state->save_item(NAME(state->m_msm5205_vclk_toggle));
 
940
        state->save_item(NAME(state->m_nsc_latch));
 
941
        state->save_item(NAME(state->m_z80_latch));
942
942
}
943
943
 
944
944
static MACHINE_RESET( common )
945
945
{
946
 
        jangou_state *state = machine->driver_data<jangou_state>();
 
946
        jangou_state *state = machine.driver_data<jangou_state>();
947
947
        int i;
948
948
 
949
 
        state->mux_data = 0;
 
949
        state->m_mux_data = 0;
950
950
 
951
951
        for (i = 0; i < 6; i++)
952
 
                state->blit_data[i] = 0;
 
952
                state->m_blit_data[i] = 0;
953
953
 
954
954
        for (i = 0; i < 16; i++)
955
 
                state->pen_data[i] = 0;
 
955
                state->m_pen_data[i] = 0;
956
956
}
957
957
 
958
958
static MACHINE_RESET( jangou )
959
959
{
960
 
        jangou_state *state = machine->driver_data<jangou_state>();
 
960
        jangou_state *state = machine.driver_data<jangou_state>();
961
961
 
962
962
        MACHINE_RESET_CALL(common);
963
963
 
964
 
        state->cvsd_shiftreg = 0;
965
 
        state->cvsd_shift_cnt = 0;
 
964
        state->m_cvsd_shiftreg = 0;
 
965
        state->m_cvsd_shift_cnt = 0;
966
966
}
967
967
 
968
968
static MACHINE_RESET( jngolady )
969
969
{
970
 
        jangou_state *state = machine->driver_data<jangou_state>();
 
970
        jangou_state *state = machine.driver_data<jangou_state>();
971
971
 
972
972
        MACHINE_RESET_CALL(common);
973
973
 
974
 
        state->adpcm_byte = 0;
975
 
        state->msm5205_vclk_toggle = 0;
976
 
        state->nsc_latch = 0;
977
 
        state->z80_latch = 0;
 
974
        state->m_adpcm_byte = 0;
 
975
        state->m_msm5205_vclk_toggle = 0;
 
976
        state->m_nsc_latch = 0;
 
977
        state->m_z80_latch = 0;
978
978
}
979
979
 
980
980
/* Note: All frequencies and dividers are unverified */
1002
1002
        MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1003
1003
        MCFG_SCREEN_SIZE(256, 256)
1004
1004
        MCFG_SCREEN_VISIBLE_AREA(0, 256-1, 16, 240-1)
 
1005
        MCFG_SCREEN_UPDATE(jangou)
1005
1006
 
1006
1007
        MCFG_PALETTE_LENGTH(32)
1007
1008
 
1008
1009
        MCFG_VIDEO_START(jangou)
1009
 
        MCFG_VIDEO_UPDATE(jangou)
1010
1010
 
1011
1011
        /* sound hardware */
1012
1012
        MCFG_SOUND_START(jangou)
1241
1241
 
1242
1242
ROM_START( cntrygrl )
1243
1243
        ROM_REGION( 0x10000, "cpu0", 0 )
1244
 
        ROM_LOAD( "rom4.bin", 0x00000, 0x02000, CRC(adba8e2f) SHA1(2aae77838e3de6e665b32a7fe4ac3f627c35b871)  )
1245
 
        ROM_LOAD( "rom5.bin", 0x02000, 0x02000, CRC(24d210ed) SHA1(6a0eae9d459975fbaad75bf21284baac3ba4f872) )
 
1244
        ROM_LOAD( "rom4.7l", 0x00000, 0x02000, CRC(adba8e2f) SHA1(2aae77838e3de6e665b32a7fe4ac3f627c35b871)  )
 
1245
        ROM_LOAD( "rom5.7k", 0x02000, 0x02000, CRC(24d210ed) SHA1(6a0eae9d459975fbaad75bf21284baac3ba4f872) )
1246
1246
 
1247
 
        /*wtf,these 2 roms are next to the CPU roms, one is a CPU rom from Moon Quasar, the other a GFX rom from Crazy Climber,
1248
 
      I dunno what's going on,the game doesn't appear to need these two....*/
 
1247
        /* wtf,these 2 roms are next to the CPU roms, one is a CPU rom from Moon Quasar, the other a GFX rom from Crazy Climber,
 
1248
        I dunno what's going on,the game doesn't appear to need these two....*/
1249
1249
        ROM_REGION( 0x1000, "user1", 0 )
1250
 
        ROM_LOAD( "rom6.bin", 0x00000, 0x0800, CRC(33965a89) SHA1(92912cea76a472d9b709c664d9818844a07fcc32)  ) // = mq3    Moon Quasar
1251
 
        ROM_LOAD( "rom7.bin", 0x00800, 0x0800, CRC(481b64cc) SHA1(3f35c545fc784ed4f969aba2d7be6e13a5ae32b7)  ) // = cc06   Crazy Climber (US)
 
1250
        ROM_LOAD( "rom6.7h", 0x00000, 0x0800, CRC(33965a89) SHA1(92912cea76a472d9b709c664d9818844a07fcc32)  ) // = mq3    Moon Quasar
 
1251
        ROM_LOAD( "rom7.7j", 0x00800, 0x0800, CRC(481b64cc) SHA1(3f35c545fc784ed4f969aba2d7be6e13a5ae32b7)  ) // = cc06   Crazy Climber (US)
1252
1252
 
1253
1253
        ROM_REGION( 0x10000, "gfx", 0 )
1254
 
        ROM_LOAD( "rom1.bin", 0x00000, 0x02000, CRC(92033f37) SHA1(aa407c2feb1cbb7cbc6c59656338453c5a670749)  )
1255
 
        ROM_LOAD( "rom2.bin", 0x02000, 0x02000, CRC(0588cc48) SHA1(f769ece2955eb9f055c499b6243a2fead9d07984)  )
1256
 
        ROM_LOAD( "rom3.bin", 0x04000, 0x02000, CRC(ce00ff56) SHA1(c5e58707a5dd0f57c34b09de542ef30e96ab95d1)  )
 
1254
        ROM_LOAD( "rom1.5m", 0x00000, 0x02000, CRC(92033f37) SHA1(aa407c2feb1cbb7cbc6c59656338453c5a670749)  )
 
1255
        ROM_LOAD( "rom2.5l", 0x02000, 0x02000, CRC(0588cc48) SHA1(f769ece2955eb9f055c499b6243a2fead9d07984)  )
 
1256
        ROM_LOAD( "rom3.5k", 0x04000, 0x02000, CRC(ce00ff56) SHA1(c5e58707a5dd0f57c34b09de542ef30e96ab95d1)  )
1257
1257
 
1258
1258
        ROM_REGION( 0x20, "proms", 0 )
1259
 
        ROM_LOAD( "countrygirl_prom.bin", 0x00, 0x20, CRC(dc54dc52) SHA1(db91a7ae05eb6b6e4b42f91dfe20ac0da6680b46)  )
 
1259
        ROM_LOAD( "countrygirl_prom.4f", 0x00, 0x20, CRC(dc54dc52) SHA1(db91a7ae05eb6b6e4b42f91dfe20ac0da6680b46)  )
1260
1260
ROM_END
1261
1261
 
1262
1262
ROM_START( fruitbun )
1292
1292
        ROM_LOAD( "5bunny.7j", 0x00800, 0x0800, CRC(06666bbf) SHA1(3d8eb4ea2d4fc6f3f327e710e19bcb68d8466d80) )
1293
1293
 
1294
1294
        ROM_REGION( 0x10000, "gfx", 0 )
1295
 
        ROM_LOAD( "rom1.bin", 0x00000, 0x02000, CRC(92033f37) SHA1(aa407c2feb1cbb7cbc6c59656338453c5a670749)  ) //5bunny.m5
1296
 
        ROM_LOAD( "rom2.bin", 0x02000, 0x02000, CRC(0588cc48) SHA1(f769ece2955eb9f055c499b6243a2fead9d07984)  ) //5bunny.l5
1297
 
        ROM_LOAD( "rom3.bin", 0x04000, 0x02000, CRC(ce00ff56) SHA1(c5e58707a5dd0f57c34b09de542ef30e96ab95d1)  ) //5bunny.k5
 
1295
        ROM_LOAD( "rom1.5m", 0x00000, 0x02000, CRC(92033f37) SHA1(aa407c2feb1cbb7cbc6c59656338453c5a670749)  ) //5bunny.m5
 
1296
        ROM_LOAD( "rom2.5l", 0x02000, 0x02000, CRC(0588cc48) SHA1(f769ece2955eb9f055c499b6243a2fead9d07984)  ) //5bunny.l5
 
1297
        ROM_LOAD( "rom3.5k", 0x04000, 0x02000, CRC(ce00ff56) SHA1(c5e58707a5dd0f57c34b09de542ef30e96ab95d1)  ) //5bunny.k5
1298
1298
 
1299
1299
        ROM_REGION( 0x20, "proms", 0 )
1300
1300
        ROM_LOAD( "tbp18s30n.4f", 0x00, 0x20, CRC(dc54dc52) SHA1(db91a7ae05eb6b6e4b42f91dfe20ac0da6680b46) ) //verified on real hardware
1356
1356
/*Temporary kludge for make the RNG work*/
1357
1357
static READ8_HANDLER( jngolady_rng_r )
1358
1358
{
1359
 
        return space->machine->rand();
 
1359
        return space->machine().rand();
1360
1360
}
1361
1361
 
1362
1362
static DRIVER_INIT( jngolady )
1363
1363
{
1364
 
        memory_install_read8_handler(cputag_get_address_space(machine, "nsc", ADDRESS_SPACE_PROGRAM), 0x08, 0x08, 0, 0, jngolady_rng_r );
 
1364
        machine.device("nsc")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x08, 0x08, FUNC(jngolady_rng_r) );
1365
1365
}
1366
1366
 
1367
1367
static DRIVER_INIT (luckygrl)
1368
1368
{
1369
1369
        // this is WRONG
1370
1370
        int A;
1371
 
        UINT8 *ROM = machine->region("cpu0")->base();
 
1371
        UINT8 *ROM = machine.region("cpu0")->base();
1372
1372
 
1373
1373
        unsigned char patn1[32] = {
1374
1374
                0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0,
1394
1394
        {
1395
1395
                FILE *fp;
1396
1396
                char filename[256];
1397
 
                sprintf(filename,"decrypted_%s", machine->gamedrv->name);
 
1397
                sprintf(filename,"decrypted_%s", machine.system().name);
1398
1398
                fp=fopen(filename, "w+b");
1399
1399
                if (fp)
1400
1400
                {