-
Notifications
You must be signed in to change notification settings - Fork 2
/
PRINTSCN.ASM
184 lines (129 loc) · 6.44 KB
/
PRINTSCN.ASM
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
$Title ('DTC/PC BIOS Print Screen Driver V1.0')
$Pagelength (80) Pagewidth (132) Debug Nogen
Name PrintScreen
; Author: Don K. Harrison
; Start date: December 7, 1983 Last edit: December 20, 1983
; ************************
; * Module Description *
; ************************
; This module contains the print screen interrupt routine
; (Int 5).
; (c) Display Telecommunications Corporation, 1983
; All Rights Reserved
$Eject
; **********************
; * Revision History *
; **********************
$Eject
; ********************
; * Public Symbols *
; ********************
Public PrintScreenInt
; *************
; * Equates *
; *************
AsciiLineFeed Equ 0AH ;Ascii line feed
AsciiCarriageReturn Equ 0DH ;Ascii carriage return
$Include (IbmInc)
$Eject
; *******************
; * Data Segments *
; *******************
BiosDataArea Segment Public
Extrn PrintScnStatus:Byte
BiosDataArea Ends
$Eject
; ******************
; * Code Segment *
; ******************
Bios Segment Common
Org 0FF54H ;Align with Pc and Xt
Assume Cs:Bios, Ds:BiosDataArea
PrintScreenInt Proc Far
Sti ;Restore interrupts
Push Ds ;................
Push Ax ;. Save .
Push Bx ;. .
Push Cx ;. Registers .
Push Dx ;................
Mov Ax,BiosDataArea ;Load our segment
Mov Ds,Ax ;...into Ds
Cmp PrintScnStatus,1 ;In progress already?
Je InProgressEnd ;...jump if so and return
; Set status = 1 = in progress
Mov PrintScnStatus,1 ;Set status
; Initialize printer
Call PCrlf ;Only needs a line feed
; Get cursor position
Mov Ah,VidCmdInfo ;Get page number and info
Int TrapVideo ;...for use later
Push Ax ;Save columns
Mov Ah,VidCmdRdCurPos ;Read cursor position
Int TrapVideo ;...for restoration purposes
Pop Ax ;Get back columns
Push Dx ;...and save cursor pos
Mov Ch,25 ;Always do 25 rows
Mov Cl,Ah ;...and (Columns) columns
Xor Dx,Dx ;Start of screen = 0,0
; Print the screen
PrintScreenLoop:
Mov Ah,VidCmdCurPos ;Set cursor to next (first)
Int TrapVideo ;...line
Mov Ah,VidCmdRdCurChAt ;Read the
Int TrapVideo ;...character
Or Al,Al ;If zero,
Jnz CharOk ;...then convert
Mov Al,' ' ;...to a space
CharOk:
; Print the character
Push Dx ;Save cursor position
Xor Dx,Dx ;Select printer 1
Mov Ah,Dl ;...print command
Int TrapPrintDrive ;Print it
Pop Dx ;Restore cursor
; Test for error
Test Ah,00100101B ;Error if any bit set
Jz NoError ;...jump if no error
Mov PrintScnStatus,0FFH ;Error status
Jmp Short PrintScnEnd
; Increment to next character position
NoError:
Inc Dl ;Bump column
Cmp Cl,Dl ;...is it right limit?
Jnz PrintScreenLoop ;...if not, loop
Xor Dl,Dl ;Do carriage return on screen
Call PCrlf ;Do carriage return on printer
Inc Dh ;Increment row
Cmp Dh,Ch ;...over limit?
Jnz PrintScreenLoop ;...jump if not
Mov PrintScnStatus,0 ;Indicate all done
; Restore cursor and return
PrintScnEnd:
Pop Dx ;Restore original
Mov Ah,VidCmdCurPos ;...cursor
Int TrapVideo ;...to screen
InProgressEnd:
Pop Dx ;................
Pop Cx ;. Restore .
Pop Bx ;. Registers .
Pop Ax ;. and .
Pop Ds ;. Return .
Iret ;................
; *****************************
; * Printer Carriage Return *
; *****************************
PCrlf Proc Near
Push Dx ;Save Dx
Xor Dx,Dx ;Select printer 1
Mov Ah,Dl ;...and command = print
Mov Al,AsciiLineFeed ;Send LF first
Int TrapPrintDrive ;...like IBM does
Xor Ah,Ah ;Ignore status
Mov Al,AsciiCarriageReturn ;Send Cr
Int TrapPrintDrive ;...next
Pop Dx ;Restore Dx
Ret ;...and return
PCrlf Endp
PrintScreenInt Endp
Bios Ends
End