- reimplemented zooming (limited range, option to reset)

- video debugging info now written to a file (if flag set)
This commit is contained in:
michniewski 2008-09-23 03:49:57 +00:00
parent 2ac740bf64
commit c47d9bbc98
7 changed files with 66 additions and 70 deletions

View File

@ -34,8 +34,8 @@ CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) \
-DCPU_SHUTDOWN -DSPC700_SHUTDOWN \ -DCPU_SHUTDOWN -DSPC700_SHUTDOWN \
-DSPC700_C -DSDD1_DECOMP \ -DSPC700_C -DSDD1_DECOMP \
-DCORRECT_VRAM_READS -DNEW_COLOUR_BLENDING \ -DCORRECT_VRAM_READS -DNEW_COLOUR_BLENDING \
$(CUSTOMFLAGS) \ -fomit-frame-pointer -fno-exceptions -Wno-unused-parameter -pipe \
-fomit-frame-pointer -fno-exceptions -Wno-unused-parameter -pipe #-D_DEBUG_VIDEO
CXXFLAGS = $(CFLAGS) CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref

View File

@ -34,8 +34,8 @@ CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) \
-DCPU_SHUTDOWN -DSPC700_SHUTDOWN \ -DCPU_SHUTDOWN -DSPC700_SHUTDOWN \
-DSPC700_C -DSDD1_DECOMP \ -DSPC700_C -DSDD1_DECOMP \
-DCORRECT_VRAM_READS -DNEW_COLOUR_BLENDING \ -DCORRECT_VRAM_READS -DNEW_COLOUR_BLENDING \
$(CUSTOMFLAGS) \ -fomit-frame-pointer -fno-exceptions -Wno-unused-parameter \
-fomit-frame-pointer -fno-exceptions -Wno-unused-parameter # -pipe #-D_DEBUG_VIDEO -pipe
CXXFLAGS = -save-temps -Xassembler -aln=$@.lst $(CFLAGS) CXXFLAGS = -save-temps -Xassembler -aln=$@.lst $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map

View File

@ -479,11 +479,11 @@ void NGCReportButtons ()
/*** Check for video zoom ***/ /*** Check for video zoom ***/
if (GCSettings.NGCZoom) if (GCSettings.NGCZoom)
{ {
if (gc_py < -18 || gc_py > 18) if (gc_py < -36 || gc_py > 36)
zoom ((float) gc_py / -18); zoom ((float) gc_py / -36);
#ifdef HW_RVL #ifdef HW_RVL
if (wm_sy < -18 || wm_sy > 18) if (wm_sy < -36 || wm_sy > 36)
zoom ((float) wm_sy / -18); zoom ((float) wm_sy / -36);
#endif #endif
} }

View File

