//------------------------------------------------ //--- 010 Editor v6.0 Binary Template // // File: OrCAD_SCH.bt // Authors: L. Potjewijd // Version: 1.3 // Purpose: Analyse drawings and blocks from // OrCad 3.20a programs. // Category: CAD // File Mask: *.sch // ID Bytes: 53 63 68 65 6D 61 74 69 63 20 46 49 4C 45 //Schematic FILE // History: // 1.3 2016-02-12 SweetScape Software: Updated header for repository submission. // 1.2 2015-05-31 L. Potjewijd: Public release. //------------------------------------------------ enum fType {BLOCK,WORKSHEET}; enum YesNo {no,yes}; enum paper {OrcadA,OrcadB,OrcadC,OrcadD,OrcadE}; enum rotate {none,CCW_90,CCW_180,CCW_270}; enum primT {dwgDetails,sheet,part,line,bus,junction,modulePort,label,busEntry,dashedLine,powerSymbol,text,EndOfList=0x0f}; enum IOtype {UNSPEC,OUTPUT,INPUT,BIDIR}; enum Pstyle {block,pointL,pointR,pointLR}; enum side {left,right,top,bottom}; enum PStype {circle,arrow,bar,wave}; enum align {centered,just_left,just_right}; enum Btype {downleft,upleft}; typedef byte bit; // just for readability typedef struct sText { byte Length ; if (Length > 0) char String[Length]; }; typedef struct fTxt (byte fixLen) { byte Length ; if (Length > 0) char String[Length]; if ((fixLen > 0) && (fixLen > Length)) char filler[fixLen-Length]; }; typedef struct Coord { short X; short Y; }; typedef struct PartField { Coord Location; sText Value; }; typedef struct IDstring { char text[14]; // "Schematic FILE" char terminator[3]; // #13, #10, #26 }; typedef struct hdrDet { IDstring head; if (head.text != "Schematic FILE") { Warning("File is not recognized as an OrCAD schematic file."); return -1; } ubyte tail[5]; int primitiveSectionLength ; Coord cursor; ushort zoom; }; typedef struct pP00 // TITLEBLOCK { ushort sheetNumber; ushort ofSheets; paper PaperSize; fTxt DocDate(12); fTxt DocNumber(36); fTxt RevNumber(3); fTxt Title(44); fTxt Organisation(44); fTxt AddressLine(44)[4] ; // for readability }; typedef struct pP01 // SHEET { local int i ; Coord Location; Coord Size; ubyte unknown[4]; ubyte Ports; sText FileName; sText SheetName; for ( i=0 ; i < Ports ; i++ ) struct PortDef { short NameXoffset; short PortYoffset; IOtype Type; sText Name; } Port; }; typedef struct pP02 // PART { Coord Location; Coord RefDesLocation; Coord ValueLocation; struct PartDet1 { ubyte raw ;/* this is to display */ FSkip (-1); /* the 'raw' bits, too */ BitfieldLeftToRight(); YesNo mirror : 1; rotate rotation : 2; byte subpackage : 5; } Details; struct PartDet2 { BigEndian(); /*************************/ ushort raw ;/* this is to display */ LittleEndian(); /* the 'raw' bits, too */ FSkip (-2); /*************************/ BitfieldLeftToRight(); bit bitF : 1 ; YesNo XtraFields : 1; bit bitD : 1 ; bit bitC : 1 ; bit bitB : 1 ; YesNo HideValue : 1; YesNo HideRefDes : 1; bit bit8 : 1 ; YesNo HideField8 : 1; YesNo HideField7 : 1; YesNo HideField6 : 1; YesNo HideField5 : 1; YesNo HideField4 : 1; YesNo HideField3 : 1; YesNo HideField2 : 1; YesNo HideField1 : 1; } Visibility; ubyte unknown[13] ; sText RefDes; sText PartValue; if (Visibility.XtraFields == yes) PartField Xfield[8] ; }; typedef struct pP03 // LINE, BUS or DASHED LINE { Coord Start; Coord End; }; typedef struct pP05 // JUNCTION { Coord Location; }; typedef struct pP06 // MOD_PORT { Coord Location; struct PortDet { ubyte MinLength; ubyte raw ;// this is to display // FSkip (-1); // the 'raw' bits, too // BitfieldLeftToRight(); IOtype PortType : 2; Pstyle PortStyle : 2; bit bit3 : 1 ; bit bit2 : 1 ; bit bit1 : 1 ; bit bit0 : 1 ; } Details; sText PortName ; }; typedef struct pP07 // LABEL or TEXT { Coord Location; short rawSize ; local ushort Size = Abs(rawSize); local YesNo Vertical = (rawSize < 0); sText Name; }; typedef struct pP08 // BUS_ENTRY { Coord Location; struct BusDet { ubyte raw ;// this is to display // FSkip (-1); // the 'raw' bits, too // BitfieldLeftToRight(); bit bit7 : 1 ; bit bit6 : 1 ; bit bit5 : 1 ; bit bit4 : 1 ; bit bit3 : 1 ; bit bit2 : 1 ; YesNo isBusType : 1; Btype direction : 1; } Details; }; typedef struct pP0A // PWR_SYM { Coord Location; struct PSDet { ubyte raw ;// this is to display // FSkip (-1); // the 'raw' bits, too // BitfieldLeftToRight(); bit bit7 : 1 ; bit bit6 : 1 ; bit bit5 : 1 ; bit bit4 : 1 ; side Orientation : 2; PStype Shape : 2; } Details; sText Name; }; typedef struct Element // the actual displayable items { primT Type ; ushort DataLength ; switch ( Type ) { case 0x00 : {pP00 TITLE_BLOCK;break;} case 0x01 : {pP01 SHEET; break;} case 0x02 : {pP02 PART; break;} case 0x03 : {pP03 LINE; break;} case 0x04 : {pP03 BUS; break;} case 0x05 : {pP05 JUNCTION; break;} case 0x06 : {pP06 MOD_PORT; break;} case 0x07 : {pP07 LABEL; break;} case 0x08 : {pP08 BUS_ENTRY; break;} case 0x09 : {pP03 DASH_LINE; break;} case 0x0a : {pP0A PWR_SYM; break;} case 0x0b : {pP07 TEXT; break;} case 0x0f : {/* End Of List */ break;} case 0x11 : {pP01 bSHEET; break;} case 0x12 : {pP02 bPART; break;} case 0x13 : {pP03 bLINE; break;} case 0x14 : {pP03 bBUS; break;} case 0x15 : {pP05 bJUNCTION; break;} case 0x16 : {pP06 bMOD_PORT; break;} case 0x17 : {pP07 bLABEL; break;} case 0x18 : {pP08 bBUS_ENTRY; break;} case 0x19 : {pP03 bDASH_LINE; break;} case 0x1a : {pP0A bPWR_SYM; break;} case 0x1b : {pP07 bTEXT; break;} default : { Printf ("Unknown primitive: %x, ",Type); return (-1); } } }; // *************************************************************************** hdrDet HEADER; do { Element primitive; } while ( primitive.Type != EndOfList ); while ( !FEof() ) { sText part; }