From f743ba405a3b89a09c13a1f104b65e8b9edb54e4 Mon Sep 17 00:00:00 2001 From: dborth Date: Fri, 26 Sep 2008 01:01:08 +0000 Subject: [PATCH] video tweak --- source/ngc/vba.cpp | 1 + source/ngc/video.cpp | 96 ++++++++++++++++++++++---------------------- source/ngc/video.h | 1 + 3 files changed, 50 insertions(+), 48 deletions(-) diff --git a/source/ngc/vba.cpp b/source/ngc/vba.cpp index 86a53f8..95d2e99 100644 --- a/source/ngc/vba.cpp +++ b/source/ngc/vba.cpp @@ -65,6 +65,7 @@ int main() int selectedMenu = -1; InitialiseVideo(); + GX_Start(); // Initialise freetype font system if (FT_Init ()) diff --git a/source/ngc/video.cpp b/source/ngc/video.cpp index ad1f6f5..2e8270a 100644 --- a/source/ngc/video.cpp +++ b/source/ngc/video.cpp @@ -21,24 +21,23 @@ /*** External 2D Video ***/ /*** 2D Video Globals ***/ -GXRModeObj *vmode; /*** Graphics Mode Object ***/ -unsigned int *xfb[2]; /*** Framebuffers ***/ -int whichfb = 0; /*** Frame buffer toggle ***/ +GXRModeObj *vmode = NULL; // Graphics Mode Object +unsigned int *xfb[2]; // Framebuffers +int whichfb = 0; // Frame buffer toggle int screenheight; /*** 3D GX ***/ #define DEFAULT_FIFO_SIZE ( 256 * 1024 ) -static u8 gp_fifo[DEFAULT_FIFO_SIZE] ATTRIBUTE_ALIGN(32); +static u8 *gp_fifo; /*** Texture memory ***/ -static u8 *texturemem; +static u8 *texturemem = NULL; static int texturesize; GXTexObj texobj; static Mtx view; static int vwidth, vheight, oldvwidth, oldvheight; -unsigned int copynow = GX_FALSE; #define HASPECT 80 #define VASPECT 45 @@ -72,6 +71,43 @@ static camera cam = { {0.0F, 0.0F, 0.0F}, {0.0F, 0.0F, -0.5F} }; +/**************************************************************************** +* Initialise Video +* +* Before doing anything in libogc, it's recommended to configure a video +* output. +****************************************************************************/ +void InitialiseVideo () +{ + // Start VIDEO Subsystem + VIDEO_Init(); + + vmode = VIDEO_GetPreferredMode(NULL); + VIDEO_Configure(vmode); + + screenheight = vmode->xfbHeight; + + xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); + xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); + + VIDEO_SetNextFramebuffer(xfb[0]); + VIDEO_SetBlack(FALSE); + + // set timings in VI to PAL60 + /*u32 *vreg = (u32 *)0xCC002000; + for (int i = 0; i < 64; i++ ) + vreg[i] = vpal60[i];*/ + + VIDEO_Flush(); + VIDEO_WaitVSync(); + + if(vmode->viTVMode & VI_NON_INTERLACE) + VIDEO_WaitVSync(); + + VIDEO_SetPostRetraceCallback((VIRetraceCallback)UpdatePadsCB); + VIDEO_SetNextFramebuffer(xfb[0]); +} + /**************************************************************************** * StartGX ****************************************************************************/ @@ -85,7 +121,7 @@ void GX_Start() memset(&gp_fifo, 0, DEFAULT_FIFO_SIZE); /*** Initialise GX ***/ - GX_Init(&gp_fifo, DEFAULT_FIFO_SIZE); + GX_Init(gp_fifo, DEFAULT_FIFO_SIZE); GX_SetCopyClear(gxbackground, 0x00ffffff); GX_SetViewport(0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1); @@ -93,8 +129,7 @@ void GX_Start() GX_SetScissor(0, 0, vmode->fbWidth, vmode->efbHeight); GX_SetDispCopySrc(0, 0, vmode->fbWidth, vmode->efbHeight); GX_SetDispCopyDst(vmode->fbWidth, vmode->xfbHeight); - GX_SetCopyFilter(vmode->aa, vmode->sample_pattern, GX_TRUE, - vmode->vfilter); + GX_SetCopyFilter(vmode->aa, vmode->sample_pattern, GX_TRUE, vmode->vfilter); GX_SetFieldMode(vmode->field_rendering, ((vmode->viHeight == 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); @@ -121,43 +156,6 @@ UpdatePadsCB () PAD_ScanPads(); } -/**************************************************************************** -* Initialise Video -* -* Before doing anything in libogc, it's recommended to configure a video -* output. -****************************************************************************/ -void InitialiseVideo () -{ - /*** Start VIDEO Subsystem ***/ - VIDEO_Init(); - - vmode = VIDEO_GetPreferredMode(NULL); - VIDEO_Configure(vmode); - - screenheight = vmode->xfbHeight; - - xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); - xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode)); - - VIDEO_SetNextFramebuffer(xfb[0]); - VIDEO_SetBlack(FALSE); - - // set timings in VI to PAL60 - /*u32 *vreg = (u32 *)0xCC002000; - for (int i = 0; i < 64; i++ ) - vreg[i] = vpal60[i];*/ - - VIDEO_Flush(); - VIDEO_WaitVSync(); - - if(vmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); - VIDEO_SetPostRetraceCallback((VIRetraceCallback)UpdatePadsCB); - VIDEO_SetNextFramebuffer(xfb[0]); - - GX_Start(); -} - /**************************************************************************** * Scaler Support Functions ****************************************************************************/ @@ -218,8 +216,11 @@ void GX_Render_Init(int width, int height, int haspect, int vaspect) /*** Allocate 32byte aligned texture memory ***/ texturesize = (width * height) * 2; - texturemem = (u8 *) memalign(32, texturesize); + if (texturemem) + free(texturemem); + + texturemem = (u8 *) memalign(32, texturesize); memset(texturemem, 0, texturesize); /*** Setup for first call to scaler ***/ @@ -307,7 +308,6 @@ void GX_Render(int width, int height, u8 * buffer, int pitch) VIDEO_SetNextFramebuffer(xfb[whichfb]); VIDEO_Flush(); - //VIDEO_WaitVSync(); } diff --git a/source/ngc/video.h b/source/ngc/video.h index 591f992..f152e6e 100644 --- a/source/ngc/video.h +++ b/source/ngc/video.h @@ -15,6 +15,7 @@ #define __GXHDR__ void InitialiseVideo (); +void GX_Start(); void GX_Render_Init(int width, int height, int haspect, int vaspect); void GX_Render(int width, int height, u8 * buffer, int pitch); void clearscreen (int colour = COLOR_BLACK);