/* Generated by CMunge 0.76 (10 May 2006) [with GCCSDK 4 changes r7662 at
 * /trunk/gcc4/riscos/cmunge]
 * CMunge Copyright (c) 1999-2006 Robin Watts/Justin Fletcher
 * Copyright (c) 2007-2014 GCCSDK Developers and contributors */

#ifndef _CMUNGE_MIDI_H_
#define _CMUNGE_MIDI_H_

#include "kernel.h"

#define CMUNGE_VERSION (76)
#define CMHG_VERSION   (531) /* Nearest equivalent version */

#define Module_Title		"MIDI"
#define Module_Help		"MIDI"
#define Module_VersionString	"0.22"
#define Module_VersionNumber	22
#ifndef Module_Date
#define Module_Date		"07 Oct 2025"
#endif

#ifdef __cplusplus
extern "C" {
#endif


/***************************************************************************
 * Function:     module_init
 * Description:  Initialise the module, setting up vectors, callbacks and
 *               any other parts of the system necessary for the module to
 *               function.
 * Parameters:   tail        = pointer to command line (control terminated)
 *               podule_base = address of podule module was started from, or
 *                             NULL if none
 *               pw          = private word for module
 * On exit:      Return NULL for successful initialisation, or a pointer to
 *               an error block if the module could not start properly.
 **************************************************************************/
_kernel_oserror *module_init(const char *tail, int podule_base, void *pw);


/***************************************************************************
 * Function:     module_term
 * Description:  Finalise the module, shutting down any systems necessary,
 *               freeing vectors and releasing workspace
 * Parameters:   fatal       = fatality indicator; 1 if fatal, 0 if
 *                             reinitialising
 *               podule_base = address of podule module was started from, or
 *                             NULL if none
 *               pw          = private word for module
 * On exit:      Return NULL for successful finalisation, or a pointer to an
 *               error block if module was not shutdown properly.
 **************************************************************************/
_kernel_oserror *module_term(int fatal, int podule_base, void *pw);


/***************************************************************************
 * Description:  Star command and help request handler routines.
 * Parameters:   arg_string = pointer to argument string (control
 *                            terminated), or output buffer
 *               argc       = number of arguments passed
 *               number     = command number (see CMD_* definitions below)
 *               pw         = private word for module
 * On exit:      If number indicates a help entry:
 *                 To output, assemble zero terminated output into
 *                 arg_string, and return help_PRINT_BUFFER to print it.
 *                 To stay silent, return NULL.
 *                 To given an error, return an error pointer.
 *                 [In this case, you need to cast the 'const' away]
 *               If number indicates a configure option:
 *                 If arg_string is arg_STATUS, then print status, otherwise
 *                 use argc and arg_string to set option.
 *                 Return NULL for no error.
 *                 Return one of the four error codes below (configure_*)
 *                 for a generic error message.
 *                 Return an error pointer for a custom error.
 *               If number indicates a command entry:
 *                 Execute the command given by number, and arg_string.
 *                 Return NULL on success,
 *                 Return a pointer to an error block on failure.
 **************************************************************************/
_kernel_oserror *module_command(const char *arg_string, int argc,
                                int number, void *pw);
#define help_PRINT_BUFFER		((_kernel_oserror *) arg_string)
#define arg_CONFIGURE_SYNTAX		((char *) 0)
#define arg_STATUS			((char *) 1)
#define configure_BAD_OPTION		((_kernel_oserror *) -1)
#define configure_NUMBER_NEEDED		((_kernel_oserror *) 1)
#define configure_TOO_LARGE		((_kernel_oserror *) 2)
#define configure_TOO_MANY_PARAMS	((_kernel_oserror *) 3)

/* Command numbers, as passed to the command handler functions (see above) */
#undef CMD_MidiSound
#define CMD_MidiSound (0)
#undef CMD_MidiTouch
#define CMD_MidiTouch (1)
#undef CMD_MidiChannel
#define CMD_MidiChannel (2)
#undef CMD_MidiMode
#define CMD_MidiMode (3)
#undef CMD_MidiStart
#define CMD_MidiStart (4)
#undef CMD_MidiStop
#define CMD_MidiStop (5)
#undef CMD_MidiContinue
#define CMD_MidiContinue (6)
#undef CMD_MidiSynth
#define CMD_MidiSynth (7)


/***************************************************************************
 * Description:  SWI handler routine. All SWIs for this module will be
 *               passed to these routines.
 * Parameters:   number = SWI number within SWI chunk (i.e. 0 to 63)
 *               r      = pointer to register block on entry
 *               pw     = private word for module
 * On exit:      Return NULL if SWI handled sucessfully, setting return
 *               register values (r0-r9) in r.
 *               Return error_BAD_SWI for out of range SWIs.
 *               Return an error block for a custom error.
 **************************************************************************/
/* Function called to handle SWI calls */
_kernel_oserror *module_swi(int number, _kernel_swi_regs *r, void *pw);
/* SWI number definitions */
#define MIDI_00 (0x000404c0)
#undef MIDI_SoundEnable
#undef XMIDI_SoundEnable
#define MIDI_SoundEnable          (0x000404c0)
#define XMIDI_SoundEnable         (0x000604c0)
#undef MIDI_SetMode
#undef XMIDI_SetMode
#define MIDI_SetMode              (0x000404c1)
#define XMIDI_SetMode             (0x000604c1)
#undef MIDI_SetTxChannel
#undef XMIDI_SetTxChannel
#define MIDI_SetTxChannel         (0x000404c2)
#define XMIDI_SetTxChannel        (0x000604c2)
#undef MIDI_SetTxActiveSensing
#undef XMIDI_SetTxActiveSensing
#define MIDI_SetTxActiveSensing   (0x000404c3)
#define XMIDI_SetTxActiveSensing  (0x000604c3)
#undef MIDI_InqSongPositionPointer
#undef XMIDI_InqSongPositionPointer
#define MIDI_InqSongPositionPointer  (0x000404c4)
#define XMIDI_InqSongPositionPointer (0x000604c4)
#undef MIDI_InqBufferSize
#undef XMIDI_InqBufferSize
#define MIDI_InqBufferSize        (0x000404c5)
#define XMIDI_InqBufferSize       (0x000604c5)
#undef MIDI_InqError
#undef XMIDI_InqError
#define MIDI_InqError             (0x000404c6)
#define XMIDI_InqError            (0x000604c6)
#undef MIDI_RxByte
#undef XMIDI_RxByte
#define MIDI_RxByte               (0x000404c7)
#define XMIDI_RxByte              (0x000604c7)
#undef MIDI_RxCommand
#undef XMIDI_RxCommand
#define MIDI_RxCommand            (0x000404c8)
#define XMIDI_RxCommand           (0x000604c8)
#undef MIDI_TxByte
#undef XMIDI_TxByte
#define MIDI_TxByte               (0x000404c9)
#define XMIDI_TxByte              (0x000604c9)
#undef MIDI_TxCommand
#undef XMIDI_TxCommand
#define MIDI_TxCommand            (0x000404ca)
#define XMIDI_TxCommand           (0x000604ca)
#undef MIDI_TxNoteOff
#undef XMIDI_TxNoteOff
#define MIDI_TxNoteOff            (0x000404cb)
#define XMIDI_TxNoteOff           (0x000604cb)
#undef MIDI_TxNoteOn
#undef XMIDI_TxNoteOn
#define MIDI_TxNoteOn             (0x000404cc)
#define XMIDI_TxNoteOn            (0x000604cc)
#undef MIDI_TxPolyKeyPressure
#undef XMIDI_TxPolyKeyPressure
#define MIDI_TxPolyKeyPressure    (0x000404cd)
#define XMIDI_TxPolyKeyPressure   (0x000604cd)
#undef MIDI_TxControlChange
#undef XMIDI_TxControlChange
#define MIDI_TxControlChange      (0x000404ce)
#define XMIDI_TxControlChange     (0x000604ce)
#undef MIDI_TxLocalControl
#undef XMIDI_TxLocalControl
#define MIDI_TxLocalControl       (0x000404cf)
#define XMIDI_TxLocalControl      (0x000604cf)
#undef MIDI_TxAllNotesOff
#undef XMIDI_TxAllNotesOff
#define MIDI_TxAllNotesOff        (0x000404d0)
#define XMIDI_TxAllNotesOff       (0x000604d0)
#undef MIDI_TxOmniModeOff
#undef XMIDI_TxOmniModeOff
#define MIDI_TxOmniModeOff        (0x000404d1)
#define XMIDI_TxOmniModeOff       (0x000604d1)
#undef MIDI_TxOmniModeOn
#undef XMIDI_TxOmniModeOn
#define MIDI_TxOmniModeOn         (0x000404d2)
#define XMIDI_TxOmniModeOn        (0x000604d2)
#undef MIDI_TxMonoModeOn
#undef XMIDI_TxMonoModeOn
#define MIDI_TxMonoModeOn         (0x000404d3)
#define XMIDI_TxMonoModeOn        (0x000604d3)
#undef MIDI_TxPolyModeOn
#undef XMIDI_TxPolyModeOn
#define MIDI_TxPolyModeOn         (0x000404d4)
#define XMIDI_TxPolyModeOn        (0x000604d4)
#undef MIDI_TxProgramChange
#undef XMIDI_TxProgramChange
#define MIDI_TxProgramChange      (0x000404d5)
#define XMIDI_TxProgramChange     (0x000604d5)
#undef MIDI_TxChannelPressure
#undef XMIDI_TxChannelPressure
#define MIDI_TxChannelPressure    (0x000404d6)
#define XMIDI_TxChannelPressure   (0x000604d6)
#undef MIDI_TxPitchWheel
#undef XMIDI_TxPitchWheel
#define MIDI_TxPitchWheel         (0x000404d7)
#define XMIDI_TxPitchWheel        (0x000604d7)
#undef MIDI_TxSongPositionPointer
#undef XMIDI_TxSongPositionPointer
#define MIDI_TxSongPositionPointer  (0x000404d8)
#define XMIDI_TxSongPositionPointer (0x000604d8)
#undef MIDI_TxSongSelect
#undef XMIDI_TxSongSelect
#define MIDI_TxSongSelect         (0x000404d9)
#define XMIDI_TxSongSelect        (0x000604d9)
#undef MIDI_TxTuneRequest
#undef XMIDI_TxTuneRequest
#define MIDI_TxTuneRequest        (0x000404da)
#define XMIDI_TxTuneRequest       (0x000604da)
#undef MIDI_TxStart
#undef XMIDI_TxStart
#define MIDI_TxStart              (0x000404db)
#define XMIDI_TxStart             (0x000604db)
#undef MIDI_TxContinue
#undef XMIDI_TxContinue
#define MIDI_TxContinue           (0x000404dc)
#define XMIDI_TxContinue          (0x000604dc)
#undef MIDI_TxStop
#undef XMIDI_TxStop
#define MIDI_TxStop               (0x000404dd)
#define XMIDI_TxStop              (0x000604dd)
#undef MIDI_TxSystemReset
#undef XMIDI_TxSystemReset
#define MIDI_TxSystemReset        (0x000404de)
#define XMIDI_TxSystemReset       (0x000604de)
#undef MIDI_IgnoreTiming
#undef XMIDI_IgnoreTiming
#define MIDI_IgnoreTiming         (0x000404df)
#define XMIDI_IgnoreTiming        (0x000604df)
#undef MIDI_SynchSoundScheduler
#undef XMIDI_SynchSoundScheduler
#define MIDI_SynchSoundScheduler  (0x000404e0)
#define XMIDI_SynchSoundScheduler (0x000604e0)
#undef MIDI_FastClock
#undef XMIDI_FastClock
#define MIDI_FastClock            (0x000404e1)
#define XMIDI_FastClock           (0x000604e1)
#undef MIDI_Init
#undef XMIDI_Init
#define MIDI_Init                 (0x000404e2)
#define XMIDI_Init                (0x000604e2)
#undef MIDI_SetBufferSize
#undef XMIDI_SetBufferSize
#define MIDI_SetBufferSize        (0x000404e3)
#define XMIDI_SetBufferSize       (0x000604e3)
#undef MIDI_Interface
#undef XMIDI_Interface
#define MIDI_Interface            (0x000404e4)
#define XMIDI_Interface           (0x000604e4)
#undef MIDI_37
#undef XMIDI_37
#define MIDI_37                   (0x000404e5)
#define XMIDI_37                  (0x000604e5)
#undef MIDI_38
#undef XMIDI_38
#define MIDI_38                   (0x000404e6)
#define XMIDI_38                  (0x000604e6)
#undef MIDI_39
#undef XMIDI_39
#define MIDI_39                   (0x000404e7)
#define XMIDI_39                  (0x000604e7)
#undef MIDI_40
#undef XMIDI_40
#define MIDI_40                   (0x000404e8)
#define XMIDI_40                  (0x000604e8)
#undef MIDI_41
#undef XMIDI_41
#define MIDI_41                   (0x000404e9)
#define XMIDI_41                  (0x000604e9)
#undef MIDI_42
#undef XMIDI_42
#define MIDI_42                   (0x000404ea)
#define XMIDI_42                  (0x000604ea)
#undef MIDI_43
#undef XMIDI_43
#define MIDI_43                   (0x000404eb)
#define XMIDI_43                  (0x000604eb)
#undef MIDI_44
#undef XMIDI_44
#define MIDI_44                   (0x000404ec)
#define XMIDI_44                  (0x000604ec)
#undef MIDI_SynthControl
#undef XMIDI_SynthControl
#define MIDI_SynthControl         (0x000404ed)
#define XMIDI_SynthControl        (0x000604ed)

/* Special error for 'SWI values out of range for this module' */
#define error_BAD_SWI ((_kernel_oserror *) -1)


/***************************************************************************
 * Function:     ticker_callback
 * Description:  Symbol for entry point to module - NOT a C function.
 *               This name should be used as an argument to
 *               OS_Claim/OS_Release as required, but should never be called
 *               from C.
 **************************************************************************/
extern void ticker_callback(void);


/***************************************************************************
 * Function:     ticker_callback_handler
 * Description:  Generic handler function
 * Parameters:   r  = pointer to register block on entry
 *               pw = private word for module
 * On exit:      Update r to alter return values
 *               Return NULL to return with V clear
 *               Return an error pointer to set V and r0
 **************************************************************************/
_kernel_oserror *ticker_callback_handler(_kernel_swi_regs *r, void *pw);


/***************************************************************************
 * Function:     tickerv
 * Description:  Symbol for entry point to module - NOT a C function.
 *               This name should be used as an argument to
 *               OS_Claim/OS_Release as required, but should never be called
 *               from C.
 **************************************************************************/
extern void tickerv(void);


/***************************************************************************
 * Function:     tickerv_handler
 * Description:  Vector handler function
 * Parameters:   r  = pointer to register block on entry
 *               pw = private word for module
 * On exit:      Update r to alter return values
 *               Return VECTOR_CLAIM to claim (return via stack)
 *               Return VECTOR_PASSON to pass on (return via r14)
 **************************************************************************/
int tickerv_handler(_kernel_swi_regs *r, void *pw);

/* VECTOR_PASSON can be returned from vectors to pass the call on to other
 * handlers. */
#define VECTOR_PASSON (1)
/* VECTOR_CLAIM can be returned from vectors to claim the vector and return
 * with the updated register block. */
#define VECTOR_CLAIM (0)

#ifdef __cplusplus
}
#endif

#endif
