/* 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_MIDIPlay_H_
#define _CMUNGE_MIDIPlay_H_

#include "kernel.h"

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

#define Module_Title		"MIDIPlay"
#define Module_Help		"MIDIPlay"
#define Module_VersionString	"3.23"
#define Module_VersionNumber	323
#ifndef Module_Date
#define Module_Date		"08 Mar 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_MidiPlayer
#define CMD_MidiPlayer (0)


/***************************************************************************
 * 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 MIDIPlay_00 (0x00045340)
#undef MIDIPlay_File
#undef XMIDIPlay_File
#define MIDIPlay_File             (0x00045340)
#define XMIDIPlay_File            (0x00065340)
#undef MIDIPlay_Start
#undef XMIDIPlay_Start
#define MIDIPlay_Start            (0x00045341)
#define XMIDIPlay_Start           (0x00065341)
#undef MIDIPlay_Stop
#undef XMIDIPlay_Stop
#define MIDIPlay_Stop             (0x00045342)
#define XMIDIPlay_Stop            (0x00065342)
#undef MIDIPlay_Volume
#undef XMIDIPlay_Volume
#define MIDIPlay_Volume           (0x00045343)
#define XMIDIPlay_Volume          (0x00065343)
#undef MIDIPlay_Tempo
#undef XMIDIPlay_Tempo
#define MIDIPlay_Tempo            (0x00045344)
#define XMIDIPlay_Tempo           (0x00065344)
#undef MIDIPlay_Info
#undef XMIDIPlay_Info
#define MIDIPlay_Info             (0x00045345)
#define XMIDIPlay_Info            (0x00065345)
#undef MIDIPlay_Close
#undef XMIDIPlay_Close
#define MIDIPlay_Close            (0x00045346)
#define XMIDIPlay_Close           (0x00065346)
#undef MIDIPlay_Player
#undef XMIDIPlay_Player
#define MIDIPlay_Player           (0x00045347)
#define XMIDIPlay_Player          (0x00065347)
#undef MIDIPlay_Pattern
#undef XMIDIPlay_Pattern
#define MIDIPlay_Pattern          (0x00045348)
#define XMIDIPlay_Pattern         (0x00065348)
#undef MIDIPlay_PatternParameter
#undef XMIDIPlay_PatternParameter
#define MIDIPlay_PatternParameter  (0x00045349)
#define XMIDIPlay_PatternParameter (0x00065349)
#undef MIDIPlay_PatternPlay
#undef XMIDIPlay_PatternPlay
#define MIDIPlay_PatternPlay      (0x0004534a)
#define XMIDIPlay_PatternPlay     (0x0006534a)
#undef MIDIPlay_PatternEvent
#undef XMIDIPlay_PatternEvent
#define MIDIPlay_PatternEvent     (0x0004534b)
#define XMIDIPlay_PatternEvent    (0x0006534b)
#undef MIDIPlay_Test
#undef XMIDIPlay_Test
#define MIDIPlay_Test             (0x0004534c)
#define XMIDIPlay_Test            (0x0006534c)
#undef MIDIPlay_Event
#undef XMIDIPlay_Event
#define MIDIPlay_Event            (0x0004534d)
#define XMIDIPlay_Event           (0x0006534d)
#undef MIDIPlay_Text
#undef XMIDIPlay_Text
#define MIDIPlay_Text             (0x0004534e)
#define XMIDIPlay_Text            (0x0006534e)
#undef MIDIPlay_15
#undef XMIDIPlay_15
#define MIDIPlay_15               (0x0004534f)
#define XMIDIPlay_15              (0x0006534f)
#undef MIDIPlay_16
#undef XMIDIPlay_16
#define MIDIPlay_16               (0x00045350)
#define XMIDIPlay_16              (0x00065350)
#undef MIDIPlay_17
#undef XMIDIPlay_17
#define MIDIPlay_17               (0x00045351)
#define XMIDIPlay_17              (0x00065351)
#undef MIDIPlay_18
#undef XMIDIPlay_18
#define MIDIPlay_18               (0x00045352)
#define XMIDIPlay_18              (0x00065352)
#undef MIDIPlay_Control
#undef XMIDIPlay_Control
#define MIDIPlay_Control          (0x00045353)
#define XMIDIPlay_Control         (0x00065353)

/* 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:     timer_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 timer_callback(void);


/***************************************************************************
 * Function:     timer_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 *timer_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)

/* Error base for this module */
#define ERROR_BASE (0x00821800)

#ifdef __cplusplus
}
#endif

#endif
