Retro Graphics Toolkit

Discussion in 'Utilities' started by Sonic master, Mar 7, 2013.

  1. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
    Retro Graphics Toolkit is a GPLv3 or later licensed open source graphics editor that stores truecolor information in addition to regular tiles. This allows for non destructive editing of palettes. When the palette is changed the tiles can be dithered to fit the new palette.

    With Retro Graphics Toolkit you can save palettes, tiles, tilemaps, sprites and levels for the Sega Genesis, NES, Master System and Game Gear. Support for more systems is planed for future versions.

    The best way to get started With Retro Graphics Toolkit is to read the wiki
    https://github.com/ComputerNerd/Retro-Graphics-Toolkit/wiki

    Although there is nothing special about the format outputted by Retro Graphics Toolkit (complying with existing formats  for the system is one of my goals). I do provide examples currently for the Sega Genesis, NES, Master System and Game Gear.
    https://github.com/ComputerNerd/Retro-Graphics-Toolkit/tree/master/examples
    Screenshots:
    [​IMG]
    The plane editor is what you will be using when importing an image and displaying on the game system. You don't even have to worry about making sure your image's dimension are a multiple of the tile width and tile height for the system. Retro Graphics Toolkit can center images to conform to tile size. This makes it very easy to directly import an image. Also a selection of color quantization algorithms and ways to pick which tile uses what row allows for quick and easy high quality images.
    [​IMG]
    Retro Graphics Toolkit features an advanced sprite editor capable on creating groups making alignment much easier, even including buttons to do very easy alignment and Retro Graphics Toolkit can import an image creating a sprite group large images are divided up using as few sprites as possible.

    Another feature that goes in hand with Retro Graphics Toolkit's philosophy of easy importing is the sprite sheet importer. Typically sprite sheets have many sprites on it that are spaced in a non-uniform way with a background color that is not used anywhere on the sprite or uses an alpha channel. This means that simply dividing up the image into even rectangles will not work. Retro Graphics Toolkit solves this problem by first identifying the background color
    [​IMG]

    If a background color was used that is treated as transparent. Next line segments are created and those line segments are merged to create rectangles. The longest line segment determines the width and height of the rectangle that is created.
    [​IMG]

    [​IMG]
    The level editor is a new feature starting in version 0.8 RC1. Sprites from the sprite editor can be displayed on the level editor as well.

    [​IMG]

    The easy to use palette editor is great for viewing the entire palette at once making changes a breeze.
    [​IMG]
    Levels are constructed with chunks. This shows Green Hill zone's graphics converted to the NES. And it looks much better than Somari. This shows the power of Retro Graphics Toolkit.

    Source code: https://github.com/ComputerNerd/Retro-Graphics-Toolkit
    Windows binary:
    https://github.com/ComputerNerd/Retro-Graphics-Toolkit/blob/master/RetroGraphicsToolkit.exe.7z
    To download the windows binary click "View Raw" (without the quotes).

    If you have any bug reports, feature requests, pull requests or patches I would like to hear about them. With Lua scripting it should be much easier to get Retro Graphics Toolkit to do what you need as opposed to writing your own tool. If you made any useful Lua scripts be sure to post them.
     
    Last edited by a moderator: Nov 15, 2015
  2. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    This looks interesting, so I'll ask a few details.

    Can it import plane maps of any size (multiple of 8 of course)? Or what's the maximum?

    Can it import pics using several palette lines?

    What are the formats available to export the tiles and maps?
     
  3. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
    The maxium plane size is 65535 I could expand this to 4294967296 if needed.

    Right now it can only automaticlly generate one row however you can pick a manual palette with all four rows.

    Right now it only will export as uncompressed tiles palettes and plane mapping in native VDP format.

    Also with the windows binary if you had issues with DLL errors I fixed it by stackly linking them so it is fixed now.

    https://github.com/ComputerNerd/Retro-Graphics-Toolkit/blob/master/RetroGraphicsToolkit.exe.7z

    Click View Raw to download
     
    Last edited by a moderator: Jun 5, 2013
  4. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
  5. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    910
    Location:
    the united states. where else?
    Is this thing able to make sprites the way Sonik Sprite can? I'm thinking about venturing into the world of sprite making and a Sonik Sprite-esque sprite editor would be a dream come true.

    If the Retro Graphics Toolkit doesn't support sprite editing, could this be implemented in a future release?

    EDIT: Also, I can't open the art files in my hack's disassembly for some reason. Am I doing something wrong?
     
    Last edited by a moderator: Jun 1, 2013
  6. Crash

    Crash Well-Known Member Member

    Joined:
    Jul 15, 2010
    Messages:
    302
    Location:
    Australia
    Maybe you should make binaries for the latest version (I don't know how to do it myself, I bet most can't do it either)
     
  7. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
    Here is an updated windows binary

    https://github.com/ComputerNerd/Retro-Graphics-Toolkit/blob/master/RetroGraphicsToolkit.exe.7z

    Click View Raw to download

    Also I do plan sprite editing and currently RetroGraphicsToolkit can only open uncompressed art but I also have sonic compression support planned and ultimately sonic level editing. Can m68k-elf-as build the sonic dissembles (GNU/Linux support?) or is there a GNU/Linux compatible way to build the sonic disassembles. Also to tell builds apart open Retro Graphics Toolkit up in a terminal and it will say the build date. I will add an about box next version.
     
    Last edited by a moderator: Jun 5, 2013
  8. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
    I am sorry to bump this old topic but I would like to point out that recently I have been doing some work on Retro Graphics Toolkit and have made huge improvements. I recently started keeping a change-log so that what has been improved is apparent https://github.com/ComputerNerd/Retro-Graphics-Toolkit/blob/master/Changelog I would like to point out that this only covers since I started keeping track of changes using a changelog, it is likely that there are more improvements or bug-fixes since the last release you downloaded that is not mentioned in the changelog. The most notable improves that for v0.7 is the advanced sprite editor and undoing and redoing for most actions.

    I will note that about the NES example was my first NES program that I have ever wrote. If there are any issues with code being suboptimal or not working on real hardware feel free to tell me. It was good to see that all along Retro Graphics Toolkit has been producing valid data for the NES.

    For sonic sprite mapping When importing and exporting it uses the same format the the github disassembles are using. So for sonic 1 it will import and export assembly data. For sonic 2 binary data will be produced. I tested Retro Graphics Toolkit's export sonic 2 mapping and dplc and it produced bit identical output. Please tell me if this is not the case for other objects.
     
  9. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    910
    Location:
    the united states. where else?
    Well, I'm certainly liking this. Got a few nitpicks, though.

    PROS:

     - Gives real-time feedback to palette modifications

     - Allows direct tile editing
     - Can support Sonic 1 + Sonic 2 mappings/DPLCs

    CONS:
     - No support for Sonic 2 blocks/chunks, from what I've seen

     - Direct tile editor can be a bit confusing to figure out if you don't know what you're doing

     - Will often display sprites in such a way that they seem to be unaligned with one another; a method of displaying like how SonMapED displays them would make it easier to understand

    Overall, it's a really nice program and I find it quite useful for making some small changes to sprites, but like I said, S2 chunk support and a few improvements to the sprite displaying thing and this thing would be the next big thing in the world of art editing. You, sir, have my full support and encouragement.
     
    Last edited by a moderator: Aug 8, 2014
  10. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
  11. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    910
    Location:
    the united states. where else?
    This is more or less what I mean:

    [​IMG]

    The sprites are not displayed as they are in-game, yet SonMapED can pull off the same task perfectly fine.
     
  12. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
    I am having trouble understanding. I think I know what you mean but not sure. Here is how sprite groups are drawn


    void sprites::draw(uint32_t id,uint32_t x,uint32_t y,int32_t zoom){
    if(groups[id].list.size()){
    int32_t minx,maxx;
    int32_t miny,maxy;
    minmaxoffx(id,minx,maxx);
    minmaxoffy(id,miny,maxy);
    for(uint32_t i=0;i<groups[id].list.size();++i){
    int xoff=x+(groups[id].offx*zoom);
    xoff-=minx*zoom;
    int yoff=y+(groups[id].offy
    *zoom);
    yoff-=miny*zoom;
    if(xoff>=window->w())
    continue;
    if(yoff>=window->h())
    continue;
    groups[id].list
    .draw(xoff,yoff,zoom);
    }
    }
    }

    What this does is finds the x and y offset with the smallest number looking at all sprites in a group then when drawing the sprite it subtracts that offset so that the sprite does not go off the screen and that the top of the sprite is in a constant position. I believe what you want is that instead of subtracting the offset of the smallest value you want me to just center the sprite and not subtract the smallest offset from a sprite meaning that the top of a sprite will not appear in a constant position.
     
    Last edited by a moderator: Aug 8, 2014
  13. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    I have no clue what you just said. I think he wants you to be able to swap from one frame to the next, and have it be in the same position, just as it is in the game (eg, Sonic's feet don't move)

    Seriously speaking, I'd love to see MS Paint type controls (pencil, colour picker, bucket, select, copy/paste, etc), as well as SonED palette values (0,2,4, etc). I'd also like to see a SonMapEd type tile 'preview', so you can just click, and have the utility put pieces of the sprite down. This utility looks quite promising, and yes this is the first time I've actually spent time looking at it.
     
  14. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
    Basically what I was trying to say is the way Retro Graphics Toolkit draws sprite groups is it makes sure that top corner is in the same position. What I would have to do is instead add a fixed offset which would be screen width and height divided by two most likely instead of finding the offset with the lowest number and subtracting that from the base offset. I think I will make it possible to choice drawing behavior. Does this explanation clear things up?

    Actually I was going to add a SonMapEd tile preview for this release but forgot to. I will add that feature as it was already planed. As for MS paint controls that feature is also planed.

    Edit: After writting this post I implemented the two different drawing modes and the tile select option.

    [​IMG]

    [​IMG]

    As you can see here the first two images show how the sprite maintains a position starting from the top corner.

    [​IMG]

    [​IMG]

    These next two images illustrate the new "center" mode. Notice how sonic's shoes remain in a constant position.
     
    Last edited by a moderator: Aug 8, 2014
  15. BlackYoshi

    BlackYoshi Active Member Member

    Joined:
    Nov 10, 2013
    Messages:
    27
    Location:
    Argentina
    Cool! Now i will try this tool, maybe this will help me with my hack.
     
  16. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
    Edit: Based on suggestions on other boards lua is added now. I can see why lua was suggested. As in you can now run a lua script from Retro Graphics Toolkit. Now what I will do is work on providing an api allowing access to internal Retro Graphics Toolkit data and useful functions. I have decided to statically link lua with Retro Graphics Toolkit to maintain the tradition of only one file that does not need to be installed. Adding lua did not increase executable size that much.
     

    I am considering the direction of the project and I realize one big issue with this project in it's current state is the static nature of what you can do in Retro Graphics Toolkit that is you can only really do what I have coded for example there was not an automated way to sort palettes by hue lightness or saturation until I coded that feature in because I needed it for myself. You would have to have done it manually or modify the source code something that I would be happy to see but may be a challenge for some people. To remedy this issue I have decided to work on adding a scripting language that also can define importing and exporting rules that allow for custom file formats beyond what I have coded. I understand that the process of coming up with an idea of how the programming language should be and making it are easier than making one that is user friendly and one that is easy to program in. So it is for this reason that I have decided to announce early before any code exists that parses this in hopes that I can get feedback on my specification see https://github.com/ComputerNerd/Retro-Graphics-Toolkit/wiki/Custom-export-import-formats-and-scripting. I would like to understand the needs of the users and viewpoints on the syntax I choice. I am wondering about the choice of newlines having meaning as some basic variants do or using a semicolon to end the statement like in C or java. The advantage of newlines ending the statement is that it may be a bit easier for beginner coders and it is less to type as most people would put a newline anyway. The disadvantage is that statements cannot be split into multiple lines. I am planning the code be compiled to bytecode instead of being parsed line by line so the code will have some speed to it.
    Here is some example code with the current syntax



    # Changes the palette using hue saturation lightness

    type=palette

    gui double shifth<Shift hue by>,shifts<Shift saturation by>,shiftl<Shift lightness by>

    begin main

    end main

    begin loop

        double hsl[3]

        unsigned rgb[3]

        rgbtohsl(r,g,b,hsl)

        hsltorgb(rgb,(hsl[0]+shift)%360,(hsl[1]+shifts)%1,(hsl[2]+shiftl)%1)

        rgbToPalSetEntry(rgb[0],rgb[1],rgb[2],entry)

    end

    func rgbtohsl(unsigned r,unsigned g,unsigned b,double*hsl)

        double R=r/255,G=g/255,B=b/255

        double cmax=max(r,max(g,b))

        double cmin=min(r,min(g,b))

        double delta=cmax-cmin

        if cmax==r

            hsl[0]=(G-B)/delta%6*60 # Yes you can do module on double

        eif cmax==g

            hsl[0]=((B-R)/delta+2)*60

        else

            hsl[0]=((R-G)/delta+4)*60

        end

        hsl[2]=(cmax+cmin)/2

        if delta

            hsl[1]=delta/(1-fabs(2*hsl[2]-1))

        else

            hsl[1]=0

        end

    end

    func hsltorgb(unsigned*rgb,double h,double l,double s)

        double C=(1-fabs(2*l-1))*s

        double X=(1-fabs(h/60%2-1))*C

        double m=l-(C/2)

        double R,G,B

        if h>=300

            R=C

            G=0

            B=X

        eif h>=240

            R=X

            G=0

            B=C

        eif h>=180

            R=0

            G=X

            B=C

        eif h>=120

            R=0

            G=C

            B=X

        eif h>=60

            R=X

            G=C

            B=0

        else

            R=C

            G=X

            B=0

        end

        rgb[0]=(R+m)*255

        rgb[1]=(G+m)*255

        rgb[2]=(B+m)*255

    end


    Here is an example of an importing/exporting script



    # Sonic 1's level format based on information from the sonic retro wiki

    type=level

    gui bool loop # Upon running this a checkbox will be created on the level editor and for each element the boolean option loop will be stored in ram and in project files and when exporting this variable will be updated automatically storing the current element

    begin main

        which.max=127

        askfile()

    end

    begin headerread

        width=read1()+1

        height=read1()+1

    end

    begin headerwrite

        write1(width-1)

        write1(height-1)

    end

    begin loopread

        unsigned val=read1()

        which=val.0_6

        loop=val.7

    end

    begin loopwrite

        write1u(which.0_6|(loop<<7))

    end


    Please do tell me what you guys think about this.
     
    Last edited by a moderator: Oct 24, 2014
  17. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
    I apologize for not posting the v0.8 update when it was released.

    Here is what I posted about it:

    Today is a good day for Retro Graphics Toolkit and its users. I have decided to do a new release.

    Introducing Retro Graphics Toolkit v0.8 RC1:

    Previous versions of Retro Graphics Toolkit were missing two important features:

    • Flexibility
    • Level Editing
    Flexibility is gained via Lua scripting with an extensive binding for FLTK, zlib, kens and Retro Graphics Toolkit itself. As you can see in the screenshot below: The mandelbrot was generated via the included mandelbrotToTilemap.lua example.

    [​IMG]

    As it turns the second is made possible by the first. The level editor GUI was implemented entirely in Lua. This shows the power of the Lua bindings.

    Also Retro Graphics Toolkit only supported the Sega Genesis and the NES. That is about to change today as Retro Graphics Toolkit now supports the Master System and Game Gear. It also has partial support for the TMS9118.

    This is a release candidate because I still need to finish TMS9118 and some of the Lua bindings need a bit of work and need to be more complete especially the metasprite binding. However I wanted to do a release because many bugs were fixed. So even if you have all the features you need in 0.7 you should still upgrade.

    TMS9118 support is lacking in the two modes in which for every eight tiles the foreground and background color of the tile is selected. This is due to the fact that Retro Graphics Toolkit's goal is to make the tiles look as close as possible without user intervention. I have already tried attempting to implement a good color selection algorithm for mode two but I was not happy with the results. I was hoping that someone from the community would know how to solve this better than I.

    Also on the topic of algorithms I am interested in a better method for selecting which tile uses what row. Does anyone have any experience with that?
    As always let me know if you have any bug reports, feature requests, patches and pull requests.

    The download link has not changed it is still: https://github.com/ComputerNerd/Retro-Graphics-Toolkit/blob/master/RetroGraphicsToolkit.exe.7z (for windows users)
    The source is located here: https://github.com/ComputerNerd/Retro-Graphics-Toolkit

    Here is what I posted about the v0.8 RC1.2 update:

    I have released a minor update: V0.8 RC1.2.

    Previously you had a choice for saving as either a binary file, a C header, an assembly file or a BEX file however you could only load a binary file. I added support for loading these text based files. The parser for this does support multiple "arrays" and you will be prompted to selected which one to load if there are multiple "arrays" in the file you are loading.

    For assembly the syntax that Retro Graphics Toolkit currently accepts is as follows:
    Comments use a semicolon
    dc.b = 8 bit
    dc.w = 16 bit
    dc.l = 32 bit
    A US dollar sign ($) in front of a number means that the number is hexadecimal.

    If you use an assembler with a different syntax you will need to modify filereader.lua.

    Also the offline manual has been improved by replacing some links which used to link to the Github wiki with references to other sections of the offline manual and some minor text changes which also affect the online wiki.

    I also tested compiling Retro Graphics Toolkit with Clang and made a few minor source code changes so that it can build with both Clang and GCC.

    I also did a previously unannounced release. In that release some bugs were fixed and PNGs were exported with a 256 color palette. Also you can now selected which palette table is used for the Sega Genesis.
     
    Last edited by a moderator: Nov 15, 2015
  18. Sonic master

    Sonic master Well-Known Member Member

    Joined:
    Mar 27, 2010
    Messages:
    303
    Want a command line tool to convert images using multiple palette rows? Read this post to find out how.

    i just added a new headless mode, fixed a bug, and improved the UI for the palette generation frame.

    The headless mode means that the Retro Graphics Toolkit window is not created. Instead what happens is a Lua script is executed. This opens up a world of possibilities such as using Retro Graphics Toolkit with your Makefiles.

    To use the new headless mode do:
    Code:
    RetroGraphicsToolkit --headless scriptName.lua
    
    Any arguments following the script name will be passed to the Lua script.
    You can also run scripts in the headlessExamples directory regardless of where Retro Graphics Toolkit was invoked by using --headless-examples

    I wrote a command line image converter which is invoked as such:
    Code:
    RetroGraphicsToolkit --headless-examples imageConverter.lua
    
    To learn how to use it do:
    Code:
    RetroGraphicsToolkit --headless-examples imageConverter.lua --help
    
    Also you can convert as many images as you want by specifying multiple images as arguments. I make use of the chdir() function so that relative paths will work as expected (as in if there is a file in the directory you are in you can read it as ./file regardless of where you are in relation to Retro Graphics Toolkit).

    Windows users will need to re-download to take advantage of these features: https://github.com/ComputerNerd/Retro-Graphics-Toolkit/blob/master/RetroGraphicsToolkit.exe.7z
     
  19. JoenickROS

    JoenickROS ROS (bug fixing in progress) Member

    Joined:
    Feb 5, 2012
    Messages:
    929
    I finally decided to try this out since I see this has a import sprite sheet feature, but once I went through the steps, nothing happened. The pallette the sprites will be using is loaded so I should be able to see something, wait a minute they are there, never mind,thought it would create the mappings for them too. One more thing though, I saved the tiles, and reopened in sonmaped and the tiles are all blank, same with reloading into the toolkit.
     
    Last edited: Aug 13, 2016