1369 Model* model = data;
1382 s32 tintCombineType;
1387 s32 fogR, fogG, fogB, fogA;
1390 mtxPushMode = G_MTX_PUSH;
1391 mtxLoadMode = G_MTX_LOAD;
1396 textureHeader = &textureHandle->
header;
1398 if (textureHandle->
gfx != NULL) {
1401 textureHeader = NULL;
1404 textureHandle = NULL;
1405 textureHeader = NULL;
1409 tintCombineType = 0;
1411 if (textureHeader != NULL) {
1412 switch (extraTileType) {
1459 gDPPipeSync((*gfxPos)++);
1466 gSPSetLights0((*gfxPos)++, lights[0]);
1469 gSPSetLights1((*gfxPos)++, lights[0]);
1472 gSPSetLights2((*gfxPos)++, lights[0]);
1475 gSPSetLights3((*gfxPos)++, lights[0]);
1478 gSPSetLights4((*gfxPos)++, lights[0]);
1481 gSPSetLights5((*gfxPos)++, lights[0]);
1484 gSPSetLights6((*gfxPos)++, lights[0]);
1487 gSPSetLights7((*gfxPos)++, lights[0]);
1493 if (textureHeader != NULL) {
1494 switch (extraTileType) {
1499 s32 shift = prop->
data.
s;
1505 (shift >> 12) & 0xF, (shift >> 16) & 0xF,
1506 offsetS & 0xFFF, (offsetT >> 12) & 0xFFF);
1509 gSPDisplayList((*gfxPos)++, textureHandle->
gfx);
1513 gSPDisplayList((*gfxPos)++, textureHandle->
gfx);
1517 gSPTexture((*gfxPos)++, 0, 0, 0, G_TX_RENDERTILE, G_OFF);
1518 gDPSetCombineMode((*gfxPos)++, G_CC_SHADE, G_CC_SHADE);
1519 gDPSetColorDither((*gfxPos)++, G_CD_MAGICSQ);
1520 gDPSetAlphaDither((*gfxPos)++, G_AD_PATTERN);
1535 if (textureHeader != NULL) {
1537 if (auxCombineType >= 3) {
1556 switch (renderClass) {
1558 switch (renderMode) {
1625 switch (renderMode) {
1689 switch (renderMode) {
1760 switch (renderMode) {
1821 gSPFogPosition((*gfxPos)++, 970, 1000);
1824 switch (renderMode) {
1896 gSPFogPosition((*gfxPos)++, fogMin, fogMax);
1900 switch (renderMode) {
1929 gSPMatrix((*gfxPos)++, model->
finalMtx, mtxLoadMode | mtxPushMode | G_MTX_MODELVIEW);
1930 if (mtxPushMode != G_MTX_NOPUSH) {
1931 mtxPushMode = G_MTX_NOPUSH;
1933 if (mtxLoadMode != G_MTX_MUL) {
1934 mtxLoadMode = G_MTX_MUL;
1938 mtxLoadMode = G_MTX_MUL;
1940 gSPMatrix((*gfxPos)++, model->
finalMtx, mtxLoadMode | mtxPushMode | G_MTX_MODELVIEW);
1941 if (mtxPushMode != G_MTX_NOPUSH) {
1942 mtxPushMode = G_MTX_NOPUSH;
1956 if (textureHeader != NULL) {
1963 switch (extraTileType) {
1965 gDPSetTileSize((*gfxPos)++, G_TX_RENDERTILE, panMainU, panMainV, (textureHeader->
mainW - 1) * 4 + panMainU, (textureHeader->
mainH / 2 - 1) * 4 + panMainV);
1966 gDPSetTileSize((*gfxPos)++, G_TX_RENDERTILE + 1, panAuxU, panAuxV, (textureHeader->
mainW - 1) * 4 + panAuxU, (textureHeader->
mainH / 2 - 1) * 4 + panAuxV);
1969 gDPSetTileSize((*gfxPos)++, G_TX_RENDERTILE, panMainU, panMainV, (textureHeader->
mainW - 1) * 4 + panMainU, (textureHeader->
mainH - 1) * 4 + panMainV);
1970 gDPSetTileSize((*gfxPos)++, G_TX_RENDERTILE + 1, panAuxU, panAuxV, (textureHeader->
auxW - 1) * 4 + panAuxU, (textureHeader->
auxH - 1) * 4 + panAuxV);
1973 gDPSetTileSize((*gfxPos)++, G_TX_RENDERTILE, panMainU, panMainV, (textureHeader->
mainW - 1) * 4 + panMainU, (textureHeader->
mainH - 1) * 4 + panMainV);
1980 gSPMatrix((*gfxPos)++,
gCameras[
gCurrentCamID].mtxBillboard, mtxLoadMode | mtxPushMode | G_MTX_MODELVIEW);
1981 if (mtxPushMode != G_MTX_NOPUSH) {
1982 mtxPushMode = G_MTX_NOPUSH;
1984 if (mtxLoadMode != G_MTX_MUL) {
1985 mtxLoadMode = G_MTX_MUL;
2002 if (mtxPushMode == G_MTX_NOPUSH) {
2003 gSPPopMatrix((*gfxPos)++, G_MTX_MODELVIEW);
2006 gDPPipeSync((*gfxPos)++);
3054 s32 mainWidth, mainHeight;
3055 s32 auxWidth, auxHeight;
3058 s32 mainWrapW, mainWrapH;
3059 s32 auxWrapW, auxWrapH;
3066 s32 auxPaletteIndex;
3069 s32 mainMasks, mainMaskt;
3070 s32 auxMasks, auxMaskt;
3075 mainWidth = header->
mainW;
3076 mainHeight = header->
mainH;
3079 auxPaletteIndex = 0;
3091 filteringMode = header->
filtering << G_MDSFT_TEXTFILT;
3093 auxWidth = header->
auxW;
3094 auxHeight = header->
auxH;
3106 if (palette != NULL) {
3107 auxPaletteIndex = 1;
3109 auxPaletteIndex = 0;
3113 if (palette != NULL || auxPalette != NULL) {
3114 lutMode = G_TT_RGBA16;
3115 if (palette != NULL) {
3116 if (mainBitDepth == G_IM_SIZ_4b) {
3117 gDPLoadTLUT_pal16((*gfxPos)++, 0, palette);
3118 }
else if (mainBitDepth == G_IM_SIZ_8b) {
3119 gDPLoadTLUT_pal256((*gfxPos)++, palette);
3122 if (auxPalette != NULL) {
3123 if (auxBitDepth == G_IM_SIZ_4b) {
3124 gDPLoadTLUT_pal16((*gfxPos)++, auxPaletteIndex, auxPalette);
3125 }
else if (auxBitDepth == G_IM_SIZ_8b) {
3126 gDPLoadTLUT_pal256((*gfxPos)++, auxPalette);
3130 lutMode = G_TT_NONE;
3139 if (texCombineType >= 3) {
3151 switch (extraTileType) {
3153 lodMode = G_TL_TILE;
3154 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
3155 switch (mainBitDepth) {
3157 gDPLoadTextureBlock_4b((*gfxPos)++, raster, mainFmt,
3158 mainWidth, mainHeight, 0,
3159 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3162 gDPLoadTextureBlock((*gfxPos)++, raster, mainFmt, G_IM_SIZ_8b,
3163 mainWidth, mainHeight, 0,
3164 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3167 gDPLoadTextureBlock((*gfxPos)++, raster, mainFmt, G_IM_SIZ_16b,
3168 mainWidth, mainHeight, 0,
3169 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3172 gDPLoadTextureBlock((*gfxPos)++, raster, mainFmt, G_IM_SIZ_32b,
3173 mainWidth, mainHeight, 0,
3174 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3180 switch (mainBitDepth) {
3182 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3183 mainWidth / lodDivisor * 4 >= 64 && mainHeight / lodDivisor != 0;
3184 rasterPtr += mainWidth / lodDivisor * mainHeight / lodDivisor / 2, lodDivisor *= 2, lod++)
3186 gDPLoadMultiTile_4b((*gfxPos)++, rasterPtr, (u32)(rasterPtr - raster) >> 3, lod, mainFmt,
3187 mainWidth / lodDivisor, mainHeight / lodDivisor,
3188 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3189 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3193 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3194 mainWidth / lodDivisor * 8 >= 64 && mainHeight / lodDivisor != 0;
3195 rasterPtr += mainWidth / lodDivisor * mainHeight / lodDivisor, lodDivisor *= 2, lod++)
3197 gDPLoadMultiTile((*gfxPos)++, rasterPtr, ((u32)(rasterPtr - raster)) >> 3, lod, mainFmt, G_IM_SIZ_8b,
3198 mainWidth / lodDivisor, mainHeight / lodDivisor,
3199 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3200 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3204 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3205 mainWidth / lodDivisor * 16 >= 64 && mainHeight / lodDivisor != 0;
3206 rasterPtr += mainWidth / lodDivisor * mainHeight / lodDivisor * 2, lodDivisor *= 2, lod++)
3208 gDPLoadMultiTile((*gfxPos)++, rasterPtr, ((u32)(rasterPtr - raster)) >> 3, lod, mainFmt, G_IM_SIZ_16b,
3209 mainWidth / lodDivisor, mainHeight / lodDivisor,
3210 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3211 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3215 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3216 mainWidth / lodDivisor * 32 >= 64 && mainHeight / lodDivisor != 0;
3217 rasterPtr += mainWidth / lodDivisor * mainHeight / lodDivisor * 4, lodDivisor *= 2, lod++)
3219 gDPLoadMultiTile((*gfxPos)++, rasterPtr, ((u32)(rasterPtr - raster)) >> 4, lod, mainFmt, G_IM_SIZ_32b,
3220 mainWidth / lodDivisor, mainHeight / lodDivisor,
3221 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3222 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3226 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, lod - 1, G_TX_RENDERTILE, G_ON);
3229 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
3230 gDPPipeSync((*gfxPos)++);
3231 lodMode = G_TL_TILE;
3232 switch (mainBitDepth) {
3235 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3236 auxOffsetS, auxOffsetT, auxShiftS, auxShiftT);
3240 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3241 auxOffsetS, auxOffsetT, auxShiftS, auxShiftT);
3245 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3246 auxOffsetS, auxOffsetT, auxShiftS, auxShiftT);
3250 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3251 auxOffsetS, auxOffsetT, auxShiftS, auxShiftT);
3256 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
3257 lodMode = G_TL_TILE;
3258 switch (mainBitDepth) {
3260 gDPLoadTextureTile_4b((*gfxPos)++, raster, mainFmt, mainWidth, mainHeight,
3261 0, 0, mainWidth - 1, mainHeight - 1, 0,
3262 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3263 lodDivisor = (((mainWidth * mainHeight) >> 1) + 7)>>3;
3266 gDPLoadTextureTile((*gfxPos)++, raster, mainFmt, G_IM_SIZ_8b, mainWidth, mainHeight,
3267 0, 0, mainWidth - 1, mainHeight - 1, 0,
3268 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3269 lodDivisor = ((mainWidth * mainHeight) + 7)>>3;
3272 gDPLoadTextureTile((*gfxPos)++, raster, mainFmt, G_IM_SIZ_16b, mainWidth, mainHeight,
3273 0, 0, mainWidth - 1, mainHeight - 1, 0,
3274 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3275 lodDivisor = ((mainWidth * mainHeight) * 2 + 7)>>3;
3278 gDPLoadTextureTile((*gfxPos)++, raster, mainFmt, G_IM_SIZ_32b, mainWidth, mainHeight,
3279 0, 0, mainWidth - 1, mainHeight - 1, 0,
3280 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3281 lodDivisor = ((mainWidth * mainHeight / 2) * 2 + 7)>>3;
3285 switch (auxBitDepth) {
3288 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3289 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3290 auxShiftS, auxShiftT, auxOffsetS, auxOffsetT);
3293 gDPScrollMultiTile((*gfxPos)++, auxRaster, lodDivisor, 1, auxFmt, G_IM_SIZ_8b, auxWidth, auxHeight,
3294 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3295 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3296 auxShiftS, auxShiftT, auxOffsetS, auxOffsetT);
3299 gDPScrollMultiTile((*gfxPos)++, auxRaster, lodDivisor, 1, auxFmt, G_IM_SIZ_16b, auxWidth, auxHeight,
3300 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3301 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3302 auxShiftS, auxShiftT, auxOffsetS, auxOffsetT);
3305 gDPScrollMultiTile((*gfxPos)++, auxRaster, lodDivisor, 1, auxFmt, G_IM_SIZ_32b, auxWidth, auxHeight,
3306 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3307 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3308 auxShiftS, auxShiftT, auxOffsetS, auxOffsetT);
3312 gSPSetOtherMode((*gfxPos)++, G_SETOTHERMODE_H, 4, 16, filteringMode | G_TC_FILT | lutMode | lodMode | G_TP_PERSP );