int SetDrawScreen(int ghandle) { GUINITCHECK; GUSTART; DXPTEXTURE3 *old = dxpGraphicsData.rendertarget; if(ghandle == -1)return -1; if(ghandle == DX_SCREEN_BACK) { dxpGraphicsData.rendertarget = dxpGraphicsData.displaybuffer_back; } else { DXPTEXTURE3 *tmp; DXPGRAPHICSHANDLE *gptr; GHANDLE2GPTR(gptr,ghandle); tmp = gptr->tex; if(!tmp->texvram || tmp->swizzledflag)return -1; if(!(tmp->psm == GU_PSM_4444 || tmp->psm == GU_PSM_5551 || tmp->psm == GU_PSM_5650 || tmp->psm == GU_PSM_8888))return -1; dxpGraphicsData.rendertarget = tmp; ++tmp->refcount; } sceGuTexFlush(); sceGuDrawBufferList(dxpGraphicsData.rendertarget->psm,dxpGraphicsData.rendertarget->texvram,dxpGraphicsData.rendertarget->pitch); sceGuOffset(2048 - (dxpGraphicsData.rendertarget->width/2),2048 - (dxpGraphicsData.rendertarget->height/2)); sceGuViewport(2048,2048,dxpGraphicsData.rendertarget->width,dxpGraphicsData.rendertarget->height); dxpGraphicsData.forceupdate = 1; if(old != NULL && old != &dxpGraphicsData.displaybuffer[0] && old != &dxpGraphicsData.displaybuffer[1]) --old->refcount; return 0; }
byte* RenderTexture_GetTex(void) { byte *texture; sceGuDrawBufferList(GU_PSM_4444,vrelptr(renderTarget), texture); return reinterpret_cast<char*>(sceGeEdramGetAddr()) + reinterpret_cast<std::size_t>(vrelptr(renderTarget)); }
void blit_start(int start, int end) { clip_min_y = start; clip_max_y = end + 1; spr_num = 0; spr_index = 0; if (start == FIRST_VISIBLE_LINE) { clut = (UINT16 *)PSP_UNCACHE_PTR(&video_palettebank[palette_bank]); fix_num = 0; spr_disable = 0; if (clear_spr_texture) blit_clear_spr_sprite(); if (clear_fix_texture) blit_clear_fix_sprite(); sceGuStart(GU_DIRECT, gulist); sceGuDrawBufferList(GU_PSM_5551, draw_frame, BUF_WIDTH); sceGuScissor(0, 0, BUF_WIDTH, SCR_WIDTH); sceGuClear(GU_COLOR_BUFFER_BIT | GU_FAST_CLEAR_BIT); sceGuDrawBufferList(GU_PSM_5551, work_frame, BUF_WIDTH); sceGuClear(GU_COLOR_BUFFER_BIT | GU_FAST_CLEAR_BIT); sceGuScissor(24, 16, 336, 240); sceGuClearColor(CNVCOL15TO32(video_palette[4095])); sceGuClear(GU_COLOR_BUFFER_BIT | GU_FAST_CLEAR_BIT); sceGuClearColor(0); sceGuEnable(GU_ALPHA_TEST); sceGuTexMode(GU_PSM_T8, 0, 0, GU_TRUE); sceGuTexFilter(GU_NEAREST, GU_NEAREST); sceGuFinish(); sceGuSync(0, GU_SYNC_FINISH); } }
static void gba_upload_vram (void) { sceGuDisable(GU_SCISSOR_TEST); sceGuDisable(GU_DEPTH_TEST); sceGuEnable(GU_TEXTURE_2D); sceGuTexMode(GU_PSM_T8, 0, 0, GU_FALSE); sceGuClutMode(GU_PSM_5551,0,0xFF,0); sceGuClutLoad(32, index_copy_clut); sceGuDrawBufferList(GU_PSM_5551, GBA_VRAMTEXTURE_8bit_GU, 128); sceGuTexImage(0, 128, 256, 128, vram); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_8bit)); sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_8bit_GU + (128*256), 128); sceGuTexImage(0, 128, 256, 128, vram + (128*256)); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_8bit)); sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_8bit_GU + (128*256*2), 128); sceGuTexImage(0, 128, 256, 128, vram + (128*256) * 2); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_8bit)); sceGuTexMode(GU_PSM_T4, 0, 0, GU_FALSE); sceGuClutMode(GU_PSM_5551,0,0xFF,0); sceGuClutLoad(32, index_copy_clut); sceGuDrawBufferList(GU_PSM_5551, GBA_VRAMTEXTURE_4bit_GU, 256); sceGuTexImage(0, 256, 256, 256, vram); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_4bit)); sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_4bit_GU + (256*256) , 256); sceGuTexImage(0, 256, 256, 256, vram + (256 * 256 / 2)); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_4bit)); sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_4bit_GU + (256*256) * 2, 256); sceGuTexImage(0, 256, 256, 256, vram + (256 * 256 / 2)*2); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_4bit)); }
bool8 S9xSceGUInit2 (void) { SceGU.line_size = 512; SceGU.max_texture_size = 512; if (SceGU.max_texture_size >= 512) { SceGU.texture_size = 512; // SceGU.num_textures = 2; // See note in 3d.h SceGU.num_textures = 1; } else { SceGU.texture_size = SceGU.max_texture_size; SceGU.num_textures = 1; } // TODO ///////Settings.SceGUEnable = TRUE; // 2nd texture may be reserved for transparency in the future. #if 0 if (SceGU.num_textures == 2) { } #endif // Use a 16-bit pixel format 5-bits for RGB and 1-bit for Alpha (unused) SceGU.texture_format = GU_PSM_5551; SceGU.pixel_format = GU_PSM_5551; SceGU.ct = GU_COLOR_5551; SceGU.tt = GU_TEXTURE_16BIT; SceGU.mt = GU_VERTEX_16BIT; SceGU.dm = GU_TRANSFORM_2D; sceGuStart (0, SceGU.list); sceGuDrawBufferList (SceGU.pixel_format, (void *)0, SceGU.line_size); sceGuDispBuffer (480, 272, (void *)0x88000, SceGU.line_size); sceGuDepthBuffer ( (void *)0x110000, SceGU.line_size); sceGuOffset (0, 0); sceGuViewport ((480 / 2), (272 / 2), 480, 272); sceGuDepthRange (0xc350, 0x2710); sceGuScissor (0, 0, 480, 272); sceGuEnable (GU_SCISSOR_TEST); sceGuDisable (GU_ALPHA_TEST); sceGuDisable (GU_DEPTH_TEST); sceGuEnable (GU_CULL_FACE); sceGuDisable (GU_LIGHTING); sceGuFrontFace (GU_CW); sceGuEnable (GU_TEXTURE_2D); sceGuClear (GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT); #if 0 sceGuTexWrap (GE_WRAP_REPEAT, GE_WRAP_REPEAT); sceGuTexFunc (GU_TFX_MODULATE, /*GE_TCC_RGBA*/ GE_TCC_RGB); #endif sceGuFinish (); sceGuSync (0, 0); S9xSceGUSwapBuffers (); return (TRUE); }
void DrawTilePSP (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE float x = Offset % GFX.Pitch; float y = Offset / GFX.Pitch; #define X 0 #define Y 1 #define U 0 #define V 1 float pos [3][4]; float tex [2][4]; static bool8 init = FALSE; if (init == FALSE) { sceGuStart(0,list); sceGuDrawBufferList(GE_PSM_5551,(void*)0,512); sceGuDispBuffer(480,272,(void*)0x88000,512); sceGuDepthBuffer((void*)0x110000,512); sceGuOffset(0,0); sceGuViewport(480/2,272/2,480,272); sceGuDepthRange(0xc350,0x2710); sceGuScissor(0,0,480,272); sceGuEnable(GU_STATE_SCISSOR); sceGuDisable(GU_STATE_ATE); sceGuDisable(GU_STATE_ZTE); sceGuEnable(GU_STATE_CULL); sceGuDisable(GU_STATE_ALPHA); sceGuDisable(GU_STATE_LIGHTING); sceGuFrontFace(GE_FACE_CW); sceGuEnable(GU_STATE_TEXTURE); sceGuClear(GE_CLEAR_COLOR|GE_CLEAR_DEPTH); sceGuFinish(); sceGuSync(0,0); init = TRUE; } pos [0][X] = 0 + x * 1; pos [0][Y] = 0 + y * 1; pos [1][X] = 0 + (x + 8.0f) * 1; pos [1][Y] = 0 + y * 1; pos [2][X] = 0 + (x + 8.0f) * 1; pos [2][Y] = 0 + (y + LineCount) * 1; pos [3][X] = 0 + x * 1; pos [4][Y] = 0 + (y + LineCount) * 1; if (!(Tile & (V_FLIP | H_FLIP))) { // Normal tex [0][U] = 0.0f; tex [0][V] = StartLine; tex [1][U] = 8.0f; tex [1][V] = StartLine; tex [2][U] = 8.0f; tex [2][V] = StartLine + LineCount; tex [3][U] = 0.0f; tex [3][V] = StartLine + LineCount; } else if (!(Tile & V_FLIP)) { // Flipped tex [0][U] = 8.0f; tex [0][V] = StartLine; tex [1][U] = 0.0f; tex [1][V] = StartLine; tex [2][U] = 0.0f; tex [2][V] = StartLine + LineCount; tex [3][U] = 8.0f; tex [3][V] = StartLine + LineCount; } else if (Tile & H_FLIP) { // Horizontal and vertical flip tex [0][U] = 8.0f; tex [0][V] = StartLine + LineCount; tex [1][U] = 0.0f; tex [1][V] = StartLine + LineCount; tex [2][U] = 0.0f; tex [2][V] = StartLine; tex [3][U] = 8.0f; tex [3][V] = StartLine; } else { // Vertical flip only tex [0][U] = 0.0f; tex [0][V] = StartLine + LineCount; tex [1][U] = 8.0f; tex [1][V] = StartLine + LineCount; tex [2][U] = 8.0f; tex [2][V] = StartLine; tex [3][U] = 0.0f; tex [3][V] = StartLine; } sceGuStart(0,list); sceGuTexMode(GU_PSM_5551,0,0,0); sceGuTexFunc(GU_TFX_REPLACE,0); sceGuTexOffset(0,0); sceGuAmbientColor(0xffffffff); sceGuTexImage (0, 8, 8, 8, (void *)pCache); sceGuTexScale (1.0/8.0f, 1.0f/8.0f); struct Vertex *vertices; vertices = (struct Vertex *)sceGuGetMemory (4 * sizeof (struct Vertex)); vertices[0].u = tex[0][U]; vertices[0].v = tex[0][V]; vertices[0].x = pos[0][X]; vertices[0].y = pos[0][Y]; vertices[0].z = 0.0f; vertices[1].u = tex[1][U]; vertices[1].v = tex[1][V]; vertices[1].x = pos[1][X]; vertices[1].y = pos[1][Y]; vertices[1].z = 0.0f; vertices[2].u = tex[2][U]; vertices[2].v = tex[2][V]; vertices[2].x = pos[2][X]; vertices[2].y = pos[2][Y]; vertices[2].z = 0.0f; vertices[3].u = tex[3][U]; vertices[3].v = tex[3][V]; vertices[3].x = pos[3][X]; vertices[3].y = pos[3][Y]; vertices[3].z = 0.0f; sceGuDrawArray (GU_PRIM_TRIANGLES,GE_SETREG_VTYPE(GE_TT_16BIT,GE_CT_5551,0,GE_MT_16BIT,0,0,0,0,GE_BM_2D),4,0,vertices); sceGuFinish (); }
int main(int argc, char* argv[]) { SetupCallbacks(); // generate geometry genTorus( TORUS_ROWS, TORUS_SLICES, TORUS_RADIUS, TORUS_THICKNESS, torus_vertices, torus_indices ); // flush cache so that no stray data remains sceKernelDcacheWritebackAll(); // setup Edram buffers void* frameBuffer = (void*)0; const void* doubleBuffer = (void*)0x44000; const void* renderTarget = (void*)0x88000; const void* depthBuffer = (void*)0x110000; // setup GU sceGuInit(); sceGuStart(GU_DIRECT,list); sceGuDrawBuffer(GU_PSM_4444,frameBuffer,BUF_WIDTH); sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)doubleBuffer,BUF_WIDTH); sceGuDepthBuffer((void*)depthBuffer,BUF_WIDTH); sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2)); sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT); sceGuDepthRange(0xc350,0x2710); sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT); sceGuEnable(GU_SCISSOR_TEST); sceGuDepthFunc(GU_GEQUAL); sceGuEnable(GU_DEPTH_TEST); sceGuFrontFace(GU_CW); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_CULL_FACE); sceGuEnable(GU_TEXTURE_2D); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); // run sample int val = 0; Texture offscreenTexture = { GU_PSM_4444, 0, 128, 128, 128, sceGeEdramGetAddr() + (int)renderTarget }; for(;;) { sceGuStart(GU_DIRECT,list); { sceGuDrawBufferList(GU_PSM_4444,(void*)renderTarget,offscreenTexture.stride); // setup viewport sceGuOffset(2048 - (offscreenTexture.width/2),2048 - (offscreenTexture.height/2)); sceGuViewport(2048,2048,offscreenTexture.width,offscreenTexture.height); // clear screen sceGuClearColor(0xffffffff); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // draw torus to offscreen texture drawTorus( val ); } { // set frame buffer sceGuDrawBufferList(GU_PSM_4444,(void*)frameBuffer,BUF_WIDTH); // setup viewport sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2)); sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT); // clear screen sceGuClearColor(0xff554433); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // draw cube using offscreen texture drawCube( &offscreenTexture, val ); } sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); frameBuffer = sceGuSwapBuffers(); val++; } sceGuTerm(); sceKernelExitGame(); return 0; }
int main(int argc, char* argv[]) { SetupCallbacks(); // generate geometry genGrid( GRID_ROWS, GRID_COLUMNS, GRID_SIZE, grid_vertices, grid_indices ); genTorus( TORUS_ROWS, TORUS_SLICES, TORUS_RADIUS, TORUS_THICKNESS, torus_vertices, torus_indices ); // flush cache so that no stray data remains sceKernelDcacheWritebackAll(); // setup VRAM buffers void* frameBuffer = (void*)0; const void* doubleBuffer = (void*)0x44000; const void* renderTarget = (void*)0x88000; const void* depthBuffer = (void*)0x110000; // setup GU sceGuInit(); sceGuStart(GU_DIRECT,list); sceGuDrawBuffer(GU_PSM_4444,frameBuffer,BUF_WIDTH); sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)doubleBuffer,BUF_WIDTH); sceGuDepthBuffer((void*)depthBuffer,BUF_WIDTH); sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2)); sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT); sceGuDepthRange(0xc350,0x2710); sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT); sceGuEnable(GU_SCISSOR_TEST); sceGuDepthFunc(GU_GEQUAL); sceGuEnable(GU_DEPTH_TEST); sceGuFrontFace(GU_CW); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_CULL_FACE); sceGuEnable(GU_TEXTURE_2D); sceGuEnable(GU_DITHER); sceGuFinish(); sceGuSync(0,0); sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); // setup matrices ScePspFMatrix4 identity; ScePspFMatrix4 projection; ScePspFMatrix4 view; gumLoadIdentity(&identity); gumLoadIdentity(&projection); gumPerspective(&projection,75.0f,16.0f/9.0f,0.5f,1000.0f); { ScePspFVector3 pos = {0,0,-5.0f}; gumLoadIdentity(&view); gumTranslate(&view,&pos); } ScePspFMatrix4 textureProjScaleTrans; gumLoadIdentity(&textureProjScaleTrans); textureProjScaleTrans.x.x = 0.5; textureProjScaleTrans.y.y = -0.5; textureProjScaleTrans.w.x = 0.5; textureProjScaleTrans.w.y = 0.5; ScePspFMatrix4 lightProjection; ScePspFMatrix4 lightProjectionInf; ScePspFMatrix4 lightView; ScePspFMatrix4 lightMatrix; gumLoadIdentity(&lightProjection); gumPerspective(&lightProjection,75.0f,1.0f,0.1f,1000.0f); gumLoadIdentity(&lightProjectionInf); gumPerspective(&lightProjectionInf,75.0f,1.0f,0.0f,1000.0f); gumLoadIdentity(&lightView); gumLoadIdentity(&lightMatrix); // define shadowmap Texture shadowmap = { GU_PSM_4444, 0, 128, 128, 128, sceGeEdramGetAddr() + (int)renderTarget }; // define geometry Geometry torus = { identity, sizeof(torus_indices)/sizeof(unsigned short), torus_indices, torus_vertices, 0xffffff }; Geometry grid = { identity, sizeof(grid_indices)/sizeof(unsigned short), grid_indices, grid_vertices, 0xff7777 }; // run sample int val = 0; for(;;) { // update matrices // grid { ScePspFVector3 pos = {0,-1.5f,0}; gumLoadIdentity(&grid.world); gumTranslate(&grid.world,&pos); } // torus { ScePspFVector3 pos = {0,0.5f,0.0f}; ScePspFVector3 rot = {val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f)}; gumLoadIdentity(&torus.world); gumTranslate(&torus.world,&pos); gumRotateXYZ(&torus.world,&rot); } // orbiting light { ScePspFVector3 lightLookAt = { torus.world.w.x, torus.world.w.y, torus.world.w.z }; ScePspFVector3 rot1 = {0,val * 0.79f * (GU_PI/180.0f),0}; ScePspFVector3 rot2 = {-(GU_PI/180.0f)*60.0f,0,0}; ScePspFVector3 pos = {0,0,LIGHT_DISTANCE}; gumLoadIdentity(&lightMatrix); gumTranslate(&lightMatrix,&lightLookAt); gumRotateXYZ(&lightMatrix,&rot1); gumRotateXYZ(&lightMatrix,&rot2); gumTranslate(&lightMatrix,&pos); } gumFastInverse(&lightView,&lightMatrix); // render to shadow map { sceGuStart(GU_DIRECT,list); // set offscreen texture as a render target sceGuDrawBufferList(GU_PSM_4444,(void*)renderTarget,shadowmap.stride); // setup viewport sceGuOffset(2048 - (shadowmap.width/2),2048 - (shadowmap.height/2)); sceGuViewport(2048,2048,shadowmap.width,shadowmap.height); // clear screen sceGuClearColor(0xffffffff); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // setup view/projection from light sceGuSetMatrix(GU_PROJECTION,&lightProjection); sceGuSetMatrix(GU_VIEW,&lightView); // shadow casters are drawn in black // disable lighting and texturing sceGuDisable(GU_LIGHTING); sceGuDisable(GU_TEXTURE_2D); // draw torus to shadow map drawShadowCaster( &torus ); sceGuFinish(); sceGuSync(0,0); } // render to frame buffer { sceGuStart(GU_DIRECT,list); // set frame buffer sceGuDrawBufferList(GU_PSM_4444,(void*)frameBuffer,BUF_WIDTH); // setup viewport sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2)); sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT); // clear screen sceGuClearColor(0xff554433); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // setup view/projection from camera sceGuSetMatrix(GU_PROJECTION,&projection); sceGuSetMatrix(GU_VIEW,&view); sceGuSetMatrix(GU_MODEL,&identity); // setup a light ScePspFVector3 lightPos = { lightMatrix.w.x, lightMatrix.w.y, lightMatrix.w.z }; ScePspFVector3 lightDir = { lightMatrix.z.x, lightMatrix.z.y, lightMatrix.z.z }; sceGuLight(0,GU_SPOTLIGHT,GU_DIFFUSE,&lightPos); sceGuLightSpot(0,&lightDir, 5.0, 0.6); sceGuLightColor(0,GU_DIFFUSE,0x00ff4040); sceGuLightAtt(0,1.0f,0.0f,0.0f); sceGuAmbient(0x00202020); sceGuEnable(GU_LIGHTING); sceGuEnable(GU_LIGHT0); // draw torus drawGeometry( &torus ); // setup texture projection sceGuTexMapMode( GU_TEXTURE_MATRIX, 0, 0 ); sceGuTexProjMapMode( GU_POSITION ); // set shadowmap as a texture sceGuTexMode(shadowmap.format,0,0,0); sceGuTexImage(shadowmap.mipmap,shadowmap.width,shadowmap.height,shadowmap.stride,shadowmap.data); sceGuTexFunc(GU_TFX_MODULATE,GU_TCC_RGB); sceGuTexFilter(GU_LINEAR,GU_LINEAR); sceGuTexWrap(GU_CLAMP,GU_CLAMP); sceGuEnable(GU_TEXTURE_2D); // calculate texture projection matrix for shadowmap ScePspFMatrix4 shadowProj; gumMultMatrix(&shadowProj, &lightProjectionInf, &lightView); gumMultMatrix(&shadowProj, &textureProjScaleTrans, &shadowProj); // draw grid receiving shadow drawShadowReceiver( &grid, shadowProj ); sceGuFinish(); sceGuSync(0,0); } sceDisplayWaitVblankStart(); frameBuffer = sceGuSwapBuffers(); val++; } sceGuTerm(); sceKernelExitGame(); return 0; }
void update_frame_ge(void) { check_gba_video_status(); // return; // printf("video mode: %u\n", gba_video_registers->lcd_control.bg_mode); int i; palette_ram_8bit[0]=palette_ram[0]&0x7FFF; for (i=1; i<256;i++) palette_ram_8bit[i]=palette_ram[i]|0x8000; palette_ram_8bit[256]=palette_ram[256]&0x7FFF; for (i=257; i<512;i++) palette_ram_8bit[i]=palette_ram[i]|0x8000; for (i=0; i<512;i++) { if (i&0xF) palette_ram_4bit[i]=palette_ram_8bit[i]|0x8000; else palette_ram_4bit[i]=palette_ram_8bit[i]&0x7FFF; } // sceKernelDcacheWritebackAll(); // sceKernelDcacheWritebackInvalidateAll(); RETRO_PERFORMANCE_INIT(gu_sync_time); RETRO_PERFORMANCE_START(gu_sync_time); sceGuSync(0,0); RETRO_PERFORMANCE_STOP(gu_sync_time); main_context_status= sceGuGetAllStatus(); sceGeSaveContext(&main_context_buffer); sceGuSetCallback(GU_CALLBACK_FINISH, list_finish_callback); sceGuStart(GU_DIRECT, d_list); init_3Dprojection(); setup_3Dprojection_16bit(); sceGuDisable(GU_DEPTH_TEST); // sceGuDepthBuffer((void*)VRAM_DEPTH,512); sceGuDepthMask(GU_TRUE); sceGuDepthRange(0,65535); sceGuDisable(GU_CULL_FACE); sceGuDisable(GU_CLIP_PLANES); // sceGuTexFilter(GU_NEAREST,GU_NEAREST); RETRO_PERFORMANCE_INIT(gba_upload_vram_proc); RETRO_PERFORMANCE_START(gba_upload_vram_proc); gba_upload_vram(); RETRO_PERFORMANCE_STOP(gba_upload_vram_proc); // sceGuDrawBufferList(GU_PSM_5551, GBA_FRAME_TEXTURE_GU, GBA_LINE_SIZE); sceGuDrawBufferList(GU_PSM_8888, GBA_FRAME_TEXTURE_GU, GBA_LINE_SIZE); sceGuDepthBuffer(GBA_DEPTH_BUFFER, GBA_LINE_SIZE); sceGuScissor(0,0,GBA_SCREEN_WIDTH,GBA_SCREEN_HEIGHT); sceGuScissor(0,0,240,160); sceGuEnable(GU_SCISSOR_TEST); // sceGuClearColor(0x000000FF); // sceGuClearColor((palette_ram[0]&0x1F<<3)|(palette_ram[0]&0x3E0<<6)|(palette_ram[0]&0x7C00<<9)|0xFF000000); sceGuClearColor(GU_COLOR(((palette_ram[0]>> 0) & 31) / 31.0f, ((palette_ram[0]>> 5) & 31) / 31.0f, ((palette_ram[0]>>10) & 31) / 31.0f, 1.0)); sceGuClear(GU_COLOR_BUFFER_BIT); // if (gba_draw_bg[gba_video_registers->lcd_control.bg_mode]) // gba_draw_bg[gba_video_registers->lcd_control.bg_mode](); RETRO_PERFORMANCE_INIT(gba_draw_bg_mode0_proc); RETRO_PERFORMANCE_START(gba_draw_bg_mode0_proc); gba_draw_bg_mode0(); RETRO_PERFORMANCE_STOP(gba_draw_bg_mode0_proc); // sceGuFinish(); sceGuFinishId(GBA_DISPLAY_LIST_ID); // RETRO_PERFORMANCE_INIT(gu_sync_time); // RETRO_PERFORMANCE_START(gu_sync_time); // sceGuSync(0,0); // RETRO_PERFORMANCE_STOP(gu_sync_time); }