1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************
Sega X-board hardware
***************************************************************************/
#include "emu.h"
#include "includes/segaxbd.h"
//**************************************************************************
// VIDEO STARTUP
//**************************************************************************
void segaxbd_state::video_start()
{
if(!m_segaic16vid->started())
throw device_missing_dependencies();
if(!m_segaic16road->started())
throw device_missing_dependencies();
// initialize the tile/text layers
m_segaic16vid->tilemap_init( 0, segaic16_video_device::TILEMAP_16B, 0x1c00, 0, 2);
// initialize the road
m_segaic16road->segaic16_road_init(machine(), 0, segaic16_road_device::ROAD_XBOARD, 0x1700, 0x1720, 0x1780, -166);
}
//**************************************************************************
// VIDEO UPDATE
//**************************************************************************
uint32_t segaxbd_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
// if no drawing is happening, fill with black and get out
if (!m_segaic16vid->m_display_enable)
{
bitmap.fill(m_palette->black_pen(), cliprect);
return 0;
}
// start the sprites drawing
m_sprites->draw_async(cliprect);
// reset priorities
screen.priority().fill(0, cliprect);
// draw the low priority road layer
m_segaic16road->segaic16_road_draw(0, bitmap, cliprect, segaic16_road_device::ROAD_BACKGROUND);
if (m_road_priority == 0)
m_segaic16road->segaic16_road_draw(0, bitmap, cliprect, segaic16_road_device::ROAD_FOREGROUND);
// draw background
m_segaic16vid->tilemap_draw( screen, bitmap, cliprect, 0, segaic16_video_device::TILEMAP_BACKGROUND, 0, 0x01);
m_segaic16vid->tilemap_draw( screen, bitmap, cliprect, 0, segaic16_video_device::TILEMAP_BACKGROUND, 1, 0x02);
// draw foreground
m_segaic16vid->tilemap_draw( screen, bitmap, cliprect, 0, segaic16_video_device::TILEMAP_FOREGROUND, 0, 0x02);
m_segaic16vid->tilemap_draw( screen, bitmap, cliprect, 0, segaic16_video_device::TILEMAP_FOREGROUND, 1, 0x04);
// draw the high priority road
if (m_road_priority == 1)
m_segaic16road->segaic16_road_draw(0, bitmap, cliprect, segaic16_road_device::ROAD_FOREGROUND);
// text layer
m_segaic16vid->tilemap_draw( screen, bitmap, cliprect, 0, segaic16_video_device::TILEMAP_TEXT, 0, 0x04);
m_segaic16vid->tilemap_draw( screen, bitmap, cliprect, 0, segaic16_video_device::TILEMAP_TEXT, 1, 0x08);
// mix in sprites
bitmap_ind16 &sprites = m_sprites->bitmap();
for (const sparse_dirty_rect *rect = m_sprites->first_dirty_rect(cliprect); rect != nullptr; rect = rect->next())
for (int y = rect->min_y; y <= rect->max_y; y++)
{
uint16_t *dest = &bitmap.pix(y);
uint16_t *src = &sprites.pix(y);
uint8_t *pri = &screen.priority().pix(y);
for (int x = rect->min_x; x <= rect->max_x; x++)
{
// only process written pixels
uint16_t pix = src[x];
if (pix != 0xffff)
{
// compare sprite priority against tilemap priority
int priority = (pix >> 12) & 3;
if ((1 << priority) > pri[x])
{
// if the shadow flag is set, this triggers shadow/hilight for pen 0xa
if ((pix & 0x400f) == 0x400a)
dest[x] += (m_paletteram[dest[x]] & 0x8000) ? m_palette_entries*2 : m_palette_entries;
// otherwise, just add in sprite palette base
else
dest[x] = pix & 0xfff;
}
}
}
}
return 0;
}
|