Purity [Concept]

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Purity [Concept]

Post by chili » July 17th, 2012, 1:28 am

Lookin' good LuX. When you say that you tried recursion, do you mean linked lists? Recursion might be messy in this case (or maybe not, I'd have to see exactly what you're doing), but a linked list seems like it would be a perfect fit for a waypoint system. Love those icons you got there. :)
Chili

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Purity [Concept]

Post by LuX » July 17th, 2012, 9:32 am

Currently I use an array that starts from 0 when I first walk, and assumes the next way point in the array to be unused. This makes a lot of things easier, but the downsides are I have a limited amount of way points and making the function I'm missing is gonna be a bit harder, unless I make some function to push the elements around when I add one in between or remove one.

I post my code once I get the movement stuff complete. I think I got rid of the weird sprites. Sometimes sprites would appear with black lines above them for no reason. I realized I was using aligned memory for all, and after removing that, it seems to have solved this.

Meanwhile, any idea what might cause a "corruption in the heap"? I've checked all my memory deletes, which seem to be fine. It points at either GDI+ shutdown code (where the green "next statement" arrow appears) or the line before it, an aligned malloc free code for my back buffers (aligned since I use SSE in sight scan, doubled the speed from 1.1 ms to 0.65 ms : -P).
ʕ •ᴥ•ʔ

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Purity [Concept]

Post by Asimov » July 17th, 2012, 2:58 pm

Hi Lux,

Malloc can cause heap problems, if you forget to free the memory in the deconstructor. I replaced all my malloc lines with new lines now.

Instead of

surface = (D3DCOLOR*)malloc( sizeof( D3DCOLOR ) * sWidth * sHeight );

I now use this

surface = new D3DCOLOR[ sWidth * sHeight ];

If you use new you have to delete it at the end. So instead of using free(surface) use delete [] surface;
eg
void SpriteLoader::FreeSprite()
{
//free (surface);
delete [] surface;
}

Asimov
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Purity [Concept]

Post by LuX » July 17th, 2012, 3:33 pm

I use that for the images, but my two screen buffers need to be 16 aligned, so SSE can access them fast and secure. But I can't align new memory to 16 bytes, can I? Using a predefined align function might work, but there's no guarantee, the compiler might just say fuq this shit and not align it.
ʕ •ᴥ•ʔ

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Purity [Concept]

Post by chili » July 17th, 2012, 3:34 pm

Hard to say where the trouble is. If you're still having the problem after you upload your code I will take a look at it and see if I can't find where the trouble is originating from.
Chili

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Purity [Concept]

Post by LuX » July 17th, 2012, 8:31 pm

Apparently the problem is my "_aligned_free();". I used _aligned_malloc to create the buffer, and if I use the aligned free or normal free I get the heap corruption error. If I don't free it at all, I don't get the error. Weird? How am I supposed to free aligned memory?

Using declare space and aligning "new" with 16 doesn't seem to work either. I get some conversion errors and stuff.

Anyways, was busy today so didn't get to coding until now, the release is going to wait a bit. I also have to write a tutorial of the controls, even that it only uses the two mouse buttons to do all the controls, it's still pretty complicated. Or maybe that's the reason : -D
ʕ •ᴥ•ʔ

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Purity [Concept]

Post by Asimov » July 17th, 2012, 9:04 pm

Hi Lux,

Stupid question, but why are you aligning to 16bytes, and what does this mean heh heh?

Asimov
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Purity [Concept]

Post by LuX » July 17th, 2012, 9:24 pm

It means the memory location is dividable by what ever it's asked to be, in this case 16. Not 100% positive on this, but it will make getting the info from that location faster, since the processor will fetch the information using a frequency. If the memory is aligned with the correct value, getting the memory can be done in one sequence using the same frequency. However, if it wasn't aligned, the processor has to figure out the size of the info gotten in sections.

Example: char would be one byte, or 8 bits. So lets say 'a' would be 01 'b' 011 and 'c' 0111. if that wasn't aligned, "abc" in memory might look like this: "010110111" so each character has a different size and the processor has to detect this. If it was aligned, it might look something like this: "01______011_____0111____" Now when the info is retrieved, all the characters are nicely in their own size, so the processor doesn't have to figure this out.

Down side is, aligning requires more memory.

Maybe chili has a better/clearer explanation.
ʕ •ᴥ•ʔ

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Purity [Concept]

Post by LuX » July 20th, 2012, 12:28 pm

Well, I have it almost done. Or have had for some time now, it's just missing one more thing.

While I like the current layout of the game, it's just not cool enough. It looks like you're planting flowers around the map and it looks really stiff and all.

Meanwhile, take a look at this new layout test. I haven't completely decided how I'm going to import it, but something like that would be cool, where players movements are hilighted like this or something...
Cell Light.rar
(22.39 KiB) Downloaded 344 times
ʕ •ᴥ•ʔ

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Purity [Concept]

Post by chili » July 21st, 2012, 7:08 am

This looks rather sexy. 8-)
Chili

Post Reply