06-02-2003, 04:02 AM
...is confusing me. I've removed all the DQB and replaced it with CosmoX, but it's not working... I've narrowed down the problem down to start of the program.
So that's what the maunal says, but I can't make use of it....
Quote:EMS Layers
If you don't know why the heck would you like a layer think on this, you
draw something in the screen, then you clear it to draw your next thing, and
you do it again, what you see ??, FLICKER!!!. The screen is flickering
constantly because you have the time to see the screen clearing. This looks
ugly. With EMS you just set up a layer (or as many as you want) and get the
page frame address. Now instead of passing the video memory address to
the library functions, pass the page frame address, obviously you don't see
anything because you are drawing in a offscreen layer, but now you copy
your layer all at a time to the video memory, clear the layer, start drawing
on it, copy it again to video memory and so on, and what you get ??...
flickerless animation!!!!.
The page frame is 64K size so you can only have a layer at a time. So to
have more than one layer, you have to be constantly remapping them.
The page frame is divided in 4 pages of 16K of memory just like the size of
the logical pages of EMS. To setup a layer just do this :
We make sure there is a Expanded Memory manager so our program won't crash.
IF CSDetectEMS = 0 THEN
PRINT "You need an EMS Manager to run this program!!"
END
END IF
We allocate 4 logical pages ( 4 * 16K = 64K = 1 layer).
Handle% = CSAllocateEMS(4)
We make sure there is a free EMS so our program won't crash.
IF Handle% = 0 THEN
PRINT "You need 64K of free EMS to run this program!!"
END
END IF
Then we get the page frame address and store it in the Layer% variable.
Layer% = CSGetEMSFrame
We map the EMS memory, we have pass the Handle we get from CSAllocateEMS
so the function can know which memory to map.
CSMapEMSLayer Handle%, 0
Note: CSMapEMSLayer maps 4 logical pages to the 4 pages in the page frame
so if the Handle passed doesn't have at least 4 logical pages, your program
may crash.
Now that our layer is mapped and is accessible we clear our layer so it
doesn't have any garbage.
CSClear Layer%, 0
And we draw something to it.
CSPrint Layer%, 5, 100, "Expanded memory is useful!!", 15
Now we pass it to the screen
CSPcopy Layer%, VIDEO
But what happens if I want more than one layer ??.
You allocate more memory for them and map them one at a time.
1 layers = 4 logical pages
2 layers = 8 logical pages
3 layers = 12 logical pages
and so on.
Get the address and allocate mmmm... 3 layers.
Layer% = CSGetEMSFrame
Handle% = CSAllocateEMS(12)
We map the first layer and draw to it.
CSMapEMSLayer Handle%, 0
CSClear Layer%, 0
CSPrint Layer%, 5, 100, "Layer 1", 15
We map the second layer and draw to it.
CSMapEMSLayer Handle%, 4
CSClear Layer%, 0
CSPrint Layer%, 5, 100, "Layer 2", 15
We map the third layer and draw to it.
CSMapEMSLayer Handle%, 8
CSClear Layer%, 0
CSPrint Layer%, 5, 100, "Layer 3", 15
Did you see how I mapped them?
I allocated 12 pages ok?, then I map the first, so I give CSMapEMSLayer
my EMS handle and the logical page where to start mapping. I give 0 the
first time because it is zero relative, so it maps the first four pages
that make my first layer, I clear it and print a message on it.
Then I map the second layer, this time I pass 4 as the logical page where
to start mapping this is because the 0, 1, 2, and 3 are the first layer,
so 4, 5, 6, and 7 are the second, so when I map the third layer I give
8 as the page where to start so 8, 9, 10, and 11 are my third layer.
Very easy, isn't it?
Just don't forget to free the memory you allocate so other programs can
use it. If you take memory and you don't return it your program will look
very unprofessional.
You free it like this :
CSDeallocateEMS Handle%
You have to do this with any handle you may have allocated. I suggest you
to use only 1 handle and allocate all your memory on it so you don't have
trouble.
So that's what the maunal says, but I can't make use of it....
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]