Fixed bug in z80 decompressing (case of ED as last byte of the block)

This commit is contained in:
fabio.olimpieri 2015-02-25 09:29:20 +00:00
parent 265be3cb86
commit 9dd5812a8b

View File

@ -56,21 +56,18 @@ void uncompress_z80(FILE *fichero,int length,unsigned char *memo) {
if(EDfound==2) { // we have two EDs if(EDfound==2) { // we have two EDs
counter=byte_loaded; counter=byte_loaded;
retval=fread(&byte_loaded,1,1,fichero); retval=fread(&byte_loaded,1,1,fichero); //ED byte
EDfound=0; EDfound=0;
continue; continue;
} }
if(byte_loaded==0xED) { if(byte_loaded==0xED) {
EDfound++; if (position+1<length) EDfound++; else memo[position++]=0xED; //If ED is the last byte of the block
} else { } else {
if(EDfound==1) { // we found ED xx. We write ED and xx if(EDfound==1) { // we found ED xx. We write ED and xx
memo[position++]=0xED; memo[position++]=0xED;
EDfound=0; EDfound=0;
} }
if (position>=length) {
break;
}
memo[position++]=byte_loaded; memo[position++]=byte_loaded;
} }
} while(position<length); } while(position<length);