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