Help with MemBlocks and Videos

Post your coding questions such as 'how to' here.
Post Reply
Hacker
Newcomer
Posts: 11
Joined: Mon Aug 11, 2008 1:36 am

Help with MemBlocks and Videos

Post by Hacker »

Hi:

What commands are used to MemBlocks?

What are the Memblocks?

The other problem I have is that the videos I try to play with CoolBasic do not play, you hear only the audio but not see the image.

How can you see that video?

Thank you.
KilledWhale
Tech Developer
Tech Developer
Posts: 545
Joined: Sun Aug 26, 2007 2:43 pm
Location: Liminka

Re: Help with MemBlocks and Videos

Post by KilledWhale »

Hacker wrote:Hi:

What commands are used to MemBlocks?

What are the Memblocks?

The other problem I have is that the videos I try to play with CoolBasic do not play, you hear only the audio but not see the image.

How can you see that video?

Thank you.
1. What commands are used to MemBlocks?
MakeMemBlock(size) - Creates memory block which is (size) bytes long.
MemBlockSize(memblock) - Tells size of memory block (memblock)
DeletememBlock(block) - Deletes memory block (block)
ResizeMemBlock(block, size) - Resizes memory block (block) to (size) bytes
PokeByte() - Puts one byte to memory block
PokeShort() - Puts two bytes to memory block
PokeInt() - Puts four bytes to memory block
PokeFloat() - Puts fourd bytes to memory block
PeekByte() - Reads byte from memory block
PeekShort() - Reads 2 bytes from memory block
PeekInt() - Reads 4 bytes from memory block
PeekFloat() - Reads 4 bytes from memory block

2. What are the Memblocks?
Memory Blocks are pieces of computer's memory which you can access to store data.

3. How can you see that video?
You are propably missing some codec that's needed to play the video. Try installing divX.
CoolBasic henkilökuntaa
Kehittäjä

cbFUN Kello
cbSDL
Whale.dy.fi

<@cce> miltäs tuntuu olla suomen paras
Hacker
Newcomer
Posts: 11
Joined: Mon Aug 11, 2008 1:36 am

Re: Help with MemBlocks and Videos

Post by Hacker »

Thank You!!

But how do you use MemBlocks?

Someone can give me a piece of code as example?

Please do not understand.

Thanks in advance.
KilledWhale
Tech Developer
Tech Developer
Posts: 545
Joined: Sun Aug 26, 2007 2:43 pm
Location: Liminka

Re: Help with MemBlocks and Videos

Post by KilledWhale »

Okay, here's my quickly written small example of memory blocks. Memory blocks are useful when you need to pass data to functions or dlls but otherwise they are not needed so much.

Code: Select all

//Memory block example
mem = MakeMEMBlock(11) // Create 12 bytes long memory block

PokeInt mem, 0, 65912 // Put number to location 0 (4 bytes long number)
PokeShort mem, 4, 2000 // Put another number to location 4 (2 bytes long number)
PokeByte mem, 6, 123 // Yet another number to location 6 (one byte long number)
PokeFloat mem, 7, 127.001 // Now we put floating point number to location 7 (4 bytes long number)

Print PeekByte(mem, 6) // Read number from our memory block from location 6. The location must be some place where you have put data
Print PeekInt(mem, 0)
Print PeekFloat(mem, 7)
Print PeekShort(mem, 4)

DeleteMEMBlock mem // Release the memory. CoolBasic should automagically clean up non deleted memory blocks but you never know :)

WaitKey
CoolBasic henkilökuntaa
Kehittäjä

cbFUN Kello
cbSDL
Whale.dy.fi

<@cce> miltäs tuntuu olla suomen paras
User avatar
Jare
Devoted Member
Posts: 877
Joined: Mon Aug 27, 2007 10:18 pm
Location: Pori
Contact:

Re: Help with MemBlocks and Videos

Post by Jare »

KilledWhale wrote:Okay, here's my quickly written small example of memory blocks. Memory blocks are useful when you need to pass data to functions or dlls but otherwise they are not needed so much.
Jea, but with MemBlocks you can also make a replacing structure for arrays and types. Though that is rarely needed to do, but sometimes it proves to be quite handy. Or if not replacing types and arrays, you can also use MemBlocks to extend their potentiality.
Hacker
Newcomer
Posts: 11
Joined: Mon Aug 11, 2008 1:36 am

Re: Help with MemBlocks and Videos

Post by Hacker »

Thank You!!!
KilledWhale
Tech Developer
Tech Developer
Posts: 545
Joined: Sun Aug 26, 2007 2:43 pm
Location: Liminka

Re: Help with MemBlocks and Videos

Post by KilledWhale »

Jare wrote:
KilledWhale wrote:Okay, here's my quickly written small example of memory blocks. Memory blocks are useful when you need to pass data to functions or dlls but otherwise they are not needed so much.
Jea, but with MemBlocks you can also make a replacing structure for arrays and types. Though that is rarely needed to do, but sometimes it proves to be quite handy. Or if not replacing types and arrays, you can also use MemBlocks to extend their potentiality.
But as an array, calculating writing and reading positions can be a bit slower than using regular arrays which isn't good especially when talking about CoolBasic. Using memory block instead of array can cost many valuable opcodes :)
CoolBasic henkilökuntaa
Kehittäjä

cbFUN Kello
cbSDL
Whale.dy.fi

<@cce> miltäs tuntuu olla suomen paras
Sly_Jack0
Devoted Member
Posts: 612
Joined: Mon Dec 10, 2007 8:25 am

Re: Help with MemBlocks and Videos

Post by Sly_Jack0 »

KilledWhale wrote:
Jare wrote:
KilledWhale wrote:Okay, here's my quickly written small example of memory blocks. Memory blocks are useful when you need to pass data to functions or dlls but otherwise they are not needed so much.
Jea, but with MemBlocks you can also make a replacing structure for arrays and types. Though that is rarely needed to do, but sometimes it proves to be quite handy. Or if not replacing types and arrays, you can also use MemBlocks to extend their potentiality.
But as an array, calculating writing and reading positions can be a bit slower than using regular arrays which isn't good especially when talking about CoolBasic. Using memory block instead of array can cost many valuable opcodes :)
But, what if you need to specify an array as type's field. This where memblocks come in handy.
User avatar
Jare
Devoted Member
Posts: 877
Joined: Mon Aug 27, 2007 10:18 pm
Location: Pori
Contact:

Re: Help with MemBlocks and Videos

Post by Jare »

Sly_Jack0 wrote: But, what if you need to specify an array as type's field. This where memblocks come in handy.
That would usually be the best solution. I really like it this way.

But another way is to make a large multidimension array and every type instance having their own unique index to the array's first dimension. Yes, it has its limits such as predefined maximum count of type instances (or need for resizing the array when a new instance is created) and unable to pass array to functions as a parameter. But the advantage here is absolutely the speed.

So my point is: there are choices. Try to select one that suits best for a certain issue. :)
Post Reply