📄 m2c.pas
字号:
program Mpeg_to_C(input,output);
uses
dos;
const
blk:string=' ';
var
f1:file;
f2:text;
ts,s1,s2:string;
sy,sm,sd:string;
buffer:array [1..1024] of byte;
i,j,k,w:word;
dir:dirstr;
name:namestr;
ext:extstr;
b1,b2:byte;
c1,c2:char;
year,month,day,week:word;
begin
if paramcount=0 then
begin
writeln('Usage: M2C filename[.MPG]');
writeln;
halt(1);
end;
s1:=paramstr(1);
for i:=1 to length(s1) do s1[i]:=upcase(s1[i]);
fsplit(s1,dir,name,ext);
if ext = '' then ext:='.MPG';
s1:=dir+name+ext;
assign(f1,s1);
reset(f1,1);
if IOresult<>0 then
begin
writeln('File '+s1+' not found.');
writeln;
halt(2);
end;
s2:=dir+'TITLE.C';
assign(f2,s2);
rewrite(f2);
if IOresult<>0 then
begin
writeln('Cannot create destination file '+s2);
writeln;
halt(3);
end;
blk[0]:=chr(8-length(name));
getdate(year,month,day,week);
str(year:4,sy);
str(month:2,sm); if sm[1]=' ' then sm[1]:='0';
str(day:2,sd); if sd[1]=' ' then sd[1]:='0';
ts:=sy+'.'+sm+'.'+sd;
writeln(f2,'/*----------------------------------------------*/');
writeln(f2,'/* Sunplus SPCA702A Title image */');
writeln(f2,'/* */');
writeln(f2,'/* Generated from '+blk+name+ext+' '+ts+' */');
writeln(f2,'/* Copyright 1999-2000 by Sunny Technology(SZ). */');
writeln(f2,'/*----------------------------------------------*/');
writeln(f2);
writeln(f2,'const unsigned char VCDTitleS [] = {');
repeat
blockread(f1,buffer,1024,w);
i:=0;
for i:=1 to (w div 16) do
begin
for j:=1 to 16 do
begin
b1:=buffer[(i-1)*16+j]; b2:=b1 and $0f; b1:=b1 shr 4;
if b1<$0a then b1:=b1+$30 else b1:=b1+$57;
if b2<$0a then b2:=b2+$30 else b2:=b2+$57;
c1:=chr(b1); c2:=chr(b2);
write(f2,'0x'+c1+c2+',');
end;
writeln(f2);
end;
for k:=1 to (w mod 16) do
begin
b1:=buffer[i*16+k]; b2:=b1 and $0f; b1:=b1 shr 4;
if b1<$0a then b1:=b1+$30 else b1:=b1+$57;
if b2<$0a then b2:=b2+$30 else b2:=b2+$57;
c1:=chr(b1); c2:=chr(b2);
write(f2,'0x'+c1+c2+',');
end;
if (w mod 16)<>0 then writeln(f2);
until eof(f1);
writeln(f2,'};');
close(f1);
close(f2);
writeln('OK!');
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -