Skip to content

Commit

Permalink
zima 0.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Mar 25, 2022
1 parent d86b93f commit db543a5
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group 'pl.asie.zima'
version '0.8.1'
version '0.8.2'

repositories {
mavenCentral()
Expand Down
7 changes: 7 additions & 0 deletions docs/changelog/0.8.2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Improvements:

* MegaZeux image conversion is now up to ~6% faster.

Bugs fixed:

* Fixed outputting Super ClassicZoo and WeaveZZT board files.
1 change: 1 addition & 0 deletions docs/changelog/versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
0.7.0
0.8.0
0.8.1
0.8.2
20 changes: 10 additions & 10 deletions src/main/java/pl/asie/libzzt/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void readZ(ZInputStream inStream) throws IOException {
}

try (ByteArrayInputStream byteStream = new ByteArrayInputStream(data); ZInputStream stream = new ZInputStream(byteStream)) {
this.name = stream.readPString(platform == Platform.SUPER_ZZT ? 60 : 50);
this.name = stream.readPString(platform.getZztWorldFormat().isSuperZZTLike() ? 60 : 50);

int ix = 1;
int iy = 1;
Expand All @@ -171,23 +171,23 @@ public void readZ(ZInputStream inStream) throws IOException {
} while (iy <= this.height);

this.maxShots = stream.readPByte();
if (platform == Platform.ZZT) {
if (platform.getZztWorldFormat().isZZTLike()) {
this.dark = stream.readPBoolean();
}
for (int i = 0; i < 4; i++)
this.neighborBoards[i] = stream.readPByte();
this.reenterWhenZapped = stream.readPBoolean();
if (platform == Platform.ZZT) {
if (platform.getZztWorldFormat().isZZTLike()) {
this.message = stream.readPString(58);
}
this.startPlayerX = stream.readPByte();
this.startPlayerY = stream.readPByte();
if (platform == Platform.SUPER_ZZT) {
if (platform.getZztWorldFormat().isSuperZZTLike()) {
stream.readPShort(); // DrawXOffset - TOOD
stream.readPShort(); // DrawYOffset - TOOD
}
this.timeLimitSec = stream.readPShort();
int skipCount = platform == Platform.SUPER_ZZT ? 14 : 16;
int skipCount = platform.getZztWorldFormat().isSuperZZTLike() ? 14 : 16;
if (stream.skip(skipCount) != skipCount) {
throw new IOException();
}
Expand All @@ -207,7 +207,7 @@ public void readZ(ZInputStream inStream) throws IOException {

public void writeZ(ZOutputStream outStream) throws IOException {
try (ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); ZOutputStream stream = new ZOutputStream(byteStream)) {
stream.writePString(this.name, platform == Platform.SUPER_ZZT ? 60 : 50);
stream.writePString(this.name, platform.getZztWorldFormat().isSuperZZTLike() ? 60 : 50);

// fancy RLE logic
int ix = 1;
Expand Down Expand Up @@ -235,23 +235,23 @@ public void writeZ(ZOutputStream outStream) throws IOException {
} while (iy <= this.height);

stream.writePByte(this.maxShots);
if (platform == Platform.ZZT) {
if (platform.getZztWorldFormat().isZZTLike()) {
stream.writePBoolean(this.dark);
}
for (int i = 0; i < 4; i++)
stream.writePByte(this.neighborBoards[i]);
stream.writePBoolean(this.reenterWhenZapped);
if (platform == Platform.ZZT) {
if (platform.getZztWorldFormat().isZZTLike()) {
stream.writePString(this.message, 58);
}
stream.writePByte(this.startPlayerX);
stream.writePByte(this.startPlayerY);
if (platform == Platform.SUPER_ZZT) {
if (platform.getZztWorldFormat().isSuperZZTLike()) {
stream.writePShort(0); // DrawXOffset - TODO
stream.writePShort(0); // DrawYOffset - TODO
}
stream.writePShort(this.timeLimitSec);
stream.pad(platform == Platform.SUPER_ZZT ? 14 : 16);
stream.pad(platform.getZztWorldFormat().isSuperZZTLike() ? 14 : 16);

stream.writePShort(stats.size() - 1);

Expand Down
10 changes: 6 additions & 4 deletions src/main/java/pl/asie/libzzt/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public final class Platform {
private final boolean maxStatCountIsActual = false;
@Builder.Default
private final boolean supportsBlinking = true;
@Builder.Default
private final ZztWorldSerializationFormat zztWorldFormat = null;
private final ElementLibrary library;

public static final Platform ZZT;
Expand All @@ -74,14 +76,14 @@ public boolean isDoubleWide(TextVisualData visual) {
}

static {
ZZT = Platform.builder().usesBoard(true).boardWidth(60).boardHeight(25).maxBoardSize(20000 + 2).maxStatCount(150).library(ElementLibraryZZT.INSTANCE).build();
SUPER_ZZT = Platform.builder().usesBoard(true).boardWidth(96).boardHeight(80).maxBoardSize(20000 + 2).maxStatCount(128).library(ElementLibrarySuperZZT.INSTANCE).doubleWide(true).build();
SUPER_CLASSICZOO = Platform.builder().usesBoard(true).boardWidth(96).boardHeight(80).maxBoardSize(65500 + 2).maxStatCount(128).library(ElementLibrarySuperZZT.INSTANCE).doubleWide(true).build();
ZZT = Platform.builder().usesBoard(true).boardWidth(60).boardHeight(25).maxBoardSize(20000 + 2).maxStatCount(150).library(ElementLibraryZZT.INSTANCE).zztWorldFormat(ZztWorldSerializationFormat.ZZT).build();
SUPER_ZZT = Platform.builder().usesBoard(true).boardWidth(96).boardHeight(80).maxBoardSize(20000 + 2).maxStatCount(128).library(ElementLibrarySuperZZT.INSTANCE).doubleWide(true).zztWorldFormat(ZztWorldSerializationFormat.SUPER_ZZT).build();
SUPER_CLASSICZOO = Platform.builder().usesBoard(true).boardWidth(96).boardHeight(80).maxBoardSize(65500 + 2).maxStatCount(128).library(ElementLibrarySuperZZT.INSTANCE).doubleWide(true).zztWorldFormat(ZztWorldSerializationFormat.SUPER_ZZT).build();
MEGAZEUX = Platform.builder().usesBoard(false).boardWidth(65535).boardHeight(65535).defaultBoardWidth(80).defaultBoardHeight(25).supportsBlinking(false).library(ElementLibraryNull.INSTANCE).build();

try {
WeaveZZTPlatformData platformData = WeaveZZTPlatformData.parse(ElementLibraryZZT.INSTANCE, null);
WEAVE_ZZT_25 = Platform.builder().usesBoard(true).boardWidth(60).boardHeight(25).maxBoardSize(65500 + 2).maxStatCount(150).library(platformData.getLibrary()).build();
WEAVE_ZZT_25 = Platform.builder().usesBoard(true).boardWidth(60).boardHeight(25).maxBoardSize(65500 + 2).maxStatCount(150).library(platformData.getLibrary()).zztWorldFormat(ZztWorldSerializationFormat.ZZT).build();
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/pl/asie/libzzt/Stat.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void readZ(ZInputStream stream, Platform platform) throws IOException {
}
this.dataPos = stream.readPShort();
int dataLen = stream.readPShort();
if (platform == Platform.ZZT) {
if (platform.getZztWorldFormat().isZZTLike()) {
if (stream.skip(8) != 8) {
throw new IOException("Could not skip unk!");
}
Expand All @@ -130,7 +130,7 @@ public void readZ(ZInputStream stream, Platform platform) throws IOException {
}

public int lengthZ(Platform platform) {
int len = (platform == Platform.ZZT ? 33 : 25);
int len = (platform.getZztWorldFormat().isZZTLike() ? 33 : 25);
if (boundStatId == 0 && data != null) {
byte[] dataBytes = data.getBytes(StandardCharsets.ISO_8859_1);
len += dataBytes.length;
Expand All @@ -155,7 +155,7 @@ public void writeZ(ZOutputStream stream, Platform platform) throws IOException {
stream.pad(4); // data^
stream.writePShort(this.dataPos);
stream.writePShort(boundStatId > 0 ? (-boundStatId) : ((dataBytes != null) ? dataBytes.length : 0));
if (platform == Platform.ZZT) {
if (platform.getZztWorldFormat().isZZTLike()) {
stream.pad(8); // unk
}
if (boundStatId == 0 && dataBytes != null) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/pl/asie/libzzt/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;

// TODO: Super ZZT world (de)serialization
@Data
public class World {
private static final int VERSION = -1;
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/pl/asie/libzzt/ZztWorldSerializationFormat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2020, 2021, 2022 Adrian Siekierka
*
* This file is part of zima.
*
* zima is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* zima is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with zima. If not, see <http://www.gnu.org/licenses/>.
*/
package pl.asie.libzzt;

public enum ZztWorldSerializationFormat {
ZZT,
SUPER_ZZT;

public boolean isZZTLike() {
return this == ZZT;
}

public boolean isSuperZZTLike() {
return this == SUPER_ZZT;
}
}

0 comments on commit db543a5

Please sign in to comment.