Пример #1
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;
		}
Пример #2
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;
		}