1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /***************************************************************************
4
5 mosaic.c
6
7 Functions to emulate the video hardware of the machine.
8
9 ***************************************************************************/
10
11 #include "emu.h"
12 #include "includes/mosaic.h"
13
14 /***************************************************************************
15
16 Callbacks for the TileMap code
17
18 ***************************************************************************/
19
TILE_GET_INFO_MEMBER(mosaic_state::get_fg_tile_info)20 TILE_GET_INFO_MEMBER(mosaic_state::get_fg_tile_info)
21 {
22 tile_index *= 2;
23 tileinfo.set(0,
24 m_fgvideoram[tile_index] + (m_fgvideoram[tile_index+1] << 8),
25 0,
26 0);
27 }
28
TILE_GET_INFO_MEMBER(mosaic_state::get_bg_tile_info)29 TILE_GET_INFO_MEMBER(mosaic_state::get_bg_tile_info)
30 {
31 tile_index *= 2;
32 tileinfo.set(1,
33 m_bgvideoram[tile_index] + (m_bgvideoram[tile_index+1] << 8),
34 0,
35 0);
36 }
37
38
39
40 /***************************************************************************
41
42 Start the video hardware emulation.
43
44 ***************************************************************************/
45
video_start()46 void mosaic_state::video_start()
47 {
48 m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(mosaic_state::get_fg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
49 m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(mosaic_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
50
51 m_fg_tilemap->set_transparent_pen(0xff);
52 }
53
54
55 /***************************************************************************
56
57 Memory handlers
58
59 ***************************************************************************/
60
fgvideoram_w(offs_t offset,uint8_t data)61 void mosaic_state::fgvideoram_w(offs_t offset, uint8_t data)
62 {
63 m_fgvideoram[offset] = data;
64 m_fg_tilemap->mark_tile_dirty(offset / 2);
65 }
66
bgvideoram_w(offs_t offset,uint8_t data)67 void mosaic_state::bgvideoram_w(offs_t offset, uint8_t data)
68 {
69 m_bgvideoram[offset] = data;
70 m_bg_tilemap->mark_tile_dirty(offset / 2);
71 }
72
73
74
screen_update(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)75 uint32_t mosaic_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
76 {
77 m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
78 m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
79 return 0;
80 }
81