wtorek, 12 sierpnia 2014

Finally completable

Hello everyone!

Great news! The Prince and the Coward is now completable! This means that we are able to play from beginning to the end of the game without skipping any important part of it. Here we have a screenshot from ending sequence to give you a proof:

Prince completable
Game ending

First thing that I had to change was hero drawing and movement to implement second hero displaying. I made some changes in Hero class (hero shadow drawing, zooming) and also update pathfinding functions for second hero and now it's working fine:

Second hero implementation
Displaying and movement

I also implement drawing "power meter" and bind it with mouse and keyboard buttons, so now last mini-game - "Escape from jail" is working correctly:

"Escape from jail"
Last mini-game

Next things that I had to code were credits loading and scrolling function for them. They are displayed after game ending animations and they look like this:

End credits
Scrolling after ending animations

I also work on graphics functions to add anti-aliasing code that exist in original version of game for sprite drawing functions. Prince is using 256 colors palette and its edge smoothing is based on 256 x 256 table of colors transition. Algorithm is checking if currently drawing pixel is located next to the edge of sprite and if it makes jagged line. If it does then this pixel is set with color from transition table calculated of original background pixel color and sprite's edge pixel color. Personally I don't see a big difference, but I think that it is visible mostly on not moving sprites, like shovel. You can compare it on screenshots below:

Anti-aliasing comparison - first location
(from left to right) Original game, ScummVM - AA on, ScummVM - AA off

Anti-aliasing comparison - shovel sprite
(from left to right) Original game, ScummVM - AA on, ScummVM - AA off

Most of work is done now, but there are still glitches that I have to fix (e.g. correct shadow drawing, fix drawing of last frames of FLC animations) and some ScummVM's Advanced Engine Features that I'd like to implement before merging of the engine.

wtorek, 5 sierpnia 2014

Mini-games and bug fixing - part two

Hello everyone!

I spent this week fixing bugs that still had left in game code and I can't believe that there are so many of them ;) I'm pretty sure that you can easily find some more, but let's talk about fixed ones now.

I reworked whole Animation class, which felt very complex at the beginning, so I skipped this task of the project at that time and work on it now.

Some frames of sprites in Prince need decompression process before drawing them. Initially, specific frame was unpacked every time the game wants to draw it, which for looped animations (like background animations) wasn't optimal.

At first attempt I changed loading function of Animation to decompress all frames of it when it is used for the first time, so every frame was unpacked just once. It turns out that this wasn't the best solution. Unpacking about 300 frames during the gameplay, not in location loading, can freeze the game for a while and player can see it. I decided to change this conception to find a golden mean for it. So now, each frame is decompressed just once and it's stored for later use, but it's done when game draw it for the first time, so it's not loading all frames at once. I made Visual Studio performance test for this solution and it looks like everything is working well now.

Next part that I was trying to finish this week were mini-games. I was able to fix four of them: "clip-clap" with bartender, one-armed bandit, "Mr. Sun puzzle" and "Throw a rock" . I don't want to spoiler a lot, so here are just a few screen-shoots of them:

"Clip-Clap" with bartender
Mini-game

One-armed bandit
Mini-game

"Mr. Sun puzzle"
Mini-game
"Throw a rock"
Mini-game

I still have to implement last one, which appears at the end of a game.

Rest of things that I fixed this week:
- hero special animation drawing (position of animation and last frames)
- hero running
- inventory  - saving, swapping, opening and new item adding animation
- German texts drawing
- background script interpreter during dialog-boxes
- cursor after loading

wtorek, 29 lipca 2014

Saving and bug fixing - part one

Hello everyone!

I spent most of this week trying to find and fix bugs that had left in game code and to implement last engine functions. I'll write about the most important ones.
I also implemented basic game saving / loading, so it should speed up my testing work.

First thing that I managed to finish this week is the map location. It's a little bit different from normal locations. There was a problem with masks and objects, which should hide undiscovered parts of map.

