コード例 #1
0
ファイル: cdc1700_dis.c プロジェクト: ST3ALth/simh
int disassem(char *buf, uint16 addr, t_bool dbg, t_bool targ, t_bool exec)
{
  int consumed = 1;
  char prot = ISPROTECTED(addr) ? 'P' : ' ';
  char mode[8], optional[8], temp[8], decoded[64];
  const char *spc, *shift, *inter, *dest;
  uint16 instr = LoadFromMem(addr);
  uint16 delta = instr & OPC_ADDRMASK;
  uint16 t;

  strcpy(optional, "    ");
  strcpy(decoded, "UNDEF");

  if ((instr & OPC_MASK) != 0) {
    strcpy(decoded, opName[(instr & OPC_MASK) >> 12]);

    if ((instr & MOD_RE) == 0)
      strcpy(mode, delta == 0 ? "+    " : "-    ");
    else strcpy(mode, "*    ");

    switch (instr & OPC_MASK) {
      case OPC_ADQ:
      case OPC_LDQ:
      case OPC_LDA:
      case OPC_EOR:
      case OPC_AND:
      case OPC_SUB:
      case OPC_ADD:
      case OPC_DVI:
      case OPC_MUI:
        if (ISCONSTANT(instr))
          strcat(mode, "=");
        break;
    }

    if (delta == 0) {
      consumed++;
      sprintf(optional, "%04X", LoadFromMem(addr + 1));
      sprintf(temp, "$%04X", LoadFromMem(addr + 1));
    } else sprintf(temp, "$%02X", delta);

    strcat(decoded, mode);
    if ((instr & MOD_IN) != 0)
      strcat(decoded, "(");
    strcat(decoded, temp);
    if ((instr & MOD_IN) != 0)
      strcat(decoded, ")");

    strcat(decoded, idxName[(instr & (MOD_I1 | MOD_I2)) >> 8]);
  } else {
コード例 #2
0
ファイル: XmlManager.cpp プロジェクト: HuugY/MFC_Project
bool CXmlManager::LoadFromFile(LPCTSTR pstrFilename, int encoding)
{
	ASSERT(pstrFilename);
    Release();
    HANDLE hFile = ::CreateFile(pstrFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    if( hFile == INVALID_HANDLE_VALUE ) return _Failed(_T("打开文件失败"));
    DWORD dwSize = ::GetFileSize(hFile, NULL);
    if( dwSize == 0 ) return _Failed(_T("File is empty"));
    if ( dwSize > 4096*1024 ) return _Failed(_T("File too large"));

    DWORD dwRead = 0;
    BYTE* pByte = new BYTE[ dwSize ];
    ::ReadFile( hFile, pByte, dwSize, &dwRead, NULL );
    ::CloseHandle( hFile );

    if( dwRead != dwSize ) 
	{
        delete[] pByte;
        Release();
        return _Failed(_T("Could not read file"));
    }

    bool ret = LoadFromMem(pByte, dwSize, encoding);
    delete[] pByte;
    return ret;
}
コード例 #3
0
ファイル: cdc1700_dp.c プロジェクト: agn453/simh
/*
 * Initiate a compare operation on a disk.
 */
static enum dpio_status DPDiskIOCompare(UNIT *uptr)
{
  struct dpio_unit *iou = (struct dpio_unit *)uptr->up7;
  uint16 numcy = ((uptr->flags & UNIT_854) != 0) ? DP_854CY : DP_853CY;
  uint32 lba = DPLBA(iou);
  int i;

  if (iou->cylinder >= numcy)
    return DPIO_ADDRERR;

  /*
   * Report any error in the underlying container infrastructure as an
   * address error.
   */
  if (sim_fseeko(uptr->fileref, lba * DP_NUMBY, SEEK_SET) ||
      (sim_fread(iou->buf, sizeof(uint16), DP_NUMWD, uptr->fileref) != DP_NUMWD))
    return DPIO_ADDRERR;

  for (i = 0; i < DP_NUMWD; i++) {
    if (iou->buf[i] != LoadFromMem(iou->CWA))
      return DPIO_MISMATCH;

    iou->CWA++;
    if (iou->CWA == iou->LWA) {
      DPDiskIOIncSector(iou);
      return DPIO_DONE;
    }
  }
  DPDiskIOIncSector(iou);
  return DPIO_MORE;
}
コード例 #4
0
ファイル: cdc1700_dp.c プロジェクト: agn453/simh
/*
 * Initiate a write operation on a disk.
 */
static enum dpio_status DPDiskIOWrite(UNIT *uptr)
{
  struct dpio_unit *iou = (struct dpio_unit *)uptr->up7;
  uint16 numcy = ((uptr->flags & UNIT_854) != 0) ? DP_854CY : DP_853CY;
  uint32 lba = DPLBA(iou);
  t_bool fill = FALSE;
  int i;

  if (iou->cylinder >= numcy)
    return DPIO_ADDRERR;

  for (i = 0; i < DP_NUMWD; i++) {
    if (!fill) {
      iou->buf[i] = LoadFromMem(iou->CWA);
      iou->CWA++;
      if (iou->CWA == iou->LWA)
        fill = TRUE;
    } else iou->buf[i] = 0;
  }

  /*
   * Report any error in the underlying container infrastructure as an
   * address error.
   */
  if (sim_fseeko(uptr->fileref, lba * DP_NUMBY, SEEK_SET) ||
      (sim_fwrite(iou->buf, sizeof(uint16), DP_NUMWD, uptr->fileref) != DP_NUMWD))
    return DPIO_ADDRERR;

  DPDiskIOIncSector(iou);
  return fill ? DPIO_DONE : DPIO_MORE;
}
コード例 #5
0
ファイル: cdc1700_dp.c プロジェクト: agn453/simh
/*
 * Set up a disk I/O operation with the A register containing FWA - 1.
 */
static void StartDPDiskIO(UNIT *uptr, struct dpio_unit *iou, uint16 state)
{
  iou->LWA = LoadFromMem(IOAreg);
  iou->CWA = ++IOAreg;

  DPbusy = TRUE;

  DPdev.STATUS &= IO_ST_READY | IO_ST_PROT | IO_1738_ONCYL;
  fw_IOunderwayEOP(&DPdev, 0);

  if ((dp_dev.dctrl & DBG_DTRACE) != 0)
    fprintf(DBGOUT,
            "%sDP - Start I/O, current: %04X, last: %04X, state: %d\r\n",
            INTprefix, iou->CWA, iou->LWA, state);

  if (iou->CWA == iou->LWA)  {
    /*
     * This is an empty I/O request, complete it immediately.
     */
    DPbusy = FALSE;

    if ((dp_dev.dctrl & DBG_DTRACE) != 0)
      fprintf(DBGOUT, "%sDP - Empty I/O request\r\n", INTprefix);

    fw_IOcompleteEOP(FALSE, &dp_dev, &DPdev, 0xFFFF, "Null transfer complete");
    return;
  }

  iou->state = state;
  sim_activate(uptr, DP_IO_WAIT);
}
コード例 #6
0
ファイル: UIMarkup.cpp プロジェクト: BattleNWar/YDWE
bool CMarkup::LoadFromFile(const wchar_t* pstrFilename, int encoding)
{
    Release();
	CUIBuffer buf;

	buf = CUIFile::LoadZip(pstrFilename);

	if (!buf)
	{
		return _Failed(L"Could not open file");
	}

	return LoadFromMem(buf.ptrData.get(), buf.nSize, encoding);
}
コード例 #7
0
BOOL CCfgFile::Load(LPCTSTR pFile, BOOL bMerge)
{_STTEX();
	if ( pFile == NULL ) return FALSE;

	// Lose old record
	if ( !bMerge ) Destroy();
	if ( !bMerge ) strcpy( m_szFileName, pFile );

	CWinFile	file;

	// Set crypto key
	if ( *m_szKey ) file.CryptoSetKey( m_szKey );

	// Open the file
	if ( !file.OpenExisting( pFile, GENERIC_READ ) )
		return FALSE;

	// Get file size
	DWORD size = file.Size();
	if ( size == 0 ) return FALSE;

	// Allocate memory
	TMem< BYTE > buf;
	if ( !buf.allocate( size + 1 ) ) return FALSE;

	// Read in the data into ram
	DWORD read;
	if ( !file.Read( buf, size, &read ) || read != size )
		return FALSE;
	buf[ size ] = 0;

	// Load the file
	if ( !LoadFromMem( buf, size, bMerge ) )
		return FALSE;

	if ( !bMerge ) strcpy( m_szFileName, pFile );

	return TRUE;
}