Silent fall

Discuss Chaos Strikes Back for Windows and Linux, an unofficial port of Chaos Strikes Back to PC by Paul Stevens, as well as CSBuild, an associated dungeon editor.

Moderator: Zyx

Forum rules
Please read the Forum rules and policies before posting. You may Image to help finance the hosting costs of this forum.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Well, 'Can't' is a bit strong. I suppose I could get the latest
headers. But I don't want to go through that trouble. The
machine I have done all the development on is an old
laptop with a 2.1 GB drive that has no connection to the
outside world. I think getting the DirectX SDK on floppies is
going to be a bit of trouble. So I have to find it somewhere
and burn it onto a CD. Then load it and see why it doesn't work
and try again.

And it is probably not going to fit on the hard drive anyway
because 2.1 GB, the Visual Studio 6.0, the project files, etc.
have it nearly full as it is.

How big are the headers that I need?

I had all the headers that were contained in your .cpp file.
One of them must be an old version, I suppose. Can I replace
the one header that is needed for this one source file?
User avatar
cowsmanaut
Moo Master
Posts: 4380
Joined: Fri Jun 30, 2000 12:53 am
Location: canada

Post by cowsmanaut »

"I'll just make it use the base. That way Paul doesn't have to waste time doing something he doesn't need to do and can work on the important stuff"

moo
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Oh, my God. I looked and saw that the DirectX SDK
is 227 MegaByte.

Is there another option?
Can you compile the one source file and send me the .obj?
User avatar
cowsmanaut
Moo Master
Posts: 4380
Joined: Fri Jun 30, 2000 12:53 am
Location: canada

Post by cowsmanaut »

"Tell Paul that I am using VC++ 7.1 and I don't think the .obj files are compatible"

moo
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Too bad. Then I guess I need the correct headers.
Hopefully without downloading 227 MegaBytes and trying
to make room for it on my little hard drive.
User avatar
cowsmanaut
Moo Master
Posts: 4380
Joined: Fri Jun 30, 2000 12:53 am
Location: canada

Post by cowsmanaut »

he says "Tell Paul not to worry, I'll make it use the base dsound.h."

moo
User avatar
cowsmanaut
Moo Master
Posts: 4380
Joined: Fri Jun 30, 2000 12:53 am
Location: canada

Post by cowsmanaut »

User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

That seems close to syntactically correct.

Code: Select all

typedef struct _DSBUFFERDESC
{
    DWORD           dwSize;
    DWORD           dwFlags;
    DWORD           dwBufferBytes;
    DWORD           dwReserved;
    LPWAVEFORMATEX  lpwfxFormat;
} DSBUFFERDESC, *LPDSBUFFERDESC;


   DSBUFFERDESC desc;
   desc.dwSize = sizeof DSBUFFERDESC;
   desc.dwFlags = 0;
   desc.dwBufferBytes = 0; // To be filled in after parsing the wave
   desc.lpwfxFormat = &
   desc.guid3DAlgorithm = GUID_NULL;
   desc.dwReserved = 0;


C:\Projects\Csb\CSBwin\src\Win32_SoundMixer.cpp(153) : error C2039: 'guid3DAlgorithm' : is not a member of '_DSBUFFERDESC'
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\dsound.h(96) : see declaration of '_DSBUFFERDESC'
E
[/quote]
Ryan

Fix for the code

Post by Ryan »

Sorry about that, I made it use the initial interfaces but I was still using a newer header that added an extra field to this structure.

Here's how it looks in my header which should make it obvious:

Code: Select all

typedef struct _DSBUFFERDESC
{
    DWORD           dwSize;
    DWORD           dwFlags;
    DWORD           dwBufferBytes;
    DWORD           dwReserved;
    LPWAVEFORMATEX  lpwfxFormat;
#if DIRECTSOUND_VERSION >= 0x0700
    GUID            guid3DAlgorithm;
#endif
} DSBUFFERDESC, *LPDSBUFFERDESC;
You can fix it by just removing this line since it's not used anyways:

Code: Select all

   desc.guid3DAlgorithm = GUID_NULL;
Hope that helps!
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Hmmmm. Works very smoothly now. Unfortunately
there is no sound now.

The initialize (four steps as I recall) works great and
returns 'true'. Then I try to play a sound. It parses the
thing and finally gets to a statement:

Code: Select all

pDirectSoundBuffer->Lock(........);
That fails and the function immediately returns.

Also I have a question. It appears that you have no
use for the sound buffer that I pass to the Play function.
So I can release it immediately when your Play() returns.
Is that correct?
Ryan

Post by Ryan »

What is the value in the EAX register when the Lock function fails? (or just say 'HRESULT hr = pblah->Lock()' and get the HRESULT.)

Be careful about trying to debug into the sound routines, they won't play unless the window you initialized with is the active window. Naturally while you're debugging that window is not active so nothing will play in the debugger. I didn't think that Lock() would fail if the window is not active though.

And yes, the buffer originally passed in is not needed after calling Play.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

0x80070057
Ryan

