Package smsqmulator

Class Monitor

java.lang.Object
smsqmulator.Monitor

public class Monitor extends Object
The "monitor" object which, controls / starts / stops the emulation thread. This is a central piece of SMSQmulator. It has a double function : 1 - it serves as a monitor/debugger for M68K machine code instructions. 2 - It is this monitor that launches the thread executing the instructions and also serves as a go-between between different objects.

This executes commands that are given to it. Somme commands are:

  • t = trace one instruction (also enter)
  • j : jump over next instruction (don't execute it).
  • g [number_of_Instructions] : execute the program, optionally for [number_of_Instructions]
  • b [address_of_breakpoint] show (no parameter) or set/unset (one parameter) a breakpoint.
  • d [address] : display memory, if no parameter is given start at current PC address
  • di [address] : disassemble instructions, if no parameter is given start at current PC address.
and many more, see the showHelp() method.

Many of the methods of this object are just go-between between the Monitor object and other objects, such as the MC68000Cpuobject. This means that some methods are called from the emulation thread, whereas others are called from the Swing Event Dispatch thread. The monitor outputs to two windows (instruction and data windows) and has an input wdw, see the MonitorPanel object.

See Also:
  • showHelp()
  • Constructor Details

    • Monitor

      public Monitor(boolean watchBreakpoints, inifile.IniFile inifile, int nbrLogs, boolean logAtStartup)
      Creates the object
      Parameters:
      watchBreakpoints - flag whether we observe breakpoints (true = yes).
      inifile - the ".ini" file with initial and current values.
      nbrLogs - whether we log the instructions traced (will make everything very slow), and how many. =0 = don't log
  • Method Details

    • setGuiAndCpu

      public void setGuiAndCpu(MonitorGui gui, TrapDispatcher trapDispatcher)
      Sets the gui for this monitor.
      Parameters:
      gui -
      trapDispatcher -
    • executeMonitorCommand

      public void executeMonitorCommand(String command)
      Executes a command.

      See the help for what commands are recognized by the monitor.

      Parameters:
      command - a command line : command [options]:

      Commands are single or double letters, possibly followed by options.

      Some commands are (there are more,see the help method):

      • h - Help: show help.
      • g - Go (start monitoring) <start_address (default current PC)> <number_of_instructions to go (default unlimited)>.
      • gb- Go to a provisional breakpoint. One parameter: the breakpoint.
      • r - Registers : show content of registers.
      • a - check whether the go thread is still running.
      • di- Disassemble instructions <start_address (default current PC)> <number_of_instructions (default : 8)>.
      • j - Jump over current instruction (do not execute, advance PC).
      • b - Breakpoint. No parameters = sh;ow breakpoints , parameter= set breakpoint at that addresss, or unset it if it already is set at that address.
      • t - Trace (execute) one instruction at the current PC.
      • d - display memory content <start_address (default current PC)> <number_of_bytes (default : 16)>.
      • k - kill current Go thread if it exists.
      • s - set a register to a value: s <reg> <value> or s <reg> <value>.
      • bc - clear all breakpoints.
      • qr- quickly execute the following instruction and set a breakpoint to the one after that. Useful for JSR/BSR/Trap.

      Options are separated from the command and each other by single spaces.

      Numbers can be given in decimal or hex format. The default is hex, decimals must be prefixed by "&".

      An address can also be given by register number enclosed in parenthesis, eg (a7) or (d0) and also (pc).

      The address will then be that of the content of the register, so, if a7= $100, 'di (a7)' will disassemble instructions as of address $100.

      An address can also be calculated with + or - , e.g. *-10 or (a0)+$100.

      See Also:
      • showHelp()
    • goCommand

      public void goCommand(String[] options, int provbkp)
      Handles the "go" command : execute all instructions until either breakpoint reached or the optional nbr of instructions is reached.

      The MonitorEmulationThread handles actual instuction execution, and can thus be stopped with the "k" commmand.

      Parameters:
      options - Options[1] optionally contains the number of instructions to execute.
      provbkp - a provisional break for the "GB" command.
    • setLoggers

      public void setLoggers(JTextArea reglogger, JTextArea datalogger)
      Sets the log windows.
      Parameters:
      reglogger - where to show the register contents.
      datalogger - where to show data, e.g. memory content.
    • getBreakpoints

      public ArrayList<Integer> getBreakpoints()
      Gets the list of breakpoints.
      Returns:
      the list of breakpoints may be empty but will not be null.
    • getLogfilename

      public String getLogfilename()
      Get the name of the logfile.
      Returns:
      the name of the logfile.
    • showInfo

      public void showInfo(boolean clearArea, JTextArea textArea)
      Shows the content of all regs and the next instruction.
      Parameters:
      clearArea - should the text area be cleared before info is shown?
      textArea - where to show the info.
    • startEmulation

      public void startEmulation()
      Starts the emulation.
    • reset

      public void reset()
      Resets the emulator : restarts it entirely.
    • emulationThreadStopped

      public void emulationThreadStopped(String message)
      This is called from the EmulationThread when it is done.
      Parameters:
      message - a String to print out.
    • suspendExecution

      public void suspendExecution()
      Suspends execution of the EmulationThread. This is called from the Event Dispatch Thread, via the MonitorGui object when the window is minimized. Note the use of Thread.suspend which is discouraged. However, adding a check for a "suspend yourself" flag within the emulationThread, which is the recommended method, would slow the emulation down. Here there is no danger of the emulationThread and the event dispatch thread blocking each other.
    • resumeExecution

      public void resumeExecution()
      Resumes execution of the EmulationThread. This is called from the Event Dispatch Thread, via the MonitorGui object when the window is minimized. Note the use of Thread.resume which is discouraged. However, adding a check for a "suspend yourself" flag within the emulationThread, which is the recommended method, would slow the emulation down. Here there is no danger of the emulationThread and the event dispatch thread blocking each other.
    • setFastMode

      public void setFastMode()
      Go into fast or slow mode
    • setScreenUpdateInterval

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

      public void setCapsLockStatus(boolean isSet)
      Set the Caps lock directly in the sysvars (!).
      Parameters:
      isSet - = true if caps lock status is to be set.
    • inputKey

      public void inputKey(int key)
      Input a key typed into the Java - SMSQE linkage block area.

      This should then be picked up by the SMSQE keyboard read routine.

      Parameters:
      key - the "key" that was typed.
    • inputMouse

      public void inputMouse(int msmvtx, int msmvty, int msx, int msy)
      Inputs the mouse position into the SMSQE linkage area. *** This is called from the swing EDT via the MonitorGui object ***.
      Parameters:
      msmvtx - x movement of the mouse (how much did mouse move).
      msmvty - y movement of the mouse.
      msx - mouse x pos.
      msy - mouse y pos.
    • inputMouseButton

      public void inputMouseButton(int btn)
      Gets the mouse button pressed into the emulation. *** This is called from the swing EDT via the MonitorGui object ***.
      Parameters:
      btn - the button (1 = left, 2=right, 4 = middle button
    • inputMouseWheel

      public void inputMouseWheel(int wheel)
      Gets the mouse wheel movement into the emulation. *** This is called from the swing EDT via the MonitorGui object ***.
      Parameters:
      wheel - the wheel rotation and char.
    • setKeyrow

      public void setKeyrow(int row, int col)
      Sets a keyrow bit for the indicated row and col. *** This is called from the swing EDT via the MonitorGui/Screen object ***
      Parameters:
      row - row number.
      col - column number.
    • removeKeyrow

      public void removeKeyrow(int row, int col)
      Removes a keyrow bit for the indicated row and col. *** This is called from the swing EDT via the MonitorGui/Screen object ***
      Parameters:
      row - row number.
      col - column number.
    • removeAllKeyrows

      public void removeAllKeyrows()
      Unsets all keyrows. This is used when the window is minimized (iconified).
    • getCPU

      public MC68000Cpu getCPU()
      Gets the CPU this object is monitoring.
      Returns:
      the CPU this object is monitoring.
    • getTrapDispatcher

      public TrapDispatcher getTrapDispatcher()
      Gets the TrapDispatcher.
      Returns:
      the TrapDispatcher.