Forum
Space Worm - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Gallery (https://www.boriel.com/forum/forumdisplay.php?fid=18)
+---- Thread: Space Worm (/showthread.php?tid=862)



Space Worm - emook - 11-15-2018

Just some fun little code.


Code:
' SpaceWorm - em00k
' David Saphier 2018

paper 0 : ink 0: cls :border 0
dim c,sc as uinteger
dim a as float

' Fill screen with some Graphics

for n=1 to 192

    print inverse 0;"\.' ";
    print inverse 1;"\.' ";
    
Next

a=1 : ad=1

do
    
    ' draws a line of attribs at X=26 Y+7 colour blue (1)
    for y=1 to 7
        poke 22528+26+(y<<5),1
    next
    
    ' reads the sin data from sinpos+c and pops into cc
    cc=peek(@sinpos+c)+1
    
    ' get the current colour and make sure its *8 so it affects the paper
    ic=i<<3
    
    ' draw the colour ic at X=26 and Y+cc
    poke 22528+26+((15-cc)<<5),ic
    poke 22528+26+((16-cc)<<5),ic
    
    ' increase c to for reading sintable
    c=c+ad
    
    ' if its bigger than 60, reset the position
    if c>60
        c=0
    endif
    
    ' increase mc, used for setting speed
    mc=mc+1

    if mc>10
        ' mc was 10 to now we make ad = (speed+sc)
        ad=peek(@speed+sc) : sc=sc+1 : mc=0
        
        if sc>13 : sc=0 :    endif     
        
    endif
    
    ' fractional for slower colour changes
    a=a+.75
    
    if a>1
        i=i+1 : a=0
        if i>7 : i=1 : endif        
    endif

    pause 2

    asm
        ; code for copying the attribs from right to left
        lin equ 4
        len equ 26
        
        ld hl,22529+lin+32
        ld de,22528+lin+32
        ld bc,len
        ldir
        
        ld hl,22529+lin+32+32
        ld de,22528+lin+32+32
        ld bc,len
        ldir
        
        ld hl,22529+lin+32+32+32
        ld de,22528+lin+32+32+32
        ld bc,len
        ldir
        
        ld hl,22529+lin+32+32+32+32
        ld de,22528+lin+32+32+32+32
        ld bc,len
        ldir
        
        ld hl,22529+lin+32+32+32+32+32
        ld de,22528+lin+32+32+32+32+32
        ld bc,len
        ldir
        ld hl,22529+lin+32+32+32+32+32+32
        ld de,22528+lin+32+32+32+32+32+32
        ld bc,len
        ldir
        
        ld hl,22529+lin+32+32+32+32+32+32+32
        ld de,22528+lin+32+32+32+32+32+32+32
        ld bc,len
        ldir
    end asm

loop

cols:
asm
    db 6,6,6,6,6,2
    db 70,68,6,6,6,2
    db 3,4,5,6,6,2
    db 6,6,6,6,6,2
    db 3,4,5,6,6,2    
end asm

sinpos:
asm
    db 2,2,2,1,1,1,1,1,0,0,0,0,0,0,0,0
    db 0,0,0,0,0,0,0,0,0,1,1,1,1,1,2,2
    db 2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,4
    db 4,4,4,4,4,4,4,4,3,3,3,3,3,2,2,2
end asm

speed:
asm
    db 1,1,2,3,4,5,6,5,4,3,2,1,1
end asm



Re: Space Worm - oblo - 11-15-2018

Nice effect, thanks for sharing!

Cheers