src/wd279x.c

changeset 71
22452603e214
parent 57
feb84193a43a
child 73
05ef5f3c5246
     1.1 --- a/src/wd279x.c	Tue Dec 28 19:23:57 2010 +0000
     1.2 +++ b/src/wd279x.c	Tue Dec 28 19:55:13 2010 +0000
     1.3 @@ -4,6 +4,9 @@
     1.4  #include "musashi/m68k.h"
     1.5  #include "wd279x.h"
     1.6  
     1.7 +#define NDEBUG
     1.8 +#include "utils.h"
     1.9 +
    1.10  /// WD2797 command constants
    1.11  enum {
    1.12  	CMD_MASK				= 0xF0,		///< Bit mask to detect command bits
    1.13 @@ -172,7 +175,7 @@
    1.14  			if (ctx->cmd_has_drq) {
    1.15  				temp = ctx->status & ~0x03;
    1.16  				temp |= (ctx->data_pos < ctx->data_len) ? 0x02 : 0x00;
    1.17 -				printf("\tWDFDC rd sr, has drq, pos=%lu len=%lu, sr=0x%02X\n", ctx->data_pos, ctx->data_len, temp);
    1.18 +				LOG("\tWDFDC rd sr, has drq, pos=%lu len=%lu, sr=0x%02X", ctx->data_pos, ctx->data_len, temp);
    1.19  			} else {
    1.20  				temp = ctx->status & ~0x01;
    1.21  			}
    1.22 @@ -382,12 +385,12 @@
    1.23  				case CMD_READ_SECTOR:
    1.24  				case CMD_READ_SECTOR_MULTI:
    1.25  					ctx->head = (val & 0x02) ? 1 : 0;
    1.26 -					printf("WD279X: READ SECTOR cmd=%02X chs=%d:%d:%d\n", cmd, ctx->track, ctx->head, ctx->sector);
    1.27 +					LOG("WD279X: READ SECTOR cmd=%02X chs=%d:%d:%d", cmd, ctx->track, ctx->head, ctx->sector);
    1.28  					// Read Sector or Read Sector Multiple
    1.29  
    1.30  					// Check to see if the cyl, hd and sec are valid
    1.31  					if ((ctx->track > (ctx->geom_tracks-1)) || (ctx->head > (ctx->geom_heads-1)) || (ctx->sector > ctx->geom_spt) || (ctx->sector == 0)) {
    1.32 -						fprintf(stderr, "*** WD2797 ALERT: CHS parameter limit exceeded! CHS=%d:%d:%d, maxCHS=%d:%d:%d\n",
    1.33 +						LOG("*** WD2797 ALERT: CHS parameter limit exceeded! CHS=%d:%d:%d, maxCHS=%d:%d:%d",
    1.34  								ctx->track, ctx->head, ctx->sector,
    1.35  								ctx->geom_tracks-1, ctx->geom_heads-1, ctx->geom_spt);
    1.36  						// CHS parameters exceed limits
    1.37 @@ -414,13 +417,13 @@
    1.38  						lba = (((ctx->track * ctx->geom_heads * ctx->geom_spt) + (ctx->head * ctx->geom_spt) + ctx->sector) + i) - 1;
    1.39  						// convert LBA to byte address
    1.40  						lba *= ctx->geom_secsz;
    1.41 -						printf("\tREAD lba = %lu\n", lba);
    1.42 +						LOG("\tREAD lba = %lu", lba);
    1.43  
    1.44  						// Read the sector from the file
    1.45  						fseek(ctx->disc_image, lba, SEEK_SET);
    1.46 +						// TODO: check fread return value! if < secsz, BAIL! (call it a crc error or secnotfound maybe? also log to stderr)
    1.47  						ctx->data_len += fread(&ctx->data[ctx->data_len], 1, ctx->geom_secsz, ctx->disc_image);
    1.48 -						printf("\tREAD len=%lu, pos=%lu, ssz=%d\n", ctx->data_len, ctx->data_pos, ctx->geom_secsz);
    1.49 -						// TODO: check fread return value! if < secsz, BAIL! (call it a crc error or secnotfound maybe? also log to stderr)
    1.50 +						LOG("\tREAD len=%lu, pos=%lu, ssz=%d", ctx->data_len, ctx->data_pos, ctx->geom_secsz);
    1.51  					}
    1.52  
    1.53  					ctx->status = 0;