void DreamcastFile::timeToBCD(vmu_timestamp_t *tdec) { tdec->cent=dec_to_bcd(tdec->cent); tdec->year=dec_to_bcd(tdec->year); tdec->month=dec_to_bcd(tdec->month); tdec->day=dec_to_bcd(tdec->day); tdec->hour=dec_to_bcd(tdec->hour); tdec->min=dec_to_bcd(tdec->min); tdec->sec=dec_to_bcd(tdec->sec); tdec->dow=dec_to_bcd(tdec->dow); }
/* ts A90830 : changed return type to int @return 0= failure 1= success */ int sector_headers(struct burn_write_opts *o, unsigned char *out, int mode, int leadin) { #ifdef Libburn_ecma130ab_includeD struct burn_drive *d = o->drive; unsigned int crc; int min, sec, frame; int modebyte = -1; int ret; ret = sector_headers_is_ok(o, mode); if (ret != 2) return !!ret; modebyte = 1; out[0] = 0; memset(out + 1, 0xFF, 10); /* sync */ out[11] = 0; if (leadin) { burn_lba_to_msf(d->rlba, &min, &sec, &frame); out[12] = dec_to_bcd(min) + 0xA0; out[13] = dec_to_bcd(sec); out[14] = dec_to_bcd(frame); out[15] = modebyte; } else { burn_lba_to_msf(d->alba, &min, &sec, &frame); out[12] = dec_to_bcd(min); out[13] = dec_to_bcd(sec); out[14] = dec_to_bcd(frame); out[15] = modebyte; } if (mode & BURN_MODE1) { #ifdef Libburn_no_crc_C crc = 0; /* dummy */ #else crc = crc_32(out, 2064); #endif out[2064] = crc & 0xFF; crc >>= 8; out[2065] = crc & 0xFF; crc >>= 8; out[2066] = crc & 0xFF; crc >>= 8; out[2067] = crc & 0xFF; }
void set_time(struct tm *t) { int regA, regB; if (Wflag) { /* Set A and B registers to their proper values according to the AT * reference manual. (For if it gets messed up, but the BIOS doesn't * repair it.) */ write_register(RTC_REG_A, RTC_A_DV_OK | RTC_A_RS_DEF); write_register(RTC_REG_B, RTC_B_24); } /* Inhibit updates. */ regB= read_register(RTC_REG_B); write_register(RTC_REG_B, regB | RTC_B_SET); t->tm_mon++; /* Counts from 1. */ if (y2kflag) { /* Set the clock back 20 years to avoid Y2K bug, good until 2020. */ if (t->tm_year >= 100) t->tm_year -= 20; } if ((regB & 0x04) == 0) { /* Convert binary to BCD (default RTC mode) */ t->tm_year = dec_to_bcd(t->tm_year % 100); t->tm_mon = dec_to_bcd(t->tm_mon); t->tm_mday = dec_to_bcd(t->tm_mday); t->tm_hour = dec_to_bcd(t->tm_hour); t->tm_min = dec_to_bcd(t->tm_min); t->tm_sec = dec_to_bcd(t->tm_sec); } write_register(RTC_YEAR, t->tm_year); write_register(RTC_MONTH, t->tm_mon); write_register(RTC_MDAY, t->tm_mday); write_register(RTC_HOUR, t->tm_hour); write_register(RTC_MIN, t->tm_min); write_register(RTC_SEC, t->tm_sec); /* Stop the clock. */ regA= read_register(RTC_REG_A); write_register(RTC_REG_A, regA | RTC_A_DV_STOP); /* Allow updates and restart the clock. */ write_register(RTC_REG_B, regB); write_register(RTC_REG_A, regA); }
static void subcode_toc(struct burn_drive *d, int mode, unsigned char *data) { unsigned char *q; int track; int crc; int min, sec, frame; track = d->toc_temp / 3; memset(data, 0, 96); q = data + 12; burn_lba_to_msf(d->rlba, &min, &sec, &frame); /*XXX track numbers are BCD a0 - 1st track ctrl a1 - last track ctrl a2 - lout ctrl */ q[0] = (d->toc_entry[track].control << 4) + 1; q[1] = 0; if (d->toc_entry[track].point < 100) q[2] = dec_to_bcd(d->toc_entry[track].point); else q[2] = d->toc_entry[track].point; q[3] = dec_to_bcd(min); q[4] = dec_to_bcd(sec); q[5] = dec_to_bcd(frame); q[6] = 0; q[7] = dec_to_bcd(d->toc_entry[track].pmin); q[8] = dec_to_bcd(d->toc_entry[track].psec); q[9] = dec_to_bcd(d->toc_entry[track].pframe); #ifdef Libburn_no_crc_C crc = 0; /* dummy */ #else crc = crc_ccitt(q, 10); #endif q[10] = crc >> 8; q[11] = crc & 0xFF; d->toc_temp++; d->toc_temp %= (d->toc_entries * 3); }
static void subcode_lout(struct burn_write_opts *o, unsigned char control, unsigned char *data) { struct burn_drive *d = o->drive; unsigned char *q; int crc; int rmin, min, rsec, sec, rframe, frame; memset(data, 0, 96); q = data + 12; burn_lba_to_msf(d->alba, &min, &sec, &frame); burn_lba_to_msf(d->rlba, &rmin, &rsec, &rframe); if (((rmin == 0) && (rsec == 0) && (rframe == 0)) || ((rsec >= 2) && !((rframe / 19) % 2))) memset(data, 0xFF, 12); q[0] = (control << 4) + 1; q[1] = 0xAA; q[2] = 0x01; q[3] = dec_to_bcd(rmin); q[4] = dec_to_bcd(rsec); q[5] = dec_to_bcd(rframe); q[6] = 0; q[7] = dec_to_bcd(min); q[8] = dec_to_bcd(sec); q[9] = dec_to_bcd(frame); #ifdef Libburn_no_crc_C crc = 0; /* dummy */ #else crc = crc_ccitt(q, 10); #endif q[10] = crc >> 8; q[11] = crc & 0xFF; }
void subcode_user(struct burn_write_opts *o, unsigned char *subcodes, unsigned char tno, unsigned char control, unsigned char indx, struct isrc *isrc, int psub) { struct burn_drive *d = o->drive; unsigned char *p, *q; int crc; int m, s, f, c, qmode; /* 1, 2 or 3 */ memset(subcodes, 0, 96); p = subcodes; if ((tno == 1) && (d->rlba == -150)) memset(p, 0xFF, 12); if (psub) memset(p, 0xFF, 12); q = subcodes + 12; qmode = 1; /* every 1 in 10 we can do something different */ if (d->rlba % 10 == 0) { /* each of these can occur 1 in 100 */ if ((d->rlba / 10) % 10 == 0) { if (o->has_mediacatalog) qmode = 2; } else if ((d->rlba / 10) % 10 == 1) { if (isrc && isrc->has_isrc) qmode = 3; } } /* ts A61010 : this cannot happen. Assert for fun ? */ /* a ssert(qmode == 1 || qmode == 2 || qmode == 3); */ switch (qmode) { case 1: q[1] = dec_to_bcd(tno); /* track number */ q[2] = dec_to_bcd(indx); /* index XXX read this shit from the track array */ burn_lba_to_msf(d->rlba, &m, &s, &f); q[3] = dec_to_bcd(m); /* rel min */ q[4] = dec_to_bcd(s); /* rel sec */ q[5] = dec_to_bcd(f); /* rel frame */ q[6] = 0; /* zero */ burn_lba_to_msf(d->alba, &m, &s, &f); q[7] = dec_to_bcd(m); /* abs min */ q[8] = dec_to_bcd(s); /* abs sec */ q[9] = dec_to_bcd(f); /* abs frame */ break; case 2: /* media catalog number */ q[1] = (o->mediacatalog[0] << 4) + o->mediacatalog[1]; q[2] = (o->mediacatalog[2] << 4) + o->mediacatalog[3]; q[3] = (o->mediacatalog[4] << 4) + o->mediacatalog[5]; q[4] = (o->mediacatalog[6] << 4) + o->mediacatalog[7]; q[5] = (o->mediacatalog[8] << 4) + o->mediacatalog[9]; q[6] = (o->mediacatalog[10] << 4) + o->mediacatalog[11]; q[7] = o->mediacatalog[12] << 4; q[8] = 0; burn_lba_to_msf(d->alba, &m, &s, &f); q[9] = dec_to_bcd(f); /* abs frame */ break; case 3: c = char_to_isrc(isrc->country[0]); /* top 6 bits of [1] is the first country code */ q[1] = c << 2; c = char_to_isrc(isrc->country[1]); /* bottom 2 bits of [1] is part of the second country code */ q[1] += (c >> 4); /* top 4 bits if [2] is the rest of the second country code */ q[2] = c << 4; c = char_to_isrc(isrc->owner[0]); /* bottom 4 bits of [2] is part of the first owner code */ q[2] += (c >> 2); /* top 2 bits of [3] is the rest of the first owner code */ q[3] = c << 6; c = char_to_isrc(isrc->owner[1]); /* bottom 6 bits of [3] is the entire second owner code */ q[3] += c; c = char_to_isrc(isrc->owner[2]); /* top 6 bits of [4] are the third owner code */ q[4] = c << 2; /* [5] is the year in 2 BCD numbers */ q[5] = dec_to_bcd(isrc->year % 100); /* [6] is the first 2 digits in the serial */ q[6] = dec_to_bcd(isrc->serial % 100); /* [7] is the next 2 digits in the serial */ q[7] = dec_to_bcd((isrc->serial / 100) % 100); /* the top 4 bits of [8] is the last serial digit, the rest is zeros */ q[8] = dec_to_bcd((isrc->serial / 10000) % 10) << 4; burn_lba_to_msf(d->alba, &m, &s, &f); q[9] = dec_to_bcd(f); /* abs frame */ break; } q[0] = (control << 4) + qmode; #ifdef Libburn_no_crc_C crc = 0; /* dummy */ #else crc = crc_ccitt(q, 10); #endif q[10] = crc >> 8; q[11] = crc & 0xff; }