diff options
author | Max Horn | 2010-07-05 19:10:20 +0000 |
---|---|---|
committer | Max Horn | 2010-07-05 19:10:20 +0000 |
commit | 68d620ccab1be965c8b0f7373cb1280e11244139 (patch) | |
tree | 8482080884fce3f4636d14e5d0da8d41d79f1ba0 /backends/platform/ds | |
parent | 776c3a1d519838910732ab31b81b11cc5d122c88 (diff) | |
download | scummvm-rg350-68d620ccab1be965c8b0f7373cb1280e11244139.tar.gz scummvm-rg350-68d620ccab1be965c8b0f7373cb1280e11244139.tar.bz2 scummvm-rg350-68d620ccab1be965c8b0f7373cb1280e11244139.zip |
DS: Fix warnings, make some vars static, cleanup
svn-id: r50701
Diffstat (limited to 'backends/platform/ds')
-rw-r--r-- | backends/platform/ds/arm9/source/cdaudio.cpp | 82 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/dsmain.cpp | 3 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/gbampsave.cpp | 54 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/osystem_ds.cpp | 2 |
4 files changed, 70 insertions, 71 deletions
diff --git a/backends/platform/ds/arm9/source/cdaudio.cpp b/backends/platform/ds/arm9/source/cdaudio.cpp index 66fbef6cdc..a5d38cb7e4 100644 --- a/backends/platform/ds/arm9/source/cdaudio.cpp +++ b/backends/platform/ds/arm9/source/cdaudio.cpp @@ -74,25 +74,25 @@ struct decoderFormat { unsigned char sample[1024]; } __attribute__ ((packed)); -bool active = false; -WaveHeader waveHeader; -Header blockHeader; -FILE *file; -int fillPos; -bool isPlayingFlag = false; - -s16 *audioBuffer; -u32 sampleNum; -s16 *decompressionBuffer; -int numLoops; -int blockCount; -int dataChunkStart; -int blocksLeft; -bool trackStartsAt2 = false; +static bool s_active = false; +static WaveHeader waveHeader; +static Header blockHeader; +static FILE *s_file; +static int fillPos; +static bool isPlayingFlag = false; + +static s16 *audioBuffer; +static u32 sampleNum; +static s16 *decompressionBuffer; +static int s_numLoops; +static int blockCount; +static int dataChunkStart; +static int blocksLeft; +static bool trackStartsAt2 = false; // These are from Microsoft's document on DVI ADPCM -const int stepTab[ 89 ] = { +static const int stepTab[ 89 ] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, @@ -106,7 +106,7 @@ const int stepTab[ 89 ] = { 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 }; -const int indexTab[ 16 ] = { -1, -1, -1, -1, 2, 4, 6, 8, +static const int indexTab[ 16 ] = { -1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8 }; void playNextBlock(); @@ -118,11 +118,11 @@ void allocBuffers() { } void setActive(bool active) { - DS::CD::active = active; + s_active = active; } bool getActive() { - return active; + return s_active; } void playTrack(int track, int numLoops, int startFrame, int duration) { @@ -148,21 +148,21 @@ void playTrack(int track, int numLoops, int startFrame, int duration) { sprintf(str, "track%d.wav", track); fname = path + str; - file = DS::std_fopen(fname.c_str(), "rb"); + s_file = DS::std_fopen(fname.c_str(), "rb"); - if (!file) { + if (!s_file) { sprintf(str, "track%02d.wav", track); fname = path + str; - file = DS::std_fopen(fname.c_str(), "rb"); + s_file = DS::std_fopen(fname.c_str(), "rb"); } - if (!file) { + if (!s_file) { consolePrintf("Failed to open %s!\n", path.c_str()); return; } - DS::std_fread(&waveHeader, sizeof(waveHeader), 1, file); + DS::std_fread(&waveHeader, sizeof(waveHeader), 1, s_file); consolePrintf("File: %s\n", fname.c_str()); @@ -174,7 +174,7 @@ void playTrack(int track, int numLoops, int startFrame, int duration) { if ((waveHeader.fmtFormatTag != 17) && (waveHeader.fmtFormatTag != 20)) { consolePrintf("Wave file is in the wrong format! You must use IMA-ADPCM 4-bit mono.\n"); - DS::std_fclose(file); + DS::std_fclose(s_file); return; } @@ -186,14 +186,14 @@ void playTrack(int track, int numLoops, int startFrame, int duration) { // Skip chunks until we reach the data chunk chunkHeader chunk; - DS::std_fread(&chunk, sizeof(chunkHeader), 1, file); + DS::std_fread(&chunk, sizeof(chunkHeader), 1, s_file); while (!((chunk.name[0] == 'd') && (chunk.name[1] == 'a') && (chunk.name[2] == 't') && (chunk.name[3] == 'a'))) { - DS::std_fseek(file, chunk.size, SEEK_CUR); - DS::std_fread(&chunk, sizeof(chunkHeader), 1, file); + DS::std_fseek(s_file, chunk.size, SEEK_CUR); + DS::std_fread(&chunk, sizeof(chunkHeader), 1, s_file); } - dataChunkStart = DS::std_ftell(file); + dataChunkStart = DS::std_ftell(s_file); static bool started = false; @@ -237,14 +237,14 @@ void playTrack(int track, int numLoops, int startFrame, int duration) { // No need to seek if we're starting from the beginning if (block != 0) { - DS::std_fseek(file, dataChunkStart + block * waveHeader.fmtBlockAlign, SEEK_SET); + DS::std_fseek(s_file, dataChunkStart + block * waveHeader.fmtBlockAlign, SEEK_SET); // consolePrintf("Startframe: %d msec: %d (%d,%d)\n", startFrame, tenthssec, samples, block); } //decompressBlock(); playNextBlock(); - DS::CD::numLoops = numLoops; + s_numLoops = numLoops; } void update() { @@ -266,20 +266,20 @@ void decompressBlock() { do { - DS::std_fread(&blockHeader, sizeof(blockHeader), 1, file); + DS::std_fread(&blockHeader, sizeof(blockHeader), 1, s_file); - DS::std_fread(&block[0], waveHeader.fmtBlockAlign - sizeof(blockHeader), 1, file); + DS::std_fread(&block[0], waveHeader.fmtBlockAlign - sizeof(blockHeader), 1, s_file); - if (DS::std_feof(file) ) { + if (DS::std_feof(s_file)) { // Reached end of file, so loop - if ((numLoops == -1) || (numLoops > 1)) { + if ((s_numLoops == -1) || (s_numLoops > 1)) { // Seek file to first packet - if (numLoops != -1) { - numLoops--; + if (s_numLoops != -1) { + s_numLoops--; } - DS::std_fseek(file, dataChunkStart, SEEK_SET); + DS::std_fseek(s_file, dataChunkStart, SEEK_SET); loop = true; } else { // Fill decompression buffer with zeros to prevent glitching @@ -465,7 +465,7 @@ void playNextBlock() { void stopTrack() { if (!isPlayingFlag) return; - DS::std_fclose(file); + DS::std_fclose(s_file); isPlayingFlag = false; @@ -498,8 +498,8 @@ bool trackExists(int num) { } consolePrintf("Looking for %s...", path.c_str()); - FILE *file; - if ((file = DS::std_fopen(path.c_str(), "r"))) { + FILE *file = DS::std_fopen(path.c_str(), "r"); + if (file) { consolePrintf("Success!\n"); setActive(true); DS::std_fclose(file); diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp index 163ae9518d..7315c25a43 100644 --- a/backends/platform/ds/arm9/source/dsmain.cpp +++ b/backends/platform/ds/arm9/source/dsmain.cpp @@ -133,8 +133,7 @@ void *operator new (size_t size) { void *res = __real_malloc(size); s_total_malloc += size; - if (!res) - { + if (!res) { // *((u8 *) NULL) = 0; consolePrintf("Failed alloc (new) %d (%d)\n", size, s_total_malloc); return NULL; diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp index dbcc310fa3..d0fb8fff3b 100644 --- a/backends/platform/ds/arm9/source/gbampsave.cpp +++ b/backends/platform/ds/arm9/source/gbampsave.cpp @@ -47,10 +47,10 @@ GBAMPSaveFile::~GBAMPSaveFile() { // consolePrintf("Closed file\n"); } -uint32 GBAMPSaveFile::read(void *buf, uint32 size) { - saveSize += size; -// consolePrintf("Read %d %d ", size, saveSize); - return DS::std_fread(buf, 1, size, handle); +uint32 GBAMPSaveFile::read(void *buf, uint32 length) { + saveSize += length; +// consolePrintf("Read %d %d ", length, saveSize); + return DS::std_fread(buf, 1, length, handle); } bool GBAMPSaveFile::eos() const { @@ -77,27 +77,27 @@ int32 GBAMPSaveFile::pos() const { int32 GBAMPSaveFile::size() const { int position = pos(); DS::std_fseek(handle, 0, SEEK_END); - int size = DS::std_ftell(handle); + int length = DS::std_ftell(handle); DS::std_fseek(handle, position, SEEK_SET); - return size; + return length; } -bool GBAMPSaveFile::seek(int32 pos, int whence) { - return DS::std_fseek(handle, pos, whence) == 0; +bool GBAMPSaveFile::seek(int32 newPos, int whence) { + return DS::std_fseek(handle, newPos, whence) == 0; } -uint32 GBAMPSaveFile::write(const void *buf, uint32 size) { - if (bufferPos + size > SAVE_BUFFER_SIZE) { +uint32 GBAMPSaveFile::write(const void *buf, uint32 length) { + if (bufferPos + length > SAVE_BUFFER_SIZE) { flushSaveBuffer(); - saveSize += size; -// consolePrintf("Writing %d bytes from %x", size, buf); -// DS::std_fwrite(buf, 1, size, handle); + saveSize += length; +// consolePrintf("Writing %d bytes from %x", length, buf); +// DS::std_fwrite(buf, 1, length, handle); - memcpy(buffer + bufferPos, buf, size); - bufferPos += size; + memcpy(buffer + bufferPos, buf, length); + bufferPos += length; - saveSize += size; + saveSize += length; /* int pos = 0; @@ -107,31 +107,31 @@ uint32 GBAMPSaveFile::write(const void *buf, uint32 size) { bufferPos = 512; pos += rest; flushSaveBuffer(); - size -= rest; + length -= rest; // consolePrintf("First section: %d\n", rest); - while (size >= 512) { + while (length >= 512) { DS::std_fwrite(((char *) (buf)) + pos, 1, 512, handle); - size -= 512; + length -= 512; pos += 512; -// consolePrintf("Full chunk, %d left ", size); +// consolePrintf("Full chunk, %d left ", length); } bufferPos = 0; - memcpy(buffer + bufferPos, ((char *) (buf)) + pos, size); - bufferPos += size; + memcpy(buffer + bufferPos, ((char *) (buf)) + pos, length); + bufferPos += length; // consolePrintf("%d left in buffer ", bufferPos);*/ } else { - memcpy(buffer + bufferPos, buf, size); - bufferPos += size; + memcpy(buffer + bufferPos, buf, length); + bufferPos += length; - saveSize += size; + saveSize += length; } -// if ((size > 100) || (size <= 0)) consolePrintf("Write %d bytes\n", size); - return size; +// if ((length > 100) || (length <= 0)) consolePrintf("Write %d bytes\n", length); + return length; } diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 418ab9d006..d750dfbc07 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -463,7 +463,7 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int } void OSystem_DS::updateScreen() { - static int cnt = 0; +// static int cnt = 0; // consolePrintf("updatescr %d\n", cnt++); if ((_frameBufferExists) && (DS::getIsDisplayMode8Bit())) { |