Here is some example code with the current syntax
Code: Select all
# Changes the palette using hue saturation lightness
type=palette
gui double shifth<Shift hue by>,shifts<Shift saturation by>,shiftl<Shift lightness by>
begin main
end main
begin loop
double hsl[3]
unsigned rgb[3]
rgbtohsl(r,g,b,hsl)
hsltorgb(rgb,(hsl[0]+shift)%360,(hsl[1]+shifts)%1,(hsl[2]+shiftl)%1)
rgbToPalSetEntry(rgb[0],rgb[1],rgb[2],entry)
end
func rgbtohsl(unsigned r,unsigned g,unsigned b,double*hsl)
double R=r/255,G=g/255,B=b/255
double cmax=max(r,max(g,b))
double cmin=min(r,min(g,b))
double delta=cmax-cmin
if cmax==r
hsl[0]=(G-B)/delta%6*60 # Yes you can do module on double
eif cmax==g
hsl[0]=((B-R)/delta+2)*60
else
hsl[0]=((R-G)/delta+4)*60
end
hsl[2]=(cmax+cmin)/2
if delta
hsl[1]=delta/(1-fabs(2*hsl[2]-1))
else
hsl[1]=0
end
end
func hsltorgb(unsigned*rgb,double h,double l,double s)
double C=(1-fabs(2*l-1))*s
double X=(1-fabs(h/60%2-1))*C
double m=l-(C/2)
double R,G,B
if h>=300
R=C
G=0
B=X
eif h>=240
R=X
G=0
B=C
eif h>=180
R=0
G=X
B=C
eif h>=120
R=0
G=C
B=X
eif h>=60
R=X
G=C
B=0
else
R=C
G=X
B=0
end
rgb[0]=(R+m)*255
rgb[1]=(G+m)*255
rgb[2]=(B+m)*255
end
Code: Select all
# Sonic 1's level format based on information from the sonic retro wiki
type=level
gui bool loop # Upon running this a checkbox will be created on the level editor and for each element the boolean option loop will be stored in ram and in project files and when exporting this variable will be updated automatically storing the current element
begin main
which.max=127
askfile()
end
begin headerread
width=read1()+1
height=read1()+1
end
begin headerwrite
write1(width-1)
write1(height-1)
end
begin loopread
unsigned val=read1()
which=val.0_6
loop=val.7
end
begin loopwrite
write1u(which.0_6|(loop<<7))
end