Skip to content

Commit f82140b

Browse files
ejaquayejaquay
authored andcommitted
Clear tape status from status line after timeout
If tape is inactive (counter is not changing) for more than fifteen seconds clear the tape status from the status line. Also adjust percentage rounding so 100% is displayed when load is complete.
1 parent 38d2cd1 commit f82140b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Cassette.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static unsigned int TempIndex=0;
4141
static unsigned int TapeRate=CAS_TAPEAUDIORATE;
4242
static unsigned int TapeSampleSize=0;
4343
static unsigned int MotorOffDelay = 0;
44+
static unsigned long PrvOffset=0,StalledCtr=0;
4445

4546
unsigned char One[21]={0xC8,0xE8,0xE8,0xF8,0xF8,0xE8,0xC8,0xA8,0x78,0x50,0x50,0x30,0x10,0x00,0x00,0x10,0x30,0x30,0x50,0x80,0xA8};
4647
unsigned char Zero[40]={0xC8,0xD8,0xE8,0xE8,0xF0,0xF8,0xF8,0xF8,0xF0,0xE8,0xD8,0xC8,0xB8,0xA8,0x90,0x78,0x78,0x68,0x50,0x40,0x30,0x20,0x10,0x08,0x00,0x00,0x00,0x08,0x10,0x10,0x20,0x30,0x40,0x50,0x68,0x68,0x80,0x90,0xA8,0xB8};
@@ -210,8 +211,14 @@ void SetTapeCounter(unsigned int Count, bool forced)
210211

211212
void UpdateTapeStatus(char* status, int max)
212213
{
213-
if (TotalSize > 0)
214-
snprintf(status, max, " | Tape:%05d (%d%%)", TapeOffset, TapeOffset * 100 / TotalSize);
214+
if (PrvOffset != TapeOffset) {
215+
StalledCtr = 0;
216+
PrvOffset = TapeOffset;
217+
} else {
218+
StalledCtr++;
219+
}
220+
if (TotalSize > 0 && StalledCtr < 1000)
221+
snprintf(status, max, " | Tape:%05d (%d%%)", TapeOffset, (TapeOffset + 50) * 100 / TotalSize);
215222
}
216223

217224
void SetTapeMode(unsigned char Mode) //Handles button pressed from Dialog

0 commit comments

Comments
 (0)