|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.razvan.jzx.Clock
public class Clock
Spectrum interrupt clock which is used for generating the 20ms interrupt on which the screen frames are synchronized.
The Spectrum clock is integral to emulating the Spectrum at a speed that resembles that of the original machine. Specifically, the main loop decodes and executes instructions at the full speed of the host machine. As each instruction is decoded, a virtual T-State counter is incremented, and whenever the virtual T-States add up to what should be one screen frame, the emulation loop simply blocks on the Clock thread until an interrupt is generated. The Clock thereby ensures that although the instructions are decoded much faster than in the original machine, the screen frames, and thus the CPU interrupts are produced at the same rate as the original hardware.
BaseSpectrum.emulate()
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
boolean |
interrupted
This is set to true, and notifyAll() is called whenever an interrupt has been generated. |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
Clock(long frequency,
ILogger logger)
Create the Clock thread and mark it as daemon. |
Method Summary | |
---|---|
void |
end()
Stops the Clock thread and causes it to exit (asynchronous.) |
long |
getFrequency()
Get the clock frequency. |
void |
run()
Generate interrupts every specified number of milliseconds. |
void |
setFrequency(long frequency)
Set the clock frequency. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public volatile boolean interrupted
Whomever is listening for the notifyAll() call is responsible for setting the interrupted flag back to false.
Constructor Detail |
---|
public Clock(long frequency, ILogger logger)
Method Detail |
---|
public long getFrequency()
public void setFrequency(long frequency)
frequency
- The clock frequency (in milliseconds).public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void end()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |