Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ It was originally developed SnowBro and later improved by Central MiB and Lab313

## Changelog

### v0.23 (by hansbonini a.k.a Anime_World)
- Add swizzle modes for texture visualizations as tile
- Fix Block Dimensions setting up canvas dimensions, now they work individually.

### v0.22 (by hansbonini a.k.a Anime_World)
- Add support for Mesen and Exodus CRAM Dump as Palette
- Add new codecs for visualization
- Add support for custom tile dimensions
- Add easy block size configuration
- Add statusbar configuration for tile and block dimensions

### v0.21 (by toruzz)
- New themes. Old custom system removed
- Fractional scale support
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>tm</groupId>
<artifactId>tilemolester</artifactId>
<version>1.0-SNAPSHOT</version>
<version>0.23</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/tm/TMFileResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ public void addToBookmarksTree(Element e, FolderNode folder) {
// String palID = e.getAttribute("palette");
String codecID = e.getAttribute("codec");
TileCodec codec = ui.getTileCodecByID(codecID);
String swizzlePattern = e.getAttribute("swizzlepattern");
if (swizzlePattern == null || swizzlePattern.isEmpty()) {
swizzlePattern = TileCodec.SWIZZLE_NONE; // Default value for backward compatibility
}
String desc = XMLParser.getNodeValue(getChildTag(e, "description", 0));
BookmarkItemNode bookmark = new BookmarkItemNode(
offset,
Expand All @@ -175,6 +179,7 @@ public void addToBookmarksTree(Element e, FolderNode folder) {
mode,
palIndex,
codec,
swizzlePattern,
desc);
folder.add(bookmark);
}
Expand Down
86 changes: 67 additions & 19 deletions src/main/java/tm/canvases/TMEditorCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ public class TMEditorCanvas extends TMTileCanvas implements MouseInputListener {
private Point moveViewPoint;
private Point moveMousePoint;

private int[] tempPixels = new int[8*8];
private Vector modifiedTiles = new Vector(); // tiles modified by operation
private Vector modifiedPixels = new Vector();
private Point[][] gridCoords;

private int blockWidth=1;
private int blockHeight=1;
private boolean rowInterleaved=false;
private String swizzlePattern = tm.tilecodecs.TileCodec.SWIZZLE_NONE;
private boolean showBlockGrid=false;

/**
Expand Down Expand Up @@ -646,7 +646,9 @@ private void drawLine(int x1, int y1, int x2, int y2, boolean trace) {

protected void setPixelTraceable(int x, int y, int argb) {
// mark the tile as modified
tileModified(x/8, y/8);
int tileWidth = (codec != null) ? codec.getTileWidth() : 8;
int tileHeight = (codec != null) ? codec.getTileHeight() : 8;
tileModified(x/tileWidth, y/tileHeight);

setPixel(x, y, argb);
}
Expand All @@ -662,8 +664,12 @@ private void tileModified(int col, int row) {
if (!modifiedTiles.contains(p)) {
modifiedTiles.add(p);
// save original pixels
int tileWidth = (codec != null) ? codec.getTileWidth() : 8;
int tileHeight = (codec != null) ? codec.getTileHeight() : 8;
int tileSize = tileWidth * tileHeight;
int[] tempPixels = new int[tileSize];
copyTilePixelsToBuffer(col, row, tempPixels, 0);
IntBuffer ib = IntBuffer.allocate(8*8);
IntBuffer ib = IntBuffer.allocate(tileSize);
ib.put(tempPixels);
modifiedPixels.add(ib);
}
Expand All @@ -677,12 +683,19 @@ private void tileModified(int col, int row) {
**/

public void copyTilePixelsToBuffer(int x, int y, int[] buf, int ofs) {
int pixOfs = (y * 8 * canvasWidth) + (x * 8);
for (int i=0; i<8; i++) {
for (int j=0; j<8; j++) {
buf[ofs++] = pixels[pixOfs++];
int tileWidth = (codec != null) ? codec.getTileWidth() : 8;
int tileHeight = (codec != null) ? codec.getTileHeight() : 8;
int pixOfs = (y * tileHeight * canvasWidth) + (x * tileWidth);
for (int i=0; i<tileHeight; i++) {
for (int j=0; j<tileWidth; j++) {
if (ofs < buf.length && pixOfs < pixels.length) {
buf[ofs++] = pixels[pixOfs++];
} else {
ofs++;
pixOfs++;
}
}
pixOfs += canvasWidth - 8;
pixOfs += canvasWidth - tileWidth;
}
}

Expand All @@ -693,12 +706,19 @@ public void copyTilePixelsToBuffer(int x, int y, int[] buf, int ofs) {
**/

public void copyBufferToTilePixels(int x, int y, int[] buf, int ofs) {
int pixOfs = (y * 8 * canvasWidth) + (x * 8);
for (int i=0; i<8; i++) {
for (int j=0; j<8; j++) {
pixels[pixOfs++] = buf[ofs++];
int tileWidth = (codec != null) ? codec.getTileWidth() : 8;
int tileHeight = (codec != null) ? codec.getTileHeight() : 8;
int pixOfs = (y * tileHeight * canvasWidth) + (x * tileWidth);
for (int i=0; i<tileHeight; i++) {
for (int j=0; j<tileWidth; j++) {
if (ofs < buf.length && pixOfs < pixels.length) {
pixels[pixOfs++] = buf[ofs++];
} else {
ofs++;
pixOfs++;
}
}
pixOfs += canvasWidth - 8;
pixOfs += canvasWidth - tileWidth;
}
}

Expand All @@ -718,17 +738,20 @@ private ReversibleTileModifyAction commitDrawingOperation(String name, boolean u
BookmarkItemNode bookmark = view.createBookmark("");

Point[] pts = new Point[modifiedTiles.size()];
int[] oldPix = new int[pts.length * 8*8];
int[] newPix = new int[pts.length * 8*8];
int tileWidth = (codec != null) ? codec.getTileWidth() : 8;
int tileHeight = (codec != null) ? codec.getTileHeight() : 8;
int tileSize = tileWidth * tileHeight;
int[] oldPix = new int[pts.length * tileSize];
int[] newPix = new int[pts.length * tileSize];

for (int i=0; i<modifiedTiles.size(); i++) {
Point p = (Point)modifiedTiles.elementAt(i);
pts[i] = new Point(p);

IntBuffer ib = (IntBuffer)modifiedPixels.elementAt(i);
System.arraycopy(ib.array(), 0, oldPix, i * 8*8, 8*8);
System.arraycopy(ib.array(), 0, oldPix, i * tileSize, tileSize);

copyTilePixelsToBuffer(p.x, p.y, newPix, i * 8*8);
copyTilePixelsToBuffer(p.x, p.y, newPix, i * tileSize);

packTile(p.x, p.y);
}
Expand Down Expand Up @@ -828,9 +851,11 @@ public void paste(TMSelectionCanvas canvas) {
**/
public void setBlankPixels(int bgColor,int x1,int y1,int x2,int y2)
{
int tileWidth = (codec != null) ? codec.getTileWidth() : 8;
int tileHeight = (codec != null) ? codec.getTileHeight() : 8;
//erases original tiles
for (int i=y1*8; i<y2*8; i++) {
for (int j=x1*8; j<x2*8; j++) {
for (int i=y1*tileHeight; i<y2*tileHeight; i++) {
for (int j=x1*tileWidth; j<x2*tileWidth; j++) {
setPixel(j, i, bgColor);
}
}
Expand Down Expand Up @@ -1562,4 +1587,27 @@ public boolean getRowInterleaveBlocks() {
return rowInterleaved;
}

/**
*
* Sets the swizzle pattern.
*
**/

public void setSwizzlePattern(String swizzlePattern) {
this.swizzlePattern = swizzlePattern;
if (codec != null) {
codec.setSwizzlePattern(swizzlePattern);
}
}

/**
*
* Gets the swizzle pattern.
*
**/

public String getSwizzlePattern() {
return swizzlePattern;
}

}
8 changes: 5 additions & 3 deletions src/main/java/tm/canvases/TMSelectionCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ public TMSelectionCanvas(TMUI ui, TMTileCanvas canvas, int x1, int y1, int w, in
}

// copy pixels
for (int i=0; i<h*8; i++) {
for (int j=0; j<w*8; j++) {
setPixel(j, i, canvas.getPixel(j+x1*8, i+y1*8));
int tileWidth = (canvas.getCodec() != null) ? canvas.getCodec().getTileWidth() : 8;
int tileHeight = (canvas.getCodec() != null) ? canvas.getCodec().getTileHeight() : 8;
for (int i=0; i<h*tileHeight; i++) {
for (int j=0; j<w*tileWidth; j++) {
setPixel(j, i, canvas.getPixel(j+x1*tileWidth, i+y1*tileHeight));
}
}

Expand Down
Loading