less int > 16-bits assumptions

git-svn-id: https://gambatte.svn.sourceforge.net/svnroot/gambatte@110 9dfb2916-2d38-0410-aef4-c5fe6c9ffc24
This commit is contained in:
sinamas 2007-11-27 05:01:13 +00:00
parent 466034d435
commit 546de53beb
6 changed files with 16 additions and 16 deletions

View File

@ -99,7 +99,7 @@ void PSG::resetCounter(const unsigned long newCc, const unsigned long oldCc, con
}
void PSG::fill_buffer(uint16_t *stream, const unsigned samples) {
const unsigned endPos = std::min(bufferPos, 35112U);
const unsigned long endPos = std::min(bufferPos, 35112U);
if (stream && samples && endPos >= samples) {
uint16_t *const streamEnd = stream + samples * 2;
@ -138,7 +138,7 @@ void PSG::fill_buffer(uint16_t *stream, const unsigned samples) {
so2 = (borderSample << 16 & 0xFFFFFFFF) - so2Tmp;
}
const unsigned long nextTotal = ratio - ((1 << 16) - frac);
const unsigned long nextTotal = ratio - ((1ul << 16) - frac);
whole = nextTotal >> 16;
frac = nextTotal & 0xFFFF;
}
@ -149,7 +149,7 @@ void PSG::fill_buffer(uint16_t *stream, const unsigned samples) {
}
void PSG::set_so_volume(const unsigned nr50) {
soVol = (nr50 & 0x7) + 1 << 16 | (nr50 >> 4 & 0x7) + 1;
soVol = (nr50 & 0x7) + 1ul << 16 | (nr50 >> 4 & 0x7) + 1;
}
void PSG::map_so(const unsigned nr51) {

View File

@ -40,7 +40,7 @@ unsigned Channel1::SweepUnit::calcFreq() {
}
void Channel1::SweepUnit::event() {
const unsigned period = nr0 >> 4 & 0x07;
const unsigned long period = nr0 >> 4 & 0x07;
if (period) {
const unsigned freq = calcFreq();
@ -53,7 +53,7 @@ void Channel1::SweepUnit::event() {
counter += period << 14;
} else
counter += 8 << 14;
counter += 8ul << 14;
}
void Channel1::SweepUnit::nr0Change(const unsigned newNr0) {
@ -189,8 +189,8 @@ void Channel1::update(uint32_t *buf, const unsigned long soBaseVol, unsigned lon
const unsigned long endCycles = cycleCounter + cycles;
while (cycleCounter < endCycles) {
const unsigned long out = 15 * 8 * 4 * 0x00010001 +
outBase * ((master && dutyUnit.isHighState()) ? envelopeUnit.getVolume() * 2 - 15 : 0 - 15);
const unsigned long out = 15 * 8 * 4 * 0x00010001ul +
outBase * ((master && dutyUnit.isHighState()) ? envelopeUnit.getVolume() * 2 - 15ul : 0 - 15ul);
unsigned long multiplier = nextEventUnit->getCounter();

View File

@ -104,7 +104,7 @@ void Channel2::update(uint32_t *buf, const unsigned long soBaseVol, unsigned lon
const unsigned long endCycles = cycleCounter + cycles;
while (cycleCounter < endCycles) {
const unsigned long out = outBase * ((master && dutyUnit.isHighState()) ? envelopeUnit.getVolume() * 2 - 15 : 0 - 15);
const unsigned long out = outBase * ((master && dutyUnit.isHighState()) ? envelopeUnit.getVolume() * 2 - 15ul : 0 - 15ul);
unsigned long multiplier = nextEventUnit->getCounter();

View File

@ -96,7 +96,7 @@ void Channel3::init(const unsigned long cc, const bool cgb) {
void Channel3::updateWaveCounter(const unsigned long cc) {
if (cc >= waveCounter) {
const unsigned period = toPeriod(nr3, nr4);
const unsigned periods = (cc - waveCounter) / period;
const unsigned long periods = (cc - waveCounter) / period;
lastReadTime = waveCounter + periods * period;
waveCounter = lastReadTime + period;
@ -115,7 +115,7 @@ void Channel3::update(uint32_t *buf, const unsigned long soBaseVol, unsigned lon
const unsigned long endCycles = cycleCounter + cycles;
while (cycleCounter < endCycles) {
const unsigned long out = outBase * (master ? ((sampleBuf >> (~wavePos << 2 & 4) & 0xF) >> rShift) * 2 - 15 : 0 - 15);
const unsigned long out = outBase * (master ? ((sampleBuf >> (~wavePos << 2 & 4) & 0xF) >> rShift) * 2 - 15ul : 0 - 15ul);
unsigned long multiplier = endCycles;
@ -146,7 +146,7 @@ void Channel3::update(uint32_t *buf, const unsigned long soBaseVol, unsigned lon
}
} else {
if (outBase) {
const unsigned long out = outBase * (0 - 15);
const unsigned long out = outBase * (0 - 15ul);
uint32_t *const bufend = buf + cycles;
while (buf != bufend)

View File

@ -223,7 +223,7 @@ void Channel4::update(uint32_t *buf, const unsigned long soBaseVol, unsigned lon
const unsigned long endCycles = cycleCounter + cycles;
while (cycleCounter < endCycles) {
const unsigned long out = outBase * ((/*master && */lfsr.isHighState()) ? envelopeUnit.getVolume() * 2 - 15 : 0 - 15);
const unsigned long out = outBase * ((/*master && */lfsr.isHighState()) ? envelopeUnit.getVolume() * 2 - 15ul : 0 - 15ul);
unsigned long multiplier = nextEventUnit->getCounter();

View File

@ -21,7 +21,7 @@
EnvelopeUnit::VolOnOffEvent EnvelopeUnit::nullEvent;
void EnvelopeUnit::event() {
const unsigned period = nr2 & 7;
const unsigned long period = nr2 & 7;
if (period) {
unsigned newVol = volume;
@ -41,7 +41,7 @@ void EnvelopeUnit::event() {
} else
counter = COUNTER_DISABLED;
} else
counter += 8 << 15;
counter += 8ul << 15;
}
bool EnvelopeUnit::nr2Change(const unsigned newNr2) {
@ -62,7 +62,7 @@ bool EnvelopeUnit::nr2Change(const unsigned newNr2) {
bool EnvelopeUnit::nr4Init(const unsigned long cc) {
{
unsigned period = nr2 & 7;
unsigned long period = nr2 & 7;
if (!period)
period = 8;
@ -84,7 +84,7 @@ void EnvelopeUnit::reset() {
void EnvelopeUnit::init(const bool ch1, const unsigned long cc) {
volume = 0;
counter = cc - (cc - 0x1000 & 0x7FFF) + 8 * 0x8000;
counter = cc - (cc - 0x1000 & 0x7FFF) + 8ul * 0x8000;
nr2 = 0;
if (ch1) {