home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / gags_1.zip / CRMBL.8 < prev    next >
Text File  |  1987-05-12  |  3KB  |  82 lines

  1. Colormem  equ  0B800h    ;Color video mem for page 1
  2. Monomem   equ  0A300h    ;Mon video mem for page 1
  3. Blank     equ  20h
  4.  
  5.           jmp  Start
  6.  
  7. Row       dw   24             ;Rows to do initially
  8.  
  9. ;First, get current video mode and page.
  10. Start:    mov  cx,Colormem    ;Assume color display
  11.           mov  ah,15          ;Get current video mode
  12.           int  10h
  13.           cmp  al,2           ;Color?
  14.           je   A2             ;Yes
  15.           cmp  al,3           ;Color?
  16.           je   A2             ;Yes
  17.           cmp  al,7           ;Mono?
  18.           je   A1             ;Yes
  19.           int  20h            ;No,quit
  20.  
  21. ;Come here if 80 col text mode; put video segment in ds.
  22. A1:       mov  cx,Monomem     ;Set for Mono
  23. A2:       mov  bl,0           ;bx=page offset
  24.           add  cx,bx          ;Video segment
  25.           mov  ds,cx          ;in ds
  26.  
  27. ;Now do crumble.
  28.           xor  bx,bx          ;Start at top left corner
  29. A3:       push bx             ;Save row start on stack
  30.           mov  bp,80          ;Reset column counter
  31. ;Do next column in a row.
  32. ;Give operator a chance to terminate the crumbling.
  33. A4:       mov  ah,0Bh         ;Check if key pressed
  34.           int  21h
  35.           cmp  al,0FFh        ;Key pressed?
  36.           je   A9             ;Yes, quit
  37. ;Continue with crumble if no key pressed.
  38.           mov  si,bx          ;Set row top in si
  39.           mov  ax,w[si]       ;Get char & attr from screen
  40.           cmp  al,Blank       ;Is it a blank?
  41.           je   A7             ;Yes, skip it
  42.           mov  dx,ax          ;No, save it in dx
  43.           mov  al,Blank       ;Make it a space
  44.           mov  w[si],ax       ;and put on screen
  45.           add  si,160         ;Set for next row
  46.           mov  di,cs:Row      ;Get rows remaining
  47. A5:       mov  ax,w[si]       ;Get the char & attr from screen
  48.           mov  w[si],dx       ;Put top row char & attr there
  49. A6:       call Vert           ;Wait for 2 vert retraces
  50.           mov  w[si],ax       ;Put original char & attr back
  51. ;Do next row, this column.
  52.           add  si,160         ;Next row
  53.           dec  di             ;Done all rows remaining?
  54.           jne  A5             ;No, do next one
  55.           mov  w[si-160],dx   ;Put char & attr on line 25 as junk
  56. ;Do next column on this row.
  57. A7:       add  bx,2           ;Next column, same row
  58.           dec  bp             ;Dec column counter; done?
  59.           jne  A4             ;No, do this column
  60. ;Do next row.
  61. A8:       pop  bx             ;Get current row start
  62.           add  bx,160         ;Next row
  63.           dec  cs:Row         ;All rows done?
  64.           jne  A3             ;No
  65. A9:       int  20h            ;Yes, quit to DOS
  66.  
  67. ; Sub to wait for 2 vertical retraces to avoid snow on CGA screen.
  68. Vert:     push ax,dx,cx       ;Save all registers used
  69.           mov  cl,2           ;Wait for 2 vert retraces
  70.           mov  dx,3DAh        ;CRT status port
  71. F1:       in   al,dx          ;Read status
  72.           test al,8           ;Vert retrace went hi?
  73.           je   F1             ;No, wait for it
  74.           dec  cl             ;2nd one?
  75.           je   F3             ;Yes, write during blanking time
  76. F2:       in   al,dx          ;No, get status
  77.           test al,8           ;Vert retrace went low?
  78.           jne  F2             ;No, wait for it
  79.           jmp  F1             ;Yes, wait for next hi
  80. F3:       pop  cx,dx,ax       ;Restore registers
  81.           ret                 ;and return
  82.