Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


can someone explain this?

This topic is 5582 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve never worked in Linux, just plain Solaris and some of the lines looks new to me. I''m a newbie to game dev too... thanks 1. What is the purpose of this code block? { u_int *source, *end; u_int addr_printf, addr_scePrintf; int counter = 0; addr_printf = ((u_int) printf & 0xFFFFFF) / 4; addr_scePrintf = ((u_int) scePrintf & 0xFFFFFF) / 4; source = (u_int *) sceGsSyncPath; end = source + 195; while (source < end) { if ((*source & 0xFF000000) == 0x0C000000) { // Function call... if ((*source & 0xFFFFFF) == addr_printf) { *source = 0x0C000000 | addr_scePrintf; counter++; } } source++; } } ********************************* 2. Many games display a checklist of objectives and mark them off as the player completes them: complete Find Red Key incomplete Open Red Door incomplete Slay All Dragons ( 2 left ) incomplete Rescue Princess ******************************** 3. What is returned below from "unsigned long color = VidSetAlpha( 255 );" unsigned long VidSetAlpha( signed char Alpha ) { unsigned long color; color = 0x80808000; // gray ( red | green | blue | alpha ) color |= Alpha; //****** WHAT''s this |= ****** return color; } Describe the code interface for such an objectives system. *********************************

Share this post

Link to post
Share on other sites

1) That code has nothing whatsoever to do with Linux.

a) It''s hideous!

b) It''s PS2 specific code.

c) It''s replacing calls to the C runtime library printf() with the PS2 OS scePrintf().

d) It looks like its replacing those calls in "sceGsSyncPath()" (a libgraph function) or an OS wide jump table. (eek!, where''s the cache sync afterwards...)

e) There''s a few hard coded assumptions in there which I''m uneasy with (195...) - that''s the kind of code which crashes when you change library version.

f) If it had comments you''d know what it did!

g) Maybe the function name is also descriptive.

h) Definately NOT beginner coder or beginner game coder code.

2) Yes, many do. If you''re after implentation details - "Finite State Machine" is your search term.

3) |= is a "bitwise OR" of the variable to the left and whatever is to the right with the result stored into the variable on the left. E.g.:

int a = 0x4018; // == %0100000000011000 in binary
int b = 0x0700; // == %0000011100000000 in binary

// then do
a |= b;

a is now == 0x4718 ( %0100011100011000 in binary )

In the particular example you give, the unsigned char (byte) containing "Alpha" passed into the function is bitwise OR''d with the rest of the value - it will end up in the low 8 bits.

Questions 1 & 3 are referring to very specific low level programming things specific to a single piece of hardware - i.e. the PS2.

If you''re new to games programming then I think you should start simple and avoid any low level engine code until you''re properly ready.

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!