home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / fakesrc / dblscrl.asm < prev    next >
Assembly Source File  |  1993-11-20  |  7KB  |  208 lines

  1. ;=============================================================================
  2. ; dblscrl.asm - Double Horizontal Scroller.
  3. ;                                                   File created: 11/21/93
  4. ; Copyright (c) 1993, Carlos Hasan                 Last modified: 11/21/93
  5. ;
  6. ; Description:
  7. ;  Another Horizontal Scroller using a Logo Picture of 256x128x256.
  8. ;
  9. ; Dependency:
  10. ;  Requires Turbo Assembler 3.2 or later to be assembled.
  11. ;  Dependant on the IBM PC 286 or better processor.
  12. ;=============================================================================
  13.  
  14.         ideal
  15.         model   small,pascal
  16.         jumps
  17.         p286
  18.  
  19.         dosseg
  20.         stack   1024
  21.     ends
  22.  
  23.         global  LogoRAW:byte            ; LOGO.RAW linked file.
  24.         global  LogoPAL:byte            ; LOGO.PAL linked file.
  25.  
  26. ;=========================== Data Segment ====================================
  27.  
  28.         dataseg
  29.  
  30. SCREENWIDTH     equ  (2*320)            ; Logical Screen Width
  31.                                         ; Enough Space for Double-Window
  32. LOGOWIDTH       equ  256                ; Logo Piccy Dimensions.
  33. LOGOHEIGHT      equ  128
  34. SCROLLSPEED     equ  2                  ; Scrollers Speed.
  35.  
  36. ;=========================== Code Segment ====================================
  37.  
  38.         codeseg
  39.  
  40. ;-----------------------------------------------------------------------------
  41. ; SetModeX - Sets the VGA in Tweaked ModeX 320x400x256.
  42. ;-----------------------------------------------------------------------------
  43.  
  44. proc    SetModeX
  45.         mov     ax,0013h                ; Sets VGA linear 320x200x256
  46.         int     10h
  47.         mov     dx,3C4h                 ; Disable Chain-Four
  48.         mov     ax,0604h
  49.         out     dx,ax
  50.         mov     dx,3C4h                 ; Enable Write to All Four Planes
  51.         mov     ax,0F02h
  52.         out     dx,ax
  53.         mov     ax,0A000h               ; Clear Display Memory
  54.         mov     es,ax
  55.         xor     di,di
  56.         xor     ax,ax
  57.         mov     cx,8000h
  58.         cld
  59.         rep     stosw
  60.         mov     dx,3D4h                 ; Reprogram CRT Controller:
  61.         mov     ax,00014h               ; turn off dword mode
  62.         out     dx,ax
  63.         mov     ax,0e317h               ; turn on byte mode
  64.         out     dx,ax
  65.         mov     ax,00009h               ; cell height
  66.         out     dx,ax
  67.         mov     dx,3D4h                 ; Sets Logical Screen Width
  68.         mov     al,13h
  69.         mov     ah,SCREENWIDTH/8
  70.         out     dx,ax
  71.         ret
  72. endp    SetModeX
  73.  
  74. ;-----------------------------------------------------------------------------
  75. ; SetStartAddr - Sets the VGA Start Address Register.
  76. ; In:
  77. ;  BX = Start Address.
  78. ;-----------------------------------------------------------------------------
  79.  
  80. proc    SetStartAddr
  81.         mov     dx,3D4h                 ; Sets VGA Start Address
  82.         mov     al,0Dh
  83.         mov     ah,bl
  84.         out     dx,ax
  85.         dec     al
  86.         mov     ah,bh
  87.         out     dx,ax
  88.         ret
  89. endp    SetStartAddr
  90.  
  91. ;-----------------------------------------------------------------------------
  92. ; WaitVR - Waits the Next VGA Vertical Retrace Ending.
  93. ;-----------------------------------------------------------------------------
  94.  
  95. proc    WaitVR
  96.         mov     dx,3DAh
  97. WaitStartVR:
  98.         in      al,dx
  99.         test    al,8
  100.         je      WaitStartVR
  101. WaitEndVR:
  102.         in      al,dx
  103.         test    al,8
  104.         jne     WaitEndVR
  105.         ret
  106. endp    WaitVR
  107.  
  108. ;-----------------------------------------------------------------------------
  109. ; DrawLogo - Writes on Screen the Logo Picture.
  110. ;-----------------------------------------------------------------------------
  111.  
  112. proc    DrawLogo
  113.         pusha
  114.         push    ds
  115.         push    es
  116.         call    WaitVR
  117.         mov     ax,SEG LogoPAL          ; Sets the Logo Palette
  118.         mov     ds,ax
  119.         mov     si,OFFSET LogoPAL
  120.         mov     cx,768
  121.         mov     dx,3C8h
  122.         xor     al,al
  123.         out     dx,al
  124.         inc     dx
  125.         rep     outsb
  126.         mov     ax,SEG LogoRAW          ; Load LogoRAW Address
  127.         mov     ds,ax
  128.         mov     si,OFFSET LogoRAW
  129.         mov     ax,0A000h               ; Load Display Memory Segment
  130.         mov     es,ax
  131.         mov     ax,1102h
  132. DrawPlanes:
  133.         push    ax
  134.         push    si
  135.         mov     dx,3C4h                 ; Select Write Plane
  136.         out     dx,ax
  137.         mov     di,(320+SCREENWIDTH*220)/4
  138.         mov     bx,LOGOHEIGHT           ; Write Pixels
  139. DrawLoop:
  140.         mov     cx,LOGOWIDTH/4
  141. DrawRow:
  142.         mov     al,[ds:si]
  143.         mov     [es:di],al
  144.         add     si,4
  145.         inc     di
  146.         loop    DrawRow
  147.         add     di,(SCREENWIDTH-LOGOWIDTH)/4
  148.         dec     bx
  149.         jne     DrawLoop
  150.         pop     si
  151.         pop     ax
  152.         inc     si
  153.         add     ah,ah                   ; Next Plane.
  154.         jnc     DrawPlanes
  155.         pop     es
  156.         pop     ds
  157.         popa
  158.         ret
  159. endp    DrawLogo
  160.  
  161. ;-----------------------------------------------------------------------------
  162. ; Start - Start the Demostration. Called from DOS.
  163. ;-----------------------------------------------------------------------------
  164.  
  165. proc    Start
  166.         mov     ax,@Data                ; Sets Data Segment.
  167.         mov     ds,ax
  168.         mov     bx,sp                   ; Shrink Program Memory Block.
  169.         shr     bx,4
  170.         inc     bx
  171.         mov     ax,ss
  172.         mov     dx,es
  173.         sub     ax,dx
  174.         add     bx,ax
  175.         mov     ah,4Ah
  176.         int     21h
  177.         call    SetModeX                ; Sets VGA ModeX.
  178.         call    DrawLogo                ; Draw Logo.
  179.         mov     cx,35                   ; Sleep about 0.5 sec
  180. SleepEntry:
  181.         call    WaitVR
  182.         loop    SleepEntry
  183.         mov     si,0                    ; Starting Scrollers
  184.         mov     di,SCREENWIDTH*164/4    ; Address Offsets.
  185. DemoLoop:
  186.         call    WaitVR                  ; Waits Vertical Retrace.
  187.         mov     bx,si                   ; Show Upper Scroller.
  188.         call    SetStartAddr
  189.         call    WaitVR                  ; Waits Vertical Retrace.
  190.         mov     bx,di                   ; Show Bottom Scroller
  191.         call    SetStartAddr
  192.         add     si,SCROLLSPEED          ; Move Scrollers to the Left&Right.
  193.         sub     di,SCROLLSPEED
  194.         cmp     si,SCREENWIDTH/4        ; Enough Frames?
  195.         jbe     DemoLoop
  196. DemoExit:
  197.         mov     cx,35                   ; Sleep about 0.5 sec
  198. SleepExit:
  199.         call    WaitVR
  200.         loop    SleepExit
  201.         mov     ax,0003h                ; Set Text Mode.
  202.         int     10h
  203.         mov     ax,4C00h                ; Exit to DOS.
  204.         int     21h
  205. endp    Start
  206.  
  207.         end     Start
  208.