AeN64Driver.h 5.51 KB

#ifndef _AE_U64Dev_h
#define _AE_U64Dev_h

#include <Vk/VkMenu.h>

#include "n64.h"
#include "GioMgr.h"
#include "AeAsset.h"
#include "AePlayer.h"
#include "AeErr.h"


class VkCallbackObject;
class List;
class AeN64Config;


enum
{
    kN64InitErr = -3000,
    kN64LowMemErr = -3001,
    kN64LowSampleMemErr = -3002,
    kN64BookMemErr = -3003,
    kN64BadBookN = -3004
};


#define  DEF_BANK_PER_BANKFILE  16
#define  DEF_INST_PER_BANK      128
#define  DEF_SND_PER_INST       64
#define  DEF_BOOK_SIZE          128

typedef struct
{
    int     	dataType;
    u8 *	memStart;
    int		memSize;
    AeAsset *	refAsset;
    int     	maxArray;
} U64Block;

typedef struct 
{
    u8     *romStart;
    int    size;
} smplBlock;


class AeN64Driver : public AePlayer
{
  public:
    static AeErr	NewN64Driver (char *, AeN64Driver *&);
                        AeN64Driver (char * configFileName = NULL);
    virtual 		~AeN64Driver (void);

    // client messages
    virtual void	SetAssetBase (AeAssetBase *);
    void    		CloseBank (void);

    virtual void	CreateAsset (AeAsset *, Boolean);
    virtual void       	UpdateAsset (AeAsset *, Boolean);
    virtual void	DeleteAsset (AeAsset *, Boolean);
    virtual void	OnlineAsset (AeAsset *, Boolean);
    virtual void	UpdateResume (void);

    // player messages
    virtual void	AuditionStart (AeAsset *);
    virtual void	AuditionStop (void);
    virtual void	BuildMenu (AeAssetWindow *);

    AeErr   		ResetDevice (void);
    AeErr		ReconfigureAudio (void);
    void		PoseConfigure (void);
    AeN64Config *	GetConfig (void) { return fConfig; }
    void		ResetMidi (void);
    AeErr   		SendMidiBlock (CommPckt *cp);

    virtual void	ReportError (AeErr);

  protected:
    AeErr   		loadBank (void);
    AeErr		loadControl (void);
    AeErr   		loadWave (void);
    void		unloadBank (void);
    AeErr   		startBank (void);

    Boolean		checkBank (void);
    Boolean		isBankOnline (void);
    Boolean		isBankLoadable (void);
    Boolean		isInstLoadable (AeInstAsset *);
    Boolean		isSoundLoadable (AeSoundAsset *);

    Boolean		checkFx (void);
    Boolean		isFxOnline (AeAsset *);
    Boolean		isFxSxnOnline (AeFxSxnAsset *);
    Boolean		isFxLoadable (AeFxAsset *);

    void		fxCreateBuiltIn (void);
    void		fxParseParamList (AeFxAsset *, int * params);
    void		fxBuildParamList (AeFxAsset *, int ** pParams, int * nParams);
    int *		fxSxnParseParamList (AeFxSxnAsset *, int * params);
    int *     		fxSxnBuildParamList (AeFxSxnAsset *, int * params);
    int			msec2alignedsamples (int);

    void		createBankAsset (AeAsset *, Boolean);
    void		createFxAsset (AeAsset *, Boolean);
    void		updateBankAsset (AeAsset *, Boolean);
    void		updateFxAsset (AeAsset *, Boolean);
    void		deleteBankAsset (AeAsset *, Boolean);
    void		deleteFxAsset (AeAsset *, Boolean);
    void		onlineBankAsset (AeAsset *, Boolean);
    void		onlineFxAsset (AeAsset *, Boolean);

    AeErr   		allocBankMem (AeAsset *);
    void    		deallocBankMem (AeAsset *);
    void		reallocBankMem (void);
    AeErr   		allocWaveMem (AeWaveAsset *);
    void    		deallocWaveMem (AeWaveAsset *);
    void		reallocWaveMem (void);

    Boolean		canGetAuditionParams (AeAsset *,
					      char * pPatch,
					      char * pKey,
					      char * pChannel);
    void		getInstPatch (AeInstAsset *, char *);

    void		updateAsset (AeAsset *);
    void		updateBankFile (AeBankFileAsset *);
    void		updateBank (AeBankAsset *);
    void		updateInst (AeInstAsset *);
    void		updateSound (AeSoundAsset *);
    void		updateEnv (AeEnvAsset *);
    void		updateKeymap (AeKeymapAsset *);
    void		updateWave (AeWaveAsset *);
    void		updateLoop (AeLoopAsset *);
    void		updateBook (AeADPCMBookAsset *);
    void     		updateFx (AeFxAsset *);
    void     		updateFxSxn (AeFxSxnAsset *);

    void		assembleAssetList (GList<AeAsset *> *, u8 *);
    void		assembleAssetRefs (AeAsset *, u8 *);
    void		assembleAsset (AeAsset *, u8 *);
    void		assembleBankFile (AeBankFileAsset *, ALBankFile *);
    void		assembleBank (AeBankAsset *, ALBank *);
    void		assembleInst (AeInstAsset *, ALInstrument *);
    void		assembleSound (AeSoundAsset *, ALSound *);
    void		assembleKeymap (AeKeymapAsset *, ALKeyMap *);
    void		assembleEnv (AeEnvAsset *, ALEnvelope *);
    void		assembleWave (AeWaveAsset *, ALWaveTable *);
    void		assembleLoop (AeLoopAsset *, ALADPCMloop *);
    void		assembleBook (AeADPCMBookAsset *, ALADPCMBook *);

    static void		configureCallback (Widget, XtPointer, XtPointer);
    static void		saveConfigCallback (Widget, XtPointer, XtPointer);
    static void		loadConfigCallback (Widget, XtPointer, XtPointer);
    static void		clearProfileCallback (Widget, XtPointer, XtPointer);
    static void		resetSystemCallback (Widget, XtPointer, XtPointer);

    VkSubMenu  *	fPlayerMenu;
    VkMenuItem *	fConfigureButton;
    VkMenuItem *	fSaveConfigButton;
    VkMenuItem *	fLoadConfigButton;
    VkMenuItem *	fClearProfileButton;
    VkMenuItem *	fResetSystemButton;
    
    List *		usedBlocks;
    List *		freeBlocks;

    List *		usedSmpl;
    List *		freeSmpl;

    u8 *		fBmemStart;
    u8 *		fBmemEnd;
    u8 *		fBmemCur;

    u8 *		fSmemStart;
    u8 *		fSmemEnd;
    u8 *		fSmemCur;

    GioMgr *		fGioMgr;
    AeN64Config *	fConfig;
    AeBankAsset *	fBank;		     // currently loaded bank
    Boolean		fBankOnlineHW;	     // true if bank loaded onto hardware
    Boolean		fNeedsConfigure;     // True if audio needs reconfigure

public:

    // utility routines
    static int	       	aetype2n64type (TAssetType);
    static TAssetType  	n64type2aetype (int);
};



#endif