{ ************************************************************* Multi-Plane Star Scroller ------------------------- In conjunction with :- M . T . S . I ------------- Multi-Tasking Software Interrupts Developed and Written By Franz - Josef Ayestaran 1992 ************************************************************** } program StarScroller; uses crt, graph; Type List = array[1..50] of integer; List2 = array[1..50] of integer; List3 = array[1..50] of integer; List4 = array[1..50] of integer; Const Gray50 : FillPatternType = ( $AA, $55, $AA, $55, $AA, $55, $AA, $55 ); Leds : FillPatternType = ( $AA, $00, $AA, $00, $AA, $00, $AA, $00 ); var gd, gm, Count, Count2, Loop, Loop2, StarsScrollCount, StarsScrollLoop, StarX, StarY, Timer, StarColor, StarsInterupt, StarsInteruptLength, StarsOn_Off : integer; OldPattern : FillPatternType; StarsX : List; StarsXBackup : List3; StarsY : List2; StarsColor : List3; Direction : char; {--------------------------------------------------------------} { >>>> P R O C E D U R E S <<<< } Procedure InitGraphics; Var Gd, Gm : integer; begin Gd := Detect; InitGraph(Gd, Gm, ''); if GraphResult <> grOK then Halt(1); end; {---------------------------------------------------------------} Procedure BackGround; begin ClearViewPort; SetColor(9); Rectangle(1,1,GetMaxX,200); FloodFill(2,2,9); end; {-----------------------------------------------------------------------} {-- 5 Plane Star Scroller Developed By Franz Ayestaran 23 October 92 --} {-----------------------------------------------------------------------} Procedure InitStars; begin SetColor(White); Randomize; Loop := 0; Repeat StarX := Random(GetMaxX); StarY := Random(GetMaxY); Repeat StarColor := 15; Until StarColor > 0; StarsX[Loop] := StarX; StarsXBackup[Loop] := StarX; StarsY[Loop] := StarY; StarsColor[Loop] := StarColor; Loop := Loop + 1; Until Loop > 49; end; {===============================================================} Procedure ClearStars; begin Loop := 0; Repeat StarX := StarsX[Loop]; StarY := StarsY[Loop]; PutPixel(StarX,StarY,0); Loop := Loop + 1; Until Loop > 50; end; {===============================================================} { M . T . S . I } { >>>> P R O C E D U R E S <<<< } Procedure ScrollStarsR2L; begin StarsInterupt := StarsInterupt + 1; If (StarsOn_Off = 1) and (StarsInterupt > StarsInteruptLength) then begin ClearStars; StarsInterupt := 0; Timer := 0; StarsScrollLoop := 0; {------------------------------------------------------------} {--- The Speed Of The 5 Scroll Planes Are Controlled Here ---} Repeat StarX := StarsX[StarsScrollLoop]; If StarX <= 0 then StarX := GetMaxX; { --- Star PlayField 1 --- } If (StarsScrollLoop >= 0) and (StarsScrollLoop <= 10) then begin StarX := StarX - 1; { <- speed } end; { --- Star PlayField 2 --- } If (StarsScrollLoop >= 10) and (StarsScrollLoop <= 20) then begin StarX := StarX - 2; end; { --- Star PlayField 3 --- } If (StarsScrollLoop >= 20) and (StarsScrollLoop <= 30) then begin StarX := StarX - 3; end; { --- Star PlayField 4 --- } If (StarsScrollLoop >= 30) and (StarsScrollLoop <= 40) then begin StarX := StarX - 4; end; { --- Star PlayField 5 --- } If (StarsScrollLoop >= 40) and (StarsScrollLoop <= 50) then begin StarX := StarX - 5; end; StarsX[StarsScrollLoop] := StarX; StarsScrollLoop := StarsScrollLoop + 1; Until StarsScrollLoop >= 51; {===============================================================} Loop := 0; Repeat StarX := StarsX[Loop]; StarY := StarsY[Loop]; StarColor := StarsColor[Loop]; PutPixel(StarX,StarY,StarColor); Loop := Loop + 1; Until Loop > 50; end; end; {---------------------------------------------------------------} {---------------------------------------------------------------} {---------------------------------------------------------------} Procedure ScrollStarsL2R; begin StarsInterupt := StarsInterupt + 1; If (StarsOn_Off = 1) and (StarsInterupt > StarsInteruptLength) then begin ClearStars; StarsInterupt := 0; Timer := 0; StarsScrollLoop := 0; {------------------------------------------------------------} {--- The Speed Of The 5 Scroll Planes Are Controlled Here ---} Repeat StarX := StarsX[StarsScrollLoop]; If StarX >= GetMaxX then StarX := 0; { --- Star PlayField 1 --- } If (StarsScrollLoop >= 0) and (StarsScrollLoop <= 10) then begin StarX := StarX + 1; { <- speed } end; { --- Star PlayField 2 --- } If (StarsScrollLoop >= 10) and (StarsScrollLoop <= 20) then begin StarX := StarX + 2; end; { --- Star PlayField 3 --- } If (StarsScrollLoop >= 20) and (StarsScrollLoop <= 30) then begin StarX := StarX + 3; end; { --- Star PlayField 4 --- } If (StarsScrollLoop >= 30) and (StarsScrollLoop <= 40) then begin StarX := StarX + 4; end; { --- Star PlayField 5 --- } If (StarsScrollLoop >= 40) and (StarsScrollLoop <= 50) then begin StarX := StarX + 5; end; StarsX[StarsScrollLoop] := StarX; StarsScrollLoop := StarsScrollLoop + 1; Until StarsScrollLoop >= 51; {===============================================================} Loop := 0; Repeat StarX := StarsX[Loop]; StarY := StarsY[Loop]; StarColor := StarsColor[Loop]; PutPixel(StarX,StarY,StarColor); Loop := Loop + 1; Until Loop > 50; end; end; {---------------------------------------------------------------} {---------------------------------------------------------------} {---------------------------------------------------------------} Procedure ScrollStarsT2B; begin StarsInteruptLength := 300; StarsInterupt := StarsInterupt + 1; If (StarsOn_Off = 1) and (StarsInterupt > StarsInteruptLength) then begin ClearStars; StarsInterupt := 0; Timer := 0; StarsScrollLoop := 0; {------------------------------------------------------------} {--- The Speed Of The 5 Scroll Planes Are Controlled Here ---} Repeat StarY := StarsY[StarsScrollLoop]; If StarY >= GetMaxY then StarY := 0; { --- Star PlayField 1 --- } If (StarsScrollLoop >= 0) and (StarsScrollLoop <= 10) then begin StarY := StarY + 1; { <- speed } end; { --- Star PlayField 2 --- } If (StarsScrollLoop >= 10) and (StarsScrollLoop <= 20) then begin StarY := StarY + 2; end; { --- Star PlayField 3 --- } If (StarsScrollLoop >= 20) and (StarsScrollLoop <= 30) then begin StarY := StarY + 3; end; { --- Star PlayField 4 --- } If (StarsScrollLoop >= 30) and (StarsScrollLoop <= 40) then begin StarY := StarY + 4; end; { --- Star PlayField 5 --- } If (StarsScrollLoop >= 40) and (StarsScrollLoop <= 50) then begin StarY := StarY + 5; end; StarsY[StarsScrollLoop] := StarY; StarsScrollLoop := StarsScrollLoop + 1; Until StarsScrollLoop >= 51; {===============================================================} Loop := 0; Repeat StarX := StarsX[Loop]; StarY := StarsY[Loop]; StarColor := StarsColor[Loop]; PutPixel(StarX,StarY,StarColor); Loop := Loop + 1; Until Loop > 50; end; end; {---------------------------------------------------------------} {---------------------------------------------------------------} {---------------------------------------------------------------} Procedure ScrollStarsB2T; begin StarsInteruptLength := 300; StarsInterupt := StarsInterupt + 1; If (StarsOn_Off = 1) and (StarsInterupt > StarsInteruptLength) then begin ClearStars; StarsInterupt := 0; Timer := 0; StarsScrollLoop := 0; {------------------------------------------------------------} {--- The Speed Of The 5 Scroll Planes Are Controlled Here ---} Repeat StarY := StarsY[StarsScrollLoop]; If StarY <= 0 then StarY := GetMaxY; { --- Star PlayField 1 --- } If (StarsScrollLoop >= 0) and (StarsScrollLoop <= 10) then begin StarY := StarY - 1; { <- speed } end; { --- Star PlayField 2 --- } If (StarsScrollLoop >= 10) and (StarsScrollLoop <= 20) then begin StarY := StarY - 2; end; { --- Star PlayField 3 --- } If (StarsScrollLoop >= 20) and (StarsScrollLoop <= 30) then begin StarY := StarY - 3; end; { --- Star PlayField 4 --- } If (StarsScrollLoop >= 30) and (StarsScrollLoop <= 40) then begin StarY := StarY - 4; end; { --- Star PlayField 5 --- } If (StarsScrollLoop >= 40) and (StarsScrollLoop <= 50) then begin StarY := StarY - 5; end; StarsY[StarsScrollLoop] := StarY; StarsScrollLoop := StarsScrollLoop + 1; Until StarsScrollLoop >= 51; {===============================================================} Loop := 0; Repeat StarX := StarsX[Loop]; StarY := StarsY[Loop]; StarColor := StarsColor[Loop]; PutPixel(StarX,StarY,StarColor); Loop := Loop + 1; Until Loop > 50; end; end; {===============================================================} Procedure Demo_1; Begin Initgraphics; InitStars; ClearViewPort; StarsInterupt := 1; StarsInteruptLength := 250; StarsOn_Off := 1; {------------------------------------} {----- Multi-Tasking Processing -----} Repeat {-- Multi Task 1 --} ScrollStarsR2L; {------------------} Until KeyPressed; closegraph; end; {---------------------------------------------------------------} { >>>> E N D O F P R O C E D U R E S <<<< } { Main } begin demo_1; end.