CreateBank

Blitz3D Forums/Blitz3D Programming/CreateBank

Yue(Posted 2014) [#1]
I never could understand a memory bank. can someone explain me the easiest possible way to work with memory banks please.


Floyd(Posted 2014) [#2]
It is simply a block of empty memory. You can do whatever you want with it.

Common uses might be to load a file into memory and then process it in some way. Another use is with external programs ( DLLs ) which need access to memory within your program. You tell the DLL the address of the memory.

I once needed to examine the bits in a floating point number. I used something like this:

Graphics 600, 400, 0, 2

bank = CreateBank(4)

x# = 25

PokeFloat bank, 0, x       ; put 4-byte Float into bank
n = PeekInt( bank, 0 )     ; read it back as if it were an Int, so we can get at the bits

Print
Print " The floating point value: " + x
Print
Print "   Consists of these bits: " + Bin(n)

WaitKey



Charrua(Posted 2014) [#3]
nice example.

they gives you the possibility of write floats, ints (32 bits each) and then read them back as bytes and vice versa

you may, for instance create a bank of 4 bytes as floyd did and store
alpha, red, green and blue in its corresponding offsets and then read the color back as integer to use in pixel handling funtions or read pixels
store on a bank and read individual color components... etc

there are many ways for doing tasks, banks gives you alternatives

(for handling colors you may use bit_shifs also, it's a matter of taste)


Krischan(Posted 2014) [#4]
You can do cool things with banks, for example image manipulation (here: 8bit grayscale for heightmaps but could be extended easy to 16,24,32 bits). As far as I remember it is even faster than the lockbuffer/readpixel/writepixel commands.




Yue(Posted 2014) [#5]
Ok, thank you all.

Every time I see the work of Christian, I feel a kick in the balls, I'm very far from doing that, and I realize that the problem is not the tools, but users.


Krischan(Posted 2014) [#6]
Thanks. If I'd have more free time and even important: more motivation (!) I think I could write even cooler stuff than BlitzTiles or PlanetCreator. I'm still dreaming of my own spaceflight game but I'm afraid to fail in this as it would be much, much larger and more complex than anything I wrote the last years and beside that I'm a perfectionist. So I stand in my own way.

But self-awareness is the first step towards self-improvement.


Hotshot2005(Posted 2014) [#7]
I remember Amiga Amos used to have bank where load image from memory :)


RemiD(Posted 2014) [#8]
About banks, you may want to take a look at these posts :
http://www.blitzbasic.com/Community/posts.php?topic=101694
http://www.blitzbasic.com/Community/posts.php?topic=101699