1 /***************************************************************************
2
3 Atari Klax hardware
4
5 ****************************************************************************/
6
7 #include "driver.h"
8 #include "machine/atarigen.h"
9 #include "klax.h"
10
11
12
13 /*************************************
14 *
15 * Tilemap callbacks
16 *
17 *************************************/
18
get_playfield_tile_info(int tile_index)19 static void get_playfield_tile_info(int tile_index)
20 {
21 UINT16 data1 = atarigen_playfield[tile_index];
22 UINT16 data2 = atarigen_playfield_upper[tile_index] >> 8;
23 int code = data1 & 0x1fff;
24 int color = data2 & 0x0f;
25 SET_TILE_INFO(0, code, color, (data1 >> 15) & 1);
26 }
27
28
29
30 /*************************************
31 *
32 * Video system start
33 *
34 *************************************/
35
VIDEO_START(klax)36 VIDEO_START( klax )
37 {
38 static const struct atarimo_desc modesc =
39 {
40 1, /* index to which gfx system */
41 1, /* number of motion object banks */
42 1, /* are the entries linked? */
43 0, /* are the entries split? */
44 0, /* render in reverse order? */
45 0, /* render in swapped X/Y order? */
46 0, /* does the neighbor bit affect the next object? */
47 8, /* pixels per SLIP entry (0 for no-slip) */
48 0, /* pixel offset for SLIPs */
49 0, /* maximum number of links to visit/scanline (0=all) */
50
51 0x000, /* base palette entry */
52 0x100, /* maximum number of colors */
53 0, /* transparent pen index */
54
55 {{ 0x00ff,0,0,0 }}, /* mask for the link */
56 {{ 0 }}, /* mask for the graphics bank */
57 {{ 0,0x0fff,0,0 }}, /* mask for the code index */
58 {{ 0 }}, /* mask for the upper code index */
59 {{ 0,0,0x000f,0 }}, /* mask for the color */
60 {{ 0,0,0xff80,0 }}, /* mask for the X position */
61 {{ 0,0,0,0xff80 }}, /* mask for the Y position */
62 {{ 0,0,0,0x0070 }}, /* mask for the width, in tiles*/
63 {{ 0,0,0,0x0007 }}, /* mask for the height, in tiles */
64 {{ 0,0,0,0x0008 }}, /* mask for the horizontal flip */
65 {{ 0 }}, /* mask for the vertical flip */
66 {{ 0 }}, /* mask for the priority */
67 {{ 0 }}, /* mask for the neighbor */
68 {{ 0 }}, /* mask for absolute coordinates */
69
70 {{ 0 }}, /* mask for the special value */
71 0, /* resulting value to indicate "special" */
72 0 /* callback routine for special entries */
73 };
74
75 /* initialize the playfield */
76 atarigen_playfield_tilemap = tilemap_create(get_playfield_tile_info, tilemap_scan_cols, TILEMAP_OPAQUE, 8,8, 64,32);
77 if (!atarigen_playfield_tilemap)
78 return 1;
79
80 /* initialize the motion objects */
81 if (!atarimo_init(0, &modesc))
82 return 1;
83 return 0;
84 }
85
86
87
88 /*************************************
89 *
90 * Latch write handler
91 *
92 *************************************/
93
WRITE16_HANDLER(klax_latch_w)94 WRITE16_HANDLER( klax_latch_w )
95 {
96 }
97
98
99
100 /*************************************
101 *
102 * Main refresh
103 *
104 *************************************/
105
VIDEO_UPDATE(klax)106 VIDEO_UPDATE( klax )
107 {
108 struct atarimo_rect_list rectlist;
109 struct mame_bitmap *mobitmap;
110 int x, y, r;
111
112 /* draw the playfield */
113 tilemap_draw(bitmap, cliprect, atarigen_playfield_tilemap, 0, 0);
114
115 /* draw and merge the MO */
116 mobitmap = atarimo_render(0, cliprect, &rectlist);
117 for (r = 0; r < rectlist.numrects; r++, rectlist.rect++)
118 for (y = rectlist.rect->min_y; y <= rectlist.rect->max_y; y++)
119 {
120 UINT16 *mo = (UINT16 *)mobitmap->base + mobitmap->rowpixels * y;
121 UINT16 *pf = (UINT16 *)bitmap->base + bitmap->rowpixels * y;
122 for (x = rectlist.rect->min_x; x <= rectlist.rect->max_x; x++)
123 if (mo[x])
124 {
125 /* verified from schematics:
126
127 PFPRI if (PFS7-4 == 0 || LBPIX3-0 == 0)
128 */
129 if ((pf[x] & 0xf0) != 0xf0)
130 pf[x] = mo[x];
131
132 /* erase behind ourselves */
133 mo[x] = 0;
134 }
135 }
136 }
137