openpip.pas 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. Program OpenPIP;
  2. { ***********************************************************************
  3. * This is an example that shows how to open a p96 PIP Window
  4. * to get input events and how to paint in that window.
  5. *
  6. *********************************************************************** }
  7. {
  8. Translated to fpc pascal.
  9. 3 Mars 2001.
  10. Updated for fpc 1.0.7
  11. 08 Jan 2003.
  12. [email protected]
  13. }
  14. uses exec, amigados, agraphics, intuition, picasso96api, utility,strings;
  15. Const
  16. WB : Pchar = 'Workbench';
  17. template : Pchar = 'Width=W/N,Height=H/N,Pubscreen=PS/K';
  18. vecarray : Array[0..2] of long = (0,0,0);
  19. ltrue : longint = 1;
  20. Var
  21. PubScreenName : Array [0..80] Of Char;
  22. height,
  23. width : longint;
  24. wd : pWindow;
  25. imsg : pIntuiMessage;
  26. goahead : Boolean;
  27. rp : pRastPort;
  28. x,
  29. y : Word;
  30. rda : pRDArgs;
  31. Begin
  32. if not Assigned(P96Base) then
  33. begin
  34. writeln('Cannot open ', PICASSO96APINAME);
  35. Halt(5);
  36. end;
  37. width := 256;
  38. height := 256;
  39. StrCopy(@PubScreenName,WB);
  40. rda:=ReadArgs(template,@vecarray,Nil);
  41. If rda<>Nil Then Begin
  42. If vecarray[0] <> 0 then width := long(@vecarray[0]);
  43. If vecarray[1] <> 0 then height := long(@vecarray[1]);
  44. If vecarray[2] <> 0 then StrCopy(@PubScreenName,@vecarray[2]);
  45. FreeArgs(rda);
  46. End;
  47. wd := p96PIP_OpenTags([P96PIP_SourceFormat, long(RGBFB_R5G5B5),
  48. P96PIP_SourceWidth,256,
  49. P96PIP_SourceHeight,256,
  50. WA_Title, AsTag('Picasso96 API PIP Test'),
  51. WA_Activate,lTRUE,
  52. WA_RMBTrap,lTRUE,
  53. WA_Width,Width,
  54. WA_Height,Height,
  55. WA_DragBar, lTRUE,
  56. WA_DepthGadget,lTRUE,
  57. WA_SimpleRefresh,lTRUE,
  58. WA_SizeGadget,lTRUE,
  59. WA_CloseGadget,lTRUE,
  60. WA_IDCMP,IDCMP_CLOSEWINDOW,
  61. WA_PubScreenName, AsTag(@PubScreenName),
  62. TAG_DONE]);
  63. If wd <> Nil Then Begin
  64. goahead:=True;
  65. rp:=Nil;
  66. p96PIP_GetTags(wd,[P96PIP_SourceRPort, AsTag(@rp), TAG_END]);
  67. If rp<>Nil Then Begin
  68. For y:=0 To (Height-1) Do
  69. For x:=0 To (Width-1) Do
  70. p96WritePixel (rp,x,y,(x*256+y)*256);
  71. End Else Writeln ('No PIP rastport.');
  72. While goahead Do Begin
  73. WaitPort (wd^.UserPort);
  74. imsg := pIntuiMessage(GetMsg (wd^.UserPort));
  75. While imsg<>Nil Do Begin
  76. If imsg^.IClass=IDCMP_CLOSEWINDOW Then goahead:=False;
  77. ReplyMsg (pMessage(imsg));
  78. imsg:=pIntuiMessage(GetMsg (wd^.UserPort));
  79. End;
  80. End;
  81. p96PIP_Close(wd);
  82. End Else Writeln ('Unable to open PIP.');
  83. End.