⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 超级解霸源代码。纯c语言写的。适合有一定编程基础的开发人员用来学习提高
💻 C
📖 第 1 页 / 共 2 页
字号:
//////////////////////////////////////////////////////////
//			Soft VCD Player
//	These code MUST Compiler by BC3.1,Not others.
//	SMALL Mode,386 Instructions,DOS Stack Code,
//		    FASTEST Optimizations.
//	  Main Program with Video Control & WndProc.
//			Southern.Liang
//			  1996.6.30
//////////////////////////////////////////////////////////
//#pragma	option	-zC_TEXT	//This Must in _TEXT segment because the library & Enter point in _TEXT
#include <windows.h>
#include <mmsystem.h>
#include <dos.h>	//Only this call C library
#include <dir.h>
#include <stdio.h>
#include <stdlib.h>
#include "DCI.H"
#include "VCDAPI.H"

extern	int	WindowsColorBits;	//Windows now Color bits
extern	int	Chinese;
extern	int	VESAColor;
extern	int	UseDCI;
extern	int	DCIPlay;
extern	int	VideoCardType;
extern	int	SubType;
extern	int	DCIType;	//If now be 640x480 and had DCI Primary 64K/32K
extern	RECT	VideoRc;
extern	RGNDATA	RgnData;
extern	int	M640x48064KC;
extern	int	M640x48032KC;
extern	HWND	MainWindow;	//Main Windows
extern	HWND 	ShowVideo;
extern	HANDLE 	hInst;
extern	HBITMAP	VCDFACE;
extern	HWND	AboutWindow;
extern	int	CurVideoType;
extern	HWND	VideoWindow;	//Video output Window.
extern	int	DrvNum;
extern	int	VideoNumber;
extern	int	CurFileNum;
extern	int	videoID;
extern	int	PlayType;
extern	LONG	CurrentPos;
extern	HPALETTE	PreviewhPal;	// ColorBits<=8 use palette
extern	int	TimeStart;
extern	int	OtherDecoder;		//Use internal MPEG decoder.
///////////////These Library functions in _TEXT segment
void	PASCAL FAR	GetCWD(char *buf, int buflen)
{
	getcwd(buf,buflen);
}
int	PASCAL FAR 	SetDisk(int drive)
{
	return	setdisk(drive);
}
int 	PASCAL FAR	ChangeDir(const char *path)
{
	return	chdir(path);
}
int 	PASCAL	FAR	FindFirst(const char *pathname,FFBLK 	*ffblk,int attrib)
{
	return findfirst(pathname,(struct ffblk *)ffblk,attrib);
}
int	PASCAL	FAR	FindNext(FFBLK 	*ffblk)
{
	return	findnext((struct ffblk *)ffblk);
}

int	PASCAL	FAR	_Dos_SetFileAttr(const char *path, unsigned attrib)
{
	return	_dos_setfileattr(path,attrib);
}
void 	PASCAL	FAR	GetFAT(unsigned char drive,char far *dtable)
{
	struct fatinfo FAT;
	struct fatinfo far * FATPtr;
	getfat(drive,&FAT);
	FATPtr=(struct fatinfo far *)dtable;
	FATPtr->fi_sclus=FAT.fi_sclus;
	FATPtr->fi_fatid=FAT.fi_fatid;
	FATPtr->fi_nclus=FAT.fi_nclus;
	FATPtr->fi_bysec=FAT.fi_bysec;
}
int	CurDisk;
char	CurPath[128];
void	GetHome(void)
{
	CurDisk=getdisk();
	getcwd(CurPath,sizeof(CurPath));
}
void	PASCAL	FAR	GoHome(void)
{	//Change Disk and Path to home
	setdisk(CurDisk);
	chdir(CurPath);
}
/////////////////// Make 32 Bits Segment /////////
typedef	struct	DESCtag
	{
	WORD	LimitLW;
	WORD	BaseLW;
	BYTE 	BaseHB;
	BYTE	Access;
	BYTE	ExtAccess;
	BYTE	BaseHH;
	}DESC;
