llega.asm
上传用户:xiaoan1112
上传日期:2013-04-11
资源大小:19621k
文件大小:54k
源码类别:

操作系统开发

开发平台:

Visual C++

  1. TITLE LLEGA - EGA screen mode support
  2. ;***
  3. ;LLEGA - EGA screen mode support
  4. ;
  5. ; Copyright <C> 1986, Microsoft Corporation
  6. ;
  7. ;Purpose:
  8. ; Support for EGA graphics screen modes (BIOS D,E,F,10).
  9. ; Note that this module module contains support
  10. ; code for all adapters capable of handling these
  11. ; screen modes and also attempts to compensate for
  12. ; the subtle differences in their treatment.
  13. ;
  14. ; This module sets hooks in the mode-independent
  15. ; modules to routines here for mode-dependent
  16. ; graphics support.  See the mode-independent
  17. ; modules for more precise descriptions of the
  18. ; purposes and interfaces of these routines.
  19. ;
  20. ; The following table summarizes the information for
  21. ; the modes and configurations covered:
  22. ;
  23. ;    C   | A      B
  24. ;    O   |  B T      I
  25. ;    L   |  I T  P      T
  26. ;    O      A M |  O R  A    C      S
  27. ;  S R      D O |  S I    C  G    H      / P
  28. ;  C B      A N | B    O  E    A   P  P L
  29. ;  R U C  R P I |  M U    L  X   Y  S    R   A  I A
  30. ;  E R O  O T T |  O T    O  R   R  I    B   G  X N
  31. ;  E S L  W E O |  D E    R  E   E  Z    O   E  E E
  32. ;  N T S  S R R |  E S    S  S   S  E    X   S  L S
  33. ; -- - -- -- - -- | -- --- ---- --- --- --- ---- --- - -
  34. ;  7 x 40 25 E C |  D 16  16 320 200  32 8x8  (2) 1 4
  35. ;  7 x 40 25 E E |  "   "   "   "   "    "  "    "  " "
  36. ;  7 x 40 25 S x |  "   "   "   "   "    "  "    "  " "
  37. ;
  38. ;  8 x 80 25 E C |  E 16  16 640 200  64 8x8  (2) 1 4
  39. ;  8 x 80 25 E E |  "   "   "   "   "    "  "    "  " "
  40. ;  8 x 80 25 S x |  "   "   "   "   "    "  "    "  " "
  41. ;
  42. ;  9 x 80 25 E E | 10  4  64 640 350  64 8x14  1  1 2  (64K video memory)
  43. ;  9 x 80 43 E E |  "   "   "   "   "    " 8x8   "  " "
  44. ;
  45. ;  9 x 80 25 E E | 10 16  64 640 350 128 8x14 (2) 1 4  (>64K video memory)
  46. ;  9 x 80 25 S x |  "   "   "   "   "    "  "    "  " "
  47. ;  9 x 80 43 E E |  "   "   "   "   "    " 8x8   "  " "
  48. ;  9 x 80 43 S x |  "   "   "   "   "    "  "    "  " "
  49. ;
  50. ; 10 x 80 25 E M |  F  4   9 640 350  64 8x14 (1) 1 2  (>64K video memory)
  51. ; 10 x 80 25 S x |  "   "   "   "   "    "  "    "  " "
  52. ; 10 x 80 43 E M |  "   "   "   "   "    " 8x8   "  " "
  53. ; 10 x 80 43 S x |  "   "   "   "   "    "  "    "  " "
  54. ;
  55. ;-----------------------------------------------------------------------
  56. ;NOTES:  (1) PAGES = <video memory> / 2 / PAGESIZE (max 8 pages)
  57. ;  (2) PAGES = <video memory> / PAGESIZE    (max 8 pages)
  58. ;-----------------------------------------------------------------------
  59. ;******************************************************************************
  60. INCLUDE switch.inc ;feature switches
  61. INCLUDE rmacros.inc
  62. USESEG _DATA
  63. USESEG _BSS
  64. USESEG GR_TEXT
  65. USESEG CN_TEXT
  66. USESEG XIB
  67. USESEG XI
  68. USESEG XIE
  69. INCLUDE seg.inc
  70. INCLUDE ibmunv.inc
  71. INCLUDE baslibma.inc
  72. INCLUDE llgrp.inc ; Constant definitions
  73. INCLUDE idmac.inc
  74. INCLUDE grmac.inc ;ModeData macros
  75. INITIALIZER B$xINITEGA ;Put B$xINITEGA in initializer list
  76. sBegin _BSS
  77. ;
  78. ; ***************************************************************************
  79. ; External function vectors
  80. ; ***************************************************************************
  81. ;
  82. externW b$PutVector
  83. externW b$PalPut
  84. externW b$SetAttr
  85. ;
  86. ; ***************************************************************************
  87. ; External variables
  88. ; ***************************************************************************
  89. ;
  90. externB b$BiosMode
  91. externB b$Adapter
  92. externB b$Monitor
  93. externW b$VideoMem
  94. externW b$CurPages
  95. externW b$VideoBase
  96. externB b$MaskC
  97. externB b$AttrC
  98. externW b$PenC 
  99. externW b$OffC
  100. externW b$SegC
  101. externB b$MaxAttr
  102. externB b$MaxColor
  103. externW B$LEOFST
  104. externW B$REOFST
  105. externB B$VLMASK
  106. externB B$VRMASK
  107. externB b$ForeColor
  108. externB b$PageSize
  109. externW b$CurrPSize
  110. externB b$ScrHeight
  111. externB b$MaxPage
  112. externB b$Tiling
  113. externB b$ForeMapped
  114. externW b$CURSOR
  115. externW b$CSRTYP
  116. externW b$SaveCa
  117. externB b$SaveCm
  118. externB b$PlaneMask
  119. externW b$ScreenTab
  120. ;
  121. ; ***************************************************************************
  122. ; Local variables
  123. ; ***************************************************************************
  124. ;
  125. staticB MapMask,,1 ;bit mask for Map Mask Register odd/even map
  126. staticB BasePlane,,1 ;base plane for odd/even modes
  127. sEnd _BSS
  128. sBegin CN_TEXT
  129. externNP B$USRCSR
  130. sEnd CN_TEXT
  131. assumes CS,GR_TEXT
  132. sBegin GR_TEXT
  133. externNP B$OutWord
  134. externNP B$BumpDS
  135. externNP B$BumpES
  136. externNP B$InitModeData
  137. externNP B$GetParm
  138. externNP b$ColorPalette
  139. externNP b$EnhPalette
  140. externNP B$EgaPalReset
  141. externNP B$EgaPalResetB
  142. externNP B$EgaPalPut
  143. externNP B$EgaPalTrans
  144. externNP B$EgaPalSet
  145. externNP B$EgaMapXYC
  146. externNP B$EgaMapXYC_D
  147. externNP B$EgaLeftC
  148. externNP B$EgaChkUpC
  149. externNP B$EgaUpC
  150. externNP B$EgaChkDownC
  151. externNP B$EgaDownC
  152. externNP B$EgaSetAttr
  153. externNP B$EgaReadC
  154. externNP B$EgaReadC_F
  155. externNP B$EgaReadC_64K
  156. externNP B$EgaSetC
  157. externNP B$EgaSetPixC
  158. externNP B$EgaSetPixFirstC
  159. externNP B$ResetEGA
  160. externNP B$EgaLineX
  161. externNP B$EgaLineY
  162. externNP B$EgaLineV
  163. externNP B$EgaPutAction
  164. externNP B$EgaPutAction_F
  165. externNP B$EgaPutAction_64K
  166. externNP B$EgaNReadL
  167. externNP B$EgaNReadL_F
  168. externNP B$EgaNWriteL
  169. externNP B$EgaNWriteL_F
  170. externNP B$EgaNSetC
  171. externNP B$EgaPaintBound
  172. externNP B$EgaPaintBound_D
  173. externNP B$EgaSetTile
  174. externNP B$EgaScanL
  175. externNP B$EgaScanR
  176. externNP B$EgaCHKBTL
  177. externNP B$EgaCHKBTR
  178. externNP B$EgaPAINPX
  179. externNP B$EgaPIXCNT
  180. externNP B$EgaScanInit
  181. externNP B$EgaSETCMP
  182. externNP B$EgaTILLFT
  183. externNP B$EgaTILRGT
  184. ;===========================================================================
  185. mModeData ModeDData
  186. ;
  187. ; SCREEN 7, BIOS mode D
  188. ;
  189. ; Mode-dependent data follows to initialize the the "b$ModeData" table
  190. ; in LLCGRP.
  191. ;
  192. ;===========================================================================
  193. mScreenMode 7
  194. mBiosMode 0DH
  195. mBurst 0
  196. mScrWidth 40
  197. mScrHeight 25
  198. mHorzRes 320
  199. mVertRes 200
  200. mVideoBase 0A000H
  201. mMaxAttr 15
  202. mMaxColor 15
  203. mPageSize 32     ;page size in K
  204. mCurrPSize <(32/4*1024) shr 4> ;page size in paragraphs (1 plane)
  205. mMaxPage 0
  206. mNullColor 0
  207. mForeColor 15
  208. mBackColor 0
  209. mEgaWrMd 2
  210. mInitPalette b$ColorPalette  ;moved to LLXGASUP for sharing
  211. mInitVgaPal b$VgaPalette
  212. mAlphaDim AlphaDim_D
  213. mSetMode SetMode
  214. mSetPages SetPages
  215. mPalReset B$EgaPalReset
  216. mPalPut  B$EgaPalPut
  217. mPalTrans B$EgaPalTrans
  218. mPalSet  B$EgaPalSet
  219. mSetColor SetColor
  220. mForeMapped 15
  221. mBitsPerPixel 1
  222. mPlanes  4
  223. mMapXYC  B$EgaMapXYC_D
  224. mLeftC B$EgaLeftC
  225. mChkUpC  B$EgaChkUpC
  226. mUpC B$EgaUpC
  227. mChkDownC B$EgaChkDownC
  228. mDownC B$EgaDownC
  229. mSetAttr B$EgaSetAttr
  230. mReadC B$EgaReadC
  231. mSetC B$EgaSetC
  232. mSetPixC B$EgaSetPixC
  233. mSetPixFirstC B$EgaSetPixFirstC
  234. mSetPixLastC B$ResetEGA
  235. mLineX B$EgaLineX
  236. mLineY B$EgaLineY
  237. mLineV B$EgaLineV
  238. mPutAction B$EgaPutAction
  239. mNReadL  B$EgaNReadL
  240. mNWriteL B$EgaNWriteL
  241. mNSetC B$EgaNSetC
  242. mPaintBound B$EgaPaintBound_D
  243. mSetTile B$EgaSetTile
  244. mScanL B$EgaScanL
  245. mScanR B$EgaScanR
  246. mEnd GraphDataLen
  247. ;===========================================================================
  248. ;===========================================================================
  249. mModeData ModeEData
  250. ;
  251. ; SCREEN 8, BIOS mode E
  252. ;
  253. ; Mode-dependent data follows to initialize the the "b$ModeData" table
  254. ; in LLCGRP.
  255. ;
  256. ;===========================================================================
  257. mScreenMode 8
  258. mBiosMode 0EH
  259. mBurst 0
  260. mScrWidth 80
  261. mScrHeight 25
  262. mHorzRes 640
  263. mVertRes 200
  264. mVideoBase 0A000H
  265. mMaxAttr 15
  266. mMaxColor 15
  267. mPageSize 64     ;page size in K
  268. mCurrPSize <(64/4*1024) shr 4> ;page size in paragraphs (1 plane)
  269. mMaxPage 0
  270. mNullColor 0
  271. mForeColor 15
  272. mBackColor 0
  273. mEgaWrMd 2
  274. mInitPalette b$ColorPalette  ;moved to LLXGASUP for sharing
  275. mInitVgaPal b$VgaPalette
  276. mAlphaDim AlphaDim_E
  277. mSetMode SetMode
  278. mSetPages SetPages
  279. mPalReset B$EgaPalReset
  280. mPalPut  B$EgaPalPut
  281. mPalTrans B$EgaPalTrans
  282. mPalSet  B$EgaPalSet
  283. mSetColor SetColor
  284. mForeMapped 15
  285. mBitsPerPixel 1
  286. mPlanes  4
  287. mMapXYC  B$EgaMapXYC
  288. mLeftC B$EgaLeftC
  289. mChkUpC  B$EgaChkUpC
  290. mUpC B$EgaUpC
  291. mChkDownC B$EgaChkDownC
  292. mDownC B$EgaDownC
  293. mSetAttr B$EgaSetAttr
  294. mReadC B$EgaReadC
  295. mSetC B$EgaSetC
  296. mSetPixC B$EgaSetPixC
  297. mSetPixFirstC B$EgaSetPixFirstC
  298. mSetPixLastC B$ResetEGA
  299. mLineX B$EgaLineX
  300. mLineY B$EgaLineY
  301. mLineV B$EgaLineV
  302. mPutAction B$EgaPutAction
  303. mNReadL  B$EgaNReadL
  304. mNWriteL B$EgaNWriteL
  305. mNSetC B$EgaNSetC
  306. mPaintBound B$EgaPaintBound
  307. mSetTile B$EgaSetTile
  308. mScanL B$EgaScanL
  309. mScanR B$EgaScanR
  310. mEnd GraphDataLen
  311. ;===========================================================================
  312. ;===========================================================================
  313. mModeData ModeFData
  314. ;
  315. ; SCREEN 10, BIOS mode F (with > 64K video memory>
  316. ;
  317. ; Mode-dependent data follows to initialize the the "b$ModeData" table
  318. ; in LLCGRP.
  319. ;
  320. ;===========================================================================
  321. mScreenMode 10
  322. mBiosMode 0FH
  323. mBurst 0
  324. mScrWidth 80
  325. mScrHeight 25
  326. mHorzRes 640
  327. mVertRes 350
  328. mVideoBase 0A000H
  329. mMaxAttr 3
  330. mMaxColor 8
  331. mPageSize 64     ;page size in K
  332. mCurrPSize <(64/2*1024) shr 4> ;page size in paragraphs (1 plane)
  333. mMaxPage 0
  334. mNullColor 0
  335. mForeColor 3
  336. mBackColor 0
  337. mEgaWrMd 2     ;no even/odd with > 64K
  338. mInitPalette ModeFPalette
  339. mInitVgaPal 0 ;not applicable
  340. mAlphaDim AlphaDim_F
  341. mSetMode SetMode
  342. mSetPages SetPages
  343. mPalReset B$EgaPalResetB
  344. mPalPut  PalPut_F
  345. mPalTrans PalTrans_F
  346. mPalSet  B$EgaPalSet
  347. mSetColor SetColor
  348. mForeMapped 5     ;attr 3 maps to hardware attr 5
  349. mBitsPerPixel 1
  350. mPlanes  2
  351. mMapXYC  B$EgaMapXYC
  352. mLeftC B$EgaLeftC
  353. mChkUpC  B$EgaChkUpC
  354. mUpC B$EgaUpC
  355. mChkDownC B$EgaChkDownC
  356. mDownC B$EgaDownC
  357. mSetAttr SetAttr_F_10_64K
  358. mReadC B$EgaReadC_F
  359. mSetC B$EgaSetC
  360. mSetPixC B$EgaSetPixC
  361. mSetPixFirstC B$EgaSetPixFirstC
  362. mSetPixLastC B$ResetEGA
  363. mLineX B$EgaLineX
  364. mLineY B$EgaLineY
  365. mLineV B$EgaLineV
  366. mPutAction B$EgaPutAction_F
  367. mNReadL  B$EgaNReadL_F
  368. mNWriteL B$EgaNWriteL_F
  369. mNSetC B$EgaNSetC
  370. mPaintBound B$EgaPaintBound
  371. mSetTile B$EgaSetTile
  372. mScanL ScanLX
  373. mScanR ScanRX
  374. mEnd GraphDataLen
  375. ;===========================================================================
  376. ;===========================================================================
  377. mModeData ModeFData_64K
  378. ;
  379. ; SCREEN 10, BIOS mode F with 64K video memory
  380. ;
  381. ; Mode-dependent data follows to initialize the the "b$ModeData" table
  382. ; in LLCGRP.
  383. ;
  384. ;===========================================================================
  385. mScreenMode 10
  386. mBiosMode 0FH
  387. mBurst 0
  388. mScrWidth 80
  389. mScrHeight 25
  390. mHorzRes 640
  391. mVertRes 350
  392. mVideoBase 0A000H
  393. mMaxAttr 3
  394. mMaxColor 8
  395. mPageSize 64     ;page size in K
  396. mCurrPSize <(64/2*1024) shr 4> ;page size in paragraphs (1 plane)
  397. mMaxPage 0
  398. mNullColor 0
  399. mForeColor 3
  400. mBackColor 0
  401. mEgaWrMd 12H
  402. mInitPalette ModeFPalette
  403. mInitVgaPal 0 ;not applicable
  404. mAlphaDim AlphaDim_F
  405. mSetMode SetMode
  406. mSetPages SetPages
  407. mPalReset B$EgaPalResetB
  408. mPalPut  PalPut_F
  409. mPalTrans PalTrans_F
  410. mPalSet  B$EgaPalSet
  411. mSetColor SetColor
  412. mForeMapped 5     ;attr 3 maps to hardware attr 5
  413. mBitsPerPixel 1
  414. mPlanes  2
  415. mMapXYC  B$EgaMapXYC
  416. mLeftC B$EgaLeftC
  417. mChkUpC  B$EgaChkUpC
  418. mUpC B$EgaUpC
  419. mChkDownC B$EgaChkDownC
  420. mDownC B$EgaDownC
  421. mSetAttr SetAttr_F_10_64K
  422. mReadC B$EgaReadC_64K
  423. mSetC B$EgaSetC
  424. mSetPixC B$EgaSetPixC
  425. mSetPixFirstC B$EgaSetPixFirstC
  426. mSetPixLastC B$ResetEGA
  427. mLineX B$EgaLineX
  428. mLineY B$EgaLineY
  429. mLineV B$EgaLineV
  430. mPutAction B$EgaPutAction_64K
  431. mNReadL  NReadL_64K
  432. mNWriteL NWriteL_64K
  433. mNSetC B$EgaNSetC
  434. mPaintBound B$EgaPaintBound
  435. mSetTile B$EgaSetTile
  436. mScanL ScanLX
  437. mScanR ScanRX
  438. mEnd GraphDataLen
  439. ;===========================================================================
  440. ;===========================================================================
  441. mModeData Mode10Data
  442. ;
  443. ; SCREEN 9, BIOS mode 10 (with > 64K video memory)
  444. ;
  445. ; Mode-dependent data follows to initialize the the "b$ModeData" table
  446. ; in LLCGRP.
  447. ;
  448. ;===========================================================================
  449. mScreenMode 9
  450. mBiosMode 10H
  451. mBurst 0
  452. mScrWidth 80
  453. mScrHeight 25
  454. mHorzRes 640
  455. mVertRes 350
  456. mVideoBase 0A000H
  457. mMaxAttr 15
  458. mMaxColor 63
  459. mPageSize 128     ;page size in K
  460. mCurrPSize <(128/4*1024) shr 4>;page size in paragraphs (1 plane)
  461. mMaxPage 0
  462. mNullColor 0
  463. mForeColor 15
  464. mBackColor 0
  465. mEgaWrMd 2
  466. mInitPalette b$EnhPalette ;moved to LLXGASUP for sharing
  467. mInitVgaPal b$VgaPalette
  468. mAlphaDim AlphaDim_10
  469. mSetMode SetMode
  470. mSetPages SetPages
  471. mPalReset B$EgaPalReset
  472. mPalPut  B$EgaPalPut
  473. mPalTrans B$EgaPalTrans
  474. mPalSet  B$EgaPalSet
  475. mSetColor SetColor
  476. mForeMapped 15
  477. mBitsPerPixel 1
  478. mPlanes  4
  479. mMapXYC  B$EgaMapXYC
  480. mLeftC B$EgaLeftC
  481. mChkUpC  B$EgaChkUpC
  482. mUpC B$EgaUpC
  483. mChkDownC B$EgaChkDownC
  484. mDownC B$EgaDownC
  485. mSetAttr B$EgaSetAttr
  486. mReadC B$EgaReadC
  487. mSetC B$EgaSetC
  488. mSetPixC B$EgaSetPixC
  489. mSetPixFirstC B$EgaSetPixFirstC
  490. mSetPixLastC B$ResetEGA
  491. mLineX B$EgaLineX
  492. mLineY B$EgaLineY
  493. mLineV B$EgaLineV
  494. mPutAction B$EgaPutAction
  495. mNReadL  B$EgaNReadL
  496. mNWriteL B$EgaNWriteL
  497. mNSetC B$EgaNSetC
  498. mPaintBound B$EgaPaintBound
  499. mSetTile B$EgaSetTile
  500. mScanL B$EgaScanL
  501. mScanR B$EgaScanR
  502. mEnd GraphDataLen
  503. ;===========================================================================
  504. ;===========================================================================
  505. mModeData Mode10Data_64K
  506. ;
  507. ; SCREEN 9, BIOS mode 10 (with 64K video memory)
  508. ;
  509. ; Mode-dependent data follows to initialize the the "b$ModeData" table
  510. ; in LLCGRP.
  511. ;
  512. ;===========================================================================
  513. mScreenMode 9
  514. mBiosMode 10H
  515. mBurst 0
  516. mScrWidth 80
  517. mScrHeight 25
  518. mHorzRes 640
  519. mVertRes 350
  520. mVideoBase 0A000H
  521. mMaxAttr 3
  522. mMaxColor 63
  523. mPageSize 64     ;page size in K
  524. mCurrPSize <(64/2*1024) shr 4> ;page size in paragraphs (1 plane)
  525. mMaxPage 0
  526. mNullColor 0
  527. mForeColor 3
  528. mBackColor 0
  529. mEgaWrMd 12H
  530. mInitPalette Mode10Palette_64K
  531. mInitVgaPal Mode10VgaPal_64K
  532. mAlphaDim AlphaDim_10
  533. mSetMode SetMode
  534. mSetPages SetPages
  535. mPalReset B$EgaPalReset
  536. mPalPut  B$EgaPalPut
  537. mPalTrans PalTrans_10_64K
  538. mPalSet  B$EgaPalSet
  539. mSetColor SetColor
  540. mForeMapped 15
  541. mBitsPerPixel 1
  542. mPlanes  2
  543. mMapXYC  B$EgaMapXYC
  544. mLeftC B$EgaLeftC
  545. mChkUpC  B$EgaChkUpC
  546. mUpC B$EgaUpC
  547. mChkDownC B$EgaChkDownC
  548. mDownC B$EgaDownC
  549. mSetAttr SetAttr_F_10_64K
  550. mReadC B$EgaReadC_64K
  551. mSetC B$EgaSetC
  552. mSetPixC B$EgaSetPixC
  553. mSetPixFirstC B$EgaSetPixFirstC
  554. mSetPixLastC B$ResetEGA
  555. mLineX B$EgaLineX
  556. mLineY B$EgaLineY
  557. mLineV B$EgaLineV
  558. mPutAction B$EgaPutAction_64K
  559. mNReadL  NReadL_64K
  560. mNWriteL NWriteL_64K
  561. mNSetC B$EgaNSetC
  562. mPaintBound B$EgaPaintBound
  563. mSetTile B$EgaSetTile
  564. mScanL ScanLX
  565. mScanR ScanRX
  566. mEnd GraphDataLen
  567. ;===========================================================================
  568. ;
  569. ; ModeFPalette - used to initialize the EGA palette for SCREEN 10
  570. ;  (BIOS mode F).
  571. ;
  572. labelB ModeFPalette ;EGA palette for BIOS mode 0FH
  573. ; RGBrgb
  574. DB 000000B  ;black
  575. DB 001000B  ;video
  576. DB 000000B  ;black
  577. DB 000000B  ;black
  578. DB 011000B  ;intensified
  579. DB 011000B  ;intensified
  580. DB 000000B  ;black
  581. DB 000000B  ;black
  582. DB 000000B  ;black
  583. DB 001000B  ;video
  584. DB 000000B  ;black
  585. DB 000000B  ;black
  586. DB 000000B  ;black
  587. DB 011000B  ;intensified
  588. DB 000000B  ;black
  589. DB 000000B  ;black
  590. ;
  591. ; Mode10Palette_64K - used to initialize the EGA palette for SCREEN 9
  592. ;   (BIOS mode 10) with 64K of video memory.
  593. ;
  594. labelB Mode10Palette_64K ;EGA palette for BIOS mode 10H with only 64K
  595. ; RGBrgb
  596. DB 000000B  ;black
  597. DB 111011B  ;light cyan
  598. DB 000000B  ;black (not used)
  599. DB 000000B  ;black (not used)
  600. DB 111101B  ;light magenta
  601. DB 111111B  ;bright white
  602. ;DB      10 DUP (0)      ;brown
  603. labelNP <PUBLIC,B$EGAUSED>
  604. ;*** 
  605. ; B$Screen7
  606. ;
  607. ;Purpose:
  608. ; Establish all relevent mode dependent data values and function
  609. ; vectors for BASIC screen mode 7.
  610. ;Entry:
  611. ; AL = screen mode (7)
  612. ; AH = burst (0 or 1)
  613. ; CL = alpha columns
  614. ;Exit:
  615. ; PSW.C = set indicates error
  616. ;Uses:
  617. ; per conv.
  618. ;Exceptions:
  619. ;******************************************************************************
  620. cProc B$Screen7,<PUBLIC,NEAR>
  621. cBegin
  622. mov bx,GR_TEXTOFFSET ModeDData  ;mode-specific data
  623. jmp short ScrCommon2     ;common routine
  624. cEnd <nogen>
  625. ;*** 
  626. ; B$Screen8
  627. ;
  628. ;Purpose:
  629. ; Establish all relevent mode dependent data values and function
  630. ; vectors for BASIC screen mode 8.
  631. ;Entry:
  632. ; AL = screen mode (8)
  633. ; AH = burst (0 or 1)
  634. ; CL = alpha columns
  635. ;Exit:
  636. ; PSW.C = set indicates error
  637. ;Uses:
  638. ; per conv.
  639. ;Exceptions:
  640. ;******************************************************************************
  641. cProc B$Screen8,<PUBLIC,NEAR>
  642. cBegin
  643. mov bx,GR_TEXTOFFSET ModeEData  ;mode-specific data
  644. ScrCommon2:
  645. test b$Monitor,AnalogColor + EnhColor + StdColor
  646. ;check for monitor support
  647. je ScrErr ;exit w/error if not supported
  648. jmp short ScrCommon ;common routine
  649. cEnd <nogen>
  650. ;*** 
  651. ; B$Screen9
  652. ;
  653. ;Purpose:
  654. ; Establish all relevent mode dependent data values and function
  655. ; vectors for BASIC screen mode 9.
  656. ;Entry:
  657. ; AL = screen mode (9)
  658. ; AH = burst (0 or 1)
  659. ; CL = alpha columns
  660. ;Exit:
  661. ; PSW.C = set indicates error
  662. ;Uses:
  663. ; per conv.
  664. ;Exceptions:
  665. ;******************************************************************************
  666. cProc B$Screen9,<PUBLIC,NEAR>
  667. cBegin
  668. test b$Monitor,AnalogColor + EnhColor ;check for monitor support
  669. je ScrErr ;exit w/error if not supported
  670. mov bx,GR_TEXTOFFSET Mode10Data ;mode-specific data
  671. cmp b$VideoMem,64 ;check for mode 10 w/only 64K
  672. ja ScrCommon ;go if greater, otherwise use diff table
  673. mov bx,GR_TEXTOFFSET Mode10Data_64K ;mode-specific data
  674. ScrCommon:
  675. test b$Adapter,VGA + EGA ;check for adapter support
  676. je ScrErr ;exit w/error if not supported
  677. mov cx,GraphDataLen 
  678. call B$InitModeData ;initialize table data
  679. mov ax,b$VideoMem ;MaxPage = VideoMem / PageSize - 1
  680. div b$PageSize
  681. dec al ;MaxPage = #pages-1
  682. mov b$MaxPage,al
  683. clc ;indicate no error
  684. cEnd
  685. ;*** 
  686. ; B$Screen10
  687. ;
  688. ;Purpose:
  689. ; Establish all relevent mode dependent data values and function
  690. ; vectors for BASIC screen mode 10.
  691. ;Entry:
  692. ; AL = screen mode (10)
  693. ; AH = burst (0 or 1)
  694. ; CL = alpha columns
  695. ;Exit:
  696. ; PSW.C = set indicates error
  697. ;Uses:
  698. ; per conv.
  699. ;Exceptions:
  700. ;******************************************************************************
  701. cProc B$Screen10,<PUBLIC,NEAR>
  702. cBegin
  703. test b$Monitor,AnalogMono + Monochrome ;check monitor support
  704. je ScrErr ;exit w/error if not supported
  705. mov bx,GR_TEXTOFFSET ModeFData  ;mode-specific data
  706. cmp b$VideoMem,64 ;check for mode F w/only 64K
  707. ja Scr10Common ;go if greater, otherwise use diff table
  708. mov bx,GR_TEXTOFFSET ModeFData_64K ;mode-specific data
  709. Scr10Common:
  710. test b$Adapter,VGA + EGA ;check for adapter support
  711. je ScrErr ;exit w/error if not supported
  712. mov cx,GraphDataLen 
  713. call B$InitModeData ;initialize table data
  714. mov ax,b$VideoMem ; MaxPage = VideoMem / 2 / PageSize - 1
  715. shr ax,1 ; divide VideoMem by 2
  716. div b$PageSize
  717. sub al,1 ;MaxPage = #pages-1
  718. adc al,0 ;if MaxPage < 0 (64K EGA), force back to 0
  719. mov b$MaxPage,al
  720. clc ;indicate no error
  721. jmp short ScrExit
  722. ScrErr:
  723. stc
  724. ScrExit:
  725. cEnd
  726. ;***
  727. ; AlphaDim_D
  728. ;
  729. ;Purpose:
  730. ; Validate the proposed text dimensions for Screen 7.
  731. ;   If 40x25 is requested, this mode satisfies the request
  732. ;   elseif 80x25 is requested, suggest screen mode 8
  733. ;   else suggest screen mode 0.
  734. ;Entry:
  735. ; BH = number of lines
  736. ; BL = number of columns
  737. ;Exit:
  738. ; AL = -1 if this mode satisfies the request, otherwise
  739. ; AL is suggested screen mode to invoke for desired dimensions
  740. ;Uses:
  741. ; per conv.
  742. ;Exceptions:
  743. ;******************************************************************************
  744. DbPub AlphaDim_D
  745. cProc AlphaDim_D,<NEAR>
  746. cBegin
  747. mov al,-1 ;flag request satisfied (maybe)
  748. cmp bx,40+25*256 ;40x25?
  749. je ADimSet  ;exit if so, standard stuff
  750. mov al,8 ;prepare request for screen 8, JIC
  751. cmp bx,80+25*256 ;80x25?
  752. je ADimDOk  ;exit if so, try screen 8
  753. xor al,al ;flag request for screen 0
  754. ADimDOk:
  755. cEnd
  756. ;***
  757. ; AlphaDim_F
  758. ;
  759. ;Purpose:
  760. ; Validate the proposed text dimensions for Screen 10.
  761. ;   If 40 columns are requested, treat as if 80 were requested.
  762. ;   Fall through to AlphaDim_10 for validation.
  763. ;Entry:
  764. ; BL = number of lines
  765. ; BH = number of columns
  766. ;Exit:
  767. ; falls through to AlphaDim_10
  768. ;Uses:
  769. ; per conv.
  770. ;Exceptions:
  771. ;******************************************************************************
  772. DbPub AlphaDim_F
  773. cProc AlphaDim_F,<NEAR>
  774. cBegin
  775. cmp bl,40 ;40 columns?
  776. jne AlphaDim_10 ;go if not, as if mode 10H
  777. mov bl,80 ;treat 40 as if request for 80
  778. cEnd <nogen>  ;fall thru to AlphaDim_10
  779. ;***
  780. ; AlphaDim_10/AlphaDim_E
  781. ;
  782. ;Purpose:
  783. ; Validate the proposed text dimensions for Screen 9 or Screen 8,
  784. ; depending on entry point.
  785. ;   If 80x25 or 80x43 is requested, this mode satisfies the request
  786. ;   elseif 40x25 is requested, suggest screen mode 7
  787. ;   else suggest screen mode 0.
  788. ;Entry:
  789. ; BL = number of lines
  790. ; BH = number of columns
  791. ;Exit:
  792. ; If this mode satisfies request
  793. ;   AL = -1
  794. ;   b$ScrHeight is set to value in BL
  795. ; else
  796. ;   AL = suggested screen mode to invoke for desired dimensions
  797. ;Uses:
  798. ; per conv.
  799. ;Exceptions:
  800. ;******************************************************************************
  801. DbPub AlphaDim_10
  802. cProc AlphaDim_10,<NEAR>
  803. cBegin
  804. mov al,-1 ;flag request satisfied (maybe)
  805. cmp bx,80+43*256 ;80x43?
  806. je ADimSet  ;exit if so, standard stuff
  807. labelNP AlphaDim_E
  808. mov al,-1 ;flag request satisfied (maybe)
  809. cmp bx,80+25*256 ;80x25?
  810. je ADimSet  ;exit if so, standard stuff
  811. mov al,7 ;prepare request for screen 7, JIC
  812. cmp bx,40+25*256 ;40x25?
  813. je ADimOk ;exit if so, try screen 7
  814. xor al,al ;flag request for screen 0
  815. jmp short ADimOk ;  and exit
  816. ADimSet:
  817. mov b$ScrHeight,bh ;set alpha rows
  818. ADimOk:
  819. clc ;no error
  820. cEnd
  821. ;***
  822. ; SetMode
  823. ;
  824. ;Purpose:
  825. ; Set EGA screen mode according to the characteristics established
  826. ; by previous call to B$Screenx and b$AlphaDim.  Set 8x8 character
  827. ; font if new mode is to be 43 lines.
  828. ;Entry:
  829. ; b$BiosMode is mode to set
  830. ; b$ScrHeight is number of lines
  831. ;Exit:
  832. ; None
  833. ;Uses:
  834. ; per conv.
  835. ;Exceptions:
  836. ;******************************************************************************
  837. cProc SetMode,<NEAR>
  838. cBegin
  839. mov al,b$BiosMode ;set BIOS mode
  840. SCNIO vSetMode
  841. cmp b$ScrHeight,43 ;43 lines?
  842. jne SetMode25 ;go if not
  843. mov dl,43 ; char gen call wants # of lines in DL
  844. mov ax,1123H ;character generator request
  845. xor bl,bl ;  to load 8x8 font
  846. SCNIO ;  which gets 43 lines
  847. SetMode25:
  848. call B$ResetEGA
  849. MOV DX,b$CURSOR ; Get current cursor position
  850. MOV BYTE PTR b$CSRTYP,-1 ; invalidate present cursor type so it
  851. ; will get changed
  852. CALL B$USRCSR ; display user cursor
  853. cEnd
  854. ;***
  855. ; SetPages
  856. ;
  857. ;Purpose:
  858. ; Set the current active and visual pages and calculate page size
  859. ; and video segment offset for EGA modes.
  860. ;Entry:
  861. ; AL = active page
  862. ; AH = visual page
  863. ;Exit:
  864. ; b$CurPages set to new active and visual pages.
  865. ; b$SegC set to start of new active page.
  866. ;Uses:
  867. ; per conv.
  868. ;Exceptions:
  869. ;******************************************************************************
  870. cProc SetPages,<NEAR>
  871. cBegin
  872. mov b$CurPages,ax ;save page numbers
  873. push ax
  874. mov al,ah
  875. SCNIO vSelActivePage ;set visual page
  876. pop ax
  877. cbw ;extend active page to word
  878. mul b$CurrPSize ;times page size in paras
  879. add ax,b$VideoBase ;set video segment
  880. mov b$SegC,ax
  881. cEnd
  882. ;***
  883. ; PalPut_F
  884. ;
  885. ;Purpose:
  886. ; Change palette entry for Screen 10 with translation/verification.
  887. ; A color value of -1 indicates that the associated palette
  888. ; entry is not to be modified.
  889. ;Entry:
  890. ; DX:AX = color
  891. ; BL = attribute
  892. ;Exit:
  893. ; PSW.C reset indicates successful operation
  894. ; set indicates PALETTE function call error
  895. ;Uses:
  896. ; per conv.
  897. ;Exceptions:
  898. ;******************************************************************************
  899. DbPub PalPut_F
  900. cProc PalPut_F,<NEAR>
  901. cBegin
  902. cmp ax,-1 ;lo word of color == -1?
  903. jne PalPut1  ;go if not, can't ignore
  904. cmp dx,ax ;hi word too?
  905. je PalPutExit ;exit if color == -1
  906. PalPut1:
  907. call PalTrans_F ;translate to external form
  908. jc PalPutExit ;exit if invalid w/error
  909. mov bh,al ;BH:BL = color:attribute
  910. mov al,bl ;ah:al = 2nd pair
  911. add al,8
  912. push ax ;save 2nd values in pair
  913. xor al,al ;subfunction "Set Individual Palette Register"
  914. SCNIO vSetEgaPalette
  915. pop ax
  916. xchg bx,ax ;2nd pair
  917. xor al,al ;subfunction "Set Individual Palette Register"
  918. SCNIO vSetEgaPalette
  919. clc ;no error
  920. PalPutExit:
  921. cEnd
  922. labelW TransF
  923. DB 0,0,0,8,0,24 ;9 possible value pairs of mode 0FH
  924. DB 8,0,8,8,8,24 ;0 - black, 8 - video, 18H - intensified
  925. DB 24,0,24,8,24,24
  926. ;***
  927. ; PalTrans_F
  928. ;
  929. ;Purpose:
  930. ; Translate a user supplied attribute/color pair for Screen 10 to
  931. ; the corresponding hardware values after verifying that they are
  932. ; in the legal range.
  933. ;     Attribute mapping: 0 --> 0
  934. ; 1 --> 1
  935. ; 2 --> 4
  936. ; 3 --> 5
  937. ;     Color pair mapping per TransF table.
  938. ;Entry:
  939. ; DX:AX = user supplied color value
  940. ; BL    = user supplied attribute value
  941. ;Exit:
  942. ; PSW.C set if illegal value, reset if Ok
  943. ; AX = actual color pair value
  944. ; BL = actual attribute value
  945. ;Uses:
  946. ; per conv.
  947. ;Exceptions:
  948. ; can exit through PalTrans_10_64K error exit.
  949. ;******************************************************************************
  950. DbPub PalTrans_F
  951. cProc PalTrans_F,<NEAR>
  952. cBegin
  953. cmp bl,b$MaxAttr ;is legal attribute ?
  954. ja PalTrErr ;error return
  955. or dh,dl ;hi 3 bytes of color must be 0
  956. or dh,ah
  957. jnz PalTrErr ;error if not
  958. cmp al,b$MaxColor ;is legal color ?
  959. ja PalTrErr ;error return
  960. cmp bl,2 ;attributes 0 and 1 map directly
  961. jb PalTrNxt ;go if so
  962. add bl,2 ;attribute 2 maps to 4, 3 to 5
  963. PalTrNxt:
  964. push di
  965. MOV DI,GR_TEXTOFFSET TransF ;translate to color pair
  966. XOR AH,AH
  967. SHL AL,1 ;word index
  968. ADD DI,AX
  969. MOV AX,CS:[DI] ;translate color AX to color pair AX
  970. pop di
  971. clc ;no error
  972. cEnd
  973. ;***
  974. ; PalTrans_10_64K
  975. ;
  976. ;Purpose:
  977. ; Translate a user supplied attribute for Screen 9/64K to the
  978. ; corresponding hardware value after verifying that the attribute
  979. ; value and the color value are in the legal ranges.
  980. ;     Attribute mapping: 0 --> 0
  981. ; 1 --> 1
  982. ; 2 --> 4
  983. ; 3 --> 5
  984. ;Entry:
  985. ; DX:AX = user supplied color value
  986. ; BL    = user supplied attribute value
  987. ;Exit:
  988. ; PSW.C set if illegal value, reset if Ok
  989. ; DX:AX = unchanged (user supplied color value)
  990. ; BL    = actual attribute value
  991. ;Uses:
  992. ; per conv.
  993. ;Exceptions:
  994. ;******************************************************************************
  995. DbPub PalTrans_10_64K
  996. cProc PalTrans_10_64K,<NEAR>
  997. cBegin
  998. call B$EgaPalTrans ;check attribute and translate color
  999. jc PalTrErr ;error return
  1000. cmp bl,2 ;attributes 0 and 1 map directly
  1001. jb PalTrExit ;go if so
  1002. add bl,2 ;attribute 2 maps to 4, 3 to 5
  1003. PalTrExit:
  1004. clc ;no error
  1005. ret
  1006. PalTrErr:
  1007. STC ;indicate error
  1008. cEnd
  1009. labelB AttrX
  1010. DB 0,3,0CH,0FH ;map to 0,3,C,F for odd/even
  1011. ;***
  1012. ; SetAttr_F_10_64K
  1013. ;
  1014. ;Purpose:
  1015. ; Map attribute value to the value needed by odd/even mode functions.
  1016. ; 0 --> 00
  1017. ; 1 --> 03
  1018. ; 2 --> 0C
  1019. ; 3 --> 0F
  1020. ; If supplied attribute is outside legal range, use maximum legal value.
  1021. ;Entry:
  1022. ; AL = attribute
  1023. ;Exit:
  1024. ; b$Attr updated
  1025. ;Uses:
  1026. ; per conv.
  1027. ;Exceptions:
  1028. ;******************************************************************************
  1029. DbPub SetAttr_F_10_64K
  1030. cProc SetAttr_F_10_64K,<NEAR>,<AX,BX>
  1031. cBegin
  1032. cmp al,b$MaxAttr ;test against maximum attribute
  1033. jbe SetAttrXOk ;Brif legal
  1034. mov al,b$MaxAttr ;limit to max
  1035. SetAttrXOk:
  1036. mov bx,GR_TEXTOFFSET AttrX ;translate for odd/even mode
  1037. xlat cs:[bx]
  1038. mov b$AttrC,al
  1039. clc ;exit no error
  1040. cEnd
  1041. ;***
  1042. ; SetColor
  1043. ;
  1044. ;Purpose:
  1045. ; Process the color statement for Bios modes 0Dh - 010h (BASIC Screen
  1046. ; modes 7-10).  Syntax for Screen 7-10 color statement is as follows:
  1047. ;
  1048. ; COLOR [foreground],[background]
  1049. ;
  1050. ; where "foreground" is the attribute to be used for the foreground
  1051. ;   and "background" is the color to be used for the background
  1052. ;
  1053. ; Any omitted parameter(s) indicate no change for that parameter.
  1054. ;Entry:
  1055. ; parameter list
  1056. ; WORD 1 = flag 0 if param not present
  1057. ; WORD 2 = parameter if WORD 1 <> 0, else second param flag
  1058. ; etc.
  1059. ;Exit:
  1060. ; PSW.C set if error, reset if Ok.
  1061. ; b$ForeColor is set to foreground attribute
  1062. ; b$ForeMapped is set to foreground attribute mapped to internal value
  1063. ;
  1064. ;Uses
  1065. ; per conv.
  1066. ;Exceptions:
  1067. ;*****************************************************************************
  1068. cProc SetColor,<NEAR>
  1069. cBegin
  1070. cCall B$GetParm ;AL=foreground parameter
  1071. mov bh,b$ForeColor ;use old values as default
  1072. mov bl,b$ForeMapped
  1073. jz GotFore  ;go if none supplied
  1074. cmp b$MaxAttr,al ;check for valid range
  1075. jc SetColDun ;go if error
  1076. push ax ;save: unmapped attr [14]
  1077. push cx ;      param count
  1078. push b$PenC  ;  b$AttrC
  1079. call [b$SetAttr] ;translate the attribute
  1080. mov bl,b$AttrC ;translated attr in BL
  1081. pop b$PenC 
  1082. pop cx
  1083. pop ax ;restore unmapped attr
  1084. mov bh,al ;unmapped attr to BH
  1085. GotFore:
  1086. cCall B$GetParm ;AL=background parameter
  1087. jz NoBack ;go if none supplied
  1088. push bx ;preserve foreground info
  1089. xor bx,bx ;attribute 0 is background
  1090. cbw ;AX=color
  1091. cwd ;DX:AX=color
  1092. call [b$PalPut] ;set background
  1093. pop bx
  1094. jc SetColDun ;go if error
  1095. NoBack:
  1096. mov b$ForeColor,bh ;save foreground values
  1097. mov b$ForeMapped,bl
  1098. clc ;indicate no error
  1099. jcxz SetColDun ;if we got all params, thats true
  1100. stc ;otherwise set error
  1101. SetColDun:
  1102. cEnd
  1103. ;***
  1104. ; PIXLF3
  1105. ;Purpose:
  1106. ; Check for non-paint pixels left, odd/even EGA modes.
  1107. ; Look through entire range of non-border pixels right to left
  1108. ; to determine whether any will actually change color.
  1109. ; Use AL as Color Don't Care mask.
  1110. ;
  1111. ; If using EGAINT10 interface, this routine must access the CDCReg
  1112. ; and perform the associated color compare read with ints disabled,
  1113. ; then reenable them to allow other processes to access the card
  1114. ; before the next byte is checked.  Since another process may have
  1115. ; modified the graphics chip index reg as well as the data reg, we
  1116. ; must send both index and data for each odd/even toggle.
  1117. ;Entry:
  1118. ; SI = byte address of rightmost byte in range
  1119. ; BH = bit mask for leftmost byte
  1120. ; BL = bit mask for rightmost byte
  1121. ; DI = total number of whole bytes between first and last
  1122. ; ES = video segment
  1123. ;Exit:
  1124. ; CL = 0 if no pixels found to change, non-zero if pixels to change
  1125. ;Uses:
  1126. ; per conv.
  1127. ;Exceptions:
  1128. ;****
  1129. DbPub PIXLF3
  1130. cProc PIXLF3,<NEAR>,<DX>
  1131. cBegin
  1132. MOV DX,GRPADD ;index port for graphics register
  1133. MOV AL,LOW CDCREG ;specify Color Don't Care
  1134. EGAINT10CLI ;disable ints if using EGAINT10
  1135. OUT DX,AL
  1136. INC DX
  1137. MOV AL,10101010B ;initially assume odd byte address
  1138. TEST SI,1
  1139. JNZ STMSKL ;if correct, set this mask
  1140. ROR AL,1 ;else rotate for other pair of planes
  1141. STMSKL:
  1142. OUT DX,AL ;set up for initial color compare
  1143. ; read first byte
  1144. MOV CL,ES:[SI] ;bit pattern of first byte with 0's where
  1145. ;color not paint attribute
  1146. AND CL,BL ;AND now produces difference if non-paint
  1147. ;bit in significant position
  1148. XOR CL,BL ;for significant bits in our first byte (bit
  1149. ;set in BH), then non-paint will be one
  1150. JNZ SETBTL ;found a bit to change
  1151. OR BH,BH ;see if only one byte
  1152. JZ NOSETL ;nothing to paint
  1153. OR DI,DI ;see if only a "last byte"
  1154. JZ LSBYT3
  1155. ; Look at whole bytes within viewport range until non-paint color found.
  1156. LKPTL3:
  1157. DEC SI
  1158. ROR AL,1
  1159. OUT DX,AL ;set up opposite Don't Care planes each time
  1160. MOV CL,ES:[SI]
  1161. EGAINT10STI ;read is done, reenable ints if EGAINT10
  1162. NOT CL ;check if all bits set (all paint color)
  1163. OR CL,CL ;NOT does not affect flags
  1164. JNZ SETBTL
  1165. DEC DI
  1166. EGAINT10CLI ;disable ints for next OUTs (loop
  1167. ; or fall through)
  1168. JNZ LKPTL3 ;keep looking until search of complete
  1169. ;bytes is exhausted
  1170. ; On last byte now, mask in BH.
  1171. LSBYT3:
  1172. DEC SI
  1173. ROR AL,1
  1174. OUT DX,AL ;last Don't Care
  1175. MOV CL,ES:[SI] ;do last compare
  1176. AND CL,BH ;significant bit = 0 if not paint color
  1177. XOR CL,BH ;if different, non-paint pixel(s) present
  1178. JNZ SETBTL
  1179. NOSETL:
  1180. XOR CL,CL ;no bits to set, so zero pixels-changed flag
  1181. SETBTL:
  1182. EGAINT10STI ;reenable ints at common exit
  1183. cEnd
  1184. ;***
  1185. ; PIXRT3
  1186. ;Purpose:
  1187. ; Check for non-paint pixels right with odd/even EGA modes.
  1188. ; Look through entire range of non-border pixels left to right
  1189. ; to determine whether any will actually change color.
  1190. ; AL is used for Color Don't Care mask
  1191. ;
  1192. ; If using EGAINT10 interface, this routine must access the CDCReg
  1193. ; and perform the associated color compare read with ints disabled,
  1194. ; then reenable them to allow other processes to access the card
  1195. ; before the next byte is checked.  Since another process may have
  1196. ; modified the graphics chip index reg as well as the data reg, we
  1197. ; must send both index and data for each odd/even toggle.
  1198. ;Entry:
  1199. ; SI = byte address of leftmost byte in range
  1200. ; BH = bit mask for rightmost byte
  1201. ; BL = bit mask for leftmost byte
  1202. ; DI = total number of whole bytes -1
  1203. ; ES = video segment
  1204. ;Exit:
  1205. ; CL = 0 if no pixels found to change, non-zero if pixels to change
  1206. ;Uses:
  1207. ; per conv.
  1208. ;Exceptions:
  1209. ;****
  1210. DbPub PIXRT3
  1211. cProc PIXRT3,<NEAR>,<DX>
  1212. cBegin
  1213. MOV DX,GRPADD ;index port for graphics
  1214. MOV AL,LOW CDCREG ;set up for Color Don't Care register
  1215. EGAINT10CLI ;disable ints if using EGAINT10
  1216. OUT DX,AL
  1217. INC DX
  1218. MOV AL,10101010B ;initially assume odd byte mask
  1219. TEST SI,1 ;check whether first byte odd or even
  1220. JNZ SETMSK ;if odd, branch to set mask
  1221. ROR AL,1 ;else rotate mask 1 right
  1222. SETMSK:
  1223. OUT DX,AL
  1224. ; read first byte
  1225. MOV CL,ES:[SI] ;bit pattern of first byte with 0's where
  1226. ;color not paint attribute
  1227. AND CL,BL ;AND now produces difference if non-paint
  1228. ;bit in significant position
  1229. XOR CL,BL ;for significant bits in our first byte (bit
  1230. ;set in BH), then non-paint will be one
  1231. JNZ PNTBIT ;found a bit to change
  1232. OR DI,DI ;any more bytes?
  1233. JZ PIXLAST  ;no full bytes, go try last
  1234. ; Look at whole bytes within viewport range until non-paint color found.
  1235. LKPTR3:
  1236. INC SI
  1237. ROR AL,1 ;shift Don't Care mask
  1238. OUT DX,AL
  1239. MOV CL,ES:[SI]
  1240. EGAINT10STI ;read is done, reenable ints if EGAINT10
  1241. NOT CL ;check if all bits set (all paint color)
  1242. OR CL,CL ;NOT does not affect flags
  1243. JNZ PNTBIT
  1244. DEC DI
  1245. EGAINT10CLI ;disable ints for next OUTs (loop
  1246. ; or fall through)
  1247. JNZ LKPTR3 ;keep looking until search of complete
  1248. ;bytes is exhausted
  1249. ; On last byte now, mask in BH.
  1250. PIXLAST:
  1251. INC SI
  1252. ROR AL,1
  1253. OUT DX,AL
  1254. MOV CL,ES:[SI] ;do last compare
  1255. AND CL,BH ;significant bit = 0 if not paint color
  1256. XOR CL,BH ;if different, non-paint color pixels
  1257. JNZ PNTBIT ;leave CL non-zero as flag
  1258. NOBTR3:
  1259. XOR CL,CL ;else zero the flag
  1260. PNTBIT:
  1261. EGAINT10STI ;reenable ints at common exit
  1262. cEnd
  1263. ;***
  1264. ; ScanLX
  1265. ;Purpose:
  1266. ; Scan left beginning with the pixel to the left of cursor,
  1267. ; and paint pixels until:
  1268. ; (1) the viewport edge is encounteered (edge painted)
  1269. ; (2) a border pixel is encountered (border not painted)
  1270. ;
  1271. ; This version supports PAINT for the odd/even EGA modes (bios mode
  1272. ; 10H with 64K of memory, and monochrome bios mode F).  It differs
  1273. ; from SCANL2 in its use of the Color Don't Care register in
  1274. ; conjunction with screen reads. This is necessary because if the
  1275. ; planes representing the even bytes and those representing the odd
  1276. ; bytes are not disabled during color compares for odd and even bytes,
  1277. ; respectively, the color compare is made as the sum of the bits set
  1278. ; for each even byte and its odd successor, all four planes at one
  1279. ; address.
  1280. ;Entry:
  1281. ; b$AddrC, b$MaskC = pixel to right of starting pixel
  1282. ; b$PaintBorder    = attribute of paint region border
  1283. ; b$AttrC    = attribute to paint
  1284. ; B$LEOFST, B$VLMASK   = left viewport edge
  1285. ;Exit:
  1286. ; BX    = number of pixels scanned
  1287. ; CL    = 0 iff no pixels changed color
  1288. ; b$OffC, b$MaskC  = the last non-border pixel examined/painted
  1289. ;Uses:
  1290. ; per conv.
  1291. ;Exceptions:
  1292. ;*****************************************************************************
  1293. DbPub ScanLX
  1294. cProc ScanLX,<NEAR>,<ES>
  1295. cBegin
  1296. CALL B$EgaScanInit
  1297. ROL CH,1 ;see if cursor is left edge of byte
  1298. JNB VWBYT1 ;if not, proceed to viewport checks
  1299. DEC SI ;if so, start next byte left
  1300. JS SCNOUT ;if negative, hit corner of screen
  1301. VWBYT1: ;start on-screen viewport checks
  1302. CMP SI,B$LEOFST ;see if off edge of viewport to left
  1303. JNB VWBYT2
  1304. SCNOUT:
  1305. JMP BRDEX3 ;else do nothing, exit
  1306. VWBYT2:
  1307. JNZ NOTBYT ;if not edge byte, skip bit checks
  1308. CMP CH,B$VLMASK ;else check for pixel left too far and
  1309. JNA NOTBYT
  1310. JMP BRDEX3 ;thus off viewport edge -- exit if so
  1311. NOTBYT:
  1312. MOV DI,SI ;extra copy of first byte address
  1313. MOV BL,CH ;extra copy of initial bit mask
  1314. MOV BP,-1 ;this will be count of whole bytes
  1315. XOR AH,AH ;initialize this byte's viewport mask to 0
  1316. ; First task is to set up initial Color Don't Care mask depending
  1317. ; on whether first byte is odd or even.
  1318. MOV CL,10101010B ;initially assume odd byte -- 10101010
  1319. TEST SI,1
  1320. JNZ STCDC3
  1321. ROR CL,1 ;if even, set up 01010101
  1322. STCDC3:
  1323. MOV DX,GRPADD
  1324. MOV AL,LOW CDCREG ;index to Color Don't Care register
  1325. OUT DX,AL
  1326. INC DX
  1327. MOV AL,CL
  1328. OUT DX,AL
  1329. ; read first byte off the screen
  1330. MOV AL,ES:[DI]
  1331. EGAINT10STI ;read is done, reenable ints if EGAINT10
  1332. TEST AL,CH ;see whether initial pixel is border
  1333. JZ SRCLF3 ;if not, start search left
  1334. XOR CL,CL ;else set pixels-changed flag back to 0
  1335. MOV BL,CL ;zero out 8-bit register used
  1336. JMP BRDEX3 ;and exit gracefully
  1337. SRCLF3:
  1338. ; look for border or viewport in first byte
  1339. CMP DI,B$LEOFST ;is this in fact viewport edge byte?
  1340. JNZ NTVWL3
  1341. MOV AH,B$VLMASK ;if so, set up viewport mask in AH
  1342. NTVWL3:
  1343. ; while not border
  1344. TEST AL,CH
  1345. JNZ HAVPX3
  1346. ; and not viewport edge
  1347. TEST AH,CH
  1348. JNZ HAVPX3
  1349. ; and not off the edge of the byte
  1350. ROL CH,1
  1351. JNB NTVWL3
  1352. ; keep moving left - edge of first byte
  1353. DEC DI ;next byte address left
  1354. INC BP ;count of intermediate bytes
  1355. ROR CL,1 ;rotate Color Don't Care mask
  1356. MOV AL,CL
  1357. OUT DX,AL
  1358. MOV AL,ES:[DI] ;read next byte left
  1359. EGAINT10STI ;reenable ints between bytes if EGAINT10
  1360. JMP SHORT SRCLF3 ;check next byte
  1361. ; Here when border or viewport edge found.
  1362. ; Set up bit mask for first (possibly only) byte
  1363. ; SI = rightmost byte
  1364. ; DI = leftmost byte (possibly same byte)
  1365. ; BL = mask for rightmost bit in rightmost byte
  1366. ; If viewport edge was found, AH will contain the viewport bit
  1367. ; mask, and DI is the viewport edge byte.  If SI=DI=viewport edge
  1368. ; byte, we need to retain the viewport mask in AH.  Otherwise
  1369. ; clear AH and fetch the mask again later if needed for DI.
  1370. HAVPX3:
  1371. CMP SI,B$LEOFST ;see if rightmost byte is LEFT viewport
  1372. JZ SINTV2 ;if so, don't clear viewport mask
  1373. ; register
  1374. XOR AH,AH ;else clear AH for CHKBTL on
  1375. SINTV2: ; rightmost byte
  1376. MOV CH,BL ;initial bit position in CH
  1377. MOV CL,10101010B ;need to reset Color Don't Care mask
  1378. TEST SI,1 ;see if odd byte
  1379. JNZ SISET
  1380. ROR CL,1
  1381. SISET:
  1382. MOV AL,CL
  1383. OUT DX,AL ;set up Color Don't Care
  1384. MOV AL,ES:[SI] ;get border bits if any
  1385. XOR DX,DX ;this will be #pixels painted
  1386. CALL B$EgaCHKBTL ;set up bit mask for first byte
  1387. MOV BL,BH ;store in BL
  1388. XOR BH,BH ;there may be only one byte
  1389. ; see if more than 1 byte to paint
  1390. PUSH SI ;save a copy of rightmost address
  1391. INC BP ;see if still -1
  1392. JZ ONEALN ;"one alone"
  1393. DEC BP ;if not, recover real value
  1394. PUSH DX ;store pixel count
  1395. MOV DX,GRPADD+1 ;data port for Color Don't Care
  1396. MOV CL,10101010B ;assume mask 10101010
  1397. TEST DI,1 ;check DI for odd or even address
  1398. JNZ DISET
  1399. ROR CL,1 ;if even, set up 01010101
  1400. DISET:
  1401. MOV AL,CL
  1402. OUT DX,AL
  1403. POP DX ;restore pixel count
  1404. MOV AL,ES:[DI] ;get border bits if any
  1405. MOV CH,1 ;set up mask for final byte
  1406. CMP DI,B$LEOFST ;was this viewport byte?
  1407. JNZ DINTV2 ;no -- don't need viewport mask
  1408. MOV AH,B$VLMASK ;yes -- get viewport mask for CHKTBL
  1409. DINTV2:
  1410. CALL B$EgaCHKBTL ;set up leftmost byte bit mask in BH
  1411. ONEALN:
  1412. MOV b$OffC,DI
  1413. MOV b$MaskC,CH ;update cursor
  1414. PUSH DI ;save a copy of leftmost address
  1415. MOV DI,BP ;store whole byte count for PIXLFT
  1416. CMP b$Tiling,0 ;see if tiling is on
  1417. JZ COLCM7
  1418. CALL B$EgaTILLFT
  1419. JMP SHORT COLCM8
  1420. COLCM7:
  1421. CALL B$EgaSETCMP ;set color compare register to paint attribute
  1422. CALL PIXLF3 ;see whether any pixels in range will change
  1423. COLCM8:
  1424. POP SI ;restore leftmost address to SI
  1425. POP DI ;restore rightmost address to DI
  1426. OR CL,CL ;returns CL non-zero if changes needed
  1427. JZ BRDEX2
  1428. ; we found at least 1 pixel to change, so set entire range
  1429. ; set pixels-changed flag, set up write mode 2
  1430. XOR CH,CH
  1431. NOT CH ;set to FF as decrement flag
  1432. STD ;for SCANL, decrement from DI
  1433. CALL B$EgaPAINPX
  1434. CLD
  1435. BRDEX2:
  1436. CALL B$EgaPIXCNT ;returns # pixels "painted" in BX
  1437. BRDEX3:
  1438. CALL B$ResetEGA
  1439. cEnd
  1440. ;***
  1441. ; ScanRX
  1442. ;Purpose:
  1443. ; Starting with the current pixel, search right until:
  1444. ; (1) a non-border pixel is found
  1445. ; (2) [DX] pixels have been tested
  1446. ; (3) the viewport edge is encountered
  1447. ;
  1448. ; If (2) or (3) terminated the scan, exit with:
  1449. ; DX = remaining border bount = 0
  1450. ;
  1451. ; If (1) terminated the scan, scan and paint non-border pixels until:
  1452. ; (1) the viewport edge is encountered (edge painted)
  1453. ; (2) a border pixel is encountered (border not painted)
  1454. ;
  1455. ; This version supports PAINT for the odd/even EGA modes (bios mode
  1456. ; 10H with 64K of memory, and monochrome bios mode F).  It differs
  1457. ; from SCANR2 in its use of the Color Don't Care register in
  1458. ; conjunction with screen reads. This is necessary because if the
  1459. ; planes representing the even bytes and those representing the odd
  1460. ; bytes are not disabled during color compares for odd and even bytes,
  1461. ; respectively, the color compare is made as the sum of the bits set
  1462. ; for each even byte and its odd successor, all four planes at one
  1463. ; address.
  1464. ;Entry:
  1465. ; DX    = count of border pixels which may be skipped
  1466. ; b$AddrC, b$MaskC = starting pixel
  1467. ; b$PaintBorder    = attribute of paint region border
  1468. ; b$AttrC    = attribute to paint
  1469. ; B$REOFST, B$VRMASK   = right viewport edge
  1470. ;Exit:
  1471. ; BX    = number of pixels painted
  1472. ; (whether or not they changed color)
  1473. ; CL    = 0 iff no pixels changed color
  1474. ; DX    = remaining border pixel count
  1475. ; b$OffC, b$MaskC  = the last non-border pixel examined/painted
  1476. ; SI, AL    = the first non-border pixel encountered
  1477. ;Uses:
  1478. ; per conv.
  1479. ;Exceptions:
  1480. ;
  1481. ;****************************************************************************
  1482. DbPub ScanRX
  1483. cProc ScanRX,<NEAR>,<ES>
  1484. cBegin
  1485. ; set up EGA registers for color compare read
  1486. ; point ES:[SI] to screen memory, b$MaskC in CH
  1487. ; CL = 0 (pixels changed flag)
  1488. CALL B$EgaScanInit ;setup
  1489. ; Initial task is to set up a mask for specifying which planes
  1490. ; we want to read when doing color compare reads. For even bytes,
  1491. ; we need to specify 0's in bits 1 and 3 (color don't care planes
  1492. ; 1 and 3), vice versa for odd bytes.  For convenience in coding,
  1493. ; we set up an 8-bit mask in CL and rotate right as we move across
  1494. ; the screen.
  1495. MOV BX,DX ;decrement BX instead of DX (needed for OUTs)
  1496. MOV CL,10101010B ;assume start mask 10101010
  1497. TEST SI,1 ;check whether odd or even byte
  1498. JNZ COLCOM ;if odd, we're in business
  1499. ROR CL,1 ;else 010101
  1500. COLCOM:
  1501. MOV DX,GRPADD ;address of index port
  1502. MOV AL,LOW CDCREG ;Color Don't Care register
  1503. OUT DX,AL
  1504. INC DX ;data port address
  1505. MOV AL,CL ;mask indicating planes to ignore (=0)
  1506. OUT DX,AL ;set up initial Color Don't Care planes
  1507. ; perform color compare on first byte
  1508. MOV AL,ES:[SI] ;bits set where border found
  1509. EGAINT10STI ;read is done, reenable ints if EGAINT10
  1510. ; Starting at entry cursor, search right looking for non-border,
  1511. ; viewport edge, or end-of-byte as long as DX does not decrement to 0.
  1512. XOR AH,AH ;initialize viewport mask to 0
  1513. SRCRT3:
  1514. CMP SI,B$REOFST ;check whether we are in viewport edge byte
  1515. JNZ NOTVP3
  1516. MOV AH,B$VRMASK ;if so, get viewport edge mask
  1517. NOTVP3:
  1518. ; While border...
  1519. TEST AL,CH ;compare color compare mask with b$MaskC
  1520. JZ ENDRT3 ;if pixel not border, exit loop
  1521. ; and not viewport edge...
  1522. TEST AH,CH ;compare viewport edge mask with b$MaskC
  1523. JNZ ENDRT3 ;if edge found, exit
  1524. ; and BX is greater than 0...
  1525. DEC BX ;contains # pixels which can be skipped
  1526. JZ ENDRT3 ;in search for non-border pixel
  1527. ; and not off the edge of the byte...
  1528. ROR CH,1 ;shift bit mask right
  1529. ; repeat the search
  1530. JNB NOTVP3
  1531. ; end of first byte.
  1532. INC SI ;next byte address
  1533. ROR CL,1 ;rotate mask for next Color Don't Care
  1534. MOV AL,CL
  1535. OUT DX,AL ;next compare with alternate planes disabled
  1536. MOV AL,ES:[SI]
  1537. EGAINT10STI ;reenable ints between bytes if EGAINT10
  1538. MOV CH,80H ;mask now 1000/0000 for next search
  1539. JMP SHORT SRCRT3
  1540. ; either (not border) OR (viewport edge) OR (DX = 0)
  1541. ENDRT3:
  1542. MOV DX,BX ;return decremented value to proper register
  1543. TEST AL,CH ;border?
  1544. JZ NTBRD3 ;if so, we are either at viewport edge
  1545. XOR DX,DX ;or have skipped DX pixels and therefore
  1546. MOV BX,DX ;should exit with info as initialized
  1547. XOR CL,CL ;restore old value to flag
  1548. JMP SHORT SCNEX3
  1549. ; Look for viewport edge to determine how many bytes to look
  1550. ; through for border pixel.
  1551. NTBRD3:
  1552. PUSH DX ;store skipcount for later
  1553. XOR DX,DX ;use to count pixels painted
  1554. MOV b$SaveCa,SI ;we have a new CSAVE
  1555. PUSH SI ;store copy of first byte address
  1556. MOV b$SaveCm,CH
  1557. CALL B$EgaCHKBTR ;set up byte for write, and count some pixels
  1558. ;(AH = viewport edge mask if any)
  1559. MOV BL,BH ;store first bit mask in BL
  1560. XOR BH,BH ;zero BH until last byte bit mask if any
  1561. XOR BP,BP ;start whole byte count at 0
  1562. MOV DI,B$REOFST
  1563. SUB DI,SI ;viewport edge address - first byte address
  1564. TEST BL,1 ;if last bit not set, we found border for sure
  1565. JZ WRTPX3 ;if just one byte, we're done
  1566. OR DI,DI ;check also if we hit viewport edge
  1567. JZ WRTPX3 ;if so, also done
  1568. ; else look through DI bytes for border (this includes viewport
  1569. ; edge byte)
  1570. DEC BP ;start increment at -1
  1571. MOV CH,80H ;start each byte at left edge
  1572. PUSH DX ;save accumulating bit count
  1573. MOV DX,GRPADD+1 ;prepare to send Color Don't Care data
  1574. SCANM3:
  1575. INC BP ;whole byte count
  1576. INC SI ;point to byte
  1577. ROR CL,1 ;rotate plane mask
  1578. MOV AL,CL
  1579. OUT DX,AL
  1580. MOV AL,ES:[SI] ;read each byte for color compare
  1581. EGAINT10STI ;read is done, reenable ints if EGAINT10
  1582. OR AL,AL ;check for occurrence of border pixel(s)
  1583. JNZ BRDPX3 ;set up last byte
  1584. DEC DI ;decrement to 0 to include last byte
  1585. JNZ SCANM3 ;go check out this byte
  1586. ; MOV AH,B$VRMASK ;if edge of viewport, get viewport mask
  1587. ;and proceed to set up byte for write
  1588. BRDPX3:
  1589. ;may have found border, viewport
  1590. ; edge, or have both in same byte
  1591. CMP SI,B$REOFST ;heck if this is edge byte
  1592. JNZ BRDFD3
  1593. MOV AH,B$VRMASK ;if found, install viewport edge mask
  1594. BRDFD3:
  1595. POP DX ;restore pixel count
  1596. CALL B$EgaCHKBTR ;set up byte for write
  1597. ; most recent call to CHKBTR has generated new cursor location and mask
  1598. WRTPX3:
  1599. MOV b$OffC,SI
  1600. MOV b$MaskC,CH
  1601. POP DI ;restore leftmost byte address
  1602. PUSH DI ;save a copy for leftmost add. for painting
  1603. PUSH SI ;save copy of rightmost address also
  1604. MOV SI,DI ;leftmost byte address in SI for PIXRGT
  1605. MOV DI,BP ;PIXRGT will use DI to count whole bytes
  1606. CMP b$Tiling,0 ;see whether tiling is on
  1607. JZ COLCM3
  1608. CALL B$EgaTILRGT
  1609. JMP SHORT COLCM4
  1610. COLCM3:
  1611. CALL B$EgaSETCMP ;set color compare register to paint attribute
  1612. CALL PIXRT3 ;routine to determine whether any pixels change
  1613. COLCM4:
  1614. POP SI ;restore rightmost
  1615. POP DI ;and leftmost byte addresses
  1616. OR CL,CL ;non-zero indicates at least one must change
  1617. JZ NPNTR3
  1618. XOR CH,CH ;zero as increment flag
  1619. CLD ;for SCANR, paint routine should increment REP
  1620. CALL B$EgaPAINPX ;set line
  1621. NPNTR3:
  1622. CALL B$EgaPIXCNT ;return # pixels "painted" in BX
  1623. POP DX ;skipcount in DX
  1624. SCNEX3:
  1625. CALL B$ResetEGA ;reset EGA registers for BIOS write mode 0
  1626. MOV SI,b$SaveCa ;return CSAVE
  1627. MOV AL,b$SaveCm
  1628. cEnd
  1629. ASSUME DS:NOTHING
  1630. ;***
  1631. ; Read_64K
  1632. ;
  1633. ;Purpose:
  1634. ; Support routine for NReadL_64K, reads one byte from screen
  1635. ; memory into AL.  Read from even plane even address, from
  1636. ; odd plane if odd address.
  1637. ;Entry:
  1638. ; DS:SI = screen address
  1639. ;Exit:
  1640. ; AL    = screen contents from address at ES:DI
  1641. ; DI    = incremented to next screen byte
  1642. ;Uses:
  1643. ; per conv.
  1644. ;Exceptions:
  1645. ;******************************************************************************
  1646. DbPub Read_64K
  1647. cProc Read_64K,<NEAR>
  1648. cBegin
  1649. EGAINT10CLI ;disable ints if using EGAINT10
  1650. mov al,RMPREG ;select read map select register
  1651. out dx,al
  1652. inc dx
  1653. xor al,al ;for plane computation
  1654. ror di,1 ;carry = 1 if odd address
  1655. adc al,BasePlane ;base plane +1 iff odd address
  1656. rol di,1 ;restore address
  1657. out dx,al ;set plane to read
  1658. dec dx
  1659. lodsb ;read it (finally!!)
  1660. EGAINT10STI ;reenable ints if using EGAINT10
  1661. cEnd
  1662. ;***
  1663. ; NReadL_64K
  1664. ;
  1665. ;Purpose:
  1666. ; Read a line of pixels from a specified plane to an array for
  1667. ; 64K Screen mode 9 (odd/even color mode).
  1668. ;Entry:
  1669. ; DS:SI = screen address
  1670. ; ES:DI = array address
  1671. ; CL    = array align shift count
  1672. ; CH    = mask for last partial byte
  1673. ; BP    = count of bits to read
  1674. ; BH    = plane to read from
  1675. ;Exit:
  1676. ; ES:DI = updated to array byte past point used
  1677. ;Uses:
  1678. ; per conv.
  1679. ;Exceptions:
  1680. ;******************************************************************************
  1681. DbPub NReadL_64K
  1682. cProc NReadL_64K,<NEAR>
  1683. cBegin
  1684. MOV DX,GRPADD ;address graphics controller
  1685. ;the next 2 statements appear to be unnecessary, but I'm not totally sure.
  1686. ; MOV AX,RWMREG ;r/w mode, [ah] = 0
  1687. ; OutWord  ;non color compare read
  1688. shl bh,1 ;plane 0 = maps 0/1, plane 1 = maps 2/3
  1689. mov BasePlane,bh
  1690. call Read_64K ;preload hi byte
  1691. mov ah,al ;  to ah
  1692. NRdLoopX:
  1693. call Read_64K ;fill ax word with video bytes
  1694. mov bh,al ;this lo byte will become next hi byte
  1695. rol ax,cl ;align to array
  1696. sub bp,8 ;8 bits done
  1697. jbe NRdLastX ;go if bit count exhausted
  1698. mov es:[di],ah ;save full byte
  1699. inc di
  1700. mov ah,bh ;move lo byte (BH) to hi byte (AH)
  1701. jnz NRdLoopX ;loop if no offset overflow
  1702. call B$BumpES ;move array pointer over segment boundary
  1703. jmp short NRdLoopX ;go do another
  1704. NRdLastX:
  1705. and ah,ch ;strip unused bits from last byte
  1706. mov es:[di],ah ;save last byte
  1707. inc di
  1708. jnz NRdDoneX
  1709. call B$BumpES ;move array pointer over segment boundary
  1710. NRdDoneX:
  1711. cEnd
  1712. ;***
  1713. ; Write_64K
  1714. ;
  1715. ;Purpose:
  1716. ; Support routine for NWriteL_64K, writes one byte to screen
  1717. ; memory from AL.  Initializes EGA regs to appropriate plane and
  1718. ; vectors through [b$PutVector] which writes the byte after
  1719. ; applying any bitwise logic necessary.
  1720. ;Entry:
  1721. ; ES:DI = screen address
  1722. ;Exit:
  1723. ; None
  1724. ;Uses:
  1725. ; per conv.
  1726. ;Exceptions:
  1727. ;******************************************************************************
  1728. DbPub Write_64K
  1729. cProc Write_64K,<NEAR>,<AX,DX>
  1730. cBegin
  1731. push ax
  1732. MOV DX,GRPADD ;address graphics controller
  1733. mov al,RMPREG ;select read map select register
  1734. out dx,al
  1735. inc dx
  1736. xor al,al ;for plane computation
  1737. ror di,1 ;carry = 1 if odd address
  1738. adc al,BasePlane ;base plane +1 iff odd address
  1739. rol di,1 ;restore address
  1740. out dx,al ;set plane to read
  1741. MOV DX,SEQADD ;address the sequencer
  1742. MOV AL,MMREG ;  map mask register
  1743. out dx,al
  1744. inc dx
  1745. mov al,b$PlaneMask ;get base plane mask
  1746. and al,MapMask ;with even/odd map mask
  1747. and al,0FH ;strip to nibble
  1748. out dx,al ;set plane to write
  1749. rol MapMask,1 ;rotate even/odd mask for next byte
  1750. pop ax
  1751. .erre ID_SSEQDS ;assumes ss = ds
  1752. call ss:[b$PutVector]   ;put the byte (finally!!)
  1753. cEnd
  1754. ;***
  1755. ; NWriteL_64K
  1756. ;
  1757. ;Purpose:
  1758. ; Write a line of pixels from an array to a specified plane for
  1759. ; 64K Screen mode 9 (odd/even color mode).
  1760. ;Entry:
  1761. ; ES:DI = screen address
  1762. ; DS:SI = array address
  1763. ; CX    = array align shift count
  1764. ; BP    = count of bits to write
  1765. ; BH    = plane to write to
  1766. ; DL    = last partial byte mask
  1767. ; DH    = first partial byte mask
  1768. ;Exit:
  1769. ; DS:SI = updated to array byte past point used
  1770. ;Uses:
  1771. ; per conv.
  1772. ;Exceptions:
  1773. ;******************************************************************************
  1774. DbPub NWriteL_64K
  1775. cProc NWriteL_64K,<NEAR>
  1776. cBegin
  1777. rol b$PlaneMask,1 ;shift to next plane
  1778. rol b$PlaneMask,1
  1779. mov MapMask,01010101B ;setup map mask for even access
  1780. test di,1 ;is it even?
  1781. jz IsEvenX  ;go if so
  1782. rol MapMask,1
  1783. IsEvenX:
  1784. shl bh,1 ;plane 0 = maps 0/1, plane 1 = maps 2/3
  1785. mov BasePlane,bh
  1786. push dx
  1787. mov ah,dh ;first byte bit mask
  1788. MOV DX,GRPADD ;address graphics controller
  1789. mov al,BMKREG ;  bit mask register
  1790. EGAINT10CLI ;disable ints if using EGAINT10 interface
  1791. OutWord  ;set first partial byte mask
  1792. pop dx
  1793. mov ah,[si]  ;preload byte from array
  1794. inc si
  1795. jnz NWrOvfl1X
  1796. call B$BumpDS ;move array pointer over segment boundary
  1797. NWrOvfl1X:
  1798. ror ax,cl ;align to video
  1799. add bp,cx
  1800. sub bp,8 ;account for first partial byte
  1801. jbe NWrLastX ;go if last byte
  1802. call Write_64K
  1803. mov dh,0FFH  ;mask for whole bytes in the middle
  1804. push ax
  1805. push dx
  1806. mov ah,dh ;middle byte bit mask
  1807. MOV DX,GRPADD ;address graphics controller
  1808. mov al,BMKREG ;  bit mask register
  1809. OutWord  ;set full byte mask for middle bytes
  1810. EGAINT10STI ;reenable ints if using EGAINT10 interface
  1811. pop dx
  1812. pop ax
  1813. jmp short NWrLoopX2
  1814. NWrLoopX:
  1815. .erre ID_SSEQDS ;assumes ss = ds
  1816. EGAINT10CLI ;disable ints if using EGAINT10 interface
  1817. call Write_64K ;put the byte
  1818. EGAINT10STI ;reenable ints if using EGAINT10 interface
  1819. NWrLoopX2:
  1820. rol ax,cl ;re-align to array
  1821. xchg ah,al
  1822. cmp cx,bp ;enough bits in this byte to finish
  1823. jae NWrOvfl2X ;go if so, don't load another
  1824. mov ah,[si]  ;fill ax word with array bytes
  1825. inc si
  1826. jnz NWrOvfl2X
  1827. call B$BumpDS ;move array pointer over segment boundary
  1828. NWrOvfl2X:
  1829. ror ax,cl ;align to video
  1830. sub bp,8 ;8 bits done
  1831. ja NWrLoopX ;go if bit count not exhausted
  1832. NWrLastX:
  1833. push ax
  1834. and dh,dl ;combine first|middle mask with end mask
  1835. mov ah,dh ;last byte bit mask
  1836. MOV DX,GRPADD ;address graphics controller
  1837. mov al,BMKREG ;  bit mask register
  1838. EGAINT10CLI ;disable ints if using EGAINT10 interface
  1839. OutWord  ;set first partial byte mask
  1840. pop ax
  1841. .erre ID_SSEQDS ;assumes ss = ds
  1842. call Write_64K ;put the last byte
  1843. EGAINT10STI ;reenable ints if using EGAINT10 interface
  1844. cEnd
  1845. ASSUME DS:DGROUP
  1846. ;***
  1847. ; B$xINITEGA - initialize EGA modes
  1848. ;
  1849. ;Purpose:
  1850. ; Added with revision [26].
  1851. ; Put the addresses of EGA screen mode support routines into the
  1852. ; dispatch table used by the screen statement.
  1853. ;
  1854. ;Entry:
  1855. ; None
  1856. ;Exit:
  1857. ; ScreenTab updated
  1858. ;Uses:
  1859. ; None
  1860. ;Exceptions:
  1861. ;******************************************************************************
  1862. cProc B$xINITEGA,<FAR,PUBLIC> 
  1863. cBegin
  1864. MOV WORD PTR [b$ScreenTab + (7*2) + 1],OFFSET B$Screen7
  1865. MOV WORD PTR [b$ScreenTab + (8*2) + 1],OFFSET B$Screen8
  1866. MOV WORD PTR [b$ScreenTab + (9*2) + 1],OFFSET B$Screen9
  1867. MOV WORD PTR [b$ScreenTab + (10*2)+ 1],OFFSET B$Screen10
  1868. cEnd
  1869. sEnd GR_TEXT
  1870. END