(*(void(*)(void))*(void**)((Uint32)&SlaveCommand+0x20000000))();
After I stopped laughing I got a headache trying to work out what it
meant. Can anyone possibly describe the function of this line in a single
sentence?
Mick.
>(*(void(*)(void))*(void**)((Uint32)&SlaveCommand+0x20000000))();
>Mick.
Easy! (explaining it, not the single sentence bit)
( * (void(*)(void)) * (void**)( (Uint32)&SlaveCommand +0x20000000))()
f e d c a b g
The steps are:
a) (Uint32)&SlaveCommand
Cast the adress of SlaveCommand to be a U32
b) +0x20000000
Put SlaveCommand to SH2 writethrough mem avoiding cache inchoherency
between the 2 sh2s.
c) (void**)
Cast the result into a ptr to a table of ptrs.
d) *
Derefernence this to get the first element
e) (void(*)(void))
Cast that to a ptr to function returning void with no params
f) *
Dereference this call it it
g) ()
Param for function call
This is the same but is a bit easier on the eyes:
typedef void (*FUNC_PTR)(void)
FUNC_PTR * FuncTab;
FUNC_PTR Function;
FuncTab = (FUNC_PTR *) ((Uint32)&SlaveCommand +0x20000000);
Function=FuncTab[0];
Function();
I think that's right otherwise I'm going to look a bit of a tit.
What dev kit are you using, PSYQ or CartDev?
______________________________________________________________________
t h e a n t i c l a y t o n (c) 1994/95
>What dev kit are you using, PSYQ or CartDev?
PsyQ, and lots of them.
Mick.
Can you provide more information on development systems for the Sega
Saturn and also the Sony PS/X? I'm interested in third-party providers
of development systems. Voice/fax and/or e-mail would be appreciated.
Thanks.
>Mick.
> (*(void(*)(void))*(void**)((Uint32)&SlaveCommand+0x20000000))();
> {snip} Can anyone possibly describe the function of this line in a single
> sentence?
No. Never having seen anything of a Saturn other than a cardboard box (and not
wanting to see anything more, reckoning the PS is miles better:), My best
attempt is:
cast ( address of SlaveCommand ) + ( 0x20000000 ) to Uint32 (unsigned long?)
result is is the address of a function, which takes no parameters.
Like I said, my best shot, especially seeing as I have work I should be doing
instead of working out this:?
Mark.
If it is just to point out how bad the samples are, let
me concur with you on that. Both the Saturn and Sony systems
are filled with horrible demos, with comments only in Kanji.
Jeff Lander
I'll give it a go.
It's taking the address of SlaveCommand, casting it to an unsigned 32 bit
integer, adding hex 200000000, casting that value to be a pointer to a
void pointer, de-referencing that pointer, and then casting the final value
to be a pointer to a function that takes no argument and has no return value,
and _then_ (finally) it actually calls that function.
Wonderful piece of code. Must rememeber it for future inclusion in
collections of obfuscated code (or for those silly job interview tests)
:-)
Frankie
Frank G. Pitt | Motif/Solaris/C++ | <fra...@mundens.equinox.gen.nz>
Christchurch | Trunked Networks | <fra...@trunk.tait.co.nz>
New Zealand | Tait Electronics | (064)(03)358-0146 (Munden's Bar)