Yes, your eyes didn't mislead you: another engine is - almost - ready to be added to ScummVM, yaay! :D
My last week was spent mostly with bug-hunting and implementation of
stubbed functions, so I really can't highlight anything from it. I also
implemented the functionality of the two volume switches on the toolbar.
It was a pretty good experience, because I had a lot of freedom
regarding this subsystem's implementation compared to other parts of the engine, since ScummVM's sound handling is highly different from DOS's. Because of that, new bugs and unwanted behavior is still possible when you use the sound options of ScummVM and the related buttons on the game's toolbar in parallel, but that's what testers for... ;>
After fixing some very ugly bug connected to script-handling, Sfinx is absolutely completable now. Here's the proof - without too many spoilers:
At the moment, we can say that the engine itself is almost complete too.
There's only one more major bug about our coordinate-handling what affects the pathfinding, so it works a bit hectically. My plan is to get done with this issue during the next week completely.
Another nice-to-have thing is the autosave function. Now CGE2 only supports classic saving and loading (it gives you the opportunity to save or load anytime you want), but as Arnaud and Paul implemented in CGE1, I also plan to add an autosave save slot which will always be overwritten when the player exits the game, and the he/she won't be able to delete this slot.
One more missing feature is the Return-to-Launcher support, but it's really the work of a couple of minutes, thanks to ScummVM's great system.
The most important thing now is the numerous memory leaks the engine still suffers from. I'll concentrate my attention on this issue along with our FXP implementation during the upcoming days.
At last, but not least, the English translation is complete as well. Many thanks goes to Arnaud for this! Currently, Thierry is trying to improve it, so hopefully we can leave the "Alfa v0.1" tag from the ribbon of the ScummVM window soon. ;)
See you next week! :)
Showing posts with label game logic. Show all posts
Showing posts with label game logic. Show all posts
Tuesday, July 29, 2014
Sunday, May 25, 2014
Roaring sphinx
Hey all! :)
Before boring you with the little details of my last week's work, let me show you the actual output of the engine:
Sfinx intro - ScummVM from Peter Bozsó on Vimeo.
Promising, isn't it? :)
Actually, it is, very much, and even more. Compared to Avalanche (which was my last year's work), CGE2 engine is more advanced, and right because of that, it needed much more work to make it show us something than the previous one. On the other hand, now I have a much deeper understanding of the whole structure of the code and I also have some plans how to proceed with the engine as a whole. Finally, I've got a grab on it and it feels safe, especially in the light of the past few weeks' anxious coding. :)
Let me explain it more deeper and make the comparison cleaner!
In case of Avalanche, all I had to do is implementing the picture loading code, then choose and put the right pictures on the screen, smash the whole thing into a big main loop with the keyboard and mouse event handling, and here you go: a half-working game, with the main character running around on the screen. (Of course, I struggled much more with it anno, and it was certainly more complex, but in a nutshell, that was that.) All in all, Avalanche was more appropriate to develop step-by-step, concentrating only on one thing at a time and bothering with the game logic only when almost all was said and done regarding the graphics.
In comparison with my previous work, CGE2 engine is more complex and was harder to find a solid grab on it. It handles things differently: it has very little, almost no hard-coded logic (which took up the greatest part of Avalanche by the way), but has a pretty scpript parser system, Snail.
I was lucky, I didn't have to implement the guts of the picture loading and drawing from scratch, using the ASM code in the original, because Arnaud and Paul did it for me during the implementation of CGE1. I only had to revise the fundamental classes and add/remove or modify function slightly to fit into CGE2's different coordinate or NPC-handling. The really hard part was to track down the inner workings of the engine through the not-so-verbose variables (there are tons of variables named "a" or "b", for example) and the not always logically named or placed functions ("getCave()" - What cave?!). Nevertheless no matter how I tried, which perspective I regarded the engine from, I always ran into Snail (called CommandHandler in the ScummVM version), which is clearly far from being complete, through the fundamentals of it are now settled, and as I concentrated on the parts what are used during the displaying of the intro, now it's done and working as you may have seen above. :)
After deciphering it, the internals of the command parser are not so hard to understand. Actually, every Sprite has a file with the extension of SPR, and those what are more than only one static image (For example the backgrounds are consist of only one picture. Yes, the backgrounds are considered as sprites by the engine as well.) has a bunch of information in them about the display sequence of the animation of the sprite. For example, 00SFINX.SPR, which contains the information of the roaring sphinx animation has a pretty readable table of the to-be-executed commands of the sprite, right under the "[near]" header in it. Especially, if you check this table of constants for the better understanding of the commands listed. So practically the intro animation is a sequence of pictures with sounds displayed right after each other, with a certain amount of delay inserted between each of them.
Luckily, I was also able to copy the main loop of the game from the ScummVM version of CGE1, and I only have to adjust some delay time to match the output of DOSBox.
My plan for the upcoming week is to proceed with the implementation of the main loop of the game and see what is needed to be implemented in order to display the first scenes of the game and very importantly: the NPC's on it and the animation of them.
See you soon! :)
Before boring you with the little details of my last week's work, let me show you the actual output of the engine:
Sfinx intro - ScummVM from Peter Bozsó on Vimeo.
Promising, isn't it? :)
Actually, it is, very much, and even more. Compared to Avalanche (which was my last year's work), CGE2 engine is more advanced, and right because of that, it needed much more work to make it show us something than the previous one. On the other hand, now I have a much deeper understanding of the whole structure of the code and I also have some plans how to proceed with the engine as a whole. Finally, I've got a grab on it and it feels safe, especially in the light of the past few weeks' anxious coding. :)
Let me explain it more deeper and make the comparison cleaner!
In case of Avalanche, all I had to do is implementing the picture loading code, then choose and put the right pictures on the screen, smash the whole thing into a big main loop with the keyboard and mouse event handling, and here you go: a half-working game, with the main character running around on the screen. (Of course, I struggled much more with it anno, and it was certainly more complex, but in a nutshell, that was that.) All in all, Avalanche was more appropriate to develop step-by-step, concentrating only on one thing at a time and bothering with the game logic only when almost all was said and done regarding the graphics.
In comparison with my previous work, CGE2 engine is more complex and was harder to find a solid grab on it. It handles things differently: it has very little, almost no hard-coded logic (which took up the greatest part of Avalanche by the way), but has a pretty scpript parser system, Snail.
I was lucky, I didn't have to implement the guts of the picture loading and drawing from scratch, using the ASM code in the original, because Arnaud and Paul did it for me during the implementation of CGE1. I only had to revise the fundamental classes and add/remove or modify function slightly to fit into CGE2's different coordinate or NPC-handling. The really hard part was to track down the inner workings of the engine through the not-so-verbose variables (there are tons of variables named "a" or "b", for example) and the not always logically named or placed functions ("getCave()" - What cave?!). Nevertheless no matter how I tried, which perspective I regarded the engine from, I always ran into Snail (called CommandHandler in the ScummVM version), which is clearly far from being complete, through the fundamentals of it are now settled, and as I concentrated on the parts what are used during the displaying of the intro, now it's done and working as you may have seen above. :)
After deciphering it, the internals of the command parser are not so hard to understand. Actually, every Sprite has a file with the extension of SPR, and those what are more than only one static image (For example the backgrounds are consist of only one picture. Yes, the backgrounds are considered as sprites by the engine as well.) has a bunch of information in them about the display sequence of the animation of the sprite. For example, 00SFINX.SPR, which contains the information of the roaring sphinx animation has a pretty readable table of the to-be-executed commands of the sprite, right under the "[near]" header in it. Especially, if you check this table of constants for the better understanding of the commands listed. So practically the intro animation is a sequence of pictures with sounds displayed right after each other, with a certain amount of delay inserted between each of them.
Luckily, I was also able to copy the main loop of the game from the ScummVM version of CGE1, and I only have to adjust some delay time to match the output of DOSBox.
My plan for the upcoming week is to proceed with the implementation of the main loop of the game and see what is needed to be implemented in order to display the first scenes of the game and very importantly: the NPC's on it and the animation of them.
See you soon! :)
Monday, September 2, 2013
A completable game
Yes, that's it! Avalot d'Argent is actually in a completable state now! Yaaaay!
A few words about the past week: In truth, I can't say much more than the previous time. I really didn't do anything spectacular, or made actually new code, I mostly spend the week with bugfixing.
Since the game has a very unique storyline, it was hard for me to complete the original one in DOSBox, but with the help of the Pascal code, and some paper and pen (I had to draw a smaller map for one part of the game.), I finally finished it. After that, it was not so difficult to find the bugs in my code. At least it was much easier to find them, then to repair some of them. To be honest, most of the problems were mismatched array indexes and numeric constants, but it didn't make the solving of them any easier.
After the game was completable, I plunged into the implementation of the drop-down menu. As the result of that, now I can proudly present you a screenshot of it and the fact that it's fully functioning and can be controlled with the mouse! (The keyboard support is coming soon as well.)
The implementation of it in fact, wasn't that hard, since I had every tool for it from previous parts of the engine. (For example the plotting of text to the screen, and ScummVM also already implemented the drawing of colored rectangles to the screen. I really didn't need much more than these, but a lot of patience.)
That's all for now. The last weeks of Summer of Code will be spent with heavy renaming and refactoring of my code, so by the end of the program, we'll be able to merge not only a working, but a working and (hopefully) readable and understandable engine into ScummVM! :)
A few words about the past week: In truth, I can't say much more than the previous time. I really didn't do anything spectacular, or made actually new code, I mostly spend the week with bugfixing.
Since the game has a very unique storyline, it was hard for me to complete the original one in DOSBox, but with the help of the Pascal code, and some paper and pen (I had to draw a smaller map for one part of the game.), I finally finished it. After that, it was not so difficult to find the bugs in my code. At least it was much easier to find them, then to repair some of them. To be honest, most of the problems were mismatched array indexes and numeric constants, but it didn't make the solving of them any easier.
After the game was completable, I plunged into the implementation of the drop-down menu. As the result of that, now I can proudly present you a screenshot of it and the fact that it's fully functioning and can be controlled with the mouse! (The keyboard support is coming soon as well.)
The implementation of it in fact, wasn't that hard, since I had every tool for it from previous parts of the engine. (For example the plotting of text to the screen, and ScummVM also already implemented the drawing of colored rectangles to the screen. I really didn't need much more than these, but a lot of patience.)
That's all for now. The last weeks of Summer of Code will be spent with heavy renaming and refactoring of my code, so by the end of the program, we'll be able to merge not only a working, but a working and (hopefully) readable and understandable engine into ScummVM! :)
Labels:
Avalanche,
DOSBox,
game logic,
graphics
Monday, August 12, 2013
Bubbles
Those connected to speaking!
And I subtly showed you an entirely new (and working) room of the game! Hah!
I am writing this post because I am leaving for three days tomorrow and I'll only come back Thursday night at best (but Friday morning is more possible). So let me sum up for you the progress of the past few days now!
First and foremost let me talk about the thing which needed the most work: the speech bubbles.
In truth, the actual drawing of them wasn't really hard. ::Graphics::Surface::fillRect() and Graphics::drawdrawPieSlice() did the most of the work. The thing I had to implement was the "tails" of the bubbles. For that, I introduced a new function, Graphics::drawTriangle():
Finished with the implementation of it, the next thing I had to pay attention was the printing of the characters to the bubbles. Since the original code used Pascal's outtextxy(), I had to come up with something to replace it as accurately as I could. As a solution, I introduced Graphics::drawText():
Using these two functions it was super easy to implement the speech bubbles, I only had to center the texts a little bit in Scrolls::bubble().
Besides these improvements, I managed to implement a lot of the game logics, so now the first 4 rooms of the game are complete and playable, all the NPC-s on these screens are fully functioning, and everything is basically very fancy. I could even make Spludwick (the mage on the screenshot above) follow Avvy around the room as in the original game.
That's all for now! I hope next time I will be able to tell you about how I managed to implement the handling of the mouse in the game and I am planning to get done with the drop-down menu right after that. See you soon!
void Graphics::drawTriangle(::Graphics::Surface &surface, Common::Point *p, byte color) {
// Draw the borders with a marking color.
_scrolls.drawLine(p[0].x, p[0].y, p[1].x, p[1].y, 255);
_scrolls.drawLine(p[1].x, p[1].y, p[2].x, p[2].y, 255);
_scrolls.drawLine(p[2].x, p[2].y, p[0].x, p[0].y, 255);
// Get the top and the bottom of the triangle.
uint16 maxY = p[0].y, minY = p[0].y;
for (byte i = 1; i < 3; i++) {
if (p[i].y < minY)
minY = p[i].y;
if (p[i].y > maxY)
maxY = p[i].y;
}
// Fill the triangle.
for (uint16 y = minY; y <= maxY; y++) {
uint16 x = 0;
while (*(byte *)_scrolls.getBasePtr(x, y) != 255)
x++;
uint16 minX = x;
uint16 maxX = x;
x++;
while ((*(byte *)_scrolls.getBasePtr(x, y) != 255) && (x != 639))
x++;
if (x != 639)
maxX = x;
if (minX != maxX)
_scrolls.drawLine(minX, y, maxX, y, color);
}
// Redraw the borders with the actual color.
_scrolls.drawLine(p[0].x, p[0].y, p[1].x, p[1].y, color);
_scrolls.drawLine(p[1].x, p[1].y, p[2].x, p[2].y, color);
_scrolls.drawLine(p[2].x, p[2].y, p[0].x, p[0].y, color);
}
It's clearly not the most optimized, nor the smartest code, but for now, it'll do. The operation of it is quite simple: First, we draw the borders of the triangle with a marking color. (255 is as good as any number bigger than 15, since our EGA palette supports only 16 colors.) After that we search for the highest and the lowest point of the triangle, and moving from the top to the bottom, we go trough every relevant line of the screen and fill the selected parts of it with the color of the shape. In the end, we redraw the borders - now with the desired color.Finished with the implementation of it, the next thing I had to pay attention was the printing of the characters to the bubbles. Since the original code used Pascal's outtextxy(), I had to come up with something to replace it as accurately as I could. As a solution, I introduced Graphics::drawText():
void Graphics::drawText(::Graphics::Surface &surface, const Common::String &text, fontType font, byte fontHeight, int16 x, int16 y, byte color) {
for (byte i = 0; i < text.size(); i++)
for (byte j = 0; j < fontHeight; j++) {
byte pixel = font[(byte)text[i]][j];
for (byte bit = 0; bit < 8; bit++) {
byte pixelBit = (pixel >> bit) & 1;
if (pixelBit)
*(byte *)surface.getBasePtr(x + i * 8 + 7 - bit, y + j) = color;
}
}
}
It's a very simple function, which's only purpose is to draw the given text with the given font to the given place on the given surface with the given color. (GIVENGIVENGIVEN!!!) It works like that: in font (which has the type of fontType), we store a mask for every character. The function simply search for every character's mask in this array, and then using that, the coordinates and the color, draws the picture of the character to the surface. Passing the height of the font is needed, because Avalanche uses 3 types of font and 2 of them has the height of 12 (used on the scrolls), but the third one (used on speech bubbles, the drop-down menu and the text input field) is only 8 pixel high.Using these two functions it was super easy to implement the speech bubbles, I only had to center the texts a little bit in Scrolls::bubble().
Besides these improvements, I managed to implement a lot of the game logics, so now the first 4 rooms of the game are complete and playable, all the NPC-s on these screens are fully functioning, and everything is basically very fancy. I could even make Spludwick (the mage on the screenshot above) follow Avvy around the room as in the original game.
That's all for now! I hope next time I will be able to tell you about how I managed to implement the handling of the mouse in the game and I am planning to get done with the drop-down menu right after that. See you soon!
Labels:
Avalanche,
game logic,
graphics
Subscribe to:
Posts (Atom)

