SetTile			
		==================================			
									
	Any Link Below is truncated to the root of SDK Manual, 		
             NINTENDO%2064%20SDK%205_CDROM/man/allman50 	
		Can Also be downloaded at romhacking			
									
		Compiled By Trevor					
		Credits to Zoinkity for Original Find			


typedef struct {
		int		cmd:8;
		unsigned int	fmt:3;
		unsigned int	siz:2;
		unsigned int	pad0:1;
		unsigned int	line:9;
		unsigned int	tmem:9;
		unsigned int	pad1:5;
		unsigned int	tile:3;
		unsigned int	palette:4;
		unsigned int	ct:1;
		unsigned int	mt:1;
		unsigned int	maskt:4;
		unsigned int	shiftt:4;
		unsigned int	cs:1;
		unsigned int	ms:1;
		unsigned int	masks:4;
		unsigned int	shifts:4;
} Gsettile;


For refrence I have included Zoinkity's Original Findings.
 
upper word
format	0x00000000	000	rgba
	0x00200000	001	yuv 
	0x00400000	010	ci
	0x00600000	011	ia
	0x00800000	100	i
size	0x00000000	000	4bit
	0x00080000	01	8bit
	0x00100000	10	16bit
	0x00180000	11	32bit
	0x0003FE00	line
	0x000001FF	tmem	TMEM offset words (64bit)

lower word
07000000	tile
00F00000	palette
00080000	clamp t
00040000	mirror t
0003C000	mask t
00003C00	shift t
00000200	clamp s
00000100	mirror s
000000F0	mask s
0000000F	shift s
	
	


BitMap: C=Clamp, M=Mirror, PAL=Pallet
1111 0101 100 1 0 00 0 0000 000 0 0010 0000 0000 0 111 0000 0 0 00 00 00 00 0 0 0000 0000
CMD FMT SZE LINE TMEM PAD TILE PAL C M MSK S SHFTS C M MSK T SHFTT
000 rgba
001 yuv
010 ci
011 ia
100 i
00 4bit
01 8bit
10 16bit
11 32bit
Words
per
Line
Address
offset
Words
Null 0-7 0-F 0-F 0-F 0-F 0-F


Applies image assuming given attibutes.
ie. F5600600 00FD8360 would load a 48x48 intensity+alpha image with 4bit pixel data and clamping the corners to the s/t given in the point data.
If palettes are loaded, you can set the palette bits to swap palettes at runtime.
	How does this work... Line = 000000011 =3... how does 3 = 48?
	OK, oops, worked it out, 3 * 16 = 48. 16 because 64/4bit = 16. Each line is 16 texels

Mip-Maps must set shift values(hex) to their level (may vary for non-square textures). 
	EG,	Tile 0 shift 0 (1) 
		Tile 1 Shift 1 (0.5)
		Tile 2 Shift 2 (0.25)
		etc.
This allows 1 texel of Tile1 to cover the same area as 2x2 texels of Tile0 and 1 texel of Tile2 to cover 4x4 texels of Tile0.

To allow an effect where distance warrants more varieation but less sharp detail like a field you can set 2 32x32 textures to the same shift values above.
Alternativly you can set a 64x32 texture to mip-map down and double the shift value. This will get blurry very quickly.


Mapping this texture on Tile 0 and 1 with a shift of 4 makes



Result is the same as using Detail mode, except that in Detail Mode you UV the "bigger" image, in this mode you UV the "Smaller" image.
Also different is that Detail uses another texture while LOD can re-use a tile Given this example
Tile 0 = Shift 0, TMEM ADD = 0
Tile 1 = Shift 4, TMEM ADD = 0
Tile 2 = Shift 5, TMEM ADD = +1 (assuming Tile0 was 64x32x4 this add would be 1024)
Tile 3 = Shift 6, TMEM ADD = +2 (1,536)
Tile 4 = Shift 7, TMEM ADD = +3 (1,792)
Tile 5 = Shift 8, TMEM ADD = +4 (1,920)
Tile 6 = Shift 9, TMEM ADD = +5 (1,984)



Visualisation of 4bit CI Mode Tile Storage in TMEM for 2 textures or 1 texture + detail. 
Textures are 64x32 and 32x32 mip-mapped (32x32 not mip-mapped as detail)
Each texture has 3 levels instead of 5 but is sufficiant to minimise moiring.
8Bit Ci can only have 1 pallet at a time
4bit IA can have double 1legnth but more moiring will occur since still only 3 tiles allowed each.
eg, 64x64 and 64x32