1 /* One Shot One Kill Video Hardware */
2
3 #include "driver.h"
4
5 extern data16_t *oneshot_sprites;
6 extern data16_t *oneshot_bg_videoram;
7 extern data16_t *oneshot_mid_videoram;
8 extern data16_t *oneshot_fg_videoram;
9 extern data16_t *oneshot_scroll;
10
11 extern int gun_x_p1,gun_y_p1,gun_x_p2,gun_y_p2;
12 extern int gun_x_shift;
13
14
15 static struct tilemap *oneshot_bg_tilemap;
16 static struct tilemap *oneshot_mid_tilemap;
17 static struct tilemap *oneshot_fg_tilemap;
18
19 /* bg tilemap */
get_oneshot_bg_tile_info(int tile_index)20 static void get_oneshot_bg_tile_info(int tile_index)
21 {
22 int tileno;
23
24 tileno = oneshot_bg_videoram[tile_index*2+1];
25
26 SET_TILE_INFO(0,tileno,0,0)
27 }
28
WRITE16_HANDLER(oneshot_bg_videoram_w)29 WRITE16_HANDLER( oneshot_bg_videoram_w )
30 {
31 if (oneshot_bg_videoram[offset] != data)
32 {
33 COMBINE_DATA(&oneshot_bg_videoram[offset]);
34 tilemap_mark_tile_dirty(oneshot_bg_tilemap,offset/2);
35 }
36 }
37
38 /* mid tilemap */
get_oneshot_mid_tile_info(int tile_index)39 static void get_oneshot_mid_tile_info(int tile_index)
40 {
41 int tileno;
42
43 tileno = oneshot_mid_videoram[tile_index*2+1];
44
45 SET_TILE_INFO(0,tileno,2,0)
46 }
47
WRITE16_HANDLER(oneshot_mid_videoram_w)48 WRITE16_HANDLER( oneshot_mid_videoram_w )
49 {
50 if (oneshot_mid_videoram[offset] != data)
51 {
52 COMBINE_DATA(&oneshot_mid_videoram[offset]);
53 tilemap_mark_tile_dirty(oneshot_mid_tilemap,offset/2);
54 }
55 }
56
57
58 /* fg tilemap */
get_oneshot_fg_tile_info(int tile_index)59 static void get_oneshot_fg_tile_info(int tile_index)
60 {
61 int tileno;
62
63 tileno = oneshot_fg_videoram[tile_index*2+1];
64
65 SET_TILE_INFO(0,tileno,3,0)
66 }
67
WRITE16_HANDLER(oneshot_fg_videoram_w)68 WRITE16_HANDLER( oneshot_fg_videoram_w )
69 {
70 if (oneshot_fg_videoram[offset] != data)
71 {
72 COMBINE_DATA(&oneshot_fg_videoram[offset]);
73 tilemap_mark_tile_dirty(oneshot_fg_tilemap,offset/2);
74 }
75 }
76
VIDEO_START(oneshot)77 VIDEO_START( oneshot )
78 {
79 oneshot_bg_tilemap = tilemap_create(get_oneshot_bg_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT, 16, 16,32,32);
80 oneshot_mid_tilemap = tilemap_create(get_oneshot_mid_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT, 16, 16,32,32);
81 oneshot_fg_tilemap = tilemap_create(get_oneshot_fg_tile_info,tilemap_scan_rows,TILEMAP_TRANSPARENT, 16, 16,32,32);
82
83 tilemap_set_transparent_pen(oneshot_bg_tilemap,0);
84 tilemap_set_transparent_pen(oneshot_mid_tilemap,0);
85 tilemap_set_transparent_pen(oneshot_fg_tilemap,0);
86
87 return 0;
88 }
89
oneshot_drawcrosshairs(struct mame_bitmap * bitmap,const struct rectangle * cliprect)90 static void oneshot_drawcrosshairs( struct mame_bitmap *bitmap, const struct rectangle *cliprect )
91 {
92 int xpos,ypos;
93 /* get gun raw coordonates (player 1) */
94 gun_x_p1 = (readinputport(5) & 0xff) * 320 / 256;
95 gun_y_p1 = (readinputport(6) & 0xff) * 240 / 256;
96
97 /* compute the coordonates for drawing (from routine at 0x009ab0) */
98 xpos = gun_x_p1;
99 ypos = gun_y_p1;
100
101 gun_x_p1+=gun_x_shift;
102
103 gun_y_p1 -= 0x0a;
104 if (gun_y_p1 < 0)
105 gun_y_p1=0;
106
107 /* draw crosshair */
108 draw_crosshair( bitmap, xpos, ypos, cliprect );
109
110
111 /* get gun raw coordonates (player 2) */
112 gun_x_p2 = (readinputport(7) & 0xff) * 320 / 256;
113 gun_y_p2 = (readinputport(8) & 0xff) * 240 / 256;
114 /* compute the coordonates for drawing (from routine at 0x009b6e) */
115 xpos = gun_x_p2;
116 ypos = gun_y_p2;
117
118 gun_x_p2 += gun_x_shift-0x0a;
119 if (gun_x_p2 < 0)
120 gun_x_p2=0;
121
122 /* draw crosshair */
123 draw_crosshair( bitmap, xpos, ypos, cliprect );
124 }
125
oneshot_drawsprites(struct mame_bitmap * bitmap,const struct rectangle * cliprect)126 static void oneshot_drawsprites( struct mame_bitmap *bitmap, const struct rectangle *cliprect )
127 {
128 const UINT16 *source = oneshot_sprites;
129 const UINT16 *finish = source+(0x1000/2);
130 const struct GfxElement *gfx = Machine->gfx[1];
131
132 int xpos,ypos;
133
134 while( source<finish )
135 {
136 int blockx,blocky;
137 int num = source[1] & 0xffff;
138 int xsize = (source[2] & 0x000f)+1;
139 int ysize = (source[3] & 0x000f)+1;
140
141 ypos = source[3] & 0xff80;
142 xpos = source[2] & 0xff80;
143
144 ypos = ypos >> 7;
145 xpos = xpos >> 7;
146
147
148 if (source[0] == 0x0001) break;
149
150 xpos -= 8;
151 ypos -= 6;
152
153
154 for (blockx = 0; blockx<xsize;blockx++) {
155 for (blocky = 0; blocky<ysize;blocky++) {
156
157
158 drawgfx(
159 bitmap,
160 gfx,
161 num+(blocky*xsize)+blockx,
162 1,
163 0,0,
164 xpos+blockx*8,ypos+blocky*8,
165 cliprect,
166 TRANSPARENCY_PEN,0
167 );
168
169 drawgfx(
170 bitmap,
171 gfx,
172 num+(blocky*xsize)+blockx,
173 1,
174 0,0,
175 xpos+blockx*8-0x200,ypos+blocky*8,
176 cliprect,
177 TRANSPARENCY_PEN,0
178 );
179 }
180 }
181 source += 0x4;
182 }
183
184 }
185
VIDEO_UPDATE(oneshot)186 VIDEO_UPDATE( oneshot )
187 {
188 fillbitmap(bitmap, get_black_pen(), cliprect);
189
190 tilemap_set_scrollx(oneshot_mid_tilemap,0, oneshot_scroll[0]-0x1f5);
191 tilemap_set_scrolly(oneshot_mid_tilemap,0, oneshot_scroll[1]);
192
193 tilemap_draw(bitmap,cliprect,oneshot_bg_tilemap,0,0);
194 tilemap_draw(bitmap,cliprect,oneshot_mid_tilemap,0,0);
195 oneshot_drawsprites(bitmap,cliprect);
196 tilemap_draw(bitmap,cliprect,oneshot_fg_tilemap,0,0);
197 oneshot_drawcrosshairs(bitmap,cliprect);
198 }
199
VIDEO_UPDATE(maddonna)200 VIDEO_UPDATE( maddonna )
201 {
202 fillbitmap(bitmap, get_black_pen(), cliprect);
203
204 tilemap_set_scrolly(oneshot_mid_tilemap,0, oneshot_scroll[1]); /* other registers aren't used so we don't know which layers they relate to*/
205
206 tilemap_draw(bitmap,cliprect,oneshot_mid_tilemap,0,0);
207 tilemap_draw(bitmap,cliprect,oneshot_fg_tilemap,0,0);
208 tilemap_draw(bitmap,cliprect,oneshot_bg_tilemap,0,0);
209 oneshot_drawsprites(bitmap,cliprect);
210 /* oneshot_drawcrosshairs(bitmap,cliprect); // not a gun game*/
211
212 /* usrintf_showmessage ("%04x %04x %04x %04x %04x %04x %04x %04x", oneshot_scroll[0],oneshot_scroll[1],oneshot_scroll[2],oneshot_scroll[3],oneshot_scroll[4],oneshot_scroll[5],oneshot_scroll[6],oneshot_scroll[7]);*/
213 }
214