From 6725df8cd64bd529b9ae23be149694516e5b336c Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Tue, 23 Aug 2016 15:20:04 +1000 Subject: [PATCH] wiz5 mazes --- .../bytezone/diskbrowser/gui/DataPanel.java | 5 +- .../diskbrowser/wizardry/MazeGridV5.java | 110 ++++++++++++------ .../diskbrowser/wizardry/Relocator.java | 2 + .../wizardry/Wizardry4BootDisk.java | 5 +- 4 files changed, 83 insertions(+), 39 deletions(-) diff --git a/src/com/bytezone/diskbrowser/gui/DataPanel.java b/src/com/bytezone/diskbrowser/gui/DataPanel.java index 4a8d63a..40e4a8d 100755 --- a/src/com/bytezone/diskbrowser/gui/DataPanel.java +++ b/src/com/bytezone/diskbrowser/gui/DataPanel.java @@ -75,8 +75,9 @@ class DataPanel extends JTabbedPane imagePanel = new ImagePanel (); imagePane = new JScrollPane (imagePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, - ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - // imagePane.getVerticalScrollBar ().setUnitIncrement (font.getSize ()); + ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + imagePane.getVerticalScrollBar ().setUnitIncrement (50); + imagePane.getHorizontalScrollBar ().setUnitIncrement (25); // setTabsFont (font); // this.setMinimumSize (new Dimension (800, 200)); diff --git a/src/com/bytezone/diskbrowser/wizardry/MazeGridV5.java b/src/com/bytezone/diskbrowser/wizardry/MazeGridV5.java index 65bded5..4716883 100644 --- a/src/com/bytezone/diskbrowser/wizardry/MazeGridV5.java +++ b/src/com/bytezone/diskbrowser/wizardry/MazeGridV5.java @@ -4,75 +4,115 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; import com.bytezone.diskbrowser.applefile.AbstractFile; import com.bytezone.diskbrowser.utilities.HexFormatter; public class MazeGridV5 extends AbstractFile { - MazeCell[][] grid = new MazeCell[8][8]; + List grids = new ArrayList (); public MazeGridV5 (String name, byte[] buffer) { super (name, buffer); - for (int row = 0; row < 8; row++) - for (int col = 0; col < 8; col++) - grid[row][col] = getLayout (row, col); + for (int i = 0; i < 16; i++) + { + MazeCell[][] grid = new MazeCell[8][8]; + for (int row = 0; row < 8; row++) + for (int col = 0; col < 8; col++) + grid[row][col] = getLayout (i, row, col); + + MazeGrid mazeGrid = new MazeGrid (); + mazeGrid.grid = grid; + grids.add (mazeGrid); + mazeGrid.yOffset = buffer[512 + i] & 0xFF; + mazeGrid.xOffset = buffer[528 + i] & 0xFF; + } } @Override public BufferedImage getImage () { Dimension cellSize = new Dimension (22, 22); - image = new BufferedImage (8 * cellSize.width + 1, 8 * cellSize.height + 1, + int gridWidth = 8 * cellSize.width + 1; + int gridHeight = 8 * cellSize.height + 1; + image = new BufferedImage (6 * gridWidth, 6 * gridHeight, BufferedImage.TYPE_USHORT_555_RGB); Graphics2D g = image.createGraphics (); g.setRenderingHint (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - for (int row = 0; row < 8; row++) - for (int column = 0; column < 8; column++) - { - MazeCell cell = grid[row][column]; - int x = column * cellSize.width; - int y = image.getHeight () - (row + 1) * cellSize.height - 1; - cell.draw (g, x, y); - } + for (int i = 0; i < 16; i++) + { + MazeGrid mazeGrid = grids.get (i); + for (int row = 0; row < 8; row++) + for (int column = 0; column < 8; column++) + { + MazeCell cell = mazeGrid.grid[row][column]; + int x = column * cellSize.width; + int y = image.getHeight () - (row + 1) * cellSize.height - 1; + x += (mazeGrid.xOffset - 0x80) * cellSize.width + 10 * cellSize.width; + y -= (mazeGrid.yOffset - 0x80) * cellSize.height + 10 * cellSize.height; + cell.draw (g, x, y); + } + } return image; } - private MazeCell getLayout (int row, int column) + private MazeCell getLayout (int gridNo, int row, int column) { MazeAddress address = new MazeAddress (0, row, column); MazeCell cell = new MazeCell (address); - int offset = column * 2 + row / 4; + int offset = gridNo * 16 + column * 2 + row / 4; + int value; - int value = HexFormatter.intValue (buffer[offset]); - value >>>= (row % 4) * 2; - cell.westWall = ((value & 1) == 1); - value >>>= 1; - cell.westDoor = ((value & 1) == 1); + if (false) + { + value = HexFormatter.intValue (buffer[offset]); + value >>>= (row % 4) * 2; + cell.westWall = ((value & 1) == 1); + value >>>= 1; + cell.westDoor = ((value & 1) == 1); + } - value = HexFormatter.intValue (buffer[offset + 16]); - value >>>= (row % 4) * 2; - cell.southWall = ((value & 1) == 1); - value >>>= 1; - cell.southDoor = ((value & 1) == 1); + if (false) + { + value = HexFormatter.intValue (buffer[offset + 256]); + value >>>= (row % 4) * 2; + cell.southWall = ((value & 1) == 1); + value >>>= 1; + cell.southDoor = ((value & 1) == 1); + } - value = HexFormatter.intValue (buffer[offset + 32]); - value >>>= (row % 4) * 2; - cell.eastWall = ((value & 1) == 1); - value >>>= 1; - cell.eastDoor = ((value & 1) == 1); + if (true) + { + value = HexFormatter.intValue (buffer[offset + 0]); + value >>>= (row % 4) * 2; + cell.eastWall = ((value & 1) == 1); + value >>>= 1; + cell.eastDoor = ((value & 1) == 1); + } - value = HexFormatter.intValue (buffer[offset + 48]); - value >>>= (row % 4) * 2; - cell.northWall = ((value & 1) == 1); - value >>>= 1; - cell.northDoor = ((value & 1) == 1); + if (true) + { + value = HexFormatter.intValue (buffer[offset + 256]); + value >>>= (row % 4) * 2; + cell.northWall = ((value & 1) == 1); + value >>>= 1; + cell.northDoor = ((value & 1) == 1); + } return cell; } + + private class MazeGrid + { + MazeCell[][] grid = new MazeCell[8][8]; + int xOffset; + int yOffset; + } } \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/wizardry/Relocator.java b/src/com/bytezone/diskbrowser/wizardry/Relocator.java index 32ea02c..7d5ac12 100644 --- a/src/com/bytezone/diskbrowser/wizardry/Relocator.java +++ b/src/com/bytezone/diskbrowser/wizardry/Relocator.java @@ -67,6 +67,8 @@ public class Relocator extends AbstractFile byte[] temp = disk.readSector (diskOffsets[logicalBlock]); DiskAddress da = master.getDiskAddress (logicalBlock); master.writeSector (da, temp); + // if (da.getBlock () == 0x126) + // System.out.println (HexFormatter.format (buffer)); // if (Utility.find (temp, key1)) // if (Utility.find (temp, key2)) // if (Utility.find (temp, key3)) diff --git a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java index 8dfc003..4f1de0a 100644 --- a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java +++ b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java @@ -167,10 +167,11 @@ public class Wizardry4BootDisk extends PascalDisk DefaultMutableTreeNode mazeNode = linkNode ("Maze", "Level 5 mazes", scenarioNode); + int base = 0x1800; for (int i = 0; i < 8; i++) { - int offset = 6144 + i * 256; - byte[] data = new byte[256]; + int offset = base + i * 1024; + byte[] data = new byte[1024]; System.arraycopy (buffer, offset, data, 0, data.length); MazeGridV5 grid = new MazeGridV5 ("test level " + i, data);