~ubuntu-branches/ubuntu/hardy/vice/hardy

« back to all changes in this revision

Viewing changes to src/drive/rotation.c

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2007-10-07 07:05:46 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071007070546-81yy0twlka7p2t0e
Tags: 1.22-1
* New upstream version (closes: #428280).
* Correct link to HTML documentation in manpage (closes: #409567).
* Fix most packaging mistakes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "types.h"
33
33
 
34
34
 
 
35
/*#define NEW_SYNC*/
 
36
 
35
37
#define ACCUM_MAX 0x10000
36
38
 
37
39
#define ROTATION_TABLE_SIZE 0x1000
309
311
    } /* if (rptr->shifter >= 8) */
310
312
}
311
313
 
312
 
#if 1
 
314
#ifdef NEW_SYNC
313
315
inline static unsigned int count_sync_from_left(BYTE gcr_byte)
314
316
{
315
317
    unsigned int num;
330
332
    return num;
331
333
}
332
334
#else
 
335
#if 0
333
336
inline static unsigned int is_one(DWORD gcr_data, unsigned int off)
334
337
{
335
338
    return ((gcr_data >> off) & 1);
359
362
        dptr->GCR_head_offset = head_next_offset(dptr);
360
363
    }
361
364
}
 
365
#else
 
366
inline static unsigned int count_sync_from_left(BYTE gcr_byte)
 
367
{
 
368
    unsigned int num;
 
369
 
 
370
    for (num = 0; (gcr_byte & 0x80) != 0; gcr_byte <<= 1)
 
371
        num++;
 
372
 
 
373
    return num;
 
374
}
 
375
 
 
376
inline static unsigned int count_sync_from_right(BYTE gcr_byte)
 
377
{
 
378
    unsigned int num;
 
379
 
 
380
    for (num = 0; (gcr_byte & 0x01) != 0; gcr_byte >>= 1)
 
381
        num++;
 
382
 
 
383
    return num;
 
384
}
 
385
#endif
362
386
#endif
363
387
 
364
388
/* Return non-zero if the Sync mark is found.  It is required to
368
392
   is found.  */
369
393
BYTE rotation_sync_found(drive_t *dptr)
370
394
{
371
 
#if 1
 
395
#ifdef NEW_SYNC
372
396
    unsigned int dnr;
373
397
    BYTE val, preval, nextval;
374
398
    unsigned int sync_bits;
402
426
       writes, do not change `drive[].bits_moved'!  */
403
427
    /* dptr->bits_moved = 0; */
404
428
#else
 
429
#if 0
405
430
    unsigned int dnr;
406
431
    DWORD val;
407
 
    unsigned int offset, i;
 
432
    unsigned int offset;
408
433
 
409
434
    dnr = dptr->mynumber;
410
435
 
423
448
    }
424
449
 
425
450
    return 0x80;
 
451
#else
 
452
    unsigned int dnr;
 
453
    BYTE val;
 
454
    unsigned int sync_bits;
 
455
    unsigned int num;
 
456
 
 
457
    dnr = dptr->mynumber;
 
458
 
 
459
    if (rotation[dnr].last_mode == 0 || dptr->attach_clk != (CLOCK)0)
 
460
        return 0x80;
 
461
 
 
462
    val = peek_current(dptr);
 
463
 
 
464
    sync_bits = count_sync_from_right(peek_previous(dptr))
 
465
                + count_sync_from_left(val);
 
466
 
 
467
    if (sync_bits >= 10)
 
468
        return 0; /* found! */
 
469
 
 
470
    if (val != 0xff) /* need to count sync bits from the right */
 
471
        sync_bits = count_sync_from_right(val);
 
472
 
 
473
    num = count_sync_from_left(peek_next(dptr));
 
474
 
 
475
    sync_bits += (num < rotation[dnr].shifter) ? num : rotation[dnr].shifter;
 
476
 
 
477
    return (sync_bits >= 10) ? 0 : 0x80;
 
478
 
 
479
    /* As the current rotation code cannot cope with non byte aligned
 
480
       writes, do not change `drive[].bits_moved'!  */
 
481
    /* dptr->bits_moved = 0; */
 
482
#endif
426
483
#endif
427
484
}
428
485