Retro Graphics Toolkit

Talk about development tools here

Moderator: BigEvilCorporation

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 » Fri Oct 24, 2014 2:52 am

I apologize for the double post but 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-G ... -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

Code: Select all

# 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

Code: Select all

# 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.

neologix
Very interested
Posts: 122
Joined: Mon May 07, 2007 5:19 pm
Location: New York, NY, USA
Contact:

Post by neologix » Fri Oct 24, 2014 5:41 am

While I personally am partial to JavaScript (my love of the Sphere engine demonstrates such), Lua seems to be the current favorite language of new apps with embedded scripting.

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Fri Oct 24, 2014 8:41 am

Yeah, I would choose Lua instead of custom-made script language.
It's very easy to learn, and very easy to connect with your application.
Anyway, please look into existing scripts.
Image

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 » Fri Oct 24, 2014 10:25 pm

Alright 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.

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Fri Oct 24, 2014 10:41 pm

I must say why separated lua dll is useful sometimes.
If you try to load some lua plugin (external dll), it will work if and only if you using separated lua dll. Reason is dll function resolve. Windows can't resolve function that must be in dll, because it's not looking in exe, and it don't have to! Otherwise you'll get another bugs.

So, try to load lua-gd library for example. (graphics library).
Image

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 » Sat Oct 25, 2014 11:38 pm

Yes I do see your point. I modified the build process to use the dll on windows. I was busy with other stuff unfortunately but now I will get to work on an API and also I will provide a lua binding with FLTK (the gui toolkit Retro Graphics Toolkit is based on) in order to quickly make additional dialogs for user input.

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 » Thu Jul 09, 2015 7:56 am

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.

Image

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-G ... kit.exe.7z (for windows users)
The source is located here: https://github.com/ComputerNerd/Retro-Graphics-Toolkit

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Re: Retro Graphics Toolkit

Post by sega16 » Sun Nov 15, 2015 9:25 pm

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.

db-electronics
Very interested
Posts: 89
Joined: Mon Feb 24, 2014 6:04 pm
Location: Kapuskasing, Ontario, Canada
Contact:

Re: Retro Graphics Toolkit

Post by db-electronics » Wed Mar 30, 2016 12:22 am

FYI I just built and installed RetroGraphicsToolkit on Ubuntu 14.04 and it needed all of this before building correctly:

sudo apt-get install libreadline6-dev
sudo apt-get install libfltk1.3-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libpng-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libxinerama-dev
sudo apt-get install libxft-dev
What does db stand for? Well that's an excellent question...
http://www.db-electronics.ca

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Re: Retro Graphics Toolkit

Post by sega16 » Wed Jun 01, 2016 12:34 am

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: Select all

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: Select all

RetroGraphicsToolkit --headless-examples imageConverter.lua
To learn how to use it do:

Code: Select all

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-G ... kit.exe.7z

segaMars
Newbie
Posts: 7
Joined: Mon Nov 14, 2016 3:18 pm
Location: Sweden

Re: Retro Graphics Toolkit

Post by segaMars » Sat Nov 03, 2018 7:43 pm

Just tried Retro Graphics Toolkit (.bin) for the first time but whatever image or spritesheet i import I get no palette colors and the imported image is just black. In the sprit tab the group name sometimes change to the image name and the sheetbox grow to the size of the image but nothing else :/.

I tried with the sonic sprite sheets in the SGDK sample project and also spritesheets from here:
https://www.spriters-resource.com/genes ... eet/61790/

Looks nice at first when importing the image as the software detects there character in the image, but after i press 'okay' the imported image is just black and there are no colors in the palette.

windows 7.

DocVooDoo
Newbie
Posts: 1
Joined: Mon Oct 29, 2018 6:49 pm

Re: Retro Graphics Toolkit

Post by DocVooDoo » Fri Nov 23, 2018 6:58 pm

segaMars wrote:
Sat Nov 03, 2018 7:43 pm
Just tried Retro Graphics Toolkit (.bin) for the first time but whatever image or spritesheet i import I get no palette colors and the imported image is just black. In the sprit tab the group name sometimes change to the image name and the sheetbox grow to the size of the image but nothing else :/.

I tried with the sonic sprite sheets in the SGDK sample project and also spritesheets from here:
https://www.spriters-resource.com/genes ... eet/61790/

Looks nice at first when importing the image as the software detects there character in the image, but after i press 'okay' the imported image is just black and there are no colors in the palette.

windows 7.
You need to create the color palette. Go to menu in Tilemaps actions -> Generate optimal palette with x amount of colors using the tilemap
Then click in the button "Preview"

You can see the original colors if you select Tilemaps actions -> Toggle true colors Viewing

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Re: Retro Graphics Toolkit

Post by sega16 » Sun Dec 09, 2018 8:43 am

To generate a palette for a sprite use the "Sprite actions" menu and click on "Generate optimal palette for selected sprite". Please first select the sprite then click on it.

You may have seen all black due to a bug that existed in previous versions of Retro Graphics Toolkit. This option would only work if you only had one row selected for palette generation. This is now resolved. Please re-download: https://github.com/ComputerNerd/Retro-G ... kit.exe.7z

Looking the sprite sheet you have posted I think those should not be sprites. Instead they would be should on plane A or B just like the way it is programmed in Sonic 1. You have a limited number of sprites on the screen. This limitation is because of the VDP/hardware not Retro Graphics Toolkit.

In addition the following changes were made:
* Fixed Riemersma dithering
* Add an example showing how to import Jazz Jackrabbit 2 levels using Lua.

Huge Lua API improvements. Instead of doing

Code: Select all

project.set(n)
tile.width
You can now do:

Code: Select all

projects[n].tiles.width
No more calling sync functions and constantly switching projects.

*The four positioned dither algorithms now use Lab for color comparison. This improved the performance of these algorithms.

Post Reply