Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1127 lines
51 KiB

  1. ;/*
  2. ; * Microsoft Confidential
  3. ; * Copyright (C) Microsoft Corporation 1988 - 1991
  4. ; * All Rights Reserved.
  5. ; */
  6. PAGE ,132 ;AN000;
  7. TITLE DOS GRAPHICS Command - Color printing modules
  8. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;AN000;
  9. ;; DOS - GRAPHICS Command
  10. ;;
  11. ;; ;AN000;
  12. ;; File Name: GRCOLPRT.ASM ;AN000;
  13. ;; ---------- ;AN000;
  14. ;; ;AN000;
  15. ;; Description: ;AN000;
  16. ;; ------------ ;AN000;
  17. ;; This file contains the code for printing a screen (text and graphics) ;AN000;
  18. ;; on a COLOR printer. ;AN000;
  19. ;; ;AN000;
  20. ;; Documentation Reference: ;AN000;
  21. ;; ------------------------ ;AN000;
  22. ;; OASIS High Level Design ;AN000;
  23. ;; OASIS GRAPHICS I1 Overview ;AN000;
  24. ;; ;AN000;
  25. ;; Procedures Contained in This File: ;AN000;
  26. ;; ---------------------------------- ;AN000;
  27. ;; ;AN000;
  28. ;; PRINT_COLOR ;AN000;
  29. ;; SCAN_FOR_BANDS_APA ;AN000;
  30. ;; SCAN_FOR_BANDS_TXT ;AN000;
  31. ;; PRINT_BAND_APA ;AN000;
  32. ;; PRINT_BAND_TXT ;AN000;
  33. ;; SET_CURSOR ;AN000;
  34. ;; SET_COLOR_BAND ;AN000;
  35. ;; INIT_BLACK_BOX ;AN000;
  36. ;; ;AN000;
  37. ;; ;AN000;
  38. ;; Include Files Required: ;AN000;
  39. ;; ----------------------- ;AN000;
  40. ;; ;AN000;
  41. ;; GRCTRL.EXT - Externals for print screen control ;AN000;
  42. ;; GRCTRL.STR - Structures and equates for print screen control ;AN000;
  43. ;; GRPATTRN.STR - Structures for the printer patterns. ;AN000;
  44. ;; ;AN000;
  45. ;; GRSHAR.STR - Shared Data Area Structure ;AN000;
  46. ;; ;AN000;
  47. ;; STRUC.INC - Macros for using structured assembly language ;AN000;
  48. ;; ;AN000;
  49. ;; External Procedure References: ;AN000;
  50. ;; ------------------------------ ;AN000;
  51. ;; FROM FILE GRCTRL.ASM: ;AN000;
  52. ;; PRT_SCR - Main module for printing the screen. ;AN000;
  53. ;; TO FILE GRCOMMON.ASM ;AN000;
  54. ;; Common modules - tools for printing a screen. ;AN000;
  55. ;; ;AN000;
  56. ;; Linkage Instructions: ;AN000;
  57. ;; -------------------- ;AN000;
  58. ;; Refer to GRAPHICS.ASM ;AN000;
  59. ;; ;AN000;
  60. ;; Change History: ;AN000;
  61. ;; --------------- ;AN000;
  62. ;; Date last updated 5/26/87. ;AN000;
  63. ;; ;AN000;
  64. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;AN000;
  65. PAGE ;AN000;
  66. CODE SEGMENT PUBLIC 'CODE' ;AN000;
  67. ASSUME CS:CODE,DS:CODE ;AN000;
  68. ;AN000;
  69. PUBLIC PRINT_MODULE_START ;; Color modules public ;AN000;
  70. PUBLIC PRINT_COLOR ;; procedures ;AN000;
  71. PUBLIC LEN_OF_COLOR_MODULES ;; ;AN000;
  72. ;; ;AN000;
  73. .XLIST ; ;AN000;
  74. INCLUDE GRCTRL.STR ; Stuctures needed ;AN000;
  75. INCLUDE GRSHAR.STR ; for both set of print modules ;AN000;
  76. INCLUDE GRPATTRN.STR ; ;AN000;
  77. ; ;AN000;
  78. INCLUDE GRCTRL.EXT ; Externals from PRT_SCR control module ;AN000;
  79. INCLUDE STRUC.INC ; ;AN000;
  80. .LIST ; ;AN000;
  81. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AN000;
  82. ;; ;AN000;
  83. ;; ;AN000;
  84. ;; PRINT_COLOR : PRINT TEXT AND APA MODE SCREEN ON A COLOR PRINTER ;AN000;
  85. ;; ;AN000;
  86. ;-------------------------------------------------------------------------------;AN000;
  87. ; ;AN000;
  88. ; INPUT: BP = Offset of the shared data area ;AN000;
  89. ; XLT_TAB = Color translation table ;AN000;
  90. ; ;AN000;
  91. ; OUTPUT: PRINTER ;AN000;
  92. ; ;AN000;
  93. ;-------------------------------------------------------------------------------;AN000;
  94. ;; ;AN000;
  95. ;; Description: ;AN000;
  96. ;; Main control module for printing of text and graphics ;AN000;
  97. ;; on color printers. ;AN000;
  98. ;; ;AN000;
  99. ;; Calls either the text or graphics mode routine. ;AN000;
  100. ;; ;AN000;
  101. ;; Called By: ;AN000;
  102. ;; PRINT_SCREEN ;AN000;
  103. ;; ;AN000;
  104. ;; External Calls: ;AN000;
  105. ;; LOC_MODE_PRT_INFO, PRINT_COLOR_APA, PRINT_COLOR_TXT ;AN000;
  106. ;; ;AN000;
  107. ;; Logic: ;AN000;
  108. ;; IF MODE_TYPE = TXT ;AN000;
  109. ;; THEN CALL PRINT_COLOR_TXT ;AN000;
  110. ;; ELSE (MODE_TYPE = APA) ;AN000;
  111. ;; CALL LOC_MODE_PRT_INFO ; Get DISPLAYMODE record from the SHARED AREA ;AN000;
  112. ;; CALL PRINT_COLOR_APA ;AN000;
  113. ;; RETURN ;AN000;
  114. ;; ;AN000;
  115. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;AN000;
  116. PRINT_MODULE_START LABEL BYTE ;AN000;
  117. PRINT_COLOR PROC NEAR ;AN000;
  118. JMP SHORT PRINT_COLOR_BEGIN ;AN000;
  119. WHITE_BOX DB 0,0,0,0 ; Print boxes for APA mode ;AN000;
  120. BLACK_BOX DB ?,?,?,? ; NOTE: 1 print box = 1 screen pixel ;AN000;
  121. ; only BOX_W bytes are used out of these 2 ;AN000;
  122. ; boxes. ;AN000;
  123. ;AN000;
  124. REQ_BAND_MASK DB ? ; Mask = "All color bands needed for the current;AN000;
  125. ; print line". ;AN000;
  126. ;AN000;
  127. PRINT_COLOR_BEGIN: ;AN000;
  128. .IF <MODE_TYPE EQ TXT> ;AN000;
  129. .THEN ;AN000;
  130. ;-------------------------------------------------------------------------------;AN000;
  131. ; The screen is in a text mode: ;AN000;
  132. ;-------------------------------------------------------------------------------;AN000;
  133. CALL PRINT_COLOR_TXT ; Print a text screen on a color printer;AN000;
  134. .ELSE ;AN000;
  135. ;-------------------------------------------------------------------------------;AN000;
  136. ; The screen is in All Points Addressable mode: ;AN000;
  137. ; Locate and extract printer DISPLAYMODE information from ;AN000;
  138. ; the shared data area. ;AN000;
  139. ;-------------------------------------------------------------------------------;AN000;
  140. CALL LOC_MODE_PRT_INFO ; Get printer info related to curr. mode;AN000;
  141. ; ;AN000;
  142. ;-------Test if DISPLAYMODE info record was found: ;AN000;
  143. .IF <ERROR_CODE EQ DISPLAYMODE_INFO_NOT_FOUND> ;AN000;
  144. .THEN ;AN000;
  145. MOV ERROR_CODE,UNABLE_TO_PRINT ; IF no record found, ;AN000;
  146. JMP SHORT PRINT_COLOR_END ; then, return error code ;AN000;
  147. .ENDIF ; and quit procedure ;AN000;
  148. ; ;AN000;
  149. ;-------Get the box size from the DISPLAYMODE info record: ;AN000;
  150. MOV BX,CUR_MODE_PTR ; BX := Offset current DISPLAYMODE info.;AN000;
  151. MOV AH,[BX].BOX_WIDTH ; Take local copy of the box size. ;AN000;
  152. MOV BOX_W,AH ; in BOX_W and BOX_H ;AN000;
  153. MOV AL,[BX].BOX_HEIGHT ;AN000;
  154. MOV BOX_H,AL ;AN000;
  155. ; ;AN000;
  156. ;-------Verify if the box size obtained from DISPLAYMODE info. is valid ;AN000;
  157. .IF <ZERO AL> OR ; IF height of the box is 0 ;AN000;
  158. .IF <ZERO AH> ; OR width of the box is 0 ;AN000;
  159. .THEN ; THEN we can't print: ;AN000;
  160. MOV ERROR_CODE,UNABLE_TO_PRINT ; return error code ;AN000;
  161. JMP SHORT PRINT_COLOR_END ; and quit ;AN000;
  162. .ENDIF ;AN000;
  163. ; ;AN000;
  164. ;-------Get the Print Orientation from the DISPLAYMODE info record ;AN000;
  165. .IF <[BX].PRINT_OPTIONS EQ ROTATE>; If printing sideways ;AN000;
  166. .THEN ; then: ;AN000;
  167. MOV ROTATE_SW,ON ; Rotate switch := "ON" ;AN000;
  168. .ENDIF ;AN000;
  169. CALL PRINT_COLOR_APA ; Print APA screen on a color printer ;AN000;
  170. .ENDIF ;AN000;
  171. PRINT_COLOR_END: ;AN000;
  172. RET ;AN000;
  173. PRINT_COLOR ENDP ;AN000;
  174. PAGE ;AN000;
  175. ;===============================================================================;AN000;
  176. ; ;AN000;
  177. ; PRINT_COLOR_TXT: PRINT A TEXT MODE SCREEN ON A COLOR PRINTER ;AN000;
  178. ; ;AN000;
  179. ;-------------------------------------------------------------------------------;AN000;
  180. ; ;AN000;
  181. ; INPUT: BP = Offset of the shared data area ;AN000;
  182. ; XLT_TAB = Color translation table ;AN000;
  183. ; SCREEN_WIDTH = Maximum length of Screen scan line. ;AN000;
  184. ; SCREEN_HEIGHT = Number of SCAN LINES on the screen ;AN000;
  185. ; ;AN000;
  186. ; OUTPUT: PRINTER ;AN000;
  187. ; ;AN000;
  188. ;-------------------------------------------------------------------------------;AN000;
  189. ; ;AN000;
  190. ; DESCRIPTION: The screen is read and printed line by line; character by ;AN000;
  191. ; character. ;AN000;
  192. ; Each line is first scanned in order to determine what colors are present on ;AN000;
  193. ; it and what printer bands will be needed to approximate these colors. ;AN000;
  194. ; ;AN000;
  195. ; For each printer color band needed for the current line, this screen line ;AN000;
  196. ; is READ AGAIN character by character; If the color of the ;AN000;
  197. ; current character must use the current color band to be ;AN000;
  198. ; approximated; then, the character is printed. ;AN000;
  199. ; ;AN000;
  200. ; ;AN000;
  201. ; LOGIC : ;AN000;
  202. ; ;AN000;
  203. ; Save current coordinates of the cursor. ;AN000;
  204. ; Initialize the cursor to the first character to be read (Top-left of screen) ;AN000;
  205. ; FOR each row on the screen (SCREEN_HEIGHT) ;AN000;
  206. ; BEGIN ;AN000;
  207. ; CALL SCAN_FOR_BANDS_TXT(CUR_ROW,CUR_COLUMN,REQ_BAND_MASK) ;AN000;
  208. ; CUR_BAND_MASK := 01H ;AN000;
  209. ; IF REQ_BAND_MASK <> 0 THEN ;AN000;
  210. ; DO 8 TIMES ;AN000;
  211. ; IF (REQ_BAND_MASK AND CUR_BAND_MASK)=1 THEN ;AN000;
  212. ; CALL PRINT_BAND_TXT(CUR_ROW,CUR_COLUMN,CUR_BAND_MASK) ;AN000;
  213. ; CALL PRINT_BYTE(CARRIAGE_RETURN) ;AN000;
  214. ; ENDIF ;AN000;
  215. ; Shift CUR_BAND_MASK one bit left ;AN000;
  216. ; ENDDO ;AN000;
  217. ; CALL PRINT_BYTE(LINE_FEED) ;AN000;
  218. ; ENDIF ;AN000;
  219. ; CUR_COLUMN := 0 ; Get next row coordinates ;AN000;
  220. ; CUR_ROW := CUR_ROW + 1 ;AN000;
  221. ; END ; FOR each row on the screen ;AN000;
  222. ; Restore initial coordinates of the cursor ;AN000;
  223. ; ;AN000;
  224. PRINT_COLOR_TXT PROC ;AN000;
  225. PUSH BX ;AN000;
  226. PUSH CX ;AN000;
  227. PUSH DX ;AN000;
  228. ; ;AN000;
  229. ;-------Save coordinates of the cursor on the stack: ;AN000;
  230. MOV AH,READ_CURSOR_CALL ; Read position of the cursor on the screen;AN000;
  231. MOV BH,CUR_PAGE ; for the current page ;AN000;
  232. INT 10H ; Call BIOS ;AN000;
  233. PUSH DX ; DH := Row number, DL := Column number ;AN000;
  234. ; CX := Top line and bottom line for cursor;AN000;
  235. ; (not needed) ;AN000;
  236. ; ;AN000;
  237. ;-------Initialize the cursor to the first character to be read ;AN000;
  238. MOV CUR_ROW,0 ; cursor = position (0,0) on the screen ;AN000;
  239. MOV CUR_COLUMN,0 ; (top-left corner) ;AN000;
  240. CALL SET_CURSOR ;AN000;
  241. ;AN000;
  242. MOV CX,SCREEN_HEIGHT ; CX := Number of rows on the screen ;AN000;
  243. ;-------------------------------------------------------------------------------;AN000;
  244. ; ;AN000;
  245. ; FOR EACH ROW ON THE SCREEN: ;AN000;
  246. ; ;AN000;
  247. ;-------------------------------------------------------------------------------;AN000;
  248. PRINT_1_TEXT_LINE: ;AN000;
  249. CALL SCAN_FOR_BANDS_TXT ; REQ_BAND_MASK := Print bands needed ;AN000;
  250. ; for this line ;AN000;
  251. MOV DL,01H ; DL :="Current Band printed" mask ;AN000;
  252. ;AN000;
  253. ; NOTE: The COLORSELECT records are stored sequentially in the ;AN000;
  254. ; Shared Data area. The band mask 00000001 corresponds to the first ;AN000;
  255. ; record, 00000010 to the second, etc. ;AN000;
  256. ; The COLORSELECT record indicates: "How to select the color band" ;AN000;
  257. ; on the printer (It contains the bytes that must be sent to the printer;AN000;
  258. ;AN000;
  259. MOV BX,DS:[BP].COLORSELECT_PTR; BX := relative offset of COLORSELECT;AN000;
  260. ADD BX,BP ; BX := absolute offset of COLORSELECT ;AN000;
  261. PUSH CX ; Save row counter ;AN000;
  262. MOV CX,8 ; For up to the maximum number of print ;AN000;
  263. ; bands with this printer ;AN000;
  264. ;-----------------------------------------------------------------------;AN000;
  265. ; ;AN000;
  266. ; FOR each Color Band available with the ribbon installed on the printer;AN000;
  267. ; ;AN000;
  268. ;-----------------------------------------------------------------------;AN000;
  269. PRINT_1_COLOR_BAND_TXT: ; Do one pass of the printer head: ;AN000;
  270. .IF <BIT REQ_BAND_MASK AND DL> ; IF this color band is needed ;AN000;
  271. .THEN ; by any character on the line ;AN000;
  272. CALL SET_COLOR_BAND ; then, select the color band ;AN000;
  273. CALL PRINT_BAND_TXT ; and do one Print Pass for it. ;AN000;
  274. .IF <BIT ERROR_CODE NZ PRINTER_ERROR> ;AN000;
  275. .THEN ; A printer error occurred: ;AN000;
  276. POP CX ; Restore the line counter ;AN000;
  277. JMP SHORT PRINT_COLOR_TXT_END ; and quit. ;AN000;
  278. .ENDIF ;AN000;
  279. MOV AL,CR ; Print a carriage return ;AN000;
  280. CALL PRINT_BYTE ;AN000;
  281. .IF C ;AN000;
  282. .THEN ; A printer error occurred: ;AN000;
  283. POP CX ; Restore the line counter ;AN000;
  284. JMP SHORT PRINT_COLOR_TXT_END ; and quit. ;AN000;
  285. .ENDIF ; ENDIF printer error ;AN000;
  286. .ENDIF ; ENDIF this color band is needed ;AN000;
  287. SHL DL,1 ; Get next Color Band mask ;AN000;
  288. ; [BX] := Next COLORSELECT record: ;AN000;
  289. MOV AL,[BX].NUM_SELECT_ESC ; skip the escape bytes ;AN000;
  290. XOR AH,AH ; ;AN000;
  291. ADD BX,AX ; ;AN000;
  292. INC BX ; skip the NUM_SELECT_ESC field ;AN000;
  293. LOOP PRINT_1_COLOR_BAND_TXT ;AN000;
  294. POP CX ; Restore row counter ;AN000;
  295. ; ;AN000;
  296. ;-----Print a line feed: ;AN000;
  297. MOV AL,LF ;AN000;
  298. CALL PRINT_BYTE ; Send the LF ;AN000;
  299. JC PRINT_COLOR_TXT_END ; If printer error, quit ;AN000;
  300. ; ;AN000;
  301. ;-------Get coordinates of the first character in the next scan line: ;AN000;
  302. INC CUR_ROW ; CUR_ROW + 1 ;AN000;
  303. MOV CUR_COLUMN,0 ; CUR_COLUMN := 0 ;AN000;
  304. ; ;AN000;
  305. ;-------Point CURSOR to first character in the next scan line: ;AN000;
  306. CALL SET_CURSOR ;AN000;
  307. ;AN000;
  308. LOOP PRINT_1_TEXT_LINE ; Print next scan line ;AN000;
  309. ;AN000;
  310. ; ;AN000;
  311. ;-------Restore CURSOR to its original location (saved on the stack) ;AN000;
  312. PRINT_COLOR_TXT_END: ;AN000;
  313. POP DX ; DH := Row number, DL := Column number ;AN000;
  314. MOV CL,DH ;AN000;
  315. MOV CUR_ROW,CX ; CUR_ROW := Original row number ;AN000;
  316. MOV CL,DL ;AN000;
  317. MOV CUR_COLUMN,CX ; CUR_COLUMN := Original column number ;AN000;
  318. CALL SET_CURSOR ; Set the cursor back there ;AN000;
  319. ;AN000;
  320. POP DX ;AN000;
  321. POP CX ;AN000;
  322. POP BX ;AN000;
  323. RET ;AN000;
  324. PRINT_COLOR_TXT ENDP ;AN000;
  325. PAGE ;AN000;
  326. ;===============================================================================;AN000;
  327. ; ;AN000;
  328. ; SCAN_FOR_BANDS_TEXT: DETERMINE WHAT PRINTER COLOR BANDS ARE NEEDED FOR ;AN000;
  329. ; PRINTING THE COLORS ON THE CURRENT SCREEN LINE. ;AN000;
  330. ; ;AN000;
  331. ;-------------------------------------------------------------------------------;AN000;
  332. ; ;AN000;
  333. ; INPUT: CUR_ROW = row to start scanning ;AN000;
  334. ; CUR_COLUMN = column to start scanning ;AN000;
  335. ; ROTATE_SW = ON if printing is sideways ;AN000;
  336. ; ;AN000;
  337. ; OUTPUT: REQ_BAND_MASK ;AN000;
  338. ; ;AN000;
  339. ; ;AN000;
  340. ; DATA STRUCTURE REFERENCED: ;AN000;
  341. ; XLT_TAB = Color translation table ;AN000;
  342. ; ;AN000;
  343. ;-------------------------------------------------------------------------------;AN000;
  344. ; ;AN000;
  345. ; DESCRIPTION: Read all characters on the current line from left to right. ;AN000;
  346. ; For each character, extract its band mask from the color translation table. ;AN000;
  347. ; Add the band mask required for this character to the "Required Bands" mask. ;AN000;
  348. ; ;AN000;
  349. ; LOGIC : ;AN000;
  350. ; Save current coordinates ;AN000;
  351. ; DO (SCREEN_WIDTH) TIMES ;AN000;
  352. ; Read a character ;AN000;
  353. ; Get its Band Mask from the color translation table in AL ;AN000;
  354. ; OR REQ_BAND_MASK,AL ; Add its band mask to the "Required bands" mask;AN000;
  355. ; ; Get coordinates of the next character: ;AN000;
  356. ; INC CUR_COLUMN ;AN000;
  357. ; Restore initial coordinates ;AN000;
  358. ; ;AN000;
  359. SCAN_FOR_BANDS_TXT PROC NEAR ;AN000;
  360. PUSH CUR_ROW ; Save coordinates ;AN000;
  361. PUSH CUR_COLUMN ;AN000;
  362. PUSH AX ;AN000;
  363. PUSH BX ;AN000;
  364. PUSH CX ;AN000;
  365. ;AN000;
  366. MOV REQ_BAND_MASK,0 ; No Color bands needed so far... ;AN000;
  367. MOV CX,SCREEN_WIDTH ; For each character on the screen row ;AN000;
  368. ;-------------------------------------------------------------------------------;AN000;
  369. ; ;AN000;
  370. ; FOR each character on the current scan line: ;AN000;
  371. ; ;AN000;
  372. ;-------------------------------------------------------------------------------;AN000;
  373. SCAN_1_CHAR: ;AN000;
  374. ; ;AN000;
  375. ;-------Read the character at the current cursor position ;AN000;
  376. CALL SET_CURSOR ; Set cursor at character to be read ;AN000;
  377. MOV AH,READ_CHAR_CALL ; Read one character ;AN000;
  378. MOV BH,CUR_PAGE ; at CUR_PAGE, CUR_COLUMN and CUR_ROW ;AN000;
  379. INT 10H ; Call BIOS ;AN000;
  380. ; AL:=Character read, AH:=Byte attribute;AN000;
  381. AND AH,00001111B ; AH := Foreground color attribute ;AN000;
  382. XCHG AL,AH ; AL := AH, used as index in the XLT_TAB;AN000;
  383. MOV BX,OFFSET XLT_TAB ; BX := Offset of translation table ;AN000;
  384. XLAT XLT_TAB ; AL = Band mask ;AN000;
  385. ; ;AN000;
  386. ;-------Obtain what Print bands are required to print the color of this char: ;AN000;
  387. OR REQ_BAND_MASK,AL ;AN000;
  388. ;AN000;
  389. INC CUR_COLUMN ; Get coordinates of next character ;AN000;
  390. LOOP SCAN_1_CHAR ; Scan next character ;AN000;
  391. ;AN000;
  392. POP CX ;AN000;
  393. POP BX ;AN000;
  394. POP AX ;AN000;
  395. POP CUR_COLUMN ; Restore initial coordinates ;AN000;
  396. POP CUR_ROW ;AN000;
  397. RET ;AN000;
  398. SCAN_FOR_BANDS_TXT ENDP ;AN000;
  399. PAGE ;AN000;
  400. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AN000;
  401. ;; ;AN000;
  402. ;; PRINT_BAND_TXT: PRINT ALL CHARACTERS ON THE CURRENT LINE THAT ARE THE SAME ;AN000;
  403. ;; COLOR AS THE CURRENT PRINT BAND. ;AN000;
  404. ;; ;AN000;
  405. ;-------------------------------------------------------------------------------;AN000;
  406. ; ;AN000;
  407. ; INPUT: CUR_ROW, ;AN000;
  408. ; CUR_COLUMN : Coordinates of the first character to be read in ;AN000;
  409. ; the current scan line. ;AN000;
  410. ; DL : Band mask indicating what print band to use ;AN000;
  411. ; for this print pass. ;AN000;
  412. ; SCAN_LINE_LENGTH: Length of the current scan line. ;AN000;
  413. ; ;AN000;
  414. ; OUTPUT: PRINTER ;AN000;
  415. ; ;AN000;
  416. ;-------------------------------------------------------------------------------;AN000;
  417. ; LOGIC: ;AN000;
  418. ; DO (SCAN_LINE_LENGTH) TIMES ;AN000;
  419. ; CALL BIOS INT 10H Read Character - returns CHAR, COLOR_NUM ;AN000;
  420. ; IF (CUR_BAND_MASK AND XLAT_TAB[COLOR_NUM])=1 ;AN000;
  421. ; THEN IF Background color is same as Foreground color ;AN000;
  422. ; THEN ;AN000;
  423. ; CALL PRINT_BYTE(SOLID_BOX) ;AN000;
  424. ; ELSE ;AN000;
  425. ; CALL PRINT_BYTE(CHAR) ;AN000;
  426. ; ELSE ;AN000;
  427. ; CALL PRINT_BYTE(blank) ;AN000;
  428. ; Get coordinates of the next character ;AN000;
  429. ; ;AN000;
  430. PRINT_BAND_TXT PROC ;AN000;
  431. SOLID_BOX EQU 219 ; ASCII Code for printing a solid box ;AN000;
  432. BLANK EQU 32 ; ASCII code for printing a space ;AN000;
  433. PUSH CUR_COLUMN ; Save column number ;AN000;
  434. PUSH AX ;AN000;
  435. PUSH BX ;AN000;
  436. PUSH CX ;AN000;
  437. MOV CX,SCREEN_WIDTH ; CX := Number of character on one screen row ;AN000;
  438. ;===============================================================================;AN000;
  439. ; ;AN000;
  440. ; FOR each character on the current row: ;AN000;
  441. ; ;AN000;
  442. ;===============================================================================;AN000;
  443. PRINT_1_CHAR: ;AN000;
  444. ; ;AN000;
  445. ;-------Read the character at the current cursor position ;AN000;
  446. CALL SET_CURSOR ; Set cursor at character to be read ;AN000;
  447. MOV AH,READ_CHAR_CALL ; Read one character ;AN000;
  448. MOV BH,CUR_PAGE ; at CUR_PAGE, CUR_COLUMN and CUR_ROW ;AN000;
  449. INT 10H ; Call BIOS ;AN000;
  450. ; AL:=Character read, AH:=Byte attribute;AN000;
  451. MOV CUR_CHAR,AL ;AN000;
  452. MOV DH,AH ; DH := Byte attribute ;AN000;
  453. AND DH,11110000B ; DH := Background color ;AN000;
  454. SHR DH,1 ; DH := Background color right justified;AN000;
  455. SHR DH,1 ;AN000;
  456. SHR DH,1 ;AN000;
  457. SHR DH,1 ;AN000;
  458. AND AH,00001111B ; AH := Foreground color right justified;AN000;
  459. ; ;AN000;
  460. ;-------Test if this character should be printed (need color of the current band;AN000;
  461. MOV AL,AH ; AL:=color used as index in the XLT_TAB;AN000;
  462. MOV BX,OFFSET XLT_TAB ; BX := Offset of translation table ;AN000;
  463. XLAT XLT_TAB ; AL := Band mask (DL=current band mask);AN000;
  464. .IF <BIT AL AND DL> ;If needs this band to print the color ;AN000;
  465. .THEN ; of this character ;AN000;
  466. .IF <AH EQ DH> ; then: when foreground = background ;AN000;
  467. .THEN ; send a solid box ;AN000;
  468. MOV AL,SOLID_BOX ; ;AN000;
  469. .ELSE ; when foreground <> background ;AN000;
  470. MOV AL,CUR_CHAR ; send the character ;AN000;
  471. .ENDIF ; Endif foreground = background ;AN000;
  472. .ELSE ; else: send a blank ;AN000;
  473. MOV AL,BLANK ; ;AN000;
  474. .ENDIF ; Endif color band needed ;AN000;
  475. CALL PRINT_BYTE ; Print the byte ;AN000;
  476. JC PRINT_BAND_TXT_END ; If printer error occurred: QUIT ;AN000;
  477. INC CUR_COLUMN ; Else, Get next column; keep going ;AN000;
  478. LOOP PRINT_1_CHAR ;AN000;
  479. ;AN000;
  480. PRINT_BAND_TXT_END: ;AN000;
  481. POP CX ;AN000;
  482. POP BX ;AN000;
  483. POP AX ;AN000;
  484. POP CUR_COLUMN ; Restore column number ;AN000;
  485. RET ;AN000;
  486. CUR_CHAR DB ? ;AN000;
  487. PRINT_BAND_TXT ENDP ;AN000;
  488. PAGE ;AN000;
  489. ;===============================================================================;AN000;
  490. ; ;AN000;
  491. ; PRINT_COLOR_APA: PRINT AN APA MODE SCREEN ON A COLOR PRINTER ;AN000;
  492. ; ;AN000;
  493. ;-------------------------------------------------------------------------------;AN000;
  494. ; ;AN000;
  495. ; INPUT: BP = Offset of the shared data area ;AN000;
  496. ; XLT_TAB = Color translation table ;AN000;
  497. ; CUR_MODE_PTR = Coordinates of current DISPLAYMODE info. ;AN000;
  498. ; ;AN000;
  499. ; OUTPUT: PRINTER ;AN000;
  500. ; ;AN000;
  501. ;-------------------------------------------------------------------------------;AN000;
  502. ; ;AN000;
  503. ; DESCRIPTION: Each pixel on the screen is printed as a "box" of dots on the ;AN000;
  504. ; printer. For a screen pixel of a given color, the best color approximation ;AN000;
  505. ; is chosen among the color available on the printer. ;AN000;
  506. ; ;AN000;
  507. ; The printer colors are obtained by selecting a print band. A few more printer ;AN000;
  508. ; color are obtained by printing twice (or more times) with different color ;AN000;
  509. ; bands. ;AN000;
  510. ; ;AN000;
  511. ; For example, let's say we have a ribbon on the printer with a YELLOW CYAN ;AN000;
  512. ; MAGENTA ribbon and we read a GREEN pixel on the screen. ;AN000;
  513. ; ;AN000;
  514. ; We first determine what "box" size will be used to represent this pixel. ;AN000;
  515. ; Let's say it's a 3x2 box (this is obtained from the DISPLAYMODE record) ;AN000;
  516. ; In all cases, we will print this pixel as a 3x2 box of printer dots. ;AN000;
  517. ; That is, we will print 6 dots on the printer for one on the screen. ;AN000;
  518. ; We do not use any kind of patterns (e,g,. printing only 2 dots out of 6) ;AN000;
  519. ; for printing on the color printer. A screen pixel is either printed ;AN000;
  520. ; as a "full" box of printer dots or not printed at all (e,g,. if it's white).;AN000;
  521. ; ;AN000;
  522. ; Now, from the COLORPRINT records, we know all the colors availables on the ;AN000;
  523. ; printer, and what print bands must be used (or overlaid) in order to ;AN000;
  524. ; obtain them. ;AN000;
  525. ; ;AN000;
  526. ; So, we consult these COLORPRINT records one by one comparing how close ;AN000;
  527. ; the color of each of them is to our GREEN pixel. (the colors for our pixel ;AN000;
  528. ; AND for the printer color are both indicated in terms of RGB values) ;AN000;
  529. ; WE PICK THE CLOSEST PRINTER COLOR. ;AN000;
  530. ; ;AN000;
  531. ; To conclude, our GREEN pixel will be printed by first selecting the YELLOW ;AN000;
  532. ; band, then sending to the printer a "box". Then, the BLUE band is selected ;AN000;
  533. ; and the "box" is sent again. ;AN000;
  534. ; ;AN000;
  535. ; This process is carried line by line. ;AN000;
  536. ; ;AN000;
  537. ; For each line, we first read each pixel to see what color bands are going ;AN000;
  538. ; to be needed for this line. ;AN000;
  539. ; ;AN000;
  540. ; Then, we loop for each band available on the printer. ;AN000;
  541. ; ;AN000;
  542. ; IF the current line needs the current printer band (i.e.,if any pixel on ;AN000;
  543. ; the line needs this color band in order to achieve its color. ;AN000;
  544. ; THEN, we select this color band (we know how to do it from the COLORSELECT ;AN000;
  545. ; record in the Shared Data area) ;AN000;
  546. ; AND we must read the line again; for each pixel that needs the current ;AN000;
  547. ; band a "box" is sent to the printer. ;AN000;
  548. ; ;AN000;
  549. ; LOGIC : ;AN000;
  550. ; CALL INIT_BLACK_BOX ; Initialize a print box ;AN000;
  551. ; CALL GET_SCREEN_INFO ;AN000;
  552. ; CALL SETUP_PRT ;AN000;
  553. ; DO (NB_SCAN_LINES) TIMES ;AN000;
  554. ; CALL DET_CUR_SCAN_LNE_LENGTH ;AN000;
  555. ; IF CUR_SCAN_LNE_LENGTH NE 0 THEN ;AN000;
  556. ; CALL SCAN_FOR_BANDS_APA(CUR_ROW,CUR_COLUMN,REQ_BAND_MASK) ;AN000;
  557. ; CUR_BAND_MASK := 01H ;AN000;
  558. ; IF REQ_BAND_MASK <> 0 THEN ;AN000;
  559. ; DO 8 TIMES ;AN000;
  560. ; IF (REQ_BAND_MASK AND CUR_BAND_MASK)=1 THEN ;AN000;
  561. ; CALL NEW_PRT_LINE ;AN000;
  562. ; CALL PRINT_BAND_APA(CUR_ROW,CUR_COLUMN,CUR_BAND_MASK) ;AN000;
  563. ; CALL PRINT_BYTE(CARRIAGE_RETURN) ;AN000;
  564. ; ENDIF ;AN000;
  565. ; Shift CUR_BAND_MASK one bit left ;AN000;
  566. ; ENDDO ;AN000;
  567. ; ENDIF ; Should make a print pass for this color band ;AN000;
  568. ; CALL PRINT_BYTE(LINE_FEED) ;AN000;
  569. ; ENDIF ; Current scan line is not empty ;AN000;
  570. ; IF rotated print THEN ;AN000;
  571. ; CUR_COLUMN := CUR_COLUMN - BOXES_PER_PRT_BUF ;AN000;
  572. ; CUR_ROW := SAVE_START_ROW ;AN000;
  573. ; ELSE ;AN000;
  574. ; CUR_ROW := CUR_ROW + BOXES_PER_PRT_BUF ;AN000;
  575. ; CUR_COLUMN := SAVE_START_COLUMN ;AN000;
  576. ; ENDIF ;AN000;
  577. ; ENDDO ; Number of Scan lines ;AN000;
  578. ; CALL RESTORE_PRT ;AN000;
  579. ; ;AN000;
  580. PRINT_COLOR_APA PROC ;AN000;
  581. PUSH AX ;AN000;
  582. PUSH BX ;AN000;
  583. PUSH CX ;AN000;
  584. PUSH DX ;AN000;
  585. ;AN000;
  586. ;AN000;
  587. ;-------Initialize print box (A "box" represents one screen pel on the printer) ;AN000;
  588. CALL INIT_BLACK_BOX ;AN000;
  589. ;-------------------------------------------------------------------------------;AN000;
  590. ; ;AN000;
  591. ; Determine where to start reading the screen: ;AN000;
  592. ; If printing sideways, start in LOW LEFT corner. ;AN000;
  593. ; If normal printing, start in TOP LEFT corner. ;AN000;
  594. ; Determine the maximum length for a scan line: ;AN000;
  595. ; If printing sideways, it is the height of the screen. ;AN000;
  596. ; For normal printing, it is the width of the screen. ;AN000;
  597. ; Determine the number of scan lines on the screen. ;AN000;
  598. ; ;AN000;
  599. ;-------------------------------------------------------------------------------;AN000;
  600. CALL GET_SCREEN_INFO ; Get info. about how to read the screen;AN000;
  601. CALL SETUP_PRT ; Set up the printer (Line spacing, etc);AN000;
  602. .IF <BIT ERROR_CODE NZ PRINTER_ERROR> ;AN000;
  603. .THEN ; A printer error occurred: quit ;AN000;
  604. JMP SHORT PRINT_COLOR_APA_END ; ;AN000;
  605. .ENDIF ;AN000;
  606. ;AN000;
  607. MOV CX,NB_SCAN_LINES ;AN000;
  608. ;---------------------------------------------------------------------------- ;AN000;
  609. ; ;AN000;
  610. ; FOR EACH SCAN LINE ON THE SCREEN (and each print line): ;AN000;
  611. ; ;AN000;
  612. ;---------------------------------------------------------------------------- ;AN000;
  613. PRINT_SCAN_LINE: ;AN000;
  614. CALL DET_CUR_SCAN_LNE_LENGTH ; Determine length of the scan line ;AN000;
  615. .IF <CUR_SCAN_LNE_LENGTH NE 0> ; If line is not empty ;AN000;
  616. .THEN ;AN000;
  617. CALL SCAN_FOR_BANDS_APA ; REQ_BAND_MASK := Mask for what print;AN000;
  618. ; bands are needed. ;AN000;
  619. MOV DL,01H ; DL := "Current Band to be printed" ;AN000;
  620. MOV BX,DS:[BP].COLORSELECT_PTR; BX := Offset of COLORSELECT record;AN000;
  621. ADD BX,BP ; ("How to select the color band");AN000;
  622. PUSH CX ; Save scan line counter ;AN000;
  623. MOV CX,8 ; For up to the maximum number of prin;AN000;
  624. ; bands with this printer ;AN000;
  625. ;---------------------------------------------------------------------;AN000;
  626. ; ;AN000;
  627. ; FOR each Color Band needed: ;AN000;
  628. ; ;AN000;
  629. ;---------------------------------------------------------------------;AN000;
  630. PRINT_1_COLOR_BAND_APA: ; Only if this color band is needed: ;AN000;
  631. .IF <BIT REQ_BAND_MASK AND DL> ; Do one pass of the printer head ;AN000;
  632. .THEN ; ;AN000;
  633. CALL SET_COLOR_BAND ; Select the color band on the printer;AN000;
  634. CALL NEW_PRT_LINE ; Send escape sequence to the printer ;AN000;
  635. ; for starting a new graphics line ;AN000;
  636. .IF <BIT ERROR_CODE NZ PRINTER_ERROR> ;AN000;
  637. .THEN ; A printer error occurred: ;AN000;
  638. POP CX ; Restore the line counter and ;AN000;
  639. JMP SHORT PRINT_COLOR_APA_END ; return ;AN000;
  640. .ENDIF ; Endif printer error occurred ;AN000;
  641. ;AN000;
  642. CALL PRINT_BAND_APA ; Do one Print Pass for current band ;AN000;
  643. MOV AL,CR ; Print a carriage return ;AN000;
  644. CALL PRINT_BYTE ;AN000;
  645. .IF C ; If a printer error occurred ;AN000;
  646. .THEN ;AN000;
  647. POP CX ; Restore the line counter and ;AN000;
  648. JMP SHORT PRINT_COLOR_APA_END ; return ;AN000;
  649. .ENDIF ; End if printer error occurred ;AN000;
  650. .ENDIF ; End if this color band is needed ;AN000;
  651. SHL DL,1 ; Get next Color Band mask ;AN000;
  652. ; Locate next COLORSELECT record: ;AN000;
  653. MOV AL,[BX].NUM_SELECT_ESC; skip the escape bytes ;AN000;
  654. XOR AH,AH ;AN000;
  655. ADD BX,AX ;AN000;
  656. INC BX ; skip the NUM_SELECT_ESC field ;AN000;
  657. LOOP PRINT_1_COLOR_BAND_APA ;AN000;
  658. POP CX ; Restore scan line counter ;AN000;
  659. .ENDIF ; Scan line length <> 0 ;AN000;
  660. ; ;AN000;
  661. ;-----Print a line feed: ;AN000;
  662. MOV AL,LF ;AN000;
  663. CALL PRINT_BYTE ;AN000;
  664. JC PRINT_COLOR_APA_END ; If a printer error occurred: quit ;AN000;
  665. ; ;AN000;
  666. ;-------Get coordinates of next scan line: ;AN000;
  667. .IF <ROTATE_SW EQ ON> ; If printing sideways ;AN000;
  668. .THEN ; then: ;AN000;
  669. MOV AL,NB_BOXES_PER_PRT_BUF; AX := Numbers of pels read on row ;AN000;
  670. CBW ; ;AN000;
  671. ADD CUR_COLUMN,AX ; CUR_COLUMN + Number of pels read ;AN000;
  672. MOV AX,SCREEN_HEIGHT ; CUR_ROW := SCREEN_HEIGHT - 1 ;AN000;
  673. DEC AX ; ;AN000;
  674. MOV CUR_ROW,AX ; ;AN000;
  675. .ELSE ; else, printing NOT rotated: ;AN000;
  676. MOV AL,NB_BOXES_PER_PRT_BUF ; AX := Number of pels read on column ;AN000;
  677. CBW ; ;AN000;
  678. ADD CUR_ROW,AX ; CUR_ROW + Number of pels read ;AN000;
  679. MOV CUR_COLUMN,0 ; CUR_COLUMN := 0 ;AN000;
  680. .ENDIF ; End if printing sideways ;AN000;
  681. LOOP PRINT_SCAN_LINE ; ;AN000;
  682. ;AN000;
  683. ;-------------------------------------------------------------------------------;AN000;
  684. ; ;AN000;
  685. ; Restore the printer (send a Page Eject, etc.) ;AN000;
  686. ; ;AN000;
  687. ;-------------------------------------------------------------------------------;AN000;
  688. CALL RESTORE_PRT ;AN000;
  689. PRINT_COLOR_APA_END: ;AN000;
  690. POP DX ;AN000;
  691. POP CX ;AN000;
  692. POP BX ;AN000;
  693. POP AX ;AN000;
  694. RET ;AN000;
  695. PRINT_COLOR_APA ENDP ;AN000;
  696. PAGE ;AN000;
  697. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AN000;
  698. ;; ;AN000;
  699. ;; ;AN000;
  700. ;; SCAN_FOR_BANDS_APA : DETERMINE WHAT PRINT BANDS ARE NEEDED FOR THE CURRENT ;AN000;
  701. ;; PRINT PASS. ;AN000;
  702. ;; ;AN000;
  703. ;;------------------------------------------------------------------------------;AN000;
  704. ; ;AN000;
  705. ; INPUT: CUR_ROW : row to start scanning (word) ;AN000;
  706. ; CUR_COLUMN : column to start scanning (word) ;AN000;
  707. ; CUR_SCAN_LNE_LENGTH : length of the current scan line (word) ;AN000;
  708. ; ROTATE_SW = ON if printing is sideways ;AN000;
  709. ; ;AN000;
  710. ; OUTPUT: REQ_BAND_MASK : band mask for required bands (byte) ;AN000;
  711. ; ;AN000;
  712. ;;------------------------------------------------------------------------------;AN000;
  713. ;; ;AN000;
  714. ;; Data Structures Referenced: ;AN000;
  715. ;; Shared Data Area ;AN000;
  716. ;; Print Info ;AN000;
  717. ;; Color Translate Table ;AN000;
  718. ;; ;AN000;
  719. ;; ;AN000;
  720. ;; Description: ;AN000;
  721. ;; Read all the dots required for one print line to determine ;AN000;
  722. ;; the print bands required. The print line corresponds to several ;AN000;
  723. ;; screen rows (or columns if rotated printing). The number of ;AN000;
  724. ;; rows / columns per print line is stored in NB_BOXES_PER_PRT_BUF. ;AN000;
  725. ;; The band information is obtained from the Color Translate Table. ;AN000;
  726. ;; ;AN000;
  727. ;; Called By: ;AN000;
  728. ;; PRINT_COLOR_APA ;AN000;
  729. ;; ;AN000;
  730. ;; External Calls: ;AN000;
  731. ;; READ_DOT, BIOS INT 10H ;AN000;
  732. ;; ;AN000;
  733. ;; Logic: ;AN000;
  734. ;; Save initial coordinates ;AN000;
  735. ;; SAVE_START_COLUMN := CUR_COLUMN ;AN000;
  736. ;; REQ_BAND_MASK := 00H ;AN000;
  737. ;; DO (SCAN_LINE_LENGTH) TIMES ;AN000;
  738. ;; Save coordinates of the "column" ;AN000;
  739. ;; DO (BOXES_PER_PRT_BUF) TIMES ;AN000;
  740. ;; CALL READ_DOT(IN CUR_ROW,CUR_COLUMN; OUT COLOR_NUM) ;AN000;
  741. ;; REQ_BAND_MASK := REQ_BAND_MASK OR COLOR_XLAT_TAB[BX] ;AN000;
  742. ;; IF rotated print THEN ;AN000;
  743. ;; Increment CUR_COLUMN ;AN000;
  744. ;; ELSE ;AN000;
  745. ;; Increment CUR_ROW ;AN000;
  746. ;; ENDIF ;AN000;
  747. ;; Restore coordinates of the "column" ;AN000;
  748. ;; ENDDO ;AN000;
  749. ;; IF rotated print THEN ;AN000;
  750. ;; Decrement CUR_ROW ;AN000;
  751. ;; ELSE ;AN000;
  752. ;; Increment CUR_COLUMN ;AN000;
  753. ;; ENDIF ;AN000;
  754. ;; ENDDO ;AN000;
  755. ;; Restore initial coordinates ;AN000;
  756. ;; RETURN ;AN000;
  757. ;; ;AN000;
  758. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;AN000;
  759. SCAN_FOR_BANDS_APA PROC NEAR ;AN000;
  760. PUSH CUR_ROW ;AN000;
  761. PUSH CUR_COLUMN ;AN000;
  762. PUSH AX ;AN000;
  763. PUSH BX ;AN000;
  764. PUSH CX ;AN000;
  765. ;AN000;
  766. MOV REQ_BAND_MASK,0 ; No Color bands needed so far... ;AN000;
  767. MOV BX,OFFSET XLT_TAB ; BX := Offset of translation table ;AN000;
  768. MOV CX,CUR_SCAN_LNE_LENGTH ;AN000;
  769. ;===============================================================================;AN000;
  770. ; ;AN000;
  771. ; FOR each column on the current scan line (up to the last non=blank): ;AN000;
  772. ; ;AN000;
  773. ;===============================================================================;AN000;
  774. SCAN_1_COLUMN: ;AN000;
  775. PUSH CX ; Save column counter ;AN000;
  776. PUSH CUR_ROW ; Save coordinates of the "column" ;AN000;
  777. PUSH CUR_COLUMN ;AN000;
  778. ;-------------------------------------------------------------------------------;AN000;
  779. ; ;AN000;
  780. ; For each pixel within the current column of the scan line: ;AN000;
  781. ; ;AN000;
  782. ;-------------------------------------------------------------------------------;AN000;
  783. XOR CX,CX ; CX := Number of pixels to read ;AN000;
  784. MOV CL,NB_BOXES_PER_PRT_BUF ; within the current "column" ;AN000;
  785. SCAN_1_PIXEL: ;AN000;
  786. CALL READ_DOT ; AL := Index into translation table ;AN000;
  787. XLAT XLT_TAB ; AL := Band mask ;AN000;
  788. OR REQ_BAND_MASK,AL ; Add bands required for this pixel ;AN000;
  789. ;AN000;
  790. ;-------Get coordinates of next pixel: ;AN000;
  791. .IF <ROTATE_SW EQ ON> ; If printing sideways ;AN000;
  792. .THEN ; ;AN000;
  793. INC CUR_COLUMN ; then, increment column number ;AN000;
  794. .ELSE ; ;AN000;
  795. INC CUR_ROW ; else, increment row number ;AN000;
  796. .ENDIF ; ;AN000;
  797. LOOP SCAN_1_PIXEL ;AN000;
  798. POP CUR_COLUMN ; Restore coordinates of the "column" ;AN000;
  799. POP CUR_ROW ; ;AN000;
  800. POP CX ; Restore column counter ;AN000;
  801. ;AN000;
  802. ;AN000;
  803. ;-------Get coordinates of next "column": ;AN000;
  804. .IF <ROTATE_SW EQ ON> ; If printing sideways ;AN000;
  805. .THEN ; ;AN000;
  806. DEC CUR_ROW ; then, get row above on screen ;AN000;
  807. .ELSE ; ;AN000;
  808. INC CUR_COLUMN ; else, get column next right ;AN000;
  809. .ENDIF ; ;AN000;
  810. LOOP SCAN_1_COLUMN ;AN000;
  811. ;AN000;
  812. POP CX ;AN000;
  813. POP BX ;AN000;
  814. POP AX ;AN000;
  815. POP CUR_COLUMN ;AN000;
  816. POP CUR_ROW ;AN000;
  817. RET ;AN000;
  818. SCAN_FOR_BANDS_APA ENDP ;AN000;
  819. PAGE ;AN000;
  820. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AN000;
  821. ;; ;AN000;
  822. ;; PRINT_BAND_APA : PRINT ALL DOTS ON CURRENT LINE THAT NEED THE CURRENT BAND ;AN000;
  823. ;; TO APPROXIMATE THEIR COLOR. ;AN000;
  824. ;; ;AN000;
  825. ;-------------------------------------------------------------------------------;AN000;
  826. ; ;AN000;
  827. ; INPUT: CUR_ROW, ;AN000;
  828. ; CUR_COLUMN : Coordinates of the first pixel to be read in the ;AN000;
  829. ; current scan line. ;AN000;
  830. ; DL : Band mask indicating what print band to use ;AN000;
  831. ; for this print pass. ;AN000;
  832. ; CUR_SCAN_LNE_LENGTH: Length of the current scan line. ;AN000;
  833. ; ROTATE_SW = ON if printing is sideways ;AN000;
  834. ; ;AN000;
  835. ; OUTPUT: PRINTER ;AN000;
  836. ; ;AN000;
  837. ;-------------------------------------------------------------------------------;AN000;
  838. ;; ;AN000;
  839. ;; Data Structures Referenced: ;AN000;
  840. ;; Shared Data Area ;AN000;
  841. ;; Print Info ;AN000;
  842. ;; Color Translate Table ;AN000;
  843. ;; ;AN000;
  844. ;; Description: ;AN000;
  845. ;; Print all dots on this print line which need the current ;AN000;
  846. ;; band. The print line corresponds to several ;AN000;
  847. ;; screen rows (or columns if rotated printing). The number of ;AN000;
  848. ;; rows / columns per print line is stored in NB_BOXES_PER_PRT_BUF. ;AN000;
  849. ;; The band information is obtained from the Color Translate Table. ;AN000;
  850. ;; ;AN000;
  851. ;; Called By: ;AN000;
  852. ;; PRINT_COLOR_APA ;AN000;
  853. ;; ;AN000;
  854. ;; External Calls: ;AN000;
  855. ;; READ_DOT, BIOS INT 10H, STORE_BOX, PRT_BUFFER, PRINT_BYTE ;AN000;
  856. ;; ;AN000;
  857. ;; Logic: ;AN000;
  858. ;; SAVE_START_ROW := CUR_ROW ;AN000;
  859. ;; SAVE_START_COLUMN := CUR_COLUMN ;AN000;
  860. ;; ;AN000;
  861. ;; CALL SET_COLOR_BAND ; Select the color for this print pass ;AN000;
  862. ;; DO (SCAN_LINE_LENGTH) TIMES ;AN000;
  863. ;; Save coordinates of the "column" ;AN000;
  864. ;; Clear the print buffer ;AN000;
  865. ;; DO (BOXES_PER_PRT_BUF) TIMES ;AN000;
  866. ;; CALL READ_DOT(CUR_ROW,CUR_COLUMN,COLOR_NUM) ;AN000;
  867. ;; IF (CUR_BAND_MASK AND XLAT_TAB[COLOR_NUM])=1 THEN ;AN000;
  868. ;; CALL STORE_BOX(black box) ;AN000;
  869. ;; ELSE ;AN000;
  870. ;; CALL STORE_BOX(white box) ;AN000;
  871. ;; ENDIF ;AN000;
  872. ;; IF rotated print THEN ;AN000;
  873. ;; Decrement CUR_COLUMN ;AN000;
  874. ;; ELSE ;AN000;
  875. ;; Increment CUR_ROW ;AN000;
  876. ;; ENDIF ;AN000;
  877. ;; ENDDO ;AN000;
  878. ;; CALL PRINT_BUFFER ;AN000;
  879. ;; Restore coordinates of the "column" ;AN000;
  880. ;; ; Get coordinates of the next "column"; ;AN000;
  881. ;; IF rotated print THEN ;AN000;
  882. ;; Decrement CUR_ROW ;AN000;
  883. ;; CUR_COLUMN := SAVE_START_COLUMN ;AN000;
  884. ;; ELSE ;AN000;
  885. ;; Increment CUR_COLUMN ;AN000;
  886. ;; CUR_ROW := SAVE_START_ROW ;AN000;
  887. ;; ENDIF ;AN000;
  888. ;; ENDDO ;AN000;
  889. ;; RETURN ;AN000;
  890. ;; ;AN000;
  891. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AN000;
  892. PRINT_BAND_APA PROC NEAR ;AN000;
  893. PUSH CUR_ROW ; Save coordinates ;AN000;
  894. PUSH CUR_COLUMN ;AN000;
  895. PUSH AX ;AN000;
  896. PUSH BX ;AN000;
  897. PUSH CX ;AN000;
  898. PUSH SI ;AN000;
  899. PUSH DI ;AN000;
  900. ;AN000;
  901. MOV BX,OFFSET XLT_TAB ; BX := Offset of translation table ;AN000;
  902. MOV CX,CUR_SCAN_LNE_LENGTH ;AN000;
  903. ;===============================================================================;AN000;
  904. ; ;AN000;
  905. ; FOR each column on the current scan line (up to the last non=blank): ;AN000;
  906. ; (One "column" contains the number of pixels required to fill the Print buffer);AN000;
  907. ; ;AN000;
  908. ;===============================================================================;AN000;
  909. PRINT_1_COLUMN: ;AN000;
  910. ;-------------------------------------------------------------------------------;AN000;
  911. ; ;AN000;
  912. ; Clear the print buffer "PRT_BUF" ;AN000;
  913. ; ;AN000;
  914. ;-------------------------------------------------------------------------------;AN000;
  915. XOR DI,DI ; DI := Number of bytes cleared in the buffer ;AN000;
  916. XOR AX,AX ;AN000;
  917. MOV AL,BOX_W ; AX := Number of bytes in the print buffer ;AN000;
  918. CLEAR_BUF: ; For each byte in the PRT_BUF: ;AN000;
  919. MOV PRT_BUF[DI],0 ; Initialize byte to blanks ;AN000;
  920. INC DI ; One more has been cleared ;AN000;
  921. CMP DI,AX ; All bytes cleared ? ;AN000;
  922. JL CLEAR_BUF ; No, clear next one. ;AN000;
  923. ;AN000;
  924. ;-------------------------------------------------------------------------------;AN000;
  925. ; ;AN000;
  926. ; Fill up the print buffer "PRT_BUF" ;AN000;
  927. ; ;AN000;
  928. ;-------------------------------------------------------------------------------;AN000;
  929. PUSH CX ; Save column counter ;AN000;
  930. XOR CX,CX ; CX := Number of pixels to read ;AN000;
  931. MOV CL,NB_BOXES_PER_PRT_BUF ; within the current "column" ;AN000;
  932. ; of the scan line ;AN000;
  933. PUSH CUR_ROW ; Save coordinates of the "column" ;AN000;
  934. PUSH CUR_COLUMN ;AN000;
  935. ; ;AN000;
  936. ; For each pixel within the current column of the scan line: ;AN000;
  937. STORE_1_PIXEL: ;AN000;
  938. CALL READ_DOT ; AL := Index into translation table ;AN000;
  939. XLAT XLT_TAB ; AL := Band mask ;AN000;
  940. .IF <BIT AL AND DL> ; If color of the current pixel needs ;AN000;
  941. .THEN ; the current printer band ;AN000;
  942. MOV SI,OFFSET BLACK_BOX ; then, store a box in the ;AN000;
  943. CALL STORE_BOX ; PRT_BUF ;AN000;
  944. .ELSE ; ;AN000;
  945. MOV SI,OFFSET WHITE_BOX ; else, store an empty box ;AN000;
  946. CALL STORE_BOX ; in the PRT_BUF ;AN000;
  947. .ENDIF ;AN000;
  948. ; ;AN000;
  949. ;-------Get coordinates of next pixel: ;AN000;
  950. .IF <ROTATE_SW EQ ON> ; If printing sideways ;AN000;
  951. .THEN ; ;AN000;
  952. INC CUR_COLUMN ; then, increment column number ;AN000;
  953. .ELSE ; ;AN000;
  954. INC CUR_ROW ; else, increment row number ;AN000;
  955. .ENDIF ; ;AN000;
  956. LOOP STORE_1_PIXEL ;AN000;
  957. ;AN000;
  958. POP CUR_COLUMN ; Restore coordinates of the "column" ;AN000;
  959. POP CUR_ROW ; ;AN000;
  960. POP CX ; Restore column counter ;AN000;
  961. ;-------------------------------------------------------------------------------;AN000;
  962. ; ;AN000;
  963. ; Print the PRT_BUF: ;AN000;
  964. ; ;AN000;
  965. ;-------------------------------------------------------------------------------;AN000;
  966. CALL PRINT_BUFFER ;AN000;
  967. .IF <BIT ERROR_CODE NZ PRINTER_ERROR> ;AN000;
  968. .THEN ; A printer error occurred: QUIT ;AN000;
  969. JMP SHORT PRINT_BAND_APA_END ; ;AN000;
  970. .ENDIF ;AN000;
  971. ;AN000;
  972. ;-------------------------------------------------------------------------------;AN000;
  973. ; ;AN000;
  974. ; Get coordinates of next "column": ;AN000;
  975. ; ;AN000;
  976. ;-------------------------------------------------------------------------------;AN000;
  977. .IF <ROTATE_SW EQ ON> ; If printing sideways ;AN000;
  978. .THEN ; ;AN000;
  979. DEC CUR_ROW ; then, get row above on screen ;AN000;
  980. .ELSE ; ;AN000;
  981. INC CUR_COLUMN ; else, get column next right ;AN000;
  982. .ENDIF ; ;AN000;
  983. LOOP PRINT_1_COLUMN ;AN000;
  984. ;AN000;
  985. PRINT_BAND_APA_END: ;AN000;
  986. POP DI ;AN000;
  987. POP SI ;AN000;
  988. POP CX ;AN000;
  989. POP BX ;AN000;
  990. POP AX ;AN000;
  991. POP CUR_COLUMN ; Restore initial coordinates ;AN000;
  992. POP CUR_ROW ;AN000;
  993. RET ;AN000;
  994. PRINT_BAND_APA ENDP ;AN000;
  995. PAGE ;AN000;
  996. ;===============================================================================;AN000;
  997. ; ;AN000;
  998. ; SET_CURSOR : SET THE CURSOR TO CUR_ROW, CUR_COLUMN AND CUR_PAGE ;AN000;
  999. ; ;AN000;
  1000. ;-------------------------------------------------------------------------------;AN000;
  1001. ; ;AN000;
  1002. ; INPUT: CUR_ROW, ;AN000;
  1003. ; CUR_COLUMN = Coordinates for the cursor (word) ;AN000;
  1004. ; CUR_PAGE = Page for which to set the cursor (byte) ;AN000;
  1005. ; ;AN000;
  1006. ; OUTPUT: SCREEN ;AN000;
  1007. ; ;AN000;
  1008. ;-------------------------------------------------------------------------------;AN000;
  1009. SET_CURSOR PROC NEAR ;AN000;
  1010. PUSH AX ;AN000;
  1011. PUSH BX ;AN000;
  1012. PUSH DX ;AN000;
  1013. MOV DH,BYTE PTR CUR_ROW ;AN000;
  1014. MOV DL,BYTE PTR CUR_COLUMN ;AN000;
  1015. MOV BH,CUR_PAGE ;AN000;
  1016. MOV AH,SET_CURSOR_CALL ; Set cursor request ;AN000;
  1017. INT 10H ; Call BIOS ;AN000;
  1018. POP DX ;AN000;
  1019. POP BX ;AN000;
  1020. POP AX ;AN000;
  1021. RET ;AN000;
  1022. SET_CURSOR ENDP ;AN000;
  1023. PAGE ;AN000;
  1024. ;===============================================================================;AN000;
  1025. ; ;AN000;
  1026. ; SET_COLOR_BAND : SET THE PRINTER TO THE CURRENT COLOR BAND ;AN000;
  1027. ; ;AN000;
  1028. ;-------------------------------------------------------------------------------;AN000;
  1029. ; ;AN000;
  1030. ; INPUT: BX = Offset of current COLORSELECT record in the ;AN000;
  1031. ; Shared data area. ;AN000;
  1032. ; DS:[BP] = Offset of shared data area ;AN000;
  1033. ; ;AN000;
  1034. ; OUTPUT: PRINTER ;AN000;
  1035. ; ;AN000;
  1036. ;-------------------------------------------------------------------------------;AN000;
  1037. SET_COLOR_BAND PROC NEAR ;AN000;
  1038. PUSH AX ;AN000;
  1039. PUSH BX ;AN000;
  1040. PUSH CX ;AN000;
  1041. ;AN000;
  1042. ;-------Send the escape sequence for selecting this color band to the printer: ;AN000;
  1043. XOR CX,CX ;AN000;
  1044. MOV CL,[BX].NUM_SELECT_ESC ; CX := Number of bytes to send ;AN000;
  1045. ADD BX,OFFSET SELECT_ESC ; BX := Offset of bytes to send ;AN000;
  1046. SEND_1_COLORSELECT_BYTE: ;AN000;
  1047. MOV AL,[BX] ; AL := Byte to send to printer ;AN000;
  1048. CALL PRINT_BYTE ; Send it ;AN000;
  1049. JC SET_COLOR_BAND_END ; If printer error: return ;AN000;
  1050. INC BX ; Get next byte ;AN000;
  1051. LOOP SEND_1_COLORSELECT_BYTE ;AN000;
  1052. ;AN000;
  1053. SET_COLOR_BAND_END: ;AN000;
  1054. POP CX ;AN000;
  1055. POP BX ;AN000;
  1056. POP AX ;AN000;
  1057. RET ;AN000;
  1058. SET_COLOR_BAND ENDP ;AN000;
  1059. PAGE ;AN000;
  1060. ;===============================================================================;AN000;
  1061. ; ;AN000;
  1062. ; INIT_BLACK_BOX: INIT. THE BOX FOR PRINTING APA MODE DOTS ON A COLOR PRINTER. ;AN000;
  1063. ; ;AN000;
  1064. ;-------------------------------------------------------------------------------;AN000;
  1065. ; ;AN000;
  1066. ; INPUT: BOX_W, ;AN000;
  1067. ; BOX_H = Size of the print box for one pixel. ;AN000;
  1068. ; ;AN000;
  1069. ; OUTPUT: BLACK_BOX = A box for which all dots are on. ;AN000;
  1070. ; ;AN000;
  1071. ;-------------------------------------------------------------------------------;AN000;
  1072. ; ;AN000;
  1073. ; DESCRIPTION: Initialize the print box used to print a screen pixel. ;AN000;
  1074. ; ;AN000;
  1075. ; For example, ;AN000;
  1076. ; with a size of 3x2 the BLACK_BOX will use 3 bytes: ;AN000;
  1077. ; ;AN000;
  1078. ; ;AN000;
  1079. ; byte1 byte2 byte3 ;AN000;
  1080. ; (column1) (column2) (column3) ;AN000;
  1081. ; bit 7 -->0 0 0 ;AN000;
  1082. ; 0 0 0 ;AN000;
  1083. ; 0 0 0 ;AN000;
  1084. ; 0 0 0 ;AN000;
  1085. ; 0 0 0 ;AN000;
  1086. ; 0 0 0 ;AN000;
  1087. ; 1 1 1 ;AN000;
  1088. ; bit 0 -->1 1 1 ;AN000;
  1089. ; ;AN000;
  1090. ;-------------------------------------------------------------------------------;AN000;
  1091. INIT_BLACK_BOX PROC NEAR ;AN000;
  1092. PUSH AX ;AN000;
  1093. PUSH BX ;AN000;
  1094. PUSH CX ;AN000;
  1095. ;AN000;
  1096. ;-------Build one box column: ;AN000;
  1097. XOR CX,CX ;AN000;
  1098. MOV CL,BOX_H ; CX := Height in bits of the print box ;AN000;
  1099. XOR AL,AL ; AX := Bit mask for creating box column ;AN000;
  1100. .REPEAT ; For height of the box: ;AN000;
  1101. SHL AL,1 ; ;AN000;
  1102. OR AL,1 ; Insert one bit in the box column ;AN000;
  1103. .LOOP ;AN000;
  1104. ;AN000;
  1105. ;-------------------------------------------------------------------------------;AN000;
  1106. ; ;AN000;
  1107. ; AL now contains one box column. ;AN000;
  1108. ; ;AN000;
  1109. ;-------------------------------------------------------------------------------;AN000;
  1110. ;AN000;
  1111. ;-------Replicate this column over all columns of the box. ;AN000;
  1112. XOR BX,BX ; BX := Index into the BOX ;AN000;
  1113. INIT_1_BLACK_COLUMN: ;AN000;
  1114. MOV BLACK_BOX[BX],AL; Init current column to black box column ;AN000;
  1115. INC BX ; Get next column ;AN000;
  1116. CMP BL,BOX_W ;AN000;
  1117. JL INIT_1_BLACK_COLUMN ;AN000;
  1118. ;AN000;
  1119. POP CX ;AN000;
  1120. POP BX ;AN000;
  1121. POP AX ;AN000;
  1122. RET ;AN000;
  1123. INIT_BLACK_BOX ENDP ;AN000;
  1124. INCLUDE GRCOMMON.ASM ;AN000;
  1125. LEN_OF_COLOR_MODULES EQU $-PRINT_COLOR ;AN000;
  1126. CODE ENDS ;AN000;
  1127. END ;AN000;
  1128.