Zalo DS Blog

Saturday, January 10, 2009

PRIXON: Time goes by... so slowly?





Damn! The new year has just began and this year I realize that I have something important to celebrate. It's been 10 years since I finished Prixon! I can't believe it has already been that long...

So let me write a little bit about this game and why it is so important for me ^_^ (no boring code stuff this time). Eleven years ago I was finishing my studies and getting ready for university. I still wasn't very clear about what I wanted to do, that's the problem when you have more than one hobby. By that time I was already involved on code stuff, but only in qbasic. I had tried to do something in C++ but those annoying pointers were being a hell for my mind in that time (:D)

I wanted to create videogames since years ago. The closer attemp I did was with click'n play... but that was more like creating a game while playing (I think Microsoft is planning to create something similar for the 360 now to compete against Sony's LBA). Then, exactly 11 years ago, on Christmas my brother brought to home a demo of a new videogames creator enviromment. It was called Div Games Studio. Div for the friends :D

The demos included on the game were really impressed and the language was quite intuitive, even it included a debugger. I was amazed. And I saw a big opportunity to do something big for the first time. After months testing the language and learning it I started a project called Chula GP (the name is also a long story) that would be renamed into Prixon a few days before finishing it.





I was working on Prixon for a little more than a year. Not fully dedicated because that year I had to study a lot for the exams we have to do before going to university. I use a lot of stuff in this game. For the first time I got contact with tiles, mode 7, music, graphic modes, palettes... and also for the first time I got in contact with 3d max (v4, in ms-dos ); yes, the models in the game where modelated in 3D, LOL, those are the worst models I have ever done in my life. Not that I am really proud of the code today, but the thing is that I finished what I wanted. No rewards except some people telling me that they loved it, which was enought.

I think that when I finished Prixon I knew what I wanted to do with my life. I have finally become a games developer. To be honest I don't know how to fell sometimes. This is a hard profession and sometimes you wish you had a bakery or a ranch in the middle of the forest :_) I am sure I am not the only one who fells like this LOL!






When I was about to finish the game I decided to create the official comic. That was very special also. It supposed the return of Cebolleto, Carateca and Topolino. For 3 years I was dedicated to my manga style and those characters were started to be forgotten. Prixon meant the end of my manga style (or should I say Toriyama style? :D) and the return to my old characters.

Guess that I owe a lot to DIV. By the way, last summer a new version of DIV was released called Gemix Studio, fully compatible with the old one without changing any line in the code (you just need to recompile) I decided to give it a try and get a version of Prixon running under Windows. Yes, you can find it here (source code included) but, be nice :P You have to look at this game like it is, the beginning into the games programming of a university starter ;)

Happy 10th anniversary Prixon!

PD: the sound doesn't work fine.




Friday, December 19, 2008

Free Radical Closes


From GamesIndustry

People who know me they know why I am posting this here. Free Radical means something to me specially since 6 months ago, when they played with me. But for some reason, these are bad news. And I am not happy for this. There were a lot of people in that studio I really wanted to work with.

It is very sad always to heard that an studio wich has made some wonderful games in the past closes its doors. As someone told me one day and I said to myself 6 months ago... "shit happens"

No resentments.

Tuesday, December 02, 2008

Rokoban Wii, 4th place in the Tehskeen Wii code competition

http://www.tehskeen.com/forums/showthread.php?threadid=9775

All right, all right... I'll do my best for the drunken coders winter competition :P

Monday, November 24, 2008

Memory Leaks

When I finished Rokoban I realized that I didn't have anything to tell me how well or bad I was working with my memory resources. So, here I'll tell you what I did to have a little bit more of control.

First of all. What's a memory leak? Well, this

void MemoryLeaker()
{
int *leak = new int[99999999];
}


is a memory leak :D

When you start learning how to make programs in C++ you soon realize that memory leaks are the more annoying part. They always teach you the basic rule: "Everything that has a new must have a delete" (or is that from the Matrix movies?). That seems easy at first, but after years of C++ development I know that no matter how hard I try, I am going to create memory leaks, and you too :P Even if you try to avoid them using smart pointers you are never safe from them.

So, is there a way to avoid them? Yeah. There are a lot of ways. You can even create a garbage collector like Java. But there is a more interesting way. It is posible not to avoid them but to let our program tell us about them. And that way you can debug your application in debug mode and finally release it without any of this checks, making it as efficient and fast as posible.