WORD	YUVRGB32Selector=0;
void	Selector16To32(WORD Sel)
{
	DESC	Desc;
	_ES=FP_SEG(&Desc);
	_DI=FP_OFF(&Desc);
	_BX=Sel;
	_AX=0x0B;
	geninterrupt(0x31);	//Get Desc
	Desc.ExtAccess|=0x40;	//Set D bit
	_ES=FP_SEG(&Desc);
	_DI=FP_OFF(&Desc);
	_BX=Sel;
	_AX=0x0C;
	geninterrupt(0x31);	//Set Desc
}
void	Selector32To16(WORD Sel)
{
	DESC	Desc;
	_ES=FP_SEG(&Desc);
	_DI=FP_OFF(&Desc);
	_BX=Sel;
	_AX=0x0B;
	geninterrupt(0x31);	//Get Desc
	Desc.ExtAccess&=0xBF;	//Clear D  Bit
	_ES=FP_SEG(&Desc);
	_DI=FP_OFF(&Desc);
	_BX=Sel;
	_AX=0x0C;
	geninterrupt(0x31);	//Set Desc
}
void	MakeYUVRGB32Segment(void)
{
	YUVRGB32Selector=FP_SEG(DrawUYVY);
	Selector16To32(YUVRGB32Selector);
}
void	RestoreYUVRGB32Segment(void)
{
	Selector32To16(YUVRGB32Selector);
}
int	Run=0;
DWORD	RunStart=0;
DWORD	RunEnd=0;
extern	char	VideoName[][80];	// Video File Name.
static	int	ParaFile(void)
{
	int	Len;
	FILE	*fp;

	Len=lstrlen(VideoName[0]);
	if(VideoName[0][Len-3]|0x20=='t' &&
	   VideoName[0][Len-2]|0x20=='x' &&
	   VideoName[0][Len-1]|0x20=='t')
		{
		int	i;
		Len=0;
		fp=fopen(VideoName[0],"rt");
		if(fp==NULL) return 0;
		while(fgets(VideoName[Len],80,fp)!=NULL) Len++;
		fclose(fp);
		for(i=0;i<Len;i++)
			{
			int	l;
			l=lstrlen(VideoName[i]);
			if(VideoName[i][l-1]==0x0A) VideoName[i][l-1]=0;
			if(VideoName[i][l-1]==0x0D) VideoName[i][l-1]=0;
			}
		return Len;
		}
	else	return 1;
}
static	int	HandleCmdLine(LPSTR lpszCmdLine)
{
	int	i;
	int	j;
	int	Ret=0;
	char	Str[32];
	i=1;
	if(lpszCmdLine[i]==0) return Ret;
	while(lpszCmdLine[i]==' ')
		{
		if(lpszCmdLine[i]==0) return Ret;
		i++;
		}
	j=0;
	while(lpszCmdLine[i]!=' ')
		{
		VideoName[0][j]=lpszCmdLine[i];
		if(lpszCmdLine[i]==0) break;
		i++;
		j++;
		}
	VideoName[0][j]=0;
	Ret=ParaFile();
	if(Ret!=1) return Ret;
	if(lpszCmdLine[i]==0) return Ret;
	//////////// Start Time ////////////
	while(lpszCmdLine[i]==' ')
		{
		if(lpszCmdLine[i]==0) return Ret;
		i++;
		}
	j=0;
	while(lpszCmdLine[i]!=' ')
		{
		Str[j]=lpszCmdLine[i];
		if(lpszCmdLine[i]==0) break;
		i++;
		j++;
		}
	Str[j]=0;
	RunStart=atol(Str);
	if(lpszCmdLine[i]==0) return Ret;
	//////////// End Time   ////////////
	while(lpszCmdLine[i]==' ')
		{
		if(lpszCmdLine[i]==0) return Ret;
		i++;
		}
	j=0;
	while(lpszCmdLine[i]!=' ')
		{
		Str[j]=lpszCmdLine[i];
		if(lpszCmdLine[i]==0) break;
		i++;
		j++;
		}
	Str[j]=0;
	RunEnd=atol(Str);
	return Ret;
}
static	void	SeekVideoTo(int VideoID,HWND hwnd,DWORD Position)
{
	MCI_SEEK_PARMS	mciSeek;

	mciSeek.dwCallback=hwnd;
	mciSeek.dwTo=Position;
	mciSendCommand(VideoID,MCI_SEEK,MCI_TO,(DWORD)(LPVOID)&mciSeek);
}
int	TestMode=0;
static	void	DeleteSTHMPEGMCI(void)
{
	WritePrivateProfileString("mci","STHMPEG",NULL,"system.ini");
}
int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance,
			LPSTR lpszCmdLine,int nCmdShow)
{
	static char szAppName[]="Southern Soft VCD Player";
	WNDCLASS 	wndclass;
	MSG		msg;
	HWND		hWnd;
	RECT		Rc;
	BITMAP		bm;
	UINT		ErrorMode;
	HDC		hdc;
	int		LineW;

	if(hPrevInstance) return 0;	//Can't Run two times.
	DeleteSTHMPEGMCI();
	GetHome();	//Get Cur Disk and Path
	hdc=GetDC(NULL);
	WindowsColorBits=GetDeviceCaps(hdc,BITSPIXEL);
	ReleaseDC(NULL,hdc);
	//////////////////////////
	Chinese=GetSystemMetrics(SM_DBCSENABLED);//In Chinese Windows
	//////////Serial ID///////
	hWnd=CheckSerialInstall();
	if(hWnd==1)
		{// Not Install
		if(Chinese) MessageBox(NULL,"此软件没安装.\n请先安装 !","无法运行",MB_OK);
		else MessageBox(NULL,"This software had not installed.\nPlease Setup at first !","Can't RUN",MB_OK);
		return 0;
		}
	if(hWnd==2)
		{// Installed but be copy the next PC
		KillCopy();
		if(Chinese) MessageBox(NULL,"此乃受法律保护产品你不应复制到别的机器.","非法产品",MB_OK);
		else MessageBox(NULL,"You Can not copy this lawful software to another PC.","Not Lawful Product",MB_OK);
		return 0;
		}
	if(hWnd==3)
		{// Had been rename
		if(Chinese) MessageBox(NULL,"此软件已被破坏 !","无法运行",MB_OK);
		else MessageBox(NULL,"The Software be destroy !","Not RUN",MB_OK);
		return 0;
		}
	if(hWnd==4)
		{// Had been rename
		KillCopy();
		if(Chinese) MessageBox(NULL,"此软件关键数据被非法改动\n继续运行会死机 ! 请重装. ","无法运行",MB_OK);
		else MessageBox(NULL,"The Software's data be Modify \nif continue will be ERROR !\n Please reinstall .","Not RUN",MB_OK);
		return 0;
		}
	//////////////////////////
	if(GetAPIEntry(0x0543)==NULL)
		{
		if(Chinese) MessageBox(NULL,"没安装加速 VXD","错误",MB_OK);
		else MessageBox(NULL,"Not Install Accelerator VXD","Error",MB_OK);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -