Package smsqmulator

Class TrapDispatcher

java.lang.Object
smsqmulator.TrapDispatcher

public class TrapDispatcher extends Object
This dispatches the various "traps" called from SMSQE. It is the primary interface between SMSQe and java. This is used for Trap#2 and Trap#3 calls to external device driver. Each device driver handles the calls to itself, and is thus a trap handler.

The trap handlers must register with this object for it to know them. There are also a number of additional "traps" for other functionalites.

The trap calls are implemented via illegal (A-line) instructions for the MC68000. These then causes this to be called in the CPU's execute() or executeContinuous() loops (possibly via the javacom instruction).

Traps handled so far are (note that these aren't real MC68000 traps, but A-line instructions):

  • 2 - corresponds to SMSQ/E TRAP#2
  • 3 - corresponds to SMSQ/E TRAP#3
  • 5 - for many miscellaneous routines
  • 6 - called for positioning the pointer in my screen object from within SMSQ/E
  • 7 - called on scheduler loop to check whether prog should sleep a bit (energy saving mode)
  • 8 - handles floppy writing/reading/formatting
  • 9 - handle IP protocols
  • A - reserved
  • B - de-iconify only
  • C - QL Screen emulation
  • D - Scrap ←→ clipboard operations
  • E - Win drive removable and remove from qkeyboard queue
  • F - Serial port integration
  • ab00 + handle some maths ops
  • Field Details

    • TIME_OFFSET

      public static int TIME_OFFSET
  • Constructor Details

    • TrapDispatcher

      public TrapDispatcher(SampledSound sam, SoundDevice sound, inifile.IniFile inifile)
      Creates the object.
      Parameters:
      sam - a SampledSound object to be used here.
      sound - the soundDevice object.
      inifile - the ".ini" file object.
  • Method Details

    • setGui

      public void setGui(MonitorGui gui)
    • dispatchTrap

      public void dispatchTrap(int trapType, MC68000Cpu cpu)
      The dispatcher's main method : Gets the correct trap handler and dispatches the trap to it, or handles traps above #3 here. This is called from the emulation thread after an "Aline" exception in SMSQE. This method does not set the CPU flags automatically, each "case" may need to do that by itself.
      Parameters:
      trapType - the type of "trap" we're dealing with.
      cpu - the cpu to be used.
    • resetCounter

      public void resetCounter()
      This resets the scheduler calls counter. This may be called from the emulation thread, but also from the EDT (key press, mouse mv)!
    • setFloppy

      public void setFloppy(FloppyDriver floppy)
      Sets the FloppyDriver object.
      Parameters:
      floppy - the FloppyDriver object to be set.
    • register

      public void register(DeviceDriver dd)
      Registers a device driver with this handler.

      An already registered device driver class will not be registered again.

      Parameters:
      dd - the device driver to register.
    • setNamesForDrives

      public void setNamesForDrives(int deviceID, String[] names, boolean forceRemove)
      Sets the names for the drives of a device, i.e. the directories the drives will point to. *** This is called from the swing EDT via the MonitorGui object ***.
      Parameters:
      deviceID - the device driver deviceID
      names - an 8 element String array with the names for 8 drives (from 0 to 7).
      forceRemove - force "unmount" of exiting drives and remount.
    • getNamesForDrives

      public String[] getNamesForDrives(int deviceID)
      Gets the names of the directories for the drives.
      Parameters:
      deviceID - the device driver ID.
      Returns:
      names an 8 element string array or null if this device driver wasn't found.
    • getNamesForDrives

      public String[] getNamesForDrives(DeviceDriver dd)
    • setFilenameChange

      public void setFilenameChange(int deviceID, int change)
      Sets whether a filename's case should be changed.
      Parameters:
      deviceID - the device driver ID.
      change - 0 = unchanged, 1=all upper case, 2=all lower case.
    • closeAllFiles

      public void closeAllFiles()
      Closes all files on all device drivers registered here, remove reference to the cpu.
    • setCpu

      public void setCpu(MC68000Cpu cpu)
      Sets the cpu used by all device drivers.
      Parameters:
      cpu - the cpu to be used.
    • setUsageForDrive

      public void setUsageForDrive(int deviceID, int usage)
      Sets the usage name for a device.
      Parameters:
      deviceID - the device to set the usage name for, an int containing a three letter word+'0', eg. 'QXL0'..
      usage - the usage name, an int containing a three letter word+'0', eg. 'QXL0'.
    • setSoundVolume

      public void setSoundVolume(int vol)
      Sets the sound volume for the Beep and SampledSound objects.
      Parameters:
      vol - volume from 0 (no sound) to 100 (loudest).
    • reset

      public void reset()
      Reset the machine.
    • addToKeyboardQueue

      public void addToKeyboardQueue(int key)
      Adds a key to the keyboard queue.
      Parameters:
      key -
    • setSerdriverNames

      public void setSerdriverNames(String[] names)
    • setFloppyNames

      public void setFloppyNames(String[] names)
      Sets the names of the native files to be used for floppy images. *** This is called from the swing EDT via the MonitorGui object ***.
      Parameters:
      names - 8 element String array with the names of the native files to be used for floppy images.
    • setTimeOffset

      public void setTimeOffset(int to)
      Sets the time offset value.
      Parameters:
      to - the time offset value.