Java Code Examples for com.igormaznitsa.jbbp.io.JBBPBitInputStream#readUnsignedShort()
The following examples show how to use
com.igormaznitsa.jbbp.io.JBBPBitInputStream#readUnsignedShort() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Info.java From zxpoly with GNU General Public License v3.0 | 5 votes |
public Info(final InputStream in) throws IOException { final JBBPBitInputStream bitin = new JBBPBitInputStream(in); this.name = new String(bitin.readByteArray(bitin.readByte()), StandardCharsets.US_ASCII); this.type = (char) bitin.readUnsignedShort(JBBPByteOrder.BIG_ENDIAN); this.startAddress = bitin.readInt(JBBPByteOrder.BIG_ENDIAN); this.length = bitin.readInt(JBBPByteOrder.BIG_ENDIAN); this.offset = bitin.readInt(JBBPByteOrder.BIG_ENDIAN); this.extra = bitin.readByteArray(bitin.readInt(JBBPByteOrder.BIG_ENDIAN)); }
Example 2
Source File: TAPPlugin.java From zxpoly with GNU General Public License v3.0 | 4 votes |
@Override public ReadResult readFrom(final File file, final int index) throws IOException { JBBPBitInputStream in = new JBBPBitInputStream(new FileInputStream(file)); try { int curindex = 0; while (in.hasAvailableData()) { final int length = in.readUnsignedShort(JBBPByteOrder.LITTLE_ENDIAN); final int flag = in.readByte(); final int offset = (int) in.getCounter(); final Info info; if (flag == 0) { // standard rom final int standardflag = in.readByte(); final byte[] data = in.readByteArray(length - 2); final int datalen = extractDataLengthField(data); final int address = extractStartAddressField(data); switch (standardflag) { case 0: { // program header info = new Info(extractHeaderName(data), 'B', address, datalen, offset); } break; case 1: { // numeric data array header info = new Info(extractHeaderName(data), 'N', address, datalen, offset); } break; case 2: { // alphanumeric data array header info = new Info(extractHeaderName(data), 'S', address, datalen, offset); } break; case 3: { // code block info = new Info(extractHeaderName(data), 'C', address, datalen, offset); } break; default: { // unknown info = new Info("<Unknown>", 'U', address, length, offset); } break; } if (curindex < index) { curindex++; } else { throw new IllegalArgumentException("Selected item is not a data block but a header"); } } else { if (flag == 0xFF) { // data block info = new Info("<Code>", 'D', -1, length - 2, offset); } else { // custom info = new Info("<Unknown>", 'U', -1, length, offset); } if (curindex < index) { curindex++; in.skip(length - 1); } else { return new ReadResult(new ZXPolyData(info, this, in.readByteArray(length - 1)), null); } } } throw new IllegalArgumentException("Can't find file for index " + index); } finally { JBBPUtils.closeQuietly(in); } }
Example 3
Source File: VarCustomImpl.java From java-binary-block-parser with Apache License 2.0 | 4 votes |
@Override public JBBPAbstractField readCustomFieldType(Object sourceStruct, JBBPBitInputStream inStream, JBBPFieldTypeParameterContainer typeParameterContainer, JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue, boolean readWholeStream, int arraySize) throws IOException { return new JBBPFieldShort(nullableNamedFieldInfo, (short) inStream.readUnsignedShort(typeParameterContainer.getByteOrder())); }
Example 4
Source File: VarCustomImpl.java From java-binary-block-parser with Apache License 2.0 | 4 votes |
@Override public JBBPAbstractField readCustomFieldType(Object sourceStruct, JBBPBitInputStream inStream, JBBPFieldTypeParameterContainer typeParameterContainer, JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue, boolean readWholeStream, int arraySize) throws IOException { return new JBBPFieldShort(nullableNamedFieldInfo, (short) inStream.readUnsignedShort(typeParameterContainer.getByteOrder())); }