implement unsigned byte & short value

This commit is contained in:
REAndroid 2023-03-12 09:42:38 -04:00
parent f81616f2f1
commit e873913f68

View File

@ -73,6 +73,13 @@ public class ByteArray extends BlockItem {
}
return getBytesInternal()[index];
}
public int getByteUnsigned(int index){
Byte b = get(index);
if(b==null){
return 0;
}
return 0xff & b;
}
public final void put(int index, byte value){
byte[] bts = getBytesInternal();
bts[index]=value;
@ -99,6 +106,9 @@ public class ByteArray extends BlockItem {
bts[offset+1]= (byte) (val >>> 8 & 0xff);
bts[offset]= (byte) (val & 0xff);
}
public final int getShortUnsigned(int offset){
return 0xffff & getShort(offset);
}
public final short getShort(int offset){
byte[] bts = getBytesInternal();
return (short) (bts[offset] & 0xff | (bts[offset+1] & 0xff) << 8);