Skip to content

Commit

Permalink
add VGM Tag Transfer tool
Browse files Browse the repository at this point in the history
also add "hard split" mode to trimming library
  • Loading branch information
ValleyBell committed Feb 9, 2019
1 parent 7cf1dfc commit d58c589
Show file tree
Hide file tree
Showing 6 changed files with 587 additions and 5 deletions.
9 changes: 7 additions & 2 deletions makefile
Expand Up @@ -38,12 +38,13 @@ TOOLS = \
vgm_stat \
vgm_tag \
vgm_trim \
vgm_tt \
vgm_vol \
vgmlpfnd \
vgmmerge

# extra tools not compiled by default, because they are
# either in beta state or not of use without special knowledge
# either in beta state or not of use/shouldn't be used without special knowledge
EXTRA_TOOLS = \
optdac \
optvgm32 \
Expand Down Expand Up @@ -76,16 +77,20 @@ vgm_sro_OBJS = vgm_sro.o chip_srom.o
vgm_stat_OBJS = vgm_stat.o
vgm_tag_OBJS = vgm_tag.o
vgm_trim_OBJS = vgm_trim.o vgm_trml.o
vgm_tt_OBJS = vgm_tt.o
vgm_vol_OBJS = vgm_vol.o
vgmlpfnd_OBJS = vgmlpfnd.o
vgmmerge_OBJS = vgmmerge.o

$(TOOLS) $(EXTRA_TOOLS): $$(addprefix $(OBJ)/,$$($$@_OBJS))
$(CC) $^ -o $@ $(LDFLAGS)
$(CXX) $^ -o $@ $(LDFLAGS)

$(OBJ)/%.o: $(SRC)/%.c
$(CC) $(CFLAGS) -c $< -o $@

$(OBJ)/%.o: $(SRC)/%.cpp
$(CXX) $(CFLAGS) -c $< -o $@

$(OBJ):
mkdir $(OBJ)

Expand Down
2 changes: 1 addition & 1 deletion opt_oki.c
Expand Up @@ -953,7 +953,7 @@ static void MakeDataStream(void)
// Now general all the special DAC Stream commands.

// (Command 90/91) * Chip Count + (Command 92/95) * played drums
CtrlCmdAlloc = 0x02 * ChipCnt + 0x02 * DrmSrtCount; // should be just enough
CtrlCmdAlloc = 0x03 * ChipCnt + 0x02 * DrmSrtCount; // should be just enough
VGMCtrlCmd = (STRM_CTRL_CMD*)malloc(CtrlCmdAlloc * sizeof(STRM_CTRL_CMD));

CtrlCmdCount = 0x00;
Expand Down
112 changes: 112 additions & 0 deletions vc6/vgm_tt.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions vc6/vgmtools.dsw
Expand Up @@ -291,6 +291,18 @@ Package=<4>

###############################################################################

Project: "vgm_tt"=".\vgm_tt.dsp" - Package Owner=<4>

Package=<5>
{{{
}}}

Package=<4>
{{{
}}}

###############################################################################

Project: "vgm_vol"=".\vgm_vol.dsp" - Package Owner=<4>

Package=<5>
Expand Down
26 changes: 24 additions & 2 deletions vgm_trml.c
Expand Up @@ -176,6 +176,7 @@ INLINE void WriteLE32(const UINT8* Data, UINT32 Value);
// - Complete Rewrite: writes some sort of chip save state at the beginning of the VGM
// - VGMTool Trim: writes all commands and simply strips the delays (deprecated, can sort of break things with OPN chips)
// - Intelligent: writes all necessary commands to restore the chip state (e.g. unused channels will be left out)
static bool HARD_SPLIT = false;
static bool COMPLETE_REWRITE = false;
static bool VGMTOOL_TRIM = false;
static bool INTELLIGENT = false;
Expand All @@ -202,6 +203,7 @@ void SetTrimOptions(UINT8 TrimMode, UINT8 WarnMask)
}
#endif

HARD_SPLIT = false;
COMPLETE_REWRITE = false;
VGMTOOL_TRIM = false;
INTELLIGENT = false;
Expand All @@ -216,6 +218,9 @@ void SetTrimOptions(UINT8 TrimMode, UINT8 WarnMask)
case 0x02:
INTELLIGENT = true; // not working yet
break;
case 0x03:
HARD_SPLIT = true;
break;
}
WARN_PLAY_NOTES = (WarnMask) ? true : false;

Expand Down Expand Up @@ -933,6 +938,18 @@ static void InitializeVGM(UINT8** DstDataRef, UINT32* DstPosRef)
//CurReg = 0x2??;
CmdType = 0x87;
}
if (HARD_SPLIT)
{
DstData[DstPos + 0x00] = 0x67;
DstData[DstPos + 0x01] = 0x66;
DstData[DstPos + 0x02] = CmdType;
WriteLE32(&DstData[DstPos + 0x03], 0x08);

WriteLE32(&DstData[DstPos + 0x07], TempMem->MemSize);
WriteLE32(&DstData[DstPos + 0x0B], 0x00);
DstPos += 0x07 + 0x08;
break;
}

if (ChipCmd && (TempCD->Regs.RegMask[CurReg] & 0x7F) == 0x01)
{
Expand Down Expand Up @@ -982,6 +999,8 @@ static void InitializeVGM(UINT8** DstDataRef, UINT32* DstPosRef)
case 0x14: // NES APU
case 0x20: // SCSP
case 0x24: // ES5503
if (HARD_SPLIT)
break;
if (CurChip == 0x05)
TempByt = 0x00;
else if (CurChip == 0x10)
Expand Down Expand Up @@ -1041,7 +1060,7 @@ static void InitializeVGM(UINT8** DstDataRef, UINT32* DstPosRef)
{
TempReg = &TempCD->Regs;

if (! TempReg->RegCount)
if (! TempReg->RegCount || HARD_SPLIT)
continue;

for (CurReg = 0x00; CurReg < TempReg->RegCount; CurReg ++)
Expand Down Expand Up @@ -2726,7 +2745,10 @@ static void CmdChk_OPL(CHIP_CHNS* ChnState, UINT8 OPLMode, UINT16 CmdReg, UINT8
else if ((CmdReg & 0x0F) < 0x09)
{
CurChn = ((CmdReg & 0x100) >> 8) * 9 + (CmdReg & 0x0F);
KeyOnOff = (Data & 0x20) >> 5;
if (OPLMode == 'L')
KeyOnOff = (Data & 0x10) >> 4;
else
KeyOnOff = (Data & 0x20) >> 5;

ChnState->ChnMask &= ~(1 << CurChn);
ChnState->ChnMask |= (KeyOnOff << CurChn);
Expand Down

0 comments on commit d58c589

Please sign in to comment.