summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats
diff options
context:
space:
mode:
author Nigel Barnes <Pernod70@users.noreply.github.com>2017-04-17 18:27:07 +0100
committer Nigel Barnes <Pernod70@users.noreply.github.com>2017-04-17 18:49:42 +0100
commit29a7778ae71edc3354236fddc62c67e3ba3b7758 (patch)
tree5e9aad4f06ef0a0fb743a6e2bcc2ecaf8196c57e /src/lib/formats
parent79e60cfae2de66608cb6c76d023ab19204f75a39 (diff)
atom: Added csw cassette format
csw_cas: Fixed Coverity CID 136200 Logically dead code (nw)
Diffstat (limited to 'src/lib/formats')
-rw-r--r--src/lib/formats/atom_tap.cpp2
-rw-r--r--src/lib/formats/csw_cas.cpp38
-rw-r--r--src/lib/formats/csw_cas.h2
3 files changed, 16 insertions, 26 deletions
diff --git a/src/lib/formats/atom_tap.cpp b/src/lib/formats/atom_tap.cpp
index 3c606901b90..881433ef1a8 100644
--- a/src/lib/formats/atom_tap.cpp
+++ b/src/lib/formats/atom_tap.cpp
@@ -43,6 +43,7 @@
#include <assert.h>
#include "atom_tap.h"
+#include "csw_cas.h"
#include "uef_cas.h"
/***************************************************************************
PARAMETERS
@@ -143,5 +144,6 @@ const struct CassetteFormat atom_tap_format =
CASSETTE_FORMATLIST_START( atom_cassette_formats )
CASSETTE_FORMAT(atom_tap_format)
+ CASSETTE_FORMAT(csw_cassette_format)
CASSETTE_FORMAT(uef_cassette_format)
CASSETTE_FORMATLIST_END
diff --git a/src/lib/formats/csw_cas.cpp b/src/lib/formats/csw_cas.cpp
index a8feccf5300..84aab50d3b8 100644
--- a/src/lib/formats/csw_cas.cpp
+++ b/src/lib/formats/csw_cas.cpp
@@ -45,12 +45,8 @@ static int mycaslen;
static int csw_cas_to_wav_size( const uint8_t *casdata, int caslen )
{
- uint32_t SampleRate;
- uint32_t NumberOfPulses;
uint8_t MajorRevision;
uint8_t MinorRevision;
- uint8_t CompressionType;
- uint8_t Flags;
uint8_t HeaderExtensionLength;
std::vector<uint8_t> gz_ptr;
@@ -83,19 +79,8 @@ static int csw_cas_to_wav_size( const uint8_t *casdata, int caslen )
goto cleanup;
}
- SampleRate=get_leuint32(casdata+0x19);
- LOG_FORMATS("Sample rate %u\n",SampleRate);
-
- NumberOfPulses=get_leuint32(casdata+0x1d);
- LOG_FORMATS("Number Of Pulses %u\n",NumberOfPulses);
-
-
- CompressionType=casdata[0x21];
- Flags=casdata[0x22];
HeaderExtensionLength=casdata[0x23];
- LOG_FORMATS("CompressionType %u Flast %u HeaderExtensionLength %u\n",CompressionType,Flags,HeaderExtensionLength);
-
mycaslen=caslen;
//from here on down for now I am assuming it is compressed csw file.
in_ptr = (uint8_t*) casdata+0x34+HeaderExtensionLength;
@@ -180,7 +165,6 @@ static int csw_cas_fill_wave( int16_t *buffer, int length, uint8_t *bytes )
int bsize=0;
int i;
-
LOG_FORMATS("Length %d\n",length);
SampleRate=get_leuint32(bytes+0x19);
@@ -193,17 +177,19 @@ static int csw_cas_fill_wave( int16_t *buffer, int length, uint8_t *bytes )
Flags=bytes[0x22];
HeaderExtensionLength=bytes[0x23];
- if ((Flags&0)==0)
- {
- Bit=-100;
- }
- else
- {
- Bit=100;
- }
+ Bit = (Flags & 1) ? 100 : -100;
+
+ LOG_FORMATS("CompressionType %u Flags %u HeaderExtensionLength %u\n",CompressionType,Flags,HeaderExtensionLength);
- LOG_FORMATS("CompressionType %u Flast %u HeaderExtensionLength %u\n",CompressionType,Flags,HeaderExtensionLength);
+ LOG_FORMATS("Encoder: ");
+ for (i = 0; i < 16; i++)
+ LOG_FORMATS("%c", bytes[0x24 + i]);
+ LOG_FORMATS("\n");
+ LOG_FORMATS("Header: ");
+ for (i = 0; i < HeaderExtensionLength; i++)
+ LOG_FORMATS("%c", bytes[0x34 + i]);
+ LOG_FORMATS("\n");
//from here on down for now I am assuming it is compressed csw file.
in_ptr = (uint8_t*) bytes+0x34+HeaderExtensionLength;
@@ -302,7 +288,7 @@ static cassette_image::error csw_cassette_load( cassette_image *cassette )
return cassette_legacy_construct( cassette, &csw_legacy_fill_wave );
}
-static const struct CassetteFormat csw_cassette_format = {
+const struct CassetteFormat csw_cassette_format = {
"csw",
csw_cassette_identify,
csw_cassette_load,
diff --git a/src/lib/formats/csw_cas.h b/src/lib/formats/csw_cas.h
index 2f1971bfdbd..cdc36001c60 100644
--- a/src/lib/formats/csw_cas.h
+++ b/src/lib/formats/csw_cas.h
@@ -11,6 +11,8 @@
#include "cassimg.h"
+extern const struct CassetteFormat csw_cassette_format;
+
CASSETTE_FORMATLIST_EXTERN(csw_cassette_formats);
CASSETTE_FORMATLIST_EXTERN(bbc_cassette_formats);