TOP

Mantle Events

Mantle assumes all software running in user-space is event-driven. Events are described in messages, which are parameters passed to a single event handler for dispatching.

When an event handler is invoked, register a0 holds the message type. Register a1 holds a timestamp, providing an indication of when the event happened, while register a2 holds a dword which is unique to the kind of event being processed.

Message Types

Message Type Value Kind of Message
mtInit 0 Initialize program. Called exactly once.
mtKeyDown 1 User pressed a key on the keyboard.
mtKeyUp 2 User released a key on the keyboard.
mtTimerTick 3 A timer has expired.
mtMouseButton 4 User pressed a button, or released a button.
mtMouseMotion 5 User moved the mouse.

Remember each type of message has a corresponding flag definition. Unless otherwise documented, the flag that corresponds to a message type is specified by the relationship (1 << type).

mtMouseButton and mtMouseMotion

On entry to a mouse button or motion handler, the registers are defined as follows:

Register a2 contains a packed structure with the following format:

63     56 55     48 47               32 31               16 15                0
|       | |       | |                 | |                 | |                 |
D... .... bbbb bbbb .... .... .... .... yyyy yyyy yyyy yyyy xxxx xxxx xxxx xxxx

Key:  . - undefined bit; ignore current value for upward compatibility.
      D - button up/down flag (1 if button down, 0 if button up)
      b - mouse button identifier
      y - mouse vertical position
      x - mouse horizontal position

The mouse pointer coordinates are absolute, relative to (0,0), the upper-lefthand corner of the physical display.

Debate: This is a matter of convenience for the implementation of the emulator. However, it constricts the implementation to a single display. If multi-head configurations are to be supported, we will need a different coordinate reporting mechanism.

Note: For mtMouseMotion events, D and b bits will always be zero. Only coordinates are communicated. Applications are expected to use mtMouseButton events to keep track of current button status.