1 // license:BSD-3-Clause
2 // copyright-holders:David Haywood
3 /* Aquarium */
4
5 #include "emu.h"
6 #include "includes/aquarium.h"
7
8
9 /* TXT Layer */
TILE_GET_INFO_MEMBER(aquarium_state::get_txt_tile_info)10 TILE_GET_INFO_MEMBER(aquarium_state::get_txt_tile_info)
11 {
12 const u32 tileno = (m_txt_videoram[tile_index] & 0x0fff);
13 const u32 colour = (m_txt_videoram[tile_index] & 0xf000) >> 12;
14 tileinfo.set(0, tileno, colour, 0);
15
16 tileinfo.category = (m_txt_videoram[tile_index] & 0x8000) >> 15;
17 }
18
txt_videoram_w(offs_t offset,u16 data,u16 mem_mask)19 void aquarium_state::txt_videoram_w(offs_t offset, u16 data, u16 mem_mask)
20 {
21 COMBINE_DATA(&m_txt_videoram[offset]);
22 m_txt_tilemap->mark_tile_dirty(offset);
23 }
24
25 /* MID Layer */
TILE_GET_INFO_MEMBER(aquarium_state::get_mid_tile_info)26 TILE_GET_INFO_MEMBER(aquarium_state::get_mid_tile_info)
27 {
28 const u32 tileno = (m_mid_videoram[tile_index * 2] & 0x0fff);
29 const u32 colour = (m_mid_videoram[tile_index * 2 + 1] & 0x001f);
30 const int flag = TILE_FLIPYX((m_mid_videoram[tile_index * 2 + 1] & 0x300) >> 8);
31
32 tileinfo.set(1, tileno, colour, flag);
33
34 tileinfo.category = (m_mid_videoram[tile_index * 2 + 1] & 0x20) >> 5;
35 }
36
mid_videoram_w(offs_t offset,u16 data,u16 mem_mask)37 void aquarium_state::mid_videoram_w(offs_t offset, u16 data, u16 mem_mask)
38 {
39 COMBINE_DATA(&m_mid_videoram[offset]);
40 m_mid_tilemap->mark_tile_dirty(offset / 2);
41 }
42
43 /* BAK Layer */
TILE_GET_INFO_MEMBER(aquarium_state::get_bak_tile_info)44 TILE_GET_INFO_MEMBER(aquarium_state::get_bak_tile_info)
45 {
46 const u32 tileno = (m_bak_videoram[tile_index * 2] & 0x0fff);
47 const u32 colour = (m_bak_videoram[tile_index * 2 + 1] & 0x001f);
48 const int flag = TILE_FLIPYX((m_bak_videoram[tile_index * 2 + 1] & 0x300) >> 8);
49
50 tileinfo.set(2, tileno, colour, flag);
51
52 tileinfo.category = (m_bak_videoram[tile_index * 2 + 1] & 0x20) >> 5;
53 }
54
bak_videoram_w(offs_t offset,u16 data,u16 mem_mask)55 void aquarium_state::bak_videoram_w(offs_t offset, u16 data, u16 mem_mask)
56 {
57 COMBINE_DATA(&m_bak_videoram[offset]);
58 m_bak_tilemap->mark_tile_dirty(offset / 2);
59 }
60
video_start()61 void aquarium_state::video_start()
62 {
63 m_txt_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(aquarium_state::get_txt_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
64 m_mid_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(aquarium_state::get_mid_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
65 m_bak_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(aquarium_state::get_bak_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
66
67 m_txt_tilemap->set_transparent_pen(0);
68 m_mid_tilemap->set_transparent_pen(0);
69 m_bak_tilemap->set_transparent_pen(0);
70 }
71
aquarium_colpri_cb(u32 & colour,u32 & pri_mask)72 void aquarium_state::aquarium_colpri_cb(u32 &colour, u32 &pri_mask)
73 {
74 pri_mask = 0;
75 if (colour & 8)
76 pri_mask |= (GFX_PMASK_2 | GFX_PMASK_4 | GFX_PMASK_8);
77 }
78
screen_update(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)79 uint32_t aquarium_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
80 {
81 m_mid_tilemap->set_scrollx(0, m_scroll[0]);
82 m_mid_tilemap->set_scrolly(0, m_scroll[1]);
83 m_bak_tilemap->set_scrollx(0, m_scroll[2]);
84 m_bak_tilemap->set_scrolly(0, m_scroll[3]);
85 m_txt_tilemap->set_scrollx(0, m_scroll[4]);
86 m_txt_tilemap->set_scrolly(0, m_scroll[5]);
87
88 screen.priority().fill(0, cliprect);
89 bitmap.fill(0, cliprect); // WDUD logo suggests this
90
91 m_bak_tilemap->draw(screen, bitmap, cliprect, 0, 1);
92 m_mid_tilemap->draw(screen, bitmap, cliprect, 0, 2);
93 m_txt_tilemap->draw(screen, bitmap, cliprect, 1, 4);
94
95 m_bak_tilemap->draw(screen, bitmap, cliprect, 1, 8);
96 m_sprgen->aquarium_draw_sprites(screen, bitmap, cliprect, 16);
97 m_mid_tilemap->draw(screen, bitmap, cliprect, 1, 0);
98 m_txt_tilemap->draw(screen, bitmap, cliprect, 0, 0);
99
100 return 0;
101 }
102