home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / xbase / library / clipper / screen / fxcolor.asm next >
Assembly Source File  |  1992-04-15  |  119KB  |  2,512 lines

  1. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2. ;▓
  3. ;▓ FXCOLOR.ASM
  4. ;▓
  5. ;▓ Written by Jim Fowler (CIS 73340,3425).
  6. ;▓
  7. ;▓ Adapted for Clipper 5.01 from code developed
  8. ;▓    by Chris Dunford (CIS 76703,2002).
  9. ;▓
  10. ;▓ This system contains functions manipulating the VGA color system allowing
  11. ;▓ special color effects to be used with Clipper 5.01.
  12. ;▓
  13. ;▓ Compile with MASM 5.x
  14. ;▓
  15. ;▓ Version History:
  16. ;▓    04/16/92   1.00   Initial release for Clipper 5.01.
  17. ;▓
  18. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  19.  
  20.  
  21. ;░░░░ Callable Functions From Clipper ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  22. ;░
  23. ;░ fx_Enable     Initializes system, call before using others.
  24. ;░ fx_Disable    Restores system, call before terminating.
  25. ;░ fx_IsFxOn     Returns .T. if special effects system enabled, .F. if not.
  26. ;░ fx_IsVGA      Returns .T. if VGA is present, .F. if not.
  27. ;░ fx_Restore    Restores all 16 palettes for one attribute to default values.
  28. ;░ fx_RestAll    Restores all 16 palettes for all attributes to default values.
  29. ;░ fx_PalRate    Sets/Returns increment rate for palette changes.
  30. ;░ fx_IntRate    Sets/Returns interval rate between palettes changes.
  31. ;░ fx_SetFix     Sets/Returns fixed palette status.  .T.=fixed palette mode on.
  32. ;░ fx_SetPal     Sets/Returns the fixed palette number.
  33. ;░ fx_Palette    Sets/Returns RGB values for all attributes for one palette.
  34. ;░ fx_PalAll     Sets/Returns RGB values for all attributes for all palettes.
  35. ;░ fx_Attr       Sets/Returns RGB values for all palettes for one attribute.
  36. ;░ fx_AttrAll    Sets/Returns RGB values for all palettes for all attributes.
  37. ;░ fx_Fade       Produces a fading effect for an attribute.
  38. ;░ fx_Blink      Produces a blinking effect for an attribute.
  39. ;░ fx_Pulse      Produces a pulsing effect for an attribute.
  40. ;░
  41. ;░ Additionally, one data item is public to other ASM or C routines.  _FxEnabled
  42. ;░ is a byte variable indicating whether the color system and the intercept
  43. ;░ routine for INT 1C is enabled.  A non-zero value indicates it is enabled.
  44. ;░ The value should not be reset from another ASM or C routine, or unpredictable
  45. ;░ results could occur.
  46. ;░
  47. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  48.  
  49.  
  50. ;░░░░ Public Declarations ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  51. ;░
  52.  
  53. Public      FX_ENABLE                           ;
  54. Public      FX_DISABLE                          ;
  55. Public      FX_ISFXON                           ;
  56. Public      FX_ISVGA                            ;
  57. Public      FX_RESTORE                          ;
  58. Public      FX_RESTALL                          ;
  59. Public      FX_PALRATE                          ;
  60. Public      FX_INTRATE                          ;
  61. Public      FX_SETFIX                           ;
  62. Public      FX_SETPAL                           ;
  63. Public      FX_PALETTE                          ;
  64. Public      FX_PALALL                           ;
  65. Public      FX_ATTR                             ;
  66. Public      FX_ATTRALL                          ;
  67. Public      FX_FADE                             ;
  68. Public      FX_BLINK                            ;
  69. Public      FX_PULSE                            ;
  70. Public      _FXENABLED                          ; Byte
  71.  
  72. ;░
  73. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  74.  
  75.  
  76. ;░░░░ External Declarations ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  77. ;░
  78.  
  79. Extrn       __ParC:Far                          ;
  80. Extrn       __ParCLen:Far                       ;
  81. Extrn       __ParInfo:Far                       ;
  82. Extrn       __ParL:Far                          ;
  83. Extrn       __ParNI:Far                         ;
  84. Extrn       __Ret:Far                           ;
  85. Extrn       __RetCLen:Far                       ;
  86. Extrn       __RetL:Far                          ;
  87. Extrn       __RetNI:Far                         ;
  88. Extrn       __XFree:Far                         ;
  89. Extrn       __XGrab:Far                         ;
  90.  
  91. ;░
  92. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  93.  
  94.  
  95. ;░░░░ Sub-Function Definitions ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  96. ;░
  97. ;░ Sub-functions (AL values) for _PalFunc (INT 10h, Function 10h).
  98. ;░
  99.  
  100. _SetPalReg  equ      2                          ;
  101. _GetPalReg  equ      9                          ;
  102. _SetDACs    equ      12h                        ; Not used / register level
  103. _SetState   equ      13h                        ;
  104. _GetDACs    equ      17h                        ;
  105. _GetState   equ      1Ah                        ;
  106.  
  107. ;░
  108. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  109.  
  110.  
  111. ;░░░░ Structure Definitions ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  112. ;░
  113. ;░ Structure for storing graded color scaling data.  See _CalcScale procedure.
  114. ;░
  115.  
  116. _ScaleFact  Struc
  117.             _ScaleIncr  db  ?                   ;
  118.             _XS_Count   db  ?                   ;
  119.             _XS_Incr    db  ?                   ;
  120. _ScaleFact  Ends
  121.  
  122. ;░
  123. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  124.  
  125.  
  126. ;▓▓▓▓ Begin Data Segment ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  127. ;▓
  128.  
  129. DGROUP      Group    _FXDATA
  130. _FXDATA     Segment  Public  'DATA'
  131.  
  132.  
  133. _RGBString  db       16*3    dup (0)            ; Storage for 48-byte RGB string
  134. _RGBDef     db       3       dup (0)            ; Storage for RBG definitions
  135. _OrigMode   db       ?                          ; Original attrib. control mode
  136. _OrigColor  db       ?                          ; Original color select reg val
  137. _OrigPals   db       16*16*3 dup (0)            ; 16 palettes, 16 attrib. each,
  138.                                                 ;    3 RGB values per attrib.
  139. _NewPals    db       16*16*3 dup (0)            ; Storage for the augmented pals
  140. _OrigRegs   db       17      dup (0)            ; Storage for the 16 palatte
  141.                                                 ;    registers + overscan reg
  142.  
  143.             ; The 16 new palette register contents we will use, plus overscan.
  144.             
  145. _NewRegs    db       0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0
  146.  
  147.             ; Storage for factors used to scale one color to another over
  148.             ; sixteen palettes.  Don't separate or re-order; module assumes
  149.             ; that the R/G/B records are contiguous and in that order.
  150.             
  151. _RedScale   _ScaleFact   <>
  152. _GrnScale   _ScaleFact   <>
  153. _BlueScale  _ScaleFact   <>
  154.  
  155.             ; Color definitions for our 16 base attributes with 3 R/G/B
  156.             ; values each.
  157.             
  158. _NewBase    Label    Byte
  159.             db 00h,00h,00h                      ; Attribute 0 (black)
  160.             db 00h,00h,2Ah                      ; Attribute 1 (blue)
  161.             db 00h,2Ah,00h                      ; Attribute 2 (green)
  162.             db 00h,2Ah,2Ah                      ; Attribute 3 (cyan)
  163.             db 2Ah,00h,00h                      ; Attribute 4 (red)
  164.             db 2Ah,00h,2Ah                      ; Attribute 5 (magenta)
  165.             db 2Ah,15h,00h                      ; Attribute 6 (brown)
  166.             db 2Ah,2Ah,2Ah                      ; Attribute 7 (white)
  167.             db 15h,15h,15h                      ; Attribute 8 (gray)
  168.             db 00h,00h,35h                      ; Attribute 9 (bright blue)
  169.             db 00h,35h,00h                      ; Attribute 10 (bright green)
  170.             db 00h,35h,35h                      ; Attribute 11 (bright cyan)
  171.             db 35h,00h,00h                      ; Attribute 12 (bright red)
  172.             db 35h,00h,35h                      ; Attribute 13 (bright magenta)
  173.             db 35h,35h,00h                      ; Attribute 14 (yellow)
  174.             db 35h,35h,35h                      ; Attribute 15 (bright white)
  175.  
  176. _FxEnabled  db       0                          ; Flag: 0=disabled, 1=enabled
  177. _TickRate   dw       1                          ; Flash rate, in timer ticks
  178. _TickCount  dw       3                          ; Remaining countdown
  179. _TickDflt   dw       3                          ; Default tick count
  180. _CurPal     db       0                          ; Current palette #
  181. _PalRate    db       1                          ; # palettes to change per flash
  182. _FixedMode  db       0                          ; Flag: 0=fixed mode OFF, 1=ON
  183. _FixedPal   db       0                          ; Storage for fixed palette
  184. _XParams    db       0                          ; Storage for number of params
  185. _XAttrib    db       0                          ; Storage for base attribute
  186. _XSecond    db       0                          ; Storage for secondary attrib
  187. _XPalette   db       0                          ; Storage for palette number
  188. _XTemp      db       0                          ; Storage for temporary byte
  189. _XTempW     dw       0                          ; Storage for temporary word
  190.  
  191. _XMemory    Label    DWord                      ; Storage for Clipper memory
  192.             _XMemVecLo  dw  ?                   ;    pointer
  193.             _XMemVecHi  dw  ?                   ;
  194.             
  195. _FXDATA     Ends
  196.  
  197. ;▓
  198. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  199.  
  200.  
  201. ;▓▓▓▓ Begin Code Segment ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  202. ;▓
  203.  
  204. _FXCODE     Segment  Word  'CODE'
  205.             Assume   CS:_FXCODE, DS:DGROUP
  206.  
  207.  
  208. ;░░░░ Code Segment Variables ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  209. ;░
  210.  
  211. _OldInt1C   Label    DWord                      ; Storage for original INT 1Ch
  212.             _Int1CLo    dw  ?                   ;    address
  213.             _Int1CHi    dw  ?                   ;
  214.  
  215. _OldInt21   Label    DWord                      ; Storage for original INT 21h
  216.             _Int21Lo    dw   ?                  ;    address
  217.             _Int21Hi    dw   ?                  ;
  218.  
  219. ;░
  220. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  221.  
  222.  
  223. ;░░░░ fx_Enable ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  224. ;░
  225. ;░ This function must be called first to initialize the system for color
  226. ;░ functions.  It accomplishes several tasks:
  227. ;░
  228. ;░    - Saves the 16 palette registers in _OrigRegs
  229. ;░    - Gets the current 256 colors (4 palettes) to _OrigPals
  230. ;░    - Duplicates palette 0 in palettes 1-15 and loads it into the VGA
  231. ;░    - Installs the INT 1C intercept
  232. ;░
  233. ;░ On exit, the system is set up, but no special effects are in use (because
  234. ;░ palettes 0-15 are identical).
  235. ;░
  236. ;░ Clipper Usage:   fx_Enable()
  237. ;░
  238. ;░ Returns .F. if no VGA detected, .T. if initialized.
  239. ;░
  240.  
  241. FX_ENABLE   Proc     Far
  242.                 
  243.             Push     BP                         ; Save registers for Clipper
  244.                 Mov      BP,SP                      ;
  245.                 Push     DS                         ;
  246.                 Push     SI                         ;
  247.             Push     DI                         ;
  248.             Push     ES                         ;
  249.             Mov      AX,DS                      ; Set ES=DS
  250.             Mov      ES,AX                      ;
  251.                 Call     _CheckVGA                  ; Test for VGA presence
  252.             JC       L01_Cont1                  ; Yes, continue
  253.             Jmp      L01_RtnF                   ; No, exit
  254. L01_Cont1:  Test     _FxEnabled,0FFh            ; Is system already enabled?
  255.             JZ       L01_Cont2                  ; No, continue
  256.             Jmp      L01_RtnT                   ; Yes, then don't redo
  257. L01_Cont2:  Mov      AL,_GetState               ;
  258.             Call     _PalFunc                   ; A VGA-only function
  259.             Mov      _OrigMode,BL               ;
  260.                 Mov      _OrigColor,BH              ;
  261.                 
  262.             ; Save the 16 current palette registers into _OrigRegs.  Reset the
  263.                 ; palette registers to contain 16 "standard" 4-bit colors.
  264.                 
  265.             Mov      DX,Offset DS:_OrigRegs     ;
  266.             Mov      AL,_GetPalReg              ;
  267.             Call     _PalFunc                   ; Get current palette regs
  268.             Mov      AL,_OrigRegs+16            ; Continue to use the current
  269.                 And      AL,0Fh                     ;    border color
  270.             Mov      _NewRegs+16,AL             ;
  271.  
  272.             ; Save the original DAC color registers (256 colors) in _OrigPals.
  273.                 
  274.                 Xor      BX,BX                      ; Start with register 0
  275.             Mov      CX,100h                    ; 256 registers
  276.             Mov      DX,Offset DS:_OrigPals     ; Put them in _OrigPals
  277.             Mov      AL,_GetDACs                ;
  278.             Call     _PalFunc                   ;
  279.             Call     _DuplPal0                  ; Create 16 standard palettes
  280.  
  281.             Mov      DX,Offset DS:_NewRegs      ;
  282.             Mov      AL,_SetPalReg              ;
  283.             Call     _PalFunc                   ; Load new palette registers
  284.             Call     _LoadPal                   ; Load new RGB values
  285.             Mov      BX,100h                    ; Set attr control to mode 1
  286.             Mov      AL,_SetState               ;
  287.             Call     _PalFunc                   ; Load new control mode 1
  288.             CLC                                 ; Set flag for off
  289.             Call     _HWBlink                   ; Set hardware blink OFF
  290.             Mov      AX,_TickDflt               ; Set defaults
  291.             Mov      _TickCount,AX              ;
  292.             Mov      _TickRate,1                ;
  293.                 Mov      _CurPal,0                  ;
  294.                 Mov      _PalRate,1                 ;
  295.             Mov      _FixedMode,0               ;
  296.             Mov      _FixedPal,0                ;
  297.             Mov      _FxEnabled,1               ; Set enabled flag
  298.             Push     ES                         ; Get the current INT 21h
  299.             Mov      AX,3521h                   ;    address and save it
  300.             Int      21h                        ;
  301.             Mov      CS:_Int21Lo,BX             ;
  302.             Mov      CS:_Int21Hi,ES             ;
  303.             Pop      ES                         ;
  304.             Push     DS                         ; Set the INTh 21 address to
  305.             Mov      DX,Offset CS:_Intrcpt21    ;    _Intrcpt21.
  306.             Mov      BX,CS                      ;
  307.             Mov      DS,BX                      ; DS:DX = new address
  308.             Mov      AX,2521h                   ;
  309.             Int      21h                        ;
  310.             Pop      DS                         ;
  311.             Push     ES                         ; Get the current INT 1Ch
  312.             Mov      AX,351Ch                   ;    address and save it
  313.             Int      21h                        ;
  314.             Mov      CS:_Int1CLo,BX             ;
  315.             Mov      CS:_Int1CHi,ES             ;
  316.             Pop      ES                         ;
  317.             Push     DS                         ; Set the INT 1Ch address to
  318.             Mov      DX,Offset CS:_Intrcpt1C    ;    _Intrcpt1C.
  319.             Mov      BX,CS                      ;
  320.             Mov      DS,BX                      ; DS:DX = new address
  321.             Mov      AX,251Ch                   ;
  322.             Int      21h                        ;
  323.             Pop      DS                         ;
  324. L01_RtnT:   Mov      AX,1                       ; Set .T. return flag
  325.             Jmp      Short L01_Cont3            ;
  326. L01_RtnF:   Mov      AX,0                       ; Set .F. return flag
  327. L01_Cont3:  Push     AX                         ;
  328.                 Call     __RetL                     ; Clipper logical return
  329.                 Add      SP,2                       ;
  330. L01_End:    Pop      ES                         ; Restore registers
  331.             Pop      DI                         ;
  332.                 Pop      SI                         ;
  333.                 Pop      DS                         ;
  334.                 Pop      BP                         ;
  335.                 CLD                                 ;
  336.             Ret                                 ;
  337.                 
  338. FX_ENABLE   Endp
  339.  
  340. ;░
  341. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  342.  
  343.  
  344. ;░░░░ fx_Disable ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  345. ;░
  346. ;░ This function must be called for cleanup when program terminates.  It
  347. ;░ uninstalls the color effect system.
  348. ;░
  349. ;░ Clipper Usage:   fx_Disable()
  350. ;░
  351. ;░ Returns a NIL value.
  352. ;░
  353.  
  354. FX_DISABLE  Proc     Far
  355.                 
  356.             Push     BP                         ; Save registers for Clipper
  357.                 Mov      BP,SP                      ;
  358.                 Push     DS                         ;
  359.                 Push     SI                         ;
  360.             Push     DI                         ;
  361.             Push     ES                         ;
  362.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  363.                 JZ       L02_Exit                   ; No, then exit
  364.             Call     _UnInstall                 ; Disable the system
  365. L02_Exit:   Call     __Ret                      ; Clipper NIL return
  366.             Pop      ES                         ; Restore registers
  367.             Pop      DI                         ;
  368.                 Pop      SI                         ;
  369.                 Pop      DS                         ;
  370.                 Pop      BP                         ;
  371.                 CLD                                 ;
  372.             Ret                                 ;
  373.                 
  374. FX_DISABLE  Endp
  375.  
  376. ;░
  377. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  378.  
  379.  
  380. ;░░░░ fx_IsFxOn ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  381. ;░
  382. ;░ Tests for special effects and timer intercept enabled.
  383. ;░
  384. ;░ Clipper Usage:   fx_IsFxOn()
  385. ;░
  386. ;░ Returns status of _FxEnabled flag (.T./.F.).
  387. ;░
  388.  
  389. FX_ISFXON   Proc     Far
  390.                 
  391.             Push     BP                         ; Save registers for Clipper
  392.                 Mov      BP,SP                      ;
  393.                 Push     DS                         ;
  394.                 Push     SI                         ;
  395.             Push     DI                         ;
  396.             Mov      AL,_FxEnabled              ; Get flag status
  397.             Xor      AH,AH                      ; Clear AH
  398.                 Push     AX                         ; AX has return value
  399.                 Call     __RetL                     ; Clipper logical return
  400.                 Add      SP,2                       ;
  401.             Pop      DI                         ; Restore registers
  402.                 Pop      SI                         ;
  403.                 Pop      DS                         ;
  404.                 Pop      BP                         ;
  405.                 CLD                                 ;
  406.             Ret                                 ;
  407.                 
  408. FX_ISFXON   Endp
  409.  
  410. ;░
  411. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  412.  
  413.  
  414. ;░░░░ fx_IsVGA ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  415. ;░
  416. ;░ Tests for a VGA installed.
  417. ;░
  418. ;░ Clipper Usage:   fx_IsVGA()
  419. ;░
  420. ;░ Returns .T. if a VGA is installed, else it returns .F.
  421. ;░
  422.  
  423. FX_ISVGA    Proc     Far
  424.                 
  425.             Push     BP                         ; Save registers for Clipper
  426.                 Mov      BP,SP                      ;
  427.                 Push     DS                         ;
  428.                 Push     SI                         ;
  429.             Push     DI                         ;
  430.             Mov      _XTemp,1                   ; Set default for .T.
  431.                 Call     _CheckVGA                  ; Test for VGA presence
  432.             JC       L04_Cont                   ; Yes, continue
  433.             Mov      _XTemp,0                   ; Set for .F.
  434. L04_Cont:   Mov      AL,_XTemp                  ; _XTemp has return value
  435.             Xor      AH,AH                      ; Clear AH
  436.             Push     AX                         ;
  437.                 Call     __RetL                     ; Clipper logical return
  438.                 Add      SP,2                       ;
  439.             Pop      DI                         ; Restore registers
  440.                 Pop      SI                         ;
  441.                 Pop      DS                         ;
  442.                 Pop      BP                         ;
  443.                 CLD                                 ;
  444.             Ret                                 ;
  445.                 
  446.  
  447. FX_ISVGA    Endp
  448.  
  449. ;░
  450. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  451.  
  452.  
  453. ;░░░░ fx_Restore ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  454. ;░
  455. ;░ Restores all palettes of one attribute to the attribute's original values.
  456. ;░
  457. ;░ Clipper Usage:   c_Restore( cBaseAttribute )
  458. ;░
  459. ;░ Where cBaseAttribute is the attribute to restore.
  460. ;░
  461. ;░ Returns NIL value.
  462. ;░
  463.  
  464. FX_RESTORE  Proc     Far
  465.                 
  466.                 Push     BP                         ; Save registers for Clipper
  467.                 Mov      BP,SP                      ;
  468.                 Push     DS                         ;
  469.                 Push     SI                         ;
  470.                 Push     DI                         ;
  471.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  472.             JZ       L05_Exit                   ; No, then exit
  473.                 Call     _ParamCnt                  ; Get number of parameters
  474.                 Or       AX,AX                      ;
  475.             JZ       L05_Exit                   ; If zero params, then exit
  476.                 Mov      AX,1                       ; Specify param #
  477.                 Call     _GetCParam                 ; Get the parameter
  478.             JC       L05_Exit                   ; If not color attr, then exit
  479.                 Mov      _XAttrib,AL                ; Save the attribute
  480.                 STC                                 ; Flag _NewBase as source
  481.             Call     _SetRGBDef                 ; Store original RGB to _RGBDef
  482.                 Push     SI                         ; Save SI
  483.             Mov      SI,Offset DS:_RGBDef       ; Set pointer DS:SI to _RGBDef
  484.                 Mov      AL,_XAttrib                ; Put attribute in AL
  485.             Mov      DX,3                       ; Set for 3-byte string
  486.             Mov      CX,0F00h                   ; Set palette range (0-15)
  487.             Call     _ColorAttr                 ; Set the new colors
  488.                 Pop      SI                         ; Restore SI
  489.                 Call     _LoadPal                   ; Load the new palettes
  490. L05_Exit:   Call     __Ret                      ; Clipper NIL return
  491.                 Pop      DI                         ; Restore registers
  492.                 Pop      SI                         ;
  493.                 Pop      DS                         ;
  494.                 Pop      BP                         ;
  495.                 CLD                                 ;
  496.                 Ret                                 ;
  497.                 
  498. FX_RESTORE  Endp
  499.  
  500. ;░
  501. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  502.  
  503.  
  504. ;░░░░ fx_RestAll ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  505. ;░
  506. ;░ Resets all palettes of all attributes to their original values and resets
  507. ;░ all flags and counters.
  508. ;░
  509. ;░ Clipper Usage:   fx_RestAll()
  510. ;░
  511. ;░ Returns NIL value.
  512. ;░
  513.  
  514. FX_RESTALL  Proc     Far
  515.                 
  516.                 Push     BP                         ; Save registers for Clipper
  517.                 Mov      BP,SP                      ;
  518.                 Push     DS                         ;
  519.                 Push     SI                         ;
  520.                 Push     DI                         ;
  521.             Push     ES                         ;
  522.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  523.             JZ       L06_Exit                   ; No, then exit
  524.             Call     _DuplPal0                  ;
  525.             Call     _LoadPal                   ; Reset all palettes
  526.                 CLI                                 ;
  527.             Test     _FixedMode,0FFh            ; Is fixed palette mode?
  528.             JNZ      L06_Cont                   ; Yes, skip setting _TickRate
  529.             Mov      _TickRate,1                ; Reset counts
  530. L06_Cont:   Mov      AX,_TickDflt               ;
  531.             Mov      _TickCount,AX              ;
  532.             Mov      _PalRate,1                 ;
  533.             STI                                 ;
  534. L06_Exit:   Call     __Ret                      ; Clipper NIL return
  535.             Pop      ES                         ; Restore registers
  536.             Pop      DI                         ;
  537.                 Pop      SI                         ;
  538.                 Pop      DS                         ;
  539.                 Pop      BP                         ;
  540.                 CLD                                 ;
  541.                 Ret                                 ;
  542.                 
  543. FX_RESTALL  Endp
  544.  
  545. ;░
  546. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  547.  
  548.  
  549. ;░░░░ fx_PalRate ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  550. ;░
  551. ;░ Sets the increment value for palette changes.  When the timer counts down
  552. ;░ and the palette is to be changed, the timer intercept will add/subtract
  553. ;░ this number to the current palette number.  With a higher _PalRate, the
  554. ;░ flashing occurs more rapidly.  E.g., with _PalRate=1, the palettes change
  555. ;░ 0,1,2,3,...,15.  With _PalRate=3, the palette changes are 0,3,6,9,12,15.
  556. ;░
  557. ;░ Clipper Usage:   fx_PalRate( [nIncrement] )
  558. ;░
  559. ;░ Where nIncrement is the palette increment value in the range 1 to 15.
  560. ;░
  561. ;░ Returns current palette increment setting.
  562. ;░
  563.  
  564. FX_PALRATE  Proc     Far
  565.                 
  566.                 Push     BP                         ; Save registers for Clipper
  567.                 Mov      BP,SP                      ;
  568.                 Push     DS                         ;
  569.                 Push     SI                         ;
  570.                 Push     DI                         ;
  571.             Mov      AL,_PalRate                ; Get the current Pal rate
  572.             Mov      _XTemp,AL                  ;    and save it
  573.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  574.             JZ       L07_Exit                   ; No, return default
  575.                 Call     _ParamCnt                  ; Get number of parameters
  576.                 Or       AX,AX                      ;
  577.             JZ       L07_Exit                   ; If zero params, then exit
  578.                 Mov      AX,1                       ; Specify param #
  579.                 Call     _GetNParam                 ; Get the parameter
  580.             JC       L07_Exit                   ; If not numeric, quit
  581.             Xor      AH,AH                      ; Clear AH
  582.             Cmp      AL,0Fh                     ; Is it <= 15?
  583.             JA       L07_Exit                   ; No, exit
  584.             Or       AL,AL                      ; Is it > 0?
  585.             JZ       L07_Exit                   ; No, exit
  586.             Mov      CL,AL                      ; Save for calculation
  587.                 CLI                                 ;
  588.             Mov      _PalRate,AL                ; Save the new rate
  589.             Mov      AL,_CurPal                 ; Calculate multiple
  590.                 Xor      AH,AH                      ;
  591.                 Div      CL                         ;
  592.                 Mul      CL                         ;
  593.             Mov      _CurPal,AL                 ; Save the new starting palette
  594.                 STI                                 ;
  595. L07_Exit:   Mov      AL,_XTemp                  ; Get prior setting
  596.             Xor      AH,AH                      ; Clear AH
  597.             Push     AX                         ; AX contains prior rate
  598.                 Call     __RetNI                    ; Clipper integer return
  599.                 Add      SP,2                       ;
  600.                 Pop      DI                         ; Restore registers
  601.                 Pop      SI                         ;
  602.                 Pop      DS                         ;
  603.                 Pop      BP                         ;
  604.                 CLD                                 ;
  605.                 Ret                                 ;
  606.                 
  607. FX_PALRATE  Endp
  608.  
  609. ;░
  610. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  611.  
  612.  
  613. ;░░░░ fx_IntRate ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  614. ;░
  615. ;░ Sets the timer interval rate (every Nth ticks) for palette changes.
  616. ;░
  617. ;░ Clipper Usage:   fx_IntRate( [nIntervalRate] )
  618. ;░
  619. ;░ Where nIntervalRate is the timer interval rate in the range 1 to 65535.
  620. ;░
  621. ;░ Returns current timer interval setting.
  622. ;░
  623.  
  624. FX_INTRATE  Proc     Far
  625.                 
  626.                 Push     BP                         ; Save registers for Clipper
  627.                 Mov      BP,SP                      ;
  628.                 Push     DS                         ;
  629.                 Push     SI                         ;
  630.                 Push     DI                         ;
  631.             Mov      AX,_TickRate               ; Get the current tick rate
  632.             Mov      _XTempW,AX                 ;    and save it
  633.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  634.             JZ       L08_Exit                   ; No, exit
  635.                 Call     _ParamCnt                  ; Get number of parameters
  636.                 Or       AX,AX                      ;
  637.             JZ       L08_Exit                   ; If zero params, then exit
  638.                 Mov      AX,1                       ; Specify param #
  639.                 Call     _GetNParam                 ; Get the parameter
  640.                 JC       L08_Exit                   ; If not numeric, quit
  641.             Or       AX,AX                      ; Is it zero?
  642.             JZ       L08_Exit                   ; Yes, so cannot set
  643.                 CLI                                 ;
  644.                 Mov      _TickRate,AX               ; Save new setting
  645.             Mov      _TickCount,AX              ;
  646.                 STI                                 ;
  647. L08_Exit:   Mov      AX,_XTempW                 ; AX now contains prior rate
  648.             Push     AX                         ;
  649.                 Call     __RetNI                    ; Clipper integer return
  650.                 Add      SP,2                       ;
  651.                 Pop      DI                         ; Restore registers
  652.                 Pop      SI                         ;
  653.                 Pop      DS                         ;
  654.                 Pop      BP                         ;
  655.                 CLD                                 ;
  656.                 Ret                                 ;
  657.                 
  658. FX_INTRATE  Endp
  659.  
  660. ;░
  661. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  662.  
  663.  
  664. ;░░░░ fx_SetFix ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  665. ;░
  666. ;░ Sets/reads the _FixedMode flag.  The _Fixed flag when non-zero indicates
  667. ;░ the same palette should be used and no switching of palettes by the timer
  668. ;░ intercept routine occurs.  The fixed palette to display is set by the
  669. ;░ fx_SetPal() function (defalut is palette 0).  When this flag is set
  670. ;░ (non-zero), the following routines have no effect:
  671. ;░
  672. ;░    - fx_PalRate()
  673. ;░    - fx_IntRate()
  674. ;░    - fx_Fade()
  675. ;░    - fx_Blink()
  676. ;░    - fx_Pulse()
  677. ;░
  678. ;░ Clipper Usage:   fx_SetFix( [lFixedSetting] )
  679. ;░
  680. ;░ Where lFixedSetting = .T. cancels palette switching and .F. restores it.
  681. ;░
  682. ;░ Returns current _FixedMode flag setting (.T./.F.).
  683. ;░
  684.  
  685. FX_SETFIX   Proc     Far
  686.                 
  687.             Push     BP                         ; Save registers for Clipper
  688.                 Mov      BP,SP                      ;
  689.                 Push     DS                         ;
  690.                 Push     SI                         ;
  691.             Push     DI                         ;
  692.             Mov      BL,_FixedMode              ; Get the current flag
  693.             Mov      _XTemp,BL                  ;    And save it
  694.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  695.             JZ       L09_Exit                   ; No, exit
  696.             Call     _ParamCnt                  ; Get number of parameters
  697.                 Or       AX,AX                      ;
  698.             JZ       L09_Exit                   ; If zero params, then exit
  699.                 Mov      AX,1                       ; Specify param #
  700.             Call     _GetLParam                 ; Get the parameter
  701.             JC       L09_Exit                   ; If not logical, then jump
  702.             CLI                                 ;
  703.             Mov      _FixedMode,AL              ; Save new setting
  704.             Mov      _TickRate,1                ; Set timer rate to default
  705.             Test     AL,0FFh                    ; Is fixed mode ON?
  706.             JZ       L09_Cont                   ; No, then continue
  707.             Mov      _TickRate,0FFFFh           ; Yes, set timer rate to max
  708. L09_Cont:   Mov      AX,_TickDflt               ;
  709.             Mov      _TickCount,AX              ; Set default count
  710.             STI                                 ;
  711. L09_Exit:   Mov      AL,_XTemp                  ; Get prior setting
  712.             Xor      AH,AH                      ; Clear AH
  713.             Push     AX                         ; AX contains prior state
  714.                 Call     __RetL                     ; Clipper logical return
  715.                 Add      SP,2                       ;
  716.                 Pop      DI                         ; Restore registers
  717.                 Pop      SI                         ;
  718.                 Pop      DS                         ;
  719.                 Pop      BP                         ;
  720.                 CLD                                 ;
  721.                 Ret                                 ;
  722.                 
  723. FX_SETFIX   Endp
  724.  
  725. ;░
  726. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  727.  
  728.  
  729. ;░░░░ fx_SetPal ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  730. ;░
  731. ;░ Sets the fixed palette number to display.  Only applicable if _FixedMode
  732. ;░ flag is set (non-zero).  Use fx_SetFix() to set the _FixedMode flag.
  733. ;░
  734. ;░ Clipper Usage:   fx_SetPal( [nPalette] )
  735. ;░
  736. ;░ Where nPalette is the palette number to fix for display.  Must be in the
  737. ;░ range 0 to 15.
  738. ;░
  739. ;░ Returns current fixed palette number.
  740. ;░
  741.  
  742. FX_SETPAL   Proc     Far
  743.                 
  744.                 Push     BP                         ; Save registers for Clipper
  745.                 Mov      BP,SP                      ;
  746.                 Push     DS                         ;
  747.                 Push     SI                         ;
  748.                 Push     DI                         ;
  749.             Mov      AL,_FixedPal               ; Get the current fixed palette
  750.             Mov      _XTemp,AL                  ;    and save it
  751.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  752.             JZ       L10_Exit                   ; No, return default value
  753.                 Call     _ParamCnt                  ; Get number of parameters
  754.                 Or       AX,AX                      ;
  755.             JZ       L10_Exit                   ; If zero params, then exit
  756.                 Mov      AX,1                       ; Specify param #
  757.                 Call     _GetNParam                 ; Get the parameter
  758.             JC       L10_Exit                   ; If not numeric, quit
  759.             Cmp      AL,0Fh                     ; Is it <= 15?
  760.             JA       L10_Exit                   ; No, then exit
  761.                 CLI                                 ;
  762.             Mov      _FixedPal,AL               ; Set the palette to use
  763.             Mov      AX,_TickDflt               ;
  764.             Mov      _TickCount,AX              ; Reset current count
  765.                 STI
  766. L10_Exit:   Mov      AL,_XTemp                  ; Get prior value
  767.             Xor      AH,AH                      ; Clear AH
  768.             Push     AX                         ; AX contains prior palette
  769.                 Call     __RetNI                    ; Clipper integer return
  770.                 Add      SP,2                       ;
  771.                 Pop      DI                         ; Restore registers
  772.                 Pop      SI                         ;
  773.                 Pop      DS                         ;
  774.                 Pop      BP                         ;
  775.                 CLD                                 ;
  776.                 Ret                                 ;
  777.                 
  778. FX_SETPAL   Endp
  779.  
  780. ;░
  781. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  782.  
  783.  
  784. ;░░░░ fx_Palette ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  785. ;░
  786. ;░ Sets/returns the RGB values for each attribute in a palette via a 48 byte
  787. ;░ character string containing RGB values.  If no string is received, or if it
  788. ;░ is not length 48 bytes, no update will occur.  Values in the string greater
  789. ;░ than 63 are not updated.  Similiar to fx_Attr(), except processes by palette,
  790. ;░ not attribute.
  791. ;░
  792. ;░ Clipper Usage:   fx_Palette( nPalette, [cRGBString] )
  793. ;░
  794. ;░ Where nPalette is the palette number to set/return in the range 0 to 15, and
  795. ;░ cRGBString is a string of RGB values (in ASC form) for the attributes in the
  796. ;░ palette.
  797. ;░
  798. ;░ Returns a 48 byte character string containing RGB information for each
  799. ;░ attribute in the palette.  Returns an empty string if a parameter error
  800. ;░ occurs.
  801. ;░
  802. ;░ RGB string information is stored in the following manner:
  803. ;░
  804. ;░                 Attribute 0                 Attribute 15
  805. ;░               Red  Green  Blue            Red  Green  Blue
  806. ;░    Byte # ->   1     2     3     .....     46    47    48
  807. ;░
  808.  
  809. FX_PALETTE  Proc     Far
  810.                 
  811.                 Push     BP                         ; Save registers for Clipper
  812.                 Mov      BP,SP                      ;
  813.                 Push     DS                         ;
  814.                 Push     SI                         ;
  815.                 Push     DI                         ;
  816.             Push     ES                         ;
  817.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  818.             JNZ      L11_Go                     ; Yes, continue
  819.             Jmp      L11_NoStr                  ; No, then exit
  820. L11_Go:     Call     _ParamCnt                  ; Get number of parameters
  821.             Or       AX,AX                      ; Is zero params?
  822.             JNZ      L11_Store                  ; No, then continue
  823.             Jmp      L11_NoStr                  ; Yes, then exit
  824. L11_Store:  Mov      _XParams,AL                ; Store the number of params
  825.                 Mov      AX,1                       ; Specify param #
  826.             Call     _GetNParam                 ; Get the parameter
  827.             JC       L11_NoStr                  ; If not numeric, then exit
  828.             Cmp      AL,0Fh                     ; Is it <= 15?
  829.             JA       L11_NoStr                  ; No, then exit
  830.             Mov      _XPalette,AL               ; Save the palette number
  831.                 
  832.             ; Copy palette to _RGBString for return string.
  833.                 
  834.             Mov      BX,DS                      ; Set ES=DS
  835.             Mov      ES,BX                      ;
  836.             Mov      DI,Offset DS:_RGBString    ; Point to _RGBString as dest.
  837.             Mov      CL,_XPalette               ; Set CL=palette
  838.             Call     _GetPalPtr                 ; Get offset of palette
  839.                 Mov      SI,BX                      ; Point to _NewPals as source
  840.             Mov      CX,18h                     ; 48 RGB values (24 words)
  841.             CLD                                 ;
  842. L11_Loop1:  Lodsw                               ; Load word from _NewPals
  843.             Stosw                               ; Store word in _RGBString
  844.             Loop     L11_Loop1                  ; Loop until CX=0
  845.             Cmp      _XParams,2                 ; Is their a second param?
  846.             JB       L11_Str                    ; No, then jump
  847.                 Mov      AX,2                       ; Specify param #
  848.                 Push     AX                         ; Put on stack
  849.                 Call     __ParInfo                  ; Retrieve type
  850.                 Add      SP,2                       ; Restore stack
  851.             Cmp      AX,1                       ; Is param character?
  852.             JNE      L11_NoStr                  ; No, quit
  853.                 Mov      AX,2                       ; Specify param #
  854.                 Push     AX                         ; Put on stack
  855.                 Call     __ParCLen                  ; Retrieve length
  856.                 Add      SP,2                       ;
  857.             Cmp      AX,30h                     ; Is it length 48?
  858.             JNE      L11_NoStr                  ; No, quit
  859.                 Mov      AX,2                       ; Specify param #
  860.                 Push     AX                         ; Put on stack
  861.                 Call     __ParC                     ; Retrieve value
  862.                 Add      SP,2                       ; DX:AX point to color string
  863.                 
  864.             ; Copy the parameter string into _NewPals.
  865.                 
  866.             Mov      CL,_XPalette               ; Retrieve palette number
  867.             Call     _GetPalPtr                 ; Get ptr to _NewPals offset
  868.                 Mov      DI,BX                      ; Point to _NewPals as dest.
  869.             Push     DS                         ; Save DS
  870.             Mov      BX,DS                      ; Set ES=DS
  871.             Mov      ES,BX                      ;
  872.                 Mov      DS,DX                      ; Point to param as source
  873.                 Mov      SI,AX                      ;
  874.             Mov      CX,30h                     ; Set for 48 RGB values
  875.             CLD                                 ;
  876. L11_Loop2:  Lodsb                               ; Load byte from param string
  877.             Cmp      AL,63                      ; Is RGB value <= 63
  878.             JA       L11_Empty                  ; No, then don't store
  879.                 Stosb                               ; Store byte in _NewPals
  880.             Jmp      Short L11_Next             ; Continue to next byte
  881. L11_Empty:  Inc      DI                         ; Adjust pointer
  882. L11_Next:   Loop     L11_Loop2                  ; Loop until CX=0
  883.             Pop      DS                         ; Restore DS
  884.                 
  885.             ; Now load the new palette to VGA and finish.
  886.  
  887.             Call     _LoadPal                   ; Load the new palette
  888. L11_Str:    Mov      AX,30h                     ; Store length (48)
  889.             Jmp      Short L11_Cont             ; Continue
  890. L11_NoStr:  Mov      AX,0                       ; Store length (0)
  891. L11_Cont:   Push     AX                         ; Put length on stack
  892.             Mov      DX,DS                      ; Get segment
  893.             Mov      AX,Offset DS:_RGBString    ; Get offset
  894.             Push     DX                         ; Store segment
  895.             Push     AX                         ; Store offset
  896.                 Call     __RetCLen                  ; Clipper fixed length string
  897.                 Add      SP,6                       ;
  898.             Pop      ES                         ; Restore registers
  899.             Pop      DI                         ;
  900.                 Pop      SI                         ;
  901.                 Pop      DS                         ;
  902.                 Pop      BP                         ;
  903.                 CLD                                 ;
  904.                 Ret                                 ;
  905.                 
  906. FX_PALETTE  Endp
  907.  
  908. ;░
  909. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  910.  
  911.  
  912. ;░░░░ fx_PalAll ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  913. ;░
  914. ;░ Sets/returns the RGB values for all attributes in all palettes via a 768 byte
  915. ;░ character string containing RGB values.  If no string is received, or if it
  916. ;░ is not length 768 bytes, no update will occur.  Values in the string greater
  917. ;░ than 63 are not updated. Similiar to fx_AttrAll(), except processes by
  918. ;░ palette, not attribute.
  919. ;░
  920. ;░ Clipper Usage:   fx_PalAll( [cRGBString] )
  921. ;░
  922. ;░ Where cRGBString is a string of RGB values (in ASC form) for all attributes
  923. ;░ in the palette.
  924. ;░
  925. ;░ Returns a 768 byte character string containing RGB information for each
  926. ;░ attribute in all palettes.  Returns an empty string if a parameter error
  927. ;░ occurs.
  928. ;░
  929. ;░ RGB string information is stored in the following manner:
  930. ;░
  931. ;░                      Attribute 0                 Attribute 15
  932. ;░                    Red  Green  Blue            Red  Green  Blue         
  933. ;░    Palette  0  ->    1     2     3    .....     46    47    48  ─┐
  934. ;░        ...     ->  ...   ...   ...    .....    ...   ...   ...   │ Byte #'s
  935. ;░    Palette 15  ->  721   722   723    .....    766   767   768  ─┘
  936. ;░
  937.  
  938. FX_PALALL   Proc     Far
  939.                 
  940.                 Push     BP                         ; Save registers for Clipper
  941.                 Mov      BP,SP                      ;
  942.                 Push     DS                         ;
  943.                 Push     SI                         ;
  944.                 Push     DI                         ;
  945.             Push     ES                         ;
  946.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  947.             JNZ      L12_Start                  ; Yes, then jump
  948.                 
  949.                 ; Not enabled, so we want to return a zero-length string and
  950.                 ; bypass allocating any of Clipper's memory.
  951.                 
  952.                 Mov      AX,0                       ; Store length (0)
  953.                 Push     AX                         ; Put length on stack
  954.             Mov      DX,DS                      ; Store segment
  955.             Mov      AX,Offset DS:_NewPals      ; Store offset
  956.                 Push     DX                         ; Put address on stack
  957.                 Push     AX                         ;
  958.                 Call     __RetCLen                  ; Clipper fixed length string
  959.                 Add      SP,6                       ;
  960.             Jmp      L12_Exit                   ;
  961.                 
  962.                 ; Let's grab some memory from Clipper for this one and
  963.                 ; copy the entire _NewPals string into memory for return.
  964.                 
  965. L12_Start:  Mov      AX,300h                    ; Request 768 bytes
  966.                 Push     AX                         ; Put on stack
  967.                 Call     __XGrab                    ; Pointer returned in DX:AX
  968.                 Add      SP,2                       ;
  969.                 Mov      _XMemVecLo,AX              ; Save pointer
  970.                 Mov      _XmemVecHi,DX              ;
  971.                 Mov      ES,DX                      ; Point to memory as destination
  972.                 Mov      DI,AX                      ;
  973.             Mov      SI,Offset DS:_NewPals      ; Point to _NewPals as source
  974.             Mov      CX,180h                    ; 768 RGB values (384 words)
  975.             CLD                                 ;
  976. L12_Loop1:  Lodsw                               ; Load word from _NewPals
  977.             Stosw                               ; Store word in memory
  978.             Loop     L12_Loop1                  ; Loop until CX=0
  979.  
  980.                 ; Now check if a parameter string was passed for updating.
  981.                 
  982.                 Call     _ParamCnt                  ; Get number of parameters
  983.                 Or       AX,AX                      ;
  984.             JZ       L12_Str                    ; If zero params, then exit
  985.                 Mov      AX,1                       ; Specify param #
  986.                 Push     AX                         ; Put on stack
  987.                 Call     __ParInfo                  ; Retrieve type
  988.                 Add      SP,2                       ; Restore stack
  989.             Cmp      AX,1                       ; Is param character?
  990.             JNE      L12_NoStr                  ; No, quit
  991.                 Mov      AX,1                       ; Specify param #
  992.                 Push     AX                         ; Put on stack
  993.                 Call     __ParCLen                  ; Retrieve length
  994.                 Add      SP,2                       ;
  995.             Cmp      AX,300h                    ; Is it length 768?
  996.             JNE      L12_NoStr                  ; No, quit
  997.                 Mov      AX,1                       ; Specify param #
  998.                 Push     AX                         ; Put on stack
  999.                 Call     __ParC                     ; Retrieve value
  1000.                 Add      SP,2                       ; DX:AX point to source string
  1001.                 
  1002.             ; Copy the parameter string into _NewPals.
  1003.  
  1004.             Mov      BX,DS                      ; Set ES=DS
  1005.             Mov      ES,BX                      ;
  1006.             Mov      DI,Offset DS:_NewPals      ; Point to _NewPals as dest.
  1007.             Push     DS                         ; Save DS
  1008.             Mov      DS,DX                      ; Point to param as source
  1009.                 Mov      SI,AX                      ;
  1010.             Mov      CX,300h                    ; Set for 768 RGB values
  1011.             CLD                                 ;
  1012. L12_Loop2:  Lodsb                               ; Load byte from param string
  1013.             Cmp      AL,63                      ; Is RGB value <= 63
  1014.             JA       L12_Empty                  ; No, then don't store
  1015.                 Stosb                               ; Store byte in _NewPals
  1016.             Jmp      Short L12_Next             ; Continue to next byte
  1017. L12_Empty:  Inc      DI                         ; Adjust pointer
  1018. L12_Next:   Loop     L12_Loop2                  ; Loop until CX=0
  1019.             Pop      DS                         ; Restore DS
  1020.                 
  1021.             ; Now load the new palette to VGA and finish.
  1022.  
  1023.             Call     _LoadPal                   ; Load the new palettes
  1024. L12_Str:    Mov      AX,300h                    ; Store length (768)
  1025.             Jmp      Short L12_Cont             ; Continue
  1026. L12_NoStr:  Mov      AX,0                       ; Store length (0)
  1027. L12_Cont:   Push     AX                         ; Put length on stack
  1028.                 Mov      DX,_XMemVecHi              ; Store segment
  1029.                 Mov      AX,_XMemVecLo              ; Store offset
  1030.                 Push     DX                         ; Put address on stack
  1031.                 Push     AX                         ;
  1032.             Call     __RetCLen                  ; Clipper fixed length string
  1033.                 Add      SP,6                       ;
  1034.                 Push     DX                         ; Put address on stack
  1035.                 Push     AX                         ;
  1036.                 Call     __XFree                    ; Deallocate memory
  1037.                 Add      SP,4                       ;
  1038. L12_Exit:   Pop      ES                         ; Restore registers
  1039.             Pop      DI                         ;
  1040.                 Pop      SI                         ;
  1041.                 Pop      DS                         ;
  1042.                 Pop      BP                         ;
  1043.                 CLD                                 ;
  1044.                 Ret                                 ;
  1045.                 
  1046. FX_PALALL   Endp
  1047.  
  1048. ;░
  1049. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1050.  
  1051.  
  1052. ;░░░░ fx_Attr ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1053. ;░
  1054. ;░ Sets/returns the RGB values for an attribute in all palettes via a 48 byte
  1055. ;░ character string containing RGB values.  If no string is received, or if it
  1056. ;░ is not length 48 bytes, no update will occur.  Values in the string greater
  1057. ;░ than 63 are not updated.  Similiar to fx_Palette(), except processes by
  1058. ;░ attribute, not palette.
  1059. ;░
  1060. ;░ Clipper Usage:   fx_Attr( cAttribute, [cRGBString] )
  1061. ;░
  1062. ;░ Where cAttribute is the attribute to set/return, and cRGBString is a string
  1063. ;░ of RGB values (in ASC form) for the attribute in each palette.
  1064. ;░
  1065. ;░ Returns a 48 byte character string containing RGB information for each
  1066. ;░ palette for the attribute.  Returns an empty string if a parameter error
  1067. ;░ occurs.
  1068. ;░
  1069. ;░ RGB string information is stored in the following manner:
  1070. ;░
  1071. ;░                  Palette 0                   Palette 15
  1072. ;░               Red  Green  Blue            Red  Green  Blue
  1073. ;░    Byte # ->   1     2     3     .....     46    47    48
  1074. ;░
  1075.  
  1076. FX_ATTR     Proc     Far
  1077.                 
  1078.                 Push     BP                         ; Save registers for Clipper
  1079.                 Mov      BP,SP                      ;
  1080.                 Push     DS                         ;
  1081.                 Push     SI                         ;
  1082.                 Push     DI                         ;
  1083.             Push     ES                         ;
  1084.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  1085.             JNZ      L13_Go                     ; Yes, continue
  1086.             Jmp      L13_NoStr                  ; No, then exit
  1087. L13_Go:     Call     _ParamCnt                  ; Get number of parameters
  1088.             Or       AX,AX                      ; Is zero params?
  1089.             JNZ      L13_Store                  ; No, then continue
  1090.             Jmp      L13_NoStr                  ; Yes, then exit
  1091. L13_Store:  Mov      _XParams,AL                ; Store the number of params
  1092.                 Mov      AX,1                       ; Specify param #
  1093.                 Call     _GetCParam                 ; Get the parameter
  1094.             JC       L13_NoStr                  ; If not character, then exit
  1095.                 Mov      _XAttrib,AL                ; Save the color attribute
  1096.                 
  1097.             ; Copy Pals 0-15 for attribute to _RGBString for return string.
  1098.                 
  1099.             Mov      BX,DS                      ; Set ES=DS
  1100.             Mov      ES,BX                      ;
  1101.             Mov      CX,0F00h                   ; Set full range for palettes
  1102.             Call     _GetDACPtr                 ; Get offset of first palette
  1103.                 Mov      SI,BX                      ; Point to _NewPals as source
  1104.             Mov      DI,Offset DS:_RGBString    ; Point to _RGBString as dest.
  1105.                 Mov      CX,10h                     ; Set for 16 palettes
  1106. L13_Loop:   Lodsb                               ; Load byte from _NewPals
  1107.             Stosb                               ; Store byte in _RGBString
  1108.                 Lodsw                               ; Load word from _NewPals
  1109.             Stosw                               ; Store word in _RGBString
  1110.                 Add      SI,16*3-3                  ; Adjust for next palette
  1111.             Loop     L13_Loop                   ; Loop until CX=0
  1112.             Cmp      _XParams,2                 ; Is their a second param?
  1113.             JB       L13_Str                    ; No, then jump
  1114.                 Mov      AX,2                       ; Specify param #
  1115.                 Push     AX                         ; Put on stack
  1116.                 Call     __ParInfo                  ; Retrieve type
  1117.                 Add      SP,2                       ; Restore stack
  1118.             Cmp      AX,1                       ; Is param character?
  1119.             JNE      L13_NoStr                  ; No, quit
  1120.                 Mov      AX,2                       ; Specify param #
  1121.                 Push     AX                         ; Put on stack
  1122.                 Call     __ParCLen                  ; Retrieve length
  1123.                 Add      SP,2                       ;
  1124.             Cmp      AX,30h                     ; Is it length 48?
  1125.             JNE      L13_NoStr                  ; No, quit
  1126.                 Mov      AX,2                       ; Specify param #
  1127.                 Push     AX                         ; Put on stack
  1128.                 Call     __ParC                     ; Retrieve value
  1129.                 Add      SP,2                       ; DX:AX point to color string
  1130.             Mov      CL,_XAttrib                ; Put attribute in CL (temp)
  1131.             Push     DS                         ; Save DS
  1132.             Mov      BX,DS                      ; Set ES=DS
  1133.             Mov      ES,BX                      ;
  1134.                 Mov      DS,DX                      ; Set pointer DS:SI
  1135.                 Mov      SI,AX                      ;
  1136.             Mov      AL,CL                      ; Move attribute to AL
  1137.             Xor      AH,AH                      ; Clear AH
  1138.             Mov      DX,30h                     ; Set flag for 48-byte string
  1139.             Mov      CX,0F00h                   ; Set palette rabge (0-15)
  1140.             Call     _ColorAttr                 ; Set the new colors
  1141.             Pop      DS                         ; Restore DS
  1142.                 Call     _LoadPal                   ; Load the new palettes
  1143. L13_Str:    Mov      AX,30h                     ; Store length (48)
  1144.             Jmp      Short L13_Cont             ; Continue
  1145. L13_NoStr:  Mov      AX,0                       ; Store length (0)
  1146. L13_Cont:   Push     AX                         ; Put length on stack
  1147.             Mov      DX,DS                      ; Get segment
  1148.             Mov      AX,Offset DS:_RGBString    ; Get offset
  1149.             Push     DX                         ; Store segment
  1150.             Push     AX                         ; Store offset
  1151.                 Call     __RetCLen                  ; Clipper fixed length string
  1152.                 Add      SP,6                       ;
  1153.             Pop      ES                         ; Restore registers
  1154.             Pop      DI                         ;
  1155.                 Pop      SI                         ;
  1156.                 Pop      DS                         ;
  1157.                 Pop      BP                         ;
  1158.                 CLD                                 ;
  1159.                 Ret                                 ;
  1160.                 
  1161. FX_ATTR     Endp
  1162.  
  1163. ;░
  1164. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1165.  
  1166.  
  1167. ;░░░░ fx_AttrAll ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1168. ;░
  1169. ;░ Sets/returns the RGB values for all attributes in all palettes via a 768 byte
  1170. ;░ character string containing RGB values.  If no string is received, or if it
  1171. ;░ is not length 768 bytes, no update will occur.  Values in the string greater
  1172. ;░ than 63 are not updated. Similiar to fx_PalAll(), except processes by
  1173. ;░ attribute, not palette.
  1174. ;░
  1175. ;░ Clipper Usage:   fx_AttrAll( [cRGBString] )
  1176. ;░
  1177. ;░ Where cRGBString is a string of RGB values (in ASC form) for all attributes.
  1178. ;░
  1179. ;░ Returns a 768 byte character string containing RGB information for each
  1180. ;░ attribute in all palettes.  Returns an empty string if a parameter error
  1181. ;░ occurs.
  1182. ;░
  1183. ;░ RGB string information is stored in the following manner:
  1184. ;░
  1185. ;░                         Palette 0                   Palette 15
  1186. ;░                      Red  Green  Blue            Red  Green  Blue
  1187. ;░    Attribute  0  ->    1     2     3    .....     46    47    48  ─┐
  1188. ;░          ...     ->  ...   ...   ...    .....    ...   ...   ...   │ Byte #'s
  1189. ;░    Attribute 15  ->  721   722   723    .....    766   767   768  ─┘
  1190. ;░
  1191.  
  1192. FX_ATTRALL  Proc     Far
  1193.                 
  1194.                 Push     BP                         ; Save registers for Clipper
  1195.                 Mov      BP,SP                      ;
  1196.                 Push     DS                         ;
  1197.                 Push     SI                         ;
  1198.                 Push     DI                         ;
  1199.             Push     ES                         ;
  1200.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  1201.             JNZ      L14_Start                  ; Yes, then jump
  1202.                 
  1203.                 ; Not enabled, so we want to return a zero-length string and
  1204.                 ; bypass allocating any of Clipper's memory.
  1205.                 
  1206.                 Mov      AX,0                       ; Store length (0)
  1207.                 Push     AX                         ; Put length on stack
  1208.             Mov      DX,DS                      ; Store segment
  1209.             Mov      AX,Offset DS:_NewPals      ; Store offset
  1210.                 Push     DX                         ; Put address on stack
  1211.                 Push     AX                         ;
  1212.                 Call     __RetCLen                  ; Clipper fixed length string
  1213.                 Add      SP,6                       ;
  1214.             Jmp      L14_Exit                   ;
  1215.                 
  1216.                 ; Let's grab some memory from Clipper for this one and
  1217.                 ; copy the entire _NewPals string into memory for return.
  1218.                 ; We need to adjust the placement because _NewPals stores
  1219.                 ; info sequentially by palettes but we want to return the
  1220.                 ; info stored sequentially by color attribute.  Note that
  1221.                 ; values are in blocks of three for RGB.
  1222.                 
  1223. L14_Start:  Mov      AX,300h                    ; Request 768 bytes
  1224.                 Push     AX                         ; Put on stack
  1225.                 Call     __XGrab                    ; Pointer returned in DX:AX
  1226.                 Add      SP,2                       ;
  1227.                 Mov      _XMemVecLo,AX              ; Save pointer
  1228.             Mov      _XMemVecHi,DX              ;
  1229.                 Mov      ES,DX                      ; Point to memory as destination
  1230.                 Mov      DI,AX                      ;
  1231.                 CLD                                 ; 
  1232.                 Mov      AX,0                       ; Start with attribute 0
  1233. L14_Loop1:  Push     AX                         ; Save current attrib on stack
  1234.                 Mov      CX,0                       ; Start with palette 0
  1235.                 Call     _GetDACPtr                 ; Get ptr to _NewPals offset
  1236.                 Mov      SI,BX                      ; Point to _NewPals as source
  1237.                 Mov      CX,10h                     ; Set for 16 palettes
  1238. L14_Loop2:  Lodsb                               ; Load byte from _NewPals
  1239.                 Stosb                               ; Store byte in memory
  1240.                 Lodsw                               ; Load word from _NewPals
  1241.                 Stosw                               ; Store word in memory
  1242.                 Add      SI,16*3-3                  ; Adjust ptr to next palette
  1243.             Loop     L14_Loop2                  ; Loop until CX=0
  1244.                 Pop      AX                         ; Retrieve current attribute
  1245.                 Inc      AX                         ; Add one for next
  1246.             Cmp      AX,10h                     ; Have we done 16 attributes?
  1247.             JB       L14_Loop1                  ; No, then do next attribute
  1248.                 
  1249.                 ; Now check if a parameter string was passed for updating.
  1250.                 
  1251.                 Call     _ParamCnt                  ; Get number of parameters
  1252.                 Or       AX,AX                      ;
  1253.             JZ       L14_Str                    ; If zero params, then exit
  1254.                 Mov      AX,1                       ; Specify param #
  1255.                 Push     AX                         ; Put on stack
  1256.                 Call     __ParInfo                  ; Retrieve type
  1257.                 Add      SP,2                       ; Restore stack
  1258.             Cmp      AX,1                       ; Is param character?
  1259.             JNE      L14_NoStr                  ; No, quit
  1260.                 Mov      AX,1                       ; Specify param #
  1261.                 Push     AX                         ; Put on stack
  1262.                 Call     __ParCLen                  ; Retrieve length
  1263.                 Add      SP,2                       ;
  1264.             Cmp      AX,300h                    ; Is it length 256*3?
  1265.             JNE      L14_NoStr                  ; No, quit
  1266.                 Mov      AX,1                       ; Specify param #
  1267.                 Push     AX                         ; Put on stack
  1268.                 Call     __ParC                     ; Retrieve value
  1269.                 Add      SP,2                       ; DX:AX point to source string
  1270.                 
  1271.                 ; Copy the parameter string into _NewPals.  We need to adjust
  1272.                 ; the placement from color attribute order (source) to palette
  1273.                 ; order (_NewPals - destination).  Note that values are in
  1274.                 ; blocks of three for RGB.
  1275.                 
  1276.             Push     DS                         ; Save DS
  1277.             Mov      BX,DS                      ; Set ES=DS
  1278.             Mov      ES,BX                      ;
  1279.                 Mov      DS,DX                      ; Point to param as source
  1280.                 Mov      SI,AX                      ;
  1281.                 CLD                                 ; 
  1282.                 Mov      AX,0                       ; Start with attribute 0
  1283. L14_Loop3:  Push     AX                         ; Save current attrib on stack
  1284.                 Mov      CX,0                       ; Start with palette 0
  1285.                 Call     _GetDACPtr                 ; Get ptr to _NewPals offset
  1286.                 Mov      DI,BX                      ; Point to _NewPals as dest.
  1287.                 Mov      CX,10h                     ; Set for 16 palettes
  1288. L14_Loop4:  Lodsb                               ; Load byte from attrib string
  1289.                 Cmp      AL,63                      ; Is color value <= 63
  1290.             JA       L14_Empty1                 ; No, then don't store
  1291.                 Stosb                               ; Store byte in _NewPals
  1292.             Jmp      Short L14_Get2             ; Continue to next byte
  1293. L14_Empty1: Inc      DI                         ; Adjust pointer
  1294. L14_Get2:   Lodsb                               ; Load byte from attrib string
  1295.                 Cmp      AL,63                      ; Is color value <= 63
  1296.             JA       L14_Empty2                 ; No, then don't store
  1297.                 Stosb                               ; Store byte in _NewPals
  1298.             Jmp      Short L14_Get3             ; Continue to next byte
  1299. L14_Empty2: Inc      DI                         ; Adjust pointer
  1300. L14_Get3:   Lodsb                               ; Load byte from attrib string
  1301.                 Cmp      AL,63                      ; Is color value <= 63
  1302.             JA       L14_Empty3                 ; No, then don't store
  1303.                 Stosb                               ; Store byte in _NewPals
  1304.             Jmp      Short L14_Next             ; Continue to next palette
  1305. L14_Empty3: Inc      DI                         ; Adjust pointer
  1306. L14_Next:   Add      DI,16*3-3                  ; Adjust ptr to next palette
  1307.             Loop     L14_Loop4                  ; Loop until CX=0
  1308.                 Pop      AX                         ; Retrieve current attribute
  1309.                 Inc      AX                         ; Add one for next
  1310.             Cmp      AX,10h                     ; Have we done 16 attributes?
  1311.             JB       L14_Loop3                  ; No, then do next attribute
  1312.             Pop      DS                         ; Restore DS
  1313.                 
  1314.                 ; Now load the new palettes to VGA and finish.
  1315.                 
  1316.             Call     _LoadPal                   ; Load the new palettes
  1317. L14_Str:    Mov      AX,300h                    ; Store length (768)
  1318.             Jmp      Short L14_Cont             ; Continue
  1319. L14_NoStr:  Mov      AX,0                       ; Store length (0)
  1320. L14_Cont:   Push     AX                         ; Put length on stack
  1321.                 Mov      DX,_XMemVecHi              ; Store segment
  1322.                 Mov      AX,_XMemVecLo              ; Store offset
  1323.                 Push     DX                         ; Put address on stack
  1324.                 Push     AX                         ;
  1325.             Call     __RetCLen                  ; Clipper fixed length string
  1326.                 Add      SP,6                       ;
  1327.                 Push     DX                         ; Put address on stack
  1328.                 Push     AX                         ;
  1329.                 Call     __XFree                    ; Deallocate memory
  1330.                 Add      SP,4                       ;
  1331. L14_Exit:   Pop      ES                         ; Restore registers
  1332.             Pop      DI                         ;
  1333.                 Pop      SI                         ;
  1334.                 Pop      DS                         ;
  1335.                 Pop      BP                         ;
  1336.                 CLD                                 ;
  1337.                 Ret                                 ;
  1338.                 
  1339. FX_ATTRALL  Endp
  1340.  
  1341. ;░
  1342. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1343.  
  1344.  
  1345. ;░░░░ fx_Fade ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1346. ;░
  1347. ;░ Produces a fading effect.  The attribute slowly fades from base attribute
  1348. ;░ to secondary attribute and back again repeatedly.
  1349. ;░
  1350. ;░ Clipper Usage:   fx_Fade( cBaseAttr, cSecondAttr )
  1351. ;░
  1352. ;░ Where cBaseAttr is the base attribute to fade (i.e. it is the one whose RGB
  1353. ;░ values are changed), cSecondAttr is the attribute color to fade TO.
  1354. ;░
  1355. ;░ The RGB definition used for both attributes is the values contained in
  1356. ;░ _NewPals/palette 0.
  1357. ;░
  1358. ;░ Returns NIL value.
  1359. ;░
  1360.  
  1361. FX_FADE     Proc     Far
  1362.                 
  1363.                 Push     BP                         ; Save registers for Clipper
  1364.                 Mov      BP,SP                      ;
  1365.                 Push     DS                         ;
  1366.                 Push     SI                         ;
  1367.                 Push     DI                         ;
  1368.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  1369.             JZ       L15_Exit                   ; No, then exit
  1370.                 Call     _ParamCnt                  ; Get number of parameters
  1371.                 Cmp      AX,2                       ; At least 2 params?
  1372.             JB       L15_Exit                   ; No, then exit
  1373.                 Mov      AX,1                       ; Specify param #
  1374.                 Call     _GetCParam                 ; Get the parameter
  1375.             JC       L15_Exit                   ; If not character, then exit
  1376.                 Mov      _XAttrib,AL                ; Save the base attribute
  1377.                 Mov      AX,2                       ; Specify param #
  1378.                 Call     _GetCParam                 ; Get the parameter
  1379.             JC       L15_Exit                   ; If not character, then exit
  1380.             CLC                                 ; AL=secondary attribute
  1381.             Call     _SetRGBDef                 ; Move _NewPals RGB into _RGBDef
  1382.             Mov      SI,Offset DS:_RGBDef       ; Get the offset
  1383.                 Mov      AL,_XAttrib                ; Set AL=base attrib.
  1384.             Mov      CX,0F00h                   ; Set palette range (0-15)
  1385.             Call     _ScaleAttr                 ; Set the palette
  1386.                 Call     _LoadPal                   ;
  1387. L15_Exit:   Call     __Ret                      ; Clipper NIL return
  1388.             Pop      DI                         ; Restore registers
  1389.                 Pop      SI                         ;
  1390.                 Pop      DS                         ;
  1391.                 Pop      BP                         ;
  1392.                 CLD                                 ;
  1393.                 Ret                                 ;
  1394.                 
  1395. FX_FADE     Endp
  1396.  
  1397. ;░
  1398. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1399.  
  1400.  
  1401. ;░░░░ fx_Blink ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1402. ;░
  1403. ;░ Produces a blinking effect.  The attribute blinks from base attribute to
  1404. ;░ secondary attribute and back again repeatedly creating an On/Off effect.
  1405. ;░
  1406. ;░ Clipper Usage:   fx_Blink( cBaseAttr, cSecondAttr, [lSoftBlink] )
  1407. ;░
  1408. ;░ Where cBaseAttr is the base attribute to blink (i.e. it is the one whose
  1409. ;░ RGB values are changed), cSecondAttr is the attribute color to blink TO,
  1410. ;░ and lSoftBlink when .T. indicates to use a fading effect.  The default is
  1411. ;░ .F., or no fading.
  1412. ;░
  1413. ;░ The RGB definition used for both attributes is the values contained in
  1414. ;░ _NewPals/palette 0.
  1415. ;░
  1416. ;░ Returns NIL value.
  1417. ;░
  1418.  
  1419. FX_BLINK    Proc     Far
  1420.                 
  1421.                 Push     BP                         ; Save registers for Clipper
  1422.                 Mov      BP,SP                      ;
  1423.                 Push     DS                         ;
  1424.                 Push     SI                         ;
  1425.                 Push     DI                         ;
  1426.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  1427.             JZ       L16_Exit                   ; No, then exit
  1428.                 Call     _ParamCnt                  ; Get number of parameters
  1429.                 Cmp      AX,2                       ; At least 2 params?
  1430.             JB       L16_Exit                   ; No, then exit
  1431.                 Mov      _XParams,AL                ; Save param count
  1432.                 Mov      AX,1                       ; Specify param #
  1433.                 Call     _GetCParam                 ; Get the parameter
  1434.             JC       L16_Exit                   ; If not character, then exit
  1435.                 Mov      _XAttrib,AL                ; Save the base attribute
  1436.                 Mov      AX,2                       ; Specify param #
  1437.                 Call     _GetCParam                 ; Get the parameter
  1438.             JC       L16_Exit                   ; If not character, then exit
  1439.                 Mov      _XSecond,AL                ; Save the background attribute
  1440.             Mov      DL,0                       ; Set default softblink .F.
  1441.                 Cmp      _XParams,3                 ; Is there 3 params?
  1442.             JB       L16_Next                   ; No, jump to next step
  1443.                 Mov      AX,3                       ; Specify param #
  1444.             Call     _GetLParam                 ; Get the param value
  1445.             JC       L16_Exit                   ; If not logical, exit
  1446.             Mov      DL,AL                      ; Transfer softblink flag
  1447. L16_Next:   Test     DL,0FFh                    ; Is softblink on?
  1448.             JZ       L16_Cont                   ; No, then jump
  1449.                 Mov      AL,_XSecond                ; Set RGB for background attrib
  1450.                 CLC                                 ;
  1451.             Call     _SetRGBDef                 ; Move _NewPals RGB into _RGBDef
  1452.             Mov      SI,Offset DS:_RGBDef       ; Get the offset
  1453.                 Mov      AL,_XAttrib                ; Set AL to base attribute
  1454.             Mov      CX,0702h                   ; Set starting/ending palette
  1455.             Call     _ScaleAttr                 ; Set the palette
  1456. L16_Cont:   Mov      AL,_XSecond                ; Get background attrib to AL
  1457.                 Mov      CL,4                       ; Multiply by 16 to make it
  1458.                 SHL      AL,CL                      ;    in bits 4-7
  1459.                 Add      AL,_XAttrib                ; Add the attribute (bits 0-3)
  1460.                 Call     _Blinker                   ; Set the palette
  1461.                 Call     _LoadPal                   ; Load the palette
  1462. L16_Exit:   Call     __Ret                      ; Clipper NIL return
  1463.             Pop      DI                         ; Restore registers
  1464.                 Pop      SI                         ;
  1465.                 Pop      DS                         ;
  1466.                 Pop      BP                         ;
  1467.                 CLD                                 ;
  1468.                 Ret                                 ;
  1469.                 
  1470. FX_BLINK    Endp
  1471.  
  1472. ;░
  1473. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1474.  
  1475.  
  1476. ;░░░░ fx_Pulse ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1477. ;░
  1478. ;░ Produces a pulsing effect.  The attribute pulses from base attribute to
  1479. ;░ RGB values 75% higher for the attribute and back again from palette ranges
  1480. ;░ 4 to 15.
  1481. ;░
  1482. ;░ Clipper Usage:   fx_Pulse( cBaseAttribute )
  1483. ;░
  1484. ;░ Where cBaseAttribute is the base attribute to pulse.
  1485. ;░
  1486. ;░ Returns NIL value.
  1487. ;░
  1488.  
  1489. FX_PULSE    Proc     Far
  1490.                 
  1491.                 Push     BP                         ; Save registers for Clipper
  1492.                 Mov      BP,SP                      ;
  1493.                 Push     DS                         ;
  1494.                 Push     SI                         ;
  1495.                 Push     DI                         ;
  1496.             Test     _FxEnabled,0FFh            ; Is the system enabled?
  1497.                 JZ       L17_Exit                   ; No, then exit
  1498.                 Call     _ParamCnt                  ; Get number of parameters
  1499.                 Or       AX,AX                      ;
  1500.             JZ       L17_Exit                   ; If zero params, then exit
  1501.                 Mov      AX,1                       ; Specify param #
  1502.                 Call     _GetCParam                 ; Get the parameter
  1503.                 JC       L17_Exit                   ; If not character, then exit
  1504.                 Mov      _XAttrib,AL                ; Save the base attribute
  1505.             CLC                                 ;
  1506.             Call     _SetRGBDef                 ; _RGBDef = attrib RGB values
  1507.             Mov      DI,0                       ; Set offset counter
  1508. L17_Loop:   Mov      AL,_RGBDef[DI]             ; Get a RGB value
  1509.             Mov      BL,AL                      ; Store it for addition
  1510.             SHR      AL,1                       ; Divide by 2
  1511.             Add      BL,AL                      ; Add back to original
  1512.             SHR      AL,1                       ; Divide by 2 again
  1513.             Add      BL,AL                      ; Add back again - now +75%
  1514.             Cmp      BL,63                      ; Is it > 63?
  1515.             JBE      L17_Store                  ; No, jump
  1516.             Mov      BL,63                      ; Set maximum 63
  1517. L17_Store:  Mov      _RGBDef[DI],BL             ; Set new ending value
  1518.             Inc      DI                         ; Set for next RGB
  1519.             Cmp      DI,3                       ; Is it = 3?
  1520.             JB       L17_Loop                   ; No, get next
  1521.             Mov      AL,_XAttrib                ; Retrieve attribute
  1522.             Mov      CX,0F04h                   ; Set palette range (4-15)
  1523.             Mov      SI,Offset DS:_RGBDef       ; Point to ending values
  1524.             Call     _ScaleAttr                 ; Now scale the palettes
  1525.             Call     _LoadPal                   ; Load the palette
  1526. L17_Exit:   Call     __Ret                      ; Clipper NIL return
  1527.             Pop      DI                         ; Restore registers
  1528.                 Pop      SI                         ;
  1529.                 Pop      DS                         ;
  1530.                 Pop      BP                         ;
  1531.                 CLD                                 ;
  1532.                 Ret                                 ;
  1533.                 
  1534. FX_PULSE    Endp
  1535.  
  1536. ;░
  1537. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1538.  
  1539.  
  1540. ;░░░░ _ColorAttr ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1541. ;░
  1542. ;░ This function sets the color definitions for attribute AL in palettes
  1543. ;░ CL to CH to the RGB definition at DS:SI.  DX must contain the length of
  1544. ;░ the RBG definition string (either 3 or 48 bytes).
  1545. ;░
  1546.  
  1547. _COLORATTR  Proc     Near
  1548.                 
  1549.                 Push     BX                         ; Save registers
  1550.                 Push     CX                         ;
  1551.                 Push     SI                         ;
  1552.                 Push     DI                         ;
  1553.             Push     ES                         ;
  1554.             Mov      BX,DGROUP                  ; Set ES=DGROUP
  1555.             Mov      ES,BX                      ;
  1556.                 
  1557.                 ; Address the base definition (palette CL) for this attribute.
  1558.                 
  1559.                 Call     _GetDACPtr                 ;
  1560.             Mov      DI,BX                      ; ES:DI -> first definition
  1561.                 Inc      CH                         ;
  1562.                 Sub      CH,CL                      ; CH = # of palettes affected
  1563.                 Mov      CL,CH                      ;
  1564.                 Xor      CH,CH                      ; Now CX
  1565.                 
  1566.                 ; Loop through the required number of palettes.  Copy definitions
  1567.             ; from SI to palette N.
  1568.                 
  1569. L18_Loop:   Cmp      DX,3                       ; Is 3-byte mode?
  1570.             JNE      L18_Cont1                  ; No, then jump
  1571.                 Push     SI                         ; Save SI for 3-byte mode
  1572. L18_Cont1:  Lodsb                               ; Load Red value for RGB
  1573.                 Cmp      AL,63                      ; Is color value <= 63
  1574.             JA       L18_Empty1                 ; No, then don't store
  1575.                 Stosb                               ;
  1576.             Jmp      Short L18_Byte2            ; Continue to next byte
  1577. L18_Empty1: Inc      DI                         ; Adjust pointer
  1578. L18_Byte2:  Lodsb                               ; Load Green value for RGB
  1579.                 Cmp      AL,63                      ; Is color value <= 63
  1580.             JA       L18_Empty2                 ; No, then don't store
  1581.                 Stosb                               ;
  1582.             Jmp      Short L18_Byte3            ; Continue to next byte
  1583. L18_Empty2: Inc      DI                         ; Adjust pointer
  1584. L18_Byte3:  Lodsb                               ; Load Blue value for RGB
  1585.                 Cmp      AL,63                      ; Is color value <= 63
  1586.             JA       L18_Empty3                 ; No, then don't store
  1587.                 Stosb                               ;
  1588.             Jmp      Short L18_Next             ; Continue
  1589. L18_Empty3: Inc      DI                         ; Adjust pointer
  1590. L18_Next:   Cmp      DX,3                       ; Is it 3-byte mode?
  1591.             JNE      L18_Cont2                  ; No, then jump
  1592.                 Pop      SI                         ; Restore SI for 3-byte mode
  1593. L18_Cont2:  Add      DI,16*3-3                  ; DI -> color def in pal n+1
  1594.             Loop     L18_Loop                   ;
  1595.             Pop      ES                         ; Restore registers
  1596.             Pop      DI                         ;
  1597.                 Pop      SI                         ;
  1598.                 Pop      CX                         ;
  1599.                 Pop      BX                         ;
  1600.                 Ret                                 ;
  1601.                 
  1602. _COLORATTR  Endp
  1603.  
  1604. ;░
  1605. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1606.  
  1607.  
  1608. ;░░░░ _ScaleAttr ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1609. ;░
  1610. ;░ This function creates a scaled set of colors for attribute AL.  CL contains
  1611. ;░ a starting palette (0-14) and CH contains an ending palette (1-15, CH>CL).
  1612. ;░
  1613. ;░ DS:SI points to the "terminal" color definition, which will be the
  1614. ;░ definition in palette CH.  On exit, palettes CL-CH will contain "scaled"
  1615. ;░ color definitions for the attribute, so that the displayed color will change
  1616. ;░ slowly from the base color (in palette CL) to the terminal color (in palette
  1617. ;░ CH).  The color definition at DS:SI is three bytes long (one byte each for
  1618. ;░ R, G, B intensity).  RGB values are modulated into the range 0-63.  The new
  1619. ;░ palette is not sent to the VGA.  _LoadPal performs that function.
  1620. ;░
  1621.  
  1622. _SCALEATTR  Proc     Near
  1623.                 
  1624.                 Push     BX                         ; Save registers
  1625.                 Push     CX                         ;
  1626.                 Push     SI                         ;
  1627.                 Push     DI                         ;
  1628.             Push     ES                         ;
  1629.             Mov      BX,DS                      ; Set ES=DS
  1630.             Mov      ES,BX                      ;
  1631.                 
  1632.                 ; Address the base definition (palette CL) for this color.
  1633.                 
  1634.                 Call     _GetDACPtr                 ;
  1635.             Push     BX                         ; Save initial address
  1636.             Sub      CH,CL                      ; CH = # of palettes scales
  1637.                 Mov      CL,CH                      ;
  1638.                 Xor      CH,CH                      ; Now CX
  1639.             Mov      DI,Offset DS:_RedScale     ;
  1640.                 Call     _CalcScale                 ; Calc red scaling factors
  1641.                 Call     _CalcScale                 ;  "   grn   "       "
  1642.                 Call     _CalcScale                 ;  "   blue  "       "
  1643.             Pop      SI                         ; Retrieve initial address
  1644.                 
  1645.                 ; Loop through the required number of palettes.
  1646.                 
  1647. L19_Loop:   Mov      DI,SI                      ; SI/DI -> color def in pal N
  1648.             Add      DI,16*3                    ; DI -> color def in pal N+1
  1649.                 
  1650.                 ; Augment RGB values for this video DAC color register
  1651.                 
  1652.             Mov      BX,Offset DS:_RedScale     ; Point to red scale factors
  1653.                 Call     _Increment                 ; Scale red
  1654.                 Call     _Increment                 ; Scale green
  1655.                 Call     _Increment                 ; Scale blue
  1656.                 Add      SI,16*3-3                  ; Next palette
  1657.             Loop     L19_Loop                   ;
  1658.             Pop      ES                         ; Restore registers
  1659.             Pop      DI                         ;
  1660.                 Pop      SI                         ;
  1661.                 Pop      CX                         ;
  1662.                 Pop      BX                         ;
  1663.                 Ret                                 ;
  1664.                 
  1665. _SCALEATTR  Endp
  1666.  
  1667. ;░
  1668. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1669.  
  1670.  
  1671. ;░░░░ _Blinker ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1672. ;░
  1673. ;░ This function creates a simulated "blinking" color for attribute AL.  Unlike
  1674. ;░ most of the other functions, this one works with a full 8-bit attribute
  1675. ;░ (bits 0-3=FG, 4-7=BG, as usual).  "Blinking" is accomplished by putting the
  1676. ;░ background color definition into palettes 8-15 for the selected foreground
  1677. ;░ attribute.
  1678. ;░
  1679. ;░ Note that palettes 0-7 are not altered, so you can do whatever you want with
  1680. ;░ the "visible" half of the blink text (like scaling it).
  1681. ;░
  1682.  
  1683. _BLINKER    Proc     Near
  1684.                 
  1685.                 Push     BX                         ; Save registers
  1686.                 Push     CX                         ;
  1687.             Push     DX                         ;
  1688.                 
  1689.                 ; Get a pointer to the color definition for the BG attribute.
  1690.                 
  1691.                 Push     AX                         ;
  1692.                 Mov      CL,4                       ; Mov high nibble (BG) to low
  1693.                 SHR      AL,CL                      ;
  1694.                 Xor      CL,CL                      ; Get ptr to def in palette 0
  1695.                 Call     _GetDACPtr                 ;
  1696.                 Mov      SI,BX                      ; SI->BG def, palette 0
  1697.                 Pop      AX                         ;
  1698.                 
  1699.             ; Now do a _ColorAttr for the FG attribute in palettes 8-15,
  1700.                 ; using the color definition at DS:SI (which is the BG color).
  1701.                 
  1702.                 And      AL,0Fh                     ; Mask the BG attribute number
  1703.                 Mov      CX,0F08h                   ; Palettes 8-15
  1704.             Mov      DX,3                       ; Set for 3-byte string
  1705.             Call     _ColorAttr                 ;
  1706.             Pop      DX                         ; Restore registers
  1707.             Pop      CX                         ;
  1708.                 Pop      BX                         ;
  1709.                 Ret                                 ;
  1710.                 
  1711. _BLINKER    Endp
  1712.  
  1713. ;░
  1714. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1715.  
  1716.  
  1717. ;░░░░ _LoadPal ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1718. ;░
  1719. ;░ Load the set of palettes in _NewPals into the VGA.  Sets ES:SI = _NewPals.
  1720. ;░
  1721.  
  1722. _LOADPAL    Proc     Near
  1723.                 
  1724.             Push     ES                         ; Save registers
  1725.             Push     SI                         ;
  1726.             Mov      BX,DS                      ; Set ES=DS
  1727.             Mov      ES,BX                      ;
  1728.             Mov      SI,Offset DS:_NewPals      ;
  1729.             Call     _SetVideo                  ; Load palettes to VGA
  1730.             Pop      SI                         ; Restore registers
  1731.             Pop      ES                         ;
  1732.                 Ret                                 ;
  1733.                 
  1734. _LOADPAL    Endp
  1735.  
  1736. ;░
  1737. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1738.  
  1739.  
  1740. ;░░░░ _DuplPal0 ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1741. ;░
  1742. ;░ This function creates 16 "standard" palettes in _NewPals.
  1743. ;░
  1744.  
  1745. _DUPLPAL0   Proc     Near
  1746.                 
  1747.                 ; Copy the base palette into palette 0 of _NewPals.  Each color
  1748.                 ; register contains 3 colors (R, G, and B), so the full palette
  1749.                 ; is 16*3 bytes long.
  1750.                 
  1751.             Push     ES                         ; Save ES register
  1752.             Mov      BX,DS                      ; Set ES=DS
  1753.             Mov      ES,BX                      ;
  1754.             Mov      SI,Offset DS:_NewBase      ;
  1755.             Mov      DI,Offset DS:_NewPals      ;
  1756.             Mov      CX,16*3/2                  ; 16 colors, 3 RGB values each
  1757.                 CLD                                 ;
  1758.                 Rep      Movsw                      ;
  1759.                 
  1760.             ; Now duplicate palette 0 (colors 0-15) to pals 1-15 (colors 16-255)
  1761.                 ; We simplify this by allowing the copies to overlap.
  1762.                 
  1763.             Mov      SI,Offset DS:_NewPals      ; SI -> palette 0
  1764.             Mov      DI,Offset DS:_NewPals+16*3 ; DI -> palette 1
  1765.                 Mov      CX,15*16*3/2               ; 15 pals, 16 colors, 3 bytes
  1766.                 Rep      Movsw                      ;
  1767.             Pop      ES                         ; Restore ES register
  1768.                 Ret                                 ;
  1769.                 
  1770. _DUPLPAL0   Endp
  1771.  
  1772. ;░
  1773. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1774.  
  1775.  
  1776. ;░░░░ _CalcScale ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1777. ;░
  1778. ;░ This function generates the parameters for scaling a color from an initial
  1779. ;░ value to a terminal value.  On entry, DS:BX points to an initial color value
  1780. ;░ (0-63), DS:SI points to a terminal color value (0-63), and ES:DI points to a
  1781. ;░ 3-byte interpolation factor storage area.  The function calculates the
  1782. ;░ numbers needed to scale the color from the initial definition to the terminal
  1783. ;░ definition over a span of CL palettes (normally 15).
  1784. ;░
  1785. ;░ The 3-byte factor storage area is filled as follows:
  1786. ;░    - byte signed integer:    increment/palette
  1787. ;░    - byte unsigned integer:  number of extra increments required
  1788. ;░    - byte signed integer:    excess increment value (1 or -1)
  1789. ;░
  1790. ;░ To scale a palette, start with palette 0 and add the increment/palette to
  1791. ;░ each succeeding palette.  Also add the excess increment value (1 or -1) to
  1792. ;░ the first N palettes (1-N), where N is the number of extra increments.  For
  1793. ;░ example, if the initial color value is 21 and the terminal is 63, the factor
  1794. ;░ storage area would contain 2,12,1.  To scale from 21 to 63, start with the
  1795. ;░ value in palette 0 and add 3 per palette (2+1) from 1-12 and two per palette
  1796. ;░ from 13-15:
  1797. ;░       0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15
  1798. ;░       21 24 27 30 33 36 39 42 45 48 51 54 57 59 61 63
  1799. ;░ (Everything in the above assumes a 15-palette scale).
  1800. ;░
  1801. ;░ On exit, BX and SI have been incremented by one, and DI by 3.  This
  1802. ;░ conveniently points to the next color values and factor storage area.
  1803. ;░
  1804.  
  1805. _CALCSCALE  Proc     Near
  1806.                 
  1807.             And      CL,0Fh                     ; Make sure CL <= 15
  1808.             Or       CL,CL                      ;
  1809.             JNZ      L23_Cont                   ;
  1810.             Mov      CL, 0Fh                    ;
  1811.  
  1812.             ; Get the initial color to AH and terminal color to AL.
  1813.  
  1814. L23_Cont:   Mov      AL,[BX]                    ; Initial color value
  1815.                 Inc      BX                         ;
  1816.                 Mov      AH,AL                      ;
  1817.                 Lodsb                               ; Terminal color value
  1818.                 And      AL,3Fh                     ; Force 0-63
  1819.                 
  1820.                 ; Compute increment/palette and number of excess increments needed.
  1821.                 
  1822.                 Sub      AL,AH                      ; AL = difference (term-init)
  1823.                 CBW                                 ;
  1824.                 IDiv     CL                         ; AL = inc/pal, AL = excess
  1825.                 Mov      [DI._ScaleIncr],AL         ; Store increment/palette
  1826.                 
  1827.                 ; Decide whether the excess increment value is +1 or -1.  It will
  1828.                 ; be -1 if the "excess" calculated above is negative; the excess
  1829.                 ; count will also have to be made positive, if so.
  1830.                 
  1831.                 Mov      AL,1                       ; Assume positive
  1832.                 Or       AH,AH                      ; Is it negative?
  1833.             JNS      L23_Save                   ; No, continue
  1834.                 Neg      AL                         ; Yes, make increment negative
  1835.                 Neg      AH                         ;    and count positive
  1836. L23_Save:   Mov      [DI._XS_Count],AH          ; Store the values
  1837.                 Mov      [DI._XS_Incr],AL           ;
  1838.                 Add      DI,Type _ScaleFact         ; Next storage area
  1839.                 Ret                                 ;
  1840.                 
  1841. _CALCSCALE  Endp
  1842.  
  1843. ;░
  1844. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1845.  
  1846.  
  1847. ;░░░░ _Increment ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1848. ;░
  1849. ;░ This subfunction increments a color value from palette N to palette N+1
  1850. ;░ using the scale factors at DS:BX (see _CalcScale procedure).
  1851. ;░
  1852. ;░ At entry:  DS:BX->scale factors, DS:SI->palette N color value,
  1853. ;░ ES:DI -> palette N+1 color value.  On exit, SI has been incremented (to
  1854. ;░ point to the next color value), and BX is increased by 3 (to point to the
  1855. ;░ next scale factor storage area).  The _XS_Incr field of the scale factor
  1856. ;░ record is decremented if not already zero.
  1857. ;░
  1858.  
  1859. _INCREMENT  Proc     Near
  1860.                 
  1861.                 Lodsb                               ; Get original R/G/B value
  1862.                 Add      AL,[BX._ScaleIncr]         ; Add per-palette increment
  1863.                 Test     [BX._XS_Count],-1          ; Any excess increments left?
  1864.             JZ       L24_NoRem                  ; No
  1865.                 Dec      [BX._XS_Count]             ; Yes, dec remain excess count
  1866.                 Add      AL,[BX._XS_Incr]           ; Add the excess incrmt (1/-1)
  1867. L24_NoRem:  Stosb                               ; Store the scaled value
  1868.                 Add      BX,Type _ScaleFact         ;
  1869.                 Ret                                 ;
  1870.                 
  1871. _INCREMENT  Endp
  1872.  
  1873. ;░
  1874. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1875.  
  1876.  
  1877. ;░░░░ _SetVideo ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1878. ;░
  1879. ;░ This function sets the 256 video DAC color registers from the table
  1880. ;░ at ES:SI, i.e., it loads the 256 colors definitions into the VGA.
  1881. ;░
  1882.  
  1883. _SETVIDEO   Proc     Near
  1884.                 
  1885.                 Push     AX                         ; Save registers
  1886.                 Push     BX                         ;
  1887.                 Push     CX                         ;
  1888.             Push     DX                         ;
  1889.             Push     DS                         ;
  1890.             Xor      AX,AX                      ; Get port address of CRT
  1891.             Mov      DS,AX                      ;    status register
  1892.                 Mov      DX,DS:[463h]               ; DX = 3x8 register
  1893.             Mov      AX,ES                      ; Set segment of data
  1894.             Mov      DS,AX                      ;    to DS
  1895.             Add      DX,6                       ; DX = 3xA, CRT status reg
  1896.             Mov      AH,5                       ; Set retrace loop to 5
  1897.             Xor      CX,CX                      ; Clear CX
  1898. L25_Wait:   In       AL,DX                      ; Wait for a retrace
  1899.             Test     AL,8                       ;
  1900.             JNZ      L25_Change                 ;
  1901.             Loop     L25_Wait                   ;
  1902.             Dec      AH                         ;
  1903.             JNZ      L25_Wait                   ;
  1904. L25_Change: Xor      CX,CX                      ; Set CX = 0
  1905.             CLI                                 ; Set interrupts off
  1906.             Mov      DX,3C8h                    ; DAC address register 3C8h
  1907. L25_Loop:   Mov      AL,CL                      ; Get next DAC register
  1908.             Out      DX,AL                      ; Select DAC register
  1909.             Inc      DX                         ; DAC data register 3C9h
  1910.             Lodsb                               ;
  1911.             Out      DX,AL                      ; Send RED value
  1912.             Lodsb                               ;
  1913.             Out      DX,AL                      ; Send GREEN value
  1914.             Lodsb                               ;
  1915.             Out      DX,AL                      ; Send BLUE value
  1916.             Dec      DX                         ; Back to DAC address register
  1917.             Inc      CX                         ;
  1918.             Cmp      CX,100h                    ; Have we did 256 regs?
  1919.             JNE      L25_Loop                   ; No, then do next
  1920.             STI                                 ; Set interrupts back on
  1921.             Pop      DS                         ; Restore registers
  1922.             Pop      DX                         ;
  1923.             Pop      CX                         ;
  1924.                 Pop      BX                         ;
  1925.                 Pop      AX                         ;
  1926.                 Ret                                 ;
  1927.                 
  1928. _SETVIDEO   Endp
  1929.  
  1930. ;░
  1931. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1932.  
  1933.  
  1934. ;░░░░ _GetDACPtr ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1935. ;░
  1936. ;░ Returns a pointer in BX to the color definition for attribute AL in palette
  1937. ;░ CL of _NewPals.
  1938. ;░
  1939.  
  1940. _GETDACPTR  Proc     Near
  1941.                 
  1942.             Push     AX                         ; Save registers
  1943.             Push     DS                         ;
  1944.             Mov      BX,DGROUP                  ; Set DS=DGROUP
  1945.             Mov      DS,BX                      ;
  1946.                 And      AX,0Fh                     ; Ensure range 0-15
  1947.                 Mov      BX,AX                      ;
  1948.             Mov      AL,_NewRegs[BX]            ; Get palreg for this attrib
  1949.                 Mov      BX,AX                      ; Triple it for offset into
  1950.                 SHL      BX,1                       ;    color table
  1951.                 Add      BX,AX                      ; BX = 3 * color #
  1952.                 Mov      AL,16*3                    ; Bytes/palette
  1953.                 Mul      CL                         ; AX -> offset of palette CL
  1954.                 Add      BX,AX                      ; BX -> offset in _NewPals
  1955.             Add      BX,Offset DS:_NewPals      ; BX -> base color definition
  1956.             Pop      DS                         ; Restore registers
  1957.                 Pop      AX                         ;
  1958.                 Ret                                 ;
  1959.                 
  1960. _GETDACPTR  Endp
  1961.  
  1962. ;░
  1963. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1964.  
  1965.  
  1966. ;░░░░ _GetPalPtr ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1967. ;░
  1968. ;░ Returns a pointer in BX to the start of palette CL of _NewPals.
  1969. ;░
  1970.  
  1971. _GETPALPTR  Proc     Near
  1972.                 
  1973.             Push     DS                         ; Save registers
  1974.             Push     AX                         ;
  1975.             Mov      BX,DGROUP                  ; Set DS=DGROUP
  1976.             Mov      DS,BX                      ;
  1977.             Mov      BX,Offset DS:_NewPals      ; Get offset of _NewPals
  1978.             Mov      AX,30h                     ; 48 Bytes/palette
  1979.             Mul      CL                         ; AX = offset into palette CL
  1980.             Add      BX,AX                      ; BX = start of palette CL
  1981.             Pop      AX                         ; Restore registers
  1982.             Pop      DS                         ;
  1983.                 Ret                                 ;
  1984.                 
  1985. _GETPALPTR  Endp
  1986.  
  1987. ;░
  1988. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1989.  
  1990.  
  1991. ;░░░░ _SetRGBDef ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1992. ;░
  1993. ;░ Moves an attribute's RGB original base values into _RGBDef variable. On
  1994. ;░ entry, AL must be set to attribute.  The carry flag determines the source.
  1995. ;░ If the carry flag is clear, _NewPals/palette 0 is used as the source, else
  1996. ;░ _NewBase is used as the source.
  1997. ;░
  1998.  
  1999. _SETRGBDEF  Proc     Near
  2000.                 
  2001.                 Push     SI                         ; Save registers
  2002.                 Push     DI                         ;
  2003.                 Push     BX                         ;
  2004.                 Push     CX                         ;
  2005.             Push     ES                         ;
  2006.             JNC      L28_Cont1                  ; Carry clear, use _NewPals
  2007.                 Xor      AH,AH                      ; Use _NewBase as source
  2008.                 Mov      BX,AX                      ; AL=attribute
  2009.                 SHL      BX,1                       ; Triple it
  2010.                 Add      BX,AX                      ; BX = offset into _NewBase
  2011.             Add      BX,Offset DS:_NewBase      ;
  2012.             Jmp      Short L28_Cont2            ; Continue
  2013. L28_Cont1:  Mov      CL,0                       ; Set for first palette
  2014.             Test     _FixedMode,0FFh            ; Is fixed palette in effect?
  2015.             JZ       L28_GetPtr                 ; No, then jump
  2016.             Mov      CL,_FixedPal               ; Set for fixed palette
  2017. L28_GetPtr: Call     _GetDACPtr                 ; Use _NewPals as source
  2018. L28_Cont2:  Mov      SI,BX                      ; Point to source
  2019.             Mov      DI,Offset DS:_RGBDef       ; Point to _RGBDef as dest.
  2020.             Mov      BX,DS                      ; Set ES=DS
  2021.             Mov      ES,BX                      ;
  2022.             Lodsb                               ; Load byte from source
  2023.             Stosb                               ; Store byte in _RGBDef
  2024.                 Lodsw                               ; Load word from source
  2025.             Stosw                               ; Store word in _RGBDef
  2026.             Pop      ES                         ; Restore registers
  2027.             Pop      CX                         ;
  2028.                 Pop      BX                         ;
  2029.                 Pop      DI                         ;
  2030.                 Pop      SI                         ;
  2031.                 Ret                                 ;
  2032.                 
  2033. _SETRGBDEF  Endp
  2034.  
  2035. ;░
  2036. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2037.  
  2038.  
  2039. ;░░░░ _ParamCnt ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2040. ;░
  2041. ;░ Test for number of parameters sent to a Clipper function.
  2042. ;░
  2043. ;░ Returns AX = Number of parameters.
  2044. ;░
  2045.  
  2046. _PARAMCNT   Proc     Near
  2047.                 
  2048.                 Mov      AX,0                       ; Specify param count request
  2049.                 Push     AX                         ; Put on stack
  2050.                 Call     __ParInfo                  ; Retrieve value
  2051.                 Add      SP,2                       ; Restore stack
  2052.                 Ret                                 ; AX=number of parameters
  2053.                 
  2054. _PARAMCNT   Endp
  2055.  
  2056. ;░
  2057. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2058.  
  2059.  
  2060. ;░░░░ _GetNParam ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2061. ;░
  2062. ;░ Checks/gets a Clipper numeric parameter.  AX must contain the parameter
  2063. ;░ number when called.  Sets the carry flag if not a numeric parameter.
  2064. ;░
  2065. ;░ Returns AX = integer parameter.
  2066. ;░
  2067.  
  2068. _GETNPARAM  Proc     Near
  2069.                 
  2070.             Push     AX                         ; Save param number
  2071.                 Push     AX                         ; Put param number on stack
  2072.                 Call     __ParInfo                  ; Retrieve param type
  2073.                 Add      SP,2                       ; Restore stack
  2074.             Pop      BX                         ; Retrieve param number
  2075.             Cmp      AX,2                       ; Is param numeric?
  2076.             JNE      L30_NoNum                  ; No, jump
  2077.                 Mov      AX,BX                      ; Specify param #
  2078.                 Push     AX                         ; Put on stack
  2079.                 Call     __ParNI                    ; Retrieve value
  2080.                 Add      SP,2                       ; Restore stack
  2081.                 CLC                                 ; Clear the carry flag
  2082.             Jmp      Short L30_Exit             ;
  2083. L30_NoNum:  STC                                 ; Set the carry flag
  2084. L30_Exit:   Ret                                 ;
  2085.                 
  2086. _GETNPARAM  Endp
  2087.  
  2088. ;░
  2089. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2090.  
  2091.  
  2092. ;░░░░ _GetLParam ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2093. ;░
  2094. ;░ Checks/gets a Clipper logical parameter.  AX must contain the parameter
  2095. ;░ number when called.  Sets the carry flag if not a logical parameter.
  2096. ;░
  2097. ;░ Returns AX = logical parameter.
  2098. ;░
  2099.  
  2100. _GETLPARAM  Proc     Near
  2101.                 
  2102.             Push     AX                         ; Save param number
  2103.                 Push     AX                         ; Put param number on stack
  2104.                 Call     __ParInfo                  ; Retrieve param type
  2105.                 Add      SP,2                       ; Restore stack
  2106.             Pop      BX                         ; Retrieve param number
  2107.             Cmp      AX,4                       ; Is param logical?
  2108.             JNE      L31_NoLog                  ; No, jump
  2109.                 Mov      AX,BX                      ; Specify param #
  2110.                 Push     AX                         ; Put on stack
  2111.             Call     __ParL                     ; Retrieve value
  2112.                 Add      SP,2                       ; Restore stack
  2113.                 CLC                                 ; Clear the carry flag
  2114.             Jmp      Short L31_Exit             ;
  2115. L31_NoLog:  STC                                 ; Set the carry flag
  2116. L31_Exit:   Ret                                 ;
  2117.                 
  2118. _GETLPARAM  Endp
  2119.  
  2120. ;░
  2121. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2122.  
  2123.  
  2124. ;░░░░ _GetCParam ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2125. ;░
  2126. ;░ Checks/gets a Clipper character color parameter.  AX must contain the
  2127. ;░ parameter number when called.  Sets the carry flag if the parameter passed
  2128. ;░ is not a character string.
  2129. ;░
  2130. ;░ Returns AL = integer color parameter (0-15).
  2131. ;░
  2132.  
  2133. _GETCPARAM  Proc     Near
  2134.                 
  2135.             Push     AX                         ; Save param number
  2136.                 Push     AX                         ; Put param number on stack
  2137.                 Call     __ParInfo                  ; Retrieve param type
  2138.                 Add      SP,2                       ; Restore stack
  2139.             Pop      BX                         ; Retrieve param nummber
  2140.             Cmp      AX,1                       ; Is param character?
  2141.             JNE      L32_NoChar                 ; No, quit
  2142.                 Mov      AX,BX                      ; Specify param #
  2143.                 Push     AX                         ; Put on stack
  2144.                 Call     __ParC                     ; Retrieve value
  2145.                 Add      SP,2                       ; DX:AX point to color string
  2146.                 Call     _CvtColor                  ; Convert string to a number
  2147.             Jmp      Short L32_Exit             ;
  2148. L32_NoChar: STC                                 ; Set the carry flag
  2149. L32_Exit:   Ret                                 ; Color number is in AL
  2150.                 
  2151. _GETCPARAM  Endp
  2152.  
  2153. ;░
  2154. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2155.  
  2156.  
  2157. ;░░░░ _CvtColor ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2158. ;░
  2159. ;░ Converts from a Clipper character color value to a numeric color value.
  2160. ;░ DX:AX must point to the character value string on entry.
  2161. ;░
  2162. ;░ Returns color number (0-15) in AL.  Sets the carry flag if invalid color
  2163. ;░ string.
  2164. ;░
  2165.  
  2166.  
  2167. _CVTCOLOR   Proc     Near
  2168.                 
  2169.             Push     DS                         ; Save registers
  2170.                 Push     SI                         ;
  2171.             Mov      DS,DX                      ; Set DS:SI to color string
  2172.                 Mov      SI,AX                      ;
  2173.             Mov      BX,0FFFFh                  ; Set BX (BH/BL) for empty test
  2174.                 Xor      CX,CX                      ; Clear CX (CH/CL)
  2175.             CLD                                 ;
  2176.                 
  2177.                 ; CL serves as storage for high intensity value in color string.
  2178.                 ; BH serves as storage for first character value in color string.
  2179.                 ; BL serves as storage for second character value in color string.
  2180.                 ; AH is temporary storage of color value.
  2181.                 ; AL contains the byte read.
  2182.                 
  2183. L33_GetChr: Xor      AH,AH                      ; Clear AH
  2184.             Lodsb                               ; Get a character in AL
  2185.                 Cmp      AL,'+'                     ; Is high intensity character?
  2186.             JNE      L33_CheckN                 ; No, jump
  2187.                 Mov      CL,8                       ; Yes, store value for '+'
  2188.             Jmp      Short L33_GetChr           ; Get next byte
  2189. L33_CheckN: And      AL,0DFh                    ; Convert to upper case
  2190.             Cmp      AL,'N'                     ; Is 'N' character in string?
  2191.             JNE      L33_CheckB                 ; No, jump
  2192.                 Mov      AH,0                       ; Yes, store value for 'N'
  2193.             Jmp      Short L33_Store1           ;
  2194. L33_CheckB: Cmp      AL,'B'                     ; Is 'B' character in string?
  2195.             JNE      L33_CheckG                 ; No, jump
  2196.                 Mov      AH,1                       ; Yes, store value for 'B'
  2197.             Jmp      Short L33_Store1           ;
  2198. L33_CheckG: Cmp      AL,'G'                     ; Is 'G' character in string?
  2199.             JNE      L33_CheckR                 ; No, jump
  2200.                 Mov      AH,2                       ; Yes, store value for 'G'
  2201.             Jmp      Short L33_Store1           ;
  2202. L33_CheckR: Cmp      AL,'R'                     ; Is 'R' character in string?
  2203.             JNE      L33_CheckW                 ; No, jump
  2204.                 Mov      AH,4                       ; Yes, store value for 'R'
  2205.             Jmp      Short L33_Store1           ;
  2206. L33_CheckW: Cmp      AL,'W'                     ; Is 'W' character in string?
  2207.             JNE      L33_Null                   ; No, jump
  2208.                 Mov      AH,7                       ; Yes, store value for 'W'
  2209.             Jmp      Short L33_Store1           ;
  2210. L33_Null:   Test     AL,0FFh                    ; Is it a null character?
  2211.             JZ       L33_Calc                   ; Yes, then jump
  2212.             Jmp      Short L33_Error            ; No, then invalid
  2213. L33_Store1: Cmp      BH,0FFh                    ; Is BH empty?
  2214.             JNE      L33_Store2                 ; No, then check BL
  2215.                 Mov      BH,AH                      ; Yes, save first color value
  2216.             Jmp      Short L33_GetChr           ; Get next byte
  2217. L33_Store2: Cmp      BL,0FFh                    ; Is BL empty?
  2218.             JNE      L33_Calc                   ; No, so we must be ready
  2219.                 Mov      BL,AH                      ; Save second color value
  2220.             Jmp      Short L33_GetChr           ; Get next byte
  2221. L33_Calc:   Cmp      BH,0FFh                    ; Is first character empty?
  2222.             JE       L33_Error                  ; Yes, nothing passed so error
  2223.                 Mov      AL,BH                      ; No, then store first value
  2224.                 Cmp      BL,0FFh                    ; Is second character empty?
  2225.             JE       L33_AddHi                  ; Yes, then do high intensity
  2226.                 Add      AL,BL                      ; No, add second value to first
  2227. L33_AddHi:  Add      AL,CL                      ; Add any high intensity value
  2228.                 And      AL,0Fh                     ; Make sure it's range 0-15
  2229.             CLC                                 ; Set for valid
  2230.             Jmp      Short L33_Exit             ;
  2231. L33_Error:  STC                                 ; Set for error
  2232. L33_Exit:   Pop      SI                         ; Restore registers
  2233.             Pop      DS                         ;
  2234.                 Ret                                 ; AL contains color value
  2235.                 
  2236. _CVTCOLOR   Endp
  2237.  
  2238. ;░
  2239. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2240.  
  2241.  
  2242. ;░░░░ _CheckVGA ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2243. ;░
  2244. ;░ Tests for a VGA installed.
  2245. ;░
  2246. ;░ Returns carry flag set if present, otherwise carry flag is clear.
  2247. ;░
  2248.  
  2249. _CHECKVGA   Proc     Near
  2250.                 
  2251.             Mov      AX,1A00h                   ; Test for VGA presence
  2252.                 Int      10h                        ; Get video display combination
  2253.                 Cmp      AL,1Ah                     ; Supported function?
  2254.             JNE      L34_NoVGA                  ; No, then no VGA BIOS
  2255.                 Cmp      BL,7                       ; VGA/mono?
  2256.             JE       L34_GotVGA                 ; Yes
  2257.                 Cmp      BL,8                       ; VGA/color?
  2258.             JE       L34_GotVGA                 ; Yes
  2259. L34_NoVGA:  CLC                                 ; Set false return flag
  2260.             Jmp      Short L34_Exit             ; Quit
  2261. L34_GotVGA: STC                                 ; Set true return flag
  2262. L34_Exit:   Ret                                 ;
  2263.                 
  2264. _CHECKVGA   Endp
  2265.  
  2266. ;░
  2267. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2268.  
  2269.  
  2270. ;░░░░ _HWBlink ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2271. ;░
  2272. ;░ Sets hardware blink on/off.  Hardware blink is set ON if carry flag is
  2273. ;░ set and set OFF if carry flag is clear.  When hardware blink is off, it
  2274. ;░ enables high intensity background colors.
  2275. ;░
  2276.  
  2277. _HWBLINK    Proc     Near
  2278.                 
  2279.             JC       L35_On                     ; If carry flag set, jump
  2280.             Xor      BL,BL                      ; Set hardware blink off
  2281.             Jmp      Short L35_Set              ;
  2282. L35_On:     Mov      BL,1                       ; Set hardware blink on
  2283. L35_Set:    Mov      AX,1003h                   ;
  2284.                 Int      10h                        ;
  2285.             Ret                                 ;
  2286.                 
  2287. _HWBLINK    Endp
  2288.  
  2289. ;░
  2290. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2291.  
  2292.  
  2293. ;░░░░ _PalFunc ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2294. ;░
  2295. ;░ Accesses the palette control video BIOS function (Int 10h).  AL contains the
  2296. ;░ command number.  Other appropriate registers should be set before calling.
  2297. ;░
  2298. ;░ Returns various information.
  2299. ;░
  2300.  
  2301. _PALFUNC    Proc     Near
  2302.  
  2303.             Mov      AH,10h                     ; Set for function 10h
  2304.             Int      10h                        ;
  2305.             Ret                                 ;
  2306.  
  2307. _PALFUNC    Endp
  2308.  
  2309. ;░
  2310. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2311.  
  2312.  
  2313. ;░░░░ _UnInstall ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2314. ;░
  2315. ;░ Uninstalls the color effects system.
  2316. ;░    - Deactivates the INT 21h intercept
  2317. ;░    - Deactivates the INT 1Ch intercept
  2318. ;░    - Restores the original VGA state
  2319. ;░
  2320.  
  2321. _UNINSTALL  Proc     Near
  2322.  
  2323.             Push     DS                         ; Save DS
  2324.             Mov      DX,CS:_Int1CLo             ; Restore INT 1Ch to its
  2325.             Mov      AX,CS:_Int1CHi             ;    original address
  2326.             Mov      DS,AX                      ;
  2327.             Mov      AX,251Ch                   ;
  2328.                 Int      21h                        ;
  2329.             Mov      DX,CS:_Int21Lo             ; Restore INT 21h to its
  2330.             Mov      AX,CS:_Int21Hi             ;    original address
  2331.             Mov      DS,AX                      ;
  2332.             Mov      AX,2521h                   ;
  2333.                 Int      21h                        ;
  2334.             Pop      DS                         ; Restore DS
  2335.  
  2336.             ; Restore original palette registers and video DAC color registers.
  2337.  
  2338.             Mov      BL,1                       ;
  2339.             Mov      BH,_OrigColor              ;
  2340.             Mov      AL,_SetState               ; Set color select register
  2341.             Call     _PalFunc                   ; Load original color
  2342.             Xor      BL,BL                      ; Restore original attribute
  2343.                 Mov      BH,_OrigMode               ;    control mode
  2344.             Mov      AL,_SetState               ;
  2345.             Call     _PalFunc                   ; Load original mode
  2346.             Mov      SI,Offset DS:_OrigPals     ; ES:SI = _OrigPals
  2347.             Call     _SetVideo                  ; Load original RGB values
  2348.             Mov      AX,DS                      ; Set ES=DS
  2349.             Mov      ES,AX                      ;
  2350.             Mov      DX,Offset DS:_OrigRegs     ;
  2351.             Mov      AL,_SetPalReg              ;
  2352.             Call     _PalFunc                   ; Load original pal registers
  2353.             STC                                 ; Set flag for ON
  2354.             Call     _HWBlink                   ; Set hardware blink ON
  2355.             Mov      _FxEnabled,0               ; Set flag for disabled
  2356.             Ret                                 ;
  2357.  
  2358. _UNINSTALL  Endp
  2359.  
  2360. ;░
  2361. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2362.  
  2363.  
  2364. ;░░░░ _Intrcpt1C ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2365. ;░
  2366. ;░ This is the INT 1C intercept.  On each timer tick, we decrement the countdown
  2367. ;░ (if we are enabled).  If the count goes to zero, we go to the next palette.
  2368. ;░ The next palette is determined by the current palette (in _CurPal) and the
  2369. ;░ _PalRate value.  _PalRate is added to the current value and range checked.
  2370. ;░ If the new palette is out of range, it's brought in range and the sign of
  2371. ;░ _PalRate is changed.  If a fixed palette mode is in effect, then no switching
  2372. ;░ of palettes occurs.
  2373. ;░
  2374.  
  2375. _INTRCPT1C  Proc     Far
  2376.  
  2377.             PushF                               ; Save registers
  2378.             Push     DS                         ;
  2379.             Push     AX                         ;
  2380.             Push     BX                         ;
  2381.             Push     CX                         ;
  2382.             Push     DX                         ;
  2383.             Mov      BX,DGROUP                  ; Set DS=DGROUP
  2384.             Mov      DS,BX                      ;
  2385.             Assume   DS:DGROUP                  ;
  2386.             CLD                                 ;
  2387.             Test     _FXEnabled,0FFh            ; Is the system enabled?
  2388.             JZ       L38_GoOrig                 ; No, skip
  2389.             Dec      _TickCount                 ; Is count zero?
  2390.             JNZ      L38_GoOrig                 ; No, skip
  2391.             Test     _FixedMode,0FFh            ; Is fixed palette mode?
  2392.             JZ       L38_Switch                 ; No
  2393.             Mov      BH,_FixedPal               ; Yes, then set fixed palette
  2394.             Jmp      Short L38_PalOK            ;
  2395.                 
  2396.                 ; _TickCount has zeroed, switch palettes by adding the _PalRate.
  2397.                 ; If the palette number goes out of range, reverse the sign of the
  2398.                 ; _PalRate and bring the palette number back into range.  _CurPal
  2399.                 ; has the current palette number.
  2400.                 
  2401. L38_Switch: Mov      BH,_CurPal                 ; Get current palette
  2402.             Add      BH,_PalRate                ; Add the _PalRate
  2403.             JS       L38_Revers                 ; Go if new palette not negative
  2404.                 Cmp      BH,15                      ; Chk for positive out-of-range
  2405.             JBE      L38_PalOk                  ; It's OK
  2406. L38_Revers: Neg      _PalRate                   ; Reverse the direction
  2407.             Add      BH,_PalRate                ; Do twice to cancel out the
  2408.             Add      BH,_PalRate                ;    earlier addition
  2409. L38_PalOk:  Mov      _CurPal,BH                 ; Save new palette number
  2410.  
  2411.             ; Use register-level programming of the attribute control reg (ACR).
  2412.                 
  2413.                 Xor      AX,AX                      ; Get port address of CRT
  2414.                 Push     DS                         ;    status register
  2415.                 Mov      DS,AX                      ;
  2416.                 Mov      DX,DS:[463h]               ; DX = 3x8 register
  2417.                 Pop      DS                         ;
  2418.                 Add      DX,6                       ; DX = 3xA, CRT status reg
  2419.             Mov      AH,5                       ; Set retrace loop to 5
  2420.             Push     CX                         ; Save CX
  2421.             Xor      CX,CX                      ; Clear CX
  2422. L38_Wait:   In       AL,DX                      ; Wait for a retrace
  2423.             Test     AL,8                       ;
  2424.             JNZ      L38_Change                 ;
  2425.             Loop     L38_Wait                   ;
  2426.             Dec      AH                         ;
  2427.             JNZ      L38_Wait                   ;
  2428. L38_Change: Pop      CX                         ; Restore CX
  2429.             CLI                                 ; Set interrupts off
  2430.             In       AL,DX                      ; Set addr/data flipflop in ACR
  2431.                 Push     DX                         ; Save CRT status reg port #
  2432.                 Mov      DX,3C0h                    ; ACR reg 14h (color select)
  2433.                 Mov      AL,14h                     ;
  2434.             Out      DX,AL                      ; Set color select
  2435.                 Jmp      $+2                        ;
  2436.             Mov      AL,BH                      ;
  2437.             Out      DX,AL                      ; Send color select data
  2438.                 Pop      DX                         ; Recover CRT status reg
  2439.                 In       AL,DX                      ; Reset flipflop
  2440.                 Mov      DX,3C0h                    ; ACR again
  2441.             Mov      AL,20h                     ;
  2442.             Out      DX,AL                      ; Restore palette
  2443.             Mov      AX,_TickRate               ; Reset the count
  2444.             Mov      _TickCount,AX              ;
  2445.             STI                                 ; Set interrupts back on
  2446. L38_GoOrig: Pop      DX                         ; Restore registers
  2447.             Pop      CX                         ;
  2448.             Pop      BX                         ;
  2449.             Pop      AX                         ;
  2450.             Pop      DS                         ;
  2451.             PopF                                ;
  2452.             Assume   DS:Nothing                 ;
  2453.             Jmp      _OldInt1C                  ; Go to original INT 1C
  2454.  
  2455. _INTRCPT1C  Endp
  2456.  
  2457. ;░
  2458. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2459.  
  2460.  
  2461. ;░░░░ _Intrcpt21 ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2462. ;░
  2463. ;░ Interrupt 21 intercept.  Checks for termination function 4Ch.  If valid,
  2464. ;░ it uninstalls the color effects system.
  2465. ;░
  2466.  
  2467.  
  2468. _INTRCPT21  Proc     Far
  2469.  
  2470.             PushF                               ; Save flags
  2471.             Cmp      AH,4Ch                     ; Check for program termination
  2472.             JNE      L39_GoOrig                 ; No, then jump
  2473.             Push     AX                         ; Save registers
  2474.             Push     BX                         ;
  2475.             Push     CX                         ;
  2476.             Push     DX                         ;
  2477.             Push     SI                         ;
  2478.             Push     DI                         ;
  2479.             Push     ES                         ;
  2480.             Push     DS                         ;
  2481.             Mov      BX,DGROUP                  ; Set DS=DGROUP
  2482.             Mov      DS,BX                      ;
  2483.             Assume   DS:DGROUP                  ;
  2484.             CLD                                 ;
  2485.             Call     _UnInstall                 ; Uninstall
  2486.             Pop      DS                         ; Restore registers
  2487.             Pop      ES                         ;
  2488.             Pop      DI                         ;
  2489.             Pop      SI                         ;
  2490.             Pop      DX                         ;
  2491.             Pop      CX                         ;
  2492.             Pop      BX                         ;
  2493.             Pop      AX                         ;
  2494. L39_GoOrig: PopF                                ;
  2495.             Assume   DS:Nothing                 ;
  2496.             Jmp      _OldInt21                  ; Go to original INT 21
  2497. _INTRCPT21  Endp
  2498.  
  2499. ;░
  2500. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2501.  
  2502.  
  2503. _FXCODE     Ends
  2504.  
  2505.             End
  2506.  
  2507. ;▓
  2508. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2509.  
  2510.  
  2511. ; {EOF: fxcolor.asm}
  2512.