Previous 15994 Revisions Next

r4206 Thursday 29th January, 2009 at 09:05:35 UTC by Robbbert
[VC4000] Committing WIP 1. Stabilised display again. 2. Fixed joysticks. 3. Simplified memory banks.
[src/mess/drivers]vc4000.c
[src/mess/video]vc4000.c

src/mess/video/vc4000.c
r4205r4206
105105READ8_HANDLER(vc4000_video_r)
106106{
107107   UINT8 data=0;
108   static UINT8 joy1_x=102,joy1_y=102,joy2_x=102,joy2_y=102;
108109   switch (offset) {
109110
110111   case 0xca:      // Background-sprite collision (bit 7-4) and sprite finished (bit 3-0)
r4205r4206
151152#else
152153
153154   case 0xcc:
154      data = 0x66;
155      // between 20 and 225
155      // between 20 and 225 - autocentre is commented out as it is impossible to play a game with the keyboard
156156      if (!cpu_get_reg(space->machine->cpu[0], S2650_FO))
157157      {
158         if (input_port_read(space->machine, "JOYS") & 0x1) data=20;
159         if (input_port_read(space->machine, "JOYS") & 0x2) data=225;
158         data = input_port_read(space->machine, "JOYS") & 3;
159         switch (data)
160         {
161            case 1:
162               joy1_x-=5;
163               if (joy1_x < 20) joy1_x=20;
164               break;
165            case 2:
166               joy1_x+=5;
167               if (joy1_x > 225) joy1_x=225;
168               break;
169   //         default:         /* autocentre */
170   //            joy1_x=102;
171         }
172         data=joy1_x;
160173      }
161174      else
162175      {
163         if (input_port_read(space->machine, "JOYS") & 0x4) data=225;
164         if (input_port_read(space->machine, "JOYS") & 0x8) data=20;
176         data = input_port_read(space->machine, "JOYS") & 12;
177         switch (data)
178         {
179            case 8:
180               joy1_y-=5;
181               if (joy1_y < 20) joy1_y=20;
182               break;
183            case 4:
184               joy1_y+=5;
185               if (joy1_y > 225) joy1_y=225;
186               break;
187   //         default:
188   //            joy1_y=102;
189         }
190         data=joy1_y;
165191      }
166192      break;
167193
168194   case 0xcd:
169      data = 0x66;
170195      if (!cpu_get_reg(space->machine->cpu[0], S2650_FO))
171196      {
172         if (input_port_read(space->machine, "JOYS") & 0x10) data=20;
173         if (input_port_read(space->machine, "JOYS") & 0x20) data=225;
197         data = input_port_read(space->machine, "JOYS") & 0x30;
198         switch (data)
199         {
200            case 0x10:
201               joy2_x-=5;
202               if (joy2_x < 20) joy2_x=20;
203               break;
204            case 0x20:
205               joy2_x+=5;
206               if (joy2_x > 225) joy2_x=225;
207               break;
208   //         default:
209   //            joy2_x=102;
210         }
211         data=joy2_x;
174212      }
175213      else
176214      {
177         if (input_port_read(space->machine, "JOYS") & 0x40) data=225;
178         if (input_port_read(space->machine, "JOYS") & 0x80) data=20;
215         data = input_port_read(space->machine, "JOYS") & 0xc0;
216         switch (data)
217         {
218            case 0x80:
219               joy2_y-=5;
220               if (joy2_y < 20) joy2_y=20;
221               break;
222            case 0x40:
223               joy2_y+=5;
224               if (joy2_y > 225) joy2_y=225;
225               break;
226   //         default:
227   //            joy2_y=102;
228         }
229         data=joy2_y;
179230      }
180231      break;
181232#endif
r4205r4206
307358
308359static void vc4000_sprite_update(bitmap_t *bitmap, UINT8 *collision, SPRITE *This)
309360{
310
311361   int i,j,m;
312362
313363   if (vc4000_video.line==0)
314364   {
315     This->y=This->data->y1;
316     This->state=0;
317     This->delay=0;
318     This->finished=FALSE;
365      This->y=This->data->y1;
366      This->state=0;
367      This->delay=0;
368      This->finished=FALSE;
319369   }
370
320371   This->finished_now=FALSE;
321372
322373   if (vc4000_video.line>269) return;
323374
324   switch (This->state) {
375   switch (This->state)
376   {
325377   case 0:
326378      if (vc4000_video.line != This->y + 2) break;
327379      This->state++;
380
328381   case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:case 9:case 10:
329382
330      if (vc4000_video.line<bitmap->height && This->data->x1<bitmap->width)
383      vc4000_collision_plot(collision+This->data->x1, This->data->bitmap[This->state-1],This->mask,This->size);
384
385      for (j=0,m=0x80; j<8; j++, m>>=1)
331386      {
332         vc4000_collision_plot(collision+This->data->x1, This->data->bitmap[This->state-1],
333               This->mask,This->size);
334         for (j=0,m=0x80; j<8; j++, m>>=1)
387         if (This->data->bitmap[This->state-1]&m)
335388         {
336            if (This->data->bitmap[This->state-1]&m)
337            {
338               for (i=0; i<This->size; i++)
339               {
340                   *BITMAP_ADDR16(bitmap, vc4000_video.line, This->data->x1 + i + j*This->size) =
341                     This->scolor;
342               }
343            }
389            for (i=0; i<This->size; i++)
390               *BITMAP_ADDR16(bitmap, vc4000_video.line, This->data->x1 + i + j*This->size) = This->scolor;
344391         }
345392      }
393
346394      This->delay++;
395
347396      if (This->delay>=This->size)
348397      {
349          This->delay=0;
350          This->state++;
398         This->delay=0;
399         This->state++;
351400      }
401
352402      if (This->state>10)
353403      {
354         This->finished=TRUE;
355         This->finished_now=TRUE;
404         This->finished=TRUE;
405         This->finished_now=TRUE;
356406      }
407
357408      break;
409
358410   case 11:
359
360411      This->y=This->data->y2;
361412
362413      if (This->y==255)
363      {
364          This->y=0;
365      }
414         This->y=0;
366415      else
367      {
368      This->y++;
369      }
416         This->y++;
370417
371418      if (This->y>252) break;
372419
r4205r4206
382429      This->state++;
383430
384431   case 13: case 14: case 15: case 16: case 17: case 18: case 19:case 20:case 21:case 22:
385//      if (vc4000_video.line<bitmap->height && This->data->x2<bitmap->width)
386      if (vc4000_video.line < 269)
432
433      vc4000_collision_plot(collision+This->data->x2,This->data->bitmap[This->state-13],This->mask,This->size);
434      for (j=0,m=0x80; j<8; j++, m>>=1)
387435      {
388         vc4000_collision_plot(collision+This->data->x2,This->data->bitmap[This->state-13],
389               This->mask,This->size);
390         for (j=0,m=0x80; j<8; j++, m>>=1)
436         if (This->data->bitmap[This->state-13]&m)
391437         {
392            if (This->data->bitmap[This->state-13]&m)
393            {
394               for (i=0; i<This->size; i++)
395               {
396                   *BITMAP_ADDR16(bitmap, vc4000_video.line, This->data->x2 + i + j*This->size) =
397                     This->scolor;
398               }
399            }
438            for (i=0; i<This->size; i++)
439               *BITMAP_ADDR16(bitmap, vc4000_video.line, This->data->x2 + i + j*This->size) = This->scolor;
400440         }
441      }
401442      This->delay++;
402443      if (This->delay<This->size) break;
403444      This->delay=0;
r4205r4206
407448      This->finished_now=TRUE;
408449      This->state=11;
409450      break;
410      }
411      break;
412451   }
413452}
414453
r4205r4206
470509
471510static TIMER_CALLBACK( vc4000_clear )
472511{
473   cpu_set_input_line(machine->cpu[0], 0, CLEAR_LINE);;
512   cpu_set_input_line(machine->cpu[0], 0, CLEAR_LINE);
474513}
475514
476515INTERRUPT_GEN( vc4000_video_line )
r4205r4206
526565      (vc4000_video.sprites[0].finished_now))
527566   {
528567      cpu_set_input_line_and_vector(device->machine->cpu[0], 0, ASSERT_LINE, 3);
529      timer_set(device->machine, ATTOTIME_IN_USEC(450), NULL, 0, vc4000_clear);
530//      cpu_set_input_line(device->machine->cpu[0], 0, CLEAR_LINE);
568      timer_set(device->machine, ATTOTIME_IN_USEC(400), NULL, 0, vc4000_clear);
531569   }
532570}
533571
src/mess/drivers/vc4000.c
r4205r4206
8989
9090static ADDRESS_MAP_START( vc4000_mem , ADDRESS_SPACE_PROGRAM, 8)
9191   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
92   AM_RANGE(0x0000, 0x07ff) AM_READWRITE( SMH_BANK1, SMH_BANK5 )
93   AM_RANGE(0x0800, 0x0fff) AM_READWRITE( SMH_BANK2, SMH_BANK6 )
94   AM_RANGE(0x1000, 0x15ff) AM_READWRITE( SMH_BANK3, SMH_BANK7 )
92   AM_RANGE(0x0000, 0x0fff) AM_ROM
9593   AM_RANGE(0x1600, 0x167f) AM_NOP
9694   AM_RANGE(0x1680, 0x16ff) AM_READWRITE( vc4000_key_r, vc4000_sound_ctl ) AM_MIRROR(0x0800)
9795   AM_RANGE(0x1700, 0x17ff) AM_READWRITE( vc4000_video_r, vc4000_video_w ) AM_MIRROR(0x0800)
98   AM_RANGE(0x1800, 0x1bff) AM_READWRITE( SMH_BANK4, SMH_BANK8 )
9996   AM_RANGE(0x1c00, 0x1e7f) AM_NOP
10097ADDRESS_MAP_END
10198
r4205r4206
194191   running_machine *machine = image->machine;
195192   int size = image_length(image);
196193
197   memory_set_bankptr(machine, 1, mess_ram);
198   memory_set_bankptr(machine, 2, mess_ram);
199   memory_set_bankptr(machine, 3, mess_ram);
200   memory_set_bankptr(machine, 4, mess_ram);
201   memory_set_bankptr(machine, 5, mess_ram);
202   memory_set_bankptr(machine, 6, mess_ram);
203   memory_set_bankptr(machine, 7, mess_ram);
204   memory_set_bankptr(machine, 8, mess_ram);
205
206194   if (size > 0x2000)
207195      size = 0x2000;
208196
209   if (size > 0)
197   if (size > 0x1800)
210198   {
211      image_fread(image, memory_region(machine, "main") + 0x0000, size);
212      memory_set_bankptr(machine, 1, memory_region(machine, "main") + 0x0000);
213      memory_set_bankptr(machine, 5, memory_region(machine, "main") + 0x0000);
214   }
199      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x1000, 0x15ff, 0, 0, SMH_BANK1);   /* extra rom */
200      memory_set_bankptr(machine, 1, memory_region(machine, "main") + 0x1000);
215201
216   if (size > 0x800)
217   {
218      memory_set_bankptr(machine, 2, memory_region(machine, "main") + 0x0800);
219      memory_set_bankptr(machine, 6, memory_region(machine, "main") + 0x0800);
202      memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x1800, 0x1bff, 0, 0, SMH_BANK3, SMH_BANK4);   /* ram */
203      memory_set_bankptr(machine, 3, memory_region(machine, "main") + 0x1800);
204      memory_set_bankptr(machine, 4, memory_region(machine, "main") + 0x1800);
220205   }
221
206   else
222207   if (size > 0x1000)
223208   {
224      memory_set_bankptr(machine, 3, memory_region(machine, "main") + 0x1000);
225      memory_set_bankptr(machine, 7, memory_region(machine, "main") + 0x1000);
209      memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x1000, 0x15ff, 0, 0x800, SMH_BANK1, SMH_BANK2); /* ram */
210      memory_set_bankptr(machine, 1, memory_region(machine, "main") + 0x1000);
211      memory_set_bankptr(machine, 2, memory_region(machine, "main") + 0x1000);
226212   }
227
228   if (size > 0x1800)
213     
214   if (size > 0)
229215   {
230      memory_set_bankptr(machine, 4, memory_region(machine, "main") + 0x1800);
231      memory_set_bankptr(machine, 8, memory_region(machine, "main") + 0x1800);
216      image_fread(image, memory_region(machine, "main") + 0x0000, size);
232217   }
233     
218
234219   return INIT_PASS;
235220}
236221
r4205r4206
247232   MDRV_SCREEN_REFRESH_RATE(50)
248233   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
249234   MDRV_SCREEN_SIZE(226, 312)
250   MDRV_SCREEN_VISIBLE_AREA(10, 182, 0, 269)
235   MDRV_SCREEN_VISIBLE_AREA(8, 182, 0, 269)
251236   MDRV_PALETTE_LENGTH(ARRAY_LENGTH(vc4000_palette))
252237   MDRV_PALETTE_INIT( vc4000 )
253238

Previous 15994 Revisions Next


© 1998-2018 The MESS Team