home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / screen / video / video1.asm < prev    next >
Assembly Source File  |  1988-12-22  |  20KB  |  849 lines

  1. ;TITLE 'Direct Video Routines'
  2.  
  3. ;
  4. ; Author: David Bennett - Version 1.0 - Date: 11/9/88
  5. ;
  6. ; This is a module of direct video writing routines for TASM.  Please see the
  7. ; file VIDEO.DOC for more information.  Examples of most routines are set forth
  8. ; in VIDDEMO.ASM.
  9. ;
  10. ; -Dave
  11. ;v1.1, Toad Hall Tweak, 22 Dec 88
  12. ; -    Rewritten to be an INCLUDE file for VIDDEMO1.ASM
  13. ;    (e.g., no separate compilation).
  14. ; -    Now compatible for MASM (don't have TASM).
  15. ;David Kirschbaum
  16. ;Toad Hall
  17. ;kirsch@braggvax.ARPA
  18.  
  19. baseOfScreen    DW    CGASEG        ; Offset for current vid mode
  20. snowcheck    DB    0        ; Check for retrace 1/0
  21. videoMode    DB    0        ; Current BIOS INT 10 vid mode
  22.  
  23. ; ------
  24. ; Macros
  25. ; ------
  26.  
  27. WaitRetrace    MACRO
  28.     LOCAL    WaitNoH, WaitH, WaitX
  29. ;
  30. ; This macro waits for the horizontial retrace signal from the
  31. ; monitor before continuing. Interrupts should be disabled B4
  32. ; calling this routine with CLI. Of course, make sure int's are
  33. ; reenabled afterwards with STI.
  34. ;
  35. ; Modifies
  36. ;    DX, AL
  37. ;
  38.     mov    dx, 3DAh        ; CGA status register
  39. WaitNoH:
  40.     in    al, dx            ; Get 6845 Status
  41.     test    al,8            ; Check vert retrace
  42.     jnz    WaitX            ;   In Progress? go
  43.     rcr    al,1            ; Wait for end of
  44.     jc    WaitNoH            ;   horizontial retrace
  45. WaitH:
  46.     in    al, dx            ; Get 6845 status again
  47.     rcr    al, 1            ; Wait for horizontial
  48.     jnc    WaitH            ;   retrace
  49. WaitX:
  50. ENDM
  51.  
  52. ; ----------------
  53. ; Video Procedures
  54. ; ----------------
  55.  
  56. MoveXY_DI    proc    near
  57. ;
  58. ; This procedure moves to the offset indicated by an X & Y cusor
  59. ; location.
  60. ;
  61. ; Input
  62. ;    AH = Row
  63. ;    AL = Column
  64. ; Output
  65. ;    DI = Memory Offset
  66. ;
  67.     push    cx        ; Save CX
  68.     xor    cl, cl        ; Clear CL
  69.     mov    ch, ah        ; CX = Row * 256
  70.     dec    ch        ; CX = (Row - 1) {0-24 Based}
  71.     shr    cx, 1        ; CX = Row * 128
  72.     mov    di, cx        ; Store in DI
  73.     shr    di, 1        ; DI = Row * 64
  74.     shr    di, 1        ; DI = Row * 32
  75.     add    di, cx        ; DI = (Row * 128)+(Row * 32) {Row*160}
  76.     xor    ch, ch        ; Clear CH register
  77.     mov    cl, al        ; CX = Columns
  78.     dec    cx        ; Make 0-79
  79.     shl    cx, 1        ; Account for attribute
  80.     add    di, cx        ; DI = (Row * 160) + (Col * 2)
  81.     pop    cx        ; Restore CX register
  82.     ret
  83.  
  84. MoveXY_DI    endp
  85.  
  86. MoveXY_SI    proc    near
  87. ;
  88. ; This procedure moves to the offset indicated by an X & Y cusor
  89. ; location.
  90. ;
  91. ; Input
  92. ;    AH = Row
  93. ;    AL = Column
  94. ; Output
  95. ;    SI = Memory Offset - Points 1 byte beyond null of str displayed
  96. ;
  97.     push    cx        ; Save CX
  98.     xor    cl, cl        ; Clear CL
  99.     mov    ch, ah        ; CX = Row * 256
  100.     dec    ch        ; CX = (Row - 1) {0-24 Based}
  101.     shr    cx, 1        ; CX = Row * 128
  102.     mov    si, cx        ; Store in SI
  103.     shr    si, 1        ; SI = Row * 64
  104.     shr    si, 1        ; SI = Row * 32
  105.     add    si, cx        ; SI = (Row * 128)+(Row * 32) {Row*160}
  106.     xor    ch, ch        ; Clear CH register
  107.     mov    cl, al        ; CX = Columns
  108.     dec    cx        ; Make 0-79
  109.     shl    cx, 1        ; Account for attribute
  110.     add    si, cx        ; DI = (Row * 160) + (Col * 2)
  111.     pop    cx        ; Restore CX register
  112.     ret
  113.  
  114. MoveXY_SI    endp
  115.  
  116. EGAInstalled    proc    near
  117. ;
  118. ; This procedure checks to see if the current adapter card is an
  119. ; EGA.
  120. ;
  121. ; Output
  122. ;    AL = 1 if EGA Adapter is found / 0 if not
  123. ; Modified
  124. ;    AX
  125. ;
  126.     push    bx        ; Store used registers
  127.     push    cx
  128.     mov    ax, 1200h    ; BIOS INT 10 function 12h
  129.     mov    bx, 10h        ; sub-func 10h (Get EGA info)
  130.     mov    cx, 0FFFFh    ; lite all bits of CX
  131.     int    10h        ; call INT 10
  132.     xor    ax, ax        ; Clear AX reg
  133.     cmp    cx, 0FFFFh    ; If CX not modified by INT call
  134.     je    EI_Done        ;   then this is not an EGA
  135.      inc    AL        ; Increment AL to show this is EGA
  136. EI_Done:
  137.     pop    cx        ; Restore regs
  138.     pop    bx
  139.     ret
  140.  
  141. EGAInstalled    endp
  142.  
  143. GetVideoMode    proc    near
  144. ;
  145. ; This procedure checks the video mode and sets the baseOfScreen
  146. ; accordingly.  It also sets snowcheck to 1 if adapter is a CGA.
  147. ;
  148. ; Output
  149. ;    baseOfScreen
  150. ;    videoMode
  151. ;    snowcheck
  152. ; Uses
  153. ;    EGAInstalled
  154. ;
  155.     push    ax            ; Store registers
  156.     push    di
  157.     push    DS
  158.     mov    ax,CS            ;v1.1
  159.     mov    DS,ax
  160.  
  161.     mov    di, CGASEG        ; move offset of CGA to DI
  162.     mov    ah, 0Fh            ; INT 10 get vid mode func
  163.     int    10h            ; get the video mode
  164.     xor    ah, ah            ; clear the AH reg
  165.     mov    videoMode, al        ; place mode into videoMode
  166.     cmp    al, 7            ; Is this a mono screen?
  167.     jne    NotMono            ; if not jump to NotMono
  168.      mov    di, MONOSEG        ; move offset of mono to DI
  169.      mov    snowcheck, 0        ; NEVER CHECK RETRACE ON MONO!
  170.      jmp    short GVM_Done
  171.  
  172. NotMono:                ; Process CGA/EGA/VGA adap.
  173.     call    EGAInstalled        ; Check for EGA adap.
  174.     rcr    al, 1            ; Move bit 1 to carry flag
  175.     jc    GVM_Done        ; If EGA then no snow check
  176.      mov    snowcheck, 1        ; Not EGA so set snow check
  177. GVM_Done:
  178.     mov    baseOfScreen, di    ; Move DI to base of screen
  179.     pop    DS            ; Restore regs
  180.     pop    di
  181.     pop    ax
  182.     ret
  183.  
  184. GetVideoMode    endp
  185.  
  186. DWriteCH    proc    near
  187. ;
  188. ; Writes a character to the screen using direct memory access.
  189. ;
  190. ; *** IMPORTANT -- CALL GetVideoMode Before using this routine!
  191. ;
  192. ; Input
  193. ;    AH    Row on screen 1-25
  194. ;    AL    Column on screen 1-80
  195. ;    BH    Video Attribute
  196. ;    BL    Character
  197. ;    CX    Number of times
  198. ; Output
  199. ;    Screen memory (B000:0000 or 8000 CGA/MONO
  200. ;
  201.     push    ax        ; Store the registers
  202.     push    cx
  203.     push    dx
  204.     push    ES
  205.     push    di
  206.  
  207.     call    MoveXY_DI    ; Set DI to row / column offset
  208.     mov    ES,baseOfScreen    ; Move screen seg to ES
  209.     mov    al,snowcheck    ; Move snow check to al
  210.     rcr    al, 1        ; snowcheck
  211.     jnc    DWC_NoWait    ; if no snowcheck goto FW_NoWait
  212. DWC_Next:
  213.     cli            ; Disable interrupts
  214.     WaitRetrace        ; Macro to wait for horiz retrace
  215.     mov    ax, bx        ; Move char/attr into AX
  216.     stosw            ; Move char/attr to screen
  217.     sti            ; Enable interrupts
  218.     loop    DWC_Next    ; Repeat CX times
  219.     jmp    short DWC_Exit    ; Exit this routine
  220.  
  221. DWC_NoWait:
  222.     mov    ax, bx        ; Move char/attr into AX
  223.     rep    stosw        ; Move char/attr to screen CX times
  224.  
  225. DWC_Exit:
  226.     pop    di        ; Restore the registers
  227.     pop    ES
  228.     pop    dx
  229.     pop    cx
  230.     pop    ax
  231.     ret
  232.  
  233. DWriteCH    endp
  234.  
  235. DWriteCHNA    proc    near
  236. ;
  237. ; Writes a character to the screen using direct memory access.
  238. ; This procedure does not disturb current attr setting.
  239. ;
  240. ; *** IMPORTANT -- CALL GetVideoMode Before using this routine!
  241. ;
  242. ; Input
  243. ;    AH    Row on screen 1-25
  244. ;    AL    Column on screen 1-80
  245. ;    BL    Character
  246. ;    CX    Number of times
  247. ; Output
  248. ;    Screen memory (B000:0000 or 8000 CGA/MONO
  249. ;
  250.     push    ax        ; Store the registers
  251.     push    cx
  252.     push    dx
  253.     push    ES
  254.     push    di
  255.  
  256.     call    MoveXY_DI    ; Set DI to row / column offset
  257.     mov    ES,baseOfScreen    ; Move screen seg to ES
  258.     mov    al,snowcheck    ; Move snow check to al
  259.     rcr    al, 1        ; snowcheck
  260.     jnc    DWCN_NoWait    ; if no snowcheck goto FW_NoWait
  261.  
  262. DWCN_Next:
  263.     cli            ; Disable interrupts
  264.     WaitRetrace        ; Macro to wait for horiz retrace
  265.     mov    al, bl        ; Move char into al
  266.     stosb            ; Move char to screen
  267.     sti            ; Enable interrupts
  268.     inc    di        ; Skip over attr
  269.     loop    DWCN_Next    ; Repeat CX times
  270.     jmp    short DWCN_Exit    ; Exit this routine
  271.  
  272. DWCN_NoWait:
  273.     mov    al, bl        ; Move char into AX
  274. DWCN_NoWaitLoop:
  275.     stosb            ; Move char to screen
  276.     inc    di        ; Skip over attr
  277.     loop    DWCN_NoWaitLoop ; Repeat CX times
  278.  
  279. DWCN_Exit:
  280.     pop    di        ; Restore the registers
  281.     pop    ES
  282.     pop    dx
  283.     pop    cx
  284.     pop    ax
  285.     ret
  286.  
  287. DWriteCHNA    endp
  288.  
  289. DWriteStr    proc    near
  290. ;
  291. ; This procedure writes a null delimited string to the screen using
  292. ; direct memory access.
  293. ;
  294. ; *** IMPORTANT -- CALL GetVideoMode Before using this routine!
  295. ;
  296. ; Input
  297. ;    DS:SI    Null terminated string to print
  298. ;    AH    Row on screen 1-25
  299. ;    AL    Column on screen 1-80
  300. ;    BH    Video Attribute
  301. ; Output
  302. ;    Screen memory (B000:0000 or 8000 CGA/MONO
  303. ; Modifies
  304. ;    SI - Points 1 byte beyond null of str displayed
  305. ;
  306.     push    ax        ; Store the registers
  307.     push    bx
  308.     push    cx
  309.     push    dx
  310.     push    ES
  311.     push    di
  312.  
  313.     call    MoveXY_DI    ; Set DI to row / column offset
  314.     mov    ES,baseOfScreen    ; Move screen seg to ES
  315.     mov    cl,snowcheck    ; Move snow check to al
  316.     cld            ; Clear the direction flag
  317.     rcr    cl, 1        ; snowcheck
  318.     mov    ah, bh        ; Place video attr in AH
  319.     jnc    DWS_NoWait    ; if no snowcheck goto DWS_NoWait
  320.  
  321. DWS_Next:
  322.     lodsb            ; Get a character from source
  323.     or    al, al        ; Check for NULL
  324.     jz    DWS_Exit    ; If NULL then exit
  325.     mov    bx, ax        ; Store video word into BX
  326.     cli            ; Disable interrupts
  327.     WaitRetrace        ; Macro to wait for horiz retrace
  328.     mov    ax, bx        ; Move word back to AX...
  329.     stosw            ; Move word to screen
  330.     sti            ; Enable interrupts
  331.     jmp    DWS_Next    ; Continue
  332.  
  333. DWS_NoWait:
  334.     lodsb            ; Get a character from string
  335.     or    al, al        ; Check for NULL
  336.     jz    DWS_Exit    ; If NULL then exit
  337.      stosw            ; Move word to screen
  338.      loop    DWS_NoWait    ; Continue
  339. DWS_Exit:
  340.     pop    di        ; Restore the registers
  341.     pop    ES
  342.     pop    dx
  343.     pop    cx
  344.     pop    bx
  345.     pop    ax
  346.     ret
  347.  
  348. DWriteStr    endp
  349.  
  350. DWriteStrNA    proc    near
  351. ;
  352. ; This procedure writes a null delimited string to the screen using
  353. ; direct memory access, attribute is not changed.
  354. ;
  355. ; *** IMPORTANT -- CALL GetVideoMode Before using this routine!
  356. ;
  357. ; Input
  358. ;    DS:SI    Null terminated string to print
  359. ;    AH    Row on screen 1-25
  360. ;    AL    Column on screen 1-80
  361. ; Output
  362. ;    Screen memory (B000:0000 or 8000 CGA/MONO)
  363. ; Modifies
  364. ;    SI - Points 1 byte beyond null of str displayed
  365. ;
  366.     push    ax        ; Store the registers
  367.     push    bx
  368.     push    cx
  369.     push    dx
  370.     push    ES
  371.     push    di
  372.  
  373.     call    MoveXY_DI    ; Set DI to screen offset pos
  374.     mov    ES,baseOfScreen    ; Move screen seg to ES
  375.     mov    cl,snowcheck    ; Move snow check to cl
  376.     cld            ; Clear the direction flag
  377.     rcr    cl, 1        ; snowcheck
  378.     jnc    DWSN_NoWait    ; if no snowcheck goto DWSN_NoWait
  379.  
  380. DWSN_Next:
  381.     lodsb            ; Get a character from source
  382.     or    al, al        ; Check for NULL
  383.     jz    DWSN_Exit    ; If NULL then exit
  384.     mov    bx, ax        ; Store video word into BX
  385.     cli            ; Turn off interrupts
  386.     WaitRetrace        ; Macro - Waits for horiz retrace
  387.     mov    ax, bx        ; Move word back to AX...
  388.     stosb            ; Move word to screen
  389.     sti            ; Enable interrupts
  390.     inc    di        ; Skip the attribute.
  391.     jmp    DWSN_Next    ; Continue
  392.  
  393. DWSN_NoWait:
  394.     lodsb            ; Get a character from string
  395.     or    al, al        ; Check for NULL
  396.     jz    DWSN_Exit    ; If NULL then exit
  397.      stosb            ; Store the byte on screen
  398.      inc    di        ; Skip attribute byte
  399.      loop    DWSN_NoWait    ; Continue
  400. DWSN_Exit:
  401.     pop    di        ; Restore the registers
  402.     pop    ES
  403.     pop    dx
  404.     pop    cx
  405.     pop    bx
  406.     pop    ax
  407.     ret
  408.  
  409. DWriteStrNA    endp
  410.  
  411. DFillCH    proc    near
  412. ;
  413. ; This procedure fills an area of the screen with the specified
  414. ; character and attribute.
  415. ;
  416. ; *** IMPORTANT -- CALL GetVideoMode Before using this routine!
  417. ;
  418. ; Input
  419. ;    AH    = Top Row
  420. ;    AL    = Left Column
  421. ;    BH    = Number of rows
  422. ;    BL    = Number of columns
  423. ;    DH    = Attribute
  424. ;    DL    = Character
  425. ;
  426.     push    ax            ; Store Registers
  427.     push    bx
  428.     push    cx
  429.     push    dx
  430.     push    ES
  431.     push    di
  432.  
  433.     mov    ES,baseOfScreen    ; Move screen seg to ES
  434.     mov    cl,snowcheck    ; Move snow check to CL
  435.  
  436.     cld            ; Clear the direction flag
  437.     rcr    cl, 1        ; snowcheck
  438.     mov    ch, 0        ; Clear CH
  439.     jnc    DFC_NoWait    ; if no snowcheck goto DFC_NoWait
  440.  
  441. DFC_Top:
  442.     mov    cl, bl        ; Load the number of columns
  443.     call    MoveXY_DI    ; Set DI to screen offset pos
  444.     push    ax        ; Store Registers AX, BX
  445.     push    bx
  446.     mov    bx,dx        ;video word into BX            v1.1
  447.  
  448. DFC_Next:
  449.     cli            ; Turn off interrupts
  450. ;    push    dx        ; Store video word
  451.     mov    bx,ax        ;store video word            v1.1
  452.     WaitRetrace        ; Macro - Waits for horiz retrace
  453. ;    pop    dx        ; Restore video word
  454. ;    mov    ax, dx        ; Move word into AX
  455.     mov    ax,bx        ;restore video word            v1.1
  456.     stosw            ; Move word to screen
  457.     sti            ; Enable interrupts
  458.     loop    DFC_Next    ; Continue
  459.  
  460.     pop    bx        ; Restore registers BX, AX
  461.     pop    ax
  462.     inc    ah        ; Next row
  463.     dec    bh        ; Decrement the number of rows done
  464. ;v1.1 the dec will set ZF appropriately if 0'ed
  465. ;    or    bh, bh        ; Check Number of columns
  466.     jnz    DFC_Top        ; Do next column if not done
  467.     jmp    short DFC_Exit    ; Exit routine
  468.  
  469. DFC_NoWait:
  470.     mov    cl, bl        ; Load the number of columns
  471.     call    MoveXY_DI    ; Set DI to screen offset pos
  472.     push    ax        ; Store the char/attr
  473.     mov    ax, dx        ; Move char/attr into ax
  474.     rep    stosw        ; Thats it!
  475.     pop    ax        ; Restore the char/attr
  476.     inc    ah        ; Next row
  477.     dec    bh        ; Decrement number of rows done
  478.     or    bh, bh        ; Check number of columns
  479.     jnz    DFC_NoWait    ; Do next column
  480.  
  481. DFC_Exit:
  482.     pop    di        ; Restore registers
  483.     pop    ES
  484.     pop    dx
  485.     pop    cx
  486.     pop    bx
  487.     pop    ax
  488.     ret
  489.  
  490. DFillCH    endp
  491.  
  492. DFillCHNA    proc    near
  493. ;
  494. ; This procedure fills an area of the screen with the specified
  495. ; character. Attribute remains the same.
  496. ;
  497. ; *** IMPORTANT -- CALL GetVideoMode Before using this routine!
  498. ;
  499. ; Input
  500. ;    AH    = Top Row
  501. ;    AL    = Left Column
  502. ;    BH    = Number of rows
  503. ;    BL    = Number of columns
  504. ;    DL    = Character
  505. ;
  506.     push    ax            ; Store Registers
  507.     push    bx
  508.     push    cx
  509.     push    dx
  510.     push    ES
  511.     push    di
  512.  
  513.     mov    ES,baseOfScreen    ; Move screen seg to ES
  514.     mov    cl,snowcheck    ; Move snow check to CL
  515.  
  516.     cld            ; Clear the direction flag
  517.     rcr    cl, 1        ; snowcheck
  518.     mov    ch, 0        ; Clear CH
  519.     jnc    DFCN_NoWait    ; if no snowcheck goto DFCN_NoWait
  520.  
  521. DFCN_Top:
  522.     mov    cl, bl        ; Load the number of columns
  523.     call    MoveXY_DI    ; Set DI to screen offset pos
  524.     push    ax        ; Store Registers AX, BX
  525.     push    bx
  526.     mov    bx,dx        ;char into BX                v1.1
  527.  
  528. DFCN_Next:
  529.     cli            ; Turn off interrupts
  530. ;    push    dx        ; Save video word
  531.     WaitRetrace        ; Macro - Waits for horiz retrace
  532. ;    pop    dx        ; Restore video word
  533. ;    mov    al, dl        ; Move character into al
  534.     mov    al,bl        ;move char into AL            v1.1
  535.     stosb            ; Move word to screen
  536.     sti            ; Enable interrupts
  537.     inc    di        ; Skip attr
  538.     loop    DFCN_Next    ; Continue
  539.  
  540.     pop    bx        ; Restore registers BX, AX
  541.     pop    ax
  542.     inc    ah        ; Next row
  543.     dec    bh        ; Decrement the number of rows done
  544.     or    bh, bh        ; Check Number of columns
  545.     jnz    DFCN_Top    ; Do next column if not done
  546.     jmp    short DFCN_Exit    ; Exit routine
  547.  
  548. DFCN_NoWait:
  549.     mov    cl, bl        ; Load the number of columns
  550.     call    MoveXY_DI    ; Set DI to screen offset pos
  551.     push    ax        ; Store the row/col info
  552.     mov    al, dl        ; Move char into ax
  553. DFCN_NoWaitLoop:
  554.     stosb            ; Thats it!
  555.     inc    di        ; Skip over attr
  556.     loop    DFCN_NoWaitLoop ; Loop for all columns
  557.     pop    ax        ; Restore the row/col info
  558.     inc    ah        ; Next row
  559.     dec    bh        ; Decrement number of rows done
  560.     or    bh, bh        ; Check number of columns
  561.     jnz    DFCN_NoWait    ; Do next column
  562.  
  563. DFCN_Exit:
  564.     pop    di        ; Restore registers
  565.     pop    ES
  566.     pop    dx
  567.     pop    cx
  568.     pop    bx
  569.     pop    ax
  570.     ret
  571.  
  572. DFillCHNA    endp
  573.  
  574. DFillAttr    proc    near
  575. ;
  576. ; This procedure fills an area of the screen with the specified
  577. ; attribute. Character remains the same.
  578. ;
  579. ; *** IMPORTANT -- CALL GetVideoMode Before using this routine!
  580. ;
  581. ; Input
  582. ;    AH    = Top Row
  583. ;    AL    = Left Column
  584. ;    BH    = Number of rows
  585. ;    BL    = Number of columns
  586. ;    DH    = Attribute
  587. ;
  588.     push    ax            ; Store Registers
  589.     push    bx
  590.     push    cx
  591.     push    dx
  592.     push    ES
  593.     push    di
  594.  
  595.     mov    ES,baseOfScreen    ; Move screen seg to ES
  596.     mov    cl,snowcheck    ; Move snow check to CL
  597.  
  598.     cld            ; Clear the direction flag
  599.     rcr    cl, 1        ; snowcheck
  600.     mov    ch, 0        ; Clear CH
  601.     jnc    DFA_NoWait    ; if no snowcheck goto DFA_NoWait
  602.  
  603. DFA_Top:
  604.     mov    cl, bl        ; Load the number of columns
  605.     call    MoveXY_DI    ; Set DI to screen offset pos
  606.     push    ax        ; Store Registers AX, BX
  607.     push    bx
  608.     mov    bx,dx        ;save attrib in BH            v1.1
  609.  
  610. DFA_Next:
  611.     cli            ; Turn off interrupts
  612. ;    push    dx        ; Save attribute in DH
  613.     WaitRetrace        ; Macro - Waits for horiz retrace
  614. ;    pop    dx        ; Restore attr
  615.     inc    di        ; Skip character
  616. ;    mov    al, dh        ; Move attr into al
  617.     mov    al,bh        ;move attr into AL            v1.1
  618.     stosb            ; Move attr to screen
  619.     sti            ; Enable interrupts
  620.     loop    DFA_Next    ; Continue
  621.  
  622.     pop    bx        ; Restore registers BX, AX
  623.     pop    ax
  624.     inc    ah        ; Next row
  625.     dec    bh        ; Decrement the number of rows done
  626.     or    bh, bh        ; Check Number of columns
  627.     jnz    DFA_Top        ; Do next column if not done
  628.     jmp    short DFA_Exit    ; Exit routine
  629.  
  630. DFA_NoWait:
  631.     mov    cl, bl        ; Load the number of columns
  632.     call    MoveXY_DI    ; Set DI to screen offset pos
  633.     push    ax        ; Store the row/col info
  634.     mov    al, dh        ; Move attr into ax
  635. DFA_NoWaitLoop:
  636.     inc    di        ; Skip over character
  637.     stosb            ; Thats it!
  638.     loop    DFA_NoWaitLoop  ; Loop for all columns
  639.     pop    ax        ; Restore the row/col info
  640.     inc    ah        ; Next row
  641.     dec    bh        ; Decrement number of rows done
  642.     or    bh, bh        ; Check number of columns
  643.     jnz    DFA_NoWait    ; Do next column
  644.  
  645. DFA_Exit:
  646.     pop    di        ; Restore registers
  647.     pop    ES
  648.     pop    dx
  649.     pop    cx
  650.     pop    bx
  651.     pop    ax
  652.     ret
  653.  
  654. DFillAttr    endp
  655.  
  656. StoreToMem    proc    near
  657. ;
  658. ; This procedure moves an image from the screen to the designated
  659. ; memory area.
  660. ;
  661. ; *** IMPORTANT -- CALL GetVideoMode Before using this routine!
  662. ;
  663. ; Input
  664. ;    AH    = Top Row
  665. ;    AL    = Left Column
  666. ;    BH    = Number of rows
  667. ;    BL    = Number of columns
  668. ;    ES:DI    = Memory Destination
  669. ; Modifies
  670. ;    DI
  671. ;
  672.     push    ax
  673.     push    bx
  674.     push    cx
  675.     push    dx
  676.     push    DS        ; Store registers
  677.     push    si
  678.  
  679.     mov DS,baseOfScreen    ; Move screen seg to DS mov cl,
  680.     mov cl,snowcheck    ; Move snow check to CL
  681.  
  682.     cld            ; Clear the direction flag
  683.     rcr    cl, 1        ; snowcheck
  684.     mov    ch, 0        ; Clear CH
  685.     jnc    STM_NoWait    ; if no snowcheck goto STM_NoWait
  686.  
  687. STM_Top:
  688.     mov    cl, bl        ; Load the number of columns
  689.     call    MoveXY_SI    ; Set SI to screen offset pos
  690.     push    ax        ; Store row/column info
  691.     push    bx        ; Store number of row/columns info
  692.  
  693. STM_Next:
  694.     lodsw            ; Get a char/word from screen
  695.     mov    bx, ax        ; Store video word into BX
  696.     cli            ; Turn off interrupts
  697.     WaitRetrace        ; Macro - Waits for horiz retrace
  698.     mov    ax, bx        ; Move word back to AX...
  699.     stosw            ; Move word to memory
  700.     sti            ; Enable interrupts
  701.     loop    STM_Next    ; Continue
  702.     pop    bx        ; Restore number of row/columns info
  703.     pop    ax        ; Restore row/column info
  704.     inc    ah        ; Next row
  705.     dec    bh        ; Decrement the number of rows done
  706.     or    bh, bh        ; Check Number of columns
  707.     jnz    STM_Top        ; Do next column if not done
  708.     jmp    short STM_Exit    ; Exit routine
  709.  
  710. STM_NoWait:
  711.     mov    cl, bl        ; Load the number of columns
  712.     call    MoveXY_SI    ; Set SI to screen offset pos
  713.     rep    movsw        ; Thats it!
  714.     inc    ah        ; Next row
  715.     dec    bh        ; Decrement number of rows done
  716.     or    bh, bh        ; Check number of columns
  717.     jnz    STM_NoWait    ; Do next column
  718.  
  719. STM_Exit:
  720.     pop    si
  721.     pop    DS
  722.     pop    dx
  723.     pop    cx
  724.     pop    bx
  725.     pop    ax
  726.     ret
  727.  
  728. StoreToMem    endp
  729.  
  730. StoreToScr    proc    near
  731. ;
  732. ; This procedure moves an image from memory to the designated
  733. ; screen location.
  734. ;
  735. ; *** IMPORTANT -- CALL GetVideoMode Before using this routine!
  736. ;
  737. ; Input
  738. ;    AH    = Top Row
  739. ;    AL    = Left Column
  740. ;    BH    = Number of rows
  741. ;    BL    = Number of columns
  742. ;    DS:SI    = Memory Area of image
  743. ; Modifies
  744. ;    SI
  745. ;
  746.     push    ax            ; Store Registers
  747.     push    bx
  748.     push    cx
  749.     push    dx
  750.     push    ES
  751.     push    di
  752.  
  753.     mov    ES,baseOfScreen    ; Move screen seg to ES
  754.     mov    cl,snowcheck    ; Move snow check to CL
  755.  
  756.     cld            ; Clear the direction flag
  757.     rcr    cl, 1        ; snowcheck
  758.     mov    ch, 0        ; Clear CH
  759.     jnc    STS_NoWait    ; if no snowcheck goto STS_NoWait
  760.  
  761. STS_Top:
  762.     mov    cl, bl        ; Load the number of columns
  763.     call    MoveXY_DI    ; Set DI to screen offset pos
  764.     push    ax        ; Store Registers AX, BX
  765.     push    bx
  766.  
  767. STS_Next:
  768.     lodsw            ; Get a char/word from memory
  769.     mov    bx, ax        ; Store video word into BX
  770.     cli            ; Turn off interrupts
  771.     WaitRetrace        ; Macro - Waits for horiz retrace
  772.     mov    ax, bx        ; Move word back to AX...
  773.     stosw            ; Move word to screen
  774.     sti            ; Enable interrupts
  775.     loop    STS_Next    ; Continue
  776.  
  777.     pop    bx        ; Restore registers BX, AX
  778.     pop    ax
  779.     inc    ah        ; Next row
  780.     dec    bh        ; Decrement the number of rows done
  781.     or    bh, bh        ; Check Number of columns
  782.     jnz    STS_Top        ; Do next column if not done
  783.     jmp    short STS_Exit    ; Exit routine
  784.  
  785. STS_NoWait:
  786.     mov    cl, bl        ; Load the number of columns
  787.     call    MoveXY_DI    ; Set DI to screen offset pos
  788.     rep    movsw        ; Thats it!
  789.     inc    ah        ; Next row
  790.     dec    bh        ; Decrement number of rows done
  791.     or    bh, bh        ; Check number of columns
  792.     jnz    STS_NoWait    ; Do next column
  793.  
  794. STS_Exit:
  795.     pop    di        ; Restore registers
  796.     pop    ES
  797.     pop    dx
  798.     pop    cx
  799.     pop    bx
  800.     pop    ax
  801.     ret
  802.  
  803. StoreToScr    endp
  804.  
  805. CursorOff    proc    near
  806. ;
  807. ; This procedure simply turns the Cursor off
  808. ;
  809.  
  810.     push    ax
  811.     push    bx
  812.     push    cx
  813.     push    dx
  814.     mov    ah, 03h        ; BIOS INT 10 func 3 (Get Cursor pos)
  815.     int    10h        ; Call INT 10
  816.     or    ch, 0100000b    ; Turn on cursor bit
  817.     mov    ah, 01h        ; BIOS INT 10 func 1 (Set cursor type)
  818.     int    10h        ; Call INT 10
  819.     pop    dx
  820.     pop    cx
  821.     pop    bx
  822.     pop    ax
  823.     ret
  824.  
  825. CursorOff    endp
  826.  
  827. CursorOn    proc    near
  828. ;
  829. ; This procedure simply turns the Cursor on
  830. ;
  831.     push    ax
  832.     push    bx
  833.     push    cx
  834.     push    dx
  835.     mov    ah, 03h        ; BIOS INT 10 func 3 (Get Cursor pos)
  836.     int    10h        ; Call INT 10
  837.     and    ch, 1011111b    ; Turn off cursor bit
  838.     mov    ah, 01h        ; BIOS INT 10 func 1 (Set cursor type)
  839.     int    10h        ; Call INT 10
  840.     pop    dx
  841.     pop    cx
  842.     pop    bx
  843.     pop    ax
  844.     ret
  845.  
  846. CursorOn    endp
  847.  
  848. ;END ; Of Video.ASM
  849.