User:Wildex999
Jump to navigation
Jump to search
E-Mail: Wildex999[at]gmail.com
Wildex999's Notes during the learning of programming for the Wii
I have had trouble finding documentation to a lot of stuff while trying to learn Wii homebrew programming, therefore I will put some notes her with what I have found out that I could find little/no documentation for. In hope to help others, and for myself ;)
Graphics
- FB stands for "FrameBuffer"(Holds the screen image i suppose)
- XFB stands for "External FrameBuffer"(Video RAM?)
- EFB stands for "Embedded FrameBuffer"(Main RAM?)
-
Images/Textures in GX needs to have a width and height that is multiples of 4(Hardware limit?)
By that I guess it means that image width/height have to be: 4, 8, 12, 16, 20...128....256(4+4+4+4 etc.) - Vertexes, Martixes and stuff like that is still a bit new to me, but I try to figure out a bit of in the go, and I have to say, the libOGC documentation isn't helping TOO much.
So, if I'm not TOO much mistaken:
This function will set what information and how, is included in each vertex. Definition:
void GX_SetVtxAttrFmt (u8 vtxfmt, u32 vtxattr, u32 comptype, u32 compsize, u32 frac)
Example:
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0);
"GX_SetVtxAttrFmt" = GX_Set Vertex Attribute Format(?)
"u8 vtxfmt" = Vertex Format to set to(GX_VTXFMT0..GX_VTXFMT7)
"u32 vtxattr" = Attribute to set(GX_VA_POS, GX_VA_TEX0, GX_VA_CLR0)(Position, Texture0, Color0)
"u32 comptype" = Component type, It defines the Attribute value type I think.(GX_POS_XY, GX_POS_XYZ, GX_TEX_ST, GX_CLR_RGBA...)
"u32 compsize" = The size of the comptype input. (GX_F32, GX_U8, GXS16...)
"u32 frac" = I have no idea, enlighten me anyone? I have always seen this set to 0.
Comptype and compsize defines the input, so, if you have this:
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0);
You would call this function when you wanted to define the position of a vertex:
GX_Position2f32(x, y);
As you see, it takes two arguments(GX_POS_XY, where XY is the two arguments) and the arguments is in the format f32(float).
If you instead set it like:
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
You would set the vertex position like this:
GX_Position3s16(x, y, z);
It's quite simple actually. The same counts for setting texture coordinates and vertex color.
Example:
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
...
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position2f32(x, y);
GX_TexCoord2f32(s,t);
..
GX_End();
Any corrections, or answers to my questions in the list, go to the discussion page.
Other
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
is a line of code often seen in the graphics initialization of a Wii program. Not much information about it is given though. It's definition is:
#define MEM_K0_TO_K1(x) (void*)((u32)(x) + (SYS_BASE_UNCACHED - SYS_BASE_CACHED))
#define MEM_K1_TO_K0(x) (void*)((u32)(x) - (SYS_BASE_UNCACHED - SYS_BASE_CACHED))
So, basically it converts the framebuffer address given in an cached area, to an uncached area of memory, or the other way(K1_TO_K0).(A little enlightenment on why/what?)- libOGC has a partly filled out documentation here: http://libogc.devkitpro.org/index.html