@ -129,7 +129,7 @@ static char prefmenu[][50] = {
"Interpolated Sound", "Interpolated Sound",
"Transparency", "Transparency",
"Display Frame Rate", "Display Frame Rate",
"C-Stick Zoom", "Enable Zooming",
"Video Filtering", "Video Filtering",
"Widescreen", "Widescreen",
@ -238,7 +238,7 @@ PreferencesMenu ()
sprintf (prefmenu[10], "Display Frame Rate %s", sprintf (prefmenu[10], "Display Frame Rate %s",
Settings.DisplayFrameRate == true ? " ON" : "OFF"); Settings.DisplayFrameRate == true ? " ON" : "OFF");
sprintf (prefmenu[11], "C-Stick Zoom %s", sprintf (prefmenu[11], "Enable Zooming %s",
GCSettings.NGCZoom == true ? " ON" : "OFF"); GCSettings.NGCZoom == true ? " ON" : "OFF");
if ( GCSettings.render == 0 ) if ( GCSettings.render == 0 )
@ -514,7 +514,7 @@ void CheatMenu()
int int
GameMenu () GameMenu ()
{ {
int gamemenuCount = 9; int gamemenuCount = 10;
char gamemenu[][50] = { char gamemenu[][50] = {
"Return to Game", "Return to Game",
"Reset Game", "Reset Game",
@ -522,6 +522,7 @@ GameMenu ()
"Cheats", "Cheats",
"Load SRAM", "Save SRAM", "Load SRAM", "Save SRAM",
"Load Game Snapshot", "Save Game Snapshot", "Load Game Snapshot", "Save Game Snapshot",
"Reset Zoom",
"Back to Main Menu" "Back to Main Menu"
}; };
@ -591,8 +592,12 @@ GameMenu ()
NGCFreezeGame (GCSettings.SaveMethod, NOTSILENT); NGCFreezeGame (GCSettings.SaveMethod, NOTSILENT);
break; break;
case 8: // Reset Zoom
zoom_reset ();
break;
case -1: // Button B case -1: // Button B
case 8: // Return to previous menu case 9: // Return to previous menu
retval = 0; retval = 0;
quit = 1; quit = 1;
break; break;

View File

@ -61,6 +61,8 @@ extern "C" {
unsigned long ARAM_ROMSIZE = 0; unsigned long ARAM_ROMSIZE = 0;
int ConfigRequested = 0; int ConfigRequested = 0;
FILE* debughandle;
extern int FrameTimer; extern int FrameTimer;
extern long long prev; extern long long prev;
@ -165,9 +167,16 @@ emulate ()
ConfigRequested = 0; ConfigRequested = 0;
#ifdef _DEBUG_VIDEO
// log stuff
fprintf(debughandle, "\n\nPlaying ROM: %s", Memory.ROMFilename);
fprintf(debughandle, "\nrender: %u", GCSettings.render);
#endif
CheckVideo = 1; // force video update CheckVideo = 1; // force video update
prevRenderedFrameCount = IPPU.RenderedFramesCount; prevRenderedFrameCount = IPPU.RenderedFramesCount;
}//if ConfigRequested }//if ConfigRequested
}//while }//while
@ -250,6 +259,11 @@ main ()
// Initialize libFAT for SD and USB // Initialize libFAT for SD and USB
fatInitDefault(); fatInitDefault();
#ifdef _DEBUG_VIDEO
// log stuff
debughandle = fopen ("log.txt", "wb");
#endif
// Initialize DVD subsystem (GameCube only) // Initialize DVD subsystem (GameCube only)
#ifndef HW_RVL #ifndef HW_RVL
DVD_Init (); DVD_Init ();

View File

@ -48,6 +48,10 @@ GXTexObj texobj;
Mtx view; Mtx view;
int vwidth, vheight, oldvwidth, oldvheight; int vwidth, vheight, oldvwidth, oldvheight;
float zoom_level = 1;
int zoom_xshift = 0;
int zoom_yshift = 0;
u32 FrameTimer = 0; u32 FrameTimer = 0;
u8 vmode_60hz = 0; u8 vmode_60hz = 0;
@ -334,8 +338,7 @@ draw_init ()
GX_SetNumChans (0); GX_SetNumChans (0);
GX_SetTexCoordGen (GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); GX_SetTexCoordGen (GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
//GX_SetTevOp (GX_TEVSTAGE0, GX_DECAL);
//GX_SetTevOrder (GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE); GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE);
GX_SetTevOrder (GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL); GX_SetTevOrder (GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL);
@ -409,8 +412,6 @@ StartGX ()
gui_alphasetup (); gui_alphasetup ();
// guPerspective (p, 60, 1.33F, 10.0F, 1000.0F);
// GX_LoadProjectionMtx (p, GX_PERSPECTIVE);
guOrtho(p, vmode->efbHeight/2, -(vmode->efbHeight/2), -(vmode->fbWidth/2), vmode->fbWidth/2, 10, 1000); // matrix, t, b, l, r, n, f guOrtho(p, vmode->efbHeight/2, -(vmode->efbHeight/2), -(vmode->fbWidth/2), vmode->fbWidth/2, 10, 1000); // matrix, t, b, l, r, n, f
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC); GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
@ -553,9 +554,7 @@ ResetVideo_Emu ()
TV_478i.viTVMode = VI_TVMODE_PAL_INT; TV_478i.viTVMode = VI_TVMODE_PAL_INT;
TV_224p.viTVMode = VI_TVMODE_PAL_DS; TV_224p.viTVMode = VI_TVMODE_PAL_DS;
TV_448i.viTVMode = VI_TVMODE_PAL_INT; TV_448i.viTVMode = VI_TVMODE_PAL_INT;
// set VI sizing // set VI position
//TV_239p.viWidth = TV_478i.viWidth = TV_224p.viWidth = TV_448i.viWidth = 640;
//TV_239p.viHeight = TV_478i.viHeight = TV_224p.viHeight = TV_448i.viHeight = 480;
TV_239p.viXOrigin = TV_478i.viXOrigin = TV_224p.viXOrigin = TV_448i.viXOrigin = (VI_MAX_WIDTH_PAL - 640)/2; TV_239p.viXOrigin = TV_478i.viXOrigin = TV_224p.viXOrigin = TV_448i.viXOrigin = (VI_MAX_WIDTH_PAL - 640)/2;
TV_239p.viYOrigin = TV_478i.viYOrigin = (VI_MAX_HEIGHT_PAL/2 - 478/2)/2; TV_239p.viYOrigin = TV_478i.viYOrigin = (VI_MAX_HEIGHT_PAL/2 - 478/2)/2;
TV_224p.viYOrigin = TV_448i.viYOrigin = (VI_MAX_HEIGHT_PAL/2 - 448/2)/2; TV_224p.viYOrigin = TV_448i.viYOrigin = (VI_MAX_HEIGHT_PAL/2 - 448/2)/2;
@ -569,9 +568,7 @@ ResetVideo_Emu ()
TV_478i.viTVMode = VI_TVMODE_NTSC_INT; TV_478i.viTVMode = VI_TVMODE_NTSC_INT;
TV_224p.viTVMode = VI_TVMODE_NTSC_DS; TV_224p.viTVMode = VI_TVMODE_NTSC_DS;
TV_448i.viTVMode = VI_TVMODE_NTSC_INT; TV_448i.viTVMode = VI_TVMODE_NTSC_INT;
// set VI sizing // set VI position
//TV_239p.viWidth = TV_478i.viWidth = TV_224p.viWidth = TV_448i.viWidth = 640;
//TV_239p.viHeight = TV_478i.viHeight = TV_224p.viHeight = TV_448i.viHeight = 480;
TV_239p.viXOrigin = TV_224p.viXOrigin = TV_478i.viXOrigin = TV_448i.viXOrigin = (VI_MAX_WIDTH_NTSC - 640)/2; TV_239p.viXOrigin = TV_224p.viXOrigin = TV_478i.viXOrigin = TV_448i.viXOrigin = (VI_MAX_WIDTH_NTSC - 640)/2;
TV_239p.viYOrigin = TV_478i.viYOrigin = (VI_MAX_HEIGHT_NTSC/2 - 478/2)/2; TV_239p.viYOrigin = TV_478i.viYOrigin = (VI_MAX_HEIGHT_NTSC/2 - 478/2)/2;
TV_224p.viYOrigin = TV_448i.viYOrigin = (VI_MAX_HEIGHT_NTSC/2 - 448/2)/2; TV_224p.viYOrigin = TV_448i.viYOrigin = (VI_MAX_HEIGHT_NTSC/2 - 448/2)/2;
@ -585,9 +582,7 @@ ResetVideo_Emu ()
TV_478i.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_INTERLACE); TV_478i.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_INTERLACE);
TV_224p.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_NON_INTERLACE); TV_224p.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_NON_INTERLACE);
TV_448i.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_INTERLACE); TV_448i.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_INTERLACE);
// set VI sizing // set VI position
//TV_239p.viWidth = TV_478i.viWidth = TV_224p.viWidth = TV_448i.viWidth = 640;
//TV_239p.viHeight = TV_478i.viHeight = TV_224p.viHeight = TV_448i.viHeight = 480;
TV_239p.viXOrigin = TV_224p.viXOrigin = TV_478i.viXOrigin = TV_448i.viXOrigin = (VI_MAX_WIDTH_NTSC - 640)/2; TV_239p.viXOrigin = TV_224p.viXOrigin = TV_478i.viXOrigin = TV_448i.viXOrigin = (VI_MAX_WIDTH_NTSC - 640)/2;
TV_239p.viYOrigin = TV_478i.viYOrigin = (VI_MAX_HEIGHT_NTSC/2 - 478/2)/2; TV_239p.viYOrigin = TV_478i.viYOrigin = (VI_MAX_HEIGHT_NTSC/2 - 478/2)/2;
TV_224p.viYOrigin = TV_448i.viYOrigin = (VI_MAX_HEIGHT_NTSC/2 - 448/2)/2; TV_224p.viYOrigin = TV_448i.viYOrigin = (VI_MAX_HEIGHT_NTSC/2 - 448/2)/2;
@ -595,10 +590,9 @@ ResetVideo_Emu ()
break; break;
} }
int i = -1;
if (GCSettings.render == 0) // original render mode if (GCSettings.render == 0) // original render mode
{ {
int i;
for (i=0; i<4; i++) { for (i=0; i<4; i++) {
if (tvmodes[i]->efbHeight == vheight) { if (tvmodes[i]->efbHeight == vheight) {
// FIX: ok? // FIX: ok?
@ -637,20 +631,14 @@ ResetVideo_Emu ()
GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
// guPerspective (p, 60, 1.33F, 10.0F, 1000.0F);
// GX_LoadProjectionMtx (p, GX_PERSPECTIVE);
guOrtho(p, rmode->efbHeight/2, -(rmode->efbHeight/2), -(rmode->fbWidth/2), rmode->fbWidth/2, 10, 1000); // matrix, t, b, l, r, n, f guOrtho(p, rmode->efbHeight/2, -(rmode->efbHeight/2), -(rmode->fbWidth/2), rmode->fbWidth/2, 10, 1000); // matrix, t, b, l, r, n, f
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC); GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
#ifdef _DEBUG_VIDEO
/* // log stuff
// DEBUG fprintf(debughandle, "\n\nrmode = tvmodes[%d], field_rendering: %d", i, (rmode->viHeight == 2 * rmode->xfbHeight));
char* msg = (char*) malloc(256*sizeof(char)); fprintf(debughandle, "\nInterlaced: %i,\t vwidth: %d, vheight: %d,\t fb_W: %u, efb_H: %u", IPPU.Interlace, vwidth, vheight, rmode->fbWidth, rmode->efbHeight);
sprintf (msg, (char*)"Interlaced: %i, vwidth: %d, vheight: %d, fb_W: %u, efb_H: %u", IPPU.Interlace, vwidth, vheight, rmode->fbWidth, rmode->efbHeight); #endif
S9xMessage (0, 0, msg);
free(msg);
*/
} }
@ -682,8 +670,6 @@ ResetVideo_Menu ()
GX_SetFieldMode (vmode->field_rendering, ((vmode->viHeight == 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); GX_SetFieldMode (vmode->field_rendering, ((vmode->viHeight == 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
// guPerspective (p, 60, 1.33F, 10.0F, 1000.0F);
// GX_LoadProjectionMtx (p, GX_PERSPECTIVE);
guOrtho(p, vmode->efbHeight/2, -(vmode->efbHeight/2), -(vmode->fbWidth/2), vmode->fbWidth/2, 10, 1000); // matrix, t, b, l, r, n, f guOrtho(p, vmode->efbHeight/2, -(vmode->efbHeight/2), -(vmode->fbWidth/2), vmode->fbWidth/2, 10, 1000); // matrix, t, b, l, r, n, f
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC); GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
} }
@ -783,6 +769,9 @@ update_video (int width, int height)
if (GCSettings.widescreen) if (GCSettings.widescreen)
xscale -= (4.0*yscale)/9; xscale -= (4.0*yscale)/9;
xscale *= zoom_level;
yscale *= zoom_level;
square[6] = square[3] = xscale + xshift; square[6] = square[3] = xscale + xshift;
square[0] = square[9] = -xscale + xshift; square[0] = square[9] = -xscale + xshift;
square[4] = square[1] = yscale + yshift; square[4] = square[1] = yscale + yshift;
@ -797,26 +786,16 @@ update_video (int width, int height)
GX_LoadTexObj (&texobj, GX_TEXMAP0); // load texture object so its ready to use GX_LoadTexObj (&texobj, GX_TEXMAP0); // load texture object so its ready to use
/* #ifdef _DEBUG_VIDEO
// DEBUG // log stuff
char* msg = (char*) malloc(256*sizeof(char)); fprintf(debughandle, "\nxscale: %d, yscale: %d", xscale, yscale);
sprintf (msg, (char*)"xscale: %d, yscale: %d", xscale, yscale); #endif
S9xMessage (0, 0, msg);
free(msg);
*/
oldvwidth = vwidth; oldvwidth = vwidth;
oldvheight = vheight; oldvheight = vheight;
CheckVideo = 0; CheckVideo = 0;
} }
/*
// for zooming
memset (&view, 0, sizeof (Mtx));
guLookAt(view, &cam.pos, &cam.up, &cam.view);
GX_LoadPosMtxImm (view, GX_PNMTX0);
*/
MakeTexture ((char *) GFX.Screen, (char *) texturemem, vwidth, vheight); // convert image to texture MakeTexture ((char *) GFX.Screen, (char *) texturemem, vwidth, vheight); // convert image to texture
DCFlushRange (texturemem, TEX_WIDTH * TEX_HEIGHT * 2); // update the texture memory DCFlushRange (texturemem, TEX_WIDTH * TEX_HEIGHT * 2); // update the texture memory
@ -836,23 +815,19 @@ update_video (int width, int height)
} }
// FIX
/**************************************************************************** /****************************************************************************
* Zoom Functions * Zoom Functions
***************************************************************************/ ***************************************************************************/
void void
zoom (float speed) zoom (float speed)
{ {
Vector v; if (zoom_level > 1)
zoom_level += (speed / -100.0);
else
zoom_level += (speed / -200.0);
v.x = cam.view.x - cam.pos.x; if (zoom_level < 0.5) zoom_level = 0.5;
v.y = cam.view.y - cam.pos.y; else if (zoom_level > 10.0) zoom_level = 10.0;
v.z = cam.view.z - cam.pos.z;
cam.pos.x += v.x * speed;
cam.pos.z += v.z * speed;
cam.view.x += v.x * speed;
cam.view.z += v.z * speed;
oldvheight = 0; // update video oldvheight = 0; // update video
} }
@ -860,10 +835,7 @@ zoom (float speed)
void void
zoom_reset () zoom_reset ()
{ {
// reset cam to defaults zoom_level = 1.0;
cam.pos.x = cam.pos.y = cam.pos.z = cam.up.x = cam.up.z = 0.0F;
cam.up.y = 0.0F;
cam.view.z = -0.5F;
oldvheight = 0; // update video oldvheight = 0; // update video
} }

View File

@ -28,4 +28,9 @@ void zoom_reset ();
extern bool progressive; extern bool progressive;
#ifdef _DEBUG_VIDEO
// log stuff
extern FILE * debughandle;
#endif
#endif #endif