Quote EmuD3D8.cpp
// *********************
// * patch: D3DDevice_BeginPush
// TODO: Find a test case and verify this
// At least one XDK has this as return VOID with a second input parameter.
// Is this definition incorrect, or did it change at some point?
// *********************
Although this suggests the possibility that this was changed, Indeed, first revision had 2 input parameters, It change at XDK 4531.
Define two functions that _D3DDevice_BeginPush@8 had 2 input parameter and _D3DDevice_BeginPush@4.
Test case
_D3DDevice_BeginPush@8
Legends of Wrestling
_D3DDevice_BeginPush@4
Crazy Taxi 3
The second param looks like it can return a reference to the push data:
2339 glw_state->device->BeginPush(vert_size + index_size + 60, &glw_state->drawArray);
See the Jedi Academy source code: http://code.metager.de/source/xref/RavenSoftware/jediacademy/codemp/win32/win_qgl_dx8.cpp
Which makes sense, as EndPush takes a reference to the last one!
So before:
PDWORD WINAPI XTL::EMUPATCH(D3DDevice_BeginPush)(DWORD Count)
After
PDWORD WINAPI XTL::EMUPATCH(D3DDevice_BeginPush)(DWORD Count, DWORD** pPushBuffer)
In other cases, we've used a '2' suffix, which would make the second version become : D3DDevice_BeginPush2
RalliSport, XDK 4134 uses two parameters calling convection. just as described by xinixmzeng, but there is no return value ,so it shall be void.
void WINAPI XTL::EMUPATCH(D3DDevice_BeginPush)(DWORD Count, DWORD** pPushBuffer)
and latter EndPush did uses the 2nd parameter's content as its parameter. so it indeed is the reference to the pushbuffer.
an decompiled code from IDA shows.
D3DDevice_BeginPush(0x7FF, &pPushBuffer);
D3DDevice_EndPush(pPushBuffer);
it's quite clear how the api shall be called.
so @jarupxx how shall we modify the OOVPA and uses the correct patch code for the titles?
For clarity, the two code paths/methods seem to be
VOID WINAPI D3DDevice_BeginPush(DWORD Count, DWORD** pPushBuffer);
D3DDevice_BeginPush(count, &pPushbuffer);
D3DDevice_EndPush(pPushBuffer);
and
PDWORD WINAPI D3DDevice_BeginPush(DWORD Count);
pPushBuffer = D3DDevice_BeginPush(count);
D3DDevice_EndPush(pPushBuffer);
We still need to identify with certainty exactly which XDK this change was made in.
@jackchentwkh D3DDevice_BeginPush have such a pattern. That's better to add an offset-pair to make it unique OOVPA.
XDK LEN PATTERN TAILING BYTES
_D3DDevice_BeginPush@8 4361 0030 568B35........6A008BCEE8........8B442408405056E8........8B4C240C 89015EC2080090909090909090909090
_D3DDevice_BeginPush@8 4432 0030 568B35........6A008BCEE8........8B442408405056E8........8B4C240C 89015EC2080090909090909090909090
_D3DDevice_BeginPush@4 4531 0020 568B35........6A008BCEE8........8B442408405056E8........5EC20400
_D3DDevice_BeginPush@4 4627 0050 568B35........6A008BCEE8........8B068B76048B4C240881C6000200008D .......8BD0D1E88D0C8D080200003BC876028BC13BCA76028BD15250E8........C204009090
Fix issue by PR #1124 #1125 #1128.
Would it be possible for close this issue? Great job!
Talking about functions name @RadWolfie. https://github.com/Cxbx-Reloaded/XbSymbolDatabase/issues/6#issue-320127672
In this case, do we have used a argument suffix if API is changed?
become to D3DDevice_BeginPush_8.
XDK have already a functions using '2' suffix, but defined as subroutine called by the main functions, I think.
I only see D3DDevice_BeginPush@4 for newest XDK title. I believe the function had been transition from D3DDevice_BeginPush@8 to D3DDevice_BeginPush@4 method. I can confirm base on @jarupxx's comment above for 4 XDK revisions.
It's similar to what happened with DSound's SetMixBinVolumes@12 change to SetMixBinVolumes@8 function which are named SetMixBinVolumes_12 and SetMixBinVolumes_8 respectfully. Except both functions wasn't in the same XDK revision. Afaik
It should be fine for sub routine, D3DDevice_BeginPush2, to be D3DDevice_BeginPush_4. Since newer revision is only using D3DDevice_BeginPush2 as main function. That's my opinion.
1 minor correction:
old XDK uses D3DDevice_BeginPush@8 (like Rallisport wit 413)
it's the newer XDK using D3DDevice_BeginPush@4 (like CraziTaxi 3 with 4953)
but strangely, the help document from 5849 still shows the call as D3DDevice_BeginPush@8
I can confirm this, however the source says it is just a wrapper for D3DDevice_BeginPush@4 which is the real main function.
It is actually a "backward compatibility" for older game engine to continue work with newer XDK revision. Though, it's strange help doc didn't include the new revision function.
With the assignment for correct XDK in OOVPA registration, the BeginPush and BeginPush2 can be distinguished from XDK 4134 and 4531, even the OOVPA pattern are identical.
that's what the current master version performs.
But it would be better to add the unique pairs to separate them.
As for the subfix, please setup the rule and use the rule, I have no ideas about it.
@jarupxx could you help @jackchentwkh ?
Ah? I thought @jarupxx is already working on it?
I am simply giving me feedback.
Is PR https://github.com/Cxbx-Reloaded/XbSymbolDatabase/pull/4 suppose to do for unique pairs? If so, have some patience while we get XbSymbolDatabase library into more complete form to be use for Cxbx-Reloaded project.
For subfix, have look in issue https://github.com/Cxbx-Reloaded/XbSymbolDatabase/issues/6 for concept rules to follow.
@jackchentwkh Yeah, PR https://github.com/Cxbx-Reloaded/XbSymbolDatabase/pull/4 is that working.
Closing old issue since https://github.com/Cxbx-Reloaded/XbSymbolDatabase/pull/4 had been merged.
Most helpful comment
The second param looks like it can return a reference to the push data:
See the Jedi Academy source code: http://code.metager.de/source/xref/RavenSoftware/jediacademy/codemp/win32/win_qgl_dx8.cpp
Which makes sense, as EndPush takes a reference to the last one!
So before:
After