Rem Project: fps challenge
Rem Created: 18/01/2006 17:40:49
 
Rem ***** Main Source File *****
 
set display mode 1024,768,32
sync rate 60
hide mouse
set camera range 0.2,20000
backdrop on
color backdrop 0
autocam off
sync on
position camera 64,30,-64
hide light 0
make light 1
set ambient light 30
make object cube 1,1
hide object 1
make object collision box 1,-0.5,-0.5,-0.5,0.5,0.5,0.5,0
set object collision on 1
Make Object plain 2,128,128
Position Object 2,64,0,64
xrotate object 2,-90
grid=free_image()
ink rgb(255,255,255),0
box 0,0,500,500
ink rgb(200,200,200),0
for x=0 to 500 step 20
for y=0 to 500 step 20
box x,y,x+10,y+10
next y
next x
get image grid,0,0,500,500
 
createsound("foot steps",2,200,20,8000,.1,4.0,2.1,10,9.2,9.2,10)
 
scalefactor#=0.99
global mx#
 
type objecttype
 boxx as float
 boxy as float
 boxz as float
 scalex as float
 scaley as float
 scalez as float
 scaleu as float
 scalev as float
 scaledu as float
 scaledv as float
 storeuscale as float
 storevscale as float
 texture as integer
 typeofobject as string
 endtype
 
gosub make_texture_sprites
texture object 2,plaster
 
 
gosub make_game_environment
sync
text 0,0,"Calculating shadows: (approx 30 seconds)"
sync
`gosub calculate_shadows
sync
 
 
create bitmap 1,250,250
cls
for n=0 to 250
  ink rgb(n,n,250),0
  line 0,n,250,n
next n
skyimage=free_image()
get image skyimage,0,0,250,250
sphere3=free_object()
delete bitmap 1
make object sphere sphere3,10000
set object collision off sphere3
set object cull sphere3,0
texture object sphere3,skyimage
scale object texture sphere3,1,1.8
set object light sphere3,0
set object fog sphere3,0
 
position object 1,64.9,3,3.6
 
 
`make rifle
make object cylinder 2000,1
scale object 2000,80,1500,80
set object cull 2000,0
color object 2000,rgb(40,30,20)
xrotate object 2000,90
fix object pivot 2000
position object 2000,0,10,0
set object collision off 2000
disable object zdepth 2000
 
`dummy object for crosshairs
make object cube 4000,1
hide object 4000
 
`make bullets
numberofbullets=60
bulletseed=3000
dim bullet(numberofbullets+bulletseed) as usertype
 
type usertype
 
  xspeed as float
  yspeed as float
  inflight as boolean
  dist as float
 
endtype
 
type targettype
 
 speed as float
 
endtype
 
numberofenemies=30
enemyseed=6000
dim target(enemyseed+1+numberofenemies) as targettype
for target=enemyseed+1 to numberofenemies+enemyseed
make object cube target,3
set object collision on target
texture object target,wood
position object target,rnd(128),1,rnd(128)
next target
 
for bullet=1+bulletseed to numberofbullets+bulletseed
make object sphere bullet,1
position object bullet,0,10,0
set object collision on bullet
next bullet
 
bulletnumber=bulletseed+1
power#=20
reload=6
gravity#=0.02
 
 
 
createsound("explode",1,6200,7000,2000,20,0.2,0,0,0,0,10)
createsound("gun1",3,60,200,6000,0.001,1.2,.0,0,0,0,10)
createsound("gun2",4,2000,200,3000,-200,1.2,.0,0,0,0,10)
 
 
 
do
mx#=mousemovex()
my#=mousemovey()
gosub movement
collision()
gosub demolition
gosub update_target
gosub aim
gosub fire
gosub update_bullet
text 0,0,str$(screen fps())
sync
loop
 
demolition:
 
target=pick object(object screen x(4000),object screen y(4000),enemyseed+1,enemyseed+numberofenemies)
if mouseclick()=1 and target>0
target_hit=1
target(target).speed=0.2
endif
 
return
 
update_target:
 
if target_hit=1 and target>0
  if target(target).speed>0
    yang#=object angle y(target)
    yrotate object target,object angle y(2000)
    move object target,target(target).speed
    if object collision(target,0)>0 and object collision(target,0)<>2
    move object target,-target(target).speed
    endif
    dec target(target).speed,0.01
    yrotate object target,yang#
  endif
  if target(target).speed<=0
   target_hit=0
  endif
endif
 
return
 
aim:
 
 
position object 4000,object position x(1),object position y(1),object position z(1)
set object to object orientation 4000,1
move object 4000,200
line object screen x(4000)-5,object screen y(4000),object screen x(4000)+5,object screen y(4000)
line object screen x(4000),object screen y(4000)-5,object screen x(4000),object screen y(4000)+5
position object 2000,object position x(1),object position y(1)-1,object position z(1)
point object 2000,object position x(4000),object position y(4000)+4,object position z(4000)
 
return
 
fire:
inc reload_time
if mouseclick()=1 and bullet(bulletnumber).inflight=0 and reload_time>reload
  position object bulletnumber,object position x(2000),object position y(2000),object position z(2000)
  set object to object orientation bulletnumber,2000
  bullet(bulletnumber).xspeed=power#
  bullet(bulletnumber).inflight=1
  play sound 3:play sound 4
  inc bulletnumber
  reload_time=0
  if bulletnumber>numberofbullets+bulletseed then bulletnumber=1+bulletseed
