summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/amunits/src/coreunits/prtbase.pas
blob: 95d8c2da8edae1789c5af310a507fd205308d849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
{
    This file is part of the Free Pascal run time library.

    A file in Amiga system run time library.
    Copyright (c) 1998-2003 by Nils Sjoholm
    member of the Amiga RTL development team.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

{
    History:

    Update for AmigaOS 3.0.
    Some const and records added and changes
    was made to a few records.
    31 Jan 2003.

    nils.sjoholm@mailbox.swipnet.se Nils Sjoholm
}

{
        printer device data definition
}

unit prtbase;

INTERFACE

uses exec, parallel, serial, amigados, intuition, timer,utility;


Type

    pDeviceData = ^tDeviceData;
    tDeviceData = record
        dd_Device       : tLibrary;     { standard library node }
        dd_Segment      : Pointer;      { A0 when initialized }
        dd_ExecBase     : Pointer;      { A6 for exec }
        dd_CmdVectors   : Pointer;      { command table for device commands }
        dd_CmdBytes     : Pointer;      { bytes describing which command queue }
        dd_NumCommands  : Word;         { the number of commands supported }
    end;

Const
     IOB_QUEUED = 4;
     IOB_CURRENT = 5;
     IOB_SERVICING = 6;
     IOB_DONE = 7;
     IOF_QUEUED = 1 shl IOB_QUEUED;
     IOF_CURRENT = 1 shl IOB_CURRENT;
     IOF_SERVICING = 1 shl IOB_SERVICING;
     IOF_DONE = 1 shl IOB_DONE;
  { pd_Flags  }
     PB_IOR0 = 0;
     PB_IOR1 = 1;
     PB_IOOPENED = 2;
     PB_EXPUNGED = 7;
     PBF_IOR0 = 1 shl PB_IOR0;
     PBF_IOR1 = 1 shl PB_IOR1;
     PBF_IOOPENDED = 1 shl PB_IOOPENED;
     PBF_EXPUNGED = 1 shl PB_EXPUNGED;
  { du_Flags (actually placed in pd_Unit.mp_Node.ln_Pri)  }
     DUB_STOPPED = 0;
     DUF_STOPPED = 1 shl DUB_STOPPED;

     P_OLDSTKSIZE        = $0800;        { stack size for child task }
     P_STKSIZE           = $1000;
     P_BUFSIZE           = 256;          { size of internal buffers for text i/o }
     P_SAFESIZE          = 128;          { safety margin for text output buffer }

{**************************************************************************}

{
        "struct PrinterData" was a very bad concept in the old V1.0 days
        because it is both: the device and the unit.

        Starting with V44 PrinterData may be duplicated for many Units. But all
        new fields that are specific to the Unit  are now part of the new
        "struct PrinterUnit". Don't touch the private fields!

        A note on the function pointers in these data structure definitions:
        unless otherwise specified, all functions expect that their parameters
        are passed on the *stack* rather than in CPU registers. Every parameter
        must be passed a 32 bit long word, i.e. an "UWORD" will use the same
        stack space as an "ULONG".
}

Type
       pPrinterData = ^tPrinterData;
       tPrinterData = record
            pd_Device : tDeviceData;
            pd_Unit : tMsgPort;
            pd_PrinterSegment : BPTR;
            pd_PrinterType : WORD;
            pd_SegmentData : Pointer;
            pd_PrintBuf : Pointer;
            pd_PWrite : Pointer;
            pd_PBothReady : Pointer;
            pd_ior0 : record
                case longint of
                   0 : ( pd_p0 : tIOExtPar );
                   1 : ( pd_s0 : tIOExtSer );
                end;
            pd_ior1 : record
                case longint of
                   0 : ( pd_p1 : tIOExtPar );
                   1 : ( pd_s1 : tIOExtSer );
                end;
            pd_TIOR : tTimeRequest;
            pd_IORPort : tMsgPort;
            pd_TC : tTask;
            pd_OldStk : array[0..(P_OLDSTKSIZE)-1] of BYTE;
            pd_Flags : BYTE;
            pd_pad : BYTE;
            pd_Preferences : tPreferences;
            pd_PWaitEnabled : BYTE;
            pd_Flags1 : BYTE;
            pd_Stk : array[0..(P_STKSIZE)-1] of BYTE;
         end;

Const

{ Printer Class }

    PPCB_GFX            = 0;            { graphics (bit position) }
    PPCF_GFX            = 1;            { graphics (and/or flag) }
    PPCB_COLOR          = 1;            { color (bit position) }
    PPCF_COLOR          = 2;            { color (and/or flag) }

    PPC_BWALPHA         = 0;            { black&white alphanumerics }
    PPC_BWGFX           = 1;            { black&white graphics }
    PPC_COLORALPHA      = 2;            { color alphanumerics }
    PPC_COLORGFX        = 3;            { color graphics }


{ extended PED structure (V44)  }
    PPCB_EXTENDED = 2;
    PPCF_EXTENDED = $4;

{
        Some printer drivers (PrinterPS) do not support
        strip printing. An application has to print a page
        using a single print request or through clever use
        of the PRD_DUMPRPORTTAGS printing callback hook.
}

{ no strip printing, please  }
       PPCB_NOSTRIP = 3;
       PPCF_NOSTRIP = $8;

{ Color Class }

    PCC_BW              = 1;            { black&white only }
    PCC_YMC             = 2;            { yellow/magenta/cyan only }
    PCC_YMC_BW          = 3;            { yellow/magenta/cyan or black&white }
    PCC_YMCB            = 4;            { yellow/magenta/cyan/black }
    PCC_4COLOR          = 4;            { a flag for YMCB and BGRW }
    PCC_ADDITIVE        = 8;            { not ymcb but blue/green/red/white }
    PCC_WB              = 9;            { black&white only, 0 == BLACK }
    PCC_BGR             = 10;           { blue/green/red }
    PCC_BGR_WB          = 11;           { blue/green/red or black&white }
    PCC_BGRW            = 12;           { blue/green/red/white }

{
        The picture must be scanned once for each color component, as the
        printer can only define one color at a time.  ie. If 'PCC_YMC' then
        first pass sends all 'Y' info to printer, second pass sends all 'M'
        info, and third pass sends all C info to printer.  The CalComp
        PlotMaster is an example of this type of printer.
}

    PCC_MULTI_PASS      = $10;          { see explanation above }

Type

    pPrinterExtendedData = ^tPrinterExtendedData;
    tPrinterExtendedData = record
        ped_PrinterName : STRPTR;         { printer name, null terminated }
        ped_Init        : procedure;      { called after LoadSeg }
        ped_Expunge     : procedure;      { called before UnLoadSeg }
        ped_Open        : function:LONG;  { called at OpenDevice }
        ped_Close       : procedure;      { called at CloseDevice }
        ped_PrinterClass : uByte;         { printer class }
        ped_ColorClass  : uByte;          { color class }
        ped_MaxColumns  : uByte;          { number of print columns available }
        ped_NumCharSets : uByte;          { number of character sets }
        ped_NumRows     : uWord;          { number of 'pins' in print head }
        ped_MaxXDots    : ULONG;          { number of dots max in a raster dump }
        ped_MaxYDots    : ULONG;          { number of dots max in a raster dump }
        ped_XDotsInch   : uWord;          { horizontal dot density }
        ped_YDotsInch   : uWord;          { vertical dot density }
        ped_Commands    : Pointer;        { printer text command table }
        ped_DoSpecial   : function:LONG;  { special command handler }
        ped_Render      : function:LONG;  { raster render function }
        ped_TimeoutSecs : Longint;        { good write timeout }

        { the following only exists if the segment version is >= 33 }

        ped_8BitChars   : Pointer;      { conv. strings for the extended font }
        ped_PrintMode   : Longint;      { set if text printed, otherwise 0 }

        { the following only exists if the segment version is >= 34 }
        { ptr to conversion function for all chars }

        ped_ConvFunc    : Pointer;
        {*************************************************************
         *
         * The following only exists if the segment version is >= 44
         * AND PPCB_EXTENDED is set in ped_PrinterClass:
         *
         ************************************************************}

        { Attributes and features }
        ped_TagList : PTagItem;
        { driver specific preferences:
         *
         *      LONG ped_DoPreferences(struct printerIO * ior,
         *                             LONG command);
         }
        ped_DoPreferences : function :LONG;
        { custom error handling:
         *
         *      VOID ped_CallErrHook(struct printerIO * ior,
         *                           struct Hook * hook);
         }
        ped_CallErrHook : procedure ;
    end;

    { The following tags are used to define more printer driver features  }

    const
       PRTA_Dummy = TAG_USER + $50000;
    {                                                                           }
    { V44 features  }
    { LBOOL  }
       PRTA_8BitGuns = PRTA_Dummy + 1;
    { LBOOL  }
       PRTA_ConvertSource = PRTA_Dummy + 2;
    { LBOOL  }
       PRTA_FloydDithering = PRTA_Dummy + 3;
    { LBOOL  }
       PRTA_AntiAlias = PRTA_Dummy + 4;
    { LBOOL  }
       PRTA_ColorCorrection = PRTA_Dummy + 5;
    { LBOOL  }
       PRTA_NoIO = PRTA_Dummy + 6;
    { LBOOL  }
       PRTA_NewColor = PRTA_Dummy + 7;
    { LONG  }
       PRTA_ColorSize = PRTA_Dummy + 8;
    { LBOOL  }
       PRTA_NoScaling = PRTA_Dummy + 9;
    { User interface  }
    { STRPTR    }
       PRTA_DitherNames = PRTA_Dummy + 20;
    { STRPTR    }
       PRTA_ShadingNames = PRTA_Dummy + 21;
    { LBOOL  }
       PRTA_ColorCorrect = PRTA_Dummy + 22;
    { STRPTR    }
       PRTA_DensityInfo = PRTA_Dummy + 23;
    { Hardware page borders  }
    { LONG, inches/1000  }
       PRTA_LeftBorder = PRTA_Dummy + 30;
    { LONG, inches/1000  }
       PRTA_TopBorder = PRTA_Dummy + 31;
    { LBOOL  }
       PRTA_MixBWColor = PRTA_Dummy + 32;
    { Driver Preferences  }
    { LBOOL  }
       PRTA_Preferences = PRTA_Dummy + 40;
type
    pPrinterSegment = ^tprinterSegment;
    tPrinterSegment = record
        ps_NextSegment  : ULONG;        { (actually a BPTR) }
        ps_runAlert     : ULONG;        { MOVEQ #0,D0 : RTS }
        ps_Version      : Word;         { segment version }
        ps_Revision     : Word;         { segment revision }
        ps_PED          : tPrinterExtendedData;  { printer extended data }
    end;

{**************************************************************************}

{
        Driver specific preferences. This structure is device specific: every
        driver must base its preferences structure on this to allow version
        checking etc.

        The application will read/write this structure as an I/O buffer.
}
      PPrtDriverPreferences = ^tPrtDriverPreferences;
       tPrtDriverPreferences = record
            pdp_Version : UWORD;   { PRIVATE! driver specific version }
            { PRIVATE! driver specific id }
            pdp_PrinterID : array[0..31] of UBYTE;
            pdp_PrefName : array[0..(FILENAME_SIZE - 16)-1] of char;
            { size of this structure }
            pdp_Length : ULONG;
         end;

IMPLEMENTATION

end.