So, what is the basic idea? C++ allows you to overload new and delete. You can overload them for a class or for the whole program. And this has a lot of advantages. You can reduce memory fragmentation and you can have control of what happens any time you request some memory from the heap and when you release it. So, basically you can implement a mechanism that everytime you reserve some memory it creates an entry on a table (for example) and everytime you realease it it deletes that entry from that table. At the end of your program all the entries in your table means memory leaks.

If you really want to know more about this take a look at this link http://entland.homelinux.com/blog/2008/08/19/practical-efficient-memory-management/. I was about to write my own memory manager for my engine. But I found that Visual C implements something very interesting for you. In fact, it all began with this link http://www.highprogrammer.com/alan/windev/visualstudio.html I really recommend its reading. Here I discovered that there is already an implemented debug heap I could use instead of writing my own. It is enought for me at the moment. I can only check memory leaks on my Windows release but because I usually develop everything in Windows and then recompile it using ZEngine for the rest of the platforms I can now be sure that the common part is memory leak free. There can be still problems with all the especific parts coded for each platform but I hardly make any memory allocation there.

I am finally doing what I found in this url http://www.cplusplus.com/forum/general/3526/:

This should go into every .cpp , after all header inclusions

#ifdef _WIN32
#ifdef _DEBUG
#include
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new new( _NORMAL_BLOCK, __FILE__, __LINE__)
#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
#endif
#endif


And then at the beggining of my app:

// Get current flag
int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
// Turn on leak-checking bit.
tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
// Set flag to the new value.
_CrtSetDbgFlag( tmpFlag );


If you do this as anilpanicker is showing then at the end of your program you will receive a very usefull output telling you where exactly you reserved some memory that was never released :D Using this I fixed a small memory leak in Rokoban, very very small, but still it was there. Now I can sleep much better.

There is still a lot of work to be done in my engine. I wish I had all the time in the world to code it but unfortunatelly I have other things to do. Anyway, knowing all those things is always really useful, you never know when you can need them. In the company when I am working at the moment they have their own memory manager implemented. More than that. They have their own asserts. I have learnt from them that if your program can't load a resource the best thing that it can do is telling you and stop. Only in debug mode, of course. This is much better ans easier that trying to make your game work without a graphic loaded of something like that. In your release you should have all your resources so it doesn't make sense to make it work without them :)

Hope any of what I have written will be useful. And take a look at all the links. They were really usefull for me.

Saturday, November 22, 2008

Downloads section updated

Hi... I have just moved the downloads to a new server... hopefully this will be working better. The only change is Rokoban for the DS wich is now a single file instead of nds+resources. I haven´t had enought time to test it but I can't find the old version so I decided to upload this one

Enjoy

Sunday, November 16, 2008

Getting into the Wii

Helloooo, everyone!!

I have finished and I am still alive... that is good!! What am I talking about? Yeah, good question!

I have spent the last three weeks porting ZEngine to the Wii :) I was in a hurry somehow because I wanted to finish something for the Tehskeen competition, so it has been a nightmare. Three weeks programming 12 hours a day, including weekends. First at job then at home... never again!!!!

What is the tehskeen competition you may be wondering. It is the first Wii homebrew competition. Take a look here and to take a look at the entries, this link You can take a look at all the games and vote Rokoban for winner :P

The Wii scene is amazing. I think that DS has stopped and lots of people are moving to the Wii, so now it seems to be the more active. The unnoficial SDK (devkitpro with libogc) allows you to do a lot of things and people are working everyday to release new versions lots of libraries, so I think it is a good a idea to move.

To be honest, I enjoy more developing for the DS. I think there is still a lack in the Wii documentation and somedays trying to do something can easily become hard. You need to look for samples, ask in forums, irc... etc

Cool! I am free! I am going to stop developing for a couple of months, I really need it. But in the meantime there is going to be a lot of time to post here all the features that I have been making to ZEngine (and belive me, there are a lot of them)

You can download Rokoban in the tehskeen competition website, I think I can't still upload it here. But there is a new version of Gea VS CoDOS (I hate it!!!) for the Wii in the downloads section or here

Have fun!

Tuesday, September 16, 2008

Texture Converter

Time for a new update :D Hey, I have been in the UK for 3 and a half months so my english is suppose to be better now (right? XD). Well, today I am going to post about something I did a couple of moths ago, just when I released Rokoban.