endif
 
 
return
 
update_bullet:
 
for updatebullet=1+bulletseed to numberofbullets+bulletseed
  if bullet(updatebullet).inflight=1
    move object updatebullet,bullet(updatebullet).xspeed
    inc bullet(updatebullet).yspeed,gravity#
    inc bullet(updatebullet).dist,bullet(updatebullet).xspeed
    move object down updatebullet,bullet(updatebullet).yspeed
    if bullet(updatebullet).dist>600
      bullet(updatebullet).inflight=0
      bullet(updatebullet).xspeed=0
      bullet(updatebullet).yspeed=0
      position object updatebullet,0,-10,0
      reload_time=0
    endif
  endif
next updatebullet
 
return
 
function free_object
 
repeat
inc n
until object exist(n)=0
 
endfunction n
 
 
 
movement:
 
speed#=0
if upkey()=1 then speed#=0.2
if downkey()=1 then speed#=-0.2
yrotate object 1,object angle y(1)+mx#/2.0
xrotate object 1,object angle x(1)+my#/2.0
 
`if inkey$()="a" then position object 1,object position x(1),object position y(1)+0.1,object position z(1)
`if inkey$()="z" then position object 1,object position x(1),object position y(1)-0.11,object position z(1)
 
`reposition dummy object
position object 1,object position x(1)+speed#*sin(object angle y(1)),object position y(1),object position z(1)+speed#*cos(object angle y(1))
if leftkey()=1 then move object left 1,0.2
if rightkey()=1 then move object right 1,0.2
`set camera to dummy object's position and orientation
position camera object position x(1),object position y(1),object position z(1)
yrotate camera object angle y(1)
 
`play footstep sound and bounce camera
 
  if speed#<>0 and footsteptimer=0
    play sound 2
    bounce#=0
  endif
  inc footsteptimer
  if speed#<>0 then inc bounce#,0.003
  if  footsteptimer>20 then footsteptimer=0
 
 
return
 
 
 
calculate_shadows:
undim pixelshaded1(128,128)
undim pixelshaded2(128,128)
dim pixelshaded1(128,128)
dim pixelshaded2(128,128)
if light1>0
create bitmap 1,128,128
set current bitmap 1
ink rgb(255,255,255),0
box 0,0,128,128
ink rgb(10,10,10),0
for y=0 to 128
for x=0 to 128
for object=3 to numberofobjects+2
if object exist(object)=1
if object<>light1 and object<>light2
ray1#=intersect object(object,x,0,y,object position x(light1),object position y(light1),object position z(light1))
if light2>0 then ray2#=intersect object(object,x,0,y,object position x(light2),object position y(light2),object position z(light2)) else ray2=0
if ray1#=0 then ray1#=1000
if ray1#<0 then ray1#=1
if ray2#=0 then ray2#=1000
if ray2#<0 then ray2#=1
if ray1#<=100 and ray2#>100
  tone=100+ray1#*2
  if pixelshaded2(x,y)=1 or pixelshaded1(x,y)=1 then tone=tone/1.5
  if tone>255 then tone=255
  ink rgb(tone,tone,tone),0
  dot x,128-y
  pixelshaded1(x,y)=1
endif
if ray2#<=100 and ray1#>100
  tone=100+ray2#*2
  if pixelshaded1(x,y)=1 or pixelshaded2(x,y)=1 then tone=tone/1.5
  if tone>255 then tone=255
  ink rgb(tone,tone,tone),0
  dot x,128-y
  pixelshaded2(x,y)=1
endif
if ray1#<=100 and ray2#<=100
  tone=50+(ray1#+ray2#)
  if tone>255 then tone=255
  ink rgb(tone,tone,tone),0
  dot x,128-y
endif
endif
endif
next object
next x
next y
blur bitmap 1,3
shadowmap=free_image()
get image shadowmap,0,0,128,128
delete bitmap 1
set light mapping on 2,shadowmap
endif `(light1 exist)
 
return
 
function free_image()
 
repeat
 inc image
until image exist(image)=0
 
endfunction image
 
 
 
make_texture_sprites:
 
create bitmap 1,64,64
 
whitesquare=free_sprite()
ink rgb(255,255,255),0
box 0,0,32,32
get image whitesquare,0,0,32,32
 
`grass
 
ink rgb(0,105,0),0
box 0,0,64,64
for n=1 to 500
x=rnd(64)
y=rnd(64)
ink rgb(rnd(40),50+rnd(150),rnd(40)),0
dot x,y
next n
blur bitmap 1,1
grass=free_sprite()
get image grass,0,0,64,64
 
`sandstone
ink rgb(200,100,0),0
box 0,0,64,64
for n=1 to 500
x=rnd(64)
y=rnd(64)
ink rgb(100,70,rnd(30)),0
dot x,y
next n
blur bitmap 1,3
sandstone=free_sprite()
get image sandstone,0,0,64,64
 
`wood
ink rgb(200,150,120),0
box 0,0,64,64
for n=1 to 40
a=rnd(64)
b=a+rnd(10)-5
ink rgb(100,50,rnd(50)),0
line a,0,b,64
next n
blur bitmap 1,3
wood=free_sprite()
get image wood,0,0,64,64
 
 
 
`mesh
 
