Skip to content

Commit

Permalink
updated JBBP to 3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
raydac committed Dec 24, 2024
1 parent 885a19b commit 294e1dd
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 57 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<netbeans.hint.license>gpl30</netbeans.hint.license>
<jbbp.version>3.0.0</jbbp.version>
<jbbp.version>3.0.1</jbbp.version>
</properties>

<issueManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.igormaznitsa.zxpoly.components.betadisk;

import static java.util.Collections.unmodifiableList;

import com.igormaznitsa.jbbp.io.JBBPBitInputStream;
import com.igormaznitsa.jbbp.utils.JBBPUtils;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand All @@ -11,8 +12,6 @@
import java.util.List;
import java.util.Locale;

import static java.util.Collections.unmodifiableList;

public final class DskContainer {

private final boolean extended;
Expand Down Expand Up @@ -48,7 +47,8 @@ public DskContainer(final byte[] data) throws IOException {

final List<Track> foundTracks = new ArrayList<>();

final JBBPBitInputStream inputStream = new JBBPBitInputStream(new ByteArrayInputStream(data));
final JBBPBitInputStream inputStream =
new JBBPBitInputStream(new ByteArrayInputStream(data), false);
inputStream.readByteArray(0x100);

for (int i = 0; i < this.tracksPerSide * this.sides && inputStream.hasAvailableData(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ final class ReaderTap implements ListModel<ReaderTap.TapBlock>, TapeSource<Reade
public ReaderTap(final TapeContext tapeContext, final String name, final InputStream tap) throws IOException {
this.tapeContext = tapeContext;
this.name = name;
final TapFormatParser tapParser = new TapFormatParser().read(new JBBPBitInputStream(tap));
final TapFormatParser tapParser =
new TapFormatParser().read(new JBBPBitInputStream(tap, false));
if (tapParser.getTapBlocks().length == 0) {
this.current = null;
LOGGER.warning("Can't find blocks in TAP file");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.igormaznitsa.zxpoly.components.tapereader.tzx;

import static com.igormaznitsa.jbbp.utils.JBBPUtils.reverseBitsInByte;
import static com.igormaznitsa.zxpoly.utils.Utils.minimalRequiredBitsFor;

import com.igormaznitsa.jbbp.io.JBBPBitInputStream;
import com.igormaznitsa.jbbp.io.JBBPBitNumber;
import com.igormaznitsa.jbbp.io.JBBPBitOrder;
import com.igormaznitsa.jbbp.io.JBBPBitOutputStream;
import com.igormaznitsa.zxpoly.utils.Utils;

import java.io.ByteArrayInputStream;
import java.io.IOException;

import static com.igormaznitsa.jbbp.utils.JBBPUtils.reverseBitsInByte;
import static com.igormaznitsa.zxpoly.utils.Utils.minimalRequiredBitsFor;

public class TzxBlockGeneralizedData extends AbstractTzxSoundDataBlock {

private final long blockLength;
Expand Down Expand Up @@ -180,7 +179,9 @@ public boolean decodeRecordsAsPulses(final boolean nextPulseLevel, final PulseWr

if (this.totalNumberOfSymbolsInDataStream > 0) {
final JBBPBitNumber charBits = JBBPBitNumber.decode(minimalRequiredBitsFor(this.numberOfDataSymbolsInAbcTable - 1));
final JBBPBitInputStream inputStream = new JBBPBitInputStream(new ByteArrayInputStream(this.dataStream), JBBPBitOrder.MSB0);
final JBBPBitInputStream inputStream =
new JBBPBitInputStream(new ByteArrayInputStream(this.dataStream), JBBPBitOrder.MSB0,
false);

for (int i = 0; i < this.totalNumberOfSymbolsInDataStream; i++) {
final int symbolIndex = reverseBitsInByte(charBits, (byte) inputStream.readBits(charBits)) & 0xFF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.igormaznitsa.jbbp.io.JBBPBitInputStream;
import com.igormaznitsa.jbbp.io.JBBPBitOutputStream;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand All @@ -24,7 +23,7 @@ public class TzxFile {
private final List<AbstractTzxBlock> blockList;

public TzxFile(final InputStream inputStream) throws IOException {
final JBBPBitInputStream jbbpBitInputStream = new JBBPBitInputStream(inputStream);
final JBBPBitInputStream jbbpBitInputStream = new JBBPBitInputStream(inputStream, false);
final String signature = new String(jbbpBitInputStream.readByteArray(7), StandardCharsets.ISO_8859_1);
if (!signature.equals("ZXTape!")) throw new IOException("TZX signature error: " + signature);
if (jbbpBitInputStream.readByte() != 0x1A) throw new IOException("TZX error end of text file marker");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public boolean canMakeSnapshotForBoardMode(final BoardMode mode) {

@Override
public void loadFromArray(final File srcFile, final Motherboard board, final VideoController vc, final byte[] array) throws IOException {
final SNAParser parser = new SNAParser().read(new JBBPBitInputStream(new ByteArrayInputStream(array)));
final SNAParser parser =
new SNAParser().read(new JBBPBitInputStream(new ByteArrayInputStream(array), false));
final boolean sna128 = array.length > 49179;

if (sna128) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public char getPORTFF() {
public abstract AbstractZ80Snapshot read(JBBPBitInputStream in) throws IOException;

public void fillFromArray(final byte[] array) throws IOException {
this.read(new JBBPBitInputStream(new ByteArrayInputStream(array)));
this.read(new JBBPBitInputStream(new ByteArrayInputStream(array), false));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package com.igormaznitsa.zxpoly.formats;

import static java.util.Arrays.copyOf;
import static java.util.Arrays.copyOfRange;
import static org.apache.commons.compress.utils.IOUtils.readFully;

import com.igormaznitsa.jbbp.io.JBBPBitInputStream;
import com.igormaznitsa.zxpoly.components.RomData;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.compress.utils.SeekableInMemoryByteChannel;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static java.util.Arrays.copyOf;
import static java.util.Arrays.copyOfRange;
import static org.apache.commons.compress.utils.IOUtils.readFully;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.compress.utils.SeekableInMemoryByteChannel;

public class Spec256Arch {

Expand Down Expand Up @@ -230,7 +234,8 @@ private static FoundSna findSna(final byte[] zipArchive) throws IOException {
return new FoundSna(
parsedSnaName,
snaFileBody,
new SNAParser().read(new JBBPBitInputStream(new ByteArrayInputStream(snaFileBody)))
new SNAParser().read(
new JBBPBitInputStream(new ByteArrayInputStream(snaFileBody), false))
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.igormaznitsa.jbbp.io.JBBPBitInputStream;
import com.igormaznitsa.jbbp.io.JBBPBitOutputStream;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down Expand Up @@ -73,7 +72,7 @@ public ZxEmlSnapshotFormat() {
}

public ZxEmlSnapshotFormat(final byte[] data) throws IOException {
this.read(new JBBPBitInputStream(new ByteArrayInputStream(data)));
this.read(new JBBPBitInputStream(new ByteArrayInputStream(data), false));
if (this.getMAGIC() != MAGIC) {
throw new IOException("It is not ZXEML snapshot");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.igormaznitsa.zxpoly.components.tapereader.tzx;

import com.igormaznitsa.jbbp.io.JBBPBitInputStream;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import com.igormaznitsa.jbbp.io.JBBPBitInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;

import static org.junit.Assert.*;
import org.junit.Test;

public class TzxBlockGeneralizedDataTest extends AbstractTzxTest {
@Test
Expand Down Expand Up @@ -46,7 +47,8 @@ public void testDocCase_1() throws IOException {
(byte) 0x80,
(byte) 0xC1};

final JBBPBitInputStream jbbpBitInputStream = new JBBPBitInputStream(new ByteArrayInputStream(testData));
final JBBPBitInputStream jbbpBitInputStream =
new JBBPBitInputStream(new ByteArrayInputStream(testData), false);
final TzxBlockGeneralizedData read = new TzxBlockGeneralizedData(jbbpBitInputStream);
assertFalse(jbbpBitInputStream.hasAvailableData());
assertEquals(19, read.getDataStream().length);
Expand Down Expand Up @@ -89,7 +91,8 @@ public void testDocCase_2() throws IOException {
(byte) 0xC1
};

final JBBPBitInputStream jbbpBitInputStream = new JBBPBitInputStream(new ByteArrayInputStream(testData));
final JBBPBitInputStream jbbpBitInputStream =
new JBBPBitInputStream(new ByteArrayInputStream(testData), false);
final TzxBlockGeneralizedData read = new TzxBlockGeneralizedData(jbbpBitInputStream);
assertFalse(jbbpBitInputStream.hasAvailableData());
assertEquals(19, read.getDataStream().length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@
*/
package com.igormaznitsa.zxpoly.formats;

import com.igormaznitsa.jbbp.io.JBBPBitInputStream;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertNotNull;

import com.igormaznitsa.jbbp.io.JBBPBitInputStream;
import java.io.ByteArrayInputStream;
import java.io.InputStream;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;

public class ZXEMLSnapshotFormatTest {

private static byte[] loadResource(final String name) throws Exception {
final InputStream ins = ZXEMLSnapshotFormatTest.class.getResourceAsStream(name);
assertNotNull("Can't find resource " + name, ins);
final JBBPBitInputStream in = new JBBPBitInputStream(ins);
final JBBPBitInputStream in = new JBBPBitInputStream(ins, false);
final byte[] result = in.readByteArray(-1);
in.close();
return result;
Expand All @@ -41,7 +40,7 @@ public void testSaveLoad_Snapshot() throws Exception {
final byte[] array = loadResource("fh.zxp");

final ZxEmlSnapshotFormat data = new ZxEmlSnapshotFormat();
data.read(new JBBPBitInputStream(new ByteArrayInputStream(array.clone())));
data.read(new JBBPBitInputStream(new ByteArrayInputStream(array.clone()), false));
assertArrayEquals(array, data.save());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
import com.igormaznitsa.jbbp.mapper.Bin;
import com.igormaznitsa.zxpspritecorrector.files.Info;
import com.igormaznitsa.zxpspritecorrector.files.plugins.AbstractFilePlugin;

import java.awt.*;
import java.awt.Rectangle;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -97,7 +96,7 @@ final class Parsed {
byte[] zxpoly3;
}

final JBBPBitInputStream inStream = new JBBPBitInputStream(in);
final JBBPBitInputStream inStream = new JBBPBitInputStream(in, false);
if (inStream.readLong(JBBPByteOrder.BIG_ENDIAN) != 0xABBAFAFABABE0123L) {
throw new IOException("It is not a valid data block");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.igormaznitsa.jbbp.io.JBBPBitInputStream;
import com.igormaznitsa.jbbp.io.JBBPByteOrder;
import com.igormaznitsa.jbbp.io.JBBPOut;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
Expand All @@ -47,7 +46,7 @@ public Info(final String name, final char type, final int startAddress, final in
}

public Info(final InputStream in, final boolean selectable) throws IOException {
final JBBPBitInputStream bitin = new JBBPBitInputStream(in);
final JBBPBitInputStream bitin = new JBBPBitInputStream(in, false);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.igormaznitsa.zxpspritecorrector.files.FileNameDialog;
import com.igormaznitsa.zxpspritecorrector.files.Info;
import com.igormaznitsa.zxpspritecorrector.files.SessionData;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -75,7 +74,7 @@ public List<Info> getImportingContainerFileList(final File file) {

JBBPBitInputStream in = null;
try {
in = new JBBPBitInputStream(new FileInputStream(file));
in = new JBBPBitInputStream(new FileInputStream(file), false);
final long id = in.readLong(JBBPByteOrder.BIG_ENDIAN);
if (id == 0x53494E434C414952L) {
// it's scl
Expand All @@ -101,7 +100,8 @@ public List<Info> getImportingContainerFileList(final File file) {
@Override
public ReadResult readFrom(final String name, final byte[] dataArray, final int index) throws IOException {
final List<SCLCatalogItem> list = new ArrayList<>();
final JBBPBitInputStream in = new JBBPBitInputStream(new ByteArrayInputStream(dataArray));
final JBBPBitInputStream in =
new JBBPBitInputStream(new ByteArrayInputStream(dataArray), false);
try {
final long id = in.readLong(JBBPByteOrder.BIG_ENDIAN);
if (id == 0x53494E434C414952L) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@
import com.igormaznitsa.zxpspritecorrector.files.FileNameDialog;
import com.igormaznitsa.zxpspritecorrector.files.Info;
import com.igormaznitsa.zxpspritecorrector.files.SessionData;
import org.apache.commons.io.FilenameUtils;

import javax.swing.*;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javax.swing.JOptionPane;
import org.apache.commons.io.FilenameUtils;

public class TAPPlugin extends AbstractFilePlugin {

Expand Down Expand Up @@ -95,7 +94,7 @@ public List<Info> getImportingContainerFileList(final File file) {

JBBPBitInputStream in = null;
try {
in = new JBBPBitInputStream(new FileInputStream(file));
in = new JBBPBitInputStream(new FileInputStream(file), false);

while (in.hasAvailableData()) {
final int length = in.readUnsignedShort(JBBPByteOrder.LITTLE_ENDIAN);
Expand Down Expand Up @@ -158,7 +157,7 @@ public List<Info> getImportingContainerFileList(final File file) {

@Override
public ReadResult readFrom(final String name, final byte[] dataArray, final int index) throws IOException {
JBBPBitInputStream in = new JBBPBitInputStream(new ByteArrayInputStream(dataArray));
JBBPBitInputStream in = new JBBPBitInputStream(new ByteArrayInputStream(dataArray), false);
try {
int currentIndex = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.igormaznitsa.zxpspritecorrector.files.FileNameDialog;
import com.igormaznitsa.zxpspritecorrector.files.Info;
import com.igormaznitsa.zxpspritecorrector.files.SessionData;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -71,7 +70,7 @@ public List<Info> getImportingContainerFileList(final File file) {

JBBPBitInputStream in = null;
try {
in = new JBBPBitInputStream(new FileInputStream(file));
in = new JBBPBitInputStream(new FileInputStream(file), false);

for (int i = 0; i < 128; i++) {
final TRDosCatalogItem item = CATALOG_PARSER.parse(in).mapTo(new TRDosCatalogItem());
Expand All @@ -93,7 +92,7 @@ public List<Info> getImportingContainerFileList(final File file) {
@Override
public ReadResult readFrom(String name, byte[] data, int index) throws IOException {
final JBBPBitInputStream inStream =
new JBBPBitInputStream(new ByteArrayInputStream(data), JBBPBitOrder.LSB0);
new JBBPBitInputStream(new ByteArrayInputStream(data), JBBPBitOrder.LSB0, false);
try {
final List<TRDosCatalogItem> list = new ArrayList<>();
for (int i = 0; i < 128; i++) {
Expand Down

0 comments on commit 294e1dd

Please sign in to comment.