Ejemplo n.º 1
0
/*
 * Verify game state is sane.
 * Correct minor problems, but write corrections to backing files only
 * if @may_put is non-zero.
 * Return -1 if uncorrected problems remain, else 0.
 */
int
ef_verify_state(int may_put)
{
    int retval = 0;
    int i;

    for (i = 0; i < EF_MAX; i++) {
	if (EF_IS_GAME_STATE(i) || EF_IS_VIEW(i))
	    retval |= verify_table(i);
    }

    /* Special checks */
    retval |= verify_sectors(may_put);
    retval |= verify_planes(may_put);
    retval |= verify_lands(may_put);
    retval |= verify_nukes(may_put);
    return retval;
}
Ejemplo n.º 2
0
char ATA_DEVICE::exec_ata_cmd(unsigned char cmd)
{
//   printf(__FUNCTION__" cmd=%02X\n", cmd);
   // EXECUTE DEVICE DIAGNOSTIC for both ATA and ATAPI
   if (cmd == 0x90)
   {
       reset_signature(RESET_SOFT);
       return 1;
   }

   if (atapi)
       return 0;

   // INITIALIZE DEVICE PARAMETERS
   if (cmd == 0x91)
   {
     // pos = (reg.cyl * h + (reg.devhead & 0x0F)) * s + reg.sec - 1;
     h = (reg.devhead & 0xF) + 1;
     s = reg.count;
     if(s == 0)
     {
          reg.status = STATUS_DRDY | STATUS_DF | STATUS_DSC | STATUS_ERR;
          return 1;
     }

     c = lba / s / h;

     reg.status = STATUS_DRDY | STATUS_DSC;
     return 1;
   }

   if ((cmd & 0xFE) == 0x20) // ATA-3 (mandatory), read sectors
   { // cmd #21 obsolette, rqd for is-dos
//       printf(__FUNCTION__" sec_cnt=%d\n", reg.count);
       read_sectors();
       return 1;
   }

   if((cmd & 0xFE) == 0x40) // ATA-3 (mandatory),  verify sectors
   { //rqd for is-dos
       verify_sectors();
       return 1;
   }

   if ((cmd & 0xFE) == 0x30 && !readonly) // ATA-3 (mandatory), write sectors
   {
      if (seek())
      {
          state = S_WRITE_SECTORS;
          reg.status = STATUS_DRQ | STATUS_DSC;
          transptr = 0;
          transcount = 0x100;
      }
      return 1;
   }

   if(cmd == 0x50) // format track (данная реализация - ничего не делает)
   {
      reg.sec = 1;
      if (seek())
      {
          state = S_FORMAT_TRACK;
          reg.status = STATUS_DRQ | STATUS_DSC;
          transptr = 0;
          transcount = 0x100;
      }
      return 1;
   }

   if (cmd == 0xEC)
   {
       prepare_id();
       return 1;
   }

   if (cmd == 0xE7)
   { // FLUSH CACHE
      if (ata_p.flush())
      {
          command_ok();
          intrq = 1;
      }
      else
          reg.status = STATUS_DRDY | STATUS_DF | STATUS_DSC | STATUS_ERR; // 0x71
      return 1;
   }

   if (cmd == 0x10)
   {
      recalibrate();
      command_ok();
      intrq = 1;
      return 1;
   }

   if (cmd == 0x70)
   { // seek
      if (!seek())
          return 1;
      command_ok();
      intrq = 1;
      return 1;
   }

   printf("*** unknown ata cmd %02X ***\n", cmd);

   return 0;
}