Objects (edges of map and black shapes) are drawn on background surface only once, at location loading, and they are removed from objects list after it. This new surface become a current background, so when masks are drawn (check here), they don't show as discovered parts. In this location masks are triggered only by hero and they are used to hide him when he's walking across unexplored places.

Map location - temple exploring
Left - before  / Right - after

Second thing that I implemented was algorithm for map exploring animation. I changed the original one a little, but final effect should still be the same or very similar:

Map during exploring - Temple
Left - original / Right - ScummVM



I was working on implementation of blackPalette() and setPalette() functions.
They are used when hero changes location and they allow to gradually change color palette from normal to black and vice-versa.

Location no. 1 - Graveyard
Palette blackout


Game saving and loading is working only during the runtime now. You can't load your save-game from a launcher, but it's working similar to original game (you always start from the beginning in it and you have to skip intro animation to load your game). I'll think on updating it later, when everything else will be done.



I aslo made huge update in sounds and midi music part. I get rid of all memory leaks in it and now all sounds (not only hero and mobs voices) are playing correctly. We can hear gravedigger polishing graves or owl sounds for example.

Rest of things that I fixed this week:
- position of texts in wider locations and fix for inventory texts
- hero special animation drawing (still without shadows)
- mob priority list (order of mobs names drawing)
- bear form animation crashes
- pathfinding update
- blocked RMB menu on map mobs

I'm going to work on fixing rest of existing bugs this week and maybe implement rest of ScummVM's Advanced Engine Features.



wtorek, 22 lipca 2014

Pathfinding and hero movement

Hello everyone!

I was working to finish pathfinding part and implement hero movement animation this week.

I made huge clean-up in code and optimized an algorithm so it's not hanging whole game now. I used Visual Studio performance test to find slowest part of code. I also found and fix several bugs in pathfinding part, so it's not causing crashes anymore and there are no memory leaks in it. I can say it's working in 99% now, but it still need some testing. ;)

I updated it to allow mouse-clicking on places where hero can't directly go and to find closest point for destination instead. Pathfinding is also working correctly in wider locations now.

Last function to implement was scanDirection(). It used calculated array of path points to create array of directions for hero animation.

After finishing engine part of pathfinding I updated script part functions - O_RUNHERO, O_MOVEHERO, O_CLEARPATH, O_SETPATH and O_LOADPATH, so hero is walking to objects or mobs before he inspects or talks with them. "Walk to" option in right mouse button menu is also working now.

I made big changes in part of code that I had implemented at the beginning of my project - most in showHero(). It's a function that, among other things, make use of path cords and directions arrays calculated in pathfinding part. It counts hero animation frames and change animation according to current direction. It allows to turn hero during the path and to speed up his movement by skipping some of points on the path.

You can watch my progress on video right here: https://www.youtube.com/watch?v=nDPYoZoO3mI





poniedziałek, 14 lipca 2014

Pathfinding - beginning of implementation

Hello everyone!

Great news, someone may actually play Prince when I finish coding it! ;)
If you understand Polish, you can check articles about my project on websites here:
cdaction.pl, antyweb.pl, polygamia.pl, przygodomania.pl, gram.pl, playingdaily.pl, gry-online.pl, polskathebest.pl, gry.interia.pl, osworld.pl

I finally edited and upload video of first location gameplay that I promised you in my previous post.
You can watch it here: https://www.youtube.com/watch?v=Q5bhHKp8Eh8


