[HOMEBREW] 3DS Paint [UPDATE][2.0][NEW]

Discussion in '3DS - Homebrew Development and Emulators' started by AlbertoSONIC, Nov 20, 2014.

  1. AlbertoSONIC
    OP

    AlbertoSONIC Pasta Team Member

    Member
    929
    1,223
    Jun 27, 2014
    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:

    Warning: Spoilers inside!


    Bugs:

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


    Downloads:

    Precompiled Files, ready to install: Link
    Nightly builds: 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
     
    cynosura, VinsCool, Hiccup and 26 others like this.


  2. Vengenceonu

    Vengenceonu Revenge is beneath me but accidents do happen.

    Member
    2,204
    1,933
    Jun 20, 2013
    United States
    The C Standard Library
    Homebrew Drawn penises incoming!
     
  3. Relys

    Relys Master of Computer Science

    Member
    863
    788
    Jan 5, 2007
    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
    1,229
    858
    Nov 24, 2012
    Nicely done! I will for sure look into that code while working on front end stuff for the 3DS :)
     
  5. memomo

    memomo ( ͡° ͜ʖ ͡°)

    Member
    1,072
    548
    Nov 30, 2013
    works great B-) thanks ​
    [​IMG]
    [​IMG]
     
    Margen67 and AlbertoSONIC like this.
  6. AlbertoSONIC
    OP

    AlbertoSONIC Pasta Team Member

    Member
    929
    1,223
    Jun 27, 2014
    Italy
    So, printbottombackgnd() should be printBottomBackgnd()?
     
    Relys likes this.
  7. gamefan5

    gamefan5 Kid Icarus Uprising connoiseur

    Member
    4,946
    2,067
    Aug 29, 2010
    Canada
    Somewhere in this Earth
    Nice... I wonder if it will support layers and other things at a later date. XD
     
  8. Relys

    Relys Master of Computer Science

    Member
    863
    788
    Jan 5, 2007
    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
    929
    1,223
    Jun 27, 2014
    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
    1,229
    858
    Nov 24, 2012
    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
    90
    29
    Feb 13, 2014
    dont worry for letter case, Im using also -_-
     
  12. filfat

    filfat Musician, Developer & Entrepreneur

    Member
    1,229
    858
    Nov 24, 2012
    Margen67, Relys and AlbertoSONIC like this.
  13. gamefan5

    gamefan5 Kid Icarus Uprising connoiseur

    Member
    4,946
    2,067
    Aug 29, 2010
    Canada
    Somewhere in this Earth
    hahaha, baby steps man. One thing at a time XD
     
  14. AlbertoSONIC
    OP

    AlbertoSONIC Pasta Team Member

    Member
    929
    1,223
    Jun 27, 2014
    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
    362
    210
    Aug 16, 2007
    France
    Maubeuge
    Strange 131Mo for your .3ds build !!!
     
  16. AlbertoSONIC
    OP

    AlbertoSONIC Pasta Team Member

    Member
    929
    1,223
    Jun 27, 2014
    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
    152
    140
    Aug 28, 2013
    You should use a line drawing algorithm between drawing points ;_;
     
  18. AlbertoSONIC
    OP

    AlbertoSONIC Pasta Team Member

    Member
    929
    1,223
    Jun 27, 2014
    Italy
    Tell me more about that...
     
  19. Relys

    Relys Master of Computer Science

    Member
    863
    788
    Jan 5, 2007
    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
    929
    1,223
    Jun 27, 2014
    Italy
    I noticed it too! May be usefull...