preferences.pas 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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 preferences.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. 17 Jan 2003.
  17. Changed cardinal > longword.
  18. Changed startcode for unit.
  19. 12 Feb 2003.
  20. [email protected] Nils Sjoholm
  21. }
  22. {$I useamigasmartlink.inc}
  23. {$ifdef use_amiga_smartlink}
  24. {$smartlink on}
  25. {$endif use_amiga_smartlink}
  26. UNIT PREFERENCES;
  27. INTERFACE
  28. USES Exec;
  29. VAR PreferencesBase : pLibrary;
  30. const
  31. PREFERENCESNAME : PChar = 'preferences.library';
  32. {
  33. $VER: preferences.h 39.6 (26.07.2000)
  34. preferences.library include
  35. (C) Copyright 2000 Satanic Dreams Software
  36. All Rights Reserved
  37. }
  38. { followed by the data, a total of ps_Size bytes }
  39. type
  40. PPrefsStruct = ^tPrefsStruct;
  41. tPrefsStruct = record
  42. ps_Size : WORD;
  43. end;
  44. { -- Scalos specific Prefs: }
  45. { ------------------ ScalosPrefs ------------------------- }
  46. { Name: "Scalos" or "ScalosPrefs" }
  47. { ID: "MAIN" }
  48. { struct [8] }
  49. const
  50. SCP_IconOffsets = $80000001;
  51. { word }
  52. SCP_IconNormFrame = $80000002;
  53. { word }
  54. SCP_IconSelFrame = $80000003;
  55. { word }
  56. SCP_IconTextMode = $80000004;
  57. { word }
  58. SCP_IconSecLine = $80000005;
  59. { word }
  60. SCP_IconTextSkip = $80000006;
  61. { byte image or image+text }
  62. SCP_BobsType = $80000010;
  63. { byte system or custom }
  64. SCP_BobsMethod = $80000011;
  65. { byte solid or transparent }
  66. SCP_BobsTranspMode = $80000012;
  67. { byte ghosted or real transparent }
  68. SCP_BobsTranspType = $80000013;
  69. { long when transparent }
  70. SCP_BobsTransp = $80000014;
  71. { string }
  72. SCP_ScreenTitle = $80000020;
  73. { string }
  74. SCP_RootWinTitle = $80000021;
  75. { string }
  76. SCP_WindowTitle = $80000022;
  77. { byte }
  78. SCP_Separator = $80000023;
  79. { byte }
  80. SCP_TitleRefresh = $80000024;
  81. { string }
  82. SCP_PathsDefIcons = $80000025;
  83. { string }
  84. SCP_PathsDiskCopy = $80000026;
  85. { string }
  86. SCP_PathsWBStartup = $80000027;
  87. { string }
  88. SCP_PathsHome = $80000028;
  89. { byte }
  90. SCP_MiscAutoRemove = $80000029;
  91. { byte }
  92. SCP_MiscClickTransp = $8000002a;
  93. { byte }
  94. SCP_MiscHardEmulation = $8000002b;
  95. { byte }
  96. SCP_MiscUseExAll = $8000002c;
  97. { byte }
  98. SCP_MiscWindowType = $8000002d;
  99. { byte }
  100. SCP_MiscDoWaitDelay = $8000002e;
  101. { byte delay }
  102. SCP_MiscDiskiconsRefresh = $8000002f;
  103. { byte }
  104. SCP_MiscMenuCurrentDir = $80000030;
  105. { byte }
  106. SCP_NewIconsTransparent = $80000031;
  107. { long }
  108. SCP_NewIconsPrecision = $80000032;
  109. { string }
  110. SCP_TextModeFont = $80000033;
  111. { byte }
  112. SCP_TextModeDateFormat = $80000034;
  113. { list }
  114. SCP_PlugInList = $80000035;
  115. FUNCTION AllocPrefsHandle(name : pCHAR) : POINTER;
  116. FUNCTION FindPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword) : pPrefsStruct;
  117. PROCEDURE FreePrefsHandle(PrefsHandle : POINTER);
  118. FUNCTION GetEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD; Entry : longword) : longword;
  119. FUNCTION GetPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD) : longword;
  120. PROCEDURE ReadPrefsHandle(PrefsHandle : POINTER; Filename : pCHAR);
  121. FUNCTION RemEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; Entry : longword) : longword;
  122. PROCEDURE SetEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD; Entry : longword);
  123. PROCEDURE SetPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD);
  124. PROCEDURE WritePrefsHandle(PrefsHandle : POINTER; Filename : pCHAR);
  125. {You can remove this include and use a define instead}
  126. {$I useautoopenlib.inc}
  127. {$ifdef use_init_openlib}
  128. procedure InitPREFERENCESLibrary;
  129. {$endif use_init_openlib}
  130. {This is a variable that knows how the unit is compiled}
  131. var
  132. PREFERENCESIsCompiledHow : longint;
  133. IMPLEMENTATION
  134. {$ifndef dont_use_openlib}
  135. uses msgbox;
  136. {$endif dont_use_openlib}
  137. FUNCTION AllocPrefsHandle(name : pCHAR) : POINTER;
  138. BEGIN
  139. ASM
  140. MOVE.L A6,-(A7)
  141. MOVEA.L name,A0
  142. MOVEA.L PreferencesBase,A6
  143. JSR -030(A6)
  144. MOVEA.L (A7)+,A6
  145. MOVE.L D0,@RESULT
  146. END;
  147. END;
  148. FUNCTION FindPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword) : pPrefsStruct;
  149. BEGIN
  150. ASM
  151. MOVE.L A6,-(A7)
  152. MOVEA.L PrefsHandle,A0
  153. MOVE.L ID,D0
  154. MOVE.L d1arg,D1
  155. MOVEA.L PreferencesBase,A6
  156. JSR -066(A6)
  157. MOVEA.L (A7)+,A6
  158. MOVE.L D0,@RESULT
  159. END;
  160. END;
  161. PROCEDURE FreePrefsHandle(PrefsHandle : POINTER);
  162. BEGIN
  163. ASM
  164. MOVE.L A6,-(A7)
  165. MOVEA.L PrefsHandle,A0
  166. MOVEA.L PreferencesBase,A6
  167. JSR -036(A6)
  168. MOVEA.L (A7)+,A6
  169. END;
  170. END;
  171. FUNCTION GetEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD; Entry : longword) : longword;
  172. BEGIN
  173. ASM
  174. MOVE.L A6,-(A7)
  175. MOVEA.L PrefsHandle,A0
  176. MOVE.L ID,D0
  177. MOVE.L d1arg,D1
  178. MOVEA.L a1arg,A1
  179. MOVE.L Struct_Size,D2
  180. MOVE.L Entry,D3
  181. MOVEA.L PreferencesBase,A6
  182. JSR -078(A6)
  183. MOVEA.L (A7)+,A6
  184. MOVE.L D0,@RESULT
  185. END;
  186. END;
  187. FUNCTION GetPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD) : longword;
  188. BEGIN
  189. ASM
  190. MOVE.L A6,-(A7)
  191. MOVEA.L PrefsHandle,A0
  192. MOVE.L ID,D0
  193. MOVE.L d1arg,D1
  194. MOVEA.L a1arg,A1
  195. MOVE.L Struct_Size,D2
  196. MOVEA.L PreferencesBase,A6
  197. JSR -048(A6)
  198. MOVEA.L (A7)+,A6
  199. MOVE.L D0,@RESULT
  200. END;
  201. END;
  202. PROCEDURE ReadPrefsHandle(PrefsHandle : POINTER; Filename : pCHAR);
  203. BEGIN
  204. ASM
  205. MOVE.L A6,-(A7)
  206. MOVEA.L PrefsHandle,A0
  207. MOVEA.L Filename,A1
  208. MOVEA.L PreferencesBase,A6
  209. JSR -054(A6)
  210. MOVEA.L (A7)+,A6
  211. END;
  212. END;
  213. FUNCTION RemEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; Entry : longword) : longword;
  214. BEGIN
  215. ASM
  216. MOVE.L A6,-(A7)
  217. MOVEA.L PrefsHandle,A0
  218. MOVE.L ID,D0
  219. MOVE.L d1arg,D1
  220. MOVE.L Entry,D2
  221. MOVEA.L PreferencesBase,A6
  222. JSR -084(A6)
  223. MOVEA.L (A7)+,A6
  224. MOVE.L D0,@RESULT
  225. END;
  226. END;
  227. PROCEDURE SetEntry(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD; Entry : longword);
  228. BEGIN
  229. ASM
  230. MOVE.L A6,-(A7)
  231. MOVEA.L PrefsHandle,A0
  232. MOVE.L ID,D0
  233. MOVE.L d1arg,D1
  234. MOVEA.L a1arg,A1
  235. MOVE.L Struct_Size,D2
  236. MOVE.L Entry,D3
  237. MOVEA.L PreferencesBase,A6
  238. JSR -072(A6)
  239. MOVEA.L (A7)+,A6
  240. END;
  241. END;
  242. PROCEDURE SetPreferences(PrefsHandle : POINTER; ID : longword; d1arg : longword; a1arg : POINTER; Struct_Size : WORD);
  243. BEGIN
  244. ASM
  245. MOVE.L A6,-(A7)
  246. MOVEA.L PrefsHandle,A0
  247. MOVE.L ID,D0
  248. MOVE.L d1arg,D1
  249. MOVEA.L a1arg,A1
  250. MOVE.L Struct_Size,D2
  251. MOVEA.L PreferencesBase,A6
  252. JSR -042(A6)
  253. MOVEA.L (A7)+,A6
  254. END;
  255. END;
  256. PROCEDURE WritePrefsHandle(PrefsHandle : POINTER; Filename : pCHAR);
  257. BEGIN
  258. ASM
  259. MOVE.L A6,-(A7)
  260. MOVEA.L PrefsHandle,A0
  261. MOVEA.L Filename,A1
  262. MOVEA.L PreferencesBase,A6
  263. JSR -060(A6)
  264. MOVEA.L (A7)+,A6
  265. END;
  266. END;
  267. const
  268. { Change VERSION and LIBVERSION to proper values }
  269. VERSION : string[2] = '0';
  270. LIBVERSION : longword = 0;
  271. {$ifdef use_init_openlib}
  272. {$Info Compiling initopening of preferences.library}
  273. {$Info don't forget to use InitPREFERENCESLibrary in the beginning of your program}
  274. var
  275. preferences_exit : Pointer;
  276. procedure ClosepreferencesLibrary;
  277. begin
  278. ExitProc := preferences_exit;
  279. if PreferencesBase <> nil then begin
  280. CloseLibrary(PreferencesBase);
  281. PreferencesBase := nil;
  282. end;
  283. end;
  284. procedure InitPREFERENCESLibrary;
  285. begin
  286. PreferencesBase := nil;
  287. PreferencesBase := OpenLibrary(PREFERENCESNAME,LIBVERSION);
  288. if PreferencesBase <> nil then begin
  289. preferences_exit := ExitProc;
  290. ExitProc := @ClosepreferencesLibrary;
  291. end else begin
  292. MessageBox('FPC Pascal Error',
  293. 'Can''t open preferences.library version ' + VERSION + #10 +
  294. 'Deallocating resources and closing down',
  295. 'Oops');
  296. halt(20);
  297. end;
  298. end;
  299. begin
  300. PREFERENCESIsCompiledHow := 2;
  301. {$endif use_init_openlib}
  302. {$ifdef use_auto_openlib}
  303. {$Info Compiling autoopening of preferences.library}
  304. var
  305. preferences_exit : Pointer;
  306. procedure ClosepreferencesLibrary;
  307. begin
  308. ExitProc := preferences_exit;
  309. if PreferencesBase <> nil then begin
  310. CloseLibrary(PreferencesBase);
  311. PreferencesBase := nil;
  312. end;
  313. end;
  314. begin
  315. PreferencesBase := nil;
  316. PreferencesBase := OpenLibrary(PREFERENCESNAME,LIBVERSION);
  317. if PreferencesBase <> nil then begin
  318. preferences_exit := ExitProc;
  319. ExitProc := @ClosepreferencesLibrary;
  320. PREFERENCESIsCompiledHow := 1;
  321. end else begin
  322. MessageBox('FPC Pascal Error',
  323. 'Can''t open preferences.library version ' + VERSION + #10 +
  324. 'Deallocating resources and closing down',
  325. 'Oops');
  326. halt(20);
  327. end;
  328. {$endif use_auto_openlib}
  329. {$ifdef dont_use_openlib}
  330. begin
  331. PREFERENCESIsCompiledHow := 3;
  332. {$Warning No autoopening of preferences.library compiled}
  333. {$Warning Make sure you open preferences.library yourself}
  334. {$endif dont_use_openlib}
  335. END. (* UNIT PREFERENCES *)
  336. {
  337. $Log
  338. }