Пример #1
0
void Tima::setTac(const unsigned data, const unsigned long cycleCounter, const TimaInterruptRequester timaIrq) {
	if (tac_ ^ data) {
		unsigned long nextIrqEventTime = timaIrq.nextIrqEventTime();
		
		if (tac_ & 0x04) {
			updateIrq(cycleCounter, timaIrq);
			updateTima(cycleCounter);

			lastUpdate_ -= (1u << (timaClock[tac_ & 3] - 1)) + 3;
			tmatime_ -= (1u << (timaClock[tac_ & 3] - 1)) + 3;
			nextIrqEventTime -= (1u << (timaClock[tac_ & 3] - 1)) + 3;
			
			if (cycleCounter >= nextIrqEventTime)
				timaIrq.flagIrq();
			
			updateTima(cycleCounter);

			tmatime_ = DISABLED_TIME;
			nextIrqEventTime = DISABLED_TIME;
		}

		if (data & 4) {
			lastUpdate_ = (cycleCounter >> timaClock[data & 3]) << timaClock[data & 3];
			nextIrqEventTime = lastUpdate_ + ((256u - tima_) << timaClock[data & 3]) + 3;
		}
Пример #2
0
void Tima::setTac(unsigned const data, unsigned long const cc, TimaInterruptRequester timaIrq) {
	if (tac_ ^ data) {
		unsigned long nextIrqEventTime = timaIrq.nextIrqEventTime();

		if (tac_ & 0x04) {
			updateIrq(cc, timaIrq);
			updateTima(cc);

			// FIXME: this looks naive.
			// TODO: more TIMA tests.
			lastUpdate_ -= (1u << (timaClock[tac_ & 3] - 1)) + 3;
			tmatime_ -= (1u << (timaClock[tac_ & 3] - 1)) + 3;
			nextIrqEventTime -= (1u << (timaClock[tac_ & 3] - 1)) + 3;

			if (cc >= nextIrqEventTime)
				timaIrq.flagIrq();

			updateTima(cc);

			tmatime_ = disabled_time;
			nextIrqEventTime = disabled_time;
		}

		if (data & 4) {
			lastUpdate_ = (cc >> timaClock[data & 3]) << timaClock[data & 3];
			nextIrqEventTime = lastUpdate_ + ((256u - tima_) << timaClock[data & 3]) + 3;
		}
Пример #3
0
void Tima::setTma(unsigned const data, unsigned long const cc, TimaInterruptRequester timaIrq) {
	if (tac_ & 0x04) {
		updateIrq(cc, timaIrq);
		updateTima(cc);
	}

	tma_ = data;
}
Пример #4
0
void Tima::setTma(const unsigned data, const unsigned long cycleCounter, const TimaInterruptRequester timaIrq) {
	if (tac_ & 0x04) {
		updateIrq(cycleCounter, timaIrq);
		updateTima(cycleCounter);
	}
	
	tma_ = data;
}
Пример #5
0
void Tima::resetCc(unsigned long const oldCc, unsigned long const newCc, TimaInterruptRequester timaIrq) {
	if (tac_ & 0x04) {
		updateIrq(oldCc, timaIrq);
		updateTima(oldCc);

		unsigned long const dec = oldCc - newCc;
		lastUpdate_ -= dec;
		timaIrq.setNextIrqEventTime(timaIrq.nextIrqEventTime() - dec);

		if (tmatime_ != disabled_time)
			tmatime_ -= dec;
	}
}
Пример #6
0
void Tima::setTima(unsigned const data, unsigned long const cc, TimaInterruptRequester timaIrq) {
	if (tac_ & 0x04) {
		updateIrq(cc, timaIrq);
		updateTima(cc);

		if (tmatime_ - cc < 4)
			tmatime_ = disabled_time;

		timaIrq.setNextIrqEventTime(lastUpdate_ + ((256u - data) << timaClock[tac_ & 3]) + 3);
	}

	tima_ = data;
}
Пример #7
0
void Tima::setTima(const unsigned data, const unsigned long cycleCounter, const TimaInterruptRequester timaIrq) {
	if (tac_ & 0x04) {
		updateIrq(cycleCounter, timaIrq);
		updateTima(cycleCounter);

		if (tmatime_ - cycleCounter < 4)
			tmatime_ = DISABLED_TIME;

		timaIrq.setNextIrqEventTime(lastUpdate_ + ((256u - data) << timaClock[tac_ & 3]) + 3);
	}
	
	tima_ = data;
}
Пример #8
0
void Tima::resetCc(const unsigned long oldCc, const unsigned long newCc, const TimaInterruptRequester timaIrq) {
	const unsigned long dec = oldCc - newCc;
	
	if (tac_ & 0x04) {
		updateIrq(oldCc, timaIrq);
		updateTima(oldCc);
		
		lastUpdate_ -= dec;
		timaIrq.setNextIrqEventTime(timaIrq.nextIrqEventTime() - dec);
		
		if (tmatime_ != DISABLED_TIME)
			tmatime_ -= dec;
	}
}