Full Code of vgmrips/vgmplay for AI

master 8262c68570d6 cached
229 files
3.1 MB
833.1k tokens
2153 symbols
1 requests
Download .txt
Showing preview only (3,342K chars total). Download the full file or copy to clipboard to get everything.
Repository: vgmrips/vgmplay
Branch: master
Commit: 8262c68570d6
Files: 229
Total size: 3.1 MB

Directory structure:
gitextract_fr0538in/

├── .gitattributes
├── .gitignore
├── .travis.yml
├── README.md
├── VGMPlay/
│   ├── .gitignore
│   ├── ChipMapper.c
│   ├── ChipMapper.h
│   ├── Makefile
│   ├── PortTalk_IOCTL.h
│   ├── Stream.c
│   ├── Stream.h
│   ├── VGMFile.h
│   ├── VGMPlay.c
│   ├── VGMPlay.dsp
│   ├── VGMPlay.dsw
│   ├── VGMPlay.h
│   ├── VGMPlay.ini
│   ├── VGMPlay.sln
│   ├── VGMPlay.txt
│   ├── VGMPlay.vcxproj
│   ├── VGMPlay.vcxproj.filters
│   ├── VGMPlayUI.c
│   ├── VGMPlay_AddFmts.c
│   ├── VGMPlay_Intf.h
│   ├── VGMPlay_Updates.txt
│   ├── XMasFiles/
│   │   ├── SWJ-SQRC01_1C.h
│   │   ├── SWJ-SQRC01_1C_trimmed_optimized.vgz
│   │   ├── WEWISH.CMF
│   │   ├── XMasBonus.h
│   │   ├── clyde1_1.dro
│   │   ├── lem_xmas_001_jb.dro
│   │   ├── lemmings_012_tim7.vgm
│   │   └── rudolph.dro
│   ├── chips/
│   │   ├── 2151intf.c
│   │   ├── 2151intf.h
│   │   ├── 2203intf.c
│   │   ├── 2203intf.h
│   │   ├── 2413intf.c
│   │   ├── 2413intf.h
│   │   ├── 2608intf.c
│   │   ├── 2608intf.h
│   │   ├── 2610intf.c
│   │   ├── 2610intf.h
│   │   ├── 2612intf.c
│   │   ├── 2612intf.h
│   │   ├── 262intf.c
│   │   ├── 262intf.h
│   │   ├── 3526intf.c
│   │   ├── 3526intf.h
│   │   ├── 3812intf.c
│   │   ├── 3812intf.h
│   │   ├── 8950intf.c
│   │   ├── 8950intf.h
│   │   ├── ChipIncl.h
│   │   ├── Ootake_PSG.c
│   │   ├── Ootake_PSG.h
│   │   ├── adlibemu.h
│   │   ├── adlibemu_opl2.c
│   │   ├── adlibemu_opl3.c
│   │   ├── ay8910.c
│   │   ├── ay8910.h
│   │   ├── ay8910_opl.c
│   │   ├── ay_intf.c
│   │   ├── ay_intf.h
│   │   ├── c140.c
│   │   ├── c140.h
│   │   ├── c352.c
│   │   ├── c352.h
│   │   ├── c6280.c
│   │   ├── c6280.h
│   │   ├── c6280intf.c
│   │   ├── c6280intf.h
│   │   ├── dac_control.c
│   │   ├── dac_control.h
│   │   ├── emu2149.c
│   │   ├── emu2149.h
│   │   ├── emu2413.c
│   │   ├── emu2413.h
│   │   ├── emu2413_NESpatches.txt
│   │   ├── emutypes.h
│   │   ├── es5503.c
│   │   ├── es5503.h
│   │   ├── es5506.c
│   │   ├── es5506.h
│   │   ├── fm.c
│   │   ├── fm.h
│   │   ├── fm2612.c
│   │   ├── fmopl.c
│   │   ├── fmopl.h
│   │   ├── gb.c
│   │   ├── gb.h
│   │   ├── iremga20.c
│   │   ├── iremga20.h
│   │   ├── k051649.c
│   │   ├── k051649.h
│   │   ├── k053260.c
│   │   ├── k053260.h
│   │   ├── k054539.c
│   │   ├── k054539.h
│   │   ├── mamedef.h
│   │   ├── multipcm.c
│   │   ├── multipcm.h
│   │   ├── nes_apu.c
│   │   ├── nes_apu.h
│   │   ├── nes_defs.h
│   │   ├── nes_intf.c
│   │   ├── nes_intf.h
│   │   ├── np_nes_apu.c
│   │   ├── np_nes_apu.h
│   │   ├── np_nes_dmc.c
│   │   ├── np_nes_dmc.h
│   │   ├── np_nes_fds.c
│   │   ├── np_nes_fds.h
│   │   ├── okim6258.c
│   │   ├── okim6258.h
│   │   ├── okim6295.c
│   │   ├── okim6295.h
│   │   ├── opl.c
│   │   ├── opl.h
│   │   ├── opll.c
│   │   ├── opll.h
│   │   ├── opm.c
│   │   ├── opm.h
│   │   ├── panning.c
│   │   ├── panning.h
│   │   ├── pokey.c
│   │   ├── pokey.h
│   │   ├── pwm.c
│   │   ├── pwm.h
│   │   ├── qsound_ctr.c
│   │   ├── qsound_ctr.h
│   │   ├── qsound_intf.c
│   │   ├── qsound_intf.h
│   │   ├── qsound_mame.c
│   │   ├── qsound_mame.h
│   │   ├── rf5c68.c
│   │   ├── rf5c68.h
│   │   ├── saa1099.c
│   │   ├── saa1099.h
│   │   ├── scd_pcm.c
│   │   ├── scd_pcm.h
│   │   ├── scsp.c
│   │   ├── scsp.h
│   │   ├── scspdsp.c
│   │   ├── scspdsp.h
│   │   ├── scsplfo.c
│   │   ├── segapcm.c
│   │   ├── segapcm.h
│   │   ├── sn76489.c
│   │   ├── sn76489.h
│   │   ├── sn76496.c
│   │   ├── sn76496.h
│   │   ├── sn76496_opl.c
│   │   ├── sn764intf.c
│   │   ├── sn764intf.h
│   │   ├── upd7759.c
│   │   ├── upd7759.h
│   │   ├── vrc7tone.h
│   │   ├── vsu.c
│   │   ├── vsu.h
│   │   ├── ws_audio.c
│   │   ├── ws_audio.h
│   │   ├── ws_initialIo.h
│   │   ├── x1_010.c
│   │   ├── x1_010.h
│   │   ├── ym2151.c
│   │   ├── ym2151.h
│   │   ├── ym2413.c
│   │   ├── ym2413.h
│   │   ├── ym2413_opl.c
│   │   ├── ym2413hd.c
│   │   ├── ym2413hd.h
│   │   ├── ym2612.c
│   │   ├── ym2612.h
│   │   ├── ym3438.c
│   │   ├── ym3438.h
│   │   ├── ymdeltat.c
│   │   ├── ymdeltat.h
│   │   ├── ymf262.c
│   │   ├── ymf262.h
│   │   ├── ymf271.c
│   │   ├── ymf271.h
│   │   ├── ymf278b.c
│   │   ├── ymf278b.h
│   │   ├── ymz280b.c
│   │   └── ymz280b.h
│   ├── dbus.c
│   ├── dbus.h
│   ├── dbus_stub.c
│   ├── licenses/
│   │   ├── GPL.txt
│   │   ├── List.txt
│   │   └── mame_license.txt
│   ├── mmkeys.h
│   ├── mmkeys_Win.c
│   ├── mmkeys_stub.c
│   ├── pt_ioctl.c
│   ├── stdbool.h
│   ├── vgm-player
│   ├── vgm2pcm.c
│   ├── vgm2wav.c
│   ├── vgm2wav.dsp
│   ├── vgmplay.1
│   ├── vgmspec171.txt
│   ├── xdg/
│   │   ├── vgmplay-mime.xml
│   │   └── vgmplay.desktop.in
│   └── zlib/
│       ├── zconf.h
│       ├── zdll.lib
│       ├── zlib.def
│       ├── zlib.h
│       ├── zlib.lib
│       └── zlibd.lib
└── in_vgm/
    ├── README.md
    ├── Winamp/
    │   ├── DSP.H
    │   ├── GEN.H
    │   ├── IN2.H
    │   ├── OUT.H
    │   ├── ipc_pe.h
    │   ├── wa_dlg.h
    │   └── wa_ipc.h
    ├── dlg_cfg.c
    ├── dlg_fileinfo.c
    ├── in_vgm.c
    ├── in_vgm.dsp
    ├── in_vgm.dsw
    ├── in_vgm.h
    ├── in_vgm.rc
    ├── ini_func.c
    ├── ini_func.h
    └── resource.h

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitattributes
================================================
*.dsp text eol=crlf
*.dsw text eol=crlf
*.sln text eol=crlf
*.vcxproj* text eol=crlf


================================================
FILE: .gitignore
================================================
##################
## Visual Studio 6
##################

# Build results
[Dd]ebug/
[Rr]elease/
*.exe
*.dll

# Object files
*.ilk
*.obj
*.pch
*.pdb
*.sbr
*.tmp

# Project cache files
*.aps
*.ncb
*.opt
*.sdf
*.suo
*.user

Thumbs.db
ehthumbs.db
Desktop.ini


================================================
FILE: .travis.yml
================================================
language: c

cache: ccache

before_install:
  - cd VGMPlay
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update       ; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install libao; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sed -i .bak 's/MACOSX = 0/MACOSX = 1/g' Makefile; fi

os:
  - linux
  - osx

compiler:
  - gcc

addons:
  apt:
    packages:
      - make 
      - gcc 
      - zlib1g-dev 
      - libao-dev
      - libdbus-1-dev

script:
  - make


================================================
FILE: README.md
================================================
# VGMPlay [![Build Status](https://travis-ci.org/vgmrips/vgmplay.svg?branch=master)](https://travis-ci.org/vgmrips/vgmplay)

The official and always up-to-date player for all [VGM](https://en.wikipedia.org/wiki/VGM_(file_format)) files.

In the future, the existing VGMPlay will be replaced by [libvgm](https://github.com/ValleyBell/libvgm), which is currently in development.

## Contact

* [VGMRips Forums](http://vgmrips.net/forum/index.php)
* IRC: irc.digibase.ca #vgmrips

## Compile VGMPlay under Windows

### Using MS Visual Studio 6.0:

1. Open `VGMPlay.dsw`.
2. Build the project.
3. Done.

### Using later versions of MS Visual Studio:

1. Open `VGMPlay.vcxproj`.
2. Build the project.
3. Done.

### Using MinGW/MSYS:

1. open MSYS and run `make WINDOWS=1` in VGMPlay's folder.
2. Done.

Note: You can compile it without MSYS, but you need to manually create
the OBJDIRS paths (or make them use the backslash '\'), because mkdir fails
at paths with a forward slash.

## Compile VGMPlay under Linux

1. [optional step] If you have libao installed, you can edit the 
Makefile to make VGMPlay use `libao` instead of `OSS`.
2. run `make` in VGMPlay's folder
3. Done. Optionally `sudo make install` and `sudo make play_install`.

### Building on Ubuntu (16.04)

#### Requirements

The following packages are needed in order to compile the binaries

```sh
sudo apt-get install make gcc zlib1g-dev libao-dev libdbus-1-dev
```

#### Building

```sh
make
```

## Compile VGMPlay under macOS

1. install libao by executing the line `brew install libao`
2. run `make install MACOSX=1 DISABLE_HWOPL_SUPPORT=1` in VGMPlay's folder 
(Alternatively edit the Makefile to set those constants and just run `make`.)
3. Done.

Thanks to grauw for macOS compilation instructions.

## Compile VGMPlay under Android
1. Install [Termux](https://github.com/termux/termux-app) on [F-Droid](https://f-droid.org/en/packages/com.termux/) or [GitHub](https://github.com/termux/termux-app/releases). Do not download Termux from Play Store for security and depreciation reasons
2. Open Termux and do `pkg update`
3. When you do pkg update, do `pkg install clang dbus git libao make pkg-config -y`
4. After the installation is done, do `git clone https://github.com/vgmrips/vgmplay`
5. After Done Cloning, do `cd vgmplay/VGMPlay`
6. And then do `make`


================================================
FILE: VGMPlay/.gitignore
================================================
/obj
/vgm2pcm
/vgmplay
/vgm2wav
vgmplay.desktop


================================================
FILE: VGMPlay/ChipMapper.c
================================================
// ChipMapper.c - Handles Chip Write (including OPL Hardware Support)

#include <stdio.h>
#include <string.h>
#include <math.h>
#include "stdbool.h"

//#define DISABLE_HW_SUPPORT	// disable support for OPL hardware
#ifdef __NetBSD__	// Thanks to nextvolume
#warning "Disabling OPL Mapper functionality, current code does not work on NetBSD"
#define DISABLE_HW_SUPPORT	// Current code does not work on NetBSD
#endif

#ifdef WIN32

#include <conio.h>
#include <windows.h>	// for QueryPerformance###

#else

#ifndef DISABLE_HW_SUPPORT
#include <unistd.h>
#ifdef __APPLE__
#include <architecture/i386/io.h>
#else
#include <sys/io.h>
#endif
#endif	// DISABLE_HW_SUPPORT

#include <time.h>
#endif

#ifdef __APPLE__
#define ioperm(x,y,z)
#define outb(x,y)
#define inb(x)
#endif

#include "chips/mamedef.h"

#include "chips/ChipIncl.h"

#ifndef DISABLE_HW_SUPPORT
unsigned char OpenPortTalk(void);
void ClosePortTalk(void);

#ifdef WIN32

void outportb(unsigned short PortAddress, unsigned char byte);
unsigned char inportb(unsigned short PortAddress);

#endif	// WIN32
#endif	// DISABLE_HW_SUPPORT

#include "ChipMapper.h"

#ifndef DISABLE_HW_SUPPORT
INLINE UINT8 OPL_HW_GetStatus(void);
INLINE void OPL_HW_WaitDelay(INT64 StartTime, float Delay);

// SN76496 OPL Translaton
void start_sn76496_opl(UINT8 ChipID, int clock, int stereo);
void sn76496_write_opl(UINT8 ChipID, offs_t offset, UINT8 data);
void sn76496_stereo_opl(UINT8 ChipID, offs_t offset, UINT8 data);
void sn76496_refresh_t6w28_opl(UINT8 ChipID);

// YM2413 OPL Translaton
void start_ym2413_opl(UINT8 ChipID);
void ym2413_w_opl(UINT8 ChipID, offs_t offset, UINT8 data);

// Meka YM2413 OPL Translation
int     FM_OPL_Init             (void *userdata);
void    FM_OPL_Close            (void);
void    FM_OPL_Write            (int Register, int Value);

// AY8910 OPL Translation
void ay8910_write_opl(UINT8 ChipID, UINT8 r, UINT8 v);
void start_ay8910_opl(UINT8 ChipID, int clock, UINT8 chip_type);


extern UINT8 OPL_MODE;
extern UINT8 OPL_CHIPS;

extern bool WINNT_MODE;
extern UINT16 FMPort;
extern UINT8 PlayingMode;
extern bool FMBreakFade;
extern bool FMOPL2Pan;
extern float FinalVol;

#ifdef WIN32
#define INP_9X		_inp
#define OUTP_9X		_outp
#define INP_NT		inportb
#define OUTP_NT		outportb
#endif

// Delays in usec (Port Reads - or microsec)
#define DELAY_OPL2_REG	 3.3f
#define DELAY_OPL2_DATA	23.0f
#define DELAY_OPL3_REG	 0.0f
//#define DELAY_OPL3_DATA	 0.28f	// fine for ISA cards (like SoundBlaster 16)
#define DELAY_OPL3_DATA	 13.3f	// required for PCI cards (CMI8738)
#ifdef WIN32
INT64 HWusTime;
#endif

#define YM2413_EC_DEFAULT	0x00
#define YM2413_EC_MEKA		0x01


typedef struct chip_mapping_info
{
	UINT8 ChipType;
	UINT8 ChipID;
	UINT8 RegBase;
	UINT8 ChnBase;
	UINT32 ChipOpt[0x10];
} CHIP_MAP;

UINT8 ChipCount = 0x00;
UINT8 SelChip;
UINT8 ChipArr[0x100];
CHIP_MAP ChipMap[0x10];
bool RegChnUsage[0x20];
UINT8 OPLReg[0x200];
UINT8 OPLRegBak[0x200];
UINT8 OPLRegForce[0x200];
bool SkipMode = false;
bool OpenedFM = false;
#endif	// DISABLE_HW_SUPPORT
UINT8 YM2413_EMU_CORE;

UINT32 OptArr[0x10];

#ifndef WIN32
unsigned char OpenPortTalk(void)
{
#ifndef DISABLE_HW_SUPPORT
	int retval;
	
	retval = ioperm(FMPort, 0x04, 1);
	
	return retval & 0xFF;
#else
	return 0xFF;	// not supported
#endif
}

void ClosePortTalk(void)
{
#ifndef DISABLE_HW_SUPPORT
	ioperm(FMPort, 0x04, 0);
#endif
	
	return;
}

#elif defined(DISABLE_HW_SUPPORT)

unsigned char OpenPortTalk(void)
{
	return 0xFF;	// not supported
}

void ClosePortTalk(void)
{
	return;
}
#endif	// WIN32

void open_fm_option(UINT8 ChipType, UINT8 OptType, UINT32 OptVal)
{
	OptArr[OptType & 0x0F] = OptVal;
	
	return;
}

void opl_chip_reset(void)
{
#ifndef DISABLE_HW_SUPPORT
	UINT16 Reg;
	float FnlVolBak;
	
	FnlVolBak = FinalVol;
	FinalVol = 1.0f;
	memset(OPLRegForce, 0x01, 0x200);
	
	OPL_HW_WriteReg(0x105, 0x01);	// OPL3 Enable
	OPL_HW_WriteReg(0x001, 0x20);	// Test Register
	OPL_HW_WriteReg(0x002, 0x00);	// Timer 1
	OPL_HW_WriteReg(0x003, 0x00);	// Timer 2
	OPL_HW_WriteReg(0x004, 0x00);	// IRQ Mask Clear
	OPL_HW_WriteReg(0x104, 0x00);	// 4-Op-Mode Disable
	OPL_HW_WriteReg(0x008, 0x00);	// Keyboard Split
	
	// make sure all internal calulations finish sound generation
	for (Reg = 0x00; Reg < 0x09; Reg ++)
	{
		OPL_HW_WriteReg(0x0C0 | Reg, 0x00);	// silence all notes (OPL3)
		OPL_HW_WriteReg(0x1C0 | Reg, 0x00);
	}
	for (Reg = 0x00; Reg < 0x16; Reg ++)
	{
		if ((Reg & 0x07) >= 0x06)
			continue;
		OPL_HW_WriteReg(0x040 | Reg, 0x3F);	// silence all notes (OPL2)
		OPL_HW_WriteReg(0x140 | Reg, 0x3F);
		
		OPL_HW_WriteReg(0x080 | Reg, 0xFF);	// set Sustain/Release Rate to FASTEST
		OPL_HW_WriteReg(0x180 | Reg, 0xFF);
		OPL_HW_WriteReg(0x060 | Reg, 0xFF);
		OPL_HW_WriteReg(0x160 | Reg, 0xFF);
		
		OPL_HW_WriteReg(0x020 | Reg, 0x00);	// NULL the rest
		OPL_HW_WriteReg(0x120 | Reg, 0x00);
		
		OPL_HW_WriteReg(0x0E0 | Reg, 0x00);
		OPL_HW_WriteReg(0x1E0 | Reg, 0x00);
	}
	OPL_HW_WriteReg(0x0BD, 0x00);	// Rhythm Mode
	for (Reg = 0x00; Reg < 0x09; Reg ++)
	{
		OPL_HW_WriteReg(0x0B0 | Reg, 0x00);	// turn all notes off (-> Release Phase)
		OPL_HW_WriteReg(0x1B0 | Reg, 0x00);
		OPL_HW_WriteReg(0x0A0 | Reg, 0x00);
		OPL_HW_WriteReg(0x1A0 | Reg, 0x00);
	}
	
	// although this would be a more proper reset, it sometimes produces clicks
	/*for (Reg = 0x020; Reg <= 0x0FF; Reg ++)
		OPL_HW_WriteReg(Reg, 0x00);
	for (Reg = 0x120; Reg <= 0x1FF; Reg ++)
		OPL_HW_WriteReg(Reg, 0x00);*/
	
	// Now do a proper reset of all other registers.
	for (Reg = 0x040; Reg < 0x0A0; Reg ++)
	{
		if ((Reg & 0x07) >= 0x06 || (Reg & 0x1F) >= 0x18)
			continue;
		OPL_HW_WriteReg(0x000 | Reg, 0x00);
		OPL_HW_WriteReg(0x100 | Reg, 0x00);
	}
	for (Reg = 0x00; Reg < 0x09; Reg ++)
	{
		OPL_HW_WriteReg(0x0C0 | Reg, 0x30);	// must be 30 to make OPL2 VGMs sound on OPL3
		OPL_HW_WriteReg(0x1C0 | Reg, 0x30);	// if they don't send the C0 reg
	}
	
	memset(OPLRegForce, 0x01, 0x200);
	FinalVol = FnlVolBak;
#endif	// DISABLE_HW_SUPPORT
	
	return;
}

void open_real_fm(void)
{
#ifndef DISABLE_HW_SUPPORT
	UINT8 CurChip;
	CHIP_MAP* CurMap;
	UINT8 CurC2;
	bool OldSM;
	
	//SkipMode = false;
	OldSM = SkipMode;
	opl_chip_reset();
	OpenedFM = true;
	
	for (CurChip = 0x00; CurChip < ChipCount; CurChip ++)
	{
		SelChip = CurChip;
		CurMap = ChipMap + SelChip;
		switch(CurMap->ChipType)
		{
		case 0x00:	// SN76496 and T6W28
			if (CurMap->ChipOpt[0x0F] & 0x80000000)
			{
				// Avoid Bugs
				CurMap->RegBase = (CurMap->ChipOpt[0x0F] >> 8) & 0xFF;
				CurMap->ChnBase = (CurMap->ChipOpt[0x0F] >> 0) & 0xFF;
			}
			
			start_sn76496_opl(CurMap->ChipID, CurMap->ChipOpt[0x00], CurMap->ChipOpt[0x05]);
			if (CurMap->ChipOpt[0x00] & 0x80000000)
			{
				// Set up T6W28
				for (CurC2 = 0x00; CurC2 < CurChip; CurC2 ++)
				{
					if (ChipMap[CurC2].ChipType == CurMap->ChipType)
					{
						CurMap->ChipOpt[0x0F] = 0x80000000 |
												(CurMap->RegBase << 8) | (CurMap->ChnBase << 0);
						CurMap->RegBase = ChipMap[CurC2].RegBase;
						CurMap->ChnBase = ChipMap[CurC2].ChnBase;
						sn76496_refresh_t6w28_opl(ChipMap[CurC2].ChipID);
						break;
					}
				}
			}
			break;
		case 0x01:	// YM2413
			switch(YM2413_EMU_CORE)
			{
			case YM2413_EC_DEFAULT:
				start_ym2413_opl(CurMap->ChipID);
				break;
			case YM2413_EC_MEKA:
				FM_OPL_Init(NULL);
				break;
			}
			break;
		case 0x09:	// YM3812
			break;
		case 0x0A:	// YM3526
			break;
		case 0x0B:	// Y8950
			break;
		case 0x0C:	// YMF262
			break;
		case 0x0D:	// YMF278B
			break;
		case 0x12:	// AY8910
			start_ay8910_opl(CurMap->ChipID, CurMap->ChipOpt[0x00], CurMap->ChipOpt[0x01]);
			break;
		}
	}
#endif	// DISABLE_HW_SUPPORT

	return;
}

void setup_real_fm(UINT8 ChipType, UINT8 ChipID)
{
#ifndef DISABLE_HW_SUPPORT
	CHIP_MAP* CurMap;
	UINT8 CurChip;
	UINT8 CurSet;
	UINT8 CurChn;
	bool ExitLoop;
	
	SelChip = ChipCount;
	ChipArr[(ChipType << 1) | (ChipID & 0x01)] = SelChip;
	CurMap = ChipMap + SelChip;
	CurMap->ChipType = ChipType;
	CurMap->ChipID = ChipID & 0x7F;
	
	switch(ChipType)
	{
	case 0x00:	// SN76496 and T6W28
	case 0x12:	// AY8910
		ExitLoop = false;
		for (CurSet = 0x00; CurSet < 0x02; CurSet ++)
		{
			for (CurChn = 0x00; CurChn < 0x09; CurChn ++)
			{
				if (! RegChnUsage[(CurSet << 4) | CurChn])
				{
					ExitLoop = true;
					break;
				}
			}
			if (ExitLoop)
				break;
		}
		CurSet %= 0x02;
		CurChn %= 0x09;
		
		CurMap->RegBase = CurSet;
		CurMap->ChnBase = CurChn;
		memcpy(CurMap->ChipOpt, OptArr, 0x10 * sizeof(UINT32));
		CurMap->ChipOpt[0x0F] = 0x00;
		if (ChipType == 0x00)
		{
			for (CurChn = 0x00; CurChn < 0x04; CurChn ++)
			{
				RegChnUsage[(CurMap->RegBase << 4) | (CurMap->ChnBase + CurChn)] = true;
			}
		}
		else
		{
			for (CurChn = 0x00; CurChn < 0x03; CurChn ++)
			{
				RegChnUsage[(CurMap->RegBase << 4) | (CurMap->ChnBase + CurChn)] = true;
			}
		}
		break;
	case 0x01:	// YM2413
		CurMap->RegBase = 0x00;
		CurMap->ChnBase = 0x00;
		
		for (CurChip = 0x00; CurChip < SelChip; CurChip ++)
		{
			if (ChipMap[CurChip].ChipType == 0x01)
			{
				CurMap->RegBase = 0x01;
				break;
			}
			
			ChipMap[CurChip].RegBase = 0x01;
		}
		for (CurChn = 0x00; CurChn < 0x09; CurChn ++)
		{
			RegChnUsage[(CurMap->RegBase << 4) | CurChn] = true;
		}
		break;
	case 0x09:	// YM3812
		for (CurSet = 0x00; CurSet < 0x02; CurSet ++)
		{
			if (! RegChnUsage[(CurSet << 4) | 0x00])
				break;
		}
		CurSet %= 0x02;
		CurMap->RegBase = CurSet;
		CurMap->ChnBase = 0x00;
		break;
	case 0x0A:	// YM3526
		for (CurSet = 0x00; CurSet < 0x02; CurSet ++)
		{
			if (! RegChnUsage[(CurSet << 4) | 0x00])
				break;
		}
		CurSet %= 0x02;
		CurMap->RegBase = CurSet;
		CurMap->ChnBase = 0x00;
		break;
	case 0x0B:	// Y8950
		for (CurSet = 0x00; CurSet < 0x02; CurSet ++)
		{
			if (! RegChnUsage[(CurSet << 4) | 0x00])
				break;
		}
		CurSet %= 0x02;
		CurMap->RegBase = CurSet;
		CurMap->ChnBase = 0x00;
		break;
	case 0x0C:	// YMF262
		CurMap->RegBase = 0x00;
		CurMap->ChnBase = 0x00;
		break;
	case 0x0D:	// YMF278B
		CurMap->RegBase = 0x00;
		CurMap->ChnBase = 0x00;
		break;
	}
	ChipCount ++;
#endif	// DISABLE_HW_SUPPORT
	
	return;
}

void close_real_fm(void)
{
#ifndef DISABLE_HW_SUPPORT
	UINT8 CurChip;
	UINT8 CurChn;
	UINT8 CurOp;
	UINT16 Reg;
	UINT8 RegOp;
	bool SoftFade;
	
	SoftFade = (FMBreakFade && FinalVol > 0.01f);
	for (CurChip = 0x00; CurChip < 0x02; CurChip ++)
	{
		for (CurChn = 0x00; CurChn < 0x09; CurChn ++)
		{
			// Make sure that the ReleaseRate takes effect ...
			for (CurOp = 0x00; CurOp < 0x02; CurOp ++)
			{
				if (! CurOp && ! (OPLReg[(CurChip << 8) | (0xC0 | CurChn)] & 0x01))
					continue;
				
				RegOp = (CurChn / 0x03) * 0x08 | (CurChn % 0x03) + (CurOp * 0x03);
				Reg = (CurChip << 8) | 0x80 | RegOp;
				if (SoftFade)
				{
					if ((OPLReg[Reg] & 0x0F) < 0x03)	// Force a soft fading
						OPL_HW_WriteReg(Reg, (OPLReg[Reg] & 0xF0) | 0x04);
				}
				else
				{
					// stop sound immediately after Note-Off
					OPL_HW_WriteReg(Reg, (OPLReg[Reg] & 0xF0) | 0x0F);
				}
			}
			
			// ... and turn off all notes.
			if (SoftFade)
			{
				// soft way (turn off and let fade)
				Reg = (CurChip << 8) | (0xB0 | CurChn);
				OPL_HW_WriteReg(Reg, OPLReg[Reg] & ~0x20);
			}
			else
			{
				// hard way (turn off and set frequency to zero)
				Reg = (CurChip << 8) | (0xA0 | CurChn);
				OPL_HW_WriteReg(Reg | 0x00, 0x00);	// A0 - Frequency LSB
				OPL_HW_WriteReg(Reg | 0x10, 0x00);	// B0 - Frequency MSB / Block / Key On
			}
		}
		
		// Set Values that are compatible with Windows' FM Driver
		OPL_HW_WriteReg(0x104, 0x00);	// 4-Op-Mode Disable
		OPL_HW_WriteReg(0x001, 0x00);	// Wave Select Disable
		OPL_HW_WriteReg(0x002, 0x00);	// Timer 1
		OPL_HW_WriteReg(0x003, 0x00);	// Timer 2
		OPL_HW_WriteReg(0x004, 0x00);	// IRQ mask clear
		OPL_HW_WriteReg(0x008, 0x00);	// Keyboard Split
		OPL_HW_WriteReg(0x0BD, 0xC0);	// Rhythm Mode
	}
	OpenedFM = false;
	ChipCount = 0x00;
	memset(RegChnUsage, 0x00, sizeof(bool) * 0x20);
#endif	// DISABLE_HW_SUPPORT
	
	return;
}

void chip_reg_write(UINT8 ChipType, UINT8 ChipID,
					UINT8 Port, UINT8 Offset, UINT8 Data)
{
#ifndef DISABLE_HW_SUPPORT
	bool ModeFM;
	UINT8 CurChip;
	
	switch(PlayingMode)
	{
	case 0x00:
		ModeFM = false;
		break;
	case 0x01:
		ModeFM = true;
		break;
	case 0x02:
		ModeFM = false;
		for (CurChip = 0x00; CurChip < ChipCount; CurChip ++)
		{
			if (ChipMap[CurChip].ChipType == ChipType &&
				ChipMap[CurChip].ChipID == ChipID)
			{
				ModeFM = true;
				break;
			}
		}
		break;
	}
	
	if (! ModeFM)
	{
#endif	// DISABLE_HW_SUPPORT
		switch(ChipType)
		{
		case 0x00:	// SN76496
			sn764xx_w(ChipID, Port, Data);
			break;
		case 0x01:	// YM2413
			ym2413_w(ChipID, 0x00, Offset);
			ym2413_w(ChipID, 0x01, Data);
			break;
		case 0x02:	// YM2612
			ym2612_w(ChipID, (Port << 1) | 0x00, Offset);
			ym2612_w(ChipID, (Port << 1) | 0x01, Data);
			break;
		case 0x03:	// YM2151
			ym2151_w(ChipID, 0x00, Offset);
			ym2151_w(ChipID, 0x01, Data);
			break;
		case 0x04:	// SegaPCM
			break;
		case 0x05:	// RF5C68
			rf5c68_w(ChipID, Offset, Data);
			break;
		case 0x06:	// YM2203
			ym2203_w(ChipID, 0x00, Offset);
			ym2203_w(ChipID, 0x01, Data);
			break;
		case 0x07:	// YM2608
			ym2608_w(ChipID, (Port << 1) | 0x00, Offset);
			ym2608_w(ChipID, (Port << 1) | 0x01, Data);
			break;
		case 0x08:	// YM2610/YM2610B
			ym2610_w(ChipID, (Port << 1) | 0x00, Offset);
			ym2610_w(ChipID, (Port << 1) | 0x01, Data);
			break;
		case 0x09:	// YM3812
			ym3812_w(ChipID, 0x00, Offset);
			ym3812_w(ChipID, 0x01, Data);
			break;
		case 0x0A:	// YM3526
			ym3526_w(ChipID, 0x00, Offset);
			ym3526_w(ChipID, 0x01, Data);
			break;
		case 0x0B:	// Y8950
			y8950_w(ChipID, 0x00, Offset);
			y8950_w(ChipID, 0x01, Data);
			break;
		case 0x0C:	// YMF262
			ymf262_w(ChipID, (Port << 1) | 0x00, Offset);
			ymf262_w(ChipID, (Port << 1) | 0x01, Data);
			break;
		case 0x0D:	// YMF278B
			ymf278b_w(ChipID, (Port << 1) | 0x00, Offset);
			ymf278b_w(ChipID, (Port << 1) | 0x01, Data);
			break;
		case 0x0E:	// YMF271
			ymf271_w(ChipID, (Port << 1) | 0x00, Offset);
			ymf271_w(ChipID, (Port << 1) | 0x01, Data);
			break;
		case 0x0F:	// YMZ280B
			ymz280b_w(ChipID, 0x00, Offset);
			ymz280b_w(ChipID, 0x01, Data);
			break;
		case 0x10:	// RF5C164
			rf5c164_w(ChipID, Offset, Data);
			break;
		case 0x11:	// PWM
			pwm_chn_w(ChipID, Port, (Offset << 8) | (Data << 0));
			break;
		case 0x12:	// AY8910
			ayxx_w(ChipID, 0x00, Offset);
			ayxx_w(ChipID, 0x01, Data);
			break;
		case 0x13:	// GameBoy
			gb_sound_w(ChipID, Offset, Data);
			break;
		case 0x14:	// NES APU
			nes_w(ChipID, Offset, Data);
			break;
		case 0x15:	// MultiPCM
			multipcm_w(ChipID, Offset, Data);
			break;
		case 0x16:	// UPD7759
			upd7759_write(ChipID, Offset, Data);
			break;
		case 0x17:	// OKIM6258
			okim6258_write(ChipID, Offset, Data);
			break;
		case 0x18:	// OKIM6295
			okim6295_w(ChipID, Offset, Data);
			break;
		case 0x19:	// K051649 / SCC1
			k051649_w(ChipID, (Port << 1) | 0x00, Offset);
			k051649_w(ChipID, (Port << 1) | 0x01, Data);
			break;
		case 0x1A:	// K054539
			k054539_w(ChipID, (Port << 8) | (Offset << 0), Data);
			break;
		case 0x1B:	// HuC6280
			c6280_w(ChipID, Offset, Data);
			break;
		case 0x1C:	// C140
			c140_w(ChipID, (Port << 8) | (Offset << 0), Data);
			break;
		case 0x1D:	// K053260
			k053260_w(ChipID, Offset, Data);
			break;
		case 0x1E:	// Pokey
			pokey_w(ChipID, Offset, Data);
			break;
		case 0x1F:	// QSound
			qsound_w(ChipID, 0x00, Port);	// Data MSB
			qsound_w(ChipID, 0x01, Offset);	// Data LSB
			qsound_w(ChipID, 0x02, Data);	// Register
			break;
		case 0x20:	// YMF292/SCSP
			scsp_w(ChipID, (Port << 8) | (Offset << 0), Data);
			break;
		case 0x21:	// WonderSwan
			ws_audio_port_write(ChipID, 0x80 | Offset, Data);
			break;
		case 0x22:	// VSU
			VSU_Write(ChipID, (Port << 8) | (Offset << 0), Data);
			break;
		case 0x23:	// SAA1099
			saa1099_control_w(ChipID, 0, Offset);
			saa1099_data_w(ChipID, 0, Data);
			break;
		case 0x24:	// ES5503
			es5503_w(ChipID, Offset, Data);
			break;
		case 0x25:	// ES5506
			if (Port & 0x80)
				es550x_w16(ChipID, Port & 0x7F, (Offset << 8) | (Data << 0));
			else
				es550x_w(ChipID, Port, Data);
			break;
		case 0x26:	// X1-010
			seta_sound_w(ChipID, (Port << 8) | (Offset << 0), Data);
			break;
		case 0x27:	// C352
			c352_w(ChipID, Port, (Offset << 8) | (Data << 0));
			break;
		case 0x28:	// GA20
			irem_ga20_w(ChipID, Offset, Data);
			break;
//		case 0x##:	// OKIM6376
//			break;
		}
#ifndef DISABLE_HW_SUPPORT
	}
	else
	{
		if (! OpenedFM)
			return;
		
		SelChip = ChipArr[(ChipType << 1) | (ChipID & 0x01)];
		switch(ChipType)
		{
		case 0x00:	// SN76496
			switch(Port)
			{
			case 0x00:
				sn76496_write_opl(ChipID, 0x00, Data);
				break;
			case 0x01:
				sn76496_stereo_opl(ChipID, 0x00, Data);
				break;
			}
			break;
		case 0x01:	// YM2413
			switch(YM2413_EMU_CORE)
			{
			case YM2413_EC_DEFAULT:
				ym2413_w_opl(ChipID, 0x00, Offset);
				ym2413_w_opl(ChipID, 0x01, Data);
				break;
			case YM2413_EC_MEKA:
				FM_OPL_Write(Offset, Data);
				break;
			}
			break;
		case 0x09:	// YM3812
			if ((Offset & 0xF0) == 0xC0 && (! FMOPL2Pan || ! (Data & 0x30)))
				Data |= 0x30;
			else if ((Offset & 0xF0) == 0xE0)
				Data &= 0xF3;
			OPL_RegMapper((ChipID << 8) | Offset, Data);
			break;
		case 0x0A:	// YM3526
			if ((Offset & 0xF0) == 0xC0 && (! FMOPL2Pan || ! (Data & 0x30)))
				Data |= 0x30;
			else if ((Offset & 0xF0) == 0xE0)
				Data &= 0xF0;
			OPL_RegMapper((ChipID << 8) | Offset, Data);
			break;
		case 0x0B:	// Y8950
			if (Offset == 0x07 || (Offset >= 0x09 && Offset <= 0x17))
				break;
			if ((Offset & 0xF0) == 0xC0 && (! FMOPL2Pan || ! (Data & 0x30)))
				Data |= 0x30;
			else if ((Offset & 0xF0) == 0xE0)
				Data &= 0xF0;
			OPL_RegMapper((ChipID << 8) | Offset, Data);
			break;
		case 0x0C:	// YMF262
			OPL_RegMapper((Port << 8) | Offset, Data);
			break;
		case 0x12:	// AY8910
			ay8910_write_opl(ChipID, Offset, Data);
			break;
		}
	}
#endif	// DISABLE_HW_SUPPORT
	return;
}

void OPL_Hardware_Detecton(void)
{
#ifndef DISABLE_HW_SUPPORT
	UINT8 Status1;
	UINT8 Status2;
#ifdef WIN32
	//LARGE_INTEGER TempQud1;
	//LARGE_INTEGER TempQud2;
	LARGE_INTEGER TempQudFreq;
	//__int64 TempQudMid;
	
	HWusTime = 0;
	if (! WINNT_MODE)
		Status1 = 0x00;
	else
#endif
		Status1 = OpenPortTalk();
	
	if (Status1)
	{
		OPL_MODE = 0x00;
		printf("Error opening FM Port! Permission denied!\n");
		goto FinishDetection;
	}
	
	OPL_MODE = 0x02;	// must be set to activate OPL2-Delays
	
	// OPL2 Detection
	OPL_HW_WriteReg(0x04, 0x60);
	OPL_HW_WriteReg(0x04, 0x80);
	Status1 = OPL_HW_GetStatus();
	Status1 &= 0xE0;
	
	OPL_HW_WriteReg(0x02, 0xFF);
	OPL_HW_WriteReg(0x04, 0x21);
	OPL_HW_WaitDelay(0, 80);
	
	Status2 = OPL_HW_GetStatus();
	Status2 &= 0xE0;
	
	OPL_HW_WriteReg(0x04, 0x60);
	OPL_HW_WriteReg(0x04, 0x80);
	
	if (! ((Status1 == 0x00) && (Status2 == 0xC0)))
	{
		// Detection failed
		OPL_MODE = 0x00;
		printf("No OPL Chip detected!\n");
		goto FinishDetection;
	}
	
	// OPL3 Detection
	Status1 = OPL_HW_GetStatus();
	Status1 &= 0x06;
	if (! Status1)
	{
		OPL_MODE = 0x03;
		OPL_CHIPS = 0x01;
		printf("OPL 3 Chip found.\n");
		goto FinishDetection;
	}
	
	// OPL2 Dual Chip Detection
	OPL_HW_WriteReg(0x104, 0x60);
	OPL_HW_WriteReg(0x104, 0x80);
	Status1 = OPL_HW_GetStatus();
	Status1 &= 0xE0;
	
	OPL_HW_WriteReg(0x102, 0xFF);
	OPL_HW_WriteReg(0x104, 0x21);
	OPL_HW_WaitDelay(0, 80);
	
	Status2 = OPL_HW_GetStatus();
	Status2 &= 0xE0;
	
	OPL_HW_WriteReg(0x104, 0x60);
	OPL_HW_WriteReg(0x104, 0x80);
	
	if ((Status1 == 0x00) && (Status2 == 0xC0))
	{
		OPL_CHIPS = 0x02;
		printf("Dual OPL 2 Chip found.\n");
	}
	else
	{
		OPL_CHIPS = 0x01;
		printf("OPL 2 Chip found.\n");
	}
	
FinishDetection:
#ifdef WIN32
	// note CPU time needed for 1 us
	QueryPerformanceFrequency(&TempQudFreq);
	HWusTime = TempQudFreq.QuadPart / 1000000;
	
	/*QueryPerformanceCounter(&TempQud1);
	OPL_HW_GetStatus();
	QueryPerformanceCounter(&TempQud2);
	TempQudMid = TempQud2.QuadPart - TempQud1.QuadPart;
	
	QueryPerformanceCounter(&TempQud1);
	OPL_HW_GetStatus();
	QueryPerformanceCounter(&TempQud2);
	TempQudMid += TempQud2.QuadPart - TempQud1.QuadPart;
	
	HWusTime = TempQudMid / 2;
	printf("Port Read Cycles: %I64u\tMSec Cycles: %I64u\n", HWusTime,
			TempQudFreq.QuadPart / 1000);
	printf("us per ms: %I64u\n", TempQudFreq.QuadPart / (HWusTime * 1000));
	HWusTime = TempQudFreq.QuadPart / 1000000;*/
	
	if (WINNT_MODE)
#endif
		ClosePortTalk();
#endif	// DISABLE_HW_SUPPORT
	
	return;
}

#ifndef DISABLE_HW_SUPPORT
INLINE UINT8 OPL_HW_GetStatus(void)
{
	UINT8 RetStatus;
	
#ifdef WIN32
	switch(WINNT_MODE)
	{
	case false:	// Windows 95/98/ME
		RetStatus = INP_9X(FMPort);
		break;
	case true:	// Windows NT/2000/XP/...
		RetStatus = INP_NT(FMPort);
		break;
	}
#else
	RetStatus = inb(FMPort);
#endif
	
	return RetStatus;
}

INLINE void OPL_HW_WaitDelay(INT64 StartTime, float Delay)
{
#ifdef WIN32
	LARGE_INTEGER CurTime;
	INT64 EndTime;
	UINT16 CurUS;
	
	// waits Delay us
	if (HWusTime)
	{
		OPL_HW_GetStatus();	// read once, just to be safe
		EndTime = (INT64)(StartTime + HWusTime * Delay);
		do
		{
			QueryPerformanceCounter(&CurTime);
		} while(CurTime.QuadPart < EndTime);
	}
	else if (Delay >= 1.0f)
	{
		for (CurUS = 0x00; CurUS < Delay; CurUS ++)
			OPL_HW_GetStatus();
	}
	else
	{
		OPL_HW_GetStatus();	// read once, just to be safe
	}

#else

	struct timespec NanoTime;
	
	OPL_HW_GetStatus();	// read once, then wait should work
	if (Delay >= 1.0f)
		Delay -= 1.0f;
	
	// waits Delay us
	NanoTime.tv_sec = 0;
	// xx-- nsec should be 1000 * Delay, but somehow the resulting Delay is too short --xx
	NanoTime.tv_nsec = 1000 * Delay;
	nanosleep(&NanoTime, NULL);
#endif
	
	return;
}
#endif	// DISABLE_HW_SUPPORT

void OPL_HW_WriteReg(UINT16 Reg, UINT8 Data)
{
#ifndef DISABLE_HW_SUPPORT
	UINT16 Port;
#ifdef WIN32
	LARGE_INTEGER StartTime;
#endif
	UINT8 DataOld;
	UINT8 OpNum;
	UINT8 TempVol;
	float TempSng;
	
	Reg &= 0x01FF;
	
	if (SkipMode)
	{
		OPLReg[Reg] = Data;
		return;
	}
	
	// Register = Rhythm Control and RhmythmOn-Bit changed
	// -> set/reset Modulator Volume of Channels 7 and 8 (Volume for HH/CYM)
	if (Reg == 0x0BD && (OPLReg[Reg] ^ Data) & 0x20 && FinalVol != 1.0f)
	{
		OPLReg[Reg] = Data;
		OPLRegForce[Reg] = 0x01;
		
		OPL_HW_WriteReg(0x51, OPLReg[0x51]);	// Ch 7 Mod TL
		OPL_HW_WriteReg(0x52, OPLReg[0x52]);	// Ch 8 Mod TL
	}
	
	DataOld = Data;
	if ((Reg & 0xE0) == 0x40)
	{
		OpNum = (Reg & 0x07) / 0x03;	// Modulator 0x00, Carrier 0x01
		TempVol = ((Reg & 0x18) >> 3) * 0x03 + ((Reg & 0x07) % 0x03);
		
		if ((OPLReg[(Reg & 0x100) | 0xC0 | TempVol] & 0x01))
			OpNum = 0x01;	// Additive Syntheses - affects final volume
		if (! (Reg & 0x100) && TempVol >= 0x07 && (OPLReg[0xBD] & 0x20))
			OpNum = 0x01;	// used as Volume for Rhythm: Hi-Hat / Cymbal
		if (OpNum == 0x01 && FinalVol != 1.0f)
		{
			TempVol = Data & 0x3F;
			TempSng = (float)pow(2.0, -TempVol / 8.0);
			TempSng *= FinalVol;
			if (TempSng > 0.0f)
				TempSng = (float)(-8.0 * log(TempSng) / log(2.0));
			else
				TempSng = 64.0f;
			if (TempSng < 0.0f)
				TempVol = 0x00;
			else if (TempSng >= 64.0f)
				TempVol = 0x3F;
			else
				TempVol = (UINT8)TempSng;
			
			Data = (Data & 0xC0) | TempVol;
		}
	}
	if (Data == DataOld && Data == OPLReg[Reg] && ! OPLRegForce[Reg])
		return;	// only write neccessary registers (avoid spamming)
	OPLReg[Reg] = DataOld;
	OPLRegForce[Reg] = (Data != DataOld) ? 0x01 : 0x00;	// force next write
	
	Port = (Reg & 0x100) ? (FMPort + 0x02) : (FMPort + 0x00);
	
	// 1. Set Register
	// 2. wait some time (short delay)
	// 3. Write Data
	// 4. wait some time (long delay)
#ifdef WIN32
	QueryPerformanceCounter(&StartTime);
	if (! WINNT_MODE)	// Windows 95/98/ME
		OUTP_9X(Port + 0x00, Reg & 0xFF);
	else				// Windows NT/2000/XP/...
		OUTP_NT(Port + 0x00, Reg & 0xFF);
	switch(OPL_MODE)
	{
	case 0x02:
		OPL_HW_WaitDelay(StartTime.QuadPart, DELAY_OPL2_REG);
		break;
	case 0x03:
		OPL_HW_WaitDelay(StartTime.QuadPart, DELAY_OPL3_REG);
		break;
	}
#else
	outb(Reg & 0xFF, Port + 0x00);
	switch(OPL_MODE)
	{
	case 0x02:
		OPL_HW_WaitDelay(0, DELAY_OPL2_REG);
		break;
	case 0x03:
		OPL_HW_WaitDelay(0, DELAY_OPL3_REG);
		break;
	}
#endif	// WIN32
	
#ifdef WIN32
	QueryPerformanceCounter(&StartTime);
	if (! WINNT_MODE)	// Windows 95/98/ME
		OUTP_9X(Port + 0x01, Data);
	else				// Windows NT/2000/XP/...
		OUTP_NT(Port + 0x01, Data);
	switch(OPL_MODE)
	{
	case 0x02:
		OPL_HW_WaitDelay(StartTime.QuadPart, DELAY_OPL2_DATA);
		break;
	case 0x03:
		OPL_HW_WaitDelay(StartTime.QuadPart, DELAY_OPL3_DATA);
		break;
	}
#else
	outb(Data, Port + 0x01);
	switch(OPL_MODE)
	{
	case 0x02:
		OPL_HW_WaitDelay(0, DELAY_OPL2_DATA);
		break;
	case 0x03:
		OPL_HW_WaitDelay(0, DELAY_OPL3_DATA);
		break;
	}
#endif	// WIN32
#endif	// DISABLE_HW_SUPPORT
	
	return;
}

void OPL_RegMapper(UINT16 Reg, UINT8 Data)
{
#ifndef DISABLE_HW_SUPPORT
	UINT16 NewReg;
	UINT8 RegType;
	UINT8 Grp;
	UINT8 Chn;
	UINT8 Slot;
	UINT8 RegOp;
	
	switch(Reg & 0xE0)
	{
	case 0x00:
		RegType = 0x00;
		break;
	case 0x20:
	case 0x40:
	case 0x60:
	case 0x80:
	case 0xE0:
		if ((Reg & 0x07) < 0x06 && ! ((Reg & 0x18) == 0x18))
			RegType = 0x01;
		else
			RegType = 0x00;
		break;
	case 0xA0:
		if ((Reg & 0x0F) < 0x09)
			RegType = 0x02;
		else
			RegType = 0x00;
		break;
	case 0xC0:
		if ((Reg & 0x1F) < 0x09)
			RegType = 0x02;
		else
			RegType = 0x00;
		break;
	}
	
	Grp = (Reg & 0x100) >> 8;
	switch(RegType)
	{
	case 0x01:
		Chn = ((Reg & 0x18) >> 3) * 0x03 + ((Reg & 0x07) % 0x03);
		Slot = (Reg & 0x07) / 0x03;
		break;
	case 0x02:
		Chn = Reg & 0x0F;
		break;
	}
	
	Grp += ChipMap[SelChip].RegBase;	Grp %= 0x02;
	Chn += ChipMap[SelChip].ChnBase;	Chn %= 0x09;
	
	switch(RegType)
	{
	case 0x00:
		NewReg = (Grp << 8) | (Reg & 0xFF);
		break;
	case 0x01:
		RegOp = (Chn / 0x03) * 0x08 | ((Slot * 0x03) + (Chn % 0x03));
		NewReg = (Grp << 8) | (Reg & 0xE0) | RegOp;
		break;
	case 0x02:
		NewReg = (Grp << 8) | (Reg & 0xF0) | Chn;
		break;
	}
	
	OPL_HW_WriteReg(NewReg, Data);
#endif	// DISABLE_HW_SUPPORT
	
	return;
}

void RefreshVolume()
{
#ifndef DISABLE_HW_SUPPORT
	UINT8 CurChip;
	UINT8 CurChn;
	UINT16 RegVal;
	
	for (CurChip = 0x00; CurChip < 0x02; CurChip ++)
	{
		for (CurChn = 0x00; CurChn < 0x09; CurChn ++)
		{
			RegVal = (CurChip << 8) | 0x40 | (CurChn / 0x03) * 0x08 | (CurChn % 0x03);
			OPL_HW_WriteReg(RegVal + 0x00, OPLReg[RegVal + 0x00]);
			OPL_HW_WriteReg(RegVal + 0x03, OPLReg[RegVal + 0x03]);
		}
	}
	
	return;
#endif
}

void StartSkipping(void)
{
#ifndef DISABLE_HW_SUPPORT
	if (SkipMode)
		return;
	
	SkipMode = true;
	memcpy(OPLRegBak, OPLReg, 0x200);
#endif
	
	return;
}

void StopSkipping(void)
{
#ifndef DISABLE_HW_SUPPORT
	UINT16 Reg;
	UINT16 OpReg;
	UINT8 RRBuffer[0x40];
	
	if (! SkipMode)
		return;
	
	SkipMode = false;
	
	// At first, turn all notes off that need it
	memcpy(RRBuffer + 0x00, &OPLReg[0x080], 0x20);
	memcpy(RRBuffer + 0x20, &OPLReg[0x180], 0x20);
	for (Reg = 0xB0; Reg < 0xB9; Reg ++)
	{
		OpReg = Reg & 0x0F;
		OpReg = (OpReg / 3) * 0x08 + (OpReg % 3);
		if (! (OPLReg[0x100 | Reg] & 0x20))
		{
			OPL_HW_WriteReg(0x180 + OpReg, (OPLReg[0x180 + OpReg] & 0xF0) | 0x0F);
			OPL_HW_WriteReg(0x183 + OpReg, (OPLReg[0x183 + OpReg] & 0xF0) | 0x0F);
			OPLRegForce[0x180 + OpReg] |= 0x01;
			OPLRegForce[0x183 + OpReg] |= 0x01;
			
			OPLRegForce[0x100 | Reg] |= (OPLReg[0x100 | Reg] != OPLRegBak[0x100 | Reg]);
			OPL_HW_WriteReg(0x100 | Reg, OPLReg[0x100 | Reg]);
		}
		if (! (OPLReg[0x000 | Reg] & 0x20))
		{
			OPL_HW_WriteReg(0x080 + OpReg, (OPLReg[0x080 + OpReg] & 0xF0) | 0x0F);
			OPL_HW_WriteReg(0x083 + OpReg, (OPLReg[0x083 + OpReg] & 0xF0) | 0x0F);
			OPLRegForce[0x080 + OpReg] |= 0x01;
			OPLRegForce[0x083 + OpReg] |= 0x01;
			
			OPLRegForce[0x000 | Reg] |= (OPLReg[0x000 | Reg] != OPLRegBak[0x000 | Reg]);
			OPL_HW_WriteReg(0x000 | Reg, OPLReg[0x000 | Reg]);
		}
	}
	memcpy(&OPLReg[0x080], RRBuffer + 0x00, 0x20);
	memcpy(&OPLReg[0x180], RRBuffer + 0x20, 0x20);
	
	// Now the actual save restore.
	Reg = 0x105;	// OPL3 Enable/Disable - this must be the very first thing sent
	OPLRegForce[Reg] |= (OPLReg[Reg] != OPLRegBak[Reg]);
	OPL_HW_WriteReg(Reg, OPLReg[Reg]);
	
	// Registers 0x00 to 0x1F and 0x100 to 0x11F MUST be sent first
	for (Reg = 0x00; Reg < 0x20; Reg ++)
	{
		// Write Port 1 first, so that Port 0 writes override them, if OPL3 mode is disabled
		OPLRegForce[0x100 | Reg] |= (OPLReg[0x100 | Reg] != OPLRegBak[0x100 | Reg]);
		OPL_HW_WriteReg(0x100 | Reg, OPLReg[0x100 | Reg]);
		OPLRegForce[0x000 | Reg] |= (OPLReg[0x000 | Reg] != OPLRegBak[0x000 | Reg]);
		OPL_HW_WriteReg(0x000 | Reg, OPLReg[0x000 | Reg]);
	}
	
	Reg = 0x200;
	do
	{
		Reg --;
		OPLRegForce[Reg] |= (OPLReg[Reg] != OPLRegBak[Reg]);
		OPL_HW_WriteReg(Reg, OPLReg[Reg]);
		
		if ((Reg & 0xFF) == 0xC0)
			Reg -= 0x20;	// Skip the frequency-registers
		if ((Reg & 0xFF) == 0x20)
			Reg -= 0x20;	// Skip the registers that are already sent
	} while(Reg);
	
	for (Reg = 0xA0; Reg < 0xC0; Reg ++)
	{
		// Writing to BA/BB on my YMF744 is like writing to B8/B9, so I need to filter such
		// writes out.
		if ((Reg & 0x0F) >= 0x09)
			continue;
		OPLRegForce[0x100 | Reg] |= (OPLReg[0x100 | Reg] != OPLRegBak[0x100 | Reg]);
		OPL_HW_WriteReg(0x100 | Reg, OPLReg[0x100 | Reg]);
		OPLRegForce[0x000 | Reg] |= (OPLReg[0x000 | Reg] != OPLRegBak[0x000 | Reg]);
		OPL_HW_WriteReg(0x000 | Reg, OPLReg[0x000 | Reg]);
	}
	
	Reg = 0x0BD;	// Rhythm Register / Vibrato/Tremolo Depth
	OPLRegForce[Reg] |= (OPLReg[Reg] != OPLRegBak[Reg]);
	OPL_HW_WriteReg(Reg, OPLReg[Reg]);
#endif
	
	return;
}

void ym2413opl_set_emu_core(UINT8 Emulator)
{
	YM2413_EMU_CORE = (Emulator < 0x02) ? Emulator : 0x00;
	
	return;
}


================================================
FILE: VGMPlay/ChipMapper.h
================================================
void open_fm_option(UINT8 ChipType, UINT8 OptType, UINT32 OptVal);
void opl_chip_reset(void);
void open_real_fm(void);
void reset_real_fm(void);
void setup_real_fm(UINT8 ChipType, UINT8 ChipID);
void close_real_fm(void);
void chip_reg_write(UINT8 ChipType, UINT8 ChipID, UINT8 Port, UINT8 Offset, UINT8 Data);
void OPL_Hardware_Detecton(void);
void OPL_HW_WriteReg(UINT16 Reg, UINT8 Data);
void OPL_RegMapper(UINT16 Reg, UINT8 Data);
void RefreshVolume(void);
void StartSkipping(void);
void StopSkipping(void);
void ym2413opl_set_emu_core(UINT8 Emulator);


================================================
FILE: VGMPlay/Makefile
================================================
########################
#
# VGMPlay Makefile
# (for GNU Make 3.81)
#
########################

# TODO: Make this look less horrible.

# (notice that you can just pass these as arguments when running make)

# set to 1 if you build on Windows using MinGW.
ifndef WINDOWS
WINDOWS = 0
endif

# set to 1 if you build on Mac OSX
ifndef MACOSX
MACOSX = 0
endif

ifeq ($(WINDOWS), 1)
# no libAO for Windows
USE_LIBAO = 0
endif
ifeq ($(MACOSX), 1)
# Mac OSX requires libAO
USE_LIBAO = 1
endif

# disable Hardware OPL Support [enabled by default]
ifndef DISABLE_HWOPL_SUPPORT
DISABLE_HWOPL_SUPPORT = 1
endif

# set to 1 if you want to use libao instead of OSS for sound streaming under Linux [enabled by default]
ifndef USE_LIBAO
USE_LIBAO = 1
endif

# set to 1 for debug builds
ifndef DEBUG
DEBUG = 0
endif

# set to 1 for swprintf fix on older MinGW versions
ifndef OLD_SWPRINTF
OLD_SWPRINTF = 0
endif

# Byte Order
#   0 = undefined (use endian-safe code, might be slightly slower)
#   1 = Little Endian (Intel) [default]
#   2 = Big Endian (Motorola)
ifndef BYTE_ORDER
BYTE_ORDER = 1
endif

# set to 0 to compile without dbus support on linux
ifndef USE_DBUS
USE_DBUS = 1
endif

ifeq ($(WINDOWS), 1)
USE_DBUS = 0
endif
ifeq ($(MACOSX), 1)
USE_DBUS = 0
endif

CC = gcc
ifndef PREFIX
PREFIX = /usr/local
#PREFIX = $(HOME)/.local
endif
MANPREFIX = $(PREFIX)/share/man

# -- VGMPlay specific Compile Flags --
MAINFLAGS := -DCONSOLE_MODE -DADDITIONAL_FORMATS -DSET_CONSOLE_TITLE
ifeq ($(WINDOWS), 1)
# MinGW defines __WINDOWS__, Visual Studio defines WIN32
MAINFLAGS += -DWIN32
endif
ifeq ($(OLD_SWPRINTF), 1)
MAINFLAGS += -DOLD_SWPRINTF
endif
ifeq ($(USE_LIBAO), 1)
MAINFLAGS += -DUSE_LIBAO
endif
EMUFLAGS := -DENABLE_ALL_CORES

# -- Byte Order Optimizations --
ifeq ($(BYTE_ORDER), 1)
# Intel Byte Order
MAINFLAGS += -DVGM_LITTLE_ENDIAN
EMUFLAGS += -DVGM_LITTLE_ENDIAN
else
ifeq ($(BYTE_ORDER), 2)
# Motorola Byte Order
MAINFLAGS += -DVGM_BIG_ENDIAN
EMUFLAGS += -DVGM_BIG_ENDIAN
else
# undefined byte order
endif
endif

ifeq ($(DISABLE_HWOPL_SUPPORT), 1)
MAINFLAGS += -DDISABLE_HW_SUPPORT
endif


ifeq ($(DEBUG), 0)
# -- General Compile Flags --
CFLAGS := -O3 -g0 -Wno-unused-variable -Wno-unused-value -Wno-unused-but-set-variable $(CFLAGS)
else
CFLAGS := -g -Wall $(CFLAGS)
endif
# libm (math library) and libz (zlib)
LDFLAGS := -lm -lz $(LDFLAGS)

ifeq ($(WINDOWS), 1)
# for Windows, add kernel32 and winmm (Multimedia APIs)
LDFLAGS += -lkernel32 -lwinmm
else	# if UNIX
ifeq ($(MACOSX), 1)
# You might want to include additional paths using -I/some/path here,
# in case some libraries (like libao) can't be found.
#CFLAGS += -I/some/path
else
# for Linux, add librt (clock stuff) and libpthread (threads)
LDFLAGS += -lrt -lpthread -pthread

#DBus
ifeq ($(USE_DBUS), 1)
CFLAGS += $(shell pkg-config --cflags dbus-1) -std=c99
LDFLAGS += $(shell pkg-config --libs dbus-1)
MAINFLAGS += -DUSE_DBUS
endif

endif
MAINFLAGS += -pthread -DSHARE_PREFIX=\"$(PREFIX)\"
endif

ifeq ($(USE_LIBAO), 1)
LDFLAGS += -lao
endif

# add Library Path, if defined
ifdef LD_LIBRARY_PATH
LDFLAGS += -L $(LD_LIBRARY_PATH)
endif

SRC = .
OBJ = obj
EMUSRC = $(SRC)/chips
EMUOBJ = $(OBJ)/chips

OBJDIRS = \
	$(OBJ) \
	$(EMUOBJ)
MAINOBJS = \
	$(OBJ)/VGMPlay.o \
	$(OBJ)/VGMPlay_AddFmts.o \
	$(OBJ)/Stream.o \
	$(OBJ)/ChipMapper.o
ifeq ($(WINDOWS), 1)
ifeq ($(DISABLE_HWOPL_SUPPORT), 0)
MAINOBJS += $(OBJ)/pt_ioctl.o
endif
endif
EMUOBJS = \
	$(EMUOBJ)/262intf.o \
	$(EMUOBJ)/2151intf.o \
	$(EMUOBJ)/2203intf.o \
	$(EMUOBJ)/2413intf.o \
	$(EMUOBJ)/2608intf.o \
	$(EMUOBJ)/2610intf.o \
	$(EMUOBJ)/2612intf.o \
	$(EMUOBJ)/3526intf.o \
	$(EMUOBJ)/3812intf.o \
	$(EMUOBJ)/8950intf.o \
	$(EMUOBJ)/adlibemu_opl2.o \
	$(EMUOBJ)/adlibemu_opl3.o \
	$(EMUOBJ)/ay8910.o \
	$(EMUOBJ)/ay_intf.o \
	$(EMUOBJ)/c140.o \
	$(EMUOBJ)/c352.o \
	$(EMUOBJ)/c6280.o \
	$(EMUOBJ)/c6280intf.o \
	$(EMUOBJ)/dac_control.o \
	$(EMUOBJ)/es5503.o \
	$(EMUOBJ)/es5506.o \
	$(EMUOBJ)/emu2149.o \
	$(EMUOBJ)/emu2413.o \
	$(EMUOBJ)/fm2612.o \
	$(EMUOBJ)/fm.o \
	$(EMUOBJ)/fmopl.o \
	$(EMUOBJ)/gb.o \
	$(EMUOBJ)/iremga20.o \
	$(EMUOBJ)/k051649.o \
	$(EMUOBJ)/k053260.o \
	$(EMUOBJ)/k054539.o \
	$(EMUOBJ)/multipcm.o \
	$(EMUOBJ)/nes_apu.o \
	$(EMUOBJ)/nes_intf.o \
	$(EMUOBJ)/np_nes_apu.o \
	$(EMUOBJ)/np_nes_dmc.o \
	$(EMUOBJ)/np_nes_fds.o \
	$(EMUOBJ)/okim6258.o \
	$(EMUOBJ)/okim6295.o \
	$(EMUOBJ)/Ootake_PSG.o \
	$(EMUOBJ)/opll.o \
	$(EMUOBJ)/opm.o \
	$(EMUOBJ)/panning.o \
	$(EMUOBJ)/pokey.o \
	$(EMUOBJ)/pwm.o \
	$(EMUOBJ)/qsound_ctr.o \
	$(EMUOBJ)/qsound_mame.o \
	$(EMUOBJ)/qsound_intf.o \
	$(EMUOBJ)/rf5c68.o \
	$(EMUOBJ)/saa1099.o \
	$(EMUOBJ)/segapcm.o \
	$(EMUOBJ)/scd_pcm.o \
	$(EMUOBJ)/scsp.o \
	$(EMUOBJ)/scspdsp.o \
	$(EMUOBJ)/sn76489.o \
	$(EMUOBJ)/sn76496.o \
	$(EMUOBJ)/sn764intf.o \
	$(EMUOBJ)/upd7759.o \
	$(EMUOBJ)/vsu.o \
	$(EMUOBJ)/ws_audio.o \
	$(EMUOBJ)/x1_010.o \
	$(EMUOBJ)/ym2151.o \
	$(EMUOBJ)/ym2413.o \
	$(EMUOBJ)/ym2612.o \
	$(EMUOBJ)/ym3438.o \
	$(EMUOBJ)/ymdeltat.o \
	$(EMUOBJ)/ymf262.o \
	$(EMUOBJ)/ymf271.o \
	$(EMUOBJ)/ymf278b.o \
	$(EMUOBJ)/ymz280b.o \
	$(EMUOBJ)/ay8910_opl.o \
	$(EMUOBJ)/sn76496_opl.o \
	$(EMUOBJ)/ym2413hd.o \
	$(EMUOBJ)/ym2413_opl.o
VGMPLAY_OBJS = \
	$(OBJ)/VGMPlayUI.o

ifeq ($(USE_DBUS), 1)
	VGMPLAY_OBJS += $(OBJ)/dbus.o
else ifeq ($(WINDOWS), 1)
	VGMPLAY_OBJS += $(OBJ)/mmkeys_Win.o $(OBJ)/dbus_stub.o
else
	VGMPLAY_OBJS += $(OBJ)/mmkeys_stub.o $(OBJ)/dbus_stub.o
endif

VGM2PCM_OBJS = \
	$(OBJ)/vgm2pcm.o
VGM2WAV_OBJS = \
	$(OBJ)/vgm2wav.o
EXTRA_OBJS = $(VGMPLAY_OBJS) $(VGM2PCM_OBJS) $(VGM2WAV_OBJS)


all:	vgmplay vgm2pcm vgm2wav

vgmplay:	$(EMUOBJS) $(MAINOBJS) $(VGMPLAY_OBJS)
ifneq ($(WINDOWS), 1)
ifneq ($(MACOSX), 1)
	@echo Generating xdg desktop entry
	@sed "s/@BIN_PATH@/$(subst /,\/,$(DESTDIR)$(PREFIX)/bin/)/" xdg/vgmplay.desktop.in > xdg/vgmplay.desktop
endif
endif
	@echo Linking vgmplay ...
	@$(CC) $(VGMPLAY_OBJS) $(MAINOBJS) $(EMUOBJS) $(LDFLAGS) -o vgmplay
	@echo Done.

vgm2pcm:	$(EMUOBJS) $(MAINOBJS) $(VGM2PCM_OBJS)
	@echo Linking vgm2pcm ...
	@$(CC) $(VGM2PCM_OBJS) $(MAINOBJS) $(EMUOBJS) $(LDFLAGS) -o vgm2pcm
	@echo Done.

vgm2wav:	$(EMUOBJS) $(MAINOBJS) $(VGM2WAV_OBJS)
	@echo Linking vgm2wav ...
	@$(CC) $(VGM2WAV_OBJS) $(MAINOBJS) $(EMUOBJS) $(LDFLAGS) -o vgm2wav
	@echo Done.

# compile the chip-emulator c-files
$(EMUOBJ)/%.o:	$(EMUSRC)/%.c
	@echo Compiling $< ...
	@mkdir -p $(@D)
	@$(CC) $(CFLAGS) $(EMUFLAGS) -c $< -o $@

# compile the main c-files
$(OBJ)/%.o:	$(SRC)/%.c
	@echo Compiling $< ...
	@mkdir -p $(@D)
	@$(CC) $(CFLAGS) $(MAINFLAGS) -c $< -o $@

clean:
	@rm -f xdg/vgmplay.desktop
	@echo Deleting object files ...
	@rm -f $(MAINOBJS) $(EMUOBJS) $(EXTRA_OBJS)
	@echo Deleting executable files ...
	@rm -f vgmplay vgm2pcm vgm2wav
	@echo Done.

# Thanks to ZekeSulastin and nextvolume for the install and uninstall routines.
install:	all
	install -m 755 vgmplay $(DESTDIR)$(PREFIX)/bin/vgmplay
	install -m 755 vgm2pcm $(DESTDIR)$(PREFIX)/bin/vgm2pcm
	install -m 755 vgm2wav $(DESTDIR)$(PREFIX)/bin/vgm2wav
	mkdir -m 755 -p $(DESTDIR)$(MANPREFIX)/man1
	install -m 644 vgmplay.1 $(DESTDIR)$(MANPREFIX)/man1/vgmplay.1
	mkdir -m 755 -p $(DESTDIR)$(PREFIX)/share/vgmplay
	install -m 644 VGMPlay.ini $(DESTDIR)$(PREFIX)/share/vgmplay/vgmplay.ini
ifneq ($(WINDOWS), 1)
ifneq ($(MACOSX), 1)
	xdg-icon-resource install --novendor --size 128 xdg/icons/vgmplay-128.png vgmplay
	xdg-icon-resource install --novendor --size 64 xdg/icons/vgmplay-64.png vgmplay
	xdg-icon-resource install --novendor --size 32 xdg/icons/vgmplay-32.png vgmplay
	xdg-icon-resource install --novendor --size 16 xdg/icons/vgmplay-16.png vgmplay
	xdg-mime install --novendor xdg/vgmplay-mime.xml
	xdg-desktop-menu install --novendor xdg/vgmplay.desktop
ifeq ($(DISABLE_HWOPL_SUPPORT), 0)
	setcap CAP_SYS_RAWIO+ep $(DESTDIR)$(PREFIX)/bin/vgmplay || true
endif
endif
endif

# install ROMs
rom_install:
	install -m 644 yrw801.rom $(DESTDIR)$(PREFIX)/share/vgmplay/yrw801.rom


# Install the "vgm-player" wrapper
play_install:	install
	install -m 755 vgm-player $(DESTDIR)$(PREFIX)/bin/vgm-player

uninstall:
	rm -f $(DESTDIR)$(PREFIX)/bin/vgmplay
	rm -f $(DESTDIR)$(PREFIX)/bin/vgm2pcm
	rm -f $(DESTDIR)$(PREFIX)/bin/vgm2wav
	rm -f $(DESTDIR)$(PREFIX)/bin/vgm-player
	rm -f $(DESTDIR)$(MANPREFIX)/man1/vgmplay.1
	rm -rf $(DESTDIR)$(PREFIX)/share/vgmplay

.PHONY: all clean install uninstall


================================================
FILE: VGMPlay/PortTalk_IOCTL.h
================================================
/******************************************************************************/
/*                                                                            */
/*                    PortTalk Driver for Windows NT/2000/XP                  */
/*                        Version 2.0, 12th January 2002                      */
/*                          http://www.beyondlogic.org                        */
/*                                                                            */
/* Copyright  2002 Craig Peacock. Craig.Peacock@beyondlogic.org              */
/* Any publication or distribution of this code in source form is prohibited  */
/* without prior written permission of the copyright holder. This source code */
/* is provided "as is", without any guarantee made as to its suitability or   */
/* fitness for any particular use. Permission is herby granted to modify or   */
/* enhance this sample code to produce a derivative program which may only be */
/* distributed in compiled object form only.                                  */
/******************************************************************************/

#define PORTTALK_TYPE 40000 /* 32768-65535 are reserved for customers */

// The IOCTL function codes from 0x800 to 0xFFF are for customer use.

#define IOCTL_IOPM_RESTRICT_ALL_ACCESS \
    CTL_CODE(PORTTALK_TYPE, 0x900, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_IOPM_ALLOW_EXCUSIVE_ACCESS \
    CTL_CODE(PORTTALK_TYPE, 0x901, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_SET_IOPM \
    CTL_CODE(PORTTALK_TYPE, 0x902, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_ENABLE_IOPM_ON_PROCESSID \
    CTL_CODE(PORTTALK_TYPE, 0x903, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_READ_PORT_UCHAR \
    CTL_CODE(PORTTALK_TYPE, 0x904, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_WRITE_PORT_UCHAR \
    CTL_CODE(PORTTALK_TYPE, 0x905, METHOD_BUFFERED, FILE_ANY_ACCESS)



================================================
FILE: VGMPlay/Stream.c
================================================
// Stream.c: C Source File for Sound Output
//

// Thanks to nextvolume for NetBSD support
#define _GNU_SOURCE
#include <stdio.h>
#include "stdbool.h"
#include <stdlib.h>

#ifdef WIN32
#include <windows.h>
#ifdef USE_LIBAO
#error "Sorry, but this doesn't work yet!"
#endif // USE_LIBAO
#else
#include <unistd.h>
#include <limits.h>
#include <sys/ioctl.h>
#include <fcntl.h>

#ifdef USE_LIBAO
#include <ao/ao.h>
#else
#ifdef __NetBSD__
#include <sys/audioio.h>
#elif defined(__linux__)
#include <linux/soundcard.h>
#endif // __NETBSD__
#endif // USE_LIBAO

#endif // WIN32

#include "chips/mamedef.h"	// for UINT8 etc.
#include "VGMPlay.h"	// neccessary for VGMPlay_Intf.h
#include "VGMPlay_Intf.h"
#include "Stream.h"

#ifndef WIN32
typedef struct
{
	UINT16 wFormatTag;
	UINT16 nChannels;
	UINT32 nSamplesPerSec;
	UINT32 nAvgBytesPerSec;
	UINT16 nBlockAlign;
	UINT16 wBitsPerSample;
	UINT16 cbSize;
} WAVEFORMATEX;	// from MSDN Help

#define WAVE_FORMAT_PCM	0x0001

#endif

#ifdef WIN32
static DWORD WINAPI WaveOutThread(void* Arg);
static void BufCheck(void);
#else
void WaveOutCallbackFnc(void);
#endif

UINT16 AUDIOBUFFERU = AUDIOBUFFERS;		// used AudioBuffers

WAVEFORMATEX WaveFmt;
extern UINT32 SampleRate;
extern volatile bool PauseThread;
volatile bool StreamPause;
extern bool ThreadPauseEnable;
extern volatile bool ThreadPauseConfrm;

UINT32 BlockLen;
#ifdef WIN32
static HWAVEOUT hWaveOut;
static WAVEHDR WaveHdrOut[AUDIOBUFFERS];
static HANDLE hWaveOutThread;
//static DWORD WaveOutCallbackThrID;
#else
static INT32 hWaveOut;
#endif
static bool WaveOutOpen;
UINT32 BUFFERSIZE;	// Buffer Size in Bytes
UINT32 SMPL_P_BUFFER;
static char BufferOut[AUDIOBUFFERS][BUFSIZE_MAX];
static volatile bool CloseThread;


bool SoundLog;
static FILE* hFile;
UINT32 SndLogLen;

UINT32 BlocksSent;
UINT32 BlocksPlayed;

char SoundLogFile[MAX_PATH];

#ifdef USE_LIBAO
ao_device* dev_ao;
#endif

INLINE int fputLE32(UINT32 Value, FILE* hFile)
{
#ifdef VGM_LITTLE_ENDIAN
	return fwrite(&Value, 0x04, 1, hFile);
#else
	int RetVal;
	int ResVal;
	
	RetVal = fputc((Value & 0x000000FF) >>  0, hFile);
	RetVal = fputc((Value & 0x0000FF00) >>  8, hFile);
	RetVal = fputc((Value & 0x00FF0000) >> 16, hFile);
	RetVal = fputc((Value & 0xFF000000) >> 24, hFile);
	ResVal = (RetVal != EOF) ? 0x04 : 0x00;
	return ResVal;
#endif
}

INLINE int fputLE16(UINT16 Value, FILE* hFile)
{
#ifdef VGM_LITTLE_ENDIAN
	return fwrite(&Value, 0x02, 1, hFile);
#else
	int RetVal;
	int ResVal;
	
	RetVal = fputc((Value & 0x00FF) >> 0, hFile);
	RetVal = fputc((Value & 0xFF00) >> 8, hFile);
	ResVal = (RetVal != EOF) ? 0x02 : 0x00;
	return ResVal;
#endif
}

UINT8 SaveFile(UINT32 FileLen, const void* TempData)
{
	//char ResultStr[0x100];
	UINT32 DataLen;
	
	if (TempData == NULL)
	{
		switch(FileLen)
		{
		case 0x00000000:
			if (hFile != NULL)
				return 0xD0;	// file already open
			
			SndLogLen = 0;
			hFile = fopen(SoundLogFile,"wb");
			if (hFile == NULL)
				return 0xFF;	// Save Error
			fseek(hFile, 0x00000000, SEEK_SET);
			fputLE32(0x46464952, hFile);	// 'RIFF'
			fputLE32(0x00000000, hFile);	// RIFF chunk length (dummy)
			
			fputLE32(0x45564157, hFile);	// 'WAVE'
			fputLE32(0x20746D66, hFile);	// 'fmt '
			DataLen = 0x00000010;
			fputLE32(DataLen, hFile);		// format chunk legth
			
#ifdef VGM_LITTLE_ENDIAN
			fwrite(&WaveFmt, DataLen, 1, hFile);
#else
			fputLE16(WaveFmt.wFormatTag,		hFile);	// 0x00
			fputLE16(WaveFmt.nChannels,			hFile);	// 0x02
			fputLE32(WaveFmt.nSamplesPerSec,	hFile);	// 0x04
			fputLE32(WaveFmt.nAvgBytesPerSec,	hFile);	// 0x08
			fputLE16(WaveFmt.nBlockAlign,		hFile);	// 0x0C
			fputLE16(WaveFmt.wBitsPerSample,	hFile);	// 0x0E
			//fputLE16(WaveFmt.cbSize, hFile);			// 0x10 (DataLen is 0x10, so leave this out)
#endif
			
			fputLE32(0x61746164, hFile);	// 'data'
			fputLE32(0x00000000, hFile);	// data chunk length (dummy)
			break;
		case 0xFFFFFFFF:
			if (hFile == NULL)
				return 0x80;	// no file opened
			
			DataLen = SndLogLen * SAMPLESIZE;
			
			fseek(hFile, 0x0028, SEEK_SET);
			fputLE32(DataLen, hFile);			// data chunk length
			fseek(hFile, 0x0004, SEEK_SET);
			fputLE32(DataLen + 0x24, hFile);	// RIFF chunk length
			fclose(hFile);
			hFile = NULL;
			break;
		}
	}
	else
	{
		if (hFile == NULL)
			return 0x80;	// no file opened
		
		//fseek(hFile, 0x00000000, SEEK_END);
		//TempVal[0x0] = ftell(hFile);
		//TempVal[0x1] = fwrite(TempData, 1, FileLen, hFile);
#ifdef VGM_LITTLE_ENDIAN
		SndLogLen += fwrite(TempData, SAMPLESIZE, FileLen, hFile);
#else
		{
			UINT32 CurSmpl;
			const UINT16* SmplData;
			
			SmplData = (UINT16*)TempData;
			DataLen = SAMPLESIZE * FileLen / 0x02;
			for (CurSmpl = 0x00; CurSmpl < DataLen; CurSmpl ++)
				SndLogLen += fputLE16(SmplData[CurSmpl], hFile);
		}
#endif
		//sprintf(ResultStr, "Position:\t%d\nBytes written:\t%d\nFile Length:\t%u\nPointer:\t%p",
		//		TempVal[0], TempVal[1], FileLen, TempData);
		//AfxMessageBox(ResultStr);
	}
	
	return 0x00;
}

UINT8 SoundLogging(UINT8 Mode)
{
	UINT8 RetVal;
	
	RetVal = (UINT8)SoundLog;
	switch(Mode)
	{
	case 0x00:
		SoundLog = false;
		break;
	case 0x01:
		SoundLog = true;
		if (WaveOutOpen && hFile == NULL)
			SaveFile(0x00000000, NULL);
		break;
	case 0xFF:
		break;
	default:
		RetVal = 0xA0;
		break;
	}
	
	return RetVal;
}

UINT8 StartStream(UINT8 DeviceID)
{
	UINT32 RetVal;
#ifdef USE_LIBAO
	ao_sample_format ao_fmt;
#else
#ifdef WIN32
	UINT16 Cnt;
	HANDLE WaveOutThreadHandle;
	DWORD WaveOutThreadID;
	//char TestStr[0x80];
#elif defined(__NetBSD__)
	struct audio_info AudioInfo;
#else
	UINT32 ArgVal;
#endif
#endif	// ! USE_LIBAO
	
	if (WaveOutOpen)
		return 0xD0;	// Thread is already active
	
	// Init Audio
	WaveFmt.wFormatTag = WAVE_FORMAT_PCM;
	WaveFmt.nChannels = 2;
	WaveFmt.nSamplesPerSec = SampleRate;
	WaveFmt.wBitsPerSample = 16;
	WaveFmt.nBlockAlign = WaveFmt.wBitsPerSample * WaveFmt.nChannels / 8;
	WaveFmt.nAvgBytesPerSec = WaveFmt.nSamplesPerSec * WaveFmt.nBlockAlign;
	WaveFmt.cbSize = 0;
	if (DeviceID == 0xFF)
		return 0x00;
	
#if defined(WIN32) || defined(USE_LIBAO)
	BUFFERSIZE = SampleRate / 100 * SAMPLESIZE;
	if (BUFFERSIZE > BUFSIZE_MAX)
		BUFFERSIZE = BUFSIZE_MAX;
#else
	BUFFERSIZE = 1 << BUFSIZELD;
#endif
	SMPL_P_BUFFER = BUFFERSIZE / SAMPLESIZE;
	if (AUDIOBUFFERU > AUDIOBUFFERS)
		AUDIOBUFFERU = AUDIOBUFFERS;
	
	PauseThread = true;
	ThreadPauseConfrm = false;
	CloseThread = false;
	StreamPause = false;
	
#ifndef USE_LIBAO
#ifdef WIN32
	ThreadPauseEnable = true;
	WaveOutThreadHandle = CreateThread(NULL, 0x00, &WaveOutThread, NULL, 0x00,
										&WaveOutThreadID);
	if(WaveOutThreadHandle == NULL)
		return 0xC8;		// CreateThread failed
	CloseHandle(WaveOutThreadHandle);
	
	RetVal = waveOutOpen(&hWaveOut, ((UINT)DeviceID - 1), &WaveFmt, 0x00, 0x00, CALLBACK_NULL);
	if(RetVal != MMSYSERR_NOERROR)
#else
	ThreadPauseEnable = false;
#ifdef __NetBSD__
	hWaveOut = open("/dev/audio", O_WRONLY);
#else
	hWaveOut = open("/dev/dsp", O_WRONLY);
#endif
	if (hWaveOut < 0)
#endif
#else	// ifdef USE_LIBAO
	ao_initialize();
	
	ThreadPauseEnable = false;
	ao_fmt.bits = WaveFmt.wBitsPerSample;
	ao_fmt.rate = WaveFmt.nSamplesPerSec;
	ao_fmt.channels = WaveFmt.nChannels;
	ao_fmt.byte_format = AO_FMT_NATIVE;
	ao_fmt.matrix = NULL;
	
	dev_ao = ao_open_live(ao_default_driver_id(), &ao_fmt, NULL);
	if (dev_ao == NULL)
#endif
	{
		CloseThread = true;
		return 0xC0;		// waveOutOpen failed
	}
	WaveOutOpen = true;
	
	//sprintf(TestStr, "Buffer 0,0:\t%p\nBuffer 0,1:\t%p\nBuffer 1,0:\t%p\nBuffer 1,1:\t%p\n",
	//		&BufferOut[0][0], &BufferOut[0][1], &BufferOut[1][0], &BufferOut[1][1]);
	//AfxMessageBox(TestStr);
#ifndef USE_LIBAO
#ifdef WIN32
	for (Cnt = 0x00; Cnt < AUDIOBUFFERU; Cnt ++)
	{
		WaveHdrOut[Cnt].lpData = BufferOut[Cnt];	// &BufferOut[Cnt][0x00];
		WaveHdrOut[Cnt].dwBufferLength = BUFFERSIZE;
		WaveHdrOut[Cnt].dwBytesRecorded = 0x00;
		WaveHdrOut[Cnt].dwUser = 0x00;
		WaveHdrOut[Cnt].dwFlags = 0x00;
		WaveHdrOut[Cnt].dwLoops = 0x00;
		WaveHdrOut[Cnt].lpNext = NULL;
		WaveHdrOut[Cnt].reserved = 0x00;
		RetVal = waveOutPrepareHeader(hWaveOut, &WaveHdrOut[Cnt], sizeof(WAVEHDR));
		WaveHdrOut[Cnt].dwFlags |= WHDR_DONE;
	}
#elif defined(__NetBSD__)
	AUDIO_INITINFO(&AudioInfo);
	
	AudioInfo.mode = AUMODE_PLAY;
	AudioInfo.play.sample_rate = WaveFmt.nSamplesPerSec;
	AudioInfo.play.channels = WaveFmt.nChannels;
	AudioInfo.play.precision = WaveFmt.wBitsPerSample;
	AudioInfo.play.encoding = AUDIO_ENCODING_SLINEAR;
	
	RetVal = ioctl(hWaveOut, AUDIO_SETINFO, &AudioInfo);
	if (RetVal)
		printf("Error setting audio information!\n");
#else
	ArgVal = (AUDIOBUFFERU << 16) | BUFSIZELD;
	RetVal = ioctl(hWaveOut, SNDCTL_DSP_SETFRAGMENT, &ArgVal);
	if (RetVal)
		printf("Error setting Fragment Size!\n");
	ArgVal = AFMT_S16_NE;
	RetVal = ioctl(hWaveOut, SNDCTL_DSP_SETFMT, &ArgVal);
	if (RetVal)
		printf("Error setting Format!\n");
	ArgVal = WaveFmt.nChannels;
	RetVal = ioctl(hWaveOut, SNDCTL_DSP_CHANNELS, &ArgVal);
	if (RetVal)
		printf("Error setting Channels!\n");
	ArgVal = WaveFmt.nSamplesPerSec;
	RetVal = ioctl(hWaveOut, SNDCTL_DSP_SPEED, &ArgVal);
	if (RetVal)
		printf("Error setting Sample Rate!\n");
#endif
#endif	// USE_LIBAO
	
	if (SoundLog)
		SaveFile(0x00000000, NULL);
	
	PauseThread = false;
	
	return 0x00;
}

UINT8 StopStream(void)
{
	UINT32 RetVal;
#ifdef WIN32
	UINT16 Cnt;
#endif
	
	if (! WaveOutOpen)
		return 0xD8;	// Thread is not active
	
	CloseThread = true;
#ifdef WIN32
	for (Cnt = 0; Cnt < 100; Cnt ++)
	{
		Sleep(1);
		if (hWaveOutThread == NULL)
			break;
	}
#endif
	if (hFile != NULL)
		SaveFile(0xFFFFFFFF, NULL);
	WaveOutOpen = false;
	
#ifndef USE_LIBAO
#ifdef WIN32
	RetVal = waveOutReset(hWaveOut);
	for (Cnt = 0x00; Cnt < AUDIOBUFFERU; Cnt ++)
		RetVal = waveOutUnprepareHeader(hWaveOut, &WaveHdrOut[Cnt], sizeof(WAVEHDR));
	
	RetVal = waveOutClose(hWaveOut);
	if(RetVal != MMSYSERR_NOERROR)
		return 0xC4;		// waveOutClose failed  -- but why ???
#else
	close(hWaveOut);
#endif
#else	// ifdef USE_LIBAO
	ao_close(dev_ao);
	
	ao_shutdown();
#endif
	
	return 0x00;
}

void PauseStream(bool PauseOn)
{
	UINT32 RetVal;
	
	if (! WaveOutOpen)
		return;	// Thread is not active
	
#ifdef WIN32
	switch(PauseOn)
	{
	case true:
		RetVal = waveOutPause(hWaveOut);
		break;
	case false:
		RetVal = waveOutRestart(hWaveOut);
		break;
	}
	StreamPause = PauseOn;
#else
	PauseThread = PauseOn;
#endif
	
	return;
}

//UINT32 FillBuffer(WAVE_16BS* Buffer, UINT32 BufferSize)
// moved to VGMPlay.c

#ifdef WIN32

static DWORD WINAPI WaveOutThread(void* Arg)
{
#ifdef NDEBUG
	UINT32 RetVal;
#endif
	UINT16 CurBuf;
	WAVE_16BS* TempBuf;
	UINT32 WrtSmpls;
	//char TestStr[0x80];
	bool DidBuffer;	// a buffer was processed
	
	hWaveOutThread = GetCurrentThread();
#ifdef NDEBUG
	RetVal = SetThreadPriority(hWaveOutThread, THREAD_PRIORITY_TIME_CRITICAL);
	if (! RetVal)
	{
		// Error by setting priority
		// try a lower priority, because too low priorities cause sound stuttering
		RetVal = SetThreadPriority(hWaveOutThread, THREAD_PRIORITY_HIGHEST);
	}
#endif
	
	BlocksSent = 0x00;
	BlocksPlayed = 0x00;
	while(! CloseThread)
	{
		while(PauseThread && ! CloseThread && ! (StreamPause && DidBuffer))
		{
			ThreadPauseConfrm = true;
			Sleep(1);
		}
		if (CloseThread)
			break;
		
		BufCheck();
		DidBuffer = false;
		for (CurBuf = 0x00; CurBuf < AUDIOBUFFERU; CurBuf ++)
		{
			if (WaveHdrOut[CurBuf].dwFlags & WHDR_DONE)
			{
				TempBuf = (WAVE_16BS*)WaveHdrOut[CurBuf].lpData;
				
				if (WaveHdrOut[CurBuf].dwUser & 0x01)
					BlocksPlayed ++;
				else
					WaveHdrOut[CurBuf].dwUser |= 0x01;
				
				WrtSmpls = FillBuffer(TempBuf, SMPL_P_BUFFER);
				
				WaveHdrOut[CurBuf].dwBufferLength = WrtSmpls * SAMPLESIZE;
				waveOutWrite(hWaveOut, &WaveHdrOut[CurBuf], sizeof(WAVEHDR));
				if (SoundLog && hFile != NULL)
					SaveFile(WrtSmpls, TempBuf);
				
				DidBuffer = true;
				BlocksSent ++;
				BufCheck();
				//CurBuf = 0x00;
				//break;
			}
			if (CloseThread)
				break;
		}
		Sleep(1);
	}
	
	hWaveOutThread = NULL;
	return 0x00000000;
}

static void BufCheck(void)
{
	UINT16 CurBuf;
	
	for (CurBuf = 0x00; CurBuf < AUDIOBUFFERU; CurBuf ++)
	{
		if (WaveHdrOut[CurBuf].dwFlags & WHDR_DONE)
		{
			if (WaveHdrOut[CurBuf].dwUser & 0x01)
			{
				WaveHdrOut[CurBuf].dwUser &= ~0x01;
				BlocksPlayed ++;
			}
		}
	}
	
	return;
}

#else	// #ifndef WIN32

void WaveOutLinuxCallBack(void)
{
	UINT32 RetVal;
	UINT16 CurBuf;
	WAVE_16BS* TempBuf;
	UINT32 WrtSmpls;
	
	if (! WaveOutOpen)
		return;	// Device not opened
	
	CurBuf = BlocksSent % AUDIOBUFFERU;
	TempBuf = (WAVE_16BS*)BufferOut[CurBuf];
	
	WrtSmpls = FillBuffer(TempBuf, SMPL_P_BUFFER);
	
#ifndef USE_LIBAO
	RetVal = write(hWaveOut, TempBuf, WrtSmpls * SAMPLESIZE);
#else
	RetVal = ao_play(dev_ao, (char*)TempBuf, WrtSmpls * SAMPLESIZE);
#endif
	if (SoundLog && hFile != NULL)
		SaveFile(WrtSmpls, TempBuf);
	BlocksSent ++;
	BlocksPlayed ++;
	
	return;
}

#endif


================================================
FILE: VGMPlay/Stream.h
================================================
// Stream.h: Header File for constants and structures related to Sound Output
//

#ifdef WIN32
#include <mmsystem.h>
#else
#define MAX_PATH	PATH_MAX
#endif

#define SAMPLESIZE		sizeof(WAVE_16BS)
#define BUFSIZE_MAX		0x1000		// Maximum Buffer Size in Bytes
#ifndef WIN32
#define BUFSIZELD		11			// Buffer Size
#endif
#define AUDIOBUFFERS	200			// Maximum Buffer Count
//	Windows:	BUFFERSIZE = SampleRate / 100 * SAMPLESIZE (44100 / 100 * 4 = 1764)
//				1 Audio-Buffer = 10 msec, Min: 5
//				Win95- / WinVista-safe: 500 msec
//	Linux:		BUFFERSIZE = 1 << BUFSIZELD (1 << 11 = 2048)
//				1 Audio-Buffer = 11.6 msec

UINT8 SaveFile(UINT32 FileLen, const void* TempData);
UINT8 SoundLogging(UINT8 Mode);
UINT8 StartStream(UINT8 DeviceID);
UINT8 StopStream(void);
void PauseStream(bool PauseOn);


================================================
FILE: VGMPlay/VGMFile.h
================================================
// Header file for VGM file handling

typedef struct _vgm_file_header
{
	UINT32 fccVGM;
	UINT32 lngEOFOffset;
	UINT32 lngVersion;
	UINT32 lngHzPSG;
	UINT32 lngHzYM2413;
	UINT32 lngGD3Offset;
	UINT32 lngTotalSamples;
	UINT32 lngLoopOffset;
	UINT32 lngLoopSamples;
	UINT32 lngRate;
	UINT16 shtPSG_Feedback;
	UINT8 bytPSG_SRWidth;
	UINT8 bytPSG_Flags;
	UINT32 lngHzYM2612;
	UINT32 lngHzYM2151;
	UINT32 lngDataOffset;
	UINT32 lngHzSPCM;
	UINT32 lngSPCMIntf;
	UINT32 lngHzRF5C68;
	UINT32 lngHzYM2203;
	UINT32 lngHzYM2608;
	UINT32 lngHzYM2610;
	UINT32 lngHzYM3812;
	UINT32 lngHzYM3526;
	UINT32 lngHzY8950;
	UINT32 lngHzYMF262;
	UINT32 lngHzYMF278B;
	UINT32 lngHzYMF271;
	UINT32 lngHzYMZ280B;
	UINT32 lngHzRF5C164;
	UINT32 lngHzPWM;
	UINT32 lngHzAY8910;
	UINT8 bytAYType;
	UINT8 bytAYFlag;
	UINT8 bytAYFlagYM2203;
	UINT8 bytAYFlagYM2608;
	UINT8 bytVolumeModifier;
	UINT8 bytReserved2;
	INT8 bytLoopBase;
	UINT8 bytLoopModifier;
	UINT32 lngHzGBDMG;
	UINT32 lngHzNESAPU;
	UINT32 lngHzMultiPCM;
	UINT32 lngHzUPD7759;
	UINT32 lngHzOKIM6258;
	UINT8 bytOKI6258Flags;
	UINT8 bytK054539Flags;
	UINT8 bytC140Type;
	UINT8 bytReservedFlags;
	UINT32 lngHzOKIM6295;
	UINT32 lngHzK051649;
	UINT32 lngHzK054539;
	UINT32 lngHzHuC6280;
	UINT32 lngHzC140;
	UINT32 lngHzK053260;
	UINT32 lngHzPokey;
	UINT32 lngHzQSound;
	UINT32 lngHzSCSP;
//	UINT32 lngHzOKIM6376;
	//UINT8 bytReserved[0x04];
	UINT32 lngExtraOffset;
	UINT32 lngHzWSwan;
	UINT32 lngHzVSU;
	UINT32 lngHzSAA1099;
	UINT32 lngHzES5503;
	UINT32 lngHzES5506;
	UINT8 bytES5503Chns;
	UINT8 bytES5506Chns;
	UINT8 bytC352ClkDiv;
	UINT8 bytESReserved;
	UINT32 lngHzX1_010;
	UINT32 lngHzC352;
	UINT32 lngHzGA20;
} VGM_HEADER;
typedef struct _vgm_header_extra
{
	UINT32 DataSize;
	UINT32 Chp2ClkOffset;
	UINT32 ChpVolOffset;
} VGM_HDR_EXTRA;
typedef struct _vgm_extra_chip_data32
{
	UINT8 Type;
	UINT32 Data;
} VGMX_CHIP_DATA32;
typedef struct _vgm_extra_chip_data16
{
	UINT8 Type;
	UINT8 Flags;
	UINT16 Data;
} VGMX_CHIP_DATA16;
typedef struct _vgm_extra_chip_extra32
{
	UINT8 ChipCnt;
	VGMX_CHIP_DATA32* CCData;
} VGMX_CHP_EXTRA32;
typedef struct _vgm_extra_chip_extra16
{
	UINT8 ChipCnt;
	VGMX_CHIP_DATA16* CCData;
} VGMX_CHP_EXTRA16;
typedef struct _vgm_header_extra_data
{
	VGMX_CHP_EXTRA32 Clocks;
	VGMX_CHP_EXTRA16 Volumes;
} VGM_EXTRA;

#define VOLUME_MODIF_WRAP	0xC0
typedef struct _vgm_gd3_tag
{
	UINT32 fccGD3;
	UINT32 lngVersion;
	UINT32 lngTagLength;
	wchar_t* strTrackNameE;
	wchar_t* strTrackNameJ;
	wchar_t* strGameNameE;
	wchar_t* strGameNameJ;
	wchar_t* strSystemNameE;
	wchar_t* strSystemNameJ;
	wchar_t* strAuthorNameE;
	wchar_t* strAuthorNameJ;
	wchar_t* strReleaseDate;
	wchar_t* strCreator;
	wchar_t* strNotes;
} GD3_TAG;
typedef struct _vgm_pcm_bank_data
{
	UINT32 DataSize;
	UINT8* Data;
	UINT32 DataStart;
} VGM_PCM_DATA;
typedef struct _vgm_pcm_bank
{
	UINT32 BankCount;
	VGM_PCM_DATA* Bank;
	UINT32 DataSize;
	UINT8* Data;
	UINT32 DataPos;
	UINT32 BnkPos;
} VGM_PCM_BANK;

#define FCC_VGM	0x206D6756	// 'Vgm '
#define FCC_GD3	0x20336447	// 'Gd3 '


================================================
FILE: VGMPlay/VGMPlay.c
================================================
// VGMPlay.c: C Source File of the Main Executable
//

// Line Size:	96 Chars
// Tab Size:	4 Spaces

/*3456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
0000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999*/

// Mixer Muting ON:
//		Mixer's FM Volume is set to 0 or Mute	-> absolutely muted
//		(sometimes it can take some time to get the Mixer Control under Windows)
// Mixer Muting OFF:
//		FM Volume is set to 0 through commands	-> very very low volume level ~0.4%
//		(faster way)
//#define MIXER_MUTING

// These defines enable additional features.
//	ADDITIONAL_FORMATS enables CMF and DRO support.
//	CONSOLE_MODE switches between VGMPlay and in_vgm mode.
//	in_vgm mode can also be used for custom players.
//
//#define ADDITIONAL_FORMATS
//#define CONSOLE_MODE
//#define VGM_LITTLE_ENDIAN	// enable optimizations for Little Endian systems
//#define VGM_BIG_ENDIAN	// enable optimizations for Big Endian systems

#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include "stdbool.h"
#include <math.h>	// for pow()

#ifdef WIN32
#ifndef NO_WCHAR_FILENAMES
// includes for manual wide-character ZLib open
#include <fcntl.h>	// for _O_RDONLY and _O_BINARY
#include <io.h>		// for _wopen and _close
#endif

#include <conio.h>	// for _inp()
#include <windows.h>
#else	//ifdef UNIX
#include <limits.h>		// for PATH_MAX
#include <pthread.h>	// for pthread functions

// (suitable?) Apple substitute for clock_gettime()
//#ifdef __MACH__
#if 0	// not required in Mac OS X 10.12 and later
#include <mach/mach_time.h>
#define CLOCK_REALTIME	0
#define CLOCK_MONOTONIC	0
int clock_gettime(int clk_id, struct timespec *t)
{
	mach_timebase_info_data_t timebase;
	mach_timebase_info(&timebase);
	uint64_t time;
	time = mach_absolute_time();
	double nseconds = ((double)time * (double)timebase.numer)/((double)timebase.denom);
	double seconds = ((double)time * (double)timebase.numer)/((double)timebase.denom * 1e9);
	t->tv_sec = seconds;
	t->tv_nsec = nseconds;
	return 0;
}
#else
#include <time.h>		// for clock_gettime()
#endif

#include <unistd.h>		// for usleep()

#define MAX_PATH	PATH_MAX
#define	Sleep(msec)	usleep(msec * 1000)

#undef MIXER_MUTING		// I didn't get the Mixer Control to work under Linux

#ifdef MIXER_MUTING
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/soundcard.h>
#endif
#endif	// WIN32/UNIX

#include <zlib.h>

#include "chips/mamedef.h"

// integer types for fast integer calculation
// the bit number is unused (it's an orientation)
#define FUINT8	unsigned int
#define FUINT16	unsigned int

#include "VGMPlay.h"
#include "VGMPlay_Intf.h"
#ifdef CONSOLE_MODE
#include "Stream.h"
#endif

#include "chips/ChipIncl.h"

unsigned char OpenPortTalk(void);
void ClosePortTalk(void);

#include "ChipMapper.h"

typedef void (*strm_func)(UINT8 ChipID, stream_sample_t **outputs, int samples);

typedef struct chip_audio_attributes CAUD_ATTR;
struct chip_audio_attributes
{
	UINT32 SmpRate;
	UINT16 Volume;
	UINT8 ChipType;
	UINT8 ChipID;		// 0 - 1st chip, 1 - 2nd chip, etc.
	// Resampler Type:
	//	00 - Old
	//	01 - Upsampling
	//	02 - Copy
	//	03 - Downsampling
	UINT8 Resampler;
	strm_func StreamUpdate;
	UINT32 SmpP;		// Current Sample (Playback Rate)
	UINT32 SmpLast;		// Sample Number Last
	UINT32 SmpNext;		// Sample Number Next
	WAVE_32BS LSmpl;	// Last Sample
	WAVE_32BS NSmpl;	// Next Sample
	CAUD_ATTR* Paired;
};

typedef struct chip_audio_struct
{
	CAUD_ATTR SN76496;
	CAUD_ATTR YM2413;
	CAUD_ATTR YM2612;
	CAUD_ATTR YM2151;
	CAUD_ATTR SegaPCM;
	CAUD_ATTR RF5C68;
	CAUD_ATTR YM2203;
	CAUD_ATTR YM2608;
	CAUD_ATTR YM2610;
	CAUD_ATTR YM3812;
	CAUD_ATTR YM3526;
	CAUD_ATTR Y8950;
	CAUD_ATTR YMF262;
	CAUD_ATTR YMF278B;
	CAUD_ATTR YMF271;
	CAUD_ATTR YMZ280B;
	CAUD_ATTR RF5C164;
	CAUD_ATTR PWM;
	CAUD_ATTR AY8910;
	CAUD_ATTR GameBoy;
	CAUD_ATTR NES;
	CAUD_ATTR MultiPCM;
	CAUD_ATTR UPD7759;
	CAUD_ATTR OKIM6258;
	CAUD_ATTR OKIM6295;
	CAUD_ATTR K051649;
	CAUD_ATTR K054539;
	CAUD_ATTR HuC6280;
	CAUD_ATTR C140;
	CAUD_ATTR K053260;
	CAUD_ATTR Pokey;
	CAUD_ATTR QSound;
	CAUD_ATTR SCSP;
	CAUD_ATTR WSwan;
	CAUD_ATTR VSU;
	CAUD_ATTR SAA1099;
	CAUD_ATTR ES5503;
	CAUD_ATTR ES5506;
	CAUD_ATTR X1_010;
	CAUD_ATTR C352;
	CAUD_ATTR GA20;
//	CAUD_ATTR OKIM6376;
} CHIP_AUDIO;

typedef struct chip_aud_list CA_LIST;
struct chip_aud_list
{
	CAUD_ATTR* CAud;
	CHIP_OPTS* COpts;
	CA_LIST* next;
};

typedef struct daccontrol_data
{
	bool Enable;
	UINT8 Bank;
} DACCTRL_DATA;

typedef struct pcmbank_table
{
	UINT8 ComprType;
	UINT8 CmpSubType;
	UINT8 BitDec;
	UINT8 BitCmp;
	UINT16 EntryCount;
	void* Entries;
} PCMBANK_TBL;


// Function Prototypes (prototypes in comments are defined in VGMPlay_Intf.h)
//void VGMPlay_Init(void);
//void VGMPlay_Init2(void);
//void VGMPlay_Deinit(void);
//char* FindFile(const char* FileName)

INLINE UINT16 ReadLE16(const UINT8* Data);
INLINE UINT16 ReadBE16(const UINT8* Data);
INLINE UINT32 ReadLE24(const UINT8* Data);
INLINE UINT32 ReadLE32(const UINT8* Data);
INLINE int gzgetLE16(gzFile hFile, UINT16* RetValue);
INLINE int gzgetLE32(gzFile hFile, UINT32* RetValue);
static UINT32 gcd(UINT32 x, UINT32 y);
//void PlayVGM(void);
//void StopVGM(void);
//void RestartVGM(void);
//void PauseVGM(bool Pause);
//void SeekVGM(bool Relative, INT32 PlayBkSamples);
//void RefreshMuting(void);
//void RefreshPanning(void);
//void RefreshPlaybackOptions(void);

//UINT32 GetGZFileLength(const char* FileName);
//UINT32 GetGZFileLengthW(const wchar_t* FileName);
static UINT32 GetGZFileLength_Internal(FILE* hFile);
//bool OpenVGMFile(const char* FileName);
static bool OpenVGMFile_Internal(gzFile hFile, UINT32 FileSize);
static void ReadVGMHeader(gzFile hFile, VGM_HEADER* RetVGMHead);
static UINT8 ReadGD3Tag(gzFile hFile, UINT32 GD3Offset, GD3_TAG* RetGD3Tag);
static void ReadChipExtraData32(UINT32 StartOffset, VGMX_CHP_EXTRA32* ChpExtra);
static void ReadChipExtraData16(UINT32 StartOffset, VGMX_CHP_EXTRA16* ChpExtra);
//void CloseVGMFile(void);
//void FreeGD3Tag(GD3_TAG* TagData);
static wchar_t* MakeEmptyWStr(void);
static wchar_t* ReadWStrFromFile(gzFile hFile, UINT32* FilePos, UINT32 EOFPos);
//UINT32 GetVGMFileInfo(const char* FileName, VGM_HEADER* RetVGMHead, GD3_TAG* RetGD3Tag);
static UINT32 GetVGMFileInfo_Internal(gzFile hFile, UINT32 FileSize,
									  VGM_HEADER* RetVGMHead, GD3_TAG* RetGD3Tag);
INLINE UINT32 MulDivRound(UINT64 Number, UINT64 Numerator, UINT64 Denominator);
//UINT32 CalcSampleMSec(UINT64 Value, UINT8 Mode);
//UINT32 CalcSampleMSecExt(UINT64 Value, UINT8 Mode, VGM_HEADER* FileHead);
//const char* GetChipName(UINT8 ChipID);
//const char* GetAccurateChipName(UINT8 ChipID, UINT8 SubType);
//UINT32 GetChipClock(VGM_HEADER* FileHead, UINT8 ChipID, UINT8* RetSubType);
static UINT16 GetChipVolume(VGM_HEADER* FileHead, UINT8 ChipID, UINT8 ChipNum, UINT8 ChipCnt);

static void RestartPlaying(void);
static void Chips_GeneralActions(UINT8 Mode);

INLINE INT32 SampleVGM2Pbk_I(INT32 SampleVal);	// inline functions
INLINE INT32 SamplePbk2VGM_I(INT32 SampleVal);
//INT32 SampleVGM2Playback(INT32 SampleVal);		// non-inline functions
//INT32 SamplePlayback2VGM(INT32 SampleVal);
static UINT8 StartThread(void);
static UINT8 StopThread(void);
#if defined(WIN32) && defined(MIXER_MUTING)
static bool GetMixerControl(void);
#endif
static bool SetMuteControl(bool mute);

static void InterpretFile(UINT32 SampleCount);
static void AddPCMData(UINT8 Type, UINT32 DataSize, const UINT8* Data);
//INLINE FUINT16 ReadBits(UINT8* Data, UINT32* Pos, FUINT8* BitPos, FUINT8 BitsToRead);
static bool DecompressDataBlk(VGM_PCM_DATA* Bank, UINT32 DataSize, const UINT8* Data);
static UINT8 GetDACFromPCMBank(void);
static UINT8* GetPointerFromPCMBank(UINT8 Type, UINT32 DataPos);
static void ReadPCMTable(UINT32 DataSize, const UINT8* Data);
static void InterpretVGM(UINT32 SampleCount);
#ifdef ADDITIONAL_FORMATS
extern void InterpretOther(UINT32 SampleCount);
#endif

static void GeneralChipLists(void);
static void SetupResampler(CAUD_ATTR* CAA);
static void ChangeChipSampleRate(void* DataPtr, UINT32 NewSmplRate);

INLINE INT16 Limit2Short(INT32 Value);
static void null_update(UINT8 ChipID, stream_sample_t **outputs, int samples);
static void dual_opl2_stereo(UINT8 ChipID, stream_sample_t **outputs, int samples);
static void ResampleChipStream(CA_LIST* CLst, WAVE_32BS* RetSample, UINT32 Length);
static INT32 RecalcFadeVolume(void);
//UINT32 FillBuffer(WAVE_16BS* Buffer, UINT32 BufferSize)

#ifdef WIN32
DWORD WINAPI PlayingThread(void* Arg);
#else
UINT64 TimeSpec2Int64(const struct timespec* ts);
void* PlayingThread(void* Arg);
#endif


// Options Variables
UINT32 SampleRate;	// Note: also used by some sound cores to determinate the chip sample rate

UINT32 VGMMaxLoop;
UINT32 VGMPbRate;	// in Hz, ignored if this value or VGM's lngRate Header value is 0
#ifdef ADDITIONAL_FORMATS
extern UINT32 CMFMaxLoop;
#endif
UINT32 FadeTime;
UINT32 PauseTime;	// current Pause Time

float VolumeLevel;
bool SurroundSound;
UINT8 HardStopOldVGMs;
bool FadeRAWLog;
//bool FullBufFill;	// Fill Buffer until it's full
bool PauseEmulate;

bool DoubleSSGVol;

UINT8 ResampleMode;	// 00 - HQ both, 01 - LQ downsampling, 02 - LQ both
UINT8 CHIP_SAMPLING_MODE;
INT32 CHIP_SAMPLE_RATE;

UINT16 FMPort;
bool FMForce;
//bool FMAccurate;
bool FMBreakFade;
float FMVol;
bool FMOPL2Pan;

CHIPS_OPTION ChipOpts[0x02];

UINT8 OPL_MODE;
UINT8 OPL_CHIPS;
#ifdef WIN32
bool WINNT_MODE;
#endif

stream_sample_t* DUMMYBUF[0x02] = {NULL, NULL};

char* AppPaths[8];

bool AutoStopSkip;

UINT8 FileMode;
VGM_HEADER VGMHead;
VGM_HDR_EXTRA VGMHeadX;
VGM_EXTRA VGMH_Extra;
UINT32 VGMDataLen;
UINT8* VGMData;
GD3_TAG VGMTag;

#define PCM_BANK_COUNT	0x40
VGM_PCM_BANK PCMBank[PCM_BANK_COUNT];
PCMBANK_TBL PCMTbl;
UINT8 DacCtrlUsed;
UINT8 DacCtrlUsg[0xFF];
DACCTRL_DATA DacCtrl[0xFF];

#ifdef WIN32
HANDLE hPlayThread;
#else
pthread_t hPlayThread;
#endif
bool PlayThreadOpen;
volatile bool PauseThread;
static volatile bool CloseThread;
bool ThreadPauseEnable;
volatile bool ThreadPauseConfrm;
bool ThreadNoWait;	// don't reset the timer

CHIP_AUDIO ChipAudio[0x02];
CAUD_ATTR CA_Paired[0x02][0x03];
float MasterVol;

CA_LIST ChipListBuffer[0x200];
CA_LIST* ChipListAll;	// all chips needed for playback (in general)
CA_LIST* ChipListPause;	// all chips needed for EmulateWhilePaused
//CA_LIST* ChipListOpt;	// ChipListAll minus muted chips
CA_LIST* CurChipList;	// pointer to Pause or All [Opt]

#define SMPL_BUFSIZE	0x100
static INT32* StreamBufs[0x02];

#ifdef MIXER_MUTING

#ifdef WIN32
HMIXER hmixer;
MIXERCONTROL mixctrl;
#else
int hmixer;
UINT16 mixer_vol;
#endif

#else	//#ifndef MIXER_MUTING
float VolumeBak;
#endif

UINT32 VGMPos;
INT32 VGMSmplPos;
INT32 VGMSmplPlayed;
INT32 VGMSampleRate;
static UINT32 VGMPbRateMul;
static UINT32 VGMPbRateDiv;
static UINT32 VGMSmplRateMul;
static UINT32 VGMSmplRateDiv;
static UINT32 PauseSmpls;
bool VGMEnd;
bool EndPlay;
bool PausePlay;
bool FadePlay;
bool ForceVGMExec;
UINT8 PlayingMode;
bool UseFM;
UINT32 PlayingTime;
UINT32 FadeStart;
UINT32 VGMMaxLoopM;
UINT32 VGMCurLoop;
float VolumeLevelM;
float FinalVol;
bool ResetPBTimer;

static bool Interpreting;

#ifdef CONSOLE_MODE
extern bool ErrorHappened;
extern UINT8 CmdList[0x100];
#endif

UINT8 IsVGMInit;
UINT16 Last95Drum;	// for optvgm debugging
UINT16 Last95Max;	// for optvgm debugging
UINT32 Last95Freq;	// for optvgm debugging

void VGMPlay_Init(void)
{
	UINT8 CurChip;
	UINT8 CurCSet;
	UINT8 CurChn;
	CHIP_OPTS* TempCOpt;
	CAUD_ATTR* TempCAud;
	
	SampleRate = 44100;
	FadeTime = 5000;
	PauseTime = 0;
	
	HardStopOldVGMs = 0x00;
	FadeRAWLog = false;
	VolumeLevel = 1.0f;
	//FullBufFill = false;
	FMPort = 0x0000;
	FMForce = false;
	//FMAccurate = false;
	FMBreakFade = false;
	FMVol = 0.0f;
	FMOPL2Pan = false;
	SurroundSound = false;
	VGMMaxLoop = 0x02;
	VGMPbRate = 0;
#ifdef ADDITIONAL_FORMATS
	CMFMaxLoop = 0x01;
#endif
	ResampleMode = 0x00;
	CHIP_SAMPLING_MODE = 0x00;
	CHIP_SAMPLE_RATE = 0x00000000;
	PauseEmulate = false;
	DoubleSSGVol = false;
	
	for (CurCSet = 0x00; CurCSet < 0x02; CurCSet ++)
	{
		TempCAud = (CAUD_ATTR*)&ChipAudio[CurCSet];
		for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++, TempCAud ++)
		{
			TempCOpt = (CHIP_OPTS*)&ChipOpts[CurCSet] + CurChip;
			
			TempCOpt->Disabled = false;
			TempCOpt->EmuCore = 0x00;
			TempCOpt->SpecialFlags = 0x00;
			TempCOpt->ChnCnt = 0x00;
			TempCOpt->ChnMute1 = 0x00;
			TempCOpt->ChnMute2 = 0x00;
			TempCOpt->ChnMute3 = 0x00;
			TempCOpt->Panning = NULL;
			
			// Set up some important fields to prevent in_vgm from crashing
			// when clicking on Muting checkboxes after init.
			TempCAud->ChipType = 0xFF;
			TempCAud->ChipID = CurCSet;
			TempCAud->Paired = NULL;
		}
		ChipOpts[CurCSet].GameBoy.SpecialFlags = 0x0003;
		// default options, 0x8000 skips the option write and keeps NSFPlay's default values
		// TODO: Is this really necessary??
		ChipOpts[CurCSet].NES.SpecialFlags = 0x8000 |
										(0x00 << 12) | (0x3B << 4) | (0x01 << 2) | (0x03 << 0);
		ChipOpts[CurCSet].SCSP.SpecialFlags = 0x0001;	// bypass SCSP DSP
		
		TempCAud = CA_Paired[CurCSet];
		for (CurChip = 0x00; CurChip < 0x03; CurChip ++, TempCAud ++)
		{
			TempCAud->ChipType = 0xFF;
			TempCAud->ChipID = CurCSet;
			TempCAud->Paired = NULL;
		}
		
		// currently the only chips with Panning support are
		// SN76496 and YM2413, it should be not a problem that it's hardcoded.
		TempCOpt = (CHIP_OPTS*)&ChipOpts[CurCSet].SN76496;
		TempCOpt->ChnCnt = 0x04;
		TempCOpt->Panning = (INT16*)malloc(sizeof(INT16) * TempCOpt->ChnCnt);
		for (CurChn = 0x00; CurChn < TempCOpt->ChnCnt; CurChn ++)
			TempCOpt->Panning[CurChn] = 0x00;
		
		TempCOpt = (CHIP_OPTS*)&ChipOpts[CurCSet].YM2413;
		TempCOpt->ChnCnt = 0x0E;	// 0x09 + 0x05
		TempCOpt->Panning = (INT16*)malloc(sizeof(INT16) * TempCOpt->ChnCnt);
		for (CurChn = 0x00; CurChn < TempCOpt->ChnCnt; CurChn ++)
			TempCOpt->Panning[CurChn] = 0x00;
	}
	
	for (CurChn = 0; CurChn < 8; CurChn ++)
		AppPaths[CurChn] = NULL;
	AppPaths[0] = "";
	
	FileMode = 0xFF;
	
	PausePlay = false;
	
#ifdef _DEBUG
	if (sizeof(CHIP_AUDIO) != sizeof(CAUD_ATTR) * CHIP_COUNT)
	{
		fprintf(stderr, "Fatal Error! ChipAudio structure invalid!\n");
		getchar();
		exit(-1);
	}
	if (sizeof(CHIPS_OPTION) != sizeof(CHIP_OPTS) * CHIP_COUNT)
	{
		fprintf(stderr, "Fatal Error! ChipOpts structure invalid!\n");
		getchar();
		exit(-1);
	}
#endif
	
	return;
}

void VGMPlay_Init2(void)
{
	// has to be called after the configuration is loaded
	
	if (FMPort)
	{
#if defined(WIN32) && defined(_MSC_VER)
		__try
		{
			// should work well with WinXP Compatibility Mode
			_inp(FMPort);
			WINNT_MODE = false;
		}
		__except(EXCEPTION_EXECUTE_HANDLER)
		{
			WINNT_MODE = true;
		}
#endif
		
		if (! OPL_MODE)	// OPL not forced
			OPL_Hardware_Detecton();
		if (! OPL_MODE)	// no OPL chip found
			FMPort = 0x0000;	// disable FM
	}
	if (FMPort)
	{
		// prepare FM Hardware Access and open MIDI Mixer
#ifdef WIN32
#ifdef MIXER_MUTING
		mixerOpen(&hmixer, 0x00, 0x00, 0x00, 0x00);
		GetMixerControl();
#endif
		
		if (WINNT_MODE)
		{
			if (OpenPortTalk())
				return;
		}
#else	//#ifndef WIN32
#ifdef MIXER_MUTING
		hmixer = open("/dev/mixer", O_RDWR);
#endif
		
		if (OpenPortTalk())
			return;
#endif
	}
	
	StreamBufs[0x00] = (INT32*)malloc(SMPL_BUFSIZE * sizeof(INT32));
	StreamBufs[0x01] = (INT32*)malloc(SMPL_BUFSIZE * sizeof(INT32));
	
	if (CHIP_SAMPLE_RATE <= 0)
		CHIP_SAMPLE_RATE = SampleRate;
	PlayingMode = 0xFF;
	
	return;
}

void VGMPlay_Deinit(void)
{
	UINT8 CurChip;
	UINT8 CurCSet;
	CHIP_OPTS* TempCOpt;
	
	if (FMPort)
	{
#ifdef MIXER_MUTING
#ifdef WIN32
		mixerClose(hmixer);
#else
		close(hmixer);
#endif
#endif
	}
	
	free(StreamBufs[0x00]);	StreamBufs[0x00] = NULL;
	free(StreamBufs[0x01]);	StreamBufs[0x01] = NULL;
	
	for (CurCSet = 0x00; CurCSet < 0x02; CurCSet ++)
	{
		for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++)
		{
			TempCOpt = (CHIP_OPTS*)&ChipOpts[CurCSet] + CurChip;
			
			if (TempCOpt->Panning != NULL)
			{
				free(TempCOpt->Panning);	TempCOpt->Panning = NULL;
			}
		}
	}
	
	return;
}

// Note: Caller must free the returned string.
char* FindFile(const char* FileName)
{
	char* FullName;
	char** CurPath;
	UINT32 NameLen;
	UINT32 PathLen;
	UINT32 FullLen;
	FILE* hFile;
	
	NameLen = strlen(FileName);
	//printf("Find File: %s\n", FileName);
	
	// go to end of the list + get size of largest path
	// (The first entry has the lowest priority.)
	PathLen = 0;
	CurPath = AppPaths;
	while(*CurPath != NULL)
	{
		FullLen = strlen(*CurPath);
		if (FullLen > PathLen)
			PathLen = FullLen;
		CurPath ++;
	}
	CurPath --;
	FullLen = PathLen + NameLen;
	FullName = (char*)malloc(FullLen + 1);
	
	hFile = NULL;
	for (; CurPath >= AppPaths; CurPath --)
	{
		strcpy(FullName, *CurPath);
		strcat(FullName, FileName);
		
		//printf("Trying path: %s\n", FullName);
		hFile = fopen(FullName, "r");
		if (hFile != NULL)
			break;
	}
	
	if (hFile != NULL)
	{
		fclose(hFile);
		//printf("Success!\n");
		return FullName;	// The caller has to free the string.
	}
	else
	{
		free(FullName);
		//printf("Fail!\n");
		return NULL;
	}
}

char* FindFile_List(const char** FileNameList)
{
	char* FullName;
	const char** CurFile;
	char** CurPath;
	char* PathPtr;
	UINT32 NameLen;
	UINT32 PathLen;
	UINT32 FullLen;
	FILE* hFile;
	
	NameLen = 0;
	CurFile = FileNameList;
	while(*CurFile != NULL)
	{
		FullLen = strlen(*CurFile);
		if (FullLen > NameLen)
			NameLen = FullLen;
		CurFile ++;
	}
	
	// go to end of the list + get size of largest path
	// (The first entry has the lowest priority.)
	PathLen = 0;
	CurPath = AppPaths;
	while(*CurPath != NULL)
	{
		FullLen = strlen(*CurPath);
		if (FullLen > PathLen)
			PathLen = FullLen;
		CurPath ++;
	}
	CurPath --;
	FullLen = PathLen + NameLen;
	FullName = (char*)malloc(FullLen + 1);
	
	hFile = NULL;
	while(CurPath >= AppPaths)
	{
		strcpy(FullName, *CurPath);
		PathPtr = FullName + strlen(FullName);
		CurFile = FileNameList;
		while(*CurFile != NULL)
		{
			strcpy(PathPtr, *CurFile);
			
			//printf("Trying path: %s\n", FullName);
			hFile = fopen(FullName, "r");
			if (hFile != NULL)
				break;
			
			CurFile ++;
		}
		if (hFile != NULL)
			break;
		
		CurPath --;
	}
	
	if (hFile != NULL)
	{
		fclose(hFile);
		//printf("Success!\n");
		return FullName;	// The caller has to free the string.
	}
	else
	{
		free(FullName);
		//printf("Fail!\n");
		return NULL;
	}
}


INLINE UINT16 ReadLE16(const UINT8* Data)
{
	// read 16-Bit Word (Little Endian/Intel Byte Order)
#ifdef VGM_LITTLE_ENDIAN
	return *(UINT16*)Data;
#else
	return (Data[0x01] << 8) | (Data[0x00] << 0);
#endif
}

INLINE UINT16 ReadBE16(const UINT8* Data)
{
	// read 16-Bit Word (Big Endian/Motorola Byte Order)
#ifdef VGM_BIG_ENDIAN
	return *(UINT16*)Data;
#else
	return (Data[0x00] << 8) | (Data[0x01] << 0);
#endif
}

INLINE UINT32 ReadLE24(const UINT8* Data)
{
	// read 24-Bit Word (Little Endian/Intel Byte Order)
#ifdef VGM_LITTLE_ENDIAN
	return	(*(UINT32*)Data) & 0x00FFFFFF;
#else
	return	(Data[0x02] << 16) | (Data[0x01] <<  8) | (Data[0x00] <<  0);
#endif
}

INLINE UINT32 ReadLE32(const UINT8* Data)
{
	// read 32-Bit Word (Little Endian/Intel Byte Order)
#ifdef VGM_LITTLE_ENDIAN
	return	*(UINT32*)Data;
#else
	return	(Data[0x03] << 24) | (Data[0x02] << 16) |
			(Data[0x01] <<  8) | (Data[0x00] <<  0);
#endif
}

INLINE int gzgetLE16(gzFile hFile, UINT16* RetValue)
{
#ifdef VGM_LITTLE_ENDIAN
	return gzread(hFile, RetValue, 0x02);
#else
	int RetVal;
	UINT8 Data[0x02];
	
	RetVal = gzread(hFile, Data, 0x02);
	*RetValue =	(Data[0x01] << 8) | (Data[0x00] << 0);
	return RetVal;
#endif
}

INLINE int gzgetLE32(gzFile hFile, UINT32* RetValue)
{
#ifdef VGM_LITTLE_ENDIAN
	return gzread(hFile, RetValue, 0x04);
#else
	int RetVal;
	UINT8 Data[0x04];
	
	RetVal = gzread(hFile, Data, 0x04);
	*RetValue =	(Data[0x03] << 24) | (Data[0x02] << 16) |
				(Data[0x01] <<  8) | (Data[0x00] <<  0);
	return RetVal;
#endif
}

static UINT32 gcd(UINT32 x, UINT32 y)
{
	UINT32 shift;
	UINT32 diff;
	
	// Thanks to Wikipedia for this algorithm
	// http://en.wikipedia.org/wiki/Binary_GCD_algorithm
	if (! x || ! y)
		return x | y;
	
	for (shift = 0; ((x | y) & 1) == 0; shift ++)
	{
		x >>= 1;
		y >>= 1;
	}
	
	while((x & 1) == 0)
		x >>= 1;
	
	do
	{
		while((y & 1) == 0)
			y >>= 1;
		
		if (x < y)
		{
			y -= x;
		}
		else
		{
			diff = x - y;
			x = y;
			y = diff;
		}
		y >>= 1;
	} while(y);
	
	return x << shift;
}

void PlayVGM(void)
{
	UINT8 CurChip;
	UINT8 FMVal;
	INT32 TempSLng;
	
	if (PlayingMode != 0xFF)
		return;
	
	//PausePlay = false;
	FadePlay = false;
	MasterVol = 1.0f;
	ForceVGMExec = false;
	AutoStopSkip = false;
	FadeStart = 0;
	ForceVGMExec = true;
	PauseThread = true;
	
	// FM Check
	FMVal = 0x00;
	if (FMPort)
	{
		// check usage of devices that use the FM port, and ones that don't use it
		for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++)
		{
			if (! GetChipClock(&VGMHead, CurChip, NULL))
				continue;
			
			// supported chips are:
			//	SN76496 (0x00, special behaviour), YM2413 (0x01)
			//	YM3812 (0x09), YM3526 (0x0A), Y8950 (0x0B), YMF262 (0x0C)
			if (CurChip == 0x00 || CurChip == 0x12)
									// The SN76496 and AY8910 have a special state because of
				FMVal |= 0x04;		// bad FM emulation and fast software emulation.
			else if (CurChip == 0x01 || (CurChip >= 0x09 && CurChip <= 0x0C))
				FMVal |= 0x02;
			else
				FMVal |= 0x01;
		}
		
		if (! FMForce)
		{
			if (FMVal & 0x01)	// one or more software emulators used?
				FMVal &= ~0x02;	// use only software emulation
			
			if (FMVal == 0x04)
				FMVal = 0x01;	// FM SN76496 emulaton is bad
			else if ((FMVal & 0x05) == 0x05)
				FMVal &= ~0x04;	// prefer software SN76496 instead of unsynced output
		}
		FMVal = (FMVal & ~0x04) | ((FMVal & 0x04) >> 1);
	}
	switch(FMVal)
	{
	case 0x00:
	case 0x01:
		PlayingMode = 0x00;	// Normal Mode
		break;
	case 0x02:
		PlayingMode = 0x01;	// FM only Mode
		break;
	case 0x03:
		PlayingMode = 0x02;	// Normal/FM mixed Mode (NOT in sync, Hardware is a lot faster)
		//PlayingMode = 0x00;	// Force Normal Mode until I get them in sync - Mixed Mode
								// sounds terrible
		break;
	}
	UseFM = (PlayingMode > 0x00);
	
	if (VGMHead.bytVolumeModifier <= VOLUME_MODIF_WRAP)
		TempSLng = VGMHead.bytVolumeModifier;
	else if (VGMHead.bytVolumeModifier == (VOLUME_MODIF_WRAP + 0x01))
		TempSLng = VOLUME_MODIF_WRAP - 0x100;
	else
		TempSLng = VGMHead.bytVolumeModifier - 0x100;
	VolumeLevelM = (float)(VolumeLevel * pow(2.0, TempSLng / (double)0x20));
	if (UseFM)
	{
		if (FMVol > 0.0f)
			VolumeLevelM = FMVol;
		else if (FMVol < 0.0f)
			VolumeLevelM *= -FMVol;
	}
	FinalVol = VolumeLevelM;
	
	if (! VGMMaxLoop)
	{
		VGMMaxLoopM = 0x00;
	}
	else
	{
		TempSLng = (VGMMaxLoop * VGMHead.bytLoopModifier + 0x08) / 0x10 - VGMHead.bytLoopBase;
		VGMMaxLoopM = (TempSLng >= 0x01) ? TempSLng : 0x01;
	}
	
	if (! VGMPbRate || ! VGMHead.lngRate)
	{
		VGMPbRateMul = 1;
		VGMPbRateDiv = 1;
	}
	else
	{
		// I prefer small Multiplers and Dividers, as they're used very often
		TempSLng = gcd(VGMHead.lngRate, VGMPbRate);
		VGMPbRateMul = VGMHead.lngRate / TempSLng;
		VGMPbRateDiv = VGMPbRate / TempSLng;
	}
	VGMSmplRateMul = SampleRate * VGMPbRateMul;
	VGMSmplRateDiv = VGMSampleRate * VGMPbRateDiv;
	// same as above - to speed up the VGM <-> Playback calculation
	TempSLng = gcd(VGMSmplRateMul, VGMSmplRateDiv);
	VGMSmplRateMul /= TempSLng;
	VGMSmplRateDiv /= TempSLng;
	
	PlayingTime = 0;
	EndPlay = false;
	
	VGMPos = VGMHead.lngDataOffset;
	VGMSmplPos = 0;
	VGMSmplPlayed = 0;
	VGMEnd = false;
	VGMCurLoop = 0x00;
	PauseSmpls = (PauseTime * SampleRate + 500) / 1000;
	if (VGMPos >= VGMHead.lngEOFOffset)
		VGMEnd = true;
	
#ifdef CONSOLE_MODE
	memset(CmdList, 0x00, 0x100 * sizeof(UINT8));
#endif
	
	if (! PauseEmulate)
	{
		switch(PlayingMode)
		{
		case 0x00:
			//PauseStream(PausePlay);
			break;
		case 0x01:
			//PauseThread = PausePlay;
			SetMuteControl(PausePlay);
			break;
		case 0x02:
			//PauseStream(PausePlay);
			SetMuteControl(PausePlay);
			break;
		}
	}
	
	Chips_GeneralActions(0x00);	// Start chips
	// also does Reset (0x01), Muting Mask (0x10) and Panning (0x20)
	
	if (UseFM)
	{
		// TODO: get FirstInit working
		//if (! FirstInit)
		{
			StartSkipping();	// don't apply OPL Reset to make Track changes smooth
			AutoStopSkip = true;
		}
		open_real_fm();
	}
	
	switch(PlayingMode)
	{
	case 0x00:	// the application controls the playback thread
		break;
	case 0x01:	// FM Playback needs an independent thread
		ResetPBTimer = false;
		if (StartThread())
		{
			fprintf(stderr, "Error starting Playing Thread!\n");
			return;
		}
#ifdef CONSOLE_MODE
		PauseStream(true);
#endif
		break;
	case 0x02:	// like Mode 0x00, but Hardware is also controlled (not synced)
		break;
	}
	
	Last95Drum = 0xFFFF;
	Last95Freq = 0;
	Last95Max = 0xFFFF;
	IsVGMInit = true;
	Interpreting = false;
	InterpretFile(0);
	IsVGMInit = false;
	
	PauseThread = false;
	AutoStopSkip = true;
	ForceVGMExec = false;
	
	return;
}

void StopVGM(void)
{
	if (PlayingMode == 0xFF)
		return;
	
	if (! PauseEmulate)
	{
		if (UseFM && PausePlay)
			SetMuteControl(false);
	}
	
	switch(PlayingMode)
	{
	case 0x00:
		break;
	case 0x01:
		StopThread();
		/*if (SmoothTrackChange)
		{
			if (ThreadPauseEnable)
			{
				ThreadPauseConfrm = false;
				PauseThread = true;
				while(! ThreadPauseConfrm)
					Sleep(1);	// Wait until the Thread is finished
			}
		}*/
		break;
	case 0x02:
		break;
	}
	
	Chips_GeneralActions(0x02);	// Stop chips
	if (UseFM)
		close_real_fm();
	PlayingMode = 0xFF;
	
	return;
}

void RestartVGM(void)
{
	if (PlayingMode == 0xFF || ! VGMSmplPlayed)
		return;
	
	RestartPlaying();
	
	return;
}

void PauseVGM(bool Pause)
{
	if (PlayingMode == 0xFF || Pause == PausePlay)
		return;
	
	// now uses a temporary variable to avoid gaps (especially with DAC Stream Controller)
	if (! PauseEmulate)
	{
		if (Pause && ThreadPauseEnable)
		{
			ThreadPauseConfrm = false;
			PauseThread = true;
		}
		switch(PlayingMode)
		{
		case 0x00:
#ifdef CONSOLE_MODE
			PauseStream(Pause);
#endif
			break;
		case 0x01:
			ThreadNoWait = false;
			SetMuteControl(Pause);
			break;
		case 0x02:
#ifdef CONSOLE_MODE
			PauseStream(Pause);
#endif
			SetMuteControl(Pause);
			break;
		}
		if (Pause && ThreadPauseEnable)
		{
			while(! ThreadPauseConfrm)
				Sleep(1);	// Wait until the Thread is finished
		}
		PauseThread = Pause;
	}
	PausePlay = Pause;
	
	return;
}

void SeekVGM(bool Relative, INT32 PlayBkSamples)
{
	INT32 Samples;
	UINT32 LoopSmpls;
	
	if (PlayingMode == 0xFF || (Relative && ! PlayBkSamples))
		return;
	
	LoopSmpls = VGMCurLoop * SampleVGM2Pbk_I(VGMHead.lngLoopSamples);
	if (! Relative)
		Samples = PlayBkSamples - (LoopSmpls + VGMSmplPlayed);
	else
		Samples = PlayBkSamples;
	
	ThreadNoWait = false;
	PauseThread = true;
	if (UseFM)
		StartSkipping();
	if (Samples < 0)
	{
		Samples = LoopSmpls + VGMSmplPlayed + Samples;
		if (Samples < 0)
			Samples = 0;
		RestartPlaying();
	}
	
	ForceVGMExec = true;
	InterpretFile(Samples);
	ForceVGMExec = false;
#ifdef CONSOLE_MODE
	if (FadePlay && FadeStart)
		FadeStart += Samples;
#endif
	if (UseFM)
		StopSkipping();
	PauseThread = PausePlay;
	
	return;
}

void RefreshMuting(void)
{
	Chips_GeneralActions(0x10);	// set muting mask
	
	return;
}

void RefreshPanning(void)
{
	Chips_GeneralActions(0x20);	// set panning
	
	return;
}

void RefreshPlaybackOptions(void)
{
	INT32 TempVol;
	UINT8 CurChip;
	CHIP_OPTS* TempCOpt1;
	CHIP_OPTS* TempCOpt2;
	
	if (VGMHead.bytVolumeModifier <= VOLUME_MODIF_WRAP)
		TempVol = VGMHead.bytVolumeModifier;
	else if (VGMHead.bytVolumeModifier == (VOLUME_MODIF_WRAP + 0x01))
		TempVol = VOLUME_MODIF_WRAP - 0x100;
	else
		TempVol = VGMHead.bytVolumeModifier - 0x100;
	VolumeLevelM = (float)(VolumeLevel * pow(2.0, TempVol / (double)0x20));
	if (UseFM)
	{
		if (FMVol > 0.0f)
			VolumeLevelM = FMVol;
		else if (FMVol < 0.0f)
			VolumeLevelM *= -FMVol;
	}
	FinalVol = VolumeLevelM * MasterVol * MasterVol;
	
	//PauseSmpls = (PauseTime * SampleRate + 500) / 1000;
	
	if (PlayingMode == 0xFF)
	{
		TempCOpt1 = (CHIP_OPTS*)&ChipOpts[0x00];
		TempCOpt2 = (CHIP_OPTS*)&ChipOpts[0x01];
		for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++, TempCOpt1 ++, TempCOpt2 ++)
		{
			TempCOpt2->EmuCore = TempCOpt1->EmuCore;
			TempCOpt2->SpecialFlags = TempCOpt1->SpecialFlags;
		}
	}
	
	return;
}


UINT32 GetGZFileLength(const char* FileName)
{
	FILE* hFile;
	UINT32 FileSize;
	
	hFile = fopen(FileName, "rb");
	if (hFile == NULL)
		return 0xFFFFFFFF;
	
	FileSize = GetGZFileLength_Internal(hFile);
	
	fclose(hFile);
	return FileSize;
}

#ifndef NO_WCHAR_FILENAMES
UINT32 GetGZFileLengthW(const wchar_t* FileName)
{
	FILE* hFile;
	UINT32 FileSize;
	
	hFile = _wfopen(FileName, L"rb");
	if (hFile == NULL)
		return 0xFFFFFFFF;
	
	FileSize = GetGZFileLength_Internal(hFile);
	
	fclose(hFile);
	return FileSize;
}
#endif

static UINT32 GetGZFileLength_Internal(FILE* hFile)
{
	UINT32 FileSize;
	UINT16 gzHead;
	size_t RetVal;
	
	RetVal = fread(&gzHead, 0x02, 0x01, hFile);
	if (RetVal >= 1)
	{
		gzHead = ReadBE16((UINT8*)&gzHead);
		if (gzHead != 0x1F8B)
		{
			RetVal = 0;	// no .gz signature - treat as normal file
		}
		else
		{
			// .gz File
			fseek(hFile, -4, SEEK_END);
			// Note: In the error case it falls back to fseek/ftell.
			RetVal = fread(&FileSize, 0x04, 0x01, hFile);
#ifndef VGM_LITTLE_ENDIAN
			FileSize = ReadLE32((UINT8*)&FileSize);
#endif
		}
	}
	if (RetVal <= 0)
	{
		// normal file
		fseek(hFile, 0x00, SEEK_END);
		FileSize = ftell(hFile);
	}
	
	return FileSize;
}

bool OpenVGMFile(const char* FileName)
{
	gzFile hFile;
	UINT32 FileSize;
	bool RetVal;
	
	FileSize = GetGZFileLength(FileName);
	
	hFile = gzopen(FileName, "rb");
	if (hFile == NULL)
		return false;
	
	RetVal = OpenVGMFile_Internal(hFile, FileSize);
	
	gzclose(hFile);
	return RetVal;
}

#ifndef NO_WCHAR_FILENAMES
bool OpenVGMFileW(const wchar_t* FileName)
{
	gzFile hFile;
	UINT32 FileSize;
	bool RetVal;
#if ZLIB_VERNUM < 0x1270
	int fDesc;
	
	FileSize = GetGZFileLengthW(FileName);
	
	fDesc = _wopen(FileName, _O_RDONLY | _O_BINARY);
	hFile = gzdopen(fDesc, "rb");
	if (hFile == NULL)
	{
		_close(fDesc);
		return false;
	}
#else
	FileSize = GetGZFileLengthW(FileName);
	
	hFile = gzopen_w(FileName, "rb");
	if (hFile == NULL)
		return false;
#endif
	
	RetVal = OpenVGMFile_Internal(hFile, FileSize);
	
	gzclose(hFile);
	return RetVal;
}
#endif

static bool OpenVGMFile_Internal(gzFile hFile, UINT32 FileSize)
{
	UINT32 fccHeader;
	UINT32 CurPos;
	UINT32 HdrLimit;
	
	//gzseek(hFile, 0x00, SEEK_SET);
	gzrewind(hFile);
	gzgetLE32(hFile, &fccHeader);
	if (fccHeader != FCC_VGM)
		return false;
	
	if (FileMode != 0xFF)
		CloseVGMFile();
	
	FileMode = 0x00;
	VGMDataLen = FileSize;
	
	gzseek(hFile, 0x00, SEEK_SET);
	//gzrewind(hFile);
	ReadVGMHeader(hFile, &VGMHead);
	if (VGMHead.fccVGM != FCC_VGM)
	{
		fprintf(stderr, "VGM signature matched on the first read, but not on the second one!\n");
		fprintf(stderr, "This is a known zlib bug where gzseek fails. Please install a fixed zlib.\n");
		return false;
	}
	
	VGMSampleRate = 44100;
	if (! VGMDataLen)
		VGMDataLen = VGMHead.lngEOFOffset;
	if (! VGMHead.lngEOFOffset || VGMHead.lngEOFOffset > VGMDataLen)
	{
		fprintf(stderr, "Warning! Invalid EOF Offset 0x%02X! (should be: 0x%02X)\n",
				VGMHead.lngEOFOffset, VGMDataLen);
		VGMHead.lngEOFOffset = VGMDataLen;
	}
	if (VGMHead.lngLoopOffset && ! VGMHead.lngLoopSamples)
	{
		// 0-Sample-Loops causes the program to hangs in the playback routine
		fprintf(stderr, "Warning! Ignored Zero-Sample-Loop!\n");
		VGMHead.lngLoopOffset = 0x00000000;
	}
	if (VGMHead.lngDataOffset < 0x00000040)
	{
		fprintf(stderr, "Warning! Invalid Data Offset 0x%02X!\n", VGMHead.lngDataOffset);
		VGMHead.lngDataOffset = 0x00000040;
	}
	
	memset(&VGMHeadX, 0x00, sizeof(VGM_HDR_EXTRA));
	memset(&VGMH_Extra, 0x00, sizeof(VGM_EXTRA));
	
	// Read Data
	VGMDataLen = VGMHead.lngEOFOffset;
	VGMData = (UINT8*)malloc(VGMDataLen);
	if (VGMData == NULL)
		return false;
	//gzseek(hFile, 0x00, SEEK_SET);
	gzrewind(hFile);
	gzread(hFile, VGMData, VGMDataLen);
	
	// Read Extra Header Data
	if (VGMHead.lngExtraOffset)
	{
		UINT32* TempPtr;
		
		CurPos = VGMHead.lngExtraOffset;
		TempPtr = (UINT32*)&VGMHeadX;
		// Read Header Size
		VGMHeadX.DataSize = ReadLE32(&VGMData[CurPos]);
		if (VGMHeadX.DataSize > sizeof(VGM_HDR_EXTRA))
			VGMHeadX.DataSize = sizeof(VGM_HDR_EXTRA);
		HdrLimit = CurPos + VGMHeadX.DataSize;
		CurPos += 0x04;
		TempPtr ++;
		
		// Read all relative offsets of this header and make them absolute.
		for (; CurPos < HdrLimit; CurPos += 0x04, TempPtr ++)
		{
			*TempPtr = ReadLE32(&VGMData[CurPos]);
			if (*TempPtr)
				*TempPtr += CurPos;
		}
		
		ReadChipExtraData32(VGMHeadX.Chp2ClkOffset, &VGMH_Extra.Clocks);
		ReadChipExtraData16(VGMHeadX.ChpVolOffset, &VGMH_Extra.Volumes);
	}
	
	// Read GD3 Tag
	HdrLimit = ReadGD3Tag(hFile, VGMHead.lngGD3Offset, &VGMTag);
	if (HdrLimit == 0x10)
	{
		VGMHead.lngGD3Offset = 0x00000000;
		//return false;
	}
	if (! VGMHead.lngGD3Offset)
	{
		// replace all NULL pointers with empty strings
		VGMTag.strTrackNameE = MakeEmptyWStr();
		VGMTag.strTrackNameJ = MakeEmptyWStr();
		VGMTag.strGameNameE = MakeEmptyWStr();
		VGMTag.strGameNameJ = MakeEmptyWStr();
		VGMTag.strSystemNameE = MakeEmptyWStr();
		VGMTag.strSystemNameJ = MakeEmptyWStr();
		VGMTag.strAuthorNameE = MakeEmptyWStr();
		VGMTag.strAuthorNameJ = MakeEmptyWStr();
		VGMTag.strReleaseDate = MakeEmptyWStr();
		VGMTag.strCreator = MakeEmptyWStr();
		VGMTag.strNotes = MakeEmptyWStr();
	}
	
	return true;
}

static void ReadVGMHeader(gzFile hFile, VGM_HEADER* RetVGMHead)
{
	VGM_HEADER CurHead;
	UINT32 CurPos;
	UINT32 HdrLimit;
	
	gzread(hFile, &CurHead, sizeof(VGM_HEADER));
#ifndef VGM_LITTLE_ENDIAN
	{
		UINT8* TempPtr;
		
		// Warning: Lots of pointer casting ahead!
		for (CurPos = 0x00; CurPos < sizeof(VGM_HEADER); CurPos += 0x04)
		{
			TempPtr = (UINT8*)&CurHead + CurPos;
			switch(CurPos)
			{
			case 0x28:
				// 0x28	[16-bit] SN76496 Feedback Mask
				// 0x2A	[ 8-bit] SN76496 Shift Register Width
				// 0x2B	[ 8-bit] SN76496 Flags
				*(UINT16*)TempPtr = ReadLE16(TempPtr);
				break;
			case 0x78:	// 78-7B [8-bit] AY8910 Type/Flags
			case 0x7C:	// 7C-7F [8-bit] Volume/Loop Modifiers
			case 0x94:	// 94-97 [8-bit] various flags
				break;
			default:
				// everything else is 32-bit
				*(UINT32*)TempPtr = ReadLE32(TempPtr);
				break;
			}
		}
	}
#endif
	
	// Header preperations
	if (CurHead.lngVersion < 0x00000101)
	{
		CurHead.lngRate = 0;
	}
	if (CurHead.lngVersion < 0x00000110)
	{
		CurHead.shtPSG_Feedback = 0x0000;
		CurHead.bytPSG_SRWidth = 0x00;
		CurHead.lngHzYM2612 = CurHead.lngHzYM2413;
		CurHead.lngHzYM2151 = CurHead.lngHzYM2413;
	}
	if (CurHead.lngVersion < 0x00000150)
	{
		CurHead.lngDataOffset = 0x00000000;
	// If I would aim to be very strict, I would uncomment these few lines,
	// but I sometimes use v1.51 Flags with v1.50 for better compatibility.
	// (Some hyper-strict players refuse to play v1.51 files, even if there's
	//  no new chip used.)
	//}
	//if (CurHead.lngVersion < 0x00000151)
	//{
		CurHead.bytPSG_Flags = 0x00;
		CurHead.lngHzSPCM = 0x0000;
		CurHead.lngSPCMIntf = 0x00000000;
		// all others are zeroed by memset
	}
	
	if (CurHead.lngHzPSG)
	{
		if (! CurHead.shtPSG_Feedback)
			CurHead.shtPSG_Feedback = 0x0009;
		if (! CurHead.bytPSG_SRWidth)
			CurHead.bytPSG_SRWidth = 0x10;
	}
	
	// relative -> absolute addresses
	if (CurHead.lngEOFOffset)
		CurHead.lngEOFOffset += 0x00000004;
	if (CurHead.lngGD3Offset)
		CurHead.lngGD3Offset += 0x00000014;
	if (CurHead.lngLoopOffset)
		CurHead.lngLoopOffset += 0x0000001C;
	
	if (CurHead.lngVersion < 0x00000150)
		CurHead.lngDataOffset = 0x0000000C;
	//if (CurHead.lngDataOffset < 0x0000000C)
	//	CurHead.lngDataOffset = 0x0000000C;
	if (CurHead.lngDataOffset)
		CurHead.lngDataOffset += 0x00000034;
	
	CurPos = CurHead.lngDataOffset;
	// should actually check v1.51 (first real usage of DataOffset)
	// v1.50 is checked to support things like the Volume Modifiers in v1.50 files
	if (CurHead.lngVersion < 0x00000150 /*0x00000151*/)
		CurPos = 0x40;
	if (! CurPos)
		CurPos = 0x40;
	HdrLimit = sizeof(VGM_HEADER);
	if (HdrLimit > CurPos)
		memset((UINT8*)&CurHead + CurPos, 0x00, HdrLimit - CurPos);
	
	if (! CurHead.bytLoopModifier)
		CurHead.bytLoopModifier = 0x10;
	
	if (CurHead.lngExtraOffset)
	{
		CurHead.lngExtraOffset += 0xBC;
		
		CurPos = CurHead.lngExtraOffset;
		if (CurPos < HdrLimit)
			memset((UINT8*)&CurHead + CurPos, 0x00, HdrLimit - CurPos);
	}
	
	if (CurHead.lngGD3Offset >= CurHead.lngEOFOffset)
		CurHead.lngGD3Offset = 0x00;
	if (CurHead.lngLoopOffset >= CurHead.lngEOFOffset)
		CurHead.lngLoopOffset = 0x00;
	if (CurHead.lngDataOffset >= CurHead.lngEOFOffset)
		CurHead.lngDataOffset = 0x40;
	if (CurHead.lngExtraOffset >= CurHead.lngEOFOffset)
		CurHead.lngExtraOffset = 0x00;
	
	*RetVGMHead = CurHead;
	return;
}

static UINT8 ReadGD3Tag(gzFile hFile, UINT32 GD3Offset, GD3_TAG* RetGD3Tag)
{
	UINT32 CurPos;
	UINT32 TempLng;
	UINT8 ResVal;
	
	ResVal = 0x00;
	
	// Read GD3 Tag
	if (GD3Offset)
	{
		gzseek(hFile, GD3Offset, SEEK_SET);
		gzgetLE32(hFile, &TempLng);
		if (TempLng != FCC_GD3)
		{
			GD3Offset = 0x00000000;
			ResVal = 0x10;	// invalid GD3 offset
		}
	}
	
	if (RetGD3Tag == NULL)
		return ResVal;
	
	if (! GD3Offset)
	{
		RetGD3Tag->fccGD3 = 0x00000000;
		RetGD3Tag->lngVersion = 0x00000000;
		RetGD3Tag->lngTagLength = 0x00000000;
		RetGD3Tag->strTrackNameE = NULL;
		RetGD3Tag->strTrackNameJ = NULL;
		RetGD3Tag->strGameNameE = NULL;
		RetGD3Tag->strGameNameJ = NULL;
		RetGD3Tag->strSystemNameE = NULL;
		RetGD3Tag->strSystemNameJ = NULL;
		RetGD3Tag->strAuthorNameE = NULL;
		RetGD3Tag->strAuthorNameJ = NULL;
		RetGD3Tag->strReleaseDate = NULL;
		RetGD3Tag->strCreator = NULL;
		RetGD3Tag->strNotes = NULL;
	}
	else
	{
		//CurPos = GD3Offset;
		//gzseek(hFile, CurPos, SEEK_SET);
		//CurPos += gzgetLE32(hFile, &RetGD3Tag->fccGD3);
		
		CurPos = GD3Offset + 0x04;		// Save some back seeking, yay!
		RetGD3Tag->fccGD3 = TempLng;	// (That costs lots of CPU in .gz files.)
		CurPos += gzgetLE32(hFile, &RetGD3Tag->lngVersion);
		CurPos += gzgetLE32(hFile, &RetGD3Tag->lngTagLength);
		
		TempLng = CurPos + RetGD3Tag->lngTagLength;
		RetGD3Tag->strTrackNameE =	ReadWStrFromFile(hFile, &CurPos, TempLng);
		RetGD3Tag->strTrackNameJ =	ReadWStrFromFile(hFile, &CurPos, TempLng);
		RetGD3Tag->strGameNameE =	ReadWStrFromFile(hFile, &CurPos, TempLng);
		RetGD3Tag->strGameNameJ =	ReadWStrFromFile(hFile, &CurPos, TempLng);
		RetGD3Tag->strSystemNameE =	ReadWStrFromFile(hFile, &CurPos, TempLng);
		RetGD3Tag->strSystemNameJ =	ReadWStrFromFile(hFile, &CurPos, TempLng);
		RetGD3Tag->strAuthorNameE =	ReadWStrFromFile(hFile, &CurPos, TempLng);
		RetGD3Tag->strAuthorNameJ =	ReadWStrFromFile(hFile, &CurPos, TempLng);
		RetGD3Tag->strReleaseDate =	ReadWStrFromFile(hFile, &CurPos, TempLng);
		RetGD3Tag->strCreator =		ReadWStrFromFile(hFile, &CurPos, TempLng);
		RetGD3Tag->strNotes =		ReadWStrFromFile(hFile, &CurPos, TempLng);
	}
	
	return ResVal;
}

static void ReadChipExtraData32(UINT32 StartOffset, VGMX_CHP_EXTRA32* ChpExtra)
{
	UINT32 CurPos;
	UINT8 CurChp;
	VGMX_CHIP_DATA32* TempCD;
	
	if (! StartOffset || StartOffset >= VGMDataLen)
	{
		ChpExtra->ChipCnt = 0x00;
		ChpExtra->CCData = NULL;
		return;
	}
	
	CurPos = StartOffset;
	ChpExtra->ChipCnt = VGMData[CurPos];
	if (ChpExtra->ChipCnt)
		ChpExtra->CCData = (VGMX_CHIP_DATA32*)malloc(sizeof(VGMX_CHIP_DATA32) *
													ChpExtra->ChipCnt);
	else
		ChpExtra->CCData = NULL;
	CurPos ++;
	
	for (CurChp = 0x00; CurChp < ChpExtra->ChipCnt; CurChp ++)
	{
		TempCD = &ChpExtra->CCData[CurChp];
		TempCD->Type = VGMData[CurPos + 0x00];
		TempCD->Data = ReadLE32(&VGMData[CurPos + 0x01]);
		CurPos += 0x05;
	}
	
	return;
}

static void ReadChipExtraData16(UINT32 StartOffset, VGMX_CHP_EXTRA16* ChpExtra)
{
	UINT32 CurPos;
	UINT8 CurChp;
	VGMX_CHIP_DATA16* TempCD;
	
	if (! StartOffset || StartOffset >= VGMDataLen)
	{
		ChpExtra->ChipCnt = 0x00;
		ChpExtra->CCData = NULL;
		return;
	}
	
	CurPos = StartOffset;
	ChpExtra->ChipCnt = VGMData[CurPos];
	if (ChpExtra->ChipCnt)
		ChpExtra->CCData = (VGMX_CHIP_DATA16*)malloc(sizeof(VGMX_CHIP_DATA16) *
													ChpExtra->ChipCnt);
	else
		ChpExtra->CCData = NULL;
	CurPos ++;
	
	for (CurChp = 0x00; CurChp < ChpExtra->ChipCnt; CurChp ++)
	{
		TempCD = &ChpExtra->CCData[CurChp];
		TempCD->Type = VGMData[CurPos + 0x00];
		TempCD->Flags = VGMData[CurPos + 0x01];
		TempCD->Data = ReadLE16(&VGMData[CurPos + 0x02]);
		CurPos += 0x04;
	}
	
	return;
}

void CloseVGMFile(void)
{
	if (FileMode == 0xFF)
		return;
	
	VGMHead.fccVGM = 0x00;
	free(VGMH_Extra.Clocks.CCData);		VGMH_Extra.Clocks.CCData = NULL;
	free(VGMH_Extra.Volumes.CCData);	VGMH_Extra.Volumes.CCData = NULL;
	free(VGMData);	VGMData = NULL;
	
	if (FileMode == 0x00)
	FreeGD3Tag(&VGMTag);
	
	FileMode = 0xFF;
	
	return;
}

void FreeGD3Tag(GD3_TAG* TagData)
{
	if (TagData == NULL)
		return;
	
	TagData->fccGD3 = 0x00;
	free(TagData->strTrackNameE);	TagData->strTrackNameE = NULL;
	free(TagData->strTrackNameJ);	TagData->strTrackNameJ = NULL;
	free(TagData->strGameNameE);	TagData->strGameNameE = NULL;
	free(TagData->strGameNameJ);	TagData->strGameNameJ = NULL;
	free(TagData->strSystemNameE);	TagData->strSystemNameE = NULL;
	free(TagData->strSystemNameJ);	TagData->strSystemNameJ = NULL;
	free(TagData->strAuthorNameE);	TagData->strAuthorNameE = NULL;
	free(TagData->strAuthorNameJ);	TagData->strAuthorNameJ = NULL;
	free(TagData->strReleaseDate);	TagData->strReleaseDate = NULL;
	free(TagData->strCreator);		TagData->strCreator = NULL;
	free(TagData->strNotes);		TagData->strNotes = NULL;
	
	return;
}

static wchar_t* MakeEmptyWStr(void)
{
	wchar_t* Str;
	
	Str = (wchar_t*)malloc(0x01 * sizeof(wchar_t));
	Str[0x00] = L'\0';
	
	return Str;
}

static wchar_t* ReadWStrFromFile(gzFile hFile, UINT32* FilePos, UINT32 EOFPos)
{
	// Note: Works with Windows (16-bit wchar_t) as well as Linux (32-bit wchar_t)
	UINT32 CurPos;
	wchar_t* TextStr;
	wchar_t* TempStr;
	UINT32 StrLen;
	UINT16 UnicodeChr;
	
	CurPos = *FilePos;
	if (CurPos >= EOFPos)
		return NULL;
	TextStr = (wchar_t*)malloc((EOFPos - CurPos) / 0x02 * sizeof(wchar_t));
	if (TextStr == NULL)
		return NULL;
	
	if ((UINT32)gztell(hFile) != CurPos)
		gzseek(hFile, CurPos, SEEK_SET);
	TempStr = TextStr - 1;
	StrLen = 0x00;
	do
	{
		TempStr ++;
		gzgetLE16(hFile, &UnicodeChr);
		*TempStr = (wchar_t)UnicodeChr;
		CurPos += 0x02;
		StrLen ++;
		if (CurPos >= EOFPos)
		{
			*TempStr = L'\0';
			break;
		}
	} while(*TempStr != L'\0');
	
	TextStr = (wchar_t*)realloc(TextStr, StrLen * sizeof(wchar_t));
	*FilePos = CurPos;
	
	return TextStr;
}

UINT32 GetVGMFileInfo(const char* FileName, VGM_HEADER* RetVGMHead, GD3_TAG* RetGD3Tag)
{
	gzFile hFile;
	UINT32 FileSize;
	UINT32 RetVal;
	
	FileSize = GetGZFileLength(FileName);
	
	hFile = gzopen(FileName, "rb");
	if (hFile == NULL)
		return 0x00;
	
	RetVal = GetVGMFileInfo_Internal(hFile, FileSize, RetVGMHead, RetGD3Tag);
	
	gzclose(hFile);
	return RetVal;
}

#ifndef NO_WCHAR_FILENAMES
UINT32 GetVGMFileInfoW(const wchar_t* FileName, VGM_HEADER* RetVGMHead, GD3_TAG* RetGD3Tag)
{
	gzFile hFile;
	UINT32 FileSize;
	UINT32 RetVal;
#if ZLIB_VERNUM < 0x1270
	int fDesc;
	
	FileSize = GetGZFileLengthW(FileName);
	
	fDesc = _wopen(FileName, _O_RDONLY | _O_BINARY);
	hFile = gzdopen(fDesc, "rb");
	if (hFile == NULL)
	{
		_close(fDesc);
		return 0x00;
	}
#else
	FileSize = GetGZFileLengthW(FileName);
	
	hFile = gzopen_w(FileName, "rb");
	if (hFile == NULL)
		return 0x00;
#endif
	
	RetVal = GetVGMFileInfo_Internal(hFile, FileSize, RetVGMHead, RetGD3Tag);
	
	gzclose(hFile);
	return RetVal;
}
#endif

static UINT32 GetVGMFileInfo_Internal(gzFile hFile, UINT32 FileSize,
									  VGM_HEADER* RetVGMHead, GD3_TAG* RetGD3Tag)
{
	// this is a copy-and-paste from OpenVGM, just a little stripped
	UINT32 fccHeader;
	UINT32 TempLng;
	VGM_HEADER TempHead;
	
	//gzseek(hFile, 0x00, SEEK_SET);
	gzrewind(hFile);
	gzgetLE32(hFile, &fccHeader);
	if (fccHeader != FCC_VGM)
		return 0x00;
	
	if (RetVGMHead == NULL && RetGD3Tag == NULL)
		return FileSize;
	
	//gzseek(hFile, 0x00, SEEK_SET);
	gzrewind(hFile);
	ReadVGMHeader(hFile, &TempHead);
	
	if (! TempHead.lngEOFOffset || TempHead.lngEOFOffset > FileSize)
		TempHead.lngEOFOffset = FileSize;
	if (TempHead.lngDataOffset < 0x00000040)
		TempHead.lngDataOffset = 0x00000040;
	
	/*if (TempHead.lngGD3Offset)
	{
		gzseek(hFile, TempHead.lngGD3Offset, SEEK_SET);
		gzgetLE32(hFile, &fccHeader);
		if (fccHeader != FCC_GD3)
			TempHead.lngGD3Offset = 0x00000000;
			//return 0x00;
	}*/
	
	if (RetVGMHead != NULL)
		*RetVGMHead = TempHead;
	
	// Read GD3 Tag
	if (RetGD3Tag != NULL)
		TempLng = ReadGD3Tag(hFile, TempHead.lngGD3Offset, RetGD3Tag);
	
	return FileSize;
}

INLINE UINT32 MulDivRound(UINT64 Number, UINT64 Numerator, UINT64 Denominator)
{
	return (UINT32)((Number * Numerator + Denominator / 2) / Denominator);
}

UINT32 CalcSampleMSec(UINT64 Value, UINT8 Mode)
{
	// Mode:
	//	Bit 0 (01):	Calculation Mode
	//				0 - Sample2MSec
	//				1 - MSec2Sample
	//	Bit 1 (02):	Calculation Samlpe Rate
	//				0 - current playback rate
	//				1 - 44.1 KHz (VGM native)
	UINT32 SmplRate;
	UINT32 PbMul;
	UINT32 PbDiv;
	UINT32 RetVal;
	
	if (! (Mode & 0x02))
	{
		SmplRate = SampleRate;
		PbMul = 1;
		PbDiv = 1;
	}
	else
	{
		SmplRate = VGMSampleRate;
		PbMul = VGMPbRateMul;
		PbDiv = VGMPbRateDiv;
	}
	
	switch(Mode & 0x01)
	{
	case 0x00:
		RetVal = MulDivRound(Value, (UINT64)1000 * PbMul, (UINT64)SmplRate * PbDiv);
		break;
	case 0x01:
		RetVal = MulDivRound(Value, (UINT64)SmplRate * PbDiv, (UINT64)1000 * PbMul);
		break;
	}
	
	return RetVal;
}

UINT32 CalcSampleMSecExt(UINT64 Value, UINT8 Mode, VGM_HEADER* FileHead)
{
	// Note: This function was NOT tested with non-VGM formats!
	
	// Mode: see function above
	UINT32 SmplRate;
	UINT32 PbMul;
	UINT32 PbDiv;
	UINT32 RetVal;
	
	if (! (Mode & 0x02))
	{
		SmplRate = SampleRate;
		PbMul = 1;
		PbDiv = 1;
	}
	else
	{
		// TODO: make it work for non-VGM formats
		// (i.e. get VGMSampleRate information from FileHead)
		//
		// But currently GetVGMFileInfo doesn't support them, it doesn't matter either way
		SmplRate = 44100;
		if (! VGMPbRate || ! FileHead->lngRate)
		{
			PbMul = 1;
			PbDiv = 1;
		}
		else
		{
			PbMul = FileHead->lngRate;
			PbDiv = VGMPbRate;
		}
	}
	
	switch(Mode & 0x01)
	{
	case 0x00:
		RetVal = MulDivRound(Value, 1000 * PbMul, SmplRate * PbDiv);
		break;
	case 0x01:
		RetVal = MulDivRound(Value, SmplRate * PbDiv, 1000 * PbMul);
		break;
	}
	
	return RetVal;
}

#if 0
static UINT32 EncryptChipName(void* DstBuf, const void* SrcBuf, UINT32 Length)
{
	// using nineko's awesome encryption algorithm
	// http://forums.sonicretro.org/index.php?showtopic=25300
	// based on C code by sasuke
	const UINT8* SrcPos;
	UINT8* DstPos;
	UINT32 CurPos;
	UINT8 CryptShift;	// Src Bit/Dst Byte
	UINT8 PlainShift;	// Src Byte/Dst Bit
	
	if (Length & 0x07)
		return 0x00;	// Length MUST be a multiple of 8
	
	SrcPos = (const UINT8*)SrcBuf;
	DstPos = (UINT8*)DstBuf;
	for (CurPos = 0; CurPos < Length; CurPos += 8, SrcPos += 8, DstPos += 8)
	{
		for (CryptShift = 0; CryptShift < 8; CryptShift ++)
		{
			DstPos[CryptShift] = 0x00;
			for (PlainShift = 0; PlainShift < 8; PlainShift ++)
			{
				if (SrcPos[PlainShift] & (1 << CryptShift))
					DstPos[CryptShift] |= (1 << PlainShift);
			}
		}
	}
	
	return Length;
}
#endif

const char* GetChipName(UINT8 ChipID)
{
	const char* CHIP_STRS[CHIP_COUNT] = 
	{	"SN76496", "YM2413", "YM2612", "YM2151", "SegaPCM", "RF5C68", "YM2203", "YM2608",
		"YM2610", "YM3812", "YM3526", "Y8950", "YMF262", "YMF278B", "YMF271", "YMZ280B",
		"RF5C164", "PWM", "AY8910", "GameBoy", "NES APU", "YMW258", "uPD7759", "OKIM6258",
		"OKIM6295", "K051649", "K054539", "HuC6280", "C140", "K053260", "Pokey", "QSound",
		"SCSP", "WSwan", "VSU", "SAA1099", "ES5503", "ES5506", "X1-010", "C352",
		"GA20"};
	
	/*if (ChipID == 0x21)
	{
		static char TempStr[0x08];
		UINT32 TempData[2];
		
		//EncryptChipName(TempData, "WSwan", 0x08);
		TempData[0] = 0x1015170F;
		TempData[1] = 0x001F1C07;
		EncryptChipName(TempStr, TempData, 0x08);
		return TempStr;	// "WSwan"
	}*/
	
	if (ChipID < CHIP_COUNT)
		return CHIP_STRS[ChipID];
	else
		return NULL;
}

const char* GetAccurateChipName(UINT8 ChipID, UINT8 SubType)
{
	const char* RetStr;
	
	if ((ChipID & 0x7F) >= CHIP_COUNT)
		return NULL;
	
	RetStr = NULL;
	switch(ChipID & 0x7F)
	{
	case 0x00:
		if (! (ChipID & 0x80))
		{
			switch(SubType)
			{
			case 0x01:
				RetStr = "SN76489";
				break;
			case 0x02:
				RetStr = "SN76489A";
				break;
			case 0x03:
				RetStr = "SN76494";
				break;
			case 0x04:
				RetStr = "SN76496";
				break;
			case 0x05:
				RetStr = "SN94624";
				break;
			case 0x06:
				RetStr = "SEGA PSG";
				break;
			case 0x07:
				RetStr = "NCR8496";
				break;
			case 0x08:
				RetStr = "PSSJ-3";
				break;
			default:
				RetStr = "SN76496";
				break;
			}
		}
		else
		{
			RetStr = "T6W28";
		}
		break;
	case 0x01:
		if (ChipID & 0x80)
			RetStr = "VRC7";
		break;
	case 0x02:
		if (! (ChipID & 0x80))
			RetStr = "YM2612";
		else
			RetStr = "YM3438";
		break;
	case 0x04:
		RetStr = "Sega PCM";
		break;
	case 0x08:
		if (! (ChipID & 0x80))
			RetStr = "YM2610";
		else
			RetStr = "YM2610B";
		break;
	case 0x12:	// AY8910
		switch(SubType)
		{
		case 0x00:
			RetStr = "AY-3-8910";
			break;
		case 0x01:
			RetStr = "AY-3-8912";
			break;
		case 0x02:
			RetStr = "AY-3-8913";
			break;
		case 0x03:
			RetStr = "AY8930";
			break;
		case 0x04:
			RetStr = "AY-3-8914";
			break;
		case 0x10:
			RetStr = "YM2149";
			break;
		case 0x11:
			RetStr = "YM3439";
			break;
		case 0x12:
			RetStr = "YMZ284";
			break;
		case 0x13:
			RetStr = "YMZ294";
			break;
		}
		break;
	case 0x13:
		RetStr = "GB DMG";
		break;
	case 0x14:
		if (! (ChipID & 0x80))
			RetStr = "NES APU";
		else
			RetStr = "NES APU + FDS";
		break;
	case 0x19:
		if (! (ChipID & 0x80))
			RetStr = "K051649";
		else
			RetStr = "K052539";
		break;
	case 0x1C:
		switch(SubType)
		{
		case 0x00:
		case 0x01:
			RetStr = "C140";
			break;
		case 0x02:
			RetStr = "C219";
			break;
		}
		break;
	case 0x21:
		RetStr = "WonderSwan";
		break;
	case 0x22:
		RetStr = "VSU-VUE";
		break;
	case 0x25:
		if (! (ChipID & 0x80))
			RetStr = "ES5505";
		else
			RetStr = "ES5506";
		break;
	case 0x28:
		RetStr = "Irem GA20";
		break;
	}
	// catch all default-cases
	if (RetStr == NULL)
		RetStr = GetChipName(ChipID & 0x7F);
	
	return RetStr;
}

UINT32 GetChipClock(VGM_HEADER* FileHead, UINT8 ChipID, UINT8* RetSubType)
{
	UINT32 Clock;
	UINT8 SubType;
	UINT8 CurChp;
	bool AllowBit31;
	
	SubType = 0x00;
	AllowBit31 = 0x00;
	switch(ChipID & 0x7F)
	{
	case 0x00:
		Clock = FileHead->lngHzPSG;
		AllowBit31 = 0x01;	// T6W28 Mode
		if (RetSubType != NULL && ! (Clock & 0x80000000))	// The T6W28 is handled differently.
		{
			switch(FileHead->bytPSG_SRWidth)
			{
			case 0x0F:	//  0x4000
				if (FileHead->bytPSG_Flags & 0x08)	// Clock Divider == 1?
					SubType = 0x05;	// SN94624
				else
					SubType = 0x01;	// SN76489
				break;
			case 0x10:	//  0x8000
				if (FileHead->shtPSG_Feedback == 0x0009)
					SubType = 0x06;	// SEGA PSG
				else if (FileHead->shtPSG_Feedback == 0x0022)
				{
					if (FileHead->bytPSG_Flags & 0x10)	// if Tandy noise mode enabled
						SubType = (FileHead->bytPSG_Flags & 0x02) ? 0x07 : 0x08;	// NCR8496 / PSSJ-3
					else
						SubType = 0x07;	// NCR8496
				}
				break;
			case 0x11:	// 0x10000
				if (FileHead->bytPSG_Flags & 0x08)	// Clock Divider == 1?
					SubType = 0x03;	// SN76494
				else
					SubType = 0x02;	// SN76489A/SN76496
				break;
			}
			/*
								 FbMask  Noise Taps  Negate Stereo Dv Freq0		Fb	SR	Flags
				01 SN76489		 0x4000, 0x01, 0x02, TRUE,  FALSE, 8, TRUE		03	0F	07 (02|04|00|01) [unverified]
				02 SN76489A		0x10000, 0x04, 0x08, FALSE, FALSE, 8, TRUE		0C	11	05 (00|04|00|01)
				03 SN76494		0x10000, 0x04, 0x08, FALSE, FALSE, 1, TRUE		0C	11	0D (00|04|08|01)
				04 SN76496		0x10000, 0x04, 0x08, FALSE, FALSE, 8, TRUE		0C	11	05 (00|04|00|01) [same as SN76489A]
				05 SN94624		 0x4000, 0x01, 0x02, TRUE,  FALSE, 1, TRUE		03	0F	0F (02|04|08|01) [unverified, SN76489A without /8]
				06 GameGear PSG	 0x8000, 0x01, 0x08, TRUE,  TRUE,  8, FALSE		09	10	02 (02|00|00|00)
				06 SEGA VDP PSG	 0x8000, 0x01, 0x08, TRUE,  FALSE, 8, FALSE		09	10	06 (02|04|00|00)
				07 NCR8496		 0x8000, 0x02, 0x20, TRUE,  FALSE, 8, TRUE		22	10	07 (02|04|00|01)
				08 PSSJ-3		 0x8000, 0x02, 0x20, FALSE, FALSE, 8, TRUE		22	10	05 (00|04|00|01)
				01 U8106		 0x4000, 0x01, 0x02, TRUE,  FALSE, 8, TRUE		03	0F	07 (02|04|00|01) [unverified, same as SN76489]
				02 Y2404		0x10000, 0x04, 0x08, FALSE, FALSE; 8, TRUE		0C	11	05 (00|04|00|01) [unverified, same as SN76489A]
				-- T6W28		0x10000, 0x04, 0x08, ????,  FALSE, 8, ????		0C	11	?? (??|??|00|01) [It IS stereo, but not in GameGear way].
			*/
		}
		break;
	case 0x01:
		Clock = FileHead->lngHzYM2413;
		AllowBit31 = 0x01;	// VRC7 Mode
		break;
	case 0x02:
		Clock = FileHead->lngHzYM2612;
		AllowBit31 = 0x01;	// YM3438 Mode
		break;
	case 0x03:
		Clock = FileHead->lngHzYM2151;
		break;
	case 0x04:
		Clock = FileHead->lngHzSPCM;
		break;
	case 0x05:
		if (ChipID & 0x80)
			return 0;
		Clock = FileHead->lngHzRF5C68;
		break;
	case 0x06:
		Clock = FileHead->lngHzYM2203;
		break;
	case 0x07:
		Clock = FileHead->lngHzYM2608;
		break;
	case 0x08:
		Clock = FileHead->lngHzYM2610;
		AllowBit31 = 0x01;	// YM2610B Mode
		break;
	case 0x09:
		Clock = FileHead->lngHzYM3812;
		AllowBit31 = 0x01;	// Dual OPL2, panned to the L/R speakers
		break;
	case 0x0A:
		Clock = FileHead->lngHzYM3526;
		break;
	case 0x0B:
		Clock = FileHead->lngHzY8950;
		break;
	case 0x0C:
		Clock = FileHead->lngHzYMF262;
		break;
	case 0x0D:
		Clock = FileHead->lngHzYMF278B;
		break;
	case 0x0E:
		Clock = FileHead->lngHzYMF271;
		break;
	case 0x0F:
		Clock = FileHead->lngHzYMZ280B;
		break;
	case 0x10:
		if (ChipID & 0x80)
			return 0;
		Clock = FileHead->lngHzRF5C164;
		AllowBit31 = 0x01;	// hack for Cosmic Fantasy Stories
		break;
	case 0x11:
		if (ChipID & 0x80)
			return 0;
		Clock = FileHead->lngHzPWM;
		break;
	case 0x12:
		Clock = FileHead->lngHzAY8910;
		SubType = FileHead->bytAYType;
		break;
	case 0x13:
		Clock = FileHead->lngHzGBDMG;
		break;
	case 0x14:
		Clock = FileHead->lngHzNESAPU;
		AllowBit31 = 0x01;	// FDS Enable
		break;
	case 0x15:
		Clock = FileHead->lngHzMultiPCM;
		break;
	case 0x16:
		Clock = FileHead->lngHzUPD7759;
		AllowBit31 = 0x01;	// Master/Slave Bit
		break;
	case 0x17:
		Clock = FileHead->lngHzOKIM6258;
		break;
	case 0x18:
		Clock = FileHead->lngHzOKIM6295;
		AllowBit31 = 0x01;	// Pin 7 State
		break;
	case 0x19:
		Clock = FileHead->lngHzK051649;
		AllowBit31 = 0x01;	// SCC/SCC+ Bit
		break;
	case 0x1A:
		Clock = FileHead->lngHzK054539;
		break;
	case 0x1B:
		Clock = FileHead->lngHzHuC6280;
		break;
	case 0x1C:
		Clock = FileHead->lngHzC140;
		SubType = FileHead->bytC140Type;
		break;
	case 0x1D:
		Clock = FileHead->lngHzK053260;
		break;
	case 0x1E:
		Clock = FileHead->lngHzPokey;
		break;
	case 0x1F:
		if (ChipID & 0x80)
			return 0;
		Clock = FileHead->lngHzQSound;
		break;
	case 0x20:
		Clock = FileHead->lngHzSCSP;
		break;
	case 0x21:
		Clock = FileHead->lngHzWSwan;
		break;
	case 0x22:
		Clock = FileHead->lngHzVSU;
		break;
	case 0x23:
		Clock = FileHead->lngHzSAA1099;
		break;
	case 0x24:
		Clock = FileHead->lngHzES5503;
		break;
	case 0x25:
		Clock = FileHead->lngHzES5506;
		AllowBit31 = 0x01;	// ES5505/5506 switch
		break;
	case 0x26:
		Clock = FileHead->lngHzX1_010;
		break;
	case 0x27:
		Clock = FileHead->lngHzC352;
		AllowBit31 = 0x01;	// disable rear channels
		break;
	case 0x28:
		Clock = FileHead->lngHzGA20;
		break;
	default:
		return 0;
	}
	if (ChipID & 0x80)
	{
		VGMX_CHP_EXTRA32* TempCX;
		
		if (! (Clock & 0x40000000))
			return 0;
		
		ChipID &= 0x7F;
		TempCX = &VGMH_Extra.Clocks;
		for (CurChp = 0x00; CurChp < TempCX->ChipCnt; CurChp ++)
		{
			if (TempCX->CCData[CurChp].Type == ChipID)
			{
				if (TempCX->CCData[CurChp].Data)
					Clock = TempCX->CCData[CurChp].Data;
				break;
			}
		}
	}
	
	if (RetSubType != NULL)
		*RetSubType = SubType;
	if (AllowBit31)
		return Clock & 0xBFFFFFFF;
	else
		return Clock & 0x3FFFFFFF;
}

static UINT16 GetChipVolume(VGM_HEADER* FileHead, UINT8 ChipID, UINT8 ChipNum, UINT8 ChipCnt)
{
	// ChipID: ID of Chip
	//		Bit 7 - Is Paired Chip
	// ChipNum: chip number (0 - first chip, 1 - second chip)
	// ChipCnt: chip volume divider (number of used chips)
	const UINT16 CHIP_VOLS[CHIP_COUNT] =
	{	0x80, 0x200/*0x155*/, 0x100, 0x100, 0x180, 0xB0, 0x100, 0x80,	// 00-07
		0x80, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x98,			// 08-0F
		0x80, 0xE0/*0xCD*/, 0x100, 0xC0, 0x100, 0x40, 0x11E, 0x1C0,		// 10-17
		0x100/*110*/, 0xA0, 0x100, 0x100, 0x100, 0xB3, 0x100, 0x100,	// 18-1F
		0x20, 0x100, 0x100, 0x100, 0x40, 0x20, 0x100, 0x40,			// 20-27
		0x280};
	UINT16 Volume;
	UINT8 CurChp;
	VGMX_CHP_EXTRA16* TempCX;
	VGMX_CHIP_DATA16* TempCD;
	
	Volume = CHIP_VOLS[ChipID & 0x7F];
	switch(ChipID)
	{
	case 0x00:	// SN76496
		// if T6W28, set Volume Divider to 01
		if (GetChipClock(&VGMHead, (ChipID << 7) | ChipID, NULL) & 0x80000000)
		{
			// The T6W28 consists of 2 "half" chips.
			ChipNum = 0x01;
			ChipCnt = 0x01;
		}
		break;
	case 0x18:	// OKIM6295
		// CP System 1 patch
		if (VGMTag.strSystemNameE != NULL && ! wcsncmp(VGMTag.strSystemNameE, L"CP", 0x02))
			Volume = 110;
		break;
	case 0x86:	// YM2203's AY
		Volume /= 2;
		break;
	case 0x87:	// YM2608's AY
		// The YM2608 outputs twice as loud as the YM2203 here.
		//Volume *= 1;
		break;
	case 0x88:	// YM2610's AY
		//Volume *= 1;
		break;
	}
	if (ChipCnt > 1)
		Volume /= ChipCnt;
	
	TempCX = &VGMH_Extra.Volumes;
	TempCD = TempCX->CCData;
	for (CurChp = 0x00; CurChp < TempCX->ChipCnt; CurChp ++, TempCD ++)
	{
		if (TempCD->Type == ChipID && (TempCD->Flags & 0x01) == ChipNum)
		{
			// Bit 15 - absolute/relative volume
			//	0 - absolute
			//	1 - relative (0x0100 = 1.0, 0x80 = 0.5, etc.)
			if (TempCD->Data & 0x8000)
				Volume = (Volume * (TempCD->Data & 0x7FFF) + 0x80) >> 8;
			else
			{
				Volume = TempCD->Data;
				if ((ChipID & 0x80) && DoubleSSGVol)
					Volume *= 2;
			}
			break;
		}
	}
	
	return Volume;
}


static void RestartPlaying(void)
{
	bool OldPThread;
	
	OldPThread = PauseThread;
	if (ThreadPauseEnable)
	{
		ThreadNoWait = false;
		ThreadPauseConfrm = false;
		PauseThread = true;
		while(! ThreadPauseConfrm)
			Sleep(1);	// Wait until the Thread is finished
	}
	Interpreting = true;	// Avoid any Thread-Call
	
	VGMPos = VGMHead.lngDataOffset;
	VGMSmplPos = 0;
	VGMSmplPlayed = 0;
	VGMEnd = false;
	EndPlay = false;
	VGMCurLoop = 0x00;
	PauseSmpls = (PauseTime * SampleRate + 500) / 1000;
	
	Chips_GeneralActions(0x01);	// Reset Chips
	// also does Muting Mask (0x10) and Panning (0x20)
	
	if (UseFM)
	{
		open_real_fm();	// reset OPL chip and reload settings
		StartSkipping();
		AutoStopSkip = true;
	}
	
	Last95Drum = 0xFFFF;
	Last95Freq = 0;
	Interpreting = false;
	ForceVGMExec = true;
	IsVGMInit = true;
	InterpretFile(0);
	IsVGMInit = false;
	ForceVGMExec = false;
#ifndef CONSOLE_MODE
	FadePlay = false;
	MasterVol = 1.0f;
	FadeStart = 0;
	FinalVol = VolumeLevelM;
	PlayingTime = 0;
#endif
	PauseThread = OldPThread;
	
	return;
}

static void Chips_GeneralActions(UINT8 Mode)
{
	UINT32 AbsVol;
	//UINT16 ChipVol;
	CAUD_ATTR* CAA;
	CHIP_OPTS* COpt;
	UINT8 ChipCnt;
	UINT8 CurChip;
	UINT8 CurCSet;	// Chip Set
	UINT32 MaskVal;
	UINT32 ChipClk;
	
	switch(Mode)
	{
	case 0x00:	// Start Chips
		for (CurCSet = 0x00; CurCSet < 0x02; CurCSet ++)
		{
			CAA = (CAUD_ATTR*)&ChipAudio[CurCSet];
			for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++, CAA ++)
			{
				CAA->SmpRate = 0x00;
				CAA->Volume = 0x00;
				CAA->ChipType = 0xFF;
				CAA->ChipID = CurCSet;
				CAA->Resampler = 0x00;
				CAA->StreamUpdate = &null_update;
				CAA->Paired = NULL;
			}
			CAA = CA_Paired[CurCSet];
			for (CurChip = 0x00; CurChip < 0x03; CurChip ++, CAA ++)
			{
				CAA->SmpRate = 0x00;
				CAA->Volume = 0x00;
				CAA->ChipType = 0xFF;
				CAA->ChipID = CurCSet;
				CAA->Resampler = 0x00;
				CAA->StreamUpdate = &null_update;
				CAA->Paired = NULL;
			}
		}
		
		// Initialize Sound Chips
		AbsVol = 0x00;
		if (VGMHead.lngHzPSG)
		{
			//ChipVol = UseFM ? 0x00 : 0x80;
			sn764xx_set_emu_core(ChipOpts[0x00].SN76496.EmuCore);
			ChipOpts[0x01].SN76496.EmuCore = ChipOpts[0x00].SN76496.EmuCore;
			
			ChipCnt = (VGMHead.lngHzPSG & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].SN76496;
				CAA->ChipType = 0x00;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				ChipClk &= ~0x80000000;
				ChipClk |= VGMHead.lngHzPSG & ((CurChip & 0x01) << 31);
				if (! UseFM)
				{
					CAA->SmpRate = device_start_sn764xx(CurChip, ChipClk,
														VGMHead.bytPSG_SRWidth,
														VGMHead.shtPSG_Feedback,
														(VGMHead.bytPSG_Flags & 0x02) >> 1,
														(VGMHead.bytPSG_Flags & 0x04) >> 2,
														(VGMHead.bytPSG_Flags & 0x08) >> 3,
														(VGMHead.bytPSG_Flags & 0x01) >> 0);
					CAA->StreamUpdate = &sn764xx_stream_update;
					
					CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
					if (! CurChip || ! (ChipClk & 0x80000000))
						AbsVol += CAA->Volume;
				}
				else
				{
					open_fm_option(CAA->ChipType, 0x00, ChipClk);
					open_fm_option(CAA->ChipType, 0x01, VGMHead.bytPSG_SRWidth);
					open_fm_option(CAA->ChipType, 0x02, VGMHead.shtPSG_Feedback);
					open_fm_option(CAA->ChipType, 0x04, (VGMHead.bytPSG_Flags & 0x02) >> 1);
					open_fm_option(CAA->ChipType, 0x05, (VGMHead.bytPSG_Flags & 0x04) >> 2);
					open_fm_option(CAA->ChipType, 0x06, (VGMHead.bytPSG_Flags & 0x08) >> 3);
					open_fm_option(CAA->ChipType, 0x07, (VGMHead.bytPSG_Flags & 0x01) >> 0);
					setup_real_fm(CAA->ChipType, CurChip);
					
					CAA->SmpRate = 0x00000000;
					CAA->Volume = 0x0000;
				}
			}
			if (VGMHead.lngHzPSG & 0x80000000)
				ChipCnt = 0x01;
		}
		if (VGMHead.lngHzYM2413)
		{
			//ChipVol = UseFM ? 0x00 : 0x200/*0x155*/;
			if (! UseFM)
				ym2413_set_emu_core(ChipOpts[0x00].YM2413.EmuCore);
			else
				ym2413opl_set_emu_core(ChipOpts[0x00].YM2413.EmuCore);
			ChipOpts[0x01].YM2413.EmuCore = ChipOpts[0x00].YM2413.EmuCore;
			
			ChipCnt = (VGMHead.lngHzYM2413 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YM2413;
				CAA->ChipType = 0x01;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				if (! UseFM)
				{
					CAA->SmpRate = device_start_ym2413(CurChip, ChipClk);
					CAA->StreamUpdate = &ym2413_stream_update;
					
					CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
					// WHY has this chip such a low volume???
					//AbsVol += (CAA->Volume + 1) * 3 / 4;
					AbsVol += CAA->Volume / 2;
				}
				else
				{
					setup_real_fm(CAA->ChipType, CurChip);
					
					CAA->SmpRate = 0x00000000;
					CAA->Volume = 0x0000;
				}
			}
		}
		if (VGMHead.lngHzYM2612)
		{
			//ChipVol = 0x100;
			ym2612_set_emu_core(ChipOpts[0x00].YM2612.EmuCore);
			ym2612_set_options((UINT8)ChipOpts[0x00].YM2612.SpecialFlags);
			ChipOpts[0x01].YM2612.EmuCore = ChipOpts[0x00].YM2612.EmuCore;
			ChipOpts[0x01].YM2612.SpecialFlags = ChipOpts[0x00].YM2612.SpecialFlags;
			ChipCnt = (VGMHead.lngHzYM2612 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YM2612;
				CAA->ChipType = 0x02;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_ym2612(CurChip, ChipClk);
				CAA->StreamUpdate = &ym2612_stream_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzYM2151)
		{
			//ChipVol = 0x100;
			ym2151_set_emu_core(ChipOpts[0x00].YM2151.EmuCore);
			ChipCnt = (VGMHead.lngHzYM2151 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YM2151;
				CAA->ChipType = 0x03;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_ym2151(CurChip, ChipClk);
				CAA->StreamUpdate = &ym2151_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzSPCM)
		{
			//ChipVol = 0x180;
			ChipCnt = (VGMHead.lngHzSPCM & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].SegaPCM;
				CAA->ChipType = 0x04;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_segapcm(CurChip, ChipClk, VGMHead.lngSPCMIntf);
				CAA->StreamUpdate = &SEGAPCM_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzRF5C68)
		{
			//ChipVol = 0xB0;	// that's right according to MAME, but it's almost too loud
			ChipCnt = 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].RF5C68;
				CAA->ChipType = 0x05;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_rf5c68(CurChip, ChipClk);
				CAA->StreamUpdate = &rf5c68_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzYM2203)
		{
			//ChipVol = 0x100;
			ym2203_set_ay_emu_core(ChipOpts[0x00].YM2203.EmuCore);
			ChipOpts[0x01].YM2203.EmuCore = ChipOpts[0x00].YM2203.EmuCore;
			ChipOpts[0x01].YM2203.SpecialFlags = ChipOpts[0x00].YM2203.SpecialFlags;
			
			ChipCnt = (VGMHead.lngHzYM2203 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YM2203;
				COpt = &ChipOpts[CurChip].YM2203;
				CAA->ChipType = 0x06;
				CAA->Paired = &CA_Paired[CurChip][0x00];
				CAA->Paired->ChipType = 0x80 | CAA->ChipType;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_ym2203(CurChip, ChipClk, COpt->SpecialFlags & 0x01,
													VGMHead.bytAYFlagYM2203,
													(int*)&CAA->Paired->SmpRate);
				CAA->StreamUpdate = &ym2203_stream_update;
				CAA->Paired->StreamUpdate = &ym2203_stream_update_ay;
				ym2203_set_srchg_cb(CurChip, &ChangeChipSampleRate, CAA, CAA->Paired);
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				CAA->Paired->Volume = GetChipVolume(&VGMHead, CAA->Paired->ChipType,
													CurChip, ChipCnt);
				AbsVol += CAA->Volume + CAA->Paired->Volume;
			}
		}
		if (VGMHead.lngHzYM2608)
		{
			//ChipVol = 0x80;
			ym2608_set_ay_emu_core(ChipOpts[0x00].YM2608.EmuCore);
			ChipOpts[0x01].YM2608.EmuCore = ChipOpts[0x00].YM2608.EmuCore;
			ChipOpts[0x01].YM2608.SpecialFlags = ChipOpts[0x00].YM2608.SpecialFlags;
			
			ChipCnt = (VGMHead.lngHzYM2608 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YM2608;
				COpt = &ChipOpts[CurChip].YM2608;
				CAA->ChipType = 0x07;
				CAA->Paired = &CA_Paired[CurChip][0x01];
				CAA->Paired->ChipType = 0x80 | CAA->ChipType;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_ym2608(CurChip, ChipClk, COpt->SpecialFlags & 0x01,
													VGMHead.bytAYFlagYM2608,
													(int*)&CAA->Paired->SmpRate);
				CAA->StreamUpdate = &ym2608_stream_update;
				CAA->Paired->StreamUpdate = &ym2608_stream_update_ay;
				ym2608_set_srchg_cb(CurChip, &ChangeChipSampleRate, CAA, CAA->Paired);
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				CAA->Paired->Volume = GetChipVolume(&VGMHead, CAA->Paired->ChipType,
													CurChip, ChipCnt);
				AbsVol += CAA->Volume + CAA->Paired->Volume;
				//CAA->Volume = ChipVol;
				//CAA->Paired->Volume = ChipVol * 2;
			}
		}
		if (VGMHead.lngHzYM2610)
		{
			//ChipVol = 0x80;
			ym2610_set_ay_emu_core(ChipOpts[0x00].YM2610.EmuCore);
			ChipOpts[0x01].YM2610.EmuCore = ChipOpts[0x00].YM2610.EmuCore;
			ChipOpts[0x01].YM2610.SpecialFlags = ChipOpts[0x00].YM2610.SpecialFlags;
			
			ChipCnt = (VGMHead.lngHzYM2610 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YM2610;
				COpt = &ChipOpts[CurChip].YM2610;
				CAA->ChipType = 0x08;
				CAA->Paired = &CA_Paired[CurChip][0x02];
				CAA->Paired->ChipType = 0x80 | CAA->ChipType;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_ym2610(CurChip, ChipClk, COpt->SpecialFlags & 0x01,
													(int*)&CAA->Paired->SmpRate);
				CAA->StreamUpdate = (ChipClk & 0x80000000) ? ym2610b_stream_update :
															ym2610_stream_update;
				CAA->Paired->StreamUpdate = &ym2610_stream_update_ay;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				CAA->Paired->Volume = GetChipVolume(&VGMHead, CAA->Paired->ChipType,
													CurChip, ChipCnt);
				AbsVol += CAA->Volume + CAA->Paired->Volume;
				//CAA->Volume = ChipVol;
				//CAA->Paired->Volume = ChipVol * 2;
			}
		}
		if (VGMHead.lngHzYM3812)
		{
			//ChipVol = UseFM ? 0x00 : 0x100;
			ym3812_set_emu_core(ChipOpts[0x00].YM3812.EmuCore);
			ChipOpts[0x01].YM3812.EmuCore = ChipOpts[0x00].YM3812.EmuCore;
			
			ChipCnt = (VGMHead.lngHzYM3812 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YM3812;
				CAA->ChipType = 0x09;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				if (! UseFM)
				{
					CAA->SmpRate = device_start_ym3812(CurChip, ChipClk);
					CAA->StreamUpdate = (ChipClk & 0x80000000) ? dual_opl2_stereo :
																ym3812_stream_update;
					
					CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
					if (! CurChip || ! (ChipClk & 0x80000000))
						AbsVol += CAA->Volume * 2;
				}
				else
				{
					setup_real_fm(CAA->ChipType, CurChip);
					
					CAA->SmpRate = 0x00000000;
					CAA->Volume = 0x0000;
				}
			}
		}
		if (VGMHead.lngHzYM3526)
		{
			//ChipVol = UseFM ? 0x00 : 0x100;
			ChipCnt = (VGMHead.lngHzYM3526 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YM3526;
				CAA->ChipType = 0x0A;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				if (! UseFM)
				{
					CAA->SmpRate = device_start_ym3526(CurChip, ChipClk);
					CAA->StreamUpdate = &ym3526_stream_update;
					
					CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
					AbsVol += CAA->Volume * 2;
				}
				else
				{
					setup_real_fm(CAA->ChipType, CurChip);
					
					CAA->SmpRate = 0x00000000;
					CAA->Volume = 0x0000;
				}
			}
		}
		if (VGMHead.lngHzY8950)
		{
			//ChipVol = UseFM ? 0x00 : 0x100;
			ChipCnt = (VGMHead.lngHzY8950 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].Y8950;
				CAA->ChipType = 0x0B;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				if (! UseFM)
				{
					CAA->SmpRate = device_start_y8950(CurChip, ChipClk);
					CAA->StreamUpdate = &y8950_stream_update;
					
					CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
					AbsVol += CAA->Volume * 2;
				}
				else
				{
					setup_real_fm(CAA->ChipType, CurChip);
					
					CAA->SmpRate = 0x00000000;
					CAA->Volume = 0x0000;
				}
			}
		}
		if (VGMHead.lngHzYMF262)
		{
			//ChipVol = UseFM ? 0x00 : 0x100;
			ymf262_set_emu_core(ChipOpts[0x00].YMF262.EmuCore);
			ChipOpts[0x01].YMF262.EmuCore = ChipOpts[0x00].YMF262.EmuCore;
			
			ChipCnt = (VGMHead.lngHzYMF262 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YMF262;
				CAA->ChipType = 0x0C;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				if (! UseFM)
				{
					CAA->SmpRate = device_start_ymf262(CurChip, ChipClk);
					CAA->StreamUpdate = &ymf262_stream_update;
					
					CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
					AbsVol += CAA->Volume * 2;
				}
				else
				{
					setup_real_fm(CAA->ChipType, CurChip);
					
					CAA->SmpRate = 0x00000000;
					CAA->Volume = 0x0000;
				}
			}
		}
		if (VGMHead.lngHzYMF278B)
		{
			//ChipVol = 0x100;
			ChipCnt = (VGMHead.lngHzYMF278B & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YMF278B;
				CAA->ChipType = 0x0D;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_ymf278b(CurChip, ChipClk);
				CAA->StreamUpdate = &ymf278b_pcm_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;	//good as long as it only uses WaveTable Synth
			}
		}
		if (VGMHead.lngHzYMF271)
		{
			//ChipVol = 0x100;
			ChipCnt = (VGMHead.lngHzYMF271 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YMF271;
				CAA->ChipType = 0x0E;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_ymf271(CurChip, ChipClk);
				CAA->StreamUpdate = &ymf271_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzYMZ280B)
		{
			//ChipVol = 0x98;
			ChipCnt = (VGMHead.lngHzYMZ280B & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].YMZ280B;
				CAA->ChipType = 0x0F;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_ymz280b(CurChip, ChipClk);
				CAA->StreamUpdate = &ymz280b_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += (CAA->Volume * 0x20 / 0x13);
			}
		}
		if (VGMHead.lngHzRF5C164)
		{
			//ChipVol = 0x80;
			ChipCnt = 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].RF5C164;
				CAA->ChipType = 0x10;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_rf5c164(CurChip, ChipClk);
				CAA->StreamUpdate = &rf5c164_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume * 2;
			}
		}
		if (VGMHead.lngHzPWM)
		{
			//ChipVol = 0xE0;	// 0xCD
			ChipCnt = 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].PWM;
				CAA->ChipType = 0x11;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_pwm(CurChip, ChipClk);
				CAA->StreamUpdate = &pwm_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzAY8910)
		{
			//ChipVol = 0x100;
			ayxx_set_emu_core(ChipOpts[0x00].AY8910.EmuCore);
			ChipOpts[0x01].AY8910.EmuCore = ChipOpts[0x00].AY8910.EmuCore;
			
			ChipCnt = (VGMHead.lngHzAY8910 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].AY8910;
				CAA->ChipType = 0x12;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				if (! UseFM)
				{
					CAA->SmpRate = device_start_ayxx(CurChip, ChipClk,
													VGMHead.bytAYType, VGMHead.bytAYFlag);
					CAA->StreamUpdate = &ayxx_stream_update;
					
					CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
					AbsVol += CAA->Volume * 2;
				}
				else
				{
					open_fm_option(CAA->ChipType, 0x00, ChipClk);
					open_fm_option(CAA->ChipType, 0x01, VGMHead.bytAYType);
					open_fm_option(CAA->ChipType, 0x02, VGMHead.bytAYFlag);
					setup_real_fm(CAA->ChipType, CurChip);
					
					CAA->SmpRate = 0x00000000;
					CAA->Volume = 0x0000;
				}
			}
		}
		if (VGMHead.lngHzGBDMG)
		{
			//ChipVol = 0xC0;
			gameboy_sound_set_options((UINT8)ChipOpts[0x00].GameBoy.SpecialFlags);
			ChipOpts[0x01].GameBoy.SpecialFlags = ChipOpts[0x00].GameBoy.SpecialFlags;
			
			ChipCnt = (VGMHead.lngHzGBDMG & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].GameBoy;
				CAA->ChipType = 0x13;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_gameboy_sound(CurChip, ChipClk);
				CAA->StreamUpdate = &gameboy_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume * 2;
			}
		}
		if (VGMHead.lngHzNESAPU)
		{
			//ChipVol = 0x100;
			nes_set_emu_core(ChipOpts[0x00].NES.EmuCore);
			nes_set_options(ChipOpts[0x00].NES.SpecialFlags);
			ChipOpts[0x01].NES.EmuCore = ChipOpts[0x00].NES.EmuCore;
			ChipOpts[0x01].NES.SpecialFlags = ChipOpts[0x00].NES.SpecialFlags;
			
			ChipCnt = (VGMHead.lngHzNESAPU & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].NES;
				CAA->ChipType = 0x14;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_nes(CurChip, ChipClk);
				CAA->StreamUpdate = &nes_stream_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume * 2;
			}
		}
		if (VGMHead.lngHzMultiPCM)
		{
			//ChipVol = 0x40;
			ChipCnt = (VGMHead.lngHzMultiPCM & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].MultiPCM;
				CAA->ChipType = 0x15;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_multipcm(CurChip, ChipClk);
				CAA->StreamUpdate = &MultiPCM_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume * 4;
			}
		}
		if (VGMHead.lngHzUPD7759)
		{
			//ChipVol = 0x11E;
			ChipCnt = (VGMHead.lngHzUPD7759 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].UPD7759;
				CAA->ChipType = 0x16;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_upd7759(CurChip, ChipClk);
				CAA->StreamUpdate = &upd7759_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzOKIM6258)
		{
			//ChipVol = 0x1C0;
			okim6258_set_options(ChipOpts[0x00].OKIM6258.SpecialFlags);
			ChipOpts[0x01].OKIM6258.SpecialFlags = ChipOpts[0x00].OKIM6258.SpecialFlags;
			
			ChipCnt = (VGMHead.lngHzOKIM6258 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].OKIM6258;
				CAA->ChipType = 0x17;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_okim6258(CurChip, ChipClk,
													(VGMHead.bytOKI6258Flags & 0x03) >> 0,
													(VGMHead.bytOKI6258Flags & 0x04) >> 2,
													(VGMHead.bytOKI6258Flags & 0x08) >> 3);
				CAA->StreamUpdate = &okim6258_update;
				okim6258_set_srchg_cb(CurChip, &ChangeChipSampleRate, CAA);
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume * 2;
			}
		}
		if (VGMHead.lngHzOKIM6295)
		{
			/*// Use the System Tag to decide between normal and CP System volume level.
			// I know, this is very hackish, but ATM there's no better solution.
			if (VGMTag.strSystemNameE != NULL && ! wcsncmp(VGMTag.strSystemNameE, L"CP", 0x02))
				ChipVol = 110;
			else
				ChipVol = 0x100;*/
			ChipCnt = (VGMHead.lngHzOKIM6295 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].OKIM6295;
				CAA->ChipType = 0x18;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_okim6295(CurChip, ChipClk);
				CAA->StreamUpdate = &okim6295_update;
				okim6295_set_srchg_cb(CurChip, &ChangeChipSampleRate, CAA);
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume * 2;
			}
		}
		if (VGMHead.lngHzK051649)
		{
			//ChipVol = 0xA0;
			ChipCnt = (VGMHead.lngHzK051649 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].K051649;
				CAA->ChipType = 0x19;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_k051649(CurChip, ChipClk);
				CAA->StreamUpdate = &k051649_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzK054539)
		{
			//ChipVol = 0x100;
			ChipCnt = (VGMHead.lngHzK054539 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].K054539;
				CAA->ChipType = 0x1A;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_k054539(CurChip, ChipClk);
				CAA->StreamUpdate = &k054539_update;
				k054539_init_flags(CurChip, VGMHead.bytK054539Flags);
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzHuC6280)
		{
			//ChipVol = 0x100;
			c6280_set_emu_core(ChipOpts[0x00].HuC6280.EmuCore);
			ChipOpts[0x01].HuC6280.EmuCore = ChipOpts[0x00].HuC6280.EmuCore;
			
			ChipCnt = (VGMHead.lngHzHuC6280 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].HuC6280;
				CAA->ChipType = 0x1B;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_c6280(CurChip, ChipClk);
				CAA->StreamUpdate = &c6280_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzC140)
		{
			//ChipVol = 0x100;
			ChipCnt = (VGMHead.lngHzC140 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].C140;
				CAA->ChipType = 0x1C;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_c140(CurChip, ChipClk, VGMHead.bytC140Type);
				CAA->StreamUpdate = &c140_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzK053260)
		{
			//ChipVol = 0xB3;
			ChipCnt = (VGMHead.lngHzK053260 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].K053260;
				CAA->ChipType = 0x1D;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_k053260(CurChip, ChipClk);
				CAA->StreamUpdate = &k053260_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzPokey)
		{
			//ChipVol = 0x100;
			ChipCnt = (VGMHead.lngHzPokey & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].Pokey;
				CAA->ChipType = 0x1E;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_pokey(CurChip, ChipClk);
				CAA->StreamUpdate = &pokey_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzQSound)
		{
			qsound_set_emu_core(ChipOpts[0x00].QSound.EmuCore);
			ChipOpts[0x01].QSound.EmuCore = ChipOpts[0x00].QSound.EmuCore;
			
			//ChipVol = 0x100;
			ChipCnt = (VGMHead.lngHzQSound & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].QSound;
				CAA->ChipType = 0x1F;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_qsound(CurChip, ChipClk);
				CAA->StreamUpdate = &qsound_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzSCSP)
		{
			scsp_set_options((UINT8)ChipOpts[0x00].SCSP.SpecialFlags);
			ChipOpts[0x01].SCSP.SpecialFlags = ChipOpts[0x00].SCSP.SpecialFlags;
			
			//ChipVol = 0x20;
			ChipCnt = (VGMHead.lngHzSCSP & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].SCSP;
				CAA->ChipType = 0x20;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_scsp(CurChip, ChipClk);
				CAA->StreamUpdate = &SCSP_Update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume * 8;
			}
		}
		if (VGMHead.lngHzWSwan)
		{
			//ChipVol = 0x100;
			ChipCnt = (VGMHead.lngHzWSwan & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].WSwan;
				CAA->ChipType = 0x21;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = ws_audio_init(CurChip, ChipClk);
				CAA->StreamUpdate = &ws_audio_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzVSU)
		{
			//ChipVol = 0x100;
			ChipCnt = (VGMHead.lngHzVSU & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].VSU;
				CAA->ChipType = 0x22;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_vsu(CurChip, ChipClk);
				CAA->StreamUpdate = &vsu_stream_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzSAA1099)
		{
			//ChipVol = 0x100;
			ChipCnt = (VGMHead.lngHzSAA1099 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].SAA1099;
				CAA->ChipType = 0x23;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_saa1099(CurChip, ChipClk);
				CAA->StreamUpdate = &saa1099_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzES5503)
		{
			//ChipVol = 0x40;
			ChipCnt = (VGMHead.lngHzES5503 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].ES5503;
				CAA->ChipType = 0x24;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_es5503(CurChip, ChipClk, VGMHead.bytES5503Chns);
				CAA->StreamUpdate = &es5503_pcm_update;
				es5503_set_srchg_cb(CurChip, &ChangeChipSampleRate, CAA);
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume * 8;
			}
		}
		if (VGMHead.lngHzES5506)
		{
			//ChipVol = 0x20;
			ChipCnt = (VGMHead.lngHzES5506 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].ES5506;
				CAA->ChipType = 0x25;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_es5506(CurChip, ChipClk, VGMHead.bytES5506Chns);
				CAA->StreamUpdate = &es5506_update;
				es5506_set_srchg_cb(CurChip, &ChangeChipSampleRate, CAA);
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume * 16;
			}
		}
		if (VGMHead.lngHzX1_010)
		{
			//ChipVol = 0x100;
			ChipCnt = (VGMHead.lngHzX1_010 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].X1_010;
				CAA->ChipType = 0x26;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_x1_010(CurChip, ChipClk);
				CAA->StreamUpdate = &seta_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		if (VGMHead.lngHzC352)
		{
			c352_set_options((UINT8)ChipOpts[0x00].C352.SpecialFlags);
			ChipOpts[0x01].C352.SpecialFlags = ChipOpts[0x00].C352.SpecialFlags;
			
			//ChipVol = 0x40;
			ChipCnt = (VGMHead.lngHzC352 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].C352;
				CAA->ChipType = 0x27;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_c352(CurChip, ChipClk, VGMHead.bytC352ClkDiv * 4);
				CAA->StreamUpdate = &c352_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume * 8;
			}
		}
		if (VGMHead.lngHzGA20)
		{
			//ChipVol = 0x280;
			ChipCnt = (VGMHead.lngHzGA20 & 0x40000000) ? 0x02 : 0x01;
			for (CurChip = 0x00; CurChip < ChipCnt; CurChip ++)
			{
				CAA = &ChipAudio[CurChip].GA20;
				CAA->ChipType = 0x28;
				
				ChipClk = GetChipClock(&VGMHead, (CurChip << 7) | CAA->ChipType, NULL);
				CAA->SmpRate = device_start_iremga20(CurChip, ChipClk);
				CAA->StreamUpdate = &IremGA20_update;
				
				CAA->Volume = GetChipVolume(&VGMHead, CAA->ChipType, CurChip, ChipCnt);
				AbsVol += CAA->Volume;
			}
		}
		
		// Initialize DAC Control and PCM Bank
		DacCtrlUsed = 0x00;
		//memset(DacCtrlUsg, 0x00, 0x01 * 0xFF);
		for (CurChip = 0x00; CurChip < 0xFF; CurChip ++)
		{
			DacCtrl[CurChip].Enable = false;
		}
		//memset(DacCtrl, 0x00, sizeof(DACCTRL_DATA) * 0xFF);
		
		memset(PCMBank, 0x00, sizeof(VGM_PCM_BANK) * PCM_BANK_COUNT);
		memset(&PCMTbl, 0x00, sizeof(PCMBANK_TBL));
		
		// Reset chips
		Chips_GeneralActions(0x01);
		
		while(AbsVol < 0x200 && AbsVol)
		{
			for (CurCSet = 0x00; CurCSet < 0x02; CurCSet ++)
			{
				CAA = (CAUD_ATTR*)&ChipAudio[CurCSet];
				for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++, CAA ++)
					CAA->Volume *= 2;
				CAA = CA_Paired[CurCSet];
				for (CurChip = 0x00; CurChip < 0x03; CurChip ++, CAA ++)
					CAA->Volume *= 2;
			}
			AbsVol *= 2;
		}
		while(AbsVol > 0x300)
		{
			for (CurCSet = 0x00; CurCSet < 0x02; CurCSet ++)
			{
				CAA = (CAUD_ATTR*)&ChipAudio[CurCSet];
				for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++, CAA ++)
					CAA->Volume /= 2;
				CAA = CA_Paired[CurCSet];
				for (CurChip = 0x00; CurChip < 0x03; CurChip ++, CAA ++)
					CAA->Volume /= 2;
			}
			AbsVol /= 2;
		}
		
		// Initialize Resampler
		for (CurCSet = 0x00; CurCSet < 0x02; CurCSet ++)
		{
			CAA = (CAUD_ATTR*)&ChipAudio[CurCSet];
			for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++, CAA ++)
				SetupResampler(CAA);
			
			CAA = CA_Paired[CurCSet];
			for (CurChip = 0x00; CurChip < 0x03; CurChip ++, CAA ++)
				SetupResampler(CAA);
		}
		
		GeneralChipLists();
		break;
	case 0x01:	// Reset chips
		for (CurCSet = 0x00; CurCSet < 0x02; CurCSet ++)
		{
		
		CAA = (CAUD_ATTR*)&ChipAudio[CurCSet];
		for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++, CAA ++)
		{
			if (CAA->ChipType == 0xFF)	// chip unused
				continue;
			else if (CAA->ChipType == 0x00 && ! UseFM)
				device_reset_sn764xx(CurCSet);
			else if (CAA->ChipType == 0x01 && ! UseFM)
				device_reset_ym2413(CurCSet);
			else if (CAA->ChipType == 0x02)
				device_reset_ym2612(CurCSet);
			else if (CAA->ChipType == 0x03)
				device_reset_ym2151(CurCSet);
			else if (CAA->ChipType == 0x04)
				device_reset_segapcm(CurCSet);
			else if (CAA->ChipType == 0x05)
				device_reset_rf5c68(CurCSet);
			else if (CAA->ChipType == 0x06)
				device_reset_ym2203(CurCSet);
			else if (CAA->ChipType == 0x07)
				device_reset_ym2608(CurCSet);
			else if (CAA->ChipType == 0x08)
				device_reset_ym2610(CurCSet);
			else if (CAA->ChipType == 0x09)
			{
				if (! UseFM)
				{
					device_reset_ym3812(CurCSet);
				}
				if (FileMode == 0x01)
				{
					chip_reg_write(0x09, CurCSet, 0x00, 0x01, 0x20);	// Enable Waveform Select
					chip_reg_write(0x09, CurCSet, 0x00, 0xBD, 0xC0);	// Disable Rhythm Mode
				}
			}
			else if (CAA->ChipType == 0x0A && ! UseFM)
				device_reset_ym3526(CurCSet);
			else if (CAA->ChipType == 0x0B && ! UseFM)
				device_reset_y8950(CurCSet);
			else if (CAA->ChipType == 0x0C)
			{
				if (! UseFM)
				{
					device_reset_ymf262(CurCSet);
				}
				if (FileMode >= 0x01)
				{
					chip_reg_write(0x0C, CurCSet, 0x01, 0x05, 0x01);	// Enable OPL3-Mode
					chip_reg_write(0x0C, CurCSet, 0x00, 0xBD, 0xC0);	// Disable Rhythm Mode
					chip_reg_write(0x0C, CurCSet, 0x01, 0x04, 0x00);	// Disable 4-Op-Mode
				}
			}
			else if (CAA->ChipType == 0x0D)
				device_reset_ymf278b(CurCSet);
			else if (CAA->ChipType == 0x0E)
				device_reset_ymf271(CurCSet);
			else if (CAA->ChipType == 0x0F)
				device_reset_ymz280b(CurCSet);
			else if (CAA->ChipType == 0x10)
				device_reset_rf5c164(CurCSet);
			else if (CAA->ChipType == 0x11)
				device_reset_pwm(CurCSet);
			else if (CAA->ChipType == 0x12 && ! UseFM)
				device_reset_ayxx(CurCSet);
			else if (CAA->ChipType == 0x13)
				device_reset_gameboy_sound(CurCSet);
			else if (CAA->ChipType == 0x14)
				device_reset_nes(CurCSet);
			else if (CAA->ChipType == 0x15)
				device_reset_multipcm(CurCSet);
			else if (CAA->ChipType == 0x16)
				device_reset_upd7759(CurCSet);
			else if (CAA->ChipType == 0x17)
				device_reset_okim6258(CurCSet);
			else if (CAA->ChipType == 0x18)
				device_reset_okim6295(CurCSet);
			else if (CAA->ChipType == 0x19)
				device_reset_k051649(CurCSet);
			else if (CAA->ChipType == 0x1A)
				device_reset_k054539(CurCSet);
			else if (CAA->ChipType == 0x1B)
				device_reset_c6280(CurCSet);
			else if (CAA->ChipType == 0x1C)
				device_reset_c140(CurCSet);
			else if (CAA->ChipType == 0x1D)
				device_reset_k053260(CurCSet);
			else if (CAA->ChipType == 0x1E)
				device_reset_pokey(CurCSet);
			else if (CAA->ChipType == 0x1F)
				device_reset_qsound(CurCSet);
			else if (CAA->ChipType == 0x20)
				device_reset_scsp(CurCSet);
			else if (CAA->ChipType == 0x21)
				ws_audio_reset(CurCSet);
			else if (CAA->ChipType == 0x22)
				device_reset_vsu(CurCSet);
			else if (CAA->ChipType == 0x23)
				device_reset_saa1099(CurCSet);
			else if (CAA->ChipType == 0x24)
				device_reset_es5503(CurCSet);
			else if (CAA->ChipType == 0x25)
				device_reset_es5506(CurCSet);
			else if (CAA->ChipType == 0x26)
				device_reset_x1_010(CurCSet);
			else if (CAA->ChipType == 0x27)
				device_reset_c352(CurCSet);
			else if (CAA->ChipType == 0x28)
				device_reset_iremga20(CurCSet);
		}	// end for CurChip
		
		}	// end for CurCSet
		
		Chips_GeneralActions(0x10);	// set muting mask
		Chips_GeneralActions(0x20);	// set panning
		
		for (CurChip = 0x00; CurChip < DacCtrlUsed; CurChip ++)
		{
			CurCSet = DacCtrlUsg[CurChip];
			device_reset_daccontrol(CurCSet);
			//DacCtrl[CurCSet].Enable = false;
		}
		//DacCtrlUsed = 0x00;
		//memset(DacCtrlUsg, 0x00, 0x01 * 0xFF);
		
		for (CurChip = 0x00; CurChip < PCM_BANK_COUNT; CurChip ++)
		{
			// reset PCM Bank, but not the data
			// (this way I don't need to decompress the data again when restarting)
			PCMBank[CurChip].DataPos = 0x00000000;
			PCMBank[CurChip].BnkPos = 0x00000000;
		}
		PCMTbl.EntryCount = 0x00;
		break;
	case 0x02:	// Stop chips
		for (CurCSet = 0x00; CurCSet < 0x02; CurCSet ++)
		{
		
		CAA = (CAUD_ATTR*)&ChipAudio[CurCSet];
		for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++, CAA ++)
		{
			if (CAA->ChipType == 0xFF)	// chip unused
				continue;
			else if (CAA->ChipType == 0x00 && ! UseFM)
				device_stop_sn764xx(CurCSet);
			else if (CAA->ChipType == 0x01 && ! UseFM)
				device_stop_ym2413(CurCSet);
			else if (CAA->ChipType == 0x02)
				device_stop_ym2612(CurCSet);
			else if (CAA->ChipType == 0x03)
				device_stop_ym2151(CurCSet);
			else if (CAA->ChipType == 0x04)
				device_stop_segapcm(CurCSet);
			else if (CAA->ChipType == 0x05)
				device_stop_rf5c68(CurCSet);
			else if (CAA->ChipType == 0x06)
				device_stop_ym2203(CurCSet);
			else if (CAA->ChipType == 0x07)
				device_stop_ym2608(CurCSet);
			else if (CAA->ChipType == 0x08)
				device_stop_ym2610(CurCSet);
			else if (CAA->ChipType == 0x09 && ! UseFM)
				device_stop_ym3812(CurCSet);
			else if (CAA->ChipType == 0x0A && ! UseFM)
				device_stop_ym3526(CurCSet);
			else if (CAA->ChipType == 0x0B && ! UseFM)
				device_stop_y8950(CurCSet);
			else if (CAA->ChipType == 0x0C && ! UseFM)
				device_stop_ymf262(CurCSet);
			else if (CAA->ChipType == 0x0D)
				device_stop_ymf278b(CurCSet);
			else if (CAA->ChipType == 0x0E)
				device_stop_ymf271(CurCSet);
			else if (CAA->ChipType == 0x0F)
				device_stop_ymz280b(CurCSet);
			else if (CAA->ChipType == 0x10)
				device_stop_rf5c164(CurCSet);
			else if (CAA->ChipType == 0x11)
				device_stop_pwm(CurCSet);
			else if (CAA->ChipType == 0x12 && ! UseFM)
				device_stop_ayxx(CurCSet);
			else if (CAA->ChipType == 0x13)
				device_stop_gameboy_sound(CurCSet);
			else if (CAA->ChipType == 0x14)
				device_stop_nes(CurCSet);
			else if (CAA->ChipType == 0x15)
				device_stop_multipcm(CurCSet);
			else if (CAA->ChipType == 0x16)
				device_stop_upd7759(CurCSet);
			else if (CAA->ChipType == 0x17)
				device_stop_okim6258(CurCSet);
			else if (CAA->ChipType == 0x18)
				device_stop_okim6295(CurCSet);
			else if (CAA->ChipType == 0x19)
				device_stop_k051649(CurCSet);
			else if (CAA->ChipType == 0x1A)
				device_stop_k054539(CurCSet);
			else if (CAA->ChipType == 0x1B)
				device_stop_c6280(CurCSet);
			else if (CAA->ChipType == 0x1C)
				device_stop_c140(CurCSet);
			else if (CAA->ChipType == 0x1D)
				device_stop_k053260(CurCSet);
			else if (CAA->ChipType == 0x1E)
				device_stop_pokey(CurCSet);
			else if (CAA->ChipType == 0x1F)
				device_stop_qsound(CurCSet);
			else if (CAA->ChipType == 0x20)
				device_stop_scsp(CurCSet);
			else if (CAA->ChipType == 0x21)
				ws_audio_done(CurCSet);
			else if (CAA->ChipType == 0x22)
				device_stop_vsu(CurCSet);
			else if (CAA->ChipType == 0x23)
				device_stop_saa1099(CurCSet);
			else if (CAA->ChipType == 0x24)
				device_stop_es5503(CurCSet);
			else if (CAA->ChipType == 0x25)
				device_stop_es5506(CurCSet);
			else if (CAA->ChipType == 0x26)
				device_stop_x1_010(CurCSet);
			else if (CAA->ChipType == 0x27)
				device_stop_c352(CurCSet);
			else if (CAA->ChipType == 0x28)
				device_stop_iremga20(CurCSet);
			
			CAA->ChipType = 0xFF;	// mark as "unused"
		}	// end for CurChip
		
		}	// end for CurCSet
		
		for (CurChip = 0x00; CurChip < DacCtrlUsed; CurChip ++)
		{
			CurCSet = DacCtrlUsg[CurChip];
			device_stop_daccontrol(CurCSet);
			DacCtrl[CurCSet].Enable = false;
		}
		DacCtrlUsed = 0x00;
		
		for (CurChip = 0x00; CurChip < PCM_BANK_COUNT; CurChip ++)
		{
			free(PCMBank[CurChip].Bank);
			free(PCMBank[CurChip].Data);
		}
		//memset(PCMBank, 0x00, sizeof(VGM_PCM_BANK) * PCM_BANK_COUNT);
		free(PCMTbl.Entries);
		//memset(&PCMTbl, 0x00, sizeof(PCMBANK_TBL));
		break;
	case 0x10:	// Set Muting Mask
		for (CurCSet = 0x00; CurCSet < 0x02; CurCSet ++)
		{
		
		CAA = (CAUD_ATTR*)&ChipAudio[CurCSet];
		for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++, CAA ++)
		{
			if (CAA->ChipType == 0xFF)	// chip unused
				continue;
			else if (CAA->ChipType == 0x00 && ! UseFM)
				sn764xx_set_mute_mask(CurCSet, ChipOpts[CurCSet].SN76496.ChnMute1);
			else if (CAA->ChipType == 0x01 && ! UseFM)
				ym2413_set_mute_mask(CurCSet, ChipOpts[CurCSet].YM2413.ChnMute1);
			else if (CAA->ChipType == 0x02)
				ym2612_set_mute_mask(CurCSet, ChipOpts[CurCSet].YM2612.ChnMute1);
			else if (CAA->ChipType == 0x03)
				ym2151_set_mute_mask(CurCSet, ChipOpts[CurCSet].YM2151.ChnMute1);
			else if (CAA->ChipType == 0x04)
				segapcm_set_mute_mask(CurCSet, ChipOpts[CurCSet].SegaPCM.ChnMute1);
			else if (CAA->ChipType == 0x05)
				rf5c68_set_mute_mask(CurCSet, ChipOpts[CurCSet].RF5C68.ChnMute1);
			else if (CAA->ChipType == 0x06)
				ym2203_set_mute_mask(CurCSet, ChipOpts[CurCSet].YM2203.ChnMute1,
									ChipOpts[CurCSet].YM2203.ChnMute3);
			else if (CAA->ChipType == 0x07)
			{
				MaskVal  = (ChipOpts[CurCSet].YM2608.ChnMute1 & 0x3F) << 0;
				MaskVal |= (ChipOpts[CurCSet].YM2608.ChnMute2 & 0x7F) << 6;
				ym2608_set_mute_mask(CurCSet, MaskVal, ChipOpts[CurCSet].YM2608.ChnMute3);
			}
			else if (CAA->ChipType == 0x08)
			{
				MaskVal  = (ChipOpts[CurCSet].YM2610.ChnMute1 & 0x3F) << 0;
				MaskVal |= (ChipOpts[CurCSet].YM2610.ChnMute2 & 0x7F) << 6;
				ym2610_set_mute_mask(CurCSet, MaskVal, ChipOpts[CurCSet].YM2610.ChnMute3);
			}
			else if (CAA->ChipType == 0x09 && ! UseFM)
				ym3812_set_mute_mask(CurCSet, ChipOpts[CurCSet].YM3812.ChnMute1);
			else if (CAA->ChipType == 0x0A && ! UseFM)
				ym3526_set_mute_mask(CurCSet, ChipOpts[CurCSet].YM3526.ChnMute1);
			else if (CAA->ChipType == 0x0B && ! UseFM)
				y8950_set_mute_mask(CurCSet, ChipOpts[CurCSet].Y8950.ChnMute1);
			else if (CAA->ChipType == 0x0C && ! UseFM)
				ymf262_set_mute_mask(CurCSet, ChipOpts[CurCSet].YMF262.ChnMute1);
			else if (CAA->ChipType == 0x0D)
				ymf278b_set_mute_mask(CurCSet, ChipOpts[CurCSet].YMF278B.ChnMute1,
										ChipOpts[CurCSet].YMF278B.ChnMute2);
			else if (CAA->ChipType == 0x0E)
				ymf271_set_mute_mask(CurCSet, ChipOpts[CurCSet].YMF271.ChnMute1);
			else if (CAA->ChipType == 0x0F)
				ymz280b_set_mute_mask(CurCSet, ChipOpts[CurCSet].YMZ280B.ChnMute1);
			else if (CAA->ChipType == 0x10)
				rf5c164_set_mute_mask(CurCSet, ChipOpts[CurCSet].RF5C164.ChnMute1);
			else if (CAA->ChipType == 0x11)
				;	// PWM - nothing to mute
			else if (CAA->ChipType == 0x12 && ! UseFM)
				ayxx_set_mute_mask(CurCSet, ChipOpts[CurCSet].AY8910.ChnMute1);
			else if (CAA->ChipType == 0x13)
				gameboy_sound_set_mute_mask(CurCSet, ChipOpts[CurCSet].GameBoy.ChnMute1);
			else if (CAA->ChipType == 0x14)
				nes_set_mute_mask(CurCSet, ChipOpts[CurCSet].NES.ChnMute1);
			else if (CAA->ChipType == 0x15)
				multipcm_set_mute_mask(CurCSet, ChipOpts[CurCSet].MultiPCM.ChnMute1);
			else if (CAA->ChipType == 0x16)
				;	// UPD7759 - nothing to mute
			else if (CAA->ChipType == 0x17)
				;	// OKIM6258 - nothing to mute
			else if (CAA->ChipType == 0x18)
				okim6295_set_mute_mask(CurCSet, ChipOpts[CurCSet].OKIM6295.ChnMute1);
			else if (CAA->ChipType == 0x19)
				k051649_set_mute_mask(CurCSet, ChipOpts[CurCSet].K051649.ChnMute1);
			else if (CAA->ChipType == 0x1A)
				k054539_set_mute_mask(CurCSet, ChipOpts[CurCSet].K054539.ChnMute1);
			else if (CAA->ChipType == 0x1B)
				c6280_set_mute_mask(CurCSet, ChipOpts[CurCSet].HuC6280.ChnMute1);
			else if (CAA->ChipType == 0x1C)
				c140_set_mute_mask(CurCSet, ChipOpts[CurCSet].C140.ChnMute1);
			else if (CAA->ChipType == 0x1D)
				k053260_set_mute_mask(CurCSet, ChipOpts[CurCSet].K053260.ChnMute1);
			else if (CAA->ChipType == 0x1E)
				pokey_set_mute_mask(CurCSet, ChipOpts[CurCSet].Pokey.ChnMute1);
			else if (CAA->ChipType == 0x1F)
				qsound_set_mute_mask(CurCSet, ChipOpts[CurCSet].QSound.ChnMute1);
			else if (CAA->ChipType == 0x20)
				scsp_set_mute_mask(CurCSet, ChipOpts[CurCSet].SCSP.ChnMute1);
			else if (CAA->ChipType == 0x21)
				ws_set_mute_mask(CurCSet, ChipOpts[CurCSet].WSwan.ChnMute1);
			else if (CAA->ChipType == 0x22)
				vsu_set_mute_mask(CurCSet, ChipOpts[CurCSet].VSU.ChnMute1);
			else if (CAA->ChipType == 0x23)
				saa1099_set_mute_mask(CurCSet, ChipOpts[CurCSet].SAA1099.ChnMute1);
			else if (CAA->ChipType == 0x24)
				es5503_set_mute_mask(CurCSet, ChipOpts[CurCSet].ES5503.ChnMute1);
			else if (CAA->ChipType == 0x25)
				es5506_set_mute_mask(CurCSet, ChipOpts[CurCSet].ES5506.ChnMute1);
			else if (CAA->ChipType == 0x26)
				x1_010_set_mute_mask(CurCSet, ChipOpts[CurCSet].X1_010.ChnMute1);
			else if (CAA->ChipType == 0x27)
				c352_set_mute_mask(CurCSet, ChipOpts[CurCSet].C352.ChnMute1);
			else if (CAA->ChipType == 0x28)
				iremga20_set_mute_mask(CurCSet, ChipOpts[CurCSet].GA20.ChnMute1);
		}	// end for CurChip
		
		}	// end for CurCSet
		break;
	case 0x20:	// Set Panning
		for (CurCSet = 0x00; CurCSet < 0x02; CurCSet ++)
		{
		
		CAA = (CAUD_ATTR*)&ChipAudio[CurCSet];
		for (CurChip = 0x00; CurChip < CHIP_COUNT; CurChip ++, CAA ++)
		{
			if (CAA->ChipType == 0xFF)	// chip unused
				continue;
			else if (CAA->ChipType == 0x00 && ! UseFM)
				sn764xx_set_panning(CurCSet, ChipOpts[CurCSet].SN76496.Panning);
			else if (CAA->ChipType == 0x01 && ! UseFM)
				ym2413_set_panning(CurCSet, ChipOpts[CurCSet].YM2413.Panning);
		}	// end for CurChip
		
		}	// end for CurCSet
		break;
	}
	
	return;
}

INLINE INT32 SampleVGM2Pbk_I(INT32 SampleVal)
{
	return (INT32)((INT64)SampleVal * VGMSmplRateMul / VGMSmplRateDiv);
}

INLINE INT32 SamplePbk2VGM_I(INT32 SampleVal)
{
	return (INT32)((INT64)SampleVal * VGMSmplRateDiv / VGMSmplRateMul);
}

INT32 SampleVGM2Playback(INT32 SampleVal)
{
	return (INT32)((INT64)SampleVal * VGMSmplRateMul / VGMSmplRateDiv);
}

INT32 SamplePlayback2VGM(INT32 SampleVal)
{
	return (INT32)((INT64)SampleVal * VGMSmplRateDiv / VGMSmplRateMul);
}

static UINT8 StartThread(void)
{
#ifdef WIN32
	HANDLE PlayThreadHandle;
	DWORD PlayThreadID;
	//char TestStr[0x80];
	
	if (PlayThreadOpen)
		return 0xD0;	// Thread is already active
	
	PauseThread = true;
	ThreadNoWait = false;
	ThreadPauseConfrm = false;
	CloseThread = false;
	ThreadPauseEnable = true;
	
	PlayThreadHandle = CreateThread(NULL, 0x00, &PlayingThread, NULL, 0x00, &PlayThreadID);
	if (PlayThreadHandle == NULL)
		return 0xC8;		// CreateThread failed
	CloseHandle(PlayThreadHandle);
	
	PlayThreadOpen = true;
	//PauseThread = false;	is done after File Init
	
	return 0x00;
#else
	UINT32 RetVal;
	
	PauseThread = true;
	ThreadNoWait = false;
	ThreadPauseConfrm = false;
	CloseThread = false;
	ThreadPauseEnable = true;
	
	RetVal = pthread_create(&hPlayThread, NULL, &PlayingThread, NULL);
	if (RetVal)
		return 0xC8;		// CreateThread failed
	
	PlayThreadOpen = true;
	
	return 0x00;
#endif
}

static UINT8 StopThread(void)
{
#ifdef WIN32
	UINT16 Cnt;
#endif
	
	if (! PlayThreadOpen)
		return 0xD8;	// Thread is not active
	
#ifdef WIN32
	CloseThread = true;
	for (Cnt = 0; Cnt < 100; Cnt ++)
	{
		Sleep(1);
		if (hPlayThread == NULL)
			break;
	}
#else
	CloseThread = true;
	pthread_join(hPlayThread, NULL);
#endif
	PlayThreadOpen = false;
	ThreadPauseEnable = false;
	
	return 0x00;
}

#if defined(WIN32) && defined(MIXER_MUTING)
//static bool GetMixerControl(HMIXEROBJ hmixer, MIXERCONTROL* mxc)
static bool GetMixerControl(void)
{
	// This function attempts to obtain a mixer control. Returns True if successful.
	MIXERLINECONTROLS mxlc;
	MIXERLINE mxl;
	HGLOBAL hmem;
	MMRESULT RetVal;
	
	mxl.cbStruct = sizeof(MIXERLINE);
	mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER;
	// Obtain a line corresponding to the component type
	RetVal = mixerGetLineInfo((HMIXEROBJ)hmixer, &mxl, MIXER_GETLINEINFOF_COMPONENTTYPE);
	if (RetVal != MMSYSERR_NOERROR)
		return false;
	
	mxlc.cbStruct = sizeof(MIXERLINECONTROLS);
	mxlc.dwLineID = mxl.dwLineID;
	mxlc.dwControlID = MIXERCONTROL_CONTROLTYPE_MUTE;
	mxlc.cControls = 1;
	mxlc.cbmxctrl = sizeof(MIXERCONTROL);
	
	// Allocate a buffer for the control
	hmem = GlobalAlloc(0x40, sizeof(MIXERCONTROL));
	mxlc.pamxctrl = (MIXERCONTROL*)GlobalLock(hmem);
	mixctrl.cbStruct = sizeof(MIXERCONTROL);
	
	// Get the control
	RetVal = mixerGetLineControls((HMIXEROBJ)hmixer, &mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
	if (RetVal != MMSYSERR_NOERROR)
	{
		GlobalFree(hmem);
		return false;
	}
	
	// Copy the control into the destination structure
	//memcpy(mixctrl, mxlc.pamxctrl, sizeof(MIXERCONTROL));
	mixctrl = *mxlc.pamxctrl;
	GlobalFree(hmem);
	
	return true;
}
#endif

//static bool SetMuteControl(HMIXEROBJ hmixer, MIXERCONTROL* mxc, bool mute)
static bool SetMuteControl(bool mute)
{
#ifdef MIXER_MUTING

#ifdef WIN32
	MIXERCONTROLDETAILS mxcd;
	MIXERCONTROLDETAILS_UNSIGNED vol;
	HGLOBAL hmem;
	MMRESULT RetVal;
	
	mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
	mxcd.dwControlID = mixctrl.dwControlID;
	mxcd.cChannels = 1;
	mxcd.cMultipleItems = 0;
	mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
	
	hmem = GlobalAlloc(0x40, sizeof(MIXERCONTROLDETAILS_UNSIGNED));
	mxcd.paDetails = GlobalLock(hmem);
	vol.dwValue = mute;
	
	memcpy(mxcd.paDetails, &vol, sizeof(MIXERCONTROLDETAILS_UNSIGNED));
	RetVal = mixerSetControlDetails((HMIXEROBJ)hmixer, &mxcd, MIXER_SETCONTROLDETAILSF_VALUE);
	GlobalFree(hmem);
	
	if (RetVal != MMSYSERR_NOERROR)
		return false;
	
	return true;
#else
	UINT16 mix_vol;
	int RetVal;
	
	ioctl(hmixer, MIXER_READ(SOUND_MIXER_SYNTH), &mix_vol);
	if (mix_vol)
		mixer_vol = mix_vol;
	mix_vol = mute ? 0x0000: mixer_vol;
	
	RetVal = ioctl(hmixer, MIXER_WRITE(SOUND_MIXER_SYNTH), &mix_vol);
	
	return ! RetVal;
#endif

#else	//#indef MIXER_MUTING
	float TempVol;
	
	TempVol = MasterVol;
	if (TempVol > 0.0f)
		VolumeBak = TempVol;
	
	MasterVol = mute ? 0.0f : VolumeBak;
	FinalVol = VolumeLevelM * MasterVol * MasterVol;
	RefreshVolume();
	
	return true;
#endif
}



static void InterpretFile(UINT32 SampleCount)
{
	UINT32 TempLng;
	UINT8 CurChip;
	
	//if (Interpreting && SampleCount == 1)
	//	return;
	while(Interpreting)
		Sleep(1);
	
	if (DacCtrlUsed && SampleCount > 1)	// handle skipping
	{
		for (CurChip = 0x00; CurChip < DacCtrlUsed; CurChip ++)
		{
			daccontrol_update(DacCtrlUsg[CurChip], SampleCount - 1);
		}
	}
	
	Interpreting = true;
	if (! FileMode)
		InterpretVGM(SampleCount);
#ifdef ADDITIONAL_FORMATS
	else
		InterpretOther(SampleCount);
#endif
	
	if (DacCtrlUsed && SampleCount)
	{
		// calling this here makes "Emulating while Paused" nicer
		for (CurChip = 0x00; CurChip < DacCtrlUsed; CurChip ++)
		{
			daccontrol_update(DacCtrlUsg[CurChip], 1);
		}
	}
	
	if (UseFM && FadePlay)
	{
		//TempLng = PlayingTime % (SampleRate / 5);
		//if (! TempLng)
		TempLng = PlayingTime / (SampleRate / 5) -
					(PlayingTime + SampleCount) / (SampleRate / 5);
		if (TempLng)
			RefreshVolume();
	}
	if (AutoStopSkip && SampleCount)
	{
		StopSkipping();
		AutoStopSkip = false;
		ResetPBTimer = true;
	}
	
	if (! PausePlay || ForceVGMExec)
		VGMSmplPlayed += SampleCount;
	PlayingTime += SampleCount;
	
	//if (FadePlay && ! FadeTime)
	//	EndPlay = true;
	
	Interpreting = false;
	
	return;
}

static void AddPCMData(UINT8 Type, UINT32 DataSize, const UINT8* Data)
{
	UINT32 CurBnk;
	VGM_PCM_BANK* TempPCM;
	VGM_PCM_DATA* TempBnk;
	UINT32 BankSize;
	bool RetVal;
	UINT8 BnkType;
	UINT8 CurDAC;
	
	BnkType = Type & 0x3F;
	if (BnkType >= PCM_BANK_COUNT || VGMCurLoop)
		return;
	
	if (Type == 0x7F)
	{
		ReadPCMTable(DataSize, Data);
		return;
	}
	
	TempPCM = &PCMBank[BnkType];
	TempPCM->BnkPos ++;
	if (TempPCM->BnkPos <= TempPCM->BankCount)
		return;	// Speed hack for restarting playback (skip already loaded blocks)
	CurBnk = TempPCM->BankCount;
	TempPCM->BankCount ++;
	if (Last95Max != 0xFFFF)
		Last95Max = TempPCM->BankCount;
	TempPCM->Bank = (VGM_PCM_DATA*)realloc(TempPCM->Bank,
											sizeof(VGM_PCM_DATA) * TempPCM->BankCount);
	
	if (! (Type & 0x40))
		BankSize = DataSize;
	else
		BankSize = ReadLE32(&Data[0x01]);
	TempPCM->Data = realloc(TempPCM->Data, TempPCM->DataSize + BankSize);
	TempBnk = &TempPCM->Bank[CurBnk];
	TempBnk->DataStart = TempPCM->DataSize;
	if (! (Type & 0x40))
	{
		TempBnk->DataSize = DataSize;
		TempBnk->Data = TempPCM->Data + TempBnk->DataStart;
		memcpy(TempBnk->Data, Data, DataSize);
	}
	else
	{
		TempBnk->Data = TempPCM->Data + TempBnk->DataStart;
		RetVal = DecompressDataBlk(TempBnk, DataSize, Data);
		if (! RetVal)
		{
			TempBnk->Data = NULL;
			TempBnk->DataSize = 0x00;
			//return;
			goto RefreshDACStrm;	// sorry for the goto, but I don't want to copy-paste the code
		}
	}
	if (BankSize != TempBnk->DataSize)
		fprintf(stderr, "Error reading Data Block! Data Size conflict!\n");
	TempPCM->DataSize += BankSize;
	
	// realloc may've moved the Bank block, so refresh all DAC Streams
RefreshDACStrm:
	for (CurDAC = 0x00; CurDAC < DacCtrlUsed; CurDAC ++)
	{
		if (DacCtrl[DacCtrlUsg[CurDAC]].Bank == BnkType)
			daccontrol_refresh_data(DacCtrlUsg[CurDAC], TempPCM->Data, TempPCM->DataSize);
	}
	
	return;
}

/*INLINE FUINT16 ReadBits(UINT8* Data, UINT32* Pos, FUINT8* BitPos, FUINT8 BitsToRead)
{
	FUINT8 BitReadVal;
	UINT32 InPos;
	FUINT8 InVal;
	FUINT8 BitMask;
	FUINT8 InShift;
	FUINT8 OutBit;
	FUINT16 RetVal;
	
	InPos = *Pos;
	InShift = *BitPos;
	OutBit = 0x00;
	RetVal = 0x0000;
	while(BitsToRead)
	{
		BitReadVal = (BitsToRead >= 8) ? 8 : BitsToRead;
		BitsToRead -= BitReadVal;
		BitMask = (1 << BitReadVal) - 1;
		
		InShift += BitReadVal;
		InVal = (Data[InPos] << InShift >> 8) & BitMask;
		if (InShift >= 8)
		{
			InShift -= 8;
			InPos ++;
			if (InShift)
				InVal |= (Data[InPos] << InShift >> 8) & BitMask;
		}
		
		RetVal |= InVal << OutBit;
		OutBit += BitReadVal;
	}
	
	*Pos = InPos;
	*BitPos = InShift;
	return RetVal;
}

static void DecompressDataBlk(VGM_PCM_DATA* Bank, UINT32 DataSize, const UINT8* Data)
{
	UINT8 ComprType;
	UINT8 BitDec;
	FUINT8 BitCmp;
	UINT8 CmpSubType;
	UINT16 AddVal;
	UINT32 InPos;
	UINT32 OutPos;
	FUINT16 InVal;
	FUINT16 OutVal;
	FUINT8 ValSize;
	FUINT8 InShift;
	FUINT8 OutShift;
	UINT8* Ent1B;
	UINT16* Ent2B;
	//UINT32 Time;
	
	//Time = GetTickCount();
	ComprType = Data[0x00];
	Bank->DataSize = ReadLE32(&Data[0x01]);
	BitDec = Data[0x05];
	BitCmp = Data[0x06];
	CmpSubType = Data[0x07];
	AddVal = ReadLE16(&Data[0x08]);
	
	switch(ComprType)
	{
	case 0x00:	// n-Bit compression
		if (CmpSubType == 0x02)
		{
			Ent1B = (UINT8*)PCMTbl.Entries;
			Ent2B = (UINT16*)PCMTbl.Entries;
			if (! PCMTbl.EntryCount)
			{
				fprintf(stderr, "Error loading table-compressed data block! No table loaded!\n");
				return;
			}
			else if (BitDec != PCMTbl.BitDec || BitCmp != PCMTbl.BitCmp)
			{
				fprintf(stderr, "Warning! Data block and loaded value table incompatible!\n");
				return;
			}
		}
		
		ValSize = (BitDec + 7) / 8;
		InPos = 0x0A;
		InShift = 0;
		OutShift = BitDec - BitCmp;
		
		for (OutPos = 0x00; OutPos < Bank->DataSize; OutPos += ValSize)
		{
			if (InPos >= DataSize)
				break;
			InVal = ReadBits(Data, &InPos, &InShift, BitCmp);
			switch(CmpSubType)
			{
			case 0x00:	// Copy
				OutVal = InVal + AddVal;
				break;
			case 0x01:	// Shift Left
				OutVal = (InVal << OutShift) + AddVal;
				break;
			case 0x02:	// Table
				switch(ValSize)
				{
				case 0x01:
					OutVal = Ent1B[InVal];
					break;
				case 0x02:
					OutVal = Ent2B[InVal];
					break;
				}
				break;
			}
			memcpy(&Bank->Data[OutPos], &OutVal, ValSize);
		}
		break;
	}
	
	//Time = GetTickCount() - Time;
	//printf("Decompression Time: %u\n", Time);
	
	return;
}*/

static bool DecompressDataBlk(VGM_PCM_DATA* Bank, UINT32 DataSize, const UINT8* Data)
{
	UINT8 ComprType;
	UINT8 BitDec;
	FUINT8 BitCmp;
	UINT8 CmpSubType;
	UINT16 AddVal;
	const UINT8* InPos;
	const UINT8* InDataEnd;
	UINT8* OutPos;
	const UINT8* OutDataEnd;
	FUINT16 InVal;
	FUINT16 OutVal;
	FUINT8 ValSize;
	FUINT8 InShift;
	FUINT8 OutShift;
	UINT8* Ent1B;
	UINT16* Ent2B;
#if defined(_DEBUG) && defined(WIN32)
	UINT32 Time;
#endif
	
	// ReadBits Variables
	FUINT8 BitsToRead;
	FUINT8 BitReadVal;
	FUINT8 InValB;
	FUINT8 BitMask;
	FUINT8 OutBit;
	
	// Variables for DPCM
	UINT16 OutMask;
	
#if defined(_DEBUG) && defined(WIN32)
	Time = GetTickCount();
#endif
	ComprType = Data[0x00];
	Bank->DataSize = ReadLE32(&Data[0x01]);
	
	switch(ComprType)
	{
	case 0x00:	// n-Bit compression
		BitDec = Data[0x05];
		BitCmp = Data[0x06];
		CmpSubType = Data[0x07];
		AddVal = ReadLE16(&Data[0x08]);
		Ent1B = NULL;
		Ent2B = NULL;
		
		if (CmpSubType == 0x02)
		{
			Ent1B = (UINT8*)PCMTbl.Entries;	// Big Endian note: Those are stored in LE and converted when reading.
			Ent2B = (UINT16*)PCMTbl.Entries;
			if (! PCMTbl.EntryCount)
			{
				Bank->DataSize = 0x00;
				fprintf(stderr, "Error loading table-compressed data block! No table loaded!\n");
				return false;
			}
			else if (BitDec != PCMTbl.BitDec || BitCmp != PCMTbl.BitCmp)
			{
				Bank->DataSize = 0x00;
				fprintf(stderr, "Warning! Data block and loaded value table incompatible!\n");
				return false;
			}
		}
		
		ValSize = (BitDec + 7) / 8;
		InPos = Data + 0x0A;
		InDataEnd = Data + DataSize;
		InShift = 0;
		OutShift = BitDec - BitCmp;
		OutDataEnd = Bank->Data + Bank->DataSize;
		OutVal = 0x0000;
		
		for (OutPos = Bank->Data; OutPos < OutDataEnd && InPos < InDataEnd; OutPos += ValSize)
		{
			//InVal = ReadBits(Data, InPos, &InShift, BitCmp);
			// inlined - is 30% faster
			OutBit = 0x00;
			InVal = 0x0000;
			BitsToRead = BitCmp;
			while(BitsToRead)
			{
				BitReadVal = (BitsToRead >= 8) ? 8 : BitsToRead;
				BitsToRead -= BitReadVal;
				BitMask = (1 << BitReadVal) - 1;
				
				InShift += BitReadVal;
				InValB = (*InPos << InShift >> 8) & BitMask;
				if (InShift >= 8)
				{
					InShift -= 8;
					InPos ++;
					if (InShift)
						InValB |= (*InPos << InShift >> 8) & BitMask;
				}
				
				InVal |= InValB << OutBit;
				OutBit += BitReadVal;
			}
			
			switch(CmpSubType)
			{
			case 0x00:	// Copy
				OutVal = InVal + AddVal;
				break;
			case 0x01:	// Shift Left
				OutVal = (InVal << OutShift) + AddVal;
				break;
			case 0x02:	// Table
				switch(ValSize)
				{
				case 0x01:
					OutVal = Ent1B[InVal];
					break;
				case 0x02:
#ifdef VGM_LITTLE_ENDIAN
					OutVal = Ent2B[InVal];
#else
					OutVal = ReadLE16((UINT8*)&Ent2B[InVal]);
#endif
					break;
				}
				break;
			}
			
#ifdef VGM_LITTLE_ENDIAN
			//memcpy(OutPos, &OutVal, ValSize);
			if (ValSize == 0x01)
				*((UINT8*)OutPos) = (UINT8)OutVal;
			else //if (ValSize == 0x02)
				*((UINT16*)OutPos) = (UINT16)OutVal;
#else
			if (ValSize == 0x01)
			{
				*OutPos = (UINT8)OutVal;
			}
			else //if (ValSize == 0x02)
			{
				OutPos[0x00] = (UINT8)((OutVal & 0x00FF) >> 0);
				OutPos[0x01] = (UINT8)((OutVal & 0xFF00) >> 8);
			}
#endif
		}
		break;
	case 0x01:	// Delta-PCM
		BitDec = Data[0x05];
		BitCmp = Data[0x06];
		OutVal = ReadLE16(&Data[0x08]);
		
		Ent1B = (UINT8*)PCMTbl.Entries;
		Ent2B = (UINT16*)PCMTbl.Entries;
		if (! PCMTbl.EntryCount)
		{
			Bank->DataSize = 0x00;
			fprintf(stderr, "Error loading table-compressed data block! No table loaded!\n");
			return false;
		}
		else if (BitDec != PCMTbl.BitDec || BitCmp != PCMTbl.BitCmp)
		{
			Bank->DataSize = 0x00;
			fprintf(stderr, "Warning! Data block and loaded value table incompatible!\n");
			return false;
		}
		
		ValSize = (BitDec + 7) / 8;
		OutMask = (1 << BitDec) - 1;
		InPos = Data + 0x0A;
		InDataEnd = Data + DataSize;
		InShift = 0;
		OutShift = BitDec - BitCmp;
		OutDataEnd = Bank->Data + Bank->DataSize;
		AddVal = 0x0000;
		
		for (OutPos = Bank->Data; OutPos < OutDataEnd && InPos < InDataEnd; OutPos += ValSize)
		{
			//InVal = ReadBits(Data, InPos, &InShift, BitCmp);
			// inlined - is 30% faster
			OutBit = 0x00;
			InVal = 0x0000;
			BitsToRead = BitCmp;
			while(BitsToRead)
			{
				BitReadVal = (BitsToRead >= 8) ? 8 : BitsToRead;
				BitsToRead -= BitReadVal;
				BitMask = (1 << BitReadVal) - 1;
				
				InShift += BitReadVal;
				InValB = (*InPos << InShift >> 8) & BitMask;
				if (InShift >= 8)
				{
					InShift -= 8;
					InPos ++;
					if (InShift)
						InValB |= (*InPos << InShift >> 8) & BitMask;
				}
				
				InVal |= InValB << OutBit;
				OutBit += BitReadVal;
			}
			
			switch(ValSize)
			{
			case 0x01:
				AddVal = Ent1B[InVal];
				OutVal += AddVal;
				OutVal &= OutMask;
				*((UINT8*)OutPos) = (UINT8)OutVal;
				break;
			case 0x02:
#ifdef VGM_LITTLE_ENDIAN
				AddVal = Ent2B[InVal];
				OutVal += AddVal;
				OutVal &= OutMask;
				*((UINT16*)OutPos) = (UINT16)OutVal;
#else
				AddVal = ReadLE16((UINT8*)&Ent2B[InVal]);
				OutVal += AddVal;
				OutVal &= OutMask;
				OutPos[0x00] = (UINT8)((OutVal & 0x00FF) >> 0);
				OutPos[0x01] = (UINT8)((OutVal & 0xFF00) >> 8);
#endif
				break;
			}
		}
		break;
	default:
		fprintf(stderr, "Error: Unknown data block compression!\n");
		return false;
	}
	
#if defined(_DEBUG) && defined(WIN32)
	Time = GetTickCount() - Time;
	fprintf(stderr, "Decompression Time: %u\n", Time);
#endif
	
	return true;
}

static UINT8 GetDACFromPCMBank(void)
{
	// for YM2612 DAC data only
	/*VGM_PCM_BANK* TempPCM;
	UINT32 CurBnk;*/
	UINT32 DataPos;
	
	/*TempPCM = &PCMBank[0x00];
	DataPos = TempPCM->DataPos;
	for (CurBnk = 0x00; CurBnk < TempPCM->BankCount; CurBnk ++)
	{
		if (DataPos < TempPCM->Bank[CurBnk].DataSize)
		{
			if (TempPCM->DataPos < TempPCM->DataSize)
				TempPCM->DataPos ++;
			return TempPCM->Bank[CurBnk].Data[DataPos];
		}
		DataPos -= TempPCM->Bank[CurBnk].DataSize;
	}
	return 0x80;*/
	
	DataPos = PCMBank[0x00].DataPos;
	if (DataPos >= PCMBank[0x00].DataSize)
		return 0x80;
	
	PCMBank[0x00].DataPos ++;
	return PCMBank[0x00].Data[DataPos];
}

static UINT8* GetPointerFromPCMBank(UINT8 Type, UINT32 DataPos)
{
	if (Type >= PCM_BANK_COUNT)
		return NULL;
	
	if (DataPos >= PCMBank[Type].DataSize)
		return NULL;
	
	return &PCMBank[Type].Data[DataPos];
}

static void ReadPCMTable(UINT32 DataSize, const UINT8* Data)
{
	UINT8 ValSize;
	UINT32 TblSize;
	
	PCMTbl.ComprType = Data[0x00];
	PCMTbl.CmpSubType = Data[0x01];
	PCMTbl.BitDec = Data[0x02];
	PCMTbl.BitCmp = Data[0x03];
	PCMTbl.EntryCount = ReadLE16(&Data[0x04]);
	
	ValSize = (PCMTbl.BitDec + 7) / 8;
	TblSize = PCMTbl.EntryCount * ValSize;
	
	PCMTbl.Entries = realloc(PCMTbl.Entries, TblSize);
	memcpy(PCMTbl.Entries, &Data[0x06], TblSize);
	
	if (DataSize < 0x06 + TblSize)
		fprintf(stderr, "Warning! Bad PCM Table Length!\n");
	
	return;
}

#define CHIP_CHECK(name)	(ChipAudio[CurChip].name.ChipType != 0xFF)
static void InterpretVGM(UINT32 SampleCount)
{
	INT32 SmplPlayed;
	UINT8 Command;
	UINT8 TempByt;
	UINT16 TempSht;
	UINT32 TempLng;
	VGM_PCM_BANK* TempPCM;
	VGM_PCM_DATA* TempBnk;
	UINT32 ROMSize;
	UINT32 DataStart;
	UINT32 DataLen;
	const UINT8* ROMData;
	UINT8 CurChip;
	const UINT8* VGMPnt;
	
	if (VGMEnd)
		return;
	if (PausePlay && ! ForceVGMExec)
		return;
	
	SmplPlayed = SamplePbk2VGM_I(VGMSmplPlayed + SampleCount);
	while(VGMSmplPos <= SmplPlayed)
	{
		Command = VGMData[VGMPos + 0x00];
		if (Command >= 0x70 && Command <= 0x8F)
		{
			switch(Command & 0xF0)
			{
			case 0x70:
				VGMSmplPos += (Command & 0x0F) + 0x01;
				break;
			case 0x80:
				TempByt = GetDACFromPCMBank();
				if (VGMHead.lngHzYM2612)
				{
					chip_reg_write(0x02, 0x00, 0x00, 0x2A, TempByt);
				}
				VGMSmplPos += (Command & 0x0F);
				break;
			}
			VGMPos += 0x01;
		}
		else
		{
			VGMPnt = &VGMData[VGMPos];
			
			// Cheat Mode (to use 2 instances of 1 chip)
			CurChip = 0x00;
			switch(Command)
			{
			case 0x30:
				if (VGMHead.lngHzPSG & 0x40000000)
				{
					Command += 0x20;
					CurChip = 0x01;
				}
				break;
			case 0x3F:
				if (VGMHead.lngHzPSG & 0x40000000)
				{
					Command += 0x10;
					CurChip = 0x01;
				}
				break;
			case 0xA1:
				if (VGMHead.lngHzYM2413 & 0x40000000)
				{
					Command -= 0x50;
					CurChip = 0x01;
				}
				break;
			case 0xA2:
			case 0xA3:
				if (VGMHead.lngHzYM2612 & 0x40000000)
				{
					Command -= 0x50;
					CurChip = 0x01;
				}
				break;
			case 0xA4:
				if (VGMHead.lngHzYM2151 & 0x40000000)
				{
					Command -= 0x50;
					CurChip = 0x01;
				}
				break;
			case 0xA5:
				if (VGMHead.lngHzYM2203 & 0x40000000)
				{
					Command -= 0x50;
					CurChip = 0x01;
				}
				break;
			case 0xA6:
			case 0xA7:
				if (VGMHead.lngHzYM2608 & 0x40000000)
				{
					Command -= 0x50;
					CurChip = 0x01;
				}
				break;
			case 0xA8:
			case 0xA9:
				if (VGMHead.lngHzYM2610 & 0x40000000)
				{
					Command -= 0x50;
					CurChip = 0x01;
				}
				break;
			case 0xAA:
				if (VGMHead.lngHzYM3812 & 0x40000000)
				{
					Command -= 0x50;
					CurChip = 0x01;
				}
				break;
			case 0xAB:
				if (VGMHead.lngHzYM3526 & 0x40000000)
				{
					Command -= 0x50;
					CurChip = 0x01;
				}
				break;
			case 0xAC:
				if (VGMHead.lngHzY8950 & 0x40000000)
				{
					Command -= 0x50;
					CurChip = 0x01;
				}
				break;
			case 0xAE:
			case 0xAF:
				if (VGMHead.lngHzYMF262 & 0x40000000)
				{
					Command -= 0x50;
					CurChip = 0x01;
				}
				break;
			case 0xAD:
				if (VGMHead.lngHzYMZ280B & 0x40000000)
				{
					Command -= 0x50;
					CurChip = 0x01;
				}
				break;
			}
			
			switch(Command)
			{
			case 0x66:	// End Of File
				if (VGMHead.lngLoopOffset)
				{
					VGMPos = VGMHead.lngLoopOffset;
					VGMSmplPos -= VGMHead.lngLoopSamples;
					VGMSmplPlayed -= SampleVGM2Pbk_I(VGMHead.lngLoopSamples);
					SmplPlayed = SamplePbk2VGM_I(VGMSmplPlayed + SampleCount);
					VGMCurLoop ++;
					
					if (VGMMaxLoopM && VGMCurLoop >= VGMMaxLoopM)
					{
#ifndef CONSOLE_MODE
						if (! FadePlay)
						{
							FadeStart = SampleVGM2Pbk_I(VGMHead.lngTotalSamples +
															(VGMCurLoop - 1) * VGMHead.lngLoopSamples);
						}
#endif
						FadePlay = true;
					}
					if (FadePlay && ! FadeTime)
						VGMEnd = true;
				}
				else
				{
					if (VGMHead.lngTotalSamples != (UINT32)VGMSmplPos)
					{
#ifdef CONSOLE_MODE
						fprintf(stderr, "Warning! Header Samples: %u\t Counted Samples: %u\n",
								VGMHead.lngTotalSamples, VGMSmplPos);
						ErrorHappened = true;
#endif
						VGMHead.lngTotalSamples = VGMSmplPos;
					}
					
					if (HardStopOldVGMs)
					{
						if (VGMHead.lngVersion < 0x150 ||
							(VGMHead.lngVersion == 0x150 && HardStopOldVGMs == 0x02))
						Chips_GeneralActions(0x01); // reset all chips, for instant silence
					}
					VGMEnd = true;
					break;
				}
				break;
			case 0x62:	// 1/60s delay
				VGMSmplPos += 735;
				VGMPos += 0x01;
				break;
			case 0x63:	// 1/50s delay
				VGMSmplPos += 882;
				VGMPos += 0x01;
				break;
			case 0x61:	// xx Sample Delay
				TempSht = ReadLE16(&VGMPnt[0x01]);
				VGMSmplPos += TempSht;
				VGMPos += 0x03;
				break;
			case 0x50:	// SN76496 write
				if (CHIP_CHECK(SN76496))
				{
					chip_reg_write(0x00, CurChip, 0x00, 0x00, VGMPnt[0x01]);
				}
				VGMPos += 0x02;
				break;
			case 0x51:	// YM2413 write
				if (CHIP_CHECK(YM2413))
				{
					chip_reg_write(0x01, CurChip, 0x00, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0x52:	// YM2612 write port 0
			case 0x53:	// YM2612 write port 1
				if (CHIP_CHECK(YM2612))
				{
					chip_reg_write(0x02, CurChip, Command & 0x01, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0x67:	// PCM Data Stream
				TempByt = VGMPnt[0x02];
				TempLng = ReadLE32(&VGMPnt[0x03]);
				if (TempLng & 0x80000000)
				{
					TempLng &= 0x7FFFFFFF;
					CurChip = 0x01;
				}
				
				switch(TempByt & 0xC0)
				{
				case 0x00:	// Database Block
				case 0x40:
					AddPCMData(TempByt, TempLng, &VGMPnt[0x07]);
					/*switch(TempByt)
					{
					case 0x00:	// YM2612 PCM Database
						break;
					case 0x01:	// RF5C68 PCM Database
						break;
					case 0x02:	// RF5C164 PCM Database
						break;
					}*/
					break;
				case 0x80:	// ROM/RAM Dump
					if (VGMCurLoop)
						break;
					
					ROMSize = ReadLE32(&VGMPnt[0x07]);
					DataStart = ReadLE32(&VGMPnt[0x0B]);
					DataLen = TempLng - 0x08;
					ROMData = &VGMPnt[0x0F];
					switch(TempByt)
					{
					case 0x80:	// SegaPCM ROM
						if (! CHIP_CHECK(SegaPCM))
							break;
						sega_pcm_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x81:	// YM2608 DELTA-T ROM Image
						if (! CHIP_CHECK(YM2608))
							break;
						ym2608_write_data_pcmrom(CurChip, 0x02, ROMSize, DataStart, DataLen,
												ROMData);
						break;
					case 0x82:	// YM2610 ADPCM ROM Image
					case 0x83:	// YM2610 DELTA-T ROM Image
						if (! CHIP_CHECK(YM2610))
							break;
						TempByt = 0x01 + (TempByt - 0x82);
						ym2610_write_data_pcmrom(CurChip, TempByt, ROMSize, DataStart, DataLen,
												ROMData);
						break;
					case 0x84:	// YMF278B ROM Image
						if (! CHIP_CHECK(YMF278B))
							break;
						ymf278b_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x85:	// YMF271 ROM Image
						if (! CHIP_CHECK(YMF271))
							break;
						ymf271_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x86:	// YMZ280B ROM Image
						if (! CHIP_CHECK(YMZ280B))
							break;
						ymz280b_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x87:	// YMF278B RAM Image
						if (! CHIP_CHECK(YMF278B))
							break;
						ymf278b_write_ram(CurChip, DataStart, DataLen, ROMData);
						break;
					case 0x88:	// Y8950 DELTA-T ROM Image
						if (! CHIP_CHECK(Y8950) || PlayingMode == 0x01)
							break;
						y8950_write_data_pcmrom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x89:	// MultiPCM ROM Image
						if (! CHIP_CHECK(MultiPCM))
							break;
						multipcm_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x8A:	// UPD7759 ROM Image
						if (! CHIP_CHECK(UPD7759))
							break;
						upd7759_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x8B:	// OKIM6295 ROM Image
						if (! CHIP_CHECK(OKIM6295))
							break;
						okim6295_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x8C:	// K054539 ROM Image
						if (! CHIP_CHECK(K054539))
							break;
						k054539_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x8D:	// C140 ROM Image
						if (! CHIP_CHECK(C140))
							break;
						c140_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x8E:	// K053260 ROM Image
						if (! CHIP_CHECK(K053260))
							break;
						k053260_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x8F:	// QSound ROM Image
						if (! CHIP_CHECK(QSound))
							break;
						qsound_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x90:	// ES5506 ROM Image
						if (! CHIP_CHECK(ES5506))
							break;
						es5506_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x91:	// X1-010 ROM Image
						if (! CHIP_CHECK(X1_010))
							break;
						x1_010_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x92:	// C352 ROM Image
						if (! CHIP_CHECK(C352))
							break;
						c352_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
					case 0x93:	// GA20 ROM Image
						if (! CHIP_CHECK(GA20))
							break;
						iremga20_write_rom(CurChip, ROMSize, DataStart, DataLen, ROMData);
						break;
				//	case 0x8C:	// OKIM6376 ROM Image
				//		if (! CHIP_CHECK(OKIM6376))
				//			break;
				//		break;
					}
					break;
				case 0xC0:	// RAM Write
					if (! (TempByt & 0x20))
					{
						DataStart = ReadLE16(&VGMPnt[0x07]);
						DataLen = TempLng - 0x02;
						ROMData = &VGMPnt[0x09];
					}
					else
					{
						DataStart = ReadLE32(&VGMPnt[0x07]);
						DataLen = TempLng - 0x04;
						ROMData = &VGMPnt[0x0B];
					}
					switch(TempByt)
					{
					case 0xC0:	// RF5C68 RAM Database
						if (! CHIP_CHECK(RF5C68))
							break;
						rf5c68_write_ram(CurChip, DataStart, DataLen, ROMData);
						break;
					case 0xC1:	// RF5C164 RAM Database
						if (! CHIP_CHECK(RF5C164))
							break;
						rf5c164_write_ram(CurChip, DataStart, DataLen, ROMData);
						break;
					case 0xC2:	// NES APU RAM
						if (! CHIP_CHECK(NES))
							break;
						nes_write_ram(CurChip, DataStart, DataLen, ROMData);
						break;
					case 0xE0:	// SCSP RAM
						if (! CHIP_CHECK(SCSP))
							break;
						scsp_write_ram(CurChip, DataStart, DataLen, ROMData);
						break;
					case 0xE1:	// ES5503 RAM
						if (! CHIP_CHECK(ES5503))
							break;
						es5503_write_ram(CurChip, DataStart, DataLen, ROMData);
						break;
					}
					break;
				}
				VGMPos += 0x07 + TempLng;
				break;
			case 0xE0:	// Seek to PCM Data Bank Pos
				PCMBank[0x00].DataPos = ReadLE32(&VGMPnt[0x01]);
				VGMPos += 0x05;
				break;
			case 0x31:	// Set AY8910 stereo mask
				TempByt = VGMPnt[0x01];
				TempLng = TempByt & 0x3F;
				CurChip = (TempByt & 0x80)? 1: 0;
				if (TempByt & 0x40)
					ym2203_set_stereo_mask_ay(CurChip, TempLng);
				else
					ayxx_set_stereo_mask(CurChip, TempLng);
				VGMPos += 0x02;
				break;
			case 0x4F:	// GG Stereo
				if (CHIP_CHECK(SN76496))
				{
					chip_reg_write(0x00, CurChip, 0x01, 0x00, VGMPnt[0x01]);
				}
				VGMPos += 0x02;
				break;
			case 0x54:	// YM2151 write
				if (CHIP_CHECK(YM2151))
				{
					chip_reg_write(0x03, CurChip, 0x01, VGMPnt[0x01], VGMPnt[0x02]);
				}
				//VGMSmplPos += 80;
				VGMPos += 0x03;
				break;
			case 0xC0:	// Sega PCM memory write
				TempSht = ReadLE16(&VGMPnt[0x01]);
				CurChip = (TempSht & 0x8000) >> 15;
				if (CHIP_CHECK(SegaPCM))
				{
					sega_pcm_w(CurChip, TempSht & 0x7FFF, VGMPnt[0x03]);
				}
				VGMPos += 0x04;
				break;
			case 0xB0:	// RF5C68 register write
				if (CHIP_CHECK(RF5C68))
				{
					chip_reg_write(0x05, CurChip, 0x00, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0xC1:	// RF5C164 memory write
				if (CHIP_CHECK(RF5C68))
				{
					TempSht = ReadLE16(&VGMPnt[0x01]);
					rf5c68_mem_w(CurChip, TempSht, VGMPnt[0x03]);
				}
				VGMPos += 0x04;
				break;
			case 0x55:	// YM2203
				if (CHIP_CHECK(YM2203))
				{
					chip_reg_write(0x06, CurChip, 0x00, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0x56:	// YM2608 write port 0
			case 0x57:	// YM2608 write port 1
				if (CHIP_CHECK(YM2608))
				{
					chip_reg_write(0x07, CurChip, Command & 0x01, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0x58:	// YM2610 write port 0
			case 0x59:	// YM2610 write port 1
				if (CHIP_CHECK(YM2610))
				{
					chip_reg_write(0x08, CurChip, Command & 0x01, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0x5A:	// YM3812 write
				if (CHIP_CHECK(YM3812))
				{
					chip_reg_write(0x09, CurChip, 0x00, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0x5B:	// YM3526 write
				if (CHIP_CHECK(YM3526))
				{
					chip_reg_write(0x0A, CurChip, 0x00, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0x5C:	// Y8950 write
				if (CHIP_CHECK(Y8950))
				{
					chip_reg_write(0x0B, CurChip, 0x00, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0x5E:	// YMF262 write port 0
			case 0x5F:	// YMF262 write port 1
				if (CHIP_CHECK(YMF262))
				{
					chip_reg_write(0x0C, CurChip, Command & 0x01, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0x5D:	// YMZ280B write
				if (CHIP_CHECK(YMZ280B))
				{
					chip_reg_write(0x0F, CurChip, 0x00, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0xD0:	// YMF278B write
				if (CHIP_CHECK(YMF278B))
				{
					CurChip = (VGMPnt[0x01] & 0x80) >> 7;
					chip_reg_write(0x0D, CurChip, VGMPnt[0x01] & 0x7F, VGMPnt[0x02], VGMPnt[0x03]);
				}
				VGMPos += 0x04;
				break;
			case 0xD1:	// YMF271 write
				if (CHIP_CHECK(YMF271))
				{
					CurChip = (VGMPnt[0x01] & 0x80) >> 7;
					chip_reg_write(0x0E, CurChip, VGMPnt[0x01] & 0x7F, VGMPnt[0x02], VGMPnt[0x03]);
				}
				VGMPos += 0x04;
				break;
			case 0xB1:	// RF5C164 register write
				if (CHIP_CHECK(RF5C164))
				{
					chip_reg_write(0x10, CurChip, 0x00, VGMPnt[0x01], VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0xC2:	// RF5C164 memory write
				if (CHIP_CHECK(RF5C164))
				{
					TempSht = ReadLE16(&VGMPnt[0x01]);
					rf5c164_mem_w(CurChip, TempSht, VGMPnt[0x03]);
				}
				VGMPos += 0x04;
				break;
			case 0xB2:	// PWM channel write
				if (CHIP_CHECK(PWM))
				{
					chip_reg_write(0x11, CurChip, (VGMPnt[0x01] & 0xF0) >> 4,
									VGMPnt[0x01] & 0x0F, VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0x68:	// PCM RAM write
				CurChip = (VGMPnt[0x02] & 0x80) >> 7;
				TempByt =  VGMPnt[0x02] & 0x7F;
				
				DataStart = ReadLE24(&VGMPnt[0x03]);
				TempLng = ReadLE24(&VGMPnt[0x06]);
				DataLen = ReadLE24(&VGMPnt[0x09]);
				if (! DataLen)
					DataLen += 0x01000000;
				ROMData = GetPointerFromPCMBank(TempByt, DataStart);
				if (ROMData == NULL)
				{
					VGMPos += 0x0C;
					break;
				}
				
				switch(TempByt)
				{
				case 0x01:
					if (! CHIP_CHECK(RF5C68))
						break;
					rf5c68_write_ram(CurChip, TempLng, DataLen, ROMData);
					break;
				case 0x02:
					if (! CHIP_CHECK(RF5C164))
						break;
					rf5c164_write_ram(CurChip, TempLng, DataLen, ROMData);
					break;
				case 0x06:
					if (! CHIP_CHECK(SCSP))
						break;
					scsp_write_ram(CurChip, TempLng, DataLen, ROMData);
					break;
				case 0x07:
					if (! CHIP_CHECK(NES))
						break;
					Last95Drum = DataStart / DataLen - 1;
					Last95Max = PCMBank[TempByt].DataSize / DataLen;
					nes_write_ram(CurChip, TempLng, DataLen, ROMData);
					break;
				}
				VGMPos += 0x0C;
				break;
			case 0xA0:	// AY8910 write
				CurChip = (VGMPnt[0x01] & 0x80) >> 7;
				if (CHIP_CHECK(AY8910))
				{
					chip_reg_write(0x12, CurChip, 0x00, VGMPnt[0x01] & 0x7F, VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0xB3:	// GameBoy DMG write
				CurChip = (VGMPnt[0x01] & 0x80) >> 7;
				if (CHIP_CHECK(GameBoy))
				{
					chip_reg_write(0x13, CurChip, 0x00, VGMPnt[0x01] & 0x7F, VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0xB4:	// NES APU write
				CurChip = (VGMPnt[0x01] & 0x80) >> 7;
				if (CHIP_CHECK(NES))
				{
					chip_reg_write(0x14, CurChip, 0x00, VGMPnt[0x01] & 0x7F, VGMPnt[0x02]);
				}
				VGMPos += 0x03;
				break;
			case 0xB5:	// MultiPCM write
				CurChip = (VGMPnt[0x01] & 0
Download .txt
gitextract_fr0538in/

├── .gitattributes
├── .gitignore
├── .travis.yml
├── README.md
├── VGMPlay/
│   ├── .gitignore
│   ├── ChipMapper.c
│   ├── ChipMapper.h
│   ├── Makefile
│   ├── PortTalk_IOCTL.h
│   ├── Stream.c
│   ├── Stream.h
│   ├── VGMFile.h
│   ├── VGMPlay.c
│   ├── VGMPlay.dsp
│   ├── VGMPlay.dsw
│   ├── VGMPlay.h
│   ├── VGMPlay.ini
│   ├── VGMPlay.sln
│   ├── VGMPlay.txt
│   ├── VGMPlay.vcxproj
│   ├── VGMPlay.vcxproj.filters
│   ├── VGMPlayUI.c
│   ├── VGMPlay_AddFmts.c
│   ├── VGMPlay_Intf.h
│   ├── VGMPlay_Updates.txt
│   ├── XMasFiles/
│   │   ├── SWJ-SQRC01_1C.h
│   │   ├── SWJ-SQRC01_1C_trimmed_optimized.vgz
│   │   ├── WEWISH.CMF
│   │   ├── XMasBonus.h
│   │   ├── clyde1_1.dro
│   │   ├── lem_xmas_001_jb.dro
│   │   ├── lemmings_012_tim7.vgm
│   │   └── rudolph.dro
│   ├── chips/
│   │   ├── 2151intf.c
│   │   ├── 2151intf.h
│   │   ├── 2203intf.c
│   │   ├── 2203intf.h
│   │   ├── 2413intf.c
│   │   ├── 2413intf.h
│   │   ├── 2608intf.c
│   │   ├── 2608intf.h
│   │   ├── 2610intf.c
│   │   ├── 2610intf.h
│   │   ├── 2612intf.c
│   │   ├── 2612intf.h
│   │   ├── 262intf.c
│   │   ├── 262intf.h
│   │   ├── 3526intf.c
│   │   ├── 3526intf.h
│   │   ├── 3812intf.c
│   │   ├── 3812intf.h
│   │   ├── 8950intf.c
│   │   ├── 8950intf.h
│   │   ├── ChipIncl.h
│   │   ├── Ootake_PSG.c
│   │   ├── Ootake_PSG.h
│   │   ├── adlibemu.h
│   │   ├── adlibemu_opl2.c
│   │   ├── adlibemu_opl3.c
│   │   ├── ay8910.c
│   │   ├── ay8910.h
│   │   ├── ay8910_opl.c
│   │   ├── ay_intf.c
│   │   ├── ay_intf.h
│   │   ├── c140.c
│   │   ├── c140.h
│   │   ├── c352.c
│   │   ├── c352.h
│   │   ├── c6280.c
│   │   ├── c6280.h
│   │   ├── c6280intf.c
│   │   ├── c6280intf.h
│   │   ├── dac_control.c
│   │   ├── dac_control.h
│   │   ├── emu2149.c
│   │   ├── emu2149.h
│   │   ├── emu2413.c
│   │   ├── emu2413.h
│   │   ├── emu2413_NESpatches.txt
│   │   ├── emutypes.h
│   │   ├── es5503.c
│   │   ├── es5503.h
│   │   ├── es5506.c
│   │   ├── es5506.h
│   │   ├── fm.c
│   │   ├── fm.h
│   │   ├── fm2612.c
│   │   ├── fmopl.c
│   │   ├── fmopl.h
│   │   ├── gb.c
│   │   ├── gb.h
│   │   ├── iremga20.c
│   │   ├── iremga20.h
│   │   ├── k051649.c
│   │   ├── k051649.h
│   │   ├── k053260.c
│   │   ├── k053260.h
│   │   ├── k054539.c
│   │   ├── k054539.h
│   │   ├── mamedef.h
│   │   ├── multipcm.c
│   │   ├── multipcm.h
│   │   ├── nes_apu.c
│   │   ├── nes_apu.h
│   │   ├── nes_defs.h
│   │   ├── nes_intf.c
│   │   ├── nes_intf.h
│   │   ├── np_nes_apu.c
│   │   ├── np_nes_apu.h
│   │   ├── np_nes_dmc.c
│   │   ├── np_nes_dmc.h
│   │   ├── np_nes_fds.c
│   │   ├── np_nes_fds.h
│   │   ├── okim6258.c
│   │   ├── okim6258.h
│   │   ├── okim6295.c
│   │   ├── okim6295.h
│   │   ├── opl.c
│   │   ├── opl.h
│   │   ├── opll.c
│   │   ├── opll.h
│   │   ├── opm.c
│   │   ├── opm.h
│   │   ├── panning.c
│   │   ├── panning.h
│   │   ├── pokey.c
│   │   ├── pokey.h
│   │   ├── pwm.c
│   │   ├── pwm.h
│   │   ├── qsound_ctr.c
│   │   ├── qsound_ctr.h
│   │   ├── qsound_intf.c
│   │   ├── qsound_intf.h
│   │   ├── qsound_mame.c
│   │   ├── qsound_mame.h
│   │   ├── rf5c68.c
│   │   ├── rf5c68.h
│   │   ├── saa1099.c
│   │   ├── saa1099.h
│   │   ├── scd_pcm.c
│   │   ├── scd_pcm.h
│   │   ├── scsp.c
│   │   ├── scsp.h
│   │   ├── scspdsp.c
│   │   ├── scspdsp.h
│   │   ├── scsplfo.c
│   │   ├── segapcm.c
│   │   ├── segapcm.h
│   │   ├── sn76489.c
│   │   ├── sn76489.h
│   │   ├── sn76496.c
│   │   ├── sn76496.h
│   │   ├── sn76496_opl.c
│   │   ├── sn764intf.c
│   │   ├── sn764intf.h
│   │   ├── upd7759.c
│   │   ├── upd7759.h
│   │   ├── vrc7tone.h
│   │   ├── vsu.c
│   │   ├── vsu.h
│   │   ├── ws_audio.c
│   │   ├── ws_audio.h
│   │   ├── ws_initialIo.h
│   │   ├── x1_010.c
│   │   ├── x1_010.h
│   │   ├── ym2151.c
│   │   ├── ym2151.h
│   │   ├── ym2413.c
│   │   ├── ym2413.h
│   │   ├── ym2413_opl.c
│   │   ├── ym2413hd.c
│   │   ├── ym2413hd.h
│   │   ├── ym2612.c
│   │   ├── ym2612.h
│   │   ├── ym3438.c
│   │   ├── ym3438.h
│   │   ├── ymdeltat.c
│   │   ├── ymdeltat.h
│   │   ├── ymf262.c
│   │   ├── ymf262.h
│   │   ├── ymf271.c
│   │   ├── ymf271.h
│   │   ├── ymf278b.c
│   │   ├── ymf278b.h
│   │   ├── ymz280b.c
│   │   └── ymz280b.h
│   ├── dbus.c
│   ├── dbus.h
│   ├── dbus_stub.c
│   ├── licenses/
│   │   ├── GPL.txt
│   │   ├── List.txt
│   │   └── mame_license.txt
│   ├── mmkeys.h
│   ├── mmkeys_Win.c
│   ├── mmkeys_stub.c
│   ├── pt_ioctl.c
│   ├── stdbool.h
│   ├── vgm-player
│   ├── vgm2pcm.c
│   ├── vgm2wav.c
│   ├── vgm2wav.dsp
│   ├── vgmplay.1
│   ├── vgmspec171.txt
│   ├── xdg/
│   │   ├── vgmplay-mime.xml
│   │   └── vgmplay.desktop.in
│   └── zlib/
│       ├── zconf.h
│       ├── zdll.lib
│       ├── zlib.def
│       ├── zlib.h
│       ├── zlib.lib
│       └── zlibd.lib
└── in_vgm/
    ├── README.md
    ├── Winamp/
    │   ├── DSP.H
    │   ├── GEN.H
    │   ├── IN2.H
    │   ├── OUT.H
    │   ├── ipc_pe.h
    │   ├── wa_dlg.h
    │   └── wa_ipc.h
    ├── dlg_cfg.c
    ├── dlg_fileinfo.c
    ├── in_vgm.c
    ├── in_vgm.dsp
    ├── in_vgm.dsw
    ├── in_vgm.h
    ├── in_vgm.rc
    ├── ini_func.c
    ├── ini_func.h
    └── resource.h
Download .txt
SYMBOL INDEX (2153 symbols across 133 files)

FILE: VGMPlay/ChipMapper.c
  type CHIP_MAP (line 112) | typedef struct chip_mapping_info
  function OpenPortTalk (line 137) | unsigned char OpenPortTalk(void)
  function ClosePortTalk (line 150) | void ClosePortTalk(void)
  function OpenPortTalk (line 161) | unsigned char OpenPortTalk(void)
  function ClosePortTalk (line 166) | void ClosePortTalk(void)
  function open_fm_option (line 172) | void open_fm_option(UINT8 ChipType, UINT8 OptType, UINT32 OptVal)
  function opl_chip_reset (line 179) | void opl_chip_reset(void)
  function open_real_fm (line 257) | void open_real_fm(void)
  function setup_real_fm (line 333) | void setup_real_fm(UINT8 ChipType, UINT8 ChipID)
  function close_real_fm (line 452) | void close_real_fm(void)
  function chip_reg_write (line 520) | void chip_reg_write(UINT8 ChipType, UINT8 ChipID,
  function OPL_Hardware_Detecton (line 768) | void OPL_Hardware_Detecton(void)
  function INLINE (line 888) | INLINE UINT8 OPL_HW_GetStatus(void)
  function INLINE (line 909) | INLINE void OPL_HW_WaitDelay(INT64 StartTime, float Delay)
  function OPL_HW_WriteReg (line 955) | void OPL_HW_WriteReg(UINT16 Reg, UINT8 Data)
  function OPL_RegMapper (line 1086) | void OPL_RegMapper(UINT16 Reg, UINT8 Data)
  function RefreshVolume (line 1160) | void RefreshVolume()
  function StartSkipping (line 1181) | void StartSkipping(void)
  function StopSkipping (line 1194) | void StopSkipping(void)
  function ym2413opl_set_emu_core (line 1285) | void ym2413opl_set_emu_core(UINT8 Emulator)

FILE: VGMPlay/Stream.c
  type WAVEFORMATEX (line 39) | typedef struct
  function INLINE (line 99) | INLINE int fputLE32(UINT32 Value, FILE* hFile)
  function INLINE (line 116) | INLINE int fputLE16(UINT16 Value, FILE* hFile)
  function UINT8 (line 131) | UINT8 SaveFile(UINT32 FileLen, const void* TempData)
  function UINT8 (line 216) | UINT8 SoundLogging(UINT8 Mode)
  type audio_info (line 253) | struct audio_info
  function UINT8 (line 386) | UINT8 StopStream(void)
  function PauseStream (line 430) | void PauseStream(bool PauseOn)
  function DWORD (line 460) | static DWORD WINAPI WaveOutThread(void* Arg)
  function BufCheck (line 530) | static void BufCheck(void)
  function WaveOutLinuxCallBack (line 551) | void WaveOutLinuxCallBack(void)

FILE: VGMPlay/VGMFile.h
  type VGM_HEADER (line 3) | typedef struct _vgm_file_header
  type VGM_HDR_EXTRA (line 79) | typedef struct _vgm_header_extra
  type VGMX_CHIP_DATA32 (line 85) | typedef struct _vgm_extra_chip_data32
  type VGMX_CHIP_DATA16 (line 90) | typedef struct _vgm_extra_chip_data16
  type VGMX_CHP_EXTRA32 (line 96) | typedef struct _vgm_extra_chip_extra32
  type VGMX_CHP_EXTRA16 (line 101) | typedef struct _vgm_extra_chip_extra16
  type VGM_EXTRA (line 106) | typedef struct _vgm_header_extra_data
  type GD3_TAG (line 113) | typedef struct _vgm_gd3_tag
  type VGM_PCM_DATA (line 130) | typedef struct _vgm_pcm_bank_data
  type VGM_PCM_BANK (line 136) | typedef struct _vgm_pcm_bank

FILE: VGMPlay/VGMPlay.c
  function clock_gettime (line 55) | int clock_gettime(int clk_id, struct timespec *t)
  type CAUD_ATTR (line 109) | typedef struct chip_audio_attributes CAUD_ATTR;
  type chip_audio_attributes (line 110) | struct chip_audio_attributes
  type CHIP_AUDIO (line 131) | typedef struct chip_audio_struct
  type CA_LIST (line 177) | typedef struct chip_aud_list CA_LIST;
  type chip_aud_list (line 178) | struct chip_aud_list
  type DACCTRL_DATA (line 185) | typedef struct daccontrol_data
  type PCMBANK_TBL (line 191) | typedef struct pcmbank_table
  type timespec (line 288) | struct timespec
  function VGMPlay_Init (line 428) | void VGMPlay_Init(void)
  function VGMPlay_Init2 (line 540) | void VGMPlay_Init2(void)
  function VGMPlay_Deinit (line 598) | void VGMPlay_Deinit(void)
  function INLINE (line 762) | INLINE UINT16 ReadLE16(const UINT8* Data)
  function INLINE (line 772) | INLINE UINT16 ReadBE16(const UINT8* Data)
  function INLINE (line 782) | INLINE UINT32 ReadLE24(const UINT8* Data)
  function INLINE (line 792) | INLINE UINT32 ReadLE32(const UINT8* Data)
  function INLINE (line 803) | INLINE int gzgetLE16(gzFile hFile, UINT16* RetValue)
  function INLINE (line 817) | INLINE int gzgetLE32(gzFile hFile, UINT32* RetValue)
  function UINT32 (line 832) | static UINT32 gcd(UINT32 x, UINT32 y)
  function PlayVGM (line 872) | void PlayVGM(void)
  function StopVGM (line 1068) | void StopVGM(void)
  function RestartVGM (line 1108) | void RestartVGM(void)
  function PauseVGM (line 1118) | void PauseVGM(bool Pause)
  function SeekVGM (line 1161) | void SeekVGM(bool Relative, INT32 PlayBkSamples)
  function RefreshMuting (line 1201) | void RefreshMuting(void)
  function RefreshPanning (line 1208) | void RefreshPanning(void)
  function RefreshPlaybackOptions (line 1215) | void RefreshPlaybackOptions(void)
  function UINT32 (line 1255) | UINT32 GetGZFileLength(const char* FileName)
  function UINT32 (line 1271) | UINT32 GetGZFileLengthW(const wchar_t* FileName)
  function UINT32 (line 1287) | static UINT32 GetGZFileLength_Internal(FILE* hFile)
  function OpenVGMFile (line 1322) | bool OpenVGMFile(const char* FileName)
  function OpenVGMFileW (line 1341) | bool OpenVGMFileW(const wchar_t* FileName)
  function OpenVGMFile_Internal (line 1373) | static bool OpenVGMFile_Internal(gzFile hFile, UINT32 FileSize)
  function ReadVGMHeader (line 1487) | static void ReadVGMHeader(gzFile hFile, VGM_HEADER* RetVGMHead)
  function UINT8 (line 1610) | static UINT8 ReadGD3Tag(gzFile hFile, UINT32 GD3Offset, GD3_TAG* RetGD3Tag)
  function ReadChipExtraData32 (line 1678) | static void ReadChipExtraData32(UINT32 StartOffset, VGMX_CHP_EXTRA32* Ch...
  function ReadChipExtraData16 (line 1711) | static void ReadChipExtraData16(UINT32 StartOffset, VGMX_CHP_EXTRA16* Ch...
  function CloseVGMFile (line 1745) | void CloseVGMFile(void)
  function FreeGD3Tag (line 1763) | void FreeGD3Tag(GD3_TAG* TagData)
  function wchar_t (line 1784) | static wchar_t* MakeEmptyWStr(void)
  function wchar_t (line 1794) | static wchar_t* ReadWStrFromFile(gzFile hFile, UINT32* FilePos, UINT32 E...
  function UINT32 (line 1834) | UINT32 GetVGMFileInfo(const char* FileName, VGM_HEADER* RetVGMHead, GD3_...
  function UINT32 (line 1853) | UINT32 GetVGMFileInfoW(const wchar_t* FileName, VGM_HEADER* RetVGMHead, ...
  function UINT32 (line 1885) | static UINT32 GetVGMFileInfo_Internal(gzFile hFile, UINT32 FileSize,
  function INLINE (line 1930) | INLINE UINT32 MulDivRound(UINT64 Number, UINT64 Numerator, UINT64 Denomi...
  function UINT32 (line 1935) | UINT32 CalcSampleMSec(UINT64 Value, UINT8 Mode)
  function UINT32 (line 1975) | UINT32 CalcSampleMSecExt(UINT64 Value, UINT8 Mode, VGM_HEADER* FileHead)
  function UINT32 (line 2024) | static UINT32 EncryptChipName(void* DstBuf, const void* SrcBuf, UINT32 L...
  function UINT32 (line 2235) | UINT32 GetChipClock(VGM_HEADER* FileHead, UINT8 ChipID, UINT8* RetSubType)
  function UINT16 (line 2466) | static UINT16 GetChipVolume(VGM_HEADER* FileHead, UINT8 ChipID, UINT8 Ch...
  function RestartPlaying (line 2540) | static void RestartPlaying(void)
  function Chips_GeneralActions (line 2593) | static void Chips_GeneralActions(UINT8 Mode)
  function INLINE (line 3965) | INLINE INT32 SampleVGM2Pbk_I(INT32 SampleVal)
  function INLINE (line 3970) | INLINE INT32 SamplePbk2VGM_I(INT32 SampleVal)
  function INT32 (line 3975) | INT32 SampleVGM2Playback(INT32 SampleVal)
  function INT32 (line 3980) | INT32 SamplePlayback2VGM(INT32 SampleVal)
  function UINT8 (line 3985) | static UINT8 StartThread(void)
  function UINT8 (line 4029) | static UINT8 StopThread(void)
  function GetMixerControl (line 4058) | static bool GetMixerControl(void)
  function SetMuteControl (line 4102) | static bool SetMuteControl(bool mute)
  function InterpretFile (line 4161) | static void InterpretFile(UINT32 SampleCount)
  function AddPCMData (line 4224) | static void AddPCMData(UINT8 Type, UINT32 DataSize, const UINT8* Data)
  function DecompressDataBlk (line 4420) | static bool DecompressDataBlk(VGM_PCM_DATA* Bank, UINT32 DataSize, const...
  function UINT8 (line 4659) | static UINT8 GetDACFromPCMBank(void)
  function UINT8 (line 4688) | static UINT8* GetPointerFromPCMBank(UINT8 Type, UINT32 DataPos)
  function ReadPCMTable (line 4699) | static void ReadPCMTable(UINT32 DataSize, const UINT8* Data)
  function InterpretVGM (line 4723) | static void InterpretVGM(UINT32 SampleCount)
  function GeneralChipLists (line 5721) | static void GeneralChipLists(void)
  function SetupResampler (line 5789) | static void SetupResampler(CAUD_ATTR* CAA)
  function ChangeChipSampleRate (line 5830) | static void ChangeChipSampleRate(void* DataPtr, UINT32 NewSmplRate)
  function INLINE (line 5853) | INLINE INT16 Limit2Short(INT32 Value)
  function null_update (line 5866) | static void null_update(UINT8 ChipID, stream_sample_t **outputs, int sam...
  function dual_opl2_stereo (line 5874) | static void dual_opl2_stereo(UINT8 ChipID, stream_sample_t **outputs, in...
  type UINT32 (line 5891) | typedef UINT32	SLINT;
  type UINT64 (line 5893) | typedef UINT64	SLINT;
  function ResampleChipStream (line 5904) | static void ResampleChipStream(CA_LIST* CLst, WAVE_32BS* RetSample, UINT...
  function INT32 (line 6138) | static INT32 RecalcFadeVolume(void)
  function UINT32 (line 6161) | UINT32 FillBuffer(WAVE_16BS* Buffer, UINT32 BufferSize)
  function DWORD (line 6303) | DWORD WINAPI PlayingThread(void* Arg)
  function UINT64 (line 6376) | UINT64 TimeSpec2Int64(const struct timespec* ts)
  type timespec (line 6389) | struct timespec

FILE: VGMPlay/VGMPlay.h
  type CHIP_OPTS (line 12) | typedef struct chip_options
  type CHIPS_OPTION (line 31) | typedef struct chips_options

FILE: VGMPlay/VGMPlayUI.c
  type termios (line 223) | struct termios
  function BOOL (line 239) | static BOOL WINAPI signal_handler(DWORD dwCtrlType)
  function signal_handler (line 255) | static void signal_handler(int signal)
  function main (line 262) | int main(int argc, char* argv[])
  function RemoveNewLines (line 674) | static void RemoveNewLines(char* String)
  function RemoveQuotationMarks (line 688) | static void RemoveQuotationMarks(char* String)
  function IsAbsolutePath (line 718) | static bool IsAbsolutePath(const char* FilePath)
  function StandardizeDirSeparators (line 749) | static void StandardizeDirSeparators(char* FilePath)
  function WinNT_Check (line 765) | static void WinNT_Check(void)
  function cls (line 815) | static void cls(void)
  function changemode (line 856) | static void changemode(bool dir)
  function _kbhit (line 878) | static int _kbhit(void)
  function _getch (line 902) | static int _getch(void)
  function INT8 (line 918) | static INT8 stricmp_u(const char *string1, const char *string2)
  function INT8 (line 948) | static INT8 strnicmp_u(const char *string1, const char *string2, size_t ...
  function ReadOptions (line 980) | static void ReadOptions(const char* AppName)
  function GetBoolFromStr (line 1628) | static bool GetBoolFromStr(const char* TextStr)
  function XMas_Extra (line 1639) | static bool XMas_Extra(char* FileName, bool Mode)
  function ConvertCP1252toUTF8 (line 1730) | static void ConvertCP1252toUTF8(char** DstStr, const char* SrcStr)
  function OpenPlayListFile (line 1794) | static bool OpenPlayListFile(const char* FileName)
  function OpenMusicFile (line 1912) | static bool OpenMusicFile(const char* FileName)
  function wprintc (line 1922) | static void wprintc(const wchar_t* format, ...)
  function PrintChipStr (line 1977) | static void PrintChipStr(UINT8 ChipID, UINT8 SubType, UINT32 Clock)
  function wchar_t (line 1997) | const wchar_t* GetTagStrEJ(const wchar_t* EngTag, const wchar_t* JapTag)
  function ShowVGMTag (line 2023) | static void ShowVGMTag(void)
  function MMKey_Event (line 2151) | static void MMKey_Event(UINT8 event)
  function PlayVGM_UI (line 2159) | static void PlayVGM_UI(void)
  function INLINE (line 2718) | INLINE INT8 sign(double Value)
  function Round (line 2728) | INLINE long int Round(double Value)
  function INLINE (line 2734) | INLINE double RoundSpecial(double Value, double RoundTo)
  function PrintMinSec (line 2739) | static void PrintMinSec(UINT32 SamplePos, UINT32 SmplRate)

FILE: VGMPlay/VGMPlay_AddFmts.c
  type CMF_HEADER (line 27) | typedef struct _cmf_file_header
  type CMF_INSTRUMENT (line 42) | typedef struct _cmf_instrument_table
  type DRO_HEADER (line 53) | typedef struct _dro_file_header
  type DRO_VER_HEADER_1 (line 59) | typedef struct _dro_version_header_1
  type DRO_VER_HEADER_2 (line 65) | typedef struct _dro_version_header_2
  function OpenOtherFile (line 138) | bool OpenOtherFile(const char* FileName)
  function INLINE (line 430) | INLINE UINT16 ReadLE16(const UINT8* Data)
  function INLINE (line 440) | INLINE UINT32 ReadLE32(const UINT8* Data)
  function INLINE (line 451) | INLINE int gzgetLE32(gzFile hFile, UINT32* RetValue)
  function UINT32 (line 466) | static UINT32 GetMIDIDelay(UINT32* DelayLen)
  function UINT16 (line 483) | static UINT16 MIDINote2FNum(UINT8 Note, INT8 Pitch)
  function SendMIDIVolume (line 501) | static void SendMIDIVolume(UINT8 ChipID, UINT8 Channel, UINT8 Command,
  function InterpretOther (line 569) | void InterpretOther(UINT32 SampleCount)
  function INLINE (line 1144) | INLINE INT32 SampleVGM2Playback(INT32 SampleVal)
  function INLINE (line 1149) | INLINE INT32 SamplePlayback2VGM(INT32 SampleVal)

FILE: VGMPlay/VGMPlay_Intf.h
  type WAVE_16BS (line 10) | typedef struct waveform_16bit_stereo
  type WAVE_32BS (line 16) | typedef struct waveform_32bit_stereo

FILE: VGMPlay/chips/2151intf.c
  type ym2151_state (line 24) | typedef struct _ym2151_state ym2151_state;
  type _ym2151_state (line 25) | struct _ym2151_state
  function ym2151_update (line 52) | void ym2151_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_ym2151 (line 82) | int device_start_ym2151(UINT8 ChipID, int clock)
  function device_stop_ym2151 (line 128) | void device_stop_ym2151(UINT8 ChipID)
  function device_reset_ym2151 (line 147) | void device_reset_ym2151(UINT8 ChipID)
  function UINT8 (line 167) | UINT8 ym2151_r(UINT8 ChipID, offs_t offset)
  function ym2151_w (line 188) | void ym2151_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 217) | UINT8 ym2151_status_port_r(UINT8 ChipID, offs_t offset)
  function ym2151_register_port_w (line 222) | void ym2151_register_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2151_data_port_w (line 226) | void ym2151_data_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2151_set_emu_core (line 232) | void ym2151_set_emu_core(UINT8 Emulator)
  function ym2151_set_mute_mask (line 244) | void ym2151_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/2203intf.c
  type ym2203_state (line 17) | typedef struct _ym2203_state ym2203_state;
  type _ym2203_state (line 18) | struct _ym2203_state
  function psg_set_clock (line 49) | static void psg_set_clock(void *param, int clock)
  function psg_write (line 68) | static void psg_write(void *param, int address, int data)
  function psg_read (line 87) | static int psg_read(void *param)
  function psg_reset (line 105) | static void psg_reset(void *param)
  function ym2203_update_request (line 155) | void ym2203_update_request(void *param)
  function ym2203_stream_update (line 195) | void ym2203_stream_update(UINT8 ChipID, stream_sample_t **outputs, int s...
  function ym2203_stream_update_ay (line 202) | void ym2203_stream_update_ay(UINT8 ChipID, stream_sample_t **outputs, in...
  function device_start_ym2203 (line 239) | int device_start_ym2203(UINT8 ChipID, int clock, UINT8 AYDisable, UINT8 ...
  function device_stop_ym2203 (line 322) | void device_stop_ym2203(UINT8 ChipID)
  function device_reset_ym2203 (line 345) | void device_reset_ym2203(UINT8 ChipID)
  function UINT8 (line 356) | UINT8 ym2203_r(UINT8 ChipID, offs_t offset)
  function ym2203_w (line 364) | void ym2203_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 373) | UINT8 ym2203_status_port_r(UINT8 ChipID, offs_t offset)
  function UINT8 (line 378) | UINT8 ym2203_read_port_r(UINT8 ChipID, offs_t offset)
  function ym2203_control_port_w (line 383) | void ym2203_control_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2203_write_port_w (line 388) | void ym2203_write_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2203_set_ay_emu_core (line 394) | void ym2203_set_ay_emu_core(UINT8 Emulator)
  function ym2203_set_mute_mask (line 405) | void ym2203_set_mute_mask(UINT8 ChipID, UINT32 MuteMaskFM, UINT32 MuteMa...
  function ym2203_set_stereo_mask_ay (line 425) | void ym2203_set_stereo_mask_ay(UINT8 ChipID, UINT32 StereoMaskAY)
  function ym2203_set_srchg_cb (line 444) | void ym2203_set_srchg_cb(UINT8 ChipID, SRATE_CALLBACK CallbackFunc, void...

FILE: VGMPlay/chips/2203intf.h
  type ym2203_interface (line 8) | typedef struct _ym2203_interface ym2203_interface;
  type _ym2203_interface (line 9) | struct _ym2203_interface

FILE: VGMPlay/chips/2413intf.c
  type ym2413_state (line 26) | typedef struct _ym2413_state ym2413_state;
  type _ym2413_state (line 27) | struct _ym2413_state
  function YM2413DAC_update (line 56) | void YM2413DAC_update(int chip,stream_sample_t **inputs, stream_sample_t...
  function _emu2413_calc_stereo (line 69) | static void _emu2413_calc_stereo(OPLL *opll, INT32 **out, int samples)
  function _emu2413_set_mute_mask (line 84) | static void _emu2413_set_mute_mask(OPLL *opll, UINT32 MuteMask)
  function ym2413_stream_update (line 129) | void ym2413_stream_update(UINT8 ChipID, stream_sample_t **outputs, int s...
  function _stream_update (line 148) | static void _stream_update(void *param, int interval)
  function device_start_ym2413 (line 170) | int device_start_ym2413(UINT8 ChipID, int clock)
  function device_stop_ym2413 (line 251) | void device_stop_ym2413(UINT8 ChipID)
  function device_reset_ym2413 (line 272) | void device_reset_ym2413(UINT8 ChipID)
  function ym2413_w (line 301) | void ym2413_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2413_register_port_w (line 322) | void ym2413_register_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2413_data_port_w (line 327) | void ym2413_data_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2413_set_emu_core (line 333) | void ym2413_set_emu_core(UINT8 Emulator)
  function ym2413_set_mute_mask (line 344) | void ym2413_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function ym2413_set_panning (line 365) | void ym2413_set_panning(UINT8 ChipID, INT16* PanVals)

FILE: VGMPlay/chips/2608intf.c
  type ym2608_state (line 29) | typedef struct _ym2608_state ym2608_state;
  type _ym2608_state (line 30) | struct _ym2608_state
  function psg_set_clock (line 62) | static void psg_set_clock(void *param, int clock)
  function psg_write (line 81) | static void psg_write(void *param, int address, int data)
  function psg_read (line 100) | static int psg_read(void *param)
  function psg_reset (line 118) | static void psg_reset(void *param)
  function ym2608_update_request (line 183) | void ym2608_update_request(void *param)
  function ym2608_stream_update (line 195) | void ym2608_stream_update(UINT8 ChipID, stream_sample_t **outputs, int s...
  function ym2608_stream_update_ay (line 202) | void ym2608_stream_update_ay(UINT8 ChipID, stream_sample_t **outputs, in...
  function device_start_ym2608 (line 239) | int device_start_ym2608(UINT8 ChipID, int clock, UINT8 AYDisable, UINT8 ...
  function device_stop_ym2608 (line 325) | void device_stop_ym2608(UINT8 ChipID)
  function device_reset_ym2608 (line 348) | void device_reset_ym2608(UINT8 ChipID)
  function UINT8 (line 358) | UINT8 ym2608_r(UINT8 ChipID, offs_t offset)
  function ym2608_w (line 366) | void ym2608_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 374) | UINT8 ym2608_read_port_r(UINT8 ChipID, offs_t offset)
  function UINT8 (line 379) | UINT8 ym2608_status_port_a_r(UINT8 ChipID, offs_t offset)
  function UINT8 (line 384) | UINT8 ym2608_status_port_b_r(UINT8 ChipID, offs_t offset)
  function ym2608_control_port_a_w (line 390) | void ym2608_control_port_a_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2608_control_port_b_w (line 395) | void ym2608_control_port_b_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2608_data_port_a_w (line 400) | void ym2608_data_port_a_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2608_data_port_b_w (line 405) | void ym2608_data_port_b_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2608_set_ay_emu_core (line 411) | void ym2608_set_ay_emu_core(UINT8 Emulator)
  function ym2608_write_data_pcmrom (line 422) | void ym2608_write_data_pcmrom(UINT8 ChipID, UINT8 rom_id, offs_t ROMSize...
  function ym2608_set_mute_mask (line 429) | void ym2608_set_mute_mask(UINT8 ChipID, UINT32 MuteMaskFM, UINT32 MuteMa...
  function ym2608_set_srchg_cb (line 449) | void ym2608_set_srchg_cb(UINT8 ChipID, SRATE_CALLBACK CallbackFunc, void...

FILE: VGMPlay/chips/2608intf.h
  type ym2608_interface (line 9) | typedef struct _ym2608_interface ym2608_interface;
  type _ym2608_interface (line 10) | struct _ym2608_interface

FILE: VGMPlay/chips/2610intf.c
  type ym2610_state (line 29) | typedef struct _ym2610_state ym2610_state;
  type _ym2610_state (line 30) | struct _ym2610_state
  function psg_set_clock (line 62) | static void psg_set_clock(void *param, int clock)
  function psg_write (line 81) | static void psg_write(void *param, int address, int data)
  function psg_read (line 100) | static int psg_read(void *param)
  function psg_reset (line 118) | static void psg_reset(void *param)
  function ym2610_update_request (line 184) | void ym2610_update_request(void *param)
  function ym2610_stream_update (line 197) | void ym2610_stream_update(UINT8 ChipID, stream_sample_t **outputs, int s...
  function ym2610b_stream_update (line 205) | void ym2610b_stream_update(UINT8 ChipID, stream_sample_t **outputs, int ...
  function ym2610_stream_update_ay (line 212) | void ym2610_stream_update_ay(UINT8 ChipID, stream_sample_t **outputs, in...
  function device_start_ym2610 (line 249) | int device_start_ym2610(UINT8 ChipID, int clock, UINT8 AYDisable, int* A...
  function device_stop_ym2610 (line 344) | void device_stop_ym2610(UINT8 ChipID)
  function device_reset_ym2610 (line 367) | void device_reset_ym2610(UINT8 ChipID)
  function UINT8 (line 377) | UINT8 ym2610_r(UINT8 ChipID, offs_t offset)
  function ym2610_w (line 385) | void ym2610_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 394) | UINT8 ym2610_status_port_a_r(UINT8 ChipID, offs_t offset)
  function UINT8 (line 399) | UINT8 ym2610_status_port_b_r(UINT8 ChipID, offs_t offset)
  function UINT8 (line 404) | UINT8 ym2610_read_port_r(UINT8 ChipID, offs_t offset)
  function ym2610_control_port_a_w (line 410) | void ym2610_control_port_a_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2610_control_port_b_w (line 415) | void ym2610_control_port_b_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2610_data_port_a_w (line 420) | void ym2610_data_port_a_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2610_data_port_b_w (line 425) | void ym2610_data_port_b_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2610_set_ay_emu_core (line 431) | void ym2610_set_ay_emu_core(UINT8 Emulator)
  function ym2610_write_data_pcmrom (line 442) | void ym2610_write_data_pcmrom(UINT8 ChipID, UINT8 rom_id, offs_t ROMSize...
  function ym2610_set_mute_mask (line 449) | void ym2610_set_mute_mask(UINT8 ChipID, UINT32 MuteMaskFM, UINT32 MuteMa...

FILE: VGMPlay/chips/2612intf.c
  type ym2612_state (line 35) | typedef struct _ym2612_state ym2612_state;
  type _ym2612_state (line 36) | struct _ym2612_state
  function ym2612_update_request (line 104) | void ym2612_update_request(void *param)
  function ym2612_stream_update (line 130) | void ym2612_stream_update(UINT8 ChipID, stream_sample_t **outputs, int s...
  function device_start_ym2612 (line 172) | int device_start_ym2612(UINT8 ChipID, int clock)
  function device_stop_ym2612 (line 239) | void device_stop_ym2612(UINT8 ChipID)
  function device_reset_ym2612 (line 266) | void device_reset_ym2612(UINT8 ChipID)
  function UINT8 (line 288) | UINT8 ym2612_r(UINT8 ChipID, offs_t offset)
  function ym2612_w (line 308) | void ym2612_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 338) | UINT8 ym2612_status_port_a_r(UINT8 ChipID, offs_t offset)
  function UINT8 (line 342) | UINT8 ym2612_status_port_b_r(UINT8 ChipID, offs_t offset)
  function UINT8 (line 346) | UINT8 ym2612_data_port_a_r(UINT8 ChipID, offs_t offset)
  function UINT8 (line 350) | UINT8 ym2612_data_port_b_r(UINT8 ChipID, offs_t offset)
  function ym2612_control_port_a_w (line 355) | void ym2612_control_port_a_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2612_control_port_b_w (line 359) | void ym2612_control_port_b_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2612_data_port_a_w (line 363) | void ym2612_data_port_a_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2612_data_port_b_w (line 367) | void ym2612_data_port_b_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym2612_set_emu_core (line 373) | void ym2612_set_emu_core(UINT8 Emulator)
  function ym2612_set_options (line 384) | void ym2612_set_options(UINT8 Flags)
  function ym2612_set_mute_mask (line 405) | void ym2612_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/262intf.c
  type ymf262_state (line 26) | typedef struct _ymf262_state ymf262_state;
  type _ymf262_state (line 27) | struct _ymf262_state
  function IRQHandler_262 (line 56) | static void IRQHandler_262(void *param,int irq)
  function timer_handler_262 (line 75) | static void timer_handler_262(void *param,int timer, int period)
  function ymf262_stream_update (line 89) | void ymf262_stream_update(UINT8 ChipID, stream_sample_t **outputs, int s...
  function _stream_update (line 106) | static void _stream_update(void *param/*, int interval*/)
  function device_start_ymf262 (line 126) | int device_start_ymf262(UINT8 ChipID, int clock)
  function device_stop_ymf262 (line 174) | void device_stop_ymf262(UINT8 ChipID)
  function device_reset_ymf262 (line 193) | void device_reset_ymf262(UINT8 ChipID)
  function UINT8 (line 212) | UINT8 ymf262_r(UINT8 ChipID, offs_t offset)
  function ymf262_w (line 230) | void ymf262_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 248) | UINT8 ymf262_status_r(UINT8 ChipID, offs_t offset)
  function ymf262_register_a_w (line 253) | void ymf262_register_a_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ymf262_register_b_w (line 258) | void ymf262_register_b_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ymf262_data_a_w (line 263) | void ymf262_data_a_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ymf262_data_b_w (line 268) | void ymf262_data_b_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ymf262_set_emu_core (line 274) | void ymf262_set_emu_core(UINT8 Emulator)
  function ymf262_set_mute_mask (line 285) | void ymf262_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/3526intf.c
  type ym3526_state (line 27) | typedef struct _ym3526_state ym3526_state;
  type _ym3526_state (line 28) | struct _ym3526_state
  function IRQHandler (line 54) | static void IRQHandler(void *param,int irq)
  function TimerHandler (line 73) | static void TimerHandler(void *param,int c,int period)
  function ym3526_stream_update (line 89) | void ym3526_stream_update(UINT8 ChipID, stream_sample_t **outputs, int s...
  function _stream_update (line 96) | static void _stream_update(void *param/*, int interval*/)
  function device_start_ym3526 (line 106) | int device_start_ym3526(UINT8 ChipID, int clock)
  function device_stop_ym3526 (line 142) | void device_stop_ym3526(UINT8 ChipID)
  function device_reset_ym3526 (line 150) | void device_reset_ym3526(UINT8 ChipID)
  function UINT8 (line 159) | UINT8 ym3526_r(UINT8 ChipID, offs_t offset)
  function ym3526_w (line 167) | void ym3526_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 175) | UINT8 ym3526_status_port_r(UINT8 ChipID, offs_t offset)
  function UINT8 (line 180) | UINT8 ym3526_read_port_r(UINT8 ChipID, offs_t offset)
  function ym3526_control_port_w (line 185) | void ym3526_control_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym3526_write_port_w (line 190) | void ym3526_write_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym3526_set_mute_mask (line 196) | void ym3526_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/3812intf.c
  type ym3812_state (line 39) | typedef struct _ym3812_state ym3812_state;
  type _ym3812_state (line 40) | struct _ym3812_state
  function IRQHandler (line 68) | static void IRQHandler(void *param,int irq)
  function TimerHandler (line 87) | static void TimerHandler(void *param,int c,int period)
  function ym3812_stream_update (line 103) | void ym3812_stream_update(UINT8 ChipID, stream_sample_t **outputs, int s...
  function _stream_update (line 120) | static void _stream_update(void * param/*, int interval*/)
  function device_start_ym3812 (line 140) | int device_start_ym3812(UINT8 ChipID, int clock)
  function device_stop_ym3812 (line 187) | void device_stop_ym3812(UINT8 ChipID)
  function device_reset_ym3812 (line 205) | void device_reset_ym3812(UINT8 ChipID)
  function UINT8 (line 224) | UINT8 ym3812_r(UINT8 ChipID, offs_t offset)
  function ym3812_w (line 242) | void ym3812_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 260) | UINT8 ym3812_status_port_r(UINT8 ChipID, offs_t offset)
  function UINT8 (line 265) | UINT8 ym3812_read_port_r(UINT8 ChipID, offs_t offset)
  function ym3812_control_port_w (line 270) | void ym3812_control_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym3812_write_port_w (line 275) | void ym3812_write_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ym3812_set_emu_core (line 281) | void ym3812_set_emu_core(UINT8 Emulator)
  function ym3812_set_mute_mask (line 292) | void ym3812_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/8950intf.c
  type y8950_state (line 30) | typedef struct _y8950_state y8950_state;
  type _y8950_state (line 31) | struct _y8950_state
  function IRQHandler (line 56) | static void IRQHandler(void *param,int irq)
  function TimerHandler (line 73) | static void TimerHandler(void *param,int c,int period)
  function Y8950PortHandler_r (line 88) | static unsigned char Y8950PortHandler_r(void *param)
  function Y8950PortHandler_w (line 96) | static void Y8950PortHandler_w(void *param,unsigned char data)
  function Y8950KeyboardHandler_r (line 103) | static unsigned char Y8950KeyboardHandler_r(void *param)
  function Y8950KeyboardHandler_w (line 111) | static void Y8950KeyboardHandler_w(void *param,unsigned char data)
  function y8950_stream_update (line 119) | void y8950_stream_update(UINT8 ChipID, stream_sample_t **outputs, int sa...
  function _stream_update (line 126) | static void _stream_update(void *param/*, int interval*/)
  function device_start_y8950 (line 136) | int device_start_y8950(UINT8 ChipID, int clock)
  function device_stop_y8950 (line 181) | void device_stop_y8950(UINT8 ChipID)
  function device_reset_y8950 (line 189) | void device_reset_y8950(UINT8 ChipID)
  function UINT8 (line 198) | UINT8 y8950_r(UINT8 ChipID, offs_t offset)
  function y8950_w (line 206) | void y8950_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 214) | UINT8 y8950_status_port_r(UINT8 ChipID, offs_t offset)
  function UINT8 (line 219) | UINT8 y8950_read_port_r(UINT8 ChipID, offs_t offset)
  function y8950_control_port_w (line 224) | void y8950_control_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function y8950_write_port_w (line 229) | void y8950_write_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function y8950_write_data_pcmrom (line 235) | void y8950_write_data_pcmrom(UINT8 ChipID, offs_t ROMSize, offs_t DataSt...
  function y8950_set_mute_mask (line 245) | void y8950_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/Ootake_PSG.c
  type PSG (line 203) | typedef struct
  type huc6280_state (line 223) | typedef struct
  function create_volume_table (line 311) | static void
  function create_noise_table (line 327) | static void
  function INLINE (line 353) | INLINE void
  function set_VOL (line 523) | static void
  function PSG_Mix (line 548) | void
  function psg_reset (line 669) | static void
  function PSG_Deinit (line 759) | void
  function Uint8 (line 782) | Uint8
  function PSG_Write (line 800) | void
  function PSG_SetVolume (line 836) | static void PSG_SetVolume(huc6280_state* info)
  function PSG_ResetVolumeReg (line 857) | void
  function PSG_SetMutePsgChannel (line 877) | void
  function PSG_SetMuteMask (line 893) | void PSG_SetMuteMask(void* chip, Uint32 MuteMask)
  function BOOL (line 904) | BOOL
  function PSG_SetHoneyInTheSky (line 915) | void

FILE: VGMPlay/chips/Ootake_PSG.h
  type UINT8 (line 24) | typedef UINT8	Uint8;
  type INT16 (line 25) | typedef INT16	Sint16;
  type INT32 (line 26) | typedef INT32	Sint32;
  type UINT32 (line 27) | typedef UINT32	Uint32;
  type UINT8 (line 28) | typedef UINT8	BOOL;

FILE: VGMPlay/chips/ay8910.c
  type ay_ym_param (line 186) | typedef struct _ay_ym_param ay_ym_param;
  type _ay_ym_param (line 187) | struct _ay_ym_param
  type ay8910_context (line 195) | typedef struct _ay8910_context ay8910_context;
  type _ay8910_context (line 196) | struct _ay8910_context
  function INLINE (line 387) | INLINE void build_3D_table(double rl, const ay_ym_param *par, const ay_y...
  function INLINE (line 459) | INLINE void build_single_table(double rl, const ay_ym_param *par, int no...
  function INLINE (line 502) | INLINE UINT16 mix_3D(ay8910_context *psg)
  function ay8910_write_reg (line 532) | static void ay8910_write_reg(ay8910_context *psg, int r, int v)
  function ay8910_update_one (line 640) | void ay8910_update_one(void *param, stream_sample_t **outputs, int samples)
  function build_mixer_table (line 820) | static void build_mixer_table(ay8910_context *psg)
  function ay8910_stop_ym (line 969) | void ay8910_stop_ym(void *chip)
  function ay8910_reset_ym (line 974) | void ay8910_reset_ym(void *chip)
  function ay8910_set_clock_ym (line 1024) | void ay8910_set_clock_ym(void *chip, int clock)
  function ay8910_write_ym (line 1038) | void ay8910_write_ym(void *chip, int addr, int data)
  function ay8910_read_ym (line 1061) | int ay8910_read_ym(void *chip)
  function ay8910_start (line 1138) | int ay8910_start(void **chip, int clock, UINT8 chip_type, UINT8 Flags)
  function ay8910_set_mute_mask_ym (line 1327) | void ay8910_set_mute_mask_ym(void *chip, UINT32 MuteMask)
  function ay8910_set_stereo_mask_ym (line 1338) | void ay8910_set_stereo_mask_ym(void *chip, UINT32 StereoMask)
  function ay8910_set_srchg_cb_ym (line 1356) | void ay8910_set_srchg_cb_ym(void *chip, SRATE_CALLBACK CallbackFunc, voi...

FILE: VGMPlay/chips/ay8910.h
  type ay8910_interface (line 75) | typedef struct _ay8910_interface ay8910_interface;
  type _ay8910_interface (line 76) | struct _ay8910_interface

FILE: VGMPlay/chips/ay8910_opl.c
  type ay_ym_param (line 38) | typedef struct _ay_ym_param ay_ym_param;
  type _ay_ym_param (line 39) | struct _ay_ym_param
  type ay8910_context_opl (line 47) | typedef struct _ay8910_context_opl ay8910_context_opl;
  type _ay8910_context_opl (line 48) | struct _ay8910_context_opl
  function SendVolume (line 140) | static void SendVolume(ay8910_context_opl* chip, UINT8 Channel)
  function SendFrequency (line 171) | static void SendFrequency(ay8910_context_opl* chip, UINT8 Channel)
  function ay8910_write_opl (line 225) | void ay8910_write_opl(UINT8 ChipID, UINT8 r, UINT8 v)
  function INLINE (line 283) | INLINE void build_single_table(double rl, const ay_ym_param *par, INT32 ...
  function ay8910_start_opl (line 316) | static void ay8910_start_opl(int clock, ay8910_context_opl* chip, UINT8 ...
  function start_ay8910_opl (line 381) | void start_ay8910_opl(UINT8 ChipID, int clock, UINT8 chip_type)

FILE: VGMPlay/chips/ay_intf.c
  type ayxx_state (line 25) | typedef struct _ayxx_state ayxx_state;
  type _ayxx_state (line 26) | struct _ayxx_state
  function ayxx_stream_update (line 39) | void ayxx_stream_update(UINT8 ChipID, stream_sample_t **outputs, int sam...
  function device_start_ayxx (line 55) | int device_start_ayxx(UINT8 ChipID, int clock, UINT8 chip_type, UINT8 Fl...
  function device_stop_ayxx (line 93) | void device_stop_ayxx(UINT8 ChipID)
  function device_reset_ayxx (line 110) | void device_reset_ayxx(UINT8 ChipID)
  function ayxx_w (line 127) | void ayxx_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ayxx_set_emu_core (line 143) | void ayxx_set_emu_core(UINT8 Emulator)
  function ayxx_set_mute_mask (line 154) | void ayxx_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function ayxx_set_stereo_mask (line 172) | void ayxx_set_stereo_mask(UINT8 ChipID, UINT32 StereoMask)

FILE: VGMPlay/chips/c140.c
  type voice_registers (line 55) | struct voice_registers
  type VOICE (line 72) | typedef struct
  type c140_state (line 94) | typedef struct _c140_state c140_state;
  type _c140_state (line 95) | struct _c140_state
  function init_voice (line 128) | static void init_voice( VOICE *v )
  function UINT8 (line 142) | UINT8 c140_r(UINT8 ChipID, offs_t offset)
  function find_sample (line 158) | static long find_sample(c140_state *info, long adrs, long bank, int voice)
  function c140_w (line 215) | void c140_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function c140_set_base (line 279) | void c140_set_base(UINT8 ChipID, void *base)
  function c140_update (line 294) | void c140_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_c140 (line 497) | int device_start_c140(UINT8 ChipID, int clock, int banking_type)
  function device_stop_c140 (line 558) | void device_stop_c140(UINT8 ChipID)
  function device_reset_c140 (line 568) | void device_reset_c140(UINT8 ChipID)
  function c140_write_rom (line 581) | void c140_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, offs...
  function c140_set_mute_mask (line 603) | void c140_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/c352.c
  type C352_Voice (line 49) | typedef struct {
  type C352 (line 72) | typedef struct {
  function C352_fetch_sample (line 100) | static void C352_fetch_sample(C352 *c, C352_Voice *v)
  function c352_ramp_volume (line 161) | static void c352_ramp_volume(C352_Voice* v,int ch,UINT8 val)
  function c352_update (line 168) | void c352_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_c352 (line 239) | int device_start_c352(UINT8 ChipID, int clock, int clkdiv)
  function device_stop_c352 (line 281) | void device_stop_c352(UINT8 ChipID)
  function device_reset_c352 (line 291) | void device_reset_c352(UINT8 ChipID)
  function UINT16 (line 321) | UINT16 c352_r(UINT8 ChipID, offs_t address)
  function c352_w (line 333) | void c352_w(UINT8 ChipID, offs_t address, UINT16 val)
  function c352_write_rom (line 376) | void c352_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, offs...
  function c352_set_mute_mask (line 400) | void c352_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function UINT32 (line 411) | UINT32 c352_get_mute_mask(UINT8 ChipID)
  function c352_set_options (line 424) | void c352_set_options(UINT8 Flags)

FILE: VGMPlay/chips/c6280.c
  type t_channel (line 63) | typedef struct {
  type c6280_t (line 76) | typedef struct {
  function c6280_init (line 102) | static void c6280_init(/*device_t *device,*/ c6280_t *p, double clk, dou...
  function c6280_write (line 146) | static void c6280_write(c6280_t *p, int offset, int data)
  function c6280m_update (line 230) | void c6280m_update(void* param, stream_sample_t **outputs, int samples)
  function device_stop_c6280m (line 356) | void device_stop_c6280m(void* chip)
  function device_reset_c6280m (line 365) | void device_reset_c6280m(void* chip)
  function UINT8 (line 395) | UINT8 c6280m_r(void* chip, offs_t offset)
  function c6280m_w (line 406) | void c6280m_w(void* chip, offs_t offset, UINT8 data)
  function c6280m_set_mute_mask (line 415) | void c6280m_set_mute_mask(void* chip, UINT32 MuteMask)

FILE: VGMPlay/chips/c6280.h
  type c6280_interface (line 5) | typedef struct _c6280_interface c6280_interface;
  type _c6280_interface (line 6) | struct _c6280_interface

FILE: VGMPlay/chips/c6280intf.c
  type c6280_state (line 13) | typedef struct _c6280_state
  function c6280_update (line 26) | void c6280_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_c6280 (line 42) | int device_start_c6280(UINT8 ChipID, int clock)
  function device_stop_c6280 (line 76) | void device_stop_c6280(UINT8 ChipID)
  function device_reset_c6280 (line 95) | void device_reset_c6280(UINT8 ChipID)
  function UINT8 (line 112) | UINT8 c6280_r(UINT8 ChipID, offs_t offset)
  function c6280_w (line 128) | void c6280_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function c6280_set_emu_core (line 147) | void c6280_set_emu_core(UINT8 Emulator)
  function c6280_set_mute_mask (line 158) | void c6280_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/dac_control.c
  type dac_control (line 30) | typedef struct _dac_control
  function INLINE (line 62) | INLINE void daccontrol_SendCommand(dac_control *chip)
  function INLINE (line 215) | INLINE UINT32 muldiv64round(UINT32 Multiplicand, UINT32 Multiplier, UINT...
  function daccontrol_update (line 221) | void daccontrol_update(UINT8 ChipID, UINT32 samples)
  function UINT8 (line 282) | UINT8 device_start_daccontrol(UINT8 ChipID)
  function device_stop_daccontrol (line 300) | void device_stop_daccontrol(UINT8 ChipID)
  function device_reset_daccontrol (line 309) | void device_reset_daccontrol(UINT8 ChipID)
  function daccontrol_setup_chip (line 336) | void daccontrol_setup_chip(UINT8 ChipID, UINT8 ChType, UINT8 ChNum, UINT...
  function daccontrol_set_data (line 368) | void daccontrol_set_data(UINT8 ChipID, UINT8* Data, UINT32 DataLen, UINT...
  function daccontrol_refresh_data (line 392) | void daccontrol_refresh_data(UINT8 ChipID, UINT8* Data, UINT32 DataLen)
  function daccontrol_set_frequency (line 414) | void daccontrol_set_frequency(UINT8 ChipID, UINT32 Frequency)
  function daccontrol_start (line 428) | void daccontrol_start(UINT8 ChipID, UINT32 DataPos, UINT8 LenMode, UINT3...
  function daccontrol_stop (line 483) | void daccontrol_stop(UINT8 ChipID)

FILE: VGMPlay/chips/emu2149.c
  function internal_refresh (line 40) | static void
  function EMU2149_API (line 57) | EMU2149_API void
  function EMU2149_API (line 64) | EMU2149_API void
  function EMU2149_API (line 71) | EMU2149_API void
  function EMU2149_API (line 78) | EMU2149_API PSG *
  function EMU2149_API (line 99) | EMU2149_API void
  function EMU2149_API (line 119) | EMU2149_API void
  function EMU2149_API (line 136) | EMU2149_API e_uint32
  function EMU2149_API (line 148) | EMU2149_API void
  function EMU2149_API (line 160) | EMU2149_API e_uint32
  function EMU2149_API (line 172) | EMU2149_API void
  function EMU2149_API (line 207) | EMU2149_API void
  function EMU2149_API (line 213) | EMU2149_API e_uint8
  function EMU2149_API (line 219) | EMU2149_API e_uint8
  function EMU2149_API (line 226) | EMU2149_API void
  function INLINE (line 235) | INLINE static e_int16
  function EMU2149_API (line 324) | EMU2149_API e_int16
  function INLINE (line 343) | INLINE static void
  function EMU2149_API (line 437) | EMU2149_API void
  function EMU2149_API (line 473) | EMU2149_API void

FILE: VGMPlay/chips/emu2149.h
  type PSG (line 27) | typedef struct __PSG

FILE: VGMPlay/chips/emu2413.c
  type __OPLL_EG_STATE (line 212) | enum __OPLL_EG_STATE { ATTACK, DECAY, SUSTAIN, RELEASE, DAMP, UNKNOWN }
  function blackman (line 252) | static double blackman(double x) { return 0.42 - 0.5 * cos(2 * _PI_ * x)...
  function sinc (line 253) | static double sinc(double x) { return (x == 0.0 ? 1.0 : sin(_PI_ * x) / ...
  function windowed_sinc (line 254) | static double windowed_sinc(double x) { return blackman(0.5 + 0.5 * x / ...
  function OPLL_RateConv (line 257) | OPLL_RateConv *OPLL_RateConv_new(double f_inp, double f_out, int ch) {
  function INLINE (line 284) | static INLINE int16_t lookup_sinc_table(int16_t *table, double x) {
  function OPLL_RateConv_reset (line 291) | void OPLL_RateConv_reset(OPLL_RateConv *conv) {
  function OPLL_RateConv_putData (line 300) | void OPLL_RateConv_putData(OPLL_RateConv *conv, int ch, int16_t data) {
  function OPLL_RateConv_getData (line 311) | int16_t OPLL_RateConv_getData(OPLL_RateConv *conv, int ch) {
  function OPLL_RateConv_delete (line 327) | void OPLL_RateConv_delete(OPLL_RateConv *conv) {
  function makeSinTable (line 343) | static void makeSinTable(void) {
  function makeTllTable (line 361) | static void makeTllTable(void) {
  function makeRksTable (line 385) | static void makeRksTable(void) {
  function makeDefaultPatch (line 394) | static void makeDefaultPatch() {
  function initializeTables (line 403) | static void initializeTables() {
  function _debug_print_patch (line 429) | static void _debug_print_patch(OPLL_SLOT *slot) {
  function INLINE (line 454) | static INLINE void _debug_print_slot_info(OPLL_SLOT *slot) {
  function INLINE (line 463) | static INLINE int get_parameter_rate(OPLL_SLOT *slot) {
  type SLOT_UPDATE_FLAG (line 491) | enum SLOT_UPDATE_FLAG {
  function INLINE (line 499) | static INLINE void request_update(OPLL_SLOT *slot, int flag) { slot->upd...
  function commit_slot_update (line 501) | static void commit_slot_update(OPLL_SLOT *slot) {
  function reset_slot (line 548) | static void reset_slot(OPLL_SLOT *slot, int number) {
  function INLINE (line 571) | static INLINE void slotOn(OPLL *opll, int i) {
  function INLINE (line 578) | static INLINE void slotOff(OPLL *opll, int i) {
  function INLINE (line 587) | static INLINE void update_key_status(OPLL *opll) {
  function INLINE (line 632) | static INLINE void set_patch(OPLL *opll, int32_t ch, int32_t num) {
  function INLINE (line 640) | static INLINE void set_sus_flag(OPLL *opll, int ch, int flag) {
  function INLINE (line 650) | static INLINE void set_volume(OPLL *opll, int ch, int volume) {
  function INLINE (line 655) | static INLINE void set_slot_volume(OPLL_SLOT *slot, int volume) {
  function INLINE (line 661) | static INLINE void set_fnumber(OPLL *opll, int ch, int fnum) {
  function INLINE (line 673) | static INLINE void set_block(OPLL *opll, int ch, int blk) {
  function INLINE (line 684) | static INLINE void update_rhythm_mode(OPLL *opll) {
  function update_ampm (line 717) | static void update_ampm(OPLL *opll) {
  function update_noise (line 728) | static void update_noise(OPLL *opll, int cycle) {
  function update_short_noise (line 738) | static void update_short_noise(OPLL *opll) {
  function INLINE (line 752) | static INLINE void calc_phase(OPLL_SLOT *slot, int32_t pm_phase, uint8_t...
  function INLINE (line 762) | static INLINE uint8_t lookup_attack_step(OPLL_SLOT *slot, uint32_t count...
  function INLINE (line 784) | static INLINE uint8_t lookup_decay_step(OPLL_SLOT *slot, uint32_t counte...
  function INLINE (line 804) | static INLINE void start_envelope(OPLL_SLOT *slot) {
  function INLINE (line 815) | static INLINE void calc_envelope(OPLL_SLOT *slot, OPLL_SLOT *buddy, uint...
  function update_slots (line 873) | static void update_slots(OPLL *opll) {
  function INLINE (line 895) | static INLINE int16_t lookup_exp_table(uint16_t i) {
  function INLINE (line 902) | static INLINE int16_t to_linear(uint16_t h, OPLL_SLOT *slot, int16_t am) {
  function INLINE (line 911) | static INLINE int16_t calc_slot_car(OPLL *opll, int ch, int16_t fm) {
  function INLINE (line 922) | static INLINE int16_t calc_slot_mod(OPLL *opll, int ch) {
  function INLINE (line 934) | static INLINE int16_t calc_slot_tom(OPLL *opll) {
  function INLINE (line 943) | static INLINE int16_t calc_slot_snare(OPLL *opll) {
  function INLINE (line 956) | static INLINE int16_t calc_slot_cym(OPLL *opll) {
  function INLINE (line 964) | static INLINE int16_t calc_slot_hat(OPLL *opll) {
  function update_output (line 980) | static void update_output(OPLL *opll) {
  function INLINE (line 1040) | INLINE static void mix_output(OPLL *opll) {
  function INLINE (line 1053) | INLINE static void mix_output_stereo(OPLL *opll) {
  function OPLL (line 1076) | OPLL *OPLL_new(uint32_t clk, uint32_t rate) {
  function OPLL_delete (line 1104) | void OPLL_delete(OPLL *opll) {
  function reset_rate_conversion_params (line 1112) | static void reset_rate_conversion_params(OPLL *opll) {
  function OPLL_reset (line 1134) | void OPLL_reset(OPLL *opll) {
  function OPLL_forceRefresh (line 1174) | void OPLL_forceRefresh(OPLL *opll) {
  function OPLL_setRate (line 1189) | void OPLL_setRate(OPLL *opll, uint32_t rate) {
  function OPLL_setQuality (line 1194) | void OPLL_setQuality(OPLL *opll, uint8_t q) {}
  function OPLL_setChipType (line 1196) | void OPLL_setChipType(OPLL *opll, uint8_t type) { opll->chip_type = type; }
  function OPLL_writeReg (line 1198) | void OPLL_writeReg(OPLL *opll, uint32_t reg, uint8_t data) {
  function OPLL_writeIO (line 1372) | void OPLL_writeIO(OPLL *opll, uint32_t adr, uint8_t val) {
  function OPLL_setPan (line 1379) | void OPLL_setPan(OPLL *opll, uint32_t ch, uint8_t pan) { opll->pan[ch & ...
  function OPLL_setPanEx (line 1381) | void OPLL_setPanEx(OPLL *opll, uint32_t ch, int16_t pan) {
  function OPLL_setPanFine (line 1385) | void OPLL_setPanFine(OPLL *opll, uint32_t ch, float pan[2]) {
  function OPLL_dumpToPatch (line 1390) | void OPLL_dumpToPatch(const uint8_t *dump, OPLL_PATCH *patch) {
  function OPLL_getDefaultPatch (line 1419) | void OPLL_getDefaultPatch(int32_t type, int32_t num, OPLL_PATCH *patch) {
  function OPLL_setPatch (line 1423) | void OPLL_setPatch(OPLL *opll, const uint8_t *dump) {
  function OPLL_patchToDump (line 1433) | void OPLL_patchToDump(const OPLL_PATCH *patch, uint8_t *dump) {
  function OPLL_copyPatch (line 1444) | void OPLL_copyPatch(OPLL *opll, int32_t num, OPLL_PATCH *patch) {
  function OPLL_resetPatch (line 1448) | void OPLL_resetPatch(OPLL *opll, uint8_t type) {
  function OPLL_calc (line 1454) | int16_t OPLL_calc(OPLL *opll) {
  function OPLL_calcStereo (line 1467) | void OPLL_calcStereo(OPLL *opll, int32_t out[2]) {
  function OPLL_setMask (line 1483) | uint32_t OPLL_setMask(OPLL *opll, uint32_t mask) {
  function OPLL_toggleMask (line 1494) | uint32_t OPLL_toggleMask(OPLL *opll, uint32_t mask) {

FILE: VGMPlay/chips/emu2413.h
  type OPLL_TONE_ENUM (line 12) | enum OPLL_TONE_ENUM { OPLL_2413_TONE = 0, OPLL_VRC7_TONE = 1, OPLL_281B_...
  type OPLL_PATCH (line 15) | typedef struct __OPLL_PATCH {
  type OPLL_SLOT (line 20) | typedef struct __OPLL_SLOT {
  type OPLL_RateConv (line 73) | typedef struct __OPLL_RateConv {
  type OPLL (line 87) | typedef struct __OPLL {

FILE: VGMPlay/chips/emutypes.h
  type e_uint (line 19) | typedef unsigned int e_uint;
  type e_int (line 20) | typedef signed int e_int;
  type e_uint8 (line 22) | typedef unsigned char e_uint8 ;
  type e_int8 (line 23) | typedef signed char e_int8 ;
  type e_uint16 (line 25) | typedef unsigned short e_uint16 ;
  type e_int16 (line 26) | typedef signed short e_int16 ;
  type e_uint32 (line 28) | typedef unsigned int e_uint32 ;
  type e_int32 (line 29) | typedef signed int e_int32 ;
  type e_uint8 (line 36) | typedef e_uint8 uint8_t;
  type e_int8 (line 37) | typedef e_int8 int8_t;
  type e_uint16 (line 38) | typedef e_uint16 uint16_t;
  type e_int16 (line 39) | typedef e_int16 int16_t;
  type e_uint32 (line 40) | typedef e_uint32 uint32_t;
  type e_int32 (line 41) | typedef e_int32 int32_t;

FILE: VGMPlay/chips/es5503.c
  type ES5503Osc (line 46) | typedef struct
  type ES5503Chip (line 63) | typedef struct
  function es5503_halt_osc (line 118) | static void es5503_halt_osc(ES5503Chip *chip, int onum, int type, UINT32...
  function es5503_pcm_update (line 168) | void es5503_pcm_update(UINT8 ChipID, stream_sample_t **outputs, int samp...
  function device_start_es5503 (line 273) | int device_start_es5503(UINT8 ChipID, int clock, int channels)
  function device_stop_es5503 (line 327) | void device_stop_es5503(UINT8 ChipID)
  function device_reset_es5503 (line 336) | void device_reset_es5503(UINT8 ChipID)
  function UINT8 (line 371) | UINT8 es5503_r(UINT8 ChipID, offs_t offset)
  function es5503_w (line 477) | void es5503_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function es5503_write_ram (line 566) | void es5503_write_ram(UINT8 ChipID, offs_t DataStart, offs_t DataLength,...
  function es5503_set_mute_mask (line 580) | void es5503_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function es5503_set_srchg_cb (line 591) | void es5503_set_srchg_cb(UINT8 ChipID, SRATE_CALLBACK CallbackFunc, void...

FILE: VGMPlay/chips/es5506.c
  type es5506_voice (line 144) | typedef struct _es5506_voice es5506_voice;
  type _es5506_voice (line 145) | struct _es5506_voice
  type es5506_state (line 177) | typedef struct _es5506_state es5506_state;
  type _es5506_state (line 178) | struct _es5506_state
  function update_irq_state (line 245) | static void update_irq_state(es5506_state *chip)
  function update_internal_irq_state (line 252) | static void update_internal_irq_state(es5506_state *chip)
  function compute_tables (line 275) | static void compute_tables(es5506_state *chip)
  function generate_dummy (line 541) | void generate_dummy(es5506_state *chip, es5506_voice *voice, UINT16 *bas...
  function generate_ulaw (line 602) | static void generate_ulaw(es5506_state *chip, es5506_voice *voice, UINT1...
  function generate_pcm (line 714) | static void generate_pcm(es5506_state *chip, es5506_voice *voice, UINT16...
  function generate_samples (line 818) | static void generate_samples(es5506_state *chip, INT32 **outputs, int of...
  function es5506_update (line 896) | void es5506_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function es5506_start_common (line 933) | static void es5506_start_common(es5506_state *chip, int clock, UINT8 snd...
  function device_start_es5506 (line 1037) | int device_start_es5506(UINT8 ChipID, int clock, int channels)
  function device_stop_es5506 (line 1062) | void device_stop_es5506(UINT8 ChipID)
  function device_reset_es5506 (line 1092) | void device_reset_es5506(UINT8 ChipID)
  function INLINE (line 1118) | INLINE void es5506_reg_write_low(es5506_state *chip, es5506_voice *voice...
  function INLINE (line 1217) | INLINE void es5506_reg_write_high(es5506_state *chip, es5506_voice *voic...
  function INLINE (line 1303) | INLINE void es5506_reg_write_test(es5506_state *chip, es5506_voice *voic...
  function es5506_w (line 1383) | static void es5506_w(es5506_state *chip, offs_t offset, UINT8 data)
  function INLINE (line 1419) | INLINE UINT32 es5506_reg_read_low(es5506_state *chip, es5506_voice *voic...
  function INLINE (line 1495) | INLINE UINT32 es5506_reg_read_high(es5506_state *chip, es5506_voice *voi...
  function INLINE (line 1570) | INLINE UINT32 es5506_reg_read_test(es5506_state *chip, es5506_voice *voi...
  function UINT8 (line 1593) | static UINT8 es5506_r(es5506_state *chip, offs_t offset)
  function es5506_voice_bank_w (line 1627) | void es5506_voice_bank_w(UINT8 ChipID, int voice, int bank)
  function INLINE (line 1683) | INLINE void es5505_reg_write_low(es5506_state *chip, es5506_voice *voice...
  function INLINE (line 1844) | INLINE void es5505_reg_write_high(es5506_state *chip, es5506_voice *voic...
  function INLINE (line 1958) | INLINE void es5505_reg_write_test(es5506_state *chip, es5506_voice *voic...
  function es5505_w (line 2011) | static void es5505_w(es5506_state *chip, offs_t offset, UINT8 data)
  function INLINE (line 2038) | INLINE UINT16 es5505_reg_read_low(es5506_state *chip, es5506_voice *voic...
  function INLINE (line 2116) | INLINE UINT16 es5505_reg_read_high(es5506_state *chip, es5506_voice *voi...
  function INLINE (line 2190) | INLINE UINT16 es5505_reg_read_test(es5506_state *chip, es5506_voice *voi...
  function UINT8 (line 2224) | static UINT8 es5505_r(es5506_state *chip, offs_t offset)
  function UINT8 (line 2254) | UINT8 es550x_r(UINT8 ChipID, offs_t offset)
  function es550x_w (line 2264) | void es550x_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function es550x_w16 (line 2282) | void es550x_w16(UINT8 ChipID, offs_t offset, UINT16 data)
  function es5506_write_rom (line 2326) | void es5506_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, of...
  function es5506_set_mute_mask (line 2370) | void es5506_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function es5506_set_srchg_cb (line 2381) | void es5506_set_srchg_cb(UINT8 ChipID, SRATE_CALLBACK CallbackFunc, void...

FILE: VGMPlay/chips/fm.c
  type FM_SLOT (line 534) | typedef struct
  type FM_CH (line 575) | typedef struct
  type FM_ST (line 601) | typedef struct
  type FM_3SLOT (line 638) | typedef struct
  type FM_OPN (line 647) | typedef struct
  function INLINE (line 707) | INLINE void FM_STATUS_SET(FM_ST *ST,int flag)
  function INLINE (line 720) | INLINE void FM_STATUS_RESET(FM_ST *ST,int flag)
  function INLINE (line 733) | INLINE void FM_IRQMASK_SET(FM_ST *ST,int flag)
  function INLINE (line 742) | INLINE void set_timers( FM_ST *ST, void *n, int v )
  function INLINE (line 800) | INLINE void TimerAOver(FM_ST *ST)
  function INLINE (line 809) | INLINE void TimerBOver(FM_ST *ST)
  function INLINE (line 851) | INLINE UINT8 FM_STATUS_FLAG(FM_ST *ST)
  function INLINE (line 862) | INLINE void FM_BUSY_SET(FM_ST *ST,int busyclock )
  function INLINE (line 876) | INLINE void FM_KEYON(UINT8 type, FM_CH *CH , int s )
  function INLINE (line 888) | INLINE void FM_KEYOFF(FM_CH *CH , int s )
  function setup_connection (line 900) | static void setup_connection( FM_OPN *OPN, FM_CH *CH, int ch )
  function INLINE (line 988) | INLINE void set_det_mul(FM_ST *ST,FM_CH *CH,FM_SLOT *SLOT,int v)
  function INLINE (line 996) | INLINE void set_tl(FM_CH *CH,FM_SLOT *SLOT , int v)
  function INLINE (line 1002) | INLINE void set_ar_ksr(UINT8 type, FM_CH *CH,FM_SLOT *SLOT,int v)
  function INLINE (line 1028) | INLINE void set_dr(UINT8 type, FM_SLOT *SLOT,int v)
  function INLINE (line 1037) | INLINE void set_sr(UINT8 type, FM_SLOT *SLOT,int v)
  function INLINE (line 1046) | INLINE void set_sl_rr(UINT8 type, FM_SLOT *SLOT,int v)
  function op_calc (line 1058) | INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm)
  function op_calc1 (line 1069) | INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm)
  function INLINE (line 1081) | INLINE void advance_lfo(FM_OPN *OPN)
  function advance_eg_channel (line 1123) | static void advance_eg_channel(FM_OPN *OPN, FM_SLOT *SLOT)
  function INLINE (line 1274) | INLINE void update_phase_lfo_slot(FM_OPN *OPN, FM_SLOT *SLOT, INT32 pms,...
  function INLINE (line 1308) | INLINE void update_phase_lfo_channel(FM_OPN *OPN, FM_CH *CH)
  function INLINE (line 1359) | INLINE void chan_calc(FM_OPN *OPN, FM_CH *CH, int chnum)
  function INLINE (line 1438) | INLINE void refresh_fc_eg_slot(FM_OPN *OPN, FM_SLOT *SLOT , int fc , int...
  function refresh_fc_eg_chan (line 1478) | static void refresh_fc_eg_chan(FM_OPN *OPN, FM_CH *CH )
  function init_timetables (line 1492) | static void init_timetables( FM_ST *ST , const UINT8 *dttable )
  function reset_channels (line 1519) | static void reset_channels( FM_ST *ST , FM_CH *CH , int num )
  function init_tables (line 1552) | static int init_tables(void)
  function FMCloseTable (line 1669) | static void FMCloseTable( void )
  function INLINE (line 1679) | INLINE void CSMKeyControll(UINT8 type, FM_CH *CH)
  function FMsave_state_channel (line 1706) | static void FMsave_state_channel(const device_config *device,FM_CH *CH,i...
  function FMsave_state_st (line 1726) | static void FMsave_state_st(const device_config *device,FM_ST *ST)
  function OPNSetPres (line 1751) | static void OPNSetPres(FM_OPN *OPN, int pres, int timer_prescaler, int S...
  function OPNWriteMode (line 1809) | static void OPNWriteMode(FM_OPN *OPN, int r, int v)
  function OPNWriteReg (line 1858) | static void OPNWriteReg(FM_OPN *OPN, int r, int v)
  function OPNPrescaler_w (line 2078) | static void OPNPrescaler_w(FM_OPN *OPN , int addr, int pre_divider)
  type YM2203 (line 2115) | typedef struct
  function ym2203_update_one (line 2123) | void ym2203_update_one(void *chip, FMSAMPLE **buffer, int length)
  function ym2203_reset_chip (line 2210) | void ym2203_reset_chip(void *chip)
  function ym2203_postload (line 2237) | void ym2203_postload(void *chip)
  function YM2203_save_state (line 2269) | static void YM2203_save_state(YM2203 *F2203, const device_config *device)
  function ym2203_shutdown (line 2323) | void ym2203_shutdown(void *chip)
  function ym2203_write (line 2332) | int ym2203_write(void *chip,int a,UINT8 v)
  function UINT8 (line 2373) | UINT8 ym2203_read(void *chip,int a)
  function ym2203_timer_over (line 2390) | int ym2203_timer_over(void *chip,int c)
  function ym2203_set_mutemask (line 2412) | void ym2203_set_mutemask(void *chip, UINT32 MuteMask)
  type ADPCM_CH (line 2429) | typedef struct
  type YM2610 (line 2450) | typedef struct
  type YM2610 (line 2473) | typedef YM2610 YM2608;
  function Init_ADPCMATable (line 2501) | static void Init_ADPCMATable(void)
  function INLINE (line 2517) | INLINE void ADPCMA_calc_chan( YM2610 *F2610, ADPCM_CH *ch )
  function FM_ADPCMAWrite (line 2584) | static void FM_ADPCMAWrite(YM2610 *F2610,int r,int v)
  function FMsave_state_adpcma (line 2711) | static void FMsave_state_adpcma(const device_config *device,ADPCM_CH *ad...
  function INLINE (line 3295) | INLINE void YM2608IRQFlagWrite(FM_OPN *OPN, YM2608 *F2608, int v)
  function INLINE (line 3309) | INLINE void YM2608IRQMaskWrite(FM_OPN *OPN, YM2608 *F2608, int v)
  function ym2608_update_one (line 3325) | void ym2608_update_one(void *chip, FMSAMPLE **buffer, int length)
  function ym2608_postload (line 3483) | void ym2608_postload(void *chip)
  function YM2608_save_state (line 3528) | static void YM2608_save_state(YM2608 *F2608, const device_config *device)
  function YM2608_deltat_status_set (line 3546) | static void YM2608_deltat_status_set(void *chip, UINT8 changebits)
  function YM2608_deltat_status_reset (line 3551) | static void YM2608_deltat_status_reset(void *chip, UINT8 changebits)
  function ym2608_shutdown (line 3619) | void ym2608_shutdown(void *chip)
  function ym2608_reset_chip (line 3630) | void ym2608_reset_chip(void *chip)
  function ym2608_write (line 3712) | int ym2608_write(void *chip, int a,UINT8 v)
  function UINT8 (line 3811) | UINT8 ym2608_read(void *chip,int a)
  function ym2608_timer_over (line 3854) | int ym2608_timer_over(void *chip,int c)
  function ym2608_write_pcmrom (line 3891) | void ym2608_write_pcmrom(void *chip, UINT8 rom_id, offs_t ROMSize, offs_...
  function ym2608_set_mutemask (line 3921) | void ym2608_set_mutemask(void *chip, UINT32 MuteMask)
  function ym2610_update_one (line 3942) | void ym2610_update_one(void *chip, FMSAMPLE **buffer, int length)
  function ym2610b_update_one (line 4101) | void ym2610b_update_one(void *chip, FMSAMPLE **buffer, int length)
  function ym2610_postload (line 4258) | void ym2610_postload(void *chip)
  function YM2610_save_state (line 4305) | static void YM2610_save_state(YM2610 *F2610, const device_config *device)
  function YM2610_deltat_status_set (line 4325) | static void YM2610_deltat_status_set(void *chip, UINT8 changebits)
  function YM2610_deltat_status_reset (line 4330) | static void YM2610_deltat_status_reset(void *chip, UINT8 changebits)
  function ym2610_shutdown (line 4392) | void ym2610_shutdown(void *chip)
  function ym2610_reset_chip (line 4404) | void ym2610_reset_chip(void *chip)
  function ym2610_write (line 4488) | int ym2610_write(void *chip, int a, UINT8 v)
  function UINT8 (line 4593) | UINT8 ym2610_read(void *chip,int a)
  function ym2610_timer_over (line 4622) | int ym2610_timer_over(void *chip,int c)
  function ym2610_write_pcmrom (line 4644) | void ym2610_write_pcmrom(void *chip, UINT8 rom_id, offs_t ROMSize, offs_...
  function ym2610_set_mutemask (line 4685) | void ym2610_set_mutemask(void *chip, UINT32 MuteMask)

FILE: VGMPlay/chips/fm.h
  type ssg_callbacks (line 36) | typedef struct _ssg_callbacks ssg_callbacks;
  type _ssg_callbacks (line 37) | struct _ssg_callbacks
  type UINT8 (line 84) | typedef unsigned char	UINT8;
  type UINT16 (line 85) | typedef unsigned short	UINT16;
  type UINT32 (line 86) | typedef unsigned int	UINT32;
  type INT8 (line 87) | typedef signed char		INT8;
  type INT16 (line 88) | typedef signed short	INT16;
  type INT32 (line 89) | typedef signed int		INT32;
  type stream_sample_t (line 95) | typedef stream_sample_t FMSAMPLE;

FILE: VGMPlay/chips/fm2612.c
  type FM_SLOT (line 539) | typedef struct
  type FM_CH (line 580) | typedef struct
  type FM_ST (line 606) | typedef struct
  type FM_3SLOT (line 643) | typedef struct
  type FM_OPN (line 653) | typedef struct
  type YM2612 (line 687) | typedef struct
  function INLINE (line 729) | INLINE void FM_STATUS_SET(FM_ST *ST,int flag)
  function INLINE (line 742) | INLINE void FM_STATUS_RESET(FM_ST *ST,int flag)
  function INLINE (line 755) | INLINE void FM_IRQMASK_SET(FM_ST *ST,int flag)
  function INLINE (line 763) | INLINE void FM_KEYON(FM_OPN *OPN, FM_CH *CH , int s )
  function INLINE (line 801) | INLINE void FM_KEYOFF(FM_OPN *OPN, FM_CH *CH , int s )
  function INLINE (line 840) | INLINE void FM_KEYON_CSM(FM_OPN *OPN, FM_CH *CH , int s )
  function INLINE (line 873) | INLINE void FM_KEYOFF_CSM(FM_CH *CH , int s )
  function INLINE (line 910) | INLINE void set_timers( FM_OPN *OPN, FM_ST *ST, void *n, int v )
  function INLINE (line 965) | INLINE void TimerAOver(FM_ST *ST)
  function INLINE (line 975) | INLINE void TimerBOver(FM_ST *ST)
  function INLINE (line 1018) | INLINE UINT8 FM_STATUS_FLAG(FM_ST *ST)
  function INLINE (line 1029) | INLINE void FM_BUSY_SET(FM_ST *ST,int busyclock )
  function INLINE (line 1042) | INLINE void setup_connection( FM_OPN *OPN, FM_CH *CH, int ch )
  function INLINE (line 1130) | INLINE void set_det_mul(FM_ST *ST,FM_CH *CH,FM_SLOT *SLOT,int v)
  function INLINE (line 1138) | INLINE void set_tl(FM_CH *CH,FM_SLOT *SLOT , int v)
  function INLINE (line 1150) | INLINE void set_ar_ksr(UINT8 type, FM_CH *CH,FM_SLOT *SLOT,int v)
  function INLINE (line 1179) | INLINE void set_dr(UINT8 type, FM_SLOT *SLOT,int v)
  function INLINE (line 1188) | INLINE void set_sr(UINT8 type, FM_SLOT *SLOT,int v)
  function INLINE (line 1197) | INLINE void set_sl_rr(UINT8 type, FM_SLOT *SLOT,int v)
  function INLINE (line 1212) | INLINE void advance_lfo(FM_OPN *OPN)
  function INLINE (line 1242) | INLINE void advance_eg_channel(FM_OPN *OPN, FM_SLOT *SLOT)
  function INLINE (line 1399) | INLINE void update_ssg_eg_channel(FM_SLOT *SLOT)
  function INLINE (line 1458) | INLINE void update_phase_lfo_slot(FM_OPN *OPN, FM_SLOT *SLOT, INT32 pms,...
  function INLINE (line 1496) | INLINE void update_phase_lfo_channel(FM_OPN *OPN, FM_CH *CH)
  function INLINE (line 1545) | INLINE void refresh_fc_eg_slot(FM_OPN *OPN, FM_SLOT *SLOT , int fc , int...
  function INLINE (line 1584) | INLINE void refresh_fc_eg_chan(FM_OPN *OPN, FM_CH *CH )
  function op_calc (line 1599) | INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm)
  function op_calc1 (line 1610) | INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm)
  function INLINE (line 1621) | INLINE void chan_calc(YM2612 *F2612, FM_OPN *OPN, FM_CH *CH)
  function FMCloseTable (line 1698) | static void FMCloseTable( void )
  function INLINE (line 1708) | INLINE void CSMKeyControll(FM_OPN *OPN, FM_CH *CH)
  function FMsave_state_channel (line 1720) | static void FMsave_state_channel(running_device *device,FM_CH *CH,int nu...
  function FMsave_state_st (line 1740) | static void FMsave_state_st(running_device *device,FM_ST *ST)
  function OPNWriteMode (line 1762) | static void OPNWriteMode(FM_OPN *OPN, int r, int v)
  function OPNWriteReg (line 1826) | static void OPNWriteReg(FM_OPN *OPN, int r, int v)
  function init_timetables (line 2044) | static void init_timetables(FM_OPN *OPN, double freqbase)
  function OPNSetPres (line 2079) | static void OPNSetPres(FM_OPN *OPN, int pres, int timer_prescaler, int S...
  function reset_channels (line 2101) | static void reset_channels( FM_ST *ST , FM_CH *CH , int num )
  function init_tables (line 2128) | static void init_tables(void)
  function ym2612_update_one (line 2239) | void ym2612_update_one(void *chip, FMSAMPLE **buffer, int length)
  function ym2612_postload (line 2443) | void ym2612_postload(void *chip)
  function YM2612_save_state (line 2473) | static void YM2612_save_state(YM2612 *F2612, running_device *device)
  function ym2612_shutdown (line 2532) | void ym2612_shutdown(void *chip)
  function ym2612_reset_chip (line 2543) | void ym2612_reset_chip(void *chip)
  function ym2612_write (line 2606) | int ym2612_write(void *chip, int a, UINT8 v)
  function UINT8 (line 2674) | UINT8 ym2612_read(void *chip,int a)
  function ym2612_timer_over (line 2691) | int ym2612_timer_over(void *chip,int c)
  function ym2612_set_mutemask (line 2714) | void ym2612_set_mutemask(void *chip, UINT32 MuteMask)
  function ym2612_setoptions (line 2726) | void ym2612_setoptions(UINT8 Flags)

FILE: VGMPlay/chips/fmopl.c
  function acc_calc (line 139) | INLINE signed int acc_calc(signed int value)
  type OPL_SLOT (line 210) | typedef struct
  type OPL_CH (line 251) | typedef struct
  type FM_OPL (line 263) | typedef struct fm_opl_f
  function INLINE (line 675) | INLINE void OPL_STATUS_SET(FM_OPL *OPL,int flag)
  function INLINE (line 691) | INLINE void OPL_STATUS_RESET(FM_OPL *OPL,int flag)
  function INLINE (line 707) | INLINE void OPL_STATUSMASK_SET(FM_OPL *OPL,int flag)
  function INLINE (line 717) | INLINE void advance_lfo(FM_OPL *OPL)
  function INLINE (line 737) | INLINE void refresh_eg(FM_OPL* OPL)
  function INLINE (line 807) | INLINE void advance(FM_OPL *OPL)
  function op_calc (line 970) | INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm,...
  function op_calc1 (line 981) | INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm...
  function INLINE (line 996) | INLINE void OPL_CALC_CH( FM_OPL *OPL, OPL_CH *CH )
  function INLINE (line 1065) | INLINE void OPL_CALC_RH( FM_OPL *OPL, OPL_CH *CH, unsigned int noise )
  function init_tables (line 1231) | static int init_tables(void)
  function OPLCloseTable (line 1337) | static void OPLCloseTable( void )
  function OPL_initalize (line 1346) | static void OPL_initalize(FM_OPL *OPL)
  function INLINE (line 1415) | INLINE void FM_KEYON(OPL_SLOT *SLOT, UINT32 key_set)
  function INLINE (line 1427) | INLINE void FM_KEYOFF(OPL_SLOT *SLOT, UINT32 key_clr)
  function INLINE (line 1443) | INLINE void CALC_FCSLOT(OPL_CH *CH,OPL_SLOT *SLOT)
  function INLINE (line 1474) | INLINE void set_mul(FM_OPL *OPL,int slot,int v)
  function INLINE (line 1488) | INLINE void set_ksl_tl(FM_OPL *OPL,int slot,int v)
  function INLINE (line 1500) | INLINE void set_ar_dr(FM_OPL *OPL,int slot,int v)
  function INLINE (line 1524) | INLINE void set_sl_rr(FM_OPL *OPL,int slot,int v)
  function OPLWriteReg (line 1538) | static void OPLWriteReg(FM_OPL *OPL, int r, int v)
  function OPL_LockTable (line 1825) | static int OPL_LockTable(void)
  function OPL_UnLockTable (line 1851) | static void OPL_UnLockTable(void)
  function OPLResetChip (line 1865) | static void OPLResetChip(FM_OPL *OPL)
  function OPL_postload (line 1913) | static void OPL_postload(void* param)
  function OPLsave_state_channel (line 1971) | static void OPLsave_state_channel(OPL_CH *CH)
  function FM_OPL (line 2066) | static FM_OPL *OPLCreate(UINT32 clock, UINT32 rate, int type)
  function OPLDestroy (line 2113) | static void OPLDestroy(FM_OPL *OPL)
  function OPLSetTimerHandler (line 2121) | static void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER timer_handle...
  function OPLSetIRQHandler (line 2126) | static void OPLSetIRQHandler(FM_OPL *OPL,OPL_IRQHANDLER IRQHandler,void ...
  function OPLSetUpdateHandler (line 2131) | static void OPLSetUpdateHandler(FM_OPL *OPL,OPL_UPDATEHANDLER UpdateHand...
  function OPLWrite (line 2137) | static int OPLWrite(FM_OPL *OPL,int a,int v)
  function OPLRead (line 2151) | static unsigned char OPLRead(FM_OPL *OPL,int a)
  function INLINE (line 2224) | INLINE void CSMKeyControll(OPL_CH *CH)
  function OPLTimerOver (line 2236) | static int OPLTimerOver(FM_OPL *OPL,int c)
  function ym3812_shutdown (line 2277) | void ym3812_shutdown(void *chip)
  function ym3812_reset_chip (line 2283) | void ym3812_reset_chip(void *chip)
  function ym3812_write (line 2289) | int ym3812_write(void *chip, int a, int v)
  function ym3812_read (line 2295) | unsigned char ym3812_read(void *chip, int a)
  function ym3812_timer_over (line 2301) | int ym3812_timer_over(void *chip, int c)
  function ym3812_set_timer_handler (line 2307) | void ym3812_set_timer_handler(void *chip, OPL_TIMERHANDLER timer_handler...
  function ym3812_set_irq_handler (line 2312) | void ym3812_set_irq_handler(void *chip,OPL_IRQHANDLER IRQHandler,void *p...
  function ym3812_set_update_handler (line 2317) | void ym3812_set_update_handler(void *chip,OPL_UPDATEHANDLER UpdateHandle...
  function ym3812_update_one (line 2331) | void ym3812_update_one(void *chip, OPLSAMPLE **buffer, int length)
  function ym3526_shutdown (line 2412) | void ym3526_shutdown(void *chip)
  function ym3526_reset_chip (line 2418) | void ym3526_reset_chip(void *chip)
  function ym3526_write (line 2424) | int ym3526_write(void *chip, int a, int v)
  function ym3526_read (line 2430) | unsigned char ym3526_read(void *chip, int a)
  function ym3526_timer_over (line 2436) | int ym3526_timer_over(void *chip, int c)
  function ym3526_set_timer_handler (line 2442) | void ym3526_set_timer_handler(void *chip, OPL_TIMERHANDLER timer_handler...
  function ym3526_set_irq_handler (line 2447) | void ym3526_set_irq_handler(void *chip,OPL_IRQHANDLER IRQHandler,void *p...
  function ym3526_set_update_handler (line 2452) | void ym3526_set_update_handler(void *chip,OPL_UPDATEHANDLER UpdateHandle...
  function ym3526_update_one (line 2466) | void ym3526_update_one(void *chip, OPLSAMPLE **buffer, int length)
  function Y8950_deltat_status_set (line 2530) | static void Y8950_deltat_status_set(void *chip, UINT8 changebits)
  function Y8950_deltat_status_reset (line 2535) | static void Y8950_deltat_status_reset(void *chip, UINT8 changebits)
  function y8950_shutdown (line 2567) | void y8950_shutdown(void *chip)
  function y8950_reset_chip (line 2576) | void y8950_reset_chip(void *chip)
  function y8950_write (line 2582) | int y8950_write(void *chip, int a, int v)
  function y8950_read (line 2588) | unsigned char y8950_read(void *chip, int a)
  function y8950_timer_over (line 2593) | int y8950_timer_over(void *chip, int c)
  function y8950_set_timer_handler (line 2599) | void y8950_set_timer_handler(void *chip, OPL_TIMERHANDLER timer_handler,...
  function y8950_set_irq_handler (line 2604) | void y8950_set_irq_handler(void *chip,OPL_IRQHANDLER IRQHandler,void *pa...
  function y8950_set_update_handler (line 2609) | void y8950_set_update_handler(void *chip,OPL_UPDATEHANDLER UpdateHandler...
  function y8950_set_delta_t_memory (line 2615) | void y8950_set_delta_t_memory(void *chip, void * deltat_mem_ptr, int del...
  function y8950_write_pcmrom (line 2622) | void y8950_write_pcmrom(void *chip, offs_t ROMSize, offs_t DataStart,
  function y8950_update_one (line 2651) | void y8950_update_one(void *chip, OPLSAMPLE **buffer, int length)
  function y8950_set_port_handler (line 2715) | void y8950_set_port_handler(void *chip,OPL_PORTHANDLER_W PortHandler_w,O...
  function y8950_set_keyboard_handler (line 2723) | void y8950_set_keyboard_handler(void *chip,OPL_PORTHANDLER_W KeyboardHan...
  function opl_set_mute_mask (line 2733) | void opl_set_mute_mask(void *chip, UINT32 MuteMask)

FILE: VGMPlay/chips/fmopl.h
  type stream_sample_t (line 31) | typedef stream_sample_t OPLSAMPLE;

FILE: VGMPlay/chips/gb.c
  type UINT8 (line 63) | typedef UINT8	bool;
  type RATIO_CNTR (line 70) | typedef struct
  function INLINE (line 76) | INLINE void RC_SET_RATIO(RATIO_CNTR* rc, UINT32 mul, UINT32 div)
  type SOUND (line 143) | struct SOUND
  type SOUNDC (line 184) | struct SOUNDC
  type gb_sound_t (line 204) | typedef struct _gb_sound_t gb_sound_t;
  type _gb_sound_t (line 205) | struct _gb_sound_t
  type SOUND (line 235) | struct SOUND
  type SOUND (line 236) | struct SOUND
  type SOUND (line 237) | struct SOUND
  function UINT8 (line 244) | UINT8 gb_wave_r(UINT8 ChipID, offs_t offset)
  function gb_wave_w (line 261) | void gb_wave_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 287) | UINT8 gb_sound_r(UINT8 ChipID, offs_t offset)
  function gb_sound_w_internal (line 322) | void gb_sound_w_internal(gb_sound_t *gb, UINT8 offset, UINT8 data)
  function gb_sound_w (line 673) | void gb_sound_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function gb_corrupt_wave_ram (line 702) | static void gb_corrupt_wave_ram(gb_sound_t *gb)
  function gb_apu_power_off (line 722) | static void gb_apu_power_off(gb_sound_t *gb)
  function gb_tick_length (line 807) | static void gb_tick_length(struct SOUND *snd)
  function INT32 (line 821) | static INT32 gb_calculate_next_sweep(struct SOUND *snd)
  function gb_apply_next_sweep (line 836) | static void gb_apply_next_sweep(struct SOUND *snd)
  function gb_tick_sweep (line 848) | static void gb_tick_sweep(struct SOUND *snd)
  function gb_tick_envelope (line 864) | static void gb_tick_envelope(struct SOUND *snd)
  function INLINE (line 892) | INLINE bool gb_dac_enabled(struct SOUND *snd)
  function gb_update_square_channel (line 898) | static void gb_update_square_channel(struct SOUND *snd, UINT32 cycles)
  function gb_update_wave_channel (line 935) | static void gb_update_wave_channel(gb_sound_t *gb, struct SOUND *snd, UI...
  function gb_update_noise_channel (line 991) | static void gb_update_noise_channel(gb_sound_t *gb, struct SOUND *snd, U...
  function gb_update_state (line 1032) | static void gb_update_state(gb_sound_t *gb, UINT32 cycles)
  function INLINE (line 1105) | INLINE UINT32 gb_noise_period_cycles(gb_sound_t *gb)
  function gameboy_update (line 1112) | void gameboy_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_gameboy_sound (line 1186) | int device_start_gameboy_sound(UINT8 ChipID, int clock)
  function device_stop_gameboy_sound (line 1210) | void device_stop_gameboy_sound(UINT8 ChipID)
  function device_reset_gameboy_sound (line 1215) | void device_reset_gameboy_sound(UINT8 ChipID)
  function gameboy_sound_set_mute_mask (line 1284) | void gameboy_sound_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function UINT32 (line 1296) | UINT32 gameboy_sound_get_mute_mask(UINT8 ChipID)
  function gameboy_sound_set_options (line 1309) | void gameboy_sound_set_options(UINT8 Flags)

FILE: VGMPlay/chips/iremga20.c
  type IremGA20_channel_def (line 38) | struct IremGA20_channel_def
  type ga20_state (line 53) | typedef struct _ga20_state ga20_state;
  type _ga20_state (line 54) | struct _ga20_state
  function IremGA20_update (line 76) | void IremGA20_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function irem_ga20_w (line 155) | void irem_ga20_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 204) | UINT8 irem_ga20_r(UINT8 ChipID, offs_t offset)
  function iremga20_reset (line 227) | static void iremga20_reset(ga20_state *chip)
  function device_reset_iremga20 (line 247) | void device_reset_iremga20(UINT8 ChipID)
  function device_start_iremga20 (line 257) | int device_start_iremga20(UINT8 ChipID, int clock)
  function device_stop_iremga20 (line 300) | void device_stop_iremga20(UINT8 ChipID)
  function iremga20_write_rom (line 309) | void iremga20_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, ...
  function iremga20_set_mute_mask (line 331) | void iremga20_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/k051649.c
  type k051649_sound_channel (line 36) | typedef struct
  type k051649_state (line 46) | typedef struct _k051649_state k051649_state;
  type _k051649_state (line 47) | struct _k051649_state
  function make_mixer_table (line 75) | static void make_mixer_table(/*running_machine *machine,*/ k051649_state...
  function k051649_update (line 101) | void k051649_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_k051649 (line 149) | int device_start_k051649(UINT8 ChipID, int clock)
  function device_stop_k051649 (line 180) | void device_stop_k051649(UINT8 ChipID)
  function device_reset_k051649 (line 191) | void device_reset_k051649(UINT8 ChipID)
  function k051649_waveform_w (line 217) | void k051649_waveform_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 239) | UINT8 k051649_waveform_r(UINT8 ChipID, offs_t offset)
  function k052539_waveform_w (line 259) | void k052539_waveform_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 273) | UINT8 k052539_waveform_r(UINT8 ChipID, offs_t offset)
  function k051649_volume_w (line 288) | void k051649_volume_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function k051649_frequency_w (line 297) | void k051649_frequency_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function k051649_keyonoff_w (line 320) | void k051649_keyonoff_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function k051649_test_w (line 335) | void k051649_test_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 343) | UINT8 k051649_test_r(UINT8 ChipID, offs_t offset)
  function k051649_w (line 351) | void k051649_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function k051649_set_mute_mask (line 389) | void k051649_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/k053260.c
  type k053260_channel (line 23) | typedef struct _k053260_channel k053260_channel;
  type _k053260_channel (line 24) | struct _k053260_channel
  type k053260_state (line 40) | typedef struct _k053260_state k053260_state;
  type _k053260_state (line 41) | struct _k053260_state
  function InitDeltaTable (line 66) | static void InitDeltaTable( k053260_state *ic, int rate, int clock )
  function device_reset_k053260 (line 91) | void device_reset_k053260(UINT8 ChipID)
  function INLINE (line 112) | INLINE int limit( int val, int max, int min )
  function k053260_update (line 127) | void k053260_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_k053260 (line 238) | int device_start_k053260(UINT8 ChipID, int clock)
  function device_stop_k053260 (line 308) | void device_stop_k053260(UINT8 ChipID)
  function INLINE (line 318) | INLINE void check_bounds( k053260_state *ic, int channel )
  function k053260_w (line 341) | void k053260_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 460) | UINT8 k053260_r(UINT8 ChipID, offs_t offset)
  function k053260_write_rom (line 499) | void k053260_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, o...
  function k053260_set_mute_mask (line 521) | void k053260_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/k054539.c
  type k054539_channel (line 63) | typedef struct _k054539_channel k054539_channel;
  type _k054539_channel (line 64) | struct _k054539_channel {
  type k054539_state (line 71) | typedef struct _k054539_state k054539_state;
  type _k054539_state (line 72) | struct _k054539_state {
  function k054539_init_flags (line 113) | void k054539_init_flags(UINT8 ChipID, int flags)
  function k054539_set_gain (line 121) | void k054539_set_gain(UINT8 ChipID, int channel, double gain)
  function k054539_regupdate (line 129) | static int k054539_regupdate(k054539_state *info)
  function k054539_keyon (line 134) | static void k054539_keyon(k054539_state *info, int channel)
  function k054539_keyoff (line 140) | static void k054539_keyoff(k054539_state *info, int channel)
  function k054539_update (line 147) | void k054539_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function k054539_init_chip (line 370) | static int k054539_init_chip(k054539_state *info, int clock)
  function k054539_w (line 416) | void k054539_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function reset_zones (line 559) | static void reset_zones(k054539_state *info)
  function UINT8 (line 567) | UINT8 k054539_r(UINT8 ChipID, offs_t offset)
  function device_start_k054539 (line 591) | int device_start_k054539(UINT8 ChipID, int clock)
  function device_stop_k054539 (line 642) | void device_stop_k054539(UINT8 ChipID)
  function device_reset_k054539 (line 652) | void device_reset_k054539(UINT8 ChipID)
  function k054539_write_rom (line 667) | void k054539_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, o...
  function k054539_set_mute_mask (line 701) | void k054539_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/mamedef.h
  type UINT8 (line 6) | typedef unsigned char						UINT8;
  type INT8 (line 7) | typedef signed char 						INT8;
  type UINT16 (line 10) | typedef unsigned short						UINT16;
  type INT16 (line 11) | typedef signed short						INT16;
  type UINT32 (line 15) | typedef unsigned int						UINT32;
  type INT32 (line 16) | typedef signed int							INT32;
  type INT64 (line 22) | typedef signed __int64						INT64;
  type UINT64 (line 23) | typedef unsigned __int64					UINT64;
  type UINT64 (line 25) | __extension__ typedef unsigned long long	UINT64;
  type INT64 (line 26) | __extension__ typedef signed long long		INT64;
  type UINT32 (line 31) | typedef UINT32	offs_t;
  type INT32 (line 34) | typedef INT32 stream_sample_t;

FILE: VGMPlay/chips/multipcm.c
  type _Sample (line 48) | struct _Sample
  type _STATE (line 59) | typedef enum {ATTACK,DECAY1,DECAY2,RELEASE} _STATE;
  type _EG (line 60) | struct _EG
  type _LFO (line 73) | struct _LFO
  type _SLOT (line 82) | struct _SLOT
  type MultiPCM (line 102) | typedef struct _MultiPCM MultiPCM;
  type _MultiPCM (line 103) | struct _MultiPCM
  function EG_Update (line 169) | static int EG_Update(struct _SLOT *slot)
  function Get_RATE (line 209) | static unsigned int Get_RATE(unsigned int *Steps,unsigned int rate,unsig...
  function EG_Calc (line 221) | static void EG_Calc(MultiPCM *ptChip,struct _SLOT *slot)
  function LFO_Init (line 263) | static void LFO_Init(void)
  function PLFO_Step (line 303) | INLINE signed int PLFO_Step(struct _LFO *LFO)
  function ALFO_Step (line 312) | INLINE signed int ALFO_Step(struct _LFO *LFO)
  function LFO_ComputeStep (line 321) | static void LFO_ComputeStep(MultiPCM *ptChip,struct _LFO *LFO,UINT32 LFO...
  function WriteSlot (line 339) | static void WriteSlot(MultiPCM *ptChip,struct _SLOT *slot,int reg,unsign...
  function MultiPCM_update (line 467) | void MultiPCM_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function UINT8 (line 538) | UINT8 multipcm_r(UINT8 ChipID, offs_t offset)
  function device_start_multipcm (line 546) | int device_start_multipcm(UINT8 ChipID, int clock)
  function device_stop_multipcm (line 716) | void device_stop_multipcm(UINT8 ChipID)
  function device_reset_multipcm (line 725) | void device_reset_multipcm(UINT8 ChipID)
  function multipcm_w (line 741) | void multipcm_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function multipcm_set_bank (line 765) | void multipcm_set_bank(UINT8 ChipID, UINT32 leftoffs, UINT32 rightoffs)
  function multipcm_bank_write (line 774) | void multipcm_bank_write(UINT8 ChipID, UINT8 offset, UINT16 data)
  function multipcm_write_rom (line 794) | void multipcm_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, ...
  function multipcm_set_mute_mask (line 845) | void multipcm_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function UINT8 (line 857) | UINT8 multipcm_get_channels(UINT8 ChipID, UINT32* ChannelMask)

FILE: VGMPlay/chips/nes_apu.c
  type nesapu_state (line 63) | typedef struct _nesapu_state nesapu_state;
  type _nesapu_state (line 64) | struct _nesapu_state
  function create_vbltimes (line 93) | static void create_vbltimes(uint32 * table,const uint8 *vbl,unsigned int...
  function create_syncs (line 102) | static void create_syncs(nesapu_state *info, unsigned long sps)
  function create_noise (line 123) | static void create_noise(uint8 *buf, const int bits, int size)
  function int8 (line 142) | static int8 apu_square(nesapu_state *info, square_t *chan)
  function int8 (line 228) | static int8 apu_triangle(nesapu_state *info, triangle_t *chan)
  function int8 (line 286) | static int8 apu_noise(nesapu_state *info, noise_t *chan)
  function INLINE (line 353) | INLINE void apu_dpcmreset(dpcm_t *chan)
  function int8 (line 366) | static int8 apu_dpcm(nesapu_state *info, dpcm_t *chan)
  function INLINE (line 447) | INLINE void apu_regwrite(nesapu_state *info,int address, uint8 value)
  function INLINE (line 656) | INLINE void apu_update(nesapu_state *info, stream_sample_t **buffer16, i...
  function INLINE (line 692) | INLINE uint8 apu_read(nesapu_state *info,int address)
  function INLINE (line 722) | INLINE void apu_write(nesapu_state *info,int address, uint8 value)
  function UINT8 (line 735) | UINT8 nes_psg_r(void* chip, offs_t offset)
  function nes_psg_w (line 741) | void nes_psg_w(void* chip, offs_t offset, UINT8 data)
  function nes_psg_update_sound (line 749) | void nes_psg_update_sound(void* chip, stream_sample_t **outputs, int sam...
  function device_stop_nesapu (line 866) | void device_stop_nesapu(void* chip)
  function device_reset_nesapu (line 875) | void device_reset_nesapu(void* chip)
  function nesapu_set_rom (line 895) | void nesapu_set_rom(void* chip, const UINT8* ROMData)
  function nesapu_set_mute_mask (line 903) | void nesapu_set_mute_mask(void* chip, UINT32 MuteMask)

FILE: VGMPlay/chips/nes_defs.h
  type INT8 (line 36) | typedef INT8          int8;
  type INT16 (line 37) | typedef INT16         int16;
  type INT32 (line 38) | typedef INT32         int32;
  type UINT8 (line 39) | typedef UINT8         uint8;
  type UINT16 (line 40) | typedef UINT16        uint16;
  type UINT32 (line 41) | typedef UINT32        uint32;
  type UINT8 (line 42) | typedef UINT8         boolean;
  type queue_t (line 51) | typedef struct queue_s
  type square_t (line 88) | typedef struct square_s
  type triangle_t (line 104) | typedef struct triangle_s
  type noise_t (line 119) | typedef struct noise_s
  type dpcm_t (line 133) | typedef struct dpcm_s
  type apu_t (line 152) | typedef struct apu

FILE: VGMPlay/chips/nes_intf.c
  type nes_state (line 28) | typedef struct _nes_state nes_state;
  type _nes_state (line 29) | struct _nes_state
  function nes_stream_update (line 48) | void nes_stream_update(UINT8 ChipID, stream_sample_t **outputs, int samp...
  function device_start_nes (line 85) | int device_start_nes(UINT8 ChipID, int clock)
  function device_stop_nes (line 154) | void device_stop_nes(UINT8 ChipID)
  function device_reset_nes (line 184) | void device_reset_nes(UINT8 ChipID)
  function nes_w (line 204) | void nes_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function nes_write_ram (line 242) | void nes_write_ram(UINT8 ChipID, offs_t DataStart, offs_t DataLength, co...
  function nes_set_emu_core (line 280) | void nes_set_emu_core(UINT8 Emulator)
  function nes_set_options (line 291) | void nes_set_options(UINT16 Options)
  function nes_set_chip_option (line 298) | static void nes_set_chip_option(UINT8 ChipID)
  function nes_set_mute_mask (line 339) | void nes_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/np_nes_apu.c
  type Counter (line 43) | typedef struct _Counter Counter;
  type _Counter (line 44) | struct _Counter
  type NES_APU (line 60) | typedef struct _NES_APU NES_APU;
  type _NES_APU (line 61) | struct _NES_APU
  function sweep_sqr (line 109) | static void sweep_sqr(NES_APU* apu, int i)
  function NES_APU_np_FrameSequence (line 117) | void NES_APU_np_FrameSequence(void* chip, int s)
  function INT32 (line 193) | static INT32 calc_sqr(NES_APU* apu, int i, UINT32 clocks)
  function NES_APU_np_Read (line 223) | bool NES_APU_np_Read(void* chip, UINT32 adr, UINT32* val)
  function Tick (line 241) | static void Tick(NES_APU* apu, UINT32 clocks)
  function UINT32 (line 248) | UINT32 NES_APU_np_Render(void* chip, INT32 b[2])
  function NES_APU_np_Destroy (line 328) | void NES_APU_np_Destroy(void* chip)
  function NES_APU_np_Reset (line 333) | void NES_APU_np_Reset(void* chip)
  function NES_APU_np_SetOption (line 367) | void NES_APU_np_SetOption(void* chip, int id, int val)
  function NES_APU_np_SetClock (line 374) | void NES_APU_np_SetClock(void* chip, double c)
  function NES_APU_np_SetRate (line 381) | void NES_APU_np_SetRate(void* chip, double r)
  function NES_APU_np_SetMask (line 391) | void NES_APU_np_SetMask(void* chip, int m)
  function NES_APU_np_SetStereoMix (line 397) | void NES_APU_np_SetStereoMix(void* chip, int trk, INT16 mixl, INT16 mixr)
  function NES_APU_np_Write (line 407) | bool NES_APU_np_Write(void* chip, UINT32 adr, UINT32 val)

FILE: VGMPlay/chips/np_nes_dmc.c
  type Counter (line 41) | typedef struct _Counter Counter;
  type _Counter (line 42) | struct _Counter
  type NES_DMC (line 58) | typedef struct _NES_DMC NES_DMC;
  type _NES_DMC (line 59) | struct _NES_DMC
  function NES_DMC_np_Destroy (line 190) | void NES_DMC_np_Destroy(void* chip)
  function NES_DMC_np_GetDamp (line 195) | int NES_DMC_np_GetDamp(void* chip)
  function NES_DMC_np_SetMask (line 202) | void NES_DMC_np_SetMask(void* chip, int m)
  function NES_DMC_np_SetStereoMix (line 209) | void NES_DMC_np_SetStereoMix(void* chip, int trk, INT16 mixl, INT16 mixr)
  function FrameSequence (line 219) | static void FrameSequence(NES_DMC* dmc, int s)
  function UINT32 (line 294) | UINT32 calc_tri(NES_DMC* dmc, UINT32 clocks)
  function UINT32 (line 338) | UINT32 calc_noise(NES_DMC* dmc, UINT32 clocks)
  function UINT32 (line 385) | UINT32 calc_dmc(NES_DMC* dmc, UINT32 clocks)
  function TickFrameSequence (line 434) | static void TickFrameSequence(NES_DMC* dmc, UINT32 clocks)
  function Tick (line 447) | static void Tick(NES_DMC* dmc, UINT32 clocks)
  function UINT32 (line 454) | UINT32 NES_DMC_np_Render(void* chip, INT32 b[2])
  function NES_DMC_np_SetClock (line 530) | void NES_DMC_np_SetClock(void* chip, double c)
  function NES_DMC_np_SetRate (line 542) | void NES_DMC_np_SetRate(void* chip, double r)
  function NES_DMC_np_SetPal (line 552) | void NES_DMC_np_SetPal(void* chip, bool is_pal)
  function NES_DMC_np_SetAPU (line 561) | void NES_DMC_np_SetAPU(void* chip, void* apu_)
  function InitializeTNDTable (line 569) | static void InitializeTNDTable(NES_DMC* dmc, double wt, double wn, doubl...
  function NES_DMC_np_Reset (line 602) | void NES_DMC_np_Reset(void* chip)
  function NES_DMC_np_SetMemory (line 660) | void NES_DMC_np_SetMemory(void* chip, const UINT8* r)
  function NES_DMC_np_SetOption (line 667) | void NES_DMC_np_SetOption(void* chip, int id, int val)
  function NES_DMC_np_Write (line 679) | bool NES_DMC_np_Write(void* chip, UINT32 adr, UINT32 val)
  function NES_DMC_np_Read (line 849) | bool NES_DMC_np_Read(void* chip, UINT32 adr, UINT32* val)

FILE: VGMPlay/chips/np_nes_fds.c
  type Counter (line 55) | typedef struct _Counter Counter;
  type _Counter (line 56) | struct _Counter
  type NES_FDS (line 72) | typedef struct _NES_FDS NES_FDS;
  type _NES_FDS (line 73) | struct _NES_FDS
  function NES_FDS_Destroy (line 144) | void NES_FDS_Destroy(void* chip)
  function NES_FDS_SetMask (line 149) | void NES_FDS_SetMask(void* chip, int m)
  function NES_FDS_SetStereoMix (line 156) | void NES_FDS_SetStereoMix(void* chip, int trk, INT16 mixl, INT16 mixr)
  function NES_FDS_SetClock (line 166) | void NES_FDS_SetClock(void* chip, double c)
  function NES_FDS_SetRate (line 173) | void NES_FDS_SetRate(void* chip, double r)
  function NES_FDS_SetOption (line 192) | void NES_FDS_SetOption(void* chip, int id, int val)
  function NES_FDS_Reset (line 202) | void NES_FDS_Reset(void* chip)
  function Tick (line 257) | static void Tick(NES_FDS* fds, UINT32 clocks)
  function UINT32 (line 383) | UINT32 NES_FDS_Render(void* chip, INT32 b[2])
  function NES_FDS_Write (line 418) | bool NES_FDS_Write(void* chip, UINT32 adr, UINT32 val)
  function NES_FDS_Read (line 521) | bool NES_FDS_Read(void* chip, UINT32 adr, UINT32* val)

FILE: VGMPlay/chips/okim6258.c
  type okim6258_state (line 33) | typedef struct _okim6258_state okim6258_state;
  type _okim6258_state (line 34) | struct _okim6258_state
  function compute_tables (line 98) | static void compute_tables(void)
  function INT16 (line 135) | static INT16 clock_adpcm(okim6258_state *chip, UINT8 nibble)
  function okim6258_update (line 171) | void okim6258_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function get_vclk (line 284) | static int get_vclk(okim6258_state* info)
  function device_start_okim6258 (line 294) | int device_start_okim6258(UINT8 ChipID, int clock, int divider, int adpc...
  function device_stop_okim6258 (line 343) | void device_stop_okim6258(UINT8 ChipID)
  function device_reset_okim6258 (line 351) | void device_reset_okim6258(UINT8 ChipID)
  function okim6258_set_divider (line 388) | void okim6258_set_divider(UINT8 ChipID, int val)
  function okim6258_set_clock (line 408) | void okim6258_set_clock(UINT8 ChipID, int val)
  function okim6258_get_vclk (line 437) | int okim6258_get_vclk(UINT8 ChipID)
  function okim6258_data_w (line 470) | static void okim6258_data_w(UINT8 ChipID, /*offs_t offset, */UINT8 data)
  function okim6258_ctrl_w (line 503) | static void okim6258_ctrl_w(UINT8 ChipID, /*offs_t offset, */UINT8 data)
  function okim6258_set_clock_byte (line 550) | static void okim6258_set_clock_byte(UINT8 ChipID, UINT8 Byte, UINT8 val)
  function okim6258_pan_w (line 559) | static void okim6258_pan_w(UINT8 ChipID, UINT8 data)
  function okim6258_write (line 569) | void okim6258_write(UINT8 ChipID, UINT8 Port, UINT8 Data)
  function okim6258_set_options (line 600) | void okim6258_set_options(UINT16 Options)
  function okim6258_set_srchg_cb (line 607) | void okim6258_set_srchg_cb(UINT8 ChipID, SRATE_CALLBACK CallbackFunc, vo...

FILE: VGMPlay/chips/okim6295.c
  type ADPCMVoice (line 41) | struct ADPCMVoice
  type okim6295_state (line 54) | typedef struct _okim6295_state okim6295_state;
  type _okim6295_state (line 55) | struct _okim6295_state
  function compute_tables (line 138) | static void compute_tables(void)
  function reset_adpcm (line 179) | void reset_adpcm(struct adpcm_state *state)
  function INT16 (line 198) | INT16 clock_adpcm(struct adpcm_state *state, UINT8 nibble)
  function UINT8 (line 237) | static UINT8 memory_raw_read_byte(okim6295_state *chip, offs_t offset)
  function generate_adpcm (line 271) | static void generate_adpcm(okim6295_state *chip, struct ADPCMVoice *voic...
  function okim6295_update (line 337) | void okim6295_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_okim6295 (line 419) | int device_start_okim6295(UINT8 ChipID, int clock)
  function device_stop_okim6295 (line 468) | void device_stop_okim6295(UINT8 ChipID)
  function device_reset_okim6295 (line 485) | void device_reset_okim6295(UINT8 ChipID)
  function okim6295_set_bank_base (line 518) | void okim6295_set_bank_base(okim6295_state *info, int base)
  function okim6295_clock_changed (line 548) | static void okim6295_clock_changed(okim6295_state *info)
  function INLINE (line 558) | INLINE void okim6295_set_pin7(okim6295_state *info, int pin7)
  function UINT8 (line 574) | UINT8 okim6295_r(UINT8 ChipID, offs_t offset)
  function okim6295_write_command (line 605) | void okim6295_write_command(okim6295_state *info, UINT8 data)
  function okim6295_w (line 705) | void okim6295_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function okim6295_write_rom (line 754) | void okim6295_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, ...
  function okim6295_set_mute_mask (line 777) | void okim6295_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function okim6295_set_srchg_cb (line 788) | void okim6295_set_srchg_cb(UINT8 ChipID, SRATE_CALLBACK CallbackFunc, vo...

FILE: VGMPlay/chips/okim6295.h
  type adpcm_state (line 42) | struct adpcm_state
  type adpcm_state (line 47) | struct adpcm_state
  type adpcm_state (line 48) | struct adpcm_state

FILE: VGMPlay/chips/opl.c
  function INLINE (line 153) | INLINE void operator_advance(OPL_DATA* chip, op_type* op_pt, Bit32s vib) {
  function INLINE (line 163) | INLINE void operator_advance_drums(OPL_DATA* chip, op_type* op_pt1, Bit3...
  function INLINE (line 201) | INLINE void operator_output(op_type* op_pt, Bit32s modulator, Bit32s trem)
  function operator_off (line 220) | static void operator_off(op_type* op_pt) {
  function operator_sustain (line 225) | static void operator_sustain(op_type* op_pt)
  function operator_release (line 237) | static void operator_release(op_type* op_pt)
  function operator_decay (line 272) | static void operator_decay(op_type* op_pt)
  function operator_attack (line 312) | static void operator_attack(op_type* op_pt)
  function operator_eg_attack_check (line 343) | static void operator_eg_attack_check(op_type* op_pt)
  function change_attackrate (line 370) | static void change_attackrate(OPL_DATA* chip, Bitu regbase, op_type* op_pt)
  function change_decayrate (line 418) | static void change_decayrate(OPL_DATA* chip, Bitu regbase, op_type* op_pt)
  function change_releaserate (line 437) | static void change_releaserate(OPL_DATA* chip, Bitu regbase, op_type* op...
  function change_sustainlevel (line 457) | static void change_sustainlevel(OPL_DATA* chip, Bitu regbase, op_type* o...
  function change_waveform (line 471) | static void change_waveform(OPL_DATA* chip, Bitu regbase, op_type* op_pt)
  function change_keepsustain (line 482) | static void change_keepsustain(OPL_DATA* chip, Bitu regbase, op_type* op...
  function change_vibrato (line 498) | static void change_vibrato(OPL_DATA* chip, Bitu regbase, op_type* op_pt)
  function change_feedback (line 505) | static void change_feedback(OPL_DATA* chip, Bitu chanbase, op_type* op_pt)
  function change_frequency (line 514) | static void change_frequency(OPL_DATA* chip, Bitu chanbase, Bitu regbase...
  function enable_operator (line 548) | static void enable_operator(OPL_DATA* chip, Bitu regbase, op_type* op_pt...
  function disable_operator (line 565) | static void disable_operator(op_type* op_pt, Bit32u act_type)
  function adlib_write (line 801) | static void adlib_write(void *chip, Bitu idx, Bit8u val)
  function Bitu (line 1161) | Bitu ADLIBEMU(reg_read)(void *chip, UINT32 port)

FILE: VGMPlay/chips/opl.h
  type UINT32 (line 45) | typedef UINT32		Bitu;
  type INT32 (line 46) | typedef INT32		Bits;
  type UINT32 (line 47) | typedef UINT32		Bit32u;
  type INT32 (line 48) | typedef INT32		Bit32s;
  type UINT16 (line 49) | typedef UINT16		Bit16u;
  type INT16 (line 50) | typedef INT16		Bit16s;
  type UINT8 (line 51) | typedef UINT8		Bit8u;
  type INT8 (line 52) | typedef INT8		Bit8s;
  type op_type (line 136) | typedef struct operator_struct {
  type OPL_DATA (line 167) | typedef struct opl_chip

FILE: VGMPlay/chips/opll.c
  function OPLL_DoIO (line 233) | void OPLL_DoIO(opll_t *chip) {
  function OPLL_DoModeWrite (line 241) | void OPLL_DoModeWrite(opll_t *chip) {
  function OPLL_Reset (line 294) | void OPLL_Reset(opll_t *chip, uint32_t chip_type, uint32_t rate, uint32_...
  function OPLL_DoRegWrite (line 340) | void OPLL_DoRegWrite(opll_t *chip) {
  function OPLL_PreparePatch1 (line 407) | void OPLL_PreparePatch1(opll_t *chip) {
  function OPLL_PreparePatch2 (line 444) | void OPLL_PreparePatch2(opll_t *chip) {
  function OPLL_PhaseGenerate (line 476) | void OPLL_PhaseGenerate(opll_t *chip) {
  function OPLL_PhaseCalcIncrement (line 542) | void OPLL_PhaseCalcIncrement(opll_t *chip) {
  function OPLL_EnvelopeKSLTL (line 575) | void OPLL_EnvelopeKSLTL(opll_t *chip)
  function OPLL_EnvelopeOutput (line 595) | void OPLL_EnvelopeOutput(opll_t *chip)
  function OPLL_EnvelopeGenerate (line 616) | void OPLL_EnvelopeGenerate(opll_t *chip) {
  function OPLL_Channel (line 848) | void OPLL_Channel(opll_t *chip) {
  function OPLL_Operator (line 909) | void OPLL_Operator(opll_t *chip) {
  function OPLL_DoRhythm (line 1023) | void OPLL_DoRhythm(opll_t *chip) {
  function OPLL_DoLFO (line 1032) | void OPLL_DoLFO(opll_t *chip) {
  function OPLL_Clock (line 1081) | void OPLL_Clock(opll_t *chip, int32_t *buffer) {
  function OPLL_Write (line 1120) | void OPLL_Write(opll_t *chip, uint32_t port, uint8_t data) {
  function OPLL_WriteBuffered (line 1131) | void OPLL_WriteBuffered(opll_t* chip, uint32_t port, uint8_t data)
  function OPLL_GenerateResampled (line 1168) | void OPLL_GenerateResampled(opll_t *chip, int32_t *buf)
  function OPLL_GenerateStream (line 1297) | void OPLL_GenerateStream(opll_t* chip, int32_t** sndptr, uint32_t numsam...
  function OPLL_SetMute (line 1313) | void OPLL_SetMute(opll_t* chip, uint32_t mute)

FILE: VGMPlay/chips/opll.h
  type opll_writebuf (line 67) | typedef struct _opll_writebuf {
  type opll_patch_t (line 73) | typedef struct {
  type opll_t (line 90) | typedef struct {

FILE: VGMPlay/chips/opm.c
  type freqtable_t (line 119) | typedef struct {
  function OPM_KCToFNum (line 236) | static int32_t OPM_KCToFNum(int32_t kcode)
  function OPM_LFOApplyPMS (line 279) | static int32_t OPM_LFOApplyPMS(int32_t lfo, int32_t pms)
  function OPM_CalcKCode (line 329) | static int32_t OPM_CalcKCode(int32_t kcf, int32_t lfo, int32_t lfo_sign,...
  function OPM_PhaseCalcFNumBlock (line 399) | static void OPM_PhaseCalcFNumBlock(opm_t *chip)
  function OPM_PhaseCalcIncrement (line 415) | static void OPM_PhaseCalcIncrement(opm_t *chip)
  function OPM_PhaseGenerate (line 463) | static void OPM_PhaseGenerate(opm_t *chip)
  function OPM_PhaseDebug (line 483) | static void OPM_PhaseDebug(opm_t *chip)
  function OPM_KeyOn1 (line 492) | static void OPM_KeyOn1(opm_t *chip)
  function OPM_KeyOn2 (line 502) | static void OPM_KeyOn2(opm_t *chip)
  function OPM_EnvelopePhase1 (line 514) | static void OPM_EnvelopePhase1(opm_t *chip)
  function OPM_EnvelopePhase2 (line 528) | static void OPM_EnvelopePhase2(opm_t *chip)
  function OPM_EnvelopePhase3 (line 602) | static void OPM_EnvelopePhase3(opm_t *chip)
  function OPM_EnvelopePhase4 (line 616) | static void OPM_EnvelopePhase4(opm_t *chip)
  function OPM_EnvelopePhase5 (line 722) | static void OPM_EnvelopePhase5(opm_t *chip)
  function OPM_EnvelopePhase6 (line 763) | static void OPM_EnvelopePhase6(opm_t *chip)
  function OPM_EnvelopeClock (line 779) | static void OPM_EnvelopeClock(opm_t *chip)
  function OPM_EnvelopeTimer (line 796) | static void OPM_EnvelopeTimer(opm_t *chip)
  function OPM_OperatorPhase1 (line 848) | static void OPM_OperatorPhase1(opm_t *chip)
  function OPM_OperatorPhase2 (line 867) | static void OPM_OperatorPhase2(opm_t *chip)
  function OPM_OperatorPhase3 (line 873) | static void OPM_OperatorPhase3(opm_t *chip)
  function OPM_OperatorPhase4 (line 886) | static void OPM_OperatorPhase4(opm_t *chip)
  function OPM_OperatorPhase5 (line 892) | static void OPM_OperatorPhase5(opm_t *chip)
  function OPM_OperatorPhase6 (line 898) | static void OPM_OperatorPhase6(opm_t *chip)
  function OPM_OperatorPhase7 (line 908) | static void OPM_OperatorPhase7(opm_t *chip)
  function OPM_OperatorPhase8 (line 915) | static void OPM_OperatorPhase8(opm_t *chip)
  function OPM_OperatorPhase9 (line 922) | static void OPM_OperatorPhase9(opm_t *chip)
  function OPM_OperatorPhase10 (line 933) | static void OPM_OperatorPhase10(opm_t *chip)
  function OPM_OperatorPhase11 (line 939) | static void OPM_OperatorPhase11(opm_t *chip)
  function OPM_OperatorPhase12 (line 945) | static void OPM_OperatorPhase12(opm_t *chip)
  function OPM_OperatorPhase13 (line 951) | static void OPM_OperatorPhase13(opm_t *chip)
  function OPM_OperatorPhase14 (line 958) | static void OPM_OperatorPhase14(opm_t *chip)
  function OPM_OperatorPhase15 (line 981) | static void OPM_OperatorPhase15(opm_t *chip)
  function OPM_OperatorPhase16 (line 1018) | static void OPM_OperatorPhase16(opm_t *chip)
  function OPM_OperatorCounter (line 1029) | static void OPM_OperatorCounter(opm_t *chip)
  function OPM_Mixer2 (line 1041) | static void OPM_Mixer2(opm_t *chip)
  function OPM_Output (line 1123) | static void OPM_Output(opm_t *chip)
  function OPM_DAC (line 1131) | static void OPM_DAC(opm_t *chip)
  function OPM_Mixer (line 1154) | static void OPM_Mixer(opm_t *chip)
  function OPM_Noise (line 1266) | static void OPM_Noise(opm_t *chip)
  function OPM_NoiseTimer (line 1282) | static void OPM_NoiseTimer(opm_t *chip)
  function OPM_DoTimerA (line 1302) | static void OPM_DoTimerA(opm_t *chip)
  function OPM_DoTimerA2 (line 1319) | static void OPM_DoTimerA2(opm_t *chip)
  function OPM_DoTimerB (line 1340) | static void OPM_DoTimerB(opm_t *chip)
  function OPM_DoTimerB2 (line 1369) | static void OPM_DoTimerB2(opm_t *chip)
  function OPM_DoTimerIRQ (line 1386) | static void OPM_DoTimerIRQ(opm_t *chip)
  function OPM_DoLFOMult (line 1391) | static void OPM_DoLFOMult(opm_t *chip)
  function OPM_DoLFO1 (line 1441) | static void OPM_DoLFO1(opm_t *chip)
  function OPM_DoLFO2 (line 1548) | static void OPM_DoLFO2(opm_t *chip)
  function OPM_CSM (line 1582) | static void OPM_CSM(opm_t *chip)
  function OPM_NoiseChannel (line 1591) | static void OPM_NoiseChannel(opm_t *chip)
  function OPM_DoIO (line 1621) | static void OPM_DoIO(opm_t *chip)
  function OPM_DoRegWrite (line 1638) | static void OPM_DoRegWrite(opm_t *chip)
  function OPM_DoIC (line 1791) | static void OPM_DoIC(opm_t *chip)
  function OPM_Clock (line 1858) | void OPM_Clock(opm_t *chip, int32_t *output, uint8_t *sh1, uint8_t *sh2,...
  function OPM_Write (line 1934) | void OPM_Write(opm_t *chip, uint32_t port, uint8_t data)
  function OPM_Read (line 1951) | uint8_t OPM_Read(opm_t *chip, uint32_t port)
  function OPM_ReadIRQ (line 1969) | uint8_t OPM_ReadIRQ(opm_t *chip, uint32_t port)
  function OPM_ReadCT1 (line 1974) | uint8_t OPM_ReadCT1(opm_t *chip)
  function OPM_ReadCT2 (line 1979) | uint8_t OPM_ReadCT2(opm_t *chip)
  function OPM_SetIC (line 1988) | void OPM_SetIC(opm_t *chip, uint8_t ic)
  function OPM_Reset (line 2001) | void OPM_Reset(opm_t *chip)
  function OPM_WriteBuffered (line 2015) | void OPM_WriteBuffered(opm_t *chip, uint32_t port, uint8_t data)
  function OPM_GenerateResampled (line 2051) | void OPM_GenerateResampled(opm_t *chip, int32_t *buf)
  function OPM_GenerateStream (line 2092) | void OPM_GenerateStream(opm_t *chip, int32_t **sndptr, uint32_t numsamples)
  function OPM_Reset (line 2108) | void OPM_Reset(opm_t* chip, uint32_t rate, uint32_t clock)
  function OPM_SetMute (line 2129) | void OPM_SetMute(opm_t *chip, uint32_t mute)

FILE: VGMPlay/chips/opm.h
  type opm_writebuf (line 35) | typedef struct {
  type opm_t (line 41) | typedef struct {

FILE: VGMPlay/chips/panning.c
  function calc_panning (line 17) | void calc_panning(float channels[2], int position)
  function centre_panning (line 38) | void centre_panning(float channels[2])

FILE: VGMPlay/chips/pokey.c
  type pokey_state (line 161) | typedef struct _pokey_state pokey_state;
  type _pokey_state (line 162) | struct _pokey_state
  function pokey_update (line 543) | void pokey_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function poly_init (line 554) | static void poly_init(UINT8 *poly, int size, int left, int right, int add)
  function rand_init (line 569) | static void rand_init(UINT8 *rng, int size, int left, int right, int add)
  function device_start_pokey (line 627) | int device_start_pokey(UINT8 ChipID, int clock)
  function device_stop_pokey (line 698) | void device_stop_pokey(UINT8 ChipID)
  function device_reset_pokey (line 705) | void device_reset_pokey(UINT8 ChipID)
  function UINT8 (line 877) | UINT8 pokey_r(UINT8 ChipID, offs_t offset)
  function pokey_w (line 1015) | void pokey_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function pokey_set_mute_mask (line 1455) | void pokey_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/pwm.c
  type pwm_chip (line 57) | typedef struct _pwm_chip
  function PWM_Init (line 113) | void PWM_Init(pwm_chip* chip)
  function PWM_Recalc_Scale (line 139) | void PWM_Recalc_Scale(pwm_chip* chip)
  function PWM_Set_Cycle (line 147) | void PWM_Set_Cycle(pwm_chip* chip, unsigned int cycle)
  function PWM_Set_Int (line 160) | void PWM_Set_Int(pwm_chip* chip, unsigned int int_time)
  function PWM_Clear_Timer (line 170) | void PWM_Clear_Timer(pwm_chip* chip)
  function INLINE (line 283) | INLINE int PWM_Update_Scale(pwm_chip* chip, int PWM_In)
  function PWM_Update (line 315) | void PWM_Update(pwm_chip* chip, int **buf, int length)
  function pwm_update (line 343) | void pwm_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_pwm (line 350) | int device_start_pwm(UINT8 ChipID, int clock)
  function device_stop_pwm (line 374) | void device_stop_pwm(UINT8 ChipID)
  function device_reset_pwm (line 382) | void device_reset_pwm(UINT8 ChipID)
  function pwm_chn_w (line 388) | void pwm_chn_w(UINT8 ChipID, UINT8 Channel, UINT16 data)

FILE: VGMPlay/chips/qsound_ctr.c
  type qsound_voice (line 27) | struct qsound_voice {
  type qsound_adpcm (line 38) | struct qsound_adpcm {
  type qsound_fir (line 50) | struct qsound_fir {
  type qsound_delay (line 59) | struct qsound_delay {
  type qsound_echo (line 67) | struct qsound_echo {
  type qsound_chip (line 77) | struct qsound_chip {
  type qsound_chip (line 116) | struct qsound_chip
  type qsound_chip (line 117) | struct qsound_chip
  type qsound_chip (line 118) | struct qsound_chip
  type qsound_chip (line 120) | struct qsound_chip
  type qsound_chip (line 121) | struct qsound_chip
  type qsound_chip (line 122) | struct qsound_chip
  type qsound_chip (line 123) | struct qsound_chip
  type qsound_chip (line 125) | struct qsound_chip
  type qsound_chip (line 126) | struct qsound_chip
  type qsound_chip (line 127) | struct qsound_chip
  type qsound_chip (line 128) | struct qsound_chip
  type qsound_echo (line 129) | struct qsound_echo
  type qsound_fir (line 130) | struct qsound_fir
  type qsound_delay (line 131) | struct qsound_delay
  type qsound_delay (line 132) | struct qsound_delay
  type qsound_chip (line 137) | struct qsound_chip
  function device_start_qsound_ctr (line 139) | int device_start_qsound_ctr(UINT8 ChipID, int clock)
  function device_stop_qsound_ctr (line 157) | void device_stop_qsound_ctr(UINT8 ChipID)
  function device_reset_qsound_ctr (line 166) | void device_reset_qsound_ctr(UINT8 ChipID)
  function UINT8 (line 178) | UINT8 qsoundc_r(UINT8 ChipID, offs_t offset)
  function qsoundc_w (line 185) | void qsoundc_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function qsoundc_write_data (line 207) | void qsoundc_write_data(UINT8 ChipID, UINT8 address, UINT16 data)
  function qsoundc_update (line 219) | void qsoundc_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function qsoundc_write_rom (line 237) | void qsoundc_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, o...
  function qsoundc_set_mute_mask (line 259) | void qsoundc_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function qsoundc_wait_busy (line 268) | void qsoundc_wait_busy(UINT8 ChipID)
  function init_pan_tables (line 384) | static void init_pan_tables(struct qsound_chip *chip)
  function init_register_map (line 401) | static void init_register_map(struct qsound_chip *chip)
  function INLINE (line 454) | INLINE INT16 get_sample(struct qsound_chip *chip, UINT16 bank,UINT16 add...
  function INLINE (line 472) | INLINE const INT16* get_filter_table(struct qsound_chip *chip, UINT16 of...
  function update_sample (line 489) | static void update_sample(struct qsound_chip *chip)
  function state_init (line 512) | static void state_init(struct qsound_chip *chip)
  function state_refresh_filter_1 (line 587) | static void state_refresh_filter_1(struct qsound_chip *chip)
  function state_refresh_filter_2 (line 606) | static void state_refresh_filter_2(struct qsound_chip *chip)
  function INLINE (line 633) | INLINE INT16 pcm_update(struct qsound_chip *chip, int voice_no, INT32 *e...
  function INLINE (line 666) | INLINE void adpcm_update(struct qsound_chip *chip, int voice_no, int nib...
  function INLINE (line 722) | INLINE INT16 echo(struct qsound_echo *r,INT32 input)
  function state_normal_update (line 743) | static void state_normal_update(struct qsound_chip *chip)
  function INLINE (line 825) | INLINE INT32 fir(struct qsound_fir *f, INT16 input)
  function INLINE (line 847) | INLINE INT32 delay(struct qsound_delay *d, INT32 input)
  function INLINE (line 863) | INLINE void delay_update(struct qsound_delay *d)

FILE: VGMPlay/chips/qsound_intf.c
  function device_start_qsound (line 26) | int device_start_qsound(UINT8 ChipID, int clock)
  function device_stop_qsound (line 47) | void device_stop_qsound(UINT8 ChipID)
  function device_reset_qsound (line 60) | void device_reset_qsound(UINT8 ChipID)
  function qsound_w (line 78) | void qsound_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 137) | UINT8 qsound_r(UINT8 ChipID, offs_t offset)
  function qsound_update (line 151) | void qsound_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function qsound_write_rom (line 164) | void qsound_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, of...
  function qsound_set_mute_mask (line 178) | void qsound_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function qsound_set_emu_core (line 191) | void qsound_set_emu_core(UINT8 Emulator)

FILE: VGMPlay/chips/qsound_mame.c
  type INT8 (line 53) | typedef INT8 QSOUND_SRC_SAMPLE;
  type stream_sample_t (line 58) | typedef stream_sample_t QSOUND_SAMPLE;
  type QSOUND_CHANNEL (line 60) | struct QSOUND_CHANNEL
  type qsound_state (line 78) | typedef struct _qsound_state qsound_state;
  type _qsound_state (line 79) | struct _qsound_state
  function device_start_qsoundm (line 111) | int device_start_qsoundm(UINT8 ChipID, int clock)
  function device_stop_qsoundm (line 175) | void device_stop_qsoundm(UINT8 ChipID)
  function device_reset_qsoundm (line 192) | void device_reset_qsoundm(UINT8 ChipID)
  function qsoundm_w (line 209) | void qsoundm_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 235) | UINT8 qsoundm_r(UINT8 ChipID, offs_t offset)
  function qsound_set_command (line 241) | static void qsound_set_command(qsound_state *chip, UINT8 address, UINT16...
  function qsoundm_update (line 358) | void qsoundm_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function qsoundm_write_rom (line 427) | void qsoundm_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, o...
  function qsoundm_set_mute_mask (line 449) | void qsoundm_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/rf5c68.c
  type pcm_channel (line 20) | typedef struct _pcm_channel pcm_channel;
  type _pcm_channel (line 21) | struct _pcm_channel
  type mem_stream (line 33) | typedef struct _mem_stream mem_stream;
  type _mem_stream (line 34) | struct _mem_stream
  type rf5c68_state (line 44) | typedef struct _rf5c68_state rf5c68_state;
  type _rf5c68_state (line 45) | struct _rf5c68_state
  function memstream_sample_check (line 77) | static void memstream_sample_check(rf5c68_state *chip, UINT32 addr, UINT...
  function rf5c68_update (line 115) | void rf5c68_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_rf5c68 (line 225) | int device_start_rf5c68(UINT8 ChipID, int clock)
  function device_stop_rf5c68 (line 256) | void device_stop_rf5c68(UINT8 ChipID)
  function device_reset_rf5c68 (line 264) | void device_reset_rf5c68(UINT8 ChipID)
  function rf5c68_w (line 303) | void rf5c68_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 371) | UINT8 rf5c68_mem_r(UINT8 ChipID, offs_t offset)
  function rf5c68_mem_w (line 384) | void rf5c68_mem_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function rf5c68_mem_stream_flush (line 392) | static void rf5c68_mem_stream_flush(rf5c68_state *chip)
  function rf5c68_write_ram (line 405) | void rf5c68_write_ram(UINT8 ChipID, offs_t DataStart, offs_t DataLength,...
  function rf5c68_set_mute_mask (line 439) | void rf5c68_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/saa1099.c
  type saa1099_channel (line 76) | struct saa1099_channel
  type saa1099_noise (line 93) | struct saa1099_noise
  type saa1099_state (line 102) | typedef struct _saa1099_state saa1099_state;
  type _saa1099_state (line 103) | struct _saa1099_state
  function saa1099_envelope (line 185) | static void saa1099_envelope(saa1099_state *saa, int ch)
  function saa1099_update (line 229) | void saa1099_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_saa1099 (line 370) | int device_start_saa1099(UINT8 ChipID, int clock)
  function device_stop_saa1099 (line 396) | void device_stop_saa1099(UINT8 ChipID)
  function device_reset_saa1099 (line 403) | void device_reset_saa1099(UINT8 ChipID)
  function saa1099_control_w (line 447) | void saa1099_control_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function saa1099_data_w (line 472) | void saa1099_data_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function saa1099_set_mute_mask (line 560) | void saa1099_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/scd_pcm.c
  type pcm_chip_ (line 28) | struct pcm_chip_
  function PCM_Init (line 42) | int PCM_Init(UINT8 ChipID, int Rate)
  function PCM_Reset (line 85) | void PCM_Reset(UINT8 ChipID)
  function PCM_Set_Rate (line 119) | void PCM_Set_Rate(UINT8 ChipID, int Rate)
  function PCM_Write_Reg (line 143) | void PCM_Write_Reg(UINT8 ChipID, unsigned int Reg, unsigned int Data)
  function PCM_Update (line 270) | int PCM_Update(UINT8 ChipID, int **buf, int Length)
  function rf5c164_update (line 434) | void rf5c164_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_rf5c164 (line 441) | int device_start_rf5c164(UINT8 ChipID, int clock)
  function device_stop_rf5c164 (line 466) | void device_stop_rf5c164(UINT8 ChipID)
  function device_reset_rf5c164 (line 474) | void device_reset_rf5c164(UINT8 ChipID)
  function rf5c164_w (line 480) | void rf5c164_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function rf5c164_mem_w (line 486) | void rf5c164_mem_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function rf5c164_write_ram (line 492) | void rf5c164_write_ram(UINT8 ChipID, offs_t DataStart, offs_t DataLength...
  function rf5c164_set_mute_mask (line 508) | void rf5c164_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/scd_pcm.h
  type pcm_chip_ (line 1) | struct pcm_chip_

FILE: VGMPlay/chips/scsp.c
  type _STATE (line 117) | typedef enum {ATTACK,DECAY1,DECAY2,RELEASE} _STATE;
  type _EG (line 118) | struct _EG
  type _SLOT (line 134) | struct _SLOT
  type scsp_state (line 182) | typedef struct _scsp_state scsp_state;
  type _scsp_state (line 183) | struct _scsp_state
  function Get_AR (line 383) | static int Get_AR(scsp_state *scsp,int base,int R)
  function Get_DR (line 391) | static int Get_DR(scsp_state *scsp,int base,int R)
  function Get_RR (line 399) | static int Get_RR(scsp_state *scsp,int base,int R)
  function Compute_EG (line 407) | static void Compute_EG(scsp_state *scsp,struct _SLOT *slot)
  type _SLOT (line 425) | struct _SLOT
  function EG_Update (line 427) | static int EG_Update(struct _SLOT *slot)
  function UINT32 (line 477) | static UINT32 SCSP_Step(struct _SLOT *slot)
  function Compute_LFO (line 494) | static void Compute_LFO(struct _SLOT *slot)
  function SCSP_StartSlot (line 502) | static void SCSP_StartSlot(scsp_state *scsp, struct _SLOT *slot)
  function SCSP_StopSlot (line 523) | static void SCSP_StopSlot(struct _SLOT *slot,int keyoff)
  function SCSP_Init (line 539) | static void SCSP_Init(scsp_state *scsp, int clock)
  function INLINE (line 682) | INLINE void SCSP_UpdateSlotReg(scsp_state *scsp,int s,int r)
  function INLINE (line 725) | INLINE void SCSP_UpdateReg(scsp_state *scsp, /*address_space &space,*/ i...
  function SCSP_UpdateSlotRegR (line 909) | static void SCSP_UpdateSlotRegR(scsp_state *scsp, int slot,int reg)
  function SCSP_UpdateRegR (line 914) | static void SCSP_UpdateRegR(scsp_state *scsp, int reg)
  function INLINE (line 973) | INLINE void SCSP_w16(scsp_state *scsp,unsigned int addr,unsigned short val)
  function SCSP_r16 (line 1014) | INLINE unsigned short SCSP_r16(scsp_state *scsp, unsigned int addr)
  function INLINE (line 1092) | INLINE INT32 SCSP_UpdateSlot(scsp_state *scsp, struct _SLOT *slot)
  function INLINE (line 1284) | INLINE void SCSP_DoMasterSamples(scsp_state *scsp, stream_sample_t **out...
  function SCSP_IRQCB (line 1449) | int SCSP_IRQCB(void *param)
  function SCSP_Update (line 1457) | void SCSP_Update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_scsp (line 1468) | int device_start_scsp(UINT8 ChipID, int clock)
  function device_stop_scsp (line 1500) | void device_stop_scsp(UINT8 ChipID)
  function device_reset_scsp (line 1509) | void device_reset_scsp(UINT8 ChipID)
  function UINT16 (line 1545) | UINT16 scsp_r(UINT8 ChipID, offs_t offset)
  function scsp_w (line 1556) | void scsp_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function scsp_write_ram (line 1619) | void scsp_write_ram(UINT8 ChipID, offs_t DataStart, offs_t DataLength, c...
  function scsp_set_mute_mask (line 1634) | void scsp_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function scsp_set_options (line 1645) | void scsp_set_options(UINT8 Flags)
  function UINT8 (line 1652) | UINT8 scsp_get_channels(UINT32* ChannelMask)

FILE: VGMPlay/chips/scspdsp.c
  function UINT16 (line 7) | static UINT16 PACK(INT32 val)
  function INT32 (line 34) | static INT32 UNPACK(UINT16 val)
  function SCSPDSP_Init (line 58) | void SCSPDSP_Init(struct _SCSPDSP *DSP)
  function SCSPDSP_Step (line 65) | void SCSPDSP_Step(struct _SCSPDSP *DSP)
  function SCSPDSP_SetSample (line 335) | void SCSPDSP_SetSample(struct _SCSPDSP *DSP,INT32 sample,int SEL,int MXL)
  function SCSPDSP_Start (line 343) | void SCSPDSP_Start(struct _SCSPDSP *DSP)

FILE: VGMPlay/chips/scspdsp.h
  type _SCSPDSP (line 7) | struct _SCSPDSP
  type _SCSPDSP (line 35) | struct _SCSPDSP
  type _SCSPDSP (line 36) | struct _SCSPDSP
  type _SCSPDSP (line 37) | struct _SCSPDSP
  type _SCSPDSP (line 38) | struct _SCSPDSP

FILE: VGMPlay/chips/scsplfo.c
  type _LFO (line 13) | struct _LFO
  function LFO_Init (line 42) | static void LFO_Init(/*running_machine &machine*/)
  function PLFO_Step (line 115) | INLINE signed int PLFO_Step(struct _LFO *LFO)
  function ALFO_Step (line 127) | INLINE signed int ALFO_Step(struct _LFO *LFO)
  function LFO_ComputeStep (line 139) | static void LFO_ComputeStep(struct _LFO *LFO,UINT32 LFOF,UINT32 LFOWS,UI...

FILE: VGMPlay/chips/segapcm.c
  type segapcm_state (line 14) | typedef struct _segapcm_state segapcm_state;
  type _segapcm_state (line 15) | struct _segapcm_state
  function SEGAPCM_update (line 52) | void SEGAPCM_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_segapcm (line 206) | int device_start_segapcm(UINT8 ChipID, int clock, int intf_bank)
  function device_stop_segapcm (line 268) | void device_stop_segapcm(UINT8 ChipID)
  function device_reset_segapcm (line 283) | void device_reset_segapcm(UINT8 ChipID)
  function sega_pcm_w (line 295) | void sega_pcm_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 305) | UINT8 sega_pcm_r(UINT8 ChipID, offs_t offset)
  function sega_pcm_write_rom (line 313) | void sega_pcm_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, ...
  function sega_pcm_fwrite_romusage (line 359) | static void sega_pcm_fwrite_romusage(UINT8 ChipID)
  function segapcm_set_mute_mask (line 376) | void segapcm_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/segapcm.h
  type sega_pcm_interface (line 14) | typedef struct _sega_pcm_interface sega_pcm_interface;
  type _sega_pcm_interface (line 15) | struct _sega_pcm_interface

FILE: VGMPlay/chips/sn76489.c
  function SN76489_Context (line 47) | SN76489_Context* SN76489_Init( int PSGClockValue, int SamplingRate)
  function SN76489_Reset (line 81) | void SN76489_Reset(SN76489_Context* chip)
  function SN76489_Shutdown (line 116) | void SN76489_Shutdown(SN76489_Context* chip)
  function SN76489_Config (line 121) | void SN76489_Config(SN76489_Context* chip, /*int mute,*/ int feedback, i...
  function SN76489_Write (line 149) | void SN76489_Write(SN76489_Context* chip, int data)
  function SN76489_GGStereoWrite (line 183) | void SN76489_GGStereoWrite(SN76489_Context* chip, int data)
  function SN76489_Update (line 189) | void SN76489_Update(SN76489_Context* chip, INT32 **buffer, int length)
  function SN76489_SetMute (line 392) | void SN76489_SetMute(SN76489_Context* chip, int val)
  function SN76489_SetPanning (line 397) | void SN76489_SetPanning(SN76489_Context* chip, int ch0, int ch1, int ch2...

FILE: VGMPlay/chips/sn76489.h
  type feedback_patterns (line 28) | enum feedback_patterns {
  type sr_widths (line 34) | enum sr_widths {
  type volume_modes (line 39) | enum volume_modes {
  type mute_values (line 44) | enum mute_values {
  type SN76489_Context (line 53) | typedef struct

FILE: VGMPlay/chips/sn76496.c
  type sn76496_state (line 138) | typedef struct _sn76496_state sn76496_state;
  type _sn76496_state (line 139) | struct _sn76496_state
  function UINT8 (line 184) | UINT8 sn76496_ready_r(void *chip, offs_t offset)
  function sn76496_stereo_w (line 193) | void sn76496_stereo_w(void *chip, offs_t offset, UINT8 data)
  function sn76496_write_reg (line 205) | void sn76496_write_reg(void *chip, offs_t offset, UINT8 data)
  function SN76496Update (line 280) | void SN76496Update(void *chip, stream_sample_t **outputs, int samples)
  function SN76496_set_gain (line 507) | static void SN76496_set_gain(sn76496_state *R,int gain)
  function SN76496_init (line 536) | static int SN76496_init(int clock, sn76496_state *R, int stereo)
  function generic_start (line 581) | static int generic_start(sn76496_state *chip, int clock, int feedbackmas...
  function sn76496_start (line 642) | unsigned long int sn76496_start(void **chip, int clock, int shiftregwidt...
  function sn76496_shutdown (line 678) | void sn76496_shutdown(void *chip)
  function sn76496_reset (line 686) | void sn76496_reset(void *chip)
  function sn76496_freq_limiter (line 716) | void sn76496_freq_limiter(int clock, int clockdiv, int sample_rate)
  function sn76496_set_mutemask (line 723) | void sn76496_set_mutemask(void *chip, UINT32 MuteMask)

FILE: VGMPlay/chips/sn76496_opl.c
  type sn76496_state_opl (line 7) | typedef struct _sn76496_state_opl sn76496_state_opl;
  type _sn76496_state_opl (line 8) | struct _sn76496_state_opl
  function sn76496_stereo_opl (line 131) | void sn76496_stereo_opl(UINT8 ChipID, offs_t offset, UINT8 data)
  function sn76496_refresh_t6w28_opl (line 153) | void sn76496_refresh_t6w28_opl(UINT8 ChipID)
  function SendVolume (line 180) | static void SendVolume(sn76496_state_opl* R, UINT8 Channel)
  function SendFrequency (line 208) | static void SendFrequency(sn76496_state_opl* R, UINT8 Channel)
  function sn76496_write_opl (line 300) | void sn76496_write_opl(UINT8 ChipID, offs_t offset, UINT8 data)
  function SN76496_init (line 364) | static void SN76496_init(int clock, sn76496_state_opl *R, int stereo)
  function start_sn76496_opl (line 432) | void start_sn76496_opl(UINT8 ChipID, int clock, int stereo)

FILE: VGMPlay/chips/sn764intf.c
  type sn764xx_state (line 22) | typedef struct _sn764xx_state sn764xx_state;
  type _sn764xx_state (line 23) | struct _sn764xx_state
  function sn764xx_stream_update (line 34) | void sn764xx_stream_update(UINT8 ChipID, stream_sample_t **outputs, int ...
  function device_start_sn764xx (line 50) | int device_start_sn764xx(UINT8 ChipID, int clock, int shiftregwidth, int...
  function device_stop_sn764xx (line 82) | void device_stop_sn764xx(UINT8 ChipID)
  function device_reset_sn764xx (line 98) | void device_reset_sn764xx(UINT8 ChipID)
  function sn764xx_w (line 115) | void sn764xx_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function sn764xx_set_emu_core (line 147) | void sn764xx_set_emu_core(UINT8 Emulator)
  function sn764xx_set_mute_mask (line 158) | void sn764xx_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)
  function sn764xx_set_panning (line 176) | void sn764xx_set_panning(UINT8 ChipID, INT16* PanVals)

FILE: VGMPlay/chips/upd7759.c
  type upd7759_state (line 155) | typedef struct _upd7759_state upd7759_state;
  type _upd7759_state (line 156) | struct _upd7759_state
  function INLINE (line 257) | INLINE void update_adpcm(upd7759_state *chip, int data)
  function get_fifo_data (line 278) | static void get_fifo_data(upd7759_state *chip)
  function advance_state (line 293) | static void advance_state(upd7759_state *chip)
  function upd7759_update (line 507) | void upd7759_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function upd7759_reset (line 629) | static void upd7759_reset(upd7759_state *chip)
  function device_reset_upd7759 (line 665) | void device_reset_upd7759(UINT8 ChipID)
  function device_start_upd7759 (line 715) | int device_start_upd7759(UINT8 ChipID, int clock)
  function device_stop_upd7759 (line 766) | void device_stop_upd7759(UINT8 ChipID)
  function upd7759_reset_w (line 784) | void upd7759_reset_w(UINT8 ChipID, UINT8 data)
  function upd7759_start_w (line 801) | void upd7759_start_w(UINT8 ChipID, UINT8 data)
  function upd7759_port_w (line 828) | void upd7759_port_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function upd7759_busy_r (line 849) | int upd7759_busy_r(UINT8 ChipID)
  function upd7759_set_bank_base (line 859) | void upd7759_set_bank_base(UINT8 ChipID, UINT32 base)
  function upd7759_write (line 867) | void upd7759_write(UINT8 ChipID, UINT8 Port, UINT8 Data)
  function upd7759_write_rom (line 888) | void upd7759_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, o...

FILE: VGMPlay/chips/upd7759.h
  type upd7759_interface (line 12) | typedef struct _upd7759_interface upd7759_interface;
  type _upd7759_interface (line 13) | struct _upd7759_interface

FILE: VGMPlay/chips/vsu.c
  type vsu_state (line 23) | typedef struct
  function VSU_Power (line 93) | static void VSU_Power(vsu_state* chip)
  function VSU_Write (line 134) | void VSU_Write(UINT8 ChipID, UINT32 A, UINT8 V)
  function INLINE (line 257) | INLINE void VSU_CalcCurrentOutput(vsu_state* chip, int ch, int* left, in...
  function VSU_Update (line 297) | static void VSU_Update(vsu_state* chip, INT32 timestamp, int* outleft, i...
  function vsu_stream_update (line 567) | void vsu_stream_update(UINT8 ChipID, stream_sample_t **outputs, int samp...
  function device_start_vsu (line 596) | int device_start_vsu(UINT8 ChipID, int clock)
  function device_stop_vsu (line 617) | void device_stop_vsu(UINT8 ChipID)
  function device_reset_vsu (line 622) | void device_reset_vsu(UINT8 ChipID)
  function vsu_set_mute_mask (line 635) | void vsu_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/ws_audio.c
  type UINT8 (line 7) | typedef UINT8	BYTE;
  type UINT8 (line 8) | typedef UINT8	byte;
  type UINT8 (line 9) | typedef UINT8	uint8;
  type WS_AUDIO (line 55) | typedef struct
  type wsa_state (line 66) | typedef struct
  function ws_audio_init (line 103) | int ws_audio_init(UINT8 ChipID, int clock)
  function ws_audio_reset (line 127) | void ws_audio_reset(UINT8 ChipID)
  function ws_audio_done (line 148) | void ws_audio_done(UINT8 ChipID)
  function ws_audio_update (line 158) | void ws_audio_update(UINT8 ChipID, stream_sample_t** buffer, int length)
  function ws_audio_port_write (line 287) | void ws_audio_port_write(UINT8 ChipID, BYTE port, BYTE value)
  function BYTE (line 399) | BYTE ws_audio_port_read(UINT8 ChipID, BYTE port)
  function ws_audio_process (line 407) | static void ws_audio_process(wsa_state* chip)
  function ws_write_ram (line 460) | void ws_write_ram(UINT8 ChipID, UINT16 offset, UINT8 value)
  function ws_set_mute_mask (line 472) | void ws_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/x1_010.c
  type X1_010_CHANNEL (line 75) | typedef struct {
  type x1_010_state (line 85) | typedef struct _x1_010_state x1_010_state;
  type _x1_010_state (line 86) | struct _x1_010_state
  function seta_update (line 127) | void seta_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_x1_010 (line 219) | int device_start_x1_010(UINT8 ChipID, int clock)
  function device_stop_x1_010 (line 255) | void device_stop_x1_010(UINT8 ChipID)
  function device_reset_x1_010 (line 264) | void device_reset_x1_010(UINT8 ChipID)
  function UINT8 (line 289) | UINT8 seta_sound_r(UINT8 ChipID, offs_t offset)
  function seta_sound_w (line 301) | void seta_sound_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function x1_010_write_rom (line 320) | void x1_010_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, of...
  function x1_010_set_mute_mask (line 342) | void x1_010_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/ym2151.c
  type YM2151Operator (line 34) | typedef struct{
  type YM2151 (line 86) | typedef struct
  function init_tables (line 506) | static void init_tables(void)
  function init_chip_tables (line 595) | static void init_chip_tables(YM2151 *chip)
  function TIMER_CALLBACK (line 861) | static TIMER_CALLBACK( timer_callback_chip_busy )
  function INLINE (line 874) | INLINE void set_connect( YM2151Operator *om1, int cha, int v)
  function INLINE (line 966) | INLINE void refresh_EG(YM2151Operator * op)
  function ym2151_write_reg (line 1057) | void ym2151_write_reg(void *_chip, int r, int v)
  function ym2151_read_status (line 1383) | int ym2151_read_status( void *_chip )
  function ym2151_shutdown (line 1578) | void ym2151_shutdown(void *_chip)
  function ym2151_reset_chip (line 1608) | void ym2151_reset_chip(void *_chip)
  function op_calc (line 1670) | INLINE signed int op_calc(YM2151Operator * OP, unsigned int env, signed ...
  function op_calc1 (line 1683) | INLINE signed int op_calc1(YM2151Operator * OP, unsigned int env, signed...
  function INLINE (line 1707) | INLINE void chan_calc(unsigned int chan)
  function INLINE (line 1761) | INLINE void chan7_calc(void)
  function INLINE (line 2036) | INLINE void advance_eg(void)
  function INLINE (line 2120) | INLINE void advance(void)
  function acc_calc (line 2301) | INLINE signed int acc_calc(signed int value)
  function ym2151_update_one (line 2402) | void ym2151_update_one(void *chip, SAMP **buffers, int length)
  function ym2151_set_mutemask (line 2527) | void ym2151_set_mutemask(void *chip, UINT32 MuteMask)

FILE: VGMPlay/chips/ym2151.h
  type stream_sample_t (line 37) | typedef stream_sample_t SAMP;

FILE: VGMPlay/chips/ym2413.c
  function acc_calc (line 105) | INLINE signed int acc_calc(signed int value)
  type OPLL_SLOT (line 173) | typedef struct{
  type OPLL_CH (line 217) | typedef struct{
  type YM2413 (line 229) | typedef struct {
  function INLINE (line 646) | INLINE void advance_lfo(YM2413 *chip)
  function INLINE (line 660) | INLINE void advance(YM2413 *chip)
  function op_calc (line 890) | INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm,...
  function op_calc1 (line 901) | INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm...
  function INLINE (line 923) | INLINE void chan_calc( YM2413*chip, OPLL_CH *CH )
  function INLINE (line 1003) | INLINE void rhythm_calc( YM2413 *chip, OPLL_CH *CH, unsigned int noise )
  function init_tables (line 1169) | static int init_tables(void)
  function OPLCloseTable (line 1259) | static void OPLCloseTable( void )
  function OPLL_initalize (line 1340) | static void OPLL_initalize(YM2413 *chip)
  function INLINE (line 1409) | INLINE void KEY_ON(OPLL_SLOT *SLOT, UINT32 key_set)
  function INLINE (line 1420) | INLINE void KEY_OFF(OPLL_SLOT *SLOT, UINT32 key_clr)
  function INLINE (line 1436) | INLINE void CALC_FCSLOT(OPLL_CH *CH,OPLL_SLOT *SLOT)
  function INLINE (line 1482) | INLINE void set_mul(YM2413 *chip,int slot,int v)
  function INLINE (line 1496) | INLINE void set_ksl_tl(YM2413 *chip,int chan,int v)
  function INLINE (line 1508) | INLINE void set_ksl_wave_fb(YM2413 *chip,int chan,int v)
  function INLINE (line 1526) | INLINE void set_ar_dr(YM2413 *chip,int slot,int v)
  function INLINE (line 1550) | INLINE void set_sl_rr(YM2413 *chip,int slot,int v)
  function load_instrument (line 1562) | static void load_instrument(YM2413 *chip, UINT32 chan, UINT32 slot, UINT...
  function update_instrument_zero (line 1573) | static void update_instrument_zero(YM2413 *chip, UINT8 r )
  function OPLLWriteReg (line 1661) | static void OPLLWriteReg(YM2413 *chip, int r, int v)
  function OPLL_LockTable (line 1943) | static int OPLL_LockTable(void)
  function OPLL_UnLockTable (line 1969) | static void OPLL_UnLockTable(void)
  function OPLLResetChip (line 1983) | static void OPLLResetChip(YM2413 *chip)
  function YM2413 (line 2026) | static YM2413 *OPLLCreate(int clock, int rate)
  function OPLLDestroy (line 2060) | static void OPLLDestroy(YM2413 *chip)
  function OPLLSetUpdateHandler (line 2068) | static void OPLLSetUpdateHandler(YM2413 *chip,OPLL_UPDATEHANDLER UpdateH...
  function OPLLWrite (line 2075) | static void OPLLWrite(YM2413 *chip,int a,int v)
  function OPLLRead (line 2088) | static unsigned char OPLLRead(YM2413 *chip,int a)
  function ym2413_shutdown (line 2109) | void ym2413_shutdown(void *chip)
  function ym2413_reset_chip (line 2117) | void ym2413_reset_chip(void *chip)
  function ym2413_write (line 2123) | void ym2413_write(void *chip, int a, int v)
  function ym2413_read (line 2129) | unsigned char ym2413_read(void *chip, int a)
  function ym2413_set_update_handler (line 2135) | void ym2413_set_update_handler(void *chip,OPLL_UPDATEHANDLER UpdateHandl...
  function ym2413_update_one (line 2149) | void ym2413_update_one(void *_chip, SAMP **buffers, int length)
  function ym2413_set_mutemask (line 2216) | void ym2413_set_mutemask(void* chip, UINT32 MuteMask)
  function ym2413_set_chip_mode (line 2229) | void ym2413_set_chip_mode(void* chip, UINT8 Mode)
  function ym2413_override_patches (line 2239) | void ym2413_override_patches(void* chip, const UINT8* PatchDump)

FILE: VGMPlay/chips/ym2413.h
  type stream_sample_t (line 18) | typedef stream_sample_t SAMP;

FILE: VGMPlay/chips/ym2413_opl.c
  type OPLL_SLOT_OPL (line 9) | typedef struct{
  type OPLL_CH_OPL (line 40) | typedef struct{
  type YM2413 (line 54) | typedef struct {
  function INLINE (line 123) | INLINE void set_mul(YM2413 *chip,int slot,int v)
  function INLINE (line 139) | INLINE void set_ksl_tl(YM2413 *chip,int chan,int v)
  function INLINE (line 153) | INLINE void set_ksl_wave_fb(YM2413 *chip,int chan,int v)
  function INLINE (line 176) | INLINE void set_ar_dr(YM2413 *chip,int slot,int v)
  function INLINE (line 188) | INLINE void set_sl_rr(YM2413 *chip,int slot,int v)
  function load_instrument (line 199) | static void load_instrument(YM2413 *chip, UINT32 chan, UINT32 slot, UINT...
  function update_instrument_zero (line 211) | static void update_instrument_zero(YM2413 *chip, UINT8 r )
  function OPLLWriteReg2OPL (line 299) | static void OPLLWriteReg2OPL(YM2413 *chip, int r, int v)
  function OPLLWrite (line 507) | static void OPLLWrite(YM2413 *chip,int a,int v)
  function OPLLResetChip (line 519) | static void OPLLResetChip(YM2413 *chip)
  function start_ym2413_opl (line 578) | void start_ym2413_opl(UINT8 ChipID)
  function ym2413_w_opl (line 592) | void ym2413_w_opl(UINT8 ChipID, offs_t offset, UINT8 data)

FILE: VGMPlay/chips/ym2413hd.c
  type byte (line 12) | typedef unsigned char       byte;
  type word (line 13) | typedef unsigned short      word;
  type dword (line 14) | typedef unsigned long       dword;
  function FM_OPL_Init (line 115) | int     FM_OPL_Init (void *userdata /* unused */)
  function FM_OPL_Close (line 130) | void    FM_OPL_Close (void)
  function FM_OPL_Reset (line 152) | void    FM_OPL_Reset (void)
  function FM_OPL_Set_Voice (line 304) | void            FM_OPL_Set_Voice (int R, int V, int VL)
  function FM_OPL_Set_User_Voice (line 338) | void    FM_OPL_Set_User_Voice (void)
  function FM_OPL_Write (line 399) | void    FM_OPL_Write (int R, int V)

FILE: VGMPlay/chips/ym2413hd.h
  type FM_OPL_Patch (line 21) | typedef struct

FILE: VGMPlay/chips/ym2612.c
  function INLINE (line 272) | INLINE void CALC_FINC_SL(slot_ *SL, int finc, int kc)
  function INLINE (line 308) | INLINE void CALC_FINC_CH(channel_ *CH)
  function INLINE (line 328) | INLINE void KEY_ON(channel_ *CH, int nsl)
  function INLINE (line 351) | INLINE void KEY_OFF(channel_ *CH, int nsl)
  function INLINE (line 369) | INLINE void CSM_Key_Control(ym2612_ *YM2612)
  function SLOT_SET (line 378) | int SLOT_SET(ym2612_ *YM2612, int Adr, unsigned char data)
  function CHANNEL_SET (line 522) | int CHANNEL_SET(ym2612_ *YM2612, int Adr, unsigned char data)
  function YM_SET (line 662) | int YM_SET(ym2612_ *YM2612, int Adr, unsigned char data)
  function Env_NULL_Next (line 807) | void Env_NULL_Next(slot_ *SL)
  function Env_Attack_Next (line 812) | void Env_Attack_Next(slot_ *SL)
  function Env_Decay_Next (line 823) | void Env_Decay_Next(slot_ *SL)
  function Env_Substain_Next (line 834) | void Env_Substain_Next(slot_ *SL)
  function Env_Release_Next (line 877) | void Env_Release_Next(slot_ *SL)
  function Update_Chan_Algo0 (line 1115) | void Update_Chan_Algo0(ym2612_ *YM2612, channel_ *CH, int **buf, int len...
  function Update_Chan_Algo1 (line 1137) | void Update_Chan_Algo1(ym2612_ *YM2612, channel_ *CH, int **buf, int len...
  function Update_Chan_Algo2 (line 1159) | void Update_Chan_Algo2(ym2612_ *YM2612, channel_ *CH, int **buf, int len...
  function Update_Chan_Algo3 (line 1181) | void Update_Chan_Algo3(ym2612_ *YM2612, channel_ *CH, int **buf, int len...
  function Update_Chan_Algo4 (line 1203) | void Update_Chan_Algo4(ym2612_ *YM2612, channel_ *CH, int **buf, int len...
  function Update_Chan_Algo5 (line 1225) | void Update_Chan_Algo5(ym2612_ *YM2612, channel_ *CH, int **buf, int len...
  function Update_Chan_Algo6 (line 1247) | void Update_Chan_Algo6(ym2612_ *YM2612, channel_ *CH, int **buf, int len...
  function Update_Chan_Algo7 (line 1269) | void Update_Chan_Algo7(ym2612_ *YM2612, channel_ *CH, int **buf, int len...
  function Update_Chan_Algo0_LFO (line 1291) | void Update_Chan_Algo0_LFO(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo1_LFO (line 1313) | void Update_Chan_Algo1_LFO(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo2_LFO (line 1335) | void Update_Chan_Algo2_LFO(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo3_LFO (line 1357) | void Update_Chan_Algo3_LFO(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo4_LFO (line 1379) | void Update_Chan_Algo4_LFO(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo5_LFO (line 1401) | void Update_Chan_Algo5_LFO(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo6_LFO (line 1423) | void Update_Chan_Algo6_LFO(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo7_LFO (line 1445) | void Update_Chan_Algo7_LFO(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo0_Int (line 1472) | void Update_Chan_Algo0_Int(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo1_Int (line 1496) | void Update_Chan_Algo1_Int(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo2_Int (line 1520) | void Update_Chan_Algo2_Int(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo3_Int (line 1544) | void Update_Chan_Algo3_Int(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo4_Int (line 1568) | void Update_Chan_Algo4_Int(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo5_Int (line 1592) | void Update_Chan_Algo5_Int(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo6_Int (line 1616) | void Update_Chan_Algo6_Int(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo7_Int (line 1640) | void Update_Chan_Algo7_Int(ym2612_ *YM2612, channel_ *CH, int **buf, int...
  function Update_Chan_Algo0_LFO_Int (line 1664) | void Update_Chan_Algo0_LFO_Int(ym2612_ *YM2612, channel_ *CH, int **buf,...
  function Update_Chan_Algo1_LFO_Int (line 1688) | void Update_Chan_Algo1_LFO_Int(ym2612_ *YM2612, channel_ *CH, int **buf,...
  function Update_Chan_Algo2_LFO_Int (line 1712) | void Update_Chan_Algo2_LFO_Int(ym2612_ *YM2612, channel_ *CH, int **buf,...
  function Update_Chan_Algo3_LFO_Int (line 1736) | void Update_Chan_Algo3_LFO_Int(ym2612_ *YM2612, channel_ *CH, int **buf,...
  function Update_Chan_Algo4_LFO_Int (line 1760) | void Update_Chan_Algo4_LFO_Int(ym2612_ *YM2612, channel_ *CH, int **buf,...
  function Update_Chan_Algo5_LFO_Int (line 1784) | void Update_Chan_Algo5_LFO_Int(ym2612_ *YM2612, channel_ *CH, int **buf,...
  function Update_Chan_Algo6_LFO_Int (line 1808) | void Update_Chan_Algo6_LFO_Int(ym2612_ *YM2612, channel_ *CH, int **buf,...
  function Update_Chan_Algo7_LFO_Int (line 1832) | void Update_Chan_Algo7_LFO_Int(ym2612_ *YM2612, channel_ *CH, int **buf,...
  function ym2612_ (line 1863) | ym2612_ *YM2612_Init(int Clock, int Rate, int Interpolation)
  function YM2612_End (line 2123) | int YM2612_End(ym2612_ *YM2612)
  function YM2612_Reset (line 2136) | int YM2612_Reset(ym2612_ *YM2612)
  function YM2612_Read (line 2223) | int YM2612_Read(ym2612_ *YM2612)
  function YM2612_Write (line 2238) | int YM2612_Write(ym2612_ *YM2612, unsigned char adr, unsigned char data)
  function YM2612_GetMute (line 2317) | int YM2612_GetMute(ym2612_ *YM2612)
  function YM2612_SetMute (line 2329) | void YM2612_SetMute(ym2612_ *YM2612, int val)
  function YM2612_SetOptions (line 2340) | void YM2612_SetOptions(int Flags)
  function YM2612_ClearBuffer (line 2346) | void YM2612_ClearBuffer(int **buffer, int length)
  function YM2612_Update (line 2363) | void YM2612_Update(ym2612_ *YM2612, int **buf, int length)
  function YM2612_DacAndTimers_Update (line 2487) | void YM2612_DacAndTimers_Update(ym2612_ *YM2612, int **buffer, int length)
  function YM2612_Special_Update (line 2544) | void YM2612_Special_Update(ym2612_ *YM2612)

FILE: VGMPlay/chips/ym2612.h
  type slot_ (line 20) | typedef struct slot__ {
  type channel_ (line 60) | typedef struct channel__ {
  type ym2612_ (line 78) | typedef struct ym2612__ {

FILE: VGMPlay/chips/ym3438.c
  function OPN2_DoIO (line 227) | void OPN2_DoIO(ym3438_t *chip)
  function OPN2_DoRegWrite (line 241) | void OPN2_DoRegWrite(ym3438_t *chip)
  function OPN2_PhaseCalcIncrement (line 460) | void OPN2_PhaseCalcIncrement(ym3438_t *chip)
  function OPN2_PhaseGenerate (line 527) | void OPN2_PhaseGenerate(ym3438_t *chip)
  function OPN2_EnvelopeSSGEG (line 546) | void OPN2_EnvelopeSSGEG(ym3438_t *chip)
  function OPN2_EnvelopeADSR (line 593) | void OPN2_EnvelopeADSR(ym3438_t *chip)
  function OPN2_EnvelopePrepare (line 717) | void OPN2_EnvelopePrepare(ym3438_t *chip)
  function OPN2_EnvelopeGenerate (line 805) | void OPN2_EnvelopeGenerate(ym3438_t *chip)
  function OPN2_UpdateLFO (line 838) | void OPN2_UpdateLFO(ym3438_t *chip)
  function OPN2_FMPrepare (line 852) | void OPN2_FMPrepare(ym3438_t *chip)
  function OPN2_ChGenerate (line 914) | void OPN2_ChGenerate(ym3438_t *chip)
  function OPN2_ChOutput (line 949) | void OPN2_ChOutput(ym3438_t *chip)
  function OPN2_FMGenerate (line 1036) | void OPN2_FMGenerate(ym3438_t *chip)
  function OPN2_DoTimerA (line 1074) | void OPN2_DoTimerA(ym3438_t *chip)
  function OPN2_DoTimerB (line 1123) | void OPN2_DoTimerB(ym3438_t *chip)
  function OPN2_KeyOn (line 1168) | void OPN2_KeyOn(ym3438_t*chip)
  function OPN2_Reset (line 1192) | void OPN2_Reset(ym3438_t *chip, Bit32u rate, Bit32u clock)
  function OPN2_SetChipType (line 1219) | void OPN2_SetChipType(Bit32u type)
  function OPN2_Clock (line 1229) | void OPN2_Clock(ym3438_t *chip, Bit32s *buffer)
  function OPN2_Write (line 1363) | void OPN2_Write(ym3438_t *chip, Bit32u port, Bit8u data)
  function OPN2_SetTestPin (line 1379) | void OPN2_SetTestPin(ym3438_t *chip, Bit32u value)
  function Bit32u (line 1384) | Bit32u OPN2_ReadTestPin(ym3438_t *chip)
  function Bit32u (line 1393) | Bit32u OPN2_ReadIRQPin(ym3438_t *chip)
  function Bit8u (line 1398) | Bit8u OPN2_Read(ym3438_t *chip, Bit32u port)
  function OPN2_WriteBuffered (line 1433) | void OPN2_WriteBuffered(ym3438_t *chip, Bit32u port, Bit8u data)
  function OPN2_GenerateResampled (line 1468) | void OPN2_GenerateResampled(ym3438_t *chip, Bit32s *buf)
  function OPN2_GenerateStream (line 1544) | void OPN2_GenerateStream(ym3438_t *chip, Bit32s **sndptr, Bit32u numsamp...
  function OPN2_SetOptions (line 1560) | void OPN2_SetOptions(Bit8u flags)
  function OPN2_SetMute (line 1580) | void OPN2_SetMute(ym3438_t *chip, Bit32u mute)

FILE: VGMPlay/chips/ym3438.h
  type UINT64 (line 45) | typedef UINT64          Bit64u;
  type INT64 (line 46) | typedef INT64           Bit64s;
  type UINT32 (line 47) | typedef UINT32          Bit32u;
  type INT32 (line 48) | typedef INT32           Bit32s;
  type UINT16 (line 49) | typedef UINT16          Bit16u;
  type INT16 (line 50) | typedef INT16           Bit16s;
  type UINT8 (line 51) | typedef UINT8           Bit8u;
  type INT8 (line 52) | typedef INT8            Bit8s;
  type opn2_writebuf (line 54) | typedef struct _opn2_writebuf {
  type ym3438_t (line 60) | typedef struct

FILE: VGMPlay/chips/ymdeltat.c
  function YM_DELTAT_BRDY_callback (line 93) | void YM_DELTAT_BRDY_callback(YM_DELTAT *DELTAT)
  function UINT8 (line 104) | UINT8 YM_DELTAT_ADPCM_Read(YM_DELTAT *DELTAT)
  function YM_DELTAT_ADPCM_Write (line 159) | void YM_DELTAT_ADPCM_Write(YM_DELTAT *DELTAT,int r,int v)
  function YM_DELTAT_ADPCM_Reset (line 421) | void YM_DELTAT_ADPCM_Reset(YM_DELTAT *DELTAT,int pan,int emulation_mode)
  function INLINE (line 486) | INLINE void YM_DELTAT_synthesis_from_external_memory(YM_DELTAT *DELTAT)
  function INLINE (line 570) | INLINE void YM_DELTAT_synthesis_from_CPU_memory(YM_DELTAT *DELTAT)
  function YM_DELTAT_ADPCM_CALC (line 629) | void YM_DELTAT_ADPCM_CALC(YM_DELTAT *DELTAT)
  function YM_DELTAT_calc_mem_mask (line 665) | void YM_DELTAT_calc_mem_mask(YM_DELTAT* DELTAT)

FILE: VGMPlay/chips/ymdeltat.h
  type YM_DELTAT (line 13) | typedef struct deltat_adpcm_state {     /* AT: rearranged and tigntened ...

FILE: VGMPlay/chips/ymf262.c
  type OPL3_SLOT (line 148) | typedef struct{
  type OPL3_CH (line 198) | typedef struct{
  type OPL3 (line 224) | typedef struct {
  function INLINE (line 622) | INLINE void OPL3_STATUS_SET(OPL3 *chip,int flag)
  function INLINE (line 638) | INLINE void OPL3_STATUS_RESET(OPL3 *chip,int flag)
  function INLINE (line 654) | INLINE void OPL3_STATUSMASK_SET(OPL3 *chip,int flag)
  function INLINE (line 664) | INLINE void advance_lfo(OPL3 *chip)
  function INLINE (line 685) | INLINE void advance(OPL3 *chip)
  function op_calc (line 853) | INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm,...
  function op_calc1 (line 864) | INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm...
  function INLINE (line 880) | INLINE void chan_calc( OPL3 *chip, OPL3_CH *CH )
  function INLINE (line 918) | INLINE void chan_calc_ext( OPL3 *chip, OPL3_CH *CH )
  function INLINE (line 979) | INLINE void chan_calc_rhythm( OPL3 *chip, OPL3_CH *CH, unsigned int noise )
  function init_tables (line 1148) | static int init_tables(void)
  function OPLCloseTable (line 1306) | static void OPLCloseTable( void )
  function OPL3_initalize (line 1315) | static void OPL3_initalize(OPL3 *chip)
  function INLINE (line 1379) | INLINE void FM_KEYON(OPL3_SLOT *SLOT, UINT32 key_set)
  function INLINE (line 1391) | INLINE void FM_KEYOFF(OPL3_SLOT *SLOT, UINT32 key_clr)
  function INLINE (line 1407) | INLINE void CALC_FCSLOT(OPL3_CH *CH,OPL3_SLOT *SLOT)
  function INLINE (line 1442) | INLINE void set_mul(OPL3 *chip,int slot,int v)
  function INLINE (line 1508) | INLINE void set_ksl_tl(OPL3 *chip,int slot,int v)
  function INLINE (line 1572) | INLINE void set_ar_dr(OPL3 *chip,int slot,int v)
  function INLINE (line 1599) | INLINE void set_sl_rr(OPL3 *chip,int slot,int v)
  function update_channels (line 1613) | static void update_channels(OPL3 *chip, OPL3_CH *CH)
  function OPL3WriteReg (line 1628) | static void OPL3WriteReg(OPL3 *chip, int r, int v)
  function OPL3_LockTable (line 2265) | static int OPL3_LockTable()
  function OPL3_UnLockTable (line 2290) | static void OPL3_UnLockTable(void)
  function OPL3ResetChip (line 2304) | static void OPL3ResetChip(OPL3 *chip)
  function OPL3 (line 2349) | static OPL3 *OPL3Create(int clock, int rate, int type)
  function OPL3Destroy (line 2377) | static void OPL3Destroy(OPL3 *chip)
  function OPL3SetTimerHandler (line 2386) | static void OPL3SetTimerHandler(OPL3 *chip,OPL3_TIMERHANDLER timer_handl...
  function OPL3SetIRQHandler (line 2391) | static void OPL3SetIRQHandler(OPL3 *chip,OPL3_IRQHANDLER IRQHandler,void...
  function OPL3SetUpdateHandler (line 2396) | static void OPL3SetUpdateHandler(OPL3 *chip,OPL3_UPDATEHANDLER UpdateHan...
  function OPL3Write (line 2403) | static int OPL3Write(OPL3 *chip, int a, int v)
  function OPL3Read (line 2450) | static unsigned char OPL3Read(OPL3 *chip,int a)
  function OPL3TimerOver (line 2463) | static int OPL3TimerOver(OPL3 *chip,int c)
  function ymf262_shutdown (line 2486) | void ymf262_shutdown(void *chip)
  function ymf262_reset_chip (line 2490) | void ymf262_reset_chip(void *chip)
  function ymf262_write (line 2495) | int ymf262_write(void *chip, int a, int v)
  function ymf262_read (line 2500) | unsigned char ymf262_read(void *chip, int a)
  function ymf262_timer_over (line 2513) | int ymf262_timer_over(void *chip, int c)
  function ymf262_set_timer_handler (line 2518) | void ymf262_set_timer_handler(void *chip, OPL3_TIMERHANDLER timer_handle...
  function ymf262_set_irq_handler (line 2522) | void ymf262_set_irq_handler(void *chip,OPL3_IRQHANDLER IRQHandler,void *...
  function ymf262_set_update_handler (line 2526) | void ymf262_set_update_handler(void *chip,OPL3_UPDATEHANDLER UpdateHandl...
  function ymf262_set_mutemask (line 2531) | void ymf262_set_mutemask(void *chip, UINT32 MuteMask)
  function ymf262_update_one (line 2552) | void ymf262_update_one(void *_chip, OPL3SAMPLE **buffers, int length)

FILE: VGMPlay/chips/ymf262.h
  type stream_sample_t (line 19) | typedef stream_sample_t OPL3SAMPLE;

FILE: VGMPlay/chips/ymf271.c
  type YMF271Slot (line 223) | typedef struct
  type YMF271Group (line 276) | typedef struct
  type YMF271Chip (line 282) | typedef struct
  function INLINE (line 341) | INLINE void calculate_step(YMF271Slot *slot)
  function INLINE (line 373) | INLINE bool check_envelope_end(YMF271Slot *slot)
  function update_envelope (line 384) | static void update_envelope(YMF271Slot *slot)
  function INLINE (line 428) | INLINE int get_keyscaled_rate(int rate, int keycode, int keyscale)
  function INLINE (line 443) | INLINE int get_internal_keycode(int block, int fns)
  function INLINE (line 466) | INLINE int get_external_keycode(int block, int fns)
  function init_envelope (line 489) | static void init_envelope(YMF271Chip *chip, YMF271Slot *slot)
  function init_lfo (line 526) | static void init_lfo(YMF271Chip *chip, YMF271Slot *slot)
  function INLINE (line 535) | INLINE void update_lfo(YMF271Chip *chip, YMF271Slot *slot)
  function INLINE (line 545) | INLINE int calculate_slot_volume(YMF271Chip *chip, YMF271Slot *slot)
  function update_pcm (line 568) | static void update_pcm(YMF271Chip *chip, int slotnum, INT32 *mixp, int l...
  function INT64 (line 645) | static INT64 calculate_op(YMF271Chip *chip, int slotnum, INT64 inp)
  function set_feedback (line 673) | static void set_feedback(YMF271Chip *chip, int slotnum, INT64 inp)
  function ymf271_update (line 680) | void ymf271_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function write_register (line 1132) | static void write_register(YMF271Chip *chip, int slotnum, int reg, UINT8...
  function ymf271_write_fm (line 1237) | static void ymf271_write_fm(YMF271Chip *chip, int bank, UINT8 address, U...
  function ymf271_write_pcm (line 1337) | static void ymf271_write_pcm(YMF271Chip *chip, UINT8 address, UINT8 data)
  function UINT8 (line 1436) | static UINT8 ymf271_read_memory(YMF271Chip *chip, UINT32 offset)
  function ymf271_write_timer (line 1460) | static void ymf271_write_timer(YMF271Chip *chip, UINT8 address, UINT8 data)
  function ymf271_w (line 1556) | void ymf271_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function UINT8 (line 1604) | UINT8 ymf271_r(UINT8 ChipID, offs_t offset)
  function init_tables (line 1637) | static void init_tables(YMF271Chip *chip)
  function device_start_ymf271 (line 1837) | int device_start_ymf271(UINT8 ChipID, int clock)
  function device_stop_ymf271 (line 1871) | void device_stop_ymf271(UINT8 ChipID)
  function device_reset_ymf271 (line 1902) | void device_reset_ymf271(UINT8 ChipID)
  function ymf271_write_rom (line 1926) | void ymf271_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, of...
  function ymf271_set_mute_mask (line 1947) | void ymf271_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/ymf278b.c
  type YMF278BSlot (line 74) | typedef struct
  type YMF278BChip (line 117) | typedef struct
  function ymf278b_slot_reset (line 302) | void ymf278b_slot_reset(YMF278BSlot* slot)
  function INLINE (line 322) | INLINE int ymf278b_slot_compute_rate(YMF278BSlot* slot, int val)
  function INLINE (line 360) | INLINE int ymf278b_slot_compute_vib(YMF278BSlot* slot)
  function INLINE (line 366) | INLINE int ymf278b_slot_compute_am(YMF278BSlot* slot)
  function INLINE (line 374) | INLINE void ymf278b_slot_set_lfo(YMF278BSlot* slot, int newlfo)
  function INLINE (line 383) | INLINE void ymf278b_advance(YMF278BChip* chip)
  function INLINE (line 552) | INLINE UINT8 ymf278b_readMem(YMF278BChip* chip, offs_t address)
  function INLINE (line 562) | INLINE UINT8* ymf278b_readMemAddr(YMF278BChip* chip, offs_t address)
  function INLINE (line 572) | INLINE void ymf278b_writeMem(YMF278BChip* chip, offs_t address, UINT8 va...
  function INLINE (line 584) | INLINE INT16 ymf278b_getSample(YMF278BChip* chip, YMF278BSlot* op)
  function ymf278b_anyActive (line 619) | int ymf278b_anyActive(YMF278BChip* chip)
  function ymf278b_pcm_update (line 631) | void ymf278b_pcm_update(UINT8 ChipID, stream_sample_t** outputs, int sam...
  function INLINE (line 736) | INLINE void ymf278b_keyOnHelper(YMF278BChip* chip, YMF278BSlot* slot)
  function ymf278b_A_w (line 761) | static void ymf278b_A_w(YMF278BChip *chip, UINT8 reg, UINT8 data)
  function ymf278b_B_w (line 801) | static void ymf278b_B_w(YMF278BChip *chip, UINT8 reg, UINT8 data)
  function ymf278b_C_w (line 821) | void ymf278b_C_w(YMF278BChip* chip, UINT8 reg, UINT8 data)
  function UINT8 (line 1014) | UINT8 ymf278b_readReg(YMF278BChip* chip, UINT8 reg)
  function UINT8 (line 1038) | UINT8 ymf278b_peekReg(YMF278BChip* chip, UINT8 reg)
  function UINT8 (line 1059) | UINT8 ymf278b_readStatus(YMF278BChip* chip)
  function ymf278b_w (line 1070) | void ymf278b_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ymf278b_clearRam (line 1115) | void ymf278b_clearRam(YMF278BChip* chip)
  function ymf278b_load_rom (line 1120) | static void ymf278b_load_rom(YMF278BChip *chip)
  function ymf278b_init (line 1163) | static int ymf278b_init(YMF278BChip *chip, int clock, void (*cb)(int))
  function device_start_ymf278b (line 1189) | int device_start_ymf278b(UINT8 ChipID, int clock)
  function device_stop_ymf278b (line 1227) | void device_stop_ymf278b(UINT8 ChipID)
  function device_reset_ymf278b (line 1238) | void device_reset_ymf278b(UINT8 ChipID)
  function ymf278b_write_rom (line 1260) | void ymf278b_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, o...
  function ymf278b_write_ram (line 1281) | void ymf278b_write_ram(UINT8 ChipID, offs_t DataStart, offs_t DataLength...
  function ymf278b_set_mute_mask (line 1296) | void ymf278b_set_mute_mask(UINT8 ChipID, UINT32 MuteMaskFM, UINT32 MuteM...

FILE: VGMPlay/chips/ymf278b.h
  type ymf278b_interface (line 6) | typedef struct _ymf278b_interface ymf278b_interface;
  type _ymf278b_interface (line 7) | struct _ymf278b_interface

FILE: VGMPlay/chips/ymz280b.c
  type YMZ280BVoice (line 71) | struct YMZ280BVoice
  type ymz280b_state (line 105) | typedef struct _ymz280b_state ymz280b_state;
  type _ymz280b_state (line 106) | struct _ymz280b_state
  function INLINE (line 186) | INLINE void update_irq_state(ymz280b_state *chip)
  function INLINE (line 214) | INLINE void update_step(ymz280b_state *chip, struct YMZ280BVoice *voice)
  function INLINE (line 227) | INLINE void update_volumes(struct YMZ280BVoice *voice)
  function INLINE (line 265) | INLINE UINT8 ymz280b_read_memory(UINT8 *base, UINT32 size, UINT32 offset)
  function update_irq_state_timer_common (line 280) | static void update_irq_state_timer_common(void *param, int voicenum)
  function compute_tables (line 309) | static void compute_tables(void)
  function generate_adpcm (line 334) | static int generate_adpcm(struct YMZ280BVoice *voice, UINT8 *base, UINT3...
  function generate_pcm8 (line 463) | static int generate_pcm8(struct YMZ280BVoice *voice, UINT8 *base, UINT32...
  function generate_pcm16 (line 548) | static int generate_pcm16(struct YMZ280BVoice *voice, UINT8 *base, UINT3...
  function ymz280b_update (line 638) | void ymz280b_update(UINT8 ChipID, stream_sample_t **outputs, int samples)
  function device_start_ymz280b (line 809) | int device_start_ymz280b(UINT8 ChipID, int clock)
  function device_stop_ymz280b (line 919) | void device_stop_ymz280b(UINT8 ChipID)
  function device_reset_ymz280b (line 940) | void device_reset_ymz280b(UINT8 ChipID)
  function write_to_register (line 1009) | static void write_to_register(ymz280b_state *chip, int data)
  function compute_status (line 1241) | static int compute_status(ymz280b_state *chip)
  function UINT8 (line 1266) | UINT8 ymz280b_r(UINT8 ChipID, offs_t offset)
  function ymz280b_w (line 1292) | void ymz280b_w(UINT8 ChipID, offs_t offset, UINT8 data)
  function ymz280b_write_rom (line 1308) | void ymz280b_write_rom(UINT8 ChipID, offs_t ROMSize, offs_t DataStart, o...
  function ymz280b_set_mute_mask (line 1330) | void ymz280b_set_mute_mask(UINT8 ChipID, UINT32 MuteMask)

FILE: VGMPlay/chips/ymz280b.h
  type ymz280b_interface (line 12) | typedef struct _ymz280b_interface ymz280b_interface;
  type _ymz280b_interface (line 13) | struct _ymz280b_interface

FILE: VGMPlay/dbus.c
  type DBusMetadata (line 93) | typedef struct DBusMetadata_
  function invalidateArtCache (line 109) | static inline void invalidateArtCache()
  function ReturnPosMsec (line 162) | static inline int64_t ReturnPosMsec(UINT32 SamplePos, UINT32 SmplRate)
  function INT32 (line 168) | static inline INT32 ReturnSamplePos(int64_t UsecPos, UINT32 SmplRate)
  function FileExists (line 173) | static inline int FileExists(char* file)
  function DBusEmptyMethodResponse (line 179) | static void DBusEmptyMethodResponse(DBusConnection* connection, DBusMess...
  function DBusReplyToIntrospect (line 187) | static void DBusReplyToIntrospect(DBusConnection* connection, DBusMessag...
  function DBusReplyWithVariant (line 279) | static void DBusReplyWithVariant(DBusMessageIter* args, int type, char* ...
  function DBusAppendCanGoNext (line 287) | void DBusAppendCanGoNext(DBusMessageIter* args)
  function DBusAppendCanGoPrevious (line 296) | void DBusAppendCanGoPrevious(DBusMessageIter* args)
  function DBusSendMetadataArray (line 305) | static void DBusSendMetadataArray(DBusMessageIter* dict_root, DBusMetada...
  function getArtPath (line 370) | static inline void getArtPath(const char* utf8album, char* artpath, cons...
  function DBusSendMetadata (line 425) | static void DBusSendMetadata(DBusMessageIter* dict_root)
  function DBusSendPlaybackStatus (line 616) | static void DBusSendPlaybackStatus(DBusMessageIter* args)
  function DBus_EmitSignal_Internal (line 630) | void DBus_EmitSignal_Internal(DBusConnection* connection, UINT8 type)
  function DBus_EmitSignal (line 737) | void DBus_EmitSignal(UINT8 type)
  function DBusSendMimeTypes (line 742) | static void DBusSendMimeTypes(DBusMessageIter* args)
  function DBusSendUriSchemes (line 757) | static void DBusSendUriSchemes(DBusMessageIter* args)
  function DBusSendEmptyMethodResponse (line 772) | static void DBusSendEmptyMethodResponse(DBusConnection* connection, DBus...
  function DBusHandlerResult (line 781) | static DBusHandlerResult DBusHandler(DBusConnection* connection, DBusMes...
  function UINT8 (line 1227) | UINT8 MultimediaKeyHook_Init(void)
  function MultimediaKeyHook_Deinit (line 1262) | void MultimediaKeyHook_Deinit(void)
  function MultimediaKeyHook_SetCallback (line 1270) | void MultimediaKeyHook_SetCallback(mmkey_cbfunc callbackFunc)
  function DBus_ReadWriteDispatch (line 1275) | void DBus_ReadWriteDispatch(void)

FILE: VGMPlay/dbus_stub.c
  function DBus_ReadWriteDispatch (line 3) | void DBus_ReadWriteDispatch(void)
  function DBus_EmitSignal (line 8) | void DBus_EmitSignal(UINT8 type)

FILE: VGMPlay/mmkeys_Win.c
  function DWORD (line 20) | static DWORD WINAPI KeyMessageThread(void* args)
  function UINT8 (line 50) | UINT8 MultimediaKeyHook_Init(void)
  function MultimediaKeyHook_Deinit (line 65) | void MultimediaKeyHook_Deinit(void)
  function MultimediaKeyHook_SetCallback (line 79) | void MultimediaKeyHook_SetCallback(mmkey_cbfunc callbackFunc)

FILE: VGMPlay/mmkeys_stub.c
  function UINT8 (line 4) | UINT8 MultimediaKeyHook_Init(void)
  function MultimediaKeyHook_Deinit (line 9) | void MultimediaKeyHook_Deinit(void)
  function MultimediaKeyHook_SetCallback (line 14) | void MultimediaKeyHook_SetCallback(mmkey_cbfunc callbackFunc)

FILE: VGMPlay/pt_ioctl.c
  function outportb (line 35) | void outportb(unsigned short PortAddress, unsigned char byte)
  function inportb (line 57) | unsigned char inportb(unsigned short PortAddress)
  function OpenPortTalk (line 79) | unsigned char OpenPortTalk(void)
  function ClosePortTalk (line 110) | void ClosePortTalk(void)
  function StartPortTalkDriver (line 115) | unsigned char StartPortTalkDriver(void)
  function InstallPortTalkDriver (line 182) | void InstallPortTalkDriver(void)

FILE: VGMPlay/vgm2pcm.c
  function INLINE (line 62) | INLINE int fputBE16(UINT16 Value, FILE* hFile)
  function main (line 73) | int main(int argc, char *argv[]) {

FILE: VGMPlay/vgm2wav.c
  function INLINE (line 55) | INLINE int fputLE16(UINT16 Value, FILE* hFile)
  function INLINE (line 66) | INLINE int fputLE32(UINT32 Value, FILE* hFile)
  function usage (line 79) | void usage(const char *name) {
  function main (line 94) | int main(int argc, char *argv[]) {

FILE: VGMPlay/zlib/zconf.h
  type z_size_t (line 241) | typedef unsigned long z_size_t;
  type z_size_t (line 245) | typedef unsigned NO_SIZE_T z_size_t;
  type z_size_t (line 248) | typedef size_t z_size_t;
  type z_size_t (line 250) | typedef unsigned long z_size_t;
  type Byte (line 391) | typedef unsigned char  Byte;
  type uInt (line 393) | typedef unsigned int   uInt;
  type uLong (line 394) | typedef unsigned long  uLong;
  type Byte (line 400) | typedef Byte  FAR Bytef;
  type charf (line 402) | typedef char  FAR charf;
  type intf (line 403) | typedef int   FAR intf;
  type uInt (line 404) | typedef uInt  FAR uIntf;
  type uLong (line 405) | typedef uLong FAR uLongf;
  type Byte (line 412) | typedef Byte const *voidpc;
  type Byte (line 413) | typedef Byte FAR   *voidpf;
  type Byte (line 414) | typedef Byte       *voidp;
  type Z_U4 (line 429) | typedef Z_U4 z_crc_t;
  type z_crc_t (line 431) | typedef unsigned long z_crc_t;

FILE: VGMPlay/zlib/zlib.h
  type voidpf (line 81) | typedef voidpf (*alloc_func)
  type internal_state (line 84) | struct internal_state
  type z_stream (line 86) | typedef struct z_stream_s {
  type z_stream (line 108) | typedef z_stream FAR *z_streamp;
  type gz_header (line 114) | typedef struct gz_header_s {
  type gz_header (line 131) | typedef gz_header FAR *gz_headerp;
  type gzFile_s (line 1300) | struct gzFile_s
  type gzFile_s (line 1817) | struct gzFile_s {

FILE: in_vgm/Winamp/DSP.H
  type winampDSPModule (line 12) | typedef struct winampDSPModule {
  type winampDSPHeader (line 30) | typedef struct {
  type winampDSPHeader (line 39) | typedef winampDSPHeader* (*winampDSPGetHeaderType)(HWND);
  type winampDSPHeader (line 44) | typedef winampDSPHeader* (*winampDSPGetHeaderType)(HWND);

FILE: in_vgm/Winamp/GEN.H
  type winampGeneralPurposePlugin (line 17) | typedef struct {
  type winampGeneralPurposePlugin (line 32) | typedef winampGeneralPurposePlugin * (*winampGeneralPurposePluginGetter)();

FILE: in_vgm/Winamp/IN2.H
  type In_Module (line 27) | typedef struct

FILE: in_vgm/Winamp/OUT.H
  type Out_Module (line 20) | typedef struct

FILE: in_vgm/Winamp/ipc_pe.h
  type fileinfo (line 21) | typedef struct {
  type fileinfoW (line 26) | typedef struct {
  type callbackinfo (line 31) | typedef struct {
  type fileinfo2 (line 43) | typedef struct {
  type fileinfo2W (line 49) | typedef struct

FILE: in_vgm/Winamp/wa_dlg.h
  type WACURSOR (line 99) | typedef enum _WACURSOR  // used in IPC_GETSKINCURSORS
  function WADlg_initted (line 182) | int WADlg_initted()
  function WADlg_getColor (line 187) | int WADlg_getColor(int idx)
  function HBITMAP (line 193) | HBITMAP WADlg_getBitmap()
  function WADlg_init (line 198) | void WADlg_init(HWND hwndWinamp) // call this on init, or on WM_DISPLAYC...
  function WADlg_close (line 238) | void WADlg_close()
  function WADlg_dotLine (line 246) | void WADlg_dotLine(HDC hdc, int left, int top, int len, int vert)
  function LRESULT (line 263) | LRESULT WADlg_handleDialogMsgs(HWND hwndDlg, UINT uMsg, WPARAM wParam, L...
  function RectInRect (line 349) | static int RectInRect(RECT *rect1, RECT *rect2)
  function WADlg_removeFromRgn (line 366) | static void WADlg_removeFromRgn(HRGN hrgn, int left, int top, int right,...
  function WADlg_DrawChildWindowBorders (line 373) | void WADlg_DrawChildWindowBorders(HWND hwndDlg, int *tab, int tabsize)

FILE: in_vgm/Winamp/wa_ipc.h
  type enqueueFileWithMetaStruct (line 77) | typedef struct {
  type enqueueFileWithMetaStructW (line 85) | typedef struct {
  type extendedFileInfoStruct (line 611) | typedef struct {
  type basicFileInfoStruct (line 620) | typedef struct {
  type basicFileInfoStructW (line 633) | typedef struct {
  type infoBoxParam (line 650) | typedef struct {
  type infoBoxParamW (line 657) | typedef struct {
  type waFormatTitle (line 681) | typedef struct
  type waFormatTitleExtended (line 695) | typedef struct
  type copyFileInfoStruct (line 711) | typedef struct
  type copyFileInfoStructW (line 719) | typedef struct
  type wa_inflate_struct (line 726) | typedef struct {
  type prefsDlgRec (line 742) | typedef struct _prefsDlgRec {
  type prefsDlgRecW (line 760) | typedef struct _prefsDlgRecW {
  type embedWindowState (line 1003) | typedef struct
  type SKINWINDOWPARAM (line 1046) | typedef struct __SKINWINDOWPARAM
  type embedEnumStruct (line 1055) | typedef struct embedEnumStruct
  type convertFileStruct (line 1085) | typedef struct
  type convertFileStructW (line 1107) | typedef struct
  type convertConfigStruct (line 1142) | typedef struct {
  type converterEnumFmtStruct (line 1156) | typedef struct
  type burnCDStruct (line 1165) | typedef struct
  type convertSetPriority (line 1178) | typedef struct
  type convertSetPriorityW (line 1187) | typedef struct
  type convertConfigItem (line 1197) | typedef struct
  type waHookTitleStruct (line 1211) | typedef struct
  type waHookTitleStructW (line 1238) | typedef struct
  type waSetPlColorsStruct (line 1269) | typedef struct
  type waSpawnMenuParms (line 1301) | typedef struct
  type waSpawnMenuParms2 (line 1309) | typedef struct
  type VideoOpenStruct (line 1373) | typedef struct
  type YV12_PLANE (line 1389) | struct YV12_PLANE {
  type YV12_PLANES (line 1394) | struct YV12_PLANES {
  function class (line 1401) | class IVideoOutput
  function class (line 1416) | class ITrackSelector
  type transAccelStruct (line 1582) | typedef struct {
  type windowCommand (line 1594) | typedef struct {
  type DispatchInfo (line 2290) | typedef struct
  type extendedFileInfoStructW (line 2331) | typedef struct {
  type artFetchData (line 2418) | typedef struct {

FILE: in_vgm/dlg_cfg.c
  function InitConfigDialog (line 108) | void InitConfigDialog(HWND hWndMain)
  function INLINE (line 167) | INLINE void AddTab(HWND tabCtrlWnd, int ImgIndex, char* TabTitle)
  function EnableWinXPVisualStyles (line 182) | static void EnableWinXPVisualStyles(HWND hWndMain)
  function Slider_Setup (line 216) | static void Slider_Setup(HWND hWndDlg, int DlgID, int Min, int Max, int ...
  function BOOL (line 230) | static BOOL SetDlgItemFloat(HWND hDlg, int nIDDlgItem, double Value, int...
  function LoadConfigDialogInfo (line 238) | static int LoadConfigDialogInfo(HWND hWndDlg)
  function BOOL (line 359) | BOOL CALLBACK ConfigDialogProc(HWND hWndDlg, UINT wMessage, WPARAM wPara...
  function BOOL (line 472) | BOOL CALLBACK CfgDlgPlaybackProc(HWND hWndDlg, UINT wMessage, WPARAM wPa...
  function BOOL (line 595) | BOOL CALLBACK CfgDlgTagsProc(HWND hWndDlg, UINT wMessage, WPARAM wParam,...
  function BOOL (line 645) | BOOL CALLBACK CfgDlgMutingProc(HWND hWndDlg, UINT wMessage, WPARAM wPara...
  function BOOL (line 695) | BOOL CALLBACK CfgDlgOptPanProc(HWND hWndDlg, UINT wMessage, WPARAM wPara...
  function BOOL (line 766) | BOOL CALLBACK CfgDlgChildProc(HWND hWndDlg, UINT wMessage, WPARAM wParam...
  function IsChipAvailable (line 792) | static bool IsChipAvailable(UINT8 ChipID, UINT8 ChipSet)
  function ShowMutingCheckBoxes (line 807) | static void ShowMutingCheckBoxes(UINT8 ChipID, UINT8 ChipSet)
  function SetMutingData (line 1088) | static void SetMutingData(UINT32 CheckBox, bool MuteOn)
  function ShowOptPanBoxes (line 1149) | static void ShowOptPanBoxes(UINT8 ChipID, UINT8 ChipSet)
  function SetPanningData (line 1323) | static void SetPanningData(UINT32 Slider, UINT16 Value, bool NoRefresh)
  function Dialogue_TrackChange (line 1337) | void Dialogue_TrackChange(void)

FILE: in_vgm/dlg_fileinfo.c
  type FINF_DATA (line 22) | typedef struct fileinfo_data
  function SetInfoDlgFile (line 109) | void SetInfoDlgFile(const char* FileName)
  function SetInfoDlgFileW (line 117) | void SetInfoDlgFileW(const wchar_t* FileName)
  function UINT32 (line 125) | UINT32 GetVGZFileSize(const char* FileName)
  function UINT32 (line 154) | UINT32 GetVGZFileSizeW(const wchar_t* FileName)
  function CopyWStr (line 183) | static void CopyWStr(wchar_t** DstStr, const wchar_t* SrcStr)
  function CopyTagData (line 200) | static void CopyTagData(GD3_TAG* DstTag, const GD3_TAG* SrcTag)
  function LoadInfoA (line 220) | static bool LoadInfoA(const char* FileName, FINF_DATA* FileInf)
  function LoadInfoW (line 240) | static bool LoadInfoW(const wchar_t* FileName, FINF_DATA* FileInf)
  function FixNewLine (line 422) | static void FixNewLine(wchar_t** TextData)
  function FixSeparators (line 468) | static void FixSeparators(wchar_t** TextData)
  function TrimWhitespaces (line 552) | static void TrimWhitespaces(wchar_t* TextData)
  function CheckFM2413Text (line 578) | static bool CheckFM2413Text(VGM_HEADER* FileHead)
  function UINT32 (line 593) | UINT32 FormatVGMTag(const UINT32 BufLen, in_char* Buffer, GD3_TAG* FileT...
  function AppendToStr (line 736) | static void AppendToStr(char* Buffer, const char* AppendStr, UINT8 Seper...
  function MakeChipStr (line 769) | static void MakeChipStr(char* Buffer, UINT8 ChipID, UINT8 SubType, UINT3...
  function GetChipUsageText (line 795) | static void GetChipUsageText(char* Buffer, VGM_HEADER* FileHead)
  function PrintTime (line 813) | static void PrintTime(char* Buffer, UINT32 MSecTime)
  function FormatVGMLength (line 858) | void FormatVGMLength(char* Buffer, FINF_DATA* FileInf)
  function LoadPlayingVGMInfo (line 948) | bool LoadPlayingVGMInfo(const char* FileName)
  function LoadPlayingVGMInfoW (line 976) | bool LoadPlayingVGMInfoW(const wchar_t* FileName)
  function QueueInfoReload (line 998) | void QueueInfoReload(void)
  function GetExtendedFileInfoW (line 1008) | bool GetExtendedFileInfoW(const wchar_t* FileName, const char* MetaType,...
  function wchar_t (line 1214) | const wchar_t* GetTagStringEngJap(const wchar_t* TextEng, const wchar_t*...
  function DisplayTagString (line 1241) | void DisplayTagString(HWND hWndDlg, int DlgItem, const wchar_t* TextEng,
  function BOOL (line 1274) | BOOL CALLBACK FileInfoDialogProc(HWND hWndDlg, UINT wMessage, WPARAM wPa...
  function DllExport (line 1407) | DllExport int winampGetExtendedFileInfoW(const wchar_t* wfilename, const...
  function DllExport (line 1425) | DllExport int winampGetExtendedFileInfo(const char* filename, const char...

FILE: in_vgm/in_vgm.c
  function BOOL (line 161) | BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, L...
  function Config (line 169) | void Config(HWND hWndParent)
  function About (line 177) | void About(HWND hWndParent)
  function Init (line 250) | void Init(void)
  function FindIniFile (line 275) | void FindIniFile(void)
  function LoadConfigurationFile (line 301) | void LoadConfigurationFile(void)
  function ReadIntoBitfield2 (line 468) | static void ReadIntoBitfield2(const char* Section, const char* Key, UINT...
  function SaveConfigurationFile (line 489) | void SaveConfigurationFile(void)
  function WriteFromBitfield (line 638) | static void WriteFromBitfield(const char* Section, const char* Key, UINT...
  function Deinit (line 656) | void Deinit(void)
  function IsOurFile (line 666) | int IsOurFile(const in_char* fn)
  function INLINE (line 674) | INLINE UINT32 MulDivRound(UINT64 Number, UINT64 Numerator, UINT64 Denomi...
  function Play (line 680) | int Play(const in_char* FileName)
  function Pause (line 771) | void Pause(void)
  function Unpause (line 779) | void Unpause(void)
  function IsPaused (line 787) | int IsPaused(void)
  function Stop (line 793) | void Stop(void)
  function GetFileLength (line 854) | int GetFileLength(VGM_HEADER* FileHead)
  function GetLength (line 889) | int GetLength(void)	// return length of playing track
  function GetOutputTime (line 898) | int GetOutputTime(void)
  function SetOutputTime (line 907) | void SetOutputTime(int time_in_ms)	// for seeking
  function SetVolume (line 917) | void SetVolume(int volume)
  function SetPan (line 924) | void SetPan(int pan)
  function UpdatePlayback (line 931) | void UpdatePlayback(void)
  function InfoDialog (line 946) | int InfoDialog(const in_char* FileName, HWND hWnd)
  function in_char (line 958) | const in_char* GetFileNameTitle(const in_char* FileName)
  function GetFileInfo (line 979) | void GetFileInfo(const in_char* filename, in_char* title, int* length_in...
  function EQ_Set (line 1065) | void EQ_Set(int on, char data[10], int preamp)
  function DWORD (line 1077) | DWORD WINAPI DecodeThread(LPVOID b)
  function In_Module (line 1199) | __declspec(dllexport) In_Module* winampGetInModule2(void)

FILE: in_vgm/in_vgm.h
  type PLGIN_OPTS (line 24) | typedef struct plugin_options

FILE: in_vgm/ini_func.c
  function ReadIni_Integer (line 9) | void ReadIni_Integer(const char* Section, const char* Key, UINT32* Value)
  function ReadIni_SIntSht (line 16) | void ReadIni_SIntSht(const char* Section, const char* Key, INT16* Value)
  function ReadIni_IntByte (line 23) | void ReadIni_IntByte(const char* Section, const char* Key, UINT8* Value)
  function ReadIni_Boolean (line 30) | void ReadIni_Boolean(const char* Section, const char* Key, bool* Value)
  function ReadIni_String (line 48) | void ReadIni_String(const char* Section, const char* Key, char* String, ...
  function ReadIni_Float (line 55) | void ReadIni_Float(const char* Section, const char* Key, float* Value)
  function WriteIni_Integer (line 70) | void WriteIni_Integer(const char* Section, const char* Key, UINT32 Value)
  function WriteIni_SInteger (line 80) | void WriteIni_SInteger(const char* Section, const char* Key, INT32 Value)
  function WriteIni_XInteger (line 90) | void WriteIni_XInteger(const char* Section, const char* Key, UINT32 Value)
  function WriteIni_Boolean (line 100) | void WriteIni_Boolean(const char* Section, const char* Key, bool Value)
  function WriteIni_String (line 113) | void WriteIni_String(const char* Section, const char* Key, char* String)
  function WriteIni_Float (line 120) | void WriteIni_Float(const char* Section, const char* Key, float Value)
Condensed preview — 229 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (3,584K chars).
[
  {
    "path": ".gitattributes",
    "chars": 85,
    "preview": "*.dsp text eol=crlf\n*.dsw text eol=crlf\n*.sln text eol=crlf\n*.vcxproj* text eol=crlf\n"
  },
  {
    "path": ".gitignore",
    "chars": 255,
    "preview": "##################\n## Visual Studio 6\n##################\n\n# Build results\n[Dd]ebug/\n[Rr]elease/\n*.exe\n*.dll\n\n# Object fi"
  },
  {
    "path": ".travis.yml",
    "chars": 543,
    "preview": "language: c\n\ncache: ccache\n\nbefore_install:\n  - cd VGMPlay\n  - if [[ \"$TRAVIS_OS_NAME\" == \"osx\" ]]; then brew update    "
  },
  {
    "path": "README.md",
    "chars": 2329,
    "preview": "# VGMPlay [![Build Status](https://travis-ci.org/vgmrips/vgmplay.svg?branch=master)](https://travis-ci.org/vgmrips/vgmpl"
  },
  {
    "path": "VGMPlay/.gitignore",
    "chars": 48,
    "preview": "/obj\n/vgm2pcm\n/vgmplay\n/vgm2wav\nvgmplay.desktop\n"
  },
  {
    "path": "VGMPlay/ChipMapper.c",
    "chars": 29603,
    "preview": "// ChipMapper.c - Handles Chip Write (including OPL Hardware Support)\n\n#include <stdio.h>\n#include <string.h>\n#include <"
  },
  {
    "path": "VGMPlay/ChipMapper.h",
    "chars": 556,
    "preview": "void open_fm_option(UINT8 ChipType, UINT8 OptType, UINT32 OptVal);\nvoid opl_chip_reset(void);\nvoid open_real_fm(void);\nv"
  },
  {
    "path": "VGMPlay/Makefile",
    "chars": 8285,
    "preview": "########################\n#\n# VGMPlay Makefile\n# (for GNU Make 3.81)\n#\n########################\n\n# TODO: Make this look l"
  },
  {
    "path": "VGMPlay/PortTalk_IOCTL.h",
    "chars": 1914,
    "preview": "/******************************************************************************/\n/*                                     "
  },
  {
    "path": "VGMPlay/Stream.c",
    "chars": 12830,
    "preview": "// Stream.c: C Source File for Sound Output\n//\n\n// Thanks to nextvolume for NetBSD support\n#define _GNU_SOURCE\n#include "
  },
  {
    "path": "VGMPlay/Stream.h",
    "chars": 792,
    "preview": "// Stream.h: Header File for constants and structures related to Sound Output\n//\n\n#ifdef WIN32\n#include <mmsystem.h>\n#el"
  },
  {
    "path": "VGMPlay/VGMFile.h",
    "chars": 3001,
    "preview": "// Header file for VGM file handling\n\ntypedef struct _vgm_file_header\n{\n\tUINT32 fccVGM;\n\tUINT32 lngEOFOffset;\n\tUINT32 ln"
  },
  {
    "path": "VGMPlay/VGMPlay.c",
    "chars": 164543,
    "preview": "// VGMPlay.c: C Source File of the Main Executable\n//\n\n// Line Size:\t96 Chars\n// Tab Size:\t4 Spaces\n\n/*34567890123456789"
  },
  {
    "path": "VGMPlay/VGMPlay.dsp",
    "chars": 21219,
    "preview": "# Microsoft Developer Studio Project File - Name=\"VGMPlay\" - Package Owner=<4>\r\n# Microsoft Developer Studio Generated B"
  },
  {
    "path": "VGMPlay/VGMPlay.dsw",
    "chars": 566,
    "preview": "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEI"
  },
  {
    "path": "VGMPlay/VGMPlay.h",
    "chars": 1584,
    "preview": "// Header File for structures and constants used within VGMPlay.c\n\n#include \"VGMFile.h\"\n\n#define VGMPLAY_VER_STR\t\"0.40.9"
  },
  {
    "path": "VGMPlay/VGMPlay.ini",
    "chars": 9553,
    "preview": "; VGMPlay Configuration File\n; --------------------------\n;\n; Default Values are usually 0 (False for boolean ones)\n; Bo"
  },
  {
    "path": "VGMPlay/VGMPlay.sln",
    "chars": 1232,
    "preview": "\r\nMicrosoft Visual Studio Solution File, Format Version 11.00\r\n# Visual Studio 2010\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-"
  },
  {
    "path": "VGMPlay/VGMPlay.txt",
    "chars": 6607,
    "preview": "VGM Player - Readme\n==========\n\nGeneral\n=======\nUsage: Drop a file on the executable or open the program and type the fi"
  },
  {
    "path": "VGMPlay/VGMPlay.vcxproj",
    "chars": 17976,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.micros"
  },
  {
    "path": "VGMPlay/VGMPlay.vcxproj.filters",
    "chars": 20134,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbui"
  },
  {
    "path": "VGMPlay/VGMPlayUI.c",
    "chars": 63284,
    "preview": "// VGMPlayUI.c: C Source File for the Console User Interface\n\n// Note: In order to make MS VC6 NOT crash when using fpri"
  },
  {
    "path": "VGMPlay/VGMPlay_AddFmts.c",
    "chars": 27927,
    "preview": "// VGMPlay_AddFmts.c: C Source File for playback of additional non-VGM formats\n#define _GNU_SOURCE\n#include <stdlib.h>\n#"
  },
  {
    "path": "VGMPlay/VGMPlay_Intf.h",
    "chars": 1666,
    "preview": "// VGMPlay_Intf.h: VGMPlay Interface Header File\n//\n\n//#define NO_WCHAR_FILENAMES\n#ifndef WIN32\n// Linux uses UTF-8 Unic"
  },
  {
    "path": "VGMPlay/VGMPlay_Updates.txt",
    "chars": 12488,
    "preview": "Update list since 0.4.0u3 (03.12.2012)\n- replaced some larger swich statements with function pointers (small speed up)\n-"
  },
  {
    "path": "VGMPlay/XMasFiles/SWJ-SQRC01_1C.h",
    "chars": 38897,
    "preview": "// SWJ-SQRC01_1C.vgz\nUINT8 FF1ws_1C[0x1908] =\n{\t0x1F, 0x8B, 0x08, 0x00, 0xD4, 0x7A, 0x2F, 0x52, 0x02, 0x00, 0xD4, 0x98, "
  },
  {
    "path": "VGMPlay/XMasFiles/XMasBonus.h",
    "chars": 217606,
    "preview": "// WEWISH.CMF - We Wish You A Merry Christmas\nconst unsigned char WEWISH_CMF[0x2245] =\n{\t0x43, 0x54, 0x4D, 0x46, 0x01, 0"
  },
  {
    "path": "VGMPlay/chips/2151intf.c",
    "chars": 6783,
    "preview": "/***************************************************************************\n\n  2151intf.c\n\n  Support interface YM2151(O"
  },
  {
    "path": "VGMPlay/chips/2151intf.h",
    "chars": 1124,
    "preview": "#pragma once\n\n/*typedef struct _ym2151_interface ym2151_interface;\nstruct _ym2151_interface\n{\n\t//void (*irqhandler)(cons"
  },
  {
    "path": "VGMPlay/chips/2203intf.c",
    "chars": 11497,
    "preview": "#include <math.h>\n#include <stdlib.h>\t// for free\n#include <string.h>\t// for memset\n#include <stddef.h>\t// for NULL\n#inc"
  },
  {
    "path": "VGMPlay/chips/2203intf.h",
    "chars": 1619,
    "preview": "#pragma once\n\n#include \"ay8910.h\"\n#include \"emu2149.h\"\n\nvoid ym2203_update_request(void *param);\n\ntypedef struct _ym2203"
  },
  {
    "path": "VGMPlay/chips/2413intf.c",
    "chars": 9258,
    "preview": "/****************************************************************\n\n    MAME / MESS functions\n\n**************************"
  },
  {
    "path": "VGMPlay/chips/2413intf.h",
    "chars": 789,
    "preview": "#pragma once\n\n/*WRITE8_DEVICE_HANDLER( ym2413_w );\n\nWRITE8_DEVICE_HANDLER( ym2413_register_port_w );\nWRITE8_DEVICE_HANDL"
  },
  {
    "path": "VGMPlay/chips/2608intf.c",
    "chars": 12014,
    "preview": "/***************************************************************************\n\n  2608intf.c\n\n  The YM2608 emulator suppor"
  },
  {
    "path": "VGMPlay/chips/2608intf.h",
    "chars": 2140,
    "preview": "#pragma once\n\n#include \"fm.h\"\n#include \"ay8910.h\"\n#include \"emu2149.h\"\n\nvoid ym2608_update_request(void *param);\n\ntypede"
  },
  {
    "path": "VGMPlay/chips/2610intf.c",
    "chars": 12892,
    "preview": "/***************************************************************************\n\n  2610intf.c\n\n  The YM2610 emulator suppor"
  },
  {
    "path": "VGMPlay/chips/2610intf.h",
    "chars": 2159,
    "preview": "#pragma once\n\n#include \"fm.h\"\n#include \"ay8910.h\"\n#include \"emu2149.h\"\n\n\nvoid ym2610_update_request(void *param);\n\n/*typ"
  },
  {
    "path": "VGMPlay/chips/2612intf.c",
    "chars": 11700,
    "preview": "/***************************************************************************\n\n  2612intf.c\n\n  The YM2612 emulator suppor"
  },
  {
    "path": "VGMPlay/chips/2612intf.h",
    "chars": 2467,
    "preview": "#pragma once\n\nvoid ym2612_update_request(void *param);\n\n/*typedef struct _ym2612_interface ym2612_interface;\nstruct _ym2"
  },
  {
    "path": "VGMPlay/chips/262intf.c",
    "chars": 7927,
    "preview": "/***************************************************************************\n\n  262intf.c\n\n  MAME interface for YMF262 ("
  },
  {
    "path": "VGMPlay/chips/262intf.h",
    "chars": 1289,
    "preview": "#pragma once\n\n\n/*typedef struct _ymf262_interface ymf262_interface;\nstruct _ymf262_interface\n{\n\t//void (*handler)(const "
  },
  {
    "path": "VGMPlay/chips/3526intf.c",
    "chars": 6799,
    "preview": "/******************************************************************************\n* FILE\n*   Yamaha 3812 emulator interfac"
  },
  {
    "path": "VGMPlay/chips/3526intf.h",
    "chars": 1155,
    "preview": "#pragma once\n\n/*typedef struct _ym3526_interface ym3526_interface;\nstruct _ym3526_interface\n{\n\t//void (*handler)(const d"
  },
  {
    "path": "VGMPlay/chips/3812intf.c",
    "chars": 8446,
    "preview": "/******************************************************************************\n* FILE\n*   Yamaha 3812 emulator interfac"
  },
  {
    "path": "VGMPlay/chips/3812intf.h",
    "chars": 1198,
    "preview": "#pragma once\n\n/*typedef struct _ym3812_interface ym3812_interface;\nstruct _ym3812_interface\n{\n\t//void (*handler)(const d"
  },
  {
    "path": "VGMPlay/chips/8950intf.c",
    "chars": 8027,
    "preview": "/******************************************************************************\n* FILE\n*   Yamaha 3812 emulator interfac"
  },
  {
    "path": "VGMPlay/chips/8950intf.h",
    "chars": 1389,
    "preview": "#pragma once\n\n/*typedef struct _y8950_interface y8950_interface;\nstruct _y8950_interface\n{\n\t//void (*handler)(const devi"
  },
  {
    "path": "VGMPlay/chips/ChipIncl.h",
    "chars": 910,
    "preview": "// includes all chip-headers\n\n#include \"sn764intf.h\"\n#include \"2413intf.h\"\n#include \"2612intf.h\"\n#include \"2151intf.h\"\n#"
  },
  {
    "path": "VGMPlay/chips/Ootake_PSG.c",
    "chars": 29443,
    "preview": "/******************************************************************************\nOotake\n・キューの参照処理をシンプルにした。テンポの安定性および音質の向上"
  },
  {
    "path": "VGMPlay/chips/Ootake_PSG.h",
    "chars": 2353,
    "preview": "/*-----------------------------------------------------------------------------\n\t[PSG.h]\n\t\tPSGを記述するのに必要な定義および関数のプロトタイプ宣言"
  },
  {
    "path": "VGMPlay/chips/adlibemu.h",
    "chars": 688,
    "preview": "#if defined(OPLTYPE_IS_OPL2)\n#define ADLIBEMU(name)\t\t\tadlib_OPL2_##name\n#elif defined(OPLTYPE_IS_OPL3)\n#define ADLIBEMU("
  },
  {
    "path": "VGMPlay/chips/adlibemu_opl2.c",
    "chars": 85,
    "preview": "#include \"mamedef.h\"\n\n#define OPLTYPE_IS_OPL2\n#include \"adlibemu.h\"\n#include \"opl.c\"\n"
  },
  {
    "path": "VGMPlay/chips/adlibemu_opl3.c",
    "chars": 85,
    "preview": "#include \"mamedef.h\"\n\n#define OPLTYPE_IS_OPL3\n#include \"adlibemu.h\"\n#include \"opl.c\"\n"
  },
  {
    "path": "VGMPlay/chips/ay8910.c",
    "chars": 39646,
    "preview": "/***************************************************************************\n\n  ay8910.c\n\n  Emulation of the AY-3-8910 /"
  },
  {
    "path": "VGMPlay/chips/ay8910.h",
    "chars": 4852,
    "preview": "#pragma once\n\n//#include \"devcb.h\"\n#define DEVCB_TYPE_NULL\t\t\t\t(0)\n#define DEVCB_NULL\t\t\t\t\t\t\t{ DEVCB_TYPE_NULL }\n\n/*\nAY-3-"
  },
  {
    "path": "VGMPlay/chips/ay8910_opl.c",
    "chars": 9432,
    "preview": "#include <stddef.h>\t// for NULL\n#include \"mamedef.h\"\n#include \"math.h\"\n\nvoid OPL_RegMapper(UINT16 Reg, UINT8 Data);\n\n#de"
  },
  {
    "path": "VGMPlay/chips/ay_intf.c",
    "chars": 3615,
    "preview": "/****************************************************************\n\n    MAME / MESS functions\n\n**************************"
  },
  {
    "path": "VGMPlay/chips/ay_intf.h",
    "chars": 459,
    "preview": "#pragma once\n\nvoid ayxx_stream_update(UINT8 ChipID, stream_sample_t **outputs, int samples);\n\nint device_start_ayxx(UINT"
  },
  {
    "path": "VGMPlay/chips/c140.c",
    "chars": 15845,
    "preview": "/*\nC140.c\n\nSimulator based on AMUSE sources.\nThe C140 sound chip is used by Namco System 2 and System 21\nThe 219 ASIC (w"
  },
  {
    "path": "VGMPlay/chips/c140.h",
    "chars": 898,
    "preview": "/* C140.h */\n\n#pragma once\n\nvoid c140_update(UINT8 ChipID, stream_sample_t **outputs, int samples);\nint device_start_c14"
  },
  {
    "path": "VGMPlay/chips/c352.c",
    "chars": 11032,
    "preview": "// license:BSD-3-Clause\n// copyright-holders:R. Belmont, superctr\n/*\n    c352.c - Namco C352 custom PCM chip emulation\n "
  },
  {
    "path": "VGMPlay/chips/c352.h",
    "chars": 635,
    "preview": "#pragma once\n\n#ifndef __C352_H__\n#define __C352_H__\n\nvoid c352_update(UINT8 ChipID, stream_sample_t **outputs, int sampl"
  },
  {
    "path": "VGMPlay/chips/c6280.c",
    "chars": 13038,
    "preview": "/*\n    HuC6280 sound chip emulator\n    by Charles MacDonald\n    E-mail: cgfm2@hotmail.com\n    WWW: http://cgfm2.emuviews"
  },
  {
    "path": "VGMPlay/chips/c6280.h",
    "chars": 631,
    "preview": "#pragma once\n\n//#include \"devlegcy.h\"\n\ntypedef struct _c6280_interface c6280_interface;\nstruct _c6280_interface\n{\n\tconst"
  },
  {
    "path": "VGMPlay/chips/c6280intf.c",
    "chars": 2976,
    "preview": "#include <stddef.h>\t// for NULL\n#include \"mamedef.h\"\n#ifdef ENABLE_ALL_CORES\n#include \"c6280.h\"\n#endif\n#include \"Ootake_"
  },
  {
    "path": "VGMPlay/chips/c6280intf.h",
    "chars": 412,
    "preview": "#pragma once\n\nvoid c6280_w(UINT8 ChipID, offs_t offset, UINT8 data);\nUINT8 c6280_r(UINT8 ChipID, offs_t offset);\n\nvoid c"
  },
  {
    "path": "VGMPlay/chips/dac_control.c",
    "chars": 12555,
    "preview": "// TODO: SCSP and (especially) WonderSwan\n /************************\n  *  DAC Stream Control  *\n  **********************"
  },
  {
    "path": "VGMPlay/chips/dac_control.h",
    "chars": 782,
    "preview": "void daccontrol_update(UINT8 ChipID, UINT32 samples);\nUINT8 device_start_daccontrol(UINT8 ChipID);\nvoid device_stop_dacc"
  },
  {
    "path": "VGMPlay/chips/emu2149.c",
    "chars": 11016,
    "preview": "/****************************************************************************\n\n  emu2149.c -- YM2149/AY-3-8910 emulator "
  },
  {
    "path": "VGMPlay/chips/emu2149.h",
    "chars": 2427,
    "preview": "/* emu2149.h */\n#ifndef _EMU2149_H_\n#define _EMU2149_H_\n#include \"emutypes.h\"\n\n/*#ifdef EMU2149_DLL_EXPORTS\n#define EMU2"
  },
  {
    "path": "VGMPlay/chips/emu2413.c",
    "chars": 44113,
    "preview": "/**\n * emu2413 v1.5.2\n * https://github.com/digital-sound-antiques/emu2413\n * Copyright (C) 2020 Mitsutaka Okazaki\n *\n *"
  },
  {
    "path": "VGMPlay/chips/emu2413.h",
    "chars": 6353,
    "preview": "#ifndef _EMU2413_H_\n#define _EMU2413_H_\n\n#include \"emutypes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define OPLL_DEB"
  },
  {
    "path": "VGMPlay/chips/emu2413_NESpatches.txt",
    "chars": 50,
    "preview": "http://forums.nesdev.com/viewtopic.php?f=6&t=9141\n"
  },
  {
    "path": "VGMPlay/chips/emutypes.h",
    "chars": 927,
    "preview": "#ifndef _EMUTYPES_H_\n#define _EMUTYPES_H_\n\n#ifndef INLINE\n\n#if defined(_MSC_VER)\n//#define INLINE __forceinline\n#define "
  },
  {
    "path": "VGMPlay/chips/es5503.c",
    "chars": 17042,
    "preview": "/*\n\n  ES5503 - Ensoniq ES5503 \"DOC\" emulator v2.1.1\n  By R. Belmont.\n\n  Copyright R. Belmont.\n\n  This software is dual-l"
  },
  {
    "path": "VGMPlay/chips/es5503.h",
    "chars": 1052,
    "preview": "#pragma once\n\n#ifndef __ES5503_H__\n#define __ES5503_H__\n\n///#include \"devlegcy.h\"\n\n/*typedef struct _es5503_interface es"
  },
  {
    "path": "VGMPlay/chips/es5506.c",
    "chars": 76824,
    "preview": "/**********************************************************************************************\n\n     Ensoniq ES5505/6 d"
  },
  {
    "path": "VGMPlay/chips/es5506.h",
    "chars": 2373,
    "preview": "/**********************************************************************************************\n *\n *   Ensoniq ES5505/6"
  },
  {
    "path": "VGMPlay/chips/fm.c",
    "chars": 155225,
    "preview": "#define YM2610B_WARNING\n\n/*\n**\n** File: fm.c -- software implementation of Yamaha FM sound generator\n**\n** Copyright Jar"
  },
  {
    "path": "VGMPlay/chips/fm.h",
    "chars": 7919,
    "preview": "/*\n  File: fm.h -- header file for software emulation for FM sound generator\n\n*/\n\n#pragma once\n\n/* --- select emulation "
  },
  {
    "path": "VGMPlay/chips/fm2612.c",
    "chars": 79341,
    "preview": "/*\n**\n** File: fm2612.c -- software implementation of Yamaha YM2612 FM sound generator\n** Split from fm.c to keep 2612 f"
  },
  {
    "path": "VGMPlay/chips/fmopl.c",
    "chars": 70553,
    "preview": "/*\n**\n** File: fmopl.c - software implementation of FM sound generator\n**                                            typ"
  },
  {
    "path": "VGMPlay/chips/fmopl.h",
    "chars": 4113,
    "preview": "#pragma once\n\n//#include \"attotime.h\"\n\n/* --- select emulation chips --- */\n//#define BUILD_YM3812 (HAS_YM3812)\n//#defin"
  },
  {
    "path": "VGMPlay/chips/gb.c",
    "chars": 33195,
    "preview": "// license:BSD-3-Clause\n// copyright-holders:Wilbert Pol, Anthony Kruize\n// thanks-to:Shay Green\n/**********************"
  },
  {
    "path": "VGMPlay/chips/gb.h",
    "chars": 625,
    "preview": "\n/* Custom Sound Interface */\nUINT8 gb_wave_r(UINT8 ChipID, offs_t offset);\nvoid gb_wave_w(UINT8 ChipID, offs_t offset, "
  },
  {
    "path": "VGMPlay/chips/iremga20.c",
    "chars": 9059,
    "preview": "/*********************************************************\n\nIrem GA20 PCM Sound Chip\n\nIt's not currently known whether t"
  },
  {
    "path": "VGMPlay/chips/iremga20.h",
    "chars": 896,
    "preview": "/*********************************************************\n\n    Irem GA20 PCM Sound Chip\n\n******************************"
  },
  {
    "path": "VGMPlay/chips/k051649.c",
    "chars": 11571,
    "preview": "/***************************************************************************\n\n    Konami 051649 - SCC1 sound as used in "
  },
  {
    "path": "VGMPlay/chips/k051649.h",
    "chars": 1320,
    "preview": "#pragma once\n\n//#ifndef __K051649_H__\n//#define __K051649_H__\n\n//#include \"devlegcy.h\"\n\n/*WRITE8_DEVICE_HANDLER( k051649"
  },
  {
    "path": "VGMPlay/chips/k053260.c",
    "chars": 14139,
    "preview": "/*********************************************************\n\n    Konami 053260 PCM Sound Chip\n\n**************************"
  },
  {
    "path": "VGMPlay/chips/k053260.h",
    "chars": 1009,
    "preview": "/*********************************************************\n\n    Konami 053260 PCM/ADPCM Sound Chip\n\n********************"
  },
  {
    "path": "VGMPlay/chips/k054539.c",
    "chars": 19001,
    "preview": "/*********************************************************\n\n    Konami 054539 (TOP) PCM Sound Chip\n\n    A lot of informa"
  },
  {
    "path": "VGMPlay/chips/k054539.h",
    "chars": 1928,
    "preview": "/*********************************************************\n\n    Konami 054539 PCM Sound Chip\n\n**************************"
  },
  {
    "path": "VGMPlay/chips/mamedef.h",
    "chars": 1475,
    "preview": "#ifndef __MAMEDEF_H__\n#define __MAMEDEF_H__\n\n// typedefs to use MAME's (U)INTxx types (copied from MAME\\src\\ods\\odscomm."
  },
  {
    "path": "VGMPlay/chips/multipcm.c",
    "chars": 23156,
    "preview": "/*\n * Sega System 32 Multi/Model 1/Model 2 custom PCM chip (315-5560) emulation.\n *\n * by Miguel Angel Horna (ElSemi) fo"
  },
  {
    "path": "VGMPlay/chips/multipcm.h",
    "chars": 891,
    "preview": "#pragma once\n\n//#include \"devlegcy.h\"\n\nvoid MultiPCM_update(UINT8 ChipID, stream_sample_t **outputs, int samples);\nint d"
  },
  {
    "path": "VGMPlay/chips/nes_apu.c",
    "chars": 25886,
    "preview": "/*****************************************************************************\n\n  MAME/MESS NES APU CORE\n\n  Based on the"
  },
  {
    "path": "VGMPlay/chips/nes_apu.h",
    "chars": 1867,
    "preview": "/*****************************************************************************\n\n  MAME/MESS NES APU CORE\n\n  Based on the"
  },
  {
    "path": "VGMPlay/chips/nes_defs.h",
    "chars": 4558,
    "preview": "/*****************************************************************************\n\n  MAME/MESS NES APU CORE\n\n  Based on the"
  },
  {
    "path": "VGMPlay/chips/nes_intf.c",
    "chars": 7591,
    "preview": "/****************************************************************\n\n    MAME / MESS functions\n\n**************************"
  },
  {
    "path": "VGMPlay/chips/nes_intf.h",
    "chars": 494,
    "preview": "#pragma once\n\nvoid nes_stream_update(UINT8 ChipID, stream_sample_t **outputs, int samples);\n\nint device_start_nes(UINT8 "
  },
  {
    "path": "VGMPlay/chips/np_nes_apu.c",
    "chars": 10966,
    "preview": "//\n// NES 2A03\n//\n// Ported from NSFPlay 2.2 to VGMPlay (including C++ -> C conversion)\n// by Valley Bell on 24 Septembe"
  },
  {
    "path": "VGMPlay/chips/np_nes_apu.h",
    "chars": 611,
    "preview": "void NES_APU_np_FrameSequence(void* chip, int s);\nvoid* NES_APU_np_Create(int clock, int rate);\nvoid NES_APU_np_Destroy("
  },
  {
    "path": "VGMPlay/chips/np_nes_dmc.c",
    "chars": 19532,
    "preview": "// Ported from NSFPlay to VGMPlay (including C++ -> C conversion)\n// by Valley Bell on 25 September 2013\n// Updated to N"
  },
  {
    "path": "VGMPlay/chips/np_nes_dmc.h",
    "chars": 823,
    "preview": "#ifndef _NP_NES_DMC_H_\n#define _NP_NES_DMC_H_\n\nvoid* NES_DMC_np_Create(int clock, int rate);\nvoid NES_DMC_np_Destroy(voi"
  },
  {
    "path": "VGMPlay/chips/np_nes_fds.c",
    "chars": 13312,
    "preview": "// Ported from NSFPlay 2.3 to VGMPlay (including C++ -> C conversion)\n// by Valley Bell on 26 September 2013\n\n#include <"
  },
  {
    "path": "VGMPlay/chips/np_nes_fds.h",
    "chars": 596,
    "preview": "#ifndef _NP_NES_FDS_H_\n#define _NP_NES_FDS_H_\n\nvoid* NES_FDS_Create(int clock, int rate);\nvoid NES_FDS_Destroy(void* chi"
  },
  {
    "path": "VGMPlay/chips/okim6258.c",
    "chars": 17778,
    "preview": "/**********************************************************************************************\n *\n *   OKI MSM6258 ADPC"
  },
  {
    "path": "VGMPlay/chips/okim6258.h",
    "chars": 1549,
    "preview": "#pragma once\n\n//#include \"devlegcy.h\"\n\n/* an interface for the OKIM6258 and similar chips */\n\n/*typedef struct _okim6258"
  },
  {
    "path": "VGMPlay/chips/okim6295.c",
    "chars": 23403,
    "preview": "/**********************************************************************************************\n *\n *   streaming ADPCM "
  },
  {
    "path": "VGMPlay/chips/okim6295.h",
    "chars": 1525,
    "preview": "#pragma once\n\n/* an interface for the OKIM6295 and similar chips */\n\n/*\n  Note about the playback frequency: the externa"
  },
  {
    "path": "VGMPlay/chips/opl.c",
    "chars": 55738,
    "preview": "// IMPORTANT: This file is not meant to be compiled. It's included in adlibemu_opl?.c.\n\n/*\n *  Copyright (C) 2002-2010  "
  },
  {
    "path": "VGMPlay/chips/opl.h",
    "chars": 7767,
    "preview": "/*\n *  Copyright (C) 2002-2010  The DOSBox Team\n *  OPL2/OPL3 emulation library\n *\n *  This library is free software; yo"
  },
  {
    "path": "VGMPlay/chips/opll.c",
    "chars": 52377,
    "preview": "/*\n * Copyright (C) 2019 Nuke.YKT\n *\n * This program is free software; you can redistribute it and/or\n * modify it under"
  },
  {
    "path": "VGMPlay/chips/opll.h",
    "chars": 5329,
    "preview": "/*\n * Copyright (C) 2019 Nuke.YKT\n *\n * This program is free software; you can redistribute it and/or\n * modify it under"
  },
  {
    "path": "VGMPlay/chips/opm.c",
    "chars": 56525,
    "preview": "/* Nuked OPM\n * Copyright (C) 2020 Nuke.YKT\n *\n * This file is part of Nuked OPM.\n *\n * Nuked OPM is free software: you "
  },
  {
    "path": "VGMPlay/chips/opm.h",
    "chars": 6644,
    "preview": "/* Nuked OPM\n * Copyright (C) 2020 Nuke.YKT\n *\n * This file is part of Nuked OPM.\n *\n * Nuked OPM is free software: you "
  },
  {
    "path": "VGMPlay/chips/panning.c",
    "chars": 2348,
    "preview": "#include <stdlib.h>\n#include <math.h>\n#include \"panning.h\"\n\n#ifndef PI\n#define PI 3.14159265359\n#endif\n#ifndef SQRT2\n#de"
  },
  {
    "path": "VGMPlay/chips/panning.h",
    "chars": 327,
    "preview": "/*\n\tpanning.h by Maxim in 2006\n\tImplements \"simple equal power\" panning using sine distribution\n\tI am not an expert on t"
  },
  {
    "path": "VGMPlay/chips/pokey.c",
    "chars": 49904,
    "preview": "/*****************************************************************************\n *\n *  POKEY chip emulator 4.51\n *  Copyr"
  },
  {
    "path": "VGMPlay/chips/pokey.h",
    "chars": 3091,
    "preview": "/*****************************************************************************\n *\n *  POKEY chip emulator 4.3\n *  Copyri"
  },
  {
    "path": "VGMPlay/chips/pwm.c",
    "chars": 10685,
    "preview": "/***************************************************************************\n * Gens: PWM audio emulator.               "
  },
  {
    "path": "VGMPlay/chips/pwm.h",
    "chars": 2777,
    "preview": "/***************************************************************************\n * Gens: PWM audio emulator.               "
  },
  {
    "path": "VGMPlay/chips/qsound_ctr.c",
    "chars": 23015,
    "preview": "/*\n\n\tCapcom DL-1425 QSound emulator\n\t==============================\n\t\n\tby superctr (Ian Karlsson)\n\twith thanks to Valley"
  },
  {
    "path": "VGMPlay/chips/qsound_ctr.h",
    "chars": 621,
    "preview": "#pragma once\n\nvoid qsoundc_update(UINT8 ChipID, stream_sample_t **outputs, int samples);\nint device_start_qsound_ctr(UIN"
  },
  {
    "path": "VGMPlay/chips/qsound_intf.c",
    "chars": 4605,
    "preview": "//#include \"emu.h\"\n#include \"mamedef.h\"\n#ifdef _DEBUG\n#include <stdio.h>\n#endif\n#include <stdlib.h>\n#include <string.h>\t"
  },
  {
    "path": "VGMPlay/chips/qsound_intf.h",
    "chars": 542,
    "preview": "#pragma once\n\nvoid qsound_update(UINT8 ChipID, stream_sample_t **outputs, int samples);\nint device_start_qsound(UINT8 Ch"
  },
  {
    "path": "VGMPlay/chips/qsound_mame.c",
    "chars": 12642,
    "preview": "/***************************************************************************\n\n  Capcom System QSound(tm)\n  ============="
  },
  {
    "path": "VGMPlay/chips/qsound_mame.h",
    "chars": 861,
    "preview": "/*********************************************************\n\n    Capcom Q-Sound system\n\n*********************************"
  },
  {
    "path": "VGMPlay/chips/rf5c68.c",
    "chars": 11777,
    "preview": "/*********************************************************/\n/*    ricoh RF5C68(or clone) PCM controller              */\n"
  },
  {
    "path": "VGMPlay/chips/rf5c68.h",
    "chars": 964,
    "preview": "/*********************************************************/\n/*    ricoh RF5C68(or clone) PCM controller              */\n"
  },
  {
    "path": "VGMPlay/chips/saa1099.c",
    "chars": 19407,
    "preview": "/***************************************************************************\n\n    Philips SAA1099 Sound driver\n\n    By J"
  },
  {
    "path": "VGMPlay/chips/saa1099.h",
    "chars": 750,
    "preview": "#pragma once\n\n#ifndef __SAA1099_H__\n#define __SAA1099_H__\n\n/**********************************************\n    Philips S"
  },
  {
    "path": "VGMPlay/chips/scd_pcm.c",
    "chars": 11061,
    "preview": "/***********************************************************/\n/*                                                        "
  },
  {
    "path": "VGMPlay/chips/scd_pcm.h",
    "chars": 1520,
    "preview": "struct pcm_chip_\n{\n\tfloat Rate;\n\tint Smpl0Patch;\n\tint Enable;\n\tint Cur_Chan;\n\tint Bank;\n\n\tstruct pcm_chan_\n\t{\n\t\tunsigned"
  },
  {
    "path": "VGMPlay/chips/scsp.c",
    "chars": 42460,
    "preview": "/*\n    Sega/Yamaha YMF292-F (SCSP = Saturn Custom Sound Processor) emulation\n    By ElSemi\n    MAME/M1 conversion and cl"
  },
  {
    "path": "VGMPlay/chips/scsp.h",
    "chars": 1316,
    "preview": "/*\n    SCSP (YMF292-F) header\n*/\n\n#pragma once\n\n#ifndef __SCSP_H__\n#define __SCSP_H__\n\n//#include \"devlegcy.h\"\n\n/*typede"
  },
  {
    "path": "VGMPlay/chips/scspdsp.c",
    "chars": 6108,
    "preview": "//#include \"emu.h\"\n#include <string.h>\t// for memset\n#include \"mamedef.h\"\n#include \"scsp.h\"\n#include \"scspdsp.h\"\n\nstatic"
  },
  {
    "path": "VGMPlay/chips/scspdsp.h",
    "chars": 890,
    "preview": "#pragma once\n\n#ifndef __SCSPDSP_H__\n#define __SCSPDSP_H__\n\n//the DSP Context\nstruct _SCSPDSP\n{\n//Config\n\tUINT16 *SCSPRAM"
  },
  {
    "path": "VGMPlay/chips/scsplfo.c",
    "chars": 3233,
    "preview": "/*\n    SCSP LFO handling\n\n    Part of the SCSP (YMF292-F) emulator package.\n    (not compiled directly, #included from s"
  },
  {
    "path": "VGMPlay/chips/segapcm.c",
    "chars": 10831,
    "preview": "/*********************************************************/\n/*    SEGA 16ch 8bit PCM                                 */\n"
  },
  {
    "path": "VGMPlay/chips/segapcm.h",
    "chars": 1153,
    "preview": "/*********************************************************/\n/*    SEGA 8bit PCM                                      */\n"
  },
  {
    "path": "VGMPlay/chips/sn76489.c",
    "chars": 11952,
    "preview": "/* \n\tSN76489 emulation\n\tby Maxim in 2001 and 2002\n\tconverted from my original Delphi implementation\n\n\tI'm a C newbie so "
  },
  {
    "path": "VGMPlay/chips/sn76489.h",
    "chars": 3564,
    "preview": "#ifndef _SN76489_H_\n#define _SN76489_H_\n\n// all these defines are defined in mamedef.h, but GCC's #ifdef doesn't seem to"
  },
  {
    "path": "VGMPlay/chips/sn76496.c",
    "chars": 27956,
    "preview": "/***************************************************************************\n\n  sn76496.c\n  by Nicola Salmoria\n  with co"
  },
  {
    "path": "VGMPlay/chips/sn76496.h",
    "chars": 1392,
    "preview": "#pragma once\n\n/*READ8_DEVICE_HANDLER( sn76496_ready_r );\nWRITE8_DEVICE_HANDLER( sn76496_w );\nWRITE8_DEVICE_HANDLER( sn76"
  },
  {
    "path": "VGMPlay/chips/sn76496_opl.c",
    "chars": 11702,
    "preview": "#include <stddef.h>\t// for NULL\n#include \"mamedef.h\"\n#include \"math.h\"\n\nvoid OPL_RegMapper(UINT16 Reg, UINT8 Data);\n\ntyp"
  },
  {
    "path": "VGMPlay/chips/sn764intf.c",
    "chars": 3726,
    "preview": "/****************************************************************\n\n    MAME / MESS functions\n\n**************************"
  },
  {
    "path": "VGMPlay/chips/sn764intf.h",
    "chars": 755,
    "preview": "#pragma once\n\n/*WRITE8_DEVICE_HANDLER( ym2413_w );\n\nWRITE8_DEVICE_HANDLER( ym2413_register_port_w );\nWRITE8_DEVICE_HANDL"
  },
  {
    "path": "VGMPlay/chips/upd7759.c",
    "chars": 30361,
    "preview": "/************************************************************\n\n    NEC UPD7759 ADPCM Speech Processor\n    by: Juergen Bu"
  },
  {
    "path": "VGMPlay/chips/upd7759.h",
    "chars": 1537,
    "preview": "#pragma once\n\n//#include \"devlegcy.h\"\n\n/* There are two modes for the uPD7759, selected through the !MD pin.\n   This is "
  },
  {
    "path": "VGMPlay/chips/vrc7tone.h",
    "chars": 974,
    "preview": "/* VRC7 VOICE */\n/* Dumped via VRC7 debug mode by Nuke.YKT */\n0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n0x03, 0x21"
  },
  {
    "path": "VGMPlay/chips/vsu.c",
    "chars": 15390,
    "preview": "/* Mednafen - Multi-system Emulator\n\t*\n\t* This program is free software; you can redistribute it and/or modify\n\t* it und"
  },
  {
    "path": "VGMPlay/chips/vsu.h",
    "chars": 406,
    "preview": "#ifndef __VB_VSU_H\n#define __VB_VSU_H\n\nvoid VSU_Write(UINT8 ChipID, UINT32 A, UINT8 V);\n\nvoid vsu_stream_update(UINT8 Ch"
  },
  {
    "path": "VGMPlay/chips/ws_audio.c",
    "chars": 11042,
    "preview": "\n#include <stdlib.h>\n#include <stddef.h>\t// for NULL\n#include <string.h>\t// for memset\n#include \"mamedef.h\"\n\ntypedef UIN"
  },
  {
    "path": "VGMPlay/chips/ws_audio.h",
    "chars": 560,
    "preview": "#ifndef __WS_AUDIO_H__\n#define __WS_AUDIO_H__\n\nint ws_audio_init(UINT8 ChipID, int clock);\nvoid ws_audio_reset(UINT8 Chi"
  },
  {
    "path": "VGMPlay/chips/ws_initialIo.h",
    "chars": 3132,
    "preview": "////////////////////////////////////////////////////////////////////////////////\n// Initial I/O values\n/////////////////"
  },
  {
    "path": "VGMPlay/chips/x1_010.c",
    "chars": 12808,
    "preview": "/***************************************************************************\n\n                            -= Seta Hardwa"
  },
  {
    "path": "VGMPlay/chips/x1_010.h",
    "chars": 989,
    "preview": "#pragma once\n\n#ifndef __X1_010_H__\n#define __X1_010_H__\n\n//#include \"devlegcy.h\"\n\n\n/*typedef struct _x1_010_interface x1"
  },
  {
    "path": "VGMPlay/chips/ym2151.c",
    "chars": 71260,
    "preview": "/*****************************************************************************\n*\n*   Yamaha YM2151 driver (version 2.150"
  },
  {
    "path": "VGMPlay/chips/ym2151.h",
    "chars": 2666,
    "preview": "/*\n** File: ym2151.h - header file for software implementation of YM2151\n**                                            F"
  },
  {
    "path": "VGMPlay/chips/ym2413.c",
    "chars": 60685,
    "preview": "/*\n**\n** File: ym2413.c - software implementation of YM2413\n**                  FM sound generator type OPLL\n**\n** Copyr"
  },
  {
    "path": "VGMPlay/chips/ym2413.h",
    "chars": 1301,
    "preview": "#pragma once\n\n/* select output bits size of output : 8 or 16 */\n#define SAMPLE_BITS 16\n\n/* compiler dependence */\n//#ifn"
  },
  {
    "path": "VGMPlay/chips/ym2413_opl.c",
    "chars": 15326,
    "preview": "#include \"mamedef.h\"\n\nvoid OPL_RegMapper(UINT16 Reg, UINT8 Data);\n\n/* register number to channel number , slot offset */"
  },
  {
    "path": "VGMPlay/chips/ym2413hd.c",
    "chars": 21122,
    "preview": "/*-----------------------------------*/\n/* YM-2413 emulator using OPL        */\n/* (c) by Hiromitsu Shioya           */\n"
  },
  {
    "path": "VGMPlay/chips/ym2413hd.h",
    "chars": 2646,
    "preview": "/*-----------------------------------*/\n/* YM-2413 emulator using OPL        */\n/* (c) by Hiromitsu Shioya           */\n"
  },
  {
    "path": "VGMPlay/chips/ym2612.c",
    "chars": 67997,
    "preview": "/***********************************************************/\n/*                                                        "
  },
  {
    "path": "VGMPlay/chips/ym2612.h",
    "chars": 9861,
    "preview": "#ifndef _YM2612_H_\n#define _YM2612_H_\n\n// Change it if you need to do long update\n//#define\tMAX_UPDATE_LENGHT   4000\n#de"
  },
  {
    "path": "VGMPlay/chips/ym3438.c",
    "chars": 44447,
    "preview": "//\n// Copyright (C) 2017 Alexey Khokholov (Nuke.YKT)\n// \n// This program is free software; you can redistribute it and/o"
  },
  {
    "path": "VGMPlay/chips/ym3438.h",
    "chars": 5797,
    "preview": "//\n// Copyright (C) 2017 Alexey Khokholov (Nuke.YKT)\n// \n// This program is free software; you can redistribute it and/o"
  },
  {
    "path": "VGMPlay/chips/ymdeltat.c",
    "chars": 23088,
    "preview": "/*\n**\n** File: ymdeltat.c\n**\n** YAMAHA DELTA-T adpcm sound emulation subroutine\n** used by fmopl.c (Y8950) and fm.c (YM2"
  },
  {
    "path": "VGMPlay/chips/ymdeltat.h",
    "chars": 3378,
    "preview": "#pragma once\n\n#define YM_DELTAT_SHIFT    (16)\n\n#define YM_DELTAT_EMULATION_MODE_NORMAL\t0\n#define YM_DELTAT_EMULATION_MOD"
  },
  {
    "path": "VGMPlay/chips/ymf262.c",
    "chars": 74733,
    "preview": "/*\n**\n** File: ymf262.c - software implementation of YMF262\n**                  FM sound generator type OPL3\n**\n** Copyr"
  },
  {
    "path": "VGMPlay/chips/ymf262.h",
    "chars": 1594,
    "preview": "#pragma once\n\n//#include \"attotime.h\"\n\n/* select number of output bits: 8 or 16 */\n#define OPL3_SAMPLE_BITS 16\n\n/* compi"
  },
  {
    "path": "VGMPlay/chips/ymf271.c",
    "chars": 56960,
    "preview": "/*\n    Yamaha YMF271-F \"OPX\" emulator v0.1\n    By R. Belmont.\n    Based in part on YMF278B emulator by R. Belmont and O."
  },
  {
    "path": "VGMPlay/chips/ymf271.h",
    "chars": 1016,
    "preview": "#pragma once\n\n//#include \"devcb.h\"\n\n//typedef struct _ymf271_interface ymf271_interface;\n//struct _ymf271_interface\n//{\n"
  },
  {
    "path": "VGMPlay/chips/ymf278b.c",
    "chars": 30572,
    "preview": "/*\n\n   YMF278B  FM + Wave table Synthesizer (OPL4)\n\n   Timer and PCM YMF278B.  The FM is shared with the ymf262.\n\n   Thi"
  },
  {
    "path": "VGMPlay/chips/ymf278b.h",
    "chars": 1081,
    "preview": "#pragma once\n\n#define YMF278B_STD_CLOCK (33868800)\t\t\t/* standard clock for OPL4 */\n\n\ntypedef struct _ymf278b_interface y"
  },
  {
    "path": "VGMPlay/chips/ymz280b.c",
    "chars": 37963,
    "preview": "/*\n\n Yamaha YMZ280B driver\n  by Aaron Giles\n\n  YMZ280B 8-Channel PCMD8 PCM/ADPCM Decoder\n\n Features as listed in LSI-4MZ"
  },
  {
    "path": "VGMPlay/chips/ymz280b.h",
    "chars": 1261,
    "preview": "/**********************************************************************************************\n *\n *   Yamaha YMZ280B d"
  },
  {
    "path": "VGMPlay/dbus.c",
    "chars": 49799,
    "preview": "/*\nDBus/MPRIS for VGMPlay.\nBy Tasos Sahanidis <vgmsrc@tasossah.com>\n\nrequired packages:\nlibdbus-1-dev\n\ncompiling:\nCFLAGS"
  },
  {
    "path": "VGMPlay/dbus.h",
    "chars": 608,
    "preview": "#ifndef __DBUS_H__\n#define __DBUS_H__\n\n// Defines for the DBUS Signal handler\n#define SIGNAL_METADATA    0x01 // Metadat"
  },
  {
    "path": "VGMPlay/dbus_stub.c",
    "chars": 106,
    "preview": "#include \"chips/mamedef.h\"\n\nvoid DBus_ReadWriteDispatch(void)\n{\n\n}\n\nvoid DBus_EmitSignal(UINT8 type)\n{\n\n}\n"
  },
  {
    "path": "VGMPlay/licenses/GPL.txt",
    "chars": 17992,
    "preview": "\t\t    GNU GENERAL PUBLIC LICENSE\n\t\t       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc."
  },
  {
    "path": "VGMPlay/licenses/List.txt",
    "chars": 248,
    "preview": "MAME - mame_license.txt\nDosBox - GPL.txt\nopenMSX - GPL.txt\nGens/GS - GPL.txt\nNSFPlay - [Google Code lists Apache License"
  },
  {
    "path": "VGMPlay/licenses/mame_license.txt",
    "chars": 1837,
    "preview": "Unless otherwise explicitly stated, all code in MAME is released under the\nfollowing license:\n\nCopyright Nicola Salmoria"
  },
  {
    "path": "VGMPlay/mmkeys.h",
    "chars": 320,
    "preview": "#ifndef __MMKEYS_H__\n#define __MMKEYS_H__\n\ntypedef void (*mmkey_cbfunc)(UINT8 event);\n\n#define MMKEY_PLAY\t0x01\n#define M"
  },
  {
    "path": "VGMPlay/mmkeys_Win.c",
    "chars": 1751,
    "preview": "#include <Windows.h>\n#include <stdio.h>\n\n#include \"chips/mamedef.h\"\n#include \"mmkeys.h\"\n\n#ifndef VK_MEDIA_NEXT_TRACK\n// "
  },
  {
    "path": "VGMPlay/mmkeys_stub.c",
    "chars": 219,
    "preview": "#include \"chips/mamedef.h\"\n#include \"mmkeys.h\"\n\nUINT8 MultimediaKeyHook_Init(void)\n{\n    return 0;\n}\n\nvoid MultimediaKey"
  },
  {
    "path": "VGMPlay/pt_ioctl.c",
    "chars": 11139,
    "preview": "/******************************************************************************/\n/*                                     "
  },
  {
    "path": "VGMPlay/stdbool.h",
    "chars": 376,
    "preview": "// custom stdbool.h to for 1-byte bool types\n\n#ifndef _CSTM_STDBOOL_H_\n#define\t_CSTM_STDBOOL_H_\t\n\n#ifndef __cplusplus\t//"
  },
  {
    "path": "VGMPlay/vgm-player",
    "chars": 11713,
    "preview": "#!/bin/sh\n\n# Launcher script to work around limitations in vgmplay:\n#   OSS only - detects oss wrapper and allows explic"
  },
  {
    "path": "VGMPlay/vgm2pcm.c",
    "chars": 3320,
    "preview": "#define _GNU_SOURCE\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <wchar.h>\n\n#ifdef WIN32\n#include"
  },
  {
    "path": "VGMPlay/vgm2wav.c",
    "chars": 6850,
    "preview": "/*\n *  This file is part of VGMPlay <https://github.com/vgmrips/vgmplay>\n *\n *  (c)2015 libertyernie <maybeway36@gmail.c"
  },
  {
    "path": "VGMPlay/vgm2wav.dsp",
    "chars": 20452,
    "preview": "# Microsoft Developer Studio Project File - Name=\"vgm2pcm\" - Package Owner=<4>\r\n# Microsoft Developer Studio Generated B"
  },
  {
    "path": "VGMPlay/vgmplay.1",
    "chars": 3733,
    "preview": ".TH vgmplay \"1\" \"November 10\" \"Valley Bell\" \"User Commands\"\n.nh\n.SH NAME\nvgmplay \\- the official and always up-to-date p"
  },
  {
    "path": "VGMPlay/vgmspec171.txt",
    "chars": 41548,
    "preview": "VGM Spec v1.71 beta\n==============\nVGM (Video Game Music) is a sample-accurate sound logging format for the Sega\nMaster "
  },
  {
    "path": "VGMPlay/xdg/vgmplay-mime.xml",
    "chars": 372,
    "preview": "<?xml version=\"1.0\"?>\n<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n    <mime-type type=\"aud"
  },
  {
    "path": "VGMPlay/xdg/vgmplay.desktop.in",
    "chars": 392,
    "preview": "[Desktop Entry]\nName=VGMPlay\nGenericName=VGMPlay\nComment=VGM File Player\nExec=@BIN_PATH@vgmplay %f\nTerminal=true\nIcon=vg"
  },
  {
    "path": "VGMPlay/zlib/zconf.h",
    "chars": 16298,
    "preview": "/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler\n * F"
  }
]

// ... and 29 more files (download for full content)

About this extraction

This page contains the full source code of the vgmrips/vgmplay GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 229 files (3.1 MB), approximately 833.1k tokens, and a symbol index with 2153 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!