diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 59a9abe57..e26ed29a7 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ 0.2: +- Oscilloscope is now implemented (OpenAL) - Moved initialisation of _MemorySem to memInit - SvdB - Planet scan is now cleared correctly, from l0ci - Flagship modules are now drawn correctly instead of one pix left, from l0ci diff --git a/sc2/TODO b/sc2/TODO index 810173bb7..00d7f63f4 100644 --- a/sc2/TODO +++ b/sc2/TODO @@ -146,7 +146,6 @@ Stuff still to do (large): - The Mycons can actually say "Bye sun device" Stuff still to do (medium size): -- oscilloscope - loading teams in melee - get all code to compile without warnings, when the most strict checks are performed (not just -W -Wall in gcc) diff --git a/sc2/src/msvc++/UrQuanMasters.dsp b/sc2/src/msvc++/UrQuanMasters.dsp index 3528a8a6d..0676a74aa 100644 --- a/sc2/src/msvc++/UrQuanMasters.dsp +++ b/sc2/src/msvc++/UrQuanMasters.dsp @@ -160,6 +160,10 @@ SOURCE=..\sc2code\libs\graphics\sdl\opengl.h # End 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 # End Source File # Begin Source File diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index 4e2db70b2..abc4f540e 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -18,16 +18,16 @@ #include #include "libs/graphics/gfx_common.h" +#include "libs/graphics/drawable.h" #include "libs/sound/trackplayer.h" #include "starcon.h" #include "commglue.h" #include "options.h" -void InitOscilloscope (int x, int y, int width, int height, - void *f); +void InitOscilloscope (int x, int y, int width, int height, FRAME_DESC *f); void SetSliderImage (void *f); 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 Slider (void); diff --git a/sc2/src/sc2code/libs/graphics/sdl/Makeinfo b/sc2/src/sc2code/libs/graphics/sdl/Makeinfo index 4a1f6be60..f98ef61db 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/Makeinfo +++ b/sc2/src/sc2code/libs/graphics/sdl/Makeinfo @@ -1,2 +1,2 @@ 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" diff --git a/sc2/src/sc2code/libs/graphics/sdl/oscilloscope.c b/sc2/src/sc2code/libs/graphics/sdl/oscilloscope.c new file mode 100644 index 000000000..c481730aa --- /dev/null +++ b/sc2/src/sc2code/libs/graphics/sdl/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 +#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); +} diff --git a/sc2/src/sc2code/libs/sound/openal/music.c b/sc2/src/sc2code/libs/sound/openal/music.c index 2e4efea92..34d13a577 100644 --- a/sc2/src/sc2code/libs/sound/openal/music.c +++ b/sc2/src/sc2code/libs/sound/openal/music.c @@ -33,7 +33,7 @@ PLRPlaySong (MUSIC_REF MusicRef, BOOLEAN Continuous, BYTE Priority) if (pmus) { LockMutex (soundSource[MUSIC_SOURCE].stream_mutex); - PlayStream ((*pmus), MUSIC_SOURCE, Continuous); + PlayStream ((*pmus), MUSIC_SOURCE, Continuous, AL_FALSE); UnlockMutex (soundSource[MUSIC_SOURCE].stream_mutex); curMusicRef = MusicRef; @@ -194,6 +194,7 @@ _ReleaseMusicData (MEM_HANDLE handle) if ((*pmus)->decoder) { + TFB_SoundDecoder *decoder = (*pmus)->decoder; LockMutex (soundSource[MUSIC_SOURCE].stream_mutex); if (soundSource[MUSIC_SOURCE].sample == (*pmus)) { @@ -201,7 +202,8 @@ _ReleaseMusicData (MEM_HANDLE handle) } UnlockMutex (soundSource[MUSIC_SOURCE].stream_mutex); - SoundDecoder_Free ((*pmus)->decoder); + (*pmus)->decoder = NULL; + SoundDecoder_Free (decoder); alDeleteBuffers ((*pmus)->num_buffers, (*pmus)->buffer); HFree ((*pmus)->buffer); } diff --git a/sc2/src/sc2code/libs/sound/openal/sound.c b/sc2/src/sc2code/libs/sound/openal/sound.c index 136034cb2..c510f70f6 100644 --- a/sc2/src/sc2code/libs/sound/openal/sound.c +++ b/sc2/src/sc2code/libs/sound/openal/sound.c @@ -87,6 +87,10 @@ TFB_InitSound (int driver, int flags) soundSource[i].sample = NULL; soundSource[i].stream_should_be_playing = FALSE; 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); @@ -105,7 +109,25 @@ TFB_InitSound (int driver, int flags) void TFB_UninitSound (void) { + int i; + 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); alcDestroyContext (alcContext); alcContext = NULL; @@ -132,8 +154,10 @@ SoundPlaying (void) int 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; LockMutex (soundSource[i].stream_mutex); diff --git a/sc2/src/sc2code/libs/sound/openal/sound.h b/sc2/src/sc2code/libs/sound/openal/sound.h index 8a63b3824..4b89176b4 100644 --- a/sc2/src/sc2code/libs/sound/openal/sound.h +++ b/sc2/src/sc2code/libs/sound/openal/sound.h @@ -56,6 +56,12 @@ typedef struct tfb_soundsource BOOLEAN stream_should_be_playing; Mutex stream_mutex; ALuint start_time; + + // for oscilloscope + void *sbuffer; + ALuint sbuf_start; + ALuint sbuf_size; + ALuint total_decoded; } TFB_SoundSource; diff --git a/sc2/src/sc2code/libs/sound/openal/stream.c b/sc2/src/sc2code/libs/sound/openal/stream.c index 05ea2e05e..0eb79659f 100644 --- a/sc2/src/sc2code/libs/sound/openal/stream.c +++ b/sc2/src/sc2code/libs/sound/openal/stream.c @@ -19,6 +19,7 @@ #ifdef SOUNDMODULE_OPENAL +#include #include "sound.h" #if !defined (WIN32) // && !defined (MacOS and BeOS too) @@ -29,21 +30,24 @@ BOOLEAN speech_advancetrack = FALSE; 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) return; StopStream (source); - SoundDecoder_Rewind (sample->decoder); soundSource[source].sample = sample; soundSource[source].sample->decoder->looping = looping; - 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) { ALuint decoded_bytes; @@ -75,10 +79,19 @@ PlayStream (TFB_SoundSample *sample, ALuint source, ALboolean looping) 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) break; } - + + soundSource[source].sbuf_size = pos; soundSource[source].start_time = GetTimeCounter (); soundSource[source].stream_should_be_playing = TRUE; alSourcePlay (soundSource[source].handle); @@ -92,6 +105,17 @@ StopStream (ALuint source) soundSource[source].stream_should_be_playing = FALSE; 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); alGetSourcei (soundSource[source].handle, AL_BUFFERS_PROCESSED, &processed); alGetSourcei (soundSource[source].handle, AL_BUFFERS_QUEUED, &queued); @@ -109,7 +133,7 @@ StopStream (ALuint source) void 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; alSourcePause (soundSource[source].handle); } @@ -117,7 +141,7 @@ PauseStream (ALuint source) void 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; 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); break; } + + soundSource[i].total_decoded += soundSource[i].sample->decoder->buffer_size; + if (soundSource[i].sample->decoder->error) { if (soundSource[i].sample->decoder->error == SOUNDDECODER_EOF) @@ -252,6 +279,42 @@ StreamDecoderTaskFunc (void *data) else { 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) { diff --git a/sc2/src/sc2code/libs/sound/openal/stream.h b/sc2/src/sc2code/libs/sound/openal/stream.h index 0e86081d2..dfb482b67 100644 --- a/sc2/src/sc2code/libs/sound/openal/stream.h +++ b/sc2/src/sc2code/libs/sound/openal/stream.h @@ -20,7 +20,7 @@ #ifndef 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 PauseStream (ALuint source); void ResumeStream (ALuint source); diff --git a/sc2/src/sc2code/libs/sound/openal/trackplayer.c b/sc2/src/sc2code/libs/sound/openal/trackplayer.c index 1284820e4..7ddf81708 100644 --- a/sc2/src/sc2code/libs/sound/openal/trackplayer.c +++ b/sc2/src/sc2code/libs/sound/openal/trackplayer.c @@ -19,6 +19,7 @@ #ifdef SOUNDMODULE_OPENAL +#include #include "sound.h" #include "libs/sound/trackplayer.h" @@ -64,7 +65,7 @@ advance_track (int channel_finished) if (tcur < tct) { 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); do_subtitles (0); } @@ -151,14 +152,19 @@ StopTrack () } 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); - alDeleteBuffers (track_clip[tct].sample->num_buffers, track_clip[tct].sample->buffer); - HFree (track_clip[tct].sample->buffer); + TFB_SoundDecoder *decoder = sample->decoder; + ALuint *buffer = sample->buffer; + sample->decoder = NULL; + sample->buffer = NULL; + SoundDecoder_Free (decoder); + alDeleteBuffers (sample->num_buffers, buffer); + HFree (buffer); } - HFree (track_clip[tct].sample); - track_clip[tct].sample = 0; + HFree (sample); } } tct = tcur = 0; @@ -252,14 +258,73 @@ FastForward () //no_voice = 0; } +// processes sound data to oscilloscope int -GetSoundData (char* data) - // Returns the data size. Only used in oscill.c +GetSoundData (void *data) { - //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; } +// tells current position of streaming speech int GetSoundInfo (int *length, int *offset) { diff --git a/sc2/src/sc2code/libs/sound/sdl/sound.c b/sc2/src/sc2code/libs/sound/sdl/sound.c index 2918edf29..d4af0ab13 100644 --- a/sc2/src/sc2code/libs/sound/sdl/sound.c +++ b/sc2/src/sc2code/libs/sound/sdl/sound.c @@ -121,13 +121,9 @@ SoundPlaying() } int -GetSoundData(char* data) //Returns the data size. +GetSoundData (char* data) { - int ret; - - fprintf (stderr, "Unimplemented function activated: GetSoundData()\n"); - ret = 0; - return (ret); + return 0; } // Status: Unimplemented diff --git a/sc2/src/sc2code/libs/sound/trackplayer.h b/sc2/src/sc2code/libs/sound/trackplayer.h index 42f243060..faa6e9ee3 100644 --- a/sc2/src/sc2code/libs/sound/trackplayer.h +++ b/sc2/src/sc2code/libs/sound/trackplayer.h @@ -27,7 +27,7 @@ void FastForward(); void FastReverse(); void StopTrack(); void SpliceTrack(UNICODE *filespec, UNICODE *textspec); -int GetSoundData(char *data); +int GetSoundData (void *data); int GetSoundInfo (int *len, int *offs); #endif diff --git a/sc2/src/sc2code/oscill.c b/sc2/src/sc2code/oscill.c index ad7e43c21..33de5ae76 100644 --- a/sc2/src/sc2code/oscill.c +++ b/sc2/src/sc2code/oscill.c @@ -19,156 +19,10 @@ #include "libs/graphics/gfx_common.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 buttonStamp; -int32 sliderSpace; // slider width - button width +int sliderSpace; // slider width - button width + /* * Initialise the communication progress bar @@ -180,9 +34,10 @@ int32 sliderSpace; // slider width - button width * bheight - height of button indicating progress * f - image for the slider */ + void -InitSlider (int32 x, int32 y, int32 width, int32 height, - int32 bwidth, int32 bheight, FRAME f) +InitSlider (int x, int y, int width, int height, + int bwidth, int bheight, FRAME f) { sliderStamp.origin.x = x; sliderStamp.origin.y = y; @@ -201,7 +56,7 @@ SetSliderImage (FRAME f) void Slider (void) { - int32 len, offs; + int len, offs; if (GetSoundInfo (&len, &offs)) {