From: sparky4 <sparky4@cock.li>
Date: Fri, 1 Sep 2017 00:55:58 +0000 (-0500)
Subject:  worked on SD abit so the irq0 is not needed in imfplay anymore. I will need to merge... 
X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=5cbe71279085ff3b3318dcb138168c91b72cb75d;p=16.git

 worked on SD abit so the irq0 is not needed in imfplay anymore. I will need to merge ID_SD with p16 and use opl2 and PC speaker parts of SD. i found an adlib catcher and it records it to a RAW format file. it is called rac and it is located in 16/rac] i added vgmtools repo for vgm stuff!
---

diff --git a/.gitignore b/.gitignore
index bce92ec3..8fe488a5 100755
--- a/.gitignore
+++ b/.gitignore
@@ -35,6 +35,9 @@ vrl2vrs
 vrsdump
 vrldbg
 dro2imf
+dro2vgm
+imf2vgm
+raw2vgm
 ps.exe
 *.upx
 # except foo.html which is maintained by hand.
diff --git a/.gitmodules b/.gitmodules
index ab23923c..657e577f 100755
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,6 @@
 [submodule "src/lib/doslib"]
-        path = src/lib/doslib
-        url = https://github.com/joncampbell123/doslib.git
+	path = src/lib/doslib
+	url = https://github.com/joncampbell123/doslib.git
 
 [submodule "src/lib/jsmn"]
 	path = src/lib/jsmn
@@ -11,21 +11,25 @@
 	url = https://github.com/FlatRockSoft/CatacombApocalypse.git
 
 [submodule "wolf3d"]
-        path = 16/wolf3d
-        url = https://github.com/id-Software/wolf3d.git
+	path = 16/wolf3d
+	url = https://github.com/id-Software/wolf3d.git
 
 [submodule "keen"]
-        path = 16/keen
+	path = 16/keen
 	url = https://github.com/keendreams/keen.git
 
 [submodule "Catacomb3D"]
-        path = 16/Catacomb3D
+	path = 16/Catacomb3D
 	url = https://github.com/FlatRockSoft/Catacomb3D.git
 
 [submodule "shitman"]
-        path = 16/shitman
-        url = https://github.com/joncampbell123/shitman.git
+	path = 16/shitman
+	url = https://github.com/joncampbell123/shitman.git
 
 [submodule "dro2imf"]
 	path = "16/dro2imf"
 	url = https://github.com/Malvineous/dro2imf.git
+
+[submodule "vgmtools"]
+	path = "16/vgmtools"
+	url = https://github.com/vgmrips/vgmtools.git
diff --git a/0.exe b/0.exe
new file mode 100755
index 00000000..cf069aed
Binary files /dev/null and b/0.exe differ
diff --git a/16/vgmtools b/16/vgmtools
new file mode 160000
index 00000000..057e0126
--- /dev/null
+++ b/16/vgmtools
@@ -0,0 +1 @@
+Subproject commit 057e0126a66a4d287508d79f9a407a0a30293c5f
diff --git a/data/02.vgm b/data/02.vgm
new file mode 100755
index 00000000..ae01d28e
Binary files /dev/null and b/data/02.vgm differ
diff --git a/dro2vgm b/dro2vgm
index f924965c..09a12d63 100755
Binary files a/dro2vgm and b/dro2vgm differ
diff --git a/makefile b/makefile
index b24edb2f..ac1cb527 100755
--- a/makefile
+++ b/makefile
@@ -236,7 +236,10 @@ SPRIUTILEXEC = &
 	vrl2vrs &
 	vrsdump &
 	vrldbg &
-	dro2imf
+	dro2imf &
+	dro2vgm &
+	imf2vgm &
+	raw2vgm
 #UTILEXEC += $(SPRIUTILEXEC)
 !endif
 
@@ -472,6 +475,7 @@ clean: .symbolic
 	#@for %f in ($(SPRIUTILEXEC)) do @if exist %f $(REMOVECOMMAND) %f
 	@if not exist vrl2vrs wmake -s -h pcx2vrl
 	@if not exist dro2imf wmake -s -h drotoimf
