src/mess/video/vic6560.c
| r3275 | r3276 | |
| 54 | 54 | /* 2008-05 FP: lightpen code needs to read input port from vc20.c */ |
| 55 | 55 | |
| 56 | 56 | #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) |
| 58 | 57 | #define LIGHTPEN_X_VALUE (input_port_read(machine, "LIGHTX") & ~0x01) |
| 59 | 58 | #define LIGHTPEN_Y_VALUE (input_port_read(machine, "LIGHTY") & ~0x01) |
| 60 | 59 | |
| r3275 | r3276 | |
| 117 | 116 | static int chargenaddr, videoaddr; |
| 118 | 117 | |
| 119 | 118 | /* values in videoformat */ |
| 120 | | static UINT16 backgroundcolor, framecolor, helpercolor, white, black; |
| 119 | static UINT16 backgroundcolor, framecolor, helpercolor; |
| 121 | 120 | |
| 122 | 121 | /* arrays for bit to color conversion without condition checking */ |
| 123 | 122 | static UINT16 mono[2], monoinverted[2], multi[4], multiinverted[4]; |
| 124 | 123 | |
| 125 | | /* transparent, white, black */ |
| 126 | | static UINT32 pointercolortable[3] = |
| 127 | | {0}; |
| 128 | | static 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 | | |
| 139 | | static 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 | | |
| 145 | | static gfx_element *pointerelement; |
| 146 | | |
| 147 | 124 | static void vic656x_init (void) |
| 148 | 125 | { |
| 149 | 126 | vic656x_xsize = VIC656X_XSIZE; |
| r3275 | r3276 | |
| 168 | 145 | vic656x_init (); |
| 169 | 146 | } |
| 170 | 147 | |
| 171 | | static void vic6560_video_stop(running_machine *machine) |
| 172 | | { |
| 173 | | freegfx(pointerelement); |
| 174 | | } |
| 175 | 148 | |
| 176 | 149 | VIDEO_START( vic6560 ) |
| 177 | 150 | { |
| r3275 | r3276 | |
| 179 | 152 | int width = video_screen_get_width(screen); |
| 180 | 153 | int height = video_screen_get_height(screen); |
| 181 | 154 | |
| 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; |
| 191 | 155 | vic6560_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16); |
| 192 | | add_exit_callback(machine, vic6560_video_stop); |
| 193 | 156 | } |
| 194 | 157 | |
| 195 | 158 | WRITE8_HANDLER ( vic6560_port_w ) |
| r3275 | r3276 | |
| 272 | 235 | vic6560_drawlines (lastline, rasterline); |
| 273 | 236 | val = (rasterline / 2) & 0xff; |
| 274 | 237 | break; |
| 275 | | case 6: /*lightpen horicontal */ |
| 238 | case 6: /*lightpen horizontal */ |
| 276 | 239 | case 7: /*lightpen vertical */ |
| 277 | 240 | if (LIGHTPEN_BUTTON |
| 278 | 241 | && ((attotime_to_double(timer_get_time ()) - lightpenreadtime) * VIC6560_VRETRACERATE >= 1)) |
| r3275 | r3276 | |
| 302 | 265 | return val; |
| 303 | 266 | } |
| 304 | 267 | |
| 305 | | static 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 | | |
| 326 | 268 | static void vic6560_draw_character (int ybegin, int yend, |
| 327 | 269 | int ch, int yoff, int xoff, |
| 328 | 270 | UINT16 *color) |
| r3275 | r3276 | |
| 363 | 305 | } |
| 364 | 306 | |
| 365 | 307 | |
| 366 | | #ifndef GFX |
| 367 | | INLINE 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 | | |
| 391 | 308 | static void vic6560_drawlines (int first, int last) |
| 392 | 309 | { |
| 393 | 310 | int line, vline; |
| r3275 | r3276 | |
| 485 | 402 | |
| 486 | 403 | INTERRUPT_GEN( vic656x_raster_interrupt ) |
| 487 | 404 | { |
| 488 | | rectangle r; |
| 489 | | |
| 490 | 405 | rasterline++; |
| 491 | 406 | if (rasterline >= vic656x_lines) |
| 492 | 407 | { |
| 493 | 408 | rasterline = 0; |
| 494 | 409 | vic6560_drawlines (lastline, vic656x_lines); |
| 495 | 410 | 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 | | } |
| 517 | 411 | } |
| 518 | 412 | } |
| 519 | 413 | |
src/mess/drivers/vc20.c
| r3275 | r3276 | |
| 152 | 152 | |
| 153 | 153 | static INPUT_PORTS_START( vic_lightpen_6560 ) |
| 154 | 154 | 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) |
| 156 | 156 | |
| 157 | 157 | 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) |
| 159 | 159 | INPUT_PORTS_END |
| 160 | 160 | |
| 161 | 161 | |
| 162 | 162 | static INPUT_PORTS_START( vic_lightpen_6561 ) |
| 163 | 163 | 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) |
| 165 | 165 | |
| 166 | 166 | 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) |
| 168 | 168 | INPUT_PORTS_END |
| 169 | 169 | |
| 170 | 170 | |
| 171 | | static INPUT_PORTS_START (vic20) |
| 171 | static INPUT_PORTS_START( vic20 ) |
| 172 | 172 | PORT_INCLUDE( vic_keyboard ) /* ROW0 -> ROW7 */ |
| 173 | 173 | |
| 174 | 174 | PORT_INCLUDE( vic_special ) /* SPECIAL */ |
| r3275 | r3276 | |
| 184 | 184 | INPUT_PORTS_END |
| 185 | 185 | |
| 186 | 186 | |
| 187 | | static INPUT_PORTS_START (vic1001) |
| 187 | static INPUT_PORTS_START( vic1001 ) |
| 188 | 188 | PORT_INCLUDE( vic20 ) |
| 189 | 189 | |
| 190 | 190 | PORT_MODIFY( "ROW0" ) |
| r3275 | r3276 | |
| 192 | 192 | INPUT_PORTS_END |
| 193 | 193 | |
| 194 | 194 | |
| 195 | | static INPUT_PORTS_START (vic20i) |
| 195 | static INPUT_PORTS_START( vic20i ) |
| 196 | 196 | PORT_INCLUDE( vic20 ) |
| 197 | 197 | |
| 198 | 198 | PORT_MODIFY( "CFG" ) |
| r3275 | r3276 | |
| 210 | 210 | INPUT_PORTS_END |
| 211 | 211 | |
| 212 | 212 | |
| 213 | | static INPUT_PORTS_START (vc20) |
| 213 | static INPUT_PORTS_START( vc20 ) |
| 214 | 214 | PORT_INCLUDE( vic_keyboard ) /* ROW0 -> ROW7 */ |
| 215 | 215 | |
| 216 | 216 | PORT_INCLUDE( vic_special ) /* SPECIAL */ |
| r3275 | r3276 | |
| 226 | 226 | INPUT_PORTS_END |
| 227 | 227 | |
| 228 | 228 | |
| 229 | | static INPUT_PORTS_START (vic20swe) |
| 229 | static INPUT_PORTS_START( vic20swe ) |
| 230 | 230 | PORT_INCLUDE( vc20 ) |
| 231 | 231 | |
| 232 | 232 | PORT_MODIFY( "ROW0" ) |