1 /***************************************************************************
2
3 vidhrdw.c
4
5 Functions to emulate the video hardware of the machine.
6
7 ***************************************************************************/
8
9 #include "driver.h"
10 #include "vidhrdw/generic.h"
11
12 static int gfx_bank;
13
WRITE_HANDLER(exctsccr_gfx_bank_w)14 WRITE_HANDLER( exctsccr_gfx_bank_w ) {
15 gfx_bank = data & 1;
16 }
17
18 void *exctsccr_fm_timer;
19
exctsccr_fm_callback(int param)20 static void exctsccr_fm_callback( int param ) {
21 cpu_cause_interrupt( 1, 0xff );
22 }
23
exctsccr_vh_start(void)24 int exctsccr_vh_start( void ) {
25 exctsccr_fm_timer = timer_pulse( TIME_IN_HZ( 75.0 ), 0, exctsccr_fm_callback ); /* updates fm */
26
27 return generic_vh_start();
28 }
29
exctsccr_vh_stop(void)30 void exctsccr_vh_stop( void ) {
31 if ( exctsccr_fm_timer ) {
32 timer_remove( exctsccr_fm_timer );
33 exctsccr_fm_timer = 0;
34 }
35
36 generic_vh_stop();
37 }
38
39 /***************************************************************************
40
41 Convert the color PROMs into a more useable format.
42
43 ***************************************************************************/
exctsccr_vh_convert_color_prom(unsigned char * palette,unsigned short * colortable,const unsigned char * color_prom)44 void exctsccr_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
45 {
46 int i,idx;
47 #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
48 #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
49
50 for (i = 0;i < Machine->drv->total_colors;i++)
51 {
52 int bit0,bit1,bit2;
53
54 bit0 = (color_prom[i] >> 0) & 0x01;
55 bit1 = (color_prom[i] >> 1) & 0x01;
56 bit2 = (color_prom[i] >> 2) & 0x01;
57 palette[3*i] = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
58 bit0 = (color_prom[i] >> 3) & 0x01;
59 bit1 = (color_prom[i] >> 4) & 0x01;
60 bit2 = (color_prom[i] >> 5) & 0x01;
61 palette[3*i + 1] = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
62 bit0 = 0;
63 bit1 = (color_prom[i] >> 6) & 0x01;
64 bit2 = (color_prom[i] >> 7) & 0x01;
65 palette[3*i + 2] = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
66 }
67
68 color_prom += Machine->drv->total_colors;
69
70 /* characters */
71 idx = 0;
72 for (i = 0;i < 32;i++)
73 {
74 COLOR(0,idx++) = color_prom[256+0+(i*4)];
75 COLOR(0,idx++) = color_prom[256+1+(i*4)];
76 COLOR(0,idx++) = color_prom[256+2+(i*4)];
77 COLOR(0,idx++) = color_prom[256+3+(i*4)];
78 COLOR(0,idx++) = color_prom[256+128+0+(i*4)];
79 COLOR(0,idx++) = color_prom[256+128+1+(i*4)];
80 COLOR(0,idx++) = color_prom[256+128+2+(i*4)];
81 COLOR(0,idx++) = color_prom[256+128+3+(i*4)];
82 }
83
84 /* sprites */
85
86 idx=0;
87
88 for (i = 0;i < 15*16;i++)
89 {
90 if ( (i%16) < 8 )
91 {
92 COLOR(2,idx) = color_prom[i]+16;
93 idx++;
94 }
95 }
96 for (i = 15*16;i < 16*16;i++)
97 {
98 if ( (i%16) > 7 )
99 {
100 COLOR(2,idx) = color_prom[i]+16;
101 idx++;
102 }
103 }
104 for (i = 16;i < 32;i++)
105 {
106 COLOR(2,idx++) = color_prom[256+0+(i*4)]+16;
107 COLOR(2,idx++) = color_prom[256+1+(i*4)]+16;
108 COLOR(2,idx++) = color_prom[256+2+(i*4)]+16;
109 COLOR(2,idx++) = color_prom[256+3+(i*4)]+16;
110 COLOR(2,idx++) = color_prom[256+128+0+(i*4)]+16;
111 COLOR(2,idx++) = color_prom[256+128+1+(i*4)]+16;
112 COLOR(2,idx++) = color_prom[256+128+2+(i*4)]+16;
113 COLOR(2,idx++) = color_prom[256+128+3+(i*4)]+16;
114 }
115
116 /* Patch for goalkeeper */
117 COLOR(2,29*8+7) = 16;
118
119 }
120
exctsccr_drawsprites(struct osd_bitmap * bitmap)121 static void exctsccr_drawsprites( struct osd_bitmap *bitmap ) {
122 int offs;
123 unsigned char *OBJ1, *OBJ2;
124
125 OBJ1 = videoram;
126 OBJ2 = &(spriteram[0x20]);
127
128 for ( offs = 0x0e; offs >= 0; offs -= 2 ) {
129 int sx,sy,code,bank,flipx,flipy,color;
130
131 sx = 256 - OBJ2[offs+1];
132 sy = OBJ2[offs] - 16;
133
134 code = ( OBJ1[offs] >> 2 ) & 0x3f;
135 flipx = ( OBJ1[offs] ) & 0x01;
136 flipy = ( OBJ1[offs] ) & 0x02;
137 color = ( OBJ1[offs+1] ) & 0x1f;
138 bank = 2;
139 bank += ( ( OBJ1[offs+1] >> 4 ) & 1 );
140
141 drawgfx(bitmap,Machine->gfx[bank],
142 code,
143 color,
144 flipx, flipy,
145 sx,sy,
146 &Machine->visible_area,
147 TRANSPARENCY_PEN,0);
148 }
149
150 OBJ1 = &(memory_region(REGION_CPU1)[0x8800]);
151 OBJ2 = spriteram;
152
153 for ( offs = 0x0e; offs >= 0; offs -= 2 ) {
154 int sx,sy,code,bank,flipx,flipy,color;
155
156 sx = 256 - OBJ2[offs+1];
157 sy = OBJ2[offs] - 16;
158
159 code = ( OBJ1[offs] >> 2 ) & 0x3f;
160 flipx = ( OBJ1[offs] ) & 0x01;
161 flipy = ( OBJ1[offs] ) & 0x02;
162 color = ( OBJ1[offs+1] ) & 0x1f;
163 bank = 3;
164
165 if ( color == 0 )
166 continue;
167
168 if ( color < 0x10 )
169 bank++;
170
171 if ( color > 0x10 && color < 0x17 )
172 {
173 drawgfx(bitmap,Machine->gfx[4],
174 code,
175 0x0e,
176 flipx, flipy,
177 sx,sy,
178 &Machine->visible_area,
179 TRANSPARENCY_PEN,0);
180
181 color += 6;
182 }
183 if ( color==0x1d && gfx_bank==1 )
184 {
185 drawgfx(bitmap,Machine->gfx[3],
186 code,
187 color,
188 flipx, flipy,
189 sx,sy,
190 &Machine->visible_area,
191 TRANSPARENCY_PEN,0);
192 drawgfx(bitmap,Machine->gfx[4],
193 code,
194 color,
195 flipx, flipy,
196 sx,sy,
197 &Machine->visible_area,
198 TRANSPARENCY_COLOR, 16);
199
200 } else
201 {
202 drawgfx(bitmap,Machine->gfx[bank],
203 code,
204 color,
205 flipx, flipy,
206 sx,sy,
207 &Machine->visible_area,
208 TRANSPARENCY_PEN,0);
209 }
210 }
211 }
212
213 /***************************************************************************
214
215 Draw the game screen in the given osd_bitmap.
216 Do NOT call osd_update_display() from this function, it will be called by
217 the main emulation engine.
218
219 ***************************************************************************/
exctsccr_vh_screenrefresh(struct osd_bitmap * bitmap,int full_refresh)220 void exctsccr_vh_screenrefresh( struct osd_bitmap *bitmap, int full_refresh ) {
221 int offs;
222
223 /* background chars */
224 for (offs = 0;offs < ( videoram_size - 0x10 );offs++) {
225
226 if ( dirtybuffer[offs] ) {
227 int sx,sy,code;
228
229 dirtybuffer[offs] = 0;
230
231 sx = 8 * (offs % 32);
232 sy = 8 * (offs / 32);
233
234 code = videoram[offs];
235
236 drawgfx(tmpbitmap,Machine->gfx[gfx_bank],
237 code,
238 ( colorram[offs] ) & 0x1f,
239 0, 0,
240 sx,sy,
241 &Machine->visible_area,
242 TRANSPARENCY_NONE,0);
243 }
244 }
245
246 /* copy the character mapped graphics */
247 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
248
249 /* draw sprites */
250 exctsccr_drawsprites( bitmap );
251
252 }
253