' ******************
' *** SCROLL.LST ***
' ******************
'
DEFWRD "a-z"
'
> PROCEDURE initio.scroll
  ' *** install second screen as logical screen for scrolling
  ' *** prepare (invisible) logical screen
  ' *** then call any of the following scroll-Procedures
  ' *** Procedures use Standard Global physbase%
  ' *** global :   SCROLL.SCREEN%   SCROLL!
  IF NOT scroll!                          ! create logical screen if necessary
    scroll!=TRUE
    DIM scroll.screen|(32256)
    scroll.screen%=V:scroll.screen|(0)
    scroll.screen%=scroll.screen%+256-(scroll.screen% MOD 256)
  ENDIF
  ~XBIOS(5,L:scroll.screen%,L:-1,-1)      ! scroll-screen is now logical screen
RETURN
' *****
> PROCEDURE up.scroll(scroll.lines)
  ' *** scroll-screen scrolled upwards
  ' *** slow scroll   : 1 or 2 lines (interference on 1/3 and 2/3 of height ??)
  ' *** fast scroll   : 8 (Low) or 16 (High/Med) lines
  ' *** after actual scroll, a dummy scroll follows for constant scroll-speed
  ' *** uses Standard Globals
  LOCAL bytes,n,end%,offset%
  IF high.res!
    LET bytes=80*scroll.lines
  ELSE
    LET bytes=160*scroll.lines
  ENDIF
  end%=physbase%+32000
  offset%=32000+bytes
  FOR n=1 TO scrn.y.max/scroll.lines
    n.bytes%=MUL(n,bytes)
    BMOVE scroll.screen%,SUB(end%,n.bytes%),n.bytes%
    BMOVE scroll.screen%,scroll.screen%,SUB(offset%,n.bytes%)
  NEXT n
  BMOVE scroll.screen%,physbase%,32000          ! tidy up
  ~XBIOS(5,L:physical.screen%,L:-1,-1)          ! back to normal
RETURN
' *****
> PROCEDURE slider.scroll
  ' *** fade-over with slider-effect
  ' *** High resolution only
  LOCAL y,y2
  FOR y=4 TO 400 STEP 2
    y2=SUB(400,y)
    RC_COPY scroll.screen%,0,y2,160,y TO physbase%,0,0
    RC_COPY scroll.screen%,160,0,160,y TO physbase%,160,y2
    RC_COPY scroll.screen%,320,y2,160,y TO physbase%,320,0
    RC_COPY scroll.screen%,480,0,160,y TO physbase%,480,y2
  NEXT y
  ~XBIOS(5,L:physbase%,L:-1,-1)                 ! back to normal
RETURN
' *****
> PROCEDURE stripes.scroll(n)
  ' *** fade-over with luxaflex-effect
  ' *** High resolution only
  ' *** try n=3
  LOCAL i,j,x,y
  FOR i=0 TO 39
    x=MUL(i,80)
    FOR j=0 TO 9
      y=ADD(MUL(j,3200),x)
      BMOVE ADD(scroll.screen%,y),ADD(physbase%,y),80
    NEXT j
    PAUSE n
  NEXT i
  ~XBIOS(5,L:physbase%,L:-1,-1)                 ! back to normal
RETURN
' *****
> PROCEDURE random.scroll(n)
  ' *** fade-over with random lines
  ' *** High resolution only
  ' *** try n=0 or n=1
  LOCAL i,j,z
  DIM ran.scroll(399)
  FOR i=0 TO 399
    ran.scroll(i)=i
  NEXT i
  FOR i=399 DOWNTO 0
    j=RAND(SUCC(i))                             ! integer 0-i
    SWAP ran.scroll(i),ran.scroll(j)
  NEXT i
  FOR i=0 TO 399
    z=ran.scroll(i)*80
    BMOVE ADD(scroll.screen%,z),ADD(physbase%,z),80
    PAUSE n
  NEXT i
  ERASE ran.scroll()
  ~XBIOS(5,L:physbase%,L:-1,-1)                 ! back to normal
RETURN
' *****
> PROCEDURE middle.scroll(n)
  ' *** fade-over with zoom from center
  ' *** High resolution only
  ' *** try n=1
  LOCAL x,y,xp,yp
  FOR y=5 TO 400 STEP 5
    x=y*1.6
    xp=SHR(SUB(640,x),1)
    yp=SHR(SUB(400,y),1)
    RC_COPY scroll.screen%,xp,yp,x,y TO physbase%,xp,yp
    PAUSE n
  NEXT y
  ~XBIOS(5,L:physbase%,L:-1,-1)                 ! back to normal
RETURN
' *****
> PROCEDURE dropline.scroll(n)
  ' *** fade-over with dropping lines           *** BUG ***
  ' *** High resolution only
  ' *** try n=1
  LOCAL i,j,adr2%
  FOR i=396 TO 0 STEP -4
    adr2%=ADD(scroll.screen%,MUL(i,80))
    PAUSE n
    FOR j=0 TO i STEP 4
      BMOVE adr2%,ADD(physbase%,MUL(j,80)),320
    NEXT j
  NEXT i
  ~XBIOS(5,L:physbase%,L:-1,-1)                 ! back to normal
RETURN
' *****
> PROCEDURE spiral.scroll(n)
  ' *** fade-over with spirals
  ' *** High resolution only
  ' *** try n=1
  LOCAL x,y,c,m,i
  x=320
  y=200
  c=0
  m=1
  REPEAT
    FOR i=1 TO m
      RC_COPY scroll.screen%,x,y,64,40 TO physbase%,x,y
      PAUSE n
      SELECT c MOD 4
      CASE 0
        SUB x,64
      CASE 1
        SUB y,40
      CASE 2
        ADD x,64
      CASE 3
        ADD y,40
      ENDSELECT
    NEXT i
    INC c
    IF EVEN(c)
      INC m
    ENDIF
  UNTIL c=19
  ~XBIOS(5,L:physbase%,L:-1,-1)    ! back to normal
RETURN
' **********
'
> PROCEDURE scroll.up(scroll.lines,scroll.color)
  ' *** scroll screen upwards
  ' *** for reasonably smooth scrolling, use 2 or 3 lines
  ' *** for fast scroll, use 8 (Low rez) or 16 (High/Med rez) lines
  ' *** uses Standard Globals
  LOCAL n,bytes,move.bytes,source%
  IF high.res!
    LET bytes=80*scroll.lines
  ELSE
    LET bytes=160*scroll.lines
  ENDIF
  move.bytes=32000-bytes
  source%=physbase%+bytes
  VSYNC
  BMOVE source%,physbase%,move.bytes                       ! 1st scroll
  DEFFILL scroll.color
  PBOX 0,scrn.y.max-scroll.lines+1,scrn.x.max,scrn.y.max   ! clear bottom,
  FOR n=1 TO DIV(scrn.y.max,scroll.lines)                  ! here we go
    VSYNC
    BMOVE source%,physbase%,move.bytes
  NEXT n
RETURN
' **********
'
> PROCEDURE scroll.down(scroll.lines,scroll.color)
  ' *** scroll screen downwards
  ' *** for reasonably smooth scrolling, use 2 or 3 lines
  ' *** for fast scroll, use 8 (Low rez) or 16 (High/Med rez) lines
  ' *** (interference line on 1/3 and 2/3 of screenheight, why ??)
  ' *** uses Standard Globals
  LOCAL n,bytes,move.bytes,dest%
  IF high.res!
    LET bytes=80*scroll.lines
  ELSE
    LET bytes=160*scroll.lines
  ENDIF
  move.bytes=32000-bytes
  dest%=physbase%+bytes
  VSYNC
  BMOVE physbase%,dest%,move.bytes             ! 1st scroll
  DEFFILL scroll.color
  PBOX 0,0,scrn.x.max,scroll.lines-1           ! clear top,
  FOR n=1 TO DIV(scrn.y.max,scroll.lines)      ! here we go
    VSYNC
    BMOVE physbase%,dest%,move.bytes
  NEXT n
RETURN
' **********
'