ink 0,0
box 0,0,64,64
ink rgb(150,150,150),0
for x=1 to 64 step 8
line 0,x,64,x
line x,0,x,64
next x
blur bitmap 1,3
mesh=free_sprite()
get image mesh,0,0,64,64
 
`marble
ink rgb(200,230,230),0
box 0,0,64,64
for n=1 to 500
x=rnd(64)
y=rnd(64)
ink rgb(150+rnd(20),150+rnd(20),150+rnd(20)),0
box x,y,x+rnd(5),y+rnd(5)
next n
blur bitmap 1,3
marble=free_sprite()
get image marble,0,0,64,64
 
`plaster
ink rgb(240,220,210),0
box 0,0,64,64
for n=1 to 500
x=rnd(64)
y=rnd(64)
ink rgb(200+rnd(20),190+rnd(20),180+rnd(20)),0
box x,y,x+rnd(5),y+rnd(5)
next n
blur bitmap 1,3
plaster=free_sprite()
get image plaster,0,0,64,64
 
 
`concrete
ink rgb(180,180,180),0
box 0,0,64,64
for n=1 to 200
x=rnd(64)
y=rnd(64)
ink rgb(150+rnd(100),150+rnd(100),150+rnd(100)),0
dot x,y
next n
blur bitmap 1,3
concrete=free_sprite()
get image concrete,0,0,64,64
 
`brick
ink rgb(250,150,100),0
box 0,0,64,64
for n=1 to 600
x=rnd(64)
y=rnd(64)
ink rgb(125,75,rnd(50)),0
dot x,y
next n
ink rgb(230,230,230),0
for y=1 to 61 step 10
line 0,y,64,y
for x=0 to 64 step 6+rnd(4)
line x,y,x,y+10
next x
next y
blur bitmap 1,3
brick=free_sprite()
get image brick,0,0,64,64
 
`colours
box 0,0,64,64,rgb(250,0,0),rgb(0,255,0),rgb(0,0,255),rgb(255,255,0)
colours=free_sprite()
get image colours,0,0,64,64
 
`stones
ink rgb(220,200,190),0
box 0,0,64,64
for n=1 to 500
x=rnd(64)
y=rnd(64)
ink rgb(180+rnd(20),170+rnd(20),160+rnd(20)),0
box x,y,x+rnd(5),y+rnd(5)
next n
ink rgb(250,250,250),0
for y=1 to 61 step 10
line 0,y,64,y
for x=0 to 64 step 6+rnd(4)
line x,y,x,y+10
next x
next y
blur bitmap 1,2
stones=free_sprite()
get image stones,0,0,64,64
 
 
`white
ink rgb(255,255,255),0
box 0,0,64,64
white=free_sprite()
get image white,0,0,64,64
 
`red
ink rgb(255,0,0),0
box 0,0,64,64
red=free_sprite()
get image red,0,0,64,64
 
delete bitmap 1
 
 
return
 
 
 
make_game_environment:
 
 
read numberoflights$
numberoflights=val(numberoflights$)
read lightx$
lightx#=val(lightx$)
read lighty$
lighty#=val(lighty$)
read lightz$
lightz#=val(lightz$)
position light 1,lightx#,lighty#,lightz#
if numberoflights=2
  read lightx$
  lightx#=val(lightx$)
  read lighty$
  lighty#=val(lighty$)
  read lightz$
  lightz#=val(lightz$)
  if light exist(2)=0 then make light 2
  position light 2,lightx#,lighty#,lightz#
endif
read numberofobjects$
numberofobjects=val(numberofobjects$)
undim object(numberofobjects+2)
dim object(numberofobjects+2) as objecttype
for object=3 to numberofobjects+2
 
    read typeofobject$
    object(object).typeofobject=typeofobject$
    if typeofobject$="cube" then make object cube object,5
    if typeofobject$="box"
      read boxx$
      boxx#=val(boxx$)
      read boxy$
      boxy#=val(boxy$)
      read boxz$
      boxz#=val(boxz$)
      make object box object,boxx#,boxy#,boxz#
      object(object).boxx=boxx#
      object(object).boxy=boxy#
      object(object).boxz=boxz#
    endif
    if typeofobject$="sphere" then make object sphere object,5,10,10
    if typeofobject$="cone" then make object cone object,5
    if typeofobject$="cylinder" then make object cylinder object,5
    if typeofobject$="light"
      make object sphere object,2,10,10
      color object object,rgb(255,255,0)
      set object light object,0
      if light1=0 then light1=object else light2=object
    endif
    read x$
    x#=val(x$)
    read y$
    y#=val(y$)
    read z$
    z#=val(z$)
    position object object,x#,y#,z#
    read anglex$
    anglex#=val(anglex$)
    read angley$
    angley#=val(angley$)
    read anglez$
    anglez#=val(anglez$)
    rotate object object,anglex#,angley#,anglez#
    read scalex$
    scalex#=val(scalex$)
    read scaley$
    scaley#=val(scaley$)
    read scalez$
    scalez#=val(scalez$)
    scale object object,100+scalex#,100+scaley#,100+scalez#
    object(object).scalex=scalex#
    object(object).scaley=scaley#
    object(object).scalez=scalez#
    read scaleu$
    scaleuval=val(scaleu$)
    read scalev$
    scalevval=val(scalev$)
    object(object).scaleu=scaleuval
    object(object).scalev=scalevval
    scale object texture object,scalefactor#^scaleuval,scalefactor#^scalevval
    read texturename$
    texture=val(texturename$)
    object(object).texture=texture
    texture object object,texture
    set object collision on object
 
