5252
5353/* A video mode with a 320 width; we'll build it programmatically. */
5454static GXRModeObj s_mode320 ;
55- static GXRModeObj s_mode704 ;
5655
5756static const GXRModeObj * s_ntsc_modes [] = {
5857 & TVNtsc240Ds ,
@@ -96,11 +95,12 @@ static void init_display_mode(SDL_DisplayMode *mode, const GXRModeObj *vmode)
9695 mode -> format = SDL_PIXELFORMAT_ARGB8888 ;
9796
9897 #ifdef __wii__
99- if (CONF_GetAspectRatio () == CONF_ASPECT_16_9 )
100- mode -> w = ((int )(vmode -> fbWidth * 16.0f / 9.0f )) + 1 ;
101- else
98+ if (CONF_GetAspectRatio () == CONF_ASPECT_16_9 ) {
99+ mode -> w = vmode -> fbWidth * 16.0f / 9.0f ;
100+ mode -> w = (mode -> w + 1 ) & ~1 ;
101+ }
102102 #endif
103- mode -> w = vmode -> fbWidth ;
103+ mode -> w = vmode -> fbWidth ;
104104 mode -> h = vmode -> efbHeight ;
105105 switch (format ) {
106106 case VI_DEBUG :
@@ -114,7 +114,7 @@ static void init_display_mode(SDL_DisplayMode *mode, const GXRModeObj *vmode)
114114 mode -> refresh_rate = 50 ;
115115 break ;
116116 }
117- mode -> driverdata = (GXRModeObj * )vmode ;
117+ mode -> driverdata = (GXRModeObj * )vmode ;
118118}
119119
120120static void add_supported_modes (SDL_VideoDisplay * display , u32 tv_format )
@@ -153,32 +153,6 @@ static void add_supported_modes(SDL_VideoDisplay *display, u32 tv_format)
153153 init_display_mode (& mode , & s_mode320 );
154154 SDL_AddDisplayMode (display , & mode );
155155
156- // libogc uses 640 for the viWidth, but this does not work well for Widescreen
157- // as such we extend the viWidth to 704 on a new videomode
158- // TODO: Currently ony added on wii if it's widescreen,
159- // but should work on GC and a 4:3 Wii
160- // testing needed
161-
162- #ifdef __wii__
163- if (CONF_GetAspectRatio () == CONF_ASPECT_16_9 ) {
164- memcpy (& s_mode704 , gx_modes [1 ], sizeof (s_mode704 ));
165- s_mode704 .viWidth = 704 ;
166-
167- // set Center point
168- if (& s_mode704 == & TVPal576IntDfScale || & s_mode704 == & TVPal576ProgScale ) {
169- s_mode704 .viXOrigin = (VI_MAX_WIDTH_PAL - s_mode704 .viWidth ) / 2 ;
170- s_mode704 .viYOrigin = (VI_MAX_HEIGHT_PAL - s_mode704 .viHeight ) / 2 ;
171- } else {
172- s_mode704 .viXOrigin = (VI_MAX_WIDTH_NTSC - s_mode704 .viWidth ) / 2 ;
173- s_mode704 .viYOrigin = (VI_MAX_HEIGHT_NTSC - s_mode704 .viHeight ) / 2 ;
174- }
175-
176- // Widescreen is anamorphic, so we provide a different width for the ortho projection
177- init_display_mode (& mode , & s_mode704 );
178- SDL_AddDisplayMode (display , & mode );
179- }
180- #endif
181-
182156 /* Now add all the "standard" modes from libogc */
183157 while (* gx_modes ) {
184158 init_display_mode (& mode , * gx_modes );
@@ -187,10 +161,24 @@ static void add_supported_modes(SDL_VideoDisplay *display, u32 tv_format)
187161 }
188162}
189163
190- static void setup_video_mode (_THIS , GXRModeObj * vmode , int widthAdjustedForWidescreen )
164+ static void setup_video_mode (_THIS , GXRModeObj * vmode )
191165{
192166 SDL_VideoData * videodata = (SDL_VideoData * )_this -> driverdata ;
193167
168+ // TODO: Should I make this only happen if the aspect ratio isn't 4:3?
169+ if (vmode -> viWidth == 240 || vmode -> viWidth == 640 )
170+ vmode -> viWidth = vmode -> viWidth + (VI_MAX_WIDTH_NTSC - 640 );
171+
172+ // set Center point
173+ if (VI_FORMAT_FROM_MODE (vmode -> viTVMode ) == VI_PAL ) {
174+ vmode -> viXOrigin = (VI_MAX_WIDTH_PAL - vmode -> viWidth ) / 2 ;
175+ vmode -> viYOrigin = (VI_MAX_HEIGHT_PAL - vmode -> viHeight ) / 2 ;
176+ } else {
177+ vmode -> viXOrigin = (VI_MAX_WIDTH_NTSC - vmode -> viWidth ) / 2 ;
178+ vmode -> viYOrigin = (VI_MAX_HEIGHT_NTSC - vmode -> viHeight ) / 2 ;
179+ }
180+
181+
194182 VIDEO_SetBlack (true);
195183 VIDEO_Configure (vmode );
196184
@@ -215,7 +203,7 @@ static void setup_video_mode(_THIS, GXRModeObj *vmode, int widthAdjustedForWides
215203 GX_SetFieldMode (vmode -> field_rendering ,
216204 ((vmode -> viHeight == 2 * vmode -> xfbHeight ) ? GX_ENABLE : GX_DISABLE ));
217205
218- OGC_draw_init (vmode -> fbWidth , vmode -> efbHeight , widthAdjustedForWidescreen );
206+ OGC_draw_init (vmode -> fbWidth , vmode -> efbHeight );
219207}
220208
221209static int OGC_SetDisplayMode (_THIS , SDL_VideoDisplay * display ,
@@ -230,7 +218,7 @@ static int OGC_SetDisplayMode(_THIS, SDL_VideoDisplay *display,
230218 if (videodata -> xfb [1 ])
231219 free (MEM_K1_TO_K0 (videodata -> xfb [1 ]));
232220
233- setup_video_mode (_this , vmode , mode -> w );
221+ setup_video_mode (_this , vmode );
234222 return 0 ;
235223}
236224
@@ -312,30 +300,21 @@ int OGC_VideoInit(_THIS)
312300 VIDEO_Init ();
313301
314302 vmode = VIDEO_GetPreferredMode (NULL );
315- #ifdef __wii__
316- if (CONF_GetAspectRatio () == CONF_ASPECT_16_9 ) {
317- vmode -> viWidth = 704 ;
318-
319- // set Center point
320- if (& s_mode704 == & TVPal576IntDfScale || & s_mode704 == & TVPal576ProgScale ) {
321- vmode -> viXOrigin = (VI_MAX_WIDTH_PAL - vmode -> viWidth ) / 2 ;
322- vmode -> viYOrigin = (VI_MAX_HEIGHT_PAL - vmode -> viHeight ) / 2 ;
323- } else {
324- vmode -> viXOrigin = (VI_MAX_WIDTH_NTSC - vmode -> viWidth ) / 2 ;
325- vmode -> viYOrigin = (VI_MAX_HEIGHT_NTSC - vmode -> viHeight ) / 2 ;
326- }
303+ vmode -> viWidth = VI_MAX_WIDTH_NTSC ; // VI_MAX_WIDTH is the same for all regions
304+ // set Center point
305+ if (VI_FORMAT_FROM_MODE (vmode -> viTVMode ) == VI_PAL ) {
306+ vmode -> viXOrigin = (VI_MAX_WIDTH_PAL - vmode -> viWidth ) / 2 ;
307+ vmode -> viYOrigin = (VI_MAX_HEIGHT_PAL - vmode -> viHeight ) / 2 ;
308+ } else {
309+ vmode -> viXOrigin = (VI_MAX_WIDTH_NTSC - vmode -> viWidth ) / 2 ;
310+ vmode -> viYOrigin = (VI_MAX_HEIGHT_NTSC - vmode -> viHeight ) / 2 ;
327311 }
328- #endif
312+
329313 videodata -> gp_fifo = memalign (32 , DEFAULT_FIFO_SIZE );
330314 memset (videodata -> gp_fifo , 0 , DEFAULT_FIFO_SIZE );
331315 GX_Init (videodata -> gp_fifo , DEFAULT_FIFO_SIZE );
332316
333- #ifdef __wii__
334- if (CONF_GetAspectRatio () == CONF_ASPECT_16_9 )
335- setup_video_mode (_this , vmode , 854 );
336- else
337- #endif
338- setup_video_mode (_this , vmode , vmode -> fbWidth );
317+ setup_video_mode (_this , vmode );
339318 GX_SetCopyClear (background , GX_MAX_Z24 );
340319
341320 GX_SetPixelFmt (GX_PF_RGB8_Z24 , GX_ZC_LINEAR );
0 commit comments