Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Amusing Saturn Algorithms

5 views
Skip to first unread message

Mickwest

unread,
Jul 19, 1995, 3:00:00 AM7/19/95
to
I can post the whole routine due to NDA restrictions, but this bit made me
laugh:

(*(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.

the anti clayton

unread,
Jul 20, 1995, 3:00:00 AM7/20/95
to
mick...@aol.com (Mickwest) wrote:

>(*(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


Mickwest

unread,
Jul 20, 1995, 3:00:00 AM7/20/95
to
ga...@byc.easynet.co.uk (the anti clayton) wrote:

>What dev kit are you using, PSYQ or CartDev?

PsyQ, and lots of them.

Mick.

Blake Kadatz

unread,
Jul 21, 1995, 3:00:00 AM7/21/95
to mick...@aol.com

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.


M.W. Holcroft

unread,
Jul 21, 1995, 3:00:00 AM7/21/95
to
In article <3ukebp$m...@newsbf02.news.aol.com>, mick...@aol.com (Mickwest) writes:

> (*(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.

Jeff Lander

unread,
Jul 26, 1995, 3:00:00 AM7/26/95
to
If you seriously want to know about it, send me the
code. In context I can figure it out pretty easy. I have
spent quite a bit of time on the Saturn now and am getting
pretty good at translation of the JapEnglish in the sample
code.

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

Frank Pitt

unread,
Jul 29, 1995, 3:00:00 AM7/29/95
to
In article <3ukebp$m...@newsbf02.news.aol.com> mick...@aol.com writes:
>
>I can post the whole routine due to NDA restrictions, but this bit made me
>laugh:
>
>(*(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?

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)


0 new messages