`text 0,0,"Building map: "
sync
`wait 100
next object
 
 
return
 
function free_sprite
 
repeat
inc n
until sprite exist(n)=0 and image exist(n)=0
 
endfunction n
 
 
data "1"
data "136"
data "104"
data "232"
data "140"
data "box"
data "4.99999952316"
data "19.9999980927"
data "4.99999952316"
data "64"
data "4"
data "0"
data "0"
data "0"
data "0"
data "2439"
data "-60"
data "-56"
data "-207"
data "0"
data "12"
data "box"
data "126.499977112"
data "7.99999904633"
data "1.99999976158"
data "64"
data "0"
data "124"
data "0"
data "0"
data "0"
data "0"
data "-44"
data "0"
data "-210"
data "-43"
data "12"
data "light"
data "136"
data "104"
data "232"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "box"
data "4.99999952316"
data "19.9999980927"
data "4.99999952316"
data "128"
data "4"
data "64"
data "0"
data "0"
data "0"
data "-30"
data "-53"
data "2432"
data "-182"
data "0"
data "12"
data "box"
data "1.99999976158"
data "7.99999904633"
data "125.999984741"
data "1"
data "4"
data "63"
data "0"
data "0"
data "0"
data "-4"
data "0"
data "6"
data "-224"
data "0"
data "12"
data "box"
data "1.79999947548"
data "7.99999809265"
data "125.999969482"
data "86"
data "0"
data "64"
data "0"
data "0"
data "0"
data "-48"
data "0"
data "-70"
data "-120"
data "0"
data "12"
data "box"
data "1.79999935627"
data "7.99999761581"
data "125.999961853"
data "64"
data "10"
data "52"
data "0"
data "0"
data "0"
data "2342"
data "-43"
data "-90"
data "0"
data "0"
data "7"
data "box"
data "43.9199790955"
data "3.99999856949"
data "12.5999956131"
data "64"
data "0"
data "80"
data "0"
data "0"
data "0"
data "2"
data "0"
data "-53"
data "0"
data "0"
data "7"
data "box"
data "43.9199752808"
data "3.99999833107"
data "5.0399980545"
data "64"
data "0"
data "44"
data "0"
data "0"
data "0"
data "-55"
data "10"
data "-14"
data "50"
data "0"
data "7"
data "box"
data "17.5679893494"
data "3.19999837875"
data "4.0319981575"
data "64"
data "-1"
data "40"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "59"
data "0"
data "13"
data "box"
data "17.567987442"
data "3.19999814034"
data "4.03199768066"
data "64"
data "0"
data "42"
data "0"
data "0"
data "0"
data "0"
data "-23"
data "0"
data "50"
data "0"
data "7"
data "box"
data "17.5679855347"
data "2.23999834061"
data "4.03199720383"
data "44"
data "0"
data "68"
data "0"
data "0"
data "0"
data "-77"
data "80"
data "376"
data "0"
data "0"
data "7"
data "box"
data "3.51359701157"
data "4.03199625015"
data "18.95038414"
data "71"
data "0"
data "68"
data "0"
data "0"
data "0"
data "753"
data "0"
data "2"
data "0"
data "0"
data "7"
data "box"
data "29.9709777832"
data "4.03199529648"
data "19.3293876648"
data "42"
data "1"
data "64"
data "0"
data "0"
data "0"
data "-96"
data "40"
data "94"
data "-114"
data "0"
data "12"
data "box"
data "1.1988389492"
data "5.6447930336"
data "37.4990081787"
data "86"
data "12"
data "64"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "-93"
data "0"
data "8"
data "box"
data "1.19883882999"
data "5.64479255676"
data "37.499004364"
data "42"
data "12"
data "64"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "-119"
data "0"
data "8"
data "box"
data "1.19883871078"
data "5.64479207993"
data "37.4990005493"
data "86"
data "6"
data "48"
data "0"
data "0"
data "0"
data "-3"
data "14"
data "-83"
data "44"
data "0"
data "8"
data "box"
data "1.15088498592"
data "6.32216644287"
data "5.99983930588"
data "86"
data "6"
data "58"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "87"
data "0"
data "8"
data "box"
data "1.15088486671"
data "6.32216596603"
data "5.99983882904"
data "86"
data "6"
data "80"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "107"
data "0"
data "8"
data "box"
data "1.15088474751"
data "6.3221654892"
data "5.9998383522"
data "86"
data "6"
data "68"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "105"
data "0"
data "8"
data "box"
data "1.1508846283"
data "6.32216501236"
data "5.99983787537"
data "42"
data "6"
data "48"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "1.15088450909"
data "6.32216453552"
data "5.99983739853"
data "42"
data "6"
data "58"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "1.15088438988"
data "6.32216405869"
data "5.99983692169"
data "42"
data "6"
data "80"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "1.15088427067"
data "6.32216358185"
data "5.99983644485"
data "42"
data "6"
data "68"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "1.15088415146"
data "6.32216310501"
data "5.99983596802"
data "74"
data "8"
data "48"
data "0"
data "0"
data "0"
data "-18"
data "122"
data "93"
data "0"
data "0"
data "8"
data "box"
data "0.920707285404"
data "13.9087581635"
data "7.67978954315"
data "54"
data "8"
data "48"
data "0"
data "0"
data "0"
data "32"
data "0"
data "59"
data "0"
data "0"
data "8"
data "box"
data "0.9207072258"
data "13.9087572098"
data "7.67978906631"
data "60"
data "8"
data "64"
data "0"
data "0"
data "0"
data "-1"
data "0"
data "28"
data "0"
data "0"
data "8"
data "box"
data "0.920707166195"
data "13.9087562561"
data "7.67978858948"
data "60"
data "8"
data "76"
data "0"
data "0"
data "0"
data "11"
data "0"
data "83"
data "0"
data "0"
data "8"
data "box"
data "1.28898990154"
data "13.9087553024"
data "14.1308107376"
data "74"
data "8"
data "66"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "1.28898966312"
data "13.9087533951"
data "14.1308088303"
data "74"
data "8"
data "78"
data "0"
data "0"
data "0"
data "2"
data "0"
data "-27"
data "0"
data "0"
data "8"
data "box"
data "1.31476926804"
data "13.9087524414"
data "10.1741819382"
data "74"
data "12"
data "56"
data "0"
data "0"
data "0"
data "3"
data "-58"
data "-35"
data "0"
data "0"
data "12"
data "box"
data "1.34106445313"
data "5.84167528152"
data "6.51147603989"
data "82"
data "8"
data "51"
data "0"
data "0"
data "0"
data "479"
data "135"
data "-88"
data "0"
data "0"
data "8"
data "box"
data "7.75135231018"
data "13.6695184708"
data "0.781377077103"
data "59"
data "8"
data "59"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "7.75135183334"
data "13.6695175171"
data "0.781377017498"
data "71"
data "8"
data "59"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "7.75135135651"
data "13.6695165634"
data "0.781376957893"
data "51"
data "8"
data "59"
data "0"
data "0"
data "0"
data "36"
data "18"
data "-3"
data "0"
data "0"
data "8"
data "box"
data "6.2010807991"
data "13.6695156097"
data "0.734494268894"
data "80"
data "12"
data "45"
data "0"
data "0"
data "0"
data "113"
data "-58"
data "-40"
data "0"
data "0"
data "8"
data "box"
data "11.1619443893"
data "5.74119567871"
data "0.440696537495"
data "48"
data "12"
data "45"
data "0"
data "0"
data "0"
data "18"
data "0"
data "2"
data "0"
data "0"
data "8"
data "box"
data "13.1710929871"
data "5.74119520187"
data "0.449510425329"
data "64"
data "12"
data "42"
data "0"
data "0"
data "0"
data "51"
data "0"
data "-2"
data "3"
data "0"
data "8"
data "box"
data "19.7566375732"
data "5.74119472504"
data "0.440520197153"
data "64"
data "11"
data "83"
data "0"
data "0"
data "0"
data "129"
data "39"
data "-18"
data "-136"
data "-72"
data "8"
data "box"
data "45.0451278687"
data "7.92284822464"
data "0.422899335623"
data "64"
data "-1"
data "83"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "-145"
data "-54"
data "12"
data "box"
data "45.045124054"
data "7.9228477478"
data "0.42289930582"
data "63"
data "12"
data "59"
data "0"
data "0"
data "0"
data "-84"
data "-27"
data "15"
data "0"
data "0"
data "8"
data "box"
data "7.20721912384"
data "5.70445013046"
data "0.744302690029"
data "45"
data "5"
data "83"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "7.207218647"
data "5.70444965363"
data "0.744302630424"
data "57"
data "5"
data "83"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "7.20721817017"
data "5.70444917679"
data "0.74430257082"
data "71"
data "5"
data "83"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "7.20721769333"
data "5.70444869995"
data "0.744302511215"
data "83"
data "5"
data "83"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "7.20721721649"
data "5.70444822311"
data "0.744302451611"
data "85"
data "6"
data "45"
data "0"
data "0"
data "0"
data "-56"
data "30"
data "-9"
data "0"
data "0"
data "8"
data "box"
data "3.02703094482"
data "6.95942640305"
data "0.714530289173"
data "76"
data "6"
data "45"
data "0"
data "0"
data "0"
data "0"
data "8"
data "0"
data "0"
data "0"
data "8"
data "box"
data "3.02703070641"
data "6.95942592621"
data "0.714530229568"
data "73"
data "6"
data "42"
data "0"
data "0"
data "0"
data "0"
data "44"
data "0"
data "133"
data "5"
data "8"
data "box"
data "3.02703046799"
data "10.0215730667"
data "0.714530169964"
data "55"
data "6"
data "42"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "136"
data "-6"
data "8"
data "box"
data "3.02703022957"
data "10.021572113"
data "0.714530110359"
data "43"
data "6"
data "45"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "3.02702999115"
data "10.0215711594"
data "0.714530050755"
data "52"
data "5"
data "45"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "box"
data "3.02702975273"
data "10.0215702057"
data "0.71452999115"
data "48"
data "0"
data "45"
data "0"
data "0"
data "0"
data "312"
data "-1"
data "2"
data "0"
data "0"
data "12"
data "box"
data "12.4713611603"
data "4.81035327911"
data "0.728820502758"
data "80"
data "0"
data "45"
data "0"
data "0"
data "0"
data "0"
data "108"
data "0"
data "9"
data "0"
data "12"
data "box"
data "12.4713602066"
data "4.81035280228"
data "0.728820443153"
data "64"
data "12"
data "45"
data "0"
data "0"
data "0"
data "69"
data "0"
data "-6"
data "0"
data "0"
data "12"
data "box"
data "20.951883316"
data "4.81035232544"
data "0.685091137886"
data "70"
data "7"
data "46"
data "0"
data "0"
data "0"
data "-66"
data "222"
data "-64"
data "0"
data "0"
data "13"
data "box"
data "7.12364006042"
data "15.4893341064"
data "0.246632799506"
data "58"
data "7"
data "46"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "13"
data "cone"
data "73"
data "0"
data "38"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "cone"
data "55"
data "0"
data "38"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "8"
data "cylinder"
data "70"
data "6"
data "43"
data "0"
data "0"
data "0"
data "-78"
data "234"
data "-78"
data "0"
data "77"
data "7"
data "cylinder"
data "58"
data "6"
data "43"
data "0"
data "0"
data "0"
data "-77"
data "239"
data "-77"
data "0"
data "65"
data "7"
data "box"
data "4.99999952316"
data "19.9999980927"
data "4.99999952316"
data "64"
data "15"
data "65"
data "0"
data "0"
data "0"
data "885"
data "-86"
data "860"
data "-197"
data "-35"
data "5"
data "box"
data "49.1499862671"
data "1.599999547"
data "47.5999908447"
data "32"
data "4"
data "124"
data "0"
data "0"
data "0"
data "-96"
data "403"
data "-96"
data "0"
data "0"
data "12"
data "box"
data "1.96599924564"
data "8.03199672699"
data "1.90399944782"
data "44"
data "4"
data "124"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "12"
data "box"
data "1.96599912643"
data "8.03199577332"
data "1.90399932861"
data "68"
data "4"
data "124"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "12"
data "box"
data "1.96599900723"
data "8.03199481964"
data "1.9039992094"
data "20"
data "4"
data "124"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "12"
data "box"
data "1.96599888802"
data "8.03199386597"
data "1.90399909019"
data "8"
data "4"
data "124"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "12"
data "box"
data "1.96599876881"
data "8.03199291229"
data "1.90399897099"
data "80"
data "4"
data "124"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "12"
data "box"
data "1.9659986496"
data "8.03199195862"
data "1.90399885178"
data "56"
data "4"
data "124"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "12"
data "box"
data "1.96599853039"
data "8.03199100494"
data "1.90399873257"
data "92"
data "4"
data "124"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "12"
data "box"
data "1.96599841118"
data "8.03199005127"
data "1.90399861336"
data "104"
data "4"
data "124"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "12"
data "box"
data "1.96599829197"
data "8.0319890976"
data "1.90399849415"
data "116"
data "4"
data "124"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "12"
data "box"
data "1.96599817276"
data "8.03198814392"
data "1.90399837494"
data "66"
data "9"
data "125"
data "0"
data "0"
data "0"
data "6403"
data "-68"
data "115"
data "-227"
data "4"
data "12"
data "box"
data "127.829185486"
data "2.57023596764"
data "4.07455635071"
data "16"
data "4"
data "100"
data "0"
data "0"
data "0"
data "-70"
data "408"
data "-58"
data "0"
data "0"
data "10"
data "box"
data "30.6790027618"
data "12.9539880753"
data "1.6298224926"
data "16"
data "4"
data "80"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "10"
data "box"
data "30.6790008545"
data "12.9539871216"
data "1.62982237339"
data "15"
data "4"
data "57"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "10"
data "box"
data "30.6789989471"
data "12.9539861679"
data "1.62982225418"
data "17"
data "4"
data "37"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "10"
data "box"
data "30.6789970398"
data "12.9539852142"
data "1.62982213497"
data "112"
data "3"
data "54"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "10"
data "box"
data "30.6789951324"
data "12.9539842606"
data "1.62982201576"
data "112"
data "4"
data "86"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "10"
data "box"
data "30.6789932251"
data "12.9539833069"
data "1.62982189655"
data "112"
data "4"
data "24"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "10"
data "box"
data "30.6789913177"
data "12.9539823532"
data "1.62982177734"
data "31"
data "3"
data "79"
data "0"
data "0"
data "0"
data "-96"
data "-2"
data "1010"
data "0"
data "0"
data "10"
data "box"
data "1.22715950012"
data "12.69490242"
data "18.0910205841"
data "31"
data "0"
data "57"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "10"
data "box"
data "1.22715938091"
data "12.6949014664"
data "18.0910186768"
data "31"
data "0"
data "34"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "10"
data "box"
data "1.2271592617"
data "12.6949005127"
data "18.0910167694"
data "31"
data "0"
data "102"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "10"
data "box"
data "1.22715914249"
data "12.694899559"
data "18.0910148621"
data "32"
data "8"
data "69"
data "0"
data "0"
data "0"
data "73"
data "-63"
data "246"
data "-74"
data "0"
data "10"
data "box"
data "2.1107134819"
data "4.57016372681"
data "62.594909668"
data "109"
data "9"
data "55"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "13"
data "box"
data "2.11071324348"
data "4.57016324997"
data "62.5949058533"
data "98"
data "9"
data "55"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "13"
data "box"
data "2.11071300507"
data "4.57016277313"
data "62.5949020386"
data "119"
data "9"
data "55"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "13"
data "box"
data "2.11071276665"
data "4.5701622963"
data "62.5948982239"
data "97"
data "2"
data "27"
data "0"
data "0"
data "0"
data "-15"
data "119"
data "-91"
data "0"
data "0"
data "5"
data "box"
data "1.7729985714"
data "9.9629535675"
data "5.00759124756"
data "97"
data "2"
data "39"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "1.77299845219"
data "9.96295261383"
data "5.00759077072"
data "97"
data "3"
data "54"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "1.77299833298"
data "9.96295166016"
data "5.00759029388"
data "97"
data "4"
data "84"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "1.77299821377"
data "9.96295070648"
data "5.00758981705"
data "97"
data "3"
data "70"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "1.77299809456"
data "9.96294975281"
data "5.00758934021"
data "124"
data "1"
data "3"
data "0"
data "0"
data "0"
data "64"
data "-81"
data "-52"
data "0"
data "0"
data "5"
data "box"
data "2.90771651268"
data "1.79333090782"
data "2.40364265442"
data "113"
data "1"
data "6"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "2.90771627426"
data "1.79333078861"
data "2.403642416"
data "114"
data "1"
data "16"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "2.90771603584"
data "1.7933306694"
data "2.40364217758"
data "105"
data "1"
data "21"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "cylinder"
data "4"
data "2"
data "2"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "-140"
data "0"
data "5"
data "box"
data "4.99999952316"
data "19.9999980927"
data "4.99999952316"
data "13"
data "1"
data "26"
data "0"
data "0"
data "0"
data "0"
data "-88"
data "0"
data "0"
data "0"
data "5"
data "box"
data "4.99999904633"
data "2.39999938011"
data "4.99999904633"
data "13"
data "3"
data "26"
data "0"
data "0"
data "0"
data "-53"
data "0"
data "-53"
data "0"
data "0"
data "5"
data "box"
data "2.29999947548"
data "2.39999914169"
data "2.29999947548"
data "20"
data "3"
data "54"
data "0"
data "0"
data "0"
data "-61"
data "249"
data "101"
data "0"
data "0"
data "5"
data "box"
data "0.873999714851"
data "8.35199642181"
data "4.59999847412"
data "20"
data "3"
data "47"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873999655247"
data "8.35199546814"
data "4.59999799728"
data "20"
data "3"
data "43"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873999595642"
data "8.35199451447"
data "4.59999752045"
data "20"
data "3"
data "39"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873999536037"
data "8.35199356079"
data "4.59999704361"
data "13"
data "3"
data "40"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873999476433"
data "8.35199260712"
data "4.59999656677"
data "13"
data "3"
data "44"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873999416828"
data "8.35199165344"
data "4.59999608994"
data "19"
data "4"
data "76"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873999357224"
data "8.35199069977"
data "4.5999956131"
data "19"
data "4"
data "72"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873999297619"
data "8.35198974609"
data "4.59999513626"
data "9"
data "4"
data "77"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873999238014"
data "8.35198879242"
data "4.59999465942"
data "9"
data "4"
data "73"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.87399917841"
data "8.35198783875"
data "4.59999418259"
data "8"
data "4"
data "60"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873999118805"
data "8.35198688507"
data "4.59999370575"
data "8"
data "4"
data "64"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.8739990592"
data "8.3519859314"
data "4.59999322891"
data "9"
data "4"
data "103"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873998999596"
data "8.35198497772"
data "4.59999275208"
data "9"
data "4"
data "112"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873998939991"
data "8.35198402405"
data "4.59999227524"
data "9"
data "4"
data "116"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873998880386"
data "8.35198307037"
data "4.5999917984"
data "9"
data "4"
data "120"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "0.873998820782"
data "8.3519821167"
data "4.59999132156"
data "16"
data "3"
data "111"
data "0"
data "0"
data "0"
data "1105"
data "40"
data "-70"
data "0"
data "0"
data "5"
data "box"
data "10.5229444504"
data "11.692773819"
data "1.37999737263"
data "14"
data "2"
data "105"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "10.5229434967"
data "11.6927728653"
data "1.37999725342"
data "10"
data "2"
data "70"
data "0"
data "0"
data "0"
data "-13"
data "0"
data "-1"
data "0"
data "0"
data "5"
data "box"
data "9.0497303009"
data "11.6927719116"
data "1.35239720345"
data "13"
data "1"
data "63"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "9.04972934723"
data "11.6927709579"
data "1.35239708424"
data "22"
data "1"
data "63"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "9.04972839355"
data "11.6927700043"
data "1.35239696503"
data "15"
data "1"
data "49"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "9.04972743988"
data "11.6927690506"
data "1.35239684582"
data "102"
data "3"
data "40"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "9.04972648621"
data "11.6927680969"
data "1.35239672661"
data "111"
data "3"
data "40"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "9.04972553253"
data "11.6927671432"
data "1.3523966074"
data "102"
data "1"
data "68"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "9.04972457886"
data "11.6927661896"
data "1.35239648819"
data "110"
data "3"
data "68"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "9.04972267151"
data "11.6927642822"
data "1.35239624977"
data "64"
data "11"
data "88"
data "0"
data "0"
data "0"
data "378"
data "-95"
data "812"
data "-158"
data "0"
data "5"
data "box"
data "43.2576713562"
data "0.467710524797"
data "12.3338527679"
data "65"
data "2"
data "52"
data "0"
data "0"
data "0"
data "4"
data "0"
data "6"
data "0"
data "0"
data "7"
data "sphere"
data "24.2539901733"
data "0"
data "-71.8710861206"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "7"
data "sphere"
data "64"
data "13"
data "42"
data "0"
data "0"
data "0"
data "-79"
data "-77"
data "-78"
data "0"
data "0"
data "13"
data "box"
data "4.99999952316"
data "19.9999980927"
data "4.99999952316"
data "64"
data "11"
data "41"
data "0"
data "0"
data "0"
data "160"
data "-89"
data "-92"
data "285"
data "0"
data "12"
data "box"
data "12.999997139"
data "1.99999976158"
data "0.399999916553"
data "64"
data "0"
data "42"
data "0"
data "0"
data "0"
data "223"
data "-45"
data "747"
data "0"
data "0"
data "7"
data "box"
data "41.8599891663"
data "1.0799998045"
data "3.38399910927"
data "44"
data "7"
data "42"
data "0"
data "0"
data "0"
data "-95"
data "1375"
data "-52"
data "0"
data "0"
data "7"
data "box"
data "1.67439937592"
data "15.9191961288"
data "1.62431943417"
data "84"
data "7"
data "42"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "7"
data "box"
data "1.67439925671"
data "15.9191951752"
data "1.62431931496"
data "83"
data "3"
data "91"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "1.6743991375"
data "15.9191942215"
data "1.62431919575"
data "45"
data "3"
data "91"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "1.67439901829"
data "15.9191932678"
data "1.62431907654"
data "71"
data "3"
data "91"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "1.67439889908"
data "15.9191923141"
data "1.62431895733"
data "57"
data "3"
data "91"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "0"
data "5"
data "box"
data "1.67439866066"
data "15.9191904068"
data "1.62431871891"
data "17"
data "11"
data "48"
data "0"
data "0"
data "0"
data "2222"
data "-96"
data "1462"
data "302"
data "0"
data "6"
data "box"
data "34.4926109314"
data "0.636767566204"
data "29.0103321075"
data "16"
data "11"
data "81"
data "0"
data "0"
data "0"
data "18"
data "0"
data "51"
data "312"
data "0"
data "6"
data "box"
data "40.7012748718"
data "0.636767506599"
data "43.5154953003"
data "111"
data "11"
data "55"
data "0"
data "0"
data "0"
data "-13"
data "0"
data "57"
data "0"
data "317"
data "6"
 
 
 
