More efficient texture memory usage. Fixes hickups on BGAnimation change.

This commit is contained in:
Chris Danford
2002-10-20 17:18:05 +00:00
parent 0b1cd44364
commit 1c75f1b095
5 changed files with 30 additions and 39 deletions
+1 -1
View File
@@ -66,7 +66,7 @@ void Notes::WriteSMNotesTag( FILE* fp )
CStringArray asRadarValues; CStringArray asRadarValues;
for( int r=0; r<NUM_RADAR_VALUES; r++ ) for( int r=0; r<NUM_RADAR_VALUES; r++ )
asRadarValues.Add( ssprintf("%.2f", m_fRadarValues[r]) ); asRadarValues.Add( ssprintf("%.3f", m_fRadarValues[r]) );
fprintf( fp, " %s:\n", join(",",asRadarValues) ); fprintf( fp, " %s:\n", join(",",asRadarValues) );
fprintf( fp, "%s;\n", m_sSMNoteData ); fprintf( fp, "%s;\n", m_sSMNoteData );
+5 -3
View File
@@ -223,8 +223,10 @@ bool NotesWriterDWI::Write( CString sPath, const Song &out )
if(out.m_sArtist.GetLength() != 0) if(out.m_sArtist.GetLength() != 0)
fprintf( fp, "#ARTIST:%s;\n", out.m_sArtist ); fprintf( fp, "#ARTIST:%s;\n", out.m_sArtist );
ASSERT( out.m_BPMSegments[0].m_fStartBeat == 0 ); ASSERT( out.m_BPMSegments[0].m_fStartBeat == 0 );
fprintf( fp, "#BPM:%.2f;\n", out.m_BPMSegments[0].m_fBPM ); fprintf( fp, "#BPM:%.3f;\n", out.m_BPMSegments[0].m_fBPM );
fprintf( fp, "#GAP:%d;\n", int(-roundf( out.m_fBeat0OffsetInSeconds*1000 )) ); fprintf( fp, "#GAP:%d;\n", int(-roundf( out.m_fBeat0OffsetInSeconds*1000 )) );
fprintf( fp, "#SAMPLESTART:%.3f;\n", out.m_fMusicSampleStartSeconds );
fprintf( fp, "#SAMPLELENGTH:%.3f;\n", out.m_fMusicSampleLengthSeconds );
if( out.m_StopSegments.GetSize() ) if( out.m_StopSegments.GetSize() )
{ {
@@ -233,7 +235,7 @@ bool NotesWriterDWI::Write( CString sPath, const Song &out )
for( int i=0; i<out.m_StopSegments.GetSize(); i++ ) for( int i=0; i<out.m_StopSegments.GetSize(); i++ )
{ {
const StopSegment &fs = out.m_StopSegments[i]; const StopSegment &fs = out.m_StopSegments[i];
fprintf( fp, "%.2f=%.2f", BeatToNoteRow( fs.m_fStartBeat ) * 4.0f / ROWS_PER_BEAT, fprintf( fp, "%.3f=%.3f", BeatToNoteRow( fs.m_fStartBeat ) * 4.0f / ROWS_PER_BEAT,
roundf(fs.m_fStopSeconds*1000) ); roundf(fs.m_fStopSeconds*1000) );
if( i != out.m_StopSegments.GetSize()-1 ) if( i != out.m_StopSegments.GetSize()-1 )
fprintf( fp, "," ); fprintf( fp, "," );
@@ -247,7 +249,7 @@ bool NotesWriterDWI::Write( CString sPath, const Song &out )
for( int i=1; i<out.m_BPMSegments.GetSize(); i++ ) for( int i=1; i<out.m_BPMSegments.GetSize(); i++ )
{ {
const BPMSegment &bs = out.m_BPMSegments[i]; const BPMSegment &bs = out.m_BPMSegments[i];
fprintf( fp, "%.2f=%.2f", BeatToNoteRow( bs.m_fStartBeat ) * 4.0f / ROWS_PER_BEAT, bs.m_fBPM ); fprintf( fp, "%.3f=%.3f", BeatToNoteRow( bs.m_fStartBeat ) * 4.0f / ROWS_PER_BEAT, bs.m_fBPM );
if( i != out.m_BPMSegments.GetSize()-1 ) if( i != out.m_BPMSegments.GetSize()-1 )
fprintf( fp, "," ); fprintf( fp, "," );
} }
+3 -1
View File
@@ -218,7 +218,9 @@ void Player::Update( float fDeltaTime )
if( hn.m_fStartBeat < fSongBeat && fSongBeat < hn.m_fEndBeat ) // if the song beat is in the range of this hold if( hn.m_fStartBeat < fSongBeat && fSongBeat < hn.m_fEndBeat ) // if the song beat is in the range of this hold
{ {
const bool bIsHoldingButton = INPUTMAPPER->IsButtonDown( GameI ) || PREFSMAN->m_bAutoPlay || GAMESTATE->m_bDemonstration; bool bIsHoldingButton = INPUTMAPPER->IsButtonDown( GameI );
if( !GAMESTATE->m_bEditing && (PREFSMAN->m_bAutoPlay || GAMESTATE->m_bDemonstration) )
bIsHoldingButton = true;
m_NoteField.m_bIsHoldingHoldNote[i] = bIsHoldingButton && bSteppedOnTapNote; // set host flag so NoteField can do intelligent drawing m_NoteField.m_bIsHoldingHoldNote[i] = bIsHoldingButton && bSteppedOnTapNote; // set host flag so NoteField can do intelligent drawing
+12 -25
View File
@@ -125,32 +125,19 @@ void RageBitmapTexture::Create(
// Figure out which texture format to use // Figure out which texture format to use
/////////////////////// ///////////////////////
D3DFORMAT fmtTexture; D3DFORMAT fmtTexture;
switch( dwTextureColorDepth ) if( dwTextureColorDepth == 32 )
fmtTexture = D3DFMT_A8R8G8B8;
else if( ddii.Format == D3DFMT_P8 )
fmtTexture = D3DFMT_A1R5G5B5;
else // dwTextureColorDepth == 16
{ {
case 16:
switch( iAlphaBits ) switch( iAlphaBits )
{ {
case 0: fmtTexture = D3DFMT_R5G6B5; break; case 0: fmtTexture = D3DFMT_R5G6B5; break;
case 1: fmtTexture = D3DFMT_A1R5G5B5; break; case 1: fmtTexture = D3DFMT_A1R5G5B5; break;
case 4: case 4: fmtTexture = D3DFMT_A4R4G4B4; break;
// Ignore dwTextureColorDepth, and infer based on image format default: ASSERT(0); fmtTexture = D3DFMT_A4R4G4B4; break;
switch( ddii.Format )
{
case D3DFMT_P8: fmtTexture = D3DFMT_A1R5G5B5; break;
default: fmtTexture = D3DFMT_A4R4G4B4; break;
}
break;
default:
ASSERT(0); // invalid iAlphaBits value
fmtTexture = D3DFMT_A4R4G4B4; break;
} }
break;
case 32:
fmtTexture = D3DFMT_A8R8G8B8;
break;
default:
throw RageException( "Invalid color depth: %d bits", dwTextureColorDepth );
} }
@@ -166,12 +153,12 @@ void RageBitmapTexture::Create(
if( FAILED( hr = D3DXCreateTextureFromFileEx( if( FAILED( hr = D3DXCreateTextureFromFileEx(
m_pd3dDevice, // device m_pd3dDevice, // device
m_sFilePath, // soure file m_sFilePath, // soure file
bStretch ? dwMaxSize : D3DX_DEFAULT, // width D3DX_DEFAULT, // width
bStretch ? dwMaxSize : D3DX_DEFAULT, // height D3DX_DEFAULT, // height
iMipMaps, // mip map levels iMipMaps, // mip map levels
0, // usage (is a render target?) 0, // usage (is a render target?)
fmtTexture, // our preferred texture format fmtTexture, // our preferred texture format
D3DPOOL_MANAGED, // which memory pool D3DPOOL_DEFAULT, // which memory pool
(bStretch ? D3DX_FILTER_LINEAR : D3DX_FILTER_NONE) | (bDither ? D3DX_FILTER_DITHER : 0), // filter (bStretch ? D3DX_FILTER_LINEAR : D3DX_FILTER_NONE) | (bDither ? D3DX_FILTER_DITHER : 0), // filter
D3DX_FILTER_BOX | (bDither ? D3DX_FILTER_DITHER : 0), // mip filter D3DX_FILTER_BOX | (bDither ? D3DX_FILTER_DITHER : 0), // mip filter
D3DCOLOR_ARGB(255,255,0,255), // pink color key D3DCOLOR_ARGB(255,255,0,255), // pink color key
+9 -9
View File
@@ -697,14 +697,14 @@ void Song::SaveToSMFile( CString sPath, bool bSavingCache )
fprintf( fp, "#CDTITLE:%s;\n", m_sCDTitleFile ); fprintf( fp, "#CDTITLE:%s;\n", m_sCDTitleFile );
fprintf( fp, "#MUSIC:%s;\n", m_sMusicFile ); fprintf( fp, "#MUSIC:%s;\n", m_sMusicFile );
fprintf( fp, "#MUSICBYTES:%u;\n", m_iMusicBytes ); fprintf( fp, "#MUSICBYTES:%u;\n", m_iMusicBytes );
fprintf( fp, "#MUSICLENGTH:%.2f;\n", m_fMusicLengthSeconds ); fprintf( fp, "#MUSICLENGTH:%.3f;\n", m_fMusicLengthSeconds );
if(bSavingCache) { if(bSavingCache) {
fprintf( fp, "#FIRSTBEAT:%.2f;\n", m_fFirstBeat ); fprintf( fp, "#FIRSTBEAT:%.3f;\n", m_fFirstBeat );
fprintf( fp, "#LASTBEAT:%.2f;\n", m_fLastBeat ); fprintf( fp, "#LASTBEAT:%.3f;\n", m_fLastBeat );
} }
fprintf( fp, "#OFFSET:%.2f;\n", m_fBeat0OffsetInSeconds ); fprintf( fp, "#OFFSET:%.3f;\n", m_fBeat0OffsetInSeconds );
fprintf( fp, "#SAMPLESTART:%.2f;\n", m_fMusicSampleStartSeconds ); fprintf( fp, "#SAMPLESTART:%.3f;\n", m_fMusicSampleStartSeconds );
fprintf( fp, "#SAMPLELENGTH:%.2f;\n", m_fMusicSampleLengthSeconds ); fprintf( fp, "#SAMPLELENGTH:%.3f;\n", m_fMusicSampleLengthSeconds );
fprintf( fp, "#SELECTABLE:" ); fprintf( fp, "#SELECTABLE:" );
switch(m_SelectionDisplay) { switch(m_SelectionDisplay) {
default: ASSERT(0); /* fallthrough */ default: ASSERT(0); /* fallthrough */
@@ -722,7 +722,7 @@ void Song::SaveToSMFile( CString sPath, bool bSavingCache )
{ {
BPMSegment &bs = m_BPMSegments[i]; BPMSegment &bs = m_BPMSegments[i];
fprintf( fp, "%.2f=%.2f", bs.m_fStartBeat, bs.m_fBPM ); fprintf( fp, "%.3f=%.3f", bs.m_fStartBeat, bs.m_fBPM );
if( i != m_BPMSegments.GetSize()-1 ) if( i != m_BPMSegments.GetSize()-1 )
fprintf( fp, "," ); fprintf( fp, "," );
} }
@@ -733,7 +733,7 @@ void Song::SaveToSMFile( CString sPath, bool bSavingCache )
{ {
StopSegment &fs = m_StopSegments[i]; StopSegment &fs = m_StopSegments[i];
fprintf( fp, "%.2f=%.2f", fs.m_fStartBeat, fs.m_fStopSeconds ); fprintf( fp, "%.3f=%.3f", fs.m_fStartBeat, fs.m_fStopSeconds );
if( i != m_StopSegments.GetSize()-1 ) if( i != m_StopSegments.GetSize()-1 )
fprintf( fp, "," ); fprintf( fp, "," );
} }
@@ -744,7 +744,7 @@ void Song::SaveToSMFile( CString sPath, bool bSavingCache )
{ {
BackgroundChange &seg = m_BackgroundChanges[i]; BackgroundChange &seg = m_BackgroundChanges[i];
fprintf( fp, "%.2f=%s", seg.m_fStartBeat, seg.m_sBGName ); fprintf( fp, "%.3f=%s", seg.m_fStartBeat, seg.m_sBGName );
if( i != m_BackgroundChanges.GetSize()-1 ) if( i != m_BackgroundChanges.GetSize()-1 )
fprintf( fp, "," ); fprintf( fp, "," );
} }