📄 main.c
字号:
return 0;
}
ComputePalette();
VESAColor=TestVESASupport();
if(VESAColor==8)
VESAColor=TestSupportCard();//Test S3 or GD542x
if(VESAColor==0)
{
if(Chinese) MessageBox(NULL,"非 VGA 显示卡.\n请买一个吧.\n象这种显示卡你要放VCD ?!没趣 !","错误",MB_OK);
else MessageBox(NULL,"Not any VGA.\nPlease Buy one.\nAs this Display Card You want to play VCD ?!Not fun !","Error",MB_OK);
return 0;
}
///////////////////////////
if(LoadDriverVideoAndAudio()==0)
{//Load DCI Accelector
FreeDriverVideoAndAudio();
return 0;
}
CheckErrorDCICall(); //May be the VGA not support DCI,se call will error.
UseDCI=SearchDCISupportFunction();
//////// cmd line ////////
if((lpszCmdLine[0]|0x20)=='r') Run=1; //Only Run the file.
//////// Force mode ///////
if((lpszCmdLine[0]|0x20)=='b')
{//Focre Gray scale mode
VESAColor=88;
if(UseDCI==1)
{
DeleteDCISurface();
ReleaseDCIProvider();
}
UseDCI=DCIType=0;
}
if((lpszCmdLine[0]|0x20)=='l')
{//Focre 320x200 64K/32K mode
if(VESAColor==16 || VESAColor==15 || VESAColor==163)
{
if(UseDCI==1)
{
if(UseDCI==1)
{
DeleteDCISurface();
ReleaseDCIProvider();
}
UseDCI=DCIType=0;
}
}
else {
}
}
if((lpszCmdLine[0]|0x20)=='h' && DCIType!=2)
{//Focre 640x480 64KC high res mode
VESAColor=864;
if(DCIType)
{
DCIPlay=DCIPrimaryColorBits(VESAColor);
if(DCIPlay!=8) //As VESAColor
{
DCIPlay=1; //640x480 DCI Primary play
}
else {//With BIOS 640x480 mode.
DeleteDCISurface();
ReleaseDCIProvider();
UseDCI=DCIType=0;
VideoCardType=SubType=0;//Not S3 and GD intra support
}
}
else {//With BIOS
UseDCI=DCIType=0;
VideoCardType=SubType=0;//Not S3 and GD intra support
}
}
///////////////////////////
if(UseDCI==1)
{//Offscreen
if(DCIType==2)
{
if(VESAColor==8)
{
}
DCIPlay=1;
VESAColor=128;//support YUV->RGB
GetWindowRect(GetDesktopWindow(),&VideoRc); //Get Windows size;
////////// Set Cliplist //////////
RgnData.rdh.dwSize=0x20;
RgnData.rdh.rcBound.left=VideoRc.left;
RgnData.rdh.rcBound.top=VideoRc.top;
RgnData.rdh.rcBound.right=VideoRc.right;
RgnData.rdh.rcBound.bottom=VideoRc.bottom;
}
else {//Primary
goto SearchHowDisplay;
}
}
else {
SearchHowDisplay:
if(VESAColor==8)
{//DCI primary.
if(UseDCI==1)
VESAColor=DCIPrimaryColorBits(VESAColor);
if(VESAColor!=8)
{
DCIPlay=1; //640x480 DCI Primary play
}
}
if(VESAColor==8)
{
if(M640x48064KC) VESAColor=64;
else if(M640x48032KC) VESAColor=32;
if(VESAColor!=8)
{
}
}
if(VESAColor==8)
{
}
}
//////////////////////////
switch(VESAColor)
{
case 88:VESAColor=8; //Force Gray scale
case 8:LineW=320;break;
case 163: //S3 86xx banking
case 15:
case 16:LineW=640;break;
case 24:LineW=960;break;
case 864://Force 640x480 64K mode
if(M640x48064KC) VESAColor=64;
else if(M640x48032KC) VESAColor=32;
if(UseDCI) VESAColor=DCIPrimaryColorBits(VESAColor);
case 32:
case 64:LineW=1280;break;
case 128:LineW=0;break;//YUV
}
if(SetDCI(320,200,LineW,VESAColor)==0)
{
if(Chinese) MessageBox(NULL,"没有足够内存分配视频影子缓冲区.","错误",MB_OK);
else MessageBox(NULL,"Had no memory to allocate Video shadow buffer.","Error",MB_OK);
return 0;
}
MakeYUVRGB32Segment();
//////////////////////////
AllocateVideoStateBuffer(); //Allocate Video State buffer
SetAVITypeZoomBy2AndWindow();
CreateINIFile();
if((lpszCmdLine[0]|0x20)=='t' || (lpszCmdLine[1]|0x20)=='t')
{//Run on Test mode.
TestMode=1;
SetProfileRate(0);
}
BuildSTHMPEGTypeMCI();
//////////////////////////
if(!hPrevInstance)
{
wndclass.style =CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc =(WNDPROC)WndProc;
wndclass.cbClsExtra =0;
wndclass.cbWndExtra =0;
wndclass.hInstance =hInstance;
wndclass.hIcon =LoadIcon(hInstance,"ACD");
wndclass.hCursor =LoadCursor(hInstance,"POSCUR");//LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.lpszMenuName =NULL;
wndclass.lpszClassName =szAppName;
RegisterClass(&wndclass);
}
hInst=hInstance;
////////// Control Window ////////
GetWindowRect(GetDesktopWindow(),&Rc); /* Get DeckTop size. */
/////////////// LOGO Window ///////////
VCDFACE=LoadBitmap(hInstance,"LOGO");
GetObject(VCDFACE,sizeof(BITMAP),&bm);
AboutWindow=CreateWindow(szAppName,szAppName,
WS_POPUP|WS_BORDER,
(Rc.right-Rc.left)/2-bm.bmWidth/2,
(Rc.bottom-Rc.top)/2-bm.bmHeight/2,
bm.bmWidth,
bm.bmHeight,
NULL,
NULL,
hInstance,
NULL);
SetWindowPos(AboutWindow,HWND_TOPMOST,
(Rc.right-Rc.left)/2-bm.bmWidth/2,
(Rc.bottom-Rc.top)/2-bm.bmHeight/2,
bm.bmWidth,
bm.bmHeight,
SWP_SHOWWINDOW);
hdc=GetDC(AboutWindow);
DrawBitmap(hdc,VCDFACE,0,0);
ReleaseDC(AboutWindow,hdc);
DeleteObject(VCDFACE);
////////////// Start Time counter /////////
SetTimer(AboutWindow,3838,1000,(TIMERPROC)TimerProc);
////////////////// Main Window ////////////
VCDFACE=LoadBitmap(hInstance,"VCD");
GetObject(VCDFACE,sizeof(BITMAP),&bm);
DeleteObject(VCDFACE);
MainWindow=hWnd=CreateWindow(szAppName,szAppName,
WS_POPUP,
(Rc.right-bm.bmWidth)/2,(Rc.bottom-Rc.top)/2,
bm.bmWidth,bm.bmHeight,
NULL,NULL,hInstance,NULL);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
ShowVideo=CreateWindow(szAppName,szAppName,
WS_CHILD,
47,24,
64,56,
hWnd,NULL,hInstance,NULL);
ShowWindow(ShowVideo,SW_SHOW);
UpdateWindow(ShowVideo);
//////////// Create Video Windows //////////
VideoWindow=CreateWindow(szAppName,"Video CD",
WS_POPUP,
0,0,
Rc.right-Rc.left,
Rc.bottom-Rc.top, //Clear screen
MainWindow,NULL,hInstance,NULL);
ShowWindow(VideoWindow,SW_HIDE);
UpdateWindow(VideoWindow);
/////////// Create Audio Windows /////////////
CreateAudioWindow(hInstance,MainWindow);
//////////////////////////////////////////////
LoadVideoDecoder();
//////////////////////////////////////////////
ErrorMode=SetErrorMode(SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS);
//////////////////
SetProfileRate(1); // Normal Speed
if(Run) {//Only Run the file.
VideoNumber=HandleCmdLine(lpszCmdLine);
if(VideoNumber==0) goto SEARCHCDROM;
}
else {///////// CDROM //////
SEARCHCDROM:
DrvNum=CheckCDROMEX();
if(DrvNum>1) GetCDROMName(DrvNum);
if(DrvNum)
{// Search All VCD File.
VideoNumber=SearchVideoFile();
}
}
if(VideoNumber) InitVideoState();
//////////////////
CurFileNum=0;
if(VideoNumber) OpenVideo(MainWindow,CurFileNum);//Open VCD at start.
//////////////////
if(videoID!=-1)
{
if(CurVideoType)SetVideoWindow(videoID,ShowVideo,MainWindow);
UpDateVideo(videoID,MainWindow);
PlayType=0; //VCD Type.
}
else PlayType=1; //MCI Type.
if(Run && VideoNumber==1 && videoID!=-1)
{//Seek to start
if(RunStart) SeekVideoTo(videoID,MainWindow,RunStart);
}
//////////////////////////
hdc=GetDC(MainWindow);
DrawAllStatus(hdc);
DrawPlayType(hdc);
ReleaseDC(MainWindow,hdc);
//////////////////////////
if(VideoNumber)
{
CurrentPos=GetAllVideoPosition();
if(CurrentPos<0)DisplayErrorMessage(LOWORD(CurrentPos),hWnd);
}
DisplayTime(CurrentPos);
if(Run) {//Start Run
KillTimer(AboutWindow,3838);
DestroyWindow(AboutWindow);//Delete in TimerProc
TimeStart=-1;
PostMessage(MainWindow,WM_KEYDOWN,VK_SPACE,0L);
PostMessage(MainWindow,WM_KEYUP,VK_SPACE,0L);
}
/////////////////// Start up OK ///////////
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
SetErrorMode(ErrorMode);
///////////////////////
FreeVideoDecoder();
///////////////////////
RestoreAVIZoomBy2AndWindow();
ReleaseDCI(); //No Hook DCI.
if(UseDCI==1 && OtherDecoder==0 && DCIType==2)
{
DeleteDCISurface();
ReleaseDCIProvider();
}
DeleteIniFile(); //Delete INI File Comment.
FreeDriverVideoAndAudio(); //Free STHMPEG Files.
FreeVideoStateBuffer(); //Free Video State buffer
if(PreviewhPal) DeleteObject(PreviewhPal);
RestoreYUVRGB32Segment();
DeleteSTHMPEGMCI();
////////////////////////
return msg.wParam;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -