trunk/src/mame/drivers/system16.cpp
| r253698 | r253699 | |
| 1354 | 1354 | return 0xffff;//rand(); |
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | | WRITE16_MEMBER(segas1x_bootleg_state::ddcrewbl_spritebank_w) |
| 1358 | | { |
| 1359 | | // printf("banking write %08x: %04x (%04x %04x)\n", space.device().safe_pc(), offset*2, data&mem_mask, mem_mask); |
| 1360 | | |
| 1361 | | data &= mem_mask; |
| 1362 | | // offset &= 0x7; |
| 1363 | | offset += 4; |
| 1364 | | |
| 1365 | | int maxbanks = memregion("sprites")->bytes() / 0x40000; |
| 1366 | | if (data >= maxbanks) |
| 1367 | | data = 255; |
| 1368 | | m_sprites->set_bank((offset) * 2 + 0, data * 2 + 0); |
| 1369 | | m_sprites->set_bank((offset) * 2 + 1, data * 2 + 1); |
| 1370 | | } |
| 1371 | | |
| 1372 | | |
| 1373 | 1357 | // todo: this |
| 1374 | | static ADDRESS_MAP_START(ddcrewbl_map, AS_PROGRAM, 16, segas1x_bootleg_state) |
| 1375 | | AM_RANGE(0x000000, 0x07ffff) AM_ROM // ok |
| 1376 | | AM_RANGE(0x200000, 0x27ffff) AM_ROM // ok |
| 1358 | static ADDRESS_MAP_START( ddcrewbl_map, AS_PROGRAM, 16, segas1x_bootleg_state ) |
| 1359 | AM_RANGE(0x000000, 0x07ffff) AM_ROM |
| 1360 | AM_RANGE(0x200000, 0x27ffff) AM_ROM |
| 1377 | 1361 | |
| 1378 | 1362 | AM_RANGE(0x400000, 0x40ffff) AM_RAM_WRITE(sys16_tileram_w) AM_SHARE("tileram") |
| 1379 | 1363 | AM_RANGE(0x410000, 0x410fff) AM_RAM_WRITE(sys16_textram_w) AM_SHARE("textram") |
| 1380 | | AM_RANGE(0x440000, 0x440fff) AM_RAM AM_SHARE("sprites") // ok |
| 1364 | AM_RANGE(0x440000, 0x440fff) AM_RAM AM_SHARE("sprites") |
| 1365 | // AM_RANGE(0xa00000, 0xa00001) AM_READ_PORT("COINAGE") |
| 1366 | // AM_RANGE(0xa00002, 0xa00003) AM_READ_PORT("DSW1") |
| 1381 | 1367 | |
| 1382 | | AM_RANGE(0x840000, 0x840fff) AM_RAM_WRITE(paletteram_w) AM_SHARE("paletteram") // ok |
| 1368 | // AM_RANGE(0xa0000e, 0xa0000f) AM_WRITE(sys18_tilebank_w) |
| 1369 | // AM_RANGE(0xa01000, 0xa01001) AM_READ_PORT("SERVICE") |
| 1370 | // AM_RANGE(0xa01002, 0xa01003) AM_READ_PORT("P1") |
| 1371 | // AM_RANGE(0xa01004, 0xa01005) AM_READ_PORT("P2") |
| 1372 | // AM_RANGE(0xa01006, 0xa01007) AM_READ_PORT("P3") |
| 1383 | 1373 | |
| 1384 | | AM_RANGE(0xC00000, 0xC00001) AM_WRITENOP // vdp leftovers maybe? |
| 1385 | | AM_RANGE(0xC00004, 0xC00005) AM_WRITENOP |
| 1386 | | AM_RANGE(0xC00006, 0xC00007) AM_WRITENOP |
| 1387 | | |
| 1374 | AM_RANGE(0x840000, 0x840fff) AM_RAM_WRITE(paletteram_w) AM_SHARE("paletteram") |
| 1388 | 1375 | |
| 1376 | AM_RANGE(0xC00000, 0xC00001) AM_WRITENOP |
| 1377 | |
| 1389 | 1378 | AM_RANGE(0xC40000, 0xC40001) AM_READ(ddcrew_c41006_r) |
| 1390 | 1379 | AM_RANGE(0xC40002, 0xC40003) AM_READ(ddcrew_c41006_r) |
| 1380 | |
| 1381 | |
| 1391 | 1382 | AM_RANGE(0xC41000, 0xC41001) AM_READ(ddcrew_c41006_r) |
| 1392 | | AM_RANGE(0xC41002, 0xC41003) AM_READ(ddcrew_c41006_r) |
| 1393 | | AM_RANGE(0xC41004, 0xC41005) AM_READ(ddcrew_c41006_r) |
| 1394 | 1383 | AM_RANGE(0xC41006, 0xC41007) AM_READ(ddcrew_c41006_r) |
| 1395 | 1384 | |
| 1396 | | |
| 1397 | | |
| 1398 | | AM_RANGE(0xC44000, 0xC44001) AM_WRITENOP |
| 1399 | | |
| 1400 | 1385 | AM_RANGE(0xc46600, 0xc46601) AM_WRITE(sys18_refreshenable_w) |
| 1401 | | |
| 1402 | | AM_RANGE(0xC46038, 0xC4603f) AM_WRITE(ddcrewbl_spritebank_w) // ok |
| 1403 | | |
| 1404 | | AM_RANGE(0xC46000, 0xC46001) AM_WRITENOP |
| 1405 | | AM_RANGE(0xC46010, 0xC46011) AM_WRITENOP |
| 1406 | | AM_RANGE(0xC46020, 0xC46021) AM_WRITENOP |
| 1407 | | |
| 1408 | | AM_RANGE(0xC46040, 0xC46041) AM_WRITENOP |
| 1409 | | AM_RANGE(0xC46050, 0xC46051) AM_WRITENOP |
| 1410 | | |
| 1411 | | AM_RANGE(0xC46060, 0xC46061) AM_WRITENOP |
| 1412 | | AM_RANGE(0xC46062, 0xC46063) AM_WRITENOP |
| 1413 | | AM_RANGE(0xC46064, 0xC46065) AM_WRITENOP |
| 1414 | | |
| 1415 | | AM_RANGE(0xC46070, 0xC46071) AM_WRITENOP |
| 1416 | | |
| 1417 | | AM_RANGE(0xffc000, 0xffffff) AM_RAM // ok |
| 1386 | AM_RANGE(0xffc000, 0xffffff) AM_RAM |
| 1418 | 1387 | ADDRESS_MAP_END |
| 1419 | 1388 | |
| 1420 | 1389 | /************************************* |
| r253698 | r253699 | |
| 2503 | 2472 | MACHINE_CONFIG_END |
| 2504 | 2473 | |
| 2505 | 2474 | |
| 2506 | | MACHINE_RESET_MEMBER(segas1x_bootleg_state,ddcrewbl) |
| 2507 | | { |
| 2508 | | // set up the initial banks for this game |
| 2509 | | // because it doesn't appear to actually program banks 0-3. |
| 2510 | | for (int i = 0; i < 4; i++) |
| 2511 | | { |
| 2512 | | m_sprites->set_bank((i)* 2 + 0, i * 2 + 0); |
| 2513 | | m_sprites->set_bank((i)* 2 + 1, i * 2 + 1); |
| 2514 | | } |
| 2515 | | } |
| 2516 | | |
| 2517 | | |
| 2518 | 2475 | static MACHINE_CONFIG_START( ddcrewbl, segas1x_bootleg_state ) |
| 2519 | 2476 | |
| 2520 | 2477 | /* basic machine hardware */ |
| r253698 | r253699 | |
| 2537 | 2494 | MCFG_VIDEO_START_OVERRIDE(segas1x_bootleg_state,system18old) |
| 2538 | 2495 | |
| 2539 | 2496 | MCFG_BOOTLEG_SYS16B_SPRITES_ADD("sprites") |
| 2540 | | MCFG_BOOTLEG_SYS16B_SPRITES_XORIGIN(189-124) |
| 2497 | MCFG_BOOTLEG_SYS16B_SPRITES_XORIGIN(189-107) |
| 2541 | 2498 | |
| 2542 | | MCFG_MACHINE_RESET_OVERRIDE(segas1x_bootleg_state,ddcrewbl) |
| 2543 | | |
| 2544 | 2499 | MACHINE_CONFIG_END |
| 2545 | 2500 | |
| 2546 | 2501 | |
| r253698 | r253699 | |
| 3785 | 3740 | DRIVER_INIT_MEMBER(segas1x_bootleg_state,ddcrewbl) |
| 3786 | 3741 | { |
| 3787 | 3742 | DRIVER_INIT_CALL(common); |
| 3743 | m_spritebank_type = 0; |
| 3788 | 3744 | } |
| 3789 | 3745 | |
| 3790 | 3746 | |
trunk/src/mame/video/system16.cpp
| r253698 | r253699 | |
| 34 | 34 | |
| 35 | 35 | void segas1x_bootleg_state::setup_system16_bootleg_spritebanking( ) |
| 36 | 36 | { |
| 37 | | if (m_spritebank_type == 0) |
| 37 | if (m_spritebank_type == 1) |
| 38 | 38 | { |
| 39 | static const UINT8 default_banklist[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; |
| 40 | int i; |
| 41 | for (i = 0; i < 16; i++) |
| 42 | m_sprites->set_bank(i, default_banklist[i]); |
| 43 | } |
| 44 | else |
| 45 | { |
| 39 | 46 | static const UINT8 alternate_banklist[] = { 0,255,255,255, 255,255,255,3, 255,255,255,2, 255,1,0,255 }; |
| 40 | 47 | int i; |
| 41 | 48 | for (i = 0; i < 16; i++) |
trunk/src/osd/windows/window.cpp
| r253698 | r253699 | |
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | 1615 | |
| 1616 | static inline int better_mode(int width0, int height0, int width1, int height1, float desired_aspect) |
| 1617 | { |
| 1618 | float aspect0 = (float)width0 / (float)height0; |
| 1619 | float aspect1 = (float)width1 / (float)height1; |
| 1620 | return (fabs(desired_aspect - aspect0) < fabs(desired_aspect - aspect1)) ? 0 : 1; |
| 1621 | } |
| 1616 | 1622 | |
| 1617 | 1623 | //============================================================ |
| 1618 | 1624 | // constrain_to_aspect_ratio |
| r253698 | r253699 | |
| 1626 | 1632 | INT32 propwidth, propheight; |
| 1627 | 1633 | INT32 minwidth, minheight; |
| 1628 | 1634 | INT32 maxwidth, maxheight; |
| 1629 | | INT32 viswidth, visheight; |
| 1630 | 1635 | INT32 adjwidth, adjheight; |
| 1631 | | float pixel_aspect; |
| 1636 | float desired_aspect = 1.0f; |
| 1637 | osd_dim window_dim = get_size(); |
| 1638 | INT32 target_width = window_dim.width(); |
| 1639 | INT32 target_height = window_dim.height(); |
| 1640 | INT32 xscale = 1, yscale = 1; |
| 1641 | int newwidth, newheight; |
| 1632 | 1642 | osd_monitor_info *monitor = winwindow_video_window_monitor(&rect); |
| 1633 | 1643 | |
| 1634 | 1644 | assert(GetCurrentThreadId() == window_threadid); |
| 1635 | 1645 | |
| 1636 | 1646 | // get the pixel aspect ratio for the target monitor |
| 1637 | | pixel_aspect = monitor->aspect(); |
| 1647 | float pixel_aspect = monitor->aspect(); |
| 1638 | 1648 | |
| 1639 | 1649 | // determine the proposed width/height |
| 1640 | 1650 | propwidth = rect.width() - extrawidth; |
| r253698 | r253699 | |
| 1662 | 1672 | // get the minimum width/height for the current layout |
| 1663 | 1673 | m_target->compute_minimum_size(minwidth, minheight); |
| 1664 | 1674 | |
| 1675 | // compute the appropriate visible area if we're trying to keepaspect |
| 1676 | if (video_config.keepaspect) |
| 1677 | { |
| 1678 | // make sure the monitor is up-to-date |
| 1679 | m_target->compute_visible_area(target_width, target_height, m_monitor->aspect(), m_target->orientation(), target_width, target_height); |
| 1680 | desired_aspect = (float)target_width / (float)target_height; |
| 1681 | } |
| 1682 | |
| 1683 | // non-integer scaling - often gives more pleasing results in full screen |
| 1684 | if (!video_config.fullstretch) |
| 1685 | { |
| 1686 | // compute maximum integral scaling to fit the window |
| 1687 | xscale = (target_width + 2) / newwidth; |
| 1688 | yscale = (target_height + 2) / newheight; |
| 1689 | |
| 1690 | // try a little harder to keep the aspect ratio if desired |
| 1691 | if (video_config.keepaspect) |
| 1692 | { |
| 1693 | // if we could stretch more in the X direction, and that makes a better fit, bump the xscale |
| 1694 | while (newwidth * (xscale + 1) <= window_dim.width() && |
| 1695 | better_mode(newwidth * xscale, newheight * yscale, newwidth * (xscale + 1), newheight * yscale, desired_aspect)) |
| 1696 | xscale++; |
| 1697 | |
| 1698 | // if we could stretch more in the Y direction, and that makes a better fit, bump the yscale |
| 1699 | while (newheight * (yscale + 1) <= window_dim.height() && |
| 1700 | better_mode(newwidth * xscale, newheight * yscale, newwidth * xscale, newheight * (yscale + 1), desired_aspect)) |
| 1701 | yscale++; |
| 1702 | |
| 1703 | // now that we've maxed out, see if backing off the maximally stretched one makes a better fit |
| 1704 | if (window_dim.width() - newwidth * xscale < window_dim.height() - newheight * yscale) |
| 1705 | { |
| 1706 | while (better_mode(newwidth * xscale, newheight * yscale, newwidth * (xscale - 1), newheight * yscale, desired_aspect) && (xscale >= 0)) |
| 1707 | xscale--; |
| 1708 | } |
| 1709 | else |
| 1710 | { |
| 1711 | while (better_mode(newwidth * xscale, newheight * yscale, newwidth * xscale, newheight * (yscale - 1), desired_aspect) && (yscale >= 0)) |
| 1712 | yscale--; |
| 1713 | } |
| 1714 | } |
| 1715 | |
| 1716 | // ensure at least a scale factor of 1 |
| 1717 | if (xscale <= 0) xscale = 1; |
| 1718 | if (yscale <= 0) yscale = 1; |
| 1719 | |
| 1720 | // apply the final scale |
| 1721 | newwidth *= xscale; |
| 1722 | newheight *= yscale; |
| 1723 | } |
| 1724 | else |
| 1725 | { |
| 1726 | newwidth = target_width; |
| 1727 | newheight = target_height; |
| 1728 | } |
| 1729 | |
| 1665 | 1730 | // clamp against the absolute minimum |
| 1666 | 1731 | propwidth = MAX(propwidth, MIN_WINDOW_DIM); |
| 1667 | 1732 | propheight = MAX(propheight, MIN_WINDOW_DIM); |
| r253698 | r253699 | |
| 1692 | 1757 | propwidth = MIN(propwidth, maxwidth); |
| 1693 | 1758 | propheight = MIN(propheight, maxheight); |
| 1694 | 1759 | |
| 1695 | | // compute the visible area based on the proposed rectangle |
| 1696 | | m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), viswidth, visheight); |
| 1697 | | |
| 1698 | 1760 | // compute the adjustments we need to make |
| 1699 | | adjwidth = (viswidth + extrawidth) - rect.width(); |
| 1700 | | adjheight = (visheight + extraheight) - rect.height(); |
| 1761 | adjwidth = (propwidth + extrawidth) - rect.width(); |
| 1762 | adjheight = (propheight + extraheight) - rect.height(); |
| 1701 | 1763 | |
| 1702 | 1764 | // based on which corner we're adjusting, constrain in different ways |
| 1703 | 1765 | osd_rect ret(rect); |
| r253698 | r253699 | |
| 1724 | 1786 | ret = rect.move_by(0, -adjheight).resize(rect.width() + adjwidth, rect.height() + adjheight); |
| 1725 | 1787 | break; |
| 1726 | 1788 | } |
| 1789 | |
| 1727 | 1790 | return ret; |
| 1728 | 1791 | } |
| 1729 | 1792 | |