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