www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/13/11:53:40

Date: Mon, 13 Sep 1999 12:32:02 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: aperes <ajps AT mail DOT telepac DOT pt>
cc: djgpp AT delorie DOT com
Subject: Re: SIGSEGV
In-Reply-To: <37d96949.2829314@news.telepac.pt>
Message-ID: <Pine.SUN.3.91.990913123142.8713J-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Fri, 10 Sep 1999, aperes wrote:

> s_ptr = (unsigned char *) malloc(size_of_file);
> linear_adress = 16 * __dpmi_allocate_dos_memory((size_of_file+15) >>
> 4, selector);
> dosmemput(s_ptr, size_of_file, linear_adress);
> 
> the_sound.sound = linear_adress;

No, this is incorrect.  You need to pass both segment and offset.  For
that, you will have to change the declaration of the structure (see
section 18.5 of the FAQ for details):

  typedef struct_typ {
  unsigned short sound_off; // MUST BE OFFSET SEGMENT IN 1MB ADRESS SPACE.
  unsigned short sound_seg;
  unsigned shor sndlen; // lenght of audio sample. < 64k
  unsigned short IsPlaying_off; //Adress of play status flag.REAL PTR
  unsigned short IsPlaying_seg;
  short frequency; //Playback frequency
  } sndstruct;

and then assign the pointer like this:

  the_sound.sound_off = linear_adress & 15;
  the_sound.sound_seg = linear_adress >> 4;

> the_sound.sndlen = size_of_file;
> the_sound.Isplaying = ? (I don't know how to do...REAL PTR OFF:SEG!!)

You need to copy the flag into the buffer that you allocated with
__dpmi_allocate_dos_memory, like this:

  _farpokew (_dos_ds, linear_adress + size_of_file, flag);

and then pass the seg:off address in the structure:

  the_sound.IsPlaying_off = size_of_file;
  the_sound.IsPlaying_off = linear_adress >> 4;

(Note that for this to work, you should make sure the buffer you
allocate has 2 extra bytes where you can put the flag variable.)

> /* pass the struct to adress in the first 1MB as required
> movedata(_my_ds(), (int) &the_sound, _dos_ds, __tb,
> sizeof(the_sound));

Don't forget to pack the struct, as the FAQ tells.  Otherwise, the
compiler might pad the struct members due to alignment, and the
program will crash or not work.

- Raw text -


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