void CBuffer::AddReversed(const void * pData, DWORD nLength) { EnsureBuffer( nLength ); ReverseBuffer( pData, m_pBuffer + m_nLength, nLength ); m_nLength += nLength; }
// Takes a pointer to some memory, and the number of bytes we can read there // Adds them to this buffer, except in reverse order void CBuffer::AddReversed(const void *pData, DWORD nLength) { // Make sure this buffer has enough memory allocated to hold another nLength bytes EnsureBuffer( nLength ); // Copy nLength bytes from pData to the end of the buffer, except in reverse order ReverseBuffer( pData, m_pBuffer + m_nLength, nLength ); // Record the new length m_nLength += nLength; }
// Takes a pointer to some memory, and the number of bytes we can read there // Adds them to this buffer, except in reverse order void CBuffer::AddReversed(const void *pData, const size_t nLength) { ASSERT( pData ); if ( pData == NULL ) return; // Make sure this buffer has enough memory allocated to hold another nLength bytes if ( ! EnsureBuffer( nLength ) ) return; // Copy nLength bytes from pData to the end of the buffer, except in reverse order ReverseBuffer( pData, m_pBuffer + m_nLength, nLength ); // Record the new length m_nLength += static_cast< DWORD >( nLength ); }
/* Handle the entry internally. Make an image or play the sound.... */ static void HandleInternal( Int4 index ) { unsigned char *sndbuf; unsigned char *pImgBuf ; char **xpmbuf=NULL; static char imagetext[50]; int nc; unsigned short samplerate; /* Sound sample size: The specs says a short here, with the next short empty. But some entries are (32 bits) ints, and the game engine accepts it. Examples include entries 164--171 (and many more) in strife0.wad (shareware v. 1.1), and #50 in the "Clint Eastwood DOOM (II?) sfx" pwad.... */ Uint4 nsamples; short w, h, dx, dy; switch ( pEntryTag[index] ) { case TAG_SFX : /* Read sound header */ fseek( WADfp, pDirEnt[index].start + 2, SEEK_SET ); fread( &samplerate, sizeof(short), 1, WADfp ); fread( &nsamples, sizeof(Uint4), 1, WADfp ); if ( nsamples != pDirEnt[index].size - 8) Message("Warning, sample size = %d, while Directory size = %d.\n", nsamples, pDirEnt[index].size); sndbuf = malloc( nsamples ); if ( !sndbuf ) { Message("can't malloc data for snd buf (%d bytes)\n",nsamples); return; } /* read the samples */ fread( sndbuf, 1, nsamples, WADfp ); if ( fl_get_button(rev_but) ) /* reverse ! */ ReverseBuffer( sndbuf, nsamples ); PlayRaw( sndbuf, nsamples, samplerate ); free( sndbuf ); break; case TAG_FLAT : case TAG_FULL : case TAG_IMG : pImgBuf = ParseImgBlock(pDirEnt[index], pEntryTag[index], &w, &h, &dx, &dy, WADfp); /* I planned to use the offsets (dx,dy) for better placement of the image, but I need to find out some useful heuristics for how to do it..... printf("image: %dx%d, ofs left %d, top %d\n",w,h,dx,dy); */ if ( pImgBuf && w <= 320 && h <= 200 && (xpmbuf = CreateXpmImage( pImgBuf, w, h, 0, &nc)) ) { fl_free_pixmap_pixmap( img_pxm ); fl_set_pixmap_data( img_pxm, xpmbuf ); sprintf(imagetext,"#%d, %dx%d, %d colours",index,w,h,nc); fl_set_object_label(img_txt, imagetext); } else { Message("error creating image. (%p, %hdx%hd, %p)\n", pImgBuf, w, h, xpmbuf); return; } break; default : Message("entry %d, Not implemented\n",index); break; } }
///--------------------------------------------------------------------------------- /// ///--------------------------------------------------------------------------------- void ReverseBufferJob::Run() { ReverseBuffer( m_buffer, m_bufferSize ); SetCallbackArg( (void*)m_buffer ); }