1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 Stepan Moskovchenko
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 int chVol
[16] IBSS_ATTR
; /* Channel volume */
25 int chPan
[16] IBSS_ATTR
; /* Channel panning */
26 int chPat
[16] IBSS_ATTR
; /* Channel patch */
27 int chPW
[16] IBSS_ATTR
; /* Channel pitch wheel, MSB only */
28 int chPBDepth
[16] IBSS_ATTR
; /* Channel pitch bend depth */
29 int chPBNoteOffset
[16] IBSS_ATTR
; /* Pre-computed whole semitone offset */
30 int chPBFractBend
[16] IBSS_ATTR
; /* Fractional bend applied to delta */
31 unsigned char chLastCtrlMSB
[16]; /* MIDI regs, used for Controller 6. */
32 unsigned char chLastCtrlLSB
[16]; /* The non-registered ones are ignored */
34 struct GPatch
* gusload(char *);
35 struct GPatch
* patchSet
[128];
36 struct GPatch
* drumSet
[128];
38 struct SynthObject voices
[MAX_VOICES
] IBSS_ATTR
;
42 static char *offset
= NULL
;
43 static size_t totalSize
= 0;
46 int remainder
= size
% 4;
48 size
= size
+ 4-remainder
;
52 offset
= rb
->plugin_get_audio_buffer(&totalSize
);
55 if (size
+ 4 > (int)totalSize
)
57 printf("MALLOC BARF");
58 printf("MALLOC BARF");
59 printf("MALLOC BARF");
60 printf("MALLOC BARF");
61 printf("MALLOC BARF");
62 printf("MALLOC BARF");
63 printf("MALLOC BARF");
64 /* We've made our point. */
70 *((unsigned int *)offset
) = size
;
73 totalSize
-= size
+ 4;
81 static char *offset = NULL;
82 static ssize_t totalSize = 0;
88 offset = rb->plugin_get_audio_buffer((size_t *)&totalSize);
91 if (size + 4 > totalSize)
97 *((unsigned int *)offset) = size;
100 totalSize -= size + 4;
105 #define malloc(n) my_malloc(n)
106 void * my_malloc(int size
)
111 unsigned char readChar(int file
)
114 rb
->read(file
, &buf
, 1);
118 unsigned char * readData(int file
, int len
)
120 unsigned char * dat
= malloc(len
);
121 rb
->read(file
, dat
, len
);
127 int curPos
= rb
->lseek(fd
, 0, SEEK_CUR
);
129 int size
= rb
->lseek(fd
, 0, SEEK_END
);
131 rb
->lseek(fd
, curPos
, SEEK_SET
);
132 return size
+1 == rb
->lseek(fd
, 0, SEEK_CUR
);
135 // Here is a hacked up printf command to get the output from the game.
136 int printf(const char *fmt
, ...)
138 static int p_xtpt
= 0;
144 ok
= rb
->vsnprintf(p_buf
,sizeof(p_buf
), fmt
, ap
);
149 /* Device LCDs display newlines funny. */
150 for(i
=0; p_buf
[i
]!=0; i
++)
154 rb
->lcd_putsxy(1,p_xtpt
, (unsigned char *)p_buf
);
158 if(p_xtpt
>LCD_HEIGHT
-8)
161 rb
->lcd_clear_display();