Post by Ryan »

Try merging these changes in to see if they have any effect. It's the best I can think of without reproing it locally.

Code: Select all

      void *p1=NULL;
      DWORD bytes1=0;
      void *p2=NULL;
      DWORD bytes2=0;

      if(FAILED(pDirectSoundBuffer->Lock(0, 0, &p1, &bytes1, &p2, &bytes2, DSBLOCK_ENTIREBUFFER)))
         return;

      if(bytes1!=dwDataSize)
         return;
[/code]
Ryan

Post by Ryan »

Code: Select all


      if(FAILED(pDirectSoundBuffer->Lock(0, dwDataSize, &p1, &bytes1, &p2, &bytes2, 0)))
         return;

Another thing to try, which is how my ancient DirectSound code locked the buffer. All of these have worked on my system though, so I don't know what your system is complaining about (the invalid parameter error code that is)

-Ryan
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

None of your suggested changes made the slightest difference.

So I spent a few hours reading about this stuff and trying
this and that and rebooting and so on and so forth.
I built a release executable and restarted my machine
from a power-off state and still nothing.

Perhaps it requires some hardware capability that my old
laptop does not have.

Then I packaged the same release executable and tried it on
my Windows2000 machine. It worked just fine. I will list
the concerns that I have reguarding this project.

1) It does not work on my Windows 95 machine and it
returns no information that informs me of this fact. So
I cannot recover by playing the sounds in the old way.

2) Your code appears to 'Create a Sound Buffer' and then
when the 'Lock' fails your code returns without releasing the
sound buffer. Is this proper? I know nothing of how this is
supposed to work......so I worry.

3) I don't know whether this is supposed to work on WindowsCE
or not. In any case, my experience to date indicates that I had
better do some testing.

Maybe the best thing to do is to install this code, disable it
initially, and provide a way for Cowsmanaut to enable it so
that he can hear two sounds at once. In that way it can do
no harm unless the user 'Asks for it'.

Welcome to the world of writing programs for a wide audience.
kentaro-k.21
Artisan
Posts: 178
Joined: Wed Dec 17, 2003 1:39 am
Location: Osaka, Japan
Contact:

testing tool

Post by kentaro-k.21 »

hi.

i have made a testing tool in a hour.
should i upload it?

screenshot:
http://homepage3.nifty.com/kkdf/0528_001.gif
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I forgot to list a fourth concern:

4) On my Windows2000 machine the DirectSound works
just fine but......when the program terminates (File/Exit menu)
I get a dialog box saying that it is trying to launch
Dr. Watson Postmortem Debugger. I don't need that.
Any idea why ***THAT*** is happening? It does not happen
if I terminate before the first sound is played.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

The testing tool.......Sure. I will try it.
I have spent too many hours on this already to quit
now, I guess.
kentaro-k.21
Artisan
Posts: 178
Joined: Wed Dec 17, 2003 1:39 am
Location: Osaka, Japan
Contact:

permission to distribute?

Post by kentaro-k.21 »

hello, Paul.

although i'm already ready to publish the archived package, i require the permission from its author to distribute the component.

hi Ryan, can i publish the tool (+src) with your module?
User avatar
cowsmanaut
Moo Master
Posts: 4380
Joined: Fri Jun 30, 2000 12:53 am
Location: canada

Post by cowsmanaut »

Just to interject here. The suggestion I had made was to have a switch so that those who can/want to use this little section will be able to, and for those who do not or can't, can turn it off and use the old way.

Also, I didn't but my nose in just for me. The topic arose before I even got involved. :) This stemmed from ZYX wanting hear the door close as they party screamed their way down a pit. :)


moo
Ryan

Post by Ryan »

kentaro-k.21,

You have my permission to do whatever you want with the code. I'm impressed with the utility you came up with!

Paul:

The buffer is not leaked, the release of it is handled in the CntPtrTo C++ object and is all handled automatically. That's why I just 'return' when things fail, that object manages the lifetimes for me automatically.

Also, I could have the init try to create a sound, lock it, and play silence, if that succeeds then to return true from the Init() routine. I can also have the Play() method return success/failure and if it fails to switch back to PlaySound() on your side.

You don't have to tell me about making code run on all platforms, I do that every day. My work code runs on millions of machines with every kind of hardware. Amusingly enough, the code was not sound related. Also, we typically get a few years to try it out on all the platforms we care about. Also, we stopped supporting NT 4.. perhaps that's why I can't write code that still works on it.

If you tell me the machine setup you're using I can setup an NT4 machine myself and give it a try. I know DirectSound worked fine for me back in 1997 when I was doing DirectSound stuff on NT4.
Ryan

Post by Ryan »

Oh, about the Windows CE stuff, I know that CE supports DirectSound. I just have no way of testing it here anymore (I returned my CE development machine already).
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

If you tell me the machine setup you're using I can setup an NT4 machine myself and give it a try
I don't know anything about NT4. What I have is an IBM Model
380ED very standard as it was built at the factory. It has
a built-in Crystal PnP Audio CODEC according to the Hardware
Configuration Manager. When I boot, it says some words
about pretending to be a SoundBlaster and gives the DMA address
and IRQ.

