com.monkeycoder.monkeynes.hardware
Class HighResolutionTimer

java.lang.Object
  |
  +--com.monkeycoder.monkeynes.hardware.HighResolutionTimer

public class HighResolutionTimer
extends Object

This is a hardware component representing the timing circuit in the NES.

Originally part of the MonkeyNES project.

Author:
David Stephens

Constructor Summary
HighResolutionTimer(long inClockSpeed)
          Creates a new HighResolutionTimer at the specified speed.
 
Method Summary
 long getClocksPast()
          Gets how many cycles have elapsed since the last this this function was called.
 long getClockSpeed()
          Gets the speed of this timer.
 boolean isRunning()
          Returns whether or not this timer is running.
 void setClockSpeed(long inClockSpeed)
          Sets the speed of this timer to the specified speed.
 void startClock()
          Starts this timer.
 void stopClock()
          Stops this timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HighResolutionTimer

public HighResolutionTimer(long inClockSpeed)
Creates a new HighResolutionTimer at the specified speed.

Parameters:
inClockSpeed - The speed of this timer in Hz.
Method Detail

setClockSpeed

public void setClockSpeed(long inClockSpeed)
Sets the speed of this timer to the specified speed.

Parameters:
inClockSpeed - The speed of this timer in Hz.

getClockSpeed

public long getClockSpeed()
Gets the speed of this timer.

Returns:
The speed of this timer in Hz.

startClock

public void startClock()
Starts this timer. This is required to activate and initialize the timer.


stopClock

public void stopClock()
Stops this timer.


isRunning

public boolean isRunning()
Returns whether or not this timer is running.

Returns:
Whether or not the timer is running.

getClocksPast

public long getClocksPast()
Gets how many cycles have elapsed since the last this this function was called. This number is controlled by the speed to which this timer is set.

Returns:
The number of cycles that have elapsed.