HANDLE CreateWaveOutThread(void){ WAVEFORMATEX wf = { WAVE_FORMAT_PCM, //WORD wFormatTag; 2, //WORD nChannels; SAMPLERATE, //DWORD nSamplesPerSec; SAMPLERATE * 2 * SAMPLEBITS / 8, //DWORD nAvgBytesPerSec; 2 * SAMPLEBITS / 8, //WORD nBlockAlign; SAMPLEBITS, //WORD wBitsPerSample; 0, //WORD cbSize; }; MMRESULT mmr; DWORD dw; HANDLE ret; // return NULL; /* BYTE buffer[128]; int i; for(i = 0; i < numof(buffer); i++) buffer[i] = i < numof(buffer) / 2 ? 255 : 0; // buffer[i] = i * 4 <= 255 ? i * 4 : 255 - i * 4 % 256; WAVEHDR wh;*/ InitializeCriticalSection(&gcs); ret = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WaveOutThread, &hwo, 0, &dw); mmr = waveOutOpen(&hwo, WAVE_MAPPER, &wf, dw, (DWORD)&hwo, CALLBACK_THREAD); // waveOutOpen(&hwo, WAVE_MAPPER, &wf, (DWORD)WaveOutPoster, (DWORD)pc, CALLBACK_FUNCTION); // waveOutOpen(&hwo, WAVE_MAPPER, &wf, (DWORD)pc->w, (DWORD)pc, CALLBACK_WINDOW); /* wh.lpData = (LPSTR)buffer; wh.dwBufferLength = sizeof buffer; wh.dwFlags = 0; waveOutPrepareHeader(hwo, &wh, sizeof(WAVEHDR)); wh.dwFlags |= WHDR_BEGINLOOP | WHDR_ENDLOOP; wh.dwLoops = 100; waveOutWrite(hwo, &wh, sizeof(WAVEHDR));*/ if(mmr == MMSYSERR_NOERROR){ int k; initsound(soundbuf[0]); initsound(soundbuf[1]); TimeMeasStart(&tmwo); // memset(soundbuf, 0x80, sizeof soundbuf); for(k = 0; k < 2; k++){ whs[k].lpData = (LPSTR)soundbuf[k]; whs[k].dwBufferLength = sizeof soundbuf[k]; whs[k].dwFlags = 0; waveOutPrepareHeader(hwo, &whs[k], sizeof(WAVEHDR)); whs[k].dwFlags |= WHDR_BEGINLOOP | WHDR_ENDLOOP; whs[k].dwLoops = 1; } waveOutWrite(hwo, &whs[0], sizeof(WAVEHDR)); waveOutWrite(hwo, &whs[1], sizeof(WAVEHDR)); } else hwo = NULL; return ret; }
void maininit(void) { calibrate(); ginit(); gpal(0); setretr(true); initkeyb(); detectjoy(); inir(); initsound(); recstart(); }
void initialize(){ puts("initialize"); MDFNGameInfo = &EmulatedPCE; // MDFNI_LoadGame("m:\\pce roms\\leg.pce"); // pcejin.started = true; // pcejin.romLoaded = true; initespec(); initsound(); }
void initialize(){ puts("initialize"); MDFNGameInfo = &EmulatedVB; vbjinInit(); // MDFNI_LoadGame(NULL,"c:\\wario.vb"); // pcejin.started = true; // pcejin.romLoaded = true; initespec(); initsound(); }
void maininit(void) { static int maininited = 0; if (maininited != 0) { return; } calibrate(); ddap->ginit(); ddap->gpal(0); setretr(true); initkeyb(); detectjoy(); inir(); initsound(); recstart(); maininited = 1; }
int main (int argc, char* argv[]) { int done=0; SDL_Event event; fullscreen=0; sdlglinit(640,480,BPP,fullscreen); initsound(); ourinit(); oursoundinit(); resetobjects(); while(!done) { while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_VIDEORESIZE: surface=SDL_SetVideoMode(event.resize.w,event.resize.h,BPP,videoflags); if(!surface) error("Couldn't get surface after resize: %s\n",SDL_GetError()); initgl(); /* after setting video mode, we lost every gl setting. set again. */ resizeglscene(event.resize.w,event.resize.h); break; case SDL_KEYDOWN: keys[event.key.keysym.sym]=1; handlekeypress(&event.key.keysym); break; case SDL_KEYUP: keys[event.key.keysym.sym]=0; break; case SDL_QUIT: goto theend; } } /* check for held keys */ heldkeys(); dostuff(); drawglscene(); SDL_Delay(1000/70.0); } theend: shutdownsound(); killglwindow(); return 0; }
void main() {initsound();readsong("music",song);playsong(-1,song); register int temp;rec3d startpagerec;stick3d titlestick; sks key; char3d title;hz3d prognam; init();mx=getmaxx();my=getmaxy();setbkcolor(0);If=Fpmk;Of=Fc; startpagerec.x1=startpagerec.y1=5;startpagerec.x2=mx-5;startpagerec.y2=my-100;startpagerec.widtho=startpagerec.heighto=10;startpagerec.widthm=10;startpagerec.heightm=15;startpagerec.widthi=startpagerec.heighti=7;startpagerec.fl=SOLID_FILL;startpagerec.fd=SOLID_FILL;startpagerec.fb=SOLID_FILL;startpagerec.bc=4;startpagerec.db=1;startpagerec.draw(); titlestick.x=startpagerec.x1+startpagerec.widtho+startpagerec.widthm+startpagerec.widthi+20;titlestick.y=startpagerec.y1+startpagerec.heighto+startpagerec.heightm+startpagerec.heighti+20;titlestick.wl=titlestick.hu=10;titlestick.wr=titlestick.hd=20;titlestick.wm=150;titlestick.hm=40;titlestick.fl=titlestick.fr=titlestick.fu=titlestick.fd=titlestick.fm=1;titlestick.cl=titlestick.cu=15;titlestick.cr=titlestick.cd=8;titlestick.cm=7;titlestick.bc=1;titlestick.db=1;titlestick.draw(); title.x=titlestick.x+20;title.y=titlestick.y+10;title.horiz=LEFT_TEXT;title.vert=TOP_TEXT;title.fontname=SANS_SERIF_FONT;title.fontdir=HORIZ_DIR;title.fontsize=4;title.c=15;title.co=9;title.depth=5;title.skip=1;title.dir=0;title.st="Pmk100!";title.draw(); titlestick.x=startpagerec.x2-startpagerec.widtho-startpagerec.widthm-startpagerec.widthi-20;titlestick.y=startpagerec.y1+startpagerec.heighto+startpagerec.heightm+startpagerec.heighti+20;titlestick.wl=-10;titlestick.hu=10;titlestick.wr=-20;titlestick.hd=20;titlestick.wm=-190;titlestick.hm=40;titlestick.fl=titlestick.fr=titlestick.fu=titlestick.fd=titlestick.fm=1;titlestick.cl=titlestick.cu=15;titlestick.cr=titlestick.cd=8;titlestick.cm=7;titlestick.bc=1;titlestick.db=1;titlestick.draw(); title.x=titlestick.x+titlestick.wr+titlestick.wm+titlestick.wl+30;title.y=titlestick.y+10;title.horiz=LEFT_TEXT;title.vert=TOP_TEXT;title.fontname=SANS_SERIF_FONT;title.fontdir=HORIZ_DIR;title.fontsize=4;title.c=15;title.co=9;title.depth=5;title.skip=1;title.dir=0;title.st="Made:DanSei";title.draw();prognam.x=mx/2-174;prognam.y=titlestick.y+titlestick.hu+titlestick.hm+titlestick.hd+20;prognam.fontsize=48;prognam.string=rname;prognam.c=0;prognam.co=14;prognam.depth=15;prognam.draw();d24(lib24k,rmade,mx/2-70,my-90,9,5);snhz16(eng16[_mh-1],mx/2-12,my-90,9);d24(lib24k,rds,mx/2+12,my-90,9,5);d16(eng16,vern1eng,mx/2-176,my-60,14,0);d16(eng16,vern2eng,mx/2-48,my-60,14,0);d16(eng16,vern3eng,mx/2+48,my-60,14,0); pmkm.init();pmkm.maxx=mx;pmkm.maxy=my;pmkm.cursor(knife[0]); m3dm mm(5);mm.w.cb=1;mm.it[0].st="System";mm.it[1].st="File";mm.it[2].st="Edit";mm.it[3].st="Config";mm.it[4].st="Translate";mm.it[5].st="Store";mm.set1(set1fn,TRIPLEX_FONT);mm.set1(set1vt,2);mm.set1(set1skp,15);mm.set1(set1fs,3);mm.setxy();mm.set1(set1cy,-5);mm.set1(set1cb,~4);mm.set1(set1cc,~1);mm.draw();mm.run(temp); Getch(key); cmd3d cmd;cmd.c.st="Command3d";cmd.c.fontname=TRIPLEX_FONT;cmd.c.fontsize=2;cmd.c.depth=5; cmd.setxy(stomach); cmd.o.bc=14; cmd.draw(0); while(getch()!=13); cmd.draw(1); getch(); stopsong();quitsound(); }
void CALLBACK WaveOutProc(HWAVEOUT hwo, UINT msg, DWORD ins, DWORD p1, DWORD p2){ static int init = 0; static timemeas_t tm; static int k = 0; if(/*msg == WOM_OPEN ||*/ msg == WOM_DONE){ WAVEHDR *pwho, *pwh; pwho = &whs[k]; k = (k + 1) % 2; /* if(pwho->dwFlags & WHDR_DONE) OutputDebugString("WaveOut is done!\n"); if(pwho->dwFlags & WHDR_PREPARED) OutputDebugString("WaveOut is prepared!\n");*/ waveOutUnprepareHeader(hwo, pwho, sizeof *pwho); // OutputDebugString(msg == WOM_OPEN ? "WaveOut open!\n" : "WaveOut done!\n"); dwo = TimeMeasLap(&tmwo); // EnterCriticalSection(&pc->cswave); // setmsounders(sounders, numof(sounders), msounders, numof(msounders)); InterlockedExchange(&wave_current_volume, wave_volume); { int i, t, nes = 0; // number of effective sounders for(i = 0; i < numof(sounders); i++) if(sounders[i].left) nes++; if(!nes) initsound((BYTE*)pwho->lpData); // memset(pwho->lpData, 0x80, sizeof soundbuf[0]); else{ #if 1 wavesum8s((BYTE*)pwho->lpData, sounders, numof(soundbuf[0]), numof(sounders)); #else for(t = 0; t < numof(soundbuf[0]); t++){ long tt = 0; for(i = 0; i < numof(sounders); i++){ unsigned t2 = t * (sounders[i].pitch + 32) / 32; if(t2 < sounders[i].left) tt += ((long)sounders[i].src[t2] - 128) * sounders[i].vol / 256; } ((BYTE*)pwho->lpData)[t] = tt > 127 ? 255 : tt < -128 ? 0 : (BYTE)(tt + 128); } #endif // advance buffers for(i = 0; i < numof(sounders); i++) if(sounders[i].left){ unsigned tt2 = numof(soundbuf[0]) * (sounders[i].pitch + 32) / 32; if(sounders[i].delay < tt2){ tt2 -= sounders[i].delay; sounders[i].delay = 0; } else{ sounders[i].delay -= tt2; tt2 = 0; } if(sounders[i].left < tt2){ if(!sounders[i].loops) sounders[i].left = 0; else{ sounders[i].left = sounders[i].size; sounders[i].cur = sounders[i].src; sounders[i].loops--; } } else if(tt2){ sounders[i].left -= tt2; sounders[i].cur += tt2; } } } EnterCriticalSection(&gcs); { wavesumm8s((BYTE*)pwho->lpData, msounders, numof(soundbuf[0]), numof(msounders), listener_pos, listener_xhat); // advance buffers for(i = 0; i < numof(msounders); i++) if(msounders[i].left){ unsigned tt2 = numof(soundbuf[0]) * msounders[i].pitch / 256; assert(0 <= (int)msounders[i].left); if(msounders[i].delay < tt2){ tt2 -= msounders[i].delay; msounders[i].delay = 0; } else{ msounders[i].delay -= tt2; tt2 = 0; } if(msounders[i].left < tt2){ msounders[i].left = 0; } else if(tt2){ msounders[i].left -= tt2; msounders[i].src += tt2; } } } if(listener_inwater){ int i; for(i = 1; i < numof(soundbuf[0]); i++){ #if SAMPLEBITS == 16 short (*pbuf)[2] = (short(*)[2])pwho->lpData; pbuf[i][0] = (pbuf[i][0] + pbuf[i-1][0]) / 2; pbuf[i][1] = (pbuf[i][1] + pbuf[i-1][1]) / 2; #endif } } LeaveCriticalSection(&gcs); } // LeaveCriticalSection(&pc->cswave); pwho->lpData = (LPSTR)soundbuf[pwho - whs]; pwho->dwBufferLength = sizeof soundbuf[0]; pwho->dwFlags = 0; waveOutPrepareHeader(hwo, pwho, sizeof *pwh); pwho->dwFlags |= WHDR_BEGINLOOP | WHDR_ENDLOOP; pwho->dwLoops = 1; waveOutWrite(hwo, pwho, sizeof(*pwh)); TimeMeasStart(&tm); if(!init){ init = 1; } } }
int main(int argc, char* argv[]) { int df, wf; if(argc<2) { printf("Usage: %s DM-file [wav-file]\n",argv[0]); exit(0); } dminfo=malloc(sizeof(dmarg)); wi=malloc(sizeof(wavinfo)); if(!dminfo||!wi) { printf("Memory Allocation Error!\n"); exit(0); } fp=fopen(argv[1],"rb"); if(!fp) { printf("Error opening input file %s!\n", argv[1]); exit(0); } fread(dminfo,sizeof(dmarg),1,fp); if(dminfo->magicnum!=MAGICNUM) { printf("not a dm file!\n"); exit(0); } if(dminfo->delta<0x10000) printf("DM delta value %d\n",dminfo->delta); else { int deltal=dminfo->delta&0xffff; int deltar=(dminfo->delta-deltal)/0x10000; printf("DM delta value %d/%d\n",deltal,deltar); } if(dminfo->mode==MODE_TYPE1) printf("Channel Delta Mode\n"); if(dminfo->mode==MODE_TYPE2) printf("L+R L-R Mode\n"); fread(wi,sizeof(wavinfo),1,fp); printf("Sample rate %dHz, %d bits, %d channels\n",wi->srate,wi->bits,wi->channel); printf("Length %d:%d\n",(wi->samples/wi->srate)/60,(wi->samples/wi->srate)%60); initsound(wi->srate, wi->channel); snd_pcm_prepare(pcm_handle); decodeDM(fp, wi, dminfo, buf, BUFFER_NUM*frames*2*wi->channel); snd_pcm_writei (pcm_handle, buf, BUFFER_NUM*frames); snd_pcm_start(pcm_handle); while(1) { df=decodeDM(fp, wi, dminfo, buf, BUFFER_NUM*frames*2*wi->channel); wf = snd_pcm_writei (pcm_handle, buf, df); if(df<BUFFER_NUM*frames) break; } snd_pcm_drain(pcm_handle); snd_pcm_close(pcm_handle); free(buf); }
OpenAll() { CreateBasicMaze(); /* Default maze for construction set */ strcpy(sprite_dat,"pw:sprites/sprite.dat"); if((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",36))==NULL) { wb2_0=0; if((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0))==NULL) { printf("I can't open my graphics library! Oh, NOOOO!!!"); FreeMemory(); } } else wb2_0=1; /* Hey! We're in workbench 2.0! */ /* Save the active view for quit time */ oldview = GfxBase->ActiView; if((IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",0))==NULL) { printf("Could not open the Intuition Library!"); FreeMemory(); } CloseWorkBench(); if ((DiskfontBase=(struct Library *) OpenLibrary("diskfont.library", 33L))==NULL) { printf("Could not open the diskfont library! DUUUUUUUDE!\n"); FreeMemory(); } /* Get best font available */ if(( !(defaultFont = LoadThisFont(loresAttr=&pacqAttr)))) if(( !(defaultFont = LoadThisFont(loresAttr=&cleanAttr)))) if(( !(defaultFont = LoadThisFont(loresAttr=&topazAttr)))) { printf("Couldn't open any fonts! Not even ROM fonts?!?!\n\n"); FreeMemory(); } if((ArpBase = (struct ArpBase *) OpenLibrary("arp.library",0))==NULL) { printf("Unable to open the arp.library.\nPlease use the arp.library " "V1.3 or higher to run this program.\n"); FreeMemory(); } /* if(JoySetup()) { printf("No Joystick, No program...\n\n"); FreeMemory(); } */ if(ReadSprites()) { printf("Error while trying to read sprite file \"%s\"\n\n",sprite_dat); printf("Aborting program!\n\n"); FreeMemory(); } if((pacmen=(sprite_type *)AllocMem(sizeof(sprite_type)*12, MEMF_CHIP|MEMF_CLEAR))==0) { printf("Error while allocting CHIP RAM.\n"); FreeMemory(); } /* pacmen[12] */ if((blank=(sprite_type *)AllocMem(sizeof(sprite_type), MEMF_CHIP|MEMF_CLEAR))==0) { printf("Error while allocting blank sprite.\n"); FreeMemory(); } /* pacmen[12] */ if((ghosts=(sprite_type *)AllocMem(sizeof(sprite_type)*6*MAXGHOSTS ,MEMF_CHIP))==0) { printf("Error while allocting CHIP RAM.\n"); FreeMemory(); } /* ghosts[36] */ if((eyes=(sprite_type *)AllocMem(sizeof(sprite_type)*6*MAXGHOSTS ,MEMF_CHIP))==0) { printf("Error while allocting CHIP RAM.\n"); FreeMemory(); } /* eyes[24] */ if((scores=(sprite_type *)AllocMem(sizeof(sprite_type)*NUMSCORES ,MEMF_CHIP))==0) { printf("Error while allocting CHIP RAM.\n"); FreeMemory(); } /* scores[6] */ if (initsound() || loadsound(defaultpath)) { printf("No sound files will be used.\n"); nosound = TRUE; } return 0; }
void parsecmd(int argc,char *argv[]) { char *word; Sint4 arg,i,j,speedmul; bool sf,gs=false,norepf=false; FILE *levf; for (arg=1;arg<argc;arg++) { word=argv[arg]; if (word[0]=='/' || word[0]=='-') { if (word[1]=='L' || word[1]=='l' || word[1]=='R' || word[1]=='r' || word[1]=='P' || word[1]=='p' || word[1]=='S' || word[1]=='s' || word[1]=='E' || word[1]=='e' || word[1]=='G' || word[1]=='g' || word[1]=='A' || word[1]=='a' || word[1]=='I' || word[1]=='i') if (word[2]==':') i=3; else i=2; if (word[1]=='L' || word[1]=='l') { j=0; while (word[i]!=0) levfname[j++]=word[i++]; levfname[j]=word[i]; levfflag=true; } if (word[1]=='R' || word[1]=='r') recname(word+i); if (word[1]=='P' || word[1]=='p' || word[1]=='E' || word[1]=='e') { openplay(word+i); if (escape) norepf=true; } if (word[1]=='E' || word[1]=='e') { finish(); if (escape) exit(0); exit(1); } if ((word[1]=='O' || word[1]=='o') && !norepf) { arg=0; continue; } if (word[1]=='S' || word[1]=='s') { speedmul=0; while (word[i]!=0) speedmul=10*speedmul+word[i++]-'0'; ftime=speedmul*2000l; gs=true; } if (word[1]=='I' || word[1]=='i') sscanf(word+i,"%u",&startlev); if (word[1]=='U' || word[1]=='u') unlimlives=true; if (word[1]=='?' || word[1]=='h' || word[1]=='H') { finish(); printf("DIGGER - Copyright (c) 1983 Windmill software\n" "Restored 1998 by AJ Software\n" "http://www.digger.org\n" "Version: "DIGGER_VERSION"\n\n" "Command line syntax:\n" " DIGGER [[/S:]speed] [[/L:]level file] [/C] [/B] [/Q] [/M] " "[/P:playback file]\n" " [/E:playback file] [/R:record file] [/O] [/K[A]] " "[/G[:time]] [/2]\n" " [/A:device,port,irq,dma,rate,length] [/V] [/U] " "[/I:level]\n\n" "/Q = Quiet mode (no sound at all) " "/M = No music\n" "/R = Record graphics to file\n" "/P = Playback and restart program " "/E = Playback and exit program\n" "/O = Loop to beginning of command line\n" "/K = Redefine keyboard\n" "/G = Gauntlet mode\n" "/2 = Two player simultaneous mode\n" "/A = Use alternate sound device\n" "/U = Allow unlimited lives\n" "/I = Start on a level other than 1\n"); exit(1); } if (word[1]=='Q' || word[1]=='q') soundflag=false; if (word[1]=='M' || word[1]=='m') musicflag=false; if (word[1]=='2') diggers=2; if (word[1]=='K' || word[1]=='k') if (word[2]=='A' || word[2]=='a') redefkeyb(true); else redefkeyb(false); if (word[1]=='A' || word[1]=='a') { sscanf(word+i,"%u,%x,%u,%u,%u,%u",&sound_device,&sound_port,&sound_irq, &sound_dma,&sound_rate,&sound_length); killsound(); volume=1; setupsound=s1setupsound; killsound=s1killsound; fillbuffer=s1fillbuffer; initint8=s1initint8; restoreint8=s1restoreint8; soundoff=s1soundoff; setspkrt2=s1setspkrt2; settimer0=s1settimer0; timer0=s1timer0; settimer2=s1settimer2; timer2=s1timer2; soundinitglob(sound_port,sound_irq,sound_dma,sound_length,sound_rate); initsound(); } if (word[1]=='V' || word[1]=='v') synchvid=true; if (word[1]=='G' || word[1]=='g') { gtime=0; while (word[i]!=0) gtime=10*gtime+word[i++]-'0'; if (gtime>3599) gtime=3599; if (gtime==0) gtime=120; gauntlet=true; } } else { i=strlen(word); if (i<1) continue; sf=true; if (!gs) for (j=0;j<i;j++) if (word[j]<'0' || word[j]>'9') { sf=false; break; } if (sf) { speedmul=0; j=0; while (word[j]!=0) speedmul=10*speedmul+word[j++]-'0'; gs=true; ftime=speedmul*2000l; } else { j=0; while (word[j]!=0) { levfname[j]=word[j]; j++; } levfname[j]=word[j]; levfflag=true; } } } if (levfflag) { levf=fopen(levfname,"rb"); if (levf==NULL) { strcat(levfname,".DLF"); levf=fopen(levfname,"rb"); } if (levf==NULL) levfflag=false; else { fread(&bonusscore,2,1,levf); fread(leveldat,1200,1,levf); fclose(levf); } } }