def title	"KRChipUISFX"
def version	"1.0.0"
def description	"Kobo Redux Chip Sound Theme - UI"
def author	"David Olofson"
def copyright	"Copyright 2016 David Olofson"
def license	"GPL"
def a2sversion	"1.9.1"

export S_UI_OPEN()
{
	struct { wtosc }
	w triangle
	@p -3
	a 1
	10 {
		+p .15
		d 10
	}
	a 0; d 50
}

export S_UI_OK()
{
	struct { wtosc }
	w triangle
	@p .5
	a 1
	15 {
		-p .3
		d 10
	}
	a 0; d 100
}

export S_UI_MOVE()
{
	struct { wtosc }
	w square
	@p 4;	@a .03
	p 4;	a 0;	d 5
	w noise
	@p 0;
	p 1;	a .005;	d 100
	p 0;	a 0;	d 200
}

export S_UI_TICK()
{
	struct { wtosc }
	w square
	@p 3
	@a .1;	d 10
	@a 0
}

export S_UI_CDTICK(P V=1)
{
	struct { wtosc }
	+tr P
	w pulse10
	a (V * .2); set a
	@p 0; d 10
	@p 1; d 10
	@p 2; d 10
	@p 3; d 10
	100 {
		*a .8; d 10
	}
	a 0; d 10
}

export S_UI_GAMEOVER()
{
	struct { wtosc }
	w pulse10
	a .4
	@p 0
	p -3; d 2000
	a 0; d 10
}

export S_UI_READY()
{
	struct { wtosc }
	tempo 120 32
	w triangle
	a .2
	tr -1
	15 {
		@p 0n;	td 1
		@p 4n;	td 1
		@p 7n;	td 1
		@p 4n;	td 1
		+tr 1n
		+a .025
	}
	-tr 1n
	10 {
		*a .5
		3 {
			@p 0n;	td 1
			@p 4n;	td 1
			@p 7n;	td 1
			@p 4n;	td 1
		}
	}
	a 0
	d 20
}

export S_UI_PLAY()
{
	struct { wtosc }
	tempo 120 16
	w saw
	a .2
	tr 0
	3 {
		@p 0;	td 1
		@p 4n;	td 1
		@p 7n;	td 1
		@p 4n;	td 1
		+tr 1
	}
	-tr 1
	5 {
		*a .25
		@p 0;	td 1
		@p 4n;	td 1
		@p 7n;	td 1
		@p 4n;	td 1
	}
	a 0
	d 20
}

export S_UI_PAUSE()
{
	struct { wtosc }
	tempo 120 16
	w saw
	a .05
	tr 2
	2 {
		@p 4n;	td 1
		@p 7n;	td 1
		@p 4n;	td 1
		@p 0;	td 1
		+a .05
	}
	a .2
	3 {
		-tr 1
		@p 4n;	td 1
		@p 7n;	td 1
		@p 4n;	td 1
		@p 0;	td 1
	}
	-tr 1
	a 0
	d 20
}

export S_UI_CANCEL()
{
	struct { wtosc }
	w triangle
	5 {
		@p 1; a .35;	d 10
		@p 0; a 0;	d 10
	}
}

export S_UI_ERROR()
{
	struct { wtosc }
	w square
	10 {
		@p 2.5; @a .15;	d 10
		@p 1.5; a 0;	d 10
	}
}

export S_UI_LOADER()
{
	struct { wtosc }
	w square; a .02
	for {
		if (rand 1 > .5) {
			@p 2400f
		} else {
			@p 1200f
		}
		d (1000 / 600)
	}
.stop
	a 0; d 1

	1() {
		force stop
	}
}

export S_UI_NOISE()
{
	struct { wtosc }
	w noise; @p 4
	!running 1
	while running {
		@a .1; a 0;	d 10
				d 10
	}

	1() {
		running 0
	}
}
