-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathF600prnp.pas
282 lines (258 loc) · 8.24 KB
/
F600prnp.pas
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
/////////////////////////////////////////////////////////////////////////
// //
// Orion/Z (Orion-128 + Z80-CARD-II) emulator, version 1.9 //
// //
// Author: Sergey A. <[email protected]> //
// //
// Copyright (C) 2006-2016 Sergey A. //
// //
// This program is free software; you can redistribute it and/or //
// modify it in any ways. //
// This program is distributed "AS IS" 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. //
// //
/////////////////////////////////////////////////////////////////////////
unit F600prnp;
interface
uses
Windows, Messages, SysUtils, Forms,
Mask, Classes, Controls, Dialogs, ExtCtrls, StdCtrls;
type
TfrmF600prnp = class(TForm)
btnFont: TButton;
edtFontName: TEdit;
FontDialog: TFontDialog;
btnOK: TButton;
btnCancel: TButton;
rgMode: TRadioGroup;
rgPrinter: TRadioGroup;
meFontSize: TMaskEdit;
rgCodePage: TRadioGroup;
Label1: TLabel;
meBorderTop: TMaskEdit;
meBorderBottom: TMaskEdit;
meBorderLeft: TMaskEdit;
meBorderRight: TMaskEdit;
Label2: TLabel;
procedure btnOKClick(Sender: TObject);
procedure btnFontClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmF600prnp: TfrmF600prnp;
function pConfigure: LongInt;
function flush_prnp: LongInt;
implementation
{$R *.DFM}
Uses F600common, modF600, F600printer;
// Âàðèàíò1:
// pB0...pB7 out - printer data (inverted)
// pC0 out - data strobe (active=1)
// pC7 in - printer ready (Active=1)
// Âàðèàíò2:
// PA0..PA7 out - DATA
// PC7 - STROBE - strob (inwersnyj)
// PC3 - BUSY - gotownostx{
;
; drajwer "LPT"
; "CENTRONICS" (irpr-m)
;
;======================
;
ORG 0A800H
;
PPB:EQU 0F601H
PPC:EQU 0F602H
PPU:EQU 0F603H
;
PRINT:JMP PRNT ; whod dr."wywod simwola"
STATUS:JMP STR0 ; whod dr."gotownostx"
;
STR0:MVI A,98H ; programmirowanie porta
STA PPU
XRA A
STA PPC ; ust.ishod.sost.signalow
STR1:DCR A ; zadervka
JNZ STR1
CALL STTS ; printer -- gotow?
RZ ; esli net - wyhod
PUSH H
LXI H,STTS ; wykl.ustanowo~nu` ~astx
SHLD STR0+1 ; programmy STATUS
POP H
STTS:LDA PPC ; osnow.~astx progr. STATUS
ANI 80H ; prwer. _BUSY
RET
;
PRNT:PUSH H
PUSH D
PUSH B
PUSH PSW
PRT0:JMP PRN
;
PRN:MVI A,98H ; po primeru podprog.
STA PPU ; STATUS programmiru`aq
XRA A ; ~astx podrogr. print
STA PPC
PRN1:DCR A
JNZ PRN1
CALL STTS
JZ PRT3
PUSH H
LXI H,PRT1
SHLD PRT0+1
POP H
; osnownaq ~astx podprogrm.
; wywoda simwola na printer
PRT1:CALL STTS ; ovidatx gotownosti printera
JZ PRT1 ; do priema simwola
MOV A,C
CMA ; inwertirowatx bajt simwola
STA PPB ; wywesti na printer
MVI A,1 ; \
STA PPC ; formirowanie impulxsa
XRA A ; _STROBE
STA PPC ;/
PRT2:CALL STTS ; ovidatx gotownosti printera
JZ PRT2 ; posle priema simwola
PRT3:POP PSW
POP B
POP D
POP H
RET
;
END
uproùennaq shema podkl`~eniq printera s interfejsom
"CENTRONICS".
port obozn. razxem LX-800
B1 >------------- D0 -------------- 2 DATA 1
B2 >------------- D1 -------------- 3 DATA 2
B3 >------------- D2 -------------- 4 DATA 3
B4 >------------- D3 -------------- 5 DATA 4
B5 >------------- D4 -------------- 6 DATA 5
B6 >------------- D5 -------------- 7 DATA 6
B7 >------------- D6 -------------- 8 DATA 7
B8 >------------- D7 -------------- 9 DATA 8
*
C1 >------------ _STROBE -- SC ---- 1 _STROBE
C2 >----------------------- S0 ----
C7 <----------------------- A0 ----
C8 <------------ BUSY ---- AC ---- 11 BUSY
}
var
SelectFont: boolean;
SelectPrinter: boolean;
PrnStarted: boolean;
FlushCount: integer;
function flush_prnp: LongInt;
var mode, ii: integer;
tmpbuf: TPrnBuffer;
procedure PStop;
begin
FlushCount:=0;
if PrnStarted then PrnStop;
PrnStarted:=False;
end;
begin
mode:=0;
Result:=0;
if (BufCount=0) or (trim(PrnFile)='') then
begin
if FlushCount>2 then // close printer (end job) if 3 seconds idle (end of printing)
PStop
else inc(FlushCount);
exit;
end;
if SelectFont then begin
SetPrinterParams('','Orion/Z emulator printing', PrnFont, PrnFontSize);
SelectFont:=False;
end;
if SelectPrinter then begin
if PrnPrn<>0 then mode:=PRINTER_DIALOG;
SelectPrinter:=False;
PStop;
end;
if not PrnStarted then
PrnStarted:=PrnStart(mode);
if PrnStarted then begin
for ii:=0 to BufCount-1 do
case PrnCP of
1: begin
tmpbuf[ii]:=Koi8to866(PrnBuffer[ii]);
end
end;
PrnString(PChar(@tmpbuf[0]), BufCount);
end;
FlushCount:=0;
BufCount:=0;
end;
function pConfigure: LongInt;
begin
Result:=0;
frmF600prnp:=nil;
try
frmF600prnp:=TfrmF600prnp.Create(Application);
frmF600prnp.ShowModal;
finally
if Assigned(frmF600prnp) then
frmF600prnp.Free;
end;
end;
procedure TfrmF600prnp.btnOKClick(Sender: TObject);
begin
SelectFont:=(AnsiUpperCase(PrnFont)<>AnsiUpperCase(trim(edtFontName.Text)))or
(PrnFontSize<>StrToIntDef(trim(meFontSize.Text), 8));
SelectPrinter:=(PrnPrn<>rgPrinter.ItemIndex);
PrnFont:=trim(edtFontName.Text);
PrnFontSize:=StrToIntDef(trim(meFontSize.Text), 8);
PrnPrn:=rgPrinter.ItemIndex;
PrnMode:=rgMode.ItemIndex;
PrnCP:=rgCodePage.ItemIndex;
BorderTop := StrToIntDef(meBorderTop.Text, 50);
BorderLeft := StrToIntDef(meBorderLeft.Text, 50);
BorderRight := StrToIntDef(meBorderRight.Text, 50);
BorderBottom:= StrToIntDef(meBorderBottom.Text, 50);
WritePrivateString(stSectionName, stPrnFontKey, PrnFont);
WritePrivateInt(stSectionName, stPrnFtSzKey, PrnFontSize);
WritePrivateInt(stSectionName, stPrnModeKey, PrnMode);
WritePrivateInt(stSectionName, stPrnCPKey, PrnCP);
WritePrivateInt(stSectionName, stPrnPrnKey, PrnPrn);
WritePrivateInt(stSectionName, stPrnBrdTop, BorderTop );
WritePrivateInt(stSectionName, stPrnBrdLeft, BorderLeft );
WritePrivateInt(stSectionName, stPrnBrdRight, BorderRight );
WritePrivateInt(stSectionName, stPrnBrdBot, BorderBottom );
ModalResult:=mrOk;
end;
procedure TfrmF600prnp.btnFontClick(Sender: TObject);
begin
if FontDialog.Execute then
begin
edtFontName.Text:=FontDialog.Font.Name;
meFontSize.Text:=IntToStr(FontDialog.Font.Size);
end;
end;
procedure TfrmF600prnp.FormActivate(Sender: TObject);
begin
OnActivate:=nil;
GetIniSettings;
edtFontName.Text:=PrnFont;
meFontSize.Text:=IntToStr(PrnFontSize);
rgPrinter.ItemIndex:=PrnPrn;
rgMode.ItemIndex:=PrnMode;
rgCodePage.ItemIndex:=PrnCP;
meBorderTop.Text := IntToStr(BorderTop);
meBorderLeft.Text := IntToStr(BorderLeft);
meBorderRight.Text := IntToStr(BorderRight);
meBorderBottom.Text:= IntToStr(BorderBottom);
end;
initialization
SelectPrinter:=True;
SelectFont:=True;
PrnStarted:=False;
FlushCount:=0;
end.