| 577 | // |
| 578 | //***************************************************************************** |
| 579 | void IGraphicsContext::StoreSaveScreenData() |
| 580 | { |
| 581 | s32 bufferwidth; |
| 582 | s32 pixelformat; |
| 583 | s32 unknown = 0; |
| 584 | |
| 585 | void * buffer; |
| 586 | char pngbuffer[128*1024]; |
| 587 | IO::Filename pngfile; |
| 588 | |
| 589 | extern std::string gSaveStateFilename; |
| 590 | sprintf( pngfile,"%s.png", gSaveStateFilename.c_str() ); //Add .png to filename |
| 591 | |
| 592 | u32 display_width = 0; |
| 593 | u32 display_height= 0; |
| 594 | |
| 595 | u32 frame_width = 480; |
| 596 | u32 frame_height= 272; |
| 597 | |
| 598 | // Not supported yet for tv out |
| 599 | if ( PSP_TV_CABLE > 0 ) |
| 600 | { |
| 601 | //TODO |
| 602 | //frame_width = 720; |
| 603 | //frame_height= 480; |
| 604 | return; |
| 605 | } |
| 606 | |
| 607 | ViewportType( &display_width, &display_height ); |
| 608 | #ifdef DAEDALUS_ENABLE_ASSERTS |
| 609 | DAEDALUS_ASSERT( display_width != 0 && display_height != 0, "Unhandled viewport type" ); |
| 610 | #endif |
| 611 | s32 x( (frame_width - display_width)/2 ); |
| 612 | s32 y( (frame_height - display_height)/2 ); |
| 613 | |
| 614 | sceDisplayGetFrameBuf( &buffer, &bufferwidth, &pixelformat, unknown ); |
| 615 | |
| 616 | ETextureFormat texture_format; |
| 617 | u32 bpp; |
| 618 | u32 pitch; |
| 619 | |
| 620 | switch( pixelformat ) |
| 621 | { |
| 622 | case PSP_DISPLAY_PIXEL_FORMAT_565: |
| 623 | { |
| 624 | texture_format = TexFmt_5650; |
| 625 | bpp = 2; |
| 626 | pitch = bufferwidth * bpp; |
| 627 | buffer = reinterpret_cast< u8 * >( buffer ) + (y * pitch) + (x * bpp); |
| 628 | |
| 629 | //copy and reduce data to 1/4 |
| 630 | for(u32 ys=0; ys<display_height; ys +=2) |
| 631 | { |
| 632 | for(u32 xs=0; xs<display_width; xs +=2) |
| 633 | { |
| 634 | u32 pix = *(u16*)((u32)buffer + ys * pitch + xs * bpp); |
| 635 | *(u16*)((u32)pngbuffer + (ys>>1) * (display_width>>1) * bpp + (xs>>1) * bpp) = pix; |
| 636 | } |
nothing calls this directly
no test coverage detected