| 394 | ***************************************************************************/ |
| 395 | |
| 396 | static void InitScanlineTexture() { |
| 397 | // GX_TF_I8 represents one byte per pixel. |
| 398 | // We create an 8x4 tile: Rows 0 and 2 are white (0xFF), Rows 1 and 3 are dark (0xA0). |
| 399 | for (int y = 0; y < 4; y++) { |
| 400 | u8 intensity = (y % 2 == 0) ? 0xFF : 0xA0; // 0xA0 controls the scanline darkness |
| 401 | for (int x = 0; x < 8; x++) { |
| 402 | scanline_tex_data[y * 8 + x] = intensity; |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | // CRITICAL: Flush the CPU data cache. GX reads directly from main memory. |
| 407 | DCStoreRange(scanline_tex_data, 32); |
| 408 | |
| 409 | // Initialize the texture object. Wrap modes MUST be GX_REPEAT to tile across the screen. |
| 410 | GX_InitTexObj(&scanlineTexObj, scanline_tex_data, 8, 4, GX_TF_I8, GX_REPEAT, GX_REPEAT, GX_FALSE); |
| 411 | |
| 412 | // CRITICAL: Filter mode MUST be GX_NEAR. GX_LINEAR will blur the lines into a muddy gray. |
| 413 | GX_InitTexObjFilterMode(&scanlineTexObj, GX_NEAR, GX_NEAR); |
| 414 | |
| 415 | // Load the scanline texture into MAP1 |
| 416 | GX_LoadTexObj(&scanlineTexObj, GX_TEXMAP1); |
| 417 | } |
| 418 | |
| 419 | static void SetupScanlineFilterTEV() { |
| 420 | GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_TEX1, GX_TEX_ST, GX_F32, 0); |