Previous 15994 Revisions Next

r4267 Saturday 14th February, 2009 at 07:38:13 UTC by Robbbert
[VC4000] Committed WIP
[src/mess/drivers]vc4000.c
[src/mess/video]vc4000.c

src/mess/video/vc4000.c
r4266r4267
1919static UINT8 sprite_collision[0x20];
2020static UINT8 background_collision[0x20];
2121
22#define VC4000_END_LINE (269)
23
2224typedef struct {
2325   UINT8 bitmap[10],x1,x2,y1,y2, res1, res2;
2426} SPRITE_HELPER;
r4266r4267
102104   vc4000_video.bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16);
103105}
104106
107#define STICKCENTRE   (105)
108#define STICKLOW   (20)
109#define STICKHIGH   (225)
110
111INLINE UINT8 vc4000_joystick_return_to_centre(UINT8 joy)
112{
113   UINT8 data;
114
115   if (joy > (STICKCENTRE+5))
116      data=joy-5;
117   else
118   if (joy < (STICKCENTRE-5))
119      data=joy+5;
120   else
121      data=105;
122
123   return data;
124}
125
105126READ8_HANDLER(vc4000_video_r)
106127{
107128   UINT8 data=0;
108   static UINT8 joy1_x=102,joy1_y=102,joy2_x=102,joy2_y=102;
129   static UINT8 joy1_x=STICKCENTRE,joy1_y=STICKCENTRE,joy2_x=STICKCENTRE,joy2_y=STICKCENTRE;
130   if (offset > 0xcf) offset &= 0xcf;   // c0-cf is mirrored at d0-df, e0-ef, f0-ff
109131   switch (offset) {
110132
111133   case 0xca:      // Background-sprite collision (bit 7-4) and sprite finished (bit 3-0)
r4266r4267
161183            {
162184            case 0x01:
163185               joy1_x-=5;
164               if (joy1_x < 20) joy1_x=20;
186               if (joy1_x < STICKLOW) joy1_x=STICKLOW;
165187               break;
166188            case 0x02:
167189               joy1_x+=5;
168               if (joy1_x > 225) joy1_x=225;
190               if (joy1_x > STICKHIGH) joy1_x=STICKHIGH;
169191               break;
192            case 0x00:
193               joy1_x = vc4000_joystick_return_to_centre(joy1_x);
170194            }
171195            data=joy1_x;
172196         }
r4266r4267
177201            {
178202            case 0x08:
179203               joy1_y-=5;
180               if (joy1_y < 20) joy1_y=20;
204               if (joy1_y < STICKLOW) joy1_y=STICKLOW;
181205               break;
182206            case 0x04:
183207               joy1_y+=5;
184               if (joy1_y > 225) joy1_y=225;
208               if (joy1_y > STICKHIGH) joy1_y=STICKHIGH;
185209               break;
210      //      case 0x00:
211      //         joy1_y = vc4000_joystick_return_to_centre(joy1_y);
186212            }
187213            data=joy1_y;
188214         }
r4266r4267
195221            switch (data)
196222            {
197223            case 0x01:
198               joy1_x=20;
224               joy1_x=STICKLOW;
199225               break;
200226            case 0x02:
201               joy1_x=225;
227               joy1_x=STICKHIGH;
202228               break;
203229            default:         /* autocentre */
204               joy1_x=102;
230               joy1_x=STICKCENTRE;
205231            }
206232            data=joy1_x;
207233         }
r4266r4267
211237            switch (data)
212238            {
213239            case 0x08:
214               joy1_y=20;
240               joy1_y=STICKLOW;
215241               break;
216242            case 0x04:
217               joy1_y=225;
243               joy1_y=STICKHIGH;
218244               break;
219245            default:
220               joy1_y=102;
246               joy1_y=STICKCENTRE;
221247            }
222248            data=joy1_y;
223249         }
r4266r4267
234260            {
235261            case 0x10:
236262               joy2_x-=5;
237               if (joy2_x < 20) joy2_x=20;
263               if (joy2_x < STICKLOW) joy2_x=STICKLOW;
238264               break;
239265            case 0x20:
240266               joy2_x+=5;
241               if (joy2_x > 225) joy2_x=225;
267               if (joy2_x > STICKHIGH) joy2_x=STICKHIGH;
268            case 0x00:
269               joy2_x = vc4000_joystick_return_to_centre(joy2_x);
242270               break;
243271            }
244272            data=joy2_x;
r4266r4267
250278            {
251279            case 0x80:
252280               joy2_y-=5;
253               if (joy2_y < 20) joy2_y=20;
281               if (joy2_y < STICKLOW) joy2_y=STICKLOW;
254282               break;
255283            case 0x40:
256284               joy2_y+=5;
257               if (joy2_y > 225) joy2_y=225;
285               if (joy2_y > STICKHIGH) joy2_y=STICKHIGH;
258286               break;
287         //   case 0x00:
288         //      joy2_y = vc4000_joystick_return_to_centre(joy2_y);
259289            }
260290            data=joy2_y;
261291         }
r4266r4267
268298            switch (data)
269299            {
270300            case 0x10:
271               joy2_x=20;
301               joy2_x=STICKLOW;
272302               break;
273303            case 0x20:
274               joy2_x=225;
304               joy2_x=STICKHIGH;
275305               break;
276306            default:         /* autocentre */
277               joy2_x=102;
307               joy2_x=STICKCENTRE;
278308            }
279309            data=joy2_x;
280310         }
r4266r4267
284314            switch (data)
285315            {
286316            case 0x80:
287               joy2_y=20;
317               joy2_y=STICKLOW;
288318               break;
289319            case 0x40:
290               joy2_y=225;
320               joy2_y=STICKHIGH;
291321               break;
292322            default:
293               joy2_y=102;
323               joy2_y=STICKCENTRE;
294324            }
295325            data=joy2_y;
296326         }
r4266r4267
308338WRITE8_HANDLER(vc4000_video_w)
309339{
310340//   vc4000_video.reg.data[offset]=data;
341   if (offset > 0xcf) offset &= 0xcf;   // c0-cf is mirrored at d0-df, e0-ef, f0-ff
311342
312343   switch (offset) {
313344
r4266r4267
367398
368399READ8_HANDLER(vc4000_vsync_r)
369400{
370   return vc4000_video.line >= 269 ? 0x80 : 0;
401   return vc4000_video.line >= VC4000_END_LINE ? 0x80 : 0;
371402}
372403
373404static const char led[20][12+1] =
r4266r4267
439470
440471   This->finished_now=FALSE;
441472
442   if (vc4000_video.line>269) return;
473   if (vc4000_video.line>VC4000_END_LINE) return;
443474
444475   switch (This->state)
445476   {
r4266r4267
582613   }
583614}
584615
585static TIMER_CALLBACK( vc4000_clear )
586{
587   cpu_set_input_line(machine->cpu[0], 0, CLEAR_LINE);
588}
589
590616INTERRUPT_GEN( vc4000_video_line )
591617{
592618   int x,y,i;
593619   UINT8 collision[400]={0}; // better alloca or gcc feature of non constant long automatic arrays
620   static UINT8 irq_pause=0;
621   const rectangle visarea = *video_screen_get_visible_area(device->machine->primary_screen);
594622   assert(ARRAY_LENGTH(collision) >= video_screen_get_width(device->machine->primary_screen));
595623
596624   vc4000_video.line++;
597   vc4000_video.line%=312;
625   if (irq_pause) irq_pause++;
626   if (vc4000_video.line>311) vc4000_video.line=0;
598627
599628   if (vc4000_video.line==0)
600629   {
r4266r4267
604633//      logerror("begin of frame\n");
605634   }
606635
607   if (vc4000_video.line <= 270)
636   if (irq_pause>10)
608637   {
638      cpu_set_input_line(device->machine->cpu[0], 0, CLEAR_LINE);
639      irq_pause = 0;
640   }
641
642   if (vc4000_video.line <= VC4000_END_LINE)
643   {
609644      vc4000_draw_grid(device->machine, collision);
610645
611646      /* init object colours */
612      for (y=0; y<256; y++) objects[y]=8;
647      for (i=visarea.min_x; i<visarea.max_x; i++) objects[i]=8;
613648
614649      /* calculate object colours and OR overlapping object colours */
615650      vc4000_sprite_update(vc4000_video.bitmap, collision, &vc4000_video.sprites[0]);
r4266r4267
617652      vc4000_sprite_update(vc4000_video.bitmap, collision, &vc4000_video.sprites[2]);
618653      vc4000_sprite_update(vc4000_video.bitmap, collision, &vc4000_video.sprites[3]);
619654
620      /* display final object colours */
621      for (y=0; y<256; y++)
622         if (objects[y] < 8)
623               *BITMAP_ADDR16(vc4000_video.bitmap, vc4000_video.line, y) = objects[y];
624
625      for (i=0; i<256; i++)
655      for (i=visarea.min_x; i<visarea.max_x; i++)
626656      {
627657         vc4000_video.sprite_collision|=sprite_collision[collision[i]];
628658         vc4000_video.background_collision|=background_collision[collision[i]];
659         /* display final object colours */
660         if (objects[i] < 8)
661               *BITMAP_ADDR16(vc4000_video.bitmap, vc4000_video.line, i) = objects[i];
629662      }
630663
631      y = vc4000_video.reg.d.score_control&1?180:0;
632      y += 20;
664      y = vc4000_video.reg.d.score_control&1?200:20;
665
633666      if ((vc4000_video.line>=y)&&(vc4000_video.line<y+20))
634667      {
635         x = 58;
668         x = 60;
636669         vc4000_draw_digit(vc4000_video.bitmap, x, y, vc4000_video.reg.d.bcd[0]>>4, vc4000_video.line-y);
637670         vc4000_draw_digit(vc4000_video.bitmap, x+16, y, vc4000_video.reg.d.bcd[0]&0xf, vc4000_video.line-y);
638671         if (vc4000_video.reg.d.score_control&2)   x -= 16;
r4266r4267
640673         vc4000_draw_digit(vc4000_video.bitmap, x+64, y, vc4000_video.reg.d.bcd[1]&0xf, vc4000_video.line-y);
641674      }
642675   }
643   if (vc4000_video.line==269) vc4000_video.reg.d.sprite_collision |=0x40;
676   if (vc4000_video.line==VC4000_END_LINE) vc4000_video.reg.d.sprite_collision |=0x40;
644677
645   if ((vc4000_video.line == 269) |
678   if (((vc4000_video.line == VC4000_END_LINE) |
646679      (vc4000_video.sprites[3].finished_now) |
647680      (vc4000_video.sprites[2].finished_now) |
648681      (vc4000_video.sprites[1].finished_now) |
649      (vc4000_video.sprites[0].finished_now))
650   {
651      cpu_set_input_line_and_vector(device->machine->cpu[0], 0, ASSERT_LINE, 3);
652      timer_set(device->machine, ATTOTIME_IN_USEC(400), NULL, 0, vc4000_clear);
653   }
682      (vc4000_video.sprites[0].finished_now)) && (!irq_pause))
683      {
684         cpu_set_input_line_and_vector(device->machine->cpu[0], 0, ASSERT_LINE, 3);
685         irq_pause=1;
686      }
654687}
655688
656689VIDEO_UPDATE( vc4000 )
src/mess/drivers/vc4000.c
r4266r4267
41412K Ram mapped from $0800 - $0FFF
4242The Cartridge is called Hobby Module and properly the Rom is the same as used in
4343elektor TV Game Computer which is a kind of developer machine for the VC4000.
44
45Go to the bottom to see the game list and emulation status of each.
4446******************************************************************************/
4547   
4648#include "driver.h"
r4266r4267
9092static ADDRESS_MAP_START( vc4000_mem , ADDRESS_SPACE_PROGRAM, 8)
9193   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
9294   AM_RANGE(0x0000, 0x0fff) AM_ROM
93   AM_RANGE(0x1600, 0x167f) AM_NOP AM_MIRROR(0x0800)
95//   AM_RANGE(0x1600, 0x167f) AM_NOP AM_MIRROR(0x0800)
9496   AM_RANGE(0x1680, 0x16ff) AM_READWRITE( vc4000_key_r, vc4000_sound_ctl ) AM_MIRROR(0x0800)
9597   AM_RANGE(0x1700, 0x17ff) AM_READWRITE( vc4000_video_r, vc4000_video_w ) AM_MIRROR(0x0800)
9698ADDRESS_MAP_END
r4266r4267
172174   MAKE_RGB(255, 0, 255), // magenta
173175   MAKE_RGB(200, 200, 0), // yellow
174176   MAKE_RGB(200, 200, 200), // white
175   // sprite colors
176   // simplier to add another 8 colors else using colormapping
177   // xor 7, bit 2 not green, bit 1 not blue, bit 0 not red
178//   MAKE_RGB(255, 255, 255), // white
179//   MAKE_RGB(255, 255, 0), // yellow
180//   MAKE_RGB(255, 0, 255), // magenta
181//   MAKE_RGB(175, 0, 0), // red
182//   MAKE_RGB(0, 255, 255), // cyan
183//   MAKE_RGB(0, 175, 0), // green
184//   MAKE_RGB(0, 0, 175), // blue
185//   MAKE_RGB(0, 0, 0) // black
177   /* sprite colors
178   The control line simply inverts the RGB lines all at once.
179   We can do that in the code with ^7 */
186180};
187181
188182static PALETTE_INIT( vc4000 )
r4266r4267
225219
226220static MACHINE_DRIVER_START( vc4000 )
227221   /* basic machine hardware */
228   MDRV_CPU_ADD("main", S2650, 865000)        /* 3550000/4, 3580000/3, 4430000/3 */
222//   MDRV_CPU_ADD("main", S2650, 865000)        /* 3550000/4, 3580000/3, 4430000/3 */
223   MDRV_CPU_ADD("main", S2650, 3546875/4)
229224   MDRV_CPU_PROGRAM_MAP(vc4000_mem, 0)
230225   MDRV_CPU_IO_MAP(vc4000_io, 0)
231   MDRV_CPU_PERIODIC_INT(vc4000_video_line, 312*50)
232   MDRV_QUANTUM_TIME(HZ(60))
226   MDRV_CPU_PERIODIC_INT(vc4000_video_line, 312*53)
227//   MDRV_QUANTUM_TIME(HZ(60))
233228
234229   /* video hardware */
235230   MDRV_SCREEN_ADD("main", RASTER)
236231   MDRV_SCREEN_REFRESH_RATE(50)
237232   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
238233   MDRV_SCREEN_SIZE(226, 312)
239   MDRV_SCREEN_VISIBLE_AREA(8, 182, 0, 269)
240   MDRV_PALETTE_LENGTH(ARRAY_LENGTH(vc4000_palette))
234   MDRV_SCREEN_VISIBLE_AREA(8, 184, 0, 269)
235   MDRV_PALETTE_LENGTH(8)
241236   MDRV_PALETTE_INIT( vc4000 )
242237
243238   MDRV_VIDEO_START( vc4000 )
r4266r4267
306301
307302/*   YEAR   NAME   PARENT   COMPAT   MACHINE   INPUT   INIT   CONFIG   COMPANY      FULLNAME */
308303CONS(1978,   vc4000,   0,   0,   vc4000,   vc4000,   0,   0,   "Interton",   "VC4000", GAME_IMPERFECT_GRAPHICS )
304
305/*   Game List and Emulation Status
306
307When you load a game it will normally appear to be unresponsive. Most carts contain a number of variants
308of each game (e.g. Difficulty, Player1 vs Player2 or Player1 vs Computer, etc).
309
310Press F2 (if needed) to select which game variant you would like to play. The variant number will increment
311on-screen. When you've made your choice, press F1 to start. The main keys are unlabelled, because an overlay
312is provided with each cart. See below for a guide.
313
314In some games, the joystick is used like 4 buttons, and other games like a paddle. The two modes are
315incompatible when using a keyboard. Therefore (in the emulation) a config dipswitch is used. The preferred
316setting is listed below.
317
318(AC = Auto-centre, NAC = no auto-centre, 90 = turn controller 90 degrees).
319
320The list is rather incomplete, information will be added as it becomes available.
321
322The game names and numbers were obtained from the Amigan Software site.
323
324Cart Num   Name
325----------------------------------------------
3261.      Grand Prix / Car Races / Autosport / Motor Racing / Road Race
327Config: Paddle, NAC
328Status: Working
329Controls: Left-Right: Steer; Up: Accelerate
330
3312.      Black Jack
332Status: Not working (some digits missing; indicator missing; dealer's cards missing)
333Controls: set bet with S and D; A to deal; 1 to hit, 2 to stay; Q accept insurance, E to decline; double-up (unknown key)
334Indicator: E make a bet then deal; I choose insurance; - you lost; + you won; X hit or stay
335
3363.      Olympics / Paddle Games / Bat & Ball / Pro Sport 60 / Sportsworld
337Config: Paddle, NAC
338Status: Working
339
3404.      Tank Battle / Combat
341Config: Button, 90
342Status: Working
343Controls: Left-Right: Steer; Up: Accelerate; Fire: Shoot
344
3455.      Maths 1
346Status: Working
347Controls: Z difficulty; X = addition or subtraction; C ask question; A=1;S=2;D=3;Q=4;W=5;E=6;1=7;2=8;3=9;0=0; C enter
348
3496.      Maths 2
350Status: Not working
351Controls: Same as above.
352
3537.      Air Sea Attack / Air Sea Battle
354Config: Button, 90
355Status: Working
356Controls: Left-Right: Move; Fire: Shoot
357
3588.      Treasure Hunt / Capture the Flag / Concentration / Memory Match
359Config: Buttons
360Status: Working
361
3629.      Labyrinth / Maze / Intelligence 1
363Config: Buttons
364Status: Working
365
36610.      Winter Sports
367Notes: Background colours should be Cyan and White instead of Red and Black
368
36911.      Hippodrome / Horse Race
370
37112.      Hunting / Shooting Gallery
372
37313.      Chess 1
374Status: Can't see what you're typing, wrong colours
375
37614.      Moto-cros
377
37815.      Four in a row / Intelligence 2
379Config: Buttons
380Status: Working
381Notes: Seems the unused squares should be black. The screen jumps about while the computer is "thinking".
382
38316.      Code Breaker / Master Mind / Intelligence 3 / Challenge
384
38517.      Circus
386STatus: severe gfx issues
387
38818.      Boxing / Prize Fight
389
39019.      Outer Space / Spacewar / Space Attack / Outer Space Combat
391
39220.      Melody Simon / Musical Memory / Follow the Leader / Musical Games / Electronic Music / Face the Music
393
39421.      Capture / Othello / Reversi / Attack / Intelligence 4
395Config: Buttons
396Status: Working
397Notes: Seems the unused squares should be black
398
39922.      Chess 2
400Status: Can't see what you're typing, wrong colours
401
40223.      Pinball / Flipper / Arcade
403Status: gfx issues
404
40524.      Soccer
406
40725.      Bowling / NinePins
408Config: Paddle, rotated 90 degrees, up/down autocentre, left-right does not
409Status: Working
410
41126.      Draughts
412
41327.      Golf
414Status: gfx issues
415
41628.      Cockpit
417Status: gfx issues
418
41929.      Metropolis / Hangman
420Status: gfx issues
421
42230.      Solitaire
423
42431.      Casino
425Status: gfx issues
426
42732.      Invaders / Alien Invasion / Earth Invasion
428
42933.      Super Invaders
430
43134.      (unknown, undumped pacman-like game)
432
43336.      BackGammon
434Status: Not all counters are visible, Dice not visible.
435
43637.      Monster Man / Spider's Web
437
43838.      Hyperspace
439
44040.      Super Space
441
442Public Domain:
443---------------
444* Picture (no controls) - works
445* WinArcadia Stub (no controls) - works */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team