
MTIMER driver module
--------------------
v0.04 5/3/25

This uses Timer 1 to provide a timing facility for all the midi support
 driver modules (or any other module). A module must register itself
 and provide the address of a callback routine which will be called by
 MTimer regularly at any required multiple of a base timing period
 (currently 1ms).

Although this was written for my Pi version of the Midi Support
 system, it is a separate piece of software and does not require any of
 the Midi Support programs in order to work.


SWI's:
------

MTimer_Register  &D25C0
-----------------------
Registers a client. An entry is created and the client call address
 will be called regularly at the timing period.

Entry:
  r0 = client call address
  r1 = client r12 value
  r2 = initial timing period, units of 1ms
  r3 = pointer to client name string, or zero if none. This is only
       used by the *MTimerReport command.
           
Exit:
  Registers unchanged, or r0 = pointer to error block
  

MTimer_Remove    &D25C1
-----------------------
Removes a client's entry. The client will no longer be called.

Entry:
  r0 = client call address
  
Exit:
  Registers unchanged.

  
MTimer_Read      &D25C2
-----------------------
Reads the current time counter value

Entry:
  nothing
  
Exit:
  r0 = milliseconds since MTimer module initiaisation.
  
  
Client call routine:
--------------------
This is called with registers set as follows.

  r0 = client period.
  r1 = milliseconds since MTimer module initiaisation.
  r2 = milliseconds since last call (normally = r0).
  r3 = resolution in ms, normally 1 but will be 10 if the
       system ticker has been used, or 2 if running at
       half speed as can happen with the RPCEmu.
  r12 = client private word

Processor in SVC mode.

r1 provides a timestamp which will be the same for all clients.
r2 can be used to correct the situation where the callback does
not occur before the next 1ms interrupt.

On return, the r0 value is used to update the client period and
normally should be returned unchanged. However, it can be used
to change the period of subsequent calls. A value of 0 is ignored.


Commands:
---------

*MTimerReport:
-------------
This displays the current tick value and a list of registered
timer clients. e.g.

*mtimerreport
ticks 5323455
client 1, period 1ms, call &2026AF38, MIDI
client 2, period 1ms, call &20278E4C, MIDISynth
client 3, period 1ms, call &202C695C, MIDIPlay
client 4, period 1ms, call &202CDDF0, SerialMidi
client 5, period 1ms, call &202D3F60, USBMidi

