rem: int num_pages, cur_page;
add: int num_pages, page_counter;
context: SpliceTrack (UNICODE *TrackName, UNICODE *TrackText, UNICODE *TimeStamp){	unsigned long startTime;	if (TrackText)	{		if (TrackName == 0)		{			if (tct)			{				int slen1, slen2;				UNICODE *oTT;				oTT = TrackTextArray[tct - 1];				slen1 = wstrlen (oTT);				slen2 = wstrlen (TrackText);				TrackTextArray[tct - 1] = HRealloc (oTT, slen1 + slen2 + 1);				wstrcpy (&TrackTextArray[tct - 1][slen1], TrackText);			}		}		else		{			int num_pages, cur_page;			uint32 time_stamps[50];			if (no_page_break && tct)			{				int slen1, slen2;				UNICODE *oTT;				oTT = TrackTextArray[tct - 1];				slen1 = wstrlen (oTT);				slen2 = wstrlen (TrackText);				TrackTextArray[tct - 1] = HRealloc (oTT, slen1 + slen2 + 1);				wstrcpy (&TrackTextArray[tct - 1][slen1], TrackText);			}			else			{				TrackTextArray[tct] = HMalloc (sizeof (UNICODE) * (wstrlen (TrackText) + 1));				wstrcpy (TrackTextArray[tct++], TrackText);			}			if (TimeStamp)				num_pages = GetTimeStamps (TimeStamp, time_stamps);			else				num_pages = 0;			fprintf (stderr, "SpliceTrack(): loading %s\n", TrackName);			startTime = 0;			for (cur_page = 0; cur_page <= num_pages; cur_page++)			{				if (! sound_sample)				{					TFB_SoundDecoder *decoder;					track_mutex = CreateMutex();					sound_sample = (TFB_SoundSample *) HMalloc (sizeof (TFB_SoundSample));					sound_sample->num_buffers = 8;					sound_sample->buffer_tag = HMalloc (sizeof (TFB_SoundTag *) * sound_sample->num_buffers);					sound_sample->buffer = HMalloc (sizeof (uint32) * sound_sample->num_buffers);					TFBSound_GenBuffers (sound_sample->num_buffers, sound_sample->buffer);					decoder = SoundDecoder_Load (TrackName, 4096, startTime, time_stamps[cur_page]);					sound_sample->read_chain_ptr = create_soundchain (decoder, 0.0);					sound_sample->decoder = decoder;					first_chain = last_chain = sound_sample->read_chain_ptr;					sound_sample->length = 0;				}				else				{					TFB_SoundDecoder *decoder;					decoder =  SoundDecoder_Load (TrackName, 4096, startTime, time_stamps[cur_page]);					last_chain->next = create_soundchain (decoder, sound_sample->length);					last_chain = last_chain->next;				}				startTime += time_stamps[cur_page];							// fprintf (stderr, "page (%d of %d): %d\n",cur_page, num_pages, startTime);				if (last_chain->decoder)				{					//fprintf (stderr, "    decoder: %s, rate %d format %x\n",					//	last_chain->decoder->decoder_info,					//	last_chain->decoder->frequency,					//	last_chain->decoder->format);					sound_sample->length += last_chain->decoder->length;					if (! no_page_break)					{						last_chain->tag.type = MIX_BUFFER_TAG_TEXT;						last_chain->tag.value = (void *)(((tct - 1) << 8) | cur_page);					}					no_page_break = 0;				}				else				{					fprintf (stderr, "SpliceTrack(): couldn't load %s\n", TrackName);					TFBSound_DeleteBuffers (sound_sample->num_buffers, sound_sample->buffer);					destroy_soundchain (first_chain);					first_chain = NULL;					HFree (sound_sample->buffer);					HFree (sound_sample);					sound_sample = NULL;				}			}		}	}}