I am running an old Windows 95 that came with the machine
many years ago. Version 4.0.950 B it says.

It all runs on a Intel Pentium at 166MHz. Quite quaint. But four
times what is needed to run CSBwin very well. What else can
I tell you (and how do I find it out?).
Ryan

Post by Ryan »

Well, I did the best I could do. I installed Windows 95 with a SoundBlaster card and ran my demo app on it to see if I could play sounds. The only DirectX download I could find was 8.x so I had to install that. The app worked just fine.. I closed it and no errors also.

I don't know what to say. Try running 'dxdiag' and testing DirectSound through that way to see if it has any problems playing back sound.
kentaro-k.21
Artisan
Posts: 178
Joined: Wed Dec 17, 2003 1:39 am
Location: Osaka, Japan
Contact:

uploaded

Post by kentaro-k.21 »

i have uploaded the testing tool at encyclopaedia forum.

http://dmweb.free.fr/Forum/read.php?f=8&i=303&t=303
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Some results....

I tryed the Testing Tool. Worked great. I initialized, I
played MicrosoftSound.wav, and I Shutdown. No errors.
No sound either.

By the way....I forgot to initialize once and the tester died
a rather ugly death.

I tried running dxdiag. There is no dxdiag on my Win95
machine. So I went to my Win98 machine. There is no dxdiag
on that machine. So I went to my Win2K machine. There it is!!!
I copied it to my Win95 with very little expectation. It simply told
me that a .DLL was missing.

So-----

I put in a menu option "Attempt to use DirectX". Anyone who
wants to try it can try it. If it does not work then they can turn
it off again. Unless someone has a remarkable brainstorm, I
plan to leave it at that and go onto something else.
User avatar
cowsmanaut
Moo Master
Posts: 4380
Joined: Fri Jun 30, 2000 12:53 am
Location: canada

Post by cowsmanaut »

well this begs the question then. What ver of Direct X do you have installed on your Win 95 machine. And what ver on your win 98 machine?

Since DirectX's Diagnostic tool wasn't provided with earlier versions of direct X. Dxdiag needs DXdiag.cpl and will only work with (I think) version 6 and up.

moo
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I never installed any version of DirectX on my win95 machine
so far as I know.

It came from the factory with Win95 installed. I installed
Microsoft Visual C++ Version 5.0 and later 6.0. That is
all I ever remember putting on there. If any DirectX is installed,
how do I determine what version it is?
User avatar
cowsmanaut
Moo Master
Posts: 4380
Joined: Fri Jun 30, 2000 12:53 am
Location: canada

Post by cowsmanaut »

well, as far as I know direct X didn't come with windows 95. So if you didn't put it there then chances are it's not there. Which would neatly explain why it's not working.

What you should do is download directX.. the users version not the developers. That should be only about 12 megs. Install that and then try running it.

being as this is a common and easily accessable program a lot of people (especially gamers) have a copy of it. If you like I think you can still find directX6 still if you want an earlier version than 8. It's unlikley that if anyone here has DX it would be anything less than that.

moo
User avatar
Paul Stevens
CSBwin Guru
Posts: 4322
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I don't think you yet understand. I want anyone who can
run NotePad to be able to run CSBwin. I do not want
to tell people they have to go get DirectX to run CSBwin.
You promised me that your code would check to see
if all the necessary libraries, etc. were present and if not
you would fall back to the standard Windows functions.
The function would always succeed and play the sound through whatever mechanism necessary (like falling back to WinMM if necessary).
I did not expect it to use DirectX on my Win95 machine. I expected
it to fall back, tell me that DirectX was not present, and I
would play the sounds as I always have in the past. Unfortunately,
your code said that it created the sound when it did not. Probably
a bug in my machine or my operating system. Nobody seems
to know. The bottom line is that it did not work whereas the
simple Windows interface does work.

I expected that on my Win2K machine the DirectX would work
and I would not have to play the sounds using the queue that
I recently implemented. This, in fact, has worked. But when I
exit the program it tries to load Dr. Watson Postmortem Debugger.
That is a bit ugly and sufficient reason for my wanting a way
to turn off the DirectX feature.

Therefore, as I said recently, I will install the code you provided,
give the user a Menu option to use it or not use it, and go onto
the text/wall decoration project. Any suggestions that I receive
concerning the DirectX implementation will be forwarded to you
for implementation/resolution. And I will happily install any
updates that you provide me. Fair enough?

Welcome to the world of writing programs for wide
distribution. I understand that someone out there
is running CSBuild/CSBwin on a 486. I have made a lot
of changes to accomodate that person. It is painful but
that is the way it is. I could add that my tooth is painful, too.
Been that way for 5 months. It has taught me some things.

All of this can be summarized in four letters. KISS
Post Reply

Return to “Chaos Strikes Back for Windows & Linux (CSBWin) / CSBuild”