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

« back to all changes in this revision

Viewing changes to src/mame/video/cclimber.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:
11
11
#include "includes/cclimber.h"
12
12
 
13
13
 
14
 
#define CCLIMBER_FLIP_X         (cclimber_flip_screen[0] & 0x01)
15
 
#define CCLIMBER_FLIP_Y         (cclimber_flip_screen[1] & 0x01)
 
14
#define CCLIMBER_FLIP_X         (state->m_flip_screen[0] & 0x01)
 
15
#define CCLIMBER_FLIP_Y         (state->m_flip_screen[1] & 0x01)
16
16
#define CCLIMBER_BG_PEN         (0)
17
17
#define SWIMMER_SIDE_BG_PEN     (0x120)
18
18
#define SWIMMER_BG_SPLIT        (0x18 * 8)
19
19
#define YAMATO_SKY_PEN_BASE     (0x60)
20
20
 
21
 
static tilemap_t *pf_tilemap;
22
 
static tilemap_t *bs_tilemap;
23
 
 
24
 
UINT8 *cclimber_videoram;
25
 
UINT8 *cclimber_colorram;
26
 
UINT8 *cclimber_spriteram;
27
 
 
28
 
UINT8 *cclimber_bigsprite_videoram;
29
 
UINT8 *cclimber_bigsprite_control;
30
 
UINT8 *cclimber_column_scroll;
31
 
UINT8 *cclimber_flip_screen;
32
 
 
33
 
UINT8 *swimmer_background_color;
34
 
UINT8 *swimmer_side_background_enabled;
35
 
UINT8 *swimmer_palettebank;
36
 
 
37
 
UINT8 *toprollr_bg_videoram;
38
 
UINT8 *toprollr_bg_coloram;
39
 
static tilemap_t *toproller_bg_tilemap;
40
 
 
41
21
 
42
22
/***************************************************************************
43
23
 
69
49
                        2, resistances_b,  weights_b,  0, 0,
70
50
                        0, 0, 0, 0, 0);
71
51
 
72
 
        for (i = 0;i < machine->total_colors(); i++)
 
52
        for (i = 0;i < machine.total_colors(); i++)
73
53
        {
74
54
                int bit0, bit1, bit2;
75
55
                int r, g, b;
316
296
 
317
297
***************************************************************************/
318
298
 
319
 
static void swimmer_set_background_pen(running_machine *machine)
 
