prtbase.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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) 1998-2003 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {
  13. History:
  14. Update for AmigaOS 3.0.
  15. Some const and records added and changes
  16. was made to a few records.
  17. 31 Jan 2003.
  18. [email protected] Nils Sjoholm
  19. }
  20. {
  21. printer device data definition
  22. }
  23. unit prtbase;
  24. INTERFACE
  25. uses exec, parallel, serial, amigados, intuition, timer,utility;
  26. Type
  27. pDeviceData = ^tDeviceData;
  28. tDeviceData = record
  29. dd_Device : tLibrary; { standard library node }
  30. dd_Segment : Pointer; { A0 when initialized }
  31. dd_ExecBase : Pointer; { A6 for exec }
  32. dd_CmdVectors : Pointer; { command table for device commands }
  33. dd_CmdBytes : Pointer; { bytes describing which command queue }
  34. dd_NumCommands : Word; { the number of commands supported }
  35. end;
  36. Const
  37. IOB_QUEUED = 4;
  38. IOB_CURRENT = 5;
  39. IOB_SERVICING = 6;
  40. IOB_DONE = 7;
  41. IOF_QUEUED = 1 shl IOB_QUEUED;
  42. IOF_CURRENT = 1 shl IOB_CURRENT;
  43. IOF_SERVICING = 1 shl IOB_SERVICING;
  44. IOF_DONE = 1 shl IOB_DONE;
  45. { pd_Flags }
  46. PB_IOR0 = 0;
  47. PB_IOR1 = 1;
  48. PB_IOOPENED = 2;
  49. PB_EXPUNGED = 7;
  50. PBF_IOR0 = 1 shl PB_IOR0;
  51. PBF_IOR1 = 1 shl PB_IOR1;
  52. PBF_IOOPENDED = 1 shl PB_IOOPENED;
  53. PBF_EXPUNGED = 1 shl PB_EXPUNGED;
  54. { du_Flags (actually placed in pd_Unit.mp_Node.ln_Pri) }
  55. DUB_STOPPED = 0;
  56. DUF_STOPPED = 1 shl DUB_STOPPED;
  57. P_OLDSTKSIZE = $0800; { stack size for child task }
  58. P_STKSIZE = $1000;
  59. P_BUFSIZE = 256; { size of internal buffers for text i/o }
  60. P_SAFESIZE = 128; { safety margin for text output buffer }
  61. {**************************************************************************}
  62. {
  63. "struct PrinterData" was a very bad concept in the old V1.0 days
  64. because it is both: the device and the unit.
  65. Starting with V44 PrinterData may be duplicated for many Units. But all
  66. new fields that are specific to the Unit are now part of the new
  67. "struct PrinterUnit". Don't touch the private fields!
  68. A note on the function pointers in these data structure definitions:
  69. unless otherwise specified, all functions expect that their parameters
  70. are passed on the *stack* rather than in CPU registers. Every parameter
  71. must be passed a 32 bit long word, i.e. an "UWORD" will use the same
  72. stack space as an "ULONG".
  73. }
  74. Type
  75. pPrinterData = ^tPrinterData;
  76. tPrinterData = record
  77. pd_Device : tDeviceData;
  78. pd_Unit : tMsgPort;
  79. pd_PrinterSegment : BPTR;
  80. pd_PrinterType : WORD;
  81. pd_SegmentData : Pointer;
  82. pd_PrintBuf : Pointer;
  83. pd_PWrite : Pointer;
  84. pd_PBothReady : Pointer;
  85. pd_ior0 : record
  86. case longint of
  87. 0 : ( pd_p0 : tIOExtPar );
  88. 1 : ( pd_s0 : tIOExtSer );
  89. end;
  90. pd_ior1 : record
  91. case longint of
  92. 0 : ( pd_p1 : tIOExtPar );
  93. 1 : ( pd_s1 : tIOExtSer );
  94. end;
  95. pd_TIOR : tTimeRequest;
  96. pd_IORPort : tMsgPort;
  97. pd_TC : tTask;
  98. pd_OldStk : array[0..(P_OLDSTKSIZE)-1] of BYTE;
  99. pd_Flags : BYTE;
  100. pd_pad : BYTE;
  101. pd_Preferences : tPreferences;
  102. pd_PWaitEnabled : BYTE;
  103. pd_Flags1 : BYTE;
  104. pd_Stk : array[0..(P_STKSIZE)-1] of BYTE;
  105. end;
  106. Const
  107. { Printer Class }
  108. PPCB_GFX = 0; { graphics (bit position) }
  109. PPCF_GFX = 1; { graphics (and/or flag) }
  110. PPCB_COLOR = 1; { color (bit position) }
  111. PPCF_COLOR = 2; { color (and/or flag) }
  112. PPC_BWALPHA = 0; { black&white alphanumerics }
  113. PPC_BWGFX = 1; { black&white graphics }
  114. PPC_COLORALPHA = 2; { color alphanumerics }
  115. PPC_COLORGFX = 3; { color graphics }
  116. { extended PED structure (V44) }
  117. PPCB_EXTENDED = 2;
  118. PPCF_EXTENDED = $4;
  119. {
  120. Some printer drivers (PrinterPS) do not support
  121. strip printing. An application has to print a page
  122. using a single print request or through clever use
  123. of the PRD_DUMPRPORTTAGS printing callback hook.
  124. }
  125. { no strip printing, please }
  126. PPCB_NOSTRIP = 3;
  127. PPCF_NOSTRIP = $8;
  128. { Color Class }
  129. PCC_BW = 1; { black&white only }
  130. PCC_YMC = 2; { yellow/magenta/cyan only }
  131. PCC_YMC_BW = 3; { yellow/magenta/cyan or black&white }
  132. PCC_YMCB = 4; { yellow/magenta/cyan/black }
  133. PCC_4COLOR = 4; { a flag for YMCB and BGRW }
  134. PCC_ADDITIVE = 8; { not ymcb but blue/green/red/white }
  135. PCC_WB = 9; { black&white only, 0 == BLACK }
  136. PCC_BGR = 10; { blue/green/red }
  137. PCC_BGR_WB = 11; { blue/green/red or black&white }
  138. PCC_BGRW = 12; { blue/green/red/white }
  139. {
  140. The picture must be scanned once for each color component, as the
  141. printer can only define one color at a time. ie. If 'PCC_YMC' then
  142. first pass sends all 'Y' info to printer, second pass sends all 'M'
  143. info, and third pass sends all C info to printer. The CalComp
  144. PlotMaster is an example of this type of printer.
  145. }
  146. PCC_MULTI_PASS = $10; { see explanation above }
  147. Type
  148. pPrinterExtendedData = ^tPrinterExtendedData;
  149. tPrinterExtendedData = record
  150. ped_PrinterName : STRPTR; { printer name, null terminated }
  151. ped_Init : procedure; { called after LoadSeg }
  152. ped_Expunge : procedure; { called before UnLoadSeg }
  153. ped_Open : function:LONG; { called at OpenDevice }
  154. ped_Close : procedure; { called at CloseDevice }
  155. ped_PrinterClass : uByte; { printer class }
  156. ped_ColorClass : uByte; { color class }
  157. ped_MaxColumns : uByte; { number of print columns available }
  158. ped_NumCharSets : uByte; { number of character sets }
  159. ped_NumRows : uWord; { number of 'pins' in print head }
  160. ped_MaxXDots : ULONG; { number of dots max in a raster dump }
  161. ped_MaxYDots : ULONG; { number of dots max in a raster dump }
  162. ped_XDotsInch : uWord; { horizontal dot density }
  163. ped_YDotsInch : uWord; { vertical dot density }
  164. ped_Commands : Pointer; { printer text command table }
  165. ped_DoSpecial : function:LONG; { special command handler }
  166. ped_Render : function:LONG; { raster render function }
  167. ped_TimeoutSecs : Longint; { good write timeout }
  168. { the following only exists if the segment version is >= 33 }
  169. ped_8BitChars : Pointer; { conv. strings for the extended font }
  170. ped_PrintMode : Longint; { set if text printed, otherwise 0 }
  171. { the following only exists if the segment version is >= 34 }
  172. { ptr to conversion function for all chars }
  173. ped_ConvFunc : Pointer;
  174. {*************************************************************
  175. *
  176. * The following only exists if the segment version is >= 44
  177. * AND PPCB_EXTENDED is set in ped_PrinterClass:
  178. *
  179. ************************************************************}
  180. { Attributes and features }
  181. ped_TagList : PTagItem;
  182. { driver specific preferences:
  183. *
  184. * LONG ped_DoPreferences(struct printerIO * ior,
  185. * LONG command);
  186. }
  187. ped_DoPreferences : function :LONG;
  188. { custom error handling:
  189. *
  190. * VOID ped_CallErrHook(struct printerIO * ior,
  191. * struct Hook * hook);
  192. }
  193. ped_CallErrHook : procedure ;
  194. end;
  195. { The following tags are used to define more printer driver features }
  196. const
  197. PRTA_Dummy = TAG_USER + $50000;
  198. { }
  199. { V44 features }
  200. { LBOOL }
  201. PRTA_8BitGuns = PRTA_Dummy + 1;
  202. { LBOOL }
  203. PRTA_ConvertSource = PRTA_Dummy + 2;
  204. { LBOOL }
  205. PRTA_FloydDithering = PRTA_Dummy + 3;
  206. { LBOOL }
  207. PRTA_AntiAlias = PRTA_Dummy + 4;
  208. { LBOOL }
  209. PRTA_ColorCorrection = PRTA_Dummy + 5;
  210. { LBOOL }
  211. PRTA_NoIO = PRTA_Dummy + 6;
  212. { LBOOL }
  213. PRTA_NewColor = PRTA_Dummy + 7;
  214. { LONG }
  215. PRTA_ColorSize = PRTA_Dummy + 8;
  216. { LBOOL }
  217. PRTA_NoScaling = PRTA_Dummy + 9;
  218. { User interface }
  219. { STRPTR }
  220. PRTA_DitherNames = PRTA_Dummy + 20;
  221. { STRPTR }
  222. PRTA_ShadingNames = PRTA_Dummy + 21;
  223. { LBOOL }
  224. PRTA_ColorCorrect = PRTA_Dummy + 22;
  225. { STRPTR }
  226. PRTA_DensityInfo = PRTA_Dummy + 23;
  227. { Hardware page borders }
  228. { LONG, inches/1000 }
  229. PRTA_LeftBorder = PRTA_Dummy + 30;
  230. { LONG, inches/1000 }
  231. PRTA_TopBorder = PRTA_Dummy + 31;
  232. { LBOOL }
  233. PRTA_MixBWColor = PRTA_Dummy + 32;
  234. { Driver Preferences }
  235. { LBOOL }
  236. PRTA_Preferences = PRTA_Dummy + 40;
  237. type
  238. pPrinterSegment = ^tprinterSegment;
  239. tPrinterSegment = record
  240. ps_NextSegment : ULONG; { (actually a BPTR) }
  241. ps_runAlert : ULONG; { MOVEQ #0,D0 : RTS }
  242. ps_Version : Word; { segment version }
  243. ps_Revision : Word; { segment revision }
  244. ps_PED : tPrinterExtendedData; { printer extended data }
  245. end;
  246. {**************************************************************************}
  247. {
  248. Driver specific preferences. This structure is device specific: every
  249. driver must base its preferences structure on this to allow version
  250. checking etc.
  251. The application will read/write this structure as an I/O buffer.
  252. }
  253. PPrtDriverPreferences = ^tPrtDriverPreferences;
  254. tPrtDriverPreferences = record
  255. pdp_Version : UWORD; { PRIVATE! driver specific version }
  256. { PRIVATE! driver specific id }
  257. pdp_PrinterID : array[0..31] of UBYTE;
  258. pdp_PrefName : array[0..(FILENAME_SIZE - 16)-1] of char;
  259. { size of this structure }
  260. pdp_Length : ULONG;
  261. end;
  262. IMPLEMENTATION
  263. end.