TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: BARRY BLOCK
from: DENIS BOYLES
date: 1997-05-13 13:35:00
subject: Scrolly.Asm 3/

>>> Continued from previous message
;-=] ScrollScreen [=-------------------------------------------------------
;This "scrolls" the screen or rather then text "window" left by one pixel.
;By moving video memory down one byte, we can scroll the whole section left.
ScrollScreen PROC
    push    DS                         ;save DS, SI onto the stack
    push    SI
    mov     AX,0A000h                  ;setup DS to the video memory as well.
    mov     DS,AX
    mov     SI,ScrollY * 320 + 1       ;SI = first Y line + 1 of the window
    mov     DI,ScrollY * 320           ;DI = first Y line of the window
    mov     CX,0500h                   ;CX = 8 * 320 lines to move (in words)
    call    WaitRetrace                ;wait for a vertical retrace
    rep     movsw                      ;now copy SI -> DI which does the 
scroll
    pop     SI                         ;restore SI
    pop     DS                         ;restore DS
    ret
ScrollScreen ENDP
;-=] WaitRetrace [=--------------------------------------------------------
;This waits for a vertical retrace to start on the VGA card. Vertical Retrace
;is the time when the display isn't drawing, since the beam returns to the
;top of the screen.
;
;By waiting for this, we can achieve to main things here. One, the program is
;given a "timing" delay by way of the retrace signal. This should mean the
;program will run at the same speed (VGA) on different computers. Second by
;doing the "scroll" in this period, you remove the flicker/jaggies. Giving
;a "smoother" looking scroll.
WaitRetrace PROC
    cli                                ;disable interrupts for accuracy
    mov     DX,3DAh                    ;DX = CGA status port
SS0:                                   ;first, flush any current retrace
    in      AL,DX                       ;input byte from CGA status port
    test    AL,8                        ;test bit 8 for on, (retrace)
    jnz     SS0                         ;loop while it's on to flush
SS1:                                   ;now, wait until the retrace starts
    in      AL,DX
    test    AL,8
    jz      SS1                         ;loop while off to catch retrace
    sti
    ret
WaitRetrace ENDP
;-=] HorizLine [=----------------------------------------------------------
;This draws a full horizontal line across the width of the screen in COLOR
;on the Y axis. The full width is 320 pixel here, and Y,COLOR are pushed in
;that order prior to the call.
HorizLine PROC                         ;HorizLine( y, color )
    push    BP
    mov     BP,SP
    mov     AX,320                     ;same as in PlotPixel but just the Y
    mul     word ptr [BP+6]
    mov     DI,AX                      ;set DI to Y offset
    mov     AH,[BP+4]                  ;AH = color
    mov     AL,AH                      ;AL = color (AX = color | color)
    mov     CX,160                     ;line is 160 words in length
    rep     stosw                      ;write to memory, drawing line
    pop     BP
    ret     4                          ;return and clear pushed variables
HorizLine   ENDP
PRG ENDS
    END main
 * OLX 2.1 TD * Backup not found: (A)bort (R)etry (P)anic
--- Maximus/2 3.01
---------------
* Origin: Frog Hollow Port Moody BC 604-469-0264/0284 (1:153/290)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.