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;
3105 if (palette != NULL) {
3106 auxPaletteIndex = 1;
3108 auxPaletteIndex = 0;
3112 if (palette != NULL || auxPalette != NULL) {
3113 lutMode = G_TT_RGBA16;
3114 if (palette != NULL) {
3115 if (mainBitDepth == G_IM_SIZ_4b) {
3116 gDPLoadTLUT_pal16((*gfxPos)++, 0, palette);
3117 }
else if (mainBitDepth == G_IM_SIZ_8b) {
3118 gDPLoadTLUT_pal256((*gfxPos)++, palette);
3121 if (auxPalette != NULL) {
3122 if (auxBitDepth == G_IM_SIZ_4b) {
3123 gDPLoadTLUT_pal16((*gfxPos)++, auxPaletteIndex, auxPalette);
3124 }
else if (auxBitDepth == G_IM_SIZ_8b) {
3125 gDPLoadTLUT_pal256((*gfxPos)++, auxPalette);
3129 lutMode = G_TT_NONE;
3138 if (texCombineType >= 3) {
3150 switch (extraTileType) {
3152 lodMode = G_TL_TILE;
3153 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
3154 switch (mainBitDepth) {
3156 gDPLoadTextureBlock_4b((*gfxPos)++, raster, mainFmt,
3157 mainWidth, mainHeight, 0,
3158 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3161 gDPLoadTextureBlock((*gfxPos)++, raster, mainFmt, G_IM_SIZ_8b,
3162 mainWidth, mainHeight, 0,
3163 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3166 gDPLoadTextureBlock((*gfxPos)++, raster, mainFmt, G_IM_SIZ_16b,
3167 mainWidth, mainHeight, 0,
3168 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3171 gDPLoadTextureBlock((*gfxPos)++, raster, mainFmt, G_IM_SIZ_32b,
3172 mainWidth, mainHeight, 0,
3173 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3179 switch (mainBitDepth) {
3181 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3182 mainWidth / lodDivisor * 4 >= 64 && mainHeight / lodDivisor != 0;
3183 rasterPtr += mainWidth / lodDivisor * mainHeight / lodDivisor / 2, lodDivisor *= 2, lod++)
3185 gDPLoadMultiTile_4b((*gfxPos)++, rasterPtr, (u32)(rasterPtr - raster) >> 3, lod, mainFmt,
3186 mainWidth / lodDivisor, mainHeight / lodDivisor,
3187 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3188 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3192 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3193 mainWidth / lodDivisor * 8 >= 64 && mainHeight / lodDivisor != 0;
3194 rasterPtr += mainWidth / lodDivisor * mainHeight / lodDivisor, lodDivisor *= 2, lod++)
3196 gDPLoadMultiTile((*gfxPos)++, rasterPtr, ((u32)(rasterPtr - raster)) >> 3, lod, mainFmt, G_IM_SIZ_8b,
3197 mainWidth / lodDivisor, mainHeight / lodDivisor,
3198 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3199 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3203 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3204 mainWidth / lodDivisor * 16 >= 64 && mainHeight / lodDivisor != 0;
3205 rasterPtr += mainWidth / lodDivisor * mainHeight / lodDivisor * 2, lodDivisor *= 2, lod++)
3207 gDPLoadMultiTile((*gfxPos)++, rasterPtr, ((u32)(rasterPtr - raster)) >> 3, lod, mainFmt, G_IM_SIZ_16b,
3208 mainWidth / lodDivisor, mainHeight / lodDivisor,
3209 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3210 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3214 for (rasterPtr = raster, lod = 0, lodDivisor = 1;
3215 mainWidth / lodDivisor * 32 >= 64 && mainHeight / lodDivisor != 0;
3216 rasterPtr += mainWidth / lodDivisor * mainHeight / lodDivisor * 4, lodDivisor *= 2, lod++)
3218 gDPLoadMultiTile((*gfxPos)++, rasterPtr, ((u32)(rasterPtr - raster)) >> 4, lod, mainFmt, G_IM_SIZ_32b,
3219 mainWidth / lodDivisor, mainHeight / lodDivisor,
3220 0, 0, mainWidth / lodDivisor - 1, mainHeight / lodDivisor - 1, 0,
3221 mainWrapW, mainWrapH, mainMasks - lod, mainMaskt - lod, lod, lod);
3225 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, lod - 1, G_TX_RENDERTILE, G_ON);
3228 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
3229 gDPPipeSync((*gfxPos)++);
3230 lodMode = G_TL_TILE;
3231 switch (mainBitDepth) {
3234 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3235 auxOffsetS, auxOffsetT, auxShiftS, auxShiftT);
3239 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3240 auxOffsetS, auxOffsetT, auxShiftS, auxShiftT);
3244 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3245 auxOffsetS, auxOffsetT, auxShiftS, auxShiftT);
3249 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD,
3250 auxOffsetS, auxOffsetT, auxShiftS, auxShiftT);
3255 gSPTexture((*gfxPos)++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
3256 lodMode = G_TL_TILE;
3257 switch (mainBitDepth) {
3259 gDPLoadTextureTile_4b((*gfxPos)++, raster, mainFmt, mainWidth, mainHeight,
3260 0, 0, mainWidth - 1, mainHeight - 1, 0,
3261 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3262 lodDivisor = (((mainWidth * mainHeight) >> 1) + 7)>>3;
3265 gDPLoadTextureTile((*gfxPos)++, raster, mainFmt, G_IM_SIZ_8b, mainWidth, mainHeight,
3266 0, 0, mainWidth - 1, mainHeight - 1, 0,
3267 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3268 lodDivisor = ((mainWidth * mainHeight) + 7)>>3;
3271 gDPLoadTextureTile((*gfxPos)++, raster, mainFmt, G_IM_SIZ_16b, mainWidth, mainHeight,
3272 0, 0, mainWidth - 1, mainHeight - 1, 0,
3273 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3274 lodDivisor = ((mainWidth * mainHeight) * 2 + 7)>>3;
3277 gDPLoadTextureTile((*gfxPos)++, raster, mainFmt, G_IM_SIZ_32b, mainWidth, mainHeight,
3278 0, 0, mainWidth - 1, mainHeight - 1, 0,
3279 mainWrapW, mainWrapH, mainMasks, mainMaskt, G_TX_NOLOD, G_TX_NOLOD);
3280 lodDivisor = ((mainWidth * mainHeight / 2) * 2 + 7)>>3;
3284 switch (auxBitDepth) {
3287 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3288 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3289 auxShiftS, auxShiftT, auxOffsetS, auxOffsetT);
3292 gDPScrollMultiTile((*gfxPos)++, auxRaster, lodDivisor, 1, auxFmt, G_IM_SIZ_8b, auxWidth, auxHeight,
3293 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3294 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3295 auxShiftS, auxShiftT, auxOffsetS, auxOffsetT);
3298 gDPScrollMultiTile((*gfxPos)++, auxRaster, lodDivisor, 1, auxFmt, G_IM_SIZ_16b, auxWidth, auxHeight,
3299 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3300 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3301 auxShiftS, auxShiftT, auxOffsetS, auxOffsetT);
3304 gDPScrollMultiTile((*gfxPos)++, auxRaster, lodDivisor, 1, auxFmt, G_IM_SIZ_32b, auxWidth, auxHeight,
3305 0, 0, auxWidth - 1, auxHeight - 1, auxPaletteIndex,
3306 auxWrapW, auxWrapH, auxMasks, auxMaskt,
3307 auxShiftS, auxShiftT, auxOffsetS, auxOffsetT);
3311 gSPSetOtherMode((*gfxPos)++, G_SETOTHERMODE_H, 4, 16, filteringMode | G_TC_FILT | lutMode | lodMode | G_TP_PERSP );