Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[18.190.207.144] |
|
Сообщ.
#1
,
|
|
|
Не получается. Программа не может зарегистрировать драйвер. Invalid файл драйвера.
Сейчас в тексте программы сделана загрузка драйвера штатным способом в дополнение к включению в ехешник. При попытке отключить загрузку - ошибка. Скрытый текст Program Space; Uses Dos,CRT,Graph; const centrx=300; centry=160; Var ch:char; procedure EgaVgaDriverProc; external; {$L EGAVGA.OBJ} procedure vretrace; begin repeat until port [$3da] and 8=0; repeat until port [$3da] and 8>0; end; procedure game; var ZemX, ZemY,MercX,MercY,MarsX,MarsY,VenerX,VenerY,UpiterX,UpiterY,SatX,SatY:integer; VisualPage,i:Integer; begin repeat SetVisualPage(1-VisualPage); VisualPage := VisualPage+1; SetActivePage(1 -VisualPage); vretrace; ClearDevice; For i := 1 to 100 do PutPixel(centrx+Round(70*cos((i+VisualPage/9)*Pi/50+0.7)), centry+Round(60*sin((i+VisualPage/9)*Pi/50-Pi/500)),1); For i := 1 to 100 do PutPixel(centrx+Round(90*cos((i+visualpage/7)*Pi/50+0.7)), centry+Round(83*sin((i+visualpage/7)*Pi/50-Pi/500)),2); For i := 1 to 100 do PutPixel(centrx+Round(110*cos((i+VisualPage/7)*Pi/50+0.65)), centry+Round(100*sin((i+VisualPage/7)*Pi/50-Pi/500)),3); For i := 1 to 100 do PutPixel(centrx+Round(131*cos((i+VisualPage/7)*Pi/50+0.65)), centry+Round(120*sin((i+VisualPage/7)*Pi/50-Pi/500)),4); For i := 1 to 100 do PutPixel(centrx+Round(173*cos((i+VisualPage/5)*Pi/50+0.70)), centry+Round(155*sin((i+VisualPage/5)*Pi/50-Pi/500)),5); For i := 1 to 100 do PutPixel(centrx+Round(212*cos((i+VisualPage/5)*Pi/50+0.65)), centry+Round(195*sin((i+VisualPage/5)*Pi/50-Pi/500)),6); {--------------------------------------------------------------} {mercury} MercX :=centrx-Round(70*cos((i-VisualPage/5)*Pi/50+0.7)); MercY:=centry-Round(60*sin((i-VisualPage/5)*Pi/50-Pi/500)); setcolor(lightgray); circle(MercX,MercY,4); SetFillStyle(1,LightGray); floodfill(MercX,MercY,lightgray); outtextxy(MercX-13,MercY-8,'1'); {---------------------------------------------------------------} {venera} VenerX :=centrx-Round(90*cos((i-VisualPage/4)*Pi/50+0.7)); VenerY:=centry-Round(83*sin((i-VisualPage/4)*Pi/50-Pi/500)); setcolor(lightred); circle(VenerX,VenerY,7); SetFillStyle(1,Lightred); floodfill(VenerX,VenerY,lightred); outtextxy(VenerX-13,VenerY-10,'2'); {-----------------------------------------------------------------} {zemlia} ZemX:=centrX+Round(110*cos((i-VisualPage/3)*Pi/50+0.65)); ZemY:=centrY+Round(100*sin((i-1-VisualPage/3)*Pi/50-Pi/500)); setcolor(lightblue); circle(ZemX,ZemY,7); SetFillStyle(1,Lightblue); setcolor(2); circle(ZemX,ZemY,7); SetFillStyle(1,2); floodfill(ZemX,ZemY,2); setcolor(blue); circle(zemx+1,zemy+1,3); SetFillStyle(1,blue); floodfill(ZemX,ZemY,blue); circle(zemx+3,zemy-3,2); SetFillStyle(1,blue); floodfill(ZemX+3,ZemY-3,blue); circle(zemx-4,zemy-4,2); SetFillStyle(1,blue); floodfill(ZemX-4,ZemY-4,blue); setcolor(2); outtextxy(ZemX-13,ZemY-10,'3'); {-----------------------------------------------------------------} MarsX:=Centrx+Round(131*cos((i-VisualPage/2)*Pi/50+0.65)); MarsY:=Centry+Round(120*sin((i-VisualPage/2)*Pi/50-Pi/500)); setcolor(6); circle(MarsX,MarsY,4); SetFillStyle(1, 6); floodfill(MarsX,MarsY,6); outtextxy(Marsx-11,MarsY-1,'4'); {---------------------------------------------------------------------} {Upiter} UpiterX:=Centrx+Round(173*cos((i-VisualPage/1)*Pi/50+0.7)); UpiterY:=Centry+Round(155*sin((i-VisualPage/1)*Pi/50-Pi/500)); setcolor(6); circle(UpiterX,UpiterY,12); SetFillStyle(1, 6); floodfill(UpiterX,UpiterY,6); outtextxy(Upiterx-15,UpiterY+10,'5'); {---------------------------------------------------------------------} {Saturn} SatX:=Centrx+Round(212*cos((i-VisualPage/5)*Pi/50+0.65)); SatY:=Centry+Round(195*sin((i-VisualPage/5)*Pi/50-Pi/500)); setcolor(9); circle(SatX,SatY,12); setfillstyle(1,9); floodfill(SatX,SatY,9); setcolor(13); ellipse(Satx,Saty-1,29,20,28,5); outtextxy(Satx-22,SatY+10,'6'); setcolor(9); line(satx-10,saty-6,satx+10,saty-6); {---------------------------------------------------------------------} {solnce} setcolor(yellow); circle(300,160,30); SetFillStyle(1, yellow); floodfill(300,160,yellow); For i := 1 to 100 do line(300,160,centrx+Round(31*cos((i+VisualPage/2)*Pi/50)),centry+Round(25*sin((i+VisualPage/2)*Pi/50-Pi/500))); {----------------------------------------------------------------} OutTextXY(centrx+215,centry+20,'Planets'); OutTextXY(centrx+200,centry+35,'1 - Mercury'); OutTextXY(centrx+200,centry+50,'2 - Venera'); OutTextXY(centrx+200,centry+65,'3 - Earth'); OutTextXY(centrx+200,centry+80,'4 - Mars'); OutTextXY(centrx+200,centry+95,'5 - Upiter'); OutTextXY(centrx+200,centry+110,'6 - Saturn'); until keyPressed end; Procedure MainMenu; Const menu:array[1..2] of string[20]=('New game!','Exit'); Var i,y1: integer; pos:byte; kb:char; Begin kb:=#1; SetTextStyle(4,0,2); pos:=1; y1:=centry-30; for i:=1 to 2 do begin if i=pos then begin setcolor(1); OutTextXY(230,y1,'New game!'); end else begin setcolor(15); OutTextXY(230,y1,'Exit'); end; y1:=y1+30; end; repeat y1:=centry-30; kb:=readkey; case kb of #72:if pos>1 then Dec(pos) else pos:=3; #80:if pos<2 then Inc(pos) else pos:=1; end; for i:=1 to 2 do begin if i=pos then begin setcolor(1); OutTextXY(230,y1,menu[i]); end else begin setcolor(15); OutTextXY(230,y1,menu[i]); end; y1:=y1+30; end; until kb=#13; begin if pos=1 then begin game; cleardevice; end; if pos=2 then halt; end; end; procedure grinit; var GrMode, GrError,GrDriver:Integer; {for graphic driver} Driver, Mode: Integer; DriverF: file; DriverP: pointer; begin Assign(DriverF, 'EGAVGA.BGI'); Reset(DriverF, 1); GetMem(DriverP, FileSize(DriverF)); BlockRead(DriverF, DriverP^, FileSIze(DriverF)); if RegisterBGIdriver(DriverP) < 0 then begin WriteLn('Error registering driver: ', GraphErrorMsg(GraphResult)); Halt(1); end; Driver := EGA; Mode := EGAHi; InitGraph(Driver, Mode,' '); if GraphResult < 0 then Halt(1); end; BEGIN Grinit; MainMenu; END. |
Сообщ.
#2
,
|
|
|
Сначала получить obj:
binobj.exe egavga.bgi egavga EGAVGADriverProc Потом в тексте программы или модуля PROCEDURE EgaVgaDriverProc; external; {$L EGAVGA.OBJ } Потом регистрация драйвера и использование ........... if RegisterBGIdriver(@EGAVGADriverProc) < 0 then begin ............. {действия при ошибке регистрации драйвера} ............. end; ............. GraphDriver := Detect; { автоопределение } InitGraph(GraphDriver, GraphMode, ''); { инициализация } if GraphResult <> grOk { с ошибкой ? } then begin Writeln('Ошибка инициализации графики: ', GraphErrorMsg(GraphDriver)); Halt(1); end; ............. |
Сообщ.
#3
,
|
|
|
Я сделал registerBgiDriver(@EgaVgaProc); Всё работает
А в вашем примере прога всё равно будет искать внешний bgi драйвер игнорируя что он уже в ехешнике прилинкован. |
Сообщ.
#4
,
|
|
|
Да, будет, только потому, что
GraphDriver := Detect; { автоопределение } У меня уже нет Turbo, а этот кусок кода привёл из какой-то своей программы, к которой линковал 2-3 драйвера и запускал на других машинах. Хотя, уже прошло 10 лет, могу и ошибаться... Цитата Ivanhoe75 @ А в моём примере нет такой строки? Тогда в чём разница кроме GraphDriver := Detect; Я сделал registerBgiDriver(@EgaVgaProc); Всё работает |