asm

extern	m68k_regs regs;


_regs
R_D0	 DD 0			 ; Data Registers
R_D1	 DD 0
R_D2	 DD 0
R_D3	 DD 0
R_D4	 DD 0
R_D5	 DD 0
R_D6	 DD 0
R_D7	 DD 0

R_A0	 DD 0			 ; Address Registers
R_A1	 DD 0
R_A2	 DD 0
R_A3	 DD 0
R_A4	 DD 0
R_A5	 DD 0
R_A6	 DD 0
R_A7	 DD 0

R_ISP	 DD 0			 ; Supervisor Stack
R_SR_H	 DD 0			 ; Status Register High TuSuuIII
R_CCR	 DD 0			 ; CCR Register in Intel Format
R_XC	 DD 0			 ; Extended Carry uuuuuuuX
R_PC	 DD 0			 ; Program Counter
R_IRQ	 DD 0			 ; IRQ Request Level

R_SR	 DD 0			 ; Motorola Format SR

R_IRQ_CALLBACK	 DD 0			 ; irq callback (get vector)

R_PPC	 DD 0			 ; Previous Program Counter
R_RESET_CALLBACK	 DD 0			 ; Reset Callback
R_SFC	 DD 0			 ; Source Function Call
R_DFC	 DD 0			 ; Destination Function Call
R_USP	 DD 0			 ; User Stack
R_VBR	 DD 0			 ; Vector Base
asmbank	 DD 0
BusErrorMin:
	 DD 0
BusErrorMax:
	 DD 0
CPU_TYPE:
	 DD 0


typedef struct
{
	DWORD d[8];
	DWORD a[8];

	DWORD isp;

	DWORD sr_high;
	DWORD ccr;
	DWORD x_carry;

	DWORD pc;
	DWORD IRQ_level;

	DWORD sr;

	void *irq_callback;

	DWORD ppc;
	DWORD (*reset_callback)(void);

	DWORD sfc;
	DWORD dfc;
	DWORD usp;
	DWORD vbr;

	DWORD bank;

	DWORD memmin;
	DWORD memmax;

	DWORD cputype;
} m68k_regs;


regs.irq_callback = IRQH_CallBack[i];




------------------------------------


adpcm:

int ADPCM_VolumeShift = 65536;
int dif_table[49*16];
signed short ADPCM_BufR[ADPCM_BufSize];
signed short ADPCM_BufL[ADPCM_BufSize];

long ADPCM_WrPtr = 0;
long ADPCM_RdPtr = 0;
DWORD ADPCM_SampleRate = 44100*12;
DWORD ADPCM_ClockRate = 7800*12;
DWORD ADPCM_Count = 0;
int ADPCM_Step = 0;
int ADPCM_Out = 0;
BYTE ADPCM_Playing = 0;
BYTE ADPCM_Clock = 0;
int ADPCM_PreCounter = 0;
int ADPCM_DifBuf = 0;


int ADPCM_Pan = 0x00;
int OldR = 0, OldL = 0;
int Outs[8];
int OutsIp[4];
int OutsIpR[4];
int OutsIpL[4];


-------------------------------

bg.c

	BYTE	BG[0x8000];
	BYTE	Sprite_Regs[0x800];
	BYTE	BG_Regs[0x12];
	WORD	BG_CHREND = 0;
	WORD	BG_BG0TOP = 0;
	WORD	BG_BG0END = 0;
	WORD	BG_BG1TOP = 0;
	WORD	BG_BG1END = 0;
	BYTE	BG_CHRSIZE = 16;
	DWORD	BG_AdrMask = 511;
	DWORD	BG0ScrollX = 0, BG0ScrollY = 0;
	DWORD	BG1ScrollX = 0, BG1ScrollY = 0;

	long	BG_HAdjust = 0;
	long	BG_VLINE = 0;

	BYTE	BG_Dirty0[64*64];
	BYTE	BG_Dirty1[64*64];
	BYTE	BGCHR8[8*8*256];
	BYTE	BGCHR16[16*16*256];

	WORD	BG_LineBuf[1600];
	WORD	BG_PriBuf[1600];

	DWORD	VLINEBG = 0;


------------------------------

crtc.c

	BYTE	CRTC_Regs[24*2];
	BYTE	CRTC_Mode = 0;
	DWORD	TextDotX = 768, TextDotY = 512;
	WORD	CRTC_VSTART, CRTC_VEND;
	WORD	CRTC_HSTART, CRTC_HEND;
	DWORD	TextScrollX = 0, TextScrollY = 0;
	DWORD	GrphScrollX[4] = {0, 0, 0, 0};		// zɂc
	DWORD	GrphScrollY[4] = {0, 0, 0, 0};

	BYTE	CRTC_FastClr = 0;
	BYTE	CRTC_SispScan = 0;
	DWORD	CRTC_FastClrLine = 0;
	WORD	CRTC_FastClrMask = 0;
	WORD	CRTC_IntLine = 0;
	BYTE	CRTC_VStep = 2;

	BYTE	VCReg0[2] = {0, 0};
	BYTE	VCReg1[2] = {0, 0};
	BYTE	VCReg2[2] = {0, 0};

	BYTE	CRTC_RCFlag[2] = {0, 0};
	int HSYNC_CLK = 324;

--------------------------


disk_d88.c

typedef struct {
	BYTE	c;
	BYTE	h;
	BYTE	r;
	BYTE	n;
	WORD	sectors;		// Sector Count
	BYTE	mfm_flg;		// sides
	BYTE	del_flg;		// DELETED DATA
	BYTE	stat;			// STATUS (FDC ret)
	BYTE	reserved2[5];		// Reserved
	WORD	size;			// Sector Size
//	byte	data[0];		// Sector Data
} D88_SECTOR;

typedef struct D88_SECTINFO {
	struct D88_SECTINFO* next;
	D88_SECTOR sect;
} D88_SECTINFO;

D88_SECTINFO* D88Cur[4] = {0, 0, 0, 0};
D88_SECTINFO* D88Top[4] = {0, 0, 0, 0};
D88_SECTINFO* D88Trks[4][164];

D88Cur and D88Top are pointers to ( static D88_SECTINFO* D88Trks[4][164]->next; ) objects


traverse D88Trks[0][0-163]->next - for each one, write out the D88_SECTOR and sect.size data


----------------------------

disk_dim.c

int            DIMCur[4] = {0, 0, 0, 0};
int            DIMTrk[4] = {0, 0, 0, 0};
unsigned char* DIMImg[4] = {0, 0, 0, 0};

	DIMImg[drv] = (unsigned char*)malloc(1024*9*170+sizeof(DIM_HEADER));		// Maximum size


----------------------------

disk_xdf.c

int            XDFCur[4] = {0, 0, 0, 0};
int            XDFTrk[4] = {0, 0, 0, 0};
unsigned char* XDFImg[4] = {0, 0, 0, 0};


	XDFImg[drv] = (unsigned char*)malloc(1261568);


--------------------------------

dmac.c

dmac_ch	DMA[4];
int dmatrace = 0;

int DMA_IntCH = 0;
int DMA_LastInt = 0;

-----------------------------------

fdc.c

FDC fdc;

-----------------------------------

fdd.c

FDDINFO fdd;


------------------------------------

gvram.c

	BYTE	GVRAM[0x80000];
	WORD	Grp_LineBuf[1024];
	WORD	Grp_LineBufSP[1024];		// vCIeB^pobt@
	WORD	Grp_LineBufSP2[1024];		// x[Xv[pobt@i񔼓rbgi[j

	WORD	Pal16Adr[256];			// 16bit color pbgAhXvZp

--------------------------------


ioc.c

	BYTE	IOC_IntStat = 0;
	BYTE	IOC_IntVect = 0;


-----------------------------------------

irq.c

	BYTE	IRQH_IRQ[8];
	void	*IRQH_CallBack[8];

IRQH_Callback can be one of:

NULL,
&DMA_Int
&FDC_Int
&FDD_Int
&Mcry_IntCB
&MFP_IntCallback
&MIDI_Int
&SASI_Int
&SCC_Int
&IRQH_DefaultVector

--------------------------------

mem_wrap.c

extern	BYTE*	MEM;
extern	BYTE*	IPL;
extern	BYTE*	OP_ROM;
extern	BYTE*	FONT;
extern	BYTE	traceflag;


extern    DWORD   BusErrFlag;
extern    DWORD   MemByteAccess;
extern    int     m68000_ICount;
extern    int     m68000_ICountBk;
extern int     ICount;

 MEM = (BYTE*)malloc(0xc00000);
 IPL = (BYTE*)malloc(0x40000);
FONT = (BYTE*)malloc(0xc0000);

OP_ROM is one of:

MEM;
GVRAM-0xc00000;  
SRAM-0xed0000;
TVRAM-0xe00000;
_SCSIIPL - 0ea0000h
IPL-0xfc0000;


--------------------------------------------

mercury.c

long	Mcry_WrPtr = 0;
long	Mcry_RdPtr = 0;
long	Mcry_SampleRate = 44100;
long	Mcry_ClockRate = 44100;
long	Mcry_Count = 0;
BYTE	Mcry_Status = 0;
BYTE	Mcry_LRTiming = 0;
short	Mcry_OutDataL = 0;
short	Mcry_OutDataR = 0;
short	Mcry_BufL[Mcry_BufSize];
short	Mcry_BufR[Mcry_BufSize];
long	Mcry_PreCounter = 0;

short	Mcry_OldR, Mcry_OldL;
int	Mcry_DMABytes = 0;

double Mcry_VolumeShift = 65536;
int Mcry_SampleCnt = 0;
BYTE Mcry_Vector = 255;

-------------------------------

mfp.c

BYTE testflag=0;
BYTE LastKey = 0;

BYTE MFP[24];
BYTE Timer_TBO = 0;
static BYTE Timer_Reload[4] = {0, 0, 0, 0};
static int Timer_Tick[4] = {0, 0, 0, 0};

-----------------------------

midi.c

int		MIDI_CTRL;
int		MIDI_POS;
int		MIDI_SYSCOUNT;
BYTE		MIDI_LAST;
BYTE		MIDI_BUF[MIDIBUFFERS];
BYTE		MIDI_EXCVBUF[MIDIBUFFERS];
BYTE		MIDI_EXCVWAIT;

BYTE		MIDI_RegHigh = 0;				// X68Kp
BYTE		MIDI_Playing = 0;				// }X^XCb`
BYTE		MIDI_Vector = 0;
BYTE		MIDI_IntEnable = 0;
BYTE		MIDI_IntVect = 0;
BYTE		MIDI_IntFlag = 0;
DWORD		MIDI_Buffered = 0;
long		MIDI_BufTimer = 3333;
BYTE		MIDI_R05 = 0;
DWORD		MIDI_GTimerMax = 0;
DWORD		MIDI_MTimerMax = 0;
long		MIDI_GTimerVal = 0;
long		MIDI_MTimerVal = 0;
BYTE		MIDI_TxFull = 0;
BYTE		MIDI_MODULE = MIDI_NOTUSED;


DELAYBUFITEM DelayBuf[MIDIDELAYBUF];
int DBufPtrW = 0;
int DBufPtrR = 0;

BYTE		LOADED_TONEMAP = 0;
BYTE		ENABLE_TONEMAP = 0;
BYTE		TONE_CH[16];
BYTE		TONEBANK[3][128];
BYTE		TONEMAP[3][128];

---------------------------

palette.c

	BYTE	Pal_Regs[1024];
	WORD	TextPal[256];
	WORD	GrphPal[256];
	WORD	Pal16[65536];
	WORD	Ibit;				// ƂŎg`

	WORD	Pal_HalfMask, Pal_Ix2;
	WORD	Pal_R, Pal_G, Pal_B;		// ʋPxύXp


--------------------

pia.c

PIA pia;

-----------------

rtc.c

BYTE	RTC_Regs[2][16];
BYTE	RTC_Bank = 0;
int RTC_Timer1 = 0;
int RTC_Timer16 = 0;

--------------------

sasi.c

BYTE SASI_Buf[256];
BYTE SASI_Phase = 0;
DWORD SASI_Sector = 0;
DWORD SASI_Blocks = 0;
BYTE SASI_Cmd[6];
BYTE SASI_CmdPtr = 0;
WORD SASI_Device = 0;
BYTE SASI_Unit = 0;
short SASI_BufPtr = 0;
BYTE SASI_RW = 0;
BYTE SASI_Stat = 0;
BYTE SASI_Mes = 0;
BYTE SASI_Error = 0;
BYTE SASI_SenseStatBuf[4];
BYTE SASI_SenseStatPtr = 0;

int hddtrace=0;

------------------------

scc.c

signed char MouseX = 0;
signed char MouseY = 0;
BYTE MouseSt = 0;

BYTE SCC_RegsA[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
BYTE SCC_RegNumA = 0;
BYTE SCC_RegSetA = 0;
BYTE SCC_RegsB[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
BYTE SCC_RegNumB = 0;
BYTE SCC_RegSetB = 0;
BYTE SCC_Vector = 0;
BYTE SCC_Dat[3] = {0, 0, 0};
BYTE SCC_DatNum = 0;

----------------------

scsi.c

	BYTE	SCSIIPL[0x2000];

-----------------

sram.c

	BYTE	SRAM[0x4000];
-------------------

sysport.c

BYTE	SysPort[7];

------------------
tvram.c

	BYTE	TVRAM[0x80000];
	BYTE	TextDrawWork[1024*1024];
	BYTE	TextDirtyLine[1024];

	BYTE	TextDrawPattern[2048*4];

	BYTE	Text_TrFlag[1024];

----------------------------

windrv.c

	path_buff_s	path_tbl[MAX_PATH_TBL];	//FCBpathׂ̃e[u
	int	path_cur_prio;
	char	win_letter;
	int	num_win_drv;
	char	win_drvs[32];

	files_buff_s files_tbl[MAX_FILES_TBL];
	int files_next;		//pointer
	int files_num;
	int fatr;

	int	gr_files = 0;
	char	gr_buf[16][256];


--------------------------

fmgen.cpp

	uint	sinetable[1024];
	uint32	tltable[FM_TLPOS + FM_TLENTS];
	int32	cltable[FM_CLENTS*2];
	int		kftable[64];
	
	int		pmtable[2][8][FM_LFOENTS];
	uint	amtable[2][4][FM_LFOENTS];

	static bool tablemade = false;
	static uint currentratio = ~0;

	uint	aml, pml;
	int		pmv;



uint32 Operator::multable[4][16];
Operator::Counter Operator::ratetable[64];


------------------------

fmg_wrap.cpp

static RMDATA RMData[RMBUFSIZE];
static int RMPtrW;
static int RMPtrR;

----------------------

joystick.c

BYTE JoyKeyState0 = 0;
BYTE JoyKeyState1 = 0;
BYTE JoyState0[2] = {0xff, 0xff};
BYTE JoyState1[2] = {0xff, 0xff};
BYTE JoyPortData[2] = {0, 0};

---------------------

juliet.c

_ROMEO		romeo = {NULL};

------------------

keyboard.c

BYTE	KeyBufWP;
BYTE	KeyBufRP;
BYTE	KeyBuf[KeyBufSize];
BYTE	KeyEnable = 1;
BYTE	KeyIntFlag = 0;

---------------------

windraw.c

	int	Draw_Opaque;
	int	FullScreenFlag = 0;
extern	BYTE	Draw_RedrawAllFlag;
extern	BYTE	Draw_DrawFlag = 1;
	BYTE	Draw_ClrMenu = 0;
BYTE            Debug_Text=1, Debug_Grp=1, Debug_Sp=1;

	BYTE	Draw_BitMask[800];
	BYTE	Draw_TextBitMask[800];

	int	winx=0, winy=0;
	int	winh=0, winw=0;
	WORD	FrameCount = 0;
	int	SplashFlag = 0;

	WORD	WinDraw_Pal16B, WinDraw_Pal16R, WinDraw_Pal16G;

	int	WindowX = 0;
	int	WindowY = 0;

-----------------------

mouse68k

int	MousePosX = 0;
int	MousePosY = 0;
BYTE	MouseStat = 0;
BYTE	MouseSW = 0;

POINT	CursorPos;
int	mousex=0, mousey=0;

--------------

winx68k.c

WORD      VLINE_TOTAL = 567;
DWORD     VLINE = 0;
DWORD     vline = 0;

BYTE DispFrame = 0;
DWORD SoundSampleRate;
int CurFrameRate = 1;
int NoWaitMode = 0;

int ClkUsed = 0;
int FrameSkipCount = 0;
int FrameSkipQueue = 0;




------------------------

classes

FILE.H:class FileIO
FMFILTER.H:class LPF
FMG_WRAP.CPP:class MyOPM : public FM::OPM
FMG_WRAP.CPP:class YMF288 : public FM::Y288
FMGEN.H:        class Operator
FMGEN.H:                friend class Channel4;
FMGEN.H:        class Channel4
FMTIMER.H:      class Timer
OPM.H://        class OPM
OPM.H:  class OPM : public Timer
OPNA.H://       class OPN/OPNA
OPNA.H: class OPNBase : public Timer
OPNA.H: class OPNABase : public OPNBase
OPNA.H: class OPN : public OPNBase
OPNA.H: class OPNA : public OPNABase
OPNA.H: class OPNB : public OPNABase
OPNA.H: class OPN2 : public OPNBase
OPNA.H: class Y288 : public OPNABase
PSG.H://        class PSG
PSG.H:class PSG



----------------------------

#define RMBUFSIZE (256*1024)

typedef struct {
	unsigned int time;
	int reg;
	BYTE data;
} RMDATA;

static RMDATA RMData[RMBUFSIZE];
static int RMPtrW;
static int RMPtrR;

static MyOPM* opm = NULL;

static YMF288* ymf288a = NULL;
static YMF288* ymf288b = NULL;

MyOPM -> OPM -> Timer

YMF288 -> Y288 -> OPNABase -> OPNBase -> Timer

MyOpm fmg_wrap.cpp


	int CurReg;
	DWORD CurCount;

---------------------------

OPM opm.h

		int32	ml[4];
		int32	mr[4];
		int32	mixdelta;
		int		mpratio;
		
		int		fmvolume;

		uint	clock;
		uint	rate;
		uint	pcmrate;
		uint	lpfcutoff;

		uint	pmd;
		uint	amd;
		uint	lfocount;
		uint	lfodcount;
		uint	lfowaveform;
		uint	rateratio;
		uint	noise;
		int32	noisecount;
		uint32	noisedelta;
		
		bool	interpolation;
		uint8	lfofreq;
		uint8	status;
		uint8	reg01;

		uint8	kc[8];
		uint8	kf[8];
		uint8	pan[8];

		Channel4 ch[8];
		LPF		lpf;

		static int amtable[4][FM_LFOENTS];
		static int pmtable[4][FM_LFOENTS];





--------------------
YMF288 fmg_wrap.cpp

	int CurReg[2];
	DWORD CurCount;
	int IntrFlag;

---------------------

Y288 opna.h
		struct Rhythm
		{
			uint8	pan;		// ς
			int8	level;		// 傤
			int		volume;		// 傤Ă
			int16*	sample;		// Ղ
			uint	size;		// 
			uint	pos;		// 
			uint	step;		// ĂՂ
			uint	rate;		// Ղ̂[
		};

		Rhythm	rhythm[6];
		int8	rhythmtl;		// YŜ̉
		int		rhythmtvol;		
		uint8	rhythmkey;		// ỸL[

		int	mode288;		// 288/2608[htO
--------------

OPNABase opna.h

		int32	ml[4];
		int32	mr[4];
		

		uint8	pan[6];
		uint8	fnum2[9];
		
		uint8	reg22;
		uint	reg29;
		
		uint	stmask;
		uint	statusnext;

		uint32	lfocount;
		uint32	lfodcount;
		
		uint	fnum[6];
		uint	fnum3[3];
		

		uint8*	adpcmbuf;		// ADPCM RAM
		uint	adpcmmask;		// AhXɑ΂rbg}XN
		uint	adpcmnotice;	// ADPCM ĐIɂrbg
		uint	startaddr;		// Start address
		uint	stopaddr;		// Stop address
		uint	memaddr;		// ĐAhX
		uint	limitaddr;		// Limit address/mask
		int		adpcmlevel;		// ADPCM 
		int		adpcmvolume;
		int		adpcmvol;
		uint	deltan;			// N
		int		adplc;			// gϊpϐ
		int		adpld;			// gϊpϐl
		uint	adplbase;		// adpld ̌
		int		adpcmx;			// ADPCM p x
		int		adpcmd;			// ADPCM p 
		int		adpcmout;		// ADPCM ̏o
		int		apout0;			// out(t-2)+out(t-1)
		int		apout1;			// out(t-1)+out(t)

		uint	adpcmreadbuf;	// ADPCM [hpobt@
		bool	adpcmplay;		// ADPCM Đ
		int8	granuality;		

		uint8	control1;		// ADPCM Rg[WX^P
		uint8	control2;		// ADPCM Rg[WX^Q
		uint8	adpcmreg[8];	// ADPCM WX^̈ꕔ

		Channel4 ch[6];

		static int amtable[FM_LFOENTS];
		static int pmtable[FM_LFOENTS];
------------

OPNBase opna.h

		int		fmvolume;
		
		uint	clock;				// OPN NbN
		uint	rate;				// FM [g
		uint	psgrate;			// FMGen  o̓[g
		uint	status;
		uint	lpfcutoff;			// FM  LPF cutoff
		Channel4* csmch;
		
		int32	mixdelta;
		int		mpratio;
		bool	interpolation;
		
		static  uint32 lfotable[8];
		PSG		psg;
		LPF		lpf;

----------------

Timer fmtimer.h

		uint8	status;
		uint8	regtc;
		uint8	regta[2];
		
		int32	timera, timera_count;
		int32	timerb, timerb_count;
		int32	timer_step;

---------------

Channel4 fmgen.h

		static const uint8 fbtable[8];
		uint	fb;
		int		buf[4];
		int*	in[3];			// e OP ̓̓|C^
		int*	out[3];			// e OP ̏o̓|C^
		int*	pms;

		Operator op[4];


------------------------

Operator fmgen.h

		typedef uint32 Counter;
		
		ISample	out, out2;
		uint	dp;			// P
		uint	detune;		// Detune
		uint	detune2;	// DT2
		uint	multiple;	// Multiple
		uint32	pgcount;	// Phase ݒl
		uint32	pgdcount;	// Phase l
		int32	pgdcountl;	// Phase l >> x
		OpType	type;		// OP ̎ (M, N...)
		uint	bn;			// Block/Note
		int		eglevel;	// EG ̏o͒l
		int		eglvnext;	//  phase Ɉڂl
		int32	egstep;		// EG ̎̕ψڂ܂ł̎
		int32	egstepd;	// egstep ̎ԍ
		int		egtransa;	// EG ω̊ (for attack)
		int		egtransd;	// EG ω̊ (for decay)
		int		egout;		// EG+TL 킹o͒l
		int		tlout;		// TL ̏o͒l
		int		pmd;		// PM depth
		int		amd;		// AM depth

		uint	ksr;		// key scale rate
		EGPhase	phase;
		uint*	ams;
		uint8	ms;

		bool	keyon;		// current key state
		
		uint8	tl;			// Total Level	 (0-127)
		uint8	tll;		// Total Level Latch (for CSM mode)
		uint8	ar;			// Attack Rate   (0-63)
		uint8	dr;			// Decay Rate    (0-63)
		uint8	sr;			// Sustain Rate  (0-63)
		uint8	sl;			// Sustain Level (0-127)
		uint8	rr;			// Release Rate  (0-63)
		uint8	ks;			// Keyscale      (0-3)
		uint8	ssgtype;	// SSG-Type Envelop Control

		bool	amon;		// enable Amplitude Modulation
		bool	paramchanged;	// p[^XVꂽ
		bool	mute;
		static Counter ratetable[64];
		static uint32 multable[4][16];

------------------


PSG psg.h

	uint8 reg[16];

	const uint* envelop;
	uint olevel[3];
	uint32 scount[3], speriod[3];
	uint32 ecount, eperiod;
	uint32 ncount, nperiod;
	uint32 tperiodbase;
	uint32 eperiodbase;
	uint32 nperiodbase;
	int volume;
	int mask;

	static uint enveloptable[16][64];
	static uint noisetable[noisetablesize];
	static int EmitTable[32];

----------------

LPF  fmfilter.h

	int fn[order][4];
	int b[nchs][order][2];



myopm = 156587


26210


myopm
opm

lpf
psg
operator
channel4
timer
opnbase
opnabase
y288
ymf288