+	@if not exist raw2vgm wmake -s -h vgmtools
 !else
 	@if exist *.o $(REMOVECOMMAND) *.o
 !endif
@@ -618,6 +622,7 @@ reinitlibs: .symbolic
 	@$(REMOVECOMMAND) -rf 16/Catacomb3D
 	@$(REMOVECOMMAND) -rf 16/shitman
 	@$(REMOVECOMMAND) -rf 16/dro2imf
+	@$(REMOVECOMMAND) -rf 16/vgmtools
 	@wmake -s -h initlibs
 
 initlibs: .symbolic
@@ -629,6 +634,7 @@ initlibs: .symbolic
 	@git clone https://github.com/keendreams/keen.git
 	@git clone https://github.com/FlatRockSoft/Catacomb3D.git
 	@git clone https://github.com/Malvineous/dro2imf.git
+	@git clone https://github.com/vgmrips/vgmtools.git
 	@cd $(BUILD_ROOT)
 	@$(COPYCOMMAND) $(DOSLIBDIR)/make-lowercase .
 
@@ -672,6 +678,15 @@ drotoimf: .symbolic
 	@make
 	@$(MOVECOMMAND) dro2imf ../..
 	@cd $(BUILD_ROOT)
+
+vgmtools: .symbolic
+	@cd 16/vgmtools
+	@make
+	@$(MOVECOMMAND) dro2vgm ../..
+	@$(MOVECOMMAND) imf2vgm ../..
+	@$(MOVECOMMAND) raw2vgm ../..
+	@cd $(BUILD_ROOT)
+
 vrs: .symbolic
 vrl: .symbolic
 $(SPRIUTILEXEC):
diff --git a/src/lib/.16_sd.h.kate-swp b/src/lib/.16_sd.h.kate-swp
deleted file mode 100755
index 5680e707..00000000
Binary files a/src/lib/.16_sd.h.kate-swp and /dev/null differ
diff --git a/src/lib/16_sd.h b/src/lib/16_sd.h
index 73600a11..858ed74c 100755
--- a/src/lib/16_sd.h
+++ b/src/lib/16_sd.h
@@ -54,8 +54,6 @@ typedef struct{
 	byte Feedback;                  /* feedback algorithm and strength  */
 } FMInstrument;
 
-//extern void interrupt	(*old_irq0)(void);
-
 void opl2out(word reg, word data);
 void opl3out(word reg, word data);
 void opl3exp(word data);
