Index: config.doc ================================================================== --- config.doc +++ config.doc @@ -33,18 +33,24 @@ people do not like that tuning, so you can change it. This setting only affects 24-TET sounds, and not overtone-based sounds. .audio.mmlVolume MML volume, from 0 to 1; fractions are allowed. The default value is - approximately one third. + approximately one third. Set it to zero to disable MML sounds. .audio.rate Sample rate to use for audio, in hertz. In order for audio to work at all, this value must be set. +.audio.standardSounds + The name of the Hamster archive file containing the standard sounds. If + not specified, then the standard sounds won't work. + .audio.waveVolume Wave volume, from 0 to 1; fractions are allowed. The default value is 1. + If this is zero, then it will not load any sound effects, but MML sounds + will still work (if .audio.buffer and .audio.rate are set correctly). .autoSave If true, saves changes to the level and solution files when the program terminates. If false (default), they are only saved to the user cache database; to copy the changes to the level and solution files, you must Index: sound.c ================================================================== --- sound.c +++ sound.c @@ -12,10 +12,12 @@ #include "smallxrm.h" #include "quarks.h" #include "heromesh.h" #include "cursorshapes.h" +#define N_STANDARD_SOUNDS 50 + typedef struct { Uint8*data; Uint32 len; // length in bytes } WaveSound; @@ -169,12 +171,15 @@ } else { optionquery[2]=Q_standardSounds; v=xrm_get_resource(resourcedb,optionquery,optionquery,3); if(!v) return; fp=fopen(v,"r"); - if(!fp) fatal("Cannot open standard sounds file (%m)\n"); - nstandardsounds=50; + if(!fp) { + fprintf(stderr,"Cannot open standard sounds file (%m)\n"); + return; + } + nstandardsounds=N_STANDARD_SOUNDS+N_MESSAGES; standardsounds=malloc(nstandardsounds*sizeof(WaveSound)); if(!standardsounds) fatal("Allocation failed\n"); for(i=0;idata=0; ws->len=0; } else { - //TODO: Implement standard sounds. + for(i=0;idata) goto notfound; } if(j=='A') { load_sound(fp,l_offset,l_size,ws); } else { //TODO: Compressed sounds. } } + notfound: fseek(fp,l_offset+l_size,SEEK_SET); } done: fclose(fp); free(nam); @@ -250,11 +264,11 @@ wavevolume=strtod(v,0); } optionquery[2]=Q_mmlVolume; if(v=xrm_get_resource(resourcedb,optionquery,optionquery,3)) mmlvolume=fmin(strtod(v,0)*32767.0,32767.0); if(wavevolume>0.00001) { - //load_sound_set(0); // Standard sounds + load_sound_set(0); // Standard sounds load_sound_set(1); // User sounds } if(mmlvolume) { mmltuning=malloc(256*sizeof(Uint32)); if(!mmltuning) fatal("Allocation failed\n"); @@ -339,10 +353,13 @@ if(!v2.t && !v2.u && (mmlpos || wavesound)) return; SDL_LockAudio(); wavesound=0; mmlpos=0; switch(v1.t) { + case TY_MESSAGE: + v1.u+=N_STANDARD_SOUNDS; + //fallthrough case TY_SOUND: if(v1.uw-16)/240?:1; scrmax=(nitems+columns-1)/columns; set_cursor(XC_arrow); redraw: SDL_FillRect(screen,0,0x02); @@ -408,12 +425,12 @@ draw_text(0,0," Mute Stop Status Cancel",0xF7,0xF0); if(SDL_GetAudioStatus()==SDL_AUDIO_PLAYING) draw_text(0,0,"\x0E",0xF7,0xF1); for(i=scroll*columns,x=0,y=8;iscreen->h-24) break; if(ih-8; - scrollbar(&scroll,screen->h/8-1,scrmax,0,&r); + scrollbar(&scroll,screen->h/24-1,scrmax,0,&r); SDL_Flip(screen); while(SDL_WaitEvent(&ev)) { - if(ev.type!=SDL_VIDEOEXPOSE && scrollbar(&scroll,screen->h/8-1,scrmax,&ev,&r)) goto redraw; + if(ev.type!=SDL_VIDEOEXPOSE && scrollbar(&scroll,screen->h/24-1,scrmax,&ev,&r)) goto redraw; switch(ev.type) { case SDL_MOUSEMOTION: x=ev.button.x-16; y=ev.button.y-8; if(x<0 || y<0) goto arrow; i=x/240+columns*(y/24); x%=240; y%=24; @@ -442,15 +459,20 @@ arrow: set_cursor(XC_arrow); break; case SDL_MOUSEBUTTONDOWN: x=ev.button.x-16; y=ev.button.y-8; if(x<0 || y<0) break; - i=x/240+columns*(y/24); x%=240; y%=24; + i=x/240+columns*(y/24)+scroll*columns; x%=240; y%=24; if(x<4 || x>236 || y<4 || y>20 || i<0 || i>=nitems) break; if(i