I'm aware of existing bugs in it, like:
- hero talking animation sync (fix to match currently playing voice)
- hero boredom animation timing (shouldn't start randomly in time of dialog)
- hero shouldn't have dagger equipped from the beginning of a game
- gravedigger's last line before his runaway - "O w morde..." is not playing
And gameplay also lacks working pathfinding, so Prince is standing still whole time, but I'd like to tell you about my current progress with fixing it.

I spend this week trying to analyze, code and then fix most of path-making functions.
It was lots of lines to code and it still has some things that I have to fix but right now it looks like this:

Pathfinding - testing
Path drawing #1

Pathfinding - testing
Path drawing #2

If you look closely you can see white dotted lines that are drown temporary to display array of calculated path coordinates. I'm working on part that allows to find a correct, nearest place for destination when you click on place where hero can't go.

Next step will be implementing scanDirections() function, that will allow to create array of directions for hero walk animation during the path and also updating showHero() function to fix some bugs that I mentioned before and allow hero to actually walk the path.



środa, 9 lipca 2014

First playable location

Hello everyone!

Quick update to show you my weekly progress. I was working on script part this week and I have some good news. ;)

After setting an interpreter's debugger, understanding of how game script is working was actually quite easy. Most of script functions are done and are working correctly now. It was about 60 functions to code. Many of them have just 10 - 20 lines of code, but they are doing huge job in the game (like setting frames of background animations and loading special animations).

Some of them was pretty complex though and needed serious thinking - like O_INITDIALOG.
I had to change the way text for dialog-boxes are stored. I was just using array of strings before, but it was to simple and it was blocking script. To fix it I had to stick with concept from original game that uses special characters, hidden inside texts, to know how whole conversation should look like (who is talking, where to make pause while talking etc).

After taking care of script I found lots of bugs. I had to update background animations to allow changing from one to another, make fix for some voice loading and change the way objects (like shovel) are set to visible. I also update some mouse button events again.

Right now I have first fully playable scene - graveyard and I looks so cool ;) I still have to fix map scene to allow to change to another locations correctly, but after some testing I think that basics of other locations should work well too. I have very slow Internet access where I live now, but I'll try to upload game-play of it later at night.

Location 1 - Graveyard
Gravedigger's magic

Location 1 - Graveyard
Summoning Arivald


I'm preparing for pathfinding part right now. I'd like to finish it this week. One of things that I'll have to take care next is saving. It should make testing easier and allow to skip beginning of the game.


wtorek, 1 lipca 2014

LMB outside of inventory, beginning of script part

Hello everyone!

Finally, my exam time is over and I move back from my student apartment in Gdansk to my hometown for next two months. Moving cost a lot of time and effort, but from now I'll have peace and quiet to do serious work with Prince's code ;)
I'm also waiting for results of two last exams and I wish I will pass all of them.

Let's talk about my progress in last days:

At the beginning of a week I was working on handling rest of LMB actions outside of inventory. I manged to finish rest of option frame events (Examine, Pick up, Use, Open/Push, Close/Pull, Talk to). I have to implement pathfinding part before finishing the last one - "Walk to".

After choosing one of these options, it searches in proper mobs/op codes list to check if any special event for selected mob exists. If it exists we store its op code as next for foreground interpreter. If not we just store standard procedure's op code. Something similar happens for "Give item" and "Use item" events outside of inventory (events with item taken out from inventory). Second important step it to set current mob flag to allow proper working of upcoming script's functions.

Next thing that I had to understand this week, was how actually the script part is working. I choosed "Examine" option for testing, set up interpreter's debugger to show only foreground op codes and start fixing my first script functions.

I was able to implement script O_GETMOBTEXT(), which also need big update in setVoice() function. It used to support only one type of voice file for intro part, now it should work for every voice in game.

Last thing that I fixed to finish "Examine" option was small, but was very hard to find out. I had to update loading data for longer texts, when prince is talking more then once, like for graves examining in first location. I also implement O_CHANGEMOB() that is used to set visibility of mob and allow to change from one mob to another, e.g changing "unknown grave" to "Arivald's grave" after first examining.

I also updated checkMob() function and it's displaying names of background animation mobs and objects now. I also checked original code and found part of code that update visibility of static mobs for each location.

Background animation - owl (left) / Object - shovel (right)
Displaying names of mobs


