mysticview.pas 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 2003 by Nils Sjöholm.
  5. member of the Amiga RTL development team.
  6. This is a unit for mysticview.library
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {
  14. History:
  15. First version of this unit.
  16. 16 Jan 2003.
  17. Changed startcode for unit.
  18. 12 Feb 2003.
  19. [email protected] Nils Sjoholm
  20. }
  21. {$mode objfpc}
  22. {$I useamigasmartlink.inc}
  23. {$ifdef use_amiga_smartlink}
  24. {$smartlink on}
  25. {$endif use_amiga_smartlink}
  26. UNIT MYSTICVIEW;
  27. INTERFACE
  28. USES Exec,graphics,utility,intuition;
  29. VAR MysticBase : pLibrary;
  30. const
  31. MYSTICVIEWNAME : PChar = 'mysticview.library';
  32. {
  33. $VER: mysticview.h 4.2 (1.6.99)
  34. mysticview.library definitions
  35. © 1997-99 TEK neoscientists
  36. }
  37. {
  38. Tags
  39. }
  40. const
  41. MVIEW_Dummy = TAG_USER + 765432;
  42. { left edge in rastport }
  43. MVIEW_DestX = MVIEW_Dummy + 1;
  44. { top edge in rastport }
  45. MVIEW_DestY = MVIEW_Dummy + 2;
  46. { width in rastport }
  47. MVIEW_DestWidth = MVIEW_Dummy + 3;
  48. { height in rastport }
  49. MVIEW_DestHeight = MVIEW_Dummy + 4;
  50. { background color }
  51. MVIEW_BackColor = MVIEW_Dummy + 5;
  52. { OBP_Precision (view.h) }
  53. MVIEW_Precision = MVIEW_Dummy + 6;
  54. { aspect mode - see definitions below }
  55. MVIEW_DisplayMode = MVIEW_Dummy + 7;
  56. { preview mode - see definitions below }
  57. MVIEW_PreviewMode = MVIEW_Dummy + 8;
  58. { a guigfx.library picture }
  59. MVIEW_Picture = MVIEW_Dummy + 9;
  60. { simple text line }
  61. MVIEW_Text = MVIEW_Dummy + 10;
  62. { static palette }
  63. MVIEW_StaticPalette = MVIEW_Dummy + 11;
  64. { dither activation mode (see below) }
  65. MVIEW_Dither = MVIEW_Dummy + 12;
  66. { histogram type }
  67. MVIEW_HSType = MVIEW_Dummy + 13;
  68. { screen aspect horizontal }
  69. MVIEW_ScreenAspectX = MVIEW_Dummy + 14;
  70. { screen aspect vertical }
  71. MVIEW_ScreenAspectY = MVIEW_Dummy + 15;
  72. { dither mode }
  73. MVIEW_DitherMode = MVIEW_Dummy + 16;
  74. { display cursor }
  75. MVIEW_ShowCursor = MVIEW_Dummy + 17;
  76. { zoom factor (0.1 ... 10) }
  77. MVIEW_Zoom = MVIEW_Dummy + 18;
  78. { x position (0 ... 1) }
  79. MVIEW_XPos = MVIEW_Dummy + 19;
  80. { y position (0 ... 1) }
  81. MVIEW_YPos = MVIEW_Dummy + 20;
  82. { rotation (0 ... 1) }
  83. MVIEW_Rotation = MVIEW_Dummy + 21;
  84. { do not use }
  85. MVIEW_AutoDither = MVIEW_Dummy + 22;
  86. { picture fully drawn }
  87. MVIEW_ReadySignal = MVIEW_Dummy + 23;
  88. { picture X inside the rastport }
  89. MVIEW_PictureX = MVIEW_Dummy + 24;
  90. { picture Y inside the rastport }
  91. MVIEW_PictureY = MVIEW_Dummy + 25;
  92. { picture Width inside the rastport }
  93. MVIEW_PictureWidth = MVIEW_Dummy + 26;
  94. { picture Height inside the rastport }
  95. MVIEW_PictureHeight = MVIEW_Dummy + 27;
  96. { indicate scrollability }
  97. MVIEW_DrawArrows = MVIEW_Dummy + 28;
  98. { show PIP layer }
  99. MVIEW_ShowPip = MVIEW_Dummy + 29;
  100. { text/grid color }
  101. MVIEW_TextColor = MVIEW_Dummy + 30;
  102. { color for pip-border, cursor, arrows... }
  103. MVIEW_MarkColor = MVIEW_Dummy + 31;
  104. { rastport semaphore (MV_Create() only) }
  105. MVIEW_RPSemaphore = MVIEW_Dummy + 32;
  106. { set task priority (MV_Create() only) }
  107. MVIEW_Priority = MVIEW_Dummy + 33;
  108. {
  109. Types
  110. }
  111. { image fits exactly into view }
  112. MVDISPMODE_FIT = 0;
  113. { image is fully visible }
  114. MVDISPMODE_KEEPASPECT_MIN = 1;
  115. { width or height is fully visible }
  116. MVDISPMODE_KEEPASPECT_MAX = 2;
  117. { the image aspect is ignored }
  118. MVDISPMODE_ONEPIXEL = 3;
  119. { aspect ratios are ignored }
  120. MVDISPMODE_IGNOREASPECT = 4;
  121. { no realtime refresh }
  122. MVPREVMODE_NONE = 0;
  123. { grid realtime refresh }
  124. MVPREVMODE_GRID = 1;
  125. { opaque realtime refresh }
  126. MVPREVMODE_OPAQUE = 2;
  127. { dithering on }
  128. MVDITHERMODE_ON = 0;
  129. { dithering off }
  130. MVDITHERMODE_OFF = 1;
  131. { auto dithering }
  132. MVDITHERMODE_AUTO = 2;
  133. FUNCTION MV_CreateA(screen : pScreen; a1arg : pRastPort; tags : pTagItem) : POINTER;
  134. PROCEDURE MV_Delete(mview : POINTER);
  135. PROCEDURE MV_DrawOff(mview : POINTER);
  136. FUNCTION MV_DrawOn(mview : POINTER) : BOOLEAN;
  137. PROCEDURE MV_GetAttrsA(mview : POINTER; tags : pTagItem);
  138. PROCEDURE MV_Refresh(mview : POINTER);
  139. PROCEDURE MV_SetAttrsA(mview : POINTER; tags : pTagItem);
  140. PROCEDURE MV_SetViewRelative(mview : POINTER; x : LONGINT; y : LONGINT);
  141. PROCEDURE MV_SetViewStart(mview : POINTER; x : LONGINT; y : LONGINT);
  142. {
  143. Functions and procedures with array of const go here
  144. }
  145. FUNCTION MV_Create(screen : pScreen; a1arg : pRastPort; const tags : Array Of Const) : POINTER;
  146. PROCEDURE MV_GetAttrs(mview : POINTER; const tags : Array Of Const);
  147. PROCEDURE MV_SetAttrs(mview : POINTER; const tags : Array Of Const);
  148. {You can remove this include and use a define instead}
  149. {$I useautoopenlib.inc}
  150. {$ifdef use_init_openlib}
  151. procedure InitMYSTICVIEWLibrary;
  152. {$endif use_init_openlib}
  153. {This is a variable that knows how the unit is compiled}
  154. var
  155. MYSTICVIEWIsCompiledHow : longint;
  156. IMPLEMENTATION
  157. uses
  158. {$ifndef dont_use_openlib}
  159. msgbox,
  160. {$endif dont_use_openlib}
  161. tagsarray;
  162. FUNCTION MV_CreateA(screen : pScreen; a1arg : pRastPort; tags : pTagItem) : POINTER;
  163. BEGIN
  164. ASM
  165. MOVE.L A6,-(A7)
  166. MOVEA.L screen,A0
  167. MOVEA.L a1arg,A1
  168. MOVEA.L tags,A2
  169. MOVEA.L MysticBase,A6
  170. JSR -030(A6)
  171. MOVEA.L (A7)+,A6
  172. MOVE.L D0,@RESULT
  173. END;
  174. END;
  175. PROCEDURE MV_Delete(mview : POINTER);
  176. BEGIN
  177. ASM
  178. MOVE.L A6,-(A7)
  179. MOVEA.L mview,A0
  180. MOVEA.L MysticBase,A6
  181. JSR -036(A6)
  182. MOVEA.L (A7)+,A6
  183. END;
  184. END;
  185. PROCEDURE MV_DrawOff(mview : POINTER);
  186. BEGIN
  187. ASM
  188. MOVE.L A6,-(A7)
  189. MOVEA.L mview,A0
  190. MOVEA.L MysticBase,A6
  191. JSR -054(A6)
  192. MOVEA.L (A7)+,A6
  193. END;
  194. END;
  195. FUNCTION MV_DrawOn(mview : POINTER) : BOOLEAN;
  196. BEGIN
  197. ASM
  198. MOVE.L A6,-(A7)
  199. MOVEA.L mview,A0
  200. MOVEA.L MysticBase,A6
  201. JSR -048(A6)
  202. MOVEA.L (A7)+,A6
  203. TST.W D0
  204. BEQ.B @end
  205. MOVEQ #1,D0
  206. @end: MOVE.B D0,@RESULT
  207. END;
  208. END;
  209. PROCEDURE MV_GetAttrsA(mview : POINTER; tags : pTagItem);
  210. BEGIN
  211. ASM
  212. MOVE.L A6,-(A7)
  213. MOVEA.L mview,A0
  214. MOVEA.L tags,A1
  215. MOVEA.L MysticBase,A6
  216. JSR -066(A6)
  217. MOVEA.L (A7)+,A6
  218. END;
  219. END;
  220. PROCEDURE MV_Refresh(mview : POINTER);
  221. BEGIN
  222. ASM
  223. MOVE.L A6,-(A7)
  224. MOVEA.L mview,A0
  225. MOVEA.L MysticBase,A6
  226. JSR -060(A6)
  227. MOVEA.L (A7)+,A6
  228. END;
  229. END;
  230. PROCEDURE MV_SetAttrsA(mview : POINTER; tags : pTagItem);
  231. BEGIN
  232. ASM
  233. MOVE.L A6,-(A7)
  234. MOVEA.L mview,A0
  235. MOVEA.L tags,A1
  236. MOVEA.L MysticBase,A6
  237. JSR -042(A6)
  238. MOVEA.L (A7)+,A6
  239. END;
  240. END;
  241. PROCEDURE MV_SetViewRelative(mview : POINTER; x : LONGINT; y : LONGINT);
  242. BEGIN
  243. ASM
  244. MOVE.L A6,-(A7)
  245. MOVEA.L mview,A0
  246. MOVE.L x,D0
  247. MOVE.L y,D1
  248. MOVEA.L MysticBase,A6
  249. JSR -078(A6)
  250. MOVEA.L (A7)+,A6
  251. END;
  252. END;
  253. PROCEDURE MV_SetViewStart(mview : POINTER; x : LONGINT; y : LONGINT);
  254. BEGIN
  255. ASM
  256. MOVE.L A6,-(A7)
  257. MOVEA.L mview,A0
  258. MOVE.L x,D0
  259. MOVE.L y,D1
  260. MOVEA.L MysticBase,A6
  261. JSR -072(A6)
  262. MOVEA.L (A7)+,A6
  263. END;
  264. END;
  265. {
  266. Functions and procedures with array of const go here
  267. }
  268. FUNCTION MV_Create(screen : pScreen; a1arg : pRastPort; const tags : Array Of Const) : POINTER;
  269. begin
  270. MV_Create := MV_CreateA(screen , a1arg , readintags(tags));
  271. end;
  272. PROCEDURE MV_GetAttrs(mview : POINTER; const tags : Array Of Const);
  273. begin
  274. MV_GetAttrsA(mview , readintags(tags));
  275. end;
  276. PROCEDURE MV_SetAttrs(mview : POINTER; const tags : Array Of Const);
  277. begin
  278. MV_SetAttrsA(mview , readintags(tags));
  279. end;
  280. const
  281. { Change VERSION and LIBVERSION to proper values }
  282. VERSION : string[2] = '0';
  283. LIBVERSION : longword = 0;
  284. {$ifdef use_init_openlib}
  285. {$Info Compiling initopening of mysticview.library}
  286. {$Info don't forget to use InitMYSTICVIEWLibrary in the beginning of your program}
  287. var
  288. mysticview_exit : Pointer;
  289. procedure ClosemysticviewLibrary;
  290. begin
  291. ExitProc := mysticview_exit;
  292. if MysticBase <> nil then begin
  293. CloseLibrary(MysticBase);
  294. MysticBase := nil;
  295. end;
  296. end;
  297. procedure InitMYSTICVIEWLibrary;
  298. begin
  299. MysticBase := nil;
  300. MysticBase := OpenLibrary(MYSTICVIEWNAME,LIBVERSION);
  301. if MysticBase <> nil then begin
  302. mysticview_exit := ExitProc;
  303. ExitProc := @ClosemysticviewLibrary;
  304. end else begin
  305. MessageBox('FPC Pascal Error',
  306. 'Can''t open mysticview.library version ' + VERSION + #10 +
  307. 'Deallocating resources and closing down',
  308. 'Oops');
  309. halt(20);
  310. end;
  311. end;
  312. begin
  313. MYSTICVIEWIsCompiledHow := 2;
  314. {$endif use_init_openlib}
  315. {$ifdef use_auto_openlib}
  316. {$Info Compiling autoopening of mysticview.library}
  317. var
  318. mysticview_exit : Pointer;
  319. procedure ClosemysticviewLibrary;
  320. begin
  321. ExitProc := mysticview_exit;
  322. if MysticBase <> nil then begin
  323. CloseLibrary(MysticBase);
  324. MysticBase := nil;
  325. end;
  326. end;
  327. begin
  328. MysticBase := nil;
  329. MysticBase := OpenLibrary(MYSTICVIEWNAME,LIBVERSION);
  330. if MysticBase <> nil then begin
  331. mysticview_exit := ExitProc;
  332. ExitProc := @ClosemysticviewLibrary;
  333. MYSTICVIEWIsCompiledHow := 1;
  334. end else begin
  335. MessageBox('FPC Pascal Error',
  336. 'Can''t open mysticview.library version ' + VERSION + #10 +
  337. 'Deallocating resources and closing down',
  338. 'Oops');
  339. halt(20);
  340. end;
  341. {$endif use_auto_openlib}
  342. {$ifdef dont_use_openlib}
  343. begin
  344. MYSTICVIEWIsCompiledHow := 3;
  345. {$Warning No autoopening of mysticview.library compiled}
  346. {$Warning Make sure you open mysticview.library yourself}
  347. {$endif dont_use_openlib}
  348. END. (* UNIT MYSTICVIEW *)