Jump to content


Photo

stretch movies for widescreen mod


  • Please log in to reply
27 replies to this topic

#1 aqrit

aqrit
  • Member
  • 132 posts

Posted 02 December 2011 - 08:53 PM

In the DDSurfaceI->Blt() call that outputs the movies, replace the pointer to the destination rectangle with zero
so DirectDraw will stretch ( if supported ) the image to fit automatically...

for the 4CDv1.1 version of torment we would write at virtual address 0x0043F522 the values 0x6A 0x00 0x90 0x90

the intro movies look okay IMO at 1440x900

I am wondering why I haven't seen this done before?

Edited by aqrit, 04 December 2011 - 08:38 AM.


#2 i30817

i30817
  • Member
  • 611 posts

Posted 03 December 2011 - 06:31 AM

Because no one knows how to find it.

Give a pm to ghostdog if you didn't already.

#3 Jarno Mikkola

Jarno Mikkola

    The Imp in his pink raincoat.

  • Member
  • 10911 posts

Posted 03 December 2011 - 06:39 AM

The Bigg could also be interested on this... and how you came to know it... :D

Deactivated account. The user today is known as The Imp.


#4 i30817

i30817
  • Member
  • 611 posts

Posted 03 December 2011 - 07:00 AM

With ollydbg and some knowledge of the windows api probably.

#5 ghostdog

ghostdog
  • Modder
  • 556 posts

Posted 04 December 2011 - 05:03 AM

Since my HEX skills go as far as the little work I did for this mod (=weak), how exactly do I write these values to the offset ? I tried converting bytes to hex so I changed 64009090 to 40 00 5A 5A and replaced the original offset which was 4D CC 8B 51 and it didn't work. The videos remained unstreched and the game crashed upon entering the main menu. I tried other stupid things too and they didn't work either. I'm using hex workshop btw.

#6 i30817

i30817
  • Member
  • 611 posts

Posted 04 December 2011 - 07:14 AM

Those values (0x64 0x00 0x90 0x90) are already hex.

0xNNNN

binary would be

0bNNNN

Edited by i30817, 04 December 2011 - 07:16 AM.


#7 ghostdog

ghostdog
  • Modder
  • 556 posts

Posted 04 December 2011 - 07:39 AM

Great. So, how would we write the values 0x64 0x00 0x90 0x90 at virtual address 0x0043F522 ?

#8 i30817

i30817
  • Member
  • 611 posts

Posted 04 December 2011 - 07:43 AM

Try it.

I don't say it will work, because sometimes program loaders/debuggers do funny things with the program offset, and the address that appears in the debugger is not the same as in the executable file.

I'm sure aqrit will be able to help you if it doesn't work (i didn't try it).

#9 Jarno Mikkola

Jarno Mikkola

    The Imp in his pink raincoat.

  • Member
  • 10911 posts

Posted 04 December 2011 - 07:56 AM

...

So, how would we write the values 0x64 0x00 0x90 0x90 at virtual address 0x0043F522 ?

Try it.

How is the trying done.... in .tp2 code ? Say, like this :
copy ~Torment.exe~ 

PATCH_IF ~blarg~ BEGIN

WRITE_ASCII ~0x0043F522~ ~0x64009090~
Or ?

Deactivated account. The user today is known as The Imp.


#10 aqrit

aqrit
  • Member
  • 132 posts

Posted 04 December 2011 - 08:26 AM

to patch the the exe with a tp2 we will have to convert the Virtual Address to a File Offset
which in this case is just 0x0003F522
and if we want to write all four bytes at once we have to flip them around backwards because x86 is little-endian

COPY ~Torment.exe~ ~Torment.exe~ 
    WRITE_LONG 0x0003F522 0x9090006A

edit:
sorry it should have been 0x6A NOT 0x64
thats what I get for doing things late at night

Edited by aqrit, 04 December 2011 - 08:40 AM.


#11 i30817

i30817
  • Member
  • 611 posts

Posted 04 December 2011 - 08:30 AM

Edit: answered by aqrit.

Mine was wrong anyway

that fucking big endian.
also edited out shameful byte x hex confusion.
2 hex digits are a byte.

How does it look ghostdog?

Edited by i30817, 04 December 2011 - 08:54 AM.


#12 scient

scient
  • Modder
  • 1010 posts

Posted 04 December 2011 - 10:04 AM

Oooooooo that looks nice at 1920x1080. I only watched the intro movies, didn't try any of the spell movies. The 2CD VA offset is following: 0x0043F4E2. You would use the same bytes as above (6A 00 90 90). Nice find aqrit.

Edited by scient, 04 December 2011 - 10:04 AM.

Those interested in the classic TBS game Sid Meier's Alpha Centauri / Alien Crossover should check out the unofficial patch I work on here.


#13 ghostdog

ghostdog
  • Modder
  • 556 posts

Posted 04 December 2011 - 04:09 PM

All right then. No time for it now, I'll test it tomorrow and try to find the respective offset in the 2CD version.

#14 scient

scient
  • Modder
  • 1010 posts

Posted 04 December 2011 - 05:22 PM

All right then. No time for it now, I'll test it tomorrow and try to find the respective offset in the 2CD version.


Posted 2CD VA offset above. If you want the actual file offset its: 0x0003F4E2. Same patch data.

Those interested in the classic TBS game Sid Meier's Alpha Centauri / Alien Crossover should check out the unofficial patch I work on here.


#15 aqrit

aqrit
  • Member
  • 132 posts

Posted 05 December 2011 - 12:16 AM

how-to/tut (if any1 is interested)

Grab the the ddhack logger
fix a minor issue with in the Blt logging code ( make sure LPDDBLTFX isn't NULL )
add return address logging to all relevant functions
compile ddraw.dll and drop it into your game folder

start the game, let the movies run, then immediately end the game

take a look in the log file
you'll see startup followed by the movie code then a little bit of the menu then cleanup
the movie code should be easy to spot as it will be done every frame so it will repeat like 1,000 times in a row

DDraw allows us to stretch images using the Blt call

---

I took a look at Throne of Bhaal unfortunately they are doing things the way you would expect them to
(3d acceleration off which might matter)

Lock the back buffer
--draw the movie frame by hand onto the back buffer--
Unlock the back buffer
then Flip the back buffer to the front

this time there is no convenient Blt call that is only used for the movies
the flip call is used for in-game as well
( Windowed mode uses Blt but it is just replacing the Flip )

For some reason trying to Blt the back buffer to itself doesn't turn out well.

so currently [using ddhack logger as a platform]
I just hook the movie's Lock call and pass in a (new) offscreen surface to be Locked instead of the back buffer
the movie's Unlock call is hooked so as to unlock that offscreen surface instead of the back buffer then
we (stretch) Blt that offscreen surface to fill the back buffer

I'm thinking this will be a pain to turn into a polished mod though

extern "C" void * _ReturnAddress(void);
#pragma intrinsic(_ReturnAddress)

LPDIRECTDRAWSURFACE dds_movie = NULL;
LPDIRECTDRAW2 dd; //grabbed from the myIDDraw2 constructor

HRESULT  __stdcall myIDDrawSurface1::Unlock(LPVOID a)
{

	if( (_ReturnAddress() == (VOID*)0x004610FB) )
	{
		HRESULT hr = dds_movie->Unlock(NULL);
		RECT rc = { 400,210,1040,660 }; // I'm running at 1440x900 and the movie is centered
		m_pIDDrawSurface->Blt(NULL,dds_movie,&rc,DDBLT_WAIT, NULL);
		return hr;
	}
	return m_pIDDrawSurface->Unlock(a);
}

HRESULT  __stdcall myIDDrawSurface1::Lock(LPRECT a,LPDDSURFACEDESC b,DWORD c,HANDLE d)
{
	if( _ReturnAddress() == (VOID*)0x00461004 )
	{
		if(dds_movie == NULL){
			DDSURFACEDESC ddsd;
			memset(&ddsd, 0, sizeof(ddsd));
			ddsd.dwSize = sizeof(ddsd);
			ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
			ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
			ddsd.dwWidth = 1440; // <----- blah
			ddsd.dwHeight = 900; // <----- blah
			dd->CreateSurface(&ddsd, &dds_movie, NULL);
		}
		return dds_movie->Lock(a,b,c,d);

	}
	return m_pIDDrawSurface->Lock(a,b,c,d);
}


#16 i30817

i30817
  • Member
  • 611 posts

Posted 05 December 2011 - 06:44 AM

Since you're around that zone of the code, could you possibly investigate what would be needed to skip movies? The spell animations mostly 'course.

#17 ghostdog

ghostdog
  • Modder
  • 556 posts

Posted 05 December 2011 - 12:21 PM


All right then. No time for it now, I'll test it tomorrow and try to find the respective offset in the 2CD version.


Posted 2CD VA offset above. If you want the actual file offset its: 0x0003F4E2. Same patch data.

AH, thanks. Temporary blindness can be a bitch :)

#18 Jarno Mikkola

Jarno Mikkola

    The Imp in his pink raincoat.

  • Member
  • 10911 posts

Posted 05 December 2011 - 01:15 PM

Since you're around that zone of the code, could you possibly investigate what would be needed to skip movies? The spell animations mostly 'course.

In BG games there needs to be the movie file named in the baldur.ini file under the [MOVIES] header for them to be skip-able with Esc key, and the files name is actually added to there the first time it's played.
So it might work in Torment too...

[MOVIES]
BISLOGO=1
BWDRAGON=1
WOTC=1
INTRO=1
INTRO15F=1
DEATHAND=1


Deactivated account. The user today is known as The Imp.


#19 i30817

i30817
  • Member
  • 611 posts

Posted 06 December 2011 - 12:56 AM

It's not that. It's the high level spells that have JRGP like unskipable movies. Besides, i wouldn't want to disable them, just skip if mouse pressed.

Edited by i30817, 06 December 2011 - 12:56 AM.


#20 scient

scient
  • Modder
  • 1010 posts

Posted 06 December 2011 - 08:45 AM

I can skip them using ESC in my main install of PST with latest versions of all mods (widescreen v3.05, ddfix v2.1, ghostdog UI v2.02). Actually, even my older debug install which I haven't updated in awhile using buggy nvidia fix I can skip the movies.

Those interested in the classic TBS game Sid Meier's Alpha Centauri / Alien Crossover should check out the unofficial patch I work on here.