diff --git a/src/lib/vgmsnd/imf2vgm.c b/src/lib/vgmsnd/imf2vgm.c
deleted file mode 100755
index 7d7c6834..00000000
--- a/src/lib/vgmsnd/imf2vgm.c
+++ /dev/null
@@ -1,302 +0,0 @@
-// imf2vgm.c - IMF -> VGM Converter
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "stdtype.h"
-#include "VGMFile.h"
-#include "common.h"
-
-
-static UINT8 OpenIMFFile(const char* FileName);
-static void WriteVGMFile(const char* FileName);
-static void ConvertIMF2VGM(void);
-
-
-UINT8 IMFType;
-UINT16 IMFRate;
-VGM_HEADER VGMHead;
-UINT32 IMFDataLen;
-UINT8* IMFData;
-UINT32 IMFPos;
-UINT32 IMFDataStart;
-UINT32 IMFDataEnd;
-UINT32 VGMDataLen;
-UINT8* VGMData;
-UINT32 VGMPos;
-char FileBase[0x100];
-UINT8 LoopOn;
-
-int main(int argc, char* argv[])
-{
-	int argbase;
-	int ErrVal;
-	char FileName[0x100];
-	UINT16 ForceHz;
-	UINT8 ForceType;
-	
-	printf("IMF to VGM Converter\n--------------------\n\n");
-	
-	ErrVal = 0;
-	argbase = 1;
-	ForceHz = 0;
-	ForceType = 0xFF;
-	LoopOn = 0x00;
-	
-	while(argbase < argc && argv[argbase][0] == '-')
-	{
-		if (! stricmp(argv[argbase], "-help"))
-		{
-			printf("Usage: imf2vgm [-Loop] [-Hz###] [-Type#] Input.imf [Output.vgm]\n");
-			printf("\n");
-			printf("Loop: Makes the song loop from beginning to end.\n");
-			printf("Hz:   There are 3 known speeds: 280, 560 and 700\n");
-			printf("      560 is default for .imf, 700 for .wlf files\n");
-			printf("Type: Can be 0 (no header) or 1 (header with 2-byte file size)\n");
-			return 0;
-		}
-		else if (! stricmp(argv[argbase], "-Loop"))
-		{
-			LoopOn = 0x01;
-			argbase ++;
-		}
-		else if (! strnicmp(argv[argbase], "-Hz", 3))
-		{
-			ForceHz = (UINT16)strtoul(argv[argbase] + 3, NULL, 0);
-			argbase ++;
-		}
-		else if (! strnicmp(argv[argbase], "-Type", 5))
-		{
-			ForceType = (UINT8)strtoul(argv[argbase] + 5, NULL, 0);
-			if (ForceType >= 0x02)
-			{
-				printf("Error: Type must be either 0 or 1!\n");
-				return 2;
-			}
-			argbase ++;
-		}
-		else
-		{
-			break;
-		}
-	}
-	
-	printf("File Name:\t");
-	if (argc <= argbase + 0)
-	{
-		ReadFilename(FileName, sizeof(FileName));
-	}
-	else
-	{
-		strcpy(FileName, argv[argbase + 0]);
-		printf("%s\n", FileName);
-	}
-	if (! strlen(FileName))
-		return 0;
-	
-	if (OpenIMFFile(FileName))
-	{
-		printf("Error opening the file!\n");
-		ErrVal = 1;
-		goto EndProgram;
-	}
-	printf("\n");
-	
-	if (ForceHz)
-		IMFRate = ForceHz;
-	if (ForceType < 0xFF)
-		IMFType = ForceType;
-	ConvertIMF2VGM();
-	
-	if (argc > argbase + 1)
-		strcpy(FileName, argv[argbase + 1]);
-	else
-		strcpy(FileName, "");
-	if (FileName[0] == '\0')
-	{
-		strcpy(FileName, FileBase);
-		strcat(FileName, ".vgm");
-	}
-	WriteVGMFile(FileName);
-	
-	free(IMFData);
-	free(VGMData);
-	
-EndProgram:
-	DblClickWait(argv[0]);
-	
-	return ErrVal;
-}
-
-static UINT8 OpenIMFFile(const char* FileName)
-{
-	FILE* hFile;
-	UINT16 TempSht;
-	char* TempPnt;
-	
-	hFile = fopen(FileName, "rb");
-	if (hFile == NULL)
-		return 0xFF;
-	
-	fseek(hFile, 0x00, SEEK_END);
-	IMFDataLen = ftell(hFile);
-	
-	// Read Data
-	IMFData = (UINT8*)malloc(IMFDataLen);
-	if (IMFData == NULL)
-		goto OpenErr;
-	fseek(hFile, 0x00, SEEK_SET);
-	IMFDataLen = fread(IMFData, 0x01, IMFDataLen, hFile);
-	
-	fclose(hFile);
-	
-	memcpy(&TempSht, &IMFData[0x00], 0x02);
-	if (! TempSht)
-		IMFType = 0x00;
-	else
-		IMFType = 0x01;
-	
-	strcpy(FileBase, FileName);
-	TempPnt = strrchr(FileBase, '.');
-	if (TempPnt != NULL)
-	{
-		*TempPnt = 0x00;
-		TempPnt ++;
-	}
-	else
-	{
-		TempPnt = FileBase + strlen(FileBase);
-	}
-	if (! stricmp(TempPnt, "wlf"))
-		IMFRate = 700;
-	else
-		IMFRate = 560;
-	
-	return 0x00;
-
-OpenErr:
-
-	fclose(hFile);
-	return 0x80;
-}
-
-static void WriteVGMFile(const char* FileName)
-{
-	FILE* hFile;
-	
-	hFile = fopen(FileName, "wb");
-	fwrite(VGMData, 0x01, VGMDataLen, hFile);
-	fclose(hFile);
-	
-	printf("File written.\n");
-	
-	return;
-}
-
-static void ConvertIMF2VGM(void)
-{
-	UINT16 CurDelay;
-	UINT32 CurTick;
-	UINT16 HalfRate;
-	UINT64 TempTick;
-	UINT32 VGMSmplL;
-	UINT32 VGMSmplC;
-	UINT32 SmplVal;
-	
-	VGMDataLen = sizeof(VGM_HEADER) + IMFDataLen * 0x02;
-	VGMData = (UINT8*)malloc(VGMDataLen);
-	
-	printf("IMF Type: %u, IMF Playback Rate: %u Hz\n", IMFType, IMFRate);
-	
-	memcpy(&CurDelay, &IMFData[0x00], 0x02);
-	if (IMFType == 0x00)
-	{
-		IMFDataStart = 0x0000;
-		IMFDataEnd = IMFDataLen;
-	}
-	else //if (IMFType == 0x01)
-	{
-		IMFDataStart = 0x0002;
-		IMFDataEnd = IMFDataStart + CurDelay;
-	}
-	
-	// Generate VGM Header
-	memset(&VGMHead, 0x00, sizeof(VGM_HEADER));
-	VGMHead.fccVGM = FCC_VGM;
-	VGMHead.lngVersion = 0x00000151;
-	VGMHead.lngRate = IMFRate;
-	VGMHead.lngDataOffset = 0x80;
-	VGMHead.lngHzYM3812 = 3579545;
-	
-	// Convert data
-	IMFPos = IMFDataStart;
-	VGMPos = VGMHead.lngDataOffset;
-	CurTick = 0;
-	VGMSmplL = 0;
-	HalfRate = IMFRate / 2;	// for correct rounding
-	while(IMFPos < IMFDataEnd)
-	{
-		if (VGMPos >= VGMDataLen - 0x08)
-		{
-			VGMDataLen += 0x8000;
-			VGMData = (UINT8*)realloc(VGMData, VGMDataLen);
-		}
-		VGMData[VGMPos + 0x00] = 0x5A;
-		VGMData[VGMPos + 0x01] = IMFData[IMFPos + 0x00];	// register
-		VGMData[VGMPos + 0x02] = IMFData[IMFPos + 0x01];	// data
-		VGMPos += 0x03;
-		
-		memcpy(&CurDelay, &IMFData[IMFPos + 0x02], 0x02);
-		CurTick += CurDelay;
-		TempTick = (UINT64)CurTick * 44100 + HalfRate;
-		VGMSmplC = (UINT32)(TempTick / IMFRate);
-		IMFPos += 0x04;
-		
-		if (VGMSmplL < VGMSmplC)
-		{
-			SmplVal = VGMSmplC - VGMSmplL;
-			while(SmplVal)
-			{
-				if (SmplVal <= 0xFFFF)
-					CurDelay = (UINT16)SmplVal;
-				else
-					CurDelay = 0xFFFF;
-				
-				if (VGMPos >= VGMDataLen - 0x08)
-				{
-					VGMDataLen += 0x8000;
-					VGMData = (UINT8*)realloc(VGMData, VGMDataLen);
-				}
-				VGMData[VGMPos + 0x00] = 0x61;
-				memcpy(&VGMData[VGMPos + 0x01], &CurDelay, 0x02);
-				VGMPos += 0x03;
-				SmplVal -= CurDelay;
-			}
-			VGMSmplL = VGMSmplC;
-		}
-	}
-	VGMData[VGMPos] = 0x66;
-	VGMPos += 0x01;
-	
-	VGMDataLen = VGMPos;
-	VGMHead.lngEOFOffset = VGMDataLen;
-	VGMHead.lngTotalSamples = VGMSmplL;
-	if (LoopOn)
-	{
-		VGMHead.lngLoopOffset = VGMHead.lngDataOffset;
-		VGMHead.lngLoopSamples = VGMHead.lngTotalSamples;
-	}
-	
-	SmplVal = VGMHead.lngDataOffset;
-	if (SmplVal > sizeof(VGM_HEADER))
-		SmplVal = sizeof(VGM_HEADER);
-	VGMHead.lngEOFOffset -= 0x04;
-	if (VGMHead.lngLoopOffset)
-		VGMHead.lngLoopOffset -= 0x1C;
-	VGMHead.lngDataOffset -= 0x34;
-	memcpy(&VGMData[0x00], &VGMHead, SmplVal);
-	
-	return;
-}
diff --git a/src/util/git/git_igno.re b/src/util/git/git_igno.re
index bce92ec3..8fe488a5 100755
--- a/src/util/git/git_igno.re
+++ b/src/util/git/git_igno.re
@@ -35,6 +35,9 @@ vrl2vrs
 vrsdump
 vrldbg
 dro2imf
