www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/06/18:18:21

From: Ted Larsson <f93tela AT dd DOT chalmers DOT se>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Strange results from printf()
Date: Sat, 05 Sep 1998 23:49:51 +0200
Organization: Chalmers University of Technology, Sweden
Lines: 62
Message-ID: <35F1B1FF.9216B190@dd.chalmers.se>
References: <904735570 DOT 503897 AT mars DOT cs DOT unp DOT ac DOT za>
NNTP-Posting-Host: dynamic-200-102.dialup.chalmers.se
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

James Dominy wrote:
> 
> Hi there,
> 
> I seem to be getting strange results from printf() ...
> 
> I'm calling printf() with two arguments like so :
> 
> printf("SoundBlaster DSP version %i.%i",sb_dsp_major,sb_dsp_minor);
> 
> I have a SB16 DSP ver 4.13 and the line prints out this correctly either,
> after I've run my program at least once since the last reboot, OR if I'm
> debugging (stepping through these exact lines) in RHIDE. If this is not the
> case printf() seems to be reversing the variables, ie. I appear to have SB
> DSP ver 13.4 . The variables (sb_dsp_xxxxx) are correct when I debug, and so
> I assume they are correct when I don't, so the prob seems to be in the
> printf() function itself.
> 
> Any ideas?
> 
> Thanx
> JAmes
Hi!

I did some sound programming a while ago, and I also ran into this
problem.
I even think that my sound card has the same DSP version, IIRC.

Anyway, I solved my problem by waiting some time between the reads of
the major
and minor version numbers, because modern computers are a lot faster
than the
systems on sound cards. This is the code I used:

void GetDSPversion( int *major , int *minor )
{
        WriteDSP( 0xE1 );
        delay_us( 6.0 );
        *major = ReadDSP();
        delay_us( 0.2 );
        *minor = ReadDSP();
}
void delay_us( float t )
{
        int k, A , D = (int) 1000.0 / 6.0 * t;
        for( k = 0 ; k < D ; k++ )
             A = 0; // do something
}

The delay_us() function is a very ugly thing, don't copy it, it's
somthing I
wrote before I learned about the timing functions built into DJGPP. 
However,
that isn't the issue here, the issue is trying to wait a little both
before 
reading the major and minor version numbers.

Hope this helps you.

/Ted


- Raw text -


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