View Full Version : Tile and Sprite editor for Genesis/Megadrive
Archer
05-03-2011, 03:14 AM
Besides all the other projects i am working on, i really want to write a Tile and Sprite editor exclusively for the Megadrive. The reason is that most utilities i find are to "simple" or "stupid" but mostly look and feel very dated. I also want to have some special features that i have not found yet in other programs.
I want it to be open source and multi-platform (Linux, Windows and mac) so everyone can use it. It will be written in C/C++ and use GTK+ as a GUI toolkit. Since i use Linux myself, the first version will be linux only.
Here are some of the ideas i have right now:
- Import from BMP, PNG, JPG, etc (not GIF, because it has a patent on the compression)
- Export to RAW and compressed "tile set"
- Export to Sourcecode (C, ASM 68k, ASM GAS)
- Import/Export palettes in RAW or other formats
- Undo and Redo (Partially done)
- Megadrive Color selector (DONE)
- Overview of all Tiles in a Tileset
- Editor with grid to draw and edit tiles (DONE)
- Sprite preview (with all options from the SAT - Sprite Attribute Table)
- Extended editor to edit a Sprite madeup of any size sprite (DONE, but slow for large sprites)
- TitleScreen Editor and "generator"
- Sprite color shifter (shift colors on palette and change sprite color codes to match)
Suggestions by others:
- Import palette from bitmap
- Drawing "flickering trick" tiles using solid color (saved tile is split on export)
- Clicking both mouse buttons at the same time will undo current action
- Middle mouse button select color under cursor (DONE)
- tools selectable with keyboard-shortcut
- one pixel drawing with keyboard
- Normal/Shadow/Highlight colors (DONE)
And a few more i can't think of right now. If you have ideas or features that i should add to the list just leave a message.
EDIT: I just thought about a name, searched on Google and got nothing so i guess it's not in use. What about: Gentile
Link to post with latest version: Gentile 0.07 (http://www.sega-16.com/forum/showthread.php?16785-Tile-and-Sprite-editor-for-Genesis-Megadrive&p=366878&viewfull=1#post366878)
Golpezas
05-03-2011, 04:01 AM
You may ask Tulio. When Watermelon launch PS were shown some pictures that suggest that they developed great great tools to edit sprites.
I believe those are Windows-only and I'm not sure everybody would be happy with whatever license those tools turns out to have though (this is all speculation, but whatever).
No plan for support for flickering trick on sprites? =P (some Project MD sprites did it)
Archer
05-03-2011, 06:42 AM
No plan for support for flickering trick on sprites? =P (some Project MD sprites did it)
Can you explain this trick? I can only support what i understand :D
Er, you know how when making a checkerboard pattern, there are two possible ways to do it, right?
## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ##The flickering trick consists in toggling between both patterns every frame to make it look like a solid color. It's used a lot in Project MD, even in the title screen (heck, even the arrow in the menus!).
It'd be nice if it was possible to edit tiles drawing those like a solid color. Moreover, it'd be nice if it was possible to apply that when importing sprites =P
Also you may want to offer the option that, when importing a bitmap that uses a palette, to use the palette itself and don't attempt to convert it if the user wants that. For normal importing, just take the low 4 bits of the pixels (makes it easier to have multiple subpalettes). For flickering trick, use the high 4 bits for one frame and the low 4 bits for another frame.
Archer
05-03-2011, 07:08 AM
i think i understand how this works, but drawing them as a single color would mean a table of all possible mixes needs to be made. Or a routine that calculates the color it should be. It can be done, but first i need to complete the editor itself. Importing paletes from bitmaps is one of the things i forgot, i will add your ideas to the list.
Thanks for explaining
For a 16 colors palette, there are 136 possible combinations (repeats not included, transparent included though). For 15 colors (no transparent), 120 possible combinations. Making a table isn't all that ridiculous really. You may want to provide a way to make it obvious which colors are truly solid and which colors aren't. You may also want to provide an option that lets you see it either as a solid color or as flickering, to see how well the effect works with a given combination.
Archer
05-03-2011, 08:20 AM
i was thinking about drawing a square around the pixel that is mixed with two sides made up of first color and the other two sides the second color. And have two preview "windows" that show the first and second frame of the mixed image. maybe i should even make them editable as well.
Is that making any sense? i could draw a picture if it's not clear.
That... doesn't seem very useful. You only end up with a grid-like appearance on the editor that will never appear in the actual game =S
Archer
05-03-2011, 08:47 AM
You know when you zoom in very deep in some drawing program, like paint, and have the grid enabled? Each pixel of the image is a large square in the grid, right. That's the pixel i meant to put a rectangle on.
Like This (click to see bigger image):
2876
But now i see it this way i don't think it's gonna work, it was just a thought.
djshok
05-03-2011, 10:01 AM
Check this out, I don't know much about it, but it might be relevant to your interests: http://www.segaage.com/forum/messageview.cfm?catid=48&threadid=48982
Archer
05-03-2011, 12:14 PM
Check this out, I don't know much about it, but it might be relevant to your interests: http://www.segaage.com/forum/messageview.cfm?catid=48&threadid=48982
That looks very good, and has it has some features i want in an editor. Unfortunately it's still beta and windows only. I tried it in wine and i got it working. But crashes when i create a fullscreen "sprite". They are clear about it on the site, it's not complete yet. But if you need an editor NOW, you can use it. Thanks for sharing.
I like the export options to Source code (ASM, C and BEX). i wanted to do this to, but forgot to put it on my list. 100% better than drawing using HEX codes what i have been doing so far.
Affinity: Draw is freeware but not open source. Gentile will be completely open source and multi-platform.
Archer
05-03-2011, 12:47 PM
I think i will create a GUI that looks like GnomePaint.
2877
i looked at the glade file, and i will use it as a guide for creating my own. I want a selection tool to select a palette, and view all plates. The current palette colors will be loaded into the "color bar" below.
Artemio
05-03-2011, 02:46 PM
Genitile is out there with source code (DOS only though). I know it is quite different, just mentioning it since the name is quite close. http://www.pascalorama.com/article.php?news=28&cat=21
Kamahl
05-03-2011, 02:47 PM
Hardest part is keeping motivated ;)
Archer
05-03-2011, 04:50 PM
Genitile is out there with source code (DOS only though). I know it is quite different, just mentioning it since the name is quite close. http://www.pascalorama.com/article.php?news=28&cat=21Wow, that is very close to the same name. I did visit that site once so i guess i got the name from there, just did not now it. But for now i will stick with it, unless someone has a better name. I am completely open for suggestions
Hardest part is keeping motivated ;)Motivation is not a problem, getting things done is. This is my first actual linux program, i do have experience in windows at work. I did "play" a little with GTK and the glade designer before, so i know my way around it.
I have the basic window layout done, window does nothing usefull yet. (the colors in the palette are fake, but the frame they are in is not
Kamahl
05-03-2011, 05:02 PM
Trust me motivation is the problem. Getting work done happens if the motivation is there.
You may want to allow for a different color for the left and right mouse buttons, it's really useful.
Archer
05-04-2011, 01:50 AM
Trust me motivation is the problem. Getting work done happens if the motivation is there.
You may want to allow for a different color for the left and right mouse buttons, it's really useful.
Well, right now the motivation is here. I want a complete tile and sprite editor that is made for the Megadrive. AffinityDraw looks like a good start but is not finished, and is buggy (at least in wine) And since it started to complain about missing OCX files the first time, i guess it's written in VB6. That's not going to look good in modern OS, but that's my personal opinion.
I definitely plan on using left and right button for a different color. that's one of the things i don't like about AffinityDraw. I found anouther issue, There is no Undo button. if you mess it up, you have to repair it by hand.
Both buttons together must equal cancel current operation like in MS-Paint, I cannot live without it
Archer
05-04-2011, 04:15 AM
Both buttons together must equal cancel current operation like in MS-Paint, I cannot live without itThanks for reminding me of that function, totally forgot about it. I will add it to the list so i won't foget.
I have been reading some GTK doc's on deciding which method to use for drawing images. Seems GDK seems to be the default, but will be replaced by cairo in the future. Better use cairo then i guess, or i will have to convert everything later. Both are new to me anyway.
Use middle mouse button to pick color from pixel under cursor. That'd help too a lot in terms of speed (Graphics Gale does this, albeit with the right button instead). Also make it possible to select all tools with the keyboard (in fact, if you're crazy enough, make the arrows move the cursor in case somebody wants the extra accuracy... just don't do it painfully slow =P).
EDIT: isn't Cairo for vector graphics?
Archer
05-04-2011, 07:24 AM
Use middle mouse button to pick color from pixel under cursor. That'd help too a lot in terms of speed (Graphics Gale does this, albeit with the right button instead). Also make it possible to select all tools with the keyboard (in fact, if you're crazy enough, make the arrows move the cursor in case somebody wants the extra accuracy... just don't do it painfully slow =P).
EDIT: isn't Cairo for vector graphics?I will add middle mouse button color pick to the list. I am not sure if i can make the tools selectable with the keyboard but i will see what i can do. the accuracy might not be needed, since i will have a minimal zoom level of 150 or 200% in the editor, the preview can be shown at any zoom level but defaults to 100%
I thought that too, but functions like GtkPixBuf have a note saying it will be deprecated in future versions and should not be used for new programs. I have to read more to be sure about it though, not much time today since it's my birthday.
the accuracy might not be needed, since i will have a minimal zoom level of 150 or 200% in the editor, the preview can be shown at any zoom level but defaults to 100%Some people find it easier (faster) to use the arrows to move the cursor in steps of one pixel than having to move around the mouse (though then make sure that spacebar behaves like left click!). Yes, even when zooming a lot. Mouses can be annoying to move around for some people, you know.
EDIT: just to make it clear, I meant one pixel as in one image pixel, so take zooming into account.
Archer
05-04-2011, 08:00 AM
Some people find it easier (faster) to use the arrows to move the cursor in steps of one pixel than having to move around the mouse (though then make sure that spacebar behaves like left click!). Yes, even when zooming a lot. Mouses can be annoying to move around for some people, you know.
EDIT: just to make it clear, I meant one pixel as in one image pixel, so take zooming into account.I never knew that was possible. Gnome paint has no zoom yet, so i tried it in KolourPaint. And it works! Drawing is the enter key. I could not find a key for the second color though, but in gentile this will be possible. I also noticed KolourPaint uses keyboard shortcuts for the tools, so i guess it's possible then.
one pixel keyboard drawing, added to the list.
Archer
05-06-2011, 02:31 PM
I have been reading endless pages of GTK+ documents for hours and hours, but could not get pixbuf and pixmap working. I had some results with pixmap but graphics were all scrambled. I now switched to making custom GTK widgets and draw with gdk primitives, and i finally got some results.
The palette is filled in koulorpaint since i can only fill them with white or black at the moment. The zoom buttons work, each "zoom" step makes a tile-pixel 4 pixels larger or smaller. The tile is stored in a array with "color index" value, and the 3 drawn pixels in the screenshot are set by this code:
tile_buffer[0][(2 * 8) + 3] = 15;
tile_buffer[0][(3 * 8) + 4] = 15;
tile_buffer[0][(4 * 8) + 3] = 15;Number 15 is just a number since the drawing routine only checks if the pixel value is higher than 0. Actually drawing with the mouse is not implemented at this time because i wanted a drawing area and filled palette first. Only the filled palette is left. Tile size is fixed at 8*8 for now.
The program size is only 11.8kb (plus 32.2kb for the glade XML), and shows up in system monitor and uses 1.8MB. The only dependency for now is GTK+ 2.16 or higher. I included a zip file with the linux executable and the glade file, just unpack in a folder and run ./gentile. You can click all buttons and menu's. The toolbox focus changes, but only the zoom buttons on the top toolbar are responding to signals.
WARNING: The executable in the zip-file is linux only, if you are running windows you will have to wait a little longer.
Kamahl
05-06-2011, 04:19 PM
Looking good man :cool:
Chilly Willy
05-06-2011, 04:36 PM
Runs fine for me. Seems the GUI is working.
:)
Archer
05-06-2011, 05:16 PM
@kahmal: Thank you.
@Chilly Willy: Thanks for testing, good to hear it works outside of my system :D
I got a little further now, got the label that displays the coordinates in a label working. Although when pressing any mouse button the updates stop. i guess i need to listen for another signal.
I am also looking for a way to include the glade XML in the executable. Preferably compressed and the method must work on three platforms (Linux, MacOS and windows) if someone has information on that please let me know. Feature requests can also be made here, i can add them to the list in the first post.
Kamahl
05-06-2011, 05:44 PM
I am also looking for a way to include the glade XML in the executable. Preferably compressed and the method must work on three platforms (Linux, MacOS and windows) if someone has information on that please let me know. Feature requests can also be made here, i can add them to the list in the first post.
On windows you add the file as a resource.
On Mac OSX you pack it in the .app file.
Not cross platform, you'd need to write code for both cases.
Researching Linux now, worst case scenario just add the entire file as a string in the executable.
EDIT: http://www.linuxjournal.com/content/embedding-file-executable-aka-hello-world-version-5967
Archer
05-06-2011, 06:00 PM
i have "single pixel" drawing working now, but you can't drag your "pencil" like it should do. The pixel you click on get's set, the ones you drag over do not. But i am getting close :D
For embeding the file, i was thinking compress with zlib (or gz) at compile time and at runtime decompress in /tmp. Then i only need to translate /tmp to the actual temp folder on the running platform, and just load it from there.
Kamahl
05-06-2011, 06:10 PM
i have "single pixel" drawing working now, but you can't drag your "pencil" like it should do. The pixel you click on get's set, the ones you drag over do not. But i am getting close :D
For embeding the file, i was thinking compress with zlib (or gz) at compile time and at runtime decompress in /tmp. Then i only need to translate /tmp to the actual temp folder on the running platform, and just load it from there.
Do the objcopy trick I put as a link then, objcopy is available for windows too at least and since mac osx uses GCC (for now) it should be there too.
I don't know much about Gtk+ programming but if you're using the click event you're doing it wrong :p. If Gtk+ doesn't support the MouseDown event on any control you can use a boolean to set the MouseDown, then update the grid (I assume it's a canvas?) using the mouse position.
Edit: http://www.gtk.org/tutorial1.2/gtk_tut-23.html, should have everything you need.
Archer
05-06-2011, 06:33 PM
i had found the scrible example already, and it draws to a pixbuf. I am drawing directly on the widget surface. The widget is a GtkDrawingArea and in the "expose-event" signal everything get's drawn. This event triggers every time part of the widget becomes visible, if i understood correctly Draging a window over it will trigger it a lot, making redraw very slow.
The signal for movement is "motion-notify-event", and the mouse button states are updated in the "button-press-event" and "button-release-event" signals. I just had to copy the code that actually "draws" the pixel in the array to the "motion-notify-event", and now "drag-drawing" is working :D
Thanks for the link anyway
BTW: events are called signals in GTK+
Chilly Willy
05-06-2011, 07:07 PM
Seems you're cruising along rather well. I'd be glad to test versions... the more people who do, the better the chances of spotting problems. It is nice to see a tool written first for linux, and then other platforms. :D
Archer
05-06-2011, 07:33 PM
Seems you're cruising along rather well. I'd be glad to test versions... the more people who do, the better the chances of spotting problems. It is nice to see a tool written first for linux, and then other platforms. :D
It's going pretty well, now i got the drawing part working :D. Most of the time this week i was trying to get a rectangle drawn on my window. Got it working with cairo almost immediately but the lines were to thick and i could not get them smaller :(
Consider yourself now an "official beta tester", whatever that's worth :D
I always wanted to write something for linux but never got around to it, i just needed to find an app that's usefull, simple to use and simple to make. Gentile is perfect for that. But i am still learning C and GTK+, so it might take a while for Gentile to be usable.
This is probably too much off topic, but i have a bug right now that's a pain in the ***:
draw_x = (int) ((mouse_x - 2) / pixel_size);
draw_y = (int) ((mouse_y - 2) / pixel_size); I traced it to this part. mouse_x and mouse_y are int's with the current cursor location, and pixel_size is an unsigned char with value 8 as default but it changes with the zoom level. As soon as the value for draw_x or draw_y should be higher than 9 , the program crashes.
EDIT-1: solved it, problem was not in this code directly. i am using these values to display a label that would be set to "(10,10) - 0". I only initilized the gchar with 10 and this string is 12 (including zero at the end). This just shows my inexperience with C i guess :)
EDIT-2: I now managed to get some colors into the palette using RGB values. Drawing in color is not exactly working corectly yet. But i should get that fixed in one or two hours.
EDIT-3: It took only 20 minutes to fix the drawing part. I can now draw in three colors, black, white and blue. I now have to fix the palette work fully indexed, the way it works now is not resource friendly. Although memory usage is still 1.8 MB.
Chilly Willy
05-07-2011, 03:51 AM
Consider yourself now an "official beta tester", whatever that's worth :D
Shouldn't that be the "official gentile tester"? Now you're changing the name to "beta"? ;) :D
EDIT-1: solved it, problem was not in this code directly. i am using these values to display a label that would be set to "(10,10) - 0". I only initilized the gchar with 10 and this string is 12 (including zero at the end). This just shows my inexperience with C i guess :)
Hehehe - those strings will get you every time. :twisted:
Remember, any time you're working with strings that you don't know how long they could be, use the "n" versions of the string functions (strncpy, strncat, strncmp, etc) where you pass the largest your string buffer allows. Also don't forget that when the "n" functions hit n and stop, they DO NOT null terminate! You have to do that yourself. For example:
strncpy(str, initialStr, 26);
str[26] = '\0';
The first line does a strncpy of no more than 26 chars, then the second line makes sure the string is null terminated in case the strncpy terminated on the count instead of hitting a string end.
Also don't forget that sprintf with the first parameter being NULL will effectively just count the length of the string (without null character, that is). At least that's what the standard says...
Archer
05-07-2011, 04:58 AM
Shouldn't that be the "official gentile tester"? Now you're changing the name to "beta"? ;) :D
ok, how about "The official Gentile Beta Tester" then? :D Although you might have to share that title at some point.
Hehehe - those strings will get you every time. :twisted:
Remember, any time you're working with strings that you don't know how long they could be, use the "n" versions of the string functions (strncpy, strncat, strncmp, etc) where you pass the largest your string buffer allows. Also don't forget that when the "n" functions hit n and stop, they DO NOT null terminate! You have to do that yourself. For example:
strncpy(str, initialStr, 26);
str[26] = '\0';
The first line does a strncpy of no more than 26 chars, then the second line makes sure the string is null terminated in case the strncpy terminated on the count instead of hitting a string end.That's what you get from using the "easy" languages like PHP and (Visual) Basic all these years. They handle all strings without ever complaining about size, in C i have to do it myself. It would help if the "runtime" just gave a helpfull error instead of 50 lines with numbers i don't understand (yet) So i need the n function makes sure we never go over the number? I will keep that in mind, thanks.
Also don't forget that sprintf with the first parameter being NULL will effectively just count the length of the string (without null character, that is). At least that's what the standard says...I had some trouble at first getting sprintf to work, and it's the first time i am using it. The gchar array/string is indeed empty and only declared: gchar label[20]
I am now working on detecting where the mouse is at when the motion signal triggers on the palette. it's looking good so far. My messing around with a dos based GUI/shell in QuickBasic really help now to understand the calculations that need to be made. In QB i had to do everything, even drawing the primitives, fonts, colors and stuff like that. Now i have GTK+ to do that for me :)
i will update again when there is news. I have very little time the rest of the day, so i try to get a new testing version out within an hour.
EDIT-1: I now have a palette full of 16 unique colors :)
EDIT-2: I was thinking about color 0 on the palette. On all four it's transparent, what happens if you set it to some color like red, and use that in your sprite? Will it still be transparent?
Archer
05-07-2011, 07:12 AM
Like i said, very little time right now. I got it working for the most part, but it's very unstable and the console is flooded with messages.
Besides that if you "hoover" over a color in the palette it stays "selected" and you can draw with that color. hoover over an other color and your drawing with that color.
I attached it anyway, but it might crash. i don't know yet. It will crash at some point, just happend to me while making the screenshot. :oops:
EDIT: forgot the screenshot for the people without linux. This time noting is edited, all colors are drawn by the program. the "art" in the editor is mine :D
I had some trouble at first getting sprintf to work, and it's the first time i am using it. The gchar array/string is indeed empty and only declared: [B]gchar label[20]Ahem:
len = sprintf(NULL, "(%d,%d)", cursor_x, cursor_y);Look up for tutorials on printf (it's one of the first things taught in C). The function sprintf is like printf, but instead of writing to screen, it writes to a char array (first parameter). If the char array is NULL, nothing happens. Since this function returns the length of the output in characters, passing NULL is a good way to get the length of the string.
But yeah, I'm going by the assumption you'd use dynamic allocation and such and obviously you won't =P
Chilly Willy
05-07-2011, 01:04 PM
EDIT-2: I was thinking about color 0 on the palette. On all four it's transparent, what happens if you set it to some color like red, and use that in your sprite? Will it still be transparent?
Yes. The first color of each palette cannot be used by anything but the far background color index. So you at least have the ability to select one of four background colors without disturbing any other graphics. In actual practice, it tends to be used as a sixteenth color for the backmost scroll layer.
Found a cool bug... click black and draw some; now pick red and draw some... now click individual dots instead of drag-drawing... they're still black! :) No matter what color you pick click-draw will always draw black, not the current color.
Archer
05-07-2011, 04:35 PM
@Sik: I did look up some tutorials and found the solution for now, just increased the buffer to 20. Please remember i am learning C as i go (and GTK+).
@Chilly Willy: So i should just leave the color user selectable? I was thinking about locking it as transparent.
It's not a bug, it's a feature
Seriously though, the "click" event and "move" event are separate functions. I still have to make a single "pixel_draw" function that will take care of it.
If you zoom in to make the pixel larger and draw a "dot" its black but keep your button pressed and move the mouse, then it will switch to the selected color. I will not be able to do anything about it till tomorrow, barley got time to post this here.
There is another bug, you can "click-draw" pixels outside the editor window in the "dark-grey" (depending on your theme) area. "drag-draw" does not work there though.
These bug's will all be solved when i cleanup the code. it's my coding style, make it work first and cleanup later. I also need to make redrawing the screen more efficent. i tried a 320x200 pixel buffer but it get's painfully slow. Also tried the program over a "ssh -X" connection, and it works even on my nokia N900. Over wifi it's ok, 3G is not so nice.
Have fun with the bug hunt for now :)
Chilly Willy
05-07-2011, 06:56 PM
Leave it as transparent, but allow the color to be set so that people can get a "preview" of how the sprite/tile looks against a particular color background.
Archer
05-08-2011, 03:52 AM
I have started the rewrite and i am building the internal buffer from the design of the VDP. I made an array that is 65535 bytes, included a struct with elements from the sprite attribute table. To explain it in short sentence, i am building a VDP in the background with editable VRAM. By doing this now it will make things easier when i add support for editing backgrounds , foregrounds and window layers. To make a preview i then only need to render the buffer :D This VDP implementation will not be made for speed. I will make a settings button on the top toolbar that will popup the registers and other settings i might put in for the VDP.
EDIT: Should i implement shadow and highlight colors? How does that work in relation to RGB? i was thinking of converting 7 bit rgb directly, but if i need shadow and highlight that might not work.
RGB values to use :
Normal : 0, 36, 72, 108, 144, 180, 216, 252
Shadow : 0, 18, 36, 54, 72, 90, 108, 126
Highlight : 126, 144, 162, 180, 198, 216, 234, 252
I don't think there's any point in scaling them to fit 0...255 range, 252 is near indistingushable from 255 for white.
Archer
05-08-2011, 05:27 AM
RGB values to use :
Normal : 0, 36, 72, 108, 144, 180, 216, 252
Shadow : 0, 18, 36, 54, 72, 90, 108, 126
Highlight : 126, 144, 162, 180, 198, 216, 234, 252
I don't think there's any point in scaling them to fit 0...255 range, 252 is near indistingushable from 255 for white.The RGB range in GTK+ is 65535 per channel and is automatically translated by GDK to the depth of the hardware.
I am working on the palette translation to RGB right now so these values come in at exactly the right time. i was going to use this translation:
new_rgb_color.rgb_red = (65535 / 7) * vdp_rI will put these values in in an array and use them in the translation for each channel.
Your name will be honored in the about screen of Gentile if you like:RGB values supplied by TmEE
Thanks for the values,
EDIT-1: I translated your values to the higher scale, and finished the functions to translate them to a GdkGC structure (that's needed to use the color on screen in GTK+)
EDIT-2: I now made an initialize function to set default colors and tried Normal, Shadow and Highlight. Your values work perfectly :D
Archer
05-08-2011, 11:42 AM
I was having issues with compiling, turned out you can not set a value to a variable you just declared in the header. Removed the older post with the error message since it's not relevant anymore.
EDIT-1: I also decided NOT to make the editor exactly like the VDP, it would limit some of the functionality. I can alway's implement a VDP simulator as an add-on later, and load the editor buffer into VRAM
EDIT-2: I have got the palette fully working now. You can select different color's now for the left and right buttons. Middle button has no color. I also added scrollbars to the editor that should work fully automatic when zooming in. I have not tested this since i have worked on the palette first.
EDIT-3: Editor window is working again, i should have it ready soon :D
Archer
05-08-2011, 06:39 PM
The rewrite is complete, for the most part. This is what changed:
- Complete rewrite of source code (with copy/paste/edit of the original)
- Logical Objects, like palette and editor in separate source files.
- Scroll bars added to editor window
- Palette color selection for Left and Right button.
- flicker from changing color removed.
- Both "Click-Draw" and "Drag-Draw" fully working.
- Shadow and highlight colors (thanks to TmEE for supplying the values)
- Click on the cut, copy and paste buttons on the toolbar to change
Known bugs:
- The changes are saved in the buffer, but in the wrong format.
- The following bugs are related to the bug above:
- A drawn line or pattern is messed up if: window moved offscreen, window of editor or when zoomed
- Colors in editor not changing when selecting normal, shadow or highlight colors. (Colors do change when the above issue is performed (moving the window offscreen,
These bugs do not happen if the sprite is set to 8x8 pixels, but at the moment i forced it to 32x32. Unfortunately may holiday week is over, so updates will be less frequent :(
The latest version is attached.
dra600n
05-08-2011, 08:22 PM
That looks very good, and has it has some features i want in an editor. Unfortunately it's still beta and windows only. I tried it in wine and i got it working. But crashes when i create a fullscreen "sprite". They are clear about it on the site, it's not complete yet. But if you need an editor NOW, you can use it. Thanks for sharing.
I like the export options to Source code (ASM, C and BEX). i wanted to do this to, but forgot to put it on my list. 100% better than drawing using HEX codes what i have been doing so far.
Affinity: Draw is freeware but not open source. Gentile will be completely open source and multi-platform.
If you tell me what the error code/message was, I'll see if I can fix it so it's compatible for WINE users :)
Archer
05-09-2011, 01:54 AM
If you tell me what the error code/message was, I'll see if I can fix it so it's compatible for WINE users :)maybe i should have more clear. it's not really crashing, but it freezes and won't respond to anything. Only way to close it is to force it.
Also when it does work it flickers like crazy. Scrolling is not that good ether, lot's of flicker and some time's no redraw of the editor pixels when scroling down. It just "smudges", i can't really describe it.
I have to admit my atom based system is not extremely powerful, but native Linux programs only flicker a bit when moving the window.
Chilly Willy
05-09-2011, 03:34 AM
The rewrite is complete, for the most part. This is what changed:
- Complete rewrite of source code (with copy/paste/edit of the original)
- Logical Objects, like palette and editor in separate source files.
- Scroll bars added to editor window
- Palette color selection for Left and Right button.
- flicker from changing color removed.
- Both "Click-Draw" and "Drag-Draw" fully working.
- Shadow and highlight colors (thanks to TmEE for supplying the values)
- Click on the cut, copy and paste buttons on the toolbar to change
Known bugs:
- The changes are saved in the buffer, but in the wrong format.
- The following bugs are related to the bug above:
- A drawn line or pattern is messed up if: window moved offscreen, window of editor or when zoomed
- Colors in editor not changing when selecting normal, shadow or highlight colors. (Colors do change when the above issue is performed (moving the window offscreen,
These bugs do not happen if the sprite is set to 8x8 pixels, but at the moment i forced it to 32x32. Unfortunately may holiday week is over, so updates will be less frequent :(
The latest version is attached.
Not bad... cures a number of issues. One bug I noticed - it doesn't quit with the quit menu item.
Archer
05-09-2011, 04:08 AM
Not bad... cures a number of issues. One bug I noticed - it doesn't quit with the quit menu item.None of the menu items work at this time, because i have not connected to their signals yet. The rewrite was a lot of work, more than i thought. But it's worth it, the code is much cleaner now.
The buffer storage bug is just a matter of calculating the right sprite number, i expect to get that solved somewhere today.
EDIT-1: i just noticed a huge bug when trying it on my laptop. It works perfectly, just like it should. but when you drag the window off screen memory usage shoots up like a rocket. it's already using more than before 2.8 now instead of 1.8MB. But if you drag the window it SHOOTS too 30 - 50 - 60 and higher. Must be something in the drawing routines, but i have no idea where to look.
EDIT-2: Fixed the close issue in the menu, now has the same effect as closing the window. I have been reading more about GTK+ and graphics and future versions of GTk+. The GDK drawing functions i use now will be replaced by cairo. I will continue using GDK until i can draw an 8x8 tile and save it in raw format. After that i start converting all GDK stuff to cairo while i still can.
EDIT-3: I can now draw a tile in 8x8 in size. Click the save button (stored in "/tmp/new_tile.svt"). Close Gentile and restart. Click open button, and the same file is reloaded correctly :D
EDIT-4: I had a bug in the save/load routines, but it's fixed. exporting to C source is also added. I have a few minor bugs to work out, than i will post a new version.
Archer
05-10-2011, 03:26 PM
As of now, Gentile 0.0.5 can actually be used to create Tiles :D
Additions/changes are:
- Reduced the size of the "sprite" to just one tile (8x8) pixels.
- Saving/Loading to user selected file (Format is RAW)
- Export tile to C sourcecode (file selected by user, make sure you put .c at the end)
- "New File" button clears buffer (reset to color 0).
- "new file", "open" and "save" work from toolbar and menu.
- "Quit" from menu is working now.
- Probably some new bugs i have not found yet.
Biggest bug i know of is the memory leak i spoke of before, just don't zoom, scroll or move the window too much :D
It's probably caused by GDK object's being created but not deleted after using. i am not going to fix that, but switch to cairo for drawing the palette and editor.
Version 0.0.5 is attached. No screenshot this time because visually nothing has changed
Chilly Willy
05-10-2011, 08:07 PM
I noticed something... clicking right or left sets a pixel, and holding either and clicking the other resets the pixel to the background color. Is that intended behavior? Do you plan to do color selection with the middle button?
Also, can you have an "actual size" preview somewhere in the display? That might be handy as well.
Archer
05-11-2011, 01:50 AM
I noticed something... clicking right or left sets a pixel, and holding either and clicking the other resets the pixel to the background color. Is that intended behavior? Do you plan to do color selection with the middle button?
Also, can you have an "actual size" preview somewhere in the display? That might be handy as well.
No, it's a bug in the button detection code. Clicking both buttons should undo the last action, when undo/redo is added. I will try to disable the "two-button" click. I do intend to do color selection with the middle button, it's on the list of suggestions. Export to "RAW Image" is not working yet from the menu, but it's the same as saving.
A preview "window" is planned, but i am not sure how to do it yet. I am also looking to replace the drawing functions to cairo, since in GTK+ 3.0 the GDK functions are deprecated. And if i understand correctly, cairo is faster too.
Have you tested saving. loading and exporting to C source?
EDIT: Middle button color selection is working, just need to figure out how to update the color in the palette. Draging offscreen wil update the color, and drawing in the new color works directly.
Chilly Willy
05-11-2011, 03:17 AM
Load and Save seem to work fine. I like the exported C - it has a nice format. But you need a ";" after the close brace.
//Exported to C from Gentile 0.0.5 alpha
const unsigned int tile_0[] =
{
0x00008000,
0x00080800,
0x00800080,
0x00800080,
0x00888880,
0x00800080,
0x00800080,
0x00000000,
}
Archer
05-11-2011, 05:23 AM
Load and Save seem to work fine. I like the exported C - it has a nice format. But you need a ";" after the close brace.
I copied the format format from my own demo, which is based upon your format in font.c I tried to keep the output not too much the same as AfinityDraw.
I always forget those stupid things :D I will fix the missing colon. As i said before i am switching the GDK drawing to Cairo, so i think the next version will take a little longer. I need to read a lot of doc's but it looks simpler than GDK.
I also plan to make a "color shifter", it allows to shift colors on the palette and change the color codes in the tile to match the new position. So if red is at position 3 and you move it to 5 the tile "pixels" will stay the same, but in the buffer all "3"'s will change to "5"'s and "5"'s to "3"'s. I don't know how to explain it another way, but i think you know what i mean.
Thanks for testing.
Chilly Willy
05-11-2011, 03:29 PM
I always forget those stupid things :D I will fix the missing colon.
Yes, it's those little things that you eventually get down with experience coding. Fortunately the compiler is good about picking those up in the meantime. :D
I also plan to make a "color shifter", it allows to shift colors on the palette and change the color codes in the tile to match the new position. So if red is at position 3 and you move it to 5 the tile "pixels" will stay the same, but in the buffer all "3"'s will change to "5"'s and "5"'s to "3"'s. I don't know how to explain it another way, but i think you know what i mean.
That could be REALLY handy - I've needed to do that a number of times when doing sprites, and doing it by hand isn't fun for hundreds of sprites.
Archer
05-12-2011, 10:35 AM
Yes, it's those little things that you eventually get down with experience coding. Fortunately the compiler is good about picking those up in the meantime. :D You think after 1,5 years of PHP i should have learned by now. i blame al the BASIC variants i used before :D
That could be REALLY handy - I've needed to do that a number of times when doing sprites, and doing it by hand isn't fun for hundreds of sprites.I did not look forward doing something like that by hand either, so i thought about this function. It could be used to "merge" sprites or tiles to a single palette, and shifting the color codes so they will fit. I have to think about how it will work exactly, but it can be done and is very useful. Don't expect that in the next release though;)
I am still fighting with cairo. The coordinate system is just weird. It's not aligned to pixels, but to the grid between pixels. I have to add 0.5 to the numbers to make it align normal. And cairo has no function to draw a single pixel, is a sprite preview at double resolution acceptable? I can only draw rectangle's, that means a "sprite-pixel" is a 2x2 pixel block on screen.
Chilly Willy
05-12-2011, 02:56 PM
Very odd, but I think it's because it's supposed to be independent of things like pixels. You might need to make an offscreen bitmap or icon and have it render it for a preview.
Kamahl
05-12-2011, 04:28 PM
I am still fighting with cairo. The coordinate system is just weird. It's not aligned to pixels, but to the grid between pixels. I have to add 0.5 to the numbers to make it align normal. And cairo has no function to draw a single pixel, is a sprite preview at double resolution acceptable? I can only draw rectangle's, that means a "sprite-pixel" is a 2x2 pixel block on screen.
A vector library to draw sprites is a pretty bad idea. You should drop it and just write to a bitmap directly.
Archer
05-13-2011, 10:25 AM
Very odd, but I think it's because it's supposed to be independent of things like pixels. You might need to make an offscreen bitmap or icon and have it render it for a preview.That's exactly the reason, but still very anoying. They should have added a function or method that set's the coordinates to pixels. However, i did get the palette_widget converted to cairo. i only have to modify the "mouse-event" updates and then the palette is completely done in cairo. Not really worth an update yet, because visually nothing has changed.
A vector library to draw sprites is a pretty bad idea. You should drop it and just write to a bitmap directly.You and Chilly Willy are right about drawing the pixels to a buffer and create an image object from that. that object can then be drawn on a cairo surface, i hope. For the palette_widget and editor_widget cairo is perfect, once you get to know it. But it's a weird concept to draw to the pixel grid instead of the pixels themselves, that confused me at the start.
The editor_widget is now drawn as two rectangles per pixel, one for "the grid" and one filled rectangle for the pixel color. when the editor get's larger it get's really slow. A screen of 40 x 28 tiles is already 71,680 pixels. that means 143,360 rectangles to be drawn. This will go a lot faster in cairo, but i want to change the grid drawing routine. Instead of one rectangle per pixel, i want to draw larger rectangles around a row of pixels. Both horizontal and vertical and one big one around the whole screen. I did this before in an icon editor i made 9 years ago for a ms-dos GUI/Shell, but i only just remembered it. Drawing the grid after the pixels has the advantage i can enable and disable it from the menu (the option is already there).
Kamahl
05-13-2011, 12:41 PM
Instead of one rectangle per pixel, i want to draw larger rectangles around a row of pixels. Both horizontal and vertical and one big one around the whole screen. I did this before in an icon editor i made 9 years ago for a ms-dos GUI/Shell, but i only just remembered it. Drawing the grid after the pixels has the advantage i can enable and disable it from the menu (the option is already there).
Didn't even realize you were doing that :p, heck I wouldn't even draw rects, just a bunch of lines.
Is cairo the only way to draw in GTK? Isn't there any canvas control?
I'm also pretty sure cairo does support using a bitmap as a "texture". (I don't know if it does automatic bilinear filtering though, that would suck).
Archer
05-13-2011, 01:39 PM
Didn't even realize you were doing that :p, heck I wouldn't even draw rects, just a bunch of lines.
Is cairo the only way to draw in GTK? Isn't there any canvas control?
I'm also pretty sure cairo does support using a bitmap as a "texture". (I don't know if it does automatic bilinear filtering though, that would suck).
It was just a time saver for me when writing it. I wanted to show a working version as fast as i could. Doing the calculations on the grid lines would loose time. But now it's working, i have the time to cleanup my mess :D
GDK is the other method of drawing in GTK+, but it's being deprecated in version 3.0. Cairo is the replacement so i thought it would be better to start using it early in development of Gentile.
I was using GDK until now, but i got some mayor memory leaks when redrawing is required. it did not happen when i disabled drawing the palette and editor. The new "cairo palette" has no memory leaks so far, and seems to redraw faster.
EDIT-1: The palette is now completely drawn with cairo, most of the editor is done too. Grid lines are still rectangles, but instead of around a single pixel i draw around a row and column of pixels. The grid can also be turned off now, but not yet through the menu option
EDIT-2: I just thought about a trick that might work for drawing a preview with single pixels in cairo. I just draw the 2,2 pixel blocks and set scaling to 0.5 It should work
EDIT-3: I have a buffer problem i need to fix. Since i thought of implementing a virtual VDP, the editor writes in "tile-blocks" to a buffer. This is now giving problems in the editor. The editor will use a "bitmap-buffer" as storage, end only when exporting it will translate to tiles.
Archer
05-15-2011, 01:19 PM
I fixed the buffer problem, i can now set the editor size to 40 x 30 tiles. Although at the redraw is very slow so i have to find a solution for that. With a smaller size the redraw is fast enough. This redesign creates a problem with the C export routine. I now have to calculate the address of a tile in the buffer and then get an 8x8 block out of it. I can do it but the calculations are a bit more difficult then i though. These calculations need two versions, one for backgrounds and one for sprites since i read somewhere they are stored differently.
EDIT: I forgot to mention the new save format. The format is like this:
4 "GTLE" (Short for Gentile) :D
1 {byte} (Type)
1 {byte} (Version)
1 {byte} (width in tiles)
1 {byte} (height in tiles)
8 {bytes} (reserved)
32 {bytes} (palette data) (stored as 2 bytes per RGB value)
xx {byte} (image data, one byte per pixel size is (width * 8) * (height * 8))Saving and Loading the image from this format is working, and the editor is properly resized and pixels are drawn correctly. Even with non square sizes. The palette is not yet stored in the file but i reserved the space.
EDIT-2: Exporting big sprites is now working, although a bit buggy at the moment. Take a look at my SuperTux MD (http://www.sega-16.com/forum/showthread.php?16956-SuperTux-MD) project, all graphics will be converted and edited with gentile. The scaling is done with external programs (Koulorpaint). There is a demo on page 2 (http://www.sega-16.com/forum/showthread.php?16956-SuperTux-MD&p=360031&viewfull=1#post360031) if you want to see the results, the sprite colors are from the default Gentile palette.
I need to create a window that allows to select the size you want when creating a new sprite. it's already working for loading from a file.
Archer
05-17-2011, 06:23 AM
A little update:
I don't have a window yet for selecting the sprite size, but i got it working as commandline parameters. So type this "./gentile 4 4" and the editor will be 4x4 tiles or 32x32 pixels. For SuperTux i need to convert a lot of images and the default palette i have now is very limited on colors, i want to make a window that allows to edit the palette colors. i also need a window for selecting the editor size when you create a new image. And i want to include a "PNG import" window, where you select a PNG file and on loading the colors are reduced to the 512 possible colors. The color selection is based on the RGB values in the PNG file, and will be a "best guess" match on the genesis palette.
I hope it will no take too long for a new version, but at the moment it's not stable enough.
Archer
05-26-2011, 06:12 AM
I have made a color chooser, and although it's not complete yet i would like to know what others think about the layout. I tried other methods, but it looked very much like the "color chooser" from affinity-draw. Which i do not like.
The final window will have:
- a large color preview rectangle (DONE)
- three slide controls displaying the individual RGB values (DONE)
- a label with the RGB values in VDP hex format. (DONE)
- a text entry where you can enter values manually (DONE)
Archer
05-28-2011, 07:24 AM
I have most of the color select window working.
- It pops-up on any color from the palette (middle button for now)
- The window is modal and stays above parent window
- The selected color from the active palette is loaded in the window
- Color preview (yellow square in lower right corner)
- Sliders and Spin buttons update each other (GTK+ takes care of that :D)
- When window is closed the changed (or unchanged) color is saved on the palette
And from there it goes wrong. For some reason GTK+ keeps the "Middle" button on in the mouse event. The effect is that after you opened the color select window, you can't change color anymore. I found a work around, but i need to fix this later.
Please let me know what you think about this window, and if i should change something about it.
Only thing not working yet is the actual palette preview, but will be done very soon.
Chilly Willy
05-28-2011, 05:45 PM
Good to see progress. :)
Was there a reason you didn't go with the "standard" color wheel as opposed to what you show? I think I do like your color picker better... never did care for the wheel.
Archer
05-28-2011, 07:11 PM
I did not use the standard wheel because it shows more colors than are available on the megadrive palette. I draw the middle line colors and calculate the difference for dark and light on the go. It took a while to get that right, but now you can select any color you want and tweak it as you like. And i only use the 8 levels of each component that are allowed, using the values TmEE gave me before.
Before i post a new test version i need to fix a few bugs, and make the color picker actually work :D
dra600n
05-29-2011, 06:27 AM
I have made a color chooser, and although it's not complete yet i would like to know what others think about the layout. I tried other methods, but it looked very much like the "color chooser" from affinity-draw. Which i do not like.
The final window will have:
- a large color preview rectangle (DONE)
- three slide controls displaying the individual RGB values (DONE)
- a label with the RGB values in VDP hex format. (not yet)
- a text entry where you can enter values manually (DONE)
I like the way your color picker is, much more than the way Affinity Draw is. I need to fix that :P but been lazy with setting up the palette in a similar fashion that you have. BTW, this program is looking great :) Keep up the good work.
Archer
05-30-2011, 03:11 AM
I like the way your color picker is, much more than the way Affinity Draw is. I need to fix that :P but been lazy with setting up the palette in a similar fashion that you have. BTW, this program is looking great :) Keep up the good work.
Thanks, it was not easy to get it this way. I used this image (http://en.wikipedia.org/wiki/File:RGB_9bits_palette_color_test_chart.png) as a guide but wrote all code myself. It does repeat a lot of colors though, and i am not sure if all 512 possible colors are shown. I leave the translation to you, but here is the magic code:
gentile_vdp_color vdp_colors[(43*15)];
//Check if color array is already filled, if not then calculate the color palette and fill the array
if(vdp_colors[0].vdp_red == 0)
{
red = 7;green = 0; blue = 0;
r = 0 ; g = 1; b = 0;
for(loop = 0;loop < ((6 * 7)+1);loop++)
{
red += r;
green += g;
blue += b;
if((red == 7) && (green == (7 + 1) )) {green--;g = 0;r = -1;red--;}
if((green == 7) && (red == -1)) {red = 0;r = 0;b = 1;blue++;}
if((green == 7) && (blue == (7 + 1) )) {blue--;b = 0;g = -1;green--;}
if((blue == 7) && (green == -1)) {green = 0;g = 0;r = 1;red++;}
if((blue == 7) && (red == (7 + 1) )) {red--;r = 0;b = -1;blue--;}
for(max=0;max <=7;max++) {
if(loop == (6 * 7)) {red = 7;green=7;blue=7;}
//store light color
vdp_colors[loop + (max * 43)] = palette_vdp_set_color((red - max) + 7,(green - max) + 7,(blue - max) + 7);
//store dark color
vdp_colors[loop + ((7 + max) * 43)] = palette_vdp_set_color(red - max,green - max,blue - max);
}
}
}It's not perfect, but it gets the job done.
I had to rewrite some parts, but now I know have a working color picker :D The active Palette and editor are not updated after the change, but i can fix that later. I also included a label that displays the hex codes in VDP format (shifted 1 bit to the right).
I still got a few bugs to work out and cleanup some other things in the code. I am hoping to post a new version within a few days.
dra600n
05-30-2011, 08:12 AM
Awesome man! Thanks for the help :) I just updated Affinity:Draw last night, still testing a few things, so now I'm going to see what I can do about tossing this inside of it as well. The thing I love about this color selector as opposed to mine is that the colors are all right there, and not scattered around like in ADraw. If you need any help with anything, let me know, though it seems you got a nice handle on everything :)
Archer
05-30-2011, 02:06 PM
Awesome man! Thanks for the help :) I just updated Affinity:Draw last night, still testing a few things, so now I'm going to see what I can do about tossing this inside of it as well. The thing I love about this color selector as opposed to mine is that the colors are all right there, and not scattered around like in ADraw. If you need any help with anything, let me know, though it seems you got a nice handle on everything :)
No problem, glad i could help. My first attempt at the color picker looked a lot like yours. It took me days to get it this way, but i am still not sure if all 512 possible colors are shown. I am sure i will have a problem at some point you can help me with :D
I found a bug in your palette window, if you click a color and drag the cursor out of the window you get a "runtime error '380': Invalid property value". I kind of assumed i could drag colors to the palettes below. I think you should make it clear which color on which palette is selected to be changed. I have version 2.5.1 running in wine on ubuntu 10.04
Maybe we could make our editors compatible by sharing the details of the file format's we use, or agree on a compatible format to import and export images between our programs. Could you please explain what a SGTD file is? Sega Genesis Tile Definition?
dra600n
05-30-2011, 05:15 PM
SGTD!! Is Devsters Sega Genesis Tile Designer!! Right now Adraw2 only supports squared sprite to be imported from it (so 2x2 tiles, or 8x8 tiles). Yea, I definitely need to fix the color picker for sure.
I'll hit you up with the file format of the ADraw2 files. I'm up to ADraw 2.9.0 right now.
Archer
05-31-2011, 02:23 AM
Well, i was almost right then :D I actually found that program once, but never downloaded it. I don't like the look of the interface.
I received your format, and have send mine in response.
EDIT: I am about to post the next version. A lot has changed since the last one. All drawing is now done with cairo, internal buffer is not based on tiles anymore, color picker is added, palette color is changing when color picker is used, and a few more things i will list when i post the next version later today.
EDIT-2: I had no time to fix a few bugs the other day, but i will post the new version in a few hours.
Archer
06-03-2011, 06:16 AM
I have tried to get it as stable as i can, so here is the new Gentile version 0.0.6
The changes are:
- All on screen drawing rewritten to use Cairo instead of GDK
- Palette is saved/loaded to/from file format (including changed colors)
- Variable sprite size (MUST be specified at launch on command line)
- Size of sprite is stored in file when saving
- Loading a file resets the editor size.
- Functional Color Picker
- WARNING: LARGE SPRITES ARE SLOW (think 40x28 tiles fullscreen)
When starting Gentile 0.0.6 use the following commandline "./gentile 2 2", if you do not it will give a Segmentation Fault. (yes it's a bug) The "2 2" specifies the size of the buffer in tiles: 1 1 = 8x8 pixels, 2 2 = 16x16 pixels, etc... (you are not limited to squares btw)
The color picker works, but not as good as i want it. You can select a color and change it with the sliders and spin buttons, but it is only changed when you double click on the preview color. The window will not close when you double click on the preview, i had to disable that because it does not work properly. Clicking with the right button on the color picker will reset to the original color (unless you double-clicked the preview of another color it will change to that color)
Please let me know if you find any bugs :D
As before, this is the Linux only version
EDIT: I have been trying to compile Gentile 0.0.6 on windows, and it's working, sort of. I recompiled it in Cygwin and after a few dependency and compilation problems it compiled. It does need a running X server though.
MEGADRIVE Jeroi
06-03-2011, 10:03 AM
Looks neat, keep up the good work. I like these kind of projects developing cross-platform programs.
Archer
06-04-2011, 10:06 AM
Looks neat, keep up the good work. I like these kind of projects developing cross-platform programs.Thanks, i try to keep the code as portable as i can. But Linux is my main target. I found a way to cross-compile for windows without running that OS on my system. I need to modify the makefile so it uses the MinGW compiler and windows libraries, but i work out the details later.
I made some improvements today:
- Finally removed the "rectangle-grid-drawing" and replaced it with drawing lines
- Figured out how to properly instruct the editor or palette to redraw with GTK+ function
- Added palette menu:
- Normal/Shadow/Highlight modes moved here, and they are working
- Default color palette option, in case you need to reset the colors. (will add a warning later)
- Added option for "Color Shifter, but disabled.
- In view menu "Show Grid" is checked, but disabled.
I have been reading up on libpng, but it will take some time to implement. So i think i will start with importing from BMP files, since i can easily read the RAW bytes and convert them to one of the 512 possible colors. The conversion will be a "best-guess" based on RGB values.
Chilly Willy
06-04-2011, 08:47 PM
Hmm - this new version just gives me a segmentation fault and nothing else.
Archer
06-05-2011, 02:41 AM
Hmm - this new version just gives me a segmentation fault and nothing else.I hope you read this line in my post:
When starting Gentile 0.0.6 use the following commandline "./gentile 2 2", if you do not it will give a Segmentation Fault. (yes it's a bug) The "2 2" specifies the size of the buffer in tiles: 1 1 = 8x8 pixels, 2 2 = 16x16 pixels, etc... (you are not limited to squares btw)In this version you HAVE to give two parameters on the command line to set the width and height of the editor window. It's because i have not implemented parameter checking and just assume there are two parameters. I will fix this for the next version, but for now just use the command above and it should work. You can increase the "2 2" part if you want a bigger editor/sprite, but a large one will slowdown the redraw of the editor.
EDIT: I am now reading docs on argp to handle the arguments on the commandline, it gives a very proffesional look :D
$ ./gentile --help
Usage: gentile [OPTION...]
Gentile -- A Tile and sprite editor for Sega Genesis/Megadrive
-h, --height=HEIGHT Height of editor, default = 2
-w, --width=WIDTH Width of editor, default = 2
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
$
Chilly Willy
06-05-2011, 03:43 AM
I hope you read this line in my post:
In this version you HAVE to give two parameters on the command line to set the width and height of the editor window. It's because i have not implemented parameter checking and just assume there are two parameters. I will fix this for the next version, but for now just use the command above and it should work. You can increase the "2 2" part if you want a bigger editor/sprite, but a large one will slowdown the redraw of the editor.
Nope! Didn't see that at all. :lol:
Okay, now it works! Looking good - zoom in/out is pretty fast and doesn't seem to cause any problems. Scrolling is also nice and fast without the troubles old versions had. Haven't seen a problem with resizing either. Nice work! Now add a few more functions... I'm getting bored just drawing pixels. ;) :D
I tried "8 8" and it seems pretty fast to me. I'm not even using a very powerful system... not by modern standards - I'm using a 1.6 GHz CoreDuo (not Core2) with Intel 940GM chipset/graphics.
For some odd reason "64 64" gives a segmentation fault. ;)
Archer
06-05-2011, 05:26 AM
Nope! Didn't see that at all. :lol: I already thought you missed it, glad it's not a new unknown bug. I got argp working now, so in the next version specifying the size is optional.
Okay, now it works! Looking good - zoom in/out is pretty fast and doesn't seem to cause any problems. Scrolling is also nice and fast without the troubles old versions had. Haven't seen a problem with resizing either. Nice work! Now add a few more functions... I'm getting bored just drawing pixels. ;) :DSo you don't like drawing pixels? In that case i will add line drawing, which i needed to do anyway :D. I have some idea's on how to do it, but it will take time. I will "borrow" some icons from GIMP for my toolbar on the left. Most of my time since the last version went into the conversion to cairo, and the color picker.
Did you try changing a color on the palette? By double clicking on a color. There is a small memory leak in changing the color though, about 0.2 MB per change. I need to look at that. The changed palette is also saved and loaded when you save or load a sprite. In the new version i added an option to reset the palette to the default.
I tried "8 8" and it seems pretty fast to me. I'm not even using a very powerful system... not by modern standards - I'm using a 1.6 GHz CoreDuo (not Core2) with Intel 940GM chipset/graphics."8 8" is not big, try "40 28" and you know what i mean with slow. Thats the size i have to support for a fullscreen titlescreen, it works but the redraw is slow.
You will be surprised by my system specs:
- Intel(R) Atom(TM) CPU N270 @ 1.60GHz (dual-core)
- Intel Mobile 945GME graphics
- 2 GB RAM (i think DDR2 or DDR3)
- Dual Monitor display (1600x1200 resolution per screen at 21.3")
- 128GB SSD
It's not that fast, but it is 100% silent. :D It's good enough for daily use, but not strong enough for youtube in fullscreen. Probably because of my high resolution screens :D
For some odd reason "64 64" gives a segmentation fault. ;)That's not odd at all if you know the buffer is designed for only 65535 pixels, and (64 * 8) + 64 * 8) = 262144 pixels :D That's a left over from my attempt to make an internal VDP like design. I will clean up that mess when it bothers me enough to spend time on another re-write, but it's needed. I will need to add safety checks to limit the values. Is there a reason you tried something that big?
EDIT: I found out i need to use the Bresenham line-drawing algorithm, so line drawing might happen faster than i thought.
EDIT-2: Line drawing is now working in the buffer, i only need to make the GUI interface to the line_draw function. I used the code at the bottom of this PDF (http://www.cs.toronto.edu/%7Esmalik/418/tutorial2_bresenham.pdf) i found with google
I wonder how that Atom compares to my 1.4GHz PIII....
Archer
06-05-2011, 06:33 AM
I wonder how that Atom compares to my 1.4GHz PIII....Since you run an old OS on a relatively "new" CPU, your PIII will be faster than my Atom running a light modern OS. Your PIII should alos be faster on some calculations than my Atom, but i like the silence :D
I have a Core2Duo 2Ghz laptop but i can't stand the noise for more than one hour. I also have a "normal" Core2Duo 2.5Ghz desktop which i silenced to a minimal noise level, but i rarely use it.
Back on topic .... I got some results from some site but the lines had to much errors, found a document describing the Bresenham algorithm which i am reading now.
EDIT: Line drawing is working :D (see EDIT-2 on my previous post)
Chilly Willy
06-05-2011, 07:42 AM
I already thought you missed it, glad it's not a new unknown bug. I got argp working now, so in the next version specifying the size is optional.
Why? Just let it crash if you don't enter the proper values. ;) :D
So you don't like drawing pixels? In that case i will add line drawing, which i needed to do anyway :D. I have some idea's on how to do it, but it will take time. I will "borrow" some icons from GIMP for my toolbar on the left. Most of my time since the last version went into the conversion to cairo, and the color picker.
I was thinking flood fill would be more useful.
Did you try changing a color on the palette? By double clicking on a color. There is a small memory leak in changing the color though, about 0.2 MB per change. I need to look at that. The changed palette is also saved and loaded when you save or load a sprite. In the new version i added an option to reset the palette to the default.
The color in the palette doesn't change. The chooser could also use a cancel and okay buttons. The close gadget acts like cancel, leaving the color the same as before you tried to change it.
"8 8" is not big, try "40 28" and you know what i mean with slow. Thats the size i have to support for a fullscreen titlescreen, it works but the redraw is slow.
Okay, "40 28" is a LITTLE slow on scrolling/resizing/dragging, but still not bad.
You will be surprised by my system specs:
- Intel(R) Atom(TM) CPU N270 @ 1.60GHz (dual-core)
- Intel Mobile 945GME graphics
- 2 GB RAM (i think DDR2 or DDR3)
- Dual Monitor display (1600x1200 resolution per screen at 21.3")
- 128GB SSD
It's not that fast, but it is 100% silent. :D It's good enough for daily use, but not strong enough for youtube in fullscreen. Probably because of my high resolution screens :D
Hehehe - that's REAL close to my own, but I'm using a single 1920x1200 monitor. I also use a Samsung Spinpoint drive chosen because it's virtually silent. The only thing that makes noise on this system is the fan on the CoreDuo. I know what you mean about youtube - the 94x mobile chipset is not terribly great at video or 3D.
That's not odd at all if you know the buffer is designed for only 65535 pixels, and (64 * 8) + 64 * 8) = 262144 pixels :D That's a left over from my attempt to make an internal VDP like design. I will clean up that mess when it bothers me enough to spend time on another re-write, but it's needed. I will need to add safety checks to limit the values. Is there a reason you tried something that big?
You never said what the max was, so I just picked a common map size.
EDIT: I found out i need to use the Bresenham line-drawing algorithm, so line drawing might happen faster than i thought.
EDIT-2: Line drawing is now working in the buffer, i only need to make the GUI interface to the line_draw function. I used the code at the bottom of this PDF (http://www.cs.toronto.edu/%7Esmalik/418/tutorial2_bresenham.pdf) i found with google
Yeah, Bresenham is as old as the hills, but still about the best/easiest line drawing algorithm around. I suppose you found the common circle drawing algorithm as well? You really don't want to be using trig functions. :D
Archer
06-05-2011, 09:11 AM
I was thinking flood fill would be more useful.Flood fill will be added, but i want lines and rectangles first. So i can draw a "space" that can be filled. I am searching for information on that now.
The color in the palette doesn't change. The chooser could also use a cancel and okay buttons. The close gadget acts like cancel, leaving the color the same as before you tried to change it.I thought i explained how the color picker works, you select a color and double click on the preview in the lower right. That will save the new color, and when you close the color picker the color is changed in the palette and the editor (if you used that color). I will add the buttons, it will be more intuitive than this. But functionality is there, and i did say "The color picker works, but not as good as i want it." :D
Okay, "40 28" is a LITTLE slow on scrolling/resizing/dragging, but still not bad.Your system is a bit faster than mine, so it's less noticeable for you. On my system it took almost 3 seconds to redraw with version 0.0.6, i got it down to 1.5-2 seconds now.
Hehehe - that's REAL close to my own, but I'm using a single 1920x1200 monitor. I also use a Samsung Spinpoint drive chosen because it's virtually silent. The only thing that makes noise on this system is the fan on the CoreDuo. I know what you mean about youtube - the 94x mobile chipset is not terribly great at video or 3D.I got addicted to dual screens at work, so was missing a screen all the time at home :) I had a 2.5" harddrive in this system before, but the constant buzz annoyed me. So i got a SSD and now have a silent PC :D Sometimes i even forget it's on and have to look at the LED :)
You never said what the max was, so I just picked a common map size.Do you think i should increase the maximum size? I limited it becasue it get's so slow.
Yeah, Bresenham is as old as the hills, but still about the best/easiest line drawing algorithm around. I suppose you found the common circle drawing algorithm as well? You really don't want to be using trig functions. :DI never even heard of Bresenham before i searched for line drawing :) I did read something about a modified version of Bresenham for drawing circles, but did not search for it yet. What are "trig functions"?
Archer
06-05-2011, 03:30 PM
I still need to integrate it into the GUI, but I can now draw Lines, Rectangles and Flood fill :D
EDIT-1: Flood Fill now works from the GUI, on left and right button with selected colors from the palette. Even if you draw "crazy shapes" the flood fill still works :D
Kamahl
06-05-2011, 03:55 PM
Trig functions are sin, cos, tan, that stuff :p.
Chilly Willy
06-05-2011, 09:00 PM
Flood fill will be added, but i want lines and rectangles first. So i can draw a "space" that can be filled. I am searching for information on that now.
I thought i explained how the color picker works, you select a color and double click on the preview in the lower right. That will save the new color, and when you close the color picker the color is changed in the palette and the editor (if you used that color). I will add the buttons, it will be more intuitive than this. But functionality is there, and i did say "The color picker works, but not as good as i want it." :D
Double clicking the preview is not intuitive, especially as it STILL waits for you to close the chooser before changing the color in the palette. Just have OKAY that closes the chooser and sets the color, and cancel which just closes the chooser. THAT'S the most intuitive (and most commonly used and accepted) method.
Your system is a bit faster than mine, so it's less noticeable for you. On my system it took almost 3 seconds to redraw with version 0.0.6, i got it down to 1.5-2 seconds now.
Probably a difference in the memory speed. That's not something the CPU should make that big a difference on.
I got addicted to dual screens at work, so was missing a screen all the time at home :) I had a 2.5" harddrive in this system before, but the constant buzz annoyed me. So i got a SSD and now have a silent PC :D Sometimes i even forget it's on and have to look at the LED :)
2.5" can be noisier, so I have a 3.5" spinpoint - less heat, less noise, and lower price. :cool:
I just had to find a place to stick it in the case. I got a CF2IDE adapter so I can use a CF card for the secondary drive. That gave me a way to transfer data as well until I got an external CD/DVD for it.
Do you think i should increase the maximum size? I limited it becasue it get's so slow.
Someone might want to have a BUNCH of tiles that they will load a bit at a time into vram. You could make them edit it in bunches, but then you have to load/save/reload/resave/etc when switching between them. Perhaps what you could do is to keep all the tiles in memory, but only edit something like a max of 32x32 at a time. Then the user could select which 32x32 section of the larger tile set they are editing.
I never even heard of Bresenham before i searched for line drawing :) I did read something about a modified version of Bresenham for drawing circles, but did not search for it yet.
It's covered fairly early in books on computer graphics. Any good book on computer graphics will have that and the circle drawing as well as many other topics.
Archer
06-06-2011, 07:42 AM
Trig functions are sin, cos, tan, that stuff . :pThanks for explaining, i should have just googled for it and found out they were Trigonometric functions :D
Double clicking the preview is not intuitive, especially as it STILL waits for you to close the chooser before changing the color in the palette. Just have OKAY that closes the chooser and sets the color, and cancel which just closes the chooser. THAT'S the most intuitive (and most commonly used and accepted) method.I know it's not intuitive, but i had problems closing the window through the code so i disabled that part for the moment. I just made it "work" for now, but you are right two buttons are much better and the most common method. I will add the buttons before the next version.
2.5" can be noisier, so I have a 3.5" spinpoint - less heat, less noise, and lower price. :cool:
I just had to find a place to stick it in the case. I got a CF2IDE adapter so I can use a CF card for the secondary drive. That gave me a way to transfer data as well until I got an external CD/DVD for it.My system is really small (About the size of a model 2, maybe smaller), so a 3.5 inch drive is not possible. I also put in a SSD for the speed: cold boot in less than 45 seconds. complete shutdown in 3 seconds :D
Someone might want to have a BUNCH of tiles that they will load a bit at a time into vram. You could make them edit it in bunches, but then you have to load/save/reload/resave/etc when switching between them. Perhaps what you could do is to keep all the tiles in memory, but only edit something like a max of 32x32 at a time. Then the user could select which 32x32 section of the larger tile set they are editing.I want to make a "library" file format where you can store multiple sprites and export to a UFTC compressed stream, mostly for animations. But if i understand you correctly that is not what you are describing here. My "pixel buffer" now stores data in a "bitmap-style" char array. One byte per pixel. Conversion to tiles is done only when exporting.
I think i have to draw to an image object of some sort and make better use of buffering that GTK+ has. When a part of the editor needs an update GTK+ fires an "expose-event" in which i draw the editor, but instead of only drawing the needed part i do a complete redraw.
It's covered fairly early in books on computer graphics. Any good book on computer graphics will have that and the circle drawing as well as many other topics.I never had a need to draw a line, rectangle or circle from scratch in a byte buffer because most BASIC languages have build in routines for that. What i know about graphics is what i have learned from playing with Paint (a LOT) and re-writing a dos GUI in Q-BASIC. So i never really read any books on computer graphics, but thanks too google i can now catch up and learn :D
I implemented Line-Drawing, rectangles and Flood-Fill in only one day, with help and not all of it is my own code but it's working. The line-drawing PDF i linked to before is not complete, some lines and angles are drawn the wrong way. I found a post in another forum that had code that did work (click here (http://cboard.cprogramming.com/game-programming/67832-line-drawing-algorithm.html#post485086)).
I am now writing the GUI parts to make the functions available in the Toolbox, flood-fill is already working. I will do rectangles next an then lines. I am still thinking about how to draw a preview of the lines without changing my buffer.
Archer
06-07-2011, 04:19 AM
A status update (more like a bug report) :D
I have changed the Color picker window, and now it has two functional buttons "Apply" and "Cancel" that work like you would expect. I still have a small memory leak, every time you open the color picker memory usage increases 0.1 MB (FIXED)
I noticed a bug in the Flood-Fill routine. When the fill goes over the edge of the editor, it also fills the opposite side with the new color.
Still thinking about how to implement line/rectangle drawing preview without changing the buffer. I was thinking about saving the start and endpoint, when the endpoint changes draw a "line/rectangle" with colors from the buffer to erase the old preview. Than redraw the preview without saving in the buffer. It might flicker a bit, but i think it should work.
EDIT-1: I fixed the memory leak in the color picker, it was something with GtkBuilder. Memory now stays stable between 1.9 MB and 2.0 MB on my system. I still need to fix a few things before i can release a new version.
EDIT-2: I think i have a solution for my line/rectangle preview "problem". I will rewrite the editor to use "layers". One layer for preview's, second layer for undo/redo, and third layer is the stored image. The combined layers represent the image you see in the editor. When saving the preview layer is not used. And also in a small "preview" window the "preview-layer" is not shown.
EDIT-3: My solution for preview and undo looks promising, it is kind of working already :D
EDIT-4: I now have a working undo function for the last draw action, but it's not perfect yet and needs a lot more tuning.
EDIT-5: Line drawing now works :D It get's a bit slow when the editor is too large (in pixels) but it still works, I will do rectangles next. I think i will post this version somewhere today. By implementing undo, i broke the save and load functions. When they work again and rectangle drawing works i will post it.
Archer
06-12-2011, 05:13 AM
I am not sure it's stable, but that's why it's still an alpha version right ;)
New features:
- Color Picker has "Cancel" and "Apply" buttons
- Palette menu (color mode: Shadow, Highlight, Normal) (default palette reset)
- Disabled menu options that are not working yet
- commandline options are now optional, and help is displayed if incorrect options are given
- Functional Toolbox (options not implemented are disabled)
- Pixel drawing (not really new, but now you can HAVE TO switch too it from the toolbox)
- Line drawing
- Rectangle drawing
- Flood fill
- Fixed a few memory leaks
- Undo last draw action (pixel draw, holding mouse button counts as one action)
I have not tested exporting, but i am pretty sure it's broken in this version. Focus is on the new features. I did test saving and loading and they are working, saving resets the undo level to zero. Meaning you can't undo something you draw before you saved.
This is the Linux only version
To show windows and MacOS users that it's working, i included a screenshot of some random drawings i made showing rectangles, lines and flood filled parts.
EDIT-1: First step of the rewrite is complete, all names including "vdp" have been renamed. Now i will cleanup the editor_buffer to make line drawing a bit faster.
Chilly Willy
06-12-2011, 08:45 PM
Wow! Great job! Seems to be working nicely - it doesn't blow up when you don't give the sizes, the color picker has working buttons, the command buttons select the drawing commands which seem to work well in my quick tests... so far so good! :D
EDIT: Hey, how about sprite rotation? That would be handy, especially on sprites larger than one tile. You might want to check the wikipedia page:
http://en.wikipedia.org/wiki/Pixel_art_scaling_algorithms#RotSprite
EDIT 2: Actually, scaling would be nice, too. Just read that whole page. :D
EDIT 3: Here's a link to the explanation of RotSprite:
http://forums.sonicretro.org/index.php?showtopic=8848&view=findpost&p=159754
Archer
06-13-2011, 04:10 AM
Wow! Great job! Seems to be working nicely - it doesn't blow up when you don't give the sizes, the color picker has working buttons, the command buttons select the drawing commands which seem to work well in my quick tests... so far so good! :D
Thanks, it is working better but there are a few bugs left. Just try "-s 28" and you will see a corrupted part at the bottom, if you draw into the corrupted area it will crash.
EDIT: Hey, how about sprite rotation? That would be handy, especially on sprites larger than one tile. You might want to check the wikipedia page:
http://en.wikipedia.org/wiki/Pixel_art_scaling_algorithms#RotSprite
EDIT 2: Actually, scaling would be nice, too. Just read that whole page. :D
EDIT 3: Here's a link to the explanation of RotSprite:
http://forums.sonicretro.org/index.php?showtopic=8848&view=findpost&p=159754
At first i thought, why would that be usefull. But seeing the examples at sonicretro makes it al clear :D I have read those pages, but the explanation is very vague to me. I downloaded the program, but there is no source code. Without example code i can not include RotSprite, sorry. I think i can do 90 degree rotation though, and mirror too.
I will now focus on importing sprites from images. I have example code for libpng, but stating with a fixed format BMP image to import from is easier. I made an extremely small BMP viewer in dos a few years ago, if i remember correctly it was less than 1KB.
Chilly Willy
06-13-2011, 05:20 AM
The basic gist of RotSprite is he does a good quality expansion on the sprite to 8x, then he does the "standard" nearest-neighbor rotate, then scales it according to what the user specified... by 1/8th if the user wanted no scaling, 1/4th if the user wanted 2x, etc. I'll see if I can locate some example code for the rotating.
As for loading images, I recommend stb_image.c. It can be found here (http://nothings.org/) along with a lot of other good stuff. It's PD so you don't have to worry about any license issues. I use stb_image.c on my N64 stuff at the moment.
EDIT: You can find threads on Sean's stb_ stuff here (https://mollyrocket.com/forums/viewforum.php?f=16) along with a LOT of other good PD code. Looks like there will be an update to stb_image.c in the next day or two with some bug fixes.
Archer
06-19-2011, 05:50 AM
I had very little time last week, so not much happen on gentile. But i have a very simple BMP import function working now. it makes a lot of assumptions, does no checking at all. Expects 24bit per pixel no alpha no padding. Colors are converted on the fly like this ((8.0 / 255) * fgetc(fh)); for each component. Each new color is added to a temporary palette, the palette is searched for doubles first.
To make this visible i made more assumptions, that there are no more than 16 unique colors after conversion. The editor buffer and palette are filled with the converted values. Here is a screenshot of the result:
3235
In case you are wondering what this is, it's a tile from supertux that makes up the ice below the snow. The colors are reduced to only 11 unique colors in the gentile image.
theelf
10-07-2011, 02:50 AM
I use windows, but i'm really looking forward to test this editor
For now, i´m using Paint Shop Pro + picture with all MD palette, it works, but slow :D
Thanks for your work
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.