Hi All,
1.
For my sins I sometimes convert C progs into pascal. Most of the time
I manage OK but once in awhile I tangled up in knots. Here is one such
instance. This is part of some memory management code to store images
in ems blocks.
Sometimes I'm envious of the apparent fluidity with which C treats
memory but this is tempered by the fact its not always abundantly
clear what it's up to. This is part of an emsAlloc function. In this
snippet 'emsLinestart' was previously declared as a pointer (unsigned
int *emsLinestart). Offset,page,size,lines and bytes are words.
dosalloc returns a far pointer (that's normalised to you and me). So
emslinestart appears to be a pointer to the block of memory just
allocated by dosalloc but then it morphs into an array of words?
pointers? which hold the page frames. Considering this is a dynamic
structure allocated on call to the emsalloc how does this translate
into pascal code?
if((emslinestart=(unsigned int *)dosalloc(4*lines) == NULL)return 0;
// Ok so above = quit value if not allocated else a pointer to mem
for (i=0;i<lines;++i) {
emsLinestart[i<<l] = offset; // huh? this is an array now ? are
these pointers?
emsLinestart[(i<<l)+1] = page;
offset +=bytes; // clear enough from here on
if((offset+bytes) > 0x4000 {
++page;
offset := 0;
}
2. I've written a couple of direct dos file routines in asm. Ya know
the standard create, open, read, write stuff which work fine.
One thing that I can't figure out is the text vs binary thing.
As you know in dos a file handle is just an integer. Presumably this
points to an internal record of type file or does the user need to
optionally supply a pointer to a file structure?. Is the text record
structure part of dos or is it handled entirely by pascal?. If it is
dos how might I tell dos which type of file I want?
3. Why doesn't everyone just program in dos 'unreal' flatmode ?
4. Here I'm canvassing for some feedback.
I'm thinking of bringing back swag as a website with a message board
forum too.
I personally still find swags a great way to learn stuff - its a pity
its now so out of date. It's still very popular in Romania where not
everyone is as connected as we are. Unfortunately, for non-Romanian
speakers, the swags can be difficult to interpret.
Although some argue that the swag bbs concept has been superceeded by
the internet I don't agree. It think it would be great to be able to
submit swags via a website and receive packets by e-mail for home
viewing and also be able to discuss them on a message board. The
concept could be widened to include for other pascal dialects and
languages. There would be a certain irony looking at c snippets on a
pascal swag viewer ...
:) Phil


|