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