-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMBIOS.MAC
500 lines (446 loc) · 13.1 KB
/
MBIOS.MAC
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
; FILENAME: MBIOS.MAC
;
; Copyright (c) 1988 by Borland International, Inc.
;
; DESCRIPTION: This include file contains various macros that may
; be used to communicate with the IBM-PC's BIOS. This include file uses
; Ideal mode syntax. For documentation on the macros in this file see the
; file BIOSMAC.DOC.
;
; NOTE: In order to use this macro file you must also include the files
; MMACROS.MAC and BIOS.EQU in your module.
CallBIOS macro Interrupt, Service
ErrMsg macro
display "Caller must provide Interrupt and Service parameters to CallBIOS."
err
endm
ifb <Interrupt>
ErrMsg
else
ifb <Service>
ErrMsg
else
mov ah, Service ; Select the service
int Interrupt ; Do the interrupt
endif
endif
endm
LoadBH macro Value
ifb <Value>
xor bh, bh
else
ifidni <bh>, <Value>
; Do nothing
else
mov bh, Value
endif
endif
endm
GotoXY macro Row, Column, Page
ErrMsg macro
display "The caller must provide the row and column parameters to GotoXY."
err
endm
ifb <Row>
ErrMsg
else
ifb <Column>
ErrMsg
else
LoadBH <Page>
mov dh, Row
mov dl, Column
CallBIOS <VIDEO_SERVICE>, <INT10_SET_CURSOR_POS>
endif
endif
endm
WhereXY macro Page
LoadBH <Page>
CallBIOS <VIDEO_SERVICE>, <INT10_READ_CURSOR>
endm
GetVideoMode macro
CallBIOS <VIDEO_SERVICE>, <INT10_GET_MODE>
endm
ScrollUp macro LineCount, Attrib, x1, y1, x2, y2
ErrMsg macro1
display "Caller must provide LineCount and Attribute parameters to ScrollUp."
err
endm
ErrMsg macro2
display "Must provide all coordinate parameters to ScrollUp macro."
err
endm
ifb <LineCount>
ErrMsg1
else
mov al, LineCount
ifb <Attrib>
ErrMsg1
else
LoadBH <Attrib>
endif
ifb <x1>
mov ch, 0 ; Use default screen coordinates
mov cl, 0
mov dh, 79d
ScreenRows ; Get current number of rows
mov dl, al
else
ifb <y1>
ErrMsg2
else
ifb <x2>
ErrMsg2
else
ifb <y2>
ErrMsg2
else ; All the parameters were provided
mov ch, x1 ; Define screen area to scroll.
mov cl, y1
mov dh, y2
mov dl, x2
endif
endif
endif
endif
CallBIOS <VIDEO_SERVICE>, <INT10_SCROLL_UP>
endif
endm
ScrollDown macro LineCount, Attrib, x1, y1, x2, y2
ErrMsg macro1
display "Caller must provide LineCount and Attribute parameters to ScrollDown."
err
endm
ErrMsg macro2
display "Must provide all coordinate parameters to ScrollDown macro."
err
endm
ifb <LineCount>
ErrMsg1
else
mov al, LineCount
ifb <Attrib>
ErrMsg1
else
LoadBH <Attrib>
endif
ifb <x1>
mov ch, 0 ; Use default screen coordinates
mov cl, 0
mov dh, 79d
ScreenRows ; Get current number of rows
mov dl, al
else
ifb <y1>
ErrMsg2
else
ifb <x2>
ErrMsg2
else
ifb <y2>
ErrMsg2
else ; All the parameters were provided
mov ch, x1 ; Define screen area to scroll.
mov cl, y1
mov dh, y2
mov dl, x2
endif
endif
endif
endif
CallBIOS <VIDEO_SERVICE>, <INT10_SCROLL_DOWN>
endif
endm
SetVideoMode macro Mode
ifb <Mode>
display "Caller must provide Mode parameter to SetVideoMode."
err
else
ifidni <al>, <Mode>
; Do nothing
else
mov al, Mode
endif
CallBIOS <VIDEO_SERVICE>, <INT10_SET_MODE>
endif
endm
SetCursorShape macro Starting, Ending
ifb <Starting>
display "You must specify the Starting and Ending parameters to the"
display "call to SetCursorShape."
err
endif
ifb <Ending>
display "You must supply the Ending scan line parameter to the call"
display "to SetCursorShape."
err
endif
ifidni <ch>, <Starting>
; Do nothing
else
mov ch, Starting ; Store starting scan line
endif
ifidni <cl>, <Ending>
; Do nothing
else
mov cl, Ending ; Store ending scan line
endif
CallBIOS <VIDEO_SERVICE>, <INT10_SET_CURSOR_SHAPE>
endm
GetCursorShape macro
WhereXY ; Get cursor position and shape
endm
GetLightPenPos macro
CallBIOS <VIDEO_SERVICE>, <INT10_READ_LIGHT_PEN>
endm
SetDisplayPage macro Page
ifb <Page>
xor al, al ; Use default video page of 0
else
ifidni <al>, <Page>
; Do nothing
else
mov al, Page
endif
endif
CallBIOS <VIDEO_SERVICE>, <INT10_SELECT_DISPLAY_PAGE>
endm
GetCharAttr macro Page
LoadBH <Page>
CallBIOS <VIDEO_SERVICE>, <INT10_READ_ATTR_CHAR>
endm
PutCharAttr macro Character, Attribute, Count, Page
ErrMsg macro
display "You must provide character/attribute and count parameters to PutCharAttr."
err
endm
ifb <Character>
ErrMsg
else
ifb <Attribute>
ErrMsg
else
ifb <Count>
ErrMsg
else
LoadBH <Page>
mov bl, Attribute
mov al, Character
mov cx, Count
CallBIOS <VIDEO_SERVICE>, <INT10_WRITE_ATTR_CHAR>
endif
endif
endif
endm
PutChar macro Character, Count, Page, Color
ErrMsg macro
display "You must provide character and count parameters to PutChar."
err
endm
ifb <Character>
ErrMsg
else
ifb <Count>
ErrMsg
else
LoadBH <Page>
ifb <Color> ; Determine the attribute
GetCharAttr <bh>
mov bl, ah
else
mov bl, Color
endif
mov al, Character
mov cx, Count
CallBIOS <VIDEO_SERVICE>, <INT10_WRITE_CHAR>
endif
endif
endm
SetColorPalette macro Entry, Color
ErrMsg macro
display "You must provide Entry and Color parameters to SetColorPalette."
err
endm
ifb <Entry>
ErrMsg
else
ifb <Color>
ErrMsg
else
LoadBH <Entry>
mov bl, Color
CallBIOS <VIDEO_SERVICE>, <INT10_SET_COLOR_PALETTE>
endif
endif
endm
PutPixel macro X, Y, Color
ErrMsg macro
display "You must provide coordinate and color parameters to PutPixel."
err
endm
ifb <X>
ErrMsg
else
ifb <Y>
ErrMsg
else
ifb <Color>
ErrMsg
else
mov al, Color
mov cx, X
mov dx, Y
CallBIOS <VIDEO_SERVICE>, <INT10_WRITE_PIXEL>
endif
endif
endif
endm
GetPixel macro X, Y
ErrMsg macro
display "You must provide coordinate parameters to GetPixel."
err
endm
ifb <X>
ErrMsg
else
ifb <Y>
ErrMsg
else
mov cx, X
mov dx, Y
CallBIOS <VIDEO_SERVICE>, <INT10_READ_PIXEL>
endif
endif
endm
macro PutTTY Character, Page, Color
ErrMsg macro
display "You must provide character, page and color parameters to PutTTY."
err
endm
ifb <Character>
ErrMsg
else
ifb <Page>
ErrMsg
else
ifnb <Color>
mov bl, Color
else
mov al, Character
LoadBH <Page>
CallBIOS <VIDEO_SERVICE>, <INT10_WRITE_TTY>
endif
endif
endif
endm
SetPaletteRegs macro SubService, IndexIntensity, Color, ListSeg, ListOfs
local RegToSet, BlinkIntensity, ListAddr, DoCall
ErrMsg macro
display "You must provide the SubService, IndexIntensity, Color and"
display "address parameters to SetPaletteRegs."
err
endm
ifb <SubService>
ErrMsg
else
ifb <IndexIntensity>
ErrMsg
else
ifb <Color>
ErrMsg
else
ifb <ListSeg>
ErrMsg
else
ifb <ListOfs>
ErrMsg
else
mov al, SubService ; Indicate palette service
mov bh, Color ; Store color
cmp al, 00h ; If al = 0 we are setting
; a palette register
jne short ListAddr
; Indicate which palette register
mov bl, IndexIntensity
jmp short DoCall
ListAddr:
cmp al, 02h ; If al = 2 we have a pointer to
;a list
jne short BlinkIntensity
LoadSegment <es>, <ListSeg>
mov dx, ListOfs
jmp short DoCall
BlinkIntensity: ; Indicate blinking or intensity
mov bl, IndexIntensity
DoCall:
CallBIOS <VIDEO_SERVICE>, <INT10_SET_PALETTE_REGS>
endif
endif
endif
endif
endif
endm
PutString macro Mode, X, Y, StringSeg, StringOfs, Length, Page, Attribute
local DoCall
ErrMsg macro
display "Call to PutString requires appropriate parameters."
err
endm
ifb <Mode> ; Verify that parameters were provided
ErrMsg
else
ifb <X>
ErrMsg
else
ifb <Y>
ErrMsg
else
ifb <StringSeg>
ErrMsg
else
ifb <StringOfs>
ErrMsg
else
ifb <Length>
ErrMsg
else
ifb <Page> ; Neither Page or Attribute are
; provided
xor bh, bh ; Use default page of 0
; Using mode 2 or 3
else
ifnb <Attribute>
; Using Mode 0 or 1
mov bl, Attribute
endif
mov bh, Page
endif
mov cx, Length
mov dh, Y
mov dl, X
LoadSegment <es>, <StringSeg>
mov bp, StringOfs
mov al, Mode
CallBIOS <VIDEO_SERVICE>, <INT10_WRITE_STRING>
endif
endif
endif
endif
endif
endif
endm
ScreenRows macro
mov dl, 25d ; Assume 25 lines
mov al, 30h
CallBIOS <VIDEO_SERVICE>, <INT10_FONT_SIZE>
endm
GetChar macro
CallBIOS <KEYBOARD_SERVICE>, <INT16_READ_CHAR>
endm
GetKbdStatus macro
CallBIOS <KEYBOARD_SERVICE>, <INT16_KBD_STATUS>
endm
GetKbdFlags macro
CallBIOS <KEYBOARD_SERVICE>, <INT16_KBD_FLAGS>
endm