I was also trying to find memory leak problems and I fixed most of them, but part of implemented code still need some clean-up and tweaks.

Right now I'm working on dialog part in script for "Talk to" option. It should allow to get some serious progress and to actually play a game for a while, but it's pretty complex and it requires implementing about 4-5 new script functions, so stay tuned.

wtorek, 24 czerwca 2014

Dialog frame and rest of mouse handling

Hello everyone!

This is very difficult week for me - final exams at university and midterm evaluation of GSoC at the same time. I'm doing my best to combine these two and I hope you'll like my weekly progress.
So, here we go:

At the beginning of a week I was working on implementing dialog box frames. I manage to finish it and it's drawing everything in right position now (long sentences are cut properly). Mouse handling and highlighting is working fine too. On the video and on first screenshot you can see temporary texts. It's not loading actual texts from game data yet - it needs more work at script part to be finished.

I was also fixing some of existing functions, like showTexts(). I had to change calculations of texts position to adjust it for heroTalk() function and other texts that will be shown above heads of characters. It's now using width of longest line to find a center and it's also drawing correctly at the edge of screen and in wider locations.

I also mange to do cursor changing function (screenshot no. 3) and rest of left and right mouse button handling to finish choosing from option frame (Give, Use, Open/Push, Close/Pull) in inventory.
Most of mouse button handling outside of inventory is working too.

At the end of a week I also asked wjp for help with my git repository. I had a job to recover history of malik's commits in my branch instead of initial commit that I create at the beginning of GSoC from existing Prince codes. Everything is working excellent now, so again - many thanks to wjp ;)

You can see my progress on screenshots below or watch it here: https://www.youtube.com/watch?v=V44Dbpdbxm8


Dialog box drawing
Highlighting one of options


Hero talking - working animation
Texts from dialog box in correct position

Cursor changing
Use / Give - working inventory options

This week I'll try to take a look at script part to check if I can connect existing mouse events (and their op codes) with simple actions, like drawing texts for mobs examining outside of inventory. I'm also looking at pathfinding part right now, but it still looks very complex. I'll also try to check and fix some memory problems and do some clean up in existing code.

wtorek, 17 czerwca 2014

Options menu and item examining

Hello everyone!

I would like to show you my weekly progress. I was working on left and right mouse button events and I finished drawing options menu and displaying short descriptions of items in inventory.

I had to check position of cursor to find which mob (item / object) is selected. Then if LMB is pressed I play voice sample and load proper text for calculated amount of time. If LMB is pressed again (during the voice sample) it cancel playing the sample and turn off text instantly. During this event mouse cursor is invisible and you can't leave the inventory.

RMB allows to display options menu for selected item. Selected option is highlighted properly. We have to check if cursor stays inside of rect of menu, otherwise we turn it off.
 "Examine" - first option in inventory menu starts same event as LMB click on item. I have to implement events for rest of options now.

You can check all of these on screenshots below or on video here, first time with sound ;)
https://www.youtube.com/watch?v=yPc_FXlAHyE



Drawing exam texts of items in inventory
Options menu outside of inventory
Options menu in inventory

I was also working on fixing letters from German version of game in intro animation, options menu and exam texts and it seems to be fine now:

German letters drawing in intro, options menu and exam texts

Next thing that I will implement will be probably cursor changing for "Use" and "Give" menu options. I also start working on dialog windows part.

wtorek, 10 czerwca 2014

Inventory implementation

Hello everyone!

