summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c200
1 files changed, 100 insertions, 100 deletions
diff --git a/src/main.c b/src/main.c
index 0ae2aab..7a91952 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,65 +54,65 @@
#define NUM_SOUNDS 2
struct sample {
- Uint8 *data;
- Uint32 dpos;
- Uint32 dlen;
+ Uint8 *data;
+ Uint32 dpos;
+ Uint32 dlen;
} sounds[NUM_SOUNDS];
void mixaudio(void *unused, Uint8 *stream, int len)
{
- int i;
- Uint32 amount;
-
- for ( i=0; i<NUM_SOUNDS; ++i ) {
- amount = (sounds[i].dlen-sounds[i].dpos);
- if ( amount > len ) {
- amount = len;
- }
- SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME);
- sounds[i].dpos += amount;
- }
+ int i;
+ Uint32 amount;
+
+ for ( i=0; i<NUM_SOUNDS; ++i ) {
+ amount = (sounds[i].dlen-sounds[i].dpos);
+ if ( amount > len ) {
+ amount = len;
+ }
+ SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME);
+ sounds[i].dpos += amount;
+ }
}
void play_sound(char *file)
{
- int index;
- SDL_AudioSpec wave;
- Uint8 *data;
- Uint32 dlen;
- SDL_AudioCVT cvt;
-
- /* Look for an empty (or finished) sound slot */
- for ( index=0; index<NUM_SOUNDS; ++index ) {
- if ( sounds[index].dpos == sounds[index].dlen ) {
- break;
- }
- }
- if ( index == NUM_SOUNDS )
- return;
-
- /* Load the sound file and convert it to 16-bit stereo at 22kHz */
- if ( SDL_LoadWAV(file, &wave, &data, &dlen) == NULL ) {
- fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
- return;
- }
- SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
- AUDIO_S16, 2, 22050);
- cvt.buf = malloc(dlen*cvt.len_mult);
- memcpy(cvt.buf, data, dlen);
- cvt.len = dlen;
- SDL_ConvertAudio(&cvt);
- SDL_FreeWAV(data);
-
- /* Put the sound data in the slot (it starts playing immediately) */
- if ( sounds[index].data ) {
- free(sounds[index].data);
- }
- SDL_LockAudio();
- sounds[index].data = cvt.buf;
- sounds[index].dlen = cvt.len_cvt;
- sounds[index].dpos = 0;
- SDL_UnlockAudio();
+ int index;
+ SDL_AudioSpec wave;
+ Uint8 *data;
+ Uint32 dlen;
+ SDL_AudioCVT cvt;
+
+ /* Look for an empty (or finished) sound slot */
+ for ( index=0; index<NUM_SOUNDS; ++index ) {
+ if ( sounds[index].dpos == sounds[index].dlen ) {
+ break;
+ }
+ }
+ if ( index == NUM_SOUNDS )
+ return;
+
+ /* Load the sound file and convert it to 16-bit stereo at 22kHz */
+ if ( SDL_LoadWAV(file, &wave, &data, &dlen) == NULL ) {
+ fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
+ return;
+ }
+ SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
+ AUDIO_S16, 2, 22050);
+ cvt.buf = malloc(dlen*cvt.len_mult);
+ memcpy(cvt.buf, data, dlen);
+ cvt.len = dlen;
+ SDL_ConvertAudio(&cvt);
+ SDL_FreeWAV(data);
+
+ /* Put the sound data in the slot (it starts playing immediately) */
+ if ( sounds[index].data ) {
+ free(sounds[index].data);
+ }
+ SDL_LockAudio();
+ sounds[index].data = cvt.buf;
+ sounds[index].dlen = cvt.len_cvt;
+ sounds[index].dpos = 0;
+ SDL_UnlockAudio();
}
static const char *it_msg =
@@ -1195,7 +1195,7 @@ int main(int argc, char *argv[])
pixel *load_img=NULL;//, *fbi_img=NULL;
int save_mode=0, save_x=0, save_y=0, save_w=0, save_h=0, copy_mode=0;
GSPEED = 1;
-
+
SDL_AudioSpec fmt;
/* Set 16-bit stereo audio at 22Khz */
fmt.freq = 22050;
@@ -2239,10 +2239,10 @@ int main(int argc, char *argv[])
else if (y<YRES)
{
int signi;
-
+
c = (b&1) ? sl : sr;
su = c;
-
+
if(c!=WL_SIGN+100)
{
if(!bq)
@@ -2255,12 +2255,12 @@ int main(int argc, char *argv[])
{
char buff[256];
int sldr;
-
+
memset(buff, 0, sizeof(buff));
-
+
for(sldr=3; signs[signi].text[sldr] != '|'; sldr++)
buff[sldr-3] = signs[signi].text[sldr];
-
+
char buff2[sldr-2]; //TODO: Fix this for Visual Studio
memset(buff2, 0, sizeof(buff2));
memcpy(&buff2, &buff, sldr-3);
@@ -2268,7 +2268,7 @@ int main(int argc, char *argv[])
}
}
}
-
+
if (c==WL_SIGN+100)
{
if (!bq)
@@ -2596,7 +2596,7 @@ int main(int argc, char *argv[])
if(DEBUG_MODE)
{
fillrect(vid_buf, XRES-20-textwidth(coordtext), 26, textwidth(coordtext)+8, 11, 0, 0, 0, 140);
- drawtext(vid_buf, XRES-16-textwidth(coordtext), 27, coordtext, 255, 255, 255, 200);
+ drawtext(vid_buf, XRES-16-textwidth(coordtext), 27, coordtext, 255, 255, 255, 200);
}
}
fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, 140);
@@ -2684,7 +2684,7 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
else if (strcmp(console2, "create")==0 && console3 && console4)
{
if (console_parse_type(console3, &j, console_error)
- && console_parse_coords(console4, &nx, &ny, console_error))
+ && console_parse_coords(console4, &nx, &ny, console_error))
{
if (!j)
strcpy(console_error, "Cannot create particle with type NONE");
@@ -2755,10 +2755,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].life = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].life = k;
+ }
}
else
{
@@ -2781,18 +2781,18 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
}
}
else if (console_parse_type(console4, &j, console_error)
- && console_parse_type(console5, &k, console_error))
+ && console_parse_type(console5, &k, console_error))
{
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].type = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].type = k;
+ }
}
else
{
if (console_parse_partref(console4, &i, console_error)
- && console_parse_type(console5, &j, console_error))
+ && console_parse_type(console5, &j, console_error))
{
parts[i].type = j;
}
@@ -2813,10 +2813,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].temp= k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].temp= k;
+ }
}
else
{
@@ -2842,10 +2842,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].tmp = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].tmp = k;
+ }
}
else
{
@@ -2871,10 +2871,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].x = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].x = k;
+ }
}
else
{
@@ -2900,10 +2900,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].y = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].y = k;
+ }
}
else
{
@@ -2926,18 +2926,18 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
}
}
else if (console_parse_type(console4, &j, console_error)
- && console_parse_type(console5, &k, console_error))
+ && console_parse_type(console5, &k, console_error))
{
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].ctype = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].ctype = k;
+ }
}
else
{
if (console_parse_partref(console4, &i, console_error)
- && console_parse_type(console5, &j, console_error))
+ && console_parse_type(console5, &j, console_error))
{
parts[i].ctype = j;
}
@@ -2958,10 +2958,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].vx = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].vx = k;
+ }
}
else
{
@@ -2987,10 +2987,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].vy = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].vy = k;
+ }
}
else
{