[Request] Possibility of screenshot homebrew for wii u?

Discussion in 'Wii U - Homebrew' started by Sonic Angel Knight, Oct 2, 2016.

  1. Sonic Angel Knight
    OP

    Sonic Angel Knight GBAtemp Legend

    Member
    10,032
    5,079
    May 27, 2016
    United States
    New York
    I know this maybe not of importance to anyone, but we all know the wii u lacks a proper screen shot option much like the 3DS does, but homebrew like hans which only works with carts and NTR CFW which also works but with... everything, i hope one can be made for Wii u.

    If you wondering why i brought this up, well look at it this way. For a "Screen shot" Is very uncommon but this is how you could ge one. The following requires nintendo network account.
    1. During game play, press the home button.
    2. Go to mii verse (Without closing the game)
    3. Upload to photo album on your miiverse page.
    4. Use another device. (Computer, cellphone, basically anything can download images from the web) Open web browser and log into nintendo network and miiverse then download images to device.
    5. Optionally you can also open web browser to find inside your book marks a wii u image uploader tool for other social network sites like twitter. You can download images same way.
    Sounds okay with you? Every time you want screen shots you have to do this... unlike super smash bros, where it supports taking in game screen shots and saving it to sd card, is very tedious process. Also note you cannot pause home menu on every screen so it also not such a great option, no way to have online multiplayer screen shots, or whatever.

    Why would someone want to screen shot, well think about this as well. After looking at the review section for wii u, there isn't as many games as other consoles. I believe is cause of this that discourages people for doing some of them. Yes is true most of the popular ones exist but there is games like New Super Mario bros u. A WII U LAUNCH TITLE that isn't reveiwed yet. 4 years over due. This perhaps why at the time no one knew how to get screen shots other than using a capture card like Elgato HD, or avermedia, which cost money. Basiclly having screen shot functions could be possible to

    • Capture and share precious moments with ease (without needing nintendo miiverse to do so)
    • Lead to more reveiws cause of having easier option.
    • Less reasons to visit miiverse which has so many restrictions to things discourages lots of people from using it simply cause is not very social compared to other types of social media.
    Perhaps is kinda late in asking this but i just hope someone consider this possible. Screen shots is a common thing on alomst every device now and days, why is handeled like the way i mentioned above i dunno but is very odd.
     
    CosmoCortney likes this.


  2. CosmoCortney

    CosmoCortney The Hacker Furry

    Member
    1,550
    1,470
    Apr 18, 2013
    Germany
    on the cool side of the pillow
    this could maybe be implemented into JGecko U. Gecko dNET, GCNRdGUI and WiiRdGUI have a screenshot option as well.
    I think JGecko U would need to pause the game/system while dumping the screenshot so you won't need to press the home button.
    @BullyWiiPlaza
     
  3. Sonic Angel Knight
    OP

    Sonic Angel Knight GBAtemp Legend

    Member
    10,032
    5,079
    May 27, 2016
    United States
    New York
    As long as it can save to sd instead of having to upload to mii verse then using another device to download it, i'll be glad it can be done. :)
     
  4. CosmoCortney

    CosmoCortney The Hacker Furry

    Member
    1,550
    1,470
    Apr 18, 2013
    Germany
    on the cool side of the pillow
    it'd dump it to your computer
     
  5. Sonic Angel Knight
    OP

    Sonic Angel Knight GBAtemp Legend

    Member
    10,032
    5,079
    May 27, 2016
    United States
    New York
    Why would it do that? :ninja:
     
  6. CosmoCortney

    CosmoCortney The Hacker Furry

    Member
    1,550
    1,470
    Apr 18, 2013
    Germany
    on the cool side of the pillow
    because JGecko U runs on your computer
     
  7. Sonic Angel Knight
    OP

    Sonic Angel Knight GBAtemp Legend

    Member
    10,032
    5,079
    May 27, 2016
    United States
    New York
    Well i didn't know that, well "Is better than nothing" still a sd would be better, just saying. :rolleyes:
     
    Sinon likes this.
  8. BullyWiiPlaza

    BullyWiiPlaza Nintendo Hacking <3

    Member
    1,750
    1,423
    Aug 2, 2014
    Germany
    LOL, I was going to ask about screenshots on Wii U.

    I could see if I can get it working but probably not since it's not easy to do from scratch nor do I care too much since I have an Elgato Game Capture HD60 for recording and screenshots. :creep:

    Here is the Gecko.NET Wii screenshot C# code though:
    Code:
    #region Screenshot processing
    private static Byte ConvertSafely(double floatValue)
    {
        return (Byte)Math.Round(Math.Max(0, Math.Min(floatValue, 255)));
    }
    
    private static Bitmap ProcessImage(UInt32 width, UInt32 height, Stream analyze)
    {
    
        Bitmap BitmapRGB = new Bitmap((int)width, (int)height, PixelFormat.Format24bppRgb);
        BitmapData bData = BitmapRGB.LockBits(new Rectangle(0, 0, (int)width, (int)height),
                            ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
    
        int size = bData.Stride * bData.Height;
    
        Byte[] data = new Byte[size];
    
        System.Runtime.InteropServices.Marshal.Copy(bData.Scan0, data, 0, size);
    
        Byte[] bufferBytes= new Byte[width * height * 2];
    
        int y = 0;
        int u = 0;
        int v = 0;
        int yvpos = 0;
        int rgbpos = 0;
    
        analyze.Read(bufferBytes, 0, (int)(width * height * 2));
        for (int i = 0; i < width*height; i++)
        {
            yvpos = i * 2;
            //YV encoding is a bit awkward!
            if (i % 2 == 0) //Even
            {
                y = bufferBytes[yvpos];
                u = bufferBytes[yvpos + 1]; //U value is taken from current V block
                v = bufferBytes[yvpos + 3]; //Take V from next data YV block
            }
            else //Odd
                y = bufferBytes[yvpos];
                //u is taken from last pixel
                //v too!
    
            rgbpos = (i * 3);
                data[rgbpos] = ConvertSafely(1.164 * (y - 16) + 2.017 * (u - 128));                     //Blue pixel value
            data[rgbpos + 1] = ConvertSafely(1.164 * (y - 16) - 0.392 * (u - 128) - 0.813 * (v - 128)); //Greeen pixel value
            data[rgbpos + 2] = ConvertSafely(1.164 * (y - 16) + 1.596 * (v - 128));                     //Red pixel value
        }
    
        System.Runtime.InteropServices.Marshal.Copy(data, 0, bData.Scan0, data.Length);
    
        BitmapRGB.UnlockBits(bData);
    
        return BitmapRGB;
    }
    
    public Image Screenshot()
    {
        MemoryStream analyze;
    
        //Dump video registers
        analyze = new MemoryStream();
        Dump(0xCC002000, 0xCC002080, analyze);
        analyze.Seek(0, SeekOrigin.Begin);
        Byte[] viregs = new Byte[128];
        analyze.Read(viregs, 0, 128);
        analyze.Close();
    
        //Extract width, height and offset in memory
        UInt32  swidth = (UInt32)(viregs[0x49] << 3);
        UInt32 sheight = (UInt32)(((viregs[0] << 5) | (viregs[1] >> 3)) & 0x07FE);
        UInt32 soffset = (UInt32)((viregs[0x1D] << 16) | (viregs[0x1E] << 8) | viregs[0x1F]);
        if ( (viregs[0x1C] & 0x10) == 0x10)
            soffset <<= 5;
        soffset += 0x80000000;
        soffset -= (UInt32)((viregs[0x1C] & 0xF) << 3);
    
        //Dump video data
        analyze = new MemoryStream();
        Dump(soffset, soffset + sheight * swidth * 2, analyze);
        analyze.Seek(0, SeekOrigin.Begin);
    
        if (sheight > 600) //Progressive mode!
        {
            sheight = sheight / 2;
            swidth = swidth * 2;
        }
    
        Bitmap b = ProcessImage(swidth, sheight, analyze);
        analyze.Close();
    
        return b;
    }
    #endregion
    Looks messy :(

    For Wii U, IDA Pro finds the following functions:
    Code:
    OSSetScreenCapturePermission   .text 02018370 00000048   R . . . . . .
    OSGetScreenCapturePermission   .text 020183B8 00000028   R . . . . . .
    OSSetScreenCapturePermissionEx .text 020183E0 00000060   R . . . . . .
    OSGetScreenCapturePermissionEx .text 02018440 00000040   R . . . . . .
    Not needed since everything else works without pausing as well so this will too. It only needs to dump some memory and process it
     
    Last edited by BullyWiiPlaza, Oct 2, 2016
  9. Sonic Angel Knight
    OP

    Sonic Angel Knight GBAtemp Legend

    Member
    10,032
    5,079
    May 27, 2016
    United States
    New York
    Umm i dunno what this is, but if it means that screenshots are possible that sounds nice. Too bad this gecko stuff only seem to work with PC, if it could work with android or something perhaps it be even better. :)

    Still i do wish a sd save option was possible. :unsure:

    I'm no genius, but super smash bros has screenshot to sd, so if perhaps is possible to import it to some homebrew maybe?
     
  10. BullyWiiPlaza

    BullyWiiPlaza Nintendo Hacking <3

    Member
    1,750
    1,423
    Aug 2, 2014
    Germany
    It's possible on Android if it's possible for PC because both uses Java...
     
  11. Sonic Angel Knight
    OP

    Sonic Angel Knight GBAtemp Legend

    Member
    10,032
    5,079
    May 27, 2016
    United States
    New York
    Is there app for this i am not aware of yet? :blink:
     
  12. BullyWiiPlaza

    BullyWiiPlaza Nintendo Hacking <3

    Member
    1,750
    1,423
    Aug 2, 2014
    Germany
    No but it could be made then
     
  13. Sonic Angel Knight
    OP

    Sonic Angel Knight GBAtemp Legend

    Member
    10,032
    5,079
    May 27, 2016
    United States
    New York
    Well i just needed to know if is possible. Actually having it done is umm... gonna take time especially since i have no idea what i would be doing unlike some talented users here. :blush:

    I would actually need to learn what to do if i want it done myself. But that will take long. Anyway, thanks for clearing up the possibility. :)
     
  14. wolf-snake

    wolf-snake GBAtemp Advanced Fan

    Member
    965
    575
    Feb 5, 2009
    Mexico
    Isn't that something that Usendmii does?
     
    Crayon2000 likes this.
  15. Maschell

    Maschell GBAtemp Advanced Fan

    Member
    905
    1,325
    Jun 14, 2008
    Gambia, The
    Its possible to hook into the "GX2CopyColorBufferToScanBuffer" function and dump the texture straight from the WiiU
     
  16. Ryccardo

    Ryccardo WiiUaboo

    Member
    3,220
    1,547
    Feb 13, 2015
    Italy
    Imola
    Just FYI, in the meanwhile you can go to imgur or another photo hosting website instead of the miiverse app, which might be a little faster and certainly higher quality :)
     
    Osakasan and josamilu like this.
  17. BullyWiiPlaza

    BullyWiiPlaza Nintendo Hacking <3

    Member
    1,750
    1,423
    Aug 2, 2014
    Germany
    Bump, someone needs to help realize this because I'm not sure how to do it :)

    The struct definitions look as follows:
    Code:
    typedef struct _GX2Surface {
        s32 dimension;
        u32 width;
        u32 height;
        u32 depth;
        u32 num_mips;
        s32 format;
        s32 aa;
        s32 use;
        u32 image_size;
        void *image_data;
        u32 mip_size;
        void *mip_data;
        s32 tile;
        u32 swizzle;
        u32 align;
        u32 pitch;
        u32 mip_offset[13];
    } GX2Surface;
    
    typedef struct _GX2ColorBuffer {
        GX2Surface surface;
        u32 view_mip;
        u32 view_first_slice;
        u32 view_slices_count;
        void *aux_data;
        u32  aux_size;
        u32 regs[5];
    } GX2ColorBuffer;
    So we have to hook into the function GX2CopyColorBufferToScanBuffer because it is called constantly and we can get the void *image_data field from the GX2Surface which is contained in the GX2ColorBuffer? I don't know. :( As usual, thanks for any suggestions and code contributions.
    Code:
    case 0x0D: { /* cmd_take_screenshot */
        GX2ColorBuffer colorBuffer;
        // TODO Initialize colorBuffer!
        GX2Surface surface = colorBuffer.surface;
        void *image_data = surface.image_data;
        u32 image_size = surface.image_size;
    
        // Send the image size so that the client knows how much to read
        ret = sendwait(bss, clientfd, &image_size, 4);
        ASSERT_FUNCTION_SUCCEEDED(ret, "sendwait (image size)")
    
        unsigned int imageBytesSent = 0;
        while (imageBytesSent < image_size) {
            int length = image_size - imageBytesSent;
    
            // Do not smash the buffer
            if (length > DATA_BUFFER_SIZE) {
                length = DATA_BUFFER_SIZE;
            }
    
            // Send the image bytes
            memcpy(buffer, image_data, length);
            ret = sendwait(bss, clientfd, buffer, length);
            ASSERT_FUNCTION_SUCCEEDED(ret, "sendwait (image bytes)")
    
            imageBytesSent += length;
        }
    
        break;
    }
     
    Last edited by BullyWiiPlaza, Jan 5, 2017
    CosmoCortney likes this.
  18. Osakasan

    Osakasan GBAtemp Advanced Fan

    Member
    795
    447
    Sep 19, 2015
    This.

    There's even a webpage that allows to upload directly to Twitter, fb and tumblr.

    Wii U has a built in screenshot tool, it just doesn't save to SD
     
  19. BullyWiiPlaza

    BullyWiiPlaza Nintendo Hacking <3

    Member
    1,750
    1,423
    Aug 2, 2014
    Germany
    We don't care about that cheap Miiverse suggestion, we need a proper homebrew solution with PC transfer or even SD Card xD
     
    CosmoCortney likes this.
  20. Osakasan

    Osakasan GBAtemp Advanced Fan

    Member
    795
    447
    Sep 19, 2015
    Do your even know what i'm talking about?