Oscilloscope is now implemented (OpenAL)

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@376 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2002-12-08 18:57:39 +00:00
parent 6154696451
commit e00a05afad
15 changed files with 320 additions and 185 deletions
+1
View File
@@ -1,4 +1,5 @@
0.2: 0.2:
- Oscilloscope is now implemented (OpenAL)
- Moved initialisation of _MemorySem to memInit - SvdB - Moved initialisation of _MemorySem to memInit - SvdB
- Planet scan is now cleared correctly, from l0ci - Planet scan is now cleared correctly, from l0ci
- Flagship modules are now drawn correctly instead of one pix left, from l0ci - Flagship modules are now drawn correctly instead of one pix left, from l0ci
-1
View File
@@ -146,7 +146,6 @@ Stuff still to do (large):
- The Mycons can actually say "Bye sun device" - The Mycons can actually say "Bye sun device"
Stuff still to do (medium size): Stuff still to do (medium size):
- oscilloscope
- loading teams in melee - loading teams in melee
- get all code to compile without warnings, when the most strict - get all code to compile without warnings, when the most strict
checks are performed (not just -W -Wall in gcc) checks are performed (not just -W -Wall in gcc)
+4
View File
@@ -160,6 +160,10 @@ SOURCE=..\sc2code\libs\graphics\sdl\opengl.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\oscilloscope.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\primitives.c SOURCE=..\sc2code\libs\graphics\sdl\primitives.c
# End Source File # End Source File
# Begin Source File # Begin Source File
+3 -3
View File
@@ -18,16 +18,16 @@
#include <ctype.h> #include <ctype.h>
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
#include "libs/graphics/drawable.h"
#include "libs/sound/trackplayer.h" #include "libs/sound/trackplayer.h"
#include "starcon.h" #include "starcon.h"
#include "commglue.h" #include "commglue.h"
#include "options.h" #include "options.h"
void InitOscilloscope (int x, int y, int width, int height, void InitOscilloscope (int x, int y, int width, int height, FRAME_DESC *f);
void *f);
void SetSliderImage (void *f); void SetSliderImage (void *f);
void InitSlider (int x, int y, int width, int height, void InitSlider (int x, int y, int width, int height,
int bwidth, int bheight, void *f); int bwidth, int bheight, void *f);
void Oscilloscope (int grab_data); void Oscilloscope (int grab_data);
void Slider (void); void Slider (void);
+1 -1
View File
@@ -1,2 +1,2 @@
uqm_CFILES="2xsai.c 3do_blt.c 3do_funcs.c 3do_getbody.c dcqueue.c opengl.c uqm_CFILES="2xsai.c 3do_blt.c 3do_funcs.c 3do_getbody.c dcqueue.c opengl.c
primitives.c pure.c rotozoom.c sdl_common.c" primitives.c pure.c rotozoom.c sdl_common.c oscilloscope.c"
@@ -0,0 +1,120 @@
/*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* By Mika Kolehmainen, 2002-12-08
*/
#include <assert.h>
#include "sdl_common.h"
#include "primitives.h"
#include "libs/sound/trackplayer.h"
static FRAMEPTR scope_frame;
static int scope_init = 0;
static SDL_Surface *scope_bg = NULL; // oscilloscope background (lbm/activity.9.png)
static SDL_Surface *scope_surf = NULL;
static UBYTE scope_data[RADAR_WIDTH];
void
InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME_DESC *f)
{
TFB_Image *img = (TFB_Image *)((BYTE *)f + f->DataOffs);
assert (img->NormalImg->format->BytesPerPixel == 1);
assert (img->NormalImg->w == RADAR_WIDTH);
assert (img->NormalImg->h == RADAR_HEIGHT);
if (scope_init == 0)
{
int i;
LockMutex (img->mutex);
scope_bg = SDL_CreateRGBSurface (SDL_SWSURFACE, img->NormalImg->w,
img->NormalImg->h, 8,
0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000);
scope_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, img->NormalImg->w,
img->NormalImg->h, 8,
0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000);
for (i = 0; i < 256; ++i)
{
scope_bg->format->palette->colors[i].r = scope_surf->format->palette->colors[i].r =
img->NormalImg->format->palette->colors[i].r;
scope_bg->format->palette->colors[i].g = scope_surf->format->palette->colors[i].g =
img->NormalImg->format->palette->colors[i].g;
scope_bg->format->palette->colors[i].b = scope_surf->format->palette->colors[i].b =
img->NormalImg->format->palette->colors[i].b;
}
SDL_BlitSurface (img->NormalImg, NULL, scope_bg, NULL);
UnlockMutex (img->mutex);
scope_init = 1;
}
scope_frame = f;
}
void
UninitOscilloscope (void)
{
if (scope_bg)
{
SDL_FreeSurface (scope_bg);
scope_bg = NULL;
}
if (scope_surf)
{
SDL_FreeSurface (scope_surf);
scope_surf = NULL;
}
}
// draws the oscilloscope
void
Oscilloscope (DWORD grab_data)
{
int i;
TFB_Image *img;
STAMP s;
if (!grab_data)
return;
SDL_BlitSurface (scope_bg, NULL, scope_surf, NULL);
if (GetSoundData (scope_data))
{
PutPixelFn scope_plot = putpixel_for (scope_surf);
SDL_LockSurface (scope_surf);
for (i = 0; i < RADAR_WIDTH - 1; ++i)
{
line (i, scope_data[i], i + 1, scope_data[i + 1], 238, scope_plot, scope_surf);
}
SDL_UnlockSurface (scope_surf);
}
img = (TFB_Image *)((BYTE *)scope_frame + scope_frame->DataOffs);
LockMutex (img->mutex);
SDL_BlitSurface (scope_surf, NULL, img->NormalImg, NULL);
UnlockMutex (img->mutex);
s.frame = scope_frame;
s.origin.x = s.origin.y = 0;
DrawStamp (&s);
}
+4 -2
View File
@@ -33,7 +33,7 @@ PLRPlaySong (MUSIC_REF MusicRef, BOOLEAN Continuous, BYTE Priority)
if (pmus) if (pmus)
{ {
LockMutex (soundSource[MUSIC_SOURCE].stream_mutex); LockMutex (soundSource[MUSIC_SOURCE].stream_mutex);
PlayStream ((*pmus), MUSIC_SOURCE, Continuous); PlayStream ((*pmus), MUSIC_SOURCE, Continuous, AL_FALSE);
UnlockMutex (soundSource[MUSIC_SOURCE].stream_mutex); UnlockMutex (soundSource[MUSIC_SOURCE].stream_mutex);
curMusicRef = MusicRef; curMusicRef = MusicRef;
@@ -194,6 +194,7 @@ _ReleaseMusicData (MEM_HANDLE handle)
if ((*pmus)->decoder) if ((*pmus)->decoder)
{ {
TFB_SoundDecoder *decoder = (*pmus)->decoder;
LockMutex (soundSource[MUSIC_SOURCE].stream_mutex); LockMutex (soundSource[MUSIC_SOURCE].stream_mutex);
if (soundSource[MUSIC_SOURCE].sample == (*pmus)) if (soundSource[MUSIC_SOURCE].sample == (*pmus))
{ {
@@ -201,7 +202,8 @@ _ReleaseMusicData (MEM_HANDLE handle)
} }
UnlockMutex (soundSource[MUSIC_SOURCE].stream_mutex); UnlockMutex (soundSource[MUSIC_SOURCE].stream_mutex);
SoundDecoder_Free ((*pmus)->decoder); (*pmus)->decoder = NULL;
SoundDecoder_Free (decoder);
alDeleteBuffers ((*pmus)->num_buffers, (*pmus)->buffer); alDeleteBuffers ((*pmus)->num_buffers, (*pmus)->buffer);
HFree ((*pmus)->buffer); HFree ((*pmus)->buffer);
} }
+26 -2
View File
@@ -87,6 +87,10 @@ TFB_InitSound (int driver, int flags)
soundSource[i].sample = NULL; soundSource[i].sample = NULL;
soundSource[i].stream_should_be_playing = FALSE; soundSource[i].stream_should_be_playing = FALSE;
soundSource[i].stream_mutex = CreateMutex (); soundSource[i].stream_mutex = CreateMutex ();
soundSource[i].sbuffer = NULL;
soundSource[i].sbuf_start = 0;
soundSource[i].sbuf_size = 0;
soundSource[i].total_decoded = 0;
} }
SetSFXVolume (sfxVolumeScale); SetSFXVolume (sfxVolumeScale);
@@ -105,7 +109,25 @@ TFB_InitSound (int driver, int flags)
void void
TFB_UninitSound (void) TFB_UninitSound (void)
{ {
int i;
ConcludeTask (StreamDecoderTask); ConcludeTask (StreamDecoderTask);
for (i = 0; i < NUM_SOUNDSOURCES; ++i)
{
if (soundSource[i].sample && soundSource[i].sample->decoder)
{
StopStream (i);
}
if (soundSource[i].sbuffer)
{
void *sbuffer = soundSource[i].sbuffer;
soundSource[i].sbuffer = NULL;
HFree (sbuffer);
}
DestroyMutex (soundSource[i].stream_mutex);
}
alcMakeContextCurrent (NULL); alcMakeContextCurrent (NULL);
alcDestroyContext (alcContext); alcDestroyContext (alcContext);
alcContext = NULL; alcContext = NULL;
@@ -132,8 +154,10 @@ SoundPlaying (void)
int i; int i;
for (i = 0; i < NUM_SOUNDSOURCES; ++i) for (i = 0; i < NUM_SOUNDSOURCES; ++i)
{ {
if (soundSource[i].sample && soundSource[i].sample->decoder) TFB_SoundSample *sample;
sample = soundSource[i].sample;
if (sample && sample->decoder)
{ {
BOOLEAN result; BOOLEAN result;
LockMutex (soundSource[i].stream_mutex); LockMutex (soundSource[i].stream_mutex);
@@ -56,6 +56,12 @@ typedef struct tfb_soundsource
BOOLEAN stream_should_be_playing; BOOLEAN stream_should_be_playing;
Mutex stream_mutex; Mutex stream_mutex;
ALuint start_time; ALuint start_time;
// for oscilloscope
void *sbuffer;
ALuint sbuf_start;
ALuint sbuf_size;
ALuint total_decoded;
} TFB_SoundSource; } TFB_SoundSource;
+70 -7
View File
@@ -19,6 +19,7 @@
#ifdef SOUNDMODULE_OPENAL #ifdef SOUNDMODULE_OPENAL
#include <assert.h>
#include "sound.h" #include "sound.h"
#if !defined (WIN32) // && !defined (MacOS and BeOS too) #if !defined (WIN32) // && !defined (MacOS and BeOS too)
@@ -29,21 +30,24 @@ BOOLEAN speech_advancetrack = FALSE;
void void
PlayStream (TFB_SoundSample *sample, ALuint source, ALboolean looping) PlayStream (TFB_SoundSample *sample, ALuint source, ALboolean looping, ALboolean scope)
{ {
ALuint i; ALuint i, pos = 0;
if (!sample) if (!sample)
return; return;
StopStream (source); StopStream (source);
SoundDecoder_Rewind (sample->decoder); SoundDecoder_Rewind (sample->decoder);
soundSource[source].sample = sample; soundSource[source].sample = sample;
soundSource[source].sample->decoder->looping = looping; soundSource[source].sample->decoder->looping = looping;
alSourcei (soundSource[source].handle, AL_LOOPING, AL_FALSE); alSourcei (soundSource[source].handle, AL_LOOPING, AL_FALSE);
if (scope)
{
soundSource[source].sbuffer = HMalloc (sample->num_buffers * sample->decoder->buffer_size);
}
for (i = 0; i < sample->num_buffers; ++i) for (i = 0; i < sample->num_buffers; ++i)
{ {
ALuint decoded_bytes; ALuint decoded_bytes;
@@ -75,10 +79,19 @@ PlayStream (TFB_SoundSample *sample, ALuint source, ALboolean looping)
alSourceQueueBuffers (soundSource[source].handle, 1, &sample->buffer[i]); alSourceQueueBuffers (soundSource[source].handle, 1, &sample->buffer[i]);
if (scope)
{
UBYTE *p = (UBYTE *)soundSource[source].sbuffer;
assert (pos + decoded_bytes <= sample->num_buffers * sample->decoder->buffer_size);
memcpy (&p[pos], sample->decoder->buffer, decoded_bytes);
pos += decoded_bytes;
}
if (sample->decoder->error) if (sample->decoder->error)
break; break;
} }
soundSource[source].sbuf_size = pos;
soundSource[source].start_time = GetTimeCounter (); soundSource[source].start_time = GetTimeCounter ();
soundSource[source].stream_should_be_playing = TRUE; soundSource[source].stream_should_be_playing = TRUE;
alSourcePlay (soundSource[source].handle); alSourcePlay (soundSource[source].handle);
@@ -92,6 +105,17 @@ StopStream (ALuint source)
soundSource[source].stream_should_be_playing = FALSE; soundSource[source].stream_should_be_playing = FALSE;
soundSource[source].sample = NULL; soundSource[source].sample = NULL;
if (soundSource[source].sbuffer)
{
void *sbuffer = soundSource[source].sbuffer;
soundSource[source].sbuffer = NULL;
HFree (sbuffer);
}
soundSource[source].sbuf_start = 0;
soundSource[source].sbuf_size = 0;
soundSource[source].total_decoded = 0;
alSourceStop (soundSource[source].handle); alSourceStop (soundSource[source].handle);
alGetSourcei (soundSource[source].handle, AL_BUFFERS_PROCESSED, &processed); alGetSourcei (soundSource[source].handle, AL_BUFFERS_PROCESSED, &processed);
alGetSourcei (soundSource[source].handle, AL_BUFFERS_QUEUED, &queued); alGetSourcei (soundSource[source].handle, AL_BUFFERS_QUEUED, &queued);
@@ -109,7 +133,7 @@ StopStream (ALuint source)
void void
PauseStream (ALuint source) PauseStream (ALuint source)
{ {
soundSource[source].start_time = GetTimeCounter () - soundSource[source].start_time; // TODO: how to handle start_time
soundSource[source].stream_should_be_playing = FALSE; soundSource[source].stream_should_be_playing = FALSE;
alSourcePause (soundSource[source].handle); alSourcePause (soundSource[source].handle);
} }
@@ -117,7 +141,7 @@ PauseStream (ALuint source)
void void
ResumeStream (ALuint source) ResumeStream (ALuint source)
{ {
soundSource[source].start_time = GetTimeCounter () - soundSource[source].start_time; // TODO: how to handle start_time
soundSource[source].stream_should_be_playing = TRUE; soundSource[source].stream_should_be_playing = TRUE;
alSourcePlay (soundSource[source].handle); alSourcePlay (soundSource[source].handle);
} }
@@ -197,6 +221,9 @@ StreamDecoderTaskFunc (void *data)
fprintf (stderr, "StreamDecoderTaskFunc(): OpenAL error after alSourceUnqueueBuffers: %x, file %s, source %d\n", error, soundSource[i].sample->decoder->filename, i); fprintf (stderr, "StreamDecoderTaskFunc(): OpenAL error after alSourceUnqueueBuffers: %x, file %s, source %d\n", error, soundSource[i].sample->decoder->filename, i);
break; break;
} }
soundSource[i].total_decoded += soundSource[i].sample->decoder->buffer_size;
if (soundSource[i].sample->decoder->error) if (soundSource[i].sample->decoder->error)
{ {
if (soundSource[i].sample->decoder->error == SOUNDDECODER_EOF) if (soundSource[i].sample->decoder->error == SOUNDDECODER_EOF)
@@ -252,6 +279,42 @@ StreamDecoderTaskFunc (void *data)
else else
{ {
alSourceQueueBuffers (soundSource[i].handle, 1, &buffer); alSourceQueueBuffers (soundSource[i].handle, 1, &buffer);
if (soundSource[i].sbuffer)
{
// copies decoded data to oscilloscope buffer
ALuint j, remaining_bytes = 0;
UBYTE *sbuffer = (UBYTE *) soundSource[i].sbuffer;
UBYTE *decoder_buffer = (UBYTE *) soundSource[i].sample->decoder->buffer;
if (soundSource[i].sbuf_start + decoded_bytes > soundSource[i].sbuf_size)
{
j = soundSource[i].sbuf_size;
remaining_bytes = decoded_bytes - (j - soundSource[i].sbuf_start);
}
else
{
j = soundSource[i].sbuf_start + decoded_bytes;
}
if (j - soundSource[i].sbuf_start >= 1)
{
//fprintf (stderr, "copying_a to %d - %d, %d bytes\n", soundSource[i].sbuf_start, j, j - soundSource[i].sbuf_start);
memcpy (&sbuffer[soundSource[i].sbuf_start], decoder_buffer, j - soundSource[i].sbuf_start);
}
if (remaining_bytes)
{
//fprintf (stderr, "copying_b to 0 - %d\n", remaining_bytes);
memcpy (sbuffer, &decoder_buffer[j - soundSource[i].sbuf_start], remaining_bytes);
soundSource[i].sbuf_start = remaining_bytes;
}
else
{
soundSource[i].sbuf_start += decoded_bytes;
}
}
if ((error = alGetError()) != AL_NO_ERROR) if ((error = alGetError()) != AL_NO_ERROR)
{ {
+1 -1
View File
@@ -20,7 +20,7 @@
#ifndef STREAM_H #ifndef STREAM_H
#define STREAM_H #define STREAM_H
void PlayStream (TFB_SoundSample *sample, ALuint source, ALboolean looping); void PlayStream (TFB_SoundSample *sample, ALuint source, ALboolean looping, ALboolean scope);
void StopStream (ALuint source); void StopStream (ALuint source);
void PauseStream (ALuint source); void PauseStream (ALuint source);
void ResumeStream (ALuint source); void ResumeStream (ALuint source);
+75 -10
View File
@@ -19,6 +19,7 @@
#ifdef SOUNDMODULE_OPENAL #ifdef SOUNDMODULE_OPENAL
#include <assert.h>
#include "sound.h" #include "sound.h"
#include "libs/sound/trackplayer.h" #include "libs/sound/trackplayer.h"
@@ -64,7 +65,7 @@ advance_track (int channel_finished)
if (tcur < tct) if (tcur < tct)
{ {
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex); LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
PlayStream (track_clip[tcur].sample, SPEECH_SOURCE, FALSE); PlayStream (track_clip[tcur].sample, SPEECH_SOURCE, FALSE, TRUE);
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex); UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
do_subtitles (0); do_subtitles (0);
} }
@@ -151,14 +152,19 @@ StopTrack ()
} }
if (track_clip[tct].sample) if (track_clip[tct].sample)
{ {
if (track_clip[tct].sample->decoder) TFB_SoundSample *sample = track_clip[tct].sample;
track_clip[tct].sample = NULL;
if (sample->decoder)
{ {
SoundDecoder_Free (track_clip[tct].sample->decoder); TFB_SoundDecoder *decoder = sample->decoder;
alDeleteBuffers (track_clip[tct].sample->num_buffers, track_clip[tct].sample->buffer); ALuint *buffer = sample->buffer;
HFree (track_clip[tct].sample->buffer); sample->decoder = NULL;
sample->buffer = NULL;
SoundDecoder_Free (decoder);
alDeleteBuffers (sample->num_buffers, buffer);
HFree (buffer);
} }
HFree (track_clip[tct].sample); HFree (sample);
track_clip[tct].sample = 0;
} }
} }
tct = tcur = 0; tct = tcur = 0;
@@ -252,14 +258,73 @@ FastForward ()
//no_voice = 0; //no_voice = 0;
} }
// processes sound data to oscilloscope
int int
GetSoundData (char* data) GetSoundData (void *data)
// Returns the data size. Only used in oscill.c
{ {
//fprintf (stderr, "Unimplemented function activated: GetSoundData()\n"); LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
if (soundSource[SPEECH_SOURCE].sample && soundSource[SPEECH_SOURCE].sample->decoder &&
PlayingStream (SPEECH_SOURCE) && soundSource[SPEECH_SOURCE].sbuffer)
{
float played_time = (GetTimeCounter () - soundSource[SPEECH_SOURCE].start_time) /
(float)ONE_SECOND;
int played_data = (int) (played_time * (float)soundSource[SPEECH_SOURCE].
sample->decoder->frequency * 2.0f);
int delta = played_data - soundSource[SPEECH_SOURCE].total_decoded;
unsigned int pos, i;
UBYTE *scopedata = (UBYTE *) data;
UBYTE *sbuffer = soundSource[SPEECH_SOURCE].sbuffer;
assert (soundSource[SPEECH_SOURCE].sample->decoder->frequency == 11025);
assert (soundSource[SPEECH_SOURCE].sample->decoder->format == AL_FORMAT_MONO16);
if (delta < 0)
{
//fprintf (stderr, "GetSoundData(): something's messed with timing, delta %d\n", delta);
delta = 0;
}
//fprintf (stderr, "played_data %d total_decoded %d delta %d\n", played_data, soundSource[SPEECH_SOURCE].total_decoded, delta);
pos = soundSource[SPEECH_SOURCE].sbuf_start + delta;
if (pos % 2 == 1)
pos++;
assert (pos >= 0);
for (i = 0; i < RADAR_WIDTH; ++i)
{
SWORD s;
for (;;)
{
if (pos >= soundSource[SPEECH_SOURCE].sbuf_size)
pos = pos - soundSource[SPEECH_SOURCE].sbuf_size;
else
break;
}
s = *(SWORD*) (&sbuffer[pos]);
s = (s / 1236) + (RADAR_HEIGHT >> 1);
if (s < 0)
s = 0;
else if (s > RADAR_HEIGHT)
s = RADAR_HEIGHT;
scopedata[i] = (UBYTE) s;
pos += 2;
}
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
return 1;
}
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
return 0; return 0;
} }
// tells current position of streaming speech
int int
GetSoundInfo (int *length, int *offset) GetSoundInfo (int *length, int *offset)
{ {
+2 -6
View File
@@ -121,13 +121,9 @@ SoundPlaying()
} }
int int
GetSoundData(char* data) //Returns the data size. GetSoundData (char* data)
{ {
int ret; return 0;
fprintf (stderr, "Unimplemented function activated: GetSoundData()\n");
ret = 0;
return (ret);
} }
// Status: Unimplemented // Status: Unimplemented
+1 -1
View File
@@ -27,7 +27,7 @@ void FastForward();
void FastReverse(); void FastReverse();
void StopTrack(); void StopTrack();
void SpliceTrack(UNICODE *filespec, UNICODE *textspec); void SpliceTrack(UNICODE *filespec, UNICODE *textspec);
int GetSoundData(char *data); int GetSoundData (void *data);
int GetSoundInfo (int *len, int *offs); int GetSoundInfo (int *len, int *offs);
#endif #endif
+6 -151
View File
@@ -19,156 +19,10 @@
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
#include "libs/sound/trackplayer.h" #include "libs/sound/trackplayer.h"
//Added by Chris
//Modified by Mika (removed use of SDL datatypes)
typedef unsigned char uint8;
typedef unsigned char uchar;
typedef signed char sint8;
typedef unsigned short uint16;
typedef signed short sint16;
typedef unsigned int uint32;
typedef signed int int32;
typedef signed int sint32;
//End Added by Chris
#define CEL_FLAGS \
(CCB_SPABS | CCB_PPABS | CCB_YOXY | CCB_ACW | CCB_ACCW \
| CCB_LDSIZE | CCB_CCBPRE | CCB_LDPRS | CCB_LDPPMP | CCB_ACE \
| CCB_LCE | CCB_PLUTPOS | CCB_BGND | CCB_NPABS)
#define PIXC_DUP(v) (((v) << PPMP_0_SHIFT) | ((v) << PPMP_1_SHIFT))
#define PIXC_UNCODED16 (PIXC_DUP (PPMPC_MF_8 | PPMPC_SF_8))
#define PIXC_CODED8 (PIXC_DUP (PPMPC_MS_PIN | PPMPC_SF_8))
#define NUMBER_OF_PLUTVALS 32
#define NUMBER_OF_PLUT_UINT32s (NUMBER_OF_PLUTVALS >> 1)
#define GET_VAR_PLUT(i) (_varPLUTs + (i) * NUMBER_OF_PLUT_UINT32s)
//extern uint32 *_varPLUTs;
#define NUM_THINGS 256
static CCB *plCCB;
static UBYTE flatline;
void
//InitOscilloscope (int32 x, int32 y, int32 width, int32 height, FRAME_DESC *f)
InitOscilloscope (int32 x, int32 y, int32 width, int32 height, void *f)
{
#if 0
CCB *ccb;
int32 xpos, xerr;
uint32 *cel_plut;
extern CCB *GetCelArray ();
cel_plut = GET_VAR_PLUT ((f->TypeIndexAndFlags >> 16) & 0xFF);
plCCB = GetCelArray ();
memset (plCCB, 0, sizeof (CCB) * (NUM_THINGS + 1));
ccb = plCCB;
ccb->ccb_Flags = CEL_FLAGS | CCB_PACKED | CCB_LDPLUT;
ccb->ccb_HDX = 1 << 20;
ccb->ccb_HDY = 0;
ccb->ccb_VDX = 0;
ccb->ccb_VDY = 1 << 16;
ccb->ccb_PIXC = PIXC_CODED8;
ccb->ccb_SourcePtr = (void *)((uchar *)f + f->DataOffs);
ccb->ccb_PLUTPtr = cel_plut;
ccb->ccb_Width = f->Bounds & 0xFFFF;
ccb->ccb_Height = (f->Bounds >> 16);
ccb->ccb_PRE0 =
PRE0_LITERAL |
((ccb->ccb_Height - PRE0_VCNT_PREFETCH) << PRE0_VCNT_SHIFT) |
(PRE0_BPP_8 << PRE0_BPP_SHIFT);
ccb->ccb_NextPtr = ccb + 1;
++ccb;
ccb->ccb_Width = y;
ccb->ccb_Height = height >> 1;
xpos = x;
xerr = NUM_THINGS;
do
{
int32 color;
ccb->ccb_XPos = xpos << 16;
if ((xerr -= width) <= 0)
{
++xpos;
xerr += NUM_THINGS;
}
ccb->ccb_HDX = 1 << 20;
ccb->ccb_VDY = 1 << 16;
ccb->ccb_Flags = CEL_FLAGS;
ccb->ccb_PRE0 =
(PRE0_BPP_16 << PRE0_BPP_SHIFT) |
PRE0_BGND |
PRE0_LINEAR;
ccb->ccb_PRE1 = PRE1_TLLSB_PDC0;
ccb->ccb_PIXC = PIXC_UNCODED16;
color = ((16 << 10) | (9 << 5) | 31) | 0x8000;
ccb->ccb_PLUTPtr = (void *)((color << 16) | color);
ccb->ccb_SourcePtr = (void *)&ccb->ccb_PLUTPtr;
ccb->ccb_NextPtr = ccb + 1;
} while (++ccb != &plCCB[NUM_THINGS + 1]);
#endif
flatline = 0;
}
void
Oscilloscope (int32 grab_data)
{
#if 0
CCB *ccb;
signed char buf[NUM_THINGS * 2], *data;
int32 size, ypos, max;
if (!grab_data
|| !(size = GetSoundData (buf)))
{
if (flatline)
return;
flatline = 1;
memset (buf, 0, sizeof (buf));
}
else
flatline = 0;
ccb = plCCB + 1;
max = ccb->ccb_Height;
ypos = ccb->ccb_Width + max;
data = buf;
do
{
ccb->ccb_YPos = (ypos + ((*data * max) >> 7)) << 16;
#ifndef READ_SAMPLE_DIRECTLY
data += 2;
#else
data++;
#endif
} while (++ccb != &plCCB[NUM_THINGS + 1]);
add_cels (plCCB, ccb - 1);
// ClearDrawable ();
FlushGraphics (TRUE);
#endif
}
static STAMP sliderStamp; static STAMP sliderStamp;
static STAMP buttonStamp; static STAMP buttonStamp;
int32 sliderSpace; // slider width - button width int sliderSpace; // slider width - button width
/* /*
* Initialise the communication progress bar * Initialise the communication progress bar
@@ -180,9 +34,10 @@ int32 sliderSpace; // slider width - button width
* bheight - height of button indicating progress * bheight - height of button indicating progress
* f - image for the slider * f - image for the slider
*/ */
void void
InitSlider (int32 x, int32 y, int32 width, int32 height, InitSlider (int x, int y, int width, int height,
int32 bwidth, int32 bheight, FRAME f) int bwidth, int bheight, FRAME f)
{ {
sliderStamp.origin.x = x; sliderStamp.origin.x = x;
sliderStamp.origin.y = y; sliderStamp.origin.y = y;
@@ -201,7 +56,7 @@ SetSliderImage (FRAME f)
void void
Slider (void) Slider (void)
{ {
int32 len, offs; int len, offs;
if (GetSoundInfo (&len, &offs)) if (GetSoundInfo (&len, &offs))
{ {