[wd2010] fix confusing expressions used for multisector mode

Wed, 16 Jan 2013 00:35:10 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Wed, 16 Jan 2013 00:35:10 +0000
changeset 123
82755a8d276e
parent 122
b214cf455ff2
child 124
ecaec4cfc644

[wd2010] fix confusing expressions used for multisector mode

src/wd2010.c file | annotate | diff | revisions
     1.1 --- a/src/wd2010.c	Wed Jan 16 00:34:11 2013 +0000
     1.2 +++ b/src/wd2010.c	Wed Jan 16 00:35:10 2013 +0000
     1.3 @@ -145,7 +145,7 @@
     1.4  {
     1.5  	// If there's data in the buffer, return it. Otherwise return 0xFF.
     1.6  	if (ctx->data_pos < ctx->data_len) {
     1.7 -		if (ctx->multi_sector && ctx->data_pos & !(ctx->data_pos & ~(ctx->geom_secsz - 1))){
     1.8 +		if (ctx->multi_sector && (ctx->data_pos > 0) && ((ctx->data_pos % ctx->geom_secsz) == 0)){
     1.9  			ctx->sector_count--;
    1.10  			ctx->sector_number++;
    1.11  		}
    1.12 @@ -171,7 +171,7 @@
    1.13  	// buffer, allow the write.
    1.14  	if (ctx->write_pos >= 0 && ctx->data_pos < ctx->data_len) {
    1.15  		// store data byte and increment pointer
    1.16 -		if (ctx->multi_sector && ctx->data_pos & !(ctx->data_pos & ~(ctx->geom_secsz - 1))){
    1.17 +		if (ctx->multi_sector && (ctx->data_pos > 0) && ((ctx->data_pos % ctx->geom_secsz) == 0)){
    1.18  			ctx->sector_count--;
    1.19  			ctx->sector_number++;
    1.20  		}