18 if (!config.video.force)
20 f32 xScale = _FIXED2FLOAT( _SHIFTR( *REG.VI_X_SCALE, 0, 12 ), 10 );
21 f32 xOffset = _FIXED2FLOAT( _SHIFTR( *REG.VI_X_SCALE, 16, 12 ), 10 );
23 f32 yScale = _FIXED2FLOAT( _SHIFTR( *REG.VI_Y_SCALE, 0, 12 ), 10 );
24 f32 yOffset = _FIXED2FLOAT( _SHIFTR( *REG.VI_Y_SCALE, 16, 12 ), 10 );
26 u32 hEnd = _SHIFTR( *REG.VI_H_START, 0, 10 );
27 u32 hStart = _SHIFTR( *REG.VI_H_START, 16, 10 );
29 // These are in half-lines, so shift an extra bit
30 u32 vEnd = _SHIFTR( *REG.VI_V_START, 1, 9 );
31 u32 vStart = _SHIFTR( *REG.VI_V_START, 17, 9 );
34 if (hEnd == hStart) hEnd = (u32)(*REG.VI_WIDTH / xScale);
37 VI.width = (hEnd - hStart) * xScale;
38 VI.height = (vEnd - vStart) * yScale * 1.0126582f;
42 VI.width = config.video.width;
43 VI.height = config.video.height;
46 if (VI.width == 0.0f) VI.width = 320.0f;
47 if (VI.height == 0.0f) VI.height = 240.0f;
48 VI.rwidth = 1.0f / VI.width;
49 VI.rheight = 1.0f / VI.height;
52 //add display buffer if doesn't exist
53 if (config.ignoreOffscreenRendering)
56 //int start = *REG.VI_ORIGIN;
57 u32 start = RSP_SegmentToPhysical(*REG.VI_ORIGIN) & 0x00FFFFFF;
58 u32 end = min(start + VI.width * VI.height * 4, RDRAMSize);
59 for(i = 0; i < VI.displayNum; i++)
61 if (VI.display[i].start <= end && VI.display[i].start >= start) break;
62 if (start <= VI.display[i].end && start >= VI.display[i].start) break;
64 if (i == VI.displayNum)
66 //printf("VI IMAGE=%i\n", o);
67 VI.display[i%16].start = start;
68 VI.display[i%16].end = end;
69 VI.displayNum = (VI.displayNum < 16) ? (VI.displayNum+1) : 16;
75 void VI_UpdateScreen()
78 switch(config.updateMode)
81 case SCREEN_UPDATE_AT_VI_CHANGE:
82 if (*REG.VI_ORIGIN != VI.lastOrigin)
84 if (*REG.VI_ORIGIN < VI.lastOrigin || *REG.VI_ORIGIN > VI.lastOrigin+0x2000 )
87 VI.lastOrigin = *REG.VI_ORIGIN;
91 case SCREEN_UPDATE_AT_VI_UPDATE:
92 if (gSP.changed & CHANGED_COLORBUFFER)
95 gSP.changed &= ~CHANGED_COLORBUFFER;