/*
Copyright (c) 2007-2013, John Ryland
*/
#include <corelayer.h>
#include <sound.h>


void soundTest()
{
    int fd = openSound();
    playSoundFile(fd, "sounds/listmove.wav");
    closeSound(fd);
}


int readHexStr(const char *arg)
{
    int ret = 0;
    int i = 0;
    const char *STR = "0123456789ABCDEFG";
    const char *str = "0123456789abcdefg";
    while (arg[i]) {
	int j;
	int t = 0;
	for (j = 0; j < 16; j++) {
	    if (arg[i] == str[j] || arg[i] == STR[j])
		t = j;
	}
	ret <<= 4;
	ret += t;
	i++;
    }
    return ret;
}


int main(int argc, char *argv[])
{
    int i;
    strPrint("SONY mylo audio test\n");
    strPrint("Version 0.02\n");
    strPrint("Copyright 2007 John Ryland\n");

    if ( argc > 1 ) {
	int i = readHexStr(argv[1]);
	strPrintf("setting volume to: %x (%s)\n", i, argv[1]);
	setVolume(i);
    }
    soundTest();

/*
    for (i = 0; i < 65536; i+=7) {
	strPrintf("setting volume to: %x\n", i<<10);
	setVolume(i);
        soundTest();
    }
*/
    return 0;
}

