347
328
WRITE8_HANDLER( cclimber_colorram_w )
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;
355
337
WRITE8_HANDLER( cannonb_flip_screen_w )
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;
362
345
static TILE_GET_INFO( cclimber_get_pf_tile_info )
347
cclimber_state *state = machine.driver_data<cclimber_state>();
366
int flags = TILE_FLIPYX(cclimber_colorram[tile_index] >> 6);
350
int flags = TILE_FLIPYX(state->m_colorram[tile_index] >> 6);
368
352
/* vertical flipping flips two adjacent characters */
369
353
if (flags & 0x02)
370
354
tile_index = tile_index ^ 0x20;
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];
376
color = cclimber_colorram[tile_index] & 0x0f;
360
color = state->m_colorram[tile_index] & 0x0f;
378
362
SET_TILE_INFO(0, code, color, flags);
454
443
VIDEO_START( cclimber )
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);
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 */
468
458
VIDEO_START( swimmer )
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);
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 */
482
473
VIDEO_START( toprollr )
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);
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);
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);
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);
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 */
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)
492
cclimber_state *state = machine.driver_data<cclimber_state>();
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]);
508
tilemap_draw(bitmap, cliprect, pf_tilemap, 0, 0);
501
tilemap_draw(bitmap, cliprect, state->m_pf_tilemap, 0, 0);
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)
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;
519
513
if (bigsprite_flip_x)
522
516
if (bigsprite_flip_y)
525
tilemap_mark_all_tiles_dirty(bs_tilemap);
519
tilemap_mark_all_tiles_dirty(state->m_bs_tilemap);
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));
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);
533
tilemap_draw(bitmap, cliprect, bs_tilemap, 0, 0);
527
tilemap_draw(bitmap, cliprect, state->m_bs_tilemap, 0, 0);
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)
539
UINT8 x = cclimber_bigsprite_control[3] - 8;
540
UINT8 y = cclimber_bigsprite_control[2];
542
tilemap_mark_all_tiles_dirty(bs_tilemap);
544
tilemap_set_flip(bs_tilemap, CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0);
546
tilemap_set_scrollx(bs_tilemap, 0, x);
547
tilemap_set_scrolly(bs_tilemap, 0, y);
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];
537
tilemap_mark_all_tiles_dirty(state->m_bs_tilemap);
539
tilemap_set_flip(state->m_bs_tilemap, CCLIMBER_FLIP_Y ? TILEMAP_FLIPY : 0);
541
tilemap_set_scrollx(state->m_bs_tilemap, 0, x);
542
tilemap_set_scrolly(state->m_bs_tilemap, 0, y);
544
tilemap_draw(bitmap, cliprect, state->m_bs_tilemap, 0, 0);
553
548
static void cclimber_draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx)
550
cclimber_state *state = gfx->machine().driver_data<cclimber_state>();
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)
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. */
565
int y = 240 - cclimber_spriteram[offs + 2];
567
int code = ((cclimber_spriteram[offs + 1] & 0x10) << 3) |
568
((cclimber_spriteram[offs + 1] & 0x20) << 1) |
569
( cclimber_spriteram[offs + 0] & 0x3f);
571
int color = cclimber_spriteram[offs + 1] & 0x0f;
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];
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);
567
int color = state->m_spriteram[offs + 1] & 0x0f;
569
int flipx = state->m_spriteram[offs + 0] & 0x40;
570
int flipy = state->m_spriteram[offs + 0] & 0x80;
576
572
if (CCLIMBER_FLIP_X)
667
VIDEO_UPDATE( cclimber )
665
SCREEN_UPDATE( cclimber )
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);
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))
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]);
679
678
/* draw the "big sprite" over the regular sprites */
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);
690
VIDEO_UPDATE( yamato )
689
SCREEN_UPDATE( yamato )
691
cclimber_state *state = screen->machine().driver_data<cclimber_state>();
693
UINT8 *sky_rom = screen->machine->region("user1")->base() + 0x1200;
693
UINT8 *sky_rom = screen->machine().region("user1")->base() + 0x1200;
695
695
for (i = 0; i < 0x100; i++)
701
701
*BITMAP_ADDR16(bitmap, j, (i - 8) & 0xff) = pen;
704
draw_playfield(bitmap, cliprect);
704
draw_playfield(screen->machine(), bitmap, cliprect);
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))
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]);
713
713
/* draw the "big sprite" over the regular sprites */
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);
724
VIDEO_UPDATE( swimmer )
724
SCREEN_UPDATE( swimmer )
726
swimmer_set_background_pen(screen->machine);
726
cclimber_state *state = screen->machine().driver_data<cclimber_state>();
727
swimmer_set_background_pen(screen->machine());
728
if (*swimmer_side_background_enabled & 0x01)
729
if (*state->m_swimmer_side_background_enabled & 0x01)
730
731
if (CCLIMBER_FLIP_X)
754
755
bitmap_fill(bitmap, cliprect, CCLIMBER_BG_PEN);
756
draw_playfield(bitmap, cliprect);
757
draw_playfield(screen->machine(), bitmap, cliprect);
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))
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]);
765
766
/* draw the "big sprite" over the regular sprites */
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);
776
VIDEO_UPDATE( toprollr )
777
SCREEN_UPDATE( toprollr )
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;
782
784
bitmap_fill(bitmap, cliprect, CCLIMBER_BG_PEN);
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);
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))
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);
797
799
/* draw the "big sprite" under the regular sprites */
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]);
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);