n64.h 1.96 KB
/*
 * n64.h
 */

#ifndef __n64__
#define __n64__

#include <PR/libaudio.h>
#include <dmedia/midi.h>
#include <PR/audiotools.h>
#include <PR/ramrom.h>
#include "spec.h"



#define MAX_MIDI_MSGS  	 	16
#define STATUS_TYPE    	 	1
#define SYSEX_TYPE     	 	2
#define PARAMS_PER_SECTION   	8

enum
{
    WRITE_BLOCK = 1,
    WRITE_RAMROM,
    INIT_AUDIO,
    START_SEQUENCE,
    STOP_SEQUENCE,
    SET_BANK,
    RESET_BANK,
    SET_FX_PARAM,
    SET_FX_SXN_PARAMS,
    LOAD_BANKFILE,
    LOAD_INST_VOL,
    LOAD_INST_PAN,
    LOAD_INST_PRIORITY,
    LOAD_INST_BENDRANGE
};


#define  TRUE   1
#define  FALSE  0


#ifndef MIN
#define   MIN(a,b) (((a)<(b))?(a):(b))
#endif

typedef  struct {
    unsigned char  midiByte[4];
} midiMess;

typedef  struct {
    int         numEvts;
    midiMess    mess[MAX_MIDI_MSGS];
} midiBlock;

typedef  struct {
    int         reqType;
    int         offset;
    int         value;
} SysExReq;


typedef  struct
{
    int         pcktType;
    union {
	midiBlock    mb;
	SysExReq     sysr;
    } d;
} CommPckt;


typedef struct 
{
    ALLink      node;
    int         startAddr;
    u32         lastFrame;
    char        *ptr;
} DMABuffer;

typedef struct 
{
    u8          initialized;
    DMABuffer   *firstUsed;
    DMABuffer   *firstFree;

} DMAState;


typedef struct
{
    char           *audioHeap;
    int            heapSize;
    int            frameSize;       	/* in samples per frame */
    int            maxCmdListSize; 	/* in commands, not bytes */
    int            numDMABuffs;   
    int            dmaBufSize;
    int            dmaQSize;
    int            frameLag;
    ALSynConfig    synConfig;
    ALSeqpConfig   seqpConfig;
} TN64Config;



/* 
 * The number of bytes needed to store a 16 byte aligned midiblock
 * and a 16 byte align u32.
 */

#define  CACHE_ALIGN_UP(a) ((a+15) & ~15)

#define  CACHE_ALIGN_DOWN(a) (a & ~15)

#define TRANSFER_SPACE_SIZE  (((sizeof(CommPckt)/16) + 3) * 16)

#define RDRAM_MEMORY_END     0x80300000

#endif