View Single Post
Old 01-11-11, 08:18 AM   #883
Stiebler
Fuel Supplier
 
Stiebler's Avatar
 
Join Date: Oct 2005
Location: London, UK
Posts: 1,237
Downloads: 29
Uploads: 4


Default

@H.sie:
The crash-dive routine is as follows:

The quick-dive tank is filled very fast. In order to see the filling, one has to make a break in the code at Sh3Sim.act+0x8527 immediately after pressing key 'C' (for crash-dive).

The relationship of key variables is this:
hydroplane (A) = (relative 0)
hydroplane (B) = hydroplaneA + 2C
diving tank = hydroplaneB + 1C
quick-dive tank= diving tank + 0x14
I've verified these relative values over four different cold starts of SH3 now, but you have to identify one of these starting variables first.

The quick-dive tank starts at 0.5000 (not at 0.0000, as I thought previously), and rises to 1.0000.
At a depth of about 35-39 metres (it varies even with the same IXC U-boat), the quick-dive tank starts to empty slowly.

The code which empties the quick-dive (q-d) tank is a subroutine called from Sh3Sim.act+0xB002, and located at Sh3Sim.act+0xA690.

This subroutine is called *only* to empty the q-d tank, not to fill it. The subroutine is NOT called after an interrupted crash-dive at 40-45 metres. Hence, the q-d tank never gets emptied (ie, restored from 1.0000 to 0.5000). It may be partially emptied, depending on what depth was reached before the crash-dive was interrupted.

When the U-boat is floating level at a depth of 40-45 metres (interrupted crash-dive), the only calls to Sh3Sim.act+0xAEB3 are to the hydroplanes. Otherwise, Sh3Sim.act+0x8527 provides a break-point for calls to hydroplanes and to the q-d tank.

Therefore it appears that the code needed to handle an interrupted crash-dive (to restore the q-d tank to a value of 0.5) is going to have be quite brutal. We could set a flag when the q-d tank fills to 1.0000 (occurs while the U-boat is still on the surface), check flag and depth and hydroplane status, then restore the q-d tank.

I think all three of these tests are going to be needed wherever, or however, the code gets implements (although your crashdiveflag that you reported earlier could replace the 'q-d tank = 1.0000' test.)

The big problem is this:
After an interrupted crash-dive, and if the player goes to speed = slow, the hydroplanes both have a steep up angle (about 0.5 for the front planes, and nearly as much for the rear hydroplanes), yet the U-boat continues to sink. Therefore the method of checking hydroplanes only works at high underwater speeds.

We need some new way of checking for an interrupted crash-dive, and I think this requires knowledge of depth plus something else. A crash-dive to 80m can be interrupted if the player clicks on the depthgauge for 40m, 80m or 120m, so it is necessary to check only that the depth is below the surface (>10m). But what is the 'something else'?

I suggest the simple test:
IF depth > 40m AND q-d tank value = 1.000
THEN q-d tank = 0.5000

That should resolve all problems, is easy to code, and we know that the q-d tank will be emptied to 0.5000 below 40m anyway! The only potential problem is that the U-boat will now sink less quickly to the crash-dive depth - but it will be safely below the surface. (Implement in code at or near Sh3Sim.act+0x8529.)

In fact, possibly (?) we can even remove the test for the q-d tank - implement the code whenever the depth falls below 40m however the player chooses to dive.

Stiebler.
Stiebler is offline   Reply With Quote