Skip to content

Commit

Permalink
[#28] Spectrum Tape: Minor source code improvements and bugfixes (Par…
Browse files Browse the repository at this point in the history
…t 9: Fixed computation of checksum for newly imported data blocks)
  • Loading branch information
tomas-nestorovic committed Nov 16, 2019
1 parent a39c627 commit 8d771d0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Main/src/SpectrumDos_Tape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@
#define NUMBER_OF_BYTES_TO_ALLOCATE_FILE(dataLength)\
(sizeof(TTapeFile)+dataLength)

static BYTE __getChecksum__(BYTE flag,PCBYTE data,WORD nBytes){
// computes and returns the Checksum based on specified Flag and Data
while (nBytes--) flag^=*data++;
return flag;
}

TStdWinError CSpectrumDos::CTape::ImportFile(CFile *f,DWORD fileSize,LPCTSTR nameAndExtension,DWORD winAttr,PFile &rFile){
// imports specified File (physical or virtual) into the Image; returns Windows standard i/o error
// - checking if there's an empty slot in Tape's "Directory"
Expand Down Expand Up @@ -317,6 +323,7 @@
}
// - importing File Data
f->Read( tf->data, fileSize );
tf->dataChecksum=__getChecksum__( tf->dataBlockFlag, tf->data, fileSize );
// - File successfully imported into Tape
m_bModified=TRUE;
return ERROR_SUCCESS;
Expand Down Expand Up @@ -379,11 +386,6 @@



static BYTE __getChecksum__(BYTE flag,PCBYTE data,WORD nBytes){
// computes and returns the Checksum based on specified Flag and Data
while (nBytes--) flag^=*data++;
return flag;
}
BOOL CSpectrumDos::CTape::DoSave(LPCTSTR,BOOL){
// True <=> Image successfully saved, otherwise False
fileManager.f.SetLength(0); // rewriting Tape's underlying physical file
Expand Down

0 comments on commit 8d771d0

Please sign in to comment.