Package smsqmulator

Class QL50HzInterrupt

java.lang.Object
smsqmulator.QL50HzInterrupt
All Implemented Interfaces:
ExternalInterruptHandler

public class QL50HzInterrupt extends Object implements ExternalInterruptHandler
This simulates a 50 Hz external frame interrupt, and generates screen redraws. Two independent threads are created:
  • The first one sleeps for 20 milliseconds and then signals an interrupt to the cpu = 50 Hz interrupt.
  • The second thread is responsible for (re)drawing the screen.
There are two threads because the 50 Hz interrupt is supposed to be as precise as possible, and the screen redraw may take too much time.
See Also:
  • Constructor Details

    • QL50HzInterrupt

      public QL50HzInterrupt(MC68000Cpu cpu)
      Creates the object.
      Parameters:
      cpu - the cpu to which this interrupt is attached.
  • Method Details

    • handleExternalInterrupt

      public void handleExternalInterrupt(MC68000Cpu cpu)
      Handles the interrupt, no instruction is being executed whilst this goes on. This should be called from the CPU execute thread. However, since there is only one interrupt, this isn't called at all, the CPU handles the interrupt directly. was: Port $18021 on the emulated machine is set to 8, to signal the external interrupt. An exception is raised, which changes the CPU's PC.
      Specified by:
      handleExternalInterrupt in interface ExternalInterruptHandler
      Parameters:
      cpu - the CPU for which an interrupt was generated.
      See Also:
    • startInterrupts

      public void startInterrupts()
      Starts the interrupt handler and screen redraw threads.
    • stopInterrupts

      public void stopInterrupts()
      Stops the interrupt handler and screen redraw threads.
    • removeHandler

      public void removeHandler()
      This stops the interrupt handler, and removes any reference to the cpu.
      Specified by:
      removeHandler in interface ExternalInterruptHandler
    • setScreen

      public void setScreen(Screen screen)
      Sets a (new) screen object.
      Parameters:
      screen - the Screen to set.
    • setCpu

      public void setCpu(MC68000Cpu ncpu)
      Sets a (new) cpu object. This stops the interrupt threads
      Parameters:
      ncpu - the new Cpu to set.
    • setScreenUpdateInterval

      public void setScreenUpdateInterval(int tim)
      Sets the interval between screen updates.
      Parameters:
      tim - the interval between screen updates in milliseconds