www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/02/10:33:06

Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE324A179@probe-2.Acclaim-Euro.net>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: could you look at this code for me please..
Date: Mon, 2 Nov 1998 11:17:22 -0000
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.0.1460.8)
Reply-To: djgpp AT delorie DOT com

RaVeN <grommit AT pacbell DOT net> writes:
> could you look at this code for me please..

Sure, although it is very hard to read with the bizarre way that you 
have indented it! Why not use some more conventional layout with all 
the lines in sensible places?

> char buf[80];	

Why declare this array, if you aren't then going to use it for 
anything?
     
> int main (char *argv[]) {

That's not the right prototype for main(). This must either be 
declared as int main(), or as int main(int argc, char *argv[]).

>     set_gfx_mode(GFX_VGA, 320, 200, 100,0);

Where does the 100 bit come from? If you don't need a virtual screen, 
the last two parameters should be zero. If you do need a large virtual 
screen, these values must be larger than the physical screen 
dimensions, and you must use some other driver than GFX_VGA.
       
>         load_wav("shoot.wav");
> //------------ #1 how come i get no sound 

You aren't doing anything with the return value from this load call, 
so it just reads the sample into memory but then throws away the 
result. You need to assign the loaded data to your pointer variable, 
and should also check to make sure that this call has been 
successful. See the ex17.c example program for a demo of loading 
and playing samples.

>       // --- #2 and KEY_UP, is it right
>          while (!keypressed(KEY_UP));   

Wrong: this should be while (!key[KEY_UP]), or more simply just 
readkey(). See the ex5.c example program.

>	 while (KEY_UP);  

Again wrong, for the same reasons as above.

> }              //--#3 why do i need 2 of these ..
> }

Because that is how many you have opened earlier on! One for the 
if (install_sound()) check, and one for the main() function itself.


	Shawn Hargreaves.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019