1 // license:BSD-3-Clause
2 // copyright-holders:Manuel Abadia
3 /***************************************************************************
4
5 ajax.cpp
6
7 Functions to emulate the video hardware of the machine.
8
9 ***************************************************************************/
10
11 #include "emu.h"
12 #include "includes/ajax.h"
13
14
15 /***************************************************************************
16
17 Callbacks for the K052109
18
19 ***************************************************************************/
20
K052109_CB_MEMBER(ajax_state::tile_callback)21 K052109_CB_MEMBER(ajax_state::tile_callback)
22 {
23 static const int layer_colorbase[] = { 1024 / 16, 0 / 16, 512 / 16 };
24
25 *code |= ((*color & 0x0f) << 8) | (bank << 12);
26 *color = layer_colorbase[layer] + ((*color & 0xf0) >> 4);
27 }
28
29
30 /***************************************************************************
31
32 Callbacks for the K051960
33
34 ***************************************************************************/
35
K051960_CB_MEMBER(ajax_state::sprite_callback)36 K051960_CB_MEMBER(ajax_state::sprite_callback)
37 {
38 enum { sprite_colorbase = 256 / 16 };
39
40 /* priority bits:
41 4 over zoom (0 = have priority)
42 5 over B (0 = have priority)
43 6 over A (1 = have priority)
44 never over F
45 */
46 *priority = 0;
47 if ( *color & 0x10) *priority |= GFX_PMASK_4; /* Z = 4 */
48 if (~*color & 0x40) *priority |= GFX_PMASK_2; /* A = 2 */
49 if ( *color & 0x20) *priority |= GFX_PMASK_1; /* B = 1 */
50 *color = sprite_colorbase + (*color & 0x0f);
51 }
52
53
54 /***************************************************************************
55
56 Callbacks for the K051316
57
58 ***************************************************************************/
59
K051316_CB_MEMBER(ajax_state::zoom_callback)60 K051316_CB_MEMBER(ajax_state::zoom_callback)
61 {
62 enum { zoom_colorbase = 768 / 128 };
63
64 *code |= ((*color & 0x07) << 8);
65 *color = zoom_colorbase + ((*color & 0x08) >> 3);
66 }
67
68
69 /***************************************************************************
70
71 Display Refresh
72
73 ***************************************************************************/
74
screen_update(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)75 uint32_t ajax_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
76 {
77 m_k052109->tilemap_update();
78
79 screen.priority().fill(0, cliprect);
80
81 bitmap.fill(m_palette->black_pen(), cliprect);
82 m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 1);
83 if (m_priority)
84 {
85 /* basic layer order is B, zoom, A, F */
86 m_k051316->zoom_draw(screen, bitmap, cliprect, 0, 4);
87 m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, 0, 2);
88 }
89 else
90 {
91 /* basic layer order is B, A, zoom, F */
92 m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, 0, 2);
93 m_k051316->zoom_draw(screen, bitmap, cliprect, 0, 4);
94 }
95 m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), -1, -1);
96 m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, 0, 0);
97 return 0;
98 }
99