src/mess/video/smsvdp.c
| r6603 | r6604 | |
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | 1291 | |
| 1292 | static UINT8 color_brightness(rgb_t color) |
| 1293 | { |
| 1294 | /* reference: http://www.w3.org/TR/AERT#color-contrast */ |
| 1295 | UINT8 brightness = (RGB_RED(color) * 0.299) + (RGB_GREEN(color) * 0.587) + (RGB_BLUE(color) * 0.114); |
| 1296 | //printf ("color brightness: %2X\n", brightness); |
| 1297 | return brightness; |
| 1298 | } |
| 1299 | |
| 1300 | |
| 1301 | UINT8 sms_vdp_area_brightness(const device_config *device, int x, int y, int x_range, int y_range) |
| 1302 | { |
| 1303 | int beam_x, beam_y; |
| 1304 | int dx, dy; |
| 1305 | int vint_line; |
| 1306 | smsvdp_t *smsvdp; |
| 1307 | |
| 1308 | if (x < LBORDER_START + LBORDER_X_PIXELS || x >= LBORDER_START + LBORDER_X_PIXELS + 256) |
| 1309 | { |
| 1310 | return 0x00; |
| 1311 | } |
| 1312 | |
| 1313 | smsvdp = get_safe_token(device); |
| 1314 | |
| 1315 | beam_x = video_screen_get_hpos(device->machine->primary_screen); |
| 1316 | beam_y = video_screen_get_vpos(device->machine->primary_screen); |
| 1317 | dx = x - beam_x; |
| 1318 | dy = y - beam_y; |
| 1319 | |
| 1320 | if (abs(dy) <= y_range && abs(dx) <= x_range) |
| 1321 | { |
| 1322 | rgb_t color = *BITMAP_ADDR32(smsvdp->tmpbitmap, beam_y, beam_x); |
| 1323 | return color_brightness(color); |
| 1324 | } |
| 1325 | |
| 1326 | /* Color & Switch Test ROM check TH after the line where VINT */ |
| 1327 | /* occurs (237 for NTSC/192 mode). Until details are not figured */ |
| 1328 | /* out, calculate VINT line and use it for this special case. */ |
| 1329 | vint_line = smsvdp->sms_frame_timing[VERTICAL_BLANKING] + smsvdp->sms_frame_timing[TOP_BLANKING] |
| 1330 | + smsvdp->sms_frame_timing[TOP_BORDER] + smsvdp->sms_frame_timing[ACTIVE_DISPLAY_V] |
| 1331 | + 1; |
| 1332 | |
| 1333 | if (beam_y == vint_line + 1 && abs(dx) <= x_range) |
| 1334 | { |
| 1335 | rgb_t color = *BITMAP_ADDR32(smsvdp->tmpbitmap, y, x); |
| 1336 | return color_brightness(color); |
| 1337 | } |
| 1338 | |
| 1339 | return 0x00; |
| 1340 | } |
| 1341 | |
| 1342 | |
| 1292 | 1343 | static void sms_update_palette( smsvdp_t *smsvdp ) |
| 1293 | 1344 | { |
| 1294 | 1345 | int i; |
| r6603 | r6604 | |
| 1405 | 1456 | |
| 1406 | 1457 | /* Make temp bitmap for rendering */ |
| 1407 | 1458 | smsvdp->tmpbitmap = auto_bitmap_alloc(device->machine, width, height, BITMAP_FORMAT_INDEXED32); |
| 1408 | | |
| 1409 | 1459 | smsvdp->prev_bitmap = auto_bitmap_alloc(device->machine, width, height, BITMAP_FORMAT_INDEXED32); |
| 1410 | 1460 | |
| 1411 | | |
| 1412 | 1461 | smsvdp->smsvdp_display_timer = timer_alloc(device->machine, smsvdp_display_callback, smsvdp); |
| 1413 | 1462 | timer_adjust_periodic(smsvdp->smsvdp_display_timer, video_screen_get_time_until_pos(screen, 0, 0), 0, video_screen_get_scan_period(screen)); |
| 1414 | 1463 | |
| r6603 | r6604 | |
| 1429 | 1478 | state_save_register_device_item(device, 0, smsvdp->prev_bitmap_saved); |
| 1430 | 1479 | state_save_register_device_item_array(device, 0, smsvdp->reg); |
| 1431 | 1480 | state_save_register_device_item_array(device, 0, smsvdp->current_palette); |
| 1481 | state_save_register_device_item_pointer(device, 0, smsvdp->line_buffer, 256 * 5); |
| 1482 | state_save_register_device_item_pointer(device, 0, smsvdp->collision_buffer, SMS_X_PIXELS); |
| 1483 | state_save_register_device_item_bitmap(device, 0, smsvdp->tmpbitmap); |
| 1484 | state_save_register_device_item_bitmap(device, 0, smsvdp->prev_bitmap); |
| 1432 | 1485 | } |
| 1433 | 1486 | |
| 1434 | 1487 | static DEVICE_RESET( smsvdp ) |
src/mess/machine/sms.c
| r6603 | r6604 | |
| 67 | 67 | |
| 68 | 68 | /* Data needed for Light Phaser */ |
| 69 | 69 | UINT16 lphaser_latch; |
| 70 | | UINT16 lphaser_1_x; |
| 71 | | UINT16 lphaser_1_y; |
| 72 | | UINT16 lphaser_2_x; |
| 73 | | UINT16 lphaser_2_y; |
| 74 | 70 | int lphaser_x_offs; /* Needed to 'calibrate' lphaser; set at cart loading */ |
| 75 | 71 | |
| 76 | 72 | /* Data needed for SegaScope (3D glasses) */ |
| r6603 | r6604 | |
| 188 | 184 | static UINT8 sms_vdp_hcount( running_machine *machine ) |
| 189 | 185 | { |
| 190 | 186 | UINT8 tmp; |
| 191 | | UINT64 calc_cycles; |
| 192 | | attotime time_end; |
| 193 | 187 | const device_config *screen = video_screen_first(machine->config); |
| 188 | int hpos = video_screen_get_hpos(screen); |
| 194 | 189 | |
| 195 | | //int hpos = video_screen_get_hpos(screen); |
| 190 | /* alternative method: pass HCounter test, but some others fail */ |
| 191 | //int hpos_tmp = hpos; |
| 192 | //if ((hpos + 2) % 6 == 0) hpos_tmp--; |
| 193 | //tmp = ((hpos_tmp - 46) >> 1) & 0xff; |
| 194 | |
| 195 | UINT64 calc_cycles; |
| 196 | attotime time_end; |
| 196 | 197 | int vpos = video_screen_get_vpos(screen); |
| 197 | | int width = video_screen_get_width(screen); |
| 198 | | |
| 199 | | /* this is simpler and independent of other clocks */ |
| 200 | | //tmp = ((hpos - 46) >> 1) & 0xff; |
| 201 | | |
| 202 | | /* ... but this is closer to the behavior described by Flubba */ |
| 203 | | /* and makes use of his equation posted at SMSPower forum. */ |
| 204 | | time_end = video_screen_get_time_until_pos(screen, vpos, width - 1); |
| 198 | int max_hpos = video_screen_get_width(screen) - 1; |
| 199 | |
| 200 | if (hpos == max_hpos) |
| 201 | time_end = attotime_zero; |
| 202 | else |
| 203 | time_end = video_screen_get_time_until_pos(screen, vpos, max_hpos); |
| 205 | 204 | calc_cycles = cpu_attotime_to_clocks(cputag_get_cpu(machine, "maincpu"), time_end); |
| 205 | |
| 206 | /* equation got from SMSPower forum, posted by Flubba. */ |
| 206 | 207 | tmp = ((590 - (calc_cycles * 3)) / 4) & 0xff; |
| 207 | | |
| 208 | |
| 208 | 209 | //printf ("sms_vdp_hcount: hpos %3d => hcount %2X\n", hpos, tmp); |
| 209 | 210 | return tmp; |
| 210 | 211 | } |
| r6603 | r6604 | |
| 218 | 219 | sms_vdp_hcount_latch_w(smsvdp, 0, value); |
| 219 | 220 | } |
| 220 | 221 | |
| 221 | | static int lphaser_sensor_is_on( running_machine *machine, int x, int y ) |
| 222 | | { |
| 223 | | const device_config *screen = video_screen_first(machine->config); |
| 224 | | int dx, dy; |
| 225 | | //const int r_x_r = 20 * 20; /* radius^2 */ |
| 226 | | int hpos, vpos; |
| 227 | | |
| 228 | | if (x < LBORDER_START + LBORDER_X_PIXELS || x >= LBORDER_START + LBORDER_X_PIXELS + 256) |
| 229 | | { |
| 230 | | sms_state.lphaser_latch = 0; |
| 231 | | return 0; |
| 232 | | } |
| 233 | | |
| 234 | | hpos = video_screen_get_hpos(screen); |
| 235 | | vpos = video_screen_get_vpos(screen); |
| 236 | | |
| 237 | | /* some offset seems needed for sms_vdp_hcount_latch() */ |
| 238 | | //hpos -= 44; |
| 239 | | |
| 240 | | dx = x - hpos; |
| 241 | | dy = y - vpos; |
| 242 | | |
| 243 | | //printf ("Light Phaser polling at %3d x %3d for shot %3d x %3d\n", hpos, vpos, x, y); |
| 244 | | |
| 245 | | /* SMSPower Wiki: the Light Phaser sensor "sees" a circular portion of the screen */ |
| 246 | | //if ( (dx * dx) + (dy * dy) - (r_x_r) <= 0 ) |
| 247 | | if (abs(dy) <= 5 && abs(dx) <= 60) /* simpler method used by SMSPlus-GX */ |
| 248 | | { |
| 249 | | /* avoid latching hcount more than once in a line */ |
| 250 | | if (sms_state.lphaser_latch == 0) |
| 251 | | { |
| 252 | | sms_state.lphaser_latch = 1; |
| 253 | | //sms_vdp_hcount_latch(screen); |
| 254 | | /* FIXME: sms_vdp_hcount_lphaser() is a hack necessary while normal latch gives too inconstant shot positions */ |
| 255 | | x += sms_state.lphaser_x_offs; |
| 256 | | sms_vdp_hcount_lphaser(machine, x); |
| 257 | | } |
| 258 | 222 | |
| 259 | | return 1; |
| 260 | | } |
| 261 | | else |
| 262 | | { |
| 263 | | sms_state.lphaser_latch = 0; |
| 264 | | return 0; |
| 265 | | } |
| 266 | | } |
| 267 | | |
| 268 | | |
| 269 | 223 | static UINT16 screen_hpos_nonscaled( const device_config *screen, int scaled_hpos ) |
| 270 | 224 | { |
| 271 | 225 | const rectangle *visarea = video_screen_get_visible_area(screen); |
| r6603 | r6604 | |
| 282 | 236 | } |
| 283 | 237 | |
| 284 | 238 | |
| 239 | static int lphaser_sensor_is_on( running_machine *machine, const char *tag_x, const char *tag_y ) |
| 240 | { |
| 241 | int x = screen_hpos_nonscaled(machine->primary_screen, input_port_read(machine, tag_x)); |
| 242 | int y = screen_vpos_nonscaled(machine->primary_screen, input_port_read(machine, tag_y)); |
| 243 | |
| 244 | if (sms_vdp_area_brightness(devtag_get_device(machine, "sms_vdp"), x, y, 60, 5) >= 0x7f) |
| 245 | { |
| 246 | /* avoid latching hcount more than once in a line */ |
| 247 | if (sms_state.lphaser_latch == 0) |
| 248 | { |
| 249 | sms_state.lphaser_latch = 1; |
| 250 | //sms_vdp_hcount_latch(machine); |
| 251 | /* FIXME: sms_vdp_hcount_lphaser() is a hack necessary while normal latch gives too inconstant shot positions */ |
| 252 | x += sms_state.lphaser_x_offs; |
| 253 | sms_vdp_hcount_lphaser(machine, x); |
| 254 | } |
| 255 | return 1; |
| 256 | } |
| 257 | |
| 258 | sms_state.lphaser_latch = 0; |
| 259 | return 0; |
| 260 | } |
| 261 | |
| 262 | |
| 285 | 263 | static void sms_get_inputs( const address_space *space ) |
| 286 | 264 | { |
| 287 | 265 | UINT8 data = 0x00; |
| 288 | | UINT8 data_x = 0x00; |
| 289 | | UINT8 data_y = 0x00; |
| 290 | 266 | UINT32 cpu_cycles = cpu_get_total_cycles(space->cpu); |
| 291 | 267 | running_machine *machine = space->machine; |
| 292 | 268 | |
| r6603 | r6604 | |
| 324 | 300 | { |
| 325 | 301 | if (input_port_read(machine, "RFU") & 0x01) |
| 326 | 302 | data |= sms_state.rapid_fire_state_1 & 0x10; |
| 327 | | |
| 328 | | data_x = input_port_read(machine, "LPHASER0"); |
| 329 | | data_y = input_port_read(machine, "LPHASER1"); |
| 330 | | |
| 331 | | sms_state.lphaser_1_x = screen_hpos_nonscaled(machine->primary_screen, data_x); |
| 332 | | sms_state.lphaser_1_y = screen_vpos_nonscaled(machine->primary_screen, data_y); |
| 333 | 303 | } |
| 334 | 304 | /* just consider the button (trigger) bit */ |
| 335 | 305 | data |= ~0x10; |
| r6603 | r6604 | |
| 392 | 362 | { |
| 393 | 363 | if (input_port_read(machine, "RFU") & 0x04) |
| 394 | 364 | data |= sms_state.rapid_fire_state_2 & 0x04; |
| 395 | | |
| 396 | | data_x = input_port_read(machine, "LPHASER2"); |
| 397 | | data_y = input_port_read(machine, "LPHASER3"); |
| 398 | | |
| 399 | | sms_state.lphaser_2_x = screen_hpos_nonscaled (machine->primary_screen, data_x); |
| 400 | | sms_state.lphaser_2_y = screen_vpos_nonscaled (machine->primary_screen, data_y); |
| 401 | 365 | } |
| 402 | 366 | /* just consider the button (trigger) bit */ |
| 403 | 367 | data |= ~0x04; |
| r6603 | r6604 | |
| 544 | 508 | return 0xff; |
| 545 | 509 | |
| 546 | 510 | sms_get_inputs(space); |
| 511 | |
| 512 | /* Reset Button */ |
| 513 | sms_state.input_port1 = (sms_state.input_port1 & 0xef) | (input_port_read_safe(space->machine, "RESET", 0x01) & 0x01) << 4; |
| 547 | 514 | |
| 548 | 515 | /* Do region detection if TH of ports A and B are set to output (0) */ |
| 549 | 516 | if (!(sms_state.ctrl_reg & 0x0a)) |
| r6603 | r6604 | |
| 555 | 522 | if (sms_state.is_region_japan) |
| 556 | 523 | sms_state.input_port1 ^= 0xc0; |
| 557 | 524 | } |
| 558 | | else if (sms_state.ctrl_reg & 0x02 && lphaser_sensor_is_on(space->machine, sms_state.lphaser_1_x, sms_state.lphaser_1_y)) |
| 525 | else |
| 559 | 526 | { |
| 560 | | sms_state.input_port1 &= ~0x40; |
| 527 | if (sms_state.ctrl_reg & 0x02 |
| 528 | && (input_port_read_safe(space->machine, "CTRLSEL", 0x00) & 0x0f) == 0x01 |
| 529 | && lphaser_sensor_is_on(space->machine, "LPHASER0", "LPHASER1")) |
| 530 | { |
| 531 | sms_state.input_port1 &= ~0x40; |
| 532 | } |
| 533 | if (sms_state.ctrl_reg & 0x08 |
| 534 | && (input_port_read_safe(space->machine, "CTRLSEL", 0x00) & 0xf0) == 0x10 |
| 535 | && lphaser_sensor_is_on(space->machine, "LPHASER2", "LPHASER3")) |
| 536 | { |
| 537 | sms_state.input_port1 &= ~0x80; |
| 538 | } |
| 561 | 539 | } |
| 562 | | else if (sms_state.ctrl_reg & 0x08 && lphaser_sensor_is_on(space->machine, sms_state.lphaser_2_x, sms_state.lphaser_2_y)) |
| 563 | | { |
| 564 | | sms_state.input_port1 &= ~0x80; |
| 565 | | } |
| 566 | | |
| 540 | |
| 567 | 541 | return sms_state.input_port1; |
| 568 | 542 | } |
| 569 | 543 | |
| r6603 | r6604 | |
| 1487 | 1461 | sms_state.sports_pad_2_y = 0; |
| 1488 | 1462 | |
| 1489 | 1463 | sms_state.lphaser_latch = 0; |
| 1490 | | sms_state.lphaser_1_x = 0; |
| 1491 | | sms_state.lphaser_1_y = 0; |
| 1492 | | sms_state.lphaser_2_x = 0; |
| 1493 | | sms_state.lphaser_2_x = 0; |
| 1494 | 1464 | |
| 1495 | 1465 | sms_state.sscope_state = 0; |
| 1496 | 1466 | |
docs/messnew.txt
| r6603 | r6604 | |
| 2 | 2 | |
| 3 | 3 | New System Drivers Supported: |
| 4 | 4 | ----------------------------- |
| 5 | - Consul 2717 with PMD-32 [Miodrag Milanovic] |
| 5 | 6 | - Elektor SC/MP [Miodrag Milanovic] |
| 6 | 7 | - Hawthorne Technologies TinyGiant HT68k [Miodrag Milanovic] |
| 7 | 8 | - Hector MX40c [JJ Stacino] |
| 8 | 9 | - Hector MX80c [JJ Stacino] |
| 9 | 10 | - Microsystems International Limited MOD-8 [Miodrag Milanovic] |
| 11 | - MITS Altair 8800bt [Miodrag Milanovic] |
| 12 | - Robotron K1003 [Miodrag Milanovic] |
| 10 | 13 | - Science of Cambridge MK-14 [Miodrag Milanovic] |
| 11 | | - Robotron K1003 [Miodrag Milanovic] |
| 12 | | - MITS Altair 8800bt [Miodrag Milanovic] |
| 13 | | - Consul 2717 with PMD-32 [Miodrag Milanovic] |
| 14 | 14 | |
| 15 | |
| 16 | |
| 15 | 17 | Systems Promoted from GAME_NOT_WORKING: |
| 16 | 18 | --------------------------------------- |
| 17 | 19 | - Ausbaufähiger Mikrocomputer mit dem U 880 (Huebler/Everts) [Curt Coder] |
| r6603 | r6604 | |
| 25 | 27 | |
| 26 | 28 | Skeleton drivers: |
| 27 | 29 | ----------------- |
| 30 | - Callan Unistar Terminal |
| 31 | - Dual Systems 68000 |
| 28 | 32 | - Exelvision Exeltel |
| 29 | | - Sharp PC-E220 |
| 30 | 33 | - Hewlett-Packard HP16500b [R. Belmont] |
| 34 | - Indiana University 68030 board |
| 35 | - Intel SDK-85 |
| 36 | - Intel RPC 86 |
| 37 | - Intel iSBC 86/12A |
| 38 | - Intel iSBC 286 |
| 39 | - Intel iSBC 286-10 |
| 40 | - MCS Basic 52 |
| 41 | - MCS Basic 31 |
| 31 | 42 | - Micronic 1000 [Curt Coder] |
| 32 | 43 | - MITS Altair 680b |
| 33 | | - MCS Basic 52 |
| 34 | | - MCS Basic 31 |
| 35 | | - Sun-1 |
| 44 | - Morrow Designs Micro Decision MD-2 and MD-3 |
| 45 | - Morrow Tricep |
| 46 | - NorthStar Horizon |
| 36 | 47 | - Plan-80 |
| 37 | | - SAPI-1 ZPS 2 |
| 38 | | - SAPI-1 ZPS 3 |
| 39 | 48 | - Protec Pro-80 |
| 40 | 49 | - PIMPS |
| 41 | 50 | - Sage II |
| 42 | | - NorthStar Horizon |
| 51 | - SAPI-1 ZPS 2 |
| 52 | - SAPI-1 ZPS 3 |
| 53 | - Sharp PC-E220 |
| 54 | - Sun-1 |
| 55 | - SWTPC 68000 |
| 43 | 56 | - Vector Graphic Vector 1+ |
| 44 | | - Morrow Tricep |
| 45 | | - Indiana University 68030 board |
| 46 | 57 | - Vector Graphics - Vector 4 |
| 47 | | - Callan Unistar Terminal |
| 48 | | - Dual Systems 68000 |
| 49 | | - Intel SDK-85 |
| 50 | | - Intel RPC 86 |
| 51 | | - Intel iSBC 86/12A |
| 52 | | - Intel iSBC 286 |
| 53 | | - Intel iSBC 286-10 |
| 54 | | - Morrow Designs Micro Decision MD-2 and MD-3 |
| 55 | | - SWTPC 68000 |
| 56 | 58 | |
| 59 | |
| 60 | |
| 57 | 61 | System Driver Changes: |
| 58 | 62 | ---------------------- |
| 59 | 63 | - [BETA] Fixed display flickering. [Curt Coder] |
| r6603 | r6604 | |
| 86 | 90 | Once enabled, remappable controls will also appear in the Input (this |
| 87 | 91 | System) menu. [Fabio Priuli] |
| 88 | 92 | |
| 93 | - [SMS] Added Reset button to SMS1 and improved Lightgun behavior based |
| 94 | on "Color & Switch Test". [Enik Land] |
| 95 | |
| 89 | 96 | - [TI81] Added v1.6K BIOS dump. [critor] |
| 90 | 97 | |
| 91 | 98 | - [TI85/TI86] Converted the serial interface to a device. [Wilbert Pol] |