I would like to show you my new progress. Like i wrote in my last post I'm working on inventory part right now. I have already implemented drawing the suitcase and loading sprites and texts for items. I managed to recreate animation of adding a new item with sound effect. Position of items in inventory is based on amount of them. I also handle proper opening and closing it by mouse and drawing names of item selected by a cursor.

 There were also two additional parts of code that had to be done - drawing animation of candle (it's the only one animated inventory item) and also gravedigger's curse animation for four items (immortality elixir, amulet, gem and dagger) for first location. Animation of adding new item and gravedigger's curse use other algorithm of calculating frame colors (which creates blinking effect). You can see that on screenshots below or on short video right here: https://www.youtube.com/watch?v=TsaZnmblBgM

Inventory - dagger
Name drawing, mouse handling

Inventory - Gravedigger's curse
Items animation - blinking

Next things that I want to implement are left and right mouse button events for inventory (drawing short description of item and item options window). Some functions from inventory will be very useful for dialog windows part later.


wtorek, 3 czerwca 2014

Parallax sprites, masks and Z axis

Hello everyone!
There will be more pictures to show my progress this time. ;)

I was working harder at the weekend and was able to implement loading and displaying sprites that use parallax effect.
In simple words, in Prince these are bitmaps displaying as last, on top of everything else and scrolls faster then other animations while hero is moving in wider locations. It gives a feeling that this kind of objects are closest to the screen.
You can see them by finding differences in pictures below:


Parallax sprites - loc no. 2
Before (left) / After (right)


Parallax sprites - loc no. 2
Before (left) / After (right)

Parallax sprites - loc no. 4
Before (left) / After (right)

Parallax sprites - loc no. 4
Before (left) / After (right)

Next part I manage to code was masking sprites by parts of background.
Information about masking is loading for each location. Mask doesn't contain graphics data, just info about position and which pixels of background should be redrawn on top.
I recorded short video with mask debugging - https://www.youtube.com/watch?v=6bhaI_PDOdI.
It shows working algorithm of turning on and off proper masks. It depends on position of hero, background animations and objects, etc.

Masking - loc no. 3
Before (left) / After (right)

Masking - loc no. 5
Before (left) / After (right)

Last part that I code required some thinking before actual doing it. It was a problem of drawing everything I already had (sprites of hero, background animations, masks, parallax sprites, objects) on background in proper sequence of Z axis coordinate.
I decided to create structure similar to this one from original asm code - DrawNode. It contains all information about drawing element (e.g. position, width and height of sprite, pointer to sprite) and also pointer to function that will draw it later.
Each function of drawing add new DrawNode to an array. After creating whole array I'm sorting all of them by Z coordinate and then draw them. You can see working algorithm on pictures below and also on short video here: https://www.youtube.com/watch?v=jdwqNOwqG1s

Z axis - loc no. 1
Before (left) / After (right)

Z axis - loc no. 2
Before (left) / After (right)

Next things I'll try to implement will be probably inventory drawing functions or dialog / choice frames. I'm trying to get familiar with these parts of code now.

See you next time!

piątek, 30 maja 2014

Background animations #2

Hello everyone in new weekly update.
There are four types of background animations in the game:
  • Type 0 - loop of just one sub-animation (e.g. gravedigger in loc. 1 - graveyard)
  • Type 1 - loop with randomized sub-animation (e.g. owl in loc. 1 - graveyard)
  • Type 2 - loop with base animation and after constant delay - change to one of another sub-animation (e.g. beggar in loc. 4 - city)
  • Type 3 - loop of one sub-animation that is turning off for randomized amount of time (only in loc. 14 - treasury)
I finally manage to draw background animations of all types and also to draw shadows for them:
https://www.youtube.com/watch?v=rq7yIA5Fp-c



I also allow to cut them properly on edges of the screen while scrolling the location.  I still have memory leak problems that I have to fix. Application is not crashing, but there have to be mistake somewhere. I'm using VS 2010 on Windows 7 and I don't have ScummVM compiled with gcc on Linux, so I'm using similar tool to Valgrind for memory checking - Dr. Memory. It gives me some errors in type 1 and 3 but it looks like it is not related with randomizing of sub-animations.

I also start working on part of code that allow drawing masks / overlays of background on top of other sprites (which allow to create Z axis in 2D world) and I have to say that it's going pretty good.


