Previous 199869 Revisions Next

r41745 Sunday 15th November, 2015 at 23:31:47 UTC by Ryan Holtz
Remove this==NULL comps, nw
[/branches/code_cleanup/src/devices/sound]sn76477.cpp sn76477.h
[/branches/code_cleanup/src/emu]device.cpp device.h memory.h screen.h

branches/code_cleanup/src/devices/sound/sn76477.cpp
r250256r250257
6868
6969#define LOG(n,x) do { if (VERBOSE >= (n)) logerror x; } while (0)
7070
71#define CHECK_CHIP_NUM                  assert(this != NULL)
72#define CHECK_CHIP_NUM_AND_BOOLEAN      CHECK_CHIP_NUM; assert((state & 0x01) == state)
73#define CHECK_CHIP_NUM_AND_POSITIVE     CHECK_CHIP_NUM; assert(data >= 0.0)
74#define CHECK_CHIP_NUM_AND_VOLTAGE      CHECK_CHIP_NUM; assert((data >= 0.0) && (data <= 5.0))
75#define CHECK_CHIP_NUM_AND_CAP_VOLTAGE  CHECK_CHIP_NUM; assert(((data >= 0.0) && (data <= 5.0)) || (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT))
71#define CHECK_BOOLEAN      assert((state & 0x01) == state)
72#define CHECK_POSITIVE     assert(data >= 0.0)
73#define CHECK_VOLTAGE      assert((data >= 0.0) && (data <= 5.0))
74#define CHECK_CAP_VOLTAGE  assert(((data >= 0.0) && (data <= 5.0)) || (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT))
7675
77
78
7976/*****************************************************************************
8077 *
81 *  Test Mode
82 *
83 *  in test mode, calls by the driver to
84 *  the input setter functions are ignored.
85 *  Interface values can be set in device_start
86 *  to any desired test value.
87 *  Use the space bar to enable/disable the chip.
88 *
89 *****************************************************************************/
90
91#define TEST_MODE   0
92
93/*****************************************************************************
94 *
9578 *  Constants
9679 *
9780 *****************************************************************************/
r250256r250257
225208   intialize_noise();
226209
227210   // set up mixer and envelope modes, based on interface values
228   _SN76477_mixer_a_w(m_mixer_a);
229   _SN76477_mixer_b_w(m_mixer_b);
230   _SN76477_mixer_c_w(m_mixer_c);
231   _SN76477_envelope_1_w(m_envelope_1);
232   _SN76477_envelope_2_w(m_envelope_2);
211   mixer_a_w(m_mixer_a);
212   mixer_b_w(m_mixer_b);
213   mixer_c_w(m_mixer_c);
214   envelope_1_w(m_envelope_1);
215   envelope_2_w(m_envelope_2);
233216
234217   m_one_shot_cap_voltage = ONE_SHOT_CAP_VOLTAGE_MIN;
235218   m_slf_cap_voltage = SLF_CAP_VOLTAGE_MIN;
r250256r250257
958941 *
959942 *****************************************************************************/
960943
961void sn76477_device::_SN76477_enable_w(UINT32 data)
944WRITE_LINE_MEMBER(sn76477_device::enable_w)
962945{
963   m_enable = data;
946   CHECK_BOOLEAN;
964947
965      /* if falling edge */
966   if (!m_enable)
948   if (state != m_enable)
967949   {
968      /* start the attack phase */
969      m_attack_decay_cap_voltage = AD_CAP_VOLTAGE_MIN;
950      m_channel->update();
970951
971      /* one-shot runs regardless of envelope mode */
972      m_one_shot_running_ff = 1;
973   }
974}
952       m_enable = state;
975953
954          /* if falling edge */
955       if (!m_enable)
956       {
957          /* start the attack phase */
958          m_attack_decay_cap_voltage = AD_CAP_VOLTAGE_MIN;
976959
977void sn76477_device::SN76477_test_enable_w(UINT32 data)
978{
979   if (data != m_enable)
980   {
981      m_channel->update();
960          /* one-shot runs regardless of envelope mode */
961          m_one_shot_running_ff = 1;
962       }
982963
983      _SN76477_enable_w(data);
984
985964      log_enable_line();
986965   }
987966}
988967
989968
990WRITE_LINE_MEMBER( sn76477_device::enable_w )
991{
992#if TEST_MODE == 0
993   CHECK_CHIP_NUM_AND_BOOLEAN;
994969
995   SN76477_test_enable_w(state);
996#endif
997}
998
999
1000
1001970/*****************************************************************************
1002971 *
1003972 *  Set mixer select inputs
1004973 *
1005974 *****************************************************************************/
1006975
1007void sn76477_device::_SN76477_mixer_a_w(UINT32 data)
1008{
1009   m_mixer_mode = (m_mixer_mode & ~0x01) | (data << 0);
1010}
1011
1012
1013976WRITE_LINE_MEMBER( sn76477_device::mixer_a_w )
1014977{
1015#if TEST_MODE == 0
1016   CHECK_CHIP_NUM_AND_BOOLEAN;
978   CHECK_BOOLEAN;
1017979
1018980   if (state != ((m_mixer_mode >> 0) & 0x01))
1019981   {
1020982      m_channel->update();
1021983
1022      _SN76477_mixer_a_w(state);
984      m_mixer_mode = (m_mixer_mode & ~0x01) | state;
1023985
1024986      log_mixer_mode();
1025987   }
1026#endif
1027988}
1028989
1029
1030void sn76477_device::_SN76477_mixer_b_w(UINT32 data)
1031{
1032   m_mixer_mode = (m_mixer_mode & ~0x02) | (data << 1);
1033}
1034
1035
1036990WRITE_LINE_MEMBER( sn76477_device::mixer_b_w )
1037991{
1038#if TEST_MODE == 0
1039   CHECK_CHIP_NUM_AND_BOOLEAN;
992   CHECK_BOOLEAN;
1040993
1041994   if (state != ((m_mixer_mode >> 1) & 0x01))
1042995   {
1043996      m_channel->update();
1044997
1045      _SN76477_mixer_b_w(state);
998      m_mixer_mode = (m_mixer_mode & ~0x02) | (state << 1);
1046999
10471000      log_mixer_mode();
10481001   }
1049#endif
10501002}
10511003
1052
1053void sn76477_device::_SN76477_mixer_c_w(UINT32 data)
1054{
1055   m_mixer_mode = (m_mixer_mode & ~0x04) | (data << 2);
1056}
1057
1058
10591004WRITE_LINE_MEMBER( sn76477_device::mixer_c_w )
10601005{
1061#if TEST_MODE == 0
1062   CHECK_CHIP_NUM_AND_BOOLEAN;
1006   CHECK_BOOLEAN;
10631007
10641008   if (state != ((m_mixer_mode >> 2) & 0x01))
10651009   {
10661010      m_channel->update();
10671011
1068      _SN76477_mixer_c_w(state);
1012      m_mixer_mode = (m_mixer_mode & ~0x04) | (state << 2);
10691013
10701014      log_mixer_mode();
10711015   }
1072#endif
10731016}
10741017
1075
1076
10771018/*****************************************************************************
10781019 *
10791020 *  Set envelope select inputs
10801021 *
10811022 *****************************************************************************/
10821023
1083void sn76477_device::_SN76477_envelope_1_w(UINT32 data)
1084{
1085   m_envelope_mode = (m_envelope_mode & ~0x01) | (data << 0);
1086}
1087
1088
10891024WRITE_LINE_MEMBER( sn76477_device::envelope_1_w )
10901025{
1091#if TEST_MODE == 0
1092   CHECK_CHIP_NUM_AND_BOOLEAN;
1026   CHECK_BOOLEAN;
10931027
10941028   if (state != ((m_envelope_mode >> 0) & 0x01))
10951029   {
10961030      m_channel->update();
10971031
1098      _SN76477_envelope_1_w(state);
1032      m_envelope_mode = (m_envelope_mode & ~0x01) | state;
10991033
11001034      log_envelope_mode();
11011035   }
1102#endif
11031036}
11041037
1105
1106void sn76477_device::_SN76477_envelope_2_w(UINT32 data)
1107{
1108   m_envelope_mode = (m_envelope_mode & ~0x02) | (data << 1);
1109}
1110
1111
11121038WRITE_LINE_MEMBER( sn76477_device::envelope_2_w )
11131039{
1114#if TEST_MODE == 0
1115   CHECK_CHIP_NUM_AND_BOOLEAN;
1040   CHECK_BOOLEAN;
11161041
11171042   if (state != ((m_envelope_mode >> 1) & 0x01))
11181043   {
11191044      m_channel->update();
11201045
1121      _SN76477_envelope_2_w(state);
1046      m_envelope_mode = (m_envelope_mode & ~0x02) | (state << 1);
11221047
11231048      log_envelope_mode();
11241049   }
1125#endif
11261050}
11271051
1128
1129
11301052/*****************************************************************************
11311053 *
11321054 *  Set VCO select input
11331055 *
11341056 *****************************************************************************/
11351057
1136void sn76477_device::_SN76477_vco_w(UINT32 data)
1137{
1138   m_vco_mode = data;
1139}
1140
1141
11421058WRITE_LINE_MEMBER( sn76477_device::vco_w )
11431059{
1144#if TEST_MODE == 0
1145   CHECK_CHIP_NUM_AND_BOOLEAN;
1060   CHECK_BOOLEAN;
11461061
11471062   if (state != m_vco_mode)
11481063   {
11491064      m_channel->update();
11501065
1151      _SN76477_vco_w(state);
1066      m_vco_mode = state;
11521067
11531068      log_vco_mode();
11541069   }
1155#endif
11561070}
11571071
1158
1159
11601072/*****************************************************************************
11611073 *
11621074 *  Set one-shot resistor
11631075 *
11641076 *****************************************************************************/
11651077
1166void sn76477_device::_SN76477_one_shot_res_w(double data)
1167{
1168   m_one_shot_res = data;
1169}
1170
1171
11721078void sn76477_device::one_shot_res_w(double data)
11731079{
1174#if TEST_MODE == 0
1175   CHECK_CHIP_NUM_AND_POSITIVE;
1080   CHECK_POSITIVE;
11761081
11771082   if (data != m_one_shot_res)
11781083   {
11791084      m_channel->update();
11801085
1181      _SN76477_one_shot_res_w(data);
1086      m_one_shot_res = data;
11821087
11831088      log_one_shot_time();
11841089   }
1185#endif
11861090}
11871091
1188
1189
11901092/*****************************************************************************
11911093 *
11921094 *  Set one-shot capacitor
11931095 *
11941096 *****************************************************************************/
11951097
1196void sn76477_device::_SN76477_one_shot_cap_w(double data)
1197{
1198   m_one_shot_cap = data;
1199}
1200
1201
12021098void sn76477_device::one_shot_cap_w(double data)
12031099{
1204#if TEST_MODE == 0
1205   CHECK_CHIP_NUM_AND_POSITIVE;
1100   CHECK_POSITIVE;
12061101
12071102   if (data != m_one_shot_cap)
12081103   {
12091104      m_channel->update();
12101105
1211      _SN76477_one_shot_cap_w(data);
1106      m_one_shot_cap = data;
12121107
12131108      log_one_shot_time();
12141109   }
1215#endif
12161110}
12171111
1218
1219
12201112/*****************************************************************************
12211113 *
12221114 *  Set the voltage on the one-shot capacitor
r250256r250257
12251117
12261118void sn76477_device::one_shot_cap_voltage_w(double data)
12271119{
1228#if TEST_MODE == 0
1229   CHECK_CHIP_NUM_AND_CAP_VOLTAGE;
1120   CHECK_CAP_VOLTAGE;
12301121
12311122   if (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT)
12321123   {
r250256r250257
12531144         log_one_shot_time();
12541145      }
12551146   }
1256#endif
12571147}
12581148
1259
1260
12611149/*****************************************************************************
12621150 *
12631151 *  Set SLF resistor
12641152 *
12651153 *****************************************************************************/
12661154
1267void sn76477_device::_SN76477_slf_res_w(double data)
1268{
1269   m_slf_res = data;
1270}
1271
1272
12731155void sn76477_device::slf_res_w(double data)
12741156{
1275#if TEST_MODE == 0
1276   CHECK_CHIP_NUM_AND_POSITIVE;
1157   CHECK_POSITIVE;
12771158
12781159   if (data != m_slf_res)
12791160   {
12801161      m_channel->update();
12811162
1282      _SN76477_slf_res_w(data);
1163      m_slf_res = data;
12831164
12841165      log_slf_freq();
12851166   }
1286#endif
12871167}
12881168
1289
1290
12911169/*****************************************************************************
12921170 *
12931171 *  Set SLF capacitor
12941172 *
12951173 *****************************************************************************/
12961174
1297void sn76477_device::_SN76477_slf_cap_w(double data)
1298{
1299   m_slf_cap = data;
1300}
1301
1302
13031175void sn76477_device::slf_cap_w(double data)
13041176{
1305#if TEST_MODE == 0
1306   CHECK_CHIP_NUM_AND_POSITIVE;
1177   CHECK_POSITIVE;
13071178
13081179   if (data != m_slf_cap)
13091180   {
13101181      m_channel->update();
13111182
1312      _SN76477_slf_cap_w(data);
1183      m_slf_cap = data;
13131184
13141185      log_slf_freq();
13151186   }
1316#endif
13171187}
13181188
1319
1320
13211189/*****************************************************************************
13221190 *
13231191 *  Set the voltage on the SLF capacitor
r250256r250257
13281196
13291197void sn76477_device::slf_cap_voltage_w(double data)
13301198{
1331#if TEST_MODE == 0
1332   CHECK_CHIP_NUM_AND_CAP_VOLTAGE;
1199   CHECK_CAP_VOLTAGE;
13331200
13341201   if (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT)
13351202   {
r250256r250257
13561223         log_slf_freq();
13571224      }
13581225   }
1359#endif
13601226}
13611227
1362
1363
13641228/*****************************************************************************
13651229 *
13661230 *  Set VCO resistor
13671231 *
13681232 *****************************************************************************/
13691233
1370void sn76477_device::_SN76477_vco_res_w(double data)
1371{
1372   m_vco_res = data;
1373}
1374
1375
13761234void sn76477_device::vco_res_w(double data)
13771235{
1378#if TEST_MODE == 0
1379   CHECK_CHIP_NUM_AND_POSITIVE;
1236   CHECK_POSITIVE;
13801237
13811238   if (data != m_vco_res)
13821239   {
13831240      m_channel->update();
13841241
1385      _SN76477_vco_res_w(data);
1242      m_vco_res = data;
13861243
13871244      log_vco_freq();
13881245   }
1389#endif
13901246}
13911247
1392
1393
13941248/*****************************************************************************
13951249 *
13961250 *  Set VCO capacitor
13971251 *
13981252 *****************************************************************************/
13991253
1400void sn76477_device::_SN76477_vco_cap_w(double data)
1401{
1402   m_vco_cap = data;
1403}
1404
1405
14061254void sn76477_device::vco_cap_w(double data)
14071255{
1408#if TEST_MODE == 0
1409   CHECK_CHIP_NUM_AND_POSITIVE;
1256   CHECK_POSITIVE;
14101257
14111258   if (data != m_vco_cap)
14121259   {
14131260      m_channel->update();
14141261
1415      _SN76477_vco_cap_w(data);
1262      m_vco_cap = data;
14161263
14171264      log_vco_freq();
14181265   }
1419#endif
14201266}
14211267
1422
1423
14241268/*****************************************************************************
14251269 *
14261270 *  Set the voltage on the VCO capacitor
r250256r250257
14291273
14301274void sn76477_device::vco_cap_voltage_w(double data)
14311275{
1432#if TEST_MODE == 0
1433   CHECK_CHIP_NUM_AND_CAP_VOLTAGE;
1276   CHECK_CAP_VOLTAGE;
14341277
14351278   if (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT)
14361279   {
r250256r250257
14571300         log_vco_freq();
14581301      }
14591302   }
1460#endif
14611303}
14621304
1463
1464
14651305/*****************************************************************************
14661306 *
14671307 *  Set VCO voltage
14681308 *
14691309 *****************************************************************************/
14701310
1471void sn76477_device::_SN76477_vco_voltage_w(double data)
1472{
1473   m_vco_voltage = data;
1474}
1475
1476
14771311void sn76477_device::vco_voltage_w(double data)
14781312{
1479#if TEST_MODE == 0
1480   CHECK_CHIP_NUM_AND_VOLTAGE;
1313   CHECK_VOLTAGE;
14811314
14821315   if (data != m_vco_voltage)
14831316   {
14841317      m_channel->update();
14851318
1486      _SN76477_vco_voltage_w(data);
1319      m_vco_voltage = data;
14871320
14881321      log_vco_ext_voltage();
14891322      log_vco_duty_cycle();
14901323   }
1491#endif
14921324}
14931325
1494
1495
14961326/*****************************************************************************
14971327 *
14981328 *  Set pitch voltage
14991329 *
15001330 *****************************************************************************/
15011331
1502void sn76477_device::_SN76477_pitch_voltage_w(double data)
1503{
1504   m_pitch_voltage = data;
1505}
1506
1507
15081332void sn76477_device::pitch_voltage_w(double data)
15091333{
1510#if TEST_MODE == 0
1511   CHECK_CHIP_NUM_AND_VOLTAGE;
1334   CHECK_VOLTAGE;
15121335
15131336   if (data != m_pitch_voltage)
15141337   {
15151338      m_channel->update();
15161339
1517      _SN76477_pitch_voltage_w(data);
1340      m_pitch_voltage = data;
15181341
15191342      log_vco_pitch_voltage();
15201343      log_vco_duty_cycle();
15211344   }
1522#endif
15231345}
15241346
1525
1526
15271347/*****************************************************************************
15281348 *
15291349 *  Set noise external clock
r250256r250257
15321352
15331353WRITE_LINE_MEMBER( sn76477_device::noise_clock_w )
15341354{
1535#if TEST_MODE == 0
1536   CHECK_CHIP_NUM_AND_BOOLEAN;
1355   CHECK_BOOLEAN;
15371356
15381357   if (state != m_noise_clock)
15391358   {
r250256r250257
15481367         m_real_noise_bit_ff = generate_next_real_noise_bit();
15491368      }
15501369   }
1551#endif
15521370}
15531371
1554
1555
15561372/*****************************************************************************
15571373 *
15581374 *  Set noise clock resistor
15591375 *
15601376 *****************************************************************************/
15611377
1562void sn76477_device::_SN76477_noise_clock_res_w(double data)
1563{
1564   if (data == 0)
1565   {
1566      m_noise_clock_ext = 1;
1567   }
1568   else
1569   {
1570      m_noise_clock_ext = 0;
1571
1572      m_noise_clock_res = data;
1573   }
1574}
1575
1576
15771378void sn76477_device::noise_clock_res_w(double data)
15781379{
1579#if TEST_MODE == 0
1580   CHECK_CHIP_NUM_AND_POSITIVE;
1380   CHECK_POSITIVE;
15811381
15821382   if (((data == 0) && !m_noise_clock_ext) ||
15831383      ((data != 0) && (data != m_noise_clock_res)))
15841384   {
15851385      m_channel->update();
15861386
1587      _SN76477_noise_clock_res_w(data);
1387       if (data == 0)
1388       {
1389          m_noise_clock_ext = 1;
1390       }
1391       else
1392       {
1393          m_noise_clock_ext = 0;
15881394
1395          m_noise_clock_res = data;
1396       }
1397
15891398      log_noise_gen_freq();
15901399   }
1591#endif
15921400}
15931401
1594
1595
15961402/*****************************************************************************
15971403 *
15981404 *  Set noise filter resistor
15991405 *
16001406 *****************************************************************************/
16011407
1602void sn76477_device::_SN76477_noise_filter_res_w(double data)
1603{
1604   m_noise_filter_res = data;
1605}
1606
1607
16081408void sn76477_device::noise_filter_res_w(double data)
16091409{
1610#if TEST_MODE == 0
1611   CHECK_CHIP_NUM_AND_POSITIVE;
1410   CHECK_POSITIVE;
16121411
16131412   if (data != m_noise_filter_res)
16141413   {
16151414      m_channel->update();
16161415
1617      _SN76477_noise_filter_res_w(data);
1416      m_noise_filter_res = data;
16181417
16191418      log_noise_filter_freq();
16201419   }
1621#endif
16221420}
16231421
1624
1625
16261422/*****************************************************************************
16271423 *
16281424 *  Set noise filter capacitor
16291425 *
16301426 *****************************************************************************/
16311427
1632void sn76477_device::_SN76477_noise_filter_cap_w(double data)
1633{
1634   m_noise_filter_cap = data;
1635}
1636
1637
16381428void sn76477_device::noise_filter_cap_w(double data)
16391429{
1640#if TEST_MODE == 0
1641   CHECK_CHIP_NUM_AND_POSITIVE;
1430   CHECK_POSITIVE;
16421431
16431432   if (data != m_noise_filter_cap)
16441433   {
16451434      m_channel->update();
16461435
1647      _SN76477_noise_filter_cap_w(data);
1436      m_noise_filter_cap = data;
16481437
16491438      log_noise_filter_freq();
16501439   }
1651#endif
16521440}
16531441
1654
1655
16561442/*****************************************************************************
16571443 *
16581444 *  Set the voltage on the noise filter capacitor
r250256r250257
16611447
16621448void sn76477_device::noise_filter_cap_voltage_w(double data)
16631449{
1664#if TEST_MODE == 0
1665   CHECK_CHIP_NUM_AND_CAP_VOLTAGE;
1450   CHECK_CAP_VOLTAGE;
16661451
16671452   if (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT)
16681453   {
r250256r250257
16891474         log_noise_filter_freq();
16901475      }
16911476   }
1692#endif
16931477}
16941478
1695
1696
16971479/*****************************************************************************
16981480 *
16991481 *  Set attack resistor
17001482 *
17011483 *****************************************************************************/
17021484
1703void sn76477_device::_SN76477_attack_res_w(double data)
1704{
1705   m_attack_res = data;
1706}
1707
1708
17091485void sn76477_device::attack_res_w(double data)
17101486{
1711#if TEST_MODE == 0
1712   CHECK_CHIP_NUM_AND_POSITIVE;
1487   CHECK_POSITIVE;
17131488
17141489   if (data != m_attack_res)
17151490   {
17161491      m_channel->update();
17171492
1718      _SN76477_attack_res_w(data);
1493      m_attack_res = data;
17191494
17201495      log_attack_time();
17211496   }
1722#endif
17231497}
17241498
1725
1726
17271499/*****************************************************************************
17281500 *
17291501 *  Set decay resistor
17301502 *
17311503 *****************************************************************************/
17321504
1733void sn76477_device::_SN76477_decay_res_w(double data)
1734{
1735   m_decay_res = data;
1736}
1737
1738
17391505void sn76477_device::decay_res_w(double data)
17401506{
1741#if TEST_MODE == 0
1742   CHECK_CHIP_NUM_AND_POSITIVE;
1507   CHECK_POSITIVE;
17431508
17441509   if (data != m_decay_res)
17451510   {
17461511      m_channel->update();
17471512
1748      _SN76477_decay_res_w(data);
1513      m_decay_res = data;
17491514
17501515      log_decay_time();
17511516   }
1752#endif
17531517}
17541518
1755
1756
17571519/*****************************************************************************
17581520 *
17591521 *  Set attack/decay capacitor
17601522 *
17611523 *****************************************************************************/
17621524
1763void sn76477_device::_SN76477_attack_decay_cap_w(double data)
1764{
1765   m_attack_decay_cap = data;
1766}
1767
1768
17691525void sn76477_device::attack_decay_cap_w(double data)
17701526{
1771#if TEST_MODE == 0
1772   CHECK_CHIP_NUM_AND_POSITIVE;
1527   CHECK_POSITIVE;
17731528
17741529   if (data != m_attack_decay_cap)
17751530   {
17761531      m_channel->update();
17771532
1778      _SN76477_attack_decay_cap_w(data);
1533      m_attack_decay_cap = data;
17791534
17801535      log_attack_time();
17811536      log_decay_time();
17821537   }
1783#endif
17841538}
17851539
1786
1787
17881540/*****************************************************************************
17891541 *
17901542 *  Set the voltage on the attack/decay capacitor
r250256r250257
17931545
17941546void sn76477_device::attack_decay_cap_voltage_w(double data)
17951547{
1796#if TEST_MODE == 0
1797   CHECK_CHIP_NUM_AND_CAP_VOLTAGE;
1548   CHECK_CAP_VOLTAGE;
17981549
17991550   if (data == SN76477_EXTERNAL_VOLTAGE_DISCONNECT)
18001551   {
r250256r250257
18231574         log_decay_time();
18241575      }
18251576   }
1826#endif
18271577}
18281578
1829
1830
18311579/*****************************************************************************
18321580 *
18331581 *  Set amplitude resistor
18341582 *
18351583 *****************************************************************************/
18361584
1837void sn76477_device::_SN76477_amplitude_res_w(double data)
1838{
1839   m_amplitude_res = data;
1840}
1841
1842
18431585void sn76477_device::amplitude_res_w(double data)
18441586{
1845#if TEST_MODE == 0
1846   CHECK_CHIP_NUM_AND_POSITIVE;
1587   CHECK_POSITIVE;
18471588
18481589   if (data != m_amplitude_res)
18491590   {
18501591      m_channel->update();
18511592
1852      _SN76477_amplitude_res_w(data);
1593      m_amplitude_res = data;
18531594
18541595      log_voltage_out();
18551596   }
1856#endif
18571597}
18581598
1859
1860
18611599/*****************************************************************************
18621600 *
18631601 *  Set feedback resistor
18641602 *
18651603 *****************************************************************************/
18661604
1867void sn76477_device::_SN76477_feedback_res_w(double data)
1868{
1869   m_feedback_res = data;
1870}
1871
1872
18731605void sn76477_device::feedback_res_w(double data)
18741606{
1875#if TEST_MODE == 0
1876   CHECK_CHIP_NUM_AND_POSITIVE;
1607   CHECK_POSITIVE;
18771608
18781609   if (data != m_feedback_res)
18791610   {
18801611      m_channel->update();
18811612
1882      _SN76477_feedback_res_w(data);
1613      m_feedback_res = data;
18831614
18841615      log_voltage_out();
18851616   }
1886#endif
18871617}
18881618
1889
18901619/*****************************************************************************
18911620 *
18921621 *  State saving
r250256r250257
19741703
19751704   stream_sample_t *buffer = outputs[0];
19761705
1977
1978#if TEST_MODE
1979   static int recursing = 0;   /* we need to prevent recursion since enable_w calls machine().input().code_pressed_once(KEYCODE_SPACE->update */
1980
1981   if () && !recursing)
1982   {
1983      recursing = 1;
1984
1985      machine().sound().system_enable();
1986      SN76477_test_enable_w(!m_enable);
1987   }
1988
1989   recursing = 0;
1990#endif
1991
1992   /* compute charging values, doing it here ensures that we always use the latest values */
1706    /* compute charging values, doing it here ensures that we always use the latest values */
19931707   one_shot_cap_charging_step = compute_one_shot_cap_charging_rate() / m_our_sample_rate;
19941708   one_shot_cap_discharging_step = compute_one_shot_cap_discharging_rate() / m_our_sample_rate;
19951709
branches/code_cleanup/src/devices/sound/sn76477.h
r250256r250257
304304   inline UINT32 generate_next_real_noise_bit();
305305
306306   void state_save_register();
307
308   void _SN76477_enable_w(UINT32 data);
309   void _SN76477_vco_w(UINT32 data);
310   void _SN76477_mixer_a_w(UINT32 data);
311   void _SN76477_mixer_b_w(UINT32 data);
312   void _SN76477_mixer_c_w(UINT32 data);
313   void _SN76477_envelope_1_w(UINT32 data);
314   void _SN76477_envelope_2_w(UINT32 data);
315   void _SN76477_one_shot_res_w(double data);
316   void _SN76477_one_shot_cap_w(double data);
317   void _SN76477_slf_res_w(double data);
318   void _SN76477_slf_cap_w(double data);
319   void _SN76477_vco_res_w(double data);
320   void _SN76477_vco_cap_w(double data);
321   void _SN76477_vco_voltage_w(double data);
322   void _SN76477_noise_clock_res_w(double data);
323   void _SN76477_noise_filter_res_w(double data);
324   void _SN76477_noise_filter_cap_w(double data);
325   void _SN76477_decay_res_w(double data);
326   void _SN76477_attack_res_w(double data);
327   void _SN76477_attack_decay_cap_w(double data);
328   void _SN76477_amplitude_res_w(double data);
329   void _SN76477_feedback_res_w(double data);
330   void _SN76477_pitch_voltage_w(double data);
331   void SN76477_test_enable_w(UINT32 data);
332307};
333308
334309extern const device_type SN76477;
branches/code_cleanup/src/emu/device.cpp
r250256r250257
8484
8585memory_region *device_t::memregion(const char *_tag) const
8686{
87   // safety first
88   if (this == NULL)
89      return NULL;
90
9187   // build a fully-qualified name and look it up
9288   return machine().memory().region(subtag(_tag).c_str());
9389}
r250256r250257
10096
10197memory_share *device_t::memshare(const char *_tag) const
10298{
103   // safety first
104   if (this == NULL)
105      return NULL;
106
10799   // build a fully-qualified name and look it up
108100   return machine().memory().shared(subtag(_tag).c_str());
109101}
r250256r250257
132124
133125ioport_port *device_t::ioport(const char *tag) const
134126{
135   // safety first
136   if (this == NULL)
137      return NULL;
138
139127   // build a fully-qualified name and look it up
140128   return machine().ioport().port(subtag(tag).c_str());
141129}
r250256r250257
148136
149137std::string device_t::parameter(const char *tag) const
150138{
151   // safety first
152   if (this == NULL)
153      return NULL;
154
155139   // build a fully-qualified name and look it up
156140   return machine().parameters().lookup(subtag(tag));
157141}
branches/code_cleanup/src/emu/device.h
r250256r250257
151151   // owned object helpers
152152   device_t *first_subdevice() const { return m_subdevice_list.first(); }
153153   std::string subtag(const char *tag) const;
154   std::string siblingtag(const char *tag) const { return (this != NULL && m_owner != NULL) ? m_owner->subtag(tag) : std::string(tag); }
154   std::string siblingtag(const char *tag) const { return (m_owner != NULL) ? m_owner->subtag(tag) : std::string(tag); }
155155   memory_region *memregion(const char *tag) const;
156156   memory_share *memshare(const char *tag) const;
157157   memory_bank *membank(const char *tag) const;
r250256r250257
589589
590590inline device_t *device_t::subdevice(const char *tag) const
591591{
592   // safety first
593   if (this == NULL)
594      return NULL;
595
596592   // empty string or NULL means this device
597593   if (tag == NULL || *tag == 0)
598594      return const_cast<device_t *>(this);
r250256r250257
610606
611607inline device_t *device_t::siblingdevice(const char *tag) const
612608{
613   // safety first
614   if (this == NULL)
615      return NULL;
616
617609   // empty string or NULL means this device
618610   if (tag == NULL || *tag == 0)
619611      return const_cast<device_t *>(this);
branches/code_cleanup/src/emu/memory.h
r250256r250257
641641
642642   // getters
643643   memory_share *next() const { return m_next; }
644   // NOTE: this being NULL in a C++ member function can lead to undefined behavior.
645   // However, it is relied on throughout MAME, so will remain for now.
646   void *ptr() const { if (this == NULL) return NULL; return m_ptr; }
644   void *ptr() const { return m_ptr; }
647645   size_t bytes() const { return m_bytes; }
648646   endianness_t endianness() const { return m_endianness; }
649647   UINT8 bitwidth() const { return m_bitwidth; }
r250256r250257
682680   // getters
683681   running_machine &machine() const { return m_machine; }
684682   memory_region *next() const { return m_next; }
685   UINT8 *base() { return (this != NULL) ? &m_buffer[0] : NULL; }
686   UINT8 *end() { return (this != NULL) ? base() + m_buffer.size() : NULL; }
687   UINT32 bytes() const { return (this != NULL) ? m_buffer.size() : 0; }
683   UINT8 *base() { return &m_buffer[0]; }
684   UINT8 *end() { return base() + m_buffer.size(); }
685   UINT32 bytes() const { return m_buffer.size(); }
688686   const char *name() const { return m_name.c_str(); }
689687
690688   // flag expansion
branches/code_cleanup/src/emu/screen.h
r250256r250257
216216   attotime time_until_vblank_end() const;
217217   attotime time_until_update() const { return (m_video_attributes & VIDEO_UPDATE_AFTER_VBLANK) ? time_until_vblank_end() : time_until_vblank_start(); }
218218   attotime scan_period() const { return attotime(0, m_scantime); }
219   attotime frame_period() const { return (this == NULL) ? DEFAULT_FRAME_PERIOD : attotime(0, m_frame_period); };
219   attotime frame_period() const { return attotime(0, m_frame_period); }
220220   UINT64 frame_number() const { return m_frame_number; }
221221
222222   // updating


Previous 199869 Revisions Next


© 1997-2024 The MAME Team