Created
January 11, 2021 12:59
-
-
Save Zaaphod/936901eb5f31df5044d2bd36a7cf6c91 to your computer and use it in GitHub Desktop.
Sample program to show errors with PTCGraph and PTCCRT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{$H+} | |
Program Animation_Test; | |
Uses | |
Windows,ptcgraph,ptccrt,crt; | |
Type | |
TSmallBitmapBuffer = packed record | |
width, | |
height, | |
reserved: longint; | |
data: array[0..40000] of word; | |
end; | |
Var | |
winMax_X,winMax_Y:Word; | |
ConsoleWindow,GraphicWindow:Handle; | |
WindowXResolution,WindowYResolution,WindowXPos,WindowYPos:Integer; | |
Initialrect :trect; | |
ConsoleTitle :Pchar = 'Production Automation Console'; | |
GraphTitle :Pchar = 'Production Automation Graphics Test'; | |
Ball,Unball : Tsmallbitmapbuffer; | |
I:Integer; | |
{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=} | |
Procedure Windowsgraphtitle(wintitletouse:pchar); | |
Begin | |
SetWindowTextA(graphicwindow,wintitletouse); | |
End; | |
{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=} | |
Procedure Windowsconsoletitle(wintitletouse:pchar); | |
Begin | |
SetConsoleTitle(wintitletouse); | |
End; | |
{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=} | |
Procedure MoveWindowPosition; | |
Begin | |
SetWindowPos(Graphicwindow,HWND_TOP,WindowXPos,WindowYPos,0,0,SWP_NoSize); | |
End; | |
{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=} | |
Procedure WindowsGRAPHINIT; | |
Var | |
gd,gm:smallint; | |
m: PModeInfo; | |
graphinitialize,MaxX,MaxY:Integer; | |
Begin | |
Windowtitle:='ptcgraph'; | |
graphinitialize:=1234; | |
MaxX:=0; | |
MaxY:=0; | |
m := QueryAdapterInfo; | |
while m <> nil do | |
begin | |
If m^.MaxX+1>MaxX then | |
MaxX:=m^.MaxX+1; | |
If m^.MaxY+1>MaxY then | |
MaxY:=m^.MaxY+1; | |
m := m^.next; | |
end; | |
Writeln ('Max resolution:',MaxX,'x',MaxY,' Window Resolution:',WindowXResolution,'x',WindowYResolution); | |
gd:=VESA; | |
gm:=InstallUserMode(WindowXResolution,WindowYResolution,65536,1,10000,10000); | |
If gm<0 Then | |
Begin | |
Writeln('Error Installing Graphics ',gm,' ',grapherrormsg(gm)); | |
Halt(70); | |
End; | |
PtcGraph.InitGraph(gd,gm,''); | |
Graphinitialize:=graphresult; | |
If graphinitialize = 1234 Then | |
Begin | |
Writeln('Error: Mode not found - Graphics not initialized'); | |
Halt(70); | |
End; | |
GraphicWindow:=FindWindow(nil,Pchar(Windowtitle+#0#0)); | |
Sleep(60); | |
Windowsgraphtitle(GraphTitle); | |
WinMax_X:=GetMaxX; | |
winMax_Y:=GetMaxY; | |
Write(winMax_X+1,' x ',winMax_Y+1); | |
GetWindowRect(GraphicWindow,initialrect); | |
SetWindowLongPTR(graphicwindow, GWL_STYLE, GetWindowLong(graphicwindow, GWL_STYLE) AND not(WS_SIZEBOX) And not(WS_Caption)); | |
ShowWindow(graphicwindow, SW_Minimize); | |
ShowWindow(graphicwindow, SW_Restore); | |
SetWindowPos(Graphicwindow,HWND_TOP,0,0,(WinMax_X+1),(WinMax_Y+1),0); | |
MoveWindowPosition; | |
End; | |
{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=} | |
function make_565(r ,g ,b : Byte ) : Word; | |
begin | |
make_565:= ((r and $1F ) shl 11 ) or ((g and $3F ) shl 5 ) or (b and $1F); | |
end; | |
{=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=} | |
begin | |
Windowsconsoletitle(ConsoleTitle); | |
Sleep(60); | |
ConsoleWindow:=FindWindow(nil,ConsoleTitle); | |
WindowXResolution:=1800; | |
WindowYResolution:=101; | |
WindowXPos:=50; | |
WindowYPos:=500; | |
WindowsGRAPHINIT; | |
ptcgraph.Getimage(0, 0, 100, 100,UnBall); | |
SetColor(make_565(64,255,0)); | |
SetFillStyle(SolidFill,make_565(64,255,0)); | |
fillElLipse(50,50,49,49); | |
ptcgraph.Getimage(0, 0, 100, 100,Ball); | |
ptcgraph.Putimage(I, 0,UnBall,NormaLpUT); | |
I:=-100; | |
Repeat | |
ptcgraph.Putimage(I, 0,Ball,NormaLpUT); | |
Inc(I); | |
If I>=WindowXResolution then | |
I:=-100; | |
ptcgraph.Putimage(I, 0,Ball,NormaLpUT); | |
Sleep(1); | |
//Until ptccrt.Keypressed; //Uncomment to show error on Keypressed | |
Until crt.Keypressed; //Uncomment to show error on PutImage | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment