Previous 15994 Revisions Next

r3276 Tuesday 16th September, 2008 at 10:39:06 UTC by Fabio Priuli
[C64/VIC20] Added crosshair to lightpen inputs, fixed bug 1398 removing the custom pointer code
[src/mess/drivers]vc20.c
[src/mess/machine]c64.c cbmipt.c vc20.c
[src/mess/video]vic6560.c vic6567.c

src/mess/video/vic6560.c
r3275r3276
5454/* 2008-05 FP: lightpen code needs to read input port from vc20.c */
5555
5656#define LIGHTPEN_BUTTON      (((input_port_read(machine, "CFG") & 0xf0) == 0x20) && (input_port_read(machine, "JOY") & 0x40))
57#define LIGHTPEN_POINTER   (input_port_read(machine, "CFG") & 0x20)
5857#define LIGHTPEN_X_VALUE   (input_port_read(machine, "LIGHTX") & ~0x01)
5958#define LIGHTPEN_Y_VALUE   (input_port_read(machine, "LIGHTY") & ~0x01)
6059
r3275r3276
117116static int chargenaddr, videoaddr;
118117
119118/* values in videoformat */
120static UINT16 backgroundcolor, framecolor, helpercolor, white, black;
119static UINT16 backgroundcolor, framecolor, helpercolor;
121120
122121/* arrays for bit to color conversion without condition checking */
123122static UINT16 mono[2], monoinverted[2], multi[4], multiinverted[4];
124123
125/* transparent, white, black */
126static UINT32 pointercolortable[3] =
127{0};
128static const gfx_layout pointerlayout =
129{
130   8, 8,
131   1,
132   2,
133   {0, 64},
134   {0, 1, 2, 3, 4, 5, 6, 7},
135   {0 * 8, 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8},
136   8 * 8
137};
138
139static const UINT8 pointermask[] =
140{
141   0x00, 0x70, 0x60, 0x50, 0x08, 0x04, 0x00, 0x00,      /* blackmask */
142   0xf0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00   /* whitemask */
143};
144
145static gfx_element *pointerelement;
146
147124static void vic656x_init (void)
148125{
149126   vic656x_xsize = VIC656X_XSIZE;
r3275r3276
168145   vic656x_init ();
169146}
170147
171static void vic6560_video_stop(running_machine *machine)
172{
173   freegfx(pointerelement);
174}
175148
176149VIDEO_START( vic6560 )
177150{
r3275r3276
179152   int width = video_screen_get_width(screen);
180153   int height = video_screen_get_height(screen);
181154
182   black = 0;
183   white = 1;
184   pointerelement = allocgfx(&pointerlayout);
185   decodegfx(pointerelement, pointermask, 0, 1);
186   /* 7-Sep-2007 - After 0.118u5, you cannot revector the color table */
187   /* pointerelement->colortable = pointercolortable; */
188   pointercolortable[1] = 1;
189   pointercolortable[2] = 0;
190   pointerelement->total_colors = 3;
191155   vic6560_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16);
192   add_exit_callback(machine, vic6560_video_stop);
193156}
194157
195158WRITE8_HANDLER ( vic6560_port_w )
r3275r3276
272235      vic6560_drawlines (lastline, rasterline);
273236      val = (rasterline / 2) & 0xff;
274237      break;
275   case 6:                     /*lightpen horicontal */
238   case 6:                     /*lightpen horizontal */
276239   case 7:                     /*lightpen vertical */
277240      if (LIGHTPEN_BUTTON
278241         && ((attotime_to_double(timer_get_time ()) - lightpenreadtime) * VIC6560_VRETRACERATE >= 1))
r3275r3276
302265   return val;
303266}
304267
305static int DOCLIP (rectangle *r1, const rectangle *r2)
306{
307   if (r1->min_x > r2->max_x)
308      return 0;
309   if (r1->max_x < r2->min_x)
310      return 0;
311   if (r1->min_y > r2->max_y)
312      return 0;
313   if (r1->max_y < r2->min_y)
314      return 0;
315   if (r1->min_x < r2->min_x)
316      r1->min_x = r2->min_x;
317   if (r1->max_x > r2->max_x)
318      r1->max_x = r2->max_x;
319   if (r1->min_y < r2->min_y)
320      r1->min_y = r2->min_y;
321   if (r1->max_y > r2->max_y)
322      r1->max_y = r2->max_y;
323   return 1;
324}
325
326268static void vic6560_draw_character (int ybegin, int yend,
327269                           int ch, int yoff, int xoff,
328270                           UINT16 *color)
r3275r3276
363305}
364306
365307
366#ifndef GFX
367INLINE void vic6560_draw_pointer (bitmap_t *bitmap,
368                          rectangle *visible, int xoff, int yoff)
369{
370   /* this is a a static graphical object */
371   /* should be easy to convert to gfx_element!? */
372   static const UINT8 blackmask[] =
373   {0x00, 0x70, 0x60, 0x50, 0x08, 0x04, 0x00, 0x00};
374   static const UINT8 whitemask[] =
375   {0xf0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00};
376   int i, j, y, x;
377
378   for (y = visible->min_y, j = yoff; y <= visible->max_y; y++, j++)
379   {
380      for (x = visible->min_x, i = xoff; x <= visible->max_x; x++, i++)
381      {
382         if ((blackmask[j] << i) & 0x80)
383            *BITMAP_ADDR16(bitmap, y, x) = black;
384         else if ((whitemask[j] << (i & ~1)) & 0x80)
385            *BITMAP_ADDR16(bitmap, y, x) = white;
386      }
387   }
388}
389#endif
390
391308static void vic6560_drawlines (int first, int last)
392309{
393310   int line, vline;
r3275r3276
485402
486403INTERRUPT_GEN( vic656x_raster_interrupt )
487404{
488   rectangle r;
489
490405   rasterline++;
491406   if (rasterline >= vic656x_lines)
492407   {
493408      rasterline = 0;
494409      vic6560_drawlines (lastline, vic656x_lines);
495410      lastline = 0;
496
497      if (LIGHTPEN_POINTER)
498      {
499
500         r.min_x = LIGHTPEN_X_VALUE - 1 + VIC656X_MAME_XPOS;
501         r.max_x = r.min_x + 8 - 1;
502         r.min_y = LIGHTPEN_Y_VALUE - 1 + VIC656X_MAME_YPOS;
503         r.max_y = r.min_y + 8 - 1;
504
505         if (DOCLIP (&r, video_screen_get_visible_area(video_screen_first(machine->config))))
506         {
507#ifndef GFX
508            vic6560_draw_pointer (vic6560_bitmap, &r,
509                             r.min_x - (LIGHTPEN_X_VALUE + VIC656X_MAME_XPOS - 1),
510                             r.min_y - (LIGHTPEN_Y_VALUE + VIC656X_MAME_YPOS - 1));
511#else
512            drawgfx (vic6560_bitmap, pointerelement, 0, 0, 0, 0,
513                   r.min_x - 1, r.min_y - 1, &r, TRANSPARENCY_PEN, 0);
514#endif
515         }
516      }
517411   }
518412}
519413
src/mess/video/vic6567.c
r3275r3276
9292#define FIRSTLINE ((VIC2_VISIBLELINES - VIC2_VSIZE)/2)
9393
9494/* 2008-05 FP: lightpen code needs to read input port from c64.c and cbmb.c */
95#define LIGHTPEN_BUTTON      (input_port_read(machine, "OTHER") & 0x04)
96#define LIGHTPEN_X_VALUE   (input_port_read(machine, "LIGHTX") & ~0x01)
97#define LIGHTPEN_Y_VALUE   (input_port_read(machine, "LIGHTY") & ~0x01)
9598
96#define LIGHTPEN_BUTTON      (((input_port_read(machine, "CTRLSEL") & 0xe000 ) == 0xa000 ) && (input_port_read(machine, "TRACKIPT") & 0x02))
97#define LIGHTPEN_POINTER   (((input_port_read(machine, "CTRLSEL") & 0xe000 ) == 0xa000 ) && (input_port_read(machine, "CTRLSEL") & 0x1000))
98#define LIGHTPEN_X_VALUE   (input_port_read(machine, "TRACKX") & ~1)
99#define LIGHTPEN_Y_VALUE   (input_port_read(machine, "TRACKY") & ~1)
100
10199/* lightpen delivers values from internal counters
102100 * they do not start with the visual area or frame area */
103101#define VIC2_MAME_XPOS 0
r3275r3276
123121#define VIC3_LINES      ((vic2.reg[0x31]&0x19)==0x19?400:200)
124122#define VIC3_BITPLANES_WIDTH (vic2.reg[0x31]&0x80?640:320)
125123
126    /*#define VIC2E_TEST (vic2[0x30]&2) */
124/*#define VIC2E_TEST (vic2[0x30]&2) */
127125#define DOUBLE_CLOCK (vic2.reg[0x30]&1)
128126
129127/* sprites 0 .. 7 */
src/mess/machine/cbmipt.c
r3275r3276
220220   PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CATEGORY(12) PORT_REVERSE
221221
222222   PORT_START("LIGHTX")
223   PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_X) PORT_NAME("Lightpen X Axis") PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CATEGORY(14)
223   PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_X) PORT_NAME("Lightpen X Axis") PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_PLAYER(1) PORT_CATEGORY(14)
224224   /* PORT_BIT( 0x1ff,0,IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,320-1) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(1) */
225225
226226   PORT_START("LIGHTY")
227   PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_Y) PORT_NAME("Lightpen Y Axis") PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CATEGORY(14) PORT_REVERSE
227   PORT_BIT( 0x7e, 0x00, IPT_TRACKBALL_Y) PORT_NAME("Lightpen Y Axis") PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_PLAYER(1) PORT_CATEGORY(14)
228228   /* PORT_BIT( 0xff,0,IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,200-1) PORT_CODE_DEC(KEYCODE_UP) PORT_CODE_INC(KEYCODE_DOWN) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(2) */
229229
230230   PORT_START("OTHER")
src/mess/machine/vc20.c
r3275r3276
644644}
645645
646646
647static TIMER_CALLBACK( lightpen_tick )
648{
649   if ((input_port_read(machine, "CFG") & 0xf0) == 0x20)
650   {
651      /* enable lightpen crosshair */
652      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL);
653   }
654   else
655   {
656      /* disable lightpen crosshair */
657      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE);
658   }
659}
660
647661INTERRUPT_GEN( vic20_frame_interrupt )
648662{
649663   via_0_ca1_w(machine, 0, vc20_via0_read_ca1 (machine, 0));
r3275r3276
656670   keyboard[6] = input_port_read(machine, "ROW6");
657671   keyboard[7] = input_port_read(machine, "ROW7");
658672
673   /* check if lightpen has been chosen as input: if so, enable crosshair */
674   timer_set(attotime_zero, NULL, 0, lightpen_tick);
675
659676   set_led_status (1, input_port_read(machine, "SPECIAL") & 0x01 ? 1 : 0);      /* Shift Lock */
660677}
661678
src/mess/machine/c64.c
r3275r3276
11291129}
11301130
11311131
1132static TIMER_CALLBACK( lightpen_tick )
1133{
1134   if ((input_port_read(machine, "CTRLSEL") & 0x07) == 0x04)
1135   {
1136      /* enable lightpen crosshair */
1137      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL);
1138   }
1139   else
1140   {
1141      /* disable lightpen crosshair */
1142      crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE);
1143   }
1144}
1145
11321146INTERRUPT_GEN( c64_frame_interrupt )
11331147{
11341148   static int monitor = -1;
r3275r3276
12761290
12771291   vic2_frame_interrupt (machine, cpunum);
12781292
1293   /* check if lightpen has been chosen as input: if so, enable crosshair */
1294   timer_set(attotime_zero, NULL, 0, lightpen_tick);
1295
12791296   set_led_status (1, input_port_read(machine, "SPECIAL") & 0x40 ? 1 : 0);      /* Shift Lock */
12801297   set_led_status (0, input_port_read(machine, "CTRLSEL") & 0x80 ? 1 : 0);      /* Joystick Swap */
12811298}
src/mess/drivers/vc20.c
r3275r3276
152152
153153static INPUT_PORTS_START( vic_lightpen_6560 )
154154   PORT_START( "LIGHTX" )
155   PORT_BIT (0xff, 0, IPT_PADDLE) PORT_NAME("Lightpen X Axis") PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(VIC6560_MAME_XSIZE - 1)) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CATEGORY(12) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH)
155   PORT_BIT( 0xff, 0, IPT_PADDLE ) PORT_NAME("Lightpen X Axis") PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(VIC6560_MAME_XSIZE - 1)) PORT_CATEGORY(12) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH)
156156
157157   PORT_START( "LIGHTY" )
158   PORT_BIT (0xff, 0, IPT_PADDLE) PORT_NAME("Lightpen Y Axis") PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(VIC6560_MAME_YSIZE - 1)) PORT_CODE_DEC(KEYCODE_UP) PORT_CODE_INC(KEYCODE_DOWN) PORT_CATEGORY(12) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH)
158   PORT_BIT( 0xff, 0, IPT_PADDLE ) PORT_NAME("Lightpen Y Axis") PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(VIC6560_MAME_YSIZE - 1)) PORT_CATEGORY(12) PORT_CODE_DEC(KEYCODE_UP) PORT_CODE_INC(KEYCODE_DOWN) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH)
159159INPUT_PORTS_END
160160
161161
162162static INPUT_PORTS_START( vic_lightpen_6561 )
163163   PORT_START( "LIGHTX" )
164   PORT_BIT (0xff, 0, IPT_PADDLE) PORT_NAME("Lightpen X Axis") PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(VIC6560_MAME_XSIZE - 1)) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CATEGORY(12) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH)
164   PORT_BIT( 0xff, 0, IPT_PADDLE ) PORT_NAME("Lightpen X Axis") PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(VIC6560_MAME_XSIZE - 1)) PORT_CATEGORY(12) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH)
165165
166166   PORT_START( "LIGHTY" )
167   PORT_BIT (0x1ff, 0, IPT_PADDLE) PORT_NAME("Lightpen Y Axis") PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(VIC6561_MAME_YSIZE - 1)) PORT_CODE_DEC(KEYCODE_UP) PORT_CODE_INC(KEYCODE_DOWN) PORT_CATEGORY(12) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH)
167   PORT_BIT( 0x1ff, 0, IPT_PADDLE ) PORT_NAME("Lightpen Y Axis") PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(30) PORT_KEYDELTA(2) PORT_MINMAX(0,(VIC6561_MAME_YSIZE - 1)) PORT_CATEGORY(12) PORT_CODE_DEC(KEYCODE_UP) PORT_CODE_INC(KEYCODE_DOWN) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH)
168168INPUT_PORTS_END
169169
170170
171static INPUT_PORTS_START (vic20)
171static INPUT_PORTS_START( vic20 )
172172   PORT_INCLUDE( vic_keyboard )      /* ROW0 -> ROW7 */
173173
174174   PORT_INCLUDE( vic_special )         /* SPECIAL */
r3275r3276
184184INPUT_PORTS_END
185185
186186
187static INPUT_PORTS_START (vic1001)
187static INPUT_PORTS_START( vic1001 )
188188   PORT_INCLUDE( vic20 )
189189
190190   PORT_MODIFY( "ROW0" )
r3275r3276
192192INPUT_PORTS_END
193193
194194
195static INPUT_PORTS_START (vic20i)
195static INPUT_PORTS_START( vic20i )
196196   PORT_INCLUDE( vic20 )
197197
198198   PORT_MODIFY( "CFG" )
r3275r3276
210210INPUT_PORTS_END
211211
212212
213static INPUT_PORTS_START (vc20)
213static INPUT_PORTS_START( vc20 )
214214   PORT_INCLUDE( vic_keyboard )      /* ROW0 -> ROW7 */
215215
216216   PORT_INCLUDE( vic_special )         /* SPECIAL */
r3275r3276
226226INPUT_PORTS_END
227227
228228
229static INPUT_PORTS_START (vic20swe)
229static INPUT_PORTS_START( vic20swe )
230230   PORT_INCLUDE( vc20 )
231231
232232   PORT_MODIFY( "ROW0" )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team