Wiki

Clone wiki

agtools / Conventions

For those just encountering the AGT code.. here are some more or less consistent patterns you'll find in the examples (if not quite all of the AGT code! At the time of writing it's still being cleaned up!).

s16

A 16bit signed type. -32768 -> +32767

u16

A 16bit unsigned type. 0 -> 65535

s8 u8 s32 u32

As above, for 8bit and 32bit sizes accordingly.

fixed32/fixed_t

An optional 32bit signed type, used for fixedpoint. In all respects identical to s32 but used to indicate purpose (early versions of AGT will still use s32 for this).

s16 g_variable;

A global variable - can be accessed from anywhere including other .cpp files if necessary.

static s16 s_variable;

A file-local (but still global) variable. Can only be accessed from the same .cpp file. Hint: The more local something is in C/C++, the more likely it is to benefit from optimizations.

entity_t *g_pe_object;

A global pointer to an entity.

entity_t *pe_object;

A local pointer to an entity.

s32 s_fxposition; fixed32 s_fxposition;

Both are 16:16 fixedpoint coordinates, denoted by 'f' prefix before the last part of the variable name.

s16 s_xposition;

An integer coordinate. No 'f' prefix.

AGT_

Prefix for lower-level AGT interfaces. Most of these have been moved behind C++ interfaces but a few still remain e.g. AGT_InstallInputService() for installing the keyboard handler at startup.

AGT_BLiT_/AGT_CPU_/AGT_STF_

Prefix for blitter- or cpu-specific low-level AGT interfaces. There will sometimes be an equivalent AGT_CPU_ non-blitter version available on STEs. The STF platform will use AGT_STF_ prefix instead, which is equivalent to AGT_CPU_ on STEs. These functions are rarely needed since most drawing should be done via the entity manager. However sometimes its still useful to be able to call primitives directly.

(s16 _x, s16 _y)

The _ prefix indicates a parameter to a function or method. Something that has been 'passed into' the code and not defined/created locally in the code using it.

(s16 &r_x, s16 &r_y)

The r_ prefix (combined with the C++ reference & symbol) indicates a returned or to-be-modified parameter. The code in the called function will modify/replace/return a value to a variable owned by the caller. Pay attention when you see these - can be a common source of confusion.

Note: This is a typical pattern for returning multiple values from one C++ function.

s16 variable_;

A trailing _ denotes a data member of an object or class. Usually an internal/private member. This notation helps distinguish access to object storage vs parameters or local temporary variables, within complicated areas of code.

examples:

func(s16 _parameter);

void func() { s16 localvariable; }

struct object { s16 objectmember_; };

Updated