Skip to content

Commit

Permalink
Merge branch 'Stephane-D:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Leur68 authored Nov 7, 2024
2 parents 495bf84 + 35d7178 commit 5f4a8d4
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
Binary file modified bin/rescomp.jar
Binary file not shown.
8 changes: 6 additions & 2 deletions bin/rescomp.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ResComp 3.85 (August 2024)
ResComp 3.87 (November 2024)
Copyright Stephane Dallongeville
https://github.com/Stephane-D/SGDK

Expand Down Expand Up @@ -343,7 +343,11 @@ SPRITE name img_file width height [compression [time [collision [opt_type [opt_l
1 / APLIB = aplib library (good compression ratio but slow, don't use it for streamed sprite)
2 / FAST / LZ4W = custom lz4 compression (average compression ratio but fast, recommended for streamed sprite)
time display frame time in 1/60 of second (time between each animation frame)
If this value is set to 0 (default) then auto animation is disabled
If this value is set to 0 (default) then auto animation is disabled.
It can be either set globally (single value) or independently for each frame of each animation.
Example for 3 anim x 5 frame sprite sheet:
[[3,3,3,4,4][4,5,5][2,3,3,4]]
No space allowed ! And you can have empty value for empty frame.
collision collision type: CIRCLE, BOX or NONE (NONE by default)
opt_type sprite cutting optimization strategy, accepted values:
0 / BALANCED = balance between used tiles and hardware sprites (default)
Expand Down
4 changes: 4 additions & 0 deletions src/pal.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ bool NO_INLINE PAL_initFade(u16 fromCol, u16 toCol, const u16* palSrc, const u16

bool NO_INLINE PAL_doFadeStep(void)
{
// fading is done? --> exit
if (fadeCounter <= 0)
return FALSE;

// prepare fade palette for next frame
s16* palR = fadeR;
s16* palG = fadeG;
Expand Down
2 changes: 1 addition & 1 deletion tools/rescomp/src/sgdk/rescomp/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ else if (dep && depTarget == null)
depTarget = param;
}

System.out.println("ResComp 3.86 - SGDK Resource Compiler - Copyright 2024 (Stephane Dallongeville)");
System.out.println("ResComp 3.87 - SGDK Resource Compiler - Copyright 2024 (Stephane Dallongeville)");

if (fileName == null)
{
Expand Down
9 changes: 7 additions & 2 deletions tools/rescomp/src/sgdk/rescomp/processor/SpriteProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public Resource execute(String[] fields) throws Exception
System.out.println(" 1 / APLIB = aplib library (good compression ratio but slow)");
System.out.println(" 2 / FAST / LZ4W = custom lz4 compression (average compression ratio but fast)");
System.out.println(" time display frame time in 1/60 of second (time between each animation frame)");
System.out.println(" If this value is set to 0 (default) then auto animation is disabled");
System.out.println(" It can be set globally (single value) or independently for each frame of each animation");
System.out.println(" Example for a sprite sheet of 3 animations x 5 frames:");
System.out.println(" [[3,3,3,4,4][4,5,5][2,3,3,4]]");
System.out.println(" As you can see you can have empty value for empty frame");
System.out.println(" collision collision type: CIRCLE, BOX or NONE (BOX by default)");
System.out.println(" opt_type sprite cutting optimization strategy, accepted values:");
System.out.println(" 0 / BALANCED = balance between used tiles and hardware sprites (default)");
Expand Down Expand Up @@ -90,9 +95,9 @@ public Resource execute(String[] fields) throws Exception
if (fields.length >= 6)
compression = Util.getCompression(fields[5]);
// get frame time
int time = 0;
int[][] time = new int[][] {{ 0 }};
if (fields.length >= 7)
time = StringUtil.parseInt(fields[6], 0);
time = StringUtil.parseIntArray2D(fields[6], new int[][] {{ 0 }});
// get collision value
CollisionType collision = CollisionType.NONE;
if (fields.length >= 8)
Expand Down
4 changes: 2 additions & 2 deletions tools/rescomp/src/sgdk/rescomp/resource/Sprite.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Sprite extends Resource

public final Palette palette;

public Sprite(String id, String imgFile, int wf, int hf, Compression compression, int time, CollisionType collision, OptimizationType optType,
public Sprite(String id, String imgFile, int wf, int hf, Compression compression, int[][] time, CollisionType collision, OptimizationType optType,
OptimizationLevel optLevel, boolean showCut, boolean optDuplicate) throws Exception
{
super(id);
Expand Down Expand Up @@ -108,7 +108,7 @@ public Sprite(String id, String imgFile, int wf, int hf, Compression compression
for (int i = 0; i < numAnim; i++)
{
// build sprite animation
SpriteAnimation animation = new SpriteAnimation(id + "_animation" + i, image, wt, ht, i, wf, hf, time, collision, compression, optType, optLevel, optDuplicate);
SpriteAnimation animation = new SpriteAnimation(id + "_animation" + i, image, wt, ht, i, wf, hf, time[Math.min(time.length - 1, i)], collision, compression, optType, optLevel, optDuplicate);

// check if empty
if (!animation.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class SpriteAnimation extends Resource
* height of frame in tile
* @param showCuttingResult
*/
public SpriteAnimation(String id, byte[] image8bpp, int w, int h, int animIndex, int wf, int hf, int time, CollisionType collision, Compression compression,
public SpriteAnimation(String id, byte[] image8bpp, int w, int h, int animIndex, int wf, int hf, int[] time, CollisionType collision, Compression compression,
OptimizationType optType, OptimizationLevel optLevel, boolean optDuplicate)
{
super(id);
Expand Down Expand Up @@ -117,7 +117,7 @@ public SpriteAnimation(String id, byte[] image8bpp, int w, int h, int animIndex,
// frames.add(frame);

// create sprite frame ('timer' is augmented by number of duplicate)
SpriteFrame frame = new SpriteFrame(id + "_frame" + i, frameImage, wf, hf, time * (duplicate + 1), collision, compression, optType, optLevel);
SpriteFrame frame = new SpriteFrame(id + "_frame" + i, frameImage, wf, hf, time[Math.min(time.length - 1, i)] * (duplicate + 1), collision, compression, optType, optLevel);
// add as internal resource (get duplicate if exist)
frame = (SpriteFrame) addInternalResource(frame);
// bypass duplicates
Expand Down

0 comments on commit 5f4a8d4

Please sign in to comment.