Skip to content

Commit

Permalink
Fixed some small bugs in XGM2Tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane-D committed Jan 3, 2025
1 parent 50a8aa3 commit 5841032
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
Binary file modified bin/xgm2tool.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion tools/xgm2tool/src/sgdk/xgm2tool/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class Launcher extends JFrame
{
final static String VERSION = "1.04";
final static String VERSION = "1.05";

final static int SYSTEM_AUTO = -1;
final static int SYSTEM_NTSC = 0;
Expand Down
29 changes: 22 additions & 7 deletions tools/xgm2tool/src/sgdk/xgm2tool/format/XGM.java
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ else if (com.isYMSetTL() || com.isYMKeyAdvWrite() || com.isYMKeySequence() || co
boolean canCombineON = false;
XGMFMCommand setFreq = null;

// isolated key-on / key-off combine
// isolated key-off/on sequence combine
for (XGMFMCommand com : fmChannelCommands)
{
if (com.isYMKeyOFFWrite())
Expand All @@ -926,12 +926,26 @@ else if (com.isYMKeyONWrite())
}
else if (com.isYMSetTL() || com.isYMKeyAdvWrite() || com.isYMKeySequence() || com.isYMLoadInst() || com.isYMWrite())
{
// not yet meet the set freq command ? --> cancel combination
if (setFreq == null)
// meet a set freq command ? --> combine now
if (setFreq != null)
{
canCombineOFF = false;
canCombineON = false;
if (canCombineOFF)
{
setFreq.setYMFreqKeyOFF();
lastKeyOFF.setDummy();
}
if (canCombineON)
{
setFreq.setYMFreqKeyON();
lastKeyON.setDummy();
}
}

// done
canCombineOFF = false;
canCombineON = false;
setFreq = null;
hasKeyOn = false;
}
// the driver does not support key on/off on setFreq special
else if (com.isYMFreqWrite() && !com.isYMFreqSpecialWrite())
Expand All @@ -942,14 +956,15 @@ else if (com.isYMFreqWrite() && !com.isYMFreqSpecialWrite())
}
}

// last set Freq to combine ?
if (setFreq != null)
{
if (canCombineOFF && !setFreq.isYMFreqWithKeyOFF())
if (canCombineOFF)
{
setFreq.setYMFreqKeyOFF();
lastKeyOFF.setDummy();
}
if (canCombineON && !setFreq.isYMFreqWithKeyON())
if (canCombineON)
{
setFreq.setYMFreqKeyON();
lastKeyON.setDummy();
Expand Down
19 changes: 16 additions & 3 deletions tools/xgm2tool/src/sgdk/xgm2tool/struct/PSGState.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,37 @@ else if (type == 1)

public boolean isSame(PSGState state, int ind, int typ)
{
if ((init[ind][typ] == false) && (state.init[ind][typ] == false))
// consider same if 'state' is not initialised here
if (!state.init[ind][typ])
return true;
// consider different if we are not initialised here while 'state' is
if (!init[ind][typ])
return false;

return init[ind][typ] && (state.get(ind, typ) == get(ind, typ));
}

public boolean isLowSame(PSGState state, int ind, int typ)
{
if ((init[ind][typ] == false) && (state.init[ind][typ] == false))
// consider same if 'state' is not initialised here
if (!state.init[ind][typ])
return true;
// consider different if we are not initialised here while 'state' is
if (!init[ind][typ])
return false;

return init[ind][typ] && ((state.get(ind, typ) & 0xF) == (get(ind, typ) & 0xF));
}

public boolean isHighSame(PSGState state, int ind, int typ)
{
if ((init[ind][typ] == false) && (state.init[ind][typ] == false))
// consider same if 'state' is not initialised here
if (!state.init[ind][typ])
return true;
// consider different if we are not initialised here while 'state' is
if (!init[ind][typ])
return false;


return init[ind][typ] && ((state.get(ind, typ) & 0x3F0) == (get(ind, typ) & 0x3F0));
}
Expand Down

0 comments on commit 5841032

Please sign in to comment.