+dro2vgm
+imf2vgm
+raw2vgm
 ps.exe
 *.upx
 # except foo.html which is maintained by hand.
diff --git a/src/util/git/git_modu.les b/src/util/git/git_modu.les
index ab23923c..657e577f 100755
--- a/src/util/git/git_modu.les
+++ b/src/util/git/git_modu.les
@@ -1,6 +1,6 @@
 [submodule "src/lib/doslib"]
-        path = src/lib/doslib
-        url = https://github.com/joncampbell123/doslib.git
+	path = src/lib/doslib
+	url = https://github.com/joncampbell123/doslib.git
 
 [submodule "src/lib/jsmn"]
 	path = src/lib/jsmn
@@ -11,21 +11,25 @@
 	url = https://github.com/FlatRockSoft/CatacombApocalypse.git
 
 [submodule "wolf3d"]
-        path = 16/wolf3d
-        url = https://github.com/id-Software/wolf3d.git
+	path = 16/wolf3d
+	url = https://github.com/id-Software/wolf3d.git
 
 [submodule "keen"]
-        path = 16/keen
+	path = 16/keen
 	url = https://github.com/keendreams/keen.git
 
 [submodule "Catacomb3D"]
-        path = 16/Catacomb3D
+	path = 16/Catacomb3D
 	url = https://github.com/FlatRockSoft/Catacomb3D.git
 
 [submodule "shitman"]
