1. AlbertoSONIC

    OP AlbertoSONIC Pasta Team Member
    Member

    Joined:
    Jun 27, 2014
    Messages:
    927
    Country:
    Italy
    3DS Paint

    Today i introduce you to my latest 3DS Homebrew: 3DS Paint! With this app you can draw anything you want, with 7 colors and an eraser! You can also save your drawing to the SDCARD! (.bmp image output) You can find some instructions on the 3DS's top screen!


    How to install:

    You can install this app in many ways. As a Gateway's 3ds file, as a .cia file, it's also ready for SSSPwn! You can find files below!


    Screenshots:

    [​IMG]

    MAIN SCREEN:
    [​IMG]

    ABOUT POPUP:
    [​IMG]

    DEBUG POPUP:
    [​IMG]

    PAINT SCREEN:
    [​IMG]

    CLEAR SCREEN POPUP:
    [​IMG]

    EXIT POPUP:
    [​IMG]

    DRAWING SAVED!!
    [​IMG]

    HERE'S THE SAVED DRAWING:
    https://www.dropbox.com/s/mssno9rkp13vy4p/3dspaint_drawing_01342922.bmp?dl=0


    Bugs:

    - There's a small undrawable corner around the the touchscreen.


    Downloads:

    Precompiled Files, ready to install: Link
    Github Repo: Link


    ChangeLog:

    New 2.0 update brings:
    - Whole app rewritten
    - Now it exit without crashing, fully working on both NINJHAX and GATEWAY
    - Much smoother (30fps)
    - Debug features
    - A main menu!
    - Now you can save your drawings to SDCARD (.bmp image output)!
    - HUGE performance improvement

    - Less load for 3DS's ARM11 cpu
    - Developed and built with latest CTRULIB
    - New icon!
    - Now using an UI framework!
    - "Pop" sound when changing color! (Only for ninjhax users)
    - New font!
    - Screen Flickering fixed!
    . Huge bugfix!

    Credits:

    Relys
    filfat
    Bond697
    Screenshot feature (needed for saving) taken from BlargSnes
     
    Last edited: Sep 6, 2018
    cynosura, VinsCool, Hiccup and 26 others like this.
  2. Vengenceonu

    Vengenceonu Revenge is beneath me but accidents do happen.
    Member

    Joined:
    Jun 20, 2013
    Messages:
    2,213
    Country:
    United States
    Homebrew Drawn penises incoming!
     
  3. Relys

    Relys ^(Software | Hardware) Exploit? Development.$
    Member

    Joined:
    Jan 5, 2007
    Messages:
    874
    Country:
    United States
    Very nice. Clean example. Well documented. :)

    One thing I would recommend is using camelCase (https://en.wikipedia.org/wiki/CamelCase) for function names with the first word lowercase.

    Code:
    int fooBar() //camel case.
    {
        int someNumber=0; //Same idea for variables.
        return someNumber;
    }
    It really helps the readability and most C/C++ developers conform to this in their coding style standard (just look at ctrulib for example).
     
    Margen67, filfat and AlbertoSONIC like this.
  4. filfat

    filfat Musician, Developer & Entrepreneur
    Member

    Joined:
    Nov 24, 2012
    Messages:
    1,260
    Nicely done! I will for sure look into that code while working on front end stuff for the 3DS :)
     
  5. memomo

    memomo ( ͡° ͜ʖ ͡°)
    Member

    Joined:
    Nov 30, 2013
    Messages:
    1,079
    Country:
    works great B-) thanks ​
    [​IMG]
    [​IMG]
     
    Margen67 and AlbertoSONIC like this.
  6. AlbertoSONIC

    OP AlbertoSONIC Pasta Team Member
    Member

    Joined:
    Jun 27, 2014
    Messages:
    927
    Country:
    Italy
    So, printbottombackgnd() should be printBottomBackgnd()?
     
    Relys likes this.
  7. gamefan5

    gamefan5 Kid Icarus Uprising connoiseur
    Member

    Joined:
    Aug 29, 2010
    Messages:
    4,989
    Country:
    Canada
    Nice... I wonder if it will support layers and other things at a later date. XD
     
  8. Relys

    Relys ^(Software | Hardware) Exploit? Development.$
    Member

    Joined:
    Jan 5, 2007
    Messages:
    874
    Country:
    United States

    Yeah that's correct. It just helps readability and is a good habit to get into. :)
     
  9. AlbertoSONIC

    OP AlbertoSONIC Pasta Team Member
    Member

    Joined:
    Jun 27, 2014
    Messages:
    927
    Country:
    Italy
    First i'd like to find a way to output an image of the painting to the sdcard! But i think it won't be that easy...
     
    Margen67, SignZ, I pwned U! and 2 others like this.
  10. filfat

    filfat Musician, Developer & Entrepreneur
    Member

    Joined:
    Nov 24, 2012
    Messages:
    1,260
    Another tip would be naming structs like this "structNameHere_s" and naming local vars either "nameHere_l" or "_localVar" :)
     
    Relys likes this.
  11. jocopoco

    jocopoco Advanced Member
    Newcomer

    Joined:
    Feb 13, 2014
    Messages:
    90
    Country:
    dont worry for letter case, Im using also -_-
     
  12. filfat

    filfat Musician, Developer & Entrepreneur
    Member

    Joined:
    Nov 24, 2012
    Messages:
    1,260
    Margen67, Relys and AlbertoSONIC like this.
  13. gamefan5

    gamefan5 Kid Icarus Uprising connoiseur
    Member

    Joined:
    Aug 29, 2010
    Messages:
    4,989
    Country:
    Canada
    hahaha, baby steps man. One thing at a time XD
     
  14. AlbertoSONIC

    OP AlbertoSONIC Pasta Team Member
    Member

    Joined:
    Jun 27, 2014
    Messages:
    927
    Country:
    Italy
    Relys Just updated github repo, now functions names uses CamelCase. Guys you don't need to download another file, these changes doesn't affect the user experience at all!
     
    Relys likes this.
  15. Cid2mizard

    Cid2mizard GBAtemp Fan
    Member

    Joined:
    Aug 16, 2007
    Messages:
    388
    Country:
    France
    Strange 131Mo for your .3ds build !!!
     
  16. AlbertoSONIC

    OP AlbertoSONIC Pasta Team Member
    Member

    Joined:
    Jun 27, 2014
    Messages:
    927
    Country:
    Italy
    I know... I'm using a modified rsf file that output a 128 mb file. That's because of my Gateway's SPI Failure. Default rsf up in a minute ;)

    EDIT: Repo updated!
     
    Relys and Cid2mizard like this.
  17. ernilos

    ernilos GBAtemp Regular
    Member

    Joined:
    Aug 28, 2013
    Messages:
    152
    Country:
    United States
    You should use a line drawing algorithm between drawing points ;_;
     
  18. AlbertoSONIC

    OP AlbertoSONIC Pasta Team Member
    Member

    Joined:
    Jun 27, 2014
    Messages:
    927
    Country:
    Italy
    Tell me more about that...
     
  19. Relys

    Relys ^(Software | Hardware) Exploit? Development.$
    Member

    Joined:
    Jan 5, 2007
    Messages:
    874
    Country:
    United States
    Here's an example of loading an image from the sd card to the screen: https://github.com/smealum/ctrulib/blob/master/examples/sdmc/source/main.c


    Here I am attempting to reverse that process to write framebuffer to allocated buffer in memory and then write to file on sd card.
    Code:
     
        fsInit(); //needed for filesystem stuff
        u8* buffer;
        u64 size;
        u32 bytesWritten;
        Handle fileHandle;
        //setup SDMC archive
        FS_archive sdmcArchive=(FS_archive){ARCH_SDMC, (FS_path){PATH_EMPTY, 1, (u8*)""}};
        //create file path struct (note : FS_makePath actually only supports PATH_CHAR, it will change in the future)
        FS_path filePath=FS_makePath(PATH_CHAR, "/test.bin");
     
        //open file
        Result ret=FSUSER_OpenFileDirectly(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_CREATE, FS_ATTRIBUTE_NONE); //RELYS: Changed FS_OPEN_READ to FS_OPEN_CREATE. Not sure if FS_ATTRIBUTE_NONE needs to be changed to FS_ATTRIBUTE_ARCHIVE
        //check for errors : exit if there is one
        if(ret)goto exit;
     
        //get screen size
        size=320*240*3; // RELYS: x resolution * y resolution * 3 colors per pixel
     
        //allocate a buffer on linear heap (could just be a malloc fwiw)
        buffer=linearAlloc(size);
        if(!buffer)goto exit;
     
        //copy lower screen to buffer
        memcpy(buffer,gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL), size);
     
        //Write contents
        ret=FSFILE_Write(fileHandle, &bytesWritten, 0x0, buffer,FS_WRITE_FLUSH); //RELYS: Not sure if we want to use FS_WRITE_FLUSH or FS_WRITE_NOFLUSH
        if(ret || size!=bytesWritten)goto exit;
     
        //close the file because we like being nice and tidy
        ret=FSFILE_Close(fileHandle);
        if(ret)goto exit;
     
        //cleanup and return
        //returning from main() returns to hbmenu when run under ninjhax
        exit:
        //closing all handles is super important
        svcCloseHandle(fileHandle);
    I also noticed in the example that they use this for rendering. Maybe we should be using gfxSwappBuffersGPU and gspWaitForEvent???

    Code:
            renderEffect();
            //wait & swap
            gfxSwapBuffersGpu();
            gspWaitForEvent(GSPEVENT_VBlank0, false);
     
  20. AlbertoSONIC

    OP AlbertoSONIC Pasta Team Member
    Member

    Joined:
    Jun 27, 2014
    Messages:
    927
    Country:
    Italy
    I noticed it too! May be usefull...
     
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - [HOMEBREW], [UPDATE][2, 0][NEW]