function createsound(name$,soundnumber,frequency#,length#,loudness#,bend#,decay#,vibratospeed#,vibratodepth#,tremelospeed#,tremelodepth#,attack#)
 
outWord as word
dword1 as dword: dword2 as dword: dword3 as dword: dword4 as dword
dword5 as dword: dword6 as dword: dword7 as dword
 
samples=int((length#/1000)*44100)
 
if memblock exist(1) then delete memblock 1
make memblock 1,samples*2+28
 
` write 28 memblock header bytes
dword1=1      ` gg query: is this the number of channels?
dword2=2      ` gg query: is this the number of bytes per sample?
dword3=22050  ` gg query: seems to be half the number of samples per second - why?
dword4=88200  ` gg query: is this the number of bytes per second?
dword5=4      ` gg query: what does this represent?
dword6=16     ` gg query:     (ditto)            ?
dword7=0      ` gg query:     (ditto)            ?
 
position=0
write memblock dword 1, position, dword1 : inc position,4
write memblock dword 1, position, dword2 : inc position,4
write memblock dword 1, position, dword3 : inc position,4
write memblock dword 1, position, dword4 : inc position,4
write memblock dword 1, position, dword5 : inc position,4
write memblock dword 1, position, dword6 : inc position,4
write memblock dword 1, position, dword7 : inc position,4
 
rem generate and write wave
riseinloudness#=loudness#
for x=1 to samples
  outInteger=int(sin((x/122.5)*(frequency#+vibratodepth#*sin(theta#)))*(loudness#-fallinloudness#-riseinloudness#+tremelodepth#*sin(phi#)))*3.0
  if outInteger <-32767 then outInteger=-32767  ` gg query: is this the valid range?
  if outInteger>32767 then outInteger=32767     ` gg query:       (ditto)          ?
  outWord=outInteger
  inc theta#,vibratospeed#
  inc phi#,tremelospeed#
  dec frequency#,bend#
 
  if fallinloudness#<loudness#
    inc fallinloudness#,decay#
  endif
 
  if riseinloudness#>0
    dec riseinloudness#,attack#
  endif
 
  write memblock word 1, position, outWord : inc position,2
next x
 
if sound exist(soundnumber)=1 then delete sound soundnumber
 
make sound from memblock 999, 1 ` assumes you won't need sound number 999!
clone sound soundnumber, 999
delete sound 999
 
` memblock no longer required
delete memblock 1
 
endfunction
 
function collision()
 
 
coll=object collision(1,0)
 
 
`apply sliding collision
if coll>1
position object 1,object position x(1)-get object collision x(),object position y(1),object position z(1)-get object collision z()
endif
 
endfunction