Previous 15994 Revisions Next

r6847 Friday 1st January, 2010 at 21:28:02 UTC by Wilbert Pol
[SCV] Added palette. Added Vblank IRQ triggering. Added simple sprite drawing.
[src/mess/drivers]scv.c

src/mess/drivers/scv.c
r6846r6847
2020static UINT8 *scv_vram;
2121static UINT8 scv_porta;
2222static UINT8 scv_portc;
23static emu_timer *scv_vb_timer;
2324
2425
2526static ADDRESS_MAP_START( scv_mem, ADDRESS_SPACE_PROGRAM, 8 )
2627   AM_RANGE( 0x0000, 0x0fff ) AM_ROM      /* BIOS */
2728
28   AM_RANGE( 0x2000, 0x33ff ) AM_RAM AM_BASE( &scv_vram )
29   AM_RANGE( 0x2000, 0x3403 ) AM_RAM AM_BASE( &scv_vram )   /* VRAM + 4 registers */
2930
3031   AM_RANGE( 0x8000, 0xff7f ) AM_ROM AM_REGION("cart", 0)
3132   AM_RANGE( 0xff80, 0xffff ) AM_RAM      /* upd7801 internal RAM */
r6846r6847
136137}
137138
138139
140static PALETTE_INIT( scv )
141{
142   /* Palette borrowed from eSCV. No idea if this is correct */
143   palette_set_color_rgb( machine,  0,   0,  90, 156 );
144   palette_set_color_rgb( machine,  1,   0,   0,   0 );
145   palette_set_color_rgb( machine,  2,  58, 148, 255 );
146   palette_set_color_rgb( machine,  3,   0,   0, 255 );
147   palette_set_color_rgb( machine,  4,  16, 214,   0 );
148   palette_set_color_rgb( machine,  5,  66, 255,  16 );
149   palette_set_color_rgb( machine,  6, 123, 230, 197 );
150   palette_set_color_rgb( machine,  7,   0, 173,   0 );
151   palette_set_color_rgb( machine,  8, 255,  41, 148 );
152   palette_set_color_rgb( machine,  9, 255,  49,  16 );
153   palette_set_color_rgb( machine, 10, 255,  58, 255 );
154   palette_set_color_rgb( machine, 11, 239, 156, 255 );
155   palette_set_color_rgb( machine, 12, 255, 206,  33 );
156   palette_set_color_rgb( machine, 13,  74, 123,  16 );
157   palette_set_color_rgb( machine, 14, 165, 148, 165 );
158   palette_set_color_rgb( machine, 15, 255, 255, 255 );
159}
160
161
162static TIMER_CALLBACK( scv_vb_callback )
163{
164   int vpos = video_screen_get_vpos(machine->primary_screen);
165
166   switch( vpos )
167   {
168   case 240:
169      cputag_set_input_line(machine, "maincpu", UPD7810_INTF2, CLEAR_LINE);
170      break;
171   case 0:
172      cputag_set_input_line(machine, "maincpu", UPD7810_INTF2, ASSERT_LINE);
173      break;
174   }
175
176   timer_adjust_oneshot( scv_vb_timer, video_screen_get_time_until_pos( machine->primary_screen, ( vpos + 1 ) % 262, 0 ), 0 );
177}
178
179
180static void plot_sprite_part( bitmap_t *bitmap, UINT8 x, UINT8 y, UINT8 pat, UINT8 col )
181{
182   if ( pat & 0x08 )
183      *BITMAP_ADDR16( bitmap, y, x ) = col;
184   if ( pat & 0x04 && x < 255 )
185      *BITMAP_ADDR16( bitmap, y, x + 1 ) = col;
186   if ( pat & 0x02 && x < 254 )
187      *BITMAP_ADDR16( bitmap, y, x + 2 ) = col;
188   if ( pat & 0x01 && x < 253 )
189      *BITMAP_ADDR16( bitmap, y, x + 3 ) = col;
190}
191
192
193static VIDEO_UPDATE( scv )
194{
195   /* Draw background */
196
197   /* Draw sprites */
198   if ( scv_vram[0x1400] & 0x10 )
199   {
200      int i, j;
201
202/*
20300 37 CE 00 01 FF FF 08 11 FF FF 88 11 FF FF 88
20400 F7 FE 00 00 30 C8 00 00 11 00 00 00 00 A4 00
205
20600000000 00110111 11001110 00000000 00000001 11111111 11111111 00001000 00010001 11111111 11111111 10001000 000010001 11111111 11111111 10001000
20700000000 11110111 11111110 00000000 00000000 00110000 11001000 00000000 00000000 00010001 00000000 00000000 000000000 00000000 10100100 00000000
208
2090000 0011 1100 0000 +0 Hi +1 Hi +2 Hi +3 Hi
2100000 0111 1110 0000 +0 Lo +1 Lo +2 Lo +3 Lo
2110000 1111 1111 1000 +4
2120001 1111 1111 1000 +4
2130001 1111 1111 1000 +8
2140001 1111 1111 1000 +8
2150001 1111 1111 1000 +12
2160001 1111 1111 1000 +12
2170000 1111 1111 0000 +16
2180000 0111 1110 0000 +16
2190000 0011 1100 0000 +20
2200000 0000 1000 0000 +20
2210000 0001 0000 0000 +24
2220000 0001 0000 0000 +24
2230000 0000 1010 0000 +28
2240000 0000 0100 0000 +28
225*/
226      for ( i = 0; i < 128; i++ )
227      {
228         UINT8 spr_y = scv_vram[ 0x1200 + i * 4 ];
229         UINT8 col = scv_vram[ 0x1201 + i * 4 ] & 0x0f;
230         UINT8 spr_x = scv_vram[ 0x1202 + i * 4 ];
231         UINT8 tile_idx = scv_vram[ 0x1203 + i * 4 ];
232
233         for ( j = 0; j < 8; j++ )
234         {
235            UINT8 pat0 = scv_vram[ tile_idx * 32 + j * 4 + 0 ];
236            UINT8 pat1 = scv_vram[ tile_idx * 32 + j * 4 + 1 ];
237            UINT8 pat2 = scv_vram[ tile_idx * 32 + j * 4 + 2 ];
238            UINT8 pat3 = scv_vram[ tile_idx * 32 + j * 4 + 3 ];
239
240            plot_sprite_part( bitmap, spr_x     , spr_y, pat0 >> 4, col );
241            plot_sprite_part( bitmap, spr_x +  4, spr_y, pat1 >> 4, col );
242            plot_sprite_part( bitmap, spr_x +  8, spr_y, pat2 >> 4, col );
243            plot_sprite_part( bitmap, spr_x + 12, spr_y, pat3 >> 4, col );
244
245            plot_sprite_part( bitmap, spr_x     , spr_y + 1, pat0 & 0x0f, col );
246            plot_sprite_part( bitmap, spr_x +  4, spr_y + 1, pat1 & 0x0f, col );
247            plot_sprite_part( bitmap, spr_x +  8, spr_y + 1, pat2 & 0x0f, col );
248            plot_sprite_part( bitmap, spr_x + 12, spr_y + 1, pat3 & 0x0f, col );
249
250            spr_y += 2;
251         }
252      }
253   }
254
255   return 0;
256}
257
258
259static MACHINE_START( scv )
260{
261   scv_vb_timer = timer_alloc( machine, scv_vb_callback, NULL );
262}
263
264
265static MACHINE_RESET( scv )
266{
267   timer_adjust_oneshot( scv_vb_timer, video_screen_get_time_until_pos( machine->primary_screen, 0, 0 ), 0 );
268}
269
270
139271static const UPD7810_CONFIG scv_cpu_config = { TYPE_7801, NULL };
140272
141273
r6846r6847
145277   MDRV_CPU_IO_MAP( scv_io )
146278   MDRV_CPU_CONFIG( scv_cpu_config )
147279
280   MDRV_MACHINE_START( scv )
281   MDRV_MACHINE_RESET( scv )
282
148283   MDRV_SCREEN_ADD( "screen", RASTER )
149284   MDRV_SCREEN_FORMAT( BITMAP_FORMAT_INDEXED16 )
150285   MDRV_SCREEN_RAW_PARAMS( XTAL_14_31818MHz/2, 456, 0, 256, 262, 0, 200 )   /* TODO: Verify */
151286
152   MDRV_PALETTE_LENGTH(16)
287   MDRV_PALETTE_LENGTH( 16 )
288   MDRV_PALETTE_INIT( scv )
153289
154290   /* Video chip is EPOCH TV-1 */
291   MDRV_VIDEO_UPDATE( scv )
155292
156293   /* Sound is generated by UPD1771C clocked at XTAL_6MHz */
157294
r6846r6847
168305   MDRV_CPU_IO_MAP( scv_io )
169306   MDRV_CPU_CONFIG( scv_cpu_config )
170307
308   MDRV_MACHINE_START( scv )
309   MDRV_MACHINE_RESET( scv )
310
171311   MDRV_SCREEN_ADD( "screen", RASTER )
172312   MDRV_SCREEN_FORMAT( BITMAP_FORMAT_INDEXED16 )
173313   MDRV_SCREEN_RAW_PARAMS( XTAL_13_4MHz/2, 456, 0, 256, 342, 0, 200 )      /* TODO: Verify */
174314
175   MDRV_PALETTE_LENGTH(16)
315   MDRV_PALETTE_LENGTH( 16 )
316   MDRV_PALETTE_INIT( scv )
176317
177318   /* Video chip is EPOCH TV-1A */
178319

Previous 15994 Revisions Next


© 1998-2018 The MESS Team