299
static void swimmer_set_background_pen(running_machine &machine)
320
300
{
 
301
        cclimber_state *state = machine.driver_data<cclimber_state>();
321
302
        int bit0, bit1, bit2;
322
303
        int r, g, b;
323
304
 
324
305
        /* red component */
325
306
        bit0 = 0;
326
 
        bit1 = (*swimmer_background_color >> 6) & 0x01;
327
 
        bit2 = (*swimmer_background_color >> 7) & 0x01;
 
307
        bit1 = (*state->m_swimmer_background_color >> 6) & 0x01;
 
308
        bit2 = (*state->m_swimmer_background_color >> 7) & 0x01;
328
309
        r = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2;
329
310
 
330
311
        /* green component */
331
 
        bit0 = (*swimmer_background_color >> 3) & 0x01;
332
 
        bit1 = (*swimmer_background_color >> 4) & 0x01;
333
 
        bit2 = (*swimmer_background_color >> 5) & 0x01;
 
312
        bit0 = (*state->m_swimmer_background_color >> 3) & 0x01;
 
313
        bit1 = (*state->m_swimmer_background_color >> 4) & 0x01;
 
314
        bit2 = (*state->m_swimmer_background_color >> 5) & 0x01;
334
315
        g = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2;
335
316
 
336
317
        /* blue component */
337
 
        bit0 = (*swimmer_background_color >> 0) & 0x01;
338
 
        bit1 = (*swimmer_background_color >> 1) & 0x01;
339
 
        bit2 = (*swimmer_background_color >> 2) & 0x01;
 
318
        bit0 = (*state->m_swimmer_background_color >> 0) & 0x01;
 
319
        bit1 = (*state->m_swimmer_background_color >> 1) & 0x01;
 
320
        bit2 = (*state->m_swimmer_background_color >> 2) & 0x01;
340
321
        b = 0x20 * bit0 + 0x40 * bit1 + 0x80 * bit2;
341
322
 
342
323
        palette_set_color(machine, CCLIMBER_BG_PEN, MAKE_RGB(r, g, b));
346
327
 
347
328
WRITE8_HANDLER( cclimber_colorram_w )
348
329
{
 
330
        cclimber_state *state = space->machine().driver_data<cclimber_state>();
349
331
        /* A5 is not connected, there is only 0x200 bytes of RAM */
350
 
        cclimber_colorram[offset & ~0x20] = data;
351
 
        cclimber_colorram[offset |  0x20] = data;
 
332
        state->m_colorram[offset & ~0x20] = data;
 
333
        state->m_colorram[offset |  0x20] = data;
352
334
}
353
335
 
354
336
 
355
337
WRITE8_HANDLER( cannonb_flip_screen_w )
356
338
{
357
 
        cclimber_flip_screen[0] = data;
358
 
        cclimber_flip_screen[1] = data;
 
339
        cclimber_state *state = space->machine().driver_data<cclimber_state>();
 
340
        state->m_flip_screen[0] = data;
 
341
        state->m_flip_screen[1] = data;
359
342
}
360
343
 
361
344
 
362
345
static TILE_GET_INFO( cclimber_get_pf_tile_info )
363
346
{
 
347
        cclimber_state *state = machine.driver_data<cclimber_state>();
364
348
        int code, color;
365
349
 
366
 
        int flags = TILE_FLIPYX(cclimber_colorram[tile_index] >> 6);
 
350
        int flags = TILE_FLIPYX(state->m_colorram[tile_index] >> 6);
367
351
 
368
352
        /* vertical flipping flips two adjacent characters */
369
353
        if (flags & 0x02)
370
354
                tile_index = tile_index ^ 0x20;
371
355
 
372
 
        code = ((cclimber_colorram[tile_index] & 0x10) << 5) |
373
 
                   ((cclimber_colorram[tile_index] & 0x20) << 3) |
374
 
                         cclimber_videoram[tile_index];
 
356
        code = ((state->m_colorram[tile_index] & 0x10) << 5) |
 
357
                   ((state->m_colorram[tile_index] & 0x20) << 3) |
 
358
                         state->m_videoram[tile_index];
375
359
 
376
 
        color = cclimber_colorram[tile_index] & 0x0f;
 
360
        color = state->m_colorram[tile_index] & 0x0f;
377
361
 
378
362
        SET_TILE_INFO(0, code, color, flags);
379
363
}
381
365
 
382
366
static TILE_GET_INFO( swimmer_get_pf_tile_info )
383
367
{
 
368
        cclimber_state *state = machine.driver_data<cclimber_state>();
384
369
        int code, color;
385
370
 
386
 
        int flags = TILE_FLIPYX(cclimber_colorram[tile_index] >> 6);
 
371
        int flags = TILE_FLIPYX(state->m_colorram[tile_index] >> 6);
387
372
 
388
373
        /* vertical flipping flips two adjacent characters */
389
374
        if (flags & 0x02)
390
375
                tile_index = tile_index ^ 0x20;
391
376
 
392
 
        code = ((cclimber_colorram[tile_index] & 0x10) << 4) | cclimber_videoram[tile_index];
393
 
        color = ((*swimmer_palettebank & 0x01) << 4) | (cclimber_colorram[tile_index] & 0x0f);
 
377
        code = ((state->m_colorram[tile_index] & 0x10) << 4) | state->m_videoram[tile_index];
 
378
        color = ((*state->m_swimmer_palettebank & 0x01) << 4) | (state->m_colorram[tile_index] & 0x0f);
394
379
 
395
380
        SET_TILE_INFO(0, code, color, flags);
396
381
}
398
383
 
399
384
static TILE_GET_INFO( toprollr_get_pf_tile_info )
400
385
{
 
386
        cclimber_state *state = machine.driver_data<cclimber_state>();
401
387
        int code, attr, color;
402
388
 
403
 
        attr = tile_index & 0x10 ? cclimber_colorram[tile_index & ~0x20] : cclimber_colorram[tile_index];
404
 
        code = ((attr & 0x30) << 4) | cclimber_videoram[tile_index];
 
389
        attr = tile_index & 0x10 ? state->m_colorram[tile_index & ~0x20] : state->m_colorram[tile_index];
 
390
        code = ((attr & 0x30) << 4) | state->m_videoram[tile_index];
405
391
        color = attr & 0x0f;
406
392
 
407
393
        SET_TILE_INFO(0, code, color, 0);
410
396
 
411
397
static TILE_GET_INFO( cclimber_get_bs_tile_info )
412
398
{
 
399
        cclimber_state *state = machine.driver_data<cclimber_state>();
413
400
        int code, color;
414
401
 
415
402
        /* only the lower right is visible */
418
405
        /* the address doesn't use A4 of the coordinates, giving a 16x16 map */
419
406
        tile_index = ((tile_index & 0x1e0) >> 1) | (tile_index & 0x0f);
420
407
 
421
 
        code = ((cclimber_bigsprite_control[1] & 0x08) << 5) | cclimber_bigsprite_videoram[tile_index];
422
 
        color = cclimber_bigsprite_control[1] & 0x07;
 
408
        code = ((state->m_bigsprite_control[1] & 0x08) << 5) | state->m_bigsprite_videoram[tile_index];
 
409
        color = state->m_bigsprite_control[1] & 0x07;
423
410
 
424
411
        SET_TILE_INFO(2, code, color, 0);
425
412
}
427
414
 
428
415
static TILE_GET_INFO( toprollr_get_bs_tile_info )
429
416
{
 
417
        cclimber_state *state = machine.driver_data<cclimber_state>();
430
418
        int code, color;
431
419
 
432
420
        /* only the lower right is visible */
435
423
        /* the address doesn't use A4 of the coordinates, giving a 16x16 map */
436
424
        tile_index = ((tile_index & 0x1e0) >> 1) | (tile_index & 0x0f);
437
425
 
438
 
        code = ((cclimber_bigsprite_control[1] & 0x18) << 5) | cclimber_bigsprite_videoram[tile_index];
439
 
        color = cclimber_bigsprite_control[1] & 0x07;
 
426
        code = ((state->m_bigsprite_control[1] & 0x18) << 5) | state->m_bigsprite_videoram[tile_index];
 
427
        color = state->m_bigsprite_control[1] & 0x07;
440
428
 
441
429
        SET_TILE_INFO(2, code, color, 0);
442
430
}
444
432
 
445
433
static TILE_GET_INFO( toproller_get_bg_tile_info )
446
434
{
447
 
        int code = ((toprollr_bg_coloram[tile_index] & 0x40) << 2) | toprollr_bg_videoram[tile_index];
448
 
        int color = toprollr_bg_coloram[tile_index] & 0x0f;
 
435
        cclimber_state *state = machine.driver_data<cclimber_state>();
 
436
        int code = ((state->m_toprollr_bg_coloram[tile_index] & 0x40) << 2) | state->m_toprollr_bg_videoram[tile_index];
 
437
        int color = state->m_toprollr_bg_coloram[tile_index] & 0x0f;
449
438
 
450
439
        SET_TILE_INFO(3, code, color, TILE_FLIPX);
451
440
}
453
442
 
454
443
VIDEO_START( cclimber )
455
444
{
456
 
        pf_tilemap = tilemap_create(machine, cclimber_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
457
 
        tilemap_set_transparent_pen(pf_tilemap, 0);
458
 
        tilemap_set_scroll_cols(pf_tilemap, 32);
 
445
        cclimber_state *state = machine.driver_data<cclimber_state>();
 
446
        state->m_pf_tilemap = tilemap_create(machine, cclimber_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
 
447
        tilemap_set_transparent_pen(state->m_pf_tilemap, 0);
 
448
        tilemap_set_scroll_cols(state->m_pf_tilemap, 32);
459
449
 
460
 
        bs_tilemap = tilemap_create(machine, cclimber_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
461
 
        tilemap_set_scroll_cols(bs_tilemap, 1);
462
 
        tilemap_set_scroll_rows(bs_tilemap, 1);
463
 
        tilemap_set_transmask(bs_tilemap, 0, 0x01, 0);  /* pen 0 is transaprent */
464
 
        tilemap_set_transmask(bs_tilemap, 1, 0x0f, 0);  /* all 4 pens are transparent */
 
450
        state->m_bs_tilemap = tilemap_create(machine, cclimber_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
 
451
        tilemap_set_scroll_cols(state->m_bs_tilemap, 1);
 
452
        tilemap_set_scroll_rows(state->m_bs_tilemap, 1);
 
453
        tilemap_set_transmask(state->m_bs_tilemap, 0, 0x01, 0); /* pen 0 is transaprent */
 
454
        tilemap_set_transmask(state->m_bs_tilemap, 1, 0x0f, 0);  /* all 4 pens are transparent */
465
455
}
466
456
 
467
457
 
468
458
VIDEO_START( swimmer )
469
459
{
470
 
        pf_tilemap = tilemap_create(machine, swimmer_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
471
 
        tilemap_set_transparent_pen(pf_tilemap, 0);
472
 
        tilemap_set_scroll_cols(pf_tilemap, 32);
 
460
        cclimber_state *state = machine.driver_data<cclimber_state>();
 
461
        state->m_pf_tilemap = tilemap_create(machine, swimmer_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
 
462
        tilemap_set_transparent_pen(state->m_pf_tilemap, 0);
 
463
        tilemap_set_scroll_cols(state->m_pf_tilemap, 32);
473
464
 
474
 
        bs_tilemap = tilemap_create(machine, cclimber_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
475
 
        tilemap_set_scroll_cols(bs_tilemap, 1);
476
 
        tilemap_set_scroll_rows(bs_tilemap, 1);
477
 
        tilemap_set_transmask(bs_tilemap, 0, 0x01, 0);  /* pen 0 is transaprent */
478
 
        tilemap_set_transmask(bs_tilemap, 1, 0xff, 0);  /* all 8 pens are transparent */
 
465
        state->m_bs_tilemap = tilemap_create(machine, cclimber_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
 
466
        tilemap_set_scroll_cols(state->m_bs_tilemap, 1);
 
467
        tilemap_set_scroll_rows(state->m_bs_tilemap, 1);
 
468
        tilemap_set_transmask(state->m_bs_tilemap, 0, 0x01, 0); /* pen 0 is transaprent */
 
469
        tilemap_set_transmask(state->m_bs_tilemap, 1, 0xff, 0);  /* all 8 pens are transparent */
479
470
}
480
471
 
481
472
 
482
473
VIDEO_START( toprollr )
483
474
{
484
 
        pf_tilemap = tilemap_create(machine, toprollr_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
485
 
        tilemap_set_transparent_pen(pf_tilemap, 0);
486
 
 
487
 
        toproller_bg_tilemap = tilemap_create(machine, toproller_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
488
 
        tilemap_set_scroll_rows(toproller_bg_tilemap, 1);
489
 
 
490
 
        bs_tilemap = tilemap_create(machine, toprollr_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
491
 
        tilemap_set_scroll_cols(bs_tilemap, 1);
492
 
        tilemap_set_scroll_rows(bs_tilemap, 1);
493
 
        tilemap_set_transmask(bs_tilemap, 0, 0x01, 0);  /* pen 0 is transaprent */
494
 
        tilemap_set_transmask(bs_tilemap, 1, 0x0f, 0);  /* all 4 pens are transparent */
 
475
        cclimber_state *state = machine.driver_data<cclimber_state>();
 
476
        state->m_pf_tilemap = tilemap_create(machine, toprollr_get_pf_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
 
477
        tilemap_set_transparent_pen(state->m_pf_tilemap, 0);
 
478
 
 
479
        state->m_toproller_bg_tilemap = tilemap_create(machine, toproller_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
 
480
        tilemap_set_scroll_rows(state->m_toproller_bg_tilemap, 1);
 
481
 
 
482
        state->m_bs_tilemap = tilemap_create(machine, toprollr_get_bs_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
 
483
        tilemap_set_scroll_cols(state->m_bs_tilemap, 1);
 
484
        tilemap_set_scroll_rows(state->m_bs_tilemap, 1);
 
485
        tilemap_set_transmask(state->m_bs_tilemap, 0, 0x01, 0); /* pen 0 is transaprent */
 
486
        tilemap_set_transmask(state->m_bs_tilemap, 1, 0x0f, 0);  /* all 4 pens are transparent */
495
487
}
496
488
 
497
489
 
498
 
static void draw_playfield(bitmap_t *bitmap, const rectangle *cliprect)
 
490
static void draw_playfield(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
499
491
{
 
492
        cclimber_state *state = machine.driver_data<cclimber_state>();
500
493
        int i;
501
494
 
502
 
        tilemap_mark_all_tiles_dirty(pf_tilemap);
503
 
        tilemap_set_flip(pf_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) |
 
495
        tilemap_mark_all_tiles_dirty(state->m_pf_tilemap);
 
496
        tilemap_set_flip(state->m_pf_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) |
504
497
                                                                 (CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0));
505
498
        for (i = 0; i < 32; i++)
506
 
                tilemap_set_scrolly(pf_tilemap, i, cclimber_column_scroll[i]);
 
499
                tilemap_set_scrolly(state->m_pf_tilemap, i, state->m_column_scroll[i]);
507
500
 
508
 
        tilemap_draw(bitmap, cliprect, pf_tilemap, 0, 0);
 
501
        tilemap_draw(bitmap, cliprect, state->m_pf_tilemap, 0, 0);
509
502
}
510
503
 
511
504
 
512
 
static void cclimber_draw_bigsprite(bitmap_t *bitmap, const rectangle *cliprect)
 
505
static void cclimber_draw_bigsprite(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
513
506
{
514
 
        UINT8 x = cclimber_bigsprite_control[3] - 8;
515
 
        UINT8 y = cclimber_bigsprite_control[2];
516
 
        int bigsprite_flip_x = (cclimber_bigsprite_control[1] & 0x10) >> 4;
517
 
        int bigsprite_flip_y = (cclimber_bigsprite_control[1] & 0x20) >> 5;
 
507
        cclimber_state *state = machine.driver_data<cclimber_state>();
 
508
        UINT8 x = state->m_bigsprite_control[3] - 8;
 
509
        UINT8 y = state->m_bigsprite_control[2];
 
510
        int bigsprite_flip_x = (state->m_bigsprite_control[1] & 0x10) >> 4;
 
511
        int bigsprite_flip_y = (state->m_bigsprite_control[1] & 0x20) >> 5;
518
512
 
519
513
        if (bigsprite_flip_x)
520
514
                x = 0x80 - x;
522
516
        if (bigsprite_flip_y)
523
517
                y = 0x80 - y;
524
518
 
525
 
        tilemap_mark_all_tiles_dirty(bs_tilemap);
 
519
        tilemap_mark_all_tiles_dirty(state->m_bs_tilemap);
526
520
 
527
 
        tilemap_set_flip(bs_tilemap, (bigsprite_flip_x ? TILEMAP_FLIPX : 0) |
 
521
        tilemap_set_flip(state->m_bs_tilemap, (bigsprite_flip_x ? TILEMAP_FLIPX : 0) |
528
522
                                                                 (CCLIMBER_FLIP_Y ^ bigsprite_flip_y ? TILEMAP_FLIPY : 0));
529
523
 
530
 
        tilemap_set_scrollx(bs_tilemap, 0, x);
531
 
        tilemap_set_scrolly(bs_tilemap, 0, y);
 
524
        tilemap_set_scrollx(state->m_bs_tilemap, 0, x);
 
525
        tilemap_set_scrolly(state->m_bs_tilemap, 0, y);
532
526
 
533
 
        tilemap_draw(bitmap, cliprect, bs_tilemap, 0, 0);
 
527
        tilemap_draw(bitmap, cliprect, state->m_bs_tilemap, 0, 0);
534
528
}
535
529
 
536
530
 
537
 
static void toprollr_draw_bigsprite(bitmap_t *bitmap, const rectangle *cliprect)
 
531
static void toprollr_draw_bigsprite(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
538
532
{
539
 
        UINT8 x = cclimber_bigsprite_control[3] - 8;
540
 
        UINT8 y = cclimber_bigsprite_control[2];
541
 
 
542
 
        tilemap_mark_all_tiles_dirty(bs_tilemap);
543
 
 
544
 
        tilemap_set_flip(bs_tilemap, CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0);
545
 
 
546
 
        tilemap_set_scrollx(bs_tilemap, 0, x);
547
 
        tilemap_set_scrolly(bs_tilemap, 0, y);
548
 
 
549
 
        tilemap_draw(bitmap, cliprect, bs_tilemap, 0, 0);
 
533
        cclimber_state *state = machine.driver_data<cclimber_state>();
 
534
        UINT8 x = state->m_bigsprite_control[3] - 8;
 
535
        UINT8 y = state->m_bigsprite_control[2];
 
536
 
 
537
        tilemap_mark_all_tiles_dirty(state->m_bs_tilemap);
 
538
 
 
539
        tilemap_set_flip(state->m_bs_tilemap, CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0);
 
540
 
 
541
        tilemap_set_scrollx(state->m_bs_tilemap, 0, x);
 
542
        tilemap_set_scrolly(state->m_bs_tilemap, 0, y);
 
543
 
 
544
        tilemap_draw(bitmap, cliprect, state->m_bs_tilemap, 0, 0);
550
545
}
551
546
 
552
547
 
553
548
static void cclimber_draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx)
554
549
{
 
550
        cclimber_state *state = gfx->machine().driver_data<cclimber_state>();
555
551
        int offs;
556
552
 
557
553
        /* draw the sprites -- note that it is important to draw them exactly in this
558
554
       order, to have the correct priorities. */
559
555
        for (offs = 0x1c; offs >= 0; offs -= 4)
560
556
        {
561
 
                int x = cclimber_spriteram[offs + 3] + 1;
 
557
                int x = state->m_spriteram[offs + 3] + 1;
562
558
                /* x + 1 is evident in cclimber and ckong. It looks worse,
563
559
        but it has been confirmed on several PCBs. */
564
560
 
565
 
                int y = 240 - cclimber_spriteram[offs + 2];
566
 
 
567
 
                int code = ((cclimber_spriteram[offs + 1] & 0x10) << 3) |
568
 
                                   ((cclimber_spriteram[offs + 1] & 0x20) << 1) |
569
 
                                   ( cclimber_spriteram[offs + 0] & 0x3f);
570
 
 
571
 
                int color = cclimber_spriteram[offs + 1] & 0x0f;
572
 
 
573
 
                int flipx = cclimber_spriteram[offs + 0] & 0x40;
574
 
                int flipy = cclimber_spriteram[offs + 0] & 0x80;
 
561
                int y = 240 - state->m_spriteram[offs + 2];
 
562
 
 
563
                int code = ((state->m_spriteram[offs + 1] & 0x10) << 3) |
 
564
                                   ((state->m_spriteram[offs + 1] & 0x20) << 1) |
 
565
                                   ( state->m_spriteram[offs + 0] & 0x3f);
 
566
 
 
567
                int color = state->m_spriteram[offs + 1] & 0x0f;
 
568
 
 
569
                int flipx = state->m_spriteram[offs + 0] & 0x40;
 
570
                int flipy = state->m_spriteram[offs + 0] & 0x80;
575
571
 
576
572
                if (CCLIMBER_FLIP_X)
577
573
                {
592
588
 
593
589
static void toprollr_draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx)
594
590
{
 
591
        cclimber_state *state = gfx->machine().driver_data<cclimber_state>();
595
592
        int offs;
596
593
 
597
594
        /* draw the sprites -- note that it is important to draw them exactly in this
598
595
       order, to have the correct priorities. */
599
596
        for (offs = 0x1c; offs >= 0; offs -= 4)
600
597
        {
601
 
                int x = cclimber_spriteram[offs + 3];
602
 
                int y = 240 - cclimber_spriteram[offs + 2];
603
 
 
604
 
                int code = ((cclimber_spriteram[offs + 1] & 0x10) << 3) |
605
 
                                   ((cclimber_spriteram[offs + 1] & 0x20) << 1) |
606
 
                                   ( cclimber_spriteram[offs + 0] & 0x3f);
607
 
 
608
 
                int color = cclimber_spriteram[offs + 1] & 0x0f;
609
 
 
610
 
                int flipx = cclimber_spriteram[offs + 0] & 0x40;
611
 
                int flipy = cclimber_spriteram[offs + 0] & 0x80;
 
598
                int x = state->m_spriteram[offs + 3];
 
599
                int y = 240 - state->m_spriteram[offs + 2];
 
600
 
 
601
                int code = ((state->m_spriteram[offs + 1] & 0x10) << 3) |
 
602
                                   ((state->m_spriteram[offs + 1] & 0x20) << 1) |
 
603
                                   ( state->m_spriteram[offs + 0] & 0x3f);
 
604
 
 
605
                int color = state->m_spriteram[offs + 1] & 0x0f;
 
606
 
 
607
                int flipx = state->m_spriteram[offs + 0] & 0x40;
 
608
                int flipy = state->m_spriteram[offs + 0] & 0x80;
612
609
 
613
610
                if (CCLIMBER_FLIP_X)
614
611
                {
629
626
 
630
627
static void swimmer_draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx)
631
628
{
 
629
        cclimber_state *state = gfx->machine().driver_data<cclimber_state>();
632
630
        int offs;
633
631
 
634
632
        /* draw the sprites -- note that it is important to draw them exactly in this
635
633
       order, to have the correct priorities. */
636
634
        for (offs = 0x1c; offs >= 0; offs -= 4)
637
635
        {
638
 
                int x = cclimber_spriteram[offs + 3];
639
 
                int y = 240 - cclimber_spriteram[offs + 2];
640
 
 
641
 
                int code = ((cclimber_spriteram[offs + 1] & 0x10) << 2) |
642
 
                                   (cclimber_spriteram[offs + 0] & 0x3f);
643
 
 
644
 
                int color = ((*swimmer_palettebank & 0x01) << 4) |
645
 
                                        (cclimber_spriteram[offs + 1] & 0x0f);
646
 
 
647
 
                int flipx = cclimber_spriteram[offs + 0] & 0x40;
648
 
                int flipy = cclimber_spriteram[offs + 0] & 0x80;
 
636
                int x = state->m_spriteram[offs + 3];
 
637
                int y = 240 - state->m_spriteram[offs + 2];
 
638
 
 
639
                int code = ((state->m_spriteram[offs + 1] & 0x10) << 2) |
 
640
                                   (state->m_spriteram[offs + 0] & 0x3f);
 
641
 
 
642
                int color = ((*state->m_swimmer_palettebank & 0x01) << 4) |
 
643
                                        (state->m_spriteram[offs + 1] & 0x0f);
 
644
 
 
645
                int flipx = state->m_spriteram[offs + 0] & 0x40;
 
646
                int flipy = state->m_spriteram[offs + 0] & 0x80;
649
647
 
650
648
                if (CCLIMBER_FLIP_X)
651
649
                {
664
662
}
665
663
 
666
664
 
667
 
VIDEO_UPDATE( cclimber )
 
665
SCREEN_UPDATE( cclimber )
668
666
{
 
667
        cclimber_state *state = screen->machine().driver_data<cclimber_state>();
669
668
        bitmap_fill(bitmap, cliprect, CCLIMBER_BG_PEN);
670
 
        draw_playfield(bitmap, cliprect);
 
669
        draw_playfield(screen->machine(), bitmap, cliprect);
671
670
 
672
671
        /* draw the "big sprite" under the regular sprites */
673
 
        if ((cclimber_bigsprite_control[0] & 0x01))
 
672
        if ((state->m_bigsprite_control[0] & 0x01))
674
673
        {
675
 
                cclimber_draw_bigsprite(bitmap, cliprect);
676
 
                cclimber_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]);
 
674
                cclimber_draw_bigsprite(screen->machine(), bitmap, cliprect);
 
675
                cclimber_draw_sprites(bitmap, cliprect, screen->machine().gfx[1]);
677
676
        }
678
677
 
679
678
        /* draw the "big sprite" over the regular sprites */
680
679
        else
681
680
        {
682
 
                cclimber_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]);
683
 
                cclimber_draw_bigsprite(bitmap, cliprect);
 
681
                cclimber_draw_sprites(bitmap, cliprect, screen->machine().gfx[1]);
 
682
                cclimber_draw_bigsprite(screen->machine(), bitmap, cliprect);
684
683
        }
685
684
 
686
685
        return 0;
687
686
}
688
687
 
689
688
 
690
 
VIDEO_UPDATE( yamato )
 
689
SCREEN_UPDATE( yamato )
691
690
{
 
691
        cclimber_state *state = screen->machine().driver_data<cclimber_state>();
692
692
        int i;
693
 
        UINT8 *sky_rom = screen->machine->region("user1")->base() + 0x1200;
 
693
        UINT8 *sky_rom = screen->machine().region("user1")->base() + 0x1200;
694
694
 
695
695
        for (i = 0; i < 0x100; i++)
696
696
        {
701
701
                        *BITMAP_ADDR16(bitmap, j, (i - 8) & 0xff) = pen;
702
702
        }
703
703
 
704
 
        draw_playfield(bitmap, cliprect);
 
704
        draw_playfield(screen->machine(), bitmap, cliprect);
705
705
 
706
706
        /* draw the "big sprite" under the regular sprites */
707
 
        if ((cclimber_bigsprite_control[0] & 0x01))
 
707
        if ((state->m_bigsprite_control[0] & 0x01))
708
708
        {
709
 
                cclimber_draw_bigsprite(bitmap, cliprect);
710
 
                toprollr_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]);
 
709
                cclimber_draw_bigsprite(screen->machine(), bitmap, cliprect);
 
710
                toprollr_draw_sprites(bitmap, cliprect, screen->machine().gfx[1]);
711
711
        }
712
712
 
713
713
        /* draw the "big sprite" over the regular sprites */
714
714
        else
715
715
        {
716
 
                toprollr_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]);
717
 
                cclimber_draw_bigsprite(bitmap, cliprect);
 
716
                toprollr_draw_sprites(bitmap, cliprect, screen->machine().gfx[1]);
 
717
                cclimber_draw_bigsprite(screen->machine(), bitmap, cliprect);
718
718
        }
719
719
 
720
720
        return 0;
721
721
}
722
722
 
723
723
 
724
 
VIDEO_UPDATE( swimmer )
 
724
SCREEN_UPDATE( swimmer )
725
725
{
726
 
        swimmer_set_background_pen(screen->machine);
 
726
        cclimber_state *state = screen->machine().driver_data<cclimber_state>();
 
727
        swimmer_set_background_pen(screen->machine());
727
728
 
728
 
        if (*swimmer_side_background_enabled & 0x01)
 
729
        if (*state->m_swimmer_side_background_enabled & 0x01)
729
730
        {
730
731
                if (CCLIMBER_FLIP_X)
731
732
                {
753
754
        else
754
755
                bitmap_fill(bitmap, cliprect, CCLIMBER_BG_PEN);
755
756
 
756
 
        draw_playfield(bitmap, cliprect);
 
757
        draw_playfield(screen->machine(), bitmap, cliprect);
757
758
 
758
759
        /* draw the "big sprite" under the regular sprites */
759
 
        if ((cclimber_bigsprite_control[0] & 0x01))
 
760
        if ((state->m_bigsprite_control[0] & 0x01))
760
761
        {
761
 
                cclimber_draw_bigsprite(bitmap, cliprect);
762
 
                swimmer_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]);
 
762
                cclimber_draw_bigsprite(screen->machine(), bitmap, cliprect);
 
763
                swimmer_draw_sprites(bitmap, cliprect, screen->machine().gfx[1]);
763
764
        }
764
765
 
765
766
        /* draw the "big sprite" over the regular sprites */
766
767
        else
767
768
        {
768
 
                swimmer_draw_sprites(bitmap, cliprect, screen->machine->gfx[1]);
769
 
                cclimber_draw_bigsprite(bitmap, cliprect);
 
769
                swimmer_draw_sprites(bitmap, cliprect, screen->machine().gfx[1]);
 
770
                cclimber_draw_bigsprite(screen->machine(), bitmap, cliprect);
770
771
        }
771
772
 
772
773
        return 0;
773
774
}
774
775
 
775
776
 
776
 
VIDEO_UPDATE( toprollr )
 
777
SCREEN_UPDATE( toprollr )
777
778
{
 
779
        cclimber_state *state = screen->machine().driver_data<cclimber_state>();
778
780
        rectangle scroll_area_clip = *cliprect;
779
781
        scroll_area_clip.min_x = 4*8;
780
782
        scroll_area_clip.max_x = 29*8-1;
781
783
 
782
784
        bitmap_fill(bitmap, cliprect, CCLIMBER_BG_PEN);
783
785
 
784
 
        tilemap_set_scrollx(toproller_bg_tilemap, 0, toprollr_bg_videoram[0]);
785
 
        tilemap_set_flip(toproller_bg_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) |
 
786
        tilemap_set_scrollx(state->m_toproller_bg_tilemap, 0, state->m_toprollr_bg_videoram[0]);
 
787
        tilemap_set_flip(state->m_toproller_bg_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) |
786
788
                                                                                   (CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0));
787
 
        tilemap_mark_all_tiles_dirty(toproller_bg_tilemap);
788
 
        tilemap_draw(bitmap, &scroll_area_clip, toproller_bg_tilemap, 0, 0);
 
789
        tilemap_mark_all_tiles_dirty(state->m_toproller_bg_tilemap);
 
790
        tilemap_draw(bitmap, &scroll_area_clip, state->m_toproller_bg_tilemap, 0, 0);
789
791
 
790
792
        /* draw the "big sprite" over the regular sprites */
791
 
        if ((cclimber_bigsprite_control[1] & 0x20))
 
793
        if ((state->m_bigsprite_control[1] & 0x20))
792
794
        {
793
 
                toprollr_draw_sprites(bitmap, &scroll_area_clip, screen->machine->gfx[1]);
794
 
                toprollr_draw_bigsprite(bitmap, &scroll_area_clip);
 
795
                toprollr_draw_sprites(bitmap, &scroll_area_clip, screen->machine().gfx[1]);
 
796
                toprollr_draw_bigsprite(screen->machine(), bitmap, &scroll_area_clip);
795
797
        }
796
798
 
797
799
        /* draw the "big sprite" under the regular sprites */
798
800
        else
799
801
        {
800
 
                toprollr_draw_bigsprite(bitmap, &scroll_area_clip);
801
 
                toprollr_draw_sprites(bitmap, &scroll_area_clip, screen->machine->gfx[1]);
 
802
                toprollr_draw_bigsprite(screen->machine(), bitmap, &scroll_area_clip);
 
803
                toprollr_draw_sprites(bitmap, &scroll_area_clip, screen->machine().gfx[1]);
802
804
        }
803
805
 
804
 
        tilemap_mark_all_tiles_dirty(pf_tilemap);
805
 
        tilemap_set_flip(pf_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) |
 
806
        tilemap_mark_all_tiles_dirty(state->m_pf_tilemap);
 
807
        tilemap_set_flip(state->m_pf_tilemap, (CCLIMBER_FLIP_X ? TILEMAP_FLIPX : 0) |
806
808
                                                                 (CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0));
807
 
        tilemap_draw(bitmap, cliprect, pf_tilemap, 0, 0);
 
809
        tilemap_draw(bitmap, cliprect, state->m_pf_tilemap, 0, 0);
808
810
 
809
811
        return 0;
810
812
}