int snd_init_firmware(const char *filename) { file_t f; size_t sz; uint8 *buff; f = fs_open(filename, O_RDONLY); if(f < 0) { ds_printf("DS_ERROR: Can't open firmware %s\n", filename); return -1; } sz = fs_total(f); ds_printf("DS_PROCESS: Loading firmware %s (%d bytes) into SPU RAM\n", filename, sz); buff = (uint8*)malloc(sz); fs_read(f, buff, sz); fs_close(f); spu_disable(); spu_memset(0, 0, AICA_RAM_START); spu_memload(0, buff, sz); /* Enable the AICA and give it a few ms to start up */ spu_enable(); timer_spin_sleep(10); /* Initialize the RAM allocator */ snd_mem_init(AICA_RAM_START); return 0; }
/* Initialize driver; note that this replaces the AICA program so that if you had anything else going on, it's gone now! */ int snd_init() { int amt; /* Finish loading the stream driver */ if (!initted) { spu_disable(); spu_memset(0, 0, AICA_RAM_START); amt = snd_stream_drv_end - snd_stream_drv; if (amt % 4) amt = (amt + 4) & ~3; printf("snd_init(): loading %d bytes into SPU RAM\n", amt); spu_memload(0, snd_stream_drv, amt); /* Enable the AICA and give it a few ms to start up */ spu_enable(); timer_spin_sleep(10); /* Initialize the RAM allocator */ snd_mem_init(AICA_RAM_START); /* Setup semaphores */ sem_qram = sem_create(1); } initted = 1; return 0; }