summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Robbbert <Robbbert@users.noreply.github.com>2021-03-28 21:08:40 +1100
committer Robbbert <Robbbert@users.noreply.github.com>2021-03-28 21:08:40 +1100
commit648374e4350e710befe20b69510bd0e2d8de3171 (patch)
tree8ffd0f18cbd1255f081f8e965a1b8d4d85d836d6
parentbbe3ba79aa6b4f20542ec4cc3a7b2d2fd253fcd0 (diff)
trs80: fixed loading of CAS files
-rw-r--r--src/lib/formats/trs_cas.cpp54
-rw-r--r--src/mame/drivers/trs80.cpp1
-rw-r--r--src/mame/machine/trs80.cpp3
3 files changed, 27 insertions, 31 deletions
diff --git a/src/lib/formats/trs_cas.cpp b/src/lib/formats/trs_cas.cpp
index 7556c392427..0c17daaa493 100644
--- a/src/lib/formats/trs_cas.cpp
+++ b/src/lib/formats/trs_cas.cpp
@@ -15,42 +15,33 @@ Support for TRS80 .cas cassette images
#define SMPHI 32767
-static int cas_size; // FIXME: global variable prevents mutliple instances
+static int cas_size; // FIXME: global variable prevents multiple instances
/*******************************************************************
Generate one high-low cycle of sample data
********************************************************************/
-static inline int trs80l2_cas_cycle(int16_t *buffer, int sample_pos, int silence, int high, int low)
+static inline int trs80l2_cas_cycle(int16_t *buffer, int sample_pos, bool bit)
{
- int i = 0;
+ uint8_t i;
if ( buffer )
{
- while( i < silence )
- {
- buffer[ sample_pos + i ] = SILENCE;
- i++;
- }
- while( i < silence + high)
- {
- buffer[ sample_pos + i ] = SMPHI;
- i++;
- }
-
- while( i < silence + high + low )
- {
- buffer[ sample_pos + i ] = SMPLO;
- i++;
- }
+ for (i = 0; i < 32; i++)
+ buffer[ sample_pos++ ] = SILENCE;
+ for (i = 0; i < 6; i++)
+ buffer[ sample_pos++ ] = bit ? SMPHI : SILENCE;
+ for (i = 0; i < 6; i++)
+ buffer[ sample_pos++ ] = bit ? SMPLO : SILENCE;
}
- return silence + high + low;
+ return 44;
}
static int trs80l2_handle_cas(int16_t *buffer, const uint8_t *casdata)
{
- int data_pos, sample_count;
+ int data_pos = 0, sample_count = 0;
+ bool a5sw = false;
data_pos = 0;
sample_count = 0;
@@ -58,24 +49,31 @@ static int trs80l2_handle_cas(int16_t *buffer, const uint8_t *casdata)
while( data_pos < cas_size )
{
uint8_t data = casdata[data_pos];
- int i;
- for ( i = 0; i < 8; i++ )
+ for (uint8_t i = 0; i < 8; i++ )
{
/* Signal code */
- sample_count += trs80l2_cas_cycle( buffer, sample_count, 33, 6, 6 );
+ sample_count += trs80l2_cas_cycle( buffer, sample_count, true );
/* Bit code */
- if ( data & 0x80 )
- sample_count += trs80l2_cas_cycle( buffer, sample_count, 33, 6, 6 );
- else
- sample_count += trs80l2_cas_cycle( buffer, sample_count, 33 + 6 + 6, 0, 0 );
+ sample_count += trs80l2_cas_cycle( buffer, sample_count, data >> 7 );
data <<= 1;
}
+ if (!a5sw && (casdata[data_pos] == 0xA5))
+ {
+ a5sw = true;
+ // Need 1ms silence here while rom is busy
+ sample_count += trs80l2_cas_cycle( buffer, sample_count, false );
+ }
+
data_pos++;
}
+
+ // Specification requires a short silence to indicate EOF
+ sample_count += trs80l2_cas_cycle( buffer, sample_count, false );
+ sample_count += trs80l2_cas_cycle( buffer, sample_count, false );
return sample_count;
}
diff --git a/src/mame/drivers/trs80.cpp b/src/mame/drivers/trs80.cpp
index 8a2c922524e..56f9c924c1d 100644
--- a/src/mame/drivers/trs80.cpp
+++ b/src/mame/drivers/trs80.cpp
@@ -155,7 +155,6 @@ lnw80: works
2021-03-26 MT 07903 - most floppies no longer boot.
Most machines have problems loading real tapes.
- Cannot load CAS tapes, but they can be loaded with trs80m3.
*******************************************************************************************************/
diff --git a/src/mame/machine/trs80.cpp b/src/mame/machine/trs80.cpp
index c68964cd46f..99dbe12934d 100644
--- a/src/mame/machine/trs80.cpp
+++ b/src/mame/machine/trs80.cpp
@@ -12,8 +12,7 @@
TIMER_CALLBACK_MEMBER(trs80_state::cassette_data_callback)
{
-/* This does all baud rates. 250 baud (trs80), and 500 baud (all others) set bit 7 of "cassette_data".
- 1500 baud (trs80m3, trs80m4) is interrupt-driven and uses bit 0 of "cassette_data" */
+// This does all baud rates. 250 baud (trs80), and 500 baud (all others) set bit 7 of "cassette_data".
double new_val = (m_cassette->input());