Package smsqmulator
Class TrapDispatcher
java.lang.Object
smsqmulator.TrapDispatcher
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTrapDispatcher
(SampledSound sam, SoundDevice sound, inifile.IniFile inifile) Creates the object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToKeyboardQueue
(int key) Adds a key to the keyboard queue.void
Closes all files on all device drivers registered here, remove reference to the cpu.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.String[]
getNamesForDrives
(int deviceID) Gets the names of the directories for the drives.String[]
void
register
(DeviceDriver dd) Registers a device driver with this handler.void
reset()
Reset the machine.void
This resets the scheduler calls counter.void
setCpu
(MC68000Cpu cpu) Sets the cpu used by all device drivers.void
setFilenameChange
(int deviceID, int change) Sets whether a filename's case should be changed.void
setFloppy
(FloppyDriver floppy) Sets the FloppyDriver object.void
setFloppyNames
(String[] names) Sets the names of the native files to be used for floppy images.void
setGui
(MonitorGui gui) void
setNamesForDrives
(int deviceID, String[] names, boolean forceRemove) Sets the names for the drives of a device, i.e.void
setSerdriverNames
(String[] names) void
setSoundVolume
(int vol) Sets the sound volume for the Beep and SampledSound objects.void
setTimeOffset
(int to) Sets the time offset value.void
setUsageForDrive
(int deviceID, int usage) Sets the usage name for a device.
-
Field Details
-
TIME_OFFSET
public static int TIME_OFFSET
-
-
Constructor Details
-
TrapDispatcher
Creates the object.- Parameters:
sam
- a SampledSound object to be used here.sound
- the soundDevice object.inifile
- the ".ini" file object.
-
-
Method Details
-
setGui
-
dispatchTrap
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
Sets the FloppyDriver object.- Parameters:
floppy
- the FloppyDriver object to be set.
-
register
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
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 deviceIDnames
- an 8 element String array with the names for 8 drives (from 0 to 7).forceRemove
- force "unmount" of exiting drives and remount.
-
getNamesForDrives
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
-
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
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
-
setFloppyNames
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.
-