From e94bb52e354234ebeb1f4e0a6ac775014e1d7164 Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew@gmail.com" Date: Thu, 3 Dec 2009 07:17:36 +0000 Subject: [PATCH] Erwan - adding some debugging stuff for the purple screen --- JGE/include/JRenderer.h | 4 +++ JGE/src/JGfx.cpp | 80 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/JGE/include/JRenderer.h b/JGE/include/JRenderer.h index b11d14922..43931923e 100644 --- a/JGE/include/JRenderer.h +++ b/JGE/include/JRenderer.h @@ -83,6 +83,10 @@ public: ////////////////////////////////////////////////////////////////////////// static JRenderer* GetInstance(); +//START PurpleScreen Debug + static int debugged; +//END PurpleScreen Debug + static void Destroy(); static void Set3DFlag(bool flag); diff --git a/JGE/src/JGfx.cpp b/JGE/src/JGfx.cpp index 9887822e8..327ea9b8e 100644 --- a/JGE/src/JGfx.cpp +++ b/JGE/src/JGfx.cpp @@ -40,6 +40,56 @@ static unsigned int __attribute__((aligned(16))) list[262144]; extern void SwizzlePlot(u8* out, PIXEL_TYPE color, int i, int j, unsigned int width); +//START PurpleScreen Debug +int JRenderer::debugged = 0; +typedef struct +{ + unsigned int* start; + unsigned int* current; + int parent_context; +} GuDisplayList; + +typedef struct +{ + GuDisplayList list; + int scissor_enable; + int scissor_start[2]; + int scissor_end[2]; + int near_plane; + int far_plane; + int depth_offset; + int fragment_2x; + int texture_function; + int texture_proj_map_mode; + int texture_map_mode; + int sprite_mode[4]; + unsigned int clear_color; + unsigned int clear_stencil; + unsigned int clear_depth; + int texture_mode; +} GuContext; + +typedef struct +{ + int pixel_size; + int frame_width; + void* frame_buffer; + void* disp_buffer; + void* depth_buffer; + int depth_width; + int width; + int height; + } GuDrawBuffer; + +extern int gu_curr_context; +extern GuDrawBuffer gu_draw_buffer; +extern GuContext gu_contexts[3]; +extern GuDisplayList* gu_list; + + +//END PurpleScreen Debug + + void Swap(float *a, float *b) { @@ -211,14 +261,6 @@ void JRenderer::InitRenderer() sceGuDepthBuffer(zbp, FRAME_BUFFER_WIDTH); } - FILE * pFile; - pFile = fopen ("graphiclog.txt","w"); - char temp[600]; - sprintf(temp,"fbp0:%p\nfbp1:%p\nBuffer Format:%d\nFrame Buffer Width:%d\nScreen Width:%d\nScreen Height:%d\n",fbp0,fbp1,BUFFER_FORMAT,FRAME_BUFFER_WIDTH,SCREEN_WIDTH,SCREEN_HEIGHT); - fputs(temp,pFile); - fclose (pFile); - - sceGuOffset(2048 - (SCREEN_WIDTH/2), 2048 - (SCREEN_HEIGHT/2)); sceGuViewport(2048, 2048, SCREEN_WIDTH, SCREEN_HEIGHT); sceGuScissor(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); @@ -352,6 +394,28 @@ void JRenderer::EndScene() mCurrentTex = -1; mCurrentBlend = -1; + +//START PurpleScreen Debug + if (!debugged){ + debugged = 1; + FILE * pFile; + pFile = fopen ("graphiclog.txt","w"); + char temp[4096]; + sprintf(temp,"fbp0:%p\nfbp1:%p\nBuffer Format:%d\nFrame Buffer Width:%d\nScreen Width:%d\nScreen Height:%d\n",fbp0,fbp1,BUFFER_FORMAT,FRAME_BUFFER_WIDTH,SCREEN_WIDTH,SCREEN_HEIGHT); + fputs(temp,pFile); + sprintf(temp,"\nDRAW BUFFER:\npixel_size:%d\nframe_width:%d\nframe_buffer:%p\n",gu_draw_buffer.pixel_size,gu_draw_buffer.frame_width,gu_draw_buffer.frame_buffer); + fputs(temp,pFile); + sprintf(temp,"disp_buffer:%p\ndepth_buffer:%p\ndepth_width:%d\nwidth:%d\nheight:%d\n",gu_draw_buffer.disp_buffer,gu_draw_buffer.depth_buffer,gu_draw_buffer.depth_width,gu_draw_buffer.width,gu_draw_buffer.height); + fputs(temp,pFile); + + GuContext gc = gu_contexts[gu_curr_context]; + + sprintf(temp,"\nGU CONTEXT:\nscissor_enable:%d\ndepth_offset:%d\nfragment_2x:%d\ntexture_function:%d\ntexture_mode:%d\n",gc.scissor_enable,gc.depth_offset,gc.fragment_2x,gc.texture_function,gc.texture_mode); + fputs(temp,pFile); + fclose (pFile); + } +//END PurpleScreen Debug + }