-        path = 16/shitman
-        url = https://github.com/joncampbell123/shitman.git
+	path = 16/shitman
+	url = https://github.com/joncampbell123/shitman.git
 
 [submodule "dro2imf"]
 	path = "16/dro2imf"
 	url = https://github.com/Malvineous/dro2imf.git
+
+[submodule "vgmtools"]
+	path = "16/vgmtools"
+	url = https://github.com/vgmrips/vgmtools.git
diff --git a/src/util/shbat/run.bat b/src/util/shbat/run.bat
new file mode 100755
index 00000000..093735f0
--- /dev/null
+++ b/src/util/shbat/run.bat
@@ -0,0 +1,5 @@
+@echo off
+wmake clean
+wmake exmmtest.exe > exmmtest.16
+@rem wmakescroll.exe > scroll.16
+@rem wmake maptest.exemaptest.exe > maptest.16
diff --git a/src/util/shbat/winnbuil.sh b/src/util/shbat/winnbuil.sh
new file mode 100755
index 00000000..e6652305
--- /dev/null
+++ b/src/util/shbat/winnbuil.sh
@@ -0,0 +1,2 @@
+wmake -h clean
+wmake -h inntest.exe
diff --git a/src/util/shbat/winrun.bat b/src/util/shbat/winrun.bat
new file mode 100755
index 00000000..6717a782
--- /dev/null
+++ b/src/util/shbat/winrun.bat
@@ -0,0 +1,2 @@
+db\dosbox -conf data\winrun.cfg -exit
+exit
diff --git a/zcroll.exe b/zcroll.exe
new file mode 100755
index 00000000..1896348f
Binary files /dev/null and b/zcroll.exe differ