Qbasicnews.com

Full Version: Enhanced memory and pseudo-pointers in QB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Some of you may remember the memory routines I posted here a while ago. I have since improved them to make them a little more general purpose. The routines use DIrectQB's EMS peek and poke commands, but it could be made to work with any XMS/EMS library. The memory managment routines provide a block list of memory which can be malloced and freed (in a similar fashion to C's functions) to get a pointer (which is just an integer) to a block of memory. Two functions, memStore and memLoad allow you to store and retreive values and structures from EMS.

The pointer aspect allows more advanced structures such as linked lists to be made in QB, for example:
Code:
const SIZEOFNODE = 4
const NULL = -1

type nodeType
  values as integer
  link as integer
end type

dim rootNode as nodeType
dim linkNode as nodeType
dim rootPtr as integer

rootPtr = malloc%(SIZEOFNODE)

rootNode.value = 10
rootNode.link = malloc(SIZEOFNODE)
memStore varseg(rootNode), varptr(rootNode), rootPtr, SIZEOFNODE

linkNode.value = 20
linkNode.link = NULL
memStore varseg(linkNode), varptr(linkNode), rootNode.link, SIZEOFNODE

Working with the routines has a slight amount of overhead, for example to modify something store in EMS, you need to fetch it with memLoad, change it and then restore it using memStore.

The major benefits of using the library is that EMS can be used instead of conventional memory for storing large arrays and structs and data structures such as linked lists and binary trees can be created using pseudo pointers.

I have the routines working and could write a number of demos showing how various things can be acheived with them. How many people are actually interested in seeing/using the code, there didn't seem to be a large amount of interest when I posted the code for the original routines a while ago.
I am. ;*)
I'm really interested upon this work. Mostly on its graphics applications (storing big amounts of sprite data).

Great work, man.
Im currently using the routines for QBDBZ (Yeah I am still slowly working on it) to store all of the move data, collision boxes, sprite tables etc. When I changed from storing the game data in conventional memory to Expanded memory I was able to go from having about 50 odd moves, spriteframes per player to about 300 (many of the special moves use several moves chained together to produce the overall effect).

Ill tidy the routines up a bit and write some examples and documentation. Ill probably get Oracle to host it on QBNZ. Ill try and get it done over the next couple of days.
That's cool man...I'd like to see that...the routines and the game
That kind of routines were the kind of stuff I was looking for to do my sidescroller beat-em-up game. My problem is that the hassle to write them from scratch was overwhelming Smile
It's a hassle on the brain to make special structures without pointers, but I've never tried it with pointers, so it might be just as hassling. But might not..... Smile
Okay, finally got around to getting it working. Oracle has kindly hosted it for me, so grab it, try it out and let me know what you think. As always, comments, suggestions and criticism welcome.

Edit: As usual, I can't spel, so heres the actual link.

http://qbnz.com/pages/downloads/utilities/memory.zip
Great. LooseCaboose. When I have the time, I'll take a glance.

Cheers.

EDITED :: I got a file not found. I've tried all the "methods" Wink
Opps, fixed the link to point to the actual addres :oops:
Pages: 1 2