sobota, 24 maja 2014

Background animations and objects displaying



I had a lot of school work this week, so my progress is smaller then I hope. I’m not proud of it but I’m going to work harder in upcoming week.

I was working on background animations displaying. I manage to load and display proper first frames of animations for each location. At the beginning I thought that I will be able to use same way of loading that is used for objects loading (like for shovel in first location). Sadly, there are more complications with them.

I was trying to understand how animations for Prince are stored. For each location we have anim.lst file that contains information about all animations of loaded room: special animations of hero (like hero with shovel for first room), background animations (like owl or bats in loc no. 1) and normal animations (like wizard Arivald). I had to implement InstallBackAnimations and InstallSingleBackAnim functions to find and load only background animations. These functions allow to find their proper numbers in anim.lst and load data for them.

But there are some background animations that has more then one type / sub-animation (like owl in first location – there are animations of her blinking eyes, waving her wings, etc). I decided to store main info (BAS structure) and array of all sub-animations (Anim) for one background animation in one structure (BackgroundAnim) and then create array of these structures (backAnimList) that contains all of them, but I’m not 100% sure if it’s the best idea. Some of background animations can change into normal animations (like gravedigger in first location) and that will be important too.
 
I’m still working on finding which sub-animation should be loaded in specific moment - it’s calculated in ShowBackAnims function.

Background animations - location no. 1

Background animations - location no. 3

Background animations - location no. 10

piątek, 16 maja 2014

Hero’s shadow drawing #2



I finally updated showHeroShadow function and I think that it’s working as in original game now.
 
With help of Eugene I manage to fix shadow colors. I had thought that there was a problem with algorithm or with finding right values in memory, but there was small mistake in getting location palette for makeShadowTable function - I was using palette from previous location after loading a new one. It was easy to fix but very hard to find out, so thanks again to him.
 
I also extend shadow function by adding proper drawing on walls and masking on objects and you can see it on screenshots below:

 
Location no. 1 - shadow masking and correct palette
ScummVM (left) / Original game (right)

Location no. 2 - shadow masking and correct palette
ScummVM (left) / Original game (right)

Location no. 2 - shadow after hero scrolling
ScummVM (left) / Original game (right)


Location no. 3 - shadow drawing on walls
ScummVM (left) / Original game (right)


 

poniedziałek, 12 maja 2014

Hero’s shadow drawing



So here we have next weekly update:

I finally made progress with shadow drawing last night. Position of hero’s shadow is changing in different locations and shape of the shadow depends on a hero position right now. Shadow is also correctly zooming when hero is resizing. I also manage to fix some memory leak problems in this functions.

I still have problems with shadow color palette so I’m using black color to fill the shadows and to check if the shape is good. There is a part of code that needs to be implemented that allows to change the shadow’s shape when it’s drawing on a wall of a building and I’m going to work on this part right now. Actual code still needs some tweaks and clean up which I’m also going to do this week.

ScummVM (left) / Original game (right)
Location no. 1
ScummVM (left) / Original game (right)
Location no. 2

ScummVM (left) / Original game (right)
Location no. 7


My actual shadow palette - loc no. 1


My actual shadow palette - loc no. 2


niedziela, 4 maja 2014

Hero scrolling and zooming


I am in the middle of work with hero sprite displaying. My progress isn’t as fast as I was thinking at a beginning but I’m not losing my hope. I feel that assembler and I are getting to know each other better but there are still some new things that I have to learn.

The best progress is when you can see it, so here we go:

First location - before hero zooming

First location - after hero zooming


Second location - before hero zooming

Second location - after hero zooming

Hero is also drawing in a right spot in wider locations where a background is moving while he walks.
Next thing that I am going to implement is drawing hero's shadow so wish me luck ;)
I'm still fighting with functions that allow to calculate colors and positions for it but I'm slowly pushing it forward.

See you next week!