I don't know if you have realized but in Rokoban there is no use of channel alpha at all, I mean, by that time I wasn't able to load textures with transparent colors. Not even a simple bit for transparency. That's why all the texts in the game appear over a black background. Ok, if you didn't realize then I have showed every artist in this world that channel alpha is not required anymore! ... not even me can believe that

And why didn`t I give a little support for alpha channel? Because my textures were in bmp format. Bmps doesn't suppot alpha channel. Well, I am not sure at all about this... I think there are some programs that allows you to save 32 bits bmps. The problem is that you don't need your textures to be that large. 32 bits bmps has 8 bits for each channel (Red, green, blue, alpha). The DS doesn't suppor that format so you have to conver it in execution time and that is a waste of time (for the conversion) and size (your textures are taking more space that they really need)

So, basically, what are the texture formats supported by the DS? Those here:
GL_RGB32_A3 = 1, /*!< 32 color palette, 3 bits of alpha */
GL_RGB4 = 2, /*!< 4 color palette */
GL_RGB16 = 3, /*!< 16 color palette */
GL_RGB256 = 4, /*!< 256 color palette */
GL_COMPRESSED = 5, /*!< compressed texture */
GL_RGB8_A5 = 6, /*!< 8 color palette, 5 bits of alpha */
GL_RGBA = 7, /*!< 15 bit direct color, 1 bit of alpha */
GL_RGB = 8 /*!< 15 bit direct color, manually sets alpha bit to 1 */
Maybe for those of you with more experience in console development those formats are familiar, but for me, I have never used something like that. Which program allows you to save into one of these formats? Well, the last two ones (with no palette) can be more or less a 16 bits BMP and you can do some tricks like reserving one of the colors for alpha, and make that conversion when reading. That seems to be what most of the people are doing.

Problem with that? Well, you only have support for 1 bit of alpha (wich means, no gradient) and it is using 2 bytes for each color, and it is not bad... but when you want to load the more textures as posible into memory (and you always are going to need that if you are working whit artist that always want more and more AND MORE!!!... sorry) that is not good at all.

Some people in the homebrew are using PCX. I don't know that format very well. But I know it doesn't give you suppor for any of those weird formats. So I imagine that they are converting the textures when loading then. I was doing something similar for my textures. I was reading paletted bmps and the converting then into 16 bits bmps in execution time. For the alpha channel I was plannig to load another texture in grayscale as I have seen in some games...

Ok. All of those solutions work. But are not the best. Wouldn't it be great to have a program that allows you to save in one of those formats so that you don't have to do anything in execution time? Some people in the homebrew has released programs to do that. But It's been a while and I haven't been able to download one of them. There is also de DDS format for directX, but the pixel formats supported are not compatible either (take a loook... mmmmmm,google,tacata.... here: http://www.imageconverterplus.com/help-center/about-icp/supported-formats/dds/). And there is also a program that people from ID made for quake models but I can't remember the name... so it doesn't matter XD

So... I dediced to write my own converter XDDD Yes, if you spent more time looking for something than the time that you really need to do it then you are wasting your time. The converter I have developed is better than just one specific for the DS (My engine has to be multiplatform :P) So it supports a big variety of formats. You can select how many bits you want for each channel, and in case of palettes, you can select how many bits you need for palette index. It is designed at this momento so that alpha channel in paletted textures is not stored in the palette, but in the index. So, the palette has only 3 channels (RGB) for each color and then in the index there are n-bits for the index and n-bits for the alpha channel. That't the way DS works and it is ok for the moment.

For the first time and without meaning a precedent (I think you can't say that in english) I am going to release not only the tool, but also the source code, so that you can improve it if you want ^_^. Format specification is very simple (and it is included in a .txt) and loading textures is quite straightforward for the DS. To use the program just drag and drop the files you want to convert. I decided to use C++ and MFC this time instead of Java, which is the language in wich I usually code my tools




Download it from here Any comments, suggestions are always welcome ;)


PD: by the way, Capcom... What is the meaning of MEGAMAN 9!!!! You must be thinking we are stupid
PD2: square... WHAT THE HELL ARE YOU DOING RELEASING A PORT OF CHRONO TRIGGER FOR THE DS INSTEAD OF A REMAKE!!! DO YOU THINK WE ARE SO STUPID TO BUY THE SAME GAME TWICE????