Skip to content

Commit 5841032

Browse files
committed
Fixed some small bugs in XGM2Tool
1 parent 50a8aa3 commit 5841032

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

bin/xgm2tool.jar

5.64 KB
Binary file not shown.

tools/xgm2tool/src/sgdk/xgm2tool/Launcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
public class Launcher extends JFrame
1919
{
20-
final static String VERSION = "1.04";
20+
final static String VERSION = "1.05";
2121

2222
final static int SYSTEM_AUTO = -1;
2323
final static int SYSTEM_NTSC = 0;

tools/xgm2tool/src/sgdk/xgm2tool/format/XGM.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ else if (com.isYMSetTL() || com.isYMKeyAdvWrite() || com.isYMKeySequence() || co
906906
boolean canCombineON = false;
907907
XGMFMCommand setFreq = null;
908908

909-
// isolated key-on / key-off combine
909+
// isolated key-off/on sequence combine
910910
for (XGMFMCommand com : fmChannelCommands)
911911
{
912912
if (com.isYMKeyOFFWrite())
@@ -926,12 +926,26 @@ else if (com.isYMKeyONWrite())
926926
}
927927
else if (com.isYMSetTL() || com.isYMKeyAdvWrite() || com.isYMKeySequence() || com.isYMLoadInst() || com.isYMWrite())
928928
{
929-
// not yet meet the set freq command ? --> cancel combination
930-
if (setFreq == null)
929+
// meet a set freq command ? --> combine now
930+
if (setFreq != null)
931931
{
932-
canCombineOFF = false;
933-
canCombineON = false;
932+
if (canCombineOFF)
933+
{
934+
setFreq.setYMFreqKeyOFF();
935+
lastKeyOFF.setDummy();
936+
}
937+
if (canCombineON)
938+
{
939+
setFreq.setYMFreqKeyON();
940+
lastKeyON.setDummy();
941+
}
934942
}
943+
944+
// done
945+
canCombineOFF = false;
946+
canCombineON = false;
947+
setFreq = null;
948+
hasKeyOn = false;
935949
}
936950
// the driver does not support key on/off on setFreq special
937951
else if (com.isYMFreqWrite() && !com.isYMFreqSpecialWrite())
@@ -942,14 +956,15 @@ else if (com.isYMFreqWrite() && !com.isYMFreqSpecialWrite())
942956
}
943957
}
944958

959+
// last set Freq to combine ?
945960
if (setFreq != null)
946961
{
947-
if (canCombineOFF && !setFreq.isYMFreqWithKeyOFF())
962+
if (canCombineOFF)
948963
{
949964
setFreq.setYMFreqKeyOFF();
950965
lastKeyOFF.setDummy();
951966
}
952-
if (canCombineON && !setFreq.isYMFreqWithKeyON())
967+
if (canCombineON)
953968
{
954969
setFreq.setYMFreqKeyON();
955970
lastKeyON.setDummy();

tools/xgm2tool/src/sgdk/xgm2tool/struct/PSGState.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,37 @@ else if (type == 1)
124124

125125
public boolean isSame(PSGState state, int ind, int typ)
126126
{
127-
if ((init[ind][typ] == false) && (state.init[ind][typ] == false))
127+
// consider same if 'state' is not initialised here
128+
if (!state.init[ind][typ])
128129
return true;
130+
// consider different if we are not initialised here while 'state' is
131+
if (!init[ind][typ])
132+
return false;
129133

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

133137
public boolean isLowSame(PSGState state, int ind, int typ)
134138
{
135-
if ((init[ind][typ] == false) && (state.init[ind][typ] == false))
139+
// consider same if 'state' is not initialised here
140+
if (!state.init[ind][typ])
136141
return true;
142+
// consider different if we are not initialised here while 'state' is
143+
if (!init[ind][typ])
144+
return false;
137145

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

141149
public boolean isHighSame(PSGState state, int ind, int typ)
142150
{
143-
if ((init[ind][typ] == false) && (state.init[ind][typ] == false))
151+
// consider same if 'state' is not initialised here
152+
if (!state.init[ind][typ])
144153
return true;
154+
// consider different if we are not initialised here while 'state' is
155+
if (!init[ind][typ])
156+
return false;
157+
145158

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

0 commit comments

Comments
 (0)