CPC Basic

Basic cross-compiler for Amstad CPC


    Poking Star LIne Pixels to Screen and moving Vertically

    Out Bush
    Out Bush

    Posts : 8
    Join date : 2019-12-02

    Poking Star LIne Pixels to Screen and moving Vertically Empty Poking Star LIne Pixels to Screen and moving Vertically

    Post  Out Bush on Sat Dec 07, 2019 8:42 pm

    This is another variation of the Vertical stars I made earlier. Last year I worked out with a series of Loops to determine Blocks and Segments I could fill a whole Screen Line for Line with Random values in Locomotive BASIC. BASIC on that coding I came up with with a way to POKE some pixels (PEN 1 & 2) and have them move across the screen and as I thought the result works a little bit quicker than the earlier version which uses PLOT to do.

    Code:

    100 MODE 0:BORDER 0:INK 0,0:INK 1,26:INK 2,13
    110 DEFBYTE p : DEFWORD a-o,q-z : DIM p(2), x(10), y(10), b(10), s(10), z(10) : p(1)=128 : p(2) = 8
    120 c = 0
    130 WHILE c <> 10
    140  y(c) = RND MOD 7
    150  x(c) = RND MOD 79
    160  b(c) = RND MOD 25 : z(c) = b(c) * 80
    170  s(c) = p(RND MOD 2 + 1)
    180  GOSUB 1000
    190  c = c + 1
    200 WEND
    210 ' Main Loop
    220 c = 0
    230 WHILE 1
    240  IF x(c) = 0 THEN GOSUB 1100 : GOSUB 2000 : s(c) = p(RND MOD 2 + 1)
    250  IF x(c) > 0 THEN GOSUB 1100 : x(c) = x(c) - 1
    260  GOSUB 1000
    270  c = c + 1
    280  IF c=10 THEN CALL &BD19 : c=0
    290 WEND
    1000 POKE (&C000+(y(c)*&800)+z(c))+x(c),s(c)
    1010 RETURN
    1100 POKE (&C000+(y(c)*&800)+z(c))+x(c),0
    1110 RETURN
    2000 x(c) = 79
    2010 y(c) = RND MOD 7
    2020 b(c) = RND MOD 25
    2030 z(c) = b(c) * 80
    2040 RETURN

      Current date/time is Tue Feb 18, 2020 4:47 am