2005-04-15 06:08:55 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
2007-09-24 15:57:32 +00:00
|
|
|
* $Id$
|
2005-04-15 06:08:55 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Stepan Moskovchenko
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2005-04-15 06:08:55 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2007-09-24 15:57:32 +00:00
|
|
|
#include "plugin.h"
|
|
|
|
#include "midiutil.h"
|
2005-04-15 06:08:55 +00:00
|
|
|
|
2006-05-01 23:22:59 +00:00
|
|
|
int chVol[16] IBSS_ATTR; /* Channel volume */
|
2007-10-04 19:36:42 +00:00
|
|
|
int chPan[16] IBSS_ATTR; /* Channel panning */
|
2006-05-01 23:22:59 +00:00
|
|
|
int chPat[16] IBSS_ATTR; /* Channel patch */
|
|
|
|
int chPW[16] IBSS_ATTR; /* Channel pitch wheel, MSB only */
|
2007-10-17 03:48:24 +00:00
|
|
|
int chPBDepth[16] IBSS_ATTR; /* Channel pitch bend depth */
|
|
|
|
int chPBNoteOffset[16] IBSS_ATTR; /* Pre-computed whole semitone offset */
|
|
|
|
int chPBFractBend[16] IBSS_ATTR; /* Fractional bend applied to delta */
|
2007-10-21 19:47:33 +00:00
|
|
|
unsigned char chLastCtrlMSB[16]; /* MIDI regs, used for Controller 6. */
|
|
|
|
unsigned char chLastCtrlLSB[16]; /* The non-registered ones are ignored */
|
2005-04-19 15:57:07 +00:00
|
|
|
|
2005-04-15 06:08:55 +00:00
|
|
|
struct GPatch * gusload(char *);
|
|
|
|
struct GPatch * patchSet[128];
|
|
|
|
struct GPatch * drumSet[128];
|
|
|
|
|
2006-05-01 23:22:59 +00:00
|
|
|
struct SynthObject voices[MAX_VOICES] IBSS_ATTR;
|
2005-04-15 20:27:04 +00:00
|
|
|
|
2005-04-15 06:08:55 +00:00
|
|
|
void *alloc(int size)
|
|
|
|
{
|
2005-04-20 21:07:13 +00:00
|
|
|
static char *offset = NULL;
|
2007-04-21 18:38:25 +00:00
|
|
|
static ssize_t totalSize = 0;
|
2005-04-20 21:07:13 +00:00
|
|
|
char *ret;
|
2005-04-15 06:08:55 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
int remainder = size % 4;
|
2005-04-19 15:57:07 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
size = size + 4-remainder;
|
2005-04-19 15:57:07 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
if (offset == NULL)
|
|
|
|
{
|
2007-04-21 19:07:15 +00:00
|
|
|
offset = rb->plugin_get_audio_buffer((size_t *)&totalSize);
|
2005-04-20 21:07:13 +00:00
|
|
|
}
|
2005-04-15 06:08:55 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
if (size + 4 > totalSize)
|
|
|
|
{
|
2007-04-21 05:35:17 +00:00
|
|
|
printf("MALLOC BARF");
|
|
|
|
printf("MALLOC BARF");
|
|
|
|
printf("MALLOC BARF");
|
|
|
|
printf("MALLOC BARF");
|
|
|
|
printf("MALLOC BARF");
|
|
|
|
printf("MALLOC BARF");
|
|
|
|
printf("MALLOC BARF");
|
2006-05-03 05:18:18 +00:00
|
|
|
/* We've made our point. */
|
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-15 06:08:55 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
ret = offset + 4;
|
|
|
|
*((unsigned int *)offset) = size;
|
2005-04-15 06:08:55 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
offset += size + 4;
|
|
|
|
totalSize -= size + 4;
|
|
|
|
return ret;
|
2005-04-15 06:08:55 +00:00
|
|
|
}
|
2005-04-19 15:57:07 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
/* Rick's code */
|
2005-04-15 20:27:04 +00:00
|
|
|
/*
|
2005-04-19 15:57:07 +00:00
|
|
|
void *alloc(int size)
|
2005-04-15 06:08:55 +00:00
|
|
|
{
|
2005-04-20 21:07:13 +00:00
|
|
|
static char *offset = NULL;
|
2007-04-21 18:38:25 +00:00
|
|
|
static ssize_t totalSize = 0;
|
2005-04-20 21:07:13 +00:00
|
|
|
char *ret;
|
2005-04-15 06:08:55 +00:00
|
|
|
|
2005-04-19 15:57:07 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
if (offset == NULL)
|
|
|
|
{
|
2007-04-21 19:07:15 +00:00
|
|
|
offset = rb->plugin_get_audio_buffer((size_t *)&totalSize);
|
2005-04-20 21:07:13 +00:00
|
|
|
}
|
2005-04-15 06:08:55 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
if (size + 4 > totalSize)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-15 06:08:55 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
ret = offset + 4;
|
|
|
|
*((unsigned int *)offset) = size;
|
2005-04-15 06:08:55 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
offset += size + 4;
|
|
|
|
totalSize -= size + 4;
|
|
|
|
return ret;
|
2006-05-01 23:22:59 +00:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define malloc(n) my_malloc(n)
|
|
|
|
void * my_malloc(int size)
|
2005-04-15 06:08:55 +00:00
|
|
|
{
|
2005-04-20 21:07:13 +00:00
|
|
|
return alloc(size);
|
2005-04-15 06:08:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char readChar(int file)
|
|
|
|
{
|
2005-04-20 21:07:13 +00:00
|
|
|
char buf[2];
|
|
|
|
rb->read(file, &buf, 1);
|
|
|
|
return buf[0];
|
2005-04-15 06:08:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char * readData(int file, int len)
|
|
|
|
{
|
2006-05-01 23:22:59 +00:00
|
|
|
unsigned char * dat = malloc(len);
|
2005-04-20 21:07:13 +00:00
|
|
|
rb->read(file, dat, len);
|
|
|
|
return dat;
|
2005-04-15 06:08:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int eof(int fd)
|
|
|
|
{
|
2005-04-20 21:07:13 +00:00
|
|
|
int curPos = rb->lseek(fd, 0, SEEK_CUR);
|
2005-04-15 06:08:55 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
int size = rb->lseek(fd, 0, SEEK_END);
|
2005-04-15 06:08:55 +00:00
|
|
|
|
2005-04-20 21:07:13 +00:00
|
|
|
rb->lseek(fd, curPos, SEEK_SET);
|
|
|
|
return size+1 == rb->lseek(fd, 0, SEEK_CUR);
|
2005-04-15 06:08:55 +00:00
|
|
|
}
|
|
|
|
|
2006-05-01 23:22:59 +00:00
|
|
|
// Here is a hacked up printf command to get the output from the game.
|
|
|
|
int printf(const char *fmt, ...)
|
|
|
|
{
|
2008-01-02 06:35:59 +00:00
|
|
|
static int p_xtpt = 0;
|
|
|
|
char p_buf[50];
|
|
|
|
bool ok;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
ok = rb->vsnprintf(p_buf,sizeof(p_buf), fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
int i=0;
|
|
|
|
|
|
|
|
/* Device LCDs display newlines funny. */
|
|
|
|
for(i=0; p_buf[i]!=0; i++)
|
|
|
|
if(p_buf[i] == '\n')
|
|
|
|
p_buf[i] = ' ';
|
|
|
|
|
|
|
|
rb->lcd_putsxy(1,p_xtpt, (unsigned char *)p_buf);
|
|
|
|
rb->lcd_update();
|
|
|
|
|
|
|
|
p_xtpt+=8;
|
|
|
|
if(p_xtpt>LCD_HEIGHT-8)
|
|
|
|
{
|
|
|
|
p_xtpt=0;
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
}
|
|
|
|
return 1;
|
2006-05-01 23:22:59 +00:00
|
|
|
}
|
2005-04-15 06:08:55 +00:00
|
|
|
|
|
|
|
void exit(int code)
|
|
|
|
{
|
2005-04-20 21:07:13 +00:00
|
|
|
code = code; /* Stub function, kill warning for now */
|
2005-04-15 06:08:55 +00:00
|
|
|
}
|
2007-09-24 15:57:32 +00:00
|
|
|
|