diff --git a/include/gbi_custom.h b/include/gbi_custom.h index 58e353de72..04684dc15c 100644 --- a/include/gbi_custom.h +++ b/include/gbi_custom.h @@ -63,4 +63,26 @@ (lrs + scrolls)<>2)-1, \ + CALC_DXT_4b(width)); \ + gDPPipeSync(pkt); \ + gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ + G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ + shifts); \ + gDPSetTileSize(pkt, G_TX_RENDERTILE,\ + (scrolls) << G_TEXTURE_IMAGE_FRAC,\ + (scrollt) << G_TEXTURE_IMAGE_FRAC, \ + ((width)-1 + scrolls) << G_TEXTURE_IMAGE_FRAC, \ + ((height)-1 + scrollt) << G_TEXTURE_IMAGE_FRAC) \ +} + #endif diff --git a/src/sprite.c b/src/sprite.c index 674de63cd2..a9d2a9498b 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -202,10 +202,95 @@ void spr_appendGfx_component_flat( f32 arg5, Matrix4f mtx, s32 alpha -); +) { + gDPLoadTLUT_pal16(gMasterGfxPos++, 0, palette); + if (D_80151328->flags & 1) { + gDPScrollMultiTile2_4b(gMasterGfxPos++, raster, G_IM_FMT_CI, width, height, + 0, 0, width - 1, height - 1, 0, + G_TX_CLAMP, G_TX_CLAMP, 8, 8, G_TX_NOLOD, G_TX_NOLOD, + 256, 256); + gDPSetTile(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0x0100, 2, 0, G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); + gDPSetTileSize(gMasterGfxPos++, 2, 0, 0, 63 << 2, 0); + if (D_80151328->flags & 2) { + Camera* camera = &gCameras[gCurrentCamID]; + if (gGameStatusPtr->isBattle == 2) { + gSPViewport(gMasterGfxPos++, &D_802DF3E0); + } else { + gSPViewport(gMasterGfxPos++, &camera->vpAlt); + } + if (alpha == 255) { + gDPSetRenderMode(gMasterGfxPos++, AA_EN | Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | + G_RM_PASS, AA_EN | Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)); + } else { + gDPSetRenderMode(gMasterGfxPos++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + } -INCLUDE_ASM(s32, "sprite", spr_appendGfx_component_flat); + gDPSetEnvColor(gMasterGfxPos++, 0, 0, 0, alpha); + gDPSetCombineLERP(gMasterGfxPos++, 0, 0, 0, 0, ENVIRONMENT, 0, TEXEL1, 0, 0, 0, 0, 0, 0, 0, 0, COMBINED); + gSPVertex(gMasterGfxPos++, vertices, 4, 0); + gSP2Triangles(gMasterGfxPos++, 0, 2, 1, 0, 0, 3, 2, 0); + gDPPipeSync(gMasterGfxPos++); + } + create_shading_palette(mtx, 0, 0, width, height, alpha, alpha == 255 ? 0x111238 : 0x104B50); // TODO make macro for render mode + } else { + gDPScrollTextureBlock_4b(gMasterGfxPos++, raster, G_IM_FMT_CI, width, height, 0, + G_TX_CLAMP, G_TX_CLAMP, 8, 8, G_TX_NOLOD, G_TX_NOLOD, + 256, 256); + if (D_80151328->flags & 2) { + Camera* camera = &gCameras[gCurrentCamID]; + if (gGameStatusPtr->isBattle == 2) { + gSPViewport(gMasterGfxPos++, &D_802DF3E0); + } else { + gSPViewport(gMasterGfxPos++, &camera->vpAlt); + } + if (alpha == 255) { + gDPSetRenderMode(gMasterGfxPos++, AA_EN | Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | ALPHA_CVG_SEL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM), AA_EN | Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | ALPHA_CVG_SEL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)); + } else { + gDPSetRenderMode(gMasterGfxPos++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); + } + + gDPSetEnvColor(gMasterGfxPos++, 0, 0, 0, alpha); + gDPSetCombineLERP(gMasterGfxPos++, 0, 0, 0, 0, ENVIRONMENT, 0, TEXEL0, 0, 0, 0, 0, 0, ENVIRONMENT, 0, + TEXEL0, 0); + gSPVertex(gMasterGfxPos++, vertices, 4, 0); + gSP2Triangles(gMasterGfxPos++, 0, 2, 1, 0, 0, 3, 2, 0); + gDPPipeSync(gMasterGfxPos++); + + if (alpha == 255) { + gDPSetRenderMode(gMasterGfxPos++, AA_EN | Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | + GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM), + AA_EN | Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)); + } else { + gDPSetRenderMode(gMasterGfxPos++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); + } + + gDPSetEnvColor(gMasterGfxPos++, 100, 100, 100, 255); + gDPSetPrimColor(gMasterGfxPos++, 0, 0, 0, 0, 0, alpha); + gDPSetCombineLERP(gMasterGfxPos++, SHADE, ENVIRONMENT, TEXEL0, TEXEL0, PRIMITIVE, 0, TEXEL0, 0, SHADE, + ENVIRONMENT, TEXEL0, TEXEL0, PRIMITIVE, 0, TEXEL0, 0); + gDPSetColorDither(gMasterGfxPos++, G_CD_MAGICSQ); + } + } + + if (D_80151328->flags & 2) { + Camera* camera = &gCameras[gCurrentCamID]; + + if (gGameStatusPtr->isBattle == 2) { + gSPViewport(gMasterGfxPos++, &D_802DF3D0); + D_802DF3E0.vp.vtrans[0] = D_802DF3D0.vp.vtrans[0] + gGameStatusPtr->unk_82; + D_802DF3E0.vp.vtrans[1] = D_802DF3D0.vp.vtrans[1] + gGameStatusPtr->unk_83; + } else { + gSPViewport(gMasterGfxPos++, &camera->vp); + } + } + + gSPVertex(gMasterGfxPos++, vertices, 4, 0); + gSP2Triangles(gMasterGfxPos++, 0, 2, 1, 0, 0, 3, 2, 0); + gDPPipeSync(gMasterGfxPos++); +} void spr_appendGfx_component( SpriteRasterCacheEntry* cache, diff --git a/src/world/area_flo/flo_10/CB96B0.c b/src/world/area_flo/flo_10/CB96B0.c index 763b2ed2c9..2c0845df89 100644 --- a/src/world/area_flo/flo_10/CB96B0.c +++ b/src/world/area_flo/flo_10/CB96B0.c @@ -2,9 +2,88 @@ #include "nu/nusys.h" #include "model.h" -void N(UnkModelFunc000)(s32, s32, s32, s32); +void N(UnkModelFunc000)(s32 x1, s32 y1, s32 x2, s32 y2) { + s32 i; + f32 f0; + s32 n, m; + u16* img; + s32 alpha; -INCLUDE_ASM(void, "world/area_flo/flo_10/CB96B0", flo_10_UnkModelFunc000); + N(D_80244070_CBD270) += 5; + + if (x1 >= x2 || y1 >= y2) { + return; + } + + if (x1 < 0) { + x1 = 0; + } + if (y1 < 0) { + y1 = 0; + } + if (x2 < 0) { + x2 = 0; + } + if (y2 < 0) { + y2 = 0; + } + + if (x1 >= SCREEN_WIDTH) { + x1 = SCREEN_WIDTH - 1; + } + if (y1 >= SCREEN_HEIGHT) { + y1 = SCREEN_HEIGHT - 1; + } + if (x2 >= SCREEN_WIDTH) { + x2 = SCREEN_WIDTH - 1; + } + if (y2 >= SCREEN_HEIGHT) { + y2 = SCREEN_HEIGHT - 1; + } + + if (x1 == x2 || y1 == y2) { + return; + } + + x1 = x1 / 4 * 4; + x2 = x2 / 4 * 4 + 4; + + n = (y2 - y1) / 6; + m = (y2 - y1) % 6; + img = nuGfxCfb_ptr; + + for (i = 0; i < n; i++) { + alpha = (y1 - 6 * i - 6) * 2; + if (y1 - 6 * i - 6 >= 0) { + if (alpha > 255) { + alpha = 255; + } + gDPSetPrimColor(gMasterGfxPos++, 0, 0, 0xFF, 0xFF, 0xFF, alpha); + gDPLoadTextureTile(gMasterGfxPos++, osVirtualToPhysical(img), G_IM_FMT_RGBA, G_IM_SIZ_16b, + SCREEN_WIDTH, 6, + x1, y1 - 6 * i - 6, x2 - 1, y1 - 6 * i - 1, 0, + G_TX_WRAP, G_TX_WRAP, 9, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(gMasterGfxPos++, x1 * 4, (y1 + i * 6) * 4, x2 * 4, (y1 + i * 6 + 6) * 4, + G_TX_RENDERTILE, x1 * 32, (y1 - i * 6) * 32, 1024, (s32)(sin_deg(N(D_80244070_CBD270) + i * 30) * 500.0f) - 500); + } + } + + if (m != 0) { + alpha = (y1 - 6 * i - 6) * 2; + if (y1 - 6 * i - 6 >= 0) { + if (alpha > 255) { + alpha = 255; + } + gDPSetPrimColor(gMasterGfxPos++, 0, 0, 0xFF, 0xFF, 0xFF, alpha); + gDPLoadTextureTile(gMasterGfxPos++, osVirtualToPhysical(img), G_IM_FMT_RGBA, G_IM_SIZ_16b, + SCREEN_WIDTH, 6, + x1, y1 - 6 * i - m, x2 - 1, y1 - 6 * i - 1, 0, + G_TX_WRAP, G_TX_WRAP, 9, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(gMasterGfxPos++, x1 * 4, (y1 + i * 6) * 4, x2 * 4, (y1 + i * 6 + m) * 4, + G_TX_RENDERTILE, x1 * 32, (y1 - i * 6) * 32, 1024, -1024); + } + } +} void N(UnkModelFunc001)(void) { Camera* camera = &gCameras[gCurrentCameraID]; diff --git a/src/world/area_hos/hos_02/A16220.c b/src/world/area_hos/hos_02/A16220.c index b84aee4b09..4bcd552dc6 100644 --- a/src/world/area_hos/hos_02/A16220.c +++ b/src/world/area_hos/hos_02/A16220.c @@ -4,6 +4,7 @@ static char* N(exit_str_0) = "hos_01"; static char* N(exit_str_1) = "hos_03"; extern u16 D_802433AC_A195CC; +extern u16 D_802433AE_A195CE; extern u16 D_802433B0_A195D0; extern u16 D_802433B2_A195D2; extern u16 D_802433B4_A195D4; @@ -20,7 +21,28 @@ void func_8024030C_A1652C(void) { G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); } -INCLUDE_ASM(s32, "world/area_hos/hos_02/A16220", func_80240434_A16654); +void func_80240434_A16654(void) { + Vtx* firstVertex; + Vtx* copiedVertices; + s32 numVertices; + s32 i; + s32 temp3; + + mdl_get_copied_vertices(0, &firstVertex, &copiedVertices, &numVertices); + + for (i = 0; i < numVertices; i++) { + u8* colors = copiedVertices[i].v.cn; + s16 temp1 = (sins(D_802433AE_A195CE * (i % 3 + 1) + i) + 0x8000) / 2; + colors[0] = temp1 * 155 / 0x8000 + 100; + colors[1] = temp1 * 155 / 0x8000 + 100; + + temp3 = sins(D_802433AE_A195CE / 0x8000 * (((i / 2) % 3 + 1) << 15) + D_802433AE_A195CE / 0x4000 * 0x8000 + i) + 0x8000; + colors[2] = colors[0] * temp3 / 0x10000; + } + + gSPDisplayList(gMasterGfxPos++, mdl_get_copied_gfx(0)); + D_802433AE_A195CE += 0x253; +} void func_80240610_A16830(void) { Vtx* firstVertex; diff --git a/src/world/area_hos/hos_03/A1B130.c b/src/world/area_hos/hos_03/A1B130.c index 17bca541d5..999bfaf475 100644 --- a/src/world/area_hos/hos_03/A1B130.c +++ b/src/world/area_hos/hos_03/A1B130.c @@ -1,14 +1,83 @@ #include "hos_03.h" +extern u16 D_80243BCC_A1ECCC; +extern u16 D_80243BCE_A1ECCE; +extern u16 D_80243BD0_A1ECD0; +extern u16 D_80243BD2_A1ECD2; extern u16 D_80243BD4_A1ECD4; #include "world/common/atomic/TexturePan.inc.c" -INCLUDE_ASM(s32, "world/area_hos/hos_03/A1B130", func_8024033C_A1B43C); +void func_8024033C_A1B43C(void) { + Vtx* firstVertex; + Vtx* copiedVertices; + s32 numVertices; + s32 i; + s32 temp3; -INCLUDE_ASM(s32, "world/area_hos/hos_03/A1B130", func_8024060C_A1B70C); + f32 angle = sins(D_80243BCC_A1ECCC) / 32768.0f * 45.0f; + D_80243BCC_A1ECCC += 0x400; + guRotate(&gDisplayContext->matrixStack[gMatrixListPos], angle, 0.0f, 1.0f, 0.0f); + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); -INCLUDE_ASM(s32, "world/area_hos/hos_03/A1B130", func_802407E8_A1B8E8); + mdl_get_copied_vertices(1, &firstVertex, &copiedVertices, &numVertices); + + for (i = 0; i < numVertices; i++) { + u8* colors = copiedVertices[i].v.cn; + s16 temp1 = (sins(D_80243BCE_A1ECCE * (i % 3 + 1) + i) + 0x8000) / 2; + colors[0] = temp1 * 155 / 0x8000 + 100; + colors[1] = temp1 * 155 / 0x8000 + 100; + + temp3 = sins(D_80243BCE_A1ECCE / 0x8000 * (((i / 2) % 3 + 1) << 15) + D_80243BCE_A1ECCE / 0x4000 * 0x8000 + i) + 0x8000; + colors[2] = colors[0] * temp3 / 0x10000; + } + + gSPClearGeometryMode(gMasterGfxPos++, G_CULL_BOTH); + gSPDisplayList(gMasterGfxPos++, mdl_get_copied_gfx(1)); + D_80243BCE_A1ECCE += 0x666; +} + +void func_8024060C_A1B70C(void) { + Vtx* firstVertex; + Vtx* copiedVertices; + s32 numVertices; + s32 i; + s32 temp3; + + mdl_get_copied_vertices(2, &firstVertex, &copiedVertices, &numVertices); + + for (i = 0; i < numVertices; i++) { + u8* colors = copiedVertices[i].v.cn; + s16 temp1 = (sins(D_80243BD0_A1ECD0 * (i % 3 + 1) + i) + 0x8000) / 2; + colors[0] = temp1 * 155 / 0x8000 + 100; + colors[1] = temp1 * 155 / 0x8000 + 100; + + temp3 = sins(D_80243BD0_A1ECD0 / 0x8000 * (((i / 2) % 3 + 1) << 15) + D_80243BD0_A1ECD0 / 0x4000 * 0x8000 + i) + 0x8000; + colors[2] = colors[0] * temp3 / 0x10000; + } + + gSPDisplayList(gMasterGfxPos++, mdl_get_copied_gfx(2)); + D_80243BD0_A1ECD0 += 0x253; +} + +void func_802407E8_A1B8E8(void) { + Vtx* firstVertex; + Vtx* copiedVertices; + s32 numVertices; + s32 i; + + mdl_get_copied_vertices(0, &firstVertex, &copiedVertices, &numVertices); + + for (i = 0; i < numVertices; i++) { + Vtx* vtxDst = &copiedVertices[i]; + Vtx* vtxSrc = &firstVertex[i]; + s32 v0 = sins(D_80243BD2_A1ECD2 * (i % 3 + 1) + i * 0x2AAA) * 50; + vtxDst->v.ob[1] = vtxSrc->v.ob[1] + v0 / 0x8000; + } + + gSPDisplayList(gMasterGfxPos++, mdl_get_copied_gfx(0)); + D_80243BD2_A1ECD2 += 0xA3; +} void func_80240928_A1BA28(void) { f32 scale = ((sins(D_80243BD4_A1ECD4) * (1 / 32768.0f)) * 0.5 * 0.5) + 1.05; diff --git a/src/world/area_iwa/iwa_01/iwa_01.h b/src/world/area_iwa/iwa_01/iwa_01.h index 4392830a76..5632a24e64 100644 --- a/src/world/area_iwa/iwa_01/iwa_01.h +++ b/src/world/area_iwa/iwa_01/iwa_01.h @@ -21,6 +21,10 @@ enum { NPC_Cleft = 8, }; +enum { + MV_SplashState = MapVar(15), +}; + #define NAMESPACE iwa_01 extern EvtScript N(EVS_Main); diff --git a/src/world/area_iwa/iwa_01/iwa_01_1_main.c b/src/world/area_iwa/iwa_01/iwa_01_1_main.c index 8290b2676e..b936f6bdd5 100644 --- a/src/world/area_iwa/iwa_01/iwa_01_1_main.c +++ b/src/world/area_iwa/iwa_01/iwa_01_1_main.c @@ -73,3 +73,5 @@ EvtScript N(EVS_Main) = { EVT_RETURN EVT_END }; + +MAP_RODATA_PAD(1, pad) diff --git a/src/world/area_iwa/iwa_01/iwa_01_3_splash.c b/src/world/area_iwa/iwa_01/iwa_01_3_splash.c index afbae42991..f69c09dbe1 100644 --- a/src/world/area_iwa/iwa_01/iwa_01_3_splash.c +++ b/src/world/area_iwa/iwa_01/iwa_01_3_splash.c @@ -1,21 +1,101 @@ #include "iwa_01.h" -MAP_RODATA_PAD(1,splash); - #include "world/area_iwa/iwa_01/splash.png.inc.c" #include "world/area_iwa/iwa_01/splash.vtx.inc.c" #include "world/area_iwa/iwa_01/splash.gfx.inc.c" -API_CALLABLE(N(func_80240398_90FA48)); -void N(gfx_build_splash)(void); +#define NUM_SPLASHES (20) -INCLUDE_ASM(s32, "world/area_iwa/iwa_01/90F6B0", iwa_01_gfx_build_splash); -INCLUDE_ASM(s32, "world/area_iwa/iwa_01/90F6B0", iwa_01_func_80240398_90FA48); -MAP_DATA_SECTION_START; +typedef struct SplashState { + /* 0x00 */ Vec3f pos; + /* 0x0C */ f32 scale; + /* 0x10 */ Vec3f rot; + /* 0x1C */ Vec3f vel; +} SplashState; // size = 0x28 + +void N(gfx_build_splashes)(s32 index) { + s32 i; + s32 alpha; + SplashState* splash = (SplashState*)evt_get_variable(NULL, MV_SplashState); + + for (i = 0; i < NUM_SPLASHES; i++, splash++) { + if (splash->pos.y < -30.0f) { + splash->pos.x = 0.0f; + splash->pos.y = 5.0f; + splash->pos.z = -20.0f; + + splash->vel.x = (rand_int(8) - 4) / 10.0f; + splash->vel.y = rand_int(10) / 10.0f; + splash->vel.z = (rand_int(10) + 30) / 10.0f; + + splash->scale = 1.0f; + + splash->rot.x = rand_int(20) + 80; + splash->rot.y = rand_int(359); + splash->rot.z = 0; + } + + splash->vel.x *= 0.98; + splash->vel.y += -0.1; + splash->vel.z *= 0.98; + + splash->pos.x += splash->vel.x; + splash->pos.y += splash->vel.y; + splash->pos.z += splash->vel.z; + + splash->rot.x += 2.0f; + + alpha = splash->pos.y * 255.0f / -30.0f; + if (alpha < 0) { + alpha = 0; + } + if (alpha > 255) { + alpha = 255; + } + + gDPSetPrimColor(gMasterGfxPos++, 0, 0, 230, 255, 255, 255); + gDPSetBlendColor(gMasterGfxPos++, 0, 0, 0, alpha); + guPosition(&gDisplayContext->matrixStack[gMatrixListPos], + splash->rot.x, splash->rot.y, splash->rot.z, + splash->scale, + splash->pos.x, splash->pos.y, splash->pos.z); + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(gMasterGfxPos++, N(splash_gfx)); + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); + } + + gDPSetAlphaCompare(gMasterGfxPos++, G_AC_NONE); + gDPPipeSync(gMasterGfxPos++); +} + +API_CALLABLE(N(InitSplashes)) { + SplashState* splash = heap_malloc(NUM_SPLASHES * sizeof(*splash)); + s32 i; + + evt_set_variable(NULL, MV_SplashState, (s32)splash); + + for (i = 0; i < NUM_SPLASHES; i++, splash++) { + splash->pos.x = 0.0f; + splash->pos.y = -i * 30 / NUM_SPLASHES; + splash->pos.z = 0.0f; + + splash->vel.x = 0.0f; + splash->vel.y = rand_int(10) / 10.0f - (f32)i * 0.1; + splash->vel.z = 0.0f; + + splash->scale = 1.0f; + + splash->rot.x = rand_int(359); + splash->rot.y = rand_int(359); + splash->rot.z = rand_int(359); + } + + return ApiStatus_DONE2; +} EvtScript N(EVS_MakeSplashes) = { - EVT_CALL(N(func_80240398_90FA48)) - EVT_CALL(SetCustomGfxBuilders, 0, 0, EVT_PTR(N(gfx_build_splash))) + EVT_CALL(N(InitSplashes)) + EVT_CALL(SetCustomGfxBuilders, 0, 0, EVT_PTR(N(gfx_build_splashes))) EVT_CALL(SetModelCustomGfx, MODEL_dummy_sprash2, 0, -1) EVT_RETURN EVT_END diff --git a/src/world/dead/flo_10/ED46D0.c b/src/world/dead/flo_10/ED46D0.c index 21b7e9694f..56e7182a69 100644 --- a/src/world/dead/flo_10/ED46D0.c +++ b/src/world/dead/flo_10/ED46D0.c @@ -4,13 +4,159 @@ #include "model.h" // rodata -extern char D_80244BB8_ED8DD8[]; -extern char D_80244BEC_ED8E0C[]; +extern char D_80244BB8_ED8DD8[]; // 'GBI Error (aligned 8) File:%s Line:%d Adrs:%08x \n' +extern char D_80244BEC_ED8E0C[]; // evt_underwater.c -void N(UnkModelFunc000)(s32, s32, s32, s32); -INCLUDE_ASM(s32, "ED46D0", ED46D0_UnkModelFunc000); +void N(UnkModelFunc000)(s32 x1, s32 y1, s32 x2, s32 y2) { + s32 i; + f32 f0; + s32 n, m; + u16* img; + s32 alpha; -s32 func_80066FE0(u16*); + N(D_80244160_ED8380) += 5; + + if (x1 >= x2 || y1 >= y2) { + return; + } + + if (x1 < 0) { + x1 = 0; + } + if (y1 < 0) { + y1 = 0; + } + if (x2 < 0) { + x2 = 0; + } + if (y2 < 0) { + y2 = 0; + } + + if (x1 >= SCREEN_WIDTH) { + x1 = SCREEN_WIDTH - 1; + } + if (y1 >= SCREEN_HEIGHT) { + y1 = SCREEN_HEIGHT - 1; + } + if (x2 >= SCREEN_WIDTH) { + x2 = SCREEN_WIDTH - 1; + } + if (y2 >= SCREEN_HEIGHT) { + y2 = SCREEN_HEIGHT - 1; + } + + if (x1 == x2 || y1 == y2) { + return; + } + + x1 = x1 / 4 * 4; + x2 = x2 / 4 * 4 + 4; + + n = (y2 - y1) / 6; + m = (y2 - y1) % 6; + img = nuGfxCfb_ptr; + + for (i = 0; i < n; i++) { + alpha = (y1 - 6 * i - 6) * 2; + if (y1 - 6 * i - 6 >= 0) { + if (alpha > 255) { + alpha = 255; + } + gDPSetPrimColor(gMasterGfxPos++, 0, 0, 0xFF, 0xFF, 0xFF, alpha); + + //gDPLoadTextureTile(gMasterGfxPos++, osVirtualToPhysical(img), G_IM_FMT_RGBA, G_IM_SIZ_16b, + //SCREEN_WIDTH, 6, + //x1, y1 - 6 * i - 6, x2 - 1, y1 - 6 * i - 1, 0, + //G_TX_WRAP, G_TX_WRAP, 9, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + + //gDPSetTextureImage(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, osVirtualToPhysical(img)); + { + Gfx *_g = (Gfx *)(gMasterGfxPos++); + + if ((osVirtualToPhysical(img) % 8) != 0) { + osSyncPrintf(D_80244BB8_ED8DD8, D_80244BEC_ED8E0C, 83, osVirtualToPhysical(img)); + } + _g->words.w0 = _SHIFTL(G_SETTIMG, 24, 8) | _SHIFTL(G_IM_FMT_RGBA, 21, 3) | + _SHIFTL(G_IM_SIZ_16b, 19, 2) | _SHIFTL((SCREEN_WIDTH)-1, 0, 12); + + _g->words.w1 = (unsigned int)(osVirtualToPhysical(img)); + } + gDPSetTile(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, + (((((x2 - 1)-(x1)+1) * G_IM_SIZ_16b_TILE_BYTES)+7)>>3), 0, + G_TX_LOADTILE, 0 , G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP, 9, + G_TX_NOLOD); + gDPLoadSync(gMasterGfxPos++); + gDPLoadTile( gMasterGfxPos++, G_TX_LOADTILE, + (x1)<>3), 0, + G_TX_RENDERTILE, 0, G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP, 9, + G_TX_NOLOD); + gDPSetTileSize(gMasterGfxPos++, G_TX_RENDERTILE, + (x1)<= 0) { + if (alpha > 255) { + alpha = 255; + } + gDPSetPrimColor(gMasterGfxPos++, 0, 0, 0xFF, 0xFF, 0xFF, alpha); + //gDPLoadTextureTile(gMasterGfxPos++, osVirtualToPhysical(img), G_IM_FMT_RGBA, G_IM_SIZ_16b, + // SCREEN_WIDTH, 6, + // x1, y1 - 6 * i - m, x2 - 1, y1 - 6 * i - 1, 0, + // G_TX_WRAP, G_TX_WRAP, 9, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + //gDPSetTextureImage(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, osVirtualToPhysical(img)); + { + Gfx *_g = (Gfx *)(gMasterGfxPos++); + + if ((osVirtualToPhysical(img) % 8) != 0) { + osSyncPrintf(D_80244BB8_ED8DD8, D_80244BEC_ED8E0C, 107, osVirtualToPhysical(img)); + } + _g->words.w0 = _SHIFTL(G_SETTIMG, 24, 8) | _SHIFTL(G_IM_FMT_RGBA, 21, 3) | + _SHIFTL(G_IM_SIZ_16b, 19, 2) | _SHIFTL((SCREEN_WIDTH)-1, 0, 12); + + _g->words.w1 = (unsigned int)(osVirtualToPhysical(img)); + } + gDPSetTile(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, + (((((x2 - 1)-(x1)+1) * G_IM_SIZ_16b_TILE_BYTES)+7)>>3), 0, + G_TX_LOADTILE, 0 , G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP, 9, + G_TX_NOLOD); + gDPLoadSync(gMasterGfxPos++); + gDPLoadTile( gMasterGfxPos++, G_TX_LOADTILE, + (x1)<>3), 0, + G_TX_RENDERTILE, 0, G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP, 9, + G_TX_NOLOD); + gDPSetTileSize(gMasterGfxPos++, G_TX_RENDERTILE, + (x1)<