Mercurial > hg > forks > pwpunix
changeset 54:85671798fdb3
Various code cleanups, cosmetics, warning fixes.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 26 May 2010 01:22:51 +0300 |
parents | f0c596c5905b |
children | 77f40a3c0095 |
files | pwplib/convert.h pwplib/gb.c pwplib/gb.h pwplib/pwplib-unix.c pwplib/pwplib-win.c pwplib/pwplib.h pwplib/setup.c pwplib/snd-hpux.c pwplib/snd-oss.c pwplib/snd-sdl.c pwplib/snd-w32.c pwplib/sound.h pwplib/tty.c pwplib/tty.h |
diffstat | 14 files changed, 227 insertions(+), 211 deletions(-) [+] |
line wrap: on
line diff
--- a/pwplib/convert.h Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/convert.h Wed May 26 01:22:51 2010 +0300 @@ -1,3 +1,6 @@ +#ifndef PWP_CONVERT_H +#define PWP_CONVERT_H + #include "pwplib.h" #ifndef __CONVERT_C @@ -15,4 +18,7 @@ u16 rasthalve[256*256]; void(*orig_dump_attr)(); -}pwpconv; +} pwpconv; + + +#endif /* PWP_CONVERT_H */
--- a/pwplib/gb.c Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/gb.c Wed May 26 01:22:51 2010 +0300 @@ -7,11 +7,7 @@ #ifdef DRIVE_GB -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #include <math.h> - #include "pwplib.h" struct { @@ -20,10 +16,11 @@ int wvleft; int wvphase; int wvlgt1; - }ch[3]; + } ch[3]; int freq; }pwpgb; + void gb_sound(int chan,int freq,int volume,int ratio) { if(volume&&freq){ @@ -45,11 +42,13 @@ void gb_init(int freq) { - pwpgb.freq=freq; - {int i=0;for(;i<3;i++)gb_sound(i,0,0,0);} + int i; + pwpgb.freq = freq; + for(i = 0; i < 3; i++) + gb_sound(i,0,0,0); } -static void gb_gen1chan(char*d,int l,int freq) +static void gb_gen1chan(u8 *d, int l, int freq) { int ph=128*256; while(l--){ @@ -60,7 +59,7 @@ #define CH pwpgb.ch -static void gb_beepemu(char*d,int l) +static void gb_beepemu(u8 *d, int l) { static int pf=0; int @@ -91,7 +90,7 @@ pf++; } -void gb_genwave(char*d,int l) +void gb_genwave(u8 *d, int l) { int remain=0;
--- a/pwplib/gb.h Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/gb.h Wed May 26 01:22:51 2010 +0300 @@ -2,9 +2,10 @@ #define PWP_GB_H 1 #include "config.h" +#include "pwplib.h" -void gb_sound(int chan,int freq,int volume,int ratio); +void gb_sound(int chan, int freq, int volume, int ratio); void gb_init(int freq); -void gb_genwave(char*d,int l); +void gb_genwave(u8 *d, int l); #endif /* PWP_GB_H */
--- a/pwplib/pwplib-unix.c Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/pwplib-unix.c Wed May 26 01:22:51 2010 +0300 @@ -160,7 +160,7 @@ #ifdef DRIVE_SDL if (!snd) { - if (sdl_init && pwp_sdlaudio_init()) + if (sdl_init && pwp_SDL_audio_init()) snd++; } #endif
--- a/pwplib/pwplib-win.c Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/pwplib-win.c Wed May 26 01:22:51 2010 +0300 @@ -12,6 +12,7 @@ #endif #include "pwplib.h" +#include "sound.h" static int sdl_init = 0; @@ -88,7 +89,7 @@ sdl_init = 0; SDL_Quit(); } - if (sdl_init && !pwp_sdlaudio_init()) + if (sdl_init && !pwp_SDL_audio_init()) { sdl_init = 0; SDL_Quit();
--- a/pwplib/pwplib.h Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/pwplib.h Wed May 26 01:22:51 2010 +0300 @@ -1,5 +1,5 @@ -#ifndef __PWPLIB_H -#define __PWPLIB_H +#ifndef PWP_PWPLIB_H +#define PWP_PWPLIB_H #define PWPLIB_VERSION "1.95" @@ -11,9 +11,15 @@ int pwplib_init(int argc,char**argv); int pwplib_timer(); -void pwplib_shutdown(); +void pwplib_shutdown(void); +int pwplib_init_common(void); void pwplib_startup(); +char * pwp_get_locale(); +void pwplib_dump_rast_plain(); +int pwp_timer_nrt(); +void pwplib_getopts(); +void pwplib_printhelp(); void pwplib_regdestr(void(*func)()); #define pwplib_buf pwplib.videobuf.d @@ -157,13 +163,12 @@ #endif void pwp_timer_regframe(int bytes); -typedef struct -{ +typedef struct { char *name; int type; void *dflt; void **var; -}optab; +} pwp_optab; #define OPT_BIN 0 #define OPT_NOT 1 @@ -177,10 +182,6 @@ #define STDOUT 1 #define STDERR 2 -char* pwp_get_locale(); -void pwplib_dump_rast_plain(); -int pwp_timer_nrt(); -void pwplib_getopts(); -void pwplib_printhelp(); + -#endif +#endif /* PWP_PWPLIB_H */
--- a/pwplib/setup.c Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/setup.c Wed May 26 01:22:51 2010 +0300 @@ -85,7 +85,7 @@ } } -void pwplib_shutdown() +void pwplib_shutdown(void) { int i = 0; while(pwp_destr[i]!=NULL) @@ -94,7 +94,7 @@ /******************** initialization *********************/ -int pwplib_init_common() +int pwplib_init_common(void) { /*** base stuff ***/ @@ -114,11 +114,11 @@ /***********************************************/ -static void rmarg(int*argc,char**argv,int n) +static void rmarg(int *argc, char *argv[], int n) { - while(n<*argc) + while (n < *argc) { - argv[n]=argv[n+1]; + argv[n] = argv[n + 1]; n++; } (*argc)--; @@ -128,43 +128,36 @@ #define ARGC pwplib.argc #define ARGV pwplib.argv -static void getopts(optab *argin) +static void getopts(pwp_optab *opts, const int nopts) { - int i=0; + int i; - {optab*s0=argin; - while(s0->name!=NULL) - { - *(s0->var)=s0->dflt; - s0++; - } - } + for (i = 0; i < nopts; i++) + *(opts[i].var) = opts[i].dflt; - for(i=0;i<ARGC;) + for (i = 0; i < ARGC;) { - int j=0; - - int match=0,wh=-1,lev=0; + int opt, match = 0, wh = -1, lev = 0; - while(argin[j].name!=NULL) + for (opt = 0; opt < nopts; opt++) { - char*s1=argin[j].name; - char*s0=ARGV[i]; - int ngl=0,m=0; + char *s1 = opts[opt].name; + char *s0 = ARGV[i]; + int ngl = 0, m = 0; - while(*s0) + while (*s0) { - if(*s0=='-') + if (*s0=='-') ngl=0; else - if(*s0=='+') + if (*s0=='+') ngl=1; else { m++; - if(*s0=='\0' || *s1=='\0')break; + if (*s0=='\0' || *s1=='\0')break; else - if((*s0|32)!=*s1) + if ((*s0|32) != *s1) { m=0; break; @@ -174,50 +167,49 @@ s0++; } - if(m>match) + if (m > match) { - match=m; - lev=ngl; - wh=j; + match = m; + lev = ngl; + wh = opt; } - j++; } - if(wh>=0) + if (wh >= 0) { - rmarg(&ARGC,ARGV,i); + rmarg(&ARGC, ARGV, i); - switch((int)argin[wh].type) + switch (opts[wh].type) { - case(OPT_BIN): - *((int*)(argin[wh].var))=lev; + case OPT_BIN: + *((int*)(opts[wh].var)) = lev; break; - case(OPT_NOT): - *((int*)(argin[wh].var))=1-lev; + case OPT_NOT: + *((int*)(opts[wh].var)) = 1 - lev; break; - case(OPT_ONE): - *((int*)(argin[wh].var))=1; + case OPT_ONE: + *((int*)(opts[wh].var))=1; - case(OPT_INT): - if(ARGV[i]!=NULL) + case OPT_INT: + if (ARGV[i] != NULL) { - *((int*)(argin[wh].var))=atoi(ARGV[i]); - rmarg(&ARGC,ARGV,i); + *((int*)(opts[wh].var)) = atoi(ARGV[i]); + rmarg(&ARGC, ARGV, i); } break; - case(OPT_STRING): - if(ARGV[i]!=NULL) + case OPT_STRING: + if (ARGV[i] != NULL) { - *((char**)(argin[wh].var))=strdup(ARGV[i]); - rmarg(&ARGC,&ARGV,1); + *((char**)(opts[wh].var)) = strdup(ARGV[i]); + rmarg(&ARGC, &ARGV, 1); } break; } - } - else i++; + } else + i++; } } #undef ARGC @@ -225,55 +217,55 @@ /************************************/ -static optab main_init[]= -{ - /* stuph */ - "help", OPT_ONE,(void*)0,(void*)&pwplib.setup[SETUP_WANTHELP], - "shutup", OPT_ONE,(void*)0,(void*)&pwplib.setup[SETUP_SHUTUP], - "infodelay",OPT_INT,(void*)100,(void*)&pwplib.set.infodelay, +static pwp_optab main_options[] = { + /* stuph */ + { "help", OPT_ONE, (void*)0, (void*)&pwplib.setup[SETUP_WANTHELP] }, + { "shutup", OPT_ONE, (void*)0, (void*)&pwplib.setup[SETUP_SHUTUP] }, + { "infodelay", OPT_INT, (void*)100, (void*)&pwplib.set.infodelay }, - /* general */ - "nosound",OPT_ONE,(void*)0,(void*)&pwplib.setup[SETUP_NOSOUND], - "novideo",OPT_ONE,(void*)0,(void*)&pwplib.setup[SETUP_NOVIDEO], + /* general */ + { "nosound", OPT_ONE, (void*)0, (void*)&pwplib.setup[SETUP_NOSOUND] }, + { "novideo", OPT_ONE, (void*)0, (void*)&pwplib.setup[SETUP_NOVIDEO] }, - /* video */ - "term", OPT_STRING,(void*)NULL,(void*)&pwplib.set.term, - "lang", OPT_STRING,(void*)NULL,(void*)&pwplib.set.lang, - "tty", OPT_BIN,(void*)0,(void*)&pwplib.setup[SETUP_TTY], /* obsolete? */ - "pvp", OPT_BIN,(void*)0,(void*)&pwplib.setup[SETUP_PVP], + /* video */ + { "term", OPT_STRING, (void*)NULL, (void*)&pwplib.set.term }, + { "lang", OPT_STRING, (void*)NULL, (void*)&pwplib.set.lang }, + { "tty", OPT_BIN, (void*)0, (void*)&pwplib.setup[SETUP_TTY] }, /* obsolete? */ + { "pvp", OPT_BIN, (void*)0, (void*)&pwplib.setup[SETUP_PVP] }, - /* size */ - "height", OPT_INT,(void*)0,(void*)&pwplib.setup[SETUP_USERHEIGHT], - "width", OPT_INT,(void*)0,(void*)&pwplib.setup[SETUP_USERWIDTH], + /* size */ + { "height", OPT_INT, (void*)0, (void*)&pwplib.setup[SETUP_USERHEIGHT] }, + { "width", OPT_INT, (void*)0, (void*)&pwplib.setup[SETUP_USERWIDTH] }, - /* conversion */ - "trans", OPT_INT,(void*)-1,(void*)&pwplib.setup[SETUP_TRANS], - "colors", OPT_INT,(void*)-1,(void*)&pwplib.setup[SETUP_COLORS], - "raster", OPT_INT,(void*)-1,(void*)&pwplib.setup[SETUP_RASTER], - "halve", OPT_BIN,(void*)1,(void*)&pwplib.setup[SETUP_HALVE], + /* conversion */ + { "trans", OPT_INT, (void*)-1, (void*)&pwplib.setup[SETUP_TRANS] }, + { "colors", OPT_INT, (void*)-1, (void*)&pwplib.setup[SETUP_COLORS] }, + { "raster", OPT_INT, (void*)-1, (void*)&pwplib.setup[SETUP_RASTER] }, + { "halve", OPT_BIN, (void*)1, (void*)&pwplib.setup[SETUP_HALVE] }, - /* tty-etc stuff */ - "fps", OPT_INT,(void*)0,(void*)&pwplib.setup[SETUP_FPS], - "bps", OPT_INT,(void*)0,(void*)&pwplib.setup[SETUP_BPS], - "minfps", OPT_INT,(void*)0,(void*)&pwplib.setup[SETUP_MINFPS], - "maxfps", OPT_INT,(void*)256,(void*)&pwplib.setup[SETUP_MAXFPS], - "lossy", OPT_BIN,(void*)0,(void*)&pwplib.setup[SETUP_LOSSY], - "fdelay", OPT_INT,(void*)0,(void*)&pwplib.set.framedelay, - "fbytes", OPT_INT,(void*)500,(void*)&pwplib.set.framebytes, + /* tty-etc stuff */ + { "fps", OPT_INT, (void*)0, (void*)&pwplib.setup[SETUP_FPS] }, + { "bps", OPT_INT, (void*)0, (void*)&pwplib.setup[SETUP_BPS] }, + { "minfps", OPT_INT, (void*)0, (void*)&pwplib.setup[SETUP_MINFPS] }, + { "maxfps", OPT_INT, (void*)256, (void*)&pwplib.setup[SETUP_MAXFPS] }, + { "lossy", OPT_BIN, (void*)0, (void*)&pwplib.setup[SETUP_LOSSY] }, + { "fdelay", OPT_INT, (void*)0, (void*)&pwplib.set.framedelay }, + { "fbytes", OPT_INT, (void*)500, (void*)&pwplib.set.framebytes }, /* audio options */ - "audev", OPT_STRING,(void*)NULL,(void*)&pwplib.set.audev, - "volume", OPT_INT,(void*)32,(void*)&pwplib.setup[SETUP_VOLUME], + { "audev", OPT_STRING, (void*)NULL, (void*)&pwplib.set.audev }, + { "volume", OPT_INT, (void*)32, (void*)&pwplib.setup[SETUP_VOLUME] }, #if (defined(DRIVE_SDL)) - "fs", OPT_ONE,(void*)0,(void*)&pwplib.setup[SETUP_FULLSCREEN], - "xres", OPT_INT,(void*)640,(void*)&pwplib.setup[SETUP_XRES], - "yres", OPT_INT,(void*)480,(void*)&pwplib.setup[SETUP_YRES], + /* Graphical output related */ + { "fs", OPT_ONE, (void*)0, (void*)&pwplib.setup[SETUP_FULLSCREEN] }, + { "xres", OPT_INT, (void*)640, (void*)&pwplib.setup[SETUP_XRES] }, + { "yres", OPT_INT, (void*)480, (void*)&pwplib.setup[SETUP_YRES] }, #endif - NULL,0,NULL,NULL }; + void pwplib_printhelp(void) { printf( @@ -333,9 +325,9 @@ void pwplib_getopts() { - getopts(main_init); + getopts(main_options, sizeof(main_options) / sizeof(main_options[0])); - if(pwplib.set.lang==NULL) - pwplib.set.lang=pwp_get_locale(); + if (pwplib.set.lang == NULL) + pwplib.set.lang = pwp_get_locale(); }
--- a/pwplib/snd-hpux.c Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/snd-hpux.c Wed May 26 01:22:51 2010 +0300 @@ -8,58 +8,53 @@ #include <fcntl.h> #include <sys/audio.h> - -#include "pwplib.h" +#include "sound.h" -#define TIMERHZ 72 - -struct{ +struct { int fd; char buf[4096]; int buflgt; int freq; -}pwp_hpuxsnd; +} pwp_hpuxsnd; -extern void gb_sound(int,int,int,int); - -void hpuxsnd_loopflush() +static void hpuxsnd_loopflush(void) { for(;;) { struct audio_status bi; - ioctl(pwp_hpuxsnd.fd,AUDIO_GET_STATUS,&bi); - if(bi.transmit_exact_count>3000)break; + ioctl(pwp_hpuxsnd.fd, AUDIO_GET_STATUS, &bi); + if (bi.transmit_exact_count > 3000)break; pwplib.player(); - gb_genwave(pwp_hpuxsnd.buf,pwp_hpuxsnd.buflgt); - write(pwp_hpuxsnd.fd,pwp_hpuxsnd.buf,pwp_hpuxsnd.buflgt); + gb_genwave(pwp_hpuxsnd.buf, pwp_hpuxsnd.buflgt); + write(pwp_hpuxsnd.fd, pwp_hpuxsnd.buf, pwp_hpuxsnd.buflgt); - if(bi.transmit_buffer_count>6000)break; + if (bi.transmit_buffer_count > 6000) break; } } -void hpuxsnd_restore() +static void hpuxsnd_restore(void) { close(pwp_hpuxsnd.fd); } -int hpuxsnd_init() +int hpuxsnd_init(void) { - pwp_hpuxsnd.fd=open("/dev/audio",O_WRONLY); + pwp_hpuxsnd.fd = open("/dev/audio",O_WRONLY); if(pwp_hpuxsnd.fd<0)return 0; - ioctl(pwp_hpuxsnd.fd,AUDIO_SET_TXBUFSIZE,2048); - ioctl(pwp_hpuxsnd.fd,AUDIO_SET_SAMPLE_RATE,8000); - ioctl(pwp_hpuxsnd.fd,AUDIO_SET_CHANNELS,AUDIO_CHANNEL_0|AUDIO_CHANNEL_1); - ioctl(pwp_hpuxsnd.fd,AUDIO_SET_DATA_FORMAT,AUDIO_FORMAT_LINEAR8BIT); + pwp_hpuxsnd.freq = 8000; + pwp_hpuxsnd.buflgt = pwp_hpuxsnd.freq / TIMERHZ; + + ioctl(pwp_hpuxsnd.fd, AUDIO_SET_TXBUFSIZE, 2048); + ioctl(pwp_hpuxsnd.fd, AUDIO_SET_SAMPLE_RATE, pwp_hpuxsnd.freq); + ioctl(pwp_hpuxsnd.fd, AUDIO_SET_CHANNELS, AUDIO_CHANNEL_0|AUDIO_CHANNEL_1); + ioctl(pwp_hpuxsnd.fd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_LINEAR8BIT); pwpwrite("* HP-UX sound\n"); - pwp_hpuxsnd.freq=8000; - pwp_hpuxsnd.buflgt=pwp_hpuxsnd.freq/TIMERHZ; - - pwplib.sound=gb_sound; - pwplib.loopflush=hpuxsnd_loopflush; + pwplib.sound = gb_sound; + pwplib.loopflush = hpuxsnd_loopflush; gb_init(pwp_hpuxsnd.freq); pwplib_regdestr(hpuxsnd_restore);
--- a/pwplib/snd-oss.c Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/snd-oss.c Wed May 26 01:22:51 2010 +0300 @@ -8,52 +8,52 @@ #include <fcntl.h> #include <linux/soundcard.h> - -#include "pwplib.h" -#include "gb.h" +#include "sound.h" -#define TIMERHZ 72 - -struct{ +struct { int fd; char buf[4096]; int buflgt; int freq; -}pwp_oss; +} pwp_oss; -void oss_loopflush() +static void oss_loopflush() { for(;;) - {audio_buf_info bi;ioctl(pwp_oss.fd,SNDCTL_DSP_GETOSPACE,&bi); - if(bi.fragments==1)break; + { + audio_buf_info bi; + ioctl(pwp_oss.fd, SNDCTL_DSP_GETOSPACE, &bi); + if (bi.fragments == 1) break; pwplib.player(); - gb_genwave(pwp_oss.buf,pwp_oss.buflgt); - write(pwp_oss.fd,pwp_oss.buf,pwp_oss.buflgt); - if(bi.fragments<3)break; + gb_genwave(pwp_oss.buf, pwp_oss.buflgt); + write(pwp_oss.fd, pwp_oss.buf, pwp_oss.buflgt); + if (bi.fragments < 3) break; } } -void oss_restore() +static void oss_restore() { close(pwp_oss.fd); } -int oss_init() +int oss_init(void) { - pwp_oss.fd=open("/dev/dsp",O_WRONLY); - if(pwp_oss.fd<0)return 0; + pwp_oss.fd = open("/dev/dsp", O_WRONLY); + if (pwp_oss.fd < 0) + return 0; pwpwrite("* OSS sound\n"); - pwp_oss.freq=8000; - pwp_oss.buflgt=pwp_oss.freq/TIMERHZ; + pwp_oss.freq = 8000; + pwp_oss.buflgt = pwp_oss.freq/TIMERHZ; - pwplib.sound=gb_sound; - pwplib.loopflush=oss_loopflush; + pwplib.sound = gb_sound; + pwplib.loopflush = oss_loopflush; gb_init(pwp_oss.freq); pwplib_regdestr(oss_restore); return 1; } + #endif
--- a/pwplib/snd-sdl.c Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/snd-sdl.c Wed May 26 01:22:51 2010 +0300 @@ -10,46 +10,40 @@ #ifdef DRIVE_SDL -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> +#include "sound.h" #include <SDL.h> -#include "pwplib.h" -#include "gb.h" - -#define TIMERHZ 72 - -static int pwp_sdlaudio_run = 1; -static int pwp_sdlaudio_frag = -1, pwp_sdlaudio_curr; +static int pwp_SDL_audio_run = 1; +static int pwp_SDL_audio_frag = -1, pwp_SDL_audio_curr; -static void pwp_sdlaudio_fill(void * udata, Uint8 * buf, int len) +static void pwp_SDL_audio_fill(void * udata, Uint8 * buf, int len) { (void) udata; while (len > 0) { - if (pwp_sdlaudio_curr >= len) { - pwp_sdlaudio_curr -= len; + if (pwp_SDL_audio_curr >= len) { + pwp_SDL_audio_curr -= len; gb_genwave(buf, len); len = 0; } else { - gb_genwave(buf, pwp_sdlaudio_curr); - buf += pwp_sdlaudio_curr; - len -= pwp_sdlaudio_curr; - pwp_sdlaudio_curr = pwp_sdlaudio_frag; + gb_genwave(buf, pwp_SDL_audio_curr); + buf += pwp_SDL_audio_curr; + len -= pwp_SDL_audio_curr; + pwp_SDL_audio_curr = pwp_SDL_audio_frag; pwplib.player(); } } + + pwp_SDL_audio_run = 0; } -static void pwp_sdlaudio_start(void) +static void pwp_SDL_audio_start(void) { - if (pwp_sdlaudio_run) { - pwp_sdlaudio_curr = pwp_sdlaudio_frag; - pwp_sdlaudio_run = 0; - pwplib.player(); + if (pwp_SDL_audio_run) SDL_PauseAudio(0); - } + + while (pwp_SDL_audio_run) + SDL_Delay(10); /* NOTICE! A small delay is used here, because the prods using pwplib * run in a tight loop (they expect that audio rendering blocks, @@ -61,17 +55,17 @@ SDL_Delay(10); } -int pwp_sdlaudio_init() +int pwp_SDL_audio_init(void) { SDL_AudioSpec fmt; - pwp_sdlaudio_run = 1; + pwp_SDL_audio_run = 1; fmt.freq = 44100; fmt.format = AUDIO_U8; fmt.channels = 1; fmt.samples = 512; - fmt.callback = pwp_sdlaudio_fill; + fmt.callback = pwp_SDL_audio_fill; if (SDL_OpenAudio(&fmt, NULL) < 0) { @@ -79,13 +73,15 @@ return 0; } - pwp_sdlaudio_frag = fmt.freq / TIMERHZ; + pwp_SDL_audio_frag = fmt.freq / TIMERHZ; + pwp_SDL_audio_curr = pwp_SDL_audio_frag; + pwp_SDL_audio_run = 1; pwpwrite("* SDL sound (freq=%d, fmt=%d, chn=%d, buf=%d, frag=%d)\n", - fmt.freq, fmt.format, fmt.channels, fmt.samples, pwp_sdlaudio_frag); + fmt.freq, fmt.format, fmt.channels, fmt.samples, pwp_SDL_audio_frag); pwplib.sound = gb_sound; - pwplib.loopflush = pwp_sdlaudio_start; + pwplib.loopflush = pwp_SDL_audio_start; gb_init(fmt.freq); return 1;
--- a/pwplib/snd-w32.c Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/snd-w32.c Wed May 26 01:22:51 2010 +0300 @@ -5,20 +5,14 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> - #include <windows.h> -#define TIMERHZ 72 - -#include "pwplib.h" -#include "gb.h" +#include "sound.h" #define NUMBUFS 2 - #define HARDBUFSIZE 65536 -struct -{ +struct { int buffersize; HWAVEOUT outHandle; WAVEHDR waveHdr[NUMBUFS]; @@ -26,12 +20,12 @@ int currbuf; int bufferptr; int letsgo; -} -pwp_w32snd; +} pwp_w32snd; + -void win32snd_fill() +static void win32snd_fill(void) { - while(pwp_w32snd.bufferptr<(HARDBUFSIZE-pwp_w32snd.buffersize)) + while (pwp_w32snd.bufferptr < (HARDBUFSIZE - pwp_w32snd.buffersize)) { pwplib.player(); @@ -76,11 +70,11 @@ win32snd_fill(); } -void win32snd_restore() +static void win32snd_restore() { } -void win32snd_start() +static void win32snd_start() { if(pwp_w32snd.letsgo==0) { @@ -92,7 +86,7 @@ } } -int win32snd_init() +int win32snd_init(void) { HANDLE bufHandle,waveHdrHandle; WAVEFORMATEX waveFormat;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pwplib/sound.h Wed May 26 01:22:51 2010 +0300 @@ -0,0 +1,26 @@ +#ifndef PWP_SOUND_H +#define PWP_SOUND_H + +#include "config.h" +#include "pwplib.h" +#include "gb.h" + +#define TIMERHZ 72 + +#ifdef DRIVE_SDL +int pwp_SDL_audio_init(void); +#endif + +#ifdef DRIVE_OSS +int oss_init(void); +#endif + +#ifdef DRIVE_HPUX +int hpuxsnd_init(void); +#endif + +#ifdef DRIVE_WIN32 +int win32snd_init(void) +#endif + +#endif /* PWP_SOUND_H */ \ No newline at end of file
--- a/pwplib/tty.c Wed May 26 00:42:25 2010 +0300 +++ b/pwplib/tty.c Wed May 26 01:22:51 2010 +0300 @@ -68,7 +68,7 @@ tty_init_termios(); - memset((void*)&fdset,0,sizeof(fd_set)); + memset(&fdset, 0, sizeof(fd_set)); FD_SET(0,&fdset); timeout.tv_sec=0; timeout.tv_usec=250000; @@ -208,7 +208,7 @@ { #ifdef HAVE_TTYSTUFF - int colors=2,chars=2,rasters=1; + /* int colors=2,chars=2,rasters=1; */ pwp_tty.fd=2; /* stderr */ @@ -227,7 +227,7 @@ pwpwrite("* terminal on stdout: "); - switch((int)pwp_tty.type) + switch(pwp_tty.type) { case(TTY_DUMB): pwpwrite("dumb or unsupported\n");