1)
- gsGlobal = gsKit_init_global();
gsGlobal->Mode = GS_MODE_DTV_480P;
gsGlobal->Interlace = GS_NONINTERLACED;
gsGlobal->Field = GS_FRAME;
gsGlobal->Width = 720;
gsGlobal->Height = 480;
gsKit_init_screen(gsGlobal);
2)
- Make sure libpng support is compiled into gsKit.
Load the relevant iop modules for hdd access.
Mount your +MyProject partition into a free partition slot
gsKit_texture_png(gsGlobal, myTexture, pfs0:/images/image01.png);
3)
- Draw a textured primitive using your texture and texture's information.
If you're in persistent mode, you don't need to redraw in a loop just
If you're in oneshot mode, you need to redraw your primitive every loop.
The examples show how to do this.
4)
- You need to initialize your controller using libpad.
Change the relevant attributes as listed in 1 to define the mode you want.
Then call gsKit_init_screen(gsGlobal); which will reset gsKit.
You'll need to reupload your textures and such.
Look at gsInit.c for the display attributes you can use per mode as you can magnify your draw buffer for larger screens without sacrificing vram. The vsync example has multiple examples for different modes.
I tried to answer your questions as best as I could. Specific answers would require quite a large amount of space, heh. The best way to understand gsKit, at least for drawing, would be to look at libgs's source and its examples in ps2sdk, then compare the libraries together.
A guide to gsKit:
Global Init:
This gsKit_init_global function allocates memory, sets sane defaults for the gsGlobal values, and returns the structure as a pointer to its location. This is done before all else.
DMAKit Init:
The examples show how to do this. GSKit is a GIF (path3) only library so you should only need dmaKit_init(...); and dmaKit_chan_init(DMA_CHANNEL_GIF);. I think the FROMSPR and TOSPR channel inits are leftovers when gsKit still used scratchpad ram. This is done prior to using any function of gsKit except for gsKit_init_global.
Screen Init:
The gsKit_init_screen function will reset the mode and initialize the screen defined in the gsGlobal. It also sets up the drawing environment as well, so changes to your drawing environment values in gsGlobal will be reflected in the reset screen.
DE Info:
The drawing environment registers are static, so if you change a register, it changes it for every primitive drawn after the change. You can change, draw a primitive, change again, to do it on a per-primitive basis. The problem is that they're lumped in with the generic registers used for drawing as well. You can generally tell what a drawing environment register is by seeing if it has its own setter. Libgs is a great example for this. The textured primitives change the texture registers in order to map the texture onto them.
DMA Info:
GSKit uses two "pools" of dma space.
A "pool" is allocated memory to store the queue.
The "queue" is what you are currently drawing and is stored in the pool.
Drawing something specific on the PS2 takes multiple primitives, so the method is to start a dma chain(queue) for the express purpose of drawing the specific "something". GSKit takes this approach but separates it, so your primitives are stored in either a persistent queue or oneshot queue. The larger the queue gets, the more it fills the pool so it's quite possible to "flood" the pool.
Queues:
Persistent mode is the "Set it and forget it" pool, where you draw everything once, and it stays in the pool until you manually clear the queue.
Oneshot mode is a double-buffered pool, where when the queue is executed, the pool is switched allowing you to fill it again.
Primitives:
You call a function with the primitive's attributes as its parameters and it gets drawn by gsKit by filling the queue with tags that are filled by the parameters.
Primitive tags:
A "qword" is a 128-bit integer.
Primitives are made up of multiple tags or qwords. These tags set various information about the primitive. Generally, the last vertex point for the primitive (XYZ2) will kick off drawing. If you use (XYZ3) the drawing won't start. GSKit uses 64-bit memaligned pools so you need to do the first 64-bits, increment, do the next 64-bits, increment, etc... You can look at gsPrimitive.c in order to see how to draw primitives in reglist format or packed format.
Primitive tag formats:
REGLIST allows you to start the primitive using specific registers, then each qword following is 64x2 filled with data for each register in the order * NLOOP from the GIF_AD tag. If the registers are odd, then the last 64-bits is ignored. The point primitive is a good example for this.
PACKED is where each qword is data+register, where the first 64 bits are filled with data, and the last 64 bits is the register to put the data. The linestrip primitive is a good example for this.
I'm pretty sure only registers 0x00 - 0x0F are allowed in reglist mode.
Primitive coordinates:
The primitive coordinate system is handled by gsKit and offsets the coordinates for drawn primitives by the offset amount. This lets you draw primitives using negative coordinates. GSKit uses 2048 as the default offset value. Basically, think of a grid, and then your draw buffer starting at the offset point. Primitives coordinates would need to be at that offset point or higher to draw within your draw buffer.
I think that's about it for